comparison UI code/CountdownText.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 // CountdownText.h
3 // tweakathlon
4 //
5 // Created by Robert Tubb on 10/03/2014.
6 //
7 //
8
9 #ifndef __tweakathlon__CountdownText__
10 #define __tweakathlon__CountdownText__
11
12 #include <iostream>
13
14 #include "ofMain.h"
15 #include "UIElement.h"
16 #include "timeController.h"
17 #include "boost/function.hpp"
18 #include "boost/bind.hpp"
19 // actuall a countdown box
20 extern TimeController timeController;
21 class CountdownText : public UIElement{
22 public:
23
24 CountdownText(string text, int x, int y,int w,int h, const UIProps& props);
25 void draw();
26
27 ofColor foregroundHi;
28 ofColor backgroundHi;
29 ofColor foregroundLo;
30 ofColor backgroundLo;
31
32 bool handleMyTouch(int x, int y, touchType ttype, int touchID){
33 return false;
34 }
35
36 void showAndStart(int sec){
37 show();
38 stringstream s;
39 s << sec;
40 numSecondsText = s.str();
41 t = sec;
42 timeController.scheduleEvent(tcb, 1000);
43 };
44
45 void secPassed(){
46 t--;
47 if(t <= 0){
48 //finish
49 numSecondsText = "0!";
50 }else{
51 stringstream ts;
52 ts << t;
53 numSecondsText = ts.str();
54 timeController.scheduleEvent(tcb, 1000);
55 }
56 };
57 void setTestTypeString(string s){
58 testTypeString = s;
59 }
60 private:
61 int t;
62 TimerCallbackFunction tcb;
63 string testTypeString;
64 string numSecondsText;
65 };
66
67
68
69 #endif /* defined(__tweakathlon__CountdownText__) */