view UI code/Buttron.h @ 18:36cdb73691da

PIMPL speed compile? eventlogger now just saves as it goes more refactoring
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Wed, 22 Oct 2014 15:00:14 +0100
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__) */