Mercurial > hg > tweakathon2ios
view UI code/ButtronSlider.h @ 29:e7af34b1af83
animated sliders
throughput calculation
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Mon, 03 Nov 2014 18:27:58 +0000 |
parents | 27cdf475aa4b |
children | a677c027e3a0 |
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(); ofDisableDepthTest(); drawIndicator(value); if(hintShowing) drawHintIndicator(); ofEnableDepthTest(); } void setHintValue(double hval){ hintValue = (hval - minVal)/(maxVal - minVal); }; void setHintColor(ofColor c){ hintColor = c; }; void setColor(ofColor c){ foregroundHi = c; foregroundLo = 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); }; void showValueIndicator(bool show){ indicatorShowing = show; } virtual bool handleMyTouch(int x, int y, touchType ttype, int touchID); void setRange(float lo, float hi){ minVal = lo; maxVal = hi; } void animateHintToNewValue(int newVal, float timeToTake); void update(); private: void drawIndicator(double proportion); float minVal; float maxVal; void drawHintIndicator(); SliderType sliderType; float value; // [0. 1.] float hintValue; float posAnimIncr; bool hintShowing; bool indicatorShowing; ofColor hintColor; bool animating; }; #endif /* defined(__emptyExample__ButtronSlider__) */