Browse Source

ColorEdit: Disable Hue edit when Saturation==0 instead of letting Hue values jump around.

pull/2770/head
omar 5 years ago
parent
commit
0537ac005f
  1. 1
      docs/CHANGELOG.txt
  2. 7
      imgui_widgets.cpp

1
docs/CHANGELOG.txt

@ -37,6 +37,7 @@ Other Changes:
- ColorPicker: Made rendering aware of global style alpha of the picker can be faded out. (#2711)
Note that some elements won't accurately fade down with the same intensity, and the color wheel
when enabled will have small overlap glitches with (style.Alpha < 1.0).
- ColorEdit: Disable Hue edit when Saturation==0 instead of letting Hue values jump around.
- TabBar: fixed ScrollToBar request creating bouncing loop when tab is larger than available space.
- TabBar: fixed single-tab not shrinking their width down.
- TabBar: feed desired width (sum of unclipped tabs width) into layout system to allow for auto-resize. (#2768)

7
imgui_widgets.cpp

@ -4234,14 +4234,17 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
if (n > 0)
SameLine(0, style.ItemInnerSpacing.x);
SetNextItemWidth((n + 1 < components) ? w_item_one : w_item_last);
// Disable Hue edit when Saturation is zero
const bool disable_hue_edit = (n == 0 && (flags & ImGuiColorEditFlags_DisplayHSV) && i[1] == 0);
if (flags & ImGuiColorEditFlags_Float)
{
value_changed |= DragFloat(ids[n], &f[n], 1.0f/255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]);
value_changed |= DragFloat(ids[n], &f[n], 1.0f/255.0f, disable_hue_edit ? +FLT_MAX : 0.0f, disable_hue_edit ? -FLT_MAX : hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]);
value_changed_as_float |= value_changed;
}
else
{
value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
value_changed |= DragInt(ids[n], &i[n], 1.0f, disable_hue_edit ? INT_MAX : 0, disable_hue_edit ? INT_MIN : hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
}
if (!(flags & ImGuiColorEditFlags_NoOptions))
OpenPopupOnItemClick("context");

Loading…
Cancel
Save