-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathofxLabel.h
64 lines (51 loc) · 2.15 KB
/
ofxLabel.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
#pragma once
#include "ofxBaseGui.h"
#include "ofParameter.h"
#include "ofPath.h"
#include "ofVboMesh.h"
class ofxLabel: public ofxBaseGui {
public:
ofxLabel(){label.setSerializable(false);}
ofxLabel(ofParameter<std::string> _label, float width = defaultWidth, float height = defaultHeight);
template<typename F>
ofxLabel(ofReadOnlyParameter<std::string,F> _label, float width = defaultWidth, float height = defaultHeight){
setup(_label, width, height);
}
virtual ~ofxLabel();
ofxLabel * setup(ofParameter<std::string> _label, float width = defaultWidth, float height = defaultHeight);
template<typename F>
ofxLabel* setup(ofReadOnlyParameter<std::string,F> _label, float width, float height) {
label.makeReferenceTo(_label);
b.width = width;
b.height = height;
setNeedsRedraw();
_label.addListener(this,&ofxLabel::valueChanged);
return this;
}
ofxLabel * setup(const std::string& labelName, std::string label, float width = defaultWidth, float height = defaultHeight);
// Abstract methods we must implement, but have no need for!
virtual bool mouseMoved(ofMouseEventArgs & args){return false;}
virtual bool mousePressed(ofMouseEventArgs & args){return false;}
virtual bool mouseDragged(ofMouseEventArgs & args){return false;}
virtual bool mouseReleased(ofMouseEventArgs & args){return false;}
virtual bool mouseScrolled(ofMouseEventArgs & args){return false;}
template<class ListenerClass, typename ListenerMethod>
void addListener(ListenerClass * listener, ListenerMethod method){
label.addListener(listener,method);
}
template<class ListenerClass, typename ListenerMethod>
void removeListener(ListenerClass * listener, ListenerMethod method){
label.removeListener(listener,method);
}
std::string operator=(std::string v) { label = v; return v; }
operator const std::string & () { return label; }
ofAbstractParameter & getParameter();
protected:
void render();
ofReadOnlyParameter<std::string, ofxLabel> label;
void generateDraw();
void valueChanged(std::string & value);
bool setValue(float mx, float my, bool bCheckBounds){return false;}
ofPath bg;
ofVboMesh textMesh;
};