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@0
|
39 Buttron::draw();
|
rt300@0
|
40 drawIndicator(value);
|
rt300@0
|
41 if(hintShowing) drawHintIndicator();
|
rt300@0
|
42 }
|
rt300@0
|
43
|
rt300@0
|
44 void setHintValue(double hval){
|
rt300@0
|
45 hintValue = (hval - minVal)/(maxVal - minVal);
|
rt300@0
|
46 };
|
rt300@0
|
47 void setHintColor(ofColor c){
|
rt300@0
|
48 hintColor = c;
|
rt300@0
|
49 };
|
rt300@0
|
50 void showHint(bool tf){
|
rt300@0
|
51 hintShowing = tf;
|
rt300@0
|
52 };
|
rt300@0
|
53 void setValue(double avalue){
|
rt300@0
|
54 // scale appropriately to 0-1 (maxVal - minVal)*prop + minVal
|
rt300@0
|
55 value = avalue; // (avalue - minVal)/(maxVal - minVal);
|
rt300@0
|
56 };
|
rt300@0
|
57
|
rt300@0
|
58 void setValueAndScale(double avalue){
|
rt300@0
|
59 // scale appropriately to 0-1 (maxVal - minVal)*prop + minVal
|
rt300@0
|
60 value = (avalue - minVal)/(maxVal - minVal);
|
rt300@0
|
61 };
|
rt300@0
|
62
|
rt300@0
|
63 virtual bool handleMyTouch(int x, int y, touchType ttype, int touchID);
|
rt300@0
|
64
|
rt300@0
|
65 void setRange(float lo, float hi){
|
rt300@0
|
66 minVal = lo;
|
rt300@0
|
67 maxVal = hi;
|
rt300@0
|
68 }
|
rt300@0
|
69
|
rt300@0
|
70 private:
|
rt300@0
|
71 void drawIndicator(double proportion);
|
rt300@0
|
72 float minVal;
|
rt300@0
|
73 float maxVal;
|
rt300@0
|
74 void drawHintIndicator();
|
rt300@0
|
75 SliderType sliderType;
|
rt300@0
|
76 float value; // [0. 1.]
|
rt300@0
|
77 float hintValue;
|
rt300@0
|
78 bool hintShowing;
|
rt300@0
|
79 ofColor hintColor;
|
rt300@0
|
80 };
|
rt300@0
|
81
|
rt300@0
|
82 #endif /* defined(__emptyExample__ButtronSlider__) */
|