|
TGUI 1.13
|
Signal to which the user can subscribe to get callbacks from. More...
#include <TGUI/Signal.hpp>
Public Member Functions | |
| virtual | ~Signal ()=default |
| Default destructor. | |
| Signal (String &&name, std::size_t extraParameters=0) | |
| Constructor. | |
| Signal (const Signal &other) | |
| Copy constructor which will not copy the signal handlers. | |
| Signal (Signal &&other) noexcept=default | |
| Default move constructor. | |
| Signal & | operator= (const Signal &other) |
| Copy assignment operator which will not copy the signal handlers. | |
| Signal & | operator= (Signal &&other) noexcept=default |
| Default move assignment operator. | |
| template<typename Func, typename... BoundArgs> | |
| unsigned int | operator() (const Func &func, const BoundArgs &... args) |
| Connects a signal handler that will be called when this signal is emitted. | |
| template<typename Func, typename... BoundArgs, typename std::enable_if_t< std::is_convertible_v< Func, std::function< void(const BoundArgs &...)> > > * = nullptr> | |
| unsigned int | connect (const Func &func, const BoundArgs &... args) |
| Connects a signal handler that will be called when this signal is emitted. | |
| template<typename Func, typename... BoundArgs, typename std::enable_if_t< std::is_convertible_v< Func, std::function< void(const BoundArgs &..., const std::shared_ptr< Widget > &, const String &)> >, * = nullptr> | |
| unsigned int | connectEx (const Func &func, const BoundArgs &... args) |
| Connects a signal handler that will be called when this signal is emitted. | |
| bool | disconnect (unsigned int id) |
| Disconnect a signal handler from this signal. | |
| void | disconnectAll () |
| Disconnect all signal handler from this signal. | |
| bool | emit (const Widget *widget) |
| Call all connected signal handlers. | |
| String | getName () const |
| Returns the name given to the signal. | |
| void | setEnabled (bool enabled) |
| Changes whether this signal calls the connected functions when triggered. | |
| bool | isEnabled () const |
| Returns whether this signal calls the connected functions when triggered. | |
Static Protected Member Functions | |
| static std::shared_ptr< Widget > | getWidget () |
| Extracts the widget stored in the first parameter. | |
| template<typename Type> | |
| static const std::decay_t< Type > & | dereferenceParam (std::size_t paramIndex) |
| Turns the void* parameters back into its original type right before calling the callback function. | |
Protected Attributes | |
| bool | m_enabled = true |
| String | m_name |
| std::unordered_map< unsigned int, std::function< void()> > | m_handlers |
Static Protected Attributes | |
| static unsigned int | m_lastSignalId |
| static std::deque< const void * > | m_parameters |
Signal to which the user can subscribe to get callbacks from.
|
inline |
Constructor.
| name | Name of the signal |
| extraParameters | Amount of extra parameters to reserve space for |
|
inline |
Connects a signal handler that will be called when this signal is emitted.
| func | Callback function |
| args | Additional arguments to pass to the function |
|
inline |
Connects a signal handler that will be called when this signal is emitted.
| func | Callback function that is given a pointer to the widget and the name of the signal as arguments |
| args | Additional arguments to pass to the function |
| bool tgui::Signal::disconnect | ( | unsigned int | id | ) |
Disconnect a signal handler from this signal.
| id | Unique id of the connection returned by the connect function |
| bool tgui::Signal::emit | ( | const Widget * | widget | ) |
Call all connected signal handlers.
| widget | The sender of the signal |
|
inlinenodiscard |
Returns the name given to the signal.
|
inlinenodiscard |
Returns whether this signal calls the connected functions when triggered.
Signals are enabled by default. Temporarily disabling the signal is the better alternative to disconnecting the handler and connecting it again a few lines later.
|
inline |
Connects a signal handler that will be called when this signal is emitted.
| func | Callback function that can be passed to the connect function |
| args | Additional arguments to pass to the function |
|
inline |
Changes whether this signal calls the connected functions when triggered.
| enabled | Is the signal enabled? |
Signals are enabled by default. Temporarily disabling the signal is the better alternative to disconnecting the handler and connecting it again a few lines later.