Editor API
UnigineEditor public API
UnigineActions.h
1 // Copyright (C), UNIGINE. All rights reserved.
2 #pragma once
3 
4 
5 #include <editor/UnigineUndo.h>
6 
7 #include <UnigineNode.h>
8 #include <UnigineVector.h>
9 
10 
12 // Forward decl.
14 namespace UnigineEditor
15 {
16 class Selector;
17 class SelectionActionPrivate;
18 class CreateNodesActionPrivate;
19 class RemoveNodesActionPrivate;
20 class SetNodeTransformActionPrivate;
21 class ReparentNodesActionPrivate;
22 class RenameNodeActionPrivate;
23 class EnableNodeActionPrivate;
24 }
25 
26 
27 namespace UnigineEditor
28 {
29 
31 class UNIGINE_EDITOR_API SelectionAction : public Action
32 {
33 public:
36  explicit SelectionAction(Selector *s);
37  ~SelectionAction() override;
38 
40  void apply() override;
42  void undo() override;
44  void redo() override { apply(); }
45 
51  bool modifiesWorld() const override { return false; }
58  bool validate() override;
59 
62  static void applySelection(Selector *selector);
65  static void refreshSelection(bool expand = false);
66 
67 public:
68  ::UnigineEditor::SelectionActionPrivate *const d;
69 };
70 
72 class UNIGINE_EDITOR_API CreateNodesAction : public Action
73 {
74 public:
77  explicit CreateNodesAction(const Unigine::NodePtr &node);
80  explicit CreateNodesAction(const Unigine::Vector<Unigine::NodePtr> &nodes);
81  ~CreateNodesAction() override;
82 
84  void apply() override;
86  void undo() override;
88  void redo() override;
89 
90  Unigine::Vector<Unigine::NodePtr> getNodes() const;
91 
92 private:
93  ::UnigineEditor::CreateNodesActionPrivate *const d;
94 };
95 
97 class UNIGINE_EDITOR_API RemoveNodesAction : public Action
98 {
99 public:
102  explicit RemoveNodesAction(const Unigine::NodePtr &node);
105  explicit RemoveNodesAction(const Unigine::Vector<Unigine::NodePtr> &nodes);
106  ~RemoveNodesAction() override;
107 
109  void apply() override;
111  void undo() override;
113  void redo() override { apply(); }
114 
121  bool validate() override;
122 
123  Unigine::Vector<Unigine::NodePtr> getNodes() const;
124 
125 private:
126  ::UnigineEditor::RemoveNodesActionPrivate *const d;
127 };
128 
130 class UNIGINE_EDITOR_API SetNodeTransformAction : public Action
131 {
132 public:
136  explicit SetNodeTransformAction(const Unigine::NodePtr &node,
137  const Unigine::Math::Mat4 &transform);
138  ~SetNodeTransformAction() override;
139 
141  void apply() override;
143  void undo() override;
145  void redo() override;
152  bool validate() override;
153 
154  Unigine::NodePtr getNode() const;
155 
156 private:
157  ::UnigineEditor::SetNodeTransformActionPrivate *const d;
158 };
159 
161 class UNIGINE_EDITOR_API ReparentNodesAction final : public Action
162 {
163 public:
168  explicit ReparentNodesAction(const Unigine::Vector<Unigine::NodePtr> &nodes,
169  const Unigine::NodePtr &new_parent,
170  int new_index = -1);
171  ~ReparentNodesAction() override;
172 
174  void apply() override;
176  void undo() override;
178  void redo() override;
179 
180 private:
181  ::UnigineEditor::ReparentNodesActionPrivate *const d;
182 };
183 
185 class UNIGINE_EDITOR_API RenameNodeAction : public Action
186 {
187 public:
191  explicit RenameNodeAction(const Unigine::NodePtr &node, const char *new_name);
192  ~RenameNodeAction() override;
193 
195  void apply() override;
197  void undo() override;
199  void redo() override;
206  bool validate() override;
207 
208 private:
209  ::UnigineEditor::RenameNodeActionPrivate *const d;
210 };
211 
213 class UNIGINE_EDITOR_API EnableNodeAction : public Action
214 {
215 public:
219  explicit EnableNodeAction(const Unigine::NodePtr &node, bool enabled);
223  EnableNodeAction(const Unigine::Vector<Unigine::NodePtr> &nodes, bool enabled);
224  ~EnableNodeAction() override;
225 
227  void apply() override;
229  void undo() override;
231  void redo() override;
238  bool validate() override;
239 
240 private:
241  ::UnigineEditor::EnableNodeActionPrivate *const d;
242 };
243 
244 } // namespace UnigineEditor
This class is used to represent any user's action changing nodes parents.
Definition: UnigineActions.h:161
This class is used to represent any user's action changing node's name.
Definition: UnigineActions.h:185
void redo() override
Redoes the previously undone selection action (reverses the undo method).
Definition: UnigineActions.h:44
bool modifiesWorld() const override
Indicates whether the action brings any changes to the scene. Selection actions change nothing and sh...
Definition: UnigineActions.h:51
This basic class is used to represent any possible user action.
Definition: UnigineUndo.h:83
This class is used to represent any user's action changing node's enabled state.
Definition: UnigineActions.h:213
void redo() override
Redoes the previously undone remove nodes action (reverses the undo method).
Definition: UnigineActions.h:113
This class is used to represent any user's action creating nodes.
Definition: UnigineActions.h:72
This class is used to represent any user's action setting node transforms.
Definition: UnigineActions.h:130
This class is used to represent any user's action removing nodes.
Definition: UnigineActions.h:97
This class is used to represent any user's selection action.
Definition: UnigineActions.h:31