Fix issue in testbed application on Windows

This commit is contained in:
Daniel Chappuis 2016-03-21 18:35:44 +01:00
parent 3e98ab2282
commit e4eea29a98
4 changed files with 13 additions and 11 deletions

View File

@ -26,7 +26,7 @@ option(GLFW_INSTALL "Generate installation target" ON)
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
if (WIN32)
option(GLFW_USE_DWM_SWAP_INTERVAL "Set swap interval even when DWM compositing is enabled" OFF)
option(GLFW_USE_DWM_SWAP_INTERVAL "Set swap interval even when DWM compositing is enabled" ON)
option(GLFW_USE_OPTIMUS_HPG "Force use of high-performance GPU on Optimus systems" OFF)
endif()

View File

@ -21,7 +21,8 @@ public:
ComboBox(Widget *parent);
/// Create a new combo box with the given items
ComboBox(Widget *parent, const std::vector<std::string> &items);
ComboBox(Widget *parent, const std::vector<std::string> &items,
const std::function<void(int)>& callback);
/**
* \brief Create a new combo box with the given items, providing both short and

View File

@ -19,8 +19,10 @@ NAMESPACE_BEGIN(nanogui)
ComboBox::ComboBox(Widget *parent) : PopupButton(parent), mSelectedIndex(0) {
}
ComboBox::ComboBox(Widget *parent, const std::vector<std::string> &items)
ComboBox::ComboBox(Widget *parent, const std::vector<std::string> &items,
const std::function<void(int)>& callback)
: PopupButton(parent), mSelectedIndex(0) {
setCallback(callback);
setItems(items);
}

View File

@ -128,11 +128,10 @@ void Gui::createSimulationPanel() {
scenesNames.push_back(scenes[i]->getName().c_str());
}
Label* labelScenes = new Label(mSimulationPanel, "Scene","sans-bold");
ComboBox* comboBoxScenes = new ComboBox(mSimulationPanel, scenesNames);
comboBoxScenes->setFixedWidth(150);
comboBoxScenes->setCallback([&, scenes](int index){
ComboBox* comboBoxScenes = new ComboBox(mSimulationPanel, scenesNames, [&, scenes](int index) {
mApp->switchScene(scenes[index]);
});
comboBoxScenes->setFixedWidth(150);
}
void Gui::createSettingsPanel() {
@ -316,7 +315,7 @@ void Gui::createSettingsPanel() {
Label* labelSleepLinearVel = new Label(panelSleepLinearVel, "Sleep linear velocity","sans-bold");
labelSleepLinearVel->setFixedWidth(120);
out.str("");
out << std::setprecision(1) << std::fixed << (mApp->mEngineSettings.sleepLinearVelocity);
out << std::setprecision(2) << std::fixed << (mApp->mEngineSettings.sleepLinearVelocity);
TextBox* textboxSleepLinearVel = new TextBox(panelSleepLinearVel);
textboxSleepLinearVel->setFixedSize(Vector2i(70, 25));
textboxSleepLinearVel->setEditable(true);
@ -327,7 +326,7 @@ void Gui::createSettingsPanel() {
try {
float value = std::stof(str);
std::ostringstream out;
out << std::setprecision(1) << std::fixed << std::showpoint << value;
out << std::setprecision(2) << std::fixed << std::showpoint << value;
float finalValue = std::stof(out.str());
if (finalValue < 0 || finalValue > 10000) return false;
@ -350,18 +349,18 @@ void Gui::createSettingsPanel() {
Label* labelSleepAngularVel = new Label(panelSleepAngularVel, "Sleep angular velocity","sans-bold");
labelSleepAngularVel->setFixedWidth(120);
out.str("");
out << std::setprecision(0) << std::fixed << (mApp->mEngineSettings.sleepAngularVelocity);
out << std::setprecision(2) << std::fixed << (mApp->mEngineSettings.sleepAngularVelocity);
TextBox* textboxSleepAngularVel = new TextBox(panelSleepAngularVel);
textboxSleepAngularVel->setFixedSize(Vector2i(70, 25));
textboxSleepAngularVel->setEditable(true);
textboxSleepAngularVel->setValue(out.str());
textboxSleepAngularVel->setUnits("m/s");
textboxSleepAngularVel->setUnits("rad/s");
textboxSleepAngularVel->setCallback([&, textboxSleepAngularVel](const std::string &str) {
try {
float value = std::stof(str);
std::ostringstream out;
out << std::setprecision(0) << std::fixed << std::showpoint << value;
out << std::setprecision(2) << std::fixed << std::showpoint << value;
float finalValue = std::stof(out.str());
if (finalValue < 0 || finalValue > 10000) return false;