Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
Tucano::GUI::Element Class Reference

Base class for all GUI elements (buttons, sliders ...) More...

#include <element.hpp>

Inheritance diagram for Tucano::GUI::Element:
Tucano::GUI::Button Tucano::GUI::GroupBox Tucano::GUI::Label Tucano::GUI::SelectButton Tucano::GUI::SelectGroup Tucano::GUI::Slider

Public Member Functions

 Element (void)
 Default constructor. More...
 
Eigen::Vector2i getDimensions (void)
 Returns the element's dimensions. More...
 
Eigen::Vector2i getPosition (void)
 Returns coordinates of elements top left corner. More...
 
void setDimensions (const Eigen::Vector2i &dim)
 Sets the button dimensions. More...
 
void setDimensions (int w, int h)
 Sets the button dimensions. More...
 
virtual void setDimensionsFromHeight (int h)
 Sets the width proportinal to given height Uses texture dimensions as parameter, it must be already set. More...
 
virtual void setTexture (string file)
 Loads the button texture file. More...
 
virtual void setAltTexture (string file)
 Loads the button texture file. More...
 
virtual void setModelMatrix (void)
 Sets the element model matrix. More...
 
void setPosition (const Eigen::Vector2i &pos)
 Sets the button top left position. More...
 
void setPosition (int x, int y)
 Sets the button top left position. More...
 
bool isInside (int x, int y)
 Overloads the isInside method. Queries if a point is inside the button. More...
 
virtual bool isInside (const Eigen::Vector2i &pos)
 Returns if a point is inside the element controller. More...
 
virtual void release (void)
 Set behavior when mouse is released after clicking this element. More...
 
virtual void cursorMove (int x, int y)
 Set behavior when mouse is released after clicking this element. More...
 
virtual int getType (void)
 Returns the element type. More...
 
virtual void render (Camera &camera_2d, Shader &shader)
 
virtual void setCallback (function< void()> f)
 
virtual void setCallback1i (function< void(int) > f)
 Sets the callback from an method. More...
 
virtual void setCallback1f (function< void(float) > f)
 Sets the callback from an method. More...
 
virtual void callback (void)
 Callback with no parameters. More...
 
virtual void callback (int p)
 Callback with 1 integer. More...
 
virtual void callback (float p)
 Callback with 1 integer. More...
 
void show (void)
 Shows element. More...
 
void hide (void)
 Hides element. More...
 
void toggleDisplay (void)
 Toggles show/hide flag. More...
 
bool isVisible (void)
 Return whether element is visible or not. More...
 

Protected Attributes

int element_type = Tucano::GUI::NONE
 Type of element. More...
 
int num_params = 0
 Number of parameters for the callback. More...
 
Eigen::Affine3f model_matrix
 Model Matrix for placing element. More...
 
Eigen::Vector2i dimensions
 Dimensions in pixels. More...
 
Eigen::Vector2i position
 Position of top-left corner in pixels. More...
 
Shapes::Quad quad
 Quad to hold texture. More...
 
Tucano::Texture texture
 Element texture. More...
 
Tucano::Texture texture_alt
 Alternative texture (for example, on/off buttons) More...
 
Tucano::Texture texture_alt2
 2nd Alternative texture (for example, hover on) More...
 
bool has_alt_texture = 0
 Flag to define if element has alt texture. More...
 
bool has_alt_texture2 = 0
 Flag to define if element has second alt texture. More...
 
Eigen::Vector4f color = Eigen::Vector4f (1.0, 1.0, 1.0, 1.0)
 Color. More...
 
function< void() > callback_noparam
 
function< void(int) > callback_1i
 
function< void(float) > callback_1f
 
bool visible = true
 Flag to show/hide element. More...
 
bool hover = false
 Flag to enable/disable hover on functionality. More...
 

Detailed Description

Base class for all GUI elements (buttons, sliders ...)

This class contain the basic callback interface

Constructor & Destructor Documentation

Tucano::GUI::Element::Element ( void  )
inline

Default constructor.

Member Function Documentation

virtual void Tucano::GUI::Element::callback ( void  )
inlinevirtual

Callback with no parameters.

virtual void Tucano::GUI::Element::callback ( int  p)
inlinevirtual

Callback with 1 integer.

virtual void Tucano::GUI::Element::callback ( float  p)
inlinevirtual

Callback with 1 integer.

virtual void Tucano::GUI::Element::cursorMove ( int  x,
int  y 
)
inlinevirtual

Set behavior when mouse is released after clicking this element.

Parameters
xX position of cursor
yY position of cursor

Reimplemented in Tucano::GUI::Slider.

Eigen::Vector2i Tucano::GUI::Element::getDimensions ( void  )
inline

Returns the element's dimensions.

Returns
Element's dimensions as a Vector2i
Eigen::Vector2i Tucano::GUI::Element::getPosition ( void  )
inline

Returns coordinates of elements top left corner.

Returns
Element's position as Vector2i
virtual int Tucano::GUI::Element::getType ( void  )
inlinevirtual
void Tucano::GUI::Element::hide ( void  )
inline

Hides element.

bool Tucano::GUI::Element::isInside ( int  x,
int  y 
)
inline

Overloads the isInside method. Queries if a point is inside the button.

Parameters
xX position of query point
yY position of query point
virtual bool Tucano::GUI::Element::isInside ( const Eigen::Vector2i &  pos)
inlinevirtual

Returns if a point is inside the element controller.

Parameters
posScreen position

Reimplemented in Tucano::GUI::Slider.

bool Tucano::GUI::Element::isVisible ( void  )
inline

Return whether element is visible or not.

Returns
True if visible, false otherwise
virtual void Tucano::GUI::Element::release ( void  )
inlinevirtual

Set behavior when mouse is released after clicking this element.

Reimplemented in Tucano::GUI::Slider.

virtual void Tucano::GUI::Element::render ( Camera camera_2d,
Shader shader 
)
inlinevirtual
virtual void Tucano::GUI::Element::setAltTexture ( string  file)
inlinevirtual

Loads the button texture file.

Parameters
fileTexture path
virtual void Tucano::GUI::Element::setCallback ( function< void()>  f)
inlinevirtual
virtual void Tucano::GUI::Element::setCallback1f ( function< void(float) >  f)
inlinevirtual

Sets the callback from an method.

virtual void Tucano::GUI::Element::setCallback1i ( function< void(int) >  f)
inlinevirtual

Sets the callback from an method.

void Tucano::GUI::Element::setDimensions ( const Eigen::Vector2i &  dim)
inline

Sets the button dimensions.

Parameters
dimNew button dimensions
void Tucano::GUI::Element::setDimensions ( int  w,
int  h 
)
inline

Sets the button dimensions.

Parameters
wNew button width
hNew button height
virtual void Tucano::GUI::Element::setDimensionsFromHeight ( int  h)
inlinevirtual

Sets the width proportinal to given height Uses texture dimensions as parameter, it must be already set.

Parameters
sGiven height
virtual void Tucano::GUI::Element::setModelMatrix ( void  )
inlinevirtual

Sets the element model matrix.

Reimplemented in Tucano::GUI::Slider.

void Tucano::GUI::Element::setPosition ( const Eigen::Vector2i &  pos)
inline

Sets the button top left position.

Parameters
posNew button position
void Tucano::GUI::Element::setPosition ( int  x,
int  y 
)
inline

Sets the button top left position.

Parameters
xNew button x position
yNew button y position
virtual void Tucano::GUI::Element::setTexture ( string  file)
inlinevirtual

Loads the button texture file.

Parameters
fileTexture path

Reimplemented in Tucano::GUI::Label.

void Tucano::GUI::Element::show ( void  )
inline

Shows element.

void Tucano::GUI::Element::toggleDisplay ( void  )
inline

Toggles show/hide flag.

Member Data Documentation

function< void(float) > Tucano::GUI::Element::callback_1f
protected
function< void(int) > Tucano::GUI::Element::callback_1i
protected
function< void() > Tucano::GUI::Element::callback_noparam
protected
Eigen::Vector4f Tucano::GUI::Element::color = Eigen::Vector4f (1.0, 1.0, 1.0, 1.0)
protected

Color.

Eigen::Vector2i Tucano::GUI::Element::dimensions
protected

Dimensions in pixels.

int Tucano::GUI::Element::element_type = Tucano::GUI::NONE
protected

Type of element.

bool Tucano::GUI::Element::has_alt_texture = 0
protected

Flag to define if element has alt texture.

bool Tucano::GUI::Element::has_alt_texture2 = 0
protected

Flag to define if element has second alt texture.

bool Tucano::GUI::Element::hover = false
protected

Flag to enable/disable hover on functionality.

Eigen::Affine3f Tucano::GUI::Element::model_matrix
protected

Model Matrix for placing element.

int Tucano::GUI::Element::num_params = 0
protected

Number of parameters for the callback.

Eigen::Vector2i Tucano::GUI::Element::position
protected

Position of top-left corner in pixels.

Shapes::Quad Tucano::GUI::Element::quad
protected

Quad to hold texture.

Tucano::Texture Tucano::GUI::Element::texture
protected

Element texture.

Tucano::Texture Tucano::GUI::Element::texture_alt
protected

Alternative texture (for example, on/off buttons)

Tucano::Texture Tucano::GUI::Element::texture_alt2
protected

2nd Alternative texture (for example, hover on)

bool Tucano::GUI::Element::visible = true
protected

Flag to show/hide element.


The documentation for this class was generated from the following file: