diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-01-05 10:57:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-05 10:57:53 +0100 |
commit | 8eb1d2034686cdfcbd8f8577a2099251ac6f6600 (patch) | |
tree | f92ba6132e8096edc6773aeca89542b29c8b2159 | |
parent | 319c442771f356cb6aab8a09fe59399e71d32818 (diff) | |
parent | a7a41a3431bd4fa4282d5c22990a318bd0909896 (diff) |
Merge pull request #56206 from KoBeWi/random_call_deferred_to_the_rescue_once_again
-rw-r--r-- | scene/gui/tab_container.cpp | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index e5614ff728..c3fc08731e 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -703,30 +703,16 @@ void TabContainer::add_child_notify(Node *p_child) { return; } - Vector<Control *> tabs = _get_tabs(); _refresh_texts(); + call_deferred("_repaint"); + update(); - bool first = false; - - if (tabs.size() != 1) { - c->hide(); - } else { - c->show(); - //call_deferred(SNAME("set_current_tab"),0); - first = true; + bool first = (_get_tabs().size() == 1); + if (first) { current = 0; previous = 0; } - c->set_anchors_and_offsets_preset(Control::PRESET_WIDE); - if (tabs_visible) { - c->set_offset(SIDE_TOP, _get_top_margin()); - } - Ref<StyleBox> sb = get_theme_stylebox(SNAME("panel")); - c->set_offset(SIDE_TOP, c->get_offset(SIDE_TOP) + sb->get_margin(SIDE_TOP)); - c->set_offset(SIDE_LEFT, c->get_offset(SIDE_LEFT) + sb->get_margin(SIDE_LEFT)); - c->set_offset(SIDE_RIGHT, c->get_offset(SIDE_RIGHT) - sb->get_margin(SIDE_RIGHT)); - c->set_offset(SIDE_BOTTOM, c->get_offset(SIDE_BOTTOM) - sb->get_margin(SIDE_BOTTOM)); - update(); + p_child->connect("renamed", callable_mp(this, &TabContainer::_child_renamed_callback)); if (first && is_inside_tree()) { emit_signal(SNAME("tab_changed"), current); @@ -1223,6 +1209,7 @@ void TabContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_use_hidden_tabs_for_min_size", "enabled"), &TabContainer::set_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("_repaint"), &TabContainer::_repaint); ClassDB::bind_method(D_METHOD("_on_theme_changed"), &TabContainer::_on_theme_changed); ClassDB::bind_method(D_METHOD("_update_current_tab"), &TabContainer::_update_current_tab); |