diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UI code/sliderPanel.mm	Fri Oct 10 11:46:42 2014 +0100
@@ -0,0 +1,99 @@
+//
+//  sliderPanel.cpp
+//  tweakathlon
+//
+//  Created by Robert Tubb on 11/02/2014.
+//
+//
+
+#include "sliderPanel.h"
+
+//-----------------------------------------------------------------------------
+SliderPanel::SliderPanel(float ax,
+                         float ay,
+                         float awidth,
+                         float aheight,
+                         const UIProps& aprops,
+                         vector<controllerType> elemList) :
+UIElementContainer(ax,ay,awidth,aheight,aprops)
+{
+    cout << "SliderPanel auto layout contructor\n";
+
+    // generateControls(elemList);// called from messageorganiser
+}
+
+// NOT GENERIC
+//-----------------------------------------------------------------------------
+vector<UIElement*> SliderPanel::generateControls(vector<controllerType> elemList, controlPanelType panelType){
+    removeAllSubelements();
+    vector<controllerType>::iterator i;
+    
+    // 10 cm is 520 pixels
+    
+    // calc positions
+    int top  = y + myProps.spacerSize;
+    
+    float pixPerElem = width/(float)elemList.size();
+    if (pixPerElem < myProps.sliderWidth ){
+        cout << "error not enough room for sliders" << endl;
+    }
+    
+    int n=0;
+    for(i=elemList.begin(); i<elemList.end();i++){
+        if(*i == SLIDER){
+            // add a slider
+            float c = (n + 0.5) * pixPerElem;
+            float l = c - myProps.sliderWidth/2;
+            if(n==1){
+                cout << "centre " << c << endl;
+                cout << l << endl;
+            }
+            
+            ButtronSlider * revslider = new ButtronSlider(l , top , myProps.sliderWidth, myProps.sliderHeight,FILL, myProps);
+            revslider->setLabel("unassigned");
+            subElements.push_back(revslider);
+            revslider->showHint(false);
+            // grey out all but first
+            if(panelType == SEQUENTIAL && i != elemList.begin()){
+                revslider->setActive(false);
+            }
+            
+            n++;
+            
+        }else if(*i == XYPAD){
+            // add a xy
+            float c = (n + 0.5) * pixPerElem;
+            float left = c - myProps.XYsize/2;
+            ButtronXY * xyp = new ButtronXY(left , top , myProps);
+            xyp->setLabel("unassigned","unassigned");
+            xyp->showHint(false);
+            subElements.push_back(xyp);
+            n++;
+        }else if(*i == LEAP3D){
+            // add a threed box
+            float c = x+width*0.5;
+            float left = c - myProps.XYsize;
+            
+            //Leap3DBox * l3d = new Leap3DBox(left , top+50 , myProps.XYsize*0.75,myProps.XYsize*0.75,150,50, myProps);
+
+            Leap3DBoxGL * l3d = new Leap3DBoxGL(left , top+50 , myProps.XYsize*0.75,myProps.XYsize*0.75,150,50, myProps);
+            
+
+            
+            subElements.push_back(l3d);
+            n++;
+        
+        }else{
+            cout << "ERROR: slider panel only handles xy pads and sliders" << endl;
+        }
+        
+
+    }
+    
+    autoArrangeRow(); // will set positions
+    
+
+
+    return subElements;
+}
+