Skip to content

Commit d8558da

Browse files
committed
Merge pull request #110581 from KoBeWi/round_like_earth
Fix color picker shape minimum size
2 parents 093f176 + 43fa18c commit d8558da

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
@@ -807,27 +807,24 @@ void ColorPickerShapeWheel::_wheel_uv_draw() {
807807
}
808808

809809
void ColorPickerShapeWheel::_initialize_controls() {
810-
wheel_margin = memnew(MarginContainer);
811-
color_picker->shape_container->add_child(wheel_margin);
812-
813810
Ref<ShaderMaterial> material;
814811
material.instantiate();
815812
material->set_shader(ColorPickerShape::wheel_shader);
816813
material->set_shader_parameter("wheel_radius", WHEEL_RADIUS);
817814

818815
wheel = memnew(Control);
819816
wheel->set_material(material);
820-
wheel_margin->add_child(wheel);
817+
color_picker->shape_container->add_child(wheel);
821818
wheel->connect(SceneStringName(draw), callable_mp(this, &ColorPickerShapeWheel::_wheel_draw));
822819

823820
wheel_uv = memnew(Control);
824-
wheel_margin->add_child(wheel_uv);
821+
wheel_uv->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
822+
wheel->add_child(wheel_uv);
825823
wheel_uv->connect(SceneStringName(focus_entered), callable_mp(this, &ColorPickerShapeWheel::_reset_wheel_focus));
826824
wheel_uv->connect(SceneStringName(gui_input), callable_mp(this, &ColorPickerShapeWheel::_wheel_input));
827825
wheel_uv->connect(SceneStringName(draw), callable_mp(this, &ColorPickerShapeWheel::_wheel_uv_draw));
828826
connect_shape_focus(wheel_uv);
829827

830-
controls.append(wheel_margin);
831828
controls.append(wheel);
832829
controls.append(wheel_uv);
833830
}
@@ -848,8 +845,7 @@ void ColorPickerShapeWheel::_update_cursor(const Vector2 &p_color_change_vector,
848845

849846
void ColorPickerShapeWheel::update_theme() {
850847
const ColorPicker::ThemeCache &theme_cache = color_picker->theme_cache;
851-
wheel_margin->set_custom_minimum_size(Size2(theme_cache.sv_width, theme_cache.sv_height));
852-
wheel_margin->add_theme_constant_override(SNAME("margin_bottom"), 8 * theme_cache.base_scale);
848+
wheel->set_custom_minimum_size(Size2(theme_cache.sv_width, theme_cache.sv_height));
853849
}
854850

855851
void ColorPickerShapeWheel::grab_focus() {
@@ -877,16 +873,13 @@ void ColorPickerShapeCircle::update_circle_cursor(const Vector2 &p_color_change_
877873
}
878874

879875
void ColorPickerShapeCircle::_initialize_controls() {
880-
circle_margin = memnew(MarginContainer);
881-
color_picker->shape_container->add_child(circle_margin);
882-
883876
Ref<ShaderMaterial> material;
884877
material.instantiate();
885878
material->set_shader(_get_shader());
886879

887880
circle = memnew(Control);
888881
circle->set_material(material);
889-
circle_margin->add_child(circle);
882+
color_picker->shape_container->add_child(circle);
890883
circle->connect(SceneStringName(draw), callable_mp(this, &ColorPickerShapeCircle::_circle_draw));
891884

892885
circle_overlay = memnew(Control);
@@ -902,16 +895,14 @@ void ColorPickerShapeCircle::_initialize_controls() {
902895
value_slider->connect(SceneStringName(draw), callable_mp(this, &ColorPickerShapeCircle::_value_slider_draw));
903896
connect_shape_focus(value_slider);
904897

905-
controls.append(circle_margin);
906898
controls.append(circle);
907899
controls.append(circle_overlay);
908900
controls.append(value_slider);
909901
}
910902

911903
void ColorPickerShapeCircle::update_theme() {
912904
const ColorPicker::ThemeCache &theme_cache = color_picker->theme_cache;
913-
circle_margin->set_custom_minimum_size(Size2(theme_cache.sv_width, theme_cache.sv_height));
914-
circle_margin->add_theme_constant_override(SNAME("margin_bottom"), 8 * theme_cache.base_scale);
905+
circle->set_custom_minimum_size(Size2(theme_cache.sv_width, theme_cache.sv_height));
915906
value_slider->set_custom_minimum_size(Size2(theme_cache.h_width, 0));
916907
}
917908

scene/gui/color_picker_shape.h

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

173173
static constexpr float WHEEL_RADIUS = 0.42;
174174

175-
MarginContainer *wheel_margin = nullptr;
176175
Control *wheel = nullptr;
177176
Control *wheel_uv = nullptr;
178177

@@ -206,7 +205,6 @@ class ColorPickerShapeCircle : public ColorPickerShape {
206205
GDCLASS(ColorPickerShapeCircle, ColorPickerShape);
207206

208207
protected:
209-
MarginContainer *circle_margin = nullptr;
210208
Control *circle = nullptr;
211209
Control *circle_overlay = nullptr;
212210
Control *value_slider = nullptr;

0 commit comments

Comments
 (0)