diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UI code/buttonPanel.mm	Fri Oct 10 11:46:42 2014 +0100
@@ -0,0 +1,58 @@
+//
+//  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;
+}