MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / createSettingsPanel

Method createSettingsPanel

testbed/src/Gui.cpp:202–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202void Gui::createSettingsPanel() {
203
204 mSettingsPanel = new Window(mScreen, "Settings");
205 mSettingsPanel->set_position(Vector2i(15, 180));
206 mSettingsPanel->set_layout(new BoxLayout(Orientation::Vertical, Alignment::Middle, 10, 5));
207 //mSettingsPanel->setId("SettingsPanel");
208 mSettingsPanel->set_fixed_width(220);
209
210 // Scenes/Physics/Rendering buttons
211 Widget* buttonsPanel = new Widget(mSettingsPanel);
212 buttonsPanel->set_layout(new BoxLayout(Orientation::Horizontal, Alignment::Middle, 5, 5));
213 Button* buttonPhysics = new Button(buttonsPanel, "Physics");
214 buttonPhysics->set_flags(Button::RadioButton);
215 buttonPhysics->set_pushed(true);
216 buttonPhysics->set_change_callback([&](bool /*state*/) {
217 mPhysicsPanel->set_visible(true);
218 mRenderingPanel->set_visible(false);
219 mScreen->perform_layout();
220 });
221 Button* buttonRendering = new Button(buttonsPanel, "Rendering");
222 buttonRendering->set_flags(Button::RadioButton);
223 buttonRendering->set_change_callback([&](bool /*state*/) {
224 mRenderingPanel->set_visible(true);
225 mPhysicsPanel->set_visible(false);
226 mScreen->perform_layout();
227 });
228
229 // ---------- Physics Panel ----------
230 mPhysicsPanel = new Widget(mSettingsPanel);
231 mPhysicsPanel->set_layout(new BoxLayout(Orientation::Vertical, Alignment::Fill, 0, 5));
232
233 // Enable/Disable sleeping
234 mCheckboxSleeping = new CheckBox(mPhysicsPanel, "Sleeping enabled");
235 mCheckboxSleeping->set_checked(true);
236 mCheckboxSleeping->set_callback([&](bool value) {
237 mApp->getCurrentSceneEngineSettings().isSleepingEnabled = value;
238 mApp->notifyEngineSetttingsChanged();
239 });
240
241 // Enabled/Disable Gravity
242 mCheckboxGravity = new CheckBox(mPhysicsPanel, "Gravity enabled");
243 mCheckboxGravity->set_checked(true);
244 mCheckboxGravity->set_callback([&](bool value) {
245 mApp->getCurrentSceneEngineSettings().isGravityEnabled = value;
246 mApp->notifyEngineSetttingsChanged();
247 });
248
249 // Timestep
250 Widget* panelTimeStep = new Widget(mPhysicsPanel);
251 panelTimeStep->set_layout(new BoxLayout(Orientation::Horizontal, Alignment::Middle, 0, 5));
252 Label* labelTimeStep = new Label(panelTimeStep, "Time step","sans-bold");
253 labelTimeStep->set_fixed_width(120);
254 mTextboxTimeStep = new TextBox(panelTimeStep);
255 mTextboxTimeStep->set_fixed_size(Vector2i(70, 25));
256 mTextboxTimeStep->set_editable(true);
257 std::ostringstream out;
258 out << std::setprecision(1) << std::fixed << 0;
259 mTextboxTimeStep->set_value(out.str());

Callers

nothing calls this directly

Calls 2

enableVSyncMethod · 0.80

Tested by

no test coverage detected