libsuit  0.1.1
SFML User Interface Toolkit
Public Member Functions | List of all members
ui::Button Class Reference

A button widget. More...

#include <ui/Button.h>

Inheritance diagram for ui::Button:
Inheritance graph
[legend]

Public Member Functions

 Button (std::string text)
 Construct a button widget with some text. More...
 
const std::string & getText ()
 Get the text of the button. More...
 
void setCallback (Callback callback)
 Set the function to call when the button is pressed. More...
 
virtual void onPrimaryAction () override
 Do something if a primary action has been triggered. More...
 
virtual void onClick (sf::Mouse::Button button, const sf::Vector2f &mouse) override
 Do something when the widget is clicked. More...
 
virtual void accept (WidgetVisitor &visitor) override
 Accept the visitor. More...
 
- Public Member Functions inherited from ui::Leaf
 Leaf ()
 Construct a leaf widget. More...
 
virtual void layoutRequest () override
 Compute the size hint of the widget. More...
 
virtual void layoutAllocation () override
 Compute the size of the widget. More...
 
bool isFocusable () const
 Tell whether the widget is focusable. More...
 
void setFocusable (bool focusable=true)
 Set the focusable state of the widget. More...
 
bool isFocused () const
 Tell whether the widget is focused. More...
 
void setFocused (bool focused=true)
 Set the focused state of the widget. More...
 
void setHorizontalPadding (float padding)
 Set the horizontal padding of the widget. More...
 
void setVerticalPadding (float padding)
 Set the vertical padding of the widget. More...
 
void setPadding (float padding)
 Set the padding of the widget. More...
 
float getHorizontalPadding () const
 Get the horizontal padding. More...
 
float getVerticalPadding () const
 Get the vertical padding. More...
 
sf::FloatRect getInternalGeometry () const
 Compute the internal geometry. More...
 
- Public Member Functions inherited from ui::Widget
 Widget ()
 Construct a widget. More...
 
 Widget (const Widget &)=delete
 
Widgetoperator= (const Widget &)=delete
 
 Widget (Widget &&)=delete
 
Widgetoperator= (Widget &&)=delete
 
virtual ~Widget ()
 Destroy a widget. More...
 
void setSizeHint (float width, float height)
 Set the size hint of the widget. More...
 
sf::Vector2f getSizeHint () const
 Get the size hint of the widget. More...
 
void setHorizontalPolicy (SizePolicy policy)
 Set the horizontal size policy. More...
 
void setVerticalPolicy (SizePolicy policy)
 Set the vertical size policy. More...
 
void setSizePolicy (SizePolicy horizontal, SizePolicy vertical)
 Set the size policy. More...
 
void setHorizontalAlignment (Alignment alignment)
 Set the horizontal alignment policy. More...
 
void setVerticalAlignment (Alignment alignment)
 Set the vertical alignment policy. More...
 
const GeometrygetHorizontalGeometry () const
 Get the horizontal geometry. More...
 
GeometrygetHorizontalGeometry ()
 Get the horizontal geometry. More...
 
const GeometrygetVerticalGeometry () const
 Get the vertical geometry. More...
 
GeometrygetVerticalGeometry ()
 Get the vertical geometry. More...
 
void setGeometry (const sf::FloatRect &geometry)
 Set the vertical geometry thanks to a rectangle. More...
 
const sf::FloatRect getGeometry () const
 Get the geometry of the widget. More...
 
sf::Vector2f getCenter () const
 Get the center of the widget. More...
 
virtual void onSecondaryAction ()
 Do something if a secondary action has been triggered. More...
 

Detailed Description

A button widget.

A button widget is a widget that can be pressed to trigger an action.

Constructor & Destructor Documentation

ui::Button::Button ( std::string  text)

Construct a button widget with some text.

Parameters
textthe text of the button.

Member Function Documentation

virtual void ui::Button::accept ( WidgetVisitor visitor)
overridevirtual

Accept the visitor.

Parameters
visitorthe visitor.

Implements ui::Widget.

const std::string& ui::Button::getText ( )
inline

Get the text of the button.

Returns
the text of the button.
virtual void ui::Button::onClick ( sf::Mouse::Button  button,
const sf::Vector2f &  mouse 
)
overridevirtual

Do something when the widget is clicked.

In the case of a button, the action is to call the callback if the right button is clicked.

Reimplemented from ui::Widget.

virtual void ui::Button::onPrimaryAction ( )
overridevirtual

Do something if a primary action has been triggered.

Reimplemented from ui::Widget.

void ui::Button::setCallback ( Callback  callback)
inline

Set the function to call when the button is pressed.

Parameters
callbackthe function to call.