TGUI  1.3-dev
Loading...
Searching...
No Matches
Signal.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2024 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25
26#ifndef TGUI_SIGNAL_HPP
27#define TGUI_SIGNAL_HPP
28
30
31#include <TGUI/Global.hpp>
32#include <TGUI/String.hpp>
33#include <TGUI/Color.hpp>
34#include <TGUI/Vector2.hpp>
35#include <TGUI/Animation.hpp>
36#include <TGUI/Filesystem.hpp>
37
38#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
39 #include <unordered_map>
40 #include <type_traits>
41 #include <functional>
42 #include <typeindex>
43 #include <memory>
44 #include <vector>
45 #include <deque>
46#endif
47
48#undef MessageBox // windows.h defines MessageBox when NOMB isn't defined before including windows.h
49
51
52TGUI_MODULE_EXPORT namespace tgui
53{
54 class Widget;
55 class ChildWindow;
56 class Panel;
57
61 class TGUI_API Signal
62 {
63 public:
64
68 virtual ~Signal() = default;
69
70
77 Signal(String&& name, std::size_t extraParameters = 0) :
78 m_name{std::move(name)}
79 {
80 if (1 + extraParameters > m_parameters.size())
81 m_parameters.resize(1 + extraParameters);
82 }
83
84
88 Signal(const Signal& other);
89
90
94 Signal(Signal&& other) noexcept = default;
95
96
100 Signal& operator=(const Signal& other);
101
102
106 Signal& operator=(Signal&& other) noexcept = default;
107
108
117 template <typename Func, typename... BoundArgs>
118 unsigned int operator()(const Func& func, const BoundArgs&... args)
119 {
120 return connect(func, args...);
121 }
122
123
132 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
133 unsigned int connect(const Func& func, const BoundArgs&... args)
134 {
135 const auto id = ++m_lastSignalId;
136#if defined(__cpp_if_constexpr) && (__cpp_if_constexpr >= 201606L)
137 if constexpr(sizeof...(BoundArgs) == 0)
138 m_handlers[id] = func;
139 else
140#endif
141 {
142 m_handlers[id] = [=]{ invokeFunc(func, args...); };
143 }
144
145 return id;
146 }
147
148
157 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const std::shared_ptr<Widget>&, const String&)>>::value>* = nullptr>
158 unsigned int connectEx(const Func& func, const BoundArgs&... args)
159 {
160 // The name is copied so that the lambda does not depend on the 'this' pointer
161 return connect([func, name=m_name, args...](){ invokeFunc(func, args..., getWidget(), name); });
162 }
163
164
172 bool disconnect(unsigned int id);
173
174
179
180
188 bool emit(const Widget* widget);
189
190
196 TGUI_NODISCARD String getName() const
197 {
198 return m_name;
199 }
200
201
210 void setEnabled(bool enabled)
211 {
212 m_enabled = enabled;
213 }
214
215
224 TGUI_NODISCARD bool isEnabled() const
225 {
226 return m_enabled;
227 }
228
229
231 protected:
232
236 static std::shared_ptr<Widget> getWidget();
237
238
242 template <typename Type>
243 TGUI_NODISCARD static const std::decay_t<Type>& dereferenceParam(std::size_t paramIndex)
244 {
245 return *static_cast<const std::decay_t<Type>*>(m_parameters[paramIndex]);
246 }
247
248
249#if defined(__cpp_lib_invoke) && (__cpp_lib_invoke >= 201411L)
250 template <typename Func, typename... Args>
251 static void invokeFunc(Func&& func, Args&&... args)
252 {
253 std::invoke(std::forward<Func>(func), std::forward<Args>(args)...);
254 }
255#else
256 // std::invoke only exists in c++17 so we use our own implementation to support c++14 compilers
257 template <typename Func, typename... Args, typename std::enable_if_t<std::is_member_pointer<std::decay_t<Func>>::value>* = nullptr>
258 static void invokeFunc(Func&& func, Args&&... args)
259 {
260 (std::mem_fn(func))(std::forward<Args>(args)...);
261 }
262
263 template <typename Func, typename... Args, typename std::enable_if_t<!std::is_member_pointer<std::decay_t<Func>>::value>* = nullptr>
264 static void invokeFunc(Func&& func, Args&&... args)
265 {
266 std::forward<Func>(func)(std::forward<Args>(args)...);
267 }
268#endif
269
270
272 protected:
273
274 bool m_enabled = true;
275 String m_name;
276 std::unordered_map<unsigned int, std::function<void()>> m_handlers;
277
278 static unsigned int m_lastSignalId;
279 static std::deque<const void*> m_parameters;
280 };
281
282
289 template <typename T>
290 class SignalTyped : public Signal
291 {
292 public:
293
298 Signal{std::move(name), 1}
299 {
300 }
301
302
311 template <typename Func, typename... BoundArgs>
312 unsigned int operator()(const Func& func, const BoundArgs&... args)
313 {
314 return connect(func, args...);
315 }
316
317
326 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
327 unsigned int connect(const Func& func, const BoundArgs&... args)
328 {
329 return Signal::connect(func, args...);
330 }
331
332
341 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., T)>>::value>* = nullptr>
342 unsigned int connect(const Func& func, const BoundArgs&... args)
343 {
344 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<T>(1)); });
345 }
346
347
356 bool emit(const Widget* widget, T param)
357 {
358 if (m_handlers.empty())
359 return false;
360
361 m_parameters[1] = static_cast<const void*>(&param);
362 return Signal::emit(widget);
363 }
364 };
365
366
373 template <typename T1, typename T2>
374 class SignalTyped2 : public Signal
375 {
376 public:
377
382 Signal{std::move(name), 2}
383 {
384 }
385
386
395 template <typename Func, typename... BoundArgs>
396 unsigned int operator()(const Func& func, const BoundArgs&... args)
397 {
398 return connect(func, args...);
399 }
400
401
410 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
411 unsigned int connect(const Func& func, const BoundArgs&... args)
412 {
413 return Signal::connect(func, args...);
414 }
415
416
425 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., T1, T2)>>::value>* = nullptr>
426 unsigned int connect(const Func& func, const BoundArgs&... args)
427 {
428 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<T1>(1), dereferenceParam<T2>(2)); });
429 }
430
431
441 bool emit(const Widget* widget, T1 param1, T2 param2)
442 {
443 if (m_handlers.empty())
444 return false;
445
446 m_parameters[1] = static_cast<const void*>(&param1);
447 m_parameters[2] = static_cast<const void*>(&param2);
448 return Signal::emit(widget);
449 }
450 };
451
461
462
469 class TGUI_API SignalChildWindow : public Signal
470 {
471 public:
472
477 Signal{std::move(name), 1}
478 {
479 }
480
481
490 template <typename Func, typename... BoundArgs>
491 unsigned int operator()(const Func& func, const BoundArgs&... args)
492 {
493 return connect(func, args...);
494 }
495
496
505 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
506 unsigned int connect(const Func& func, const BoundArgs&... args)
507 {
508 return Signal::connect(func, args...);
509 }
510
511
520 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const std::shared_ptr<ChildWindow>&)>>::value>* = nullptr>
521 unsigned int connect(const Func& func, const BoundArgs&... args)
522 {
523 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceChildWindow()); });
524 }
525
526
534 bool emit(ChildWindow* param);
535
536
538 private:
539
543 static std::shared_ptr<ChildWindow> dereferenceChildWindow();
544
545
547 };
548
549
558 class TGUI_API SignalItem : public Signal
559 {
560 public:
561
566 Signal{std::move(name), 3}
567 {
568 }
569
570
579 template <typename Func, typename... BoundArgs>
580 unsigned int operator()(const Func& func, const BoundArgs&... args)
581 {
582 return connect(func, args...);
583 }
584
585
594 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
595 unsigned int connect(const Func& func, const BoundArgs&... args)
596 {
597 return Signal::connect(func, args...);
598 }
599
600
609 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., int)>>::value>* = nullptr>
610 unsigned int connect(const Func& func, const BoundArgs&... args)
611 {
612 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<int>(1)); });
613 }
614
615
624 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const String&)>>::value>* = nullptr>
625 unsigned int connect(const Func& func, const BoundArgs&... args)
626 {
627 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<String>(2)); });
628 }
629
630
639 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const String&, const String&)>>::value>* = nullptr>
640 unsigned int connect(const Func& func, const BoundArgs&... args)
641 {
642 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<String>(2), dereferenceParam<String>(3)); });
643 }
644
645
656 bool emit(const Widget* widget, int index, const String& item, const String& id);
657
658
660 };
661
662
674 class TGUI_API SignalPanelListBoxItem : public Signal
675 {
676 public:
681 Signal{std::move(name), 3}
682 { }
683
684
693 template<typename Func, typename... BoundArgs>
694 unsigned int operator()(const Func& func, const BoundArgs&... args)
695 {
696 return connect(func, args...);
697 }
698
699
708 template<typename Func, typename... BoundArgs, std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
709 unsigned int connect(const Func& func, const BoundArgs&... args)
710 {
711 return Signal::connect(func, args...);
712 }
713
714
723 template<typename Func, typename... BoundArgs, std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., int)>>::value>* = nullptr>
724 unsigned int connect(const Func& func, const BoundArgs&... args)
725 {
726 return Signal::connect([=] { invokeFunc(func, args..., dereferenceParam<int>(1)); });
727 }
728
729
738 template<typename Func, typename... BoundArgs, std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const std::shared_ptr<Panel>&)>>::value>* = nullptr>
739 unsigned int connect(const Func& func, const BoundArgs&... args)
740 {
741 return Signal::connect([=] { invokeFunc(func, args..., dereferencePanel()); });
742 }
743
744
753 template<typename Func, typename... BoundArgs, std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const String&)>>::value>* = nullptr>
754 unsigned int connect(const Func& func, const BoundArgs&... args)
755 {
756 return Signal::connect([=] { invokeFunc(func, args..., dereferenceParam<String>(3)); });
757 }
758
759
768 template<typename Func, typename... BoundArgs, std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., int, const std::shared_ptr<Panel>&)>>::value>* = nullptr>
769 unsigned int connect(const Func& func, const BoundArgs&... args)
770 {
771 return Signal::connect([=] { invokeFunc(func, args..., dereferenceParam<int>(1), dereferencePanel()); });
772 }
773
774
783 template<typename Func, typename... BoundArgs, std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const std::shared_ptr<Panel>&, const String&)>>::value>* = nullptr>
784 unsigned int connect(const Func& func, const BoundArgs&... args)
785 {
786 return Signal::connect([=] { invokeFunc(func, args..., dereferencePanel(), dereferenceParam<String>(3)); });
787 }
788
789
798 template<typename Func, typename... BoundArgs, std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., int, const std::shared_ptr<Panel>&, const String&)>>::value>* = nullptr>
799 unsigned int connect(const Func& func, const BoundArgs&... args)
800 {
801 return Signal::connect([=] { invokeFunc(func, args..., dereferenceParam<int>(1), dereferencePanel(), dereferenceParam<String>(3)); });
802 }
803
804
815 bool emit(const Widget* widget, int index, const std::shared_ptr<Panel>& panel, const String& id);
816
817
819 private:
820
824 static std::shared_ptr<Panel> dereferencePanel();
825
826
828 };
829
838 class TGUI_API SignalFileDialogPaths : public Signal
839 {
840 public:
841
846 Signal{std::move(name), 3}
847 {
848 }
849
858 template <typename Func, typename... BoundArgs>
859 unsigned int operator()(const Func& func, const BoundArgs&... args)
860 {
861 return connect(func, args...);
862 }
863
872 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
873 unsigned int connect(const Func& func, const BoundArgs&... args)
874 {
875 return Signal::connect(func, args...);
876 }
877
886 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const String&)>>::value>* = nullptr>
887 unsigned int connect(const Func& func, const BoundArgs&... args)
888 {
889 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<String>(1)); });
890 }
891
900 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const Filesystem::Path&)>>::value>* = nullptr>
901 unsigned int connect(const Func& func, const BoundArgs&... args)
902 {
903 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<Filesystem::Path>(2)); });
904 }
905
914 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const std::vector<Filesystem::Path>&)>>::value>* = nullptr>
915 unsigned int connect(const Func& func, const BoundArgs&... args)
916 {
917 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<std::vector<Filesystem::Path>>(3)); });
918 }
919
928 bool emit(const Widget* widget, const std::vector<Filesystem::Path>& paths);
929 };
930
931
940 class TGUI_API SignalShowEffect : public Signal
941 {
942 public:
943
948 Signal{std::move(name), 2}
949 {
950 }
951
952
961 template <typename Func, typename... BoundArgs>
962 unsigned int operator()(const Func& func, const BoundArgs&... args)
963 {
964 return connect(func, args...);
965 }
966
967
976 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
977 unsigned int connect(const Func& func, const BoundArgs&... args)
978 {
979 return Signal::connect(func, args...);
980 }
981
982
991 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., ShowEffectType)>>::value>* = nullptr>
992 unsigned int connect(const Func& func, const BoundArgs&... args)
993 {
994 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<ShowEffectType>(1)); });
995 }
996
997
1006 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., bool)>>::value>* = nullptr>
1007 unsigned int connect(const Func& func, const BoundArgs&... args)
1008 {
1009 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<bool>(2)); });
1010 }
1011
1012
1021 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., ShowEffectType, bool)>>::value>* = nullptr>
1022 unsigned int connect(const Func& func, const BoundArgs&... args)
1023 {
1024 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<ShowEffectType>(1), dereferenceParam<bool>(2)); });
1025 }
1026
1027
1037 bool emit(const Widget* widget, ShowEffectType type, bool visible);
1038
1039
1041 };
1042
1043
1050 class TGUI_API SignalAnimationType : public Signal
1051 {
1052 public:
1053
1058 Signal{std::move(name), 1}
1059 {
1060 }
1061
1062
1071 template <typename Func, typename... BoundArgs>
1072 unsigned int operator()(const Func& func, const BoundArgs&... args)
1073 {
1074 return connect(func, args...);
1075 }
1076
1077
1086 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
1087 unsigned int connect(const Func& func, const BoundArgs&... args)
1088 {
1089 return Signal::connect(func, args...);
1090 }
1091
1092
1101 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., AnimationType)>>::value>* = nullptr>
1102 unsigned int connect(const Func& func, const BoundArgs&... args)
1103 {
1104 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<AnimationType>(1)); });
1105 }
1106
1107
1116 bool emit(const Widget* widget, AnimationType type);
1117
1118
1120 };
1121
1122
1130 class TGUI_API SignalItemHierarchy : public Signal
1131 {
1132 public:
1133
1138 Signal{std::move(name), 2}
1139 {
1140 }
1141
1142
1151 template <typename Func, typename... BoundArgs>
1152 unsigned int operator()(const Func& func, const BoundArgs&... args)
1153 {
1154 return connect(func, args...);
1155 }
1156
1157
1166 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
1167 unsigned int connect(const Func& func, const BoundArgs&... args)
1168 {
1169 return Signal::connect(func, args...);
1170 }
1171
1172
1181 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const String&)>>::value>* = nullptr>
1182 unsigned int connect(const Func& func, const BoundArgs&... args)
1183 {
1184 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<String>(1)); });
1185 }
1186
1187
1196 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const std::vector<String>&)>>::value>* = nullptr>
1197 unsigned int connect(const Func& func, const BoundArgs&... args)
1198 {
1199 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<std::vector<String>>(2)); });
1200 }
1201
1202
1212 bool emit(const Widget* widget, const String& item, const std::vector<String>& fullItem);
1213
1214
1216 };
1217
1219}
1220
1222
1223#endif // TGUI_SIGNAL_HPP
Child window widget.
Definition ChildWindow.hpp:47
Object to represent paths on a filesystem.
Definition Filesystem.hpp:59
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:1051
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:1087
unsigned int operator()(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:1072
SignalAnimationType(String &&name)
Constructor.
Definition Signal.hpp:1057
bool emit(const Widget *widget, AnimationType type)
Call all connected signal handlers.
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:470
SignalChildWindow(String &&name)
Constructor.
Definition Signal.hpp:476
bool emit(ChildWindow *param)
Call all connected signal handlers.
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:521
unsigned int operator()(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:491
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:506
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:839
unsigned int operator()(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:859
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:873
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:915
bool emit(const Widget *widget, const std::vector< Filesystem::Path > &paths)
Call all connected signal handlers.
SignalFileDialogPaths(String &&name)
Constructor.
Definition Signal.hpp:845
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:1131
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:1197
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:1167
SignalItemHierarchy(String &&name)
Constructor.
Definition Signal.hpp:1137
bool emit(const Widget *widget, const String &item, const std::vector< String > &fullItem)
Call all connected signal handlers.
unsigned int operator()(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:1152
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:559
bool emit(const Widget *widget, int index, const String &item, const String &id)
Call all connected signal handlers.
unsigned int operator()(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:580
SignalItem(String &&name)
Constructor.
Definition Signal.hpp:565
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:595
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:675
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:739
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:709
SignalPanelListBoxItem(String &&name)
Constructor.
Definition Signal.hpp:680
bool emit(const Widget *widget, int index, const std::shared_ptr< Panel > &panel, const String &id)
Call all connected signal handlers.
unsigned int operator()(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:694
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:941
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:977
unsigned int operator()(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:962
bool emit(const Widget *widget, ShowEffectType type, bool visible)
Call all connected signal handlers.
SignalShowEffect(String &&name)
Constructor.
Definition Signal.hpp:947
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:375
bool emit(const Widget *widget, T1 param1, T2 param2)
Call all connected signal handlers.
Definition Signal.hpp:441
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:411
SignalTyped2(String &&name)
Constructor.
Definition Signal.hpp:381
unsigned int operator()(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:396
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:291
SignalTyped(String &&name)
Constructor.
Definition Signal.hpp:297
unsigned int operator()(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:312
bool emit(const Widget *widget, T param)
Call all connected signal handlers.
Definition Signal.hpp:356
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:327
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:62
bool emit(const Widget *widget)
Call all connected signal handlers.
static TGUI_NODISCARD 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.
Definition Signal.hpp:243
Signal(const Signal &other)
Copy constructor which will not copy the signal handlers.
unsigned int operator()(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:118
void disconnectAll()
Disconnect all signal handler from this signal.
void setEnabled(bool enabled)
Changes whether this signal calls the connected functions when triggered.
Definition Signal.hpp:210
TGUI_NODISCARD bool isEnabled() const
Returns whether this signal calls the connected functions when triggered.
Definition Signal.hpp:224
bool disconnect(unsigned int id)
Disconnect a signal handler from this signal.
Signal & operator=(const Signal &other)
Copy assignment operator which will not copy the signal handlers.
unsigned int connect(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:133
virtual ~Signal()=default
Default destructor.
Signal(String &&name, std::size_t extraParameters=0)
Constructor.
Definition Signal.hpp:77
Signal & operator=(Signal &&other) noexcept=default
Default move assignment operator.
TGUI_NODISCARD String getName() const
Returns the name given to the signal.
Definition Signal.hpp:196
Signal(Signal &&other) noexcept=default
Default move constructor.
static std::shared_ptr< Widget > getWidget()
Extracts the widget stored in the first parameter.
unsigned int connectEx(const Func &func, const BoundArgs &... args)
Connects a signal handler that will be called when this signal is emitted.
Definition Signal.hpp:158
Wrapper class to store strings.
Definition String.hpp:101
The parent class for every widget.
Definition Widget.hpp:84
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39
ShowEffectType
Type of effect to show/hide widget.
Definition Animation.hpp:47
AnimationType
Type of animation.
Definition Animation.hpp:66