[Editor] Update font preview directly instead of invalidating property list.

This commit is contained in:
bruvzg 2024-07-05 12:48:39 +03:00
parent 20ba2f00bd
commit 847aadee02
No known key found for this signature in database
GPG key ID: 7960FCF39844EC38
3 changed files with 18 additions and 1 deletions

View file

@ -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); 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; } 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) { 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; 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(); queue_redraw();
} }

View file

@ -225,6 +225,8 @@ protected:
Ref<Font> prev_font; Ref<Font> prev_font;
void _preview_changed();
public: public:
virtual Size2 get_minimum_size() const override; virtual Size2 get_minimum_size() const override;

View file

@ -3213,7 +3213,6 @@ void SystemFont::_update_base_font() {
} }
_invalidate_rids(); _invalidate_rids();
notify_property_list_changed();
} }
void SystemFont::reset_state() { void SystemFont::reset_state() {