Fix issue in testbed application on Windows
This commit is contained in:
parent
3e98ab2282
commit
e4eea29a98
@ -26,7 +26,7 @@ option(GLFW_INSTALL "Generate installation target" ON)
|
|||||||
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
|
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
|
||||||
|
|
||||||
if (WIN32)
|
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)
|
option(GLFW_USE_OPTIMUS_HPG "Force use of high-performance GPU on Optimus systems" OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ public:
|
|||||||
ComboBox(Widget *parent);
|
ComboBox(Widget *parent);
|
||||||
|
|
||||||
/// Create a new combo box with the given items
|
/// 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
|
* \brief Create a new combo box with the given items, providing both short and
|
||||||
|
@ -19,8 +19,10 @@ NAMESPACE_BEGIN(nanogui)
|
|||||||
ComboBox::ComboBox(Widget *parent) : PopupButton(parent), mSelectedIndex(0) {
|
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) {
|
: PopupButton(parent), mSelectedIndex(0) {
|
||||||
|
setCallback(callback);
|
||||||
setItems(items);
|
setItems(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,11 +128,10 @@ void Gui::createSimulationPanel() {
|
|||||||
scenesNames.push_back(scenes[i]->getName().c_str());
|
scenesNames.push_back(scenes[i]->getName().c_str());
|
||||||
}
|
}
|
||||||
Label* labelScenes = new Label(mSimulationPanel, "Scene","sans-bold");
|
Label* labelScenes = new Label(mSimulationPanel, "Scene","sans-bold");
|
||||||
ComboBox* comboBoxScenes = new ComboBox(mSimulationPanel, scenesNames);
|
ComboBox* comboBoxScenes = new ComboBox(mSimulationPanel, scenesNames, [&, scenes](int index) {
|
||||||
comboBoxScenes->setFixedWidth(150);
|
|
||||||
comboBoxScenes->setCallback([&, scenes](int index){
|
|
||||||
mApp->switchScene(scenes[index]);
|
mApp->switchScene(scenes[index]);
|
||||||
});
|
});
|
||||||
|
comboBoxScenes->setFixedWidth(150);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::createSettingsPanel() {
|
void Gui::createSettingsPanel() {
|
||||||
@ -316,7 +315,7 @@ void Gui::createSettingsPanel() {
|
|||||||
Label* labelSleepLinearVel = new Label(panelSleepLinearVel, "Sleep linear velocity","sans-bold");
|
Label* labelSleepLinearVel = new Label(panelSleepLinearVel, "Sleep linear velocity","sans-bold");
|
||||||
labelSleepLinearVel->setFixedWidth(120);
|
labelSleepLinearVel->setFixedWidth(120);
|
||||||
out.str("");
|
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);
|
TextBox* textboxSleepLinearVel = new TextBox(panelSleepLinearVel);
|
||||||
textboxSleepLinearVel->setFixedSize(Vector2i(70, 25));
|
textboxSleepLinearVel->setFixedSize(Vector2i(70, 25));
|
||||||
textboxSleepLinearVel->setEditable(true);
|
textboxSleepLinearVel->setEditable(true);
|
||||||
@ -327,7 +326,7 @@ void Gui::createSettingsPanel() {
|
|||||||
try {
|
try {
|
||||||
float value = std::stof(str);
|
float value = std::stof(str);
|
||||||
std::ostringstream out;
|
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());
|
float finalValue = std::stof(out.str());
|
||||||
|
|
||||||
if (finalValue < 0 || finalValue > 10000) return false;
|
if (finalValue < 0 || finalValue > 10000) return false;
|
||||||
@ -350,18 +349,18 @@ void Gui::createSettingsPanel() {
|
|||||||
Label* labelSleepAngularVel = new Label(panelSleepAngularVel, "Sleep angular velocity","sans-bold");
|
Label* labelSleepAngularVel = new Label(panelSleepAngularVel, "Sleep angular velocity","sans-bold");
|
||||||
labelSleepAngularVel->setFixedWidth(120);
|
labelSleepAngularVel->setFixedWidth(120);
|
||||||
out.str("");
|
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);
|
TextBox* textboxSleepAngularVel = new TextBox(panelSleepAngularVel);
|
||||||
textboxSleepAngularVel->setFixedSize(Vector2i(70, 25));
|
textboxSleepAngularVel->setFixedSize(Vector2i(70, 25));
|
||||||
textboxSleepAngularVel->setEditable(true);
|
textboxSleepAngularVel->setEditable(true);
|
||||||
textboxSleepAngularVel->setValue(out.str());
|
textboxSleepAngularVel->setValue(out.str());
|
||||||
textboxSleepAngularVel->setUnits("m/s");
|
textboxSleepAngularVel->setUnits("rad/s");
|
||||||
textboxSleepAngularVel->setCallback([&, textboxSleepAngularVel](const std::string &str) {
|
textboxSleepAngularVel->setCallback([&, textboxSleepAngularVel](const std::string &str) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
float value = std::stof(str);
|
float value = std::stof(str);
|
||||||
std::ostringstream out;
|
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());
|
float finalValue = std::stof(out.str());
|
||||||
|
|
||||||
if (finalValue < 0 || finalValue > 10000) return false;
|
if (finalValue < 0 || finalValue > 10000) return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user