Gamedev Framework (gf)  0.9.0
A C++14 framework for 2D games
Public Member Functions | Protected Member Functions | List of all members
gf::Widget Class Referenceabstract

The widgets abstract class. More...

#include <gf/Widget.h>

Inheritance diagram for gf::Widget:
Inheritance graph
[legend]

Public Member Functions

 Widget ()
 Constructor. More...
 
virtual bool contains (Vector2f coords)=0
 Check if the widget contains the coordinates. More...
 
void setDisabled ()
 Disable the widget. More...
 
bool isDisabled () const noexcept
 Check if the widget is disabled. More...
 
void setDefault ()
 Set the widget to it's default state. More...
 
bool isDefault () const noexcept
 Check if the widget is in default state. More...
 
void setSelected ()
 Select the widget. More...
 
bool isSelected () const
 Check if the widget is selected. More...
 
void setState (WidgetState state)
 Set the state of the widget directly. More...
 
WidgetState getState () const noexcept
 Get the state of the widget. More...
 
void setCallback (std::function< void()> callback)
 Set the callback of the widget. More...
 
void triggerCallback ()
 Execute the callback function. More...
 
- Public Member Functions inherited from gf::Transformable
 Transformable ()
 Default constructor. More...
 
void setOrigin (Vector2f origin)
 Set the local origin of the object. More...
 
Vector2f getOrigin () const
 Get the local origin of the object. More...
 
void setPosition (Vector2f position)
 Set the position of the object. More...
 
Vector2f getPosition () const
 Get the position of the object. More...
 
void move (Vector2f offset)
 Move the object by a given offset. More...
 
void setRotation (float angle)
 Set the orientation of the object. More...
 
float getRotation () const
 Get the orientation of the object. More...
 
void rotate (float angle)
 Rotate the object. More...
 
void setScale (Vector2f factors)
 Set the scale factors of the object. More...
 
void setScale (float factor)
 Set the scale factor of the object. More...
 
Vector2f getScale () const
 Get the current scale of the object. More...
 
void scale (Vector2f factors)
 Scale the object. More...
 
void scale (float factor)
 Scale the object. More...
 
Matrix3f getTransform () const
 Get the combined transform of the object. More...
 
Matrix3f getInverseTransform () const
 Get the inverse of the combined transform of the object. More...
 
- Public Member Functions inherited from gf::Drawable
virtual ~Drawable ()
 Virtual desctructor. More...
 
virtual void draw (RenderTarget &target, RenderStates states)=0
 Draw the object to a render target. More...
 

Protected Member Functions

virtual void onStateChanged ()
 Function called when the state changes. More...
 
virtual void triggered ()
 Function called when the callback is triggered. More...
 
- Protected Member Functions inherited from gf::Transformable
void setOriginFromAnchorAndBounds (Anchor anchor, const RectF &bounds)
 Set the origin from an anchor and bounds. More...
 

Detailed Description

The widgets abstract class.

Constructor & Destructor Documentation

◆ Widget()

gf::Widget::Widget ( )

Constructor.

The widget is in the default state.

Member Function Documentation

◆ contains()

virtual bool gf::Widget::contains ( Vector2f  coords)
pure virtual

Check if the widget contains the coordinates.

Parameters
coordsThe coordinates to check
Returns
True if the coordinates are inside the widget

Implemented in gf::ChoiceSpriteWidget, gf::SpriteWidget, gf::TextButtonWidget, and gf::TextWidget.

◆ getState()

WidgetState gf::Widget::getState ( ) const
inlinenoexcept

Get the state of the widget.

Returns
The current state of the widget

◆ isDefault()

bool gf::Widget::isDefault ( ) const
inlinenoexcept

Check if the widget is in default state.

Returns
True if the widget is in default state

◆ isDisabled()

bool gf::Widget::isDisabled ( ) const
inlinenoexcept

Check if the widget is disabled.

Returns
True if the widget is disabled

◆ isSelected()

bool gf::Widget::isSelected ( ) const
inline

Check if the widget is selected.

Returns
True if the widget is selected

◆ onStateChanged()

virtual void gf::Widget::onStateChanged ( )
protectedvirtual

Function called when the state changes.

Reimplemented in gf::TextButtonWidget, and gf::TextWidget.

◆ setCallback()

void gf::Widget::setCallback ( std::function< void()>  callback)

Set the callback of the widget.

Parameters
callbackThe function that will be execute when the widget will be triggered.
See also
triggerCallback()

◆ setDefault()

void gf::Widget::setDefault ( )

Set the widget to it's default state.

◆ setDisabled()

void gf::Widget::setDisabled ( )

Disable the widget.

◆ setSelected()

void gf::Widget::setSelected ( )

Select the widget.

◆ setState()

void gf::Widget::setState ( WidgetState  state)

Set the state of the widget directly.

Parameters
stateThe new state
See also
setDisabled(), setDefault(), setSelected()

◆ triggerCallback()

void gf::Widget::triggerCallback ( )

Execute the callback function.

See also
setCallback()

◆ triggered()

virtual void gf::Widget::triggered ( )
protectedvirtual

Function called when the callback is triggered.

This function is called before the callback.

Reimplemented in gf::ChoiceSpriteWidget.