ColorPicker: Fix not being able to pick exactly (1.0f, 1.0f, 1.0f) color by dragging toward the edges of the SV square. (#3517)

Old code attempted to mitigate hue/saturation resetting for colors where these components are undefined. Since we now explicitly back up and restore these components this workaround is no longer necessary.
This commit is contained in:
Rokas Kupstys 2021-04-12 12:42:04 +03:00 committed by ocornut
parent 30546bc0e7
commit 15fe7ba31f
2 changed files with 3 additions and 1 deletions

View File

@ -67,6 +67,8 @@ Other Changes:
- ColorEdit4: Fixed hue resetting to 0 when it is set to 255. [@rokups] - ColorEdit4: Fixed hue resetting to 0 when it is set to 255. [@rokups]
- ColorEdit4: Fixed hue value jitter when source color is stored as RGB in 32-bit integer and perform - ColorEdit4: Fixed hue value jitter when source color is stored as RGB in 32-bit integer and perform
RGB<>HSV round trips every frames. [@rokups] RGB<>HSV round trips every frames. [@rokups]
- ColorPicker4: Fixed picker being unable to select exact 1.0f color when dragging toward the edges
of the SV square (previously picked 0.999989986f). (#3517) [@rokups]
- Menus: Fixed vertical alignments of MenuItem() calls within a menu bar. (broken in 1.84). (#4538) - Menus: Fixed vertical alignments of MenuItem() calls within a menu bar. (broken in 1.84). (#4538)
- Menus: Adjust closing logic to accomodate for varying font size and dpi. - Menus: Adjust closing logic to accomodate for varying font size and dpi.
- Menus: Fixed crash when navigating left inside a child window inside a sub-menu. (#4510). - Menus: Fixed crash when navigating left inside a child window inside a sub-menu. (#4510).

View File

@ -5260,7 +5260,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
{ {
if (flags & ImGuiColorEditFlags_InputRGB) if (flags & ImGuiColorEditFlags_InputRGB)
{ {
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]); ColorConvertHSVtoRGB(H, S, V, col[0], col[1], col[2]);
g.ColorEditLastHue = H; g.ColorEditLastHue = H;
g.ColorEditLastSat = S; g.ColorEditLastSat = S;
g.ColorEditLastColor = ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 0)); g.ColorEditLastColor = ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 0));