view UI code/targetSymbol.h @ 28:953db6518738

leap version more or less there, needs btter results feedback but thats detail. "no movement" bit is stupid cos peopel can move their hand. light flash not work.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Thu, 30 Oct 2014 18:35:00 +0000
parents a223551fdc1f
children
line wrap: on
line source
//
//  targetSymbol.h
//  tweakathlon
//
//  Created by Robert Tubb on 11/02/2014.
//
//

#ifndef __tweakathlon__targetSymbol__
#define __tweakathlon__targetSymbol__

#include <iostream>
#include "UIElement.h"
#include "timeController.h"
extern TimeController timeController;
class TargetSymbol : public UIElement {
public:
    
    TargetSymbol(int ax, int ay,int aw, const UIProps& props):
    UIElement(ax,ay,aw,aw, props)
    {
        foregroundHi = props.buttonHi;
        backgroundHi = props.generalBackground;
        foregroundLo = props.inactiveGreyedOut; // can't be touched
        backgroundLo = props.generalBackground;
        flashing = false;
        on = false;
    };
    
    void draw(){
        if(hidden)return;
        //UIElement::draw(); // don't do background
        ofColor fg,bg;
        
        if(on){
            fg = foregroundHi;
            bg = backgroundHi;
        }else{
            fg = foregroundLo;
            bg = backgroundLo;
        }
        ofSetColor(fg);

        ofEllipse(x,y,width,height);
        
        ofSetColor(bg);
        ofEllipse(x,y,width*0.66,height*0.66);
        
        ofSetColor(fg);
        ofEllipse(x,y,width*0.33,height*0.33);
        
    };
    
    void flash(){
        // turn hilight on and off
        if (!flashing){
            setHighlight(true);
            
            // set up timer
            TimerCallbackFunction tcb;
            tcb = boost::bind(&TargetSymbol::flash, this);
            timeController.scheduleEvent(tcb, int(ALTERNATION_SPEED/4));
            flashing = true;
        }else{
            setHighlight(false);
            
            flashing = false;
        }
        
    }
    
    bool handleMyTouch(int x, int y, touchType ttype, int touchID){
        return false; // or?
    }
    
private:
    ofColor foregroundHi;
    ofColor backgroundHi;
    ofColor foregroundLo;
    ofColor backgroundLo;
    ofColor fgInactive;
    bool flashing;
};
#endif /* defined(__tweakathlon__targetSymbol__) */