view UI code/sliderPanel.h @ 19:bd23c1b922be

Explore preset saving slot stuff kind of works.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Wed, 22 Oct 2014 16:29:31 +0100
parents f83635861187
children 5cf2b80909fc
line wrap: on
line source
//
//  sliderPanel.h
//  tweakathlon
//
//  Created by Robert Tubb on 11/02/2014.
//
//

#ifndef __tweakathlon__sliderPanel__
#define __tweakathlon__sliderPanel__

#include <iostream>
#include "UIElementContainer.h"
#include <iostream>
#include "globalVariables.h"
#include "ofMain.h"
#include "UIElement.h"
#include "boost/bind.hpp"
#include "boost/function.hpp"
#include "timeController.h"
#include "ButtronSlider.h"
#include "ButtronXY.h"
#include "3Dbox.h"
#include "3DboxGL.h"
// panel with sliders and xy pads
class SliderPanel : public UIElementContainer{
    
public:
    SliderPanel(float ax,
                float ay,
                float awidth,
                float aheight,
                const UIProps& aprops,
                vector<controllerType> elemList);
    //------------------------
    void showHint(bool value){
        vector<UIElement *>::iterator UIitr;
        for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
            (*UIitr)->showHint(value);
        }
    }
    //
    void setHintValues(vector<int> vals){
        auto valItr = vals.begin();
        for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
            if (++valItr != vals.end()){
                (*UIitr)->setHintValue(*valItr);
            }
        }
    }
    void setHintColor(ofColor c){
        vector<UIElement *>::iterator UIitr;
        for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
            (*UIitr)->setHintColor(c);
        }
    }
    //------------------------
    void flash(){
        // turn hilight on and off
        if (!flashing){
            vector<UIElement *>::iterator UIitr;
            for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
                (*UIitr)->setHighlight(true);
            }
            // set up timer
            TimerCallbackFunction tcb;
            tcb = boost::bind(&SliderPanel::flash, this);
            timeController.scheduleEvent(tcb, 250);
            flashing = true;
        }else{
            vector<UIElement *>::iterator UIitr;
            for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
                (*UIitr)->setHighlight(false);
            }
            flashing = false;
        }
        
    }
    //------------------------
    void setBgColor(ofColor c){
        vector<UIElement *>::iterator UIitr;
        for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
            (*UIitr)->setColor(c);
        }
    }
    //------------------------
    vector<UIElement*> generateControls(vector<controllerType> elemList, controlPanelType panelType);
    //------------------------
    UIElement* getSlider(int index){
        if (index < subElements.size()){
            return subElements[index];
        }else{
            cout << "ERROR: index too big for sldiers" << endl;
            return NULL;
        }
    };
    // TODO override touch thing to make revisitable
private:
    bool flashing;
    controlPanelType panelType;
};

#endif /* defined(__tweakathlon__sliderPanel__) */