Răsfoiți Sursa

Fix TabContainer not setting layout immediately

(cherry picked from commit a7a41a3431bd4fa4282d5c22990a318bd0909896)
kobewi 3 ani în urmă
părinte
comite
347823c275
1 a modificat fișierele cu 6 adăugiri și 17 ștergeri
  1. 6 17
      scene/gui/tab_container.cpp

+ 6 - 17
scene/gui/tab_container.cpp

@@ -557,28 +557,16 @@ void TabContainer::add_child_notify(Node *p_child) {
 		return;
 		return;
 	}
 	}
 
 
-	bool first = false;
+	call_deferred("_repaint");
+	update();
 
 
-	if (get_tab_count() != 1) {
-		c->hide();
-	} else {
-		c->show();
-		//call_deferred("set_current_tab",0);
-		first = true;
+	bool first = (get_tab_count() == 1);
+
+	if (first) {
 		current = 0;
 		current = 0;
 		previous = 0;
 		previous = 0;
 	}
 	}
-	c->set_anchors_and_margins_preset(Control::PRESET_WIDE);
-	if (tabs_visible) {
-		c->set_margin(MARGIN_TOP, _get_top_margin());
-	}
-	Ref<StyleBox> sb = get_stylebox("panel");
-	c->set_margin(MARGIN_TOP, c->get_margin(MARGIN_TOP) + sb->get_margin(MARGIN_TOP));
-	c->set_margin(MARGIN_LEFT, c->get_margin(MARGIN_LEFT) + sb->get_margin(MARGIN_LEFT));
-	c->set_margin(MARGIN_RIGHT, c->get_margin(MARGIN_RIGHT) - sb->get_margin(MARGIN_RIGHT));
-	c->set_margin(MARGIN_BOTTOM, c->get_margin(MARGIN_BOTTOM) - sb->get_margin(MARGIN_BOTTOM));
 
 
-	update();
 	p_child->connect("renamed", this, "_child_renamed_callback");
 	p_child->connect("renamed", this, "_child_renamed_callback");
 	if (first) {
 	if (first) {
 		emit_signal("tab_changed", current);
 		emit_signal("tab_changed", current);
@@ -1069,6 +1057,7 @@ void TabContainer::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("get_use_hidden_tabs_for_min_size"), &TabContainer::get_use_hidden_tabs_for_min_size);
 	ClassDB::bind_method(D_METHOD("get_use_hidden_tabs_for_min_size"), &TabContainer::get_use_hidden_tabs_for_min_size);
 
 
 	ClassDB::bind_method(D_METHOD("_child_renamed_callback"), &TabContainer::_child_renamed_callback);
 	ClassDB::bind_method(D_METHOD("_child_renamed_callback"), &TabContainer::_child_renamed_callback);
+	ClassDB::bind_method(D_METHOD("_repaint"), &TabContainer::_repaint);
 	ClassDB::bind_method(D_METHOD("_on_theme_changed"), &TabContainer::_on_theme_changed);
 	ClassDB::bind_method(D_METHOD("_on_theme_changed"), &TabContainer::_on_theme_changed);
 	ClassDB::bind_method(D_METHOD("_on_mouse_exited"), &TabContainer::_on_mouse_exited);
 	ClassDB::bind_method(D_METHOD("_on_mouse_exited"), &TabContainer::_on_mouse_exited);
 	ClassDB::bind_method(D_METHOD("_update_current_tab"), &TabContainer::_update_current_tab);
 	ClassDB::bind_method(D_METHOD("_update_current_tab"), &TabContainer::_update_current_tab);