view UI code/CountdownText.h @ 38:fea11c3d1d94

tweaking endlessly
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Thu, 04 Dec 2014 17:03:01 +0000
parents a223551fdc1f
children
line wrap: on
line source
//
//  CountdownText.h
//  tweakathlon
//
//  Created by Robert Tubb on 10/03/2014.
//
//

#ifndef __tweakathlon__CountdownText__
#define __tweakathlon__CountdownText__

#include <iostream>

#include "ofMain.h"
#include "UIElement.h"
#include "timeController.h"
#include "boost/function.hpp"
#include "boost/bind.hpp"
// actuall a countdown box
extern TimeController timeController;
class CountdownText : public UIElement{
public:
    
    CountdownText(string text, int x, int y,int w,int h, const UIProps& props);
    void draw();
    
    ofColor foregroundHi;
    ofColor backgroundHi;
    ofColor foregroundLo;
    ofColor backgroundLo;
    
    bool handleMyTouch(int x, int y, touchType ttype, int touchID){
        return false;
    }
    
    void showAndStart(int sec){
        show();
        stringstream s;
        s << sec;
        numSecondsText = s.str();
        t = sec;
        timeController.scheduleEvent(tcb, 1000);
    };
    
    void secPassed(){
        t--;
        if(t <= 0){
            //finish
            numSecondsText = "0!";
        }else{
            stringstream ts;
            ts << t;
            numSecondsText = ts.str();
            timeController.scheduleEvent(tcb, 1000);
        }
    };
    void setTestTypeString(string s){
        testTypeString = s;
    }
private:
    int t;
    TimerCallbackFunction tcb;
    string testTypeString;
    string numSecondsText;
};



#endif /* defined(__tweakathlon__CountdownText__) */