FontEditor: Reset selected glyph on init

Fixes glyphs not updating when loading between fonts at the same
index. Fixes GlyphEditor spinbox inadvertently modifying width
of last selected index.
This commit is contained in:
thankyouverycool 2021-04-07 12:05:02 -04:00 committed by Andreas Kling
parent 57c6264877
commit ebf3ce7806
Notes: sideshowbarker 2024-07-18 20:39:47 +09:00
2 changed files with 5 additions and 3 deletions

View file

@ -253,15 +253,14 @@ void FontEditorWidget::initialize(const String& path, RefPtr<Gfx::BitmapFont>&&
m_path = path;
m_edited_font = edited_font;
m_glyph_map_widget->initialize(*m_edited_font);
m_glyph_editor_widget->initialize(*m_edited_font);
m_glyph_editor_container->set_fixed_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height());
m_left_column_container->set_fixed_width(m_glyph_editor_widget->preferred_width());
m_glyph_editor_width_spinbox->set_enabled(!m_edited_font->is_fixed_width());
m_glyph_editor_width_spinbox->set_max(m_edited_font->max_glyph_width());
m_glyph_map_widget->initialize(*m_edited_font);
m_glyph_map_widget->set_selected_glyph('A');
m_name_textbox->set_text(m_edited_font->name());
m_family_textbox->set_text(m_edited_font->family());
@ -273,6 +272,8 @@ void FontEditorWidget::initialize(const String& path, RefPtr<Gfx::BitmapFont>&&
m_fixed_width_checkbox->set_checked(m_edited_font->is_fixed_width());
m_glyph_map_widget->set_selected_glyph('A');
if (on_initialize)
on_initialize();
}

View file

@ -45,6 +45,7 @@ void GlyphMapWidget::initialize(Gfx::BitmapFont& mutable_font)
return;
m_font = mutable_font;
m_glyph_count = mutable_font.glyph_count();
m_selected_glyph = 0;
vertical_scrollbar().set_step(font().glyph_height() + m_vertical_spacing);
}