diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 6558483acf..dff6ba7e58 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -122,6 +122,9 @@ void ColorPicker::_notification(int p_what) { if (!is_picking_color) { return; } + if (Rect2(Point2(), get_size()).has_point(get_local_mouse_position())) { + return; + } set_pick_color(DisplayServer::get_singleton()->screen_get_pixel(DisplayServer::get_singleton()->mouse_get_position())); } } @@ -1003,6 +1006,9 @@ void ColorPicker::_update_text_value() { } void ColorPicker::_sample_input(const Ref &p_event) { + if (!display_old_color) { + return; + } const Ref mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { const Rect2 rect_old = Rect2(Point2(), Size2(sample->get_size().width * 0.5, sample->get_size().height * 0.95)); @@ -1740,6 +1746,7 @@ void ColorPicker::_bind_methods() { ColorPicker::ColorPicker() { internal_margin = memnew(MarginContainer); + internal_margin->set_v_size_flags(SIZE_EXPAND_FILL); add_child(internal_margin, false, INTERNAL_MODE_FRONT); VBoxContainer *real_vbox = memnew(VBoxContainer); @@ -1747,7 +1754,7 @@ ColorPicker::ColorPicker() { HBoxContainer *hb_edit = memnew(HBoxContainer); real_vbox->add_child(hb_edit); - hb_edit->set_v_size_flags(SIZE_SHRINK_BEGIN); + hb_edit->set_v_size_flags(SIZE_EXPAND_FILL); uv_edit = memnew(Control); hb_edit->add_child(uv_edit); @@ -1833,8 +1840,6 @@ ColorPicker::ColorPicker() { mode_popup->set_item_checked(current_mode, true); mode_popup->set_item_checked(MODE_MAX + 1, true); mode_popup->connect("id_pressed", callable_mp(this, &ColorPicker::_set_mode_popup_value)); - VBoxContainer *vbl = memnew(VBoxContainer); - real_vbox->add_child(vbl); VBoxContainer *vbr = memnew(VBoxContainer); diff --git a/scene/theme/default_theme.cpp b/scene/theme/default_theme.cpp index 20c6c32b3f..933d25488b 100644 --- a/scene/theme/default_theme.cpp +++ b/scene/theme/default_theme.cpp @@ -939,11 +939,11 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const // ColorPicker - theme->set_constant("margin", "ColorPicker", Math::round(4 * scale)); - theme->set_constant("sv_width", "ColorPicker", Math::round(256 * scale)); - theme->set_constant("sv_height", "ColorPicker", Math::round(256 * scale)); - theme->set_constant("h_width", "ColorPicker", Math::round(30 * scale)); - theme->set_constant("label_width", "ColorPicker", Math::round(10 * scale)); + theme->set_constant("margin", "ColorPicker", Math::round(2 * scale)); + theme->set_constant("sv_width", "ColorPicker", Math::round(128 * scale)); + theme->set_constant("sv_height", "ColorPicker", Math::round(128 * scale)); + theme->set_constant("h_width", "ColorPicker", Math::round(24 * scale)); + theme->set_constant("label_width", "ColorPicker", Math::round(20 * scale)); theme->set_constant("center_slider_grabbers", "ColorPicker", 1); theme->set_icon("folded_arrow", "ColorPicker", icons["arrow_right"]);