TGUI  1.1
Loading...
Searching...
No Matches

Classes

struct  ConnectedSignalTuple
 
struct  SignalTuple
 

Public Types

using Ptr = std::shared_ptr< SignalManager >
 Shared widget pointer.
 
using ConstPtr = std::shared_ptr< const SignalManager >
 Shared constant widget pointer.
 
using Delegate = std::function< void()>
 
using DelegateEx = std::function< void(std::shared_ptr< Widget >, const String &)>
 
using Weak = std::weak_ptr< Widget >
 
using SignalID = unsigned int
 

Public Member Functions

 SignalManager ()=default
 Default constructor.
 
virtual ~SignalManager ()=default
 Destructor.
 
template<typename Func , typename... Args, typename std::enable_if_t< std::is_convertible< Func, std::function< void(const Args &...)> >::value > * = nullptr>
unsigned int connect (String widgetName, String signalName, Func &&handler, const Args &... 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< Func, std::function< void(const BoundArgs &...)> >::value &&std::is_convertible< Func, std::function< void(const BoundArgs &..., std::shared_ptr< Widget >, const String &)> >::value , * = nullptr>
unsigned int connect (String widgetName, String signalName, Func &&handler, BoundArgs &&... args)
 Connects a signal handler that will be called when this signal is emitted.
 
virtual bool disconnect (unsigned int id)
 Disconnect a signal handler.
 
virtual void disconnectAll ()
 Disconnect all signal handler.
 
virtual void add (const Widget::Ptr &widgetPtr)
 
virtual void remove (Widget *widget)
 

Static Public Member Functions

static void setDefaultSignalManager (const SignalManager::Ptr &manager)
 Sets Signal Manager that will be used to operate a signal.
 
static TGUI_NODISCARD SignalManager::Ptr getSignalManager ()
 Retrieves Signal Manager that will be used to operate a signal.
 

Protected Member Functions

TGUI_NODISCARD std::pair< Delegate, DelegateEx > makeSignal (const Delegate &)
 
TGUI_NODISCARD std::pair< Delegate, DelegateEx > makeSignalEx (const DelegateEx &)
 
virtual void connect (SignalID id)
 Function that is called each time new signal is created with it id.
 

Protected Attributes

std::vector< Weak > m_widgets
 
std::unordered_map< SignalID, SignalTuplem_signals
 
std::vector< ConnectedSignalTuplem_connectedSignals
 

Static Protected Attributes

static SignalManager::Ptr m_manager
 

Member Function Documentation

◆ connect() [1/3]

virtual void tgui::SignalManager::connect ( SignalID  id)
protectedvirtual

Function that is called each time new signal is created with it id.

Parameters
idId of new signal

◆ connect() [2/3]

template<typename Func , typename... BoundArgs, typename std::enable_if_t<!std::is_convertible< Func, std::function< void(const BoundArgs &...)> >::value &&std::is_convertible< Func, std::function< void(const BoundArgs &..., std::shared_ptr< Widget >, const String &)> >::value , * >
unsigned int tgui::SignalManager::connect ( String  widgetName,
String  signalName,
Func &&  handler,
BoundArgs &&...  args 
)

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

Parameters
widgetNameName of the widget to connect to
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/3]

template<typename Func , typename... Args, typename std::enable_if_t< std::is_convertible< Func, std::function< void(const Args &...)> >::value > * >
unsigned int tgui::SignalManager::connect ( String  widgetName,
String  signalName,
Func &&  handler,
const Args &...  args 
)

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

Parameters
widgetNameName of the widget to connect to
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

◆ disconnect()

virtual bool tgui::SignalManager::disconnect ( unsigned int  id)
virtual

Disconnect a signal handler.

Parameters
idUnique id of the connection returned by the connect function
Returns
True when a connection with this id existed and was removed

◆ getSignalManager()

static TGUI_NODISCARD SignalManager::Ptr tgui::SignalManager::getSignalManager ( )
static

Retrieves Signal Manager that will be used to operate a signal.

Returns
Signal Manager used to operate the signals

◆ setDefaultSignalManager()

static void tgui::SignalManager::setDefaultSignalManager ( const SignalManager::Ptr manager)
static

Sets Signal Manager that will be used to operate a signal.

Parameters
managerManager that will be used to operate ours signals connected by loadWidgetsFromFile

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