MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / draw_prop_enum_button

Function draw_prop_enum_button

src/python/lfs/py_ui.cpp:520–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

518 thread_local std::stack<LayoutContext> g_layout_stack;
519
520 bool draw_prop_enum_button(nb::object data, const std::string& prop_id,
521 const std::string& value, const std::string& text) {
522 const std::string current = nb::cast<std::string>(data.attr(prop_id.c_str()));
523 const bool selected = (current == value);
524 const std::string& display = text.empty() ? value : text;
525
526 if (selected) {
527 const auto theme = get_current_theme();
528 ImGui::PushStyleColor(ImGuiCol_Button, tuple_to_imvec4(theme.palette.primary));
529 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, tuple_to_imvec4(theme.palette.primary));
530 ImGui::PushStyleColor(ImGuiCol_ButtonActive, tuple_to_imvec4(theme.palette.primary_dim));
531 }
532 const bool clicked = ImGui::Button(display.c_str());
533 if (selected)
534 ImGui::PopStyleColor(PROP_ENUM_COLOR_COUNT);
535
536 if (clicked && !selected) {
537 data.attr(prop_id.c_str()) = nb::cast(value);
538 return true;
539 }
540 return false;
541 }
542
543 // Window flags for Python bindings
544 struct PyWindowFlags {

Callers 1

prop_enumMethod · 0.85

Calls 4

get_current_themeFunction · 0.85
tuple_to_imvec4Function · 0.85
c_strMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected