yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
graphics_undo_actions.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_GRAPHICS_UNDO_ACTIONS_H_
2#define YAZE_APP_EDITOR_GRAPHICS_UNDO_ACTIONS_H_
3
4#include <cstddef>
5#include <string>
6#include <utility>
7
8#include "absl/status/status.h"
11
12namespace yaze {
13namespace editor {
14
15class GraphicsEditorState;
16
26 public:
28 std::string description)
29 : state_(state),
30 diff_(std::move(diff)),
31 description_(std::move(description)) {}
32
33 absl::Status Undo() override {
34 return ApplySheetPixelDiff(*state_, diff_, /*redo=*/false);
35 }
36 absl::Status Redo() override {
37 return ApplySheetPixelDiff(*state_, diff_, /*redo=*/true);
38 }
39
40 std::string Description() const override { return description_; }
41 size_t MemoryUsage() const override { return diff_.MemoryUsage(); }
42
43 bool CanMergeWith(const UndoAction& /*prev*/) const override {
44 // One action per stroke already.
45 return false;
46 }
47
48 const SheetPixelDiff& diff() const { return diff_; }
49
50 private:
53 std::string description_;
54};
55
56} // namespace editor
57} // namespace yaze
58
59#endif // YAZE_APP_EDITOR_GRAPHICS_UNDO_ACTIONS_H_
Shared state between GraphicsEditor panel components.
Undoable pixel edit on one graphics sheet.
bool CanMergeWith(const UndoAction &) const override
size_t MemoryUsage() const override
Approximate memory footprint for budget enforcement.
std::string Description() const override
Human-readable description (e.g., "Paint 12 tiles on map 5")
GraphicsPixelEditAction(GraphicsEditorState *state, SheetPixelDiff diff, std::string description)
const SheetPixelDiff & diff() const
Abstract base for all undoable actions (Command pattern)
Definition undo_action.h:20
The Graphics editor's path for sheet pixel writes.
absl::Status ApplySheetPixelDiff(GraphicsEditorState &state, const SheetPixelDiff &diff, bool redo)
The pixels one undo step changes in one sheet.