Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions include/TGUI/Signal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,9 @@ namespace tgui
unsigned int connect(const Func& func, const BoundArgs&... args)
{
const auto id = ++m_lastSignalId;
#if defined(__cpp_if_constexpr) && (__cpp_if_constexpr >= 201606L)
if constexpr (sizeof...(BoundArgs) == 0)
m_handlers[id] = func;
else
#endif
{
m_handlers[id] = [=] { std::invoke(func, args...); };
}
Expand Down
68 changes: 0 additions & 68 deletions include/TGUI/SignalManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ namespace tgui
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[[nodiscard]] static SignalManager::Ptr getSignalManager();

#if defined(__cpp_if_constexpr) && (__cpp_if_constexpr >= 201606L)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Connects a signal handler that will be called when this signal is emitted
///
Expand All @@ -107,41 +106,6 @@ namespace tgui
template <typename Func, typename... BoundArgs>
unsigned int connect(String widgetName, String signalName, Func&& handler, const BoundArgs&... args);

#else
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Connects a signal handler that will be called when this signal is emitted
///
/// @param widgetName Name of the widget to connect to
/// @param signalName Name of the signal
/// @param handler Callback function that is given the extra arguments provided to this function as arguments
/// @param args Optional extra arguments to pass to the signal handler when the signal is emitted
///
/// @return Unique id of the connection
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Connects a signal handler that will be called when this signal is emitted
///
/// @param widgetName Name of the widget to connect to
/// @param signalName Name of the signal
/// @param handler Callback function that is given a pointer to the widget, the name of the signal and the extra
/// arguments provided to this function as arguments
/// @param args Optional extra arguments to pass to the signal handler when the signal is emitted
///
/// @return Unique id of the connection
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template <typename Func,
typename... BoundArgs,
typename std::enable_if_t<
!std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value // Ambigious otherwise when passing bind expression
&& 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);
#endif

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Disconnect a signal handler
///
Expand Down Expand Up @@ -209,7 +173,6 @@ namespace tgui

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#if defined(__cpp_if_constexpr) && (__cpp_if_constexpr >= 201606L)
template <typename Func, typename... BoundArgs>
unsigned int SignalManager::connect(String widgetName, String signalName, Func&& handler, const BoundArgs&... args)
{
Expand All @@ -232,37 +195,6 @@ namespace tgui
connect(id);
return id;
}
#else
template <typename Func, typename... Args, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const Args&...)>>::value>*>
unsigned int SignalManager::connect(String widgetName, String signalName, Func&& handler, const Args&... args)
{
const unsigned int id = generateUniqueId();
m_signals[id] = {widgetName,
signalName,
makeSignal([f = std::function<void(const Args&...)>(handler), args...]() { f(args...); })};

connect(id);
return id;
}

template <typename Func,
typename... BoundArgs,
typename std::enable_if_t<
!std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value // Ambigious otherwise when passing bind expression
&& std::is_convertible<Func, std::function<void(const BoundArgs&..., std::shared_ptr<Widget>, const String&)>>::value>*>
unsigned int SignalManager::connect(String widgetName, String signalName, Func&& handler, BoundArgs&&... args)
{
const unsigned int id = generateUniqueId();
m_signals[id] = {widgetName,
signalName,
makeSignalEx(
[f = std::function<void(const BoundArgs&..., const std::shared_ptr<Widget>&, const String&)>(handler),
args...](const std::shared_ptr<Widget>& w, const String& s) { f(args..., w, s); })};

connect(id);
return id;
}
#endif
} // namespace tgui

#endif // TGUI_SIGNAL_MANAGER_HPP
Loading