From 2a4fc10868761136c59bb3f0eb4e2ae8e4f4e44c Mon Sep 17 00:00:00 2001 From: LuoZhihao Date: Fri, 6 Jun 2025 13:32:53 +0800 Subject: [PATCH] ColorPicker: Fix cursor position in okhsl circle --- scene/gui/color_picker_shape.cpp | 10 +++++----- scene/gui/color_picker_shape.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scene/gui/color_picker_shape.cpp b/scene/gui/color_picker_shape.cpp index 5cc2f1a8498..23aebdc107e 100644 --- a/scene/gui/color_picker_shape.cpp +++ b/scene/gui/color_picker_shape.cpp @@ -161,11 +161,11 @@ void ColorPickerShape::draw_cursor(Control *p_control, const Vector2 &p_center, p_control->draw_texture(color_picker->theme_cache.picker_cursor, position); } -void ColorPickerShape::draw_circle_cursor(Control *p_control, float p_hue) { +void ColorPickerShape::draw_circle_cursor(Control *p_control, float p_hue, float p_saturation) { const Vector2 center = p_control->get_size() * 0.5; const Vector2 cursor_pos( - center.x + (center.x * Math::cos(p_hue * Math::TAU) * color_picker->s), - center.y + (center.y * Math::sin(p_hue * Math::TAU) * color_picker->s)); + center.x + (center.x * Math::cos(p_hue * Math::TAU) * p_saturation), + center.y + (center.y * Math::sin(p_hue * Math::TAU) * p_saturation)); draw_cursor(p_control, cursor_pos); } @@ -636,7 +636,7 @@ void ColorPickerShapeVHSCircle::_circle_draw() { void ColorPickerShapeVHSCircle::_circle_overlay_draw() { draw_focus_circle(circle_overlay); - draw_circle_cursor(circle_overlay, color_picker->h); + draw_circle_cursor(circle_overlay, color_picker->h, color_picker->s); } void ColorPickerShapeVHSCircle::_value_slider_draw() { @@ -721,7 +721,7 @@ void ColorPickerShapeOKHSLCircle::_circle_draw() { void ColorPickerShapeOKHSLCircle::_circle_overlay_draw() { draw_focus_circle(circle_overlay); - draw_circle_cursor(circle_overlay, color_picker->ok_hsl_h); + draw_circle_cursor(circle_overlay, color_picker->ok_hsl_h, color_picker->ok_hsl_s); } void ColorPickerShapeOKHSLCircle::_value_slider_draw() { diff --git a/scene/gui/color_picker_shape.h b/scene/gui/color_picker_shape.h index f1f9be2956f..6f8ac6a5ddb 100644 --- a/scene/gui/color_picker_shape.h +++ b/scene/gui/color_picker_shape.h @@ -52,7 +52,7 @@ protected: void draw_focus_circle(Control *p_control); void draw_sv_square(Control *p_control, const Rect2 &p_square, bool p_draw_focus = true); void draw_cursor(Control *p_control, const Vector2 &p_center, bool p_draw_bg = true); - void draw_circle_cursor(Control *p_control, float p_hue); + void draw_circle_cursor(Control *p_control, float p_hue, float p_saturation); void connect_shape_focus(Control *p_shape); void shape_focus_entered();