view UI code/buttonPanel.mm @ 38:fea11c3d1d94

tweaking endlessly
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Thu, 04 Dec 2014 17:03:01 +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;
}