28 #include <Eigen/Dense> 102 Slider (
int w,
int h,
int x,
int y,
string bar_tex,
string slider_tex)
128 setValue ((v - min_value)/(max_value - min_value));
138 value = min( max (0.0f, normalized_pos), 1.0f);
157 if (fabs(relative_pos - value) <= 1.5*slider_dim[0]/(float)
dimensions[0])
205 slider_texture.
setTexParameters( GL_REPEAT, GL_REPEAT, GL_LINEAR, GL_LINEAR );
228 return (value)*(max_value-
min_value) + min_value;
263 slider_model_matrix = Eigen::Affine3f::Identity();
265 slider_model_matrix.translate (Eigen::Vector3f ((
float)slider_pos[0], (
float)slider_pos[1], 0.0));
267 slider_model_matrix.scale (Eigen::Vector3f( (
float)slider_dim[0], (
float)slider_dim[1], 1.0) );
269 slider_model_matrix.translate (Eigen::Vector3f (0.0, 0.5, 0.0) );
292 shader.
setUniform(
"modelMatrix", slider_model_matrix);
Eigen::Vector2i dimensions
Dimensions in pixels.
Definition: element.hpp:66
Eigen::Vector2i position
Position of top-left corner in pixels.
Definition: element.hpp:69
Base class for all GUI elements (buttons, sliders ...)
Definition: element.hpp:52
function< void(float) > callback
Slider has one callback with the slider position.
Definition: slider.hpp:47
float min_value
Min max values.
Definition: slider.hpp:53
void setModelMatrix(void)
Sets the slider model matrix.
Definition: slider.hpp:252
void getViewMatrix(GLdouble *matrix)
Return the modelview matrix as a GLdouble array.
Definition: camera.hpp:126
virtual void setModelMatrix(void)
Sets the element model matrix.
Definition: element.hpp:195
Tucano::Texture texture
Element texture.
Definition: element.hpp:75
void setColor(const Eigen::Vector4f &c)
Sets the slider color.
Definition: slider.hpp:244
void getProjectionMatrix(GLdouble *matrix)
Return the projection matrix as a GLdouble array.
Definition: camera.hpp:142
Definition: bufferobject.hpp:34
bool sliding
is holding slider
Definition: slider.hpp:60
static bool loadImage(string filename, Tucano::Texture *tex) __attribute__((unused))
Definition: imageIO.hpp:45
void bind(int texture_unit)
Binds the texture to a given unit. Note that if there is another texture already binded to this unit...
Definition: texture.hpp:285
void cursorMove(int x, int y)
Set behavior when mouse is released after clicking this element.
Definition: slider.hpp:173
void setTexParameters(GLenum wraps=GL_CLAMP, GLenum wrapt=GL_CLAMP, GLenum magfilter=GL_NEAREST, GLenum minfilter=GL_NEAREST)
Deletes the texture.
Definition: texture.hpp:221
Eigen::Affine3f slider_model_matrix
Model matrix for the slider (not constant)
Definition: slider.hpp:57
void render(Tucano::Camera &camera_2d, Shader &shader)
Definition: slider.hpp:272
float getValue(void)
Returns the value in range [min, max].
Definition: slider.hpp:226
void setValue(float normalized_pos)
Move slider to relative normalized position on bar [0,1].
Definition: slider.hpp:135
A Shader object represents one GLSL program.
Definition: shader.hpp:45
int getWidth(void)
Returns the texture width.
Definition: texture.hpp:102
void moveSlider(float v)
Move slider to relative position on bar [min,max].
Definition: slider.hpp:126
void setSliderModelMatrix(void)
Sets the model matrix for the slider with the respective position.
Definition: slider.hpp:261
bool visible
Flag to show/hide element.
Definition: element.hpp:98
virtual void callback(void)
Callback with no parameters.
Definition: element.hpp:319
Slider(int w, int h, int x, int y)
Overload Constructor.
Definition: slider.hpp:85
float value
Slider current value.
Definition: slider.hpp:50
void release(void)
Stop sliding when mouse is released.
Definition: slider.hpp:185
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 ...
Definition: slider.hpp:115
void valueChanged(void)
Callback when value changes.
Definition: slider.hpp:235
Eigen::Vector2i slider_dim
slider dimensions
Definition: slider.hpp:66
Eigen::Vector2i slider_pos
position of slider
Definition: slider.hpp:63
int num_params
Number of parameters for the callback.
Definition: element.hpp:60
void setTexture(string bar_file, string slider_file)
Loads the slider texture file.
Definition: slider.hpp:200
void unbind(void)
Disables the shader program.
Definition: shader.hpp:1184
Eigen::Affine3f model_matrix
Model Matrix for placing element.
Definition: element.hpp:63
Slider(int w, int h, int x, int y, string bar_tex, string slider_tex)
Overload constructor that receives dimensions and texture file.
Definition: slider.hpp:102
Eigen::Vector4f color
Color.
Definition: element.hpp:90
int getHeight(void)
Returns the texture height.
Definition: texture.hpp:111
virtual void unbindBuffers(void)
Unbinds all buffers.
Definition: mesh.hpp:702
int getType(void)
Returns the element type.
Definition: slider.hpp:191
bool isInside(int x, int y)
Overloads the isInside method. Queries if a point is inside the button.
Definition: element.hpp:233
An OpenGL texture. It can be a simple texture or an FBO texture.
Definition: texture.hpp:41
int element_type
Type of element.
Definition: element.hpp:57
void bind(void)
Enables the shader program for usage.
Definition: shader.hpp:1176
virtual void renderElements(void)
Call the draw method for rendering triangles. This method requires that a index buffer has been creat...
Definition: mesh.hpp:726
virtual void bindBuffers(void)
Binds all buffers.
Definition: mesh.hpp:677
Defines an abstract camera with a projection and view matrices.
Definition: camera.hpp:37
void setAttributeLocation(Shader *shader)
Automatically sets the attribute locations for a given Shader.
Definition: mesh.hpp:541
float max_value
Definition: slider.hpp:54
Tucano::Texture slider_texture
Slider texture.
Definition: slider.hpp:44
Shapes::Quad quad
Quad to hold texture.
Definition: element.hpp:72
bool isInside(const Eigen::Vector2i &pos)
Returns if clicked on slider handle If clicked on handle start slidigin while button is pressed If cl...
Definition: slider.hpp:150
Definition: element.hpp:41
Slider(void)
Default constructor.
Definition: slider.hpp:73
void unbind(void)
Unbinds this texture and frees the texture unit.
Definition: texture.hpp:367
The slide class draws a dragable cursor over a bar.
Definition: slider.hpp:39
void onValueChanged(function< void(float)> f)
Definition: slider.hpp:216
void setUniform(GLint location, GLint a, GLint b, GLint c, GLint d)
Sets an uniform integer 4D vector (ivec4) given a location and the vector values. ...
Definition: shader.hpp:1258