mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
LibGUI: Add GUndoStack and GCommand classes
This patch converts the undo stack from GTextDocument into GUndoStack, and GTextDocumentUndoCommand now inherits from GCommand. Let's turn this into a generic mechanism that can be used to implement undo/redo in any application. :^)
This commit is contained in:
parent
f8703d44cc
commit
f430da1d45
7 changed files with 156 additions and 73 deletions
20
Libraries/LibGUI/GCommand.h
Normal file
20
Libraries/LibGUI/GCommand.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
|
||||
class GCommand {
|
||||
public:
|
||||
virtual ~GCommand();
|
||||
|
||||
virtual void undo() {}
|
||||
virtual void redo() {}
|
||||
|
||||
String action_text() const { return m_action_text; }
|
||||
|
||||
protected:
|
||||
GCommand() {}
|
||||
void set_action_text(const String& text) { m_action_text = text; }
|
||||
|
||||
private:
|
||||
String m_action_text;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue