Mercurial > hg > tweakathon2ios
comparison UI code/sliderPanel.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 | 27cdf475aa4b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a223551fdc1f |
---|---|
1 // | |
2 // sliderPanel.cpp | |
3 // tweakathlon | |
4 // | |
5 // Created by Robert Tubb on 11/02/2014. | |
6 // | |
7 // | |
8 | |
9 #include "sliderPanel.h" | |
10 | |
11 //----------------------------------------------------------------------------- | |
12 SliderPanel::SliderPanel(float ax, | |
13 float ay, | |
14 float awidth, | |
15 float aheight, | |
16 const UIProps& aprops, | |
17 vector<controllerType> elemList) : | |
18 UIElementContainer(ax,ay,awidth,aheight,aprops) | |
19 { | |
20 cout << "SliderPanel auto layout contructor\n"; | |
21 | |
22 // generateControls(elemList);// called from messageorganiser | |
23 } | |
24 | |
25 // NOT GENERIC | |
26 //----------------------------------------------------------------------------- | |
27 vector<UIElement*> SliderPanel::generateControls(vector<controllerType> elemList, controlPanelType panelType){ | |
28 removeAllSubelements(); | |
29 vector<controllerType>::iterator i; | |
30 | |
31 // 10 cm is 520 pixels | |
32 | |
33 // calc positions | |
34 int top = y + myProps.spacerSize; | |
35 | |
36 float pixPerElem = width/(float)elemList.size(); | |
37 if (pixPerElem < myProps.sliderWidth ){ | |
38 cout << "error not enough room for sliders" << endl; | |
39 } | |
40 | |
41 int n=0; | |
42 for(i=elemList.begin(); i<elemList.end();i++){ | |
43 if(*i == SLIDER){ | |
44 // add a slider | |
45 float c = (n + 0.5) * pixPerElem; | |
46 float l = c - myProps.sliderWidth/2; | |
47 if(n==1){ | |
48 cout << "centre " << c << endl; | |
49 cout << l << endl; | |
50 } | |
51 | |
52 ButtronSlider * revslider = new ButtronSlider(l , top , myProps.sliderWidth, myProps.sliderHeight,FILL, myProps); | |
53 revslider->setLabel("unassigned"); | |
54 subElements.push_back(revslider); | |
55 revslider->showHint(false); | |
56 // grey out all but first | |
57 if(panelType == SEQUENTIAL && i != elemList.begin()){ | |
58 revslider->setActive(false); | |
59 } | |
60 | |
61 n++; | |
62 | |
63 }else if(*i == XYPAD){ | |
64 // add a xy | |
65 float c = (n + 0.5) * pixPerElem; | |
66 float left = c - myProps.XYsize/2; | |
67 ButtronXY * xyp = new ButtronXY(left , top , myProps); | |
68 xyp->setLabel("unassigned","unassigned"); | |
69 xyp->showHint(false); | |
70 subElements.push_back(xyp); | |
71 n++; | |
72 }else if(*i == LEAP3D){ | |
73 // add a threed box | |
74 float c = x+width*0.5; | |
75 float left = c - myProps.XYsize; | |
76 | |
77 //Leap3DBox * l3d = new Leap3DBox(left , top+50 , myProps.XYsize*0.75,myProps.XYsize*0.75,150,50, myProps); | |
78 | |
79 Leap3DBoxGL * l3d = new Leap3DBoxGL(left , top+50 , myProps.XYsize*0.75,myProps.XYsize*0.75,150,50, myProps); | |
80 | |
81 | |
82 | |
83 subElements.push_back(l3d); | |
84 n++; | |
85 | |
86 }else{ | |
87 cout << "ERROR: slider panel only handles xy pads and sliders" << endl; | |
88 } | |
89 | |
90 | |
91 } | |
92 | |
93 autoArrangeRow(); // will set positions | |
94 | |
95 | |
96 | |
97 return subElements; | |
98 } | |
99 |