|
@@ -414,8 +414,9 @@ void TabContainer::add_child_notify(Node *p_child) {
|
|
|
else {
|
|
|
c->show();
|
|
|
//call_deferred("set_current_tab",0);
|
|
|
- first=true;
|
|
|
- current=0;
|
|
|
+ first = true;
|
|
|
+ current = 0;
|
|
|
+ previous = 0;
|
|
|
}
|
|
|
c->set_area_as_parent_rect();
|
|
|
if (tabs_visible)
|
|
@@ -451,7 +452,8 @@ void TabContainer::set_current_tab(int p_current) {
|
|
|
|
|
|
ERR_FAIL_INDEX( p_current, get_tab_count() );
|
|
|
|
|
|
- current=p_current;
|
|
|
+ int pending_previous = current;
|
|
|
+ current = p_current;
|
|
|
|
|
|
int idx=0;
|
|
|
|
|
@@ -478,7 +480,13 @@ void TabContainer::set_current_tab(int p_current) {
|
|
|
}
|
|
|
|
|
|
_change_notify("current_tab");
|
|
|
- emit_signal("tab_changed",current);
|
|
|
+
|
|
|
+ if (pending_previous != current)
|
|
|
+ previous = pending_previous;
|
|
|
+
|
|
|
+ emit_signal("tab_selected", current);
|
|
|
+ emit_signal("tab_changed", current);
|
|
|
+
|
|
|
update();
|
|
|
}
|
|
|
|
|
@@ -487,6 +495,11 @@ int TabContainer::get_current_tab() const {
|
|
|
return current;
|
|
|
}
|
|
|
|
|
|
+int TabContainer::get_previous_tab() const {
|
|
|
+
|
|
|
+ return previous;
|
|
|
+}
|
|
|
+
|
|
|
Control* TabContainer::get_tab_control(int p_idx) const {
|
|
|
|
|
|
int idx=0;
|
|
@@ -508,6 +521,7 @@ Control* TabContainer::get_tab_control(int p_idx) const {
|
|
|
|
|
|
return NULL;
|
|
|
}
|
|
|
+
|
|
|
Control* TabContainer::get_current_tab_control() const {
|
|
|
|
|
|
int idx=0;
|
|
@@ -555,6 +569,7 @@ void TabContainer::set_tab_align(TabAlign p_align) {
|
|
|
|
|
|
_change_notify("tab_align");
|
|
|
}
|
|
|
+
|
|
|
TabContainer::TabAlign TabContainer::get_tab_align() const {
|
|
|
|
|
|
return align;
|
|
@@ -711,26 +726,28 @@ Popup* TabContainer::get_popup() const {
|
|
|
|
|
|
void TabContainer::_bind_methods() {
|
|
|
|
|
|
- ObjectTypeDB::bind_method(_MD("_input_event"),&TabContainer::_input_event);
|
|
|
- ObjectTypeDB::bind_method(_MD("get_tab_count"),&TabContainer::get_tab_count);
|
|
|
- ObjectTypeDB::bind_method(_MD("set_current_tab","tab_idx"),&TabContainer::set_current_tab);
|
|
|
- ObjectTypeDB::bind_method(_MD("get_current_tab"),&TabContainer::get_current_tab);
|
|
|
- ObjectTypeDB::bind_method(_MD("get_current_tab_control:Control"),&TabContainer::get_current_tab_control);
|
|
|
- ObjectTypeDB::bind_method(_MD("get_tab_control:Control","idx"),&TabContainer::get_tab_control);
|
|
|
- ObjectTypeDB::bind_method(_MD("set_tab_align","align"),&TabContainer::set_tab_align);
|
|
|
- ObjectTypeDB::bind_method(_MD("get_tab_align"),&TabContainer::get_tab_align);
|
|
|
- ObjectTypeDB::bind_method(_MD("set_tabs_visible","visible"),&TabContainer::set_tabs_visible);
|
|
|
- ObjectTypeDB::bind_method(_MD("are_tabs_visible"),&TabContainer::are_tabs_visible);
|
|
|
- ObjectTypeDB::bind_method(_MD("set_tab_title","tab_idx","title"),&TabContainer::set_tab_title);
|
|
|
- ObjectTypeDB::bind_method(_MD("get_tab_title","tab_idx"),&TabContainer::get_tab_title);
|
|
|
- ObjectTypeDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&TabContainer::set_tab_icon);
|
|
|
- ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&TabContainer::get_tab_icon);
|
|
|
- ObjectTypeDB::bind_method(_MD("set_popup","popup:Popup"),&TabContainer::set_popup);
|
|
|
- ObjectTypeDB::bind_method(_MD("get_popup:Popup"),&TabContainer::get_popup);
|
|
|
-
|
|
|
- ObjectTypeDB::bind_method(_MD("_child_renamed_callback"),&TabContainer::_child_renamed_callback);
|
|
|
-
|
|
|
- ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab")));
|
|
|
+ ObjectTypeDB::bind_method(_MD("_input_event"), &TabContainer::_input_event);
|
|
|
+ ObjectTypeDB::bind_method(_MD("get_tab_count"), &TabContainer::get_tab_count);
|
|
|
+ ObjectTypeDB::bind_method(_MD("set_current_tab","tab_idx"), &TabContainer::set_current_tab);
|
|
|
+ ObjectTypeDB::bind_method(_MD("get_current_tab"), &TabContainer::get_current_tab);
|
|
|
+ ObjectTypeDB::bind_method(_MD("get_previous_tab"), &TabContainer::get_previous_tab);
|
|
|
+ ObjectTypeDB::bind_method(_MD("get_current_tab_control:Control"), &TabContainer::get_current_tab_control);
|
|
|
+ ObjectTypeDB::bind_method(_MD("get_tab_control:Control","idx"), &TabContainer::get_tab_control);
|
|
|
+ ObjectTypeDB::bind_method(_MD("set_tab_align","align"), &TabContainer::set_tab_align);
|
|
|
+ ObjectTypeDB::bind_method(_MD("get_tab_align"), &TabContainer::get_tab_align);
|
|
|
+ ObjectTypeDB::bind_method(_MD("set_tabs_visible","visible"), &TabContainer::set_tabs_visible);
|
|
|
+ ObjectTypeDB::bind_method(_MD("are_tabs_visible"), &TabContainer::are_tabs_visible);
|
|
|
+ ObjectTypeDB::bind_method(_MD("set_tab_title","tab_idx","title"), &TabContainer::set_tab_title);
|
|
|
+ ObjectTypeDB::bind_method(_MD("get_tab_title","tab_idx"), &TabContainer::get_tab_title);
|
|
|
+ ObjectTypeDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"), &TabContainer::set_tab_icon);
|
|
|
+ ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"), &TabContainer::get_tab_icon);
|
|
|
+ ObjectTypeDB::bind_method(_MD("set_popup","popup:Popup"), &TabContainer::set_popup);
|
|
|
+ ObjectTypeDB::bind_method(_MD("get_popup:Popup"), &TabContainer::get_popup);
|
|
|
+
|
|
|
+ ObjectTypeDB::bind_method(_MD("_child_renamed_callback"), &TabContainer::_child_renamed_callback);
|
|
|
+
|
|
|
+ ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab")));
|
|
|
+ ADD_SIGNAL(MethodInfo("tab_selected", PropertyInfo(Variant::INT, "tab")));
|
|
|
ADD_SIGNAL(MethodInfo("pre_popup_pressed"));
|
|
|
|
|
|
ADD_PROPERTY( PropertyInfo(Variant::INT, "tab_align", PROPERTY_HINT_ENUM,"Left,Center,Right"), _SCS("set_tab_align"), _SCS("get_tab_align") );
|
|
@@ -741,13 +758,14 @@ void TabContainer::_bind_methods() {
|
|
|
|
|
|
TabContainer::TabContainer() {
|
|
|
|
|
|
- tab_display_ofs=0;
|
|
|
- buttons_visible_cache=false;
|
|
|
- tabs_ofs_cache=0;
|
|
|
- current=0;
|
|
|
- mouse_x_cache=0;
|
|
|
- align=ALIGN_CENTER;
|
|
|
- tabs_visible=true;
|
|
|
- popup=NULL;
|
|
|
+ tab_display_ofs = 0;
|
|
|
+ buttons_visible_cache = false;
|
|
|
+ tabs_ofs_cache = 0;
|
|
|
+ current = 0;
|
|
|
+ previous = 0;
|
|
|
+ mouse_x_cache = 0;
|
|
|
+ align = ALIGN_CENTER;
|
|
|
+ tabs_visible = true;
|
|
|
+ popup = NULL;
|
|
|
|
|
|
}
|