Skip to content

Commit 43fa18c

Browse files
committed
Fix color picker shape minimum size
1 parent 8b4b93a commit 43fa18c

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

scene/gui/color_picker_shape.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -692,27 +692,24 @@ void ColorPickerShapeWheel::_wheel_uv_draw() {
692692
}
693693

694694
void ColorPickerShapeWheel::_initialize_controls() {
695-
wheel_margin = memnew(MarginContainer);
696-
color_picker->shape_container->add_child(wheel_margin);
697-
698695
Ref<ShaderMaterial> material;
699696
material.instantiate();
700697
material->set_shader(ColorPicker::wheel_shader);
701698
material->set_shader_parameter("wheel_radius", WHEEL_RADIUS);
702699

703700
wheel = memnew(Control);
704701
wheel->set_material(material);
705-
wheel_margin->add_child(wheel);
702+
color_picker->shape_container->add_child(wheel);
706703
wheel->connect(SceneStringName(draw), callable_mp(this, &ColorPickerShapeWheel::_wheel_draw));
707704

708705
wheel_uv = memnew(Control);
709-
wheel_margin->add_child(wheel_uv);
706+
wheel_uv->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
707+
wheel->add_child(wheel_uv);
710708
wheel_uv->connect(SceneStringName(focus_entered), callable_mp(this, &ColorPickerShapeWheel::_reset_wheel_focus));
711709
wheel_uv->connect(SceneStringName(gui_input), callable_mp(this, &ColorPickerShapeWheel::_wheel_input));
712710
wheel_uv->connect(SceneStringName(draw), callable_mp(this, &ColorPickerShapeWheel::_wheel_uv_draw));
713711
connect_shape_focus(wheel_uv);
714712

715-
controls.append(wheel_margin);
716713
controls.append(wheel);
717714
controls.append(wheel_uv);
718715
}
@@ -733,8 +730,7 @@ void ColorPickerShapeWheel::_update_cursor(const Vector2 &p_color_change_vector,
733730

734731
void ColorPickerShapeWheel::update_theme() {
735732
const ColorPicker::ThemeCache &theme_cache = color_picker->theme_cache;
736-
wheel_margin->set_custom_minimum_size(Size2(theme_cache.sv_width, theme_cache.sv_height));
737-
wheel_margin->add_theme_constant_override(SNAME("margin_bottom"), 8 * theme_cache.base_scale);
733+
wheel->set_custom_minimum_size(Size2(theme_cache.sv_width, theme_cache.sv_height));
738734
}
739735

740736
void ColorPickerShapeWheel::grab_focus() {
@@ -762,16 +758,13 @@ void ColorPickerShapeCircle::update_circle_cursor(const Vector2 &p_color_change_
762758
}
763759

764760
void ColorPickerShapeCircle::_initialize_controls() {
765-
circle_margin = memnew(MarginContainer);
766-
color_picker->shape_container->add_child(circle_margin);
767-
768761
Ref<ShaderMaterial> material;
769762
material.instantiate();
770763
material->set_shader(_get_shader());
771764

772765
circle = memnew(Control);
773766
circle->set_material(material);
774-
circle_margin->add_child(circle);
767+
color_picker->shape_container->add_child(circle);
775768
circle->connect(SceneStringName(draw), callable_mp(this, &ColorPickerShapeCircle::_circle_draw));
776769

777770
circle_overlay = memnew(Control);
@@ -787,16 +780,14 @@ void ColorPickerShapeCircle::_initialize_controls() {
787780
value_slider->connect(SceneStringName(draw), callable_mp(this, &ColorPickerShapeCircle::_value_slider_draw));
788781
connect_shape_focus(value_slider);
789782

790-
controls.append(circle_margin);
791783
controls.append(circle);
792784
controls.append(circle_overlay);
793785
controls.append(value_slider);
794786
}
795787

796788
void ColorPickerShapeCircle::update_theme() {
797789
const ColorPicker::ThemeCache &theme_cache = color_picker->theme_cache;
798-
circle_margin->set_custom_minimum_size(Size2(theme_cache.sv_width, theme_cache.sv_height));
799-
circle_margin->add_theme_constant_override(SNAME("margin_bottom"), 8 * theme_cache.base_scale);
790+
circle->set_custom_minimum_size(Size2(theme_cache.sv_width, theme_cache.sv_height));
800791
value_slider->set_custom_minimum_size(Size2(theme_cache.h_width, 0));
801792
}
802793

scene/gui/color_picker_shape.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ class ColorPickerShapeWheel : public ColorPickerShape {
163163

164164
static constexpr float WHEEL_RADIUS = 0.42;
165165

166-
MarginContainer *wheel_margin = nullptr;
167166
Control *wheel = nullptr;
168167
Control *wheel_uv = nullptr;
169168

@@ -197,7 +196,6 @@ class ColorPickerShapeCircle : public ColorPickerShape {
197196
GDCLASS(ColorPickerShapeCircle, ColorPickerShape);
198197

199198
protected:
200-
MarginContainer *circle_margin = nullptr;
201199
Control *circle = nullptr;
202200
Control *circle_overlay = nullptr;
203201
Control *value_slider = nullptr;

0 commit comments

Comments
 (0)