TGUI  0.8-dev
tgui::SignalWidgetBase Class Referenceabstract

Base class for Widget which provides functionality to connect signals based on their name. More...

#include <Signal.hpp>

Inheritance diagram for tgui::SignalWidgetBase:
tgui::Widget tgui::ChatBox tgui::ClickableWidget tgui::ComboBox tgui::Container tgui::Knob tgui::ListBox tgui::MenuBar tgui::RangeSlider tgui::Scrollbar tgui::Slider tgui::Tabs tgui::TextBox

Public Member Functions

template<typename Func , typename... Args, typename std::enable_if< std::is_convertible< Func, std::function< void(const Args &...)>>::value >::type * = nullptr>
unsigned int connect (std::string signalName, Func &&handler, const Args &... args)
 Connects a signal handler that will be called when this signal is emitted. More...
 
template<typename Func , typename... BoundArgs, typename std::enable_if< std::is_convertible< Func, std::function< void(const BoundArgs &..., std::shared_ptr< Widget >, const std::string &)>>::value >::type * = nullptr>
unsigned int connect (std::string signalName, Func &&handler, BoundArgs &&... args)
 Connects a signal handler that will be called when this signal is emitted. More...
 
template<typename Func , typename... BoundArgs, typename std::enable_if<!std::is_convertible< Func, std::function< void(const BoundArgs &...)>>::value &&!std::is_convertible< Func, std::function< void(const BoundArgs &..., std::shared_ptr< Widget >, const std::string &)>>::value >::type * = nullptr>
unsigned int connect (std::string signalName, Func &&handler, BoundArgs &&... args)
 Connects a signal handler that will be called when this signal is emitted. More...
 
template<typename Func , typename... BoundArgs>
unsigned int connect (std::initializer_list< std::string > signalNames, Func &&handler, BoundArgs &&... args)
 Connect a signal handler to multiple signals. More...
 
bool disconnect (unsigned int id)
 Disconnects a signal handler. More...
 
void disconnectAll (std::string signalName)
 Disconnects all signal handler from a certain signal. More...
 
void disconnectAll ()
 Disconnects all signal handlers from signals.
 

Protected Member Functions

virtual SignalgetSignal (std::string signalName)=0
 Retrieves a signal based on its name.
 

Detailed Description

Base class for Widget which provides functionality to connect signals based on their name.

Member Function Documentation

◆ connect() [1/4]

template<typename Func , typename... Args, typename std::enable_if< std::is_convertible< Func, std::function< void(const Args &...)>>::value >::type * = nullptr>
unsigned int tgui::SignalWidgetBase::connect ( std::string  signalName,
Func &&  handler,
const Args &...  args 
)
inline

Connects a signal handler that will be called when this signal is emitted.

Parameters
signalNameName of the signal
handlerCallback function that is given the extra arguments provided to this function as arguments
argsOptional extra arguments to pass to the signal handler when the signal is emitted
Returns
Unique id of the connection

◆ connect() [2/4]

template<typename Func , typename... BoundArgs, typename std::enable_if< std::is_convertible< Func, std::function< void(const BoundArgs &..., std::shared_ptr< Widget >, const std::string &)>>::value >::type * = nullptr>
unsigned int tgui::SignalWidgetBase::connect ( std::string  signalName,
Func &&  handler,
BoundArgs &&...  args 
)
inline

Connects a signal handler that will be called when this signal is emitted.

Parameters
signalNameName of the signal
handlerCallback function that is given a pointer to the widget, the name of the signal and the extra arguments provided to this function as arguments
argsOptional extra arguments to pass to the signal handler when the signal is emitted
Returns
Unique id of the connection

◆ connect() [3/4]

template<typename Func , typename... BoundArgs, typename std::enable_if<!std::is_convertible< Func, std::function< void(const BoundArgs &...)>>::value &&!std::is_convertible< Func, std::function< void(const BoundArgs &..., std::shared_ptr< Widget >, const std::string &)>>::value >::type * = nullptr>
unsigned int tgui::SignalWidgetBase::connect ( std::string  signalName,
Func &&  handler,
BoundArgs &&...  args 
)
inline

Connects a signal handler that will be called when this signal is emitted.

Parameters
signalNameName of the signal
handlerCallback function
argsOptional extra arguments to pass to the signal handler when the signal is emitted
Returns
Unique id of the connection

◆ connect() [4/4]

template<typename Func , typename... BoundArgs>
unsigned int tgui::SignalWidgetBase::connect ( std::initializer_list< std::string >  signalNames,
Func &&  handler,
BoundArgs &&...  args 
)
inline

Connect a signal handler to multiple signals.

Parameters
signalNamesList of signal names that will trigger the signal handler
handlerCallback function
argsOptional extra arguments to pass to the signal handler when the signal is emitted
Returns
Unique id of the last connection. When passing e.g. 2 signal names, the first signal will correspond to id-1.

◆ disconnect()

bool tgui::SignalWidgetBase::disconnect ( unsigned int  id)

Disconnects a signal handler.

Parameters
idId of the connection
Returns
True when a connection with this id existed and was removed

◆ disconnectAll()

void tgui::SignalWidgetBase::disconnectAll ( std::string  signalName)

Disconnects all signal handler from a certain signal.

Parameters
signalNameName of the signal

The documentation for this class was generated from the following file: