ColorButton: Added ImGuiColorEditFlags_NoBorder flag to remove the border normally enforced by default.
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 66c5160..d071c7d 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -36,6 +36,8 @@
Other Changes:
+- ColorButton: Added ImGuiColorEditFlags_NoBorder flag to remove the border normally enforced
+ by default for standalone ColorButton.
- Backends: Added SDL2+Metal example application. (#3017) [@coding-jackalope]
diff --git a/imgui.h b/imgui.h
index c2bbb7f..a7b191e 100644
--- a/imgui.h
+++ b/imgui.h
@@ -60,7 +60,7 @@
// Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
#define IMGUI_VERSION "1.75"
-#define IMGUI_VERSION_NUM 17500
+#define IMGUI_VERSION_NUM 17501
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
@@ -1158,6 +1158,7 @@
ImGuiColorEditFlags_NoLabel = 1 << 7, // // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker).
ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small colored square preview instead.
ImGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
+ ImGuiColorEditFlags_NoBorder = 1 << 10, // // ColorButton: disable border (which is enforced by default)
// User Options (right-click on widget to change some of them).
ImGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index 7664f1b..32579d1 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -1264,7 +1264,9 @@
}
ImGui::Text("Color button only:");
- ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags, ImVec2(80,80));
+ static bool no_border = false;
+ ImGui::Checkbox("ImGuiColorEditFlags_NoBorder", &no_border);
+ ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags | (no_border ? ImGuiColorEditFlags_NoBorder : 0), ImVec2(80,80));
ImGui::Text("Color picker:");
static bool alpha = true;
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index 6d2c95d..a892b15 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -4956,8 +4956,12 @@
float grid_step = ImMin(size.x, size.y) / 2.99f;
float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f);
ImRect bb_inner = bb;
- float off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts.
- bb_inner.Expand(off);
+ float off = 0.0f;
+ if ((flags & ImGuiColorEditFlags_NoBorder) == 0)
+ {
+ off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts.
+ bb_inner.Expand(off);
+ }
if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col_rgb.w < 1.0f)
{
float mid_x = IM_ROUND((bb_inner.Min.x + bb_inner.Max.x) * 0.5f);
@@ -4974,10 +4978,13 @@
window->DrawList->AddRectFilled(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), rounding, ImDrawCornerFlags_All);
}
RenderNavHighlight(bb, id);
- if (g.Style.FrameBorderSize > 0.0f)
- RenderFrameBorder(bb.Min, bb.Max, rounding);
- else
- window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border
+ if ((flags & ImGuiColorEditFlags_NoBorder) == 0)
+ {
+ if (g.Style.FrameBorderSize > 0.0f)
+ RenderFrameBorder(bb.Min, bb.Max, rounding);
+ else
+ window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border
+ }
// Drag and Drop Source
// NB: The ActiveId test is merely an optional micro-optimization, BeginDragDropSource() does the same test.