view UI code/Buttron.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 fea11c3d1d94
line wrap: on
line source
//
//  buttron.h
//  emptyExample
//
//  Created by Robert Tubb on 30/04/2013.
//
//


// this is a rectangualr thingy with border and on/off functionality

#ifndef __emptyExample__buttron__
#define __emptyExample__buttron__

#include <iostream>
#include "ofMain.h"
#include "UIElement.h"
#include "UIProperties.h"

class Buttron : public UIElement{
    
public:
    typedef enum {TOGGLE,MOMENTARY} Mode; // should be in subclasss

    float thickness; // width of border
    float radius;   // inner radius of corners, reccomended to be same as thickness
    ofColor foregroundHi;
    ofColor backgroundHi;
    ofColor foregroundLo;
    ofColor backgroundLo;
    ofColor fgInactive;
    
    bool pressed; // on and pressed can be different
    
    Buttron();
    ~Buttron(){};
    
    // this constructor sets up with defaults obtained from UIProperties (recoomemnded)
    Buttron(float x,
            float y,
            const UIProps& props
            );
    Buttron(float x,
            float y,
            float width,
            float height,
            const UIProps& props
            );
    Buttron(float x,
            float y,
            float width,
            float height,
            const UIProps& props,
            Mode mode
            );
    
    Buttron(float x,
            float y,
            float width,
            float height,
            float thickness,
            float radius,
            ofColor foregroundHi,
            ofColor backgroundHi,
            ofColor foregroundLo,
            ofColor backgroundLo);
    void draw();
    void drawOutline();
    void drawTextLabel();
    void setMode(Mode m){
        behaviourMode = m;
    };
    virtual bool handleMyTouch(int x, int y, touchType ttype, int touchID);

protected:
    Mode behaviourMode;
    
};


#endif /* defined(__emptyExample__buttron__) */