view UI code/Buttron.h @ 49:a62e033117fa

sequence controller now generated new. but doesn't fix the bug. bad access cropping up...
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 12 Jan 2015 18:40:00 +0000
parents d810aa9ca03a
children
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;
    };
    void turnOff(){
        on = false;
    }
    void turnOn(){
        on = true;
    }
    virtual bool handleMyTouch(int x, int y, touchType ttype, int touchID);
    void setBgImage(ofImage * img){
        bgImage = img;
    }
protected:
    Mode behaviourMode;
    ofImage * bgImage;
};


#endif /* defined(__emptyExample__buttron__) */