rt300@0: // rt300@0: // textLabel.h rt300@0: // tweakathlon rt300@0: // rt300@0: // Created by Robert Tubb on 10/02/2014. rt300@0: // rt300@0: // rt300@0: rt300@0: #ifndef __tweakathlon__textLabel__ rt300@0: #define __tweakathlon__textLabel__ rt300@0: rt300@0: #include rt300@0: #include "ofMain.h" rt300@0: #include "UIElement.h" rt300@0: #include "timeController.h" rt300@0: #include "boost/function.hpp" rt300@0: #include "boost/bind.hpp" rt300@0: // actuall a countdown box rt300@0: extern TimeController timeController; rt300@0: class TextLabel : public UIElement{ rt300@0: public: rt300@0: rt300@0: TextLabel(string text, int x, int y,int w,int h, const UIProps& props); rt300@0: void draw(); rt300@0: rt300@0: void setText(string at){ rt300@0: labelName = at; rt300@0: }; rt300@0: rt300@0: ofColor foregroundHi; rt300@0: ofColor backgroundHi; rt300@0: ofColor foregroundLo; rt300@0: ofColor backgroundLo; rt300@0: rt300@0: bool handleMyTouch(int x, int y, touchType ttype, int touchID){ rt300@0: return false; rt300@0: } rt300@0: rt300@0: void showAndStart(int sec){ rt300@0: show(); rt300@0: stringstream s; rt300@0: s << sec; rt300@0: labelName = s.str(); rt300@0: t = sec; rt300@0: timeController.scheduleEvent(tcb, 1000); rt300@0: }; rt300@0: rt300@0: void secPassed(){ rt300@0: t--; rt300@0: if(t <= 0){ rt300@0: //finish rt300@0: labelName = "!"; rt300@0: }else{ rt300@0: stringstream ts; rt300@0: ts << t; rt300@0: labelName = ts.str(); rt300@0: timeController.scheduleEvent(tcb, 1000); rt300@0: } rt300@0: }; rt300@0: private: rt300@0: int t; rt300@0: TimerCallbackFunction tcb; rt300@0: rt300@0: }; rt300@0: rt300@0: #endif /* defined(__tweakathlon__textLabel__) */