summaryrefslogtreecommitdiffstats
path: root/scene/gui/tab_bar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/tab_bar.cpp')
-rw-r--r--scene/gui/tab_bar.cpp61
1 files changed, 9 insertions, 52 deletions
diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp
index d20fef8164..2d687eb201 100644
--- a/scene/gui/tab_bar.cpp
+++ b/scene/gui/tab_bar.cpp
@@ -1720,58 +1720,6 @@ bool TabBar::get_deselect_enabled() const {
return deselect_enabled;
}
-bool TabBar::_set(const StringName &p_name, const Variant &p_value) {
- Vector<String> components = String(p_name).split("/", true, 2);
- if (components.size() >= 2 && components[0].begins_with("tab_") && components[0].trim_prefix("tab_").is_valid_int()) {
- int tab_index = components[0].trim_prefix("tab_").to_int();
- const String &property = components[1];
- if (property == "title") {
- set_tab_title(tab_index, p_value);
- return true;
- } else if (property == "icon") {
- set_tab_icon(tab_index, p_value);
- return true;
- } else if (property == "disabled") {
- set_tab_disabled(tab_index, p_value);
- return true;
- }
- }
- return false;
-}
-
-bool TabBar::_get(const StringName &p_name, Variant &r_ret) const {
- Vector<String> components = String(p_name).split("/", true, 2);
- if (components.size() >= 2 && components[0].begins_with("tab_") && components[0].trim_prefix("tab_").is_valid_int()) {
- int tab_index = components[0].trim_prefix("tab_").to_int();
- const String &property = components[1];
- if (property == "title") {
- r_ret = get_tab_title(tab_index);
- return true;
- } else if (property == "icon") {
- r_ret = get_tab_icon(tab_index);
- return true;
- } else if (property == "disabled") {
- r_ret = is_tab_disabled(tab_index);
- return true;
- }
- }
- return false;
-}
-
-void TabBar::_get_property_list(List<PropertyInfo> *p_list) const {
- for (int i = 0; i < tabs.size(); i++) {
- p_list->push_back(PropertyInfo(Variant::STRING, vformat("tab_%d/title", i)));
-
- PropertyInfo pi = PropertyInfo(Variant::OBJECT, vformat("tab_%d/icon", i), PROPERTY_HINT_RESOURCE_TYPE, "Texture2D");
- pi.usage &= ~(get_tab_icon(i).is_null() ? PROPERTY_USAGE_STORAGE : 0);
- p_list->push_back(pi);
-
- pi = PropertyInfo(Variant::BOOL, vformat("tab_%d/disabled", i));
- pi.usage &= ~(!is_tab_disabled(i) ? PROPERTY_USAGE_STORAGE : 0);
- p_list->push_back(pi);
- }
-}
-
void TabBar::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_tab_count", "count"), &TabBar::set_tab_count);
ClassDB::bind_method(D_METHOD("get_tab_count"), &TabBar::get_tab_count);
@@ -1890,10 +1838,19 @@ void TabBar::_bind_methods() {
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_ICON, TabBar, close_icon, "close");
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TabBar, button_pressed_style, "button_pressed");
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, TabBar, button_hl_style, "button_highlight");
+
+ Tab defaults(true);
+
+ base_property_helper.set_prefix("tab_");
+ base_property_helper.register_property(PropertyInfo(Variant::STRING, "title"), defaults.text, &TabBar::set_tab_title, &TabBar::get_tab_title);
+ base_property_helper.register_property(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), defaults.icon, &TabBar::set_tab_icon, &TabBar::get_tab_icon);
+ base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled, &TabBar::set_tab_disabled, &TabBar::is_tab_disabled);
}
TabBar::TabBar() {
set_size(Size2(get_size().width, get_minimum_size().height));
set_focus_mode(FOCUS_ALL);
connect("mouse_exited", callable_mp(this, &TabBar::_on_mouse_exited));
+
+ property_helper.setup_for_instance(base_property_helper, this);
}