MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/FleX / imguiCollapse

Function imguiCollapse

demo/imgui.cpp:531–562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

529}
530
531bool imguiCollapse(const char* text, const char* subtext, bool checked, bool enabled)
532{
533 g_state.widgetId++;
534 unsigned int id = (g_state.areaId<<16) | g_state.widgetId;
535
536 int x = g_state.widgetX;
537 int y = g_state.widgetY - BUTTON_HEIGHT;
538 int w = g_state.widgetW;
539 int h = BUTTON_HEIGHT;
540 g_state.widgetY -= BUTTON_HEIGHT; // + DEFAULT_SPACING;
541
542 const int cx = x+BUTTON_HEIGHT/2-CHECK_SIZE/2;
543 const int cy = y+BUTTON_HEIGHT/2-CHECK_SIZE/2;
544
545 bool over = enabled && inRect(x, y, w, h);
546 bool res = buttonLogic(id, over);
547
548 if (checked)
549 addGfxCmdTriangle(cx, cy, CHECK_SIZE, CHECK_SIZE, 2, imguiRGBA(255,255,255,isActive(id)?255:200));
550 else
551 addGfxCmdTriangle(cx, cy, CHECK_SIZE, CHECK_SIZE, 1, imguiRGBA(255,255,255,isActive(id)?255:200));
552
553 if (enabled)
554 addGfxCmdText(x+BUTTON_HEIGHT, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, isHot(id) ? imguiRGBA(255,196,0,255) : imguiRGBA(255,255,255,200));
555 else
556 addGfxCmdText(x+BUTTON_HEIGHT, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_LEFT, text, imguiRGBA(128,128,128,200));
557
558 if (subtext)
559 addGfxCmdText(x+w-BUTTON_HEIGHT/2, y+BUTTON_HEIGHT/2-TEXT_HEIGHT/2, IMGUI_ALIGN_RIGHT, subtext, imguiRGBA(255,255,255,128));
560
561 return res;
562}
563
564void imguiLabel(const char* text)
565{

Callers

nothing calls this directly

Calls 7

inRectFunction · 0.85
buttonLogicFunction · 0.85
addGfxCmdTriangleFunction · 0.85
imguiRGBAFunction · 0.85
isActiveFunction · 0.85
addGfxCmdTextFunction · 0.85
isHotFunction · 0.85

Tested by

no test coverage detected