mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
FontEditor: Save discrete undo and redo states for each Command
Makes undo/redo actions compatible with the updated UndoStack sans finalization. Fixes having to click actions twice.
This commit is contained in:
parent
92fb2e2a28
commit
a621932c11
4 changed files with 13 additions and 16 deletions
|
@ -38,13 +38,11 @@ void GlyphEditorWidget::set_glyph(int glyph)
|
|||
void GlyphEditorWidget::delete_glyph()
|
||||
{
|
||||
if (on_undo_event)
|
||||
on_undo_event(false);
|
||||
on_undo_event();
|
||||
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();
|
||||
|
@ -93,7 +91,7 @@ void GlyphEditorWidget::paste_glyph()
|
|||
return;
|
||||
|
||||
if (on_undo_event)
|
||||
on_undo_event(false);
|
||||
on_undo_event();
|
||||
|
||||
auto byte_buffer = GUI::Clipboard::the().data();
|
||||
auto buffer_height = GUI::Clipboard::the().data_and_type().metadata.get("height").value().to_int();
|
||||
|
@ -115,8 +113,7 @@ 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();
|
||||
|
@ -175,7 +172,7 @@ void GlyphEditorWidget::mousedown_event(GUI::MouseEvent& event)
|
|||
return;
|
||||
m_is_clicking_valid_cell = true;
|
||||
if (on_undo_event)
|
||||
on_undo_event(false);
|
||||
on_undo_event();
|
||||
if (mode() == Paint) {
|
||||
draw_at_mouse(event);
|
||||
} else {
|
||||
|
@ -195,8 +192,6 @@ void GlyphEditorWidget::mouseup_event(GUI::MouseEvent&)
|
|||
if (!m_is_clicking_valid_cell)
|
||||
return;
|
||||
m_is_clicking_valid_cell = false;
|
||||
if (on_undo_event)
|
||||
on_undo_event(true);
|
||||
}
|
||||
|
||||
void GlyphEditorWidget::mousemove_event(GUI::MouseEvent& event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue