ColorButton, ColorEdit, ColorPicker: fixed an issue rendering colors when inside a BeginDisabled(false) block. (#9511, #9613, #9614)

This commit is contained in:
ocornut 2026-11-05 20:27:54 +01:00
parent 253aa51aba
commit dbb30112c6
2 changed files with 10 additions and 4 deletions

View File

@ -98,6 +98,10 @@ Other Changes:
end of storage when trailing items are unselected (#9604) [@MilosLord] end of storage when trailing items are unselected (#9604) [@MilosLord]
- Drags: fixed handling of `ImGuiSliderFlags_WrapAround`: value could temporarily - Drags: fixed handling of `ImGuiSliderFlags_WrapAround`: value could temporarily
escape the range when dragging fast. (#9612, #9611, #7749) [@swayie, @ocornut] escape the range when dragging fast. (#9612, #9611, #7749) [@swayie, @ocornut]
- ColorEdit:
- ColorButton, ColorEdit, ColorPicker: fixed an issue rendering colors when
inside a `BeginDisabled(false)` block, caused by the alpha cancelling-out
code in 1.93.0. (#9511, #9613, #9614) [@tksuoran]
- ImVec2: added a check for cases where a custom `IM_VEC2_CLASS_EXTRA` macro - ImVec2: added a check for cases where a custom `IM_VEC2_CLASS_EXTRA` macro
adds an extra `operator=` to ImVec2. This isn't supported but should not adds an extra `operator=` to ImVec2. This isn't supported but should not
be needed as you should have a constructor to convert from your type to ImVec2. be needed as you should have a constructor to convert from your type to ImVec2.

View File

@ -6217,7 +6217,8 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
g.NextItemData.ClearFlags(); g.NextItemData.ClearFlags();
const float backup_alpha = g.Style.Alpha; const float backup_alpha = g.Style.Alpha;
if (g.DisabledStackSize > 0) const bool is_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0 && (g.DisabledStackSize > 0); // Intentionally not check ItemFlagsSet
if (is_disabled)
g.Style.Alpha = g.DisabledAlphaBackup; // Cancel out effect of BeginDisabled() for color swatches. g.Style.Alpha = g.DisabledAlphaBackup; // Cancel out effect of BeginDisabled() for color swatches.
PushID(label); PushID(label);
@ -6579,7 +6580,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
g.ColorEditCurrentID = 0; g.ColorEditCurrentID = 0;
PopID(); PopID();
if (g.DisabledStackSize > 0) if (is_disabled)
g.Style.Alpha = backup_alpha; g.Style.Alpha = backup_alpha;
return value_changed; return value_changed;
@ -6620,7 +6621,8 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
const bool is_mixed = (g.LastItemData.ItemFlags & ImGuiItemFlags_MixedValue) != 0; const bool is_mixed = (g.LastItemData.ItemFlags & ImGuiItemFlags_MixedValue) != 0;
const float backup_alpha = g.Style.Alpha; const float backup_alpha = g.Style.Alpha;
if (g.DisabledStackSize > 0) const bool is_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0 && (g.DisabledStackSize > 0); // Intentionally not use LastItemData.ItemFlags here.
if (is_disabled)
g.Style.Alpha = g.DisabledAlphaBackup; // Cancel out effect of BeginDisabled() for color swatches. g.Style.Alpha = g.DisabledAlphaBackup; // Cancel out effect of BeginDisabled() for color swatches.
if (is_mixed) if (is_mixed)
{ {
@ -6648,7 +6650,7 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
else else
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(col_source), rounding); window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(col_source), rounding);
} }
if (g.DisabledStackSize > 0) if (is_disabled)
g.Style.Alpha = backup_alpha; g.Style.Alpha = backup_alpha;
RenderNavCursor(bb, id); RenderNavCursor(bb, id);
if ((flags & ImGuiColorEditFlags_NoBorder) == 0) if ((flags & ImGuiColorEditFlags_NoBorder) == 0)