| 393 | } |
| 394 | |
| 395 | bool StateButton(const char* str_id, const char* label, ImVec2 size, ButtonOptions options, ImGuiButtonFlags flags) { |
| 396 | |
| 397 | ImGuiContext& g = *GImGui; |
| 398 | ImGuiWindow* window = ImGui::GetCurrentWindow(); |
| 399 | if (window->SkipItems) { |
| 400 | return false; |
| 401 | } |
| 402 | |
| 403 | const ImGuiStyle& style = g.Style; |
| 404 | const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true); |
| 405 | |
| 406 | const ImGuiID id = window->GetID(str_id); |
| 407 | const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); |
| 408 | const float default_size = ImGui::GetFrameHeight(); |
| 409 | ImGui::ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : -1.0f); |
| 410 | if (!ImGui::ItemAdd(bb, id)) |
| 411 | return false; |
| 412 | |
| 413 | if (g.LastItemData.ItemFlags & ImGuiItemFlags_ButtonRepeat) { |
| 414 | ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true); |
| 415 | } |
| 416 | |
| 417 | bool hovered, held; |
| 418 | bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held, flags); |
| 419 | |
| 420 | if (g.LastItemData.ItemFlags & ImGuiItemFlags_ButtonRepeat) { |
| 421 | ImGui::PopItemFlag(); // ImGuiItemFlags_ButtonRepeat; |
| 422 | } |
| 423 | PushStyleButton(options.color); |
| 424 | // Render |
| 425 | const ImU32 bg_col = ImGui::GetColorU32((held && hovered) ? ImGuiCol_ButtonActive |
| 426 | : hovered ? ImGuiCol_ButtonHovered |
| 427 | : ImGuiCol_Button); |
| 428 | // const ImU32 text_col = ImGui::GetColorU32(ImGuiCol_Text); |
| 429 | ImGui::RenderNavHighlight(bb, id); |
| 430 | ImGui::RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding); |
| 431 | ImGui::RenderTextClipped(bb.Min + (style.FramePadding * 0.35f), bb.Max - (style.FramePadding / 4), label, NULL, |
| 432 | &label_size, style.ButtonTextAlign, &bb); |
| 433 | PopStyleButton(); |
| 434 | /*ImGui::RenderArrow(window->DrawList, |
| 435 | bb.Min + |
| 436 | ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f), ImMax(0.0f, (size.y - g.FontSize) * 0.5f)), |
| 437 | text_col, dir);*/ |
| 438 | |
| 439 | IMGUI_TEST_ENGINE_ITEM_INFO(id, str_id, g.LastItemData.StatusFlags); |
| 440 | return pressed; |
| 441 | } |
| 442 | |
| 443 | float CalcComboWidth(const char* preview_value, ImGuiComboFlags flags) { |
| 444 | ImGuiContext& g = *GImGui; |
nothing calls this directly
no test coverage detected