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:
committed by
Copybara-Service
parent
e66b9a36b2
commit
ee6a1dba28
@@ -582,6 +582,18 @@ Item types used in the UI framework.
|
|||||||
|
|
||||||
.. mujoco-include:: mjtItem
|
.. mujoco-include:: mjtItem
|
||||||
|
|
||||||
|
|
||||||
|
.. _mjtSection:
|
||||||
|
|
||||||
|
mjtSection
|
||||||
|
~~~~~~~~~~
|
||||||
|
|
||||||
|
State of a UI section.
|
||||||
|
|
||||||
|
.. mujoco-include:: mjtSection
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.. _tySpecEnums:
|
.. _tySpecEnums:
|
||||||
|
|
||||||
Spec
|
Spec
|
||||||
|
|||||||
@@ -2286,6 +2286,11 @@ typedef enum mjtItem_ { // UI item type
|
|||||||
|
|
||||||
mjNITEM // number of item types
|
mjNITEM // number of item types
|
||||||
} mjtItem;
|
} mjtItem;
|
||||||
|
typedef enum mjtSection_ { // UI section state
|
||||||
|
mjSECT_CLOSED = 0, // closed state (regular section)
|
||||||
|
mjSECT_OPEN, // open state (regular section)
|
||||||
|
mjSECT_FIXED // fixed section: always open, no title
|
||||||
|
} mjtSection;
|
||||||
struct mjuiState_ { // mouse and keyboard state
|
struct mjuiState_ { // mouse and keyboard state
|
||||||
// constants set by user
|
// constants set by user
|
||||||
int nrect; // number of rectangles used
|
int nrect; // number of rectangles used
|
||||||
@@ -2333,6 +2338,8 @@ struct mjuiThemeSpacing_ { // UI visualization theme spacing
|
|||||||
int scroll; // scrollbar width
|
int scroll; // scrollbar width
|
||||||
int label; // label width
|
int label; // label width
|
||||||
int section; // section gap
|
int section; // section gap
|
||||||
|
int cornersect; // corner radius for section
|
||||||
|
int cornersep; // corner radius for separator
|
||||||
int itemside; // item side gap
|
int itemside; // item side gap
|
||||||
int itemmid; // item middle gap
|
int itemmid; // item middle gap
|
||||||
int itemver; // item vertical gap
|
int itemver; // item vertical gap
|
||||||
@@ -2346,9 +2353,14 @@ struct mjuiThemeColor_ { // UI visualization theme color
|
|||||||
float master[3]; // master background
|
float master[3]; // master background
|
||||||
float thumb[3]; // scrollbar thumb
|
float thumb[3]; // scrollbar thumb
|
||||||
float secttitle[3]; // section title
|
float secttitle[3]; // section title
|
||||||
|
float secttitle2[3]; // section title: bottom color
|
||||||
|
float secttitlecheck[3]; // section title with checkbox
|
||||||
|
float secttitlecheck2[3]; // section title with checkbox: bottom color
|
||||||
float sectfont[3]; // section font
|
float sectfont[3]; // section font
|
||||||
float sectsymbol[3]; // section symbol
|
float sectsymbol[3]; // section symbol
|
||||||
float sectpane[3]; // section pane
|
float sectpane[3]; // section pane
|
||||||
|
float separator[3]; // separator title
|
||||||
|
float separator2[3]; // separator title: bottom color
|
||||||
float shortcut[3]; // shortcut background
|
float shortcut[3]; // shortcut background
|
||||||
float fontactive[3]; // font active
|
float fontactive[3]; // font active
|
||||||
float fontinactive[3]; // font inactive
|
float fontinactive[3]; // font inactive
|
||||||
@@ -2398,6 +2410,7 @@ struct mjuiItem_ { // UI item
|
|||||||
void *pdata; // data pointer (type-specific)
|
void *pdata; // data pointer (type-specific)
|
||||||
int sectionid; // id of section containing item
|
int sectionid; // id of section containing item
|
||||||
int itemid; // id of item within section
|
int itemid; // id of item within section
|
||||||
|
int userid; // user-supplied id (for event handling)
|
||||||
|
|
||||||
// type-specific properties
|
// type-specific properties
|
||||||
union {
|
union {
|
||||||
@@ -2409,20 +2422,23 @@ struct mjuiItem_ { // UI item
|
|||||||
|
|
||||||
// internal
|
// internal
|
||||||
mjrRect rect; // rectangle occupied by item
|
mjrRect rect; // rectangle occupied by item
|
||||||
|
int skip; // item skipped due to closed separator
|
||||||
};
|
};
|
||||||
typedef struct mjuiItem_ mjuiItem;
|
typedef struct mjuiItem_ mjuiItem;
|
||||||
struct mjuiSection_ { // UI section
|
struct mjuiSection_ { // UI section
|
||||||
// properties
|
// properties
|
||||||
char name[mjMAXUINAME]; // name
|
char name[mjMAXUINAME]; // name
|
||||||
int state; // 0: closed, 1: open
|
int state; // section state (mjtSection)
|
||||||
int modifier; // 0: none, 1: control, 2: shift; 4: alt
|
int modifier; // 0: none, 1: control, 2: shift; 4: alt
|
||||||
int shortcut; // shortcut key; 0: undefined
|
int shortcut; // shortcut key; 0: undefined
|
||||||
|
int checkbox; // 0: none, 1: hidden, 2: unchecked, 2: checked
|
||||||
int nitem; // number of items in use
|
int nitem; // number of items in use
|
||||||
mjuiItem item[mjMAXUIITEM]; // preallocated array of items
|
mjuiItem item[mjMAXUIITEM]; // preallocated array of items
|
||||||
|
|
||||||
// internal
|
// internal
|
||||||
mjrRect rtitle; // rectangle occupied by title
|
mjrRect rtitle; // rectangle occupied by title
|
||||||
mjrRect rcontent; // rectangle occupied by content
|
mjrRect rcontent; // rectangle occupied by content
|
||||||
|
int lastclick; // last mouse click over this section
|
||||||
};
|
};
|
||||||
typedef struct mjuiSection_ mjuiSection;
|
typedef struct mjuiSection_ mjuiSection;
|
||||||
struct mjUI_ { // entire UI
|
struct mjUI_ { // entire UI
|
||||||
@@ -2441,10 +2457,12 @@ struct mjUI_ { // entire UI
|
|||||||
int maxheight; // height when all sections open
|
int maxheight; // height when all sections open
|
||||||
int scroll; // scroll from top of UI
|
int scroll; // scroll from top of UI
|
||||||
|
|
||||||
// mouse focus
|
// mouse focus and count
|
||||||
int mousesect; // 0: none, -1: scroll, otherwise 1+section
|
int mousesect; // 0: none, -1: scroll, otherwise 1+section
|
||||||
int mouseitem; // item within section
|
int mouseitem; // item within section
|
||||||
int mousehelp; // help button down: print shortcuts
|
int mousehelp; // help button down: print shortcuts
|
||||||
|
int mouseclicks; // number of mouse clicks over UI
|
||||||
|
int mousesectcheck; // 0: none, otherwise 1+section
|
||||||
|
|
||||||
// keyboard focus and edit
|
// keyboard focus and edit
|
||||||
int editsect; // 0: none, otherwise 1+section
|
int editsect; // 0: none, otherwise 1+section
|
||||||
@@ -2465,6 +2483,7 @@ struct mjuiDef_ { // table passed to mjui_add()
|
|||||||
int state; // state
|
int state; // state
|
||||||
void* pdata; // pointer to data
|
void* pdata; // pointer to data
|
||||||
char other[mjMAXUITEXT]; // string with type-specific properties
|
char other[mjMAXUITEXT]; // string with type-specific properties
|
||||||
|
int otherint; // int with type-specific properties
|
||||||
};
|
};
|
||||||
typedef struct mjuiDef_ mjuiDef;
|
typedef struct mjuiDef_ mjuiDef;
|
||||||
typedef enum mjtCatBit_ { // bitflags for mjvGeom category
|
typedef enum mjtCatBit_ { // bitflags for mjvGeom category
|
||||||
|
|||||||
+24
-2
@@ -26,6 +26,7 @@
|
|||||||
#define mjMAXUIRECT 25 // maximum number of rectangles
|
#define mjMAXUIRECT 25 // maximum number of rectangles
|
||||||
|
|
||||||
#define mjSEPCLOSED 1000 // closed state of adjustable separator
|
#define mjSEPCLOSED 1000 // closed state of adjustable separator
|
||||||
|
#define mjPRESERVE 2000 // preserve section or separator state
|
||||||
|
|
||||||
|
|
||||||
// key codes matching GLFW (user must remap for other frameworks)
|
// key codes matching GLFW (user must remap for other frameworks)
|
||||||
@@ -106,6 +107,13 @@ typedef enum mjtItem_ { // UI item type
|
|||||||
} mjtItem;
|
} mjtItem;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum mjtSection_ { // UI section state
|
||||||
|
mjSECT_CLOSED = 0, // closed state (regular section)
|
||||||
|
mjSECT_OPEN, // open state (regular section)
|
||||||
|
mjSECT_FIXED // fixed section: always open, no title
|
||||||
|
} mjtSection;
|
||||||
|
|
||||||
|
|
||||||
// predicate function: set enable/disable based on item category
|
// predicate function: set enable/disable based on item category
|
||||||
typedef int (*mjfItemEnable)(int category, void* data);
|
typedef int (*mjfItemEnable)(int category, void* data);
|
||||||
|
|
||||||
@@ -163,6 +171,8 @@ struct mjuiThemeSpacing_ { // UI visualization theme spacing
|
|||||||
int scroll; // scrollbar width
|
int scroll; // scrollbar width
|
||||||
int label; // label width
|
int label; // label width
|
||||||
int section; // section gap
|
int section; // section gap
|
||||||
|
int cornersect; // corner radius for section
|
||||||
|
int cornersep; // corner radius for separator
|
||||||
int itemside; // item side gap
|
int itemside; // item side gap
|
||||||
int itemmid; // item middle gap
|
int itemmid; // item middle gap
|
||||||
int itemver; // item vertical gap
|
int itemver; // item vertical gap
|
||||||
@@ -180,9 +190,14 @@ struct mjuiThemeColor_ { // UI visualization theme color
|
|||||||
float master[3]; // master background
|
float master[3]; // master background
|
||||||
float thumb[3]; // scrollbar thumb
|
float thumb[3]; // scrollbar thumb
|
||||||
float secttitle[3]; // section title
|
float secttitle[3]; // section title
|
||||||
|
float secttitle2[3]; // section title: bottom color
|
||||||
|
float secttitlecheck[3]; // section title with checkbox
|
||||||
|
float secttitlecheck2[3]; // section title with checkbox: bottom color
|
||||||
float sectfont[3]; // section font
|
float sectfont[3]; // section font
|
||||||
float sectsymbol[3]; // section symbol
|
float sectsymbol[3]; // section symbol
|
||||||
float sectpane[3]; // section pane
|
float sectpane[3]; // section pane
|
||||||
|
float separator[3]; // separator title
|
||||||
|
float separator2[3]; // separator title: bottom color
|
||||||
float shortcut[3]; // shortcut background
|
float shortcut[3]; // shortcut background
|
||||||
float fontactive[3]; // font active
|
float fontactive[3]; // font active
|
||||||
float fontinactive[3]; // font inactive
|
float fontinactive[3]; // font inactive
|
||||||
@@ -236,6 +251,7 @@ struct mjuiItem_ { // UI item
|
|||||||
void *pdata; // data pointer (type-specific)
|
void *pdata; // data pointer (type-specific)
|
||||||
int sectionid; // id of section containing item
|
int sectionid; // id of section containing item
|
||||||
int itemid; // id of item within section
|
int itemid; // id of item within section
|
||||||
|
int userid; // user-supplied id (for event handling)
|
||||||
|
|
||||||
// type-specific properties
|
// type-specific properties
|
||||||
union {
|
union {
|
||||||
@@ -247,6 +263,7 @@ struct mjuiItem_ { // UI item
|
|||||||
|
|
||||||
// internal
|
// internal
|
||||||
mjrRect rect; // rectangle occupied by item
|
mjrRect rect; // rectangle occupied by item
|
||||||
|
int skip; // item skipped due to closed separator
|
||||||
};
|
};
|
||||||
typedef struct mjuiItem_ mjuiItem;
|
typedef struct mjuiItem_ mjuiItem;
|
||||||
|
|
||||||
@@ -256,15 +273,17 @@ typedef struct mjuiItem_ mjuiItem;
|
|||||||
struct mjuiSection_ { // UI section
|
struct mjuiSection_ { // UI section
|
||||||
// properties
|
// properties
|
||||||
char name[mjMAXUINAME]; // name
|
char name[mjMAXUINAME]; // name
|
||||||
int state; // 0: closed, 1: open
|
int state; // section state (mjtSection)
|
||||||
int modifier; // 0: none, 1: control, 2: shift; 4: alt
|
int modifier; // 0: none, 1: control, 2: shift; 4: alt
|
||||||
int shortcut; // shortcut key; 0: undefined
|
int shortcut; // shortcut key; 0: undefined
|
||||||
|
int checkbox; // 0: none, 1: hidden, 2: unchecked, 2: checked
|
||||||
int nitem; // number of items in use
|
int nitem; // number of items in use
|
||||||
mjuiItem item[mjMAXUIITEM]; // preallocated array of items
|
mjuiItem item[mjMAXUIITEM]; // preallocated array of items
|
||||||
|
|
||||||
// internal
|
// internal
|
||||||
mjrRect rtitle; // rectangle occupied by title
|
mjrRect rtitle; // rectangle occupied by title
|
||||||
mjrRect rcontent; // rectangle occupied by content
|
mjrRect rcontent; // rectangle occupied by content
|
||||||
|
int lastclick; // last mouse click over this section
|
||||||
};
|
};
|
||||||
typedef struct mjuiSection_ mjuiSection;
|
typedef struct mjuiSection_ mjuiSection;
|
||||||
|
|
||||||
@@ -287,10 +306,12 @@ struct mjUI_ { // entire UI
|
|||||||
int maxheight; // height when all sections open
|
int maxheight; // height when all sections open
|
||||||
int scroll; // scroll from top of UI
|
int scroll; // scroll from top of UI
|
||||||
|
|
||||||
// mouse focus
|
// mouse focus and count
|
||||||
int mousesect; // 0: none, -1: scroll, otherwise 1+section
|
int mousesect; // 0: none, -1: scroll, otherwise 1+section
|
||||||
int mouseitem; // item within section
|
int mouseitem; // item within section
|
||||||
int mousehelp; // help button down: print shortcuts
|
int mousehelp; // help button down: print shortcuts
|
||||||
|
int mouseclicks; // number of mouse clicks over UI
|
||||||
|
int mousesectcheck; // 0: none, otherwise 1+section
|
||||||
|
|
||||||
// keyboard focus and edit
|
// keyboard focus and edit
|
||||||
int editsect; // 0: none, otherwise 1+section
|
int editsect; // 0: none, otherwise 1+section
|
||||||
@@ -315,6 +336,7 @@ struct mjuiDef_ { // table passed to mjui_add()
|
|||||||
int state; // state
|
int state; // state
|
||||||
void* pdata; // pointer to data
|
void* pdata; // pointer to data
|
||||||
char other[mjMAXUITEXT]; // string with type-specific properties
|
char other[mjMAXUITEXT]; // string with type-specific properties
|
||||||
|
int otherint; // int with type-specific properties
|
||||||
};
|
};
|
||||||
typedef struct mjuiDef_ mjuiDef;
|
typedef struct mjuiDef_ mjuiDef;
|
||||||
|
|
||||||
|
|||||||
@@ -800,4 +800,14 @@ ENUMS: Mapping[str, EnumDecl] = dict([
|
|||||||
('mjNITEM', 14),
|
('mjNITEM', 14),
|
||||||
]),
|
]),
|
||||||
)),
|
)),
|
||||||
|
('mjtSection',
|
||||||
|
EnumDecl(
|
||||||
|
name='mjtSection',
|
||||||
|
declname='enum mjtSection_',
|
||||||
|
values=dict([
|
||||||
|
('mjSECT_CLOSED', 0),
|
||||||
|
('mjSECT_OPEN', 1),
|
||||||
|
('mjSECT_FIXED', 2),
|
||||||
|
]),
|
||||||
|
)),
|
||||||
])
|
])
|
||||||
|
|||||||
+86
-1
@@ -11350,6 +11350,16 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
type=ValueType(name='int'),
|
type=ValueType(name='int'),
|
||||||
doc='section gap',
|
doc='section gap',
|
||||||
),
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='cornersect',
|
||||||
|
type=ValueType(name='int'),
|
||||||
|
doc='corner radius for section',
|
||||||
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='cornersep',
|
||||||
|
type=ValueType(name='int'),
|
||||||
|
doc='corner radius for separator',
|
||||||
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='itemside',
|
name='itemside',
|
||||||
type=ValueType(name='int'),
|
type=ValueType(name='int'),
|
||||||
@@ -11416,6 +11426,30 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
),
|
),
|
||||||
doc='section title',
|
doc='section title',
|
||||||
),
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='secttitle2',
|
||||||
|
type=ArrayType(
|
||||||
|
inner_type=ValueType(name='float'),
|
||||||
|
extents=(3,),
|
||||||
|
),
|
||||||
|
doc='section title: bottom color',
|
||||||
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='secttitlecheck',
|
||||||
|
type=ArrayType(
|
||||||
|
inner_type=ValueType(name='float'),
|
||||||
|
extents=(3,),
|
||||||
|
),
|
||||||
|
doc='section title with checkbox',
|
||||||
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='secttitlecheck2',
|
||||||
|
type=ArrayType(
|
||||||
|
inner_type=ValueType(name='float'),
|
||||||
|
extents=(3,),
|
||||||
|
),
|
||||||
|
doc='section title with checkbox: bottom color',
|
||||||
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='sectfont',
|
name='sectfont',
|
||||||
type=ArrayType(
|
type=ArrayType(
|
||||||
@@ -11440,6 +11474,22 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
),
|
),
|
||||||
doc='section pane',
|
doc='section pane',
|
||||||
),
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='separator',
|
||||||
|
type=ArrayType(
|
||||||
|
inner_type=ValueType(name='float'),
|
||||||
|
extents=(3,),
|
||||||
|
),
|
||||||
|
doc='separator title',
|
||||||
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='separator2',
|
||||||
|
type=ArrayType(
|
||||||
|
inner_type=ValueType(name='float'),
|
||||||
|
extents=(3,),
|
||||||
|
),
|
||||||
|
doc='separator title: bottom color',
|
||||||
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='shortcut',
|
name='shortcut',
|
||||||
type=ArrayType(
|
type=ArrayType(
|
||||||
@@ -11602,6 +11652,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
type=ValueType(name='int'),
|
type=ValueType(name='int'),
|
||||||
doc='id of item within section',
|
doc='id of item within section',
|
||||||
),
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='userid',
|
||||||
|
type=ValueType(name='int'),
|
||||||
|
doc='user-supplied id (for event handling)',
|
||||||
|
),
|
||||||
AnonymousUnionDecl(
|
AnonymousUnionDecl(
|
||||||
fields=(
|
fields=(
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
@@ -11631,6 +11686,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
type=ValueType(name='mjrRect'),
|
type=ValueType(name='mjrRect'),
|
||||||
doc='rectangle occupied by item',
|
doc='rectangle occupied by item',
|
||||||
),
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='skip',
|
||||||
|
type=ValueType(name='int'),
|
||||||
|
doc='item skipped due to closed separator',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
('mjuiSection',
|
('mjuiSection',
|
||||||
@@ -11649,7 +11709,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='state',
|
name='state',
|
||||||
type=ValueType(name='int'),
|
type=ValueType(name='int'),
|
||||||
doc='0: closed, 1: open',
|
doc='section state (mjtSection)',
|
||||||
),
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='modifier',
|
name='modifier',
|
||||||
@@ -11661,6 +11721,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
type=ValueType(name='int'),
|
type=ValueType(name='int'),
|
||||||
doc='shortcut key; 0: undefined',
|
doc='shortcut key; 0: undefined',
|
||||||
),
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='checkbox',
|
||||||
|
type=ValueType(name='int'),
|
||||||
|
doc='0: none, 1: hidden, 2: unchecked, 2: checked',
|
||||||
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='nitem',
|
name='nitem',
|
||||||
type=ValueType(name='int'),
|
type=ValueType(name='int'),
|
||||||
@@ -11684,6 +11749,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
type=ValueType(name='mjrRect'),
|
type=ValueType(name='mjrRect'),
|
||||||
doc='rectangle occupied by content',
|
doc='rectangle occupied by content',
|
||||||
),
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='lastclick',
|
||||||
|
type=ValueType(name='int'),
|
||||||
|
doc='last mouse click over this section',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
('mjUI',
|
('mjUI',
|
||||||
@@ -11763,6 +11833,16 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
type=ValueType(name='int'),
|
type=ValueType(name='int'),
|
||||||
doc='help button down: print shortcuts',
|
doc='help button down: print shortcuts',
|
||||||
),
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='mouseclicks',
|
||||||
|
type=ValueType(name='int'),
|
||||||
|
doc='number of mouse clicks over UI',
|
||||||
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='mousesectcheck',
|
||||||
|
type=ValueType(name='int'),
|
||||||
|
doc='0: none, otherwise 1+section',
|
||||||
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='editsect',
|
name='editsect',
|
||||||
type=ValueType(name='int'),
|
type=ValueType(name='int'),
|
||||||
@@ -11851,6 +11931,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
),
|
),
|
||||||
doc='string with type-specific properties',
|
doc='string with type-specific properties',
|
||||||
),
|
),
|
||||||
|
StructFieldDecl(
|
||||||
|
name='otherint',
|
||||||
|
type=ValueType(name='int'),
|
||||||
|
doc='int with type-specific properties',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ jaxlib==0.4.18; python_version >= '3.9' \
|
|||||||
--hash=sha256:9593ff69f424947567e206f3e356b2a2df55ca68e6d815d5adc6cae308e8f652 \
|
--hash=sha256:9593ff69f424947567e206f3e356b2a2df55ca68e6d815d5adc6cae308e8f652 \
|
||||||
--hash=sha256:2b17b3f05b3bbf8e0ddb85fba339525ac03bac21c9f26d0f83dcea1b1654353e \
|
--hash=sha256:2b17b3f05b3bbf8e0ddb85fba339525ac03bac21c9f26d0f83dcea1b1654353e \
|
||||||
--hash=sha256:b35ec08984e2aa5e96ba3f3f8b88e90dee0283649e037f213dec8e85638fa17d \
|
--hash=sha256:b35ec08984e2aa5e96ba3f3f8b88e90dee0283649e037f213dec8e85638fa17d \
|
||||||
--hash=sha256:0bcc4768d29be80d20fd542aafd3a02510a5b1e47c7953beef8b03a9941fa64d
|
--hash=sha256:0bcc4768d29be80d20fd542aafd3a02510a5b1e47c7953beef8b03a9941fa64d \
|
||||||
|
--hash=sha256:1e4b0a0d2cfad3905123af2aa0afc2f6fcfaa9a2f74eb247cd5f140645817ab2
|
||||||
pip==23.3.1 \
|
pip==23.3.1 \
|
||||||
--hash=sha256:55eb67bb6171d37447e82213be585b75fe2b12b359e993773aca4de9247a052b
|
--hash=sha256:55eb67bb6171d37447e82213be585b75fe2b12b359e993773aca4de9247a052b
|
||||||
pytest==7.4.2 \
|
pytest==7.4.2 \
|
||||||
|
|||||||
+53
-55
@@ -117,13 +117,13 @@ enum {
|
|||||||
|
|
||||||
// file section of UI
|
// file section of UI
|
||||||
const mjuiDef defFile[] = {
|
const mjuiDef defFile[] = {
|
||||||
{mjITEM_SECTION, "File", 1, nullptr, "AF"},
|
{mjITEM_SECTION, "File", mjPRESERVE, nullptr, "AF"},
|
||||||
{mjITEM_BUTTON, "Save xml", 2, nullptr, ""},
|
{mjITEM_BUTTON, "Save xml", 2, nullptr, ""},
|
||||||
{mjITEM_BUTTON, "Save mjb", 2, nullptr, ""},
|
{mjITEM_BUTTON, "Save mjb", 2, nullptr, ""},
|
||||||
{mjITEM_BUTTON, "Print model", 2, nullptr, "CM"},
|
{mjITEM_BUTTON, "Print model", 2, nullptr, "CM"},
|
||||||
{mjITEM_BUTTON, "Print data", 2, nullptr, "CD"},
|
{mjITEM_BUTTON, "Print data", 2, nullptr, "CD"},
|
||||||
{mjITEM_BUTTON, "Quit", 1, nullptr, "CQ"},
|
{mjITEM_BUTTON, "Quit", 1, nullptr, "CQ"},
|
||||||
{mjITEM_BUTTON, "Screenshot", 2, nullptr, "CP"},
|
{mjITEM_BUTTON, "Screenshot", 2, nullptr, "CP"},
|
||||||
{mjITEM_END}
|
{mjITEM_END}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -674,15 +674,15 @@ void UpdateWatch(mj::Simulate* sim, const mjModel* m, const mjData* d) {
|
|||||||
//---------------------------------- UI construction -----------------------------------------------
|
//---------------------------------- UI construction -----------------------------------------------
|
||||||
|
|
||||||
// make physics section of UI
|
// make physics section of UI
|
||||||
void MakePhysicsSection(mj::Simulate* sim, int oldstate) {
|
void MakePhysicsSection(mj::Simulate* sim) {
|
||||||
mjOption* opt = sim->is_passive_ ? &sim->scnstate_.model.opt : &sim->m_->opt;
|
mjOption* opt = sim->is_passive_ ? &sim->scnstate_.model.opt : &sim->m_->opt;
|
||||||
mjuiDef defPhysics[] = {
|
mjuiDef defPhysics[] = {
|
||||||
{mjITEM_SECTION, "Physics", oldstate, nullptr, "AP"},
|
{mjITEM_SECTION, "Physics", mjPRESERVE, nullptr, "AP"},
|
||||||
{mjITEM_SELECT, "Integrator", 2, &(opt->integrator), "Euler\nRK4\nimplicit\nimplicitfast"},
|
{mjITEM_SELECT, "Integrator", 2, &(opt->integrator), "Euler\nRK4\nimplicit\nimplicitfast"},
|
||||||
{mjITEM_SELECT, "Cone", 2, &(opt->cone), "Pyramidal\nElliptic"},
|
{mjITEM_SELECT, "Cone", 2, &(opt->cone), "Pyramidal\nElliptic"},
|
||||||
{mjITEM_SELECT, "Jacobian", 2, &(opt->jacobian), "Dense\nSparse\nAuto"},
|
{mjITEM_SELECT, "Jacobian", 2, &(opt->jacobian), "Dense\nSparse\nAuto"},
|
||||||
{mjITEM_SELECT, "Solver", 2, &(opt->solver), "PGS\nCG\nNewton"},
|
{mjITEM_SELECT, "Solver", 2, &(opt->solver), "PGS\nCG\nNewton"},
|
||||||
{mjITEM_SEPARATOR, "Algorithmic Parameters", 1},
|
{mjITEM_SEPARATOR, "Algorithmic Parameters", mjPRESERVE},
|
||||||
{mjITEM_EDITNUM, "Timestep", 2, &(opt->timestep), "1 0 1"},
|
{mjITEM_EDITNUM, "Timestep", 2, &(opt->timestep), "1 0 1"},
|
||||||
{mjITEM_EDITINT, "Iterations", 2, &(opt->iterations), "1 0 1000"},
|
{mjITEM_EDITINT, "Iterations", 2, &(opt->iterations), "1 0 1000"},
|
||||||
{mjITEM_EDITNUM, "Tolerance", 2, &(opt->tolerance), "1 0 1"},
|
{mjITEM_EDITNUM, "Tolerance", 2, &(opt->tolerance), "1 0 1"},
|
||||||
@@ -695,22 +695,22 @@ void MakePhysicsSection(mj::Simulate* sim, int oldstate) {
|
|||||||
{mjITEM_EDITNUM, "API Rate", 2, &(opt->apirate), "1 0 1000"},
|
{mjITEM_EDITNUM, "API Rate", 2, &(opt->apirate), "1 0 1000"},
|
||||||
{mjITEM_EDITINT, "SDF Iter", 2, &(opt->sdf_iterations), "1 1 20"},
|
{mjITEM_EDITINT, "SDF Iter", 2, &(opt->sdf_iterations), "1 1 20"},
|
||||||
{mjITEM_EDITINT, "SDF Init", 2, &(opt->sdf_initpoints), "1 1 100"},
|
{mjITEM_EDITINT, "SDF Init", 2, &(opt->sdf_initpoints), "1 1 100"},
|
||||||
{mjITEM_SEPARATOR, "Physical Parameters", 1},
|
{mjITEM_SEPARATOR, "Physical Parameters", mjPRESERVE},
|
||||||
{mjITEM_EDITNUM, "Gravity", 2, opt->gravity, "3"},
|
{mjITEM_EDITNUM, "Gravity", 2, opt->gravity, "3"},
|
||||||
{mjITEM_EDITNUM, "Wind", 2, opt->wind, "3"},
|
{mjITEM_EDITNUM, "Wind", 2, opt->wind, "3"},
|
||||||
{mjITEM_EDITNUM, "Magnetic", 2, opt->magnetic, "3"},
|
{mjITEM_EDITNUM, "Magnetic", 2, opt->magnetic, "3"},
|
||||||
{mjITEM_EDITNUM, "Density", 2, &(opt->density), "1"},
|
{mjITEM_EDITNUM, "Density", 2, &(opt->density), "1"},
|
||||||
{mjITEM_EDITNUM, "Viscosity", 2, &(opt->viscosity), "1"},
|
{mjITEM_EDITNUM, "Viscosity", 2, &(opt->viscosity), "1"},
|
||||||
{mjITEM_EDITNUM, "Imp Ratio", 2, &(opt->impratio), "1"},
|
{mjITEM_EDITNUM, "Imp Ratio", 2, &(opt->impratio), "1"},
|
||||||
{mjITEM_SEPARATOR, "Disable Flags", 1},
|
{mjITEM_SEPARATOR, "Disable Flags", mjPRESERVE},
|
||||||
{mjITEM_END}
|
{mjITEM_END}
|
||||||
};
|
};
|
||||||
mjuiDef defEnableFlags[] = {
|
mjuiDef defEnableFlags[] = {
|
||||||
{mjITEM_SEPARATOR, "Enable Flags", 1},
|
{mjITEM_SEPARATOR, "Enable Flags", mjPRESERVE},
|
||||||
{mjITEM_END}
|
{mjITEM_END}
|
||||||
};
|
};
|
||||||
mjuiDef defOverride[] = {
|
mjuiDef defOverride[] = {
|
||||||
{mjITEM_SEPARATOR, "Contact Override", 1},
|
{mjITEM_SEPARATOR, "Contact Override", mjPRESERVE},
|
||||||
{mjITEM_EDITNUM, "Margin", 2, &(opt->o_margin), "1"},
|
{mjITEM_EDITNUM, "Margin", 2, &(opt->o_margin), "1"},
|
||||||
{mjITEM_EDITNUM, "Sol Imp", 2, &(opt->o_solimp), "5"},
|
{mjITEM_EDITNUM, "Sol Imp", 2, &(opt->o_solimp), "5"},
|
||||||
{mjITEM_EDITNUM, "Sol Ref", 2, &(opt->o_solref), "2"},
|
{mjITEM_EDITNUM, "Sol Ref", 2, &(opt->o_solref), "2"},
|
||||||
@@ -718,7 +718,7 @@ void MakePhysicsSection(mj::Simulate* sim, int oldstate) {
|
|||||||
{mjITEM_END}
|
{mjITEM_END}
|
||||||
};
|
};
|
||||||
mjuiDef defDisableActuator[] = {
|
mjuiDef defDisableActuator[] = {
|
||||||
{mjITEM_SEPARATOR, "Actuator Group Enable", 1},
|
{mjITEM_SEPARATOR, "Actuator Group Enable", mjPRESERVE},
|
||||||
{mjITEM_CHECKBYTE, "Act Group 0", 2, sim->enableactuator+0, ""},
|
{mjITEM_CHECKBYTE, "Act Group 0", 2, sim->enableactuator+0, ""},
|
||||||
{mjITEM_CHECKBYTE, "Act Group 1", 2, sim->enableactuator+1, ""},
|
{mjITEM_CHECKBYTE, "Act Group 1", 2, sim->enableactuator+1, ""},
|
||||||
{mjITEM_CHECKBYTE, "Act Group 2", 2, sim->enableactuator+2, ""},
|
{mjITEM_CHECKBYTE, "Act Group 2", 2, sim->enableactuator+2, ""},
|
||||||
@@ -757,12 +757,12 @@ void MakePhysicsSection(mj::Simulate* sim, int oldstate) {
|
|||||||
|
|
||||||
|
|
||||||
// make rendering section of UI
|
// make rendering section of UI
|
||||||
void MakeRenderingSection(mj::Simulate* sim, const mjModel* m, int oldstate) {
|
void MakeRenderingSection(mj::Simulate* sim, const mjModel* m) {
|
||||||
mjuiDef defRendering[] = {
|
mjuiDef defRendering[] = {
|
||||||
{
|
{
|
||||||
mjITEM_SECTION,
|
mjITEM_SECTION,
|
||||||
"Rendering",
|
"Rendering",
|
||||||
oldstate,
|
mjPRESERVE,
|
||||||
nullptr,
|
nullptr,
|
||||||
"AR"
|
"AR"
|
||||||
},
|
},
|
||||||
@@ -876,18 +876,18 @@ void MakeRenderingSection(mj::Simulate* sim, const mjModel* m, int oldstate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make visualization section of UI
|
// make visualization section of UI
|
||||||
void MakeVisualizationSection(mj::Simulate* sim, const mjModel* m, int oldstate) {
|
void MakeVisualizationSection(mj::Simulate* sim, const mjModel* m) {
|
||||||
mjStatistic* stat = sim->is_passive_ ? &sim->scnstate_.model.stat : &sim->m_->stat;
|
mjStatistic* stat = sim->is_passive_ ? &sim->scnstate_.model.stat : &sim->m_->stat;
|
||||||
mjVisual* vis = sim->is_passive_ ? &sim->scnstate_.model.vis : &sim->m_->vis;
|
mjVisual* vis = sim->is_passive_ ? &sim->scnstate_.model.vis : &sim->m_->vis;
|
||||||
|
|
||||||
mjuiDef defVisualization[] = {
|
mjuiDef defVisualization[] = {
|
||||||
{mjITEM_SECTION, "Visualization", oldstate, nullptr, "AV"},
|
{mjITEM_SECTION, "Visualization", mjPRESERVE, nullptr, "AV"},
|
||||||
{mjITEM_SEPARATOR, "Headlight", 1},
|
{mjITEM_SEPARATOR, "Headlight", 1},
|
||||||
{mjITEM_RADIO, "Active", 5, &(vis->headlight.active), "Off\nOn"},
|
{mjITEM_RADIO, "Active", 5, &(vis->headlight.active), "Off\nOn"},
|
||||||
{mjITEM_EDITFLOAT, "Ambient", 2, &(vis->headlight.ambient), "3"},
|
{mjITEM_EDITFLOAT, "Ambient", 2, &(vis->headlight.ambient), "3"},
|
||||||
{mjITEM_EDITFLOAT, "Diffuse", 2, &(vis->headlight.diffuse), "3"},
|
{mjITEM_EDITFLOAT, "Diffuse", 2, &(vis->headlight.diffuse), "3"},
|
||||||
{mjITEM_EDITFLOAT, "Specular", 2, &(vis->headlight.specular), "3"},
|
{mjITEM_EDITFLOAT, "Specular", 2, &(vis->headlight.specular), "3"},
|
||||||
{mjITEM_SEPARATOR, "Free Camera", 1},
|
{mjITEM_SEPARATOR, "Free Camera", 1},
|
||||||
{mjITEM_RADIO, "Orthographic", 2, &(vis->global.orthographic), "No\nYes"},
|
{mjITEM_RADIO, "Orthographic", 2, &(vis->global.orthographic), "No\nYes"},
|
||||||
{mjITEM_EDITFLOAT, "Field of view", 2, &(vis->global.fovy), "1"},
|
{mjITEM_EDITFLOAT, "Field of view", 2, &(vis->global.fovy), "1"},
|
||||||
{mjITEM_EDITNUM, "Center", 2, &(stat->center), "3"},
|
{mjITEM_EDITNUM, "Center", 2, &(stat->center), "3"},
|
||||||
@@ -937,9 +937,9 @@ void MakeVisualizationSection(mj::Simulate* sim, const mjModel* m, int oldstate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make group section of UI
|
// make group section of UI
|
||||||
void MakeGroupSection(mj::Simulate* sim, int oldstate) {
|
void MakeGroupSection(mj::Simulate* sim) {
|
||||||
mjuiDef defGroup[] = {
|
mjuiDef defGroup[] = {
|
||||||
{mjITEM_SECTION, "Group enable", oldstate, nullptr, "AG"},
|
{mjITEM_SECTION, "Group enable", mjPRESERVE, nullptr, "AG"},
|
||||||
{mjITEM_SEPARATOR, "Geom groups", 1},
|
{mjITEM_SEPARATOR, "Geom groups", 1},
|
||||||
{mjITEM_CHECKBYTE, "Geom 0", 2, sim->opt.geomgroup, " 0"},
|
{mjITEM_CHECKBYTE, "Geom 0", 2, sim->opt.geomgroup, " 0"},
|
||||||
{mjITEM_CHECKBYTE, "Geom 1", 2, sim->opt.geomgroup+1, " 1"},
|
{mjITEM_CHECKBYTE, "Geom 1", 2, sim->opt.geomgroup+1, " 1"},
|
||||||
@@ -997,9 +997,9 @@ void MakeGroupSection(mj::Simulate* sim, int oldstate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make joint section of UI
|
// make joint section of UI
|
||||||
void MakeJointSection(mj::Simulate* sim, int oldstate) {
|
void MakeJointSection(mj::Simulate* sim) {
|
||||||
mjuiDef defJoint[] = {
|
mjuiDef defJoint[] = {
|
||||||
{mjITEM_SECTION, "Joint", oldstate, nullptr, "AJ"},
|
{mjITEM_SECTION, "Joint", mjPRESERVE, nullptr, "AJ"},
|
||||||
{mjITEM_END}
|
{mjITEM_END}
|
||||||
};
|
};
|
||||||
mjuiDef defSlider[] = {
|
mjuiDef defSlider[] = {
|
||||||
@@ -1050,9 +1050,9 @@ void MakeJointSection(mj::Simulate* sim, int oldstate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make control section of UI
|
// make control section of UI
|
||||||
void MakeControlSection(mj::Simulate* sim, int oldstate) {
|
void MakeControlSection(mj::Simulate* sim) {
|
||||||
mjuiDef defControl[] = {
|
mjuiDef defControl[] = {
|
||||||
{mjITEM_SECTION, "Control", oldstate, nullptr, "AC"},
|
{mjITEM_SECTION, "Control", mjPRESERVE, nullptr, "AC"},
|
||||||
{mjITEM_BUTTON, "Clear all", 2},
|
{mjITEM_BUTTON, "Clear all", 2},
|
||||||
{mjITEM_END}
|
{mjITEM_END}
|
||||||
};
|
};
|
||||||
@@ -1107,35 +1107,17 @@ void MakeControlSection(mj::Simulate* sim, int oldstate) {
|
|||||||
|
|
||||||
// make model-dependent UI sections
|
// make model-dependent UI sections
|
||||||
void MakeUiSections(mj::Simulate* sim, const mjModel* m, const mjData* d) {
|
void MakeUiSections(mj::Simulate* sim, const mjModel* m, const mjData* d) {
|
||||||
// get section open-close state, UI 0
|
|
||||||
int oldstate0[NSECT0];
|
|
||||||
for (int i=0; i<NSECT0; i++) {
|
|
||||||
oldstate0[i] = 0;
|
|
||||||
if (sim->ui0.nsect>i) {
|
|
||||||
oldstate0[i] = sim->ui0.sect[i].state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get section open-close state, UI 1
|
|
||||||
int oldstate1[NSECT1];
|
|
||||||
for (int i=0; i<NSECT1; i++) {
|
|
||||||
oldstate1[i] = 0;
|
|
||||||
if (sim->ui1.nsect>i) {
|
|
||||||
oldstate1[i] = sim->ui1.sect[i].state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear model-dependent sections of UI
|
// clear model-dependent sections of UI
|
||||||
sim->ui0.nsect = SECT_PHYSICS;
|
sim->ui0.nsect = SECT_PHYSICS;
|
||||||
sim->ui1.nsect = 0;
|
sim->ui1.nsect = 0;
|
||||||
|
|
||||||
// make
|
// make
|
||||||
MakePhysicsSection(sim, oldstate0[SECT_PHYSICS]);
|
MakePhysicsSection(sim);
|
||||||
MakeRenderingSection(sim, m, oldstate0[SECT_RENDERING]);
|
MakeRenderingSection(sim, m);
|
||||||
MakeVisualizationSection(sim, m, oldstate0[SECT_VISUALIZATION]);
|
MakeVisualizationSection(sim, m);
|
||||||
MakeGroupSection(sim, oldstate0[SECT_GROUP]);
|
MakeGroupSection(sim);
|
||||||
MakeJointSection(sim, oldstate1[SECT_JOINT]);
|
MakeJointSection(sim);
|
||||||
MakeControlSection(sim, oldstate1[SECT_CONTROL]);
|
MakeControlSection(sim);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------- utility functions ---------------------------------------------
|
//---------------------------------- utility functions ---------------------------------------------
|
||||||
@@ -1265,7 +1247,7 @@ int ComputeFontScale(const mj::PlatformUIAdapter& platform_ui) {
|
|||||||
fs = 150;
|
fs = 150;
|
||||||
}
|
}
|
||||||
fs = mju_round(fs * 0.02) * 50;
|
fs = mju_round(fs * 0.02) * 50;
|
||||||
fs = mjMIN(250, mjMAX(100, fs));
|
fs = mjMIN(300, mjMAX(100, fs));
|
||||||
|
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
@@ -1322,9 +1304,22 @@ void UiLayout(mjuiState* state) {
|
|||||||
rect[3].height = rect[0].height;
|
rect[3].height = rect[0].height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// modify UI
|
||||||
void UiModify(mjUI* ui, mjuiState* state, mjrContext* con) {
|
void UiModify(mjUI* ui, mjuiState* state, mjrContext* con) {
|
||||||
mjui_resize(ui, con);
|
mjui_resize(ui, con);
|
||||||
mjr_addAux(ui->auxid, ui->width, ui->maxheight, ui->spacing.samples, con);
|
|
||||||
|
// remake aux buffer only if missing or different
|
||||||
|
int id = ui->auxid;
|
||||||
|
if (con->auxFBO[id] == 0 ||
|
||||||
|
con->auxFBO_r[id] == 0 ||
|
||||||
|
con->auxColor[id] == 0 ||
|
||||||
|
con->auxColor_r[id] == 0 ||
|
||||||
|
con->auxWidth[id] != ui->width ||
|
||||||
|
con->auxHeight[id] != ui->maxheight ||
|
||||||
|
con->auxSamples[id] != ui->spacing.samples) {
|
||||||
|
mjr_addAux(id, ui->width, ui->maxheight, ui->spacing.samples, con);
|
||||||
|
}
|
||||||
|
|
||||||
UiLayout(state);
|
UiLayout(state);
|
||||||
mjui_update(-1, -1, ui, state, con);
|
mjui_update(-1, -1, ui, state, con);
|
||||||
}
|
}
|
||||||
@@ -1504,7 +1499,7 @@ void UiEvent(mjuiState* state) {
|
|||||||
// remake joint section if joint group changed
|
// remake joint section if joint group changed
|
||||||
if (it->name[0]=='J' && it->name[1]=='o') {
|
if (it->name[0]=='J' && it->name[1]=='o') {
|
||||||
sim->ui1.nsect = SECT_JOINT;
|
sim->ui1.nsect = SECT_JOINT;
|
||||||
MakeJointSection(sim, sim->ui1.sect[SECT_JOINT].state);
|
MakeJointSection(sim);
|
||||||
sim->ui1.nsect = NSECT1;
|
sim->ui1.nsect = NSECT1;
|
||||||
UiModify(&sim->ui1, state, &sim->platform_ui->mjr_context());
|
UiModify(&sim->ui1, state, &sim->platform_ui->mjr_context());
|
||||||
}
|
}
|
||||||
@@ -2457,7 +2452,7 @@ void Simulate::Render() {
|
|||||||
if (pending_.ui_remake_ctrl) {
|
if (pending_.ui_remake_ctrl) {
|
||||||
if (this->ui1_enable && this->ui1.sect[SECT_CONTROL].state) {
|
if (this->ui1_enable && this->ui1.sect[SECT_CONTROL].state) {
|
||||||
this->ui1.nsect = SECT_CONTROL;
|
this->ui1.nsect = SECT_CONTROL;
|
||||||
MakeControlSection(this, this->ui1.sect[SECT_CONTROL].state);
|
MakeControlSection(this);
|
||||||
this->ui1.nsect = NSECT1;
|
this->ui1.nsect = NSECT1;
|
||||||
UiModify(&this->ui1, &this->uistate, &this->platform_ui->mjr_context());
|
UiModify(&this->ui1, &this->uistate, &this->platform_ui->mjr_context());
|
||||||
}
|
}
|
||||||
@@ -2645,12 +2640,15 @@ void Simulate::RenderLoop() {
|
|||||||
this->platform_ui->SetEventCallback(UiEvent);
|
this->platform_ui->SetEventCallback(UiEvent);
|
||||||
this->platform_ui->SetLayoutCallback(UiLayout);
|
this->platform_ui->SetLayoutCallback(UiLayout);
|
||||||
|
|
||||||
// populate uis with standard sections
|
// populate uis with standard sections, open some sections initially
|
||||||
this->ui0.userdata = this;
|
this->ui0.userdata = this;
|
||||||
this->ui1.userdata = this;
|
this->ui1.userdata = this;
|
||||||
mjui_add(&this->ui0, defFile);
|
mjui_add(&this->ui0, defFile);
|
||||||
mjui_add(&this->ui0, this->def_option);
|
mjui_add(&this->ui0, this->def_option);
|
||||||
mjui_add(&this->ui0, this->def_simulation);
|
mjui_add(&this->ui0, this->def_simulation);
|
||||||
|
this->ui0.sect[0].state = 1;
|
||||||
|
this->ui0.sect[1].state = 1;
|
||||||
|
this->ui0.sect[2].state = 1;
|
||||||
mjui_add(&this->ui0, this->def_watch);
|
mjui_add(&this->ui0, this->def_watch);
|
||||||
UiModify(&this->ui0, &this->uistate, &this->platform_ui->mjr_context());
|
UiModify(&this->ui0, &this->uistate, &this->platform_ui->mjr_context());
|
||||||
UiModify(&this->ui1, &this->uistate, &this->platform_ui->mjr_context());
|
UiModify(&this->ui1, &this->uistate, &this->platform_ui->mjr_context());
|
||||||
|
|||||||
+3
-3
@@ -265,7 +265,7 @@ class Simulate {
|
|||||||
// Constant arrays needed for the option section of UI and the UI interface
|
// Constant arrays needed for the option section of UI and the UI interface
|
||||||
// TODO setting the size here is not ideal
|
// TODO setting the size here is not ideal
|
||||||
const mjuiDef def_option[13] = {
|
const mjuiDef def_option[13] = {
|
||||||
{mjITEM_SECTION, "Option", 1, nullptr, "AO"},
|
{mjITEM_SECTION, "Option", mjPRESERVE, nullptr, "AO"},
|
||||||
{mjITEM_CHECKINT, "Help", 2, &this->help, " #290"},
|
{mjITEM_CHECKINT, "Help", 2, &this->help, " #290"},
|
||||||
{mjITEM_CHECKINT, "Info", 2, &this->info, " #291"},
|
{mjITEM_CHECKINT, "Info", 2, &this->info, " #291"},
|
||||||
{mjITEM_CHECKINT, "Profiler", 2, &this->profiler, " #292"},
|
{mjITEM_CHECKINT, "Profiler", 2, &this->profiler, " #292"},
|
||||||
@@ -287,7 +287,7 @@ class Simulate {
|
|||||||
|
|
||||||
// simulation section of UI
|
// simulation section of UI
|
||||||
const mjuiDef def_simulation[14] = {
|
const mjuiDef def_simulation[14] = {
|
||||||
{mjITEM_SECTION, "Simulation", 1, nullptr, "AS"},
|
{mjITEM_SECTION, "Simulation", mjPRESERVE, nullptr, "AS"},
|
||||||
{mjITEM_RADIO, "", 5, &this->run, "Pause\nRun"},
|
{mjITEM_RADIO, "", 5, &this->run, "Pause\nRun"},
|
||||||
{mjITEM_BUTTON, "Reset", 2, nullptr, " #259"},
|
{mjITEM_BUTTON, "Reset", 2, nullptr, " #259"},
|
||||||
{mjITEM_BUTTON, "Reload", 5, nullptr, "CL"},
|
{mjITEM_BUTTON, "Reload", 5, nullptr, "CL"},
|
||||||
@@ -306,7 +306,7 @@ class Simulate {
|
|||||||
|
|
||||||
// watch section of UI
|
// watch section of UI
|
||||||
const mjuiDef def_watch[5] = {
|
const mjuiDef def_watch[5] = {
|
||||||
{mjITEM_SECTION, "Watch", 0, nullptr, "AW"},
|
{mjITEM_SECTION, "Watch", mjPRESERVE, nullptr, "AW"},
|
||||||
{mjITEM_EDITTXT, "Field", 2, this->field, "qpos"},
|
{mjITEM_EDITTXT, "Field", 2, this->field, "qpos"},
|
||||||
{mjITEM_EDITINT, "Index", 2, &this->index, "1"},
|
{mjITEM_EDITINT, "Index", 2, &this->index, "1"},
|
||||||
{mjITEM_STATIC, "Value", 2, nullptr, " "},
|
{mjITEM_STATIC, "Value", 2, nullptr, " "},
|
||||||
|
|||||||
+717
-371
File diff suppressed because it is too large
Load Diff
@@ -71,6 +71,7 @@ public const int mjMAXUIMULTI = 35;
|
|||||||
public const int mjMAXUIEDIT = 7;
|
public const int mjMAXUIEDIT = 7;
|
||||||
public const int mjMAXUIRECT = 25;
|
public const int mjMAXUIRECT = 25;
|
||||||
public const int mjSEPCLOSED = 1000;
|
public const int mjSEPCLOSED = 1000;
|
||||||
|
public const int mjPRESERVE = 2000;
|
||||||
public const int mjKEY_ESCAPE = 256;
|
public const int mjKEY_ESCAPE = 256;
|
||||||
public const int mjKEY_ENTER = 257;
|
public const int mjKEY_ENTER = 257;
|
||||||
public const int mjKEY_TAB = 258;
|
public const int mjKEY_TAB = 258;
|
||||||
@@ -482,6 +483,11 @@ public enum mjtEvent : int{
|
|||||||
mjEVENT_REDRAW = 7,
|
mjEVENT_REDRAW = 7,
|
||||||
mjEVENT_FILESDROP = 8,
|
mjEVENT_FILESDROP = 8,
|
||||||
}
|
}
|
||||||
|
public enum mjtSection : int{
|
||||||
|
mjSECT_CLOSED = 0,
|
||||||
|
mjSECT_OPEN = 1,
|
||||||
|
mjSECT_FIXED = 2,
|
||||||
|
}
|
||||||
public enum mjtCatBit : int{
|
public enum mjtCatBit : int{
|
||||||
mjCAT_STATIC = 1,
|
mjCAT_STATIC = 1,
|
||||||
mjCAT_DYNAMIC = 2,
|
mjCAT_DYNAMIC = 2,
|
||||||
@@ -5722,6 +5728,8 @@ public unsafe struct mjuiThemeSpacing_ {
|
|||||||
public int scroll;
|
public int scroll;
|
||||||
public int label;
|
public int label;
|
||||||
public int section;
|
public int section;
|
||||||
|
public int cornersect;
|
||||||
|
public int cornersep;
|
||||||
public int itemside;
|
public int itemside;
|
||||||
public int itemmid;
|
public int itemmid;
|
||||||
public int itemver;
|
public int itemver;
|
||||||
@@ -5736,9 +5744,14 @@ public unsafe struct mjuiThemeColor_ {
|
|||||||
public fixed float master[3];
|
public fixed float master[3];
|
||||||
public fixed float thumb[3];
|
public fixed float thumb[3];
|
||||||
public fixed float secttitle[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 sectfont[3];
|
||||||
public fixed float sectsymbol[3];
|
public fixed float sectsymbol[3];
|
||||||
public fixed float sectpane[3];
|
public fixed float sectpane[3];
|
||||||
|
public fixed float separator[3];
|
||||||
|
public fixed float separator2[3];
|
||||||
public fixed float shortcut[3];
|
public fixed float shortcut[3];
|
||||||
public fixed float fontactive[3];
|
public fixed float fontactive[3];
|
||||||
public fixed float fontinactive[3];
|
public fixed float fontinactive[3];
|
||||||
@@ -5786,9 +5799,11 @@ public unsafe struct mjuiSection_ {
|
|||||||
public int state;
|
public int state;
|
||||||
public int modifier;
|
public int modifier;
|
||||||
public int shortcut;
|
public int shortcut;
|
||||||
|
public int checkbox;
|
||||||
public int nitem;
|
public int nitem;
|
||||||
public mjrRect_ rtitle;
|
public mjrRect_ rtitle;
|
||||||
public mjrRect_ rcontent;
|
public mjrRect_ rcontent;
|
||||||
|
public int lastclick;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
@@ -5807,6 +5822,8 @@ public unsafe struct mjUI_ {
|
|||||||
public int mousesect;
|
public int mousesect;
|
||||||
public int mouseitem;
|
public int mouseitem;
|
||||||
public int mousehelp;
|
public int mousehelp;
|
||||||
|
public int mouseclicks;
|
||||||
|
public int mousesectcheck;
|
||||||
public int editsect;
|
public int editsect;
|
||||||
public int edititem;
|
public int edititem;
|
||||||
public int editcursor;
|
public int editcursor;
|
||||||
@@ -5833,6 +5850,7 @@ public unsafe struct mjuiDef_ {
|
|||||||
public int state;
|
public int state;
|
||||||
public void* pdata;
|
public void* pdata;
|
||||||
public fixed sbyte other[300];
|
public fixed sbyte other[300];
|
||||||
|
public int otherint;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
|||||||
Reference in New Issue
Block a user