| 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 { |
no test coverage detected