TDME2  1.9.200
UIEditorTabView.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 #include <memory>
5 #include <string>
6 #include <vector>
7 
8 #include <tdme/tdme.h>
9 #include <tdme/engine/fwd-tdme.h>
13 #include <tdme/math/Matrix4x4.h>
23 #include <tdme/utilities/Float.h>
24 
25 using std::array;
26 using std::string;
27 using std::unique_ptr;
28 
45 
46 /**
47  * UI editor tab view
48  * @author Andreas Drewke
49  */
51 {
52 public:
53  struct UIScreenNode {
54  string fileName;
55  string xml;
56  // TODO: remove that here, rather store a flag if UI had been parsed and added to GUI or not
57  GUIScreenNode* screenNode { nullptr };
58  int width { -1 };
59  int height { -1 };
60  };
61 
62 protected:
63  unique_ptr<Engine> guiEngine;
64  unique_ptr<Engine> engine;
65  bool projectedUi { false };
66  unique_ptr<Prototype> prototype;
67  string modelMeshNode;
68  float projectedUiMinX { Float::MAX_VALUE };
69  float projectedUiMinZ { Float::MAX_VALUE };
70  float projectedUiMaxX { Float::MIN_VALUE };
71  float projectedUiMaxZ { Float::MIN_VALUE };
72 
73 private:
74  EditorView* editorView { nullptr };
75  string tabId;
76  GUIScreenNode* screenNode { nullptr };
77  PopUps* popUps { nullptr };
78  unique_ptr<UIEditorTabController> uiTabController;
81  vector<UIScreenNode> uiScreenNodes;
82  unique_ptr<CameraRotationInputHandler> cameraRotationInputHandler;
83 
84  int screenIdx { 0 };
85  bool visualEditor { false };
86 
88  unique_ptr<GUIStyledTextNodeController::ChangeListener> textNodeChangeListener;
89  unique_ptr<GUIStyledTextNodeController::CodeCompletionListener> textNodeCodeCompletionListener;
90  const TextFormatter::CodeCompletion* codeCompletion { nullptr };
91 
95  string display;
96  string name;
97  vector<string> parameters;
98  string returnValue;
99  };
100 
101  bool countEnabled { false };
102 
103  // overridden methods
104  void onCameraRotation() override;
105  void onCameraScale() override;
106 
107 public:
108  // forbid class copy
110 
111  /**
112  * Public constructor
113  * @param editorView editor view
114  * @param tabId tab id
115  * @param screenNode screenNode
116  * @param fileName screen XML file name
117  */
118  UIEditorTabView(EditorView* editorView, const string& tabId, GUIScreenNode* screenNode, const string& fileName);
119 
120  /**
121  * Destructor
122  */
124 
125  /**
126  * @return filename of opened file
127  */
128  inline const string& getFileName() {
129  return screenFileName;
130  }
131 
132  /**
133  * @return editor view
134  */
136  return editorView;
137  }
138 
139  /**
140  * @return associated tab controller
141  */
142  inline TabController* getTabController() override {
143  return uiTabController.get();
144  }
145 
146  /**
147  * @return pop up views
148  */
149  inline PopUps* getPopUps() {
150  return popUps;
151  }
152 
153  /**
154  * @return UI screen nodes
155  */
156  inline vector<UIScreenNode>& getUIScreenNodes() {
157  return uiScreenNodes;
158  }
159 
160  /**
161  * Add screen
162  */
163  void addScreen();
164 
165  /**
166  * Set screen
167  * @param screenIdx screen index
168  * @param fileName file name
169  */
170  void setScreen(int screenIdx, const string& fileName);
171 
172  /**
173  * Unset screen
174  * @param screenIdx screen index
175  */
176  void unsetScreen(int screenIdx);
177 
178  /**
179  * Remove screen
180  * @param screenIdx screen index
181  */
182  void removeScreen(int screenIdx);
183 
184  /**
185  * Remove screens
186  */
187  void removeScreens();
188 
189  /**
190  * Readd screens
191  */
192  void reAddScreens();
193 
194  /**
195  * @return prototype
196  */
198 
199  /**
200  * Load prototype
201  * @param pathName path name
202  * @param fileName file name
203  * @param modelMeshNode model mesh node
204  * @param modelMeshAnimation model mesh animation
205  * @return model
206  */
207  Prototype* loadPrototype(const string& pathName, const string& fileName, const string& modelMeshNode, const string& modelMeshAnimation);
208 
209  /**
210  * Set model mesh node
211  * @param modelMeshNode model mesh node
212  */
213  void setModelMeshNode(const string& modelMeshNode);
214 
215  /**
216  * Set model mesh animation
217  * @param modelMeshAnimation model mesh animation
218  */
219  void setModelMeshAnimation(const string& modelMeshAnimation);
220 
221  /**
222  * Remove model
223  */
224  void removePrototype();
225 
226  /**
227  * @return current screen index
228  */
229  inline int getScreenIdx() {
230  return screenIdx;
231  }
232 
233  /**
234  * Set screen index
235  * @param screenIdx screen index
236  */
237  void setScreenIdx(int screenIdx);
238 
239  /**
240  * Store UI XML
241  */
242  void storeUIXML();
243 
244  /**
245  * Set visual mode
246  */
247  void setVisualEditor();
248 
249  /**
250  * Set text mode
251  */
252  void setCodeEditor();
253 
254  /**
255  * Update code editor
256  */
257  void updateCodeEditor();
258 
259  // overridden methods
260  void handleInputEvents() override;
261  void display() override;
262  inline const string& getTabId() override {
263  return tabId;
264  }
265  void initialize() override;
266  void dispose() override;
267  Engine* getEngine() override;
268  void activate() override;
269  void deactivate() override;
270  void reloadOutliner() override;
271  inline bool hasFixedSize() override;
272  void updateRendering() override;
273 
274  /**
275  * @return text index
276  */
277  int getTextIndex();
278 
279  /**
280  * Find string
281  * @param findString find string
282  * @param matchCase only find string that also matches case in find string
283  * @param wholeWord only find whole worlds
284  * @param selection only find in selection
285  * @param firstSearch first search
286  * @param index index
287  * @return success
288  */
289  bool find(const string& findString, bool matchCase, bool wholeWord, bool selection, bool firstSearch, int& index);
290 
291  /**
292  * Count string
293  * @param findString find string
294  * @param matchCase only find string that also matches case in find string
295  * @param wholeWord only find whole worlds
296  * @param selection only find in selection
297  */
298  int count(const string& findString, bool matchCase, bool wholeWord, bool selection);
299 
300  /**
301  * Replace string
302  * @param findString find string
303  * @param replaceString replace string
304  * @param matchCase only find string that also matches case in find string
305  * @param wholeWord only find whole worlds
306  * @param selection only find in selection
307  * @param index index
308  * @return success
309  */
310  bool replace(const string& findString, const string& replaceString, bool matchCase, bool wholeWord, bool selection, int& index);
311 
312  /**
313  * Replace all string
314  * @param findString find string
315  * @param replaceString replace string
316  * @param matchCase only find string that also matches case in find string
317  * @param wholeWord only find whole worlds
318  * @param selection only find in selection
319  * @return success
320  */
321  bool replaceAll(const string& findString, const string& replaceString, bool matchCase, bool wholeWord, bool selection);
322 
323  /**
324  * Cancel find
325  */
326  void cancelFind();
327 
328  /**
329  * Redo
330  */
331  void redo();
332 
333  /**
334  * Redo
335  */
336  void undo();
337 
338  /**
339  * Select all
340  */
341  void selectAll();
342 
343  /**
344  * Cut
345  */
346  void cut();
347 
348  /**
349  * Copy
350  */
351  void copy();
352 
353  /**
354  * Paste
355  */
356  void paste();
357 
358  /**
359  * Delete
360  */
361  void delete_();
362 
363 };
Engine main class.
Definition: Engine.h:131
Frame buffer class.
Definition: FrameBuffer.h:22
Prototype definition.
Definition: Prototype.h:55
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:72
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Definition: Matrix4x4.h:23
Pop ups controller accessor class.
Definition: PopUps.h:29
const TextFormatter::CodeCompletion * codeCompletion
void dispose() override
Disposes the view.
bool hasFixedSize() override
If this viewport framebuffer has a fixed size.
void display() override
Renders the view.
void reloadOutliner() override
Reload outliner.
unique_ptr< GUIStyledTextNodeController::CodeCompletionListener > textNodeCodeCompletionListener
void onCameraRotation() override
On rotation event to be overloaded.
bool replace(const string &findString, const string &replaceString, bool matchCase, bool wholeWord, bool selection, int &index)
Replace string.
Prototype * loadPrototype(const string &pathName, const string &fileName, const string &modelMeshNode, const string &modelMeshAnimation)
Load prototype.
void initialize() override
Initiates the view.
void setScreen(int screenIdx, const string &fileName)
Set screen.
void handleInputEvents() override
Handle input events that have not yet been processed.
void setModelMeshAnimation(const string &modelMeshAnimation)
Set model mesh animation.
void removeScreen(int screenIdx)
Remove screen.
unique_ptr< UIEditorTabController > uiTabController
unique_ptr< CameraRotationInputHandler > cameraRotationInputHandler
int count(const string &findString, bool matchCase, bool wholeWord, bool selection)
Count string.
unique_ptr< GUIStyledTextNodeController::ChangeListener > textNodeChangeListener
bool find(const string &findString, bool matchCase, bool wholeWord, bool selection, bool firstSearch, int &index)
Find string.
void unsetScreen(int screenIdx)
Unset screen.
UIEditorTabView(EditorView *editorView, const string &tabId, GUIScreenNode *screenNode, const string &fileName)
Public constructor.
void updateRendering() override
Update rendering.
void setModelMeshNode(const string &modelMeshNode)
Set model mesh node.
void setScreenIdx(int screenIdx)
Set screen index.
void onCameraScale() override
On scale event to be overloaded.
bool replaceAll(const string &findString, const string &replaceString, bool matchCase, bool wholeWord, bool selection)
Replace all string.
Float class.
Definition: Float.h:27
Tab controller, which connects UI with logic.
Definition: TabController.h:34
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6