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

The button class draws a clickable rectangle on the screen to be used as a callback interface The select button toggles between pressed and not pressed when clicked. More...

#include <selectbutton.hpp>

Inheritance diagram for Tucano::GUI::SelectButton:
Tucano::GUI::Element

Public Member Functions

 SelectButton (void)
 Default constructor. More...
 
 SelectButton (int w, int h, int x, int y)
 Overload Constructor. More...
 
 SelectButton (int w, int h, int x, int y, string texture)
 Overload constructor that receives dimensions and texture file. More...
 
 SelectButton (int w, int h, int x, int y, string texture, string alt_texture)
 Overload constructor that receives dimensions and texture file. More...
 
int getType (void)
 Returns the element type. More...
 
void onClick (function< void()> f)
 
void clicked (void)
 Click callback. More...
 
void setColor (const Eigen::Vector4f &c)
 Sets the button color. More...
 
void toggleSelected (void)
 Toggles button state selected/unselected. More...
 
void render (Camera &camera_2d, Shader &shader)
 Renders button If has alternate texture uses the one corresponding to current state, otherwise uses always main texture. More...
 
- Public Member Functions inherited from Tucano::GUI::Element
 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 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

bool selected = false
 Flag to select (pressed) / unselect button. More...
 
function< void() > callback
 Button has one callback without parameters. More...
 
- Protected Attributes inherited from Tucano::GUI::Element
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...
 

Private Attributes

friend SelectGroup
 

Detailed Description

The button class draws a clickable rectangle on the screen to be used as a callback interface The select button toggles between pressed and not pressed when clicked.

Constructor & Destructor Documentation

Tucano::GUI::SelectButton::SelectButton ( void  )
inline

Default constructor.

Tucano::GUI::SelectButton::SelectButton ( int  w,
int  h,
int  x,
int  y 
)
inline

Overload Constructor.

Parameters
wButton width in pixels
hButton height in pixels
xButton top left corner x coordinate in pixels
yButton top left corner y coordinate in pixels
Tucano::GUI::SelectButton::SelectButton ( int  w,
int  h,
int  x,
int  y,
string  texture 
)
inline

Overload constructor that receives dimensions and texture file.

Parameters
wButton width in pixels
hButton height in pixels
xButton top left corner x coordinate in pixels
yButton top left corner y coordinate in pixels
texturePath to texture file
Tucano::GUI::SelectButton::SelectButton ( int  w,
int  h,
int  x,
int  y,
string  texture,
string  alt_texture 
)
inline

Overload constructor that receives dimensions and texture file.

Parameters
wButton width in pixels
hButton height in pixels
xButton top left corner x coordinate in pixels
yButton top left corner y coordinate in pixels
texturePath to texture file

Member Function Documentation

void Tucano::GUI::SelectButton::clicked ( void  )
inline

Click callback.

int Tucano::GUI::SelectButton::getType ( void  )
inlinevirtual

Returns the element type.

Reimplemented from Tucano::GUI::Element.

void Tucano::GUI::SelectButton::onClick ( function< void()>  f)
inline

brief Sets the button callback with no parameters

Parameters
fCallback method
void Tucano::GUI::SelectButton::render ( Camera camera_2d,
Shader shader 
)
inlinevirtual

Renders button If has alternate texture uses the one corresponding to current state, otherwise uses always main texture.

Parameters
camera_2dThe 2D GUI camera
shaderA shader for rendering the button

Reimplemented from Tucano::GUI::Element.

void Tucano::GUI::SelectButton::setColor ( const Eigen::Vector4f &  c)
inline

Sets the button color.

Parameters
cNew button color.
void Tucano::GUI::SelectButton::toggleSelected ( void  )
inline

Toggles button state selected/unselected.

Member Data Documentation

function< void() > Tucano::GUI::SelectButton::callback
protected

Button has one callback without parameters.

bool Tucano::GUI::SelectButton::selected = false
protected

Flag to select (pressed) / unselect button.

friend Tucano::GUI::SelectButton::SelectGroup
private

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