diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2024-07-05 12:48:39 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2024-07-05 12:48:39 +0300 |
commit | 847aadee02b4cacc655cc436db56dbf8c33b8278 (patch) | |
tree | adad902af91ff159a9ae94600dd43694f4fd1319 /editor | |
parent | 20ba2f00bd9199b675176a8e1ac151f96bfb5cfa (diff) | |
download | redot-engine-847aadee02b4cacc655cc436db56dbf8c33b8278.tar.gz |
[Editor] Update font preview directly instead of invalidating property list.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/font_config_plugin.cpp | 16 | ||||
-rw-r--r-- | editor/plugins/font_config_plugin.h | 2 |
2 files changed, 18 insertions, 0 deletions
diff --git a/editor/plugins/font_config_plugin.cpp b/editor/plugins/font_config_plugin.cpp index 15b268337f..4b7a01fa31 100644 --- a/editor/plugins/font_config_plugin.cpp +++ b/editor/plugins/font_config_plugin.cpp @@ -935,6 +935,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; } } @@ -945,7 +951,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; |