diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2023-05-10 17:01:08 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-13 12:53:49 +0200 |
commit | 0ad5e85163614bbabedc0318dfb3d3541c14e1fd (patch) | |
tree | 7737c8886e7179bb3f8879f4ef7effc504ba7c4f /Userland | |
parent | cf4ddd1dcf9fa9762aeae5e984b6295e82716d10 (diff) | |
download | serenity-0ad5e85163614bbabedc0318dfb3d3541c14e1fd.zip |
LibGUI+Applications: Let GlyphMapWidget initialize a null Font
FontEditor will need to clear references to its mutable font in
the future while CharacterMap has no use for the highlights clone,
so let's convert GlyphMapWidget's set_font wrapper into a separate
initialize function for the editor and stop hiding the base function
for others. Setting font null in either ultimately points the map to
the system's default font.
Diffstat (limited to 'Userland')
4 files changed, 8 insertions, 6 deletions
diff --git a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp index c559c78450..ca24c7bc1a 100644 --- a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp +++ b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp @@ -167,8 +167,7 @@ ErrorOr<void> CharacterMapWidget::initialize_menubar(GUI::Window& window) void CharacterMapWidget::did_change_font() { - // No need to track glyph modifications by cloning - m_glyph_map->GUI::AbstractScrollableWidget::set_font(font()); + m_glyph_map->set_font(font()); m_font_name_label->set_text(String::from_deprecated_string(font().human_readable_name()).release_value_but_fixme_should_propagate_errors()); m_output_box->set_font(font()); } diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp index 8195a8f202..86c045c333 100644 --- a/Userland/Applications/FontEditor/MainWidget.cpp +++ b/Userland/Applications/FontEditor/MainWidget.cpp @@ -637,7 +637,7 @@ ErrorOr<void> MainWidget::initialize(StringView path, RefPtr<Gfx::BitmapFont>&& if (m_font == mutable_font) return {}; - TRY(m_glyph_map_widget->set_font(*mutable_font)); + TRY(m_glyph_map_widget->initialize(mutable_font)); auto active_glyph = m_glyph_map_widget->active_glyph(); m_glyph_map_widget->set_focus(true); diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp index 5a472b8b6f..3908934d8c 100644 --- a/Userland/Libraries/LibGUI/GlyphMapWidget.cpp +++ b/Userland/Libraries/LibGUI/GlyphMapWidget.cpp @@ -573,9 +573,12 @@ bool GlyphMapWidget::glyph_is_modified(u32 glyph) return m_modified_glyphs.contains(glyph); } -ErrorOr<void> GlyphMapWidget::set_font(Gfx::Font const& font) +ErrorOr<void> GlyphMapWidget::initialize(Gfx::Font const* font) { - m_original_font = TRY(font.try_clone()); + if (font) + m_original_font = TRY(font->try_clone()); + else + m_original_font = nullptr; m_modified_glyphs.clear(); AbstractScrollableWidget::set_font(font); return {}; diff --git a/Userland/Libraries/LibGUI/GlyphMapWidget.h b/Userland/Libraries/LibGUI/GlyphMapWidget.h index cf8f560ecf..f90bbfea1b 100644 --- a/Userland/Libraries/LibGUI/GlyphMapWidget.h +++ b/Userland/Libraries/LibGUI/GlyphMapWidget.h @@ -20,7 +20,7 @@ class GlyphMapWidget final : public AbstractScrollableWidget { public: virtual ~GlyphMapWidget() override = default; - ErrorOr<void> set_font(Gfx::Font const&); + ErrorOr<void> initialize(Gfx::Font const*); class Selection { public: |