Ocular Engine
SceneTree.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_EDITOR_SCENE_TREE__H__
19 #define __H__OCULAR_EDITOR_SCENE_TREE__H__
20 
21 #include <QtWidgets/qtreewidget.h>
22 #include "Events/AEventListener.hpp"
23 
24 //------------------------------------------------------------------------------------------
25 
30 namespace Ocular
31 {
36  namespace Editor
37  {
38  class SceneTreeItem;
39 
44  class SceneTree : public QTreeWidget, public Ocular::Core::AEventListener
45  {
46  Q_OBJECT
47 
48  public:
49 
50  SceneTree(QWidget* parent = nullptr);
51  ~SceneTree();
52 
53  virtual QSize sizeHint() const override;
54 
58  void update();
59 
67 
74  SceneTreeItem* getItem(Core::UUID const& uuid);
75 
79  void addObject(Core::SceneObject* object);
80 
84  void removeObject(Core::UUID const& uuid);
85 
91  void selectObject(Core::SceneObject* object);
92 
98  void selectObject(Core::UUID const& uuid);
99 
100  protected:
101 
102  virtual void mousePressEvent(QMouseEvent* event) override;
103  virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
104  virtual void dropEvent(QDropEvent* event) override;
105 
106  virtual bool onEvent(std::shared_ptr<Core::AEvent> event) override;
107 
108  bool isObjectTracked(Core::SceneObject* object);
109  void createObject(std::string const& type, Core::SceneObject* parent);
110  uint32_t getItemDepth(QTreeWidgetItem* item) const;
111 
112  private slots:
113 
114  void onShowContextMenu(QPoint const& pos);
115 
116  void handleContextMenuNoSelection(QMenu* menu, QPoint const& globalPos);
117  void handleContextMenuSingleSelection(QMenu* menu, QPoint const& globalPos);
118  void handleContextMenuMultiSelection(QMenu* menu, QPoint const& globalPos, uint32_t numSelected);
119 
120  void handleContextMenuAction(QAction* action);
121  void handleContextMenuActionDuplicate();
122  void handleContextMenuActionRename();
123  void handleContextMenuActionDelete();
124  void handleContextMenuActionCreateObject(std::string const& type);
125 
126  void populateAddObjectSubmenu(QMenu* submenu);
127 
128  private:
129 
130  };
131  }
135 }
140 //------------------------------------------------------------------------------------------
141 
142 #endif
Definition: SceneTreeItem.hpp:49
Definition: AEventListener.hpp:43
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
SceneTreeItem * getItem(Core::SceneObject *object)
Definition: SceneTree.cpp:96
Definition: SceneObject.hpp:93
Definition: UUID.hpp:45
Definition: SceneTree.hpp:44
void selectObject(Core::SceneObject *object)
Definition: SceneTree.cpp:174
void update()
Definition: SceneTree.cpp:83