From 7f9533b8400120faa23e2cca7eec53e97e4143a9 Mon Sep 17 00:00:00 2001
From: ocornut <omarcornut@gmail.com>
Date: Fri, 5 Jan 2024 17:23:42 +0100
Subject: [PATCH] ColorPicker: Fixed saturation/value cursor radius not scaling
 properly.

+ Misc docs/comments.
---
 docs/CHANGELOG.txt | 7 ++++---
 imgui.cpp          | 6 ++++--
 imgui_widgets.cpp  | 2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 2369ea326..7b1d5fdda 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -42,8 +42,6 @@ HOW TO UPDATE?
 
 Breaking changes:
 
-- DragScalarN, SliderScalarN, InputScalarN: Fixed incorrect pushes into ItemWidth
-  stack when number of components is 1. [#7095] [@Nahor]
 - imgui_freetype: commented out ImGuiFreeType::BuildFontAtlas() obsoleted in 1.81.
   Prefer using #define IMGUI_ENABLE_FREETYPE or see commented code for manual calls.
 - Removed CalcListClipping() marked obsolete in 1.86. (#3841)
@@ -72,12 +70,15 @@ Other changes:
 - InputTextMultiline: Tabbing through a multi-line text editor which allows Tab character inputs
   (using the ImGuiInputTextFlags_AllowTabInput flag) doesn't automatically activate it, in order
   to allow passing through multiple widgets easily. (#3092, #5759, #787)
+- DragScalarN, SliderScalarN, InputScalarN: Fixed incorrect pushes into ItemWidth
+  stack when number of components is 1. [#7095] [@Nahor]
 - Drags, Sliders, Inputs: removed all attempts to filter non-numerical characters during text
   editing. Invalid inputs not applied to value, visibly reverted after validation. (#6810, #7096)
 - Drags, Sliders, Inputs: removal of filter means that "nan" and "inf" values may be input. (#7096)
 - DragScalarN, SliderScalarN, InputScalarN, PushMultiItemsWidths: improve multi-components
   width computation to better distribute the error. (#7120, #7121) [@Nahor]
-- ColorEdit4: Layout tweaks for very small sizes. (#7120, #7121)
+- ColorEdit: Layout tweaks for very small sizes. (#7120, #7121)
+- ColorPicker: Fixed saturation/value cursor radius not scaling properly.
 - Menus: Tweaked hover slack logic, adding a timer to avoid situations where a slow vertical
   movements toward another parent BeginMenu() can keep the wrong child menu open. (#6671, #6926)
 - Settings: Fixed an issue marking settings as dirty when merely clicking on a border or resize
diff --git a/imgui.cpp b/imgui.cpp
index 81be26d9c..2e9c7f41a 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -8721,7 +8721,9 @@ static void ImGui::UpdateKeyboardInputs()
             GetKeyData(ImGuiMod_Super)->Down = io.KeySuper;
         }
     }
+#endif
 
+    // Import legacy ImGuiNavInput_ io inputs and convert to gamepad keys
 #ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
     const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
     if (io.BackendUsingLegacyNavInputArray && nav_gamepad_active)
@@ -8744,7 +8746,6 @@ static void ImGui::UpdateKeyboardInputs()
         MAP_LEGACY_NAV_INPUT_TO_KEY1(ImGuiKey_GamepadLStickDown, ImGuiNavInput_LStickDown);
         #undef NAV_MAP_KEY
     }
-#endif
 #endif
 
     // Update aliases
@@ -8753,7 +8754,7 @@ static void ImGui::UpdateKeyboardInputs()
     UpdateAliasKey(ImGuiKey_MouseWheelX, io.MouseWheelH != 0.0f, io.MouseWheelH);
     UpdateAliasKey(ImGuiKey_MouseWheelY, io.MouseWheel != 0.0f, io.MouseWheel);
 
-    // Synchronize io.KeyMods and io.KeyXXX values.
+    // Synchronize io.KeyMods and io.KeyCtrl/io.KeyShift/etc. values.
     // - New backends (1.87+): send io.AddKeyEvent(ImGuiMod_XXX) ->                                      -> (here) deriving io.KeyMods + io.KeyXXX from key array.
     // - Legacy backends:      set io.KeyXXX bools               -> (above) set key array from io.KeyXXX -> (here) deriving io.KeyMods + io.KeyXXX from key array.
     // So with legacy backends the 4 values will do a unnecessary back-and-forth but it makes the code simpler and future facing.
@@ -8790,6 +8791,7 @@ static void ImGui::UpdateKeyboardInputs()
         owner_data->LockThisFrame = owner_data->LockUntilRelease = owner_data->LockUntilRelease && key_data->Down;  // Clear LockUntilRelease when key is not Down anymore
     }
 
+    // Update key routing (for e.g. shortcuts)
     UpdateKeyRoutingTable(&g.KeysRoutingTable);
 }
 
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index 12abfeab1..3bd656e07 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -5714,7 +5714,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
     }
 
     // Render cursor/preview circle (clamp S/V within 0..1 range because floating points colors may lead HSV values to be out of range)
-    float sv_cursor_rad = value_changed_sv ? 10.0f : 6.0f;
+    float sv_cursor_rad = value_changed_sv ? wheel_thickness * 0.55f : wheel_thickness * 0.40f;
     int sv_cursor_segments = draw_list->_CalcCircleAutoSegmentCount(sv_cursor_rad); // Lock segment count so the +1 one matches others.
     draw_list->AddCircleFilled(sv_cursor_pos, sv_cursor_rad, user_col32_striped_of_alpha, sv_cursor_segments);
     draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad + 1, col_midgrey, sv_cursor_segments);