summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-07-18 18:12:26 +0200
committerGitHub <noreply@github.com>2017-07-18 18:12:26 +0200
commit1bed4c6783ddf55efc16ad640d64eff11c67af27 (patch)
tree97bcf226528817ad8781588dedb2b5e09634265f /scene
parent0afa77a8a2e148fac6b57fab3e85c6e631e12c63 (diff)
parentb5de36b29d1c7a9535e733caf4f2bab73e18f8d2 (diff)
Merge pull request #9629 from kubecz3k/tabs-addons
Tabs enhancements: get_tab_rect(), move_tab()
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/tabs.cpp18
-rw-r--r--scene/gui/tabs.h2
2 files changed, 20 insertions, 0 deletions
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 4316f06a53..ee0ae1fb41 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -639,6 +639,22 @@ Tabs::TabAlign Tabs::get_tab_align() const {
return tab_align;
}
+void Tabs::move_tab(int from, int to) {
+
+ if (from == to)
+ return;
+
+ ERR_FAIL_INDEX(from, tabs.size());
+ ERR_FAIL_INDEX(to, tabs.size());
+
+ Tab tab_from = tabs[from];
+ tabs.remove(from);
+ tabs.insert(to, tab_from);
+
+ _update_cache();
+ update();
+}
+
int Tabs::get_tab_width(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, tabs.size(), 0);
@@ -773,6 +789,8 @@ void Tabs::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_tab_align", "align"), &Tabs::set_tab_align);
ClassDB::bind_method(D_METHOD("get_tab_align"), &Tabs::get_tab_align);
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);
ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("right_button_pressed", PropertyInfo(Variant::INT, "tab")));
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index 613c604b12..a9dd6bddd7 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -119,6 +119,8 @@ public:
void set_tab_align(TabAlign p_align);
TabAlign get_tab_align() const;
+ void move_tab(int from, int to);
+
void set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy);
int get_tab_count() const;