ColorEdit swatch alpha depends on unrelated earlier BeginDisabled(true) calls #9613

Closed
opened 2026-11-05 16:40:20 +00:00 by tksuoran · 0 comments
tksuoran commented 2026-11-05 16:40:20 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

Version 1.93.1 WIP (IMGUI_VERSION_NUM 19302), Branch: master - commit 253aa51ab

Back-ends:

tested glfw and erhe - presumably all

Compiler, OS:

GCC 13.3.0

Full config/build information:

Dear ImGui 1.93.1 WIP (19302)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201703
define: __linux__
define: __GNUC__=13
IM_ASSERT: runs expression: OK. expand size: OK
--------------------------------
io.BackendPlatformName: imgui_impl_glfw (3310)
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000003
 NavEnableKeyboard
 NavEnableGamepad
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000001E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
 RendererHasTextures
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128
io.Fonts->FontLoaderName: stb_truetype
io.DisplaySize: 1600.00,1000.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 10.00,10.00
style.WindowBorderSize: 1.00
style.FramePadding: 5.00,3.00
style.FrameRounding: 3.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 10.00,5.00
style.ItemInnerSpacing: 5.00,5.00

Details:

My Issue/Question:

I observed rendering of color buttons was off.

Repro

Repro patch

--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -1236,6 +1236,14 @@
             "be used for the tooltip and picker popup.");
         ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | base_flags);
 
+        // Repro: the swatch is not drawn inside BeginDisabled(false) until some BeginDisabled(true) ran.
+        static bool repro_disabled = false;
+        ImGui::Checkbox("Disable", &repro_disabled);
+        ImGui::SameLine();
+        ImGui::BeginDisabled(repro_disabled);
+        ImGui::ColorEdit4("MyColor##repro", (float*)&color, ImGuiColorEditFlags_NoInputs | base_flags);
+        ImGui::EndDisabled();
+
         IMGUI_DEMO_MARKER("Widgets/Color/ColorButton (with custom Picker popup)");
         ImGui::Text("Color button with Custom Picker Popup:");

Repro steps

  1. In the Demo window, open Widgets, then Color/Picker Widgets.
  2. Scroll a little to the "MyColor" swatches. Directly below them is a row with a Disable checkbox and a swatch labelled MyColor. That swatch is drawn inside BeginDisabled(), which is BeginDisabled(false) while the box is unticked.

Expected behavior

  • The swatch shows its color from the start, whatever you click.

Actual behavior

  • The swatch after "Disable" is an empty outline with no color or checkerboard, while the "MyColor" swatches above it draw normally. No real BeginDisabled(true) has run yet in this context, so the saved alpha is still 0.
  • Tick "Disable" once, then untick it: the swatch now shows its color and keeps it. Ticking ran a real BeginDisabled(true), which stored alpha 1.0, and the swatch has used that ever since. This is the same "starts working after something unrelated happens" behaviour as your selection in the Light Mixer.

Screenshots/Video:

Current unexpected rendering - see gray box in front of MyColor near bottom of screenshot

Image

Expected rendering:

Image

Minimal, Complete and Verifiable Example code:

--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -1236,6 +1236,14 @@
             "be used for the tooltip and picker popup.");
         ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | base_flags);
 
+        // Repro: the swatch is not drawn inside BeginDisabled(false) until some BeginDisabled(true) ran.
+        static bool repro_disabled = false;
+        ImGui::Checkbox("Disable", &repro_disabled);
+        ImGui::SameLine();
+        ImGui::BeginDisabled(repro_disabled);
+        ImGui::ColorEdit4("MyColor##repro", (float*)&color, ImGuiColorEditFlags_NoInputs | base_flags);
+        ImGui::EndDisabled();
+
         IMGUI_DEMO_MARKER("Widgets/Color/ColorButton (with custom Picker popup)");
         ImGui::Text("Color button with Custom Picker Popup:");
### Version/Branch of Dear ImGui: Version 1.93.1 WIP (IMGUI_VERSION_NUM 19302), Branch: master - commit 253aa51ab ### Back-ends: tested glfw and erhe - presumably all ### Compiler, OS: GCC 13.3.0 ### Full config/build information: ```cpp Dear ImGui 1.93.1 WIP (19302) -------------------------------- sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20 define: __cplusplus=201703 define: __linux__ define: __GNUC__=13 IM_ASSERT: runs expression: OK. expand size: OK -------------------------------- io.BackendPlatformName: imgui_impl_glfw (3310) io.BackendRendererName: imgui_impl_opengl3 io.ConfigFlags: 0x00000003 NavEnableKeyboard NavEnableGamepad io.ConfigNavCaptureKeyboard io.ConfigInputTextCursorBlink io.ConfigWindowsResizeFromEdges io.ConfigMemoryCompactTimer = 60.0 io.BackendFlags: 0x0000001E HasMouseCursors HasSetMousePos RendererHasVtxOffset RendererHasTextures -------------------------------- io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128 io.Fonts->FontLoaderName: stb_truetype io.DisplaySize: 1600.00,1000.00 io.DisplayFramebufferScale: 1.00,1.00 -------------------------------- style.WindowPadding: 10.00,10.00 style.WindowBorderSize: 1.00 style.FramePadding: 5.00,3.00 style.FrameRounding: 3.00 style.FrameBorderSize: 0.00 style.ItemSpacing: 10.00,5.00 style.ItemInnerSpacing: 5.00,5.00 ``` ### Details: **My Issue/Question:** I observed rendering of color buttons was off. ## Repro ### Repro patch ```patch --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1236,6 +1236,14 @@ "be used for the tooltip and picker popup."); ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | base_flags); + // Repro: the swatch is not drawn inside BeginDisabled(false) until some BeginDisabled(true) ran. + static bool repro_disabled = false; + ImGui::Checkbox("Disable", &repro_disabled); + ImGui::SameLine(); + ImGui::BeginDisabled(repro_disabled); + ImGui::ColorEdit4("MyColor##repro", (float*)&color, ImGuiColorEditFlags_NoInputs | base_flags); + ImGui::EndDisabled(); + IMGUI_DEMO_MARKER("Widgets/Color/ColorButton (with custom Picker popup)"); ImGui::Text("Color button with Custom Picker Popup:"); ``` ### Repro steps 1. In the Demo window, open Widgets, then Color/Picker Widgets. 2. Scroll a little to the "MyColor" swatches. Directly below them is a row with a Disable checkbox and a swatch labelled MyColor. That swatch is drawn inside BeginDisabled(<checkbox>), which is BeginDisabled(false) while the box is unticked. ### Expected behavior - The swatch shows its color from the start, whatever you click. ### Actual behavior - The swatch after "Disable" is an empty outline with no color or checkerboard, while the "MyColor" swatches above it draw normally. No real BeginDisabled(true) has run yet in this context, so the saved alpha is still 0. - Tick "Disable" once, then untick it: the swatch now shows its color and keeps it. Ticking ran a real BeginDisabled(true), which stored alpha 1.0, and the swatch has used that ever since. This is the same "starts working after something unrelated happens" behaviour as your selection in the Light Mixer. ### Screenshots/Video: Current unexpected rendering - see gray box in front of MyColor near bottom of screenshot <img width="577" height="717" alt="Image" src="https://github.com/user-attachments/assets/3d932b87-ffb0-463b-bccc-e9622d73d066" /> Expected rendering: <img width="577" height="717" alt="Image" src="https://github.com/user-attachments/assets/d25058cc-f293-4db9-9839-1dd73883917b" /> ### Minimal, Complete and Verifiable Example code: ```patch --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1236,6 +1236,14 @@ "be used for the tooltip and picker popup."); ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | base_flags); + // Repro: the swatch is not drawn inside BeginDisabled(false) until some BeginDisabled(true) ran. + static bool repro_disabled = false; + ImGui::Checkbox("Disable", &repro_disabled); + ImGui::SameLine(); + ImGui::BeginDisabled(repro_disabled); + ImGui::ColorEdit4("MyColor##repro", (float*)&color, ImGuiColorEditFlags_NoInputs | base_flags); + ImGui::EndDisabled(); + IMGUI_DEMO_MARKER("Widgets/Color/ColorButton (with custom Picker popup)"); ImGui::Text("Color button with Custom Picker Popup:"); ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#9613
No description provided.