rt300@0
|
1 //
|
rt300@0
|
2 // UIElementContainer.cpp
|
rt300@0
|
3 // emptyExample
|
rt300@0
|
4 //
|
rt300@0
|
5 // Created by Robert Tubb on 22/05/2013.
|
rt300@0
|
6 //
|
rt300@0
|
7 //
|
rt300@0
|
8
|
rt300@0
|
9 #include "UIElementContainer.h"
|
rt300@0
|
10 #include "ButtronXY.h"
|
rt300@0
|
11 #include "ButtronSlider.h"
|
rt300@0
|
12
|
rt300@0
|
13 //-----------------------------------------------------------------------------
|
rt300@0
|
14 UIElementContainer::UIElementContainer(float ax,
|
rt300@0
|
15 float ay,
|
rt300@0
|
16 float awidth,
|
rt300@0
|
17 float aheight,
|
rt300@0
|
18 const UIProps& aprops) :
|
rt300@0
|
19 UIElement(ax,ay,awidth,aheight,aprops.generalBackground)
|
rt300@0
|
20 {
|
rt300@0
|
21 cout << "UIElementContainer contructor\n";
|
rt300@0
|
22
|
rt300@0
|
23 myProps = aprops;
|
rt300@0
|
24 cthickness = 0.;
|
rt300@0
|
25
|
rt300@0
|
26 }
|
rt300@0
|
27
|
rt300@0
|
28 //-----------------------------------------------------------------------------
|
rt300@0
|
29 int UIElementContainer::getNumberOfControls(){
|
rt300@0
|
30 return subElements.size();
|
rt300@0
|
31 }
|
rt300@0
|
32
|
rt300@0
|
33
|
rt300@0
|
34 //-----------------------------------------------------------------------------
|
rt300@0
|
35
|
rt300@0
|
36 void UIElementContainer::removeAllSubelements(){
|
rt300@0
|
37 vector<UIElement *>::iterator UIitr;
|
rt300@0
|
38 for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
|
rt300@0
|
39 delete (*UIitr);
|
rt300@0
|
40 }
|
rt300@0
|
41 subElements.clear();
|
rt300@0
|
42 }
|
rt300@0
|
43 //-------------------------------------------------------------------
|
rt300@0
|
44 void UIElementContainer::draw(){
|
rt300@0
|
45 if(hidden) return;
|
rt300@0
|
46 //cout << "DRAWING CONTAINER"<< endl;
|
rt300@0
|
47 UIElement::draw();
|
rt300@0
|
48 // draw me
|
rt300@0
|
49 if(cthickness != 0.){
|
rt300@0
|
50 // doh, duplicate code from buttron?
|
rt300@0
|
51 drawBorder();
|
rt300@0
|
52 }
|
rt300@0
|
53
|
rt300@0
|
54 // draw my subelems
|
rt300@0
|
55 vector<UIElement *>::iterator UIitr;
|
rt300@0
|
56 for(UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){
|
rt300@0
|
57 (*UIitr)->draw();
|
rt300@0
|
58 }
|
rt300@0
|
59 };
|
rt300@0
|
60 //-------------------------------------------------------------------
|
rt300@0
|
61 void UIElementContainer::drawBorder(){
|
rt300@0
|
62 ofSetLineWidth(cthickness);
|
rt300@0
|
63 ofSetColor(myProps.borderColor);
|
rt300@0
|
64 // top
|
rt300@0
|
65 ofLine(x,y,x+width,y);
|
rt300@0
|
66 // left
|
rt300@0
|
67 ofLine(x,y,x,y+height);
|
rt300@0
|
68 //right
|
rt300@0
|
69 ofLine(x+width-cthickness,y,x+width-cthickness,y+height);
|
rt300@0
|
70 // bottom
|
rt300@0
|
71 ofLine(x-cthickness,y+height,x+width-cthickness,y+height);
|
rt300@0
|
72 }
|
rt300@0
|
73 //------------------------------------------------------------------- |