view UI code/UIElementContainer.mm @ 28:953db6518738

leap version more or less there, needs btter results feedback but thats detail. "no movement" bit is stupid cos peopel can move their hand. light flash not work.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Thu, 30 Oct 2014 18:35:00 +0000
parents a223551fdc1f
children
line wrap: on
line source
    //
//  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);
}
//-------------------------------------------------------------------