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

A text within a rounded rectangle widget. More...

#include <gf/Widgets.h>

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

Public Member Functions

 TextButtonWidget (std::string text, Font &font, unsigned characterSize=30)
 Construct a text button widget. More...
 
virtual void draw (RenderTarget &target, const RenderStates &states) override
 Draw the object to a render target. More...
 
virtual bool contains (Vector2f coords) override
 Check if the widget contains the coordinates. More...
 
void setBackgroundOutlineThickness (float thickness)
 Set the thickness of the outline. More...
 
void setDisabledBackgroundColor (const Color4f &color)
 Set the background's color of the button when disabled. More...
 
void setDisabledBackgroundOutlineColor (const Color4f &color)
 Set the outline's color of the button when disabled. More...
 
void setDefaultBackgroundColor (const Color4f &color)
 Set the background's color of the button when it's in a normal state. More...
 
void setDefaultBackgroundOutlineColor (const Color4f &color)
 Set the outline's color of the button when it's in a normal state. More...
 
void setSelectedBackgroundColor (const Color4f &color)
 Set the background's color of the button when selected. More...
 
void setSelectedBackgroundOutlineColor (const Color4f &color)
 Set the outline's color of the button when selected. More...
 
void setRadius (float radius)
 Set the radius of the corners. More...
 
void setPadding (float padding)
 Set the padding around the text. More...
 
- Public Member Functions inherited from gf::TextWidget
 TextWidget (std::string text, Font &font, unsigned characterSize=30)
 Constructor. More...
 
void setTextOutlineThickness (float thickness)
 Set the thickness of the outline. More...
 
void setDisabledTextColor (const Color4f &color)
 Set the text's color of the button when disabled. More...
 
void setDisabledTextOutlineColor (const Color4f &color)
 Set the outline's color of the button when disabled. More...
 
void setDefaultTextColor (const Color4f &color)
 Set the text's color of the button when it's in a normal state. More...
 
void setDefaultTextOutlineColor (const Color4f &color)
 Set the outline's color of the button when it's in a normal state. More...
 
void setSelectedTextColor (const Color4f &color)
 Set the text's color of the button when selected. More...
 
void setSelectedTextOutlineColor (const Color4f &color)
 Set the outline's color of the button when selected. More...
 
RectF getLocalBounds () const
 Get the local bounding rectangle of the entity. More...
 
void setAnchor (Anchor anchor)
 Set the anchor origin of the entity. More...
 
- Public Member Functions inherited from gf::Widget
 Widget ()
 Constructor. 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...
 

Protected Member Functions

void updateGeometry ()
 
virtual void onStateChanged () override
 Function called when the state changes. More...
 
- Protected Member Functions inherited from gf::TextWidget
void updateCurrentStateColors ()
 
void updateColors (Color4f textColor, Color4f outlineColor)
 
void updateGeometry ()
 
BasicTextgetText ()
 
- Protected Member Functions inherited from gf::Widget
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

A text within a rounded rectangle widget.

See also
gf::Text, gf::RoundedRectangleShape

Constructor & Destructor Documentation

◆ TextButtonWidget()

gf::TextButtonWidget::TextButtonWidget ( std::string  text,
Font font,
unsigned  characterSize = 30 
)

Construct a text button widget.

Parameters
textThe text to bind to the text button.
fontFont used to draw the text
characterSizeBase size of characters, in pixels

Member Function Documentation

◆ contains()

virtual bool gf::TextButtonWidget::contains ( Vector2f  coords)
overridevirtual

Check if the widget contains the coordinates.

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

Reimplemented from gf::TextWidget.

◆ draw()

virtual void gf::TextButtonWidget::draw ( RenderTarget target,
const RenderStates states 
)
overridevirtual

Draw the object to a render target.

This is a pure virtual function that has to be implemented by the derived class to define how the drawable should be drawn.

Parameters
targetRender target to draw to
statesCurrent render states

Reimplemented from gf::TextWidget.

◆ onStateChanged()

virtual void gf::TextButtonWidget::onStateChanged ( )
overrideprotectedvirtual

Function called when the state changes.

Reimplemented from gf::TextWidget.

◆ setBackgroundOutlineThickness()

void gf::TextButtonWidget::setBackgroundOutlineThickness ( float  thickness)

Set the thickness of the outline.

Parameters
thicknessThe new value of the outline thickness.

◆ setDefaultBackgroundColor()

void gf::TextButtonWidget::setDefaultBackgroundColor ( const Color4f color)

Set the background's color of the button when it's in a normal state.

Parameters
colorThe new color to apply

◆ setDefaultBackgroundOutlineColor()

void gf::TextButtonWidget::setDefaultBackgroundOutlineColor ( const Color4f color)

Set the outline's color of the button when it's in a normal state.

Parameters
colorThe new color to apply

◆ setDisabledBackgroundColor()

void gf::TextButtonWidget::setDisabledBackgroundColor ( const Color4f color)

Set the background's color of the button when disabled.

Parameters
colorThe new color to apply

◆ setDisabledBackgroundOutlineColor()

void gf::TextButtonWidget::setDisabledBackgroundOutlineColor ( const Color4f color)

Set the outline's color of the button when disabled.

Parameters
colorThe new color to apply

◆ setPadding()

void gf::TextButtonWidget::setPadding ( float  padding)
inline

Set the padding around the text.

Parameters
paddingThe new padding

◆ setRadius()

void gf::TextButtonWidget::setRadius ( float  radius)
inline

Set the radius of the corners.

Parameters
radiusThe new radius

◆ setSelectedBackgroundColor()

void gf::TextButtonWidget::setSelectedBackgroundColor ( const Color4f color)

Set the background's color of the button when selected.

Parameters
colorThe new color to apply

◆ setSelectedBackgroundOutlineColor()

void gf::TextButtonWidget::setSelectedBackgroundOutlineColor ( const Color4f color)

Set the outline's color of the button when selected.

Parameters
colorThe new color to apply

◆ updateGeometry()

void gf::TextButtonWidget::updateGeometry ( )
protected