FuncDoodle
Loading...
Searching...
No Matches
Frame.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "Common.h"
13#include "Project/Project.h"
14#include <optional>
15
16namespace FuncDoodle {
17
22 class DeleteFrameAction : public Action {
23 public:
28 unsigned long frameI, const SharedPtr<ProjectFile>& proj)
29 : m_Proj(proj), m_FrameIndex(frameI), m_Empty(true),
30 m_Frame(std::nullopt) {}
31
38 DeleteFrameAction(unsigned long frameI, Frame* frame,
39 const SharedPtr<ProjectFile>& proj)
40 : m_Proj(proj), m_FrameIndex(frameI), m_Empty(frame == nullptr),
41 m_Frame(frame ? std::optional<Frame>(*frame) : std::nullopt) {}
42
46 void Undo() override;
47
51 void Redo() override;
52
53 private:
54 unsigned long m_FrameIndex;
55 bool m_Empty;
56 std::optional<Frame> m_Frame;
58 };
59
64 class InsertFrameAction : public Action {
65 public:
70 unsigned long frameI, const SharedPtr<ProjectFile>& proj)
71 : m_Proj(proj), m_FrameIndex(frameI), m_Empty(true),
72 m_Frame(std::nullopt) {}
73
77 InsertFrameAction(unsigned long frameI, Frame* frame,
78 const SharedPtr<ProjectFile>& proj)
79 : m_FrameIndex(frameI), m_Proj(proj), m_Empty(frame == nullptr),
80 m_Frame(frame ? std::optional<Frame>(*frame) : std::nullopt) {}
81
85 void Undo() override;
86
90 void Redo() override;
91
92 private:
93 unsigned long m_FrameIndex;
94 bool m_Empty;
95 std::optional<Frame> m_Frame;
97 };
98
104 public:
108 unsigned long frameI, const SharedPtr<ProjectFile>& proj)
109 : m_Proj(proj), m_FrameIndex(frameI) {}
110
111 void Undo() override;
112 void Redo() override;
113
114 private:
115 unsigned long m_FrameIndex;
117 };
118
124 public:
128 unsigned long frameI, const SharedPtr<ProjectFile>& proj)
129 : m_Proj(proj), m_FrameIndex(frameI) {}
130
131 void Undo() override;
132 void Redo() override;
133
134 private:
135 unsigned long m_FrameIndex;
137 };
138
143 class RotateFrameAction : public Action {
144 public:
151 RotateFrameAction(unsigned long frameIndex, int32_t deg,
152 const SharedPtr<ProjectFile>& proj)
153 : m_FrameIndex(frameIndex), m_Proj(proj), m_Deg(deg) {}
154
155 void Undo() override;
156 void Redo() override;
157
161 [[nodiscard]] int32_t Deg() const { return m_Deg; }
162
163 private:
164 unsigned long m_FrameIndex;
165 int32_t m_Deg;
167 };
168
169} // namespace FuncDoodle
Defines the base interface for undoable and redoable editor actions.
Defines the ProjectFile class, which manages animation project data.
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
Base interface for undoable and redoable editor actions.
Definition Common.h:24
std::optional< Frame > m_Frame
Stored frame data for undo.
Definition Frame.h:56
DeleteFrameAction(unsigned long frameI, const SharedPtr< ProjectFile > &proj)
Creates an empty delete-frame action.
Definition Frame.h:27
void Redo() override
Re-applies frame deletion.
Definition Frame.cc:21
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Frame.h:57
bool m_Empty
Whether frame data exists.
Definition Frame.h:55
DeleteFrameAction(unsigned long frameI, Frame *frame, const SharedPtr< ProjectFile > &proj)
Creates a delete-frame action storing frame data.
Definition Frame.h:38
void Undo() override
Restores deleted frame.
Definition Frame.cc:6
unsigned long m_FrameIndex
Frame index affected.
Definition Frame.h:54
Wraps an ImageArray with higher-level frame editing operations.
Definition Frame.h:248
std::optional< Frame > m_Frame
Stored frame data.
Definition Frame.h:95
void Redo() override
Re-inserts frame.
Definition Frame.cc:30
InsertFrameAction(unsigned long frameI, const SharedPtr< ProjectFile > &proj)
Creates an empty insert-frame action.
Definition Frame.h:69
InsertFrameAction(unsigned long frameI, Frame *frame, const SharedPtr< ProjectFile > &proj)
Creates an insert-frame action with frame data.
Definition Frame.h:77
bool m_Empty
Whether frame data exists.
Definition Frame.h:94
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Frame.h:96
unsigned long m_FrameIndex
Frame index affected.
Definition Frame.h:93
void Undo() override
Removes inserted frame.
Definition Frame.cc:26
void Undo() override
Reverts the effects of this action.
Definition Frame.cc:45
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Frame.h:116
MoveFrameLeftAction(unsigned long frameI, const SharedPtr< ProjectFile > &proj)
Creates an action that shifts a frame one slot to the left.
Definition Frame.h:107
unsigned long m_FrameIndex
Frame index.
Definition Frame.h:115
void Redo() override
Reapplies the effects of this action.
Definition Frame.cc:50
void Redo() override
Reapplies the effects of this action.
Definition Frame.cc:60
unsigned long m_FrameIndex
Frame index.
Definition Frame.h:135
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Frame.h:136
MoveFrameRightAction(unsigned long frameI, const SharedPtr< ProjectFile > &proj)
Creates an action that shifts a frame one slot to the right.
Definition Frame.h:127
void Undo() override
Reverts the effects of this action.
Definition Frame.cc:55
int32_t Deg() const
Returns rotation angle in degrees.
Definition Frame.h:161
unsigned long m_FrameIndex
Frame index.
Definition Frame.h:164
int32_t m_Deg
Rotation angle.
Definition Frame.h:165
void Undo() override
Reverts the effects of this action.
Definition Frame.cc:66
RotateFrameAction(unsigned long frameIndex, int32_t deg, const SharedPtr< ProjectFile > &proj)
Creates a frame rotation action.
Definition Frame.h:151
void Redo() override
Reapplies the effects of this action.
Definition Frame.cc:72
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Frame.h:166
The FuncDoodle C++ namespace.
Definition Common.h:12