Skip to content

Commit

Permalink
ColorPicker update
Browse files Browse the repository at this point in the history
  • Loading branch information
WhalesState committed Feb 6, 2024
1 parent 40fc059 commit 0772b12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions scene/gui/color_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}
Expand Down Expand Up @@ -1003,6 +1006,9 @@ void ColorPicker::_update_text_value() {
}

void ColorPicker::_sample_input(const Ref<InputEvent> &p_event) {
if (!display_old_color) {
return;
}
const Ref<InputEventMouseButton> 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));
Expand Down Expand Up @@ -1740,14 +1746,15 @@ 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);
internal_margin->add_child(real_vbox);

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);
Expand Down Expand Up @@ -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);

Expand Down
10 changes: 5 additions & 5 deletions scene/theme/default_theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,11 +939,11 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &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"]);
Expand Down

0 comments on commit 0772b12

Please sign in to comment.