#include <GUIWidget.hpp>
Public Types | |
enum | Corner { Corner_TopLeft = 0, Corner_TopRight = 1, Corner_BottomLeft = 2, Corner_BottomRight = 3, Corner_All = 4 } |
Widget corners enumeration. More... | |
Public Member Functions | |
GUIWidget (GUIManager *pManager) | |
Constructor. | |
GUIWidget (GUIManager *pManager, const std::string &name) | |
Constructor. | |
virtual | ~GUIWidget () |
Destructor. | |
virtual bool | load (Core::XMLNode *pNode)=0 |
Load the widget. | |
virtual void | render (std::vector< GUIManager::Quad > &renderList) |
Render the widget. | |
bool | isPointInside (const float x, const float y) const |
Check if a point is in the widget. | |
void | setName (const std::string &name) |
Set name. | |
const std::string & | getName () const |
Get name. | |
void | setVisible (const bool visible) |
Set visibility. | |
bool | getVisible () const |
Get visibility. | |
void | setPosition (const float left, const float top) |
Set position (top left corner). | |
void | setPosition (const Ogre::Vector2 &position) |
Set position (top left corner). | |
const Ogre::Vector2 & | getPosition () const |
Get position (top left corner). | |
void | setSize (const float width, const float height) |
Set size. | |
const float | getWidth () const |
Get width. | |
const float | getHeight () const |
Get height. | |
void | setColour (const float red, const float green, const float blue, const float alpha, Corner corner=Corner_All) |
Set the colour of a corner of the widget. | |
void | setColour (const Ogre::ColourValue &colour, Corner corner=Corner_All) |
Set the colour of a corner of the widget. | |
const Ogre::ColourValue & | getColour (Corner corner) const |
Get the colour of a corner of the widget. | |
void | setTexture (const std::string &texture, Ogre::Vector2 topLeft=Ogre::Vector2(0.0, 0.0), Ogre::Vector2 topRight=Ogre::Vector2(1.0, 0.0), Ogre::Vector2 bottomLeft=Ogre::Vector2(0.0, 1.0), Ogre::Vector2 bottomRight=Ogre::Vector2(1.0, 1.0)) |
Set the texture and the texture coordinates. | |
const std::string & | getTexture () const |
Get the texture. | |
const Ogre::Vector2 & | getTextureCoordinates (Corner corner) |
Get the texture coordinates. | |
Protected Member Functions | |
bool | loadPosition (Core::XMLNode *pNode) |
Load the widget position from a XML file. | |
bool | loadSize (Core::XMLNode *pNode) |
Load the widget size from a XML file. | |
bool | loadColor (Core::XMLNode *pNode) |
Load the widget position from a XML file. | |
Protected Attributes | |
GUIManager * | m_pManager |
Manager. | |
std::string | m_name |
Name. | |
bool | m_visible |
Visibility. | |
Ogre::Vector2 | m_position |
Position. | |
float | m_width |
Width. | |
float | m_height |
Height. | |
std::string | m_texture |
Texture. | |
Ogre::Vector2 | m_textureCoordinates [4] |
Texture coordinates. | |
Ogre::ColourValue | m_colour [4] |
Widget colour. |
It is the base composent of the GUI, from which every GUI component must inherit. It does nothing when being rendered.
syBR::Game::GUIWidget::GUIWidget | ( | GUIManager * | pManager | ) |
Constructor.
Set widget name to an empty string
pManager | GUI manager using this widget |
syBR::Game::GUIWidget::GUIWidget | ( | GUIManager * | pManager, | |
const std::string & | name | |||
) |
Constructor.
pManager | GUI manager using this widget | |
name | Name of the widget |
syBR::Game::GUIWidget::~GUIWidget | ( | ) | [virtual] |
Destructor.
Release used resources.
virtual bool syBR::Game::GUIWidget::load | ( | Core::XMLNode * | pNode | ) | [pure virtual] |
Load the widget.
pNode | Pointer to the XML node corresponding to this widget |
Implemented in syBR::Game::GUIContainer, syBR::Game::GUIPicture, and syBR::Game::GUIText.
void syBR::Game::GUIWidget::render | ( | std::vector< GUIManager::Quad > & | renderList | ) | [virtual] |
Render the widget.
Render the widget and its subcomponents.
renderList | List of renderables where all the renderables of this widget and its subcomponents will be pushed back |
Reimplemented in syBR::Game::GUIContainer, syBR::Game::GUIPicture, and syBR::Game::GUIText.
bool syBR::Game::GUIWidget::isPointInside | ( | const float | x, | |
const float | y | |||
) | const |
Check if a point is in the widget.
x | X coordinate of the point to be checked | |
y | Y coordinate of the point to be checked |
void syBR::Game::GUIWidget::setName | ( | const std::string & | name | ) |
Set name.
name | Name to set to the widget |
const std::string & syBR::Game::GUIWidget::getName | ( | ) | const |
Get name.
void syBR::Game::GUIWidget::setVisible | ( | const bool | visible | ) |
Set visibility.
when not visible, a widget and all its children aren't rendered.
visible | true to show the widget and its children, false otherwise |
bool syBR::Game::GUIWidget::getVisible | ( | ) | const |
Get visibility.
If not visible, a widget and its children aren't rendered.
void syBR::Game::GUIWidget::setPosition | ( | const float | left, | |
const float | top | |||
) |
Set position (top left corner).
left | X coordinate of the new position | |
top | Y coordinate of the new position |
void syBR::Game::GUIWidget::setPosition | ( | const Ogre::Vector2 & | position | ) |
Set position (top left corner).
position | New position |
const Ogre::Vector2 & syBR::Game::GUIWidget::getPosition | ( | ) | const |
Get position (top left corner).
void syBR::Game::GUIWidget::setSize | ( | const float | width, | |
const float | height | |||
) |
Set size.
width | Width of the new size of the widget | |
height | Height of the new size of the widget |
const float syBR::Game::GUIWidget::getWidth | ( | ) | const |
Get width.
const float syBR::Game::GUIWidget::getHeight | ( | ) | const |
Get height.
void syBR::Game::GUIWidget::setColour | ( | const float | red, | |
const float | green, | |||
const float | blue, | |||
const float | alpha, | |||
Corner | corner = Corner_All | |||
) |
Set the colour of a corner of the widget.
red | Red component of the new colour | |
green | Green component of the new colour | |
blue | Blue component of the new colour | |
alpha | Alpha component of the new colour | |
corner | Corner of the widget whose colour must be modified, defaults to all corners (widget is made of only one colour) |
void syBR::Game::GUIWidget::setColour | ( | const Ogre::ColourValue & | colour, | |
Corner | corner = Corner_All | |||
) |
Set the colour of a corner of the widget.
colour | New colour | |
corner | Corner of the widget whose colour must be modified, defaults to all corners (widget is made of only one colour) |
const Ogre::ColourValue & syBR::Game::GUIWidget::getColour | ( | Corner | corner | ) | const |
Get the colour of a corner of the widget.
corner | Corner whose colour must be retrieved, if Corner_All is specified, top left corner colour will be returned |
void syBR::Game::GUIWidget::setTexture | ( | const std::string & | texture, | |
Ogre::Vector2 | topLeft = Ogre::Vector2(0.0, 0.0) , |
|||
Ogre::Vector2 | topRight = Ogre::Vector2(1.0, 0.0) , |
|||
Ogre::Vector2 | bottomLeft = Ogre::Vector2(0.0, 1.0) , |
|||
Ogre::Vector2 | bottomRight = Ogre::Vector2(1.0, 1.0) | |||
) |
Set the texture and the texture coordinates.
texture | Name of the new texture to be used when rendering | |
topLeft | Texture coordinates of the top left corner of the widget | |
topRight | Texture coordinates of the top right corner of the widget | |
bottomLeft | Texture coordinates of the bottom left corner of the widget | |
bottomRight | Texture coordinates of the bottom right corner of the widget |
(0,0) is the top left corner of the texture and (1,1) is the bottom right corner of it.
const std::string & syBR::Game::GUIWidget::getTexture | ( | ) | const |
Get the texture.
const Ogre::Vector2 & syBR::Game::GUIWidget::getTextureCoordinates | ( | Corner | corner | ) |
Get the texture coordinates.
corner | Corner of the widget whose texture coordinates must be retrieved, if Corner_All is specified, top left corner colour will be returned |
bool syBR::Game::GUIWidget::loadPosition | ( | Core::XMLNode * | pNode | ) | [protected] |
Load the widget position from a XML file.
The position node must have the following format: <position left="0.0" top="0.0"/>
pNode | Pointer to the position node from the XML file |
bool syBR::Game::GUIWidget::loadSize | ( | Core::XMLNode * | pNode | ) | [protected] |
Load the widget size from a XML file.
The size node must have the following format: <size width="0.2" height="0.1"/>
pNode | Pointer to the size node from the XML file |
bool syBR::Game::GUIWidget::loadColor | ( | Core::XMLNode * | pNode | ) | [protected] |
Load the widget position from a XML file.
The position node must have the following format: <color topLeft="1.0 0.0 0.0 1.0" bottomLeft="1.0 0.0 0.0 1.0" topRight="1.0 0.0 0.0 1.0" bottomRight="1.0 0.0 0.0 1.0"/> A color is described as "R G B A", each component being between 0 and 1.
Note that not all widget types will take the four colors in account.
pNode | Pointer to the position node from the XML file |
GUIManager* syBR::Game::GUIWidget::m_pManager [protected] |
Manager.
std::string syBR::Game::GUIWidget::m_name [protected] |
Name.
bool syBR::Game::GUIWidget::m_visible [protected] |
Visibility.
Ogre::Vector2 syBR::Game::GUIWidget::m_position [protected] |
Position.
float syBR::Game::GUIWidget::m_width [protected] |
Width.
float syBR::Game::GUIWidget::m_height [protected] |
Height.
std::string syBR::Game::GUIWidget::m_texture [protected] |
Texture.
Ogre::Vector2 syBR::Game::GUIWidget::m_textureCoordinates[4] [protected] |
Texture coordinates.
Ogre::ColourValue syBR::Game::GUIWidget::m_colour[4] [protected] |
Widget colour.
Copyright © 2008 by Sebastien Frippiat
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Last modified Tue Dec 30 17:57:33 2008