-
Notifications
You must be signed in to change notification settings - Fork 51
/
applicationmode.h
83 lines (78 loc) · 2.16 KB
/
applicationmode.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
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "uilayer.h"
// component implementing specific mode of application behaviour
// base interface
class application_mode {
public:
// destructor
virtual
~application_mode() = default;
// methods;
// initializes internal data structures of the mode. returns: true on success, false otherwise
virtual
bool
init() = 0;
// mode-specific update of simulation data. returns: false on error, true otherwise
virtual
bool
update() = 0;
// draws mode-specific user interface
inline
void
render_ui() {
if( m_userinterface != nullptr ) {
m_userinterface->render(); } }
inline
void
begin_ui_frame() {
if( m_userinterface != nullptr ) {
m_userinterface->begin_ui_frame(); } }
inline
void
set_progress( float const Progress = 0.f, float const Subtaskprogress = 0.f ) {
if( m_userinterface != nullptr ) {
m_userinterface->set_progress( Progress, Subtaskprogress ); } }
inline
void
set_tooltip( std::string const &Tooltip ) {
if( m_userinterface != nullptr ) {
m_userinterface->set_tooltip( Tooltip ); } }
// maintenance method, called when the mode is activated
virtual
void
enter() = 0;
// maintenance method, called when the mode is deactivated
virtual
void
exit() = 0;
// input handlers
virtual
void
on_key( int const Key, int const Scancode, int const Action, int const Mods ) = 0;
virtual
void
on_cursor_pos( double const X, double const Y ) = 0;
virtual
void
on_mouse_button( int const Button, int const Action, int const Mods ) = 0;
virtual
void
on_scroll( double const Xoffset, double const Yoffset ) = 0;
virtual
void
on_event_poll() = 0;
virtual
bool
is_command_processor() const = 0;
protected:
// members
std::shared_ptr<ui_layer> m_userinterface;
};