annotate UI code/sliderPanel.h @ 21:5cf2b80909fc

Hints and sliders show ok for training sequences.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Wed, 22 Oct 2014 18:12:12 +0100
parents f83635861187
children 8124f46eda65
rev   line source
rt300@0 1 //
rt300@0 2 // sliderPanel.h
rt300@0 3 // tweakathlon
rt300@0 4 //
rt300@0 5 // Created by Robert Tubb on 11/02/2014.
rt300@0 6 //
rt300@0 7 //
rt300@0 8
rt300@0 9 #ifndef __tweakathlon__sliderPanel__
rt300@0 10 #define __tweakathlon__sliderPanel__
rt300@0 11
rt300@0 12 #include <iostream>
rt300@0 13 #include "UIElementContainer.h"
rt300@0 14 #include <iostream>
rt300@0 15 #include "globalVariables.h"
rt300@0 16 #include "ofMain.h"
rt300@0 17 #include "UIElement.h"
rt300@0 18 #include "boost/bind.hpp"
rt300@0 19 #include "boost/function.hpp"
rt300@0 20 #include "timeController.h"
rt300@0 21 #include "ButtronSlider.h"
rt300@0 22 #include "ButtronXY.h"
rt300@0 23 #include "3Dbox.h"
rt300@0 24 #include "3DboxGL.h"
rt300@21 25 #include "ButtronSlider.h"
rt300@0 26 // panel with sliders and xy pads
rt300@0 27 class SliderPanel : public UIElementContainer{
rt300@0 28
rt300@0 29 public:
rt300@0 30 SliderPanel(float ax,
rt300@0 31 float ay,
rt300@0 32 float awidth,
rt300@0 33 float aheight,
rt300@0 34 const UIProps& aprops,
rt300@0 35 vector<controllerType> elemList);
rt300@0 36 //------------------------
rt300@0 37 void showHint(bool value){
rt300@0 38 vector<UIElement *>::iterator UIitr;
rt300@0 39 for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
rt300@21 40
rt300@21 41 ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr);
rt300@21 42 thisSlider->showHint(value);
rt300@0 43 }
rt300@0 44 }
rt300@0 45 //
rt300@14 46 void setHintValues(vector<int> vals){
rt300@21 47 int i = 0;
rt300@14 48 for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
rt300@21 49 ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr);
rt300@21 50 thisSlider->setHintValue(vals[i]);
rt300@21 51 i++;
rt300@14 52 }
rt300@14 53 }
rt300@0 54 void setHintColor(ofColor c){
rt300@0 55 vector<UIElement *>::iterator UIitr;
rt300@0 56 for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
rt300@0 57 (*UIitr)->setHintColor(c);
rt300@0 58 }
rt300@0 59 }
rt300@0 60 //------------------------
rt300@0 61 void flash(){
rt300@0 62 // turn hilight on and off
rt300@0 63 if (!flashing){
rt300@0 64 vector<UIElement *>::iterator UIitr;
rt300@0 65 for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
rt300@0 66 (*UIitr)->setHighlight(true);
rt300@0 67 }
rt300@0 68 // set up timer
rt300@0 69 TimerCallbackFunction tcb;
rt300@0 70 tcb = boost::bind(&SliderPanel::flash, this);
rt300@0 71 timeController.scheduleEvent(tcb, 250);
rt300@0 72 flashing = true;
rt300@0 73 }else{
rt300@0 74 vector<UIElement *>::iterator UIitr;
rt300@0 75 for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
rt300@0 76 (*UIitr)->setHighlight(false);
rt300@0 77 }
rt300@0 78 flashing = false;
rt300@0 79 }
rt300@0 80
rt300@0 81 }
rt300@0 82 //------------------------
rt300@14 83 void setBgColor(ofColor c){
rt300@14 84 vector<UIElement *>::iterator UIitr;
rt300@14 85 for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
rt300@14 86 (*UIitr)->setColor(c);
rt300@14 87 }
rt300@14 88 }
rt300@14 89 //------------------------
rt300@0 90 vector<UIElement*> generateControls(vector<controllerType> elemList, controlPanelType panelType);
rt300@0 91 //------------------------
rt300@2 92 UIElement* getSlider(int index){
rt300@2 93 if (index < subElements.size()){
rt300@2 94 return subElements[index];
rt300@2 95 }else{
rt300@2 96 cout << "ERROR: index too big for sldiers" << endl;
rt300@2 97 return NULL;
rt300@2 98 }
rt300@2 99 };
rt300@0 100 // TODO override touch thing to make revisitable
rt300@0 101 private:
rt300@0 102 bool flashing;
rt300@0 103 controlPanelType panelType;
rt300@0 104 };
rt300@0 105
rt300@0 106 #endif /* defined(__tweakathlon__sliderPanel__) */