summaryrefslogtreecommitdiff
path: root/scene/gui/button.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/button.cpp')
-rw-r--r--scene/gui/button.cpp49
1 files changed, 29 insertions, 20 deletions
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 9cdf3bf210..2932707401 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -82,13 +82,13 @@ void Button::_notification(int p_what) {
xl_text = atr(text);
_shape();
- minimum_size_changed();
+ update_minimum_size();
update();
} break;
case NOTIFICATION_THEME_CHANGED: {
_shape();
- minimum_size_changed();
+ update_minimum_size();
update();
} break;
case NOTIFICATION_DRAW: {
@@ -111,9 +111,18 @@ void Button::_notification(int p_what) {
if (!flat) {
style->draw(ci, Rect2(Point2(0, 0), size));
}
- color = get_theme_color(SNAME("font_color"));
- if (has_theme_color(SNAME("icon_normal_color"))) {
- color_icon = get_theme_color(SNAME("icon_normal_color"));
+
+ // Focus colors only take precedence over normal state.
+ if (has_focus()) {
+ color = get_theme_color(SNAME("font_focus_color"));
+ if (has_theme_color(SNAME("icon_focus_color"))) {
+ color_icon = get_theme_color(SNAME("icon_focus_color"));
+ }
+ } else {
+ color = get_theme_color(SNAME("font_color"));
+ if (has_theme_color(SNAME("icon_normal_color"))) {
+ color_icon = get_theme_color(SNAME("icon_normal_color"));
+ }
}
} break;
case DRAW_HOVER_PRESSED: {
@@ -359,7 +368,7 @@ void Button::set_text(const String &p_text) {
_shape();
update();
- minimum_size_changed();
+ update_minimum_size();
}
}
@@ -419,7 +428,7 @@ void Button::set_icon(const Ref<Texture2D> &p_icon) {
if (icon != p_icon) {
icon = p_icon;
update();
- minimum_size_changed();
+ update_minimum_size();
}
}
@@ -427,11 +436,11 @@ Ref<Texture2D> Button::get_icon() const {
return icon;
}
-void Button::set_expand_icon(bool p_expand_icon) {
- if (expand_icon != p_expand_icon) {
- expand_icon = p_expand_icon;
+void Button::set_expand_icon(bool p_enabled) {
+ if (expand_icon != p_enabled) {
+ expand_icon = p_enabled;
update();
- minimum_size_changed();
+ update_minimum_size();
}
}
@@ -439,9 +448,9 @@ bool Button::is_expand_icon() const {
return expand_icon;
}
-void Button::set_flat(bool p_flat) {
- if (flat != p_flat) {
- flat = p_flat;
+void Button::set_flat(bool p_enabled) {
+ if (flat != p_enabled) {
+ flat = p_enabled;
update();
}
}
@@ -450,11 +459,11 @@ bool Button::is_flat() const {
return flat;
}
-void Button::set_clip_text(bool p_clip_text) {
- if (clip_text != p_clip_text) {
- clip_text = p_clip_text;
+void Button::set_clip_text(bool p_enabled) {
+ if (clip_text != p_enabled) {
+ clip_text = p_enabled;
update();
- minimum_size_changed();
+ update_minimum_size();
}
}
@@ -475,7 +484,7 @@ Button::TextAlign Button::get_text_align() const {
void Button::set_icon_align(TextAlign p_align) {
icon_align = p_align;
- minimum_size_changed();
+ update_minimum_size();
update();
}
@@ -553,7 +562,7 @@ void Button::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_text_align"), &Button::get_text_align);
ClassDB::bind_method(D_METHOD("set_icon_align", "icon_align"), &Button::set_icon_align);
ClassDB::bind_method(D_METHOD("get_icon_align"), &Button::get_icon_align);
- ClassDB::bind_method(D_METHOD("set_expand_icon"), &Button::set_expand_icon);
+ ClassDB::bind_method(D_METHOD("set_expand_icon", "enabled"), &Button::set_expand_icon);
ClassDB::bind_method(D_METHOD("is_expand_icon"), &Button::is_expand_icon);
BIND_ENUM_CONSTANT(ALIGN_LEFT);