mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
LibGUI: Remove UndoStack's automatic command combo'ing
UndoStack will now merge adjacent commands *if they want to be merged* instead of bundling everything you push onto it until you tell it to "finalize the combo." This uses less memory and gives applications full control over how their undo stacks end up. :^)
This commit is contained in:
parent
81bc861085
commit
161568103e
5 changed files with 37 additions and 77 deletions
|
@ -17,7 +17,7 @@ public:
|
|||
UndoStack();
|
||||
~UndoStack();
|
||||
|
||||
void push(NonnullOwnPtr<Command>&&);
|
||||
void push(NonnullOwnPtr<Command>);
|
||||
|
||||
bool can_undo() const;
|
||||
bool can_redo() const;
|
||||
|
@ -25,8 +25,6 @@ public:
|
|||
void undo();
|
||||
void redo();
|
||||
|
||||
void finalize_current_combo();
|
||||
|
||||
void set_current_unmodified();
|
||||
bool is_current_modified() const;
|
||||
|
||||
|
@ -35,13 +33,7 @@ public:
|
|||
Function<void()> on_state_change;
|
||||
|
||||
private:
|
||||
struct Combo {
|
||||
NonnullOwnPtrVector<Command> commands;
|
||||
};
|
||||
|
||||
void pop();
|
||||
|
||||
NonnullOwnPtrVector<Combo> m_stack;
|
||||
NonnullOwnPtrVector<Command> m_stack;
|
||||
size_t m_stack_index { 0 };
|
||||
Optional<size_t> m_clean_index;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue