rt300@0
|
1 //
|
rt300@0
|
2 // buttonPanel.cpp
|
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 #include "buttonPanel.h"
|
rt300@0
|
10 ButtonPanel::ButtonPanel(float ax,
|
rt300@0
|
11 float ay,
|
rt300@0
|
12 float awidth,
|
rt300@0
|
13 float aheight,
|
rt300@0
|
14 const UIProps& aprops,
|
rt300@0
|
15 vector<controllerType> elemList) :
|
rt300@0
|
16 UIElementContainer(ax,ay,awidth,aheight,aprops)
|
rt300@0
|
17 {
|
rt300@18
|
18 //cout << "ButtonPanel auto layout contructor\n";
|
rt300@0
|
19
|
rt300@0
|
20 generateControls(elemList);
|
rt300@0
|
21 autoArrangeRow();
|
rt300@0
|
22 }
|
rt300@0
|
23 //---------------------------------------------------
|
rt300@0
|
24 ButtonPanel::ButtonPanel(float ax,
|
rt300@0
|
25 float ay,
|
rt300@0
|
26 float awidth,
|
rt300@0
|
27 float aheight,
|
rt300@0
|
28 const UIProps& aprops) :
|
rt300@0
|
29 UIElementContainer(ax,ay,awidth,aheight,aprops)
|
rt300@0
|
30 {
|
rt300@18
|
31 //cout << "ButtonPanel - ctrls added later constructor\n";
|
rt300@0
|
32
|
rt300@0
|
33 }
|
rt300@0
|
34 //---------------------------------------------------
|
rt300@0
|
35 vector<UIElement*> ButtonPanel::generateControls(vector<controllerType> elemList){
|
rt300@0
|
36 removeAllSubelements();
|
rt300@0
|
37 vector<controllerType>::iterator i;
|
rt300@0
|
38
|
rt300@0
|
39 // 10 cm is 520 pixels
|
rt300@0
|
40
|
rt300@0
|
41 // calc positions
|
rt300@0
|
42 int top = y + myProps.spacerSize;
|
rt300@0
|
43
|
rt300@0
|
44 int n=0;
|
rt300@0
|
45 for(i=elemList.begin(); i<elemList.end();i++){
|
rt300@0
|
46 if(*i == BUTTON){
|
rt300@0
|
47 // add a slider
|
rt300@0
|
48 Buttron * butt = new Buttron(0 , top , myProps.buttonWidth, myProps.buttonHeight,myProps);
|
rt300@0
|
49 butt->setLabel("unassigned");
|
rt300@0
|
50 subElements.push_back(butt);
|
rt300@0
|
51 n++;
|
rt300@0
|
52
|
rt300@0
|
53 }else{
|
rt300@0
|
54 cout << "ERROR: button panel only handles buttons" << endl;
|
rt300@0
|
55 }
|
rt300@0
|
56 }
|
rt300@0
|
57 return subElements;
|
rt300@0
|
58 }
|