This repository has been archived by the owner on Dec 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 198
/
ofxUIWidget.h
executable file
·229 lines (171 loc) · 6.97 KB
/
ofxUIWidget.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/**********************************************************************************
Copyright (C) 2012 Syed Reza Ali (www.syedrezaali.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
**********************************************************************************/
#pragma once
#include "ofxUIWrapper.h"
#include "ofxUIDefines.h"
#ifndef OFX_UI_NO_XML
#include "ofxXmlSettings.h"
#endif
class ofxUIWidget
{
public:
ofxUIWidget();
virtual ~ofxUIWidget();
ofxUIWidget(const ofxUIWidget &other); // Mitchell Nordine 2/2/14
virtual ofxUIWidget& operator=(const ofxUIWidget &other); // Mitchell Nordine 2/2/14
virtual void initRect(float x = 0, float y = 0, float w = 0, float h = 0);
virtual void initPaddingRect();
virtual void calculatePaddingRect();
virtual void setup();
virtual void update();
virtual void draw();
virtual void drawBack();
virtual void drawOutline();
virtual void drawOutlineHighlight();
virtual void drawFill();
virtual void drawFillHighlight();
virtual void drawPadded();
virtual void drawPaddedOutline();
#ifdef OFX_UI_TARGET_TOUCH
void touchDown(float x, float y, int id);
void touchMoved(float x, float y, int id);
void touchUp(float x, float y, int id);
void touchCancelled(float x, float y, int id);
void touchDoubleTap(float x, float y, int id) {}
#endif
virtual void mouseMoved(int x, int y ) {}
virtual void mouseDragged(int x, int y, int button) {}
virtual void mousePressed(int x, int y, int button) {}
virtual void mouseReleased(int x, int y, int button) {}
virtual void keyPressed(int key) {}
virtual void keyReleased(int key) {}
virtual void windowResized(int w, int h) {}
ofxUIWidget* setTriggerType(ofxUITriggerType _triggerType);
ofxUITriggerType getTriggerType();
virtual void setParent(ofxUIWidget *_parent);
virtual ofxUIWidget *getParent();
virtual void setName(string _name);
virtual string& getName();
virtual void setModal(bool _modal);
virtual bool isModal();
virtual void setVisible(bool _visible);
virtual bool isVisible();
virtual void toggleVisible();
virtual void setEmbedded(bool _embedded);
virtual bool isEmbedded();
void setID(int _id);
int getID();
virtual void setKind(ofxUIWidgetType _kind);
virtual ofxUIWidgetType getKind();
virtual bool isDraggable();
virtual bool hasLabel();
virtual void triggerEvent(ofxUIWidget *child);
virtual void triggerSelf();
virtual void stateChange();
virtual bool isHit(float x, float y);
virtual void addWidget(ofxUIWidget *widget);
virtual void removeWidget(ofxUIWidget *widget);
virtual void addEmbeddedWidget(ofxUIWidget *widget);
virtual void clearEmbeddedWidgets();
virtual int getEmbeddedWidgetsSize();
ofxUIWidget *getEmbeddedWidget(int index);
virtual void setState(int _state);
virtual int getState();
virtual void setFont(ofxUIFont *_font);
virtual void setPadding(float _padding);
virtual float getPadding();
virtual ofxUIRectangle* getRect();
virtual ofxUIRectangle *getPaddingRect();
virtual void setRectParent(ofxUIRectangle *_prect);
virtual void setDrawPadding(bool _draw_padded_rect);
virtual bool getDrawPadding();
virtual void setDrawPaddingOutline(bool _draw_padded_rect_outline);
virtual bool getDrawPaddingOutline();
virtual void setDrawBack(bool _draw_back);
virtual bool getDrawBack();
virtual void setDrawOutline(bool _draw_outline);
virtual bool getDrawOutline();
virtual void setDrawFill(bool _draw_fill);
virtual bool getDrawFill();
virtual void setDrawFillHighLight(bool _draw_fill_highlight);
virtual bool getDrawFillHighLight();
virtual void setDrawOutlineHighLight(bool _draw_outline_hightlight);
virtual bool getDrawOutlineHighLight();
virtual void setColorBack(ofxUIColor _color_back);
ofxUIColor& getColorBack();
virtual void setColorOutline(ofxUIColor _color_outline);
ofxUIColor& getColorOutline();
virtual void setColorOutlineHighlight(ofxUIColor _color_outline_highlight);
ofxUIColor& getColorOutlineHighlight();
virtual void setColorFill(ofxUIColor _color_fill);
ofxUIColor& getColorFill();
virtual void setColorFillHighlight(ofxUIColor _color_fill_highlight);
ofxUIColor& getColorFillHighlight();
virtual void setColorPadded(ofxUIColor _color_padded_rect);
ofxUIColor& getColorPadded();
virtual void setColorPaddedOutline(ofxUIColor _color_padded_rect_outline);
ofxUIColor& getColorPaddedOutline();
virtual void addModalWidget(ofxUIWidget *widget);
virtual void removeModalWidget(ofxUIWidget *widget);
ofxUIWidget *getCanvasParent();
virtual bool hasState();
virtual bool getIsBindedToKey(int key);
virtual ofxUIWidget* bindToKey(int key);
virtual ofxUIWidget* unbindToKey(int key);
virtual ofxUIWidget* unbindAllKeys();
#ifndef OFX_UI_NO_XML
virtual void saveState(ofxXmlSettings *XML);
virtual void loadState(ofxXmlSettings *XML);
#endif
protected:
ofxUIWidget *parent;
ofxUIRectangle *rect;
ofxUIFont *font;
std::string name;
ofxUIWidgetType kind;
bool visible;
int ID;
bool hit;
int state;
ofxUITriggerType triggerType;
bool embedded;
bool modal;
bool draw_back;
bool draw_outline;
bool draw_outline_highlight;
bool draw_fill;
bool draw_fill_highlight;
ofxUIColor color_back;
ofxUIColor color_outline;
ofxUIColor color_outline_highlight;
ofxUIColor color_fill;
ofxUIColor color_fill_highlight;
float padding;
ofxUIRectangle *paddedRect;
bool draw_padded_rect;
bool draw_padded_rect_outline;
ofxUIColor color_padded_rect;
ofxUIColor color_padded_rect_outline;
vector<ofxUIWidget *> embeddedWidgets;
bool bKeyHit;
map<int, bool> keyBindings;
#ifdef OFX_UI_TARGET_TOUCH
int touchId;
#endif
};