From 9393c690d47739aca935961fe26765fd0d47cd8f Mon Sep 17 00:00:00 2001 From: Nimrod Gileadi Date: Thu, 19 Oct 2023 03:37:22 -0700 Subject: [PATCH] Correctly handle full screen and vsync buttons. Fixes #1110. The code was using outdated indices since 48eb75ae929af2b6d0378b298a91765896ebd5a5. It now uses the more stable pdata pointer. PiperOrigin-RevId: 574805349 Change-Id: If6112fb2af7d60f17b35599233b24f33b6a8cac6 --- doc/changelog.rst | 8 ++++++++ simulate/simulate.cc | 20 +++++--------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index 183dc496..151c6ebf 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -2,6 +2,14 @@ Changelog ========= +Upcoming version (not yet released) +----------------------------------- + +Bug fixes +^^^^^^^^^ + +1. Fix in simulate: correct handling of "Pause update", "Fullscreen" and "VSync" buttons. + Version 3.0.0 (October 18, 2023) -------------------------------- diff --git a/simulate/simulate.cc b/simulate/simulate.cc index 5a64019f..32d6ec7a 100644 --- a/simulate/simulate.cc +++ b/simulate/simulate.cc @@ -1343,28 +1343,18 @@ void UiEvent(mjuiState* state) { // option section else if (it && it->sectionid==SECT_OPTION) { - switch (it->itemid) { - case 0: // Spacing + if (it->pdata == &sim->spacing) { sim->ui0.spacing = mjui_themeSpacing(sim->spacing); sim->ui1.spacing = mjui_themeSpacing(sim->spacing); - break; - - case 1: // Color + } else if (it->pdata == &sim->color) { sim->ui0.color = mjui_themeColor(sim->color); sim->ui1.color = mjui_themeColor(sim->color); - break; - - case 2: // Font + } else if (it->pdata == &sim->font) { mjr_changeFont(50*(sim->font+1), &sim->platform_ui->mjr_context()); - break; - - case 9: // Full screen + } else if (it->pdata == &sim->fullscreen) { sim->platform_ui->ToggleFullscreen(); - break; - - case 10: // Vertical sync + } else if (it->pdata == &sim->vsync) { sim->platform_ui->SetVSync(sim->vsync); - break; } // modify UI