view UI code/buttonPanel.mm @ 28:953db6518738

leap version more or less there, needs btter results feedback but thats detail. "no movement" bit is stupid cos peopel can move their hand. light flash not work.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Thu, 30 Oct 2014 18:35:00 +0000
parents 36cdb73691da
children
line wrap: on
line source
//
//  buttonPanel.cpp
//  tweakathlon
//
//  Created by Robert Tubb on 11/02/2014.
//
//

#include "buttonPanel.h"
ButtonPanel::ButtonPanel(float ax,
                         float ay,
                         float awidth,
                         float aheight,
                         const UIProps& aprops,
                         vector<controllerType> elemList) :
UIElementContainer(ax,ay,awidth,aheight,aprops)
{
    //cout << "ButtonPanel auto layout contructor\n";
    
    generateControls(elemList);
    autoArrangeRow();
}
//---------------------------------------------------
ButtonPanel::ButtonPanel(float ax,
                         float ay,
                         float awidth,
                         float aheight,
                         const UIProps& aprops) :
UIElementContainer(ax,ay,awidth,aheight,aprops)
{
    //cout << "ButtonPanel - ctrls added later constructor\n";

}
//---------------------------------------------------
vector<UIElement*> ButtonPanel::generateControls(vector<controllerType> elemList){
    removeAllSubelements();
    vector<controllerType>::iterator i;
    
    // 10 cm is 520 pixels
    
    // calc positions
    int top  = y + myProps.spacerSize;
    
    int n=0;
    for(i=elemList.begin(); i<elemList.end();i++){
        if(*i == BUTTON){
            // add a slider
            Buttron * butt = new Buttron(0 , top , myProps.buttonWidth, myProps.buttonHeight,myProps);
            butt->setLabel("unassigned");
            subElements.push_back(butt);
            n++;

        }else{
            cout << "ERROR: button panel only handles buttons" << endl;
        }
    }
    return subElements;
}