diff options
Diffstat (limited to 'scene/gui/control.cpp')
-rw-r--r-- | scene/gui/control.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 0ca04faf9b..4510de32a0 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1734,6 +1734,10 @@ void Control::_size_changed() { if (pos_changed && !size_changed) { _update_canvas_item_transform(); //move because it won't be updated } + } else { + if (pos_changed) { + _notify_transform(); + } } } @@ -2444,6 +2448,7 @@ void Control::_invalidate_theme_cache() { } void Control::_update_theme_item_cache() { + ThemeDB::get_singleton()->update_class_instance_items(this); } void Control::set_theme_owner_node(Node *p_node) { @@ -2461,6 +2466,11 @@ bool Control::has_theme_owner_node() const { return data.theme_owner->has_owner_node(); } +void Control::set_theme_context(ThemeContext *p_context, bool p_propagate) { + ERR_MAIN_THREAD_GUARD; + data.theme_owner->set_owner_context(p_context, p_propagate); +} + void Control::set_theme(const Ref<Theme> &p_theme) { ERR_MAIN_THREAD_GUARD; if (data.theme == p_theme) { @@ -2660,6 +2670,33 @@ int Control::get_theme_constant(const StringName &p_name, const StringName &p_th return constant; } +Variant Control::get_theme_item(Theme::DataType p_data_type, const StringName &p_name, const StringName &p_theme_type) const { + switch (p_data_type) { + case Theme::DATA_TYPE_COLOR: + return get_theme_color(p_name, p_theme_type); + case Theme::DATA_TYPE_CONSTANT: + return get_theme_constant(p_name, p_theme_type); + case Theme::DATA_TYPE_FONT: + return get_theme_font(p_name, p_theme_type); + case Theme::DATA_TYPE_FONT_SIZE: + return get_theme_font_size(p_name, p_theme_type); + case Theme::DATA_TYPE_ICON: + return get_theme_icon(p_name, p_theme_type); + case Theme::DATA_TYPE_STYLEBOX: + return get_theme_stylebox(p_name, p_theme_type); + case Theme::DATA_TYPE_MAX: + break; // Can't happen, but silences warning. + } + + return Variant(); +} + +#ifdef TOOLS_ENABLED +Ref<Texture2D> Control::get_editor_theme_icon(const StringName &p_name) const { + return get_theme_icon(p_name, SNAME("EditorIcons")); +} +#endif + bool Control::has_theme_icon(const StringName &p_name, const StringName &p_theme_type) const { ERR_READ_THREAD_GUARD_V(false); if (!data.initialized) { @@ -3114,7 +3151,9 @@ void Control::_notification(int p_notification) { notification(NOTIFICATION_TRANSLATION_CHANGED); } #endif - notification(NOTIFICATION_THEME_CHANGED); + + // Emits NOTIFICATION_THEME_CHANGED internally. + set_theme_context(ThemeDB::get_singleton()->get_nearest_theme_context(this)); } break; case NOTIFICATION_POST_ENTER_TREE: { @@ -3124,6 +3163,7 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_EXIT_TREE: { + set_theme_context(nullptr, false); release_focus(); get_viewport()->_gui_remove_control(this); } break; @@ -3622,7 +3662,7 @@ void Control::_bind_methods() { } Control::Control() { - data.theme_owner = memnew(ThemeOwner); + data.theme_owner = memnew(ThemeOwner(this)); } Control::~Control() { |