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

The slide class draws a dragable cursor over a bar. More...

#include <slider.hpp>

Inheritance diagram for Tucano::GUI::Slider:
Tucano::GUI::Element

Public Member Functions

 Slider (void)
 Default constructor. More...
 
 Slider (int w, int h, int x, int y)
 Overload Constructor. More...
 
 Slider (int w, int h, int x, int y, string bar_tex, string slider_tex)
 Overload constructor that receives dimensions and texture file. More...
 
void setMinMaxValues (float minv, float maxv)
 Sets min max values for the slide All operations are treated in range [0,1] and only when responding the callback mapped to [min, max]. More...
 
void moveSlider (float v)
 Move slider to relative position on bar [min,max]. More...
 
void setValue (float normalized_pos)
 Move slider to relative normalized position on bar [0,1]. More...
 
bool isInside (const Eigen::Vector2i &pos)
 Returns if clicked on slider handle If clicked on handle start slidigin while button is pressed If clicked on bar but on handle returns true but does not start sliding. More...
 
void cursorMove (int x, int y)
 Set behavior when mouse is released after clicking this element. More...
 
void release (void)
 Stop sliding when mouse is released. More...
 
int getType (void)
 Returns the element type. More...
 
void setTexture (string bar_file, string slider_file)
 Loads the slider texture file. More...
 
void onValueChanged (function< void(float)> f)
 
float getValue (void)
 Returns the value in range [min, max]. More...
 
void valueChanged (void)
 Callback when value changes. More...
 
void setColor (const Eigen::Vector4f &c)
 Sets the slider color. More...
 
void setModelMatrix (void)
 Sets the slider model matrix. More...
 
void setSliderModelMatrix (void)
 Sets the model matrix for the slider with the respective position. More...
 
void render (Tucano::Camera &camera_2d, Shader &shader)
 
- 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...
 
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 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

Tucano::Texture slider_texture
 Slider texture. More...
 
function< void(float) > callback
 Slider has one callback with the slider position. More...
 
float value = 0.5
 Slider current value. More...
 
float min_value = 0.0
 Min max values. More...
 
float max_value = 1.0
 
Eigen::Affine3f slider_model_matrix = Eigen::Affine3f::Identity()
 Model matrix for the slider (not constant) More...
 
bool sliding = false
 is holding slider More...
 
Eigen::Vector2i slider_pos = Eigen::Vector2i::Zero()
 position of slider More...
 
Eigen::Vector2i slider_dim = Eigen::Vector2i::Zero()
 slider dimensions 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...
 

Detailed Description

The slide class draws a dragable cursor over a bar.

Constructor & Destructor Documentation

Tucano::GUI::Slider::Slider ( void  )
inline

Default constructor.

Tucano::GUI::Slider::Slider ( 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::Slider::Slider ( int  w,
int  h,
int  x,
int  y,
string  bar_tex,
string  slider_tex 
)
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::Slider::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 from Tucano::GUI::Element.

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

Returns the element type.

Reimplemented from Tucano::GUI::Element.

float Tucano::GUI::Slider::getValue ( void  )
inline

Returns the value in range [min, max].

Returns
Slider value
bool Tucano::GUI::Slider::isInside ( const Eigen::Vector2i &  pos)
inlinevirtual

Returns if clicked on slider handle If clicked on handle start slidigin while button is pressed If clicked on bar but on handle returns true but does not start sliding.

Parameters
posScreen position of the mouse click
Returns
True if clicked on bar or handle, false otherwise

Reimplemented from Tucano::GUI::Element.

void Tucano::GUI::Slider::moveSlider ( float  v)
inline

Move slider to relative position on bar [min,max].

Parameters
vValue in range [min,max]
void Tucano::GUI::Slider::onValueChanged ( function< void(float)>  f)
inline

brief Sets the slider callback with one parameters

Parameters
fCallback method
void Tucano::GUI::Slider::release ( void  )
inlinevirtual

Stop sliding when mouse is released.

Reimplemented from Tucano::GUI::Element.

void Tucano::GUI::Slider::render ( Tucano::Camera camera_2d,
Shader shader 
)
inlinevirtual

Reimplemented from Tucano::GUI::Element.

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

Sets the slider color.

Parameters
cNew slider color.
void Tucano::GUI::Slider::setMinMaxValues ( float  minv,
float  maxv 
)
inline

Sets min max values for the slide All operations are treated in range [0,1] and only when responding the callback mapped to [min, max].

Parameters
minvMin value
maxvMax value
void Tucano::GUI::Slider::setModelMatrix ( void  )
inlinevirtual

Sets the slider model matrix.

Reimplemented from Tucano::GUI::Element.

void Tucano::GUI::Slider::setSliderModelMatrix ( void  )
inline

Sets the model matrix for the slider with the respective position.

void Tucano::GUI::Slider::setTexture ( string  bar_file,
string  slider_file 
)
inline

Loads the slider texture file.

Parameters
fileTexture path
void Tucano::GUI::Slider::setValue ( float  normalized_pos)
inline

Move slider to relative normalized position on bar [0,1].

Parameters
normalized_posValue in range [0,1]
void Tucano::GUI::Slider::valueChanged ( void  )
inline

Callback when value changes.

Member Data Documentation

function< void(float) > Tucano::GUI::Slider::callback
protected

Slider has one callback with the slider position.

float Tucano::GUI::Slider::max_value = 1.0
protected
float Tucano::GUI::Slider::min_value = 0.0
protected

Min max values.

Eigen::Vector2i Tucano::GUI::Slider::slider_dim = Eigen::Vector2i::Zero()
protected

slider dimensions

Eigen::Affine3f Tucano::GUI::Slider::slider_model_matrix = Eigen::Affine3f::Identity()
protected

Model matrix for the slider (not constant)

Eigen::Vector2i Tucano::GUI::Slider::slider_pos = Eigen::Vector2i::Zero()
protected

position of slider

Tucano::Texture Tucano::GUI::Slider::slider_texture
protected

Slider texture.

bool Tucano::GUI::Slider::sliding = false
protected

is holding slider

float Tucano::GUI::Slider::value = 0.5
protected

Slider current value.


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