diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/button.cpp | 9 | ||||
-rw-r--r-- | scene/gui/dialogs.cpp | 1 | ||||
-rw-r--r-- | scene/gui/option_button.cpp | 17 | ||||
-rw-r--r-- | scene/gui/slider.cpp | 7 | ||||
-rw-r--r-- | scene/gui/tabs.cpp | 18 | ||||
-rw-r--r-- | scene/gui/tabs.h | 2 | ||||
-rw-r--r-- | scene/resources/style_box.cpp | 78 | ||||
-rw-r--r-- | scene/resources/style_box.h | 34 |
8 files changed, 160 insertions, 6 deletions
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index a456759281..03798c01a2 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -89,7 +89,8 @@ void Button::_notification(int p_what) { case DRAW_PRESSED: { style = get_stylebox("pressed"); - style->draw(ci, Rect2(Point2(0, 0), size)); + if (!flat) + style->draw(ci, Rect2(Point2(0, 0), size)); if (has_color("font_color_pressed")) color = get_color("font_color_pressed"); else @@ -101,7 +102,8 @@ void Button::_notification(int p_what) { case DRAW_HOVER: { style = get_stylebox("hover"); - style->draw(ci, Rect2(Point2(0, 0), size)); + if (!flat) + style->draw(ci, Rect2(Point2(0, 0), size)); color = get_color("font_color_hover"); if (has_color("icon_color_hover")) color_icon = get_color("icon_color_hover"); @@ -110,7 +112,8 @@ void Button::_notification(int p_what) { case DRAW_DISABLED: { style = get_stylebox("disabled"); - style->draw(ci, Rect2(Point2(0, 0), size)); + if (!flat) + style->draw(ci, Rect2(Point2(0, 0), size)); color = get_color("font_color_disabled"); if (has_color("icon_color_disabled")) color_icon = get_color("icon_color_disabled"); diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index d5e852f840..8885bec03c 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -584,5 +584,6 @@ Button *ConfirmationDialog::get_cancel() { ConfirmationDialog::ConfirmationDialog() { set_title(RTR("Please Confirm...")); + set_custom_minimum_size(Size2(200, 70)); cancel = add_cancel(); } diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index f75e0986c1..b842419eab 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -52,11 +52,26 @@ void OptionButton::_notification(int p_what) { RID ci = get_canvas_item(); Ref<Texture> arrow = Control::get_icon("arrow"); Ref<StyleBox> normal = get_stylebox("normal"); + Color clr = Color(1, 1, 1); + if (get_constant("modulate_arrow")) + switch (get_draw_mode()) { + case DRAW_PRESSED: + clr = get_color("font_color_pressed"); + break; + case DRAW_HOVER: + clr = get_color("font_color_hover"); + break; + case DRAW_DISABLED: + clr = get_color("font_color_disabled"); + break; + default: + clr = get_color("font_color"); + } Size2 size = get_size(); Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2))); - arrow->draw(ci, ofs); + arrow->draw(ci, ofs, clr); } break; } 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/gui/tabs.cpp b/scene/gui/tabs.cpp index 4316f06a53..ee0ae1fb41 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -639,6 +639,22 @@ Tabs::TabAlign Tabs::get_tab_align() const { return tab_align; } +void Tabs::move_tab(int from, int to) { + + if (from == to) + return; + + ERR_FAIL_INDEX(from, tabs.size()); + ERR_FAIL_INDEX(to, tabs.size()); + + Tab tab_from = tabs[from]; + tabs.remove(from); + tabs.insert(to, tab_from); + + _update_cache(); + update(); +} + int Tabs::get_tab_width(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, tabs.size(), 0); @@ -773,6 +789,8 @@ void Tabs::_bind_methods() { ClassDB::bind_method(D_METHOD("set_tab_align", "align"), &Tabs::set_tab_align); ClassDB::bind_method(D_METHOD("get_tab_align"), &Tabs::get_tab_align); ClassDB::bind_method(D_METHOD("ensure_tab_visible", "idx"), &Tabs::ensure_tab_visible); + ClassDB::bind_method(D_METHOD("get_tab_rect", "tab_idx"), &Tabs::get_tab_rect); + ClassDB::bind_method(D_METHOD("move_tab", "from", "to"), &Tabs::move_tab); ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab"))); ADD_SIGNAL(MethodInfo("right_button_pressed", PropertyInfo(Variant::INT, "tab"))); diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index 613c604b12..a9dd6bddd7 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -119,6 +119,8 @@ public: void set_tab_align(TabAlign p_align); TabAlign get_tab_align() const; + void move_tab(int from, int to); + void set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy); int get_tab_count() const; diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 2714ffec10..f108809c83 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -437,3 +437,81 @@ StyleBoxFlat::StyleBoxFlat() { } StyleBoxFlat::~StyleBoxFlat() { } + +void StyleBoxLine::set_color(const Color &p_color) { + color = p_color; + emit_changed(); +} +Color StyleBoxLine::get_color() const { + return color; +} + +void StyleBoxLine::set_thickness(int p_thickness) { + thickness = p_thickness; + emit_changed(); +} +int StyleBoxLine::get_thickness() const { + return thickness; +} + +void StyleBoxLine::set_vertical(bool p_vertical) { + vertical = p_vertical; +} +bool StyleBoxLine::is_vertical() const { + return vertical; +} + +void StyleBoxLine::set_grow(float p_grow) { + grow = p_grow; + emit_changed(); +} +float StyleBoxLine::get_grow() const { + return grow; +} + +void StyleBoxLine::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_color", "color"), &StyleBoxLine::set_color); + ClassDB::bind_method(D_METHOD("get_color"), &StyleBoxLine::get_color); + ClassDB::bind_method(D_METHOD("set_thickness", "thickness"), &StyleBoxLine::set_thickness); + ClassDB::bind_method(D_METHOD("get_thickness"), &StyleBoxLine::get_thickness); + ClassDB::bind_method(D_METHOD("set_grow", "grow"), &StyleBoxLine::set_grow); + ClassDB::bind_method(D_METHOD("get_grow"), &StyleBoxLine::get_grow); + ClassDB::bind_method(D_METHOD("set_vertical", "vertical"), &StyleBoxLine::set_vertical); + ClassDB::bind_method(D_METHOD("is_vertical"), &StyleBoxLine::is_vertical); + + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "thickness", PROPERTY_HINT_RANGE, "0,10"), "set_thickness", "get_thickness"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vertical"), "set_vertical", "get_vertical"); +} +float StyleBoxLine::get_style_margin(Margin p_margin) const { + return thickness; +} +Size2 StyleBoxLine::get_center_size() const { + return Size2(); +} + +void StyleBoxLine::draw(RID p_canvas_item, const Rect2 &p_rect) const { + VisualServer *vs = VisualServer::get_singleton(); + Rect2i r = p_rect; + + if (vertical) { + r.position.y -= grow; + r.size.y += grow * 2; + r.size.x = thickness; + } else { + r.position.x -= grow; + r.size.x += grow * 2; + r.size.y = thickness; + } + + vs->canvas_item_add_rect(p_canvas_item, r, color); +} + +StyleBoxLine::StyleBoxLine() { + grow = 1.0; + thickness = 1; + color = Color(0.0, 0.0, 0.0); + vertical = false; +} +StyleBoxLine::~StyleBoxLine() {} diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 7547c2ea81..64ce3528aa 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -164,4 +164,38 @@ public: ~StyleBoxFlat(); }; +// just used to draw lines. +class StyleBoxLine : public StyleBox { + + GDCLASS(StyleBoxLine, StyleBox); + Color color; + int thickness; + bool vertical; + float grow; + +protected: + virtual float get_style_margin(Margin p_margin) const; + static void _bind_methods(); + +public: + void set_color(const Color &p_color); + Color get_color() const; + + void set_thickness(int p_thickness); + int get_thickness() const; + + void set_vertical(bool p_vertical); + bool is_vertical() const; + + void set_grow(float p_grow); + float get_grow() const; + + virtual Size2 get_center_size() const; + + virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const; + + StyleBoxLine(); + ~StyleBoxLine(); +}; + #endif |