MCPcopy Create free account
hub / github.com/TeleHuman/TextOp / UiEvent

Function UiEvent

TextOpDeploy/src/unitree_mujoco/simulate/src/mujoco/simulate.cc:1450–2014  ·  view source on GitHub ↗

handle UI event

Source from the content-addressed store, hash-verified

1448
1449 // handle UI event
1450 void UiEvent(mjuiState *state)
1451 {
1452 mj::Simulate *sim = static_cast<mj::Simulate *>(state->userdata);
1453
1454 // call UI 0 if event is directed to it
1455 if ((state->dragrect == sim->ui0.rectid) ||
1456 (state->dragrect == 0 && state->mouserect == sim->ui0.rectid) ||
1457 state->type == mjEVENT_KEY)
1458 {
1459 // process UI event
1460 mjuiItem *it = mjui_event(&sim->ui0, state, &sim->platform_ui->mjr_context());
1461
1462 // file section
1463 if (it && it->sectionid == SECT_FILE)
1464 {
1465 switch (it->itemid)
1466 {
1467 case 0: // Save xml
1468 sim->pending_.save_xml = GetSavePath("mjmodel.xml");
1469 break;
1470
1471 case 1: // Save mjb
1472 sim->pending_.save_mjb = GetSavePath("mjmodel.mjb");
1473 break;
1474
1475 case 2: // Print model
1476 sim->pending_.print_model = GetSavePath("MJMODEL.TXT");
1477 break;
1478
1479 case 3: // Print data
1480 sim->pending_.print_data = GetSavePath("MJDATA.TXT");
1481 break;
1482
1483 case 4: // Quit
1484 sim->exitrequest.store(1);
1485 break;
1486
1487 case 5: // Screenshot
1488 sim->screenshotrequest.store(true);
1489 break;
1490 }
1491 }
1492
1493 // option section
1494 else if (it && it->sectionid == SECT_OPTION)
1495 {
1496 if (it->pdata == &sim->spacing)
1497 {
1498 sim->ui0.spacing = mjui_themeSpacing(sim->spacing);
1499 sim->ui1.spacing = mjui_themeSpacing(sim->spacing);
1500 }
1501 else if (it->pdata == &sim->color)
1502 {
1503 sim->ui0.color = mjui_themeColor(sim->color);
1504 sim->ui1.color = mjui_themeColor(sim->color);
1505 }
1506 else if (it->pdata == &sim->font)
1507 {

Callers

nothing calls this directly

Calls 15

GetSavePathFunction · 0.85
UiModifyFunction · 0.85
mjui0_update_sectionFunction · 0.85
CopyCameraFunction · 0.85
strcmp_arrFunction · 0.85
MakeJointSectionFunction · 0.85
ClearTimersFunction · 0.85
UpdateProfilerFunction · 0.85
UpdateSensorFunction · 0.85
UpdateSettingsFunction · 0.85
strcpy_arrFunction · 0.85
ToggleFullscreenMethod · 0.80

Tested by

no test coverage detected