comparison UI code/buttonPanel.mm @ 0:a223551fdc1f

First commit - copy from tweakathlon.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Fri, 10 Oct 2014 11:46:42 +0100
parents
children 36cdb73691da
comparison
equal deleted inserted replaced
-1:000000000000 0:a223551fdc1f
1 //
2 // buttonPanel.cpp
3 // tweakathlon
4 //
5 // Created by Robert Tubb on 11/02/2014.
6 //
7 //
8
9 #include "buttonPanel.h"
10 ButtonPanel::ButtonPanel(float ax,
11 float ay,
12 float awidth,
13 float aheight,
14 const UIProps& aprops,
15 vector<controllerType> elemList) :
16 UIElementContainer(ax,ay,awidth,aheight,aprops)
17 {
18 cout << "ButtonPanel auto layout contructor\n";
19
20 generateControls(elemList);
21 autoArrangeRow();
22 }
23 //---------------------------------------------------
24 ButtonPanel::ButtonPanel(float ax,
25 float ay,
26 float awidth,
27 float aheight,
28 const UIProps& aprops) :
29 UIElementContainer(ax,ay,awidth,aheight,aprops)
30 {
31 cout << "ButtonPanel - ctrls added later constructor\n";
32
33 }
34 //---------------------------------------------------
35 vector<UIElement*> ButtonPanel::generateControls(vector<controllerType> elemList){
36 removeAllSubelements();
37 vector<controllerType>::iterator i;
38
39 // 10 cm is 520 pixels
40
41 // calc positions
42 int top = y + myProps.spacerSize;
43
44 int n=0;
45 for(i=elemList.begin(); i<elemList.end();i++){
46 if(*i == BUTTON){
47 // add a slider
48 Buttron * butt = new Buttron(0 , top , myProps.buttonWidth, myProps.buttonHeight,myProps);
49 butt->setLabel("unassigned");
50 subElements.push_back(butt);
51 n++;
52
53 }else{
54 cout << "ERROR: button panel only handles buttons" << endl;
55 }
56 }
57 return subElements;
58 }