mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:37:44 +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
|
@ -46,20 +46,23 @@ private:
|
|||
class GlyphUndoCommand : public GUI::Command {
|
||||
public:
|
||||
GlyphUndoCommand(UndoGlyph& glyph)
|
||||
: m_state(glyph.save_state())
|
||||
: m_undo_state(glyph.save_state())
|
||||
, m_undo_glyph(glyph)
|
||||
{
|
||||
}
|
||||
virtual void undo() override
|
||||
{
|
||||
m_undo_glyph.restore_state(*m_state);
|
||||
if (!m_redo_state)
|
||||
m_redo_state = m_undo_state->save_state();
|
||||
m_undo_glyph.restore_state(*m_undo_state);
|
||||
}
|
||||
virtual void redo() override
|
||||
{
|
||||
undo();
|
||||
m_undo_glyph.restore_state(*m_redo_state);
|
||||
}
|
||||
|
||||
private:
|
||||
RefPtr<UndoGlyph> m_state;
|
||||
RefPtr<UndoGlyph> m_undo_state;
|
||||
RefPtr<UndoGlyph> m_redo_state;
|
||||
UndoGlyph& m_undo_glyph;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue