diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/color_picker.cpp | 44 | ||||
-rw-r--r-- | scene/gui/color_picker.h | 2 | ||||
-rw-r--r-- | scene/gui/gradient_edit.cpp | 4 | ||||
-rw-r--r-- | scene/gui/slider.cpp | 7 | ||||
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 10 |
5 files changed, 38 insertions, 29 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 9ef340edbc..faaf761598 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -50,6 +50,19 @@ void ColorPicker::_notification(int p_what) { _update_color(); } break; + case NOTIFICATION_PARENTED: { + for (int i = 0; i < 4; i++) + set_margin((Margin)i, get_constant("margin")); + } break; + + case NOTIFICATION_VISIBILITY_CHANGED: { + if (get_parent()) { + Popup *p = get_parent()->cast_to<Popup>(); + if (p) + p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2)); + } + } break; + case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: { if (screen != NULL) { if (screen->is_visible()) { @@ -254,13 +267,13 @@ void ColorPicker::_update_text_value() { } void ColorPicker::_sample_draw() { - sample->draw_rect(Rect2(Point2(), Size2(uv_edit->get_size().width, 20)), color); + sample->draw_rect(Rect2(Point2(), Size2(uv_edit->get_size().width, sample->get_size().height * 0.95)), color); } -void ColorPicker::_hsv_draw(int p_wich, Control *c) { +void ColorPicker::_hsv_draw(int p_which, Control *c) { if (!c) return; - if (p_wich == 0) { + if (p_which == 0) { Vector<Point2> points; points.push_back(Vector2()); points.push_back(Vector2(c->get_size().x, 0)); @@ -291,7 +304,7 @@ void ColorPicker::_hsv_draw(int p_wich, Control *c) { c->draw_line(Point2(x, 0), Point2(x, c->get_size().y), col.inverted()); c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted()); c->draw_line(Point2(x, y), Point2(x, y), Color(1, 1, 1), 2); - } else if (p_wich == 1) { + } else if (p_which == 1) { Ref<Texture> hue = get_icon("color_hue", "ColorPicker"); c->draw_texture_rect(hue, Rect2(Point2(), c->get_size())); int y = c->get_size().y - c->get_size().y * (1.0 - h); @@ -512,23 +525,18 @@ ColorPicker::ColorPicker() uv_edit->set_mouse_filter(MOUSE_FILTER_PASS); uv_edit->set_h_size_flags(SIZE_EXPAND_FILL); uv_edit->set_v_size_flags(SIZE_EXPAND_FILL); - Vector<Variant> args = Vector<Variant>(); - args.push_back(0); - args.push_back(uv_edit); - uv_edit->connect("draw", this, "_hsv_draw", args); + uv_edit->set_custom_minimum_size(Size2(get_constant("sv_width"), get_constant("sv_height"))); + uv_edit->connect("draw", this, "_hsv_draw", make_binds(0, uv_edit)); add_child(hb_edit); w_edit = memnew(Control); //w_edit->set_ignore_mouse(false); - w_edit->set_custom_minimum_size(Size2(30, 0)); + w_edit->set_custom_minimum_size(Size2(get_constant("h_width"), 0)); w_edit->set_h_size_flags(SIZE_FILL); w_edit->set_v_size_flags(SIZE_EXPAND_FILL); w_edit->connect("gui_input", this, "_w_input"); - args.clear(); - args.push_back(1); - args.push_back(w_edit); - w_edit->connect("draw", this, "_hsv_draw", args); + w_edit->connect("draw", this, "_hsv_draw", make_binds(1, w_edit)); hb_edit->add_child(uv_edit); hb_edit->add_child(memnew(VSeparator)); @@ -549,10 +557,12 @@ ColorPicker::ColorPicker() HBoxContainer *hbc = memnew(HBoxContainer); labels[i] = memnew(Label(lt[i])); - labels[i]->set_custom_minimum_size(Size2(10, 0)); + labels[i]->set_custom_minimum_size(Size2(get_constant("label_width"), 0)); + labels[i]->set_v_size_flags(SIZE_SHRINK_CENTER); hbc->add_child(labels[i]); scroll[i] = memnew(HSlider); + scroll[i]->set_v_size_flags(SIZE_SHRINK_CENTER); hbc->add_child(scroll[i]); values[i] = memnew(SpinBox); @@ -571,7 +581,7 @@ ColorPicker::ColorPicker() HBoxContainer *hhb = memnew(HBoxContainer); btn_mode = memnew(CheckButton); - btn_mode->set_text(TTR("RAW Mode")); + btn_mode->set_text(TTR("Raw Mode")); btn_mode->connect("toggled", this, "set_raw_mode"); hhb->add_child(btn_mode); vbr->add_child(hhb); @@ -617,9 +627,7 @@ void ColorPickerButton::_color_changed(const Color &p_color) { void ColorPickerButton::pressed() { - Size2 ms = Size2(300, picker->get_combined_minimum_size().height + 10); - popup->set_position(get_global_position() - Size2(0, ms.height)); - popup->set_size(ms); + popup->set_position(get_global_position() - picker->get_combined_minimum_size()); popup->popup(); picker->set_focus_on_line_edit(); } diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index de624fd029..1a79266409 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -79,7 +79,7 @@ private: void _update_text_value(); void _text_type_toggled(); void _sample_draw(); - void _hsv_draw(int p_wich, Control *c); + void _hsv_draw(int p_which, Control *c); void _uv_input(const Ref<InputEvent> &p_input); void _w_input(const Ref<InputEvent> &p_input); diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index 58bce57580..22de28ea7f 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -61,10 +61,8 @@ int GradientEdit::_get_point_from_pos(int x) { void GradientEdit::_show_color_picker() { if (grabbed == -1) return; - Size2 ms = Size2(350, picker->get_combined_minimum_size().height + 10); picker->set_pick_color(points[grabbed].color); - popup->set_position(get_global_position() - Vector2(ms.width - get_size().width, ms.height)); - popup->set_size(ms); + popup->set_position(get_global_position() - popup->get_combined_minimum_size()); popup->popup(); } diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index c84608ef2e..9ba17ce34f 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -167,7 +167,8 @@ void Slider::_notification(int p_what) { if (orientation == VERTICAL) { - style->draw(ci, Rect2i(Point2i(), Size2i(style->get_minimum_size().width + style->get_center_size().width, size.height))); + int widget_width = style->get_minimum_size().width + style->get_center_size().width; + style->draw(ci, Rect2i(Point2i(size.width / 2 - widget_width / 2, 0), Size2i(widget_width, size.height))); /* if (mouse_inside||has_focus()) focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height))); @@ -183,7 +184,9 @@ void Slider::_notification(int p_what) { } grabber->draw(ci, Point2i(size.width / 2 - grabber->get_size().width / 2, size.height - get_as_ratio() * areasize - grabber->get_size().height)); } else { - style->draw(ci, Rect2i(Point2i(), Size2i(size.width, style->get_minimum_size().height + style->get_center_size().height))); + + int widget_height = style->get_minimum_size().height + style->get_center_size().height; + style->draw(ci, Rect2i(Point2i(0, size.height / 2 - widget_height / 2), Size2i(size.width, widget_height))); /* if (mouse_inside||has_focus()) focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height))); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index d70d91a17e..3e612c745f 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -761,11 +761,11 @@ void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref< // colorPicker - t->set_constant("value_height", "ColorPicker", 23 * scale); - t->set_constant("value_width", "ColorPicker", 50 * scale); - t->set_constant("color_width", "ColorPicker", 100 * scale); - t->set_constant("label_width", "ColorPicker", 20 * scale); - t->set_constant("hseparator", "ColorPicker", 4 * scale); + t->set_constant("margin", "ColorPicker", 4 * scale); + t->set_constant("sv_width", "ColorPicker", 256 * scale); + t->set_constant("sv_height", "ColorPicker", 256 * scale); + t->set_constant("h_width", "ColorPicker", 30 * scale); + t->set_constant("label_width", "ColorPicker", 10 * scale); t->set_icon("screen_picker", "ColorPicker", make_icon(icon_color_pick_png)); t->set_icon("add_preset", "ColorPicker", make_icon(icon_add_png)); |