Add overlay positions in the center of viewport edges, move PAUSE and LOADING... overlays to the top center.
PiperOrigin-RevId: 570054949 Change-Id: If0046df382e67ad3a48e7138a75e9e200c0626b9
This commit is contained in:
committed by
Copybara-Service
parent
639e77876d
commit
177aec68dc
@@ -1338,7 +1338,11 @@ typedef enum mjtGridPos_ { // grid position for overlay
|
||||
mjGRID_TOPLEFT = 0, // top left
|
||||
mjGRID_TOPRIGHT, // top right
|
||||
mjGRID_BOTTOMLEFT, // bottom left
|
||||
mjGRID_BOTTOMRIGHT // bottom right
|
||||
mjGRID_BOTTOMRIGHT, // bottom right
|
||||
mjGRID_TOP, // top center
|
||||
mjGRID_BOTTOM, // bottom center
|
||||
mjGRID_LEFT, // left center
|
||||
mjGRID_RIGHT // right center
|
||||
} mjtGridPos;
|
||||
typedef enum mjtFramebuffer_ { // OpenGL framebuffer option
|
||||
mjFB_WINDOW = 0, // default/window buffer
|
||||
|
||||
@@ -30,7 +30,11 @@ typedef enum mjtGridPos_ { // grid position for overlay
|
||||
mjGRID_TOPLEFT = 0, // top left
|
||||
mjGRID_TOPRIGHT, // top right
|
||||
mjGRID_BOTTOMLEFT, // bottom left
|
||||
mjGRID_BOTTOMRIGHT // bottom right
|
||||
mjGRID_BOTTOMRIGHT, // bottom right
|
||||
mjGRID_TOP, // top center
|
||||
mjGRID_BOTTOM, // bottom center
|
||||
mjGRID_LEFT, // left center
|
||||
mjGRID_RIGHT // right center
|
||||
} mjtGridPos;
|
||||
|
||||
|
||||
|
||||
@@ -610,6 +610,10 @@ ENUMS: Mapping[str, EnumDecl] = dict([
|
||||
('mjGRID_TOPRIGHT', 1),
|
||||
('mjGRID_BOTTOMLEFT', 2),
|
||||
('mjGRID_BOTTOMRIGHT', 3),
|
||||
('mjGRID_TOP', 4),
|
||||
('mjGRID_BOTTOM', 5),
|
||||
('mjGRID_LEFT', 6),
|
||||
('mjGRID_RIGHT', 7),
|
||||
]),
|
||||
)),
|
||||
('mjtFramebuffer',
|
||||
|
||||
+11
-14
@@ -2185,7 +2185,7 @@ void Simulate::Render() {
|
||||
|
||||
// label
|
||||
if (this->loadrequest) {
|
||||
mjr_overlay(mjFONT_BIG, mjGRID_TOPLEFT, smallrect, "loading", nullptr,
|
||||
mjr_overlay(mjFONT_BIG, mjGRID_TOP, smallrect, "LOADING...", nullptr,
|
||||
&this->platform_ui->mjr_context());
|
||||
} else {
|
||||
char intro_message[Simulate::kMaxFilenameLength];
|
||||
@@ -2283,10 +2283,11 @@ void Simulate::Render() {
|
||||
&this->platform_ui->mjr_context());
|
||||
}
|
||||
|
||||
// make pause/loading label
|
||||
std::string pauseloadlabel;
|
||||
// show pause/loading label
|
||||
if (!this->run || this->loadrequest) {
|
||||
pauseloadlabel = this->loadrequest ? "loading" : "pause";
|
||||
const char* label = this->loadrequest ? "LOADING..." : "PAUSE";
|
||||
mjr_overlay(mjFONT_BIG, mjGRID_TOP, smallrect, label, nullptr,
|
||||
&this->platform_ui->mjr_context());
|
||||
}
|
||||
|
||||
// get desired and actual percent-of-real-time
|
||||
@@ -2301,22 +2302,18 @@ void Simulate::Render() {
|
||||
char rtlabel[30] = {'\0'};
|
||||
if (desiredRealtime != 100.0 || misaligned) {
|
||||
// print desired realtime
|
||||
int labelsize = std::snprintf(rtlabel,
|
||||
sizeof(rtlabel), "%g%%", desiredRealtime);
|
||||
int labelsize = std::snprintf(rtlabel, sizeof(rtlabel), "%g%%", desiredRealtime);
|
||||
|
||||
// if misaligned, append to label
|
||||
if (misaligned) {
|
||||
std::snprintf(rtlabel+labelsize,
|
||||
sizeof(rtlabel)-labelsize, " (%-4.1f%%)", actualRealtime);
|
||||
std::snprintf(rtlabel+labelsize, sizeof(rtlabel)-labelsize, " (%-4.1f%%)", actualRealtime);
|
||||
}
|
||||
}
|
||||
|
||||
// draw top left overlay
|
||||
if (!pauseloadlabel.empty() || rtlabel[0]) {
|
||||
std::string newline = !pauseloadlabel.empty() && rtlabel[0] ? "\n" : "";
|
||||
std::string topleftlabel = rtlabel + newline + pauseloadlabel;
|
||||
mjr_overlay(mjFONT_BIG, mjGRID_TOPLEFT, smallrect,
|
||||
topleftlabel.c_str(), nullptr, &this->platform_ui->mjr_context());
|
||||
// show real-time overlay
|
||||
if (rtlabel[0]) {
|
||||
mjr_overlay(mjFONT_BIG, mjGRID_TOPLEFT, smallrect, rtlabel, nullptr,
|
||||
&this->platform_ui->mjr_context());
|
||||
}
|
||||
|
||||
// show ui 0
|
||||
|
||||
@@ -479,6 +479,26 @@ static int draw_overlay(int font, mjrRect viewport, int skip, int gridpos,
|
||||
case mjGRID_BOTTOMRIGHT:
|
||||
glViewport(viewport.left+viewport.width-skip-1-PAD-W,
|
||||
viewport.bottom+PAD, W, H);
|
||||
break;
|
||||
|
||||
case mjGRID_TOP:
|
||||
glViewport(viewport.left+(viewport.width-skip-W)/2-1-PAD,
|
||||
viewport.bottom+viewport.height-1-PAD-H, W, H);
|
||||
break;
|
||||
|
||||
case mjGRID_BOTTOM:
|
||||
glViewport(viewport.left+(viewport.width-skip-W)/2-1-PAD,
|
||||
viewport.bottom+PAD, W, H);
|
||||
break;
|
||||
|
||||
case mjGRID_LEFT:
|
||||
glViewport(viewport.left+skip+PAD,
|
||||
viewport.bottom+(viewport.height-H)/2-1-PAD, W, H);
|
||||
break;
|
||||
|
||||
case mjGRID_RIGHT:
|
||||
glViewport(viewport.left+viewport.width-skip-1-PAD-W,
|
||||
viewport.bottom+(viewport.height-H)/2-1-PAD, W, H);
|
||||
}
|
||||
|
||||
// set projection in pixels
|
||||
|
||||
@@ -384,6 +384,10 @@ public enum mjtGridPos : int{
|
||||
mjGRID_TOPRIGHT = 1,
|
||||
mjGRID_BOTTOMLEFT = 2,
|
||||
mjGRID_BOTTOMRIGHT = 3,
|
||||
mjGRID_TOP = 4,
|
||||
mjGRID_BOTTOM = 5,
|
||||
mjGRID_LEFT = 6,
|
||||
mjGRID_RIGHT = 7,
|
||||
}
|
||||
public enum mjtFramebuffer : int{
|
||||
mjFB_WINDOW = 0,
|
||||
|
||||
Reference in New Issue
Block a user