From 8eb36d9a7c2fac539f84c868a6db2122516ef128 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Wed, 25 Oct 2023 04:02:51 -0700 Subject: [PATCH] Improvements to simulate UI - Improved Help overlay text, mention shortcuts for UI toggle. - Removed buttons for UI toggle. - Moved Spacing / Color / Font to the end of the Option section. PiperOrigin-RevId: 576480554 Change-Id: Ie1427b97cb784421490c276a8544d570a6042188 --- simulate/simulate.cc | 34 +++++++++++++++++++++++----------- simulate/simulate.h | 10 ++++------ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/simulate/simulate.cc b/simulate/simulate.cc index 32d6ec7a..e3688c05 100644 --- a/simulate/simulate.cc +++ b/simulate/simulate.cc @@ -130,8 +130,8 @@ const mjuiDef defFile[] = { const char help_content[] = "Space\n" "+ -\n" - "Right arrow\n" - "Left arrow\n" + "Left / Right arrow\n" + "Tab / Shift-Tab\n" "[ ]\n" "Esc\n" "Double-click\n" @@ -148,25 +148,25 @@ const char help_content[] = "F3\n" "F4\n" "F5\n" - "UI right hold\n" + "UI right-button hold\n" "UI title double-click"; const char help_title[] = "Play / Pause\n" - "Speed up / down\n" - "Step forward\n" - "Step back\n" + "Speed Up / Down\n" + "Step Back / Forward\n" + "Toggle Left / Right UI\n" "Cycle cameras\n" "Free camera\n" "Select\n" "Select parent\n" - "Center\n" + "Center camera\n" "Tracking camera\n" "Zoom\n" - "View rotate\n" - "View translate\n" - "Object rotate\n" - "Object translate\n" + "View Orbit\n" + "View Pan\n" + "Object Rotate\n" + "Object Translate\n" "Help\n" "Info\n" "Profiler\n" @@ -1625,6 +1625,18 @@ void UiEvent(mjuiState* state) { sim->speed_changed = true; } break; + + case mjKEY_TAB: // toggle left/right UI + if (!state->shift) { + // toggle left UI + sim->ui0_enable = !sim->ui0_enable; + UiModify(&sim->ui0, state, &sim->platform_ui->mjr_context()); + } else { + // toggle right UI + sim->ui1_enable = !sim->ui1_enable; + UiModify(&sim->ui1, state, &sim->platform_ui->mjr_context()); + } + break; } return; diff --git a/simulate/simulate.h b/simulate/simulate.h index a21e8e0b..587dea55 100644 --- a/simulate/simulate.h +++ b/simulate/simulate.h @@ -257,13 +257,8 @@ class Simulate { // Constant arrays needed for the option section of UI and the UI interface // TODO setting the size here is not ideal - const mjuiDef def_option[15] = { + const mjuiDef def_option[13] = { {mjITEM_SECTION, "Option", 1, nullptr, "AO"}, - {mjITEM_SELECT, "Spacing", 1, &this->spacing, "Tight\nWide"}, - {mjITEM_SELECT, "Color", 1, &this->color, "Default\nOrange\nWhite\nBlack"}, - {mjITEM_SELECT, "Font", 1, &this->font, "50 %\n100 %\n150 %\n200 %\n250 %\n300 %"}, - {mjITEM_CHECKINT, "Left UI (Tab)", 1, &this->ui0_enable, " #258"}, - {mjITEM_CHECKINT, "Right UI", 1, &this->ui1_enable, "S#258"}, {mjITEM_CHECKINT, "Help", 2, &this->help, " #290"}, {mjITEM_CHECKINT, "Info", 2, &this->info, " #291"}, {mjITEM_CHECKINT, "Profiler", 2, &this->profiler, " #292"}, @@ -276,6 +271,9 @@ class Simulate { #endif {mjITEM_CHECKINT, "Vertical Sync", 1, &this->vsync, ""}, {mjITEM_CHECKINT, "Busy Wait", 1, &this->busywait, ""}, + {mjITEM_SELECT, "Spacing", 1, &this->spacing, "Tight\nWide"}, + {mjITEM_SELECT, "Color", 1, &this->color, "Default\nOrange\nWhite\nBlack"}, + {mjITEM_SELECT, "Font", 1, &this->font, "50 %\n100 %\n150 %\n200 %\n250 %\n300 %"}, {mjITEM_END} };