Mercurial > hg > tweakathon2ios
view UI code/ButtronSlider.h @ 38:fea11c3d1d94
tweaking endlessly
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Thu, 04 Dec 2014 17:03:01 +0000 |
parents | 52dbd5b4cfa9 |
children | 96ff7b41923a |
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(){ if(!isShowing()) return; 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); if (value > 1.) value = 1.; if (value < 0.) value = 0.; }; 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 setHandTexture(ofImage* img){ handTextureRef = img; } void animateHintToNewValue(int newVal, float timeToTake); void animateToNewValue(int newVal, float timeToTake); void update(); void flashScore(int score, ofColor col); private: void drawIndicator(double proportion); float minVal; float maxVal; void drawHintIndicator(); SliderType sliderType; float value; // [0. 1.] float hintValue; float hintTargVal; float targVal; float posAnimIncr; float hintPosAnimIncr; bool hintShowing; bool indicatorShowing; ofColor hintColor; ofColor flashColor; bool animating; int showScoreForFrames; ofImage* handTextureRef; ofImage defaultImage; }; #endif /* defined(__emptyExample__ButtronSlider__) */