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
144
145
146
147
148
149
150
|
#pragma once
#include <vector>
//#include "Platform.h"
#include "interface/Point.h"
#include "interface/Window.h"
#include "interface/Component.h"
#ifdef OGLI
#include "graphics/OpenGLHeaders.h"
#endif
class Graphics;
namespace ui
{
/* class XComponent
*
* An eXtension of the Component class.
* Adds the ability to have child components.
*
* See sys::Component
*/
class Component;
class Panel : public Component
{
public:
friend class Component;
#ifdef OGLI
GLuint myVid, myVidTex;
#else
pixel * myVid;
#endif
ui::Point InnerSize;
ui::Point ViewportPosition;
Panel(Point position, Point size);
virtual ~Panel();
/* Add a child component.
* Similar to XComponent::SetParent
*
* If the component is already parented, then this will become the new parent.
*/
void AddChild(Component* c);
// Remove child from component. This DOES NOT free the component from memory.
void RemoveChild(Component* c);
// Remove child from component. This WILL free the component from memory unless told otherwise.
void RemoveChild(unsigned idx, bool freeMem = true);
//Grab the number of children this component owns.
int GetChildCount();
//Get child of this component by index.
Component* GetChild(unsigned idx);
void Tick(float dt);
void Draw(const Point& screenPos);
void OnMouseHover(int localx, int localy);
void OnMouseMoved(int localx, int localy, int dx, int dy);
void OnMouseMovedInside(int localx, int localy, int dx, int dy);
void OnMouseEnter(int localx, int localy);
void OnMouseLeave(int localx, int localy);
void OnMouseDown(int x, int y, unsigned button);
void OnMouseUp(int x, int y, unsigned button);
void OnMouseClick(int localx, int localy, unsigned button);
void OnMouseUnclick(int localx, int localy, unsigned button);
void OnMouseWheel(int localx, int localy, int d);
void OnMouseWheelInside(int localx, int localy, int d);
void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
protected:
// child components
std::vector<ui::Component*> children;
bool mouseInside;
//UI functions:
/*
void XTick(float dt);
void XDraw(const Point& screenPos);
void XOnMouseHover(int localx, int localy);
void XOnMouseMoved(int localx, int localy, int dx, int dy);
void XOnMouseMovedInside(int localx, int localy, int dx, int dy);
void XOnMouseEnter(int localx, int localy);
void XOnMouseLeave(int localx, int localy);
void XOnMouseDown(int x, int y, unsigned int button);
void XOnMouseUp(int x, int y, unsigned int button);
void XOnMouseClick(int localx, int localy, unsigned int button);
void XOnMouseUnclick(int localx, int localy, unsigned int button);
void XOnMouseWheel(int localx, int localy, int d);
void XOnMouseWheelInside(int localx, int localy, int d);
void XOnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void XOnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
*/
// Overridable. Called by XComponent::Tick()
virtual void XTick(float dt);
// Overridable. Called by XComponent::Draw()
virtual void XDraw(const Point& screenPos);
// Overridable. Called by XComponent::XOnMouseHover()
virtual void XOnMouseHover(int localx, int localy);
// Overridable. Called by XComponent::OnMouseMoved()
virtual void XOnMouseMoved(int localx, int localy, int dx, int dy);
// Overridable. Called by XComponent::OnMouseMovedInside()
virtual void XOnMouseMovedInside(int localx, int localy, int dx, int dy);
// Overridable. Called by XComponent::OnMouseEnter()
virtual void XOnMouseEnter(int localx, int localy);
// Overridable. Called by XComponent::OnMouseLeave()
virtual void XOnMouseLeave(int localx, int localy);
// Overridable. Called by XComponent::OnMouseDown()
virtual void XOnMouseDown(int x, int y, unsigned button);
// Overridable. Called by XComponent::OnMouseUp()
virtual void XOnMouseUp(int x, int y, unsigned button);
// Overridable. Called by XComponent::OnMouseClick()
virtual void XOnMouseClick(int localx, int localy, unsigned button);
// Overridable. Called by XComponent::OnMouseUnclick()
virtual void XOnMouseUnclick(int localx, int localy, unsigned button);
// Overridable. Called by XComponent::OnMouseWheel()
virtual void XOnMouseWheel(int localx, int localy, int d);
// Overridable. Called by XComponent::OnMouseWheelInside()
virtual void XOnMouseWheelInside(int localx, int localy, int d);
// Overridable. Called by XComponent::OnKeyPress()
virtual void XOnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
// Overridable. Called by XComponent::OnKeyRelease()
virtual void XOnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
};
}
|