summaryrefslogtreecommitdiffstats
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/color_picker.cpp4
-rw-r--r--scene/gui/control.cpp18
-rw-r--r--scene/gui/control.h6
-rw-r--r--scene/gui/item_list.cpp7
4 files changed, 32 insertions, 3 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 3c19766ca7..2b4d5677c4 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -654,7 +654,9 @@ void ColorPicker::_text_type_toggled() {
text_is_constructor = !text_is_constructor;
if (text_is_constructor) {
text_type->set_text("");
- text_type->set_icon(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")));
+#ifdef TOOLS_ENABLED
+ text_type->set_icon(get_editor_theme_icon(SNAME("Script")));
+#endif
c_text->set_editable(false);
c_text->set_tooltip_text(RTR("Copy this constructor in a script."));
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 63692dd064..d97ce65afc 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -2465,6 +2465,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) {
@@ -2664,6 +2669,12 @@ int Control::get_theme_constant(const StringName &p_name, const StringName &p_th
return constant;
}
+#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) {
@@ -3118,7 +3129,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: {
@@ -3128,6 +3141,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;
@@ -3626,7 +3640,7 @@ void Control::_bind_methods() {
}
Control::Control() {
- data.theme_owner = memnew(ThemeOwner);
+ data.theme_owner = memnew(ThemeOwner(this));
}
Control::~Control() {
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 7cb8fc5bf6..bad78a66d3 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -42,6 +42,7 @@ class Viewport;
class Label;
class Panel;
class ThemeOwner;
+class ThemeContext;
class Control : public CanvasItem {
GDCLASS(Control, CanvasItem);
@@ -553,6 +554,8 @@ public:
Node *get_theme_owner_node() const;
bool has_theme_owner_node() const;
+ void set_theme_context(ThemeContext *p_context, bool p_propagate = true);
+
void set_theme(const Ref<Theme> &p_theme);
Ref<Theme> get_theme() const;
@@ -582,6 +585,9 @@ public:
int get_theme_font_size(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
Color get_theme_color(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
int get_theme_constant(const StringName &p_name, const StringName &p_theme_type = StringName()) const;
+#ifdef TOOLS_ENABLED
+ Ref<Texture2D> get_editor_theme_icon(const StringName &p_name) const;
+#endif
bool has_theme_icon_override(const StringName &p_name) const;
bool has_theme_stylebox_override(const StringName &p_name) const;
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 23b516192e..b03d3c52d2 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -1615,7 +1615,14 @@ bool ItemList::get_allow_search() const {
void ItemList::set_icon_scale(real_t p_scale) {
ERR_FAIL_COND(!Math::is_finite(p_scale));
+
+ if (icon_scale == p_scale) {
+ return;
+ }
+
icon_scale = p_scale;
+ queue_redraw();
+ shape_changed = true;
}
real_t ItemList::get_icon_scale() const {