ofxOui - UI Components for OpenFrameworks

ofxOuiGroup.hpp
Go to the documentation of this file.
1 /*
2  * ofxOuiGroup.hpp
3  *
4  * UI Component Group with grid layout
5  *
6  * This code has been authored by Jules Francoise <jfrancoi@sfu.ca>
7  * during his postdoc contract at Simon Fraser University (MovingStories
8  * project).
9  * See:
10  * http://julesfrancoise.com/
11  * http://movingstories.ca/
12  *
13  * Copyright (C) 2016 Jules Francoise.
14  *
15  * This Source Code Form is subject to the terms of the Mozilla Public
16  * License, v. 2.0. If a copy of the MPL was not distributed with this
17  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
18  */
19 
20 #ifndef ofxOuiGroup_hpp
21 #define ofxOuiGroup_hpp
22 
23 #include "ofxOuiComponent.hpp"
24 
25 namespace ofxOui {
26 
31 class Group {
32  public:
40  Group(int x_ = 0, int y_ = 0, int width_ = 100, int height_ = 100);
41 
45  ~Group();
46 
47  virtual void setup();
48 
52  virtual void update();
53 
57  virtual void draw();
58 
62  virtual bool inside(int x_, int y_);
63 
68  int rows() const;
69 
74  int cols() const;
75 
86  bool addComponent(shared_ptr<Component> component, int row, int col,
87  int rowSpan = 1, int colSpan = 1);
88 
95  shared_ptr<Component> getComponent(int row, int col);
96 
102  shared_ptr<Component> getComponentByLabel(string label);
103 
108  vector<shared_ptr<Component>> getComponents();
109 
115  bool removeComponent(shared_ptr<Component> component);
116 
123  bool removeComponent(int row, int col);
124 
128  void clear();
129 
133  void disable();
134 
138  void enable();
139 
143  float x;
144 
148  float y;
149 
153  float width;
154 
158  float height;
159 
164 
169 
173  int padding;
174 
179 
183  ofColor frameColor;
184 
189 
194 
195  protected:
196  map<vector<int>, shared_ptr<Component>> components;
197 };
198 }
199 
200 #endif
vector< shared_ptr< Component > > getComponents()
get a vector of pointers to the components of the group
Definition: ofxOuiGroup.cpp:198
int rows() const
get the number of rows in the group
Definition: ofxOuiGroup.cpp:149
bool removeComponent(shared_ptr< Component > component)
remove a given component from the group by pointer
Group(int x_=0, int y_=0, int width_=100, int height_=100)
Constructor.
Definition: ofxOuiGroup.cpp:22
void clear()
clear the UI group (deletes all components)
Definition: ofxOuiGroup.cpp:231
int max_component_height
maximum height of each component
Definition: ofxOuiGroup.hpp:168
int frame_width
width of the group frame
Definition: ofxOuiGroup.hpp:188
virtual void update()
OF-like update function.
Definition: ofxOuiGroup.cpp:104
shared_ptr< Component > getComponent(int row, int col)
get the pointer to a component by grid position
Definition: ofxOuiGroup.cpp:180
float y
y position(top)
Definition: ofxOuiGroup.hpp:148
void enable()
disable all components
Definition: ofxOuiGroup.cpp:242
shared_ptr< Component > getComponentByLabel(string label)
get the pointer to a component by label (inactive label)
Definition: ofxOuiGroup.cpp:189
~Group()
Destructor.
Definition: ofxOuiGroup.cpp:34
Definition: ofxOuiColormap.hpp:25
int cols() const
get the number of columns in the group
Definition: ofxOuiGroup.cpp:157
float x
x position (left)
Definition: ofxOuiGroup.hpp:143
Group of UI components.
Definition: ofxOuiGroup.hpp:31
ofColor frameColor
frame color of the group
Definition: ofxOuiGroup.hpp:183
virtual bool inside(int x_, int y_)
checks if the point (x, y) is inside the UI group
Definition: ofxOuiGroup.cpp:145
map< vector< int >, shared_ptr< Component > > components
Definition: ofxOuiGroup.hpp:196
int padding
padding between the components
Definition: ofxOuiGroup.hpp:173
Anchor
Generic Anchor specifier for Text/Image alignment.
Definition: ofxOuiCommon.hpp:57
bool addComponent(shared_ptr< Component > component, int row, int col, int rowSpan=1, int colSpan=1)
add a component to the group
Definition: ofxOuiGroup.cpp:165
float height
group height
Definition: ofxOuiGroup.hpp:158
void disable()
disable all components
Definition: ofxOuiGroup.cpp:236
float width
group width
Definition: ofxOuiGroup.hpp:153
ofColor backgroundColor
background color of the group
Definition: ofxOuiGroup.hpp:178
virtual void setup()
Definition: ofxOuiGroup.cpp:36
virtual void draw()
OF-like draw function.
Definition: ofxOuiGroup.cpp:110
int max_component_width
maximum width of each component
Definition: ofxOuiGroup.hpp:163
ofxOui::Anchor alignment
width of the group frame
Definition: ofxOuiGroup.hpp:193