summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-07-05 15:07:50 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-07-05 15:07:50 +0200
commitf1749c691f8c33d094b5b6dddb2a7b2bb4456c8e (patch)
tree55d1432f849ac1a942fe261ec6d7f77baabc7e02
parent33f456ccfed4f572d18645d58aa33730a7e5117d (diff)
parent847aadee02b4cacc655cc436db56dbf8c33b8278 (diff)
downloadredot-engine-f1749c691f8c33d094b5b6dddb2a7b2bb4456c8e.tar.gz
Merge pull request #93968 from bruvzg/font_prev_update
[Editor] Update font preview directly instead of invalidating property list.
-rw-r--r--editor/plugins/font_config_plugin.cpp16
-rw-r--r--editor/plugins/font_config_plugin.h2
-rw-r--r--scene/resources/font.cpp1
3 files changed, 18 insertions, 1 deletions
diff --git a/editor/plugins/font_config_plugin.cpp b/editor/plugins/font_config_plugin.cpp
index b18b194421..e6ce63fe36 100644
--- a/editor/plugins/font_config_plugin.cpp
+++ b/editor/plugins/font_config_plugin.cpp
@@ -950,6 +950,12 @@ void FontPreview::_notification(int p_what) {
font->draw_string(get_canvas_item(), Point2(0, font->get_height(font_size) + 2 * EDSCALE), TTR("Unable to preview font"), HORIZONTAL_ALIGNMENT_CENTER, get_size().x, font_size, text_color);
}
} break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ if (prev_font.is_valid()) {
+ prev_font->disconnect_changed(callable_mp(this, &FontPreview::_preview_changed));
+ }
+ } break;
}
}
@@ -960,7 +966,17 @@ Size2 FontPreview::get_minimum_size() const {
}
void FontPreview::set_data(const Ref<Font> &p_f) {
+ if (prev_font.is_valid()) {
+ prev_font->disconnect_changed(callable_mp(this, &FontPreview::_preview_changed));
+ }
prev_font = p_f;
+ if (prev_font.is_valid()) {
+ prev_font->connect_changed(callable_mp(this, &FontPreview::_preview_changed));
+ }
+ queue_redraw();
+}
+
+void FontPreview::_preview_changed() {
queue_redraw();
}
diff --git a/editor/plugins/font_config_plugin.h b/editor/plugins/font_config_plugin.h
index 7b2d26da4a..4e798fc3e8 100644
--- a/editor/plugins/font_config_plugin.h
+++ b/editor/plugins/font_config_plugin.h
@@ -225,6 +225,8 @@ protected:
Ref<Font> prev_font;
+ void _preview_changed();
+
public:
virtual Size2 get_minimum_size() const override;
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index bc8e0b9015..37d9d57722 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -3213,7 +3213,6 @@ void SystemFont::_update_base_font() {
}
_invalidate_rids();
- notify_property_list_changed();
}
void SystemFont::reset_state() {