diff options
author | Yuri Sizov <yuris@humnom.net> | 2022-09-02 17:45:09 +0300 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2022-09-02 23:44:23 +0300 |
commit | 8b128081e82b41f1ea5d7799236f17e6f2c1d087 (patch) | |
tree | 6f232a809d623c0cf89cd0940a29e5758cc90837 /scene/gui/control.cpp | |
parent | ddc55ef746e6778b902aa2ebeaf09d9b8d9943b5 (diff) |
Un-defer the initial theme changed notification
Co-authored-by: Rindbee <idleman@yeah.net>
Diffstat (limited to 'scene/gui/control.cpp')
-rw-r--r-- | scene/gui/control.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 6a4b61fad0..d6251872c0 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2789,21 +2789,6 @@ Control *Control::make_custom_tooltip(const String &p_text) const { // Base object overrides. -void Control::add_child_notify(Node *p_child) { - // We propagate when this node uses a custom theme, so it can pass it on to its children. - if (has_theme_owner_node()) { - // `p_notify` is false here as `NOTIFICATION_THEME_CHANGED` will be handled by `NOTIFICATION_ENTER_TREE`. - data.theme_owner->propagate_theme_changed(p_child, get_theme_owner_node(), false, true); - } -} - -void Control::remove_child_notify(Node *p_child) { - // If the removed child isn't inheriting any theme items through this node, then there's no need to propagate. - if (has_theme_owner_node()) { - data.theme_owner->propagate_theme_changed(p_child, nullptr, false, true); - } -} - void Control::_notification(int p_notification) { switch (p_notification) { case NOTIFICATION_POSTINITIALIZE: { @@ -2811,10 +2796,16 @@ void Control::_notification(int p_notification) { _update_theme_item_cache(); } break; + case NOTIFICATION_PARENTED: { + data.theme_owner->assign_theme_on_parented(this); + } break; + + case NOTIFICATION_UNPARENTED: { + data.theme_owner->clear_theme_on_unparented(this); + } break; + case NOTIFICATION_ENTER_TREE: { - // Need to defer here, because theme owner information might be set in - // add_child_notify, which doesn't get called until right after this. - call_deferred(SNAME("notification"), NOTIFICATION_THEME_CHANGED); + notification(NOTIFICATION_THEME_CHANGED); } break; case NOTIFICATION_POST_ENTER_TREE: { |