From 1db78b8ca77f4590d68d1e30b2c6a55599248b96 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 7 Jan 2020 21:25:42 +0100 Subject: [PATCH] Renaming + missing initialization + missing Changelog update. --- docs/CHANGELOG.txt | 13 ++++++++----- imgui_internal.h | 4 ++-- imgui_widgets.cpp | 10 +++++----- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index dc5d43f2..2575da17 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -65,6 +65,9 @@ Other Changes: - Inputs: Added ImGuiMouseButton enum for convenience (e.g. ImGuiMouseButton_Right=1). We forever guarantee that the existing value will not changes so existing code is free to use 0/1/2. - ColorEdit: Fix label alignment when using ImGuiColorEditFlags_NoInputs. (#2955) [@rokups] +- ColorEdit: In HSV display of a RGB stored value, attempt to locally preserve Saturation + when Value==0.0 (similar to changes done in 1.73 for Hue). Removed Hue editing lock since + those improvements in 1.73 makes them unnecessary. (#2722, #2770). [@rokups] - Misc: Added ImGuiMouseCursor_NotAllowed enum so it can be used by more shared widgets. [@rokups] - ImDrawList: Add AddNgon(), AddNgonFilled() API with a guarantee on the explicit segment count. In the current branch they are essentially the same as AddCircle(), AddCircleFilled() but as @@ -75,11 +78,11 @@ Other Changes: - Backends: SDL: Wayland: use SDL_GetMouseState (because there is no global mouse state available on Wayland). (#2800, #2802) [@NeroBurner] - Examples: Explicitly adding -DIMGUI_IMPL_OPENGL_LOADER_GL3W to Makefile to match linking - settings (otherwise if another loader such as Glew is accessible, the opengl3 backend might - automatically use it). [#2919, #2798] + settings (otherwise if another loader such as Glew is accessible, the OpenGL3 backend might + automatically use it). (#2919, #2798) - Examples: Metal: Wrapped main loop in @autoreleasepool block to ensure allocations get freed - even if underlying system event loop gets paused due to app nap (#2910, #2917). [@bear24rw] -- Examples: Added support for glbindings OpenGL loader. + even if underlying system event loop gets paused due to app nap. (#2910, #2917) [@bear24rw] +- Examples: Added support for glbindings OpenGL loader. (#2870) [@rokups] ----------------------------------------------------------------------- @@ -164,7 +167,7 @@ Other Changes: - Nav, Scrolling: Added support for Home/End key. (#787) - ColorEdit: Disable Hue edit when Saturation==0 instead of letting Hue values jump around. - ColorEdit, ColorPicker: In HSV display of a RGB stored value, attempt to locally preserve Hue - when Saturation==0, which reduces accidentally lossy interactions. (#2722, 2770) [@rokups] + when Saturation==0, which reduces accidentally lossy interactions. (#2722, #2770) [@rokups] - 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). diff --git a/imgui_internal.h b/imgui_internal.h index 4ea85076..a618b3dc 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1121,7 +1121,7 @@ struct ImGuiContext ImGuiID TempInputTextId; // Temporary text input when CTRL+clicking on a slider, etc. ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets float ColorEditLastHue; // Backup of last Hue associated to LastColor[3], so we can restore Hue in lossy RGB<>HSV round trips - float ColorEditLastSaturation; // Backup of last Saturation associated to LastColor[3], so we can restore Saturation in lossy RGB<>HSV round trips + float ColorEditLastSat; // Backup of last Saturation associated to LastColor[3], so we can restore Saturation in lossy RGB<>HSV round trips float ColorEditLastColor[3]; ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker. bool DragCurrentAccumDirty; @@ -1266,7 +1266,7 @@ struct ImGuiContext LastValidMousePos = ImVec2(0.0f, 0.0f); TempInputTextId = 0; ColorEditOptions = ImGuiColorEditFlags__OptionsDefault; - ColorEditLastHue = 0.0f; + ColorEditLastHue = ColorEditLastSat = 0.0f; ColorEditLastColor[0] = ColorEditLastColor[1] = ColorEditLastColor[2] = FLT_MAX; DragCurrentAccumDirty = false; DragCurrentAccum = 0.0f; diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index fcaaa369..1f28f464 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4227,7 +4227,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag if (f[1] == 0) f[0] = g.ColorEditLastHue; if (f[2] == 0) - f[1] = g.ColorEditLastSaturation; + f[1] = g.ColorEditLastSat; } } int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) }; @@ -4358,7 +4358,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag if ((flags & ImGuiColorEditFlags_DisplayHSV) && (flags & ImGuiColorEditFlags_InputRGB)) { g.ColorEditLastHue = f[0]; - g.ColorEditLastSaturation = f[1]; + g.ColorEditLastSat = f[1]; ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]); memcpy(g.ColorEditLastColor, f, sizeof(float) * 3); } @@ -4546,7 +4546,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl if (S == 0) H = g.ColorEditLastHue; if (V == 0) - S = g.ColorEditLastSaturation; + S = g.ColorEditLastSat; } } else if (flags & ImGuiColorEditFlags_InputHSV) @@ -4675,7 +4675,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl { ColorConvertHSVtoRGB(H >= 1.0f ? H - 10 * 1e-6f : H, S > 0.0f ? S : 10*1e-6f, V > 0.0f ? V : 1e-6f, col[0], col[1], col[2]); g.ColorEditLastHue = H; - g.ColorEditLastSaturation = S; + g.ColorEditLastSat = S; memcpy(g.ColorEditLastColor, col, sizeof(float) * 3); } else if (flags & ImGuiColorEditFlags_InputHSV) @@ -4735,7 +4735,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl if (S == 0) H = g.ColorEditLastHue; if (V == 0) - S = g.ColorEditLastSaturation; + S = g.ColorEditLastSat; } } else if (flags & ImGuiColorEditFlags_InputHSV)