UI improvements. Fixes #1274.

Copybara import of the project:

--
a1297d997d0b3cc624bbd1e704ffb7fbb2c5db9d by Emo Todorov <etodorov@gmail.com>:

UI imrovements

When OpenGL buffer size is too small to hold entire UI with all sections open, older sections (as determined by latest mouse click) are automatically closed as needed.

To test this new functionality, uncomment the test near the top of mjui_resize().

UI items now have userid, which can be used for event handling.  It is set through the (new) last field of mjuiDef, called otherint.

Sections titles can now have a checkmark - in which case they are rendered differently. Set via mjuiDef.otherint: 0- none (as before), 1- rendering changed but box not shown, 2- box shown.  This can be used to label sections of special interest to the application.

--
b0405bfb3005586ef1d2656ea9cc43c608225927 by Emo Todorov <etodorov@gmail.com>:

more ui improvements

Implemented mjPRESERVE state for adding sections and separators, so you don't have to keep track of old states.

simulate.cc is now modified to use this new functionality.  I also made the separators in the Physics section collapsible. If you don't like it, change them back to state 1.

Also added functionality for handling section checkboxes.

--
10f4c49be62a6605a38b7c0c7bfae1629024ba31 by Emo Todorov <etodorov@gmail.com>:

even more ui improvements

Selection boxes that extend below the current UI height are finally rendered in full.

Sections and collapsible separators now have rounded corners. The radius can be controlled from theme spacing.

More theme color settings were added. In particular, color gradients can now be disabled (the two end colors are set independently).

--
96c2dc601a25d31c93b21f8e089d349e729e829e by Emo Todorov <etodorov@gmail.com>:

final ui improvements

Cleaned up the code a bit.

Added more control for color gradients.

--
c9eddb679f36df3f0745d37e3fa90c4e66ee6b98 by Emo Todorov <etodorov@gmail.com>:

bug fix

Fixed some rendering bugs in the new functionality.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google-deepmind/mujoco/pull/1749 from emotodorov:ui_improve ddfc21dbcf0482b8f0d5eacab21847c302f71440
PiperOrigin-RevId: 646060325
Change-Id: Idb27aae7cd0311d00f26387bcadf5891175e867d
This commit is contained in:
Emo Todorov
2024-06-24 05:30:25 -07:00
committed by Copybara-Service
parent e66b9a36b2
commit ee6a1dba28
10 changed files with 946 additions and 435 deletions
+18
View File
@@ -71,6 +71,7 @@ public const int mjMAXUIMULTI = 35;
public const int mjMAXUIEDIT = 7;
public const int mjMAXUIRECT = 25;
public const int mjSEPCLOSED = 1000;
public const int mjPRESERVE = 2000;
public const int mjKEY_ESCAPE = 256;
public const int mjKEY_ENTER = 257;
public const int mjKEY_TAB = 258;
@@ -482,6 +483,11 @@ public enum mjtEvent : int{
mjEVENT_REDRAW = 7,
mjEVENT_FILESDROP = 8,
}
public enum mjtSection : int{
mjSECT_CLOSED = 0,
mjSECT_OPEN = 1,
mjSECT_FIXED = 2,
}
public enum mjtCatBit : int{
mjCAT_STATIC = 1,
mjCAT_DYNAMIC = 2,
@@ -5722,6 +5728,8 @@ public unsafe struct mjuiThemeSpacing_ {
public int scroll;
public int label;
public int section;
public int cornersect;
public int cornersep;
public int itemside;
public int itemmid;
public int itemver;
@@ -5736,9 +5744,14 @@ public unsafe struct mjuiThemeColor_ {
public fixed float master[3];
public fixed float thumb[3];
public fixed float secttitle[3];
public fixed float secttitle2[3];
public fixed float secttitlecheck[3];
public fixed float secttitlecheck2[3];
public fixed float sectfont[3];
public fixed float sectsymbol[3];
public fixed float sectpane[3];
public fixed float separator[3];
public fixed float separator2[3];
public fixed float shortcut[3];
public fixed float fontactive[3];
public fixed float fontinactive[3];
@@ -5786,9 +5799,11 @@ public unsafe struct mjuiSection_ {
public int state;
public int modifier;
public int shortcut;
public int checkbox;
public int nitem;
public mjrRect_ rtitle;
public mjrRect_ rcontent;
public int lastclick;
}
[StructLayout(LayoutKind.Sequential)]
@@ -5807,6 +5822,8 @@ public unsafe struct mjUI_ {
public int mousesect;
public int mouseitem;
public int mousehelp;
public int mouseclicks;
public int mousesectcheck;
public int editsect;
public int edititem;
public int editcursor;
@@ -5833,6 +5850,7 @@ public unsafe struct mjuiDef_ {
public int state;
public void* pdata;
public fixed sbyte other[300];
public int otherint;
}
[StructLayout(LayoutKind.Sequential)]