Mercurial > hg > tweakathon2ios
view UI code/ButtronSlider.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 | 8124f46eda65 |
line wrap: on
line source
// // ButtronSlider.h // emptyExample // // Created by Robert Tubb on 22/05/2013. // // #ifndef __emptyExample__ButtronSlider__ #define __emptyExample__ButtronSlider__ #include "Buttron.h" #include <iostream> class ButtronSlider : public Buttron{ public: ~ButtronSlider(){}; ButtronSlider(float ax, float ay, float awidth, float aheight, float athickness, float aradius, ofColor aforegroundHi, ofColor abackgroundHi, ofColor aforegroundLo, ofColor abackgroundLo, SliderType type); ButtronSlider(float ax, float ay, float awidth, float aheight, SliderType type, const UIProps& props); void init(); void draw(){ Buttron::draw(); drawIndicator(value); if(hintShowing) drawHintIndicator(); } void setHintValue(double hval){ hintValue = (hval - minVal)/(maxVal - minVal); }; void setHintColor(ofColor c){ hintColor = c; }; void showHint(bool tf){ hintShowing = tf; }; void setValue(double avalue){ // scale appropriately to 0-1 (maxVal - minVal)*prop + minVal value = avalue; // (avalue - minVal)/(maxVal - minVal); }; void setValueAndScale(double avalue){ // scale appropriately to 0-1 (maxVal - minVal)*prop + minVal value = (avalue - minVal)/(maxVal - minVal); }; virtual bool handleMyTouch(int x, int y, touchType ttype, int touchID); void setRange(float lo, float hi){ minVal = lo; maxVal = hi; } private: void drawIndicator(double proportion); float minVal; float maxVal; void drawHintIndicator(); SliderType sliderType; float value; // [0. 1.] float hintValue; bool hintShowing; ofColor hintColor; }; #endif /* defined(__emptyExample__ButtronSlider__) */