Mercurial > hg > tweakathon2ios
comparison UI code/targetSymbol.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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a223551fdc1f |
---|---|
1 // | |
2 // targetSymbol.h | |
3 // tweakathlon | |
4 // | |
5 // Created by Robert Tubb on 11/02/2014. | |
6 // | |
7 // | |
8 | |
9 #ifndef __tweakathlon__targetSymbol__ | |
10 #define __tweakathlon__targetSymbol__ | |
11 | |
12 #include <iostream> | |
13 #include "UIElement.h" | |
14 #include "timeController.h" | |
15 extern TimeController timeController; | |
16 class TargetSymbol : public UIElement { | |
17 public: | |
18 | |
19 TargetSymbol(int ax, int ay,int aw, const UIProps& props): | |
20 UIElement(ax,ay,aw,aw, props) | |
21 { | |
22 foregroundHi = props.buttonHi; | |
23 backgroundHi = props.generalBackground; | |
24 foregroundLo = props.inactiveGreyedOut; // can't be touched | |
25 backgroundLo = props.generalBackground; | |
26 flashing = false; | |
27 on = false; | |
28 }; | |
29 | |
30 void draw(){ | |
31 if(hidden)return; | |
32 //UIElement::draw(); // don't do background | |
33 ofColor fg,bg; | |
34 | |
35 if(on){ | |
36 fg = foregroundHi; | |
37 bg = backgroundHi; | |
38 }else{ | |
39 fg = foregroundLo; | |
40 bg = backgroundLo; | |
41 } | |
42 ofSetColor(fg); | |
43 | |
44 ofEllipse(x,y,width,height); | |
45 | |
46 ofSetColor(bg); | |
47 ofEllipse(x,y,width*0.66,height*0.66); | |
48 | |
49 ofSetColor(fg); | |
50 ofEllipse(x,y,width*0.33,height*0.33); | |
51 | |
52 }; | |
53 | |
54 void flash(){ | |
55 // turn hilight on and off | |
56 if (!flashing){ | |
57 setHighlight(true); | |
58 | |
59 // set up timer | |
60 TimerCallbackFunction tcb; | |
61 tcb = boost::bind(&TargetSymbol::flash, this); | |
62 timeController.scheduleEvent(tcb, int(ALTERNATION_SPEED/4)); | |
63 flashing = true; | |
64 }else{ | |
65 setHighlight(false); | |
66 | |
67 flashing = false; | |
68 } | |
69 | |
70 } | |
71 | |
72 bool handleMyTouch(int x, int y, touchType ttype, int touchID){ | |
73 return false; // or? | |
74 } | |
75 | |
76 private: | |
77 ofColor foregroundHi; | |
78 ofColor backgroundHi; | |
79 ofColor foregroundLo; | |
80 ofColor backgroundLo; | |
81 ofColor fgInactive; | |
82 bool flashing; | |
83 }; | |
84 #endif /* defined(__tweakathlon__targetSymbol__) */ |