From 28df6f39d9fc9e461c3000c9f9c4e5e52c8f0825 Mon Sep 17 00:00:00 2001 From: Mirolyub Hristov Date: Mon, 11 Aug 2014 21:35:27 +0200 Subject: [PATCH] Added ImGuiCol_CheckHovered to show hovered checkboxes and radio buttons --- imgui.cpp | 8 +++++--- imgui.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 449017792..4f3428146 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -227,6 +227,7 @@ ImGuiStyle::ImGuiStyle() Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.80f, 0.40f); Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.80f, 0.50f, 0.50f, 0.40f); Colors[ImGuiCol_ComboBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.99f); + Colors[ImGuiCol_CheckHovered] = ImVec4(0.60f, 0.40f, 0.40f, 1.00f); Colors[ImGuiCol_CheckActive] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f); Colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f); Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.80f, 0.50f, 0.50f, 1.00f); @@ -2168,6 +2169,7 @@ const char* GetStyleColorName(ImGuiCol idx) case ImGuiCol_ScrollbarGrabHovered: return "ScrollbarGrabHovered"; case ImGuiCol_ScrollbarGrabActive: return "ScrollbarGrabActive"; case ImGuiCol_ComboBg: return "ComboBg"; + case ImGuiCol_CheckHovered: return "CheckHovered"; case ImGuiCol_CheckActive: return "CheckActive"; case ImGuiCol_SliderGrab: return "SliderGrab"; case ImGuiCol_SliderGrabActive: return "SliderGrabActive"; @@ -3304,8 +3306,6 @@ void Checkbox(const char* label, bool* v) if (ClipAdvance(check_bb)) return; - RenderFrame(check_bb.Min, check_bb.Max, window->Color(ImGuiCol_FrameBg)); - const bool hovered = (g.HoveredWindow == window) && (g.HoveredId == 0) && IsMouseHoveringBox(check_bb); const bool pressed = hovered && g.IO.MouseClicked[0]; if (hovered) @@ -3316,6 +3316,8 @@ void Checkbox(const char* label, bool* v) g.ActiveId = 0; // Clear focus } + RenderFrame(check_bb.Min, check_bb.Max, window->Color(hovered ? ImGuiCol_CheckHovered : ImGuiCol_FrameBg)); + if (*v) { window->DrawList->AddRectFilled(check_bb.Min+ImVec2(4,4), check_bb.Max-ImVec2(4,4), window->Color(ImGuiCol_CheckActive)); @@ -3368,7 +3370,7 @@ bool RadioButton(const char* label, bool active) if (hovered) g.HoveredId = id; - window->DrawList->AddCircleFilled(center, radius, window->Color(ImGuiCol_FrameBg), 16); + window->DrawList->AddCircleFilled(center, radius, window->Color(hovered ? ImGuiCol_CheckHovered : ImGuiCol_FrameBg), 16); if (active) window->DrawList->AddCircleFilled(center, radius-2, window->Color(ImGuiCol_CheckActive), 16); diff --git a/imgui.h b/imgui.h index 8f7bf80ca..4e3274610 100644 --- a/imgui.h +++ b/imgui.h @@ -302,6 +302,7 @@ enum ImGuiCol_ ImGuiCol_ScrollbarGrabHovered, ImGuiCol_ScrollbarGrabActive, ImGuiCol_ComboBg, + ImGuiCol_CheckHovered, ImGuiCol_CheckActive, ImGuiCol_SliderGrab, ImGuiCol_SliderGrabActive,