annotate UI code/ButtronXY.h @ 52:89944ab3e129 tip

fix oF linker errors ios8
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Tue, 03 Feb 2015 13:18:23 +0000
parents a223551fdc1f
children
rev   line source
rt300@0 1 //
rt300@0 2 // ButtronXY.h
rt300@0 3 // tweakathlon
rt300@0 4 //
rt300@0 5 // Created by Robert Tubb on 25/06/2013.
rt300@0 6 //
rt300@0 7 //
rt300@0 8
rt300@0 9 #ifndef __tweakathlon__ButtronXY__
rt300@0 10 #define __tweakathlon__ButtronXY__
rt300@0 11
rt300@0 12 #include <iostream>
rt300@0 13 #include "buttron.h"
rt300@0 14
rt300@0 15 class ButtronXY: public Buttron {
rt300@0 16
rt300@0 17 public:
rt300@0 18
rt300@0 19 UICallbackFunction callback;
rt300@0 20
rt300@0 21 double xvalue, yvalue; // [0. 1.]
rt300@0 22 ~ButtronXY(){};
rt300@0 23 ButtronXY(float ax,
rt300@0 24 float ay,
rt300@0 25 const UIProps& props);
rt300@0 26 ButtronXY(float ax,
rt300@0 27 float ay,
rt300@0 28 float awidth,
rt300@0 29 float athickness,
rt300@0 30 float aradius,
rt300@0 31 ofColor aforegroundHi,
rt300@0 32 ofColor abackgroundHi,
rt300@0 33 ofColor aforegroundLo,
rt300@0 34 ofColor abackgroundLo);
rt300@0 35
rt300@0 36 void draw(){
rt300@0 37 if(hidden) return;
rt300@0 38 Buttron::draw();
rt300@0 39 drawIndicator();
rt300@0 40 drawLabels();
rt300@0 41 }
rt300@0 42 void drawLabels(){
rt300@0 43 // where?
rt300@0 44 ofColor fg,bg;
rt300@0 45
rt300@0 46 if(on){
rt300@0 47 fg = foregroundHi;
rt300@0 48 bg = backgroundHi;
rt300@0 49 }else{
rt300@0 50 fg = foregroundLo;
rt300@0 51 bg = backgroundLo;
rt300@0 52 }
rt300@0 53 ofSetColor(fg);
rt300@0 54 verdana16.drawString(labelNamex, x + width/2, y + thickness*4);
rt300@0 55 verdana16.drawString(labelNamey, x + thickness*2, y + height/2+7);
rt300@0 56 }
rt300@0 57 void init();
rt300@0 58
rt300@0 59 void setValue(double axvalue, double ayvalue){
rt300@0 60 xvalue = axvalue;
rt300@0 61 yvalue = ayvalue;
rt300@0 62 };
rt300@0 63 void setValueAndScale(double axvalue, double ayvalue){
rt300@0 64 xvalue = (axvalue - minVal)/(maxVal - minVal);
rt300@0 65 yvalue = (ayvalue - minVal)/(maxVal - minVal);
rt300@0 66 }
rt300@0 67 void setHintValue(double hvalx, double hvaly){
rt300@0 68 hintValuex = (hvalx - minVal)/(maxVal - minVal);
rt300@0 69 hintValuey = (hvaly - minVal)/(maxVal - minVal);
rt300@0 70
rt300@0 71 };
rt300@0 72 void setHintColor(ofColor c){
rt300@0 73 // TODO somehow set the fill ?
rt300@0 74 };
rt300@0 75 void setLabel(string xlabel, string ylabel){
rt300@0 76 labelNamex = xlabel;
rt300@0 77 labelNamey = ylabel;
rt300@0 78 }
rt300@0 79
rt300@0 80
rt300@0 81 void showHint(bool tf){
rt300@0 82 hintShowing = tf;
rt300@0 83 };
rt300@0 84 virtual bool handleMyTouch(int x, int y, touchType ttype, int touchID);
rt300@0 85
rt300@0 86 virtual void addHandler(UICallbackFunction handlerFunction, int paramIDX, int paramIDY) // virtual?
rt300@0 87 {
rt300@0 88 cout << "handler added to XYUIElement " << endl;
rt300@0 89 callback = handlerFunction;
rt300@0 90 myParamIDX = paramIDX;
rt300@0 91 myParamIDY = paramIDY;
rt300@0 92 };
rt300@0 93
rt300@0 94
rt300@0 95 private:
rt300@0 96 void drawIndicator();
rt300@0 97 void drawHintIndicator();
rt300@0 98 float maxVal;
rt300@0 99 float minVal;
rt300@0 100 int myParamIDX;
rt300@0 101 int myParamIDY;
rt300@0 102 float hintValuex;
rt300@0 103 float hintValuey;
rt300@0 104 bool hintShowing;
rt300@0 105 string labelNamex;
rt300@0 106 string labelNamey;
rt300@0 107 };
rt300@0 108
rt300@0 109 #endif /* defined(__tweakathlon__ButtronXY__) */