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:
27 DeleteFrameAction(uint64_t frameI, const SharedPtr<ProjectFile>& proj)
28 : m_Proj(proj), m_FrameIndex(frameI), m_Empty(true),
29 m_Frame(std::nullopt) {}
30
38 uint64_t frameI, Frame* frame, const SharedPtr<ProjectFile>& proj)
39 : m_Proj(proj), m_FrameIndex(frameI), m_Empty(frame == nullptr),
40 m_Frame(frame ? std::optional<Frame>(*frame) : std::nullopt) {}
41
45 void Undo() override;
46
50 void Redo() override;
51
52 private:
53 uint64_t m_FrameIndex;
54 bool m_Empty;
55 std::optional<Frame> m_Frame;
57 };
58
63 class InsertFrameAction : public Action {
64 public:
68 InsertFrameAction(uint64_t frameI, const SharedPtr<ProjectFile>& proj)
69 : m_Proj(proj), m_FrameIndex(frameI), m_Empty(true),
70 m_Frame(std::nullopt) {}
71
76 uint64_t frameI, Frame* frame, const SharedPtr<ProjectFile>& proj)
77 : m_FrameIndex(frameI), m_Proj(proj), m_Empty(frame == nullptr),
78 m_Frame(frame ? std::optional<Frame>(*frame) : std::nullopt) {}
79
83 void Undo() override;
84
88 void Redo() override;
89
90 private:
91 uint64_t m_FrameIndex;
92 bool m_Empty;
93 std::optional<Frame> m_Frame;
95 };
96
102 public:
105 MoveFrameLeftAction(uint64_t frameI, const SharedPtr<ProjectFile>& proj)
106 : m_Proj(proj), m_FrameIndex(frameI) {}
107
108 void Undo() override;
109 void Redo() override;
110
111 private:
112 uint64_t m_FrameIndex;
114 };
115
121 public:
125 uint64_t frameI, const SharedPtr<ProjectFile>& proj)
126 : m_Proj(proj), m_FrameIndex(frameI) {}
127
128 void Undo() override;
129 void Redo() override;
130
131 private:
132 uint64_t m_FrameIndex;
134 };
135
140 class RotateFrameAction : public Action {
141 public:
148 RotateFrameAction(uint64_t frameIndex, int32_t deg,
149 const SharedPtr<ProjectFile>& proj)
150 : m_FrameIndex(frameIndex), m_Proj(proj), m_Deg(deg) {}
151
152 void Undo() override;
153 void Redo() override;
154
158 [[nodiscard]] int32_t Deg() const { return m_Deg; }
159
160 private:
161 uint64_t m_FrameIndex;
162 int32_t m_Deg;
164 };
165
166} // 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:55
void Redo() override
Re-applies frame deletion.
Definition Frame.cc:21
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Frame.h:56
DeleteFrameAction(uint64_t frameI, Frame *frame, const SharedPtr< ProjectFile > &proj)
Creates a delete-frame action storing frame data.
Definition Frame.h:37
DeleteFrameAction(uint64_t frameI, const SharedPtr< ProjectFile > &proj)
Creates an empty delete-frame action.
Definition Frame.h:27
uint64_t m_FrameIndex
Frame index affected.
Definition Frame.h:53
bool m_Empty
Whether frame data exists.
Definition Frame.h:54
void Undo() override
Restores deleted frame.
Definition Frame.cc:6
Wraps an ImageArray with higher-level frame editing operations.
Definition Frame.h:248
std::optional< Frame > m_Frame
Stored frame data.
Definition Frame.h:93
uint64_t m_FrameIndex
Frame index affected.
Definition Frame.h:91
void Redo() override
Re-inserts frame.
Definition Frame.cc:30
InsertFrameAction(uint64_t frameI, const SharedPtr< ProjectFile > &proj)
Creates an empty insert-frame action.
Definition Frame.h:68
bool m_Empty
Whether frame data exists.
Definition Frame.h:92
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Frame.h:94
void Undo() override
Removes inserted frame.
Definition Frame.cc:26
InsertFrameAction(uint64_t frameI, Frame *frame, const SharedPtr< ProjectFile > &proj)
Creates an insert-frame action with frame data.
Definition Frame.h:75
void Undo() override
Reverts the effects of this action.
Definition Frame.cc:45
uint64_t m_FrameIndex
Frame index.
Definition Frame.h:112
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Frame.h:113
MoveFrameLeftAction(uint64_t frameI, const SharedPtr< ProjectFile > &proj)
Creates an action that shifts a frame one slot to the left.
Definition Frame.h:105
void Redo() override
Reapplies the effects of this action.
Definition Frame.cc:50
uint64_t m_FrameIndex
Frame index.
Definition Frame.h:132
MoveFrameRightAction(uint64_t frameI, const SharedPtr< ProjectFile > &proj)
Creates an action that shifts a frame one slot to the right.
Definition Frame.h:124
void Redo() override
Reapplies the effects of this action.
Definition Frame.cc:60
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Frame.h:133
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:158
int32_t m_Deg
Rotation angle.
Definition Frame.h:162
RotateFrameAction(uint64_t frameIndex, int32_t deg, const SharedPtr< ProjectFile > &proj)
Creates a frame rotation action.
Definition Frame.h:148
void Undo() override
Reverts the effects of this action.
Definition Frame.cc:66
void Redo() override
Reapplies the effects of this action.
Definition Frame.cc:72
WeakPtr< ProjectFile > m_Proj
Owning project.
Definition Frame.h:163
uint64_t m_FrameIndex
Frame index.
Definition Frame.h:161
The FuncDoodle C++ namespace.
Definition Common.h:12