diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-01-23 07:55:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-23 07:55:24 +0100 |
commit | 5ec3b5f2c9b3640aef2f3374a93cc0db3df9903a (patch) | |
tree | 80f2f74916ba554749322b5fe0c9b464c669bb7a /scene/gui | |
parent | 5027799c13d9b38b55b2184bca997632339651d8 (diff) | |
parent | 2baeb531e6dc240c7c2c3f176888c4d09715b56d (diff) |
Merge pull request #7604 from RayKoopa/gui_button_style_pressed
Respect style boxes for Button states other than "normal"
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/button.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index f28595b622..2d1d437668 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -74,17 +74,21 @@ void Button::_notification(int p_what) { //print_line(get_text()+": "+itos(is_flat())+" hover "+itos(get_draw_mode())); + Ref<StyleBox> style = get_stylebox("normal"); + switch( get_draw_mode() ) { case DRAW_NORMAL: { + style = get_stylebox("normal"); if (!flat) - get_stylebox("normal" )->draw( ci, Rect2(Point2(0,0), size) ); + style->draw( ci, Rect2(Point2(0,0), size) ); color=get_color("font_color"); } break; case DRAW_PRESSED: { - get_stylebox("pressed" )->draw( ci, Rect2(Point2(0,0), size) ); + style = get_stylebox("pressed"); + style->draw( ci, Rect2(Point2(0,0), size) ); if (has_color("font_color_pressed")) color=get_color("font_color_pressed"); else @@ -93,13 +97,15 @@ void Button::_notification(int p_what) { } break; case DRAW_HOVER: { - get_stylebox("hover" )->draw( ci, Rect2(Point2(0,0), size) ); + style = get_stylebox("hover"); + style->draw( ci, Rect2(Point2(0,0), size) ); color=get_color("font_color_hover"); } break; case DRAW_DISABLED: { - get_stylebox("disabled" )->draw( ci, Rect2(Point2(0,0), size) ); + style = get_stylebox("disabled"); + style->draw( ci, Rect2(Point2(0,0), size) ); color=get_color("font_color_disabled"); } break; @@ -111,7 +117,6 @@ void Button::_notification(int p_what) { style->draw(ci,Rect2(Point2(),size)); } - Ref<StyleBox> style = get_stylebox("normal" ); Ref<Font> font=get_font("font"); Ref<Texture> _icon; if (icon.is_null() && has_icon("icon")) |