1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:27:43 +00:00

FontEditor: Add undo and redo commands

This commit is contained in:
thankyouverycool 2021-04-22 14:12:53 -04:00 committed by Andreas Kling
parent 2785e12b76
commit 44cd121e30
6 changed files with 149 additions and 1 deletions

View file

@ -34,10 +34,14 @@ void GlyphEditorWidget::set_glyph(int glyph)
void GlyphEditorWidget::delete_glyph()
{
if (on_undo_event)
on_undo_event(false);
auto bitmap = font().glyph(m_glyph).glyph_bitmap();
for (int x = 0; x < bitmap.width(); x++)
for (int y = 0; y < bitmap.height(); y++)
bitmap.set_bit_at(x, y, false);
if (on_undo_event)
on_undo_event(true);
if (on_glyph_altered)
on_glyph_altered(m_glyph);
update();
@ -82,6 +86,9 @@ void GlyphEditorWidget::paste_glyph()
if (!mime_type.starts_with("glyph/"))
return;
if (on_undo_event)
on_undo_event(false);
auto byte_buffer = GUI::Clipboard::the().data();
auto buffer_height = GUI::Clipboard::the().data_and_type().metadata.get("height").value().to_int();
auto buffer_width = GUI::Clipboard::the().data_and_type().metadata.get("width").value().to_int();
@ -102,6 +109,8 @@ void GlyphEditorWidget::paste_glyph()
bitmap.set_bit_at(x, y, bits[x][y]);
}
}
if (on_undo_event)
on_undo_event(true);
if (on_glyph_altered)
on_glyph_altered(m_glyph);
update();