diff options
Diffstat (limited to 'scene/gui')
| -rw-r--r-- | scene/gui/button.cpp | 14 | ||||
| -rw-r--r-- | scene/gui/dialogs.cpp | 47 | ||||
| -rw-r--r-- | scene/gui/scroll_bar.cpp | 22 | ||||
| -rw-r--r-- | scene/gui/scroll_bar.h | 12 | ||||
| -rw-r--r-- | scene/gui/slider.cpp | 4 | ||||
| -rw-r--r-- | scene/gui/tabs.cpp | 16 | ||||
| -rw-r--r-- | scene/gui/tabs.h | 2 |
7 files changed, 68 insertions, 49 deletions
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 6fcc878e11..a456759281 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -69,6 +69,7 @@ void Button::_notification(int p_what) { RID ci = get_canvas_item(); Size2 size = get_size(); Color color; + Color color_icon(1, 1, 1, 1); //print_line(get_text()+": "+itos(is_flat())+" hover "+itos(get_draw_mode())); @@ -82,6 +83,8 @@ void Button::_notification(int p_what) { if (!flat) style->draw(ci, Rect2(Point2(0, 0), size)); color = get_color("font_color"); + if (has_color("icon_color_normal")) + color_icon = get_color("icon_color_normal"); } break; case DRAW_PRESSED: { @@ -91,6 +94,8 @@ void Button::_notification(int p_what) { color = get_color("font_color_pressed"); else color = get_color("font_color"); + if (has_color("icon_color_pressed")) + color_icon = get_color("icon_color_pressed"); } break; case DRAW_HOVER: { @@ -98,6 +103,8 @@ void Button::_notification(int p_what) { style = get_stylebox("hover"); 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"); } break; case DRAW_DISABLED: { @@ -105,6 +112,8 @@ void Button::_notification(int p_what) { style = get_stylebox("disabled"); 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"); } break; } @@ -148,8 +157,9 @@ void Button::_notification(int p_what) { if (!_icon.is_null()) { int valign = size.height - style->get_minimum_size().y; - - _icon->draw(ci, style->get_offset() + Point2(0, Math::floor((valign - _icon->get_height()) / 2.0)), is_disabled() ? Color(1, 1, 1, 0.4) : Color(1, 1, 1)); + if (is_disabled()) + color_icon.a = 0.4; + _icon->draw(ci, style->get_offset() + Point2(0, Math::floor((valign - _icon->get_height()) / 2.0)), color_icon); } } } diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index cf5321e907..053be515ac 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -53,25 +53,34 @@ void WindowDialog::_fix_size() { Size2i viewport_size = get_viewport_rect().size; // Windows require additional padding to keep the window chrome visible. - Ref<StyleBoxTexture> panel = get_stylebox("panel", "WindowDialog"); - + Ref<StyleBox> panel = get_stylebox("panel", "WindowDialog"); + float top = 0; + float left = 0; + float bottom = 0; + float right = 0; // Check validity, because the theme could contain a different type of StyleBox - if (panel.is_valid()) { - float top = panel->get_expand_margin_size(MARGIN_TOP); - float left = panel->get_expand_margin_size(MARGIN_LEFT); - float bottom = panel->get_expand_margin_size(MARGIN_BOTTOM); - float right = panel->get_expand_margin_size(MARGIN_RIGHT); - - pos.x = MAX(left, MIN(pos.x, viewport_size.x - size.x - right)); - pos.y = MAX(top, MIN(pos.y, viewport_size.y - size.y - bottom)); - set_global_position(pos); - - // Also resize the window to fit if a resize should be possible at all. - if (resizable) { - size.x = MIN(size.x, viewport_size.x - left - right); - size.y = MIN(size.y, viewport_size.y - top - bottom); - set_size(size); - } + if (panel->get_class() == "StyleBoxTexture") { + Ref<StyleBoxTexture> panel_texture = panel->cast_to<StyleBoxTexture>(); + top = panel_texture->get_expand_margin_size(MARGIN_TOP); + left = panel_texture->get_expand_margin_size(MARGIN_LEFT); + bottom = panel_texture->get_expand_margin_size(MARGIN_BOTTOM); + right = panel_texture->get_expand_margin_size(MARGIN_RIGHT); + } else if (panel->get_class() == "StyleBoxFlat") { + Ref<StyleBoxFlat> panel_flat = panel->cast_to<StyleBoxFlat>(); + top = panel_flat->_get_additional_border_size(MARGIN_TOP); + left = panel_flat->_get_additional_border_size(MARGIN_LEFT); + bottom = panel_flat->_get_additional_border_size(MARGIN_BOTTOM); + right = panel_flat->_get_additional_border_size(MARGIN_RIGHT); + } + + pos.x = MAX(left, MIN(pos.x, viewport_size.x - size.x - right)); + pos.y = MAX(top, MIN(pos.y, viewport_size.y - size.y - bottom)); + set_global_position(pos); + + if (resizable) { + size.x = MIN(size.x, viewport_size.x - left - right); + size.y = MIN(size.y, viewport_size.y - top - bottom); + set_size(size); } } @@ -200,7 +209,7 @@ void WindowDialog::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { close_button->set_normal_texture(get_icon("close", "WindowDialog")); close_button->set_pressed_texture(get_icon("close", "WindowDialog")); - close_button->set_hover_texture(get_icon("close_hilite", "WindowDialog")); + close_button->set_hover_texture(get_icon("close_highlight", "WindowDialog")); close_button->set_anchor(MARGIN_LEFT, ANCHOR_END); close_button->set_begin(Point2(get_constant("close_h_ofs", "WindowDialog"), -get_constant("close_v_ofs", "WindowDialog"))); } break; diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 6475371eb9..bf44493b51 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -151,24 +151,24 @@ void ScrollBar::_gui_input(InputEvent p_event) { double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width(); double total = orientation == VERTICAL ? get_size().height : get_size().width; - HiliteStatus new_hilite; + HighlightStatus new_highlight; if (ofs < decr_size) { - new_hilite = HILITE_DECR; + new_highlight = HIGHLIGHT_DECR; } else if (ofs > total - incr_size) { - new_hilite = HILITE_INCR; + new_highlight = HIGHLIGHT_INCR; } else { - new_hilite = HILITE_RANGE; + new_highlight = HIGHLIGHT_RANGE; } - if (new_hilite != hilite) { + if (new_highlight != highlight) { - hilite = new_hilite; + highlight = new_highlight; update(); } } @@ -233,10 +233,10 @@ void ScrollBar::_notification(int p_what) { RID ci = get_canvas_item(); - Ref<Texture> decr = hilite == HILITE_DECR ? get_icon("decrement_hilite") : get_icon("decrement"); - Ref<Texture> incr = hilite == HILITE_INCR ? get_icon("increment_hilite") : get_icon("increment"); + Ref<Texture> decr = highlight == HIGHLIGHT_DECR ? get_icon("decrement_highlight") : get_icon("decrement"); + Ref<Texture> incr = highlight == HIGHLIGHT_INCR ? get_icon("increment_highlight") : get_icon("increment"); Ref<StyleBox> bg = has_focus() ? get_stylebox("scroll_focus") : get_stylebox("scroll"); - Ref<StyleBox> grabber = (drag.active || hilite == HILITE_RANGE) ? get_stylebox("grabber_hilite") : get_stylebox("grabber"); + Ref<StyleBox> grabber = (drag.active || highlight == HIGHLIGHT_RANGE) ? get_stylebox("grabber_highlight") : get_stylebox("grabber"); Point2 ofs; @@ -386,7 +386,7 @@ void ScrollBar::_notification(int p_what) { if (p_what == NOTIFICATION_MOUSE_EXIT) { - hilite = HILITE_NONE; + highlight = HIGHLIGHT_NONE; update(); } } @@ -784,7 +784,7 @@ void ScrollBar::_bind_methods() { ScrollBar::ScrollBar(Orientation p_orientation) { orientation = p_orientation; - hilite = HILITE_NONE; + highlight = HIGHLIGHT_NONE; custom_step = -1; drag_slave = NULL; diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h index 9f035b4901..cb6bf227a0 100644 --- a/scene/gui/scroll_bar.h +++ b/scene/gui/scroll_bar.h @@ -39,11 +39,11 @@ class ScrollBar : public Range { GDCLASS(ScrollBar, Range); - enum HiliteStatus { - HILITE_NONE, - HILITE_DECR, - HILITE_RANGE, - HILITE_INCR, + enum HighlightStatus { + HIGHLIGHT_NONE, + HIGHLIGHT_DECR, + HIGHLIGHT_RANGE, + HIGHLIGHT_INCR, }; static bool focus_by_default; @@ -52,7 +52,7 @@ class ScrollBar : public Range { Size2 size; float custom_step; - HiliteStatus hilite; + HighlightStatus highlight; struct Drag { diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index d2a2ff7966..ae52d6d452 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -45,7 +45,7 @@ void Slider::_gui_input(InputEvent p_event) { if (mb.button_index == BUTTON_LEFT) { if (mb.pressed) { - Ref<Texture> grabber = get_icon(mouse_inside || has_focus() ? "grabber_hilite" : "grabber"); + Ref<Texture> grabber = get_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber"); grab.pos = orientation == VERTICAL ? mb.y : mb.x; double grab_width = (double)grabber->get_size().width; double grab_height = (double)grabber->get_size().height; @@ -153,7 +153,7 @@ void Slider::_notification(int p_what) { Size2i size = get_size(); Ref<StyleBox> style = get_stylebox("slider"); Ref<StyleBox> focus = get_stylebox("focus"); - Ref<Texture> grabber = get_icon(mouse_inside || has_focus() ? "grabber_hilite" : "grabber"); + Ref<Texture> grabber = get_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber"); Ref<Texture> tick = get_icon("tick"); if (orientation == VERTICAL) { diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index fb27f3b017..797082f17c 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -85,7 +85,7 @@ void Tabs::_gui_input(const InputEvent &p_event) { Point2 pos(p_event.mouse_motion.x, p_event.mouse_motion.y); - hilite_arrow = -1; + highlight_arrow = -1; if (buttons_visible) { Ref<Texture> incr = get_icon("increment"); @@ -94,9 +94,9 @@ void Tabs::_gui_input(const InputEvent &p_event) { int limit = get_size().width - incr->get_width() - decr->get_width(); if (pos.x > limit + decr->get_width()) { - hilite_arrow = 1; + highlight_arrow = 1; } else if (pos.x > limit) { - hilite_arrow = 0; + highlight_arrow = 0; } } @@ -268,8 +268,8 @@ void Tabs::_notification(int p_what) { Ref<Texture> incr = get_icon("increment"); Ref<Texture> decr = get_icon("decrement"); - Ref<Texture> incr_hl = get_icon("increment_hilite"); - Ref<Texture> decr_hl = get_icon("decrement_hilite"); + Ref<Texture> incr_hl = get_icon("increment_highlight"); + Ref<Texture> decr_hl = get_icon("decrement_highlight"); int limit = get_size().width - incr->get_size().width - decr->get_size().width; @@ -385,12 +385,12 @@ void Tabs::_notification(int p_what) { int vofs = (get_size().height - incr->get_size().height) / 2; if (offset > 0) - draw_texture(hilite_arrow == 0 ? decr_hl : decr, Point2(limit, vofs)); + draw_texture(highlight_arrow == 0 ? decr_hl : decr, Point2(limit, vofs)); else draw_texture(decr, Point2(limit, vofs), Color(1, 1, 1, 0.5)); if (missing_right) - draw_texture(hilite_arrow == 1 ? incr_hl : incr, Point2(limit + decr->get_size().width, vofs)); + draw_texture(highlight_arrow == 1 ? incr_hl : incr, Point2(limit + decr->get_size().width, vofs)); else draw_texture(incr, Point2(limit + decr->get_size().width, vofs), Color(1, 1, 1, 0.5)); @@ -677,7 +677,7 @@ Tabs::Tabs() { tab_align = ALIGN_CENTER; rb_hover = -1; rb_pressing = false; - hilite_arrow = -1; + highlight_arrow = -1; cb_hover = -1; cb_pressing = false; diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index 2392327206..131526f298 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -69,7 +69,7 @@ private: int offset; int max_drawn_tab; - int hilite_arrow; + int highlight_arrow; bool buttons_visible; bool missing_right; Vector<Tab> tabs; |