ofxOui - UI Components for OpenFrameworks

ofxOuiComponent.hpp
Go to the documentation of this file.
1 /*
2  * ofxOuiComponent.hpp
3  *
4  * UI Component Base Class
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 ofxOuiComponent_hpp
21 #define ofxOuiComponent_hpp
22 
23 #include "ofxOuiIcon.hpp"
24 #include "ofxOuiStyle.hpp"
25 #include "ofxOuiTextBox.hpp"
26 
27 namespace ofxOui {
28 
33 class Component {
34  public:
35  friend class Group;
36 
44  Component(float x_ = 0, float y_ = 0, float width_ = 0, float height_ = 0);
45 
49  virtual ~Component();
50 
54  virtual void update();
55 
61  virtual void draw();
62 
67  virtual bool inside(float x_, float y_) const;
68 
73  inline Type type() const { return type_; }
74 
79 
84 
89 
94 
98  float x;
99 
103  float y;
104 
108  float width;
109 
113  float height;
114 
118  string labelOn = "";
119 
123  string labelOff = "";
124 
129  bool disabled = false;
130 
134  bool active = false;
135 
136  protected:
137  virtual void drawBackground();
138  virtual void drawFrame();
139  virtual void drawLabel();
140  virtual void drawIcon();
142  bool hover_ = false;
145 
147 };
148 
152 typedef Component Label;
153 }
154 
155 #endif
TextBox font
textbox for the main label of the component
Definition: ofxOuiComponent.hpp:88
static Component * blocking_component
Definition: ofxOuiComponent.hpp:146
Shape shape
shape of the component
Definition: ofxOuiComponent.hpp:78
virtual void drawIcon()
Definition: ofxOuiComponent.cpp:113
virtual ~Component()
Destructor.
Definition: ofxOuiComponent.cpp:27
float y
y position(top)
Definition: ofxOuiComponent.hpp:103
virtual void drawLabel()
Definition: ofxOuiComponent.cpp:115
virtual void drawFrame()
Definition: ofxOuiComponent.cpp:98
float height
component height
Definition: ofxOuiComponent.hpp:113
Style structure shared among all components.
Definition: ofxOuiStyle.hpp:31
bool hover_
Definition: ofxOuiComponent.hpp:142
float width
component width
Definition: ofxOuiComponent.hpp:108
string labelOff
Label of the component (not active)
Definition: ofxOuiComponent.hpp:123
Shape
Base shape of the UI components.
Definition: ofxOuiCommon.hpp:73
string labelOn
Label of the component (active)
Definition: ofxOuiComponent.hpp:118
bool disabled
specifies if the component should be in "disabled" mode (no interaction)
Definition: ofxOuiComponent.hpp:129
ofColor current_frame_color_
Definition: ofxOuiComponent.hpp:144
virtual void drawBackground()
Definition: ofxOuiComponent.cpp:83
static const Style Default
Definition: ofxOuiStyle.hpp:169
Base UI Component (equivalent to a label)
Definition: ofxOuiComponent.hpp:33
Style style
style of the component
Definition: ofxOuiComponent.hpp:83
Type type_
Definition: ofxOuiComponent.hpp:141
Component(float x_=0, float y_=0, float width_=0, float height_=0)
Constructor.
Definition: ofxOuiComponent.cpp:24
float x
x position (left)
Definition: ofxOuiComponent.hpp:98
Icon icon
icon box of the component
Definition: ofxOuiComponent.hpp:93
Type
Type of UI Component.
Definition: ofxOuiCommon.hpp:38
virtual void update()
OF-like update function.
Definition: ofxOuiComponent.cpp:29
ofColor current_background_color_
Definition: ofxOuiComponent.hpp:143
Text box font wrapper.
Definition: ofxOuiTextBox.hpp:31
Definition: ofxOuiColormap.hpp:25
Icon image box wrapper.
Definition: ofxOuiIcon.hpp:31
Group of UI components.
Definition: ofxOuiGroup.hpp:31
Type type() const
get the type of the component
Definition: ofxOuiComponent.hpp:73
virtual void draw()
OF-like draw function.
Definition: ofxOuiComponent.cpp:76
virtual bool inside(float x_, float y_) const
checks if a point is inside the component (depending on the shape)
Definition: ofxOuiComponent.cpp:117
bool active
specifies if the component is active
Definition: ofxOuiComponent.hpp:134