-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMainWindow.h
62 lines (57 loc) · 3.53 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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "DemoScene.h"
#include "ui_mainwindow.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
//-----------------------------------------------------------------------------------------------------
/// @brief Explcit constructor for the main window. It is explicit so QWidgets can't be implicitly cast
/// to MainWindows.
/// @param [io] io_parent the parent widget of this window.
//-----------------------------------------------------------------------------------------------------
explicit MainWindow(QWidget *io_parent = nullptr) :
QMainWindow(io_parent)
{}
//-----------------------------------------------------------------------------------------------------
/// @brief Default destructor
//-----------------------------------------------------------------------------------------------------
~MainWindow() = default;
//-----------------------------------------------------------------------------------------------------
/// @brief Used to initialise the Window with a Scene, placing it in the central widget.
/// @param [io] io_scene is the scene to be placed in the central widget.
//-----------------------------------------------------------------------------------------------------
void init(const std::shared_ptr<Scene> &io_scene);
private:
//-----------------------------------------------------------------------------------------------------
/// @brief Used to handle a key press, will get delegated to the scene.
/// @param [io] io_event the key that was pressed.
//-----------------------------------------------------------------------------------------------------
void keyPressEvent(QKeyEvent * io_event);
//-----------------------------------------------------------------------------------------------------
/// @brief Used to handle a mouse move, will get delegated to the scene.
/// @param [io] io_event contains the mouse position.
//-----------------------------------------------------------------------------------------------------
void mouseMoveEvent(QMouseEvent * io_event);
//-----------------------------------------------------------------------------------------------------
/// @brief Used to handle a mouse button press, will get delegated to the scene.
/// @param [io] io_event contains the mouse button that was pressed.
//-----------------------------------------------------------------------------------------------------
void mousePressEvent(QMouseEvent *io_event);
//-----------------------------------------------------------------------------------------------------
/// @brief Used to handle a mouse button release, will get delegated to the scene.
/// @param [io] io_event contains the mouse button that was released.
//-----------------------------------------------------------------------------------------------------
void mouseReleaseEvent(QMouseEvent *io_event);
//-----------------------------------------------------------------------------------------------------
/// @brief The Qt UI form.
//-----------------------------------------------------------------------------------------------------
Ui::MainWindow m_ui;
//-----------------------------------------------------------------------------------------------------
/// @brief A pointer to the scene that should be placed in the central widget.
//-----------------------------------------------------------------------------------------------------
std::shared_ptr<Scene> m_scene = nullptr;
};
#endif // MAINWINDOW_H