rt300@0: // rt300@0: // buttron.h rt300@0: // emptyExample rt300@0: // rt300@0: // Created by Robert Tubb on 30/04/2013. rt300@0: // rt300@0: // rt300@0: rt300@0: rt300@0: // this is a rectangualr thingy with border and on/off functionality rt300@0: rt300@0: #ifndef __emptyExample__buttron__ rt300@0: #define __emptyExample__buttron__ rt300@0: rt300@0: #include rt300@0: #include "ofMain.h" rt300@0: #include "UIElement.h" rt300@0: #include "UIProperties.h" rt300@0: rt300@0: class Buttron : public UIElement{ rt300@0: rt300@0: public: rt300@0: typedef enum {TOGGLE,MOMENTARY} Mode; // should be in subclasss rt300@0: rt300@0: float thickness; // width of border rt300@0: float radius; // inner radius of corners, reccomended to be same as thickness rt300@0: ofColor foregroundHi; rt300@0: ofColor backgroundHi; rt300@0: ofColor foregroundLo; rt300@0: ofColor backgroundLo; rt300@0: ofColor fgInactive; rt300@0: rt300@0: bool pressed; // on and pressed can be different rt300@0: rt300@0: Buttron(); rt300@0: ~Buttron(){}; rt300@0: rt300@0: // this constructor sets up with defaults obtained from UIProperties (recoomemnded) rt300@0: Buttron(float x, rt300@0: float y, rt300@0: const UIProps& props rt300@0: ); rt300@0: Buttron(float x, rt300@0: float y, rt300@0: float width, rt300@0: float height, rt300@0: const UIProps& props rt300@0: ); rt300@0: Buttron(float x, rt300@0: float y, rt300@0: float width, rt300@0: float height, rt300@0: const UIProps& props, rt300@0: Mode mode rt300@0: ); rt300@0: rt300@0: Buttron(float x, rt300@0: float y, rt300@0: float width, rt300@0: float height, rt300@0: float thickness, rt300@0: float radius, rt300@0: ofColor foregroundHi, rt300@0: ofColor backgroundHi, rt300@0: ofColor foregroundLo, rt300@0: ofColor backgroundLo); rt300@0: void draw(); rt300@0: void drawOutline(); rt300@0: void drawTextLabel(); rt300@0: void setMode(Mode m){ rt300@0: behaviourMode = m; rt300@0: }; rt300@38: void turnOff(){ rt300@38: on = false; rt300@38: } rt300@43: void turnOn(){ rt300@43: on = true; rt300@43: } rt300@0: virtual bool handleMyTouch(int x, int y, touchType ttype, int touchID); rt300@44: void setBgImage(ofImage * img){ rt300@44: bgImage = img; rt300@44: } rt300@0: protected: rt300@0: Mode behaviourMode; rt300@44: ofImage * bgImage; rt300@0: }; rt300@0: rt300@0: rt300@0: #endif /* defined(__emptyExample__buttron__) */