diff UI code/UIElementContainer.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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UI code/UIElementContainer.mm	Fri Oct 10 11:46:42 2014 +0100
@@ -0,0 +1,73 @@
+    //
+//  UIElementContainer.cpp
+//  emptyExample
+//
+//  Created by Robert Tubb on 22/05/2013.
+//
+//
+
+#include "UIElementContainer.h"
+#include "ButtronXY.h"
+#include "ButtronSlider.h"
+
+//-----------------------------------------------------------------------------
+UIElementContainer::UIElementContainer(float ax,
+                                       float ay,
+                                       float awidth,
+                                       float aheight,
+                                       const UIProps& aprops) :
+UIElement(ax,ay,awidth,aheight,aprops.generalBackground)
+{
+    cout << "UIElementContainer contructor\n";
+    
+    myProps = aprops;
+    cthickness = 0.;
+
+}
+
+//-----------------------------------------------------------------------------
+int UIElementContainer::getNumberOfControls(){
+    return subElements.size();
+}
+
+
+//-----------------------------------------------------------------------------
+
+void UIElementContainer::removeAllSubelements(){
+    vector<UIElement *>::iterator UIitr;
+    for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
+        delete (*UIitr);
+    }
+    subElements.clear();
+}
+//-------------------------------------------------------------------
+void UIElementContainer::draw(){
+    if(hidden) return;
+    //cout << "DRAWING CONTAINER"<< endl;
+    UIElement::draw();
+    // draw me
+    if(cthickness != 0.){
+        // doh, duplicate code from buttron?
+        drawBorder();
+    }
+    
+    // draw my subelems
+    vector<UIElement *>::iterator UIitr;
+    for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
+        (*UIitr)->draw();
+    }
+};
+//-------------------------------------------------------------------
+void UIElementContainer::drawBorder(){
+    ofSetLineWidth(cthickness);
+    ofSetColor(myProps.borderColor);
+    // top
+    ofLine(x,y,x+width,y);
+    // left
+    ofLine(x,y,x,y+height);
+    //right
+    ofLine(x+width-cthickness,y,x+width-cthickness,y+height);
+    // bottom
+    ofLine(x-cthickness,y+height,x+width-cthickness,y+height);
+}
+//-------------------------------------------------------------------
\ No newline at end of file