diff --git a/scene/gui/color_mode.h b/scene/gui/color_mode.h index 00bc4839327..38e3b9f0ed4 100644 --- a/scene/gui/color_mode.h +++ b/scene/gui/color_mode.h @@ -53,7 +53,6 @@ public: virtual void slider_draw(int p_which) = 0; virtual bool apply_theme() const { return false; } - virtual ColorPicker::PickerShapeType get_shape_override() const { return ColorPicker::SHAPE_MAX; } ColorMode(ColorPicker *p_color_picker); virtual ~ColorMode() {} @@ -144,7 +143,6 @@ public: virtual void _value_changed() override; virtual void slider_draw(int p_which) override; - virtual ColorPicker::PickerShapeType get_shape_override() const override { return ColorPicker::SHAPE_OKHSL_CIRCLE; } ColorModeOKHSL(ColorPicker *p_color_picker) : ColorMode(p_color_picker) {} diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 811569bcc1b..2d21a9483f8 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -309,7 +309,7 @@ void ColorPicker::_update_controls() { alpha_label->hide(); } - switch (_get_actual_shape()) { + switch (current_shape) { case SHAPE_HSV_RECTANGLE: wheel_edit->hide(); w_edit->show(); @@ -562,7 +562,7 @@ void ColorPicker::_copy_color_to_hsv() { } void ColorPicker::_copy_hsv_to_color() { - if (_get_actual_shape() == SHAPE_OKHSL_CIRCLE) { + if (current_shape == SHAPE_OKHSL_CIRCLE) { color.set_ok_hsl(ok_hsl_h, ok_hsl_s, ok_hsl_l, color.a); } else { color.set_hsv(h, s, v, color.a); @@ -594,10 +594,6 @@ bool ColorPicker::_select_from_recent_preset_hbc(const Color &p_color) { return false; } -ColorPicker::PickerShapeType ColorPicker::_get_actual_shape() const { - return modes[current_mode]->get_shape_override() != SHAPE_MAX ? modes[current_mode]->get_shape_override() : current_shape; -} - void ColorPicker::_reset_sliders_theme() { Ref style_box_flat(memnew(StyleBoxFlat)); style_box_flat->set_content_margin(SIDE_TOP, 16 * theme_cache.base_scale); @@ -1322,19 +1318,18 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { return; } - PickerShapeType actual_shape = _get_actual_shape(); if (p_which == 0) { Color col = color; Vector2 center = c->get_size() / 2.0; - if (actual_shape == SHAPE_HSV_RECTANGLE || actual_shape == SHAPE_HSV_WHEEL) { + if (current_shape == SHAPE_HSV_RECTANGLE || current_shape == SHAPE_HSV_WHEEL) { Vector points; Vector colors; Vector colors2; points.resize(4); colors.resize(4); colors2.resize(4); - if (actual_shape == SHAPE_HSV_RECTANGLE) { + if (current_shape == SHAPE_HSV_RECTANGLE) { points.set(0, Vector2()); points.set(1, Vector2(c->get_size().x, 0)); points.set(2, c->get_size()); @@ -1368,9 +1363,9 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { int x; int y; - if (actual_shape == SHAPE_VHS_CIRCLE || actual_shape == SHAPE_OKHSL_CIRCLE) { + if (current_shape == SHAPE_VHS_CIRCLE || current_shape == SHAPE_OKHSL_CIRCLE) { Vector2 hue_offset; - if (actual_shape == SHAPE_OKHSL_CIRCLE) { + if (current_shape == SHAPE_OKHSL_CIRCLE) { hue_offset = center * Vector2(Math::cos(ok_hsl_h * Math_TAU), Math::sin(ok_hsl_h * Math_TAU)) * ok_hsl_s; } else { hue_offset = center * Vector2(Math::cos(h * Math_TAU), Math::sin(h * Math_TAU)) * s; @@ -1390,7 +1385,7 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { c->draw_texture(theme_cache.picker_cursor_bg, Point2(x, y), _col); c->draw_texture(theme_cache.picker_cursor, Point2(x, y)); - if (actual_shape == SHAPE_HSV_WHEEL) { + if (current_shape == SHAPE_HSV_WHEEL) { float _radius = WHEEL_RADIUS * 2.0; _radius += (1.0 - _radius) * 0.5; Point2 pos = center - (theme_cache.picker_cursor->get_size() * 0.5) + Point2(center.x * Math::cos(h * Math_TAU) * _radius, center.y * Math::sin(h * Math_TAU) * _radius); @@ -1398,7 +1393,7 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { } } else if (p_which == 1) { - if (actual_shape == SHAPE_HSV_RECTANGLE) { + if (current_shape == SHAPE_HSV_RECTANGLE) { c->draw_set_transform(Point2(), -Math_PI / 2, Size2(c->get_size().x, -c->get_size().y)); c->draw_texture_rect(theme_cache.color_hue, Rect2(Point2(), Size2(1, 1))); c->draw_set_transform(Point2(), 0, Size2(1, 1)); @@ -1406,7 +1401,7 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { Color col; col.set_hsv(h, 1, 1); c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted()); - } else if (actual_shape == SHAPE_OKHSL_CIRCLE) { + } else if (current_shape == SHAPE_OKHSL_CIRCLE) { Vector points; Vector colors; Color col; @@ -1433,7 +1428,7 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { int y = c->get_size().y - c->get_size().y * CLAMP(ok_hsl_l, 0, 1); col.set_ok_hsl(ok_hsl_h, 1, ok_hsl_l); c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted()); - } else if (actual_shape == SHAPE_VHS_CIRCLE) { + } else if (current_shape == SHAPE_VHS_CIRCLE) { Vector points; Vector colors; Color col; @@ -1455,9 +1450,9 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { } } else if (p_which == 2) { c->draw_rect(Rect2(Point2(), c->get_size()), Color(1, 1, 1)); - if (actual_shape == SHAPE_VHS_CIRCLE) { + if (current_shape == SHAPE_VHS_CIRCLE) { circle_mat->set_shader_parameter("v", v); - } else if (actual_shape == SHAPE_OKHSL_CIRCLE) { + } else if (current_shape == SHAPE_OKHSL_CIRCLE) { circle_mat->set_shader_parameter("ok_hsl_l", ok_hsl_l); } } @@ -1471,12 +1466,11 @@ void ColorPicker::_slider_draw(int p_which) { void ColorPicker::_uv_input(const Ref &p_event, Control *c) { Ref bev = p_event; - PickerShapeType actual_shape = _get_actual_shape(); if (bev.is_valid()) { if (bev->is_pressed() && bev->get_button_index() == MouseButton::LEFT) { Vector2 center = c->get_size() / 2.0; - if (actual_shape == SHAPE_VHS_CIRCLE || actual_shape == SHAPE_OKHSL_CIRCLE) { + if (current_shape == SHAPE_VHS_CIRCLE || current_shape == SHAPE_OKHSL_CIRCLE) { real_t dist = center.distance_to(bev->get_position()); if (dist <= center.x) { real_t rad = center.angle_to_point(bev->get_position()); @@ -1546,7 +1540,7 @@ void ColorPicker::_uv_input(const Ref &p_event, Control *c) { } Vector2 center = c->get_size() / 2.0; - if (actual_shape == SHAPE_VHS_CIRCLE || actual_shape == SHAPE_OKHSL_CIRCLE) { + if (current_shape == SHAPE_VHS_CIRCLE || current_shape == SHAPE_OKHSL_CIRCLE) { real_t dist = center.distance_to(mev->get_position()); real_t rad = center.angle_to_point(mev->get_position()); h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU; @@ -1582,13 +1576,12 @@ void ColorPicker::_uv_input(const Ref &p_event, Control *c) { void ColorPicker::_w_input(const Ref &p_event) { Ref bev = p_event; - PickerShapeType actual_shape = _get_actual_shape(); if (bev.is_valid()) { if (bev->is_pressed() && bev->get_button_index() == MouseButton::LEFT) { changing_color = true; float y = CLAMP((float)bev->get_position().y, 0, w_edit->get_size().height); - if (actual_shape == SHAPE_VHS_CIRCLE || actual_shape == SHAPE_OKHSL_CIRCLE) { + if (current_shape == SHAPE_VHS_CIRCLE || current_shape == SHAPE_OKHSL_CIRCLE) { v = 1.0 - (y / w_edit->get_size().height); ok_hsl_l = v; } else { @@ -1617,7 +1610,7 @@ void ColorPicker::_w_input(const Ref &p_event) { return; } float y = CLAMP((float)mev->get_position().y, 0, w_edit->get_size().height); - if (actual_shape == SHAPE_VHS_CIRCLE || actual_shape == SHAPE_OKHSL_CIRCLE) { + if (current_shape == SHAPE_VHS_CIRCLE || current_shape == SHAPE_OKHSL_CIRCLE) { v = 1.0 - (y / w_edit->get_size().height); ok_hsl_l = v; } else { diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index 89b5c4c6992..6ccf0bf7d1f 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -277,7 +277,6 @@ private: void _copy_color_to_hsv(); void _copy_hsv_to_color(); - PickerShapeType _get_actual_shape() const; void create_slider(GridContainer *gc, int idx); void _reset_sliders_theme(); void _html_submitted(const String &p_html);