summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorPoommetee Ketson <poommetee@protonmail.com>2017-07-22 23:15:31 +0700
committerPoommetee Ketson <poommetee@protonmail.com>2017-07-23 16:12:19 +0700
commit3ec47b4c6e0edd87819de589529e107690bc175f (patch)
treea98c293f9edcee2d4bdf9dac407b17e6adb89cd4 /scene
parent8495acc510e54c0d148b9d97c3f78f22ce16fa15 (diff)
Tabs: expose tab_close_display_policy property
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/tabs.cpp13
-rw-r--r--scene/gui/tabs.h6
2 files changed, 18 insertions, 1 deletions
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index ee0ae1fb41..c477a3156f 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -630,6 +630,7 @@ int Tabs::get_tab_idx_at_point(const Point2 &p_point) const {
void Tabs::set_tab_align(TabAlign p_align) {
+ ERR_FAIL_INDEX(p_align, ALIGN_MAX);
tab_align = p_align;
update();
}
@@ -764,10 +765,17 @@ Rect2 Tabs::get_tab_rect(int p_tab) const {
}
void Tabs::set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy) {
+
+ ERR_FAIL_INDEX(p_policy, CLOSE_BUTTON_MAX);
cb_displaypolicy = p_policy;
update();
}
+Tabs::CloseButtonDisplayPolicy Tabs::get_tab_close_display_policy() const {
+
+ return cb_displaypolicy;
+}
+
void Tabs::set_min_width(int p_width) {
min_width = p_width;
}
@@ -791,6 +799,8 @@ void Tabs::_bind_methods() {
ClassDB::bind_method(D_METHOD("ensure_tab_visible", "idx"), &Tabs::ensure_tab_visible);
ClassDB::bind_method(D_METHOD("get_tab_rect", "tab_idx"), &Tabs::get_tab_rect);
ClassDB::bind_method(D_METHOD("move_tab", "from", "to"), &Tabs::move_tab);
+ ClassDB::bind_method(D_METHOD("set_tab_close_display_policy", "policy"), &Tabs::set_tab_close_display_policy);
+ ClassDB::bind_method(D_METHOD("get_tab_close_display_policy"), &Tabs::get_tab_close_display_policy);
ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("right_button_pressed", PropertyInfo(Variant::INT, "tab")));
@@ -799,14 +809,17 @@ void Tabs::_bind_methods() {
ADD_SIGNAL(MethodInfo("reposition_active_tab_request", PropertyInfo(Variant::INT, "idx_to")));
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE, "-1,4096,1", PROPERTY_USAGE_EDITOR), "set_current_tab", "get_current_tab");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "tab_close_display_policy", PROPERTY_HINT_ENUM, "Show Never,Show Active Only,Show Always"), "set_tab_close_display_policy", "get_tab_close_display_policy");
BIND_CONSTANT(ALIGN_LEFT);
BIND_CONSTANT(ALIGN_CENTER);
BIND_CONSTANT(ALIGN_RIGHT);
+ BIND_CONSTANT(ALIGN_MAX);
BIND_CONSTANT(CLOSE_BUTTON_SHOW_ACTIVE_ONLY);
BIND_CONSTANT(CLOSE_BUTTON_SHOW_ALWAYS);
BIND_CONSTANT(CLOSE_BUTTON_SHOW_NEVER);
+ BIND_CONSTANT(CLOSE_BUTTON_MAX);
}
Tabs::Tabs() {
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index a9dd6bddd7..86ad128dcd 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -41,7 +41,8 @@ public:
ALIGN_LEFT,
ALIGN_CENTER,
- ALIGN_RIGHT
+ ALIGN_RIGHT,
+ ALIGN_MAX
};
enum CloseButtonDisplayPolicy {
@@ -49,6 +50,7 @@ public:
CLOSE_BUTTON_SHOW_NEVER,
CLOSE_BUTTON_SHOW_ACTIVE_ONLY,
CLOSE_BUTTON_SHOW_ALWAYS,
+ CLOSE_BUTTON_MAX
};
private:
@@ -122,6 +124,7 @@ public:
void move_tab(int from, int to);
void set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy);
+ CloseButtonDisplayPolicy get_tab_close_display_policy() const;
int get_tab_count() const;
void set_current_tab(int p_current);
@@ -142,5 +145,6 @@ public:
};
VARIANT_ENUM_CAST(Tabs::TabAlign);
+VARIANT_ENUM_CAST(Tabs::CloseButtonDisplayPolicy);
#endif // TABS_H