-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainwindow.h
executable file
·143 lines (102 loc) · 3.65 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <memory>
#include <map>
#include "postprocessor.h"
class QWidget;
class Renderer;
class EntityInfo;
class Component;
class PostProcessesWindow;
namespace Ui {
class MainWindow;
}
enum class ComponentType;
class QTreeWidgetItem;
class ComponentWidget;
/**
* @brief Holds all UI widgets and the renderer, helps control the lifetime of the app. When this window is closed the application quits.
*/
class MainWindow : public QMainWindow
{
friend class App;
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
/**
* @brief Updates the window status bar based on vertices renderer, FPS and time in ms between frames.
*/
void updateStatusBar(int vertices, float deltaTime, float frameCounter);
/**
* @brief Returns the render window.
*/
Renderer* getRenderer() { return mRenderer; }
Ui::MainWindow *ui;
EntityInfo* currentEntitySelected{nullptr};
EntityInfo* getEntityAt(QTreeWidgetItem* item);
/**
* @brief Sends the postprocessor info to the post processes window for setup.
*/
void addGlobalPostProcessing(const std::vector<std::pair<std::string, Postprocessor*>>& postprocessors);
signals:
void play();
void stop();
void toggleWireframe(bool value);
void shutUp(bool value);
void saveScene(const std::string& filePath);
void loadScene(const std::string& filePath);
void newScene();
void quitting();
public slots:
/**
* @brief Recreates the world outliner based on the entity info given.
*/
void updateUI(const std::vector<EntityInfo>& entityData);
void onWidgetRemoved(ComponentWidget* widget);
void refreshWidgets();
void setSceneName(const std::string& name);
private slots:
void on_actionEmpty_Object_triggered();
void on_actionCube_triggered();
void on_actionMonkey_triggered();
void on_actionPlay_triggered(bool value);
void on_button_AddComponent_clicked();
void on_lineEdit_SelectedObject_editingFinished();
void on_treeWidget_ObjectList_itemChanged(QTreeWidgetItem *item, int);
void on_treeWidget_ObjectList_itemClicked(QTreeWidgetItem *item, int);
void on_actionToggle_wireframe_triggered(bool checked);
void on_actionExit_triggered();
void on_actionToggle_shutup_triggered(bool checked);
void on_actionSave_triggered();
void on_actionLoad_triggered();
void on_actionNew_triggered();
void on_actionPost_Processes_triggered();
/**
* @brief Connected to the onSaveClicked signal in PostprocessorWindow. Updates the postprocessorsettings.json.
*/
void onPostprocessorSaved(const std::map<Postprocessor*, std::vector<Postprocessor::Setting>>& steps);
private:
/**
* @brief Recreates the component widgets given the entity.
*/
void updateComponentArea(unsigned int entityID);
/**
* @brief Updates the add component button and combobox with the types given
*/
void updateAvailableComponents(std::vector<ComponentType> types);
Renderer* mRenderer;
QWidget *mRenderWindowContainer;
std::vector<EntityInfo> mEntityDataCache;
std::vector<ComponentType> mAvailableComponentsToAddCache;
std::map<QTreeWidgetItem*, EntityInfo> mTreeDataCache;
std::vector<ComponentWidget*> mCurrentComponentWidgets;
void setSelected(EntityInfo *entityInfo);
void updateSelectedInTreeWidget(EntityInfo* entityInfo);
void updateEntityName(unsigned entity, const std::string &name);
PostProcessesWindow* mPostProcessesWindow;
protected:
void closeEvent(QCloseEvent* event) override;
};
#endif // MAINWINDOW_H