FuncDoodle
Loading...
Searching...
No Matches
Selection.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "Action/Common.h"
13#include "Project/Project.h"
14#include "Selection/Selection.h"
15#include "Util/Ptr.h"
16
17#include <cstdint>
18#include <utility>
19
20namespace FuncDoodle {
21
27 public:
35 RotateSelectionAction(unsigned long frameIndex, WeakPtr<Selection> sel,
36 int32_t deg, const SharedPtr<ProjectFile>& proj)
37 : m_FrameIndex(frameIndex), m_Sel(std::move(sel)), m_Proj(proj),
38 m_Deg(deg) {}
39
43 void Undo() override;
44
48 void Redo() override;
49
53 [[nodiscard]] int32_t Deg() const { return m_Deg; }
54
58 [[nodiscard]] WeakPtr<Selection> Sel() const { return m_Sel; }
59
60 private:
61 unsigned long m_FrameIndex;
63 int32_t m_Deg;
65 };
66
72 public:
80 DeleteSelectionAction(unsigned long frameIndex, WeakPtr<Selection> sel,
81 std::vector<Col> prevPixels, const SharedPtr<ProjectFile>& proj)
82 : m_FrameIndex(frameIndex), m_Sel(std::move(sel)),
83 m_PrevPixels(std::move(prevPixels)), m_Proj(proj) {}
84
88 void Undo() override;
89
93 void Redo() override;
94
98 [[nodiscard]] WeakPtr<Selection> Sel() const { return m_Sel; }
99
100 private:
101 unsigned long m_FrameIndex;
103 std::vector<Col> m_PrevPixels;
105 };
106
112 public:
119 : m_FrameBeforeMove(frame), m_Ctx(std::move(ctx)) {}
120
124 void Undo() override;
125
129 void Redo() override;
130
134 [[nodiscard]] WeakPtr<Selection> Sel() const { return m_Ctx.Sel; }
135
139 [[nodiscard]] Direction Dir() const { return m_Ctx.MoveDir; }
140
144 [[nodiscard]] SharedPtr<ProjectFile> Proj() const { return m_Ctx.Proj; }
145
149 [[nodiscard]] unsigned long FrameIndex() const {
150 return m_Ctx.FrameIndex;
151 }
152
156 [[nodiscard]] MoveSelectionActionContext Ctx() const { return m_Ctx; }
157
158 private:
161 };
162
163} // namespace FuncDoodle
Defines the base interface for undoable and redoable editor actions.
Defines the ProjectFile class, which manages animation project data.
Convenience type aliases for standard smart pointers.
std::weak_ptr< T > WeakPtr
Alias for a non-owning observer of a SharedPtr.
Definition Ptr.h:34
std::shared_ptr< T > SharedPtr
Alias for a reference-counted shared smart pointer.
Definition Ptr.h:31
Defines selection primitives for editing regions of pixels.
Base interface for undoable and redoable editor actions.
Definition Common.h:24
void Undo() override
Restores deleted pixels.
Definition Selection.cc:22
void Redo() override
Re-applies deletion.
Definition Selection.cc:37
std::vector< Col > m_PrevPixels
Stored pixels for undo.
Definition Selection.h:103
unsigned long m_FrameIndex
Frame index of action.
Definition Selection.h:101
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Selection.h:104
DeleteSelectionAction(unsigned long frameIndex, WeakPtr< Selection > sel, std::vector< Col > prevPixels, const SharedPtr< ProjectFile > &proj)
Constructs a delete-selection action.
Definition Selection.h:80
WeakPtr< Selection > Sel() const
Returns affected selection.
Definition Selection.h:98
WeakPtr< Selection > m_Sel
Target selection.
Definition Selection.h:102
Wraps an ImageArray with higher-level frame editing operations.
Definition Frame.h:248
void Redo() override
Reapplies movement.
Definition Selection.cc:55
Direction Dir() const
Returns movement direction.
Definition Selection.h:139
MoveSelectionActionContext Ctx() const
Returns full context snapshot.
Definition Selection.h:156
Frame m_FrameBeforeMove
Frame state before move.
Definition Selection.h:160
MoveSelectionActionContext m_Ctx
Movement context.
Definition Selection.h:159
unsigned long FrameIndex() const
Returns frame index.
Definition Selection.h:149
void Undo() override
Undoes movement.
Definition Selection.cc:45
WeakPtr< Selection > Sel() const
Returns selection being moved.
Definition Selection.h:134
MoveSelectionAction(Frame frame, MoveSelectionActionContext ctx)
Constructs a move-selection action.
Definition Selection.h:118
SharedPtr< ProjectFile > Proj() const
Returns owning project.
Definition Selection.h:144
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Selection.h:64
unsigned long m_FrameIndex
Frame index where action occurred.
Definition Selection.h:61
int32_t m_Deg
Rotation in degrees.
Definition Selection.h:63
void Redo() override
Reapplies the rotation.
Definition Selection.cc:14
WeakPtr< Selection > m_Sel
Target selection.
Definition Selection.h:62
int32_t Deg() const
Returns rotation amount in degrees.
Definition Selection.h:53
WeakPtr< Selection > Sel() const
Returns the affected selection.
Definition Selection.h:58
void Undo() override
Undoes the rotation.
Definition Selection.cc:6
RotateSelectionAction(unsigned long frameIndex, WeakPtr< Selection > sel, int32_t deg, const SharedPtr< ProjectFile > &proj)
Constructs a rotation action.
Definition Selection.h:35
The FuncDoodle C++ namespace.
Definition Common.h:12
Direction
Direction used for moving a selection.
Definition Direction.h:23
Context data required to perform a selection move action.
Definition Direction.h:32