1 | /*! |
---|
2 | * @file glgui_widget.h |
---|
3 | * The gl_widget of the openglGUI |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _GLGUI_WIDGET_H |
---|
7 | #define _GLGUI_WIDGET_H |
---|
8 | |
---|
9 | #include "element_2d.h" |
---|
10 | #include "event.h" |
---|
11 | #include "material.h" |
---|
12 | |
---|
13 | #include "glincl.h" |
---|
14 | #include "signal_connector.h" |
---|
15 | |
---|
16 | // FORWARD DECLARATION |
---|
17 | class Material; |
---|
18 | |
---|
19 | namespace OrxGui |
---|
20 | { |
---|
21 | |
---|
22 | typedef enum |
---|
23 | { |
---|
24 | Signal_click = 0, |
---|
25 | Signal_release, |
---|
26 | Signal_rollOn, |
---|
27 | Signal_rollOff, |
---|
28 | Signal_open, |
---|
29 | Signal_close, |
---|
30 | Signal_destroy, |
---|
31 | |
---|
32 | SignalCount, |
---|
33 | } SignalType; |
---|
34 | |
---|
35 | |
---|
36 | //! if the Element should be visible by default. |
---|
37 | #define GLGUI_WIDGET_DEFAULT_VISIBLE false |
---|
38 | |
---|
39 | //! This is widget part of the openglGUI class |
---|
40 | /** |
---|
41 | * A widget is the main class of all the elements of th GUI. |
---|
42 | */ |
---|
43 | class GLGuiWidget : public Element2D |
---|
44 | { |
---|
45 | private: |
---|
46 | |
---|
47 | public: |
---|
48 | GLGuiWidget(); |
---|
49 | virtual ~GLGuiWidget(); |
---|
50 | |
---|
51 | void show(); |
---|
52 | void hide(); |
---|
53 | |
---|
54 | void connectSignal(SignalType signalType, BaseObject* obj, const Executor* signal); |
---|
55 | void disconnectSignal(SignalType signalType); |
---|
56 | bool focusOverWidget(float x, float y); |
---|
57 | |
---|
58 | |
---|
59 | virtual void update() {}; |
---|
60 | virtual void draw() const; |
---|
61 | |
---|
62 | Material& backMaterial() { return this->backMat; }; |
---|
63 | const Material& backMaterial() const { return this->backMat; }; |
---|
64 | |
---|
65 | Material& frontMaterial() { return this->frontMat; }; |
---|
66 | const Material& frontMaterial() const { return this->frontMat; }; |
---|
67 | |
---|
68 | protected: |
---|
69 | // if something was clickt on the GUI-widget. |
---|
70 | virtual void clicked(const Event& event) {}; |
---|
71 | virtual void released(const Event& event) {}; |
---|
72 | |
---|
73 | virtual void receivedFocus() {}; |
---|
74 | virtual void removedFocus() {}; |
---|
75 | |
---|
76 | virtual void destroyed() {}; |
---|
77 | |
---|
78 | |
---|
79 | inline void startDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); }; |
---|
80 | inline void endDraw() const { glPopMatrix(); }; |
---|
81 | |
---|
82 | private: |
---|
83 | void init(); |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | protected: |
---|
89 | Material backMat; |
---|
90 | GLuint backModel; |
---|
91 | |
---|
92 | Material frontMat; |
---|
93 | GLuint frontModel; |
---|
94 | |
---|
95 | private: |
---|
96 | std::vector<SignalConnector> widgetSignals; |
---|
97 | |
---|
98 | bool focusable; //!< If this widget can receive focus. |
---|
99 | bool clickable; //!< if this widget can be clicked upon. |
---|
100 | }; |
---|
101 | } |
---|
102 | #endif /* _GLGUI_WIDGET_H */ |
---|