![]() |
V-Gears 0
Free Final Fantasy VII engine.
|
An UI widget. More...
#include <UiWidget.h>
Public Types | |
enum | Align { LEFT , RIGHT , CENTER } |
Horizontal alignment of the widget. More... | |
enum | VerticalAlign { TOP , BOTTOM , MIDDLE } |
Vertical alignment of the widget. More... | |
Public Member Functions | |
UiWidget (const Ogre::String &name) | |
Constructor. More... | |
UiWidget (const Ogre::String &name, const Ogre::String &path_name, UiWidget *parent) | |
Constructor. More... | |
virtual | ~UiWidget () |
Destructor. More... | |
void | Initialise () |
Initializes the widget. More... | |
virtual void | Update () |
Updates the widget status. More... | |
void | OnResize () |
Handles resizing events. More... | |
virtual void | Render () |
Renders the widget and it's children. More... | |
void | SetVisible (const bool visible) |
Toggles the widget visibility. More... | |
bool | IsVisible () const |
Checks the widget visibility. More... | |
const Ogre::String & | GetName () const |
Retrieves the widget name. More... | |
void | AddChild (UiWidget *widget) |
Add other widget as the widget's child. More... | |
UiWidget * | GetChild (const Ogre::String &name) |
Retrieves a children by name. More... | |
UiWidget * | GetChild (const unsigned int id) |
Retrieves a children by ID. More... | |
unsigned int | GetNumberOfChildren () |
Counts the widget's children. More... | |
void | RemoveAllChildren () |
Removes all children widgets. More... | |
void | AddAnimation (UiAnimation *animation) |
Adds an animation to the widget. More... | |
const Ogre::String & | GetCurrentAnimationName () const |
Retrieves the current animation name. More... | |
UiAnimation::State | GetAnimationState () const |
Retrieves the current animation state. More... | |
void | PlayAnimation (const Ogre::String &animation, UiAnimation::State state, const float start, const float end) |
Plays an animation. More... | |
void | ScriptPlayAnimation (const char *name) |
Plays an animation. More... | |
void | ScriptPlayAnimationStop (const char *name) |
Plays an animation. More... | |
void | ScriptPlayAnimation (const char *name, const float start, const float end) |
void | ScriptPlayAnimationStop (const char *name, const float start, const float end) |
Plays an animation. More... | |
void | ScriptSetDefaultAnimation (const char *animation) |
Sets the default animation for the widget. More... | |
int | ScriptAnimationSync () |
Synchronizes an animation. More... | |
void | SetUpdateTransformation () |
Marks the widget as transformed. More... | |
virtual void | UpdateTransformation () |
Recalculates the widget geometry. More... | |
void | SetAlign (const UiWidget::Align align) |
Sets the widget horizontal alignment. More... | |
void | SetVerticalAlign (const UiWidget::VerticalAlign valign) |
Sets the widget vertical alignment. More... | |
float | GetFinalZ () const |
Retrieves the final Z-index of the widget after a transformation. More... | |
Ogre::Vector2 | GetFinalOrigin () const |
Retrieves the coordinates of the widget after a transformation. More... | |
Ogre::Vector2 | GetFinalTranslate () const |
Retrieves the final translation of the widget after a transformation. More... | |
Ogre::Vector2 | GetFinalSize () const |
Retrieves the final size of the widget after a transformation. More... | |
Ogre::Vector2 | GetFinalScale () const |
Retrieves the final scale of the widget after a transformation. More... | |
Ogre::Vector4 | GetFinalScissor (bool &scissor) const |
Retrieves the final scissor of the widget after a transformation. More... | |
float | GetFinalRotation () const |
Retrieves the final rotation of the widget. More... | |
void | SetOriginX (const float percent, const float x) |
Sets the X coordinate origin for the widget. More... | |
void | SetOriginY (const float percent, const float y) |
Sets the Y coordinate origin for the widget. More... | |
void | SetX (const float percent, const float x) |
Sets the X coordinate for the widget. More... | |
void | GetX (float &percent, float &x) |
Retrieves the X coordinate for the widget. More... | |
void | SetY (const float percent, const float y) |
Sets the Y coordinate for the widget. More... | |
void | GetY (float &percent, float &y) |
Retrieves the Y coordinate for the widget. More... | |
void | SetZ (const float z) |
Sets the widget Z-index. More... | |
void | SetWidth (const float percent, const float width) |
Sets the width the widget. More... | |
void | GetWidth (float &percent, float &width) |
Retrieves the width of the widget. More... | |
void | SetHeight (const float percent, const float height) |
Sets the height the widget. More... | |
void | GetHeight (float &percent, float &height) |
Retrieves the height of the widget. More... | |
void | SetScale (const Ogre::Vector2 &scale) |
Sets the widget scale. More... | |
void | SetRotation (const float degree) |
Sets the widget rotation. More... | |
void | SetScissorArea (const float percent_x1, const float x1, const float percent_y1, const float y1, const float percent_x2, const float x2, const float percent_y2, const float y2) |
Sets the widget scissor area. More... | |
void | SetGlobalScissor (const bool global) |
void | SetColour (const float r, const float g, const float b) |
Sets the widget colour. More... | |
void | SetColours (const float r1, const float g1, const float b1, const float r2, const float g2, const float b2, const float r3, const float g3, const float b3, const float r4, const float g4, const float b4) |
Sets the widget colour. More... | |
void | SetAlpha (const float a) |
Sets the widget transparency. More... | |
virtual void | SetText (const char *text) |
Sets the text of the widget. More... | |
virtual void | SetImage (const char *image) |
Sets the text of the widget. More... | |
float | ScriptGetWidth () |
Retrieves the absolute width of the widget. More... | |
void | ScriptSetWidth (float width) |
Sets the absolute width of the widget. More... | |
float | ScriptGetHeight () |
Retrieves the absolute height of the widget. More... | |
void | ScriptSetHeight (float height) |
Sets the absolute height of the widget. More... | |
Protected Attributes | |
Ogre::String | name_ |
The widget name. More... | |
Ogre::String | path_name_ |
UiWidget * | parent_ |
The parent widget. More... | |
std::vector< UiWidget * > | children_ |
The list of children widgets. More... | |
float | screen_width_ |
Width, in game screen units. More... | |
float | screen_height_ |
Height, in game screen units. More... | |
bool | visible_ |
Indicates if the widget is visible. More... | |
Ogre::ColourValue | colour_1_ |
Top-left corner colour. More... | |
Ogre::ColourValue | colour_2_ |
Top-right corner colour. More... | |
Ogre::ColourValue | colour_3_ |
Bottom-right corner colour. More... | |
Ogre::ColourValue | colour_4_ |
Bottom-left corner colour. More... | |
Align | align_ |
The vertical alignment. More... | |
VerticalAlign | vertical_align_ |
The evrtical alignment. More... | |
bool | update_transformation_ |
Indicates if the widget is marked as transformed. More... | |
Ogre::Vector2 | final_origin_ |
Final origin point after a transformation. More... | |
Ogre::Vector2 | final_translate_ |
Final translation after a transformation. More... | |
float | final_z_ |
Final Z-index after a transformation. More... | |
Ogre::Vector2 | final_size_ |
Final size after a transformation. More... | |
Ogre::Vector2 | final_scale_ |
Final scale after a transformation. More... | |
float | final_rotation_ |
Final rotation after a transformation. More... | |
float | origin_x_percent_ |
float | origin_x_ |
The origin X coordinate. More... | |
float | origin_y_percent_ |
float | origin_y_ |
The origin Y coordinate. More... | |
float | x_percent_ |
float | x_ |
The widget X coordinate. More... | |
float | y_percent_ |
float | y_ |
The widget Y coordinate. More... | |
float | z_ |
The widget Z coordinate. More... | |
float | width_percent_ |
float | width_ |
The widget width. More... | |
float | height_percent_ |
float | height_ |
The widget height. More... | |
Ogre::Vector2 | scale_ |
The widget scale. More... | |
float | rotation_ |
The widget rotation. More... | |
bool | scissor_ |
bool | local_scissor_ |
bool | global_scissor_ |
int | scissor_top_ |
float | scissor_x_percent_top_ |
float | scissor_x_top_ |
int | scissor_bottom_ |
float | scissor_x_percent_bottom_ |
float | scissor_x_bottom_ |
int | scissor_left_ |
float | scissor_y_percent_left_ |
float | scissor_y_left_ |
int | scissor_right_ |
float | scissor_y_percent_right_ |
float | scissor_y_right_ |
UiAnimation * | animation_current_ |
The current animation. More... | |
std::vector< ScriptId > | animation_sync_ |
The animation stack. More... | |
UiAnimation::State | animation_state_ |
The current animation state. More... | |
Ogre::String | animation_default_ |
The name of the default animation. More... | |
float | animation_end_time_ |
Time for the current animation to end. More... | |
std::vector< UiAnimation * > | animations_ |
The list of animations. More... | |
Private Member Functions | |
UiWidget () | |
Constructor. More... | |
An UI widget.
enum UiWidget::Align |
UiWidget::UiWidget | ( | const Ogre::String & | name | ) |
Constructor.
[in] | name | Name for the widget. |
UiWidget::UiWidget | ( | const Ogre::String & | name, |
const Ogre::String & | path_name, | ||
UiWidget * | parent | ||
) |
Constructor.
[in] | name | Name for the widget. |
[in] | path_name |
[in] | parent | Widget to be made parent of the new one. |
|
virtual |
Destructor.
|
private |
Constructor.
void UiWidget::AddAnimation | ( | UiAnimation * | animation | ) |
Adds an animation to the widget.
[in] | animation | The animation to add. |
void UiWidget::AddChild | ( | UiWidget * | widget | ) |
Add other widget as the widget's child.
[in] | widget | Widget to be made children of this one. |
UiAnimation::State UiWidget::GetAnimationState | ( | ) | const |
Retrieves the current animation state.
UiWidget * UiWidget::GetChild | ( | const Ogre::String & | name | ) |
Retrieves a children by name.
[in] | name | Name of the children widget to retrieve. |
UiWidget * UiWidget::GetChild | ( | const unsigned int | id | ) |
Retrieves a children by ID.
[in] | id | ID of the children widget to retrieve. |
const Ogre::String & UiWidget::GetCurrentAnimationName | ( | ) | const |
Retrieves the current animation name.
Ogre::Vector2 UiWidget::GetFinalOrigin | ( | ) | const |
Retrieves the coordinates of the widget after a transformation.
float UiWidget::GetFinalRotation | ( | ) | const |
Retrieves the final rotation of the widget.
Ogre::Vector2 UiWidget::GetFinalScale | ( | ) | const |
Retrieves the final scale of the widget after a transformation.
Ogre::Vector4 UiWidget::GetFinalScissor | ( | bool & | scissor | ) | const |
Retrieves the final scissor of the widget after a transformation.
Ogre::Vector2 UiWidget::GetFinalSize | ( | ) | const |
Retrieves the final size of the widget after a transformation.
Ogre::Vector2 UiWidget::GetFinalTranslate | ( | ) | const |
Retrieves the final translation of the widget after a transformation.
float UiWidget::GetFinalZ | ( | ) | const |
Retrieves the final Z-index of the widget after a transformation.
void UiWidget::GetHeight | ( | float & | percent, |
float & | height | ||
) |
Retrieves the height of the widget.
[out] | percent |
[out] | height | The height will be loaded here. |
const Ogre::String & UiWidget::GetName | ( | ) | const |
Retrieves the widget name.
unsigned int UiWidget::GetNumberOfChildren | ( | ) |
Counts the widget's children.
void UiWidget::GetWidth | ( | float & | percent, |
float & | width | ||
) |
Retrieves the width of the widget.
[out] | percent |
[out] | width | The width will be loaded here. |
void UiWidget::GetX | ( | float & | percent, |
float & | x | ||
) |
Retrieves the X coordinate for the widget.
[out] | percent |
[out] | x | The X coordinate will be loaded here. |
void UiWidget::GetY | ( | float & | percent, |
float & | y | ||
) |
Retrieves the Y coordinate for the widget.
[out] | percent |
[out] | y | The Y coordinate will be loaded here. |
void UiWidget::Initialise | ( | ) |
Initializes the widget.
It sets the widget geometry.
bool UiWidget::IsVisible | ( | ) | const |
Checks the widget visibility.
void UiWidget::OnResize | ( | ) |
Handles resizing events.
Recalculates the widget geometry and calls OnResize for all the widget children.
void UiWidget::PlayAnimation | ( | const Ogre::String & | animation, |
UiAnimation::State | state, | ||
const float | start, | ||
const float | end | ||
) |
Plays an animation.
[in] | animation | Animation to play. |
[in] | state | Initial animation state. |
[in] | start | Seconds at which to start the animation. |
[in] | end | Seconds at which to end the animation. -1 to play it in full. |
void UiWidget::RemoveAllChildren | ( | ) |
Removes all children widgets.
|
virtual |
Renders the widget and it's children.
Reimplemented in UiSprite, and UiTextArea.
int UiWidget::ScriptAnimationSync | ( | ) |
float UiWidget::ScriptGetHeight | ( | ) |
Retrieves the absolute height of the widget.
Doesn't consider percentages.
float UiWidget::ScriptGetWidth | ( | ) |
Retrieves the absolute width of the widget.
Doesn't consider percentages.
void UiWidget::ScriptPlayAnimation | ( | const char * | name | ) |
Plays an animation.
The animation will be played from the start for it's full length.
[in] | name | The name of the animation to play. |
void UiWidget::ScriptPlayAnimation | ( | const char * | name, |
const float | start, | ||
const float | end | ||
) |
[in] | name | Name of the animation to play. |
[in] | start | Seconds at which to start the animation. |
[in] | end | Seconds at which to end the animation. -1 to play it in full. |
void UiWidget::ScriptPlayAnimationStop | ( | const char * | name | ) |
Plays an animation.
The animation will be played from the start for it's full length, only once.
[in] | name | The name of the animation to play. |
void UiWidget::ScriptPlayAnimationStop | ( | const char * | name, |
const float | start, | ||
const float | end | ||
) |
Plays an animation.
The animation will be played only once.
[in] | name | The name of the animation to play. |
[in] | start | Seconds at which to start the animation. |
[in] | end | Seconds at which to end the animation. -1 to play it in full. |
void UiWidget::ScriptSetDefaultAnimation | ( | const char * | animation | ) |
Sets the default animation for the widget.
[in] | animation | The name of the default animation. |
void UiWidget::ScriptSetHeight | ( | float | height | ) |
Sets the absolute height of the widget.
Doesn't modify percentages.
[in] | height | Absolute height. |
void UiWidget::ScriptSetWidth | ( | float | width | ) |
Sets the absolute width of the widget.
Doesn't modify percentages.
[in] | width | Absolute width. |
void UiWidget::SetAlign | ( | const UiWidget::Align | align | ) |
Sets the widget horizontal alignment.
[in] | align | Widget alignment. |
void UiWidget::SetAlpha | ( | const float | a | ) |
Sets the widget transparency.
[in] | a | Alpha value (0 opaque, 255 fully transparent). |
void UiWidget::SetColour | ( | const float | r, |
const float | g, | ||
const float | b | ||
) |
Sets the widget colour.
[in] | r | Colour red component (0-255). |
[in] | g | Colour green component (0-255). |
[in] | b | Colour blue component (0-255). |
void UiWidget::SetColours | ( | const float | r1, |
const float | g1, | ||
const float | b1, | ||
const float | r2, | ||
const float | g2, | ||
const float | b2, | ||
const float | r3, | ||
const float | g3, | ||
const float | b3, | ||
const float | r4, | ||
const float | g4, | ||
const float | b4 | ||
) |
Sets the widget colour.
It set the same colours for each corner, and blends it in the interior.
[in] | r1 | Colour red component for the top-left corner (0-255). |
[in] | g1 | Colour green component for the top-left corner (0-255). |
[in] | b1 | Colour blue component for the top-left corner (0-255). |
[in] | r2 | Colour red component for the top-right corner (0-255). |
[in] | g2 | Colour green component for the top-right corner (0-255). |
[in] | b2 | Colour blue component for the top-right corner (0-255). |
[in] | r3 | Colour red component for the bottom-right corner (0-255). |
[in] | g3 | Colour green component for the bottom-right corner (0-255). |
[in] | b3 | Colour blue component for the bottom-right corner (0-255). |
[in] | r4 | Colour red component for the bottom-left corner (0-255). |
[in] | g4 | Colour green component for the bottom-left corner (0-255). |
[in] | b4 | Colour blue component for the bottom-left corner (0-255). |
void UiWidget::SetGlobalScissor | ( | const bool | global | ) |
void UiWidget::SetHeight | ( | const float | percent, |
const float | height | ||
) |
|
virtual |
Sets the text of the widget.
If the widget doesn't have an image, it won't do anything.
[in] | image | Path to the image. |
Reimplemented in UiSprite.
void UiWidget::SetOriginX | ( | const float | percent, |
const float | x | ||
) |
Sets the X coordinate origin for the widget.
[in] | percent |
[in] | x | Origin X coordinate. |
void UiWidget::SetOriginY | ( | const float | percent, |
const float | y | ||
) |
Sets the Y coordinate origin for the widget.
[in] | percent |
[in] | y | Origin Y coordinate. |
void UiWidget::SetRotation | ( | const float | degree | ) |
Sets the widget rotation.
[in] | degree | The new widget rotation. |
void UiWidget::SetScale | ( | const Ogre::Vector2 & | scale | ) |
Sets the widget scale.
[in] | scale | The new widget scale. |
void UiWidget::SetScissorArea | ( | const float | percent_x1, |
const float | x1, | ||
const float | percent_y1, | ||
const float | y1, | ||
const float | percent_x2, | ||
const float | x2, | ||
const float | percent_y2, | ||
const float | y2 | ||
) |
Sets the widget scissor area.
[in] | percent_x1 |
[in] | x1 |
[in] | percent_y1 |
[in] | y1 |
[in] | percent_x2 |
[in] | x2 |
[in] | percent_y2 |
[in] | y2 |
|
virtual |
Sets the text of the widget.
If the widget doesn't have text, it won't do anything.
[in] | text | The text to set. |
Reimplemented in UiTextArea.
void UiWidget::SetUpdateTransformation | ( | ) |
Marks the widget as transformed.
It means that it's geometry must be updated in the next pass. It also marks the direct children as transformed.
void UiWidget::SetVerticalAlign | ( | const UiWidget::VerticalAlign | valign | ) |
Sets the widget vertical alignment.
[in] | valign | Widget alignment. |
void UiWidget::SetVisible | ( | const bool | visible | ) |
Toggles the widget visibility.
[in] | visible | True to make the widget visible, false to make it invisible. |
void UiWidget::SetWidth | ( | const float | percent, |
const float | width | ||
) |
void UiWidget::SetX | ( | const float | percent, |
const float | x | ||
) |
Sets the X coordinate for the widget.
[in] | percent |
[in] | x | The X coordinate. |
void UiWidget::SetY | ( | const float | percent, |
const float | y | ||
) |
Sets the Y coordinate for the widget.
[in] | percent |
[in] | y | The Y coordinate. |
void UiWidget::SetZ | ( | const float | z | ) |
Sets the widget Z-index.
[in] | z | The Z-index. |
|
virtual |
Updates the widget status.
Reimplemented in UiSprite, and UiTextArea.
|
virtual |
Recalculates the widget geometry.
Reimplemented in UiSprite, and UiTextArea.
|
protected |
The vertical alignment.
|
protected |
The current animation.
|
protected |
The name of the default animation.
|
protected |
Time for the current animation to end.
|
protected |
The current animation state.
|
protected |
The animation stack.
|
protected |
The list of animations.
|
protected |
The list of children widgets.
|
protected |
Top-left corner colour.
|
protected |
Top-right corner colour.
|
protected |
Bottom-right corner colour.
|
protected |
Bottom-left corner colour.
|
protected |
Final origin point after a transformation.
|
protected |
Final rotation after a transformation.
|
protected |
Final scale after a transformation.
|
protected |
Final size after a transformation.
|
protected |
Final translation after a transformation.
|
protected |
Final Z-index after a transformation.
|
protected |
|
protected |
The widget height.
|
protected |
|
protected |
|
protected |
The widget name.
|
protected |
The origin X coordinate.
|
protected |
|
protected |
The origin Y coordinate.
|
protected |
|
protected |
The parent widget.
|
protected |
|
protected |
The widget rotation.
|
protected |
The widget scale.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Height, in game screen units.
|
protected |
Width, in game screen units.
|
protected |
Indicates if the widget is marked as transformed.
|
protected |
The evrtical alignment.
|
protected |
Indicates if the widget is visible.
|
protected |
The widget width.
|
protected |
|
protected |
The widget X coordinate.
|
protected |
|
protected |
The widget Y coordinate.
|
protected |
|
protected |
The widget Z coordinate.