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

A choice sprite widget. More...

#include <gf/Widgets.h>

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

Public Member Functions

 ChoiceSpriteWidget (Sprite &empty, Sprite &chosen)
 Constructor. More...
 
void setChosen (bool chosen=true)
 Set the state of the widget. More...
 
bool isChosen () const noexcept
 Check if the widget is in the chosen state. More...
 
void setEmptySprite (Sprite &sprite)
 Set the sprite for the empty state. More...
 
void setChosenSprite (Sprite &sprite)
 Set the sprite for the chosen state. More...
 
- Public Member Functions inherited from gf::SpriteWidget
 SpriteWidget (Sprite &sprite)
 Constructor with a single sprite. More...
 
 SpriteWidget (Sprite &defaultSprite, Sprite &selectedSprite)
 Constructor with two sprites. More...
 
 SpriteWidget (Sprite &defaultSprite, Sprite &selectedSprite, Sprite &disabledSprite)
 Constructor with three sprites. More...
 
void setDisabledSprite (Sprite &sprite)
 Set the sprite for disabled state. More...
 
void setDefaultSprite (Sprite &sprite)
 Set the sprite for default state. More...
 
void setSelectedSprite (Sprite &sprite)
 Set the sprite for selected state. More...
 
virtual void render (RenderTarget &target, const RenderStates &states) override
 Render the widget on the target. More...
 
virtual bool contains (Vector2f coords) override
 Check if the widget contains the coordinates. More...
 
- Public Member Functions inherited from gf::Widget
 Widget ()
 Constructor. More...
 
virtual ~Widget ()
 Destructor. 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...
 

Protected Member Functions

virtual void triggered () override
 Function called when the callback is triggered. More...
 

Detailed Description

A choice sprite widget.

A choice widget may be used to represent a checkbox or a radio button.

Constructor & Destructor Documentation

◆ ChoiceSpriteWidget()

gf::ChoiceSpriteWidget::ChoiceSpriteWidget ( Sprite empty,
Sprite chosen 
)

Constructor.

Parameters
emptyThe sprite for representing the empty state
chosenThe sprite for representing the chosen state

Member Function Documentation

◆ isChosen()

bool gf::ChoiceSpriteWidget::isChosen ( ) const
inlinenoexcept

Check if the widget is in the chosen state.

See also
setChosen()

◆ setChosen()

void gf::ChoiceSpriteWidget::setChosen ( bool  chosen = true)

Set the state of the widget.

Parameters
chosenThe new state of the widget
See also
isChosen()

◆ setChosenSprite()

void gf::ChoiceSpriteWidget::setChosenSprite ( Sprite sprite)

Set the sprite for the chosen state.

Parameters
spriteThe sprite sued for the chosen state
See also
setEmptySprite()

◆ setEmptySprite()

void gf::ChoiceSpriteWidget::setEmptySprite ( Sprite sprite)

Set the sprite for the empty state.

Parameters
spriteThe sprite used for the empty state
See also
setChosenSprite()

◆ triggered()

virtual void gf::ChoiceSpriteWidget::triggered ( )
overrideprotectedvirtual

Function called when the callback is triggered.

This function is called before the callback.

Reimplemented from gf::Widget.