summaryrefslogtreecommitdiffstats
path: root/scene/gui/option_button.cpp
diff options
context:
space:
mode:
authorYuri Sizov <yuris@humnom.net>2023-09-08 21:00:10 +0200
committerYuri Sizov <yuris@humnom.net>2023-09-11 13:45:23 +0200
commit2924bfd4d3c6dbdf01df3263000070634826f0a9 (patch)
tree779d2aa57557af3c2fe2828e6a3a570a32e7a61b /scene/gui/option_button.cpp
parent8c1817f755b63a69378774d8d0f74499f663afe2 (diff)
downloadredot-engine-2924bfd4d3c6dbdf01df3263000070634826f0a9.tar.gz
Register theme properties with ThemeDB
Diffstat (limited to 'scene/gui/option_button.cpp')
-rw-r--r--scene/gui/option_button.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index a260385a46..f9740b1217 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -32,6 +32,7 @@
#include "core/os/keyboard.h"
#include "core/string/print_string.h"
+#include "scene/theme/theme_db.h"
static const int NONE_SELECTED = -1;
@@ -72,25 +73,6 @@ Size2 OptionButton::get_minimum_size() const {
return minsize;
}
-void OptionButton::_update_theme_item_cache() {
- Button::_update_theme_item_cache();
-
- theme_cache.normal = get_theme_stylebox(SNAME("normal"));
-
- theme_cache.font_color = get_theme_color(SNAME("font_color"));
- theme_cache.font_focus_color = get_theme_color(SNAME("font_focus_color"));
- theme_cache.font_pressed_color = get_theme_color(SNAME("font_pressed_color"));
- theme_cache.font_hover_color = get_theme_color(SNAME("font_hover_color"));
- theme_cache.font_hover_pressed_color = get_theme_color(SNAME("font_hover_pressed_color"));
- theme_cache.font_disabled_color = get_theme_color(SNAME("font_disabled_color"));
-
- theme_cache.h_separation = get_theme_constant(SNAME("h_separation"));
-
- theme_cache.arrow_icon = get_theme_icon(SNAME("arrow"));
- theme_cache.arrow_margin = get_theme_constant(SNAME("arrow_margin"));
- theme_cache.modulate_arrow = get_theme_constant(SNAME("modulate_arrow"));
-}
-
void OptionButton::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_POSTINITIALIZE: {
@@ -597,8 +579,24 @@ void OptionButton::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "selected"), "_select_int", "get_selected");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fit_to_longest_item"), "set_fit_to_longest_item", "is_fit_to_longest_item");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_reselect"), "set_allow_reselect", "get_allow_reselect");
+
ADD_SIGNAL(MethodInfo("item_selected", PropertyInfo(Variant::INT, "index")));
ADD_SIGNAL(MethodInfo("item_focused", PropertyInfo(Variant::INT, "index")));
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_STYLEBOX, OptionButton, normal);
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, OptionButton, font_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, OptionButton, font_focus_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, OptionButton, font_pressed_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, OptionButton, font_hover_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, OptionButton, font_hover_pressed_color);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, OptionButton, font_disabled_color);
+
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, OptionButton, h_separation);
+
+ BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, OptionButton, arrow_icon, "arrow");
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, OptionButton, arrow_margin);
+ BIND_THEME_ITEM(Theme::DATA_TYPE_CONSTANT, OptionButton, modulate_arrow);
}
void OptionButton::set_disable_shortcuts(bool p_disabled) {