Mercurial > hg > tweakathon2ios
comparison UI code/ButtronSlider.h @ 0:a223551fdc1f
First commit - copy from tweakathlon.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 10 Oct 2014 11:46:42 +0100 |
parents | |
children | 8124f46eda65 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a223551fdc1f |
---|---|
1 // | |
2 // ButtronSlider.h | |
3 // emptyExample | |
4 // | |
5 // Created by Robert Tubb on 22/05/2013. | |
6 // | |
7 // | |
8 | |
9 #ifndef __emptyExample__ButtronSlider__ | |
10 #define __emptyExample__ButtronSlider__ | |
11 #include "Buttron.h" | |
12 #include <iostream> | |
13 | |
14 class ButtronSlider : public Buttron{ | |
15 public: | |
16 | |
17 ~ButtronSlider(){}; | |
18 ButtronSlider(float ax, | |
19 float ay, | |
20 float awidth, | |
21 float aheight, | |
22 float athickness, | |
23 float aradius, | |
24 ofColor aforegroundHi, | |
25 ofColor abackgroundHi, | |
26 ofColor aforegroundLo, | |
27 ofColor abackgroundLo, | |
28 SliderType type); | |
29 | |
30 ButtronSlider(float ax, | |
31 float ay, | |
32 float awidth, | |
33 float aheight, | |
34 SliderType type, | |
35 const UIProps& props); | |
36 | |
37 void init(); | |
38 void draw(){ | |
39 Buttron::draw(); | |
40 drawIndicator(value); | |
41 if(hintShowing) drawHintIndicator(); | |
42 } | |
43 | |
44 void setHintValue(double hval){ | |
45 hintValue = (hval - minVal)/(maxVal - minVal); | |
46 }; | |
47 void setHintColor(ofColor c){ | |
48 hintColor = c; | |
49 }; | |
50 void showHint(bool tf){ | |
51 hintShowing = tf; | |
52 }; | |
53 void setValue(double avalue){ | |
54 // scale appropriately to 0-1 (maxVal - minVal)*prop + minVal | |
55 value = avalue; // (avalue - minVal)/(maxVal - minVal); | |
56 }; | |
57 | |
58 void setValueAndScale(double avalue){ | |
59 // scale appropriately to 0-1 (maxVal - minVal)*prop + minVal | |
60 value = (avalue - minVal)/(maxVal - minVal); | |
61 }; | |
62 | |
63 virtual bool handleMyTouch(int x, int y, touchType ttype, int touchID); | |
64 | |
65 void setRange(float lo, float hi){ | |
66 minVal = lo; | |
67 maxVal = hi; | |
68 } | |
69 | |
70 private: | |
71 void drawIndicator(double proportion); | |
72 float minVal; | |
73 float maxVal; | |
74 void drawHintIndicator(); | |
75 SliderType sliderType; | |
76 float value; // [0. 1.] | |
77 float hintValue; | |
78 bool hintShowing; | |
79 ofColor hintColor; | |
80 }; | |
81 | |
82 #endif /* defined(__emptyExample__ButtronSlider__) */ |