1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:17:35 +00:00

FontEditor: Set width to zero when deleting a glyph

Previously, Delete left a glyph's width maximized.
This commit is contained in:
thankyouverycool 2021-09-21 17:34:35 -04:00 committed by Andreas Kling
parent ca6cb6cec3
commit 1ae4caca4b
2 changed files with 13 additions and 10 deletions

View file

@ -241,13 +241,15 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::BitmapFont>&&
m_glyph_map_widget->update_glyph(m_glyph_map_widget->selected_glyph());
});
m_paste_action->set_enabled(GUI::Clipboard::the().mime_type() == "glyph/x-fonteditor");
m_delete_action = GUI::CommonActions::make_delete_action([&](auto&) {
m_edited_font->set_glyph_width(m_glyph_map_widget->selected_glyph(), m_edited_font->max_glyph_width());
m_delete_action = GUI::CommonActions::make_delete_action([this, update_statusbar](auto&) {
if (m_glyph_editor_widget->is_glyph_empty() && m_edited_font->raw_glyph_width(m_glyph_map_widget->selected_glyph()) == 0)
return;
m_glyph_editor_widget->delete_glyph();
m_glyph_map_widget->update_glyph(m_glyph_map_widget->selected_glyph());
auto glyph_width = m_edited_font->raw_glyph_width(m_glyph_map_widget->selected_glyph());
m_glyph_editor_width_spinbox->set_value(glyph_width);
m_glyph_editor_present_checkbox->set_checked(glyph_width > 0);
if (m_edited_font->is_fixed_width())
m_glyph_editor_present_checkbox->set_checked(false, GUI::AllowCallback::No);
else
m_glyph_editor_width_spinbox->set_value(0, GUI::AllowCallback::No);
update_statusbar();
});
m_undo_action = GUI::CommonActions::make_undo_action([&](auto&) {
undo();