23 #ifndef __GUIELEMENT__ 24 #define __GUIELEMENT__ 90 Eigen::Vector4f
color = Eigen::Vector4f (1.0, 1.0, 1.0, 1.0);
110 model_matrix = Eigen::Affine3f::Identity();
111 callback_noparam = NULL;
187 has_alt_texture =
true;
188 color = Eigen::Vector4f (1.0, 1.0, 1.0, 1.0);
197 model_matrix = Eigen::Affine3f::Identity();
200 model_matrix.translate (Eigen::Vector3f ((
float)position[0], (
float)position[1], 0.0) );
202 model_matrix.scale (Eigen::Vector3f ((
float)dimensions[0], (
float)dimensions[1], 1.0));
204 model_matrix.translate (Eigen::Vector3f (0.5, 0.5, 0.0) );
235 return isInside (Eigen::Vector2i(x,y));
244 if (pos[0] >= position[0] && pos[0] <= position[0] + dimensions[0] &&
245 pos[1] >= position[1] && pos[1] <= position[1] + dimensions[1])
277 shader.
setUniform(
"modelMatrix", model_matrix);
297 callback_noparam = f;
343 void show(
void) { visible =
true; }
348 void hide(
void) { visible =
false; }
Eigen::Vector2i dimensions
Dimensions in pixels.
Definition: element.hpp:66
virtual void cursorMove(int x, int y)
Set behavior when mouse is released after clicking this element.
Definition: element.hpp:260
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
Definition: element.hpp:39
void getViewMatrix(GLdouble *matrix)
Return the modelview matrix as a GLdouble array.
Definition: camera.hpp:126
A simple unitary quad.
Definition: quad.hpp:66
virtual void setModelMatrix(void)
Sets the element model matrix.
Definition: element.hpp:195
Tucano::Texture texture
Element texture.
Definition: element.hpp:75
Tucano::Texture texture_alt2
2nd Alternative texture (for example, hover on)
Definition: element.hpp:81
ElementType
Definition: element.hpp:36
void getProjectionMatrix(GLdouble *matrix)
Return the projection matrix as a GLdouble array.
Definition: camera.hpp:142
virtual bool isInside(const Eigen::Vector2i &pos)
Returns if a point is inside the element controller.
Definition: element.hpp:242
bool isVisible(void)
Return whether element is visible or not.
Definition: element.hpp:359
Definition: bufferobject.hpp:34
static bool loadImage(string filename, Tucano::Texture *tex) __attribute__((unused))
Definition: imageIO.hpp:45
virtual void callback(int p)
Callback with 1 integer.
Definition: element.hpp:327
virtual void setCallback(function< void()> f)
Definition: element.hpp:295
void hide(void)
Hides element.
Definition: element.hpp:348
void setDimensions(const Eigen::Vector2i &dim)
Sets the button dimensions.
Definition: element.hpp:139
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 setTexParameters(GLenum wraps=GL_CLAMP, GLenum wrapt=GL_CLAMP, GLenum magfilter=GL_NEAREST, GLenum minfilter=GL_NEAREST)
Deletes the texture.
Definition: texture.hpp:221
function< void(float) > callback_1f
Definition: element.hpp:95
A Shader object represents one GLSL program.
Definition: shader.hpp:45
int getWidth(void)
Returns the texture width.
Definition: texture.hpp:102
void setDimensions(int w, int h)
Sets the button dimensions.
Definition: element.hpp:150
bool hover
Flag to enable/disable hover on functionality.
Definition: element.hpp:101
bool visible
Flag to show/hide element.
Definition: element.hpp:98
virtual void callback(void)
Callback with no parameters.
Definition: element.hpp:319
Definition: element.hpp:44
Definition: element.hpp:40
bool has_alt_texture2
Flag to define if element has second alt texture.
Definition: element.hpp:87
Definition: element.hpp:43
int num_params
Number of parameters for the callback.
Definition: element.hpp:60
Eigen::Vector2i getPosition(void)
Returns coordinates of elements top left corner.
Definition: element.hpp:130
void unbind(void)
Disables the shader program.
Definition: shader.hpp:1184
virtual void release(void)
Set behavior when mouse is released after clicking this element.
Definition: element.hpp:253
Eigen::Affine3f model_matrix
Model Matrix for placing element.
Definition: element.hpp:63
function< void(int) > callback_1i
Definition: element.hpp:94
bool has_alt_texture
Flag to define if element has alt texture.
Definition: element.hpp:84
virtual void render(Camera &camera_2d, Shader &shader)
Definition: element.hpp:270
virtual void setDimensionsFromHeight(int h)
Sets the width proportinal to given height Uses texture dimensions as parameter, it must be already s...
Definition: element.hpp:160
function< void() > callback_noparam
Definition: element.hpp:93
Element(void)
Default constructor.
Definition: element.hpp:108
Eigen::Vector4f color
Color.
Definition: element.hpp:90
Definition: element.hpp:42
void setPosition(int x, int y)
Sets the button top left position.
Definition: element.hpp:224
int getHeight(void)
Returns the texture height.
Definition: texture.hpp:111
virtual void unbindBuffers(void)
Unbinds all buffers.
Definition: mesh.hpp:702
virtual void setCallback1f(function< void(float) > f)
Sets the callback from an method.
Definition: element.hpp:311
void show(void)
Shows element.
Definition: element.hpp:343
virtual void setAltTexture(string file)
Loads the button texture file.
Definition: element.hpp:183
virtual void setTexture(string file)
Loads the button texture file.
Definition: element.hpp:173
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
Tucano::Texture texture_alt
Alternative texture (for example, on/off buttons)
Definition: element.hpp:78
int element_type
Type of element.
Definition: element.hpp:57
void bind(void)
Enables the shader program for usage.
Definition: shader.hpp:1176
Definition: element.hpp:38
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 int getType(void)
Returns the element type.
Definition: element.hpp:265
virtual void bindBuffers(void)
Binds all buffers.
Definition: mesh.hpp:677
void setPosition(const Eigen::Vector2i &pos)
Sets the button top left position.
Definition: element.hpp:213
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
void toggleDisplay(void)
Toggles show/hide flag.
Definition: element.hpp:353
virtual void setCallback1i(function< void(int) > f)
Sets the callback from an method.
Definition: element.hpp:303
Shapes::Quad quad
Quad to hold texture.
Definition: element.hpp:72
Definition: element.hpp:41
virtual void callback(float p)
Callback with 1 integer.
Definition: element.hpp:335
void unbind(void)
Unbinds this texture and frees the texture unit.
Definition: texture.hpp:367
Eigen::Vector2i getDimensions(void)
Returns the element's dimensions.
Definition: element.hpp:121
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