rt300@0
|
1 //
|
rt300@0
|
2 // ButtronSlider.h
|
rt300@0
|
3 // emptyExample
|
rt300@0
|
4 //
|
rt300@0
|
5 // Created by Robert Tubb on 22/05/2013.
|
rt300@0
|
6 //
|
rt300@0
|
7 //
|
rt300@0
|
8
|
rt300@0
|
9 #ifndef __emptyExample__ButtronSlider__
|
rt300@0
|
10 #define __emptyExample__ButtronSlider__
|
rt300@0
|
11 #include "Buttron.h"
|
rt300@0
|
12 #include <iostream>
|
rt300@0
|
13
|
rt300@0
|
14 class ButtronSlider : public Buttron{
|
rt300@0
|
15 public:
|
rt300@0
|
16
|
rt300@0
|
17 ~ButtronSlider(){};
|
rt300@0
|
18 ButtronSlider(float ax,
|
rt300@0
|
19 float ay,
|
rt300@0
|
20 float awidth,
|
rt300@0
|
21 float aheight,
|
rt300@0
|
22 float athickness,
|
rt300@0
|
23 float aradius,
|
rt300@0
|
24 ofColor aforegroundHi,
|
rt300@0
|
25 ofColor abackgroundHi,
|
rt300@0
|
26 ofColor aforegroundLo,
|
rt300@0
|
27 ofColor abackgroundLo,
|
rt300@0
|
28 SliderType type);
|
rt300@0
|
29
|
rt300@0
|
30 ButtronSlider(float ax,
|
rt300@0
|
31 float ay,
|
rt300@0
|
32 float awidth,
|
rt300@0
|
33 float aheight,
|
rt300@0
|
34 SliderType type,
|
rt300@0
|
35 const UIProps& props);
|
rt300@0
|
36
|
rt300@0
|
37 void init();
|
rt300@0
|
38 void draw(){
|
rt300@38
|
39 if(!isShowing()) return;
|
rt300@0
|
40 Buttron::draw();
|
rt300@27
|
41 ofDisableDepthTest();
|
rt300@0
|
42 drawIndicator(value);
|
rt300@0
|
43 if(hintShowing) drawHintIndicator();
|
rt300@37
|
44
|
rt300@27
|
45 ofEnableDepthTest();
|
rt300@0
|
46 }
|
rt300@0
|
47
|
rt300@0
|
48 void setHintValue(double hval){
|
rt300@0
|
49 hintValue = (hval - minVal)/(maxVal - minVal);
|
rt300@0
|
50 };
|
rt300@0
|
51 void setHintColor(ofColor c){
|
rt300@0
|
52 hintColor = c;
|
rt300@0
|
53 };
|
rt300@22
|
54 void setColor(ofColor c){
|
rt300@22
|
55 foregroundHi = c;
|
rt300@22
|
56 foregroundLo = c;
|
rt300@22
|
57 }
|
rt300@0
|
58 void showHint(bool tf){
|
rt300@0
|
59 hintShowing = tf;
|
rt300@0
|
60 };
|
rt300@0
|
61 void setValue(double avalue){
|
rt300@0
|
62 // scale appropriately to 0-1 (maxVal - minVal)*prop + minVal
|
rt300@0
|
63 value = avalue; // (avalue - minVal)/(maxVal - minVal);
|
rt300@0
|
64 };
|
rt300@0
|
65
|
rt300@0
|
66 void setValueAndScale(double avalue){
|
rt300@0
|
67 // scale appropriately to 0-1 (maxVal - minVal)*prop + minVal
|
rt300@0
|
68 value = (avalue - minVal)/(maxVal - minVal);
|
rt300@38
|
69 if (value > 1.) value = 1.;
|
rt300@38
|
70 if (value < 0.) value = 0.;
|
rt300@0
|
71 };
|
rt300@27
|
72 void showValueIndicator(bool show){
|
rt300@27
|
73 indicatorShowing = show;
|
rt300@27
|
74 }
|
rt300@0
|
75 virtual bool handleMyTouch(int x, int y, touchType ttype, int touchID);
|
rt300@0
|
76
|
rt300@0
|
77 void setRange(float lo, float hi){
|
rt300@0
|
78 minVal = lo;
|
rt300@0
|
79 maxVal = hi;
|
rt300@0
|
80 }
|
rt300@37
|
81
|
rt300@37
|
82 void setHandTexture(ofImage* img){
|
rt300@41
|
83 if(img != NULL){
|
rt300@41
|
84 handTextureRef = img;
|
rt300@41
|
85 }else{
|
rt300@41
|
86 handTextureRef = &defaultImage;
|
rt300@41
|
87 }
|
rt300@37
|
88
|
rt300@37
|
89 }
|
rt300@29
|
90 void animateHintToNewValue(int newVal, float timeToTake);
|
rt300@31
|
91 void animateToNewValue(int newVal, float timeToTake);
|
rt300@29
|
92 void update();
|
rt300@39
|
93 void flashScore(int score, ofColor col, int howLong);
|
rt300@37
|
94
|
rt300@0
|
95 private:
|
rt300@0
|
96 void drawIndicator(double proportion);
|
rt300@0
|
97 float minVal;
|
rt300@0
|
98 float maxVal;
|
rt300@0
|
99 void drawHintIndicator();
|
rt300@0
|
100 SliderType sliderType;
|
rt300@0
|
101 float value; // [0. 1.]
|
rt300@0
|
102 float hintValue;
|
rt300@31
|
103
|
rt300@31
|
104 float hintTargVal;
|
rt300@31
|
105 float targVal;
|
rt300@31
|
106
|
rt300@29
|
107 float posAnimIncr;
|
rt300@47
|
108 float animFrac;
|
rt300@31
|
109 float hintPosAnimIncr;
|
rt300@0
|
110 bool hintShowing;
|
rt300@27
|
111 bool indicatorShowing;
|
rt300@0
|
112 ofColor hintColor;
|
rt300@37
|
113 ofColor flashColor;
|
rt300@29
|
114 bool animating;
|
rt300@37
|
115 int showScoreForFrames;
|
rt300@37
|
116
|
rt300@37
|
117 ofImage* handTextureRef;
|
rt300@37
|
118 ofImage defaultImage;
|
rt300@0
|
119 };
|
rt300@0
|
120
|
rt300@0
|
121 #endif /* defined(__emptyExample__ButtronSlider__) */
|