From 98f01f914333eb5e70174c4adf4a5f910a38d645 Mon Sep 17 00:00:00 2001 From: Ray Koopa Date: Sat, 21 Jan 2017 23:00:59 +0100 Subject: [PATCH] Respect style boxes for Button states other than "normal" (cherry picked from commit 2baeb531e6dc240c7c2c3f176888c4d09715b56d) --- scene/gui/button.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 6c0bcc79475..8bdf21f85e5 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -67,17 +67,21 @@ void Button::_notification(int p_what) { //print_line(get_text()+": "+itos(is_flat())+" hover "+itos(get_draw_mode())); + Ref 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 @@ -86,13 +90,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; @@ -104,7 +110,6 @@ void Button::_notification(int p_what) { style->draw(ci,Rect2(Point2(),size)); } - Ref style = get_stylebox("normal" ); Ref font=get_font("font"); Ref _icon; if (icon.is_null() && has_icon("icon"))