TGUI 1.13
Loading...
Searching...
No Matches
Signal.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2026 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#ifndef TGUI_SIGNAL_HPP
26#define TGUI_SIGNAL_HPP
27
29
30#include <TGUI/Global.hpp>
31
32#include <TGUI/Animation.hpp>
33#include <TGUI/Color.hpp>
34#include <TGUI/Filesystem.hpp>
35#include <TGUI/String.hpp>
36#include <TGUI/Vector2.hpp>
37
38#include <deque>
39#include <functional>
40#include <memory>
41#include <type_traits>
42#include <unordered_map>
43#include <vector>
44
45#undef MessageBox // windows.h defines MessageBox when NOMB isn't defined before including windows.h
46
48
49namespace tgui
50{
51 class Widget;
52 class ChildWindow;
53 class Panel;
54
58 class TGUI_API Signal
59 {
60 public:
64 virtual ~Signal() = default;
65
72 Signal(String&& name, std::size_t extraParameters = 0) :
73 m_name{std::move(name)}
74 {
75 if (1 + extraParameters > m_parameters.size())
76 m_parameters.resize(1 + extraParameters);
77 }
78
82 Signal(const Signal& other);
83
87 Signal(Signal&& other) noexcept = default;
88
92 Signal& operator=(const Signal& other);
93
97 Signal& operator=(Signal&& other) noexcept = default;
98
107 template <typename Func, typename... BoundArgs>
108 unsigned int operator()(const Func& func, const BoundArgs&... args)
109 {
110 return connect(func, args...);
111 }
112
121 template <typename Func,
122 typename... BoundArgs,
123 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&...)>>>* = nullptr>
124 unsigned int connect(const Func& func, const BoundArgs&... args)
125 {
126 const auto id = ++m_lastSignalId;
127 if constexpr (sizeof...(BoundArgs) == 0)
128 m_handlers[id] = func;
129 else
130 {
131 m_handlers[id] = [=] { std::invoke(func, args...); };
132 }
133
134 return id;
135 }
136
145 template <typename Func,
146 typename... BoundArgs,
147 typename std::enable_if_t<
148 std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const std::shared_ptr<Widget>&, const String&)>>>* = nullptr>
149 unsigned int connectEx(const Func& func, const BoundArgs&... args)
150 {
151 // The name is copied so that the lambda does not depend on the 'this' pointer
152 return connect([func, name = m_name, args...]() { std::invoke(func, args..., getWidget(), name); });
153 }
154
162 bool disconnect(unsigned int id);
163
168
176 bool emit(const Widget* widget);
177
183 [[nodiscard]] String getName() const
184 {
185 return m_name;
186 }
187
196 void setEnabled(bool enabled)
197 {
198 m_enabled = enabled;
199 }
200
209 [[nodiscard]] bool isEnabled() const
210 {
211 return m_enabled;
212 }
213
215
216 protected:
220 static std::shared_ptr<Widget> getWidget();
221
225 template <typename Type>
226 [[nodiscard]] static const std::decay_t<Type>& dereferenceParam(std::size_t paramIndex)
227 {
228 return *static_cast<const std::decay_t<Type>*>(m_parameters[paramIndex]);
229 }
230
232
233 protected:
234 bool m_enabled = true;
235 String m_name;
236 std::unordered_map<unsigned int, std::function<void()>> m_handlers;
237
238 static unsigned int m_lastSignalId;
239 static std::deque<const void*> m_parameters;
240 };
241
248 template <typename T>
249 class SignalTyped : public Signal
250 {
251 public:
256 Signal{std::move(name), 1}
257 {
258 }
259
268 template <typename Func, typename... BoundArgs>
269 unsigned int operator()(const Func& func, const BoundArgs&... args)
270 {
271 return connect(func, args...);
272 }
273
282 template <typename Func,
283 typename... BoundArgs,
284 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&...)>>>* = nullptr>
285 unsigned int connect(const Func& func, const BoundArgs&... args)
286 {
287 return Signal::connect(func, args...);
288 }
289
298 template <typename Func,
299 typename... BoundArgs,
300 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., T)>>>* = nullptr>
301 unsigned int connect(const Func& func, const BoundArgs&... args)
302 {
303 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<T>(1)); });
304 }
305
314 bool emit(const Widget* widget, T param)
315 {
316 if (m_handlers.empty())
317 return false;
318
319 m_parameters[1] = static_cast<const void*>(&param);
320 return Signal::emit(widget);
321 }
322 };
323
330 template <typename T1, typename T2>
331 class SignalTyped2 : public Signal
332 {
333 public:
338 Signal{std::move(name), 2}
339 {
340 }
341
350 template <typename Func, typename... BoundArgs>
351 unsigned int operator()(const Func& func, const BoundArgs&... args)
352 {
353 return connect(func, args...);
354 }
355
364 template <typename Func,
365 typename... BoundArgs,
366 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&...)>>>* = nullptr>
367 unsigned int connect(const Func& func, const BoundArgs&... args)
368 {
369 return Signal::connect(func, args...);
370 }
371
380 template <typename Func,
381 typename... BoundArgs,
382 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., T1, T2)>>>* = nullptr>
383 unsigned int connect(const Func& func, const BoundArgs&... args)
384 {
385 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<T1>(1), dereferenceParam<T2>(2)); });
386 }
387
397 bool emit(const Widget* widget, T1 param1, T2 param2)
398 {
399 if (m_handlers.empty())
400 return false;
401
402 m_parameters[1] = static_cast<const void*>(&param1);
403 m_parameters[2] = static_cast<const void*>(&param2);
404 return Signal::emit(widget);
405 }
406 };
407
417
424 class TGUI_API SignalChildWindow : public Signal
425 {
426 public:
431 Signal{std::move(name), 1}
432 {
433 }
434
443 template <typename Func, typename... BoundArgs>
444 unsigned int operator()(const Func& func, const BoundArgs&... args)
445 {
446 return connect(func, args...);
447 }
448
457 template <typename Func,
458 typename... BoundArgs,
459 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&...)>>>* = nullptr>
460 unsigned int connect(const Func& func, const BoundArgs&... args)
461 {
462 return Signal::connect(func, args...);
463 }
464
473 template <typename Func,
474 typename... BoundArgs,
475 typename std::enable_if_t<
476 std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const std::shared_ptr<ChildWindow>&)>>>* = nullptr>
477 unsigned int connect(const Func& func, const BoundArgs&... args)
478 {
479 return Signal::connect([=] { std::invoke(func, args..., dereferenceChildWindow()); });
480 }
481
489 bool emit(ChildWindow* childWindow);
490
492
493 private:
497 static std::shared_ptr<ChildWindow> dereferenceChildWindow();
498
500 };
501
510 class TGUI_API SignalItem : public Signal
511 {
512 public:
517 Signal{std::move(name), 3}
518 {
519 }
520
529 template <typename Func, typename... BoundArgs>
530 unsigned int operator()(const Func& func, const BoundArgs&... args)
531 {
532 return connect(func, args...);
533 }
534
543 template <typename Func,
544 typename... BoundArgs,
545 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&...)>>>* = nullptr>
546 unsigned int connect(const Func& func, const BoundArgs&... args)
547 {
548 return Signal::connect(func, args...);
549 }
550
559 template <typename Func,
560 typename... BoundArgs,
561 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., int)>>>* = nullptr>
562 unsigned int connect(const Func& func, const BoundArgs&... args)
563 {
564 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<int>(1)); });
565 }
566
575 template <typename Func,
576 typename... BoundArgs,
577 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const String&)>>>* = nullptr>
578 unsigned int connect(const Func& func, const BoundArgs&... args)
579 {
580 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<String>(2)); });
581 }
582
591 template <typename Func,
592 typename... BoundArgs,
593 typename std::enable_if_t<
594 std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const String&, const String&)>>>* = nullptr>
595 unsigned int connect(const Func& func, const BoundArgs&... args)
596 {
597 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<String>(2), dereferenceParam<String>(3)); });
598 }
599
610 bool emit(const Widget* widget, int index, const String& item, const String& id);
611
613 };
614
626 class TGUI_API SignalPanelListBoxItem : public Signal
627 {
628 public:
633 Signal{std::move(name), 3}
634 {
635 }
636
645 template <typename Func, typename... BoundArgs>
646 unsigned int operator()(const Func& func, const BoundArgs&... args)
647 {
648 return connect(func, args...);
649 }
650
659 template <typename Func,
660 typename... BoundArgs,
661 std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&...)>>>* = nullptr>
662 unsigned int connect(const Func& func, const BoundArgs&... args)
663 {
664 return Signal::connect(func, args...);
665 }
666
675 template <typename Func,
676 typename... BoundArgs,
677 std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., int)>>>* = nullptr>
678 unsigned int connect(const Func& func, const BoundArgs&... args)
679 {
680 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<int>(1)); });
681 }
682
691 template <typename Func,
692 typename... BoundArgs,
693 std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const std::shared_ptr<Panel>&)>>>* = nullptr>
694 unsigned int connect(const Func& func, const BoundArgs&... args)
695 {
696 return Signal::connect([=] { std::invoke(func, args..., dereferencePanel()); });
697 }
698
707 template <typename Func,
708 typename... BoundArgs,
709 std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const String&)>>>* = nullptr>
710 unsigned int connect(const Func& func, const BoundArgs&... args)
711 {
712 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<String>(3)); });
713 }
714
723 template <typename Func,
724 typename... BoundArgs,
725 std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., int, const std::shared_ptr<Panel>&)>>>* = nullptr>
726 unsigned int connect(const Func& func, const BoundArgs&... args)
727 {
728 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<int>(1), dereferencePanel()); });
729 }
730
739 template <typename Func,
740 typename... BoundArgs,
741 std::enable_if_t<
742 std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const std::shared_ptr<Panel>&, const String&)>>>* = nullptr>
743 unsigned int connect(const Func& func, const BoundArgs&... args)
744 {
745 return Signal::connect([=] { std::invoke(func, args..., dereferencePanel(), dereferenceParam<String>(3)); });
746 }
747
756 template <typename Func,
757 typename... BoundArgs,
758 std::enable_if_t<
759 std::is_convertible_v<Func, std::function<void(const BoundArgs&..., int, const std::shared_ptr<Panel>&, const String&)>>>* = nullptr>
760 unsigned int connect(const Func& func, const BoundArgs&... args)
761 {
762 return Signal::connect(
763 [=] { std::invoke(func, args..., dereferenceParam<int>(1), dereferencePanel(), dereferenceParam<String>(3)); });
764 }
765
776 bool emit(const Widget* widget, int index, const std::shared_ptr<Panel>& panel, const String& id);
777
779
780 private:
784 static std::shared_ptr<Panel> dereferencePanel();
785
787 };
788
797 class TGUI_API SignalFileDialogPaths : public Signal
798 {
799 public:
804 Signal{std::move(name), 3}
805 {
806 }
807
816 template <typename Func, typename... BoundArgs>
817 unsigned int operator()(const Func& func, const BoundArgs&... args)
818 {
819 return connect(func, args...);
820 }
821
830 template <typename Func,
831 typename... BoundArgs,
832 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&...)>>>* = nullptr>
833 unsigned int connect(const Func& func, const BoundArgs&... args)
834 {
835 return Signal::connect(func, args...);
836 }
837
846 template <typename Func,
847 typename... BoundArgs,
848 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const String&)>>>* = nullptr>
849 unsigned int connect(const Func& func, const BoundArgs&... args)
850 {
851 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<String>(1)); });
852 }
853
862 template <typename Func,
863 typename... BoundArgs,
864 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const Filesystem::Path&)>>>* = nullptr>
865 unsigned int connect(const Func& func, const BoundArgs&... args)
866 {
867 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<Filesystem::Path>(2)); });
868 }
869
878 template <typename Func,
879 typename... BoundArgs,
880 typename std::enable_if_t<
881 std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const std::vector<Filesystem::Path>&)>>>* = nullptr>
882 unsigned int connect(const Func& func, const BoundArgs&... args)
883 {
884 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<std::vector<Filesystem::Path>>(3)); });
885 }
886
895 bool emit(const Widget* widget, const std::vector<Filesystem::Path>& paths);
896 };
897
906 class TGUI_API SignalShowEffect : public Signal
907 {
908 public:
913 Signal{std::move(name), 2}
914 {
915 }
916
925 template <typename Func, typename... BoundArgs>
926 unsigned int operator()(const Func& func, const BoundArgs&... args)
927 {
928 return connect(func, args...);
929 }
930
939 template <typename Func,
940 typename... BoundArgs,
941 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&...)>>>* = nullptr>
942 unsigned int connect(const Func& func, const BoundArgs&... args)
943 {
944 return Signal::connect(func, args...);
945 }
946
955 template <typename Func,
956 typename... BoundArgs,
957 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., ShowEffectType)>>>* = nullptr>
958 unsigned int connect(const Func& func, const BoundArgs&... args)
959 {
960 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<ShowEffectType>(1)); });
961 }
962
971 template <typename Func,
972 typename... BoundArgs,
973 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., bool)>>>* = nullptr>
974 unsigned int connect(const Func& func, const BoundArgs&... args)
975 {
976 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<bool>(2)); });
977 }
978
987 template <typename Func,
988 typename... BoundArgs,
989 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., ShowEffectType, bool)>>>* = nullptr>
990 unsigned int connect(const Func& func, const BoundArgs&... args)
991 {
992 return Signal::connect(
993 [=] { std::invoke(func, args..., dereferenceParam<ShowEffectType>(1), dereferenceParam<bool>(2)); });
994 }
995
1005 bool emit(const Widget* widget, ShowEffectType type, bool visible);
1006
1008 };
1009
1016 class TGUI_API SignalAnimationType : public Signal
1017 {
1018 public:
1023 Signal{std::move(name), 1}
1024 {
1025 }
1026
1035 template <typename Func, typename... BoundArgs>
1036 unsigned int operator()(const Func& func, const BoundArgs&... args)
1037 {
1038 return connect(func, args...);
1039 }
1040
1049 template <typename Func,
1050 typename... BoundArgs,
1051 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&...)>>>* = nullptr>
1052 unsigned int connect(const Func& func, const BoundArgs&... args)
1053 {
1054 return Signal::connect(func, args...);
1055 }
1056
1065 template <typename Func,
1066 typename... BoundArgs,
1067 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., AnimationType)>>>* = nullptr>
1068 unsigned int connect(const Func& func, const BoundArgs&... args)
1069 {
1070 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<AnimationType>(1)); });
1071 }
1072
1081 bool emit(const Widget* widget, AnimationType type);
1082
1084 };
1085
1093 class TGUI_API SignalItemHierarchy : public Signal
1094 {
1095 public:
1100 Signal{std::move(name), 2}
1101 {
1102 }
1103
1112 template <typename Func, typename... BoundArgs>
1113 unsigned int operator()(const Func& func, const BoundArgs&... args)
1114 {
1115 return connect(func, args...);
1116 }
1117
1126 template <typename Func,
1127 typename... BoundArgs,
1128 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&...)>>>* = nullptr>
1129 unsigned int connect(const Func& func, const BoundArgs&... args)
1130 {
1131 return Signal::connect(func, args...);
1132 }
1133
1142 template <typename Func,
1143 typename... BoundArgs,
1144 typename std::enable_if_t<std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const String&)>>>* = nullptr>
1145 unsigned int connect(const Func& func, const BoundArgs&... args)
1146 {
1147 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<String>(1)); });
1148 }
1149
1158 template <typename Func,
1159 typename... BoundArgs,
1160 typename std::enable_if_t<
1161 std::is_convertible_v<Func, std::function<void(const BoundArgs&..., const std::vector<String>&)>>>* = nullptr>
1162 unsigned int connect(const Func& func, const BoundArgs&... args)
1163 {
1164 return Signal::connect([=] { std::invoke(func, args..., dereferenceParam<std::vector<String>>(2)); });
1165 }
1166
1176 bool emit(const Widget* widget, const String& item, const std::vector<String>& fullItem);
1177 };
1178} // namespace tgui
1179
1180#endif // TGUI_SIGNAL_HPP
Child window widget.
Definition ChildWindow.hpp:43
Object to represent paths on a filesystem.
Definition Filesystem.hpp:55
Group of widgets that has a background color and optional borders.
Definition Panel.hpp:39
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:1052
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:1036
SignalAnimationType(String &&name)
Constructor.
Definition Signal.hpp:1022
bool emit(const Widget *widget, AnimationType type)
Call all connected signal handlers.
bool emit(ChildWindow *childWindow)
Call all connected signal handlers.
SignalChildWindow(String &&name)
Constructor.
Definition Signal.hpp:430
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:477
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:444
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:460
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:817
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:833
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:882
bool emit(const Widget *widget, const std::vector< Filesystem::Path > &paths)
Call all connected signal handlers.
SignalFileDialogPaths(String &&name)
Constructor.
Definition Signal.hpp:803
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:1162
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:1129
SignalItemHierarchy(String &&name)
Constructor.
Definition Signal.hpp:1099
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:1113
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:530
SignalItem(String &&name)
Constructor.
Definition Signal.hpp:516
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:546
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:694
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:662
SignalPanelListBoxItem(String &&name)
Constructor.
Definition Signal.hpp:632
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:646
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:942
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:926
bool emit(const Widget *widget, ShowEffectType type, bool visible)
Call all connected signal handlers.
SignalShowEffect(String &&name)
Constructor.
Definition Signal.hpp:912
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:332
bool emit(const Widget *widget, T1 param1, T2 param2)
Call all connected signal handlers.
Definition Signal.hpp:397
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:367
SignalTyped2(String &&name)
Constructor.
Definition Signal.hpp:337
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:351
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:250
SignalTyped(String &&name)
Constructor.
Definition Signal.hpp:255
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:269
bool emit(const Widget *widget, T param)
Call all connected signal handlers.
Definition Signal.hpp:314
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:285
bool emit(const Widget *widget)
Call all connected signal handlers.
Signal(const Signal &other)
Copy constructor which will not copy the signal handlers.
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.
Definition Signal.hpp:226
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:108
bool isEnabled() const
Returns whether this signal calls the connected functions when triggered.
Definition Signal.hpp:209
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:196
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.
String getName() const
Returns the name given to the signal.
Definition Signal.hpp:183
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:124
virtual ~Signal()=default
Default destructor.
Signal(String &&name, std::size_t extraParameters=0)
Constructor.
Definition Signal.hpp:72
Signal & operator=(Signal &&other) noexcept=default
Default move assignment operator.
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:149
Wrapper class to store strings.
Definition String.hpp:94
The parent class for every widget.
Definition Widget.hpp:83
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37
SignalTyped< int > SignalInt
Signal with one "int" as optional unbound parameter.
Definition Signal.hpp:408
ShowEffectType
Type of effect to show/hide widget.
Definition Animation.hpp:44
SignalTyped2< float, float > SignalRange
Signal with two floats as optional unbound parameters.
Definition Signal.hpp:416
SignalTyped< Color > SignalColor
Signal with one "Color" as optional unbound parameter.
Definition Signal.hpp:412
SignalTyped< unsigned int > SignalUInt
Signal with one "unsigned int" as optional unbound parameter.
Definition Signal.hpp:409
SignalTyped< Vector2f > SignalVector2f
Signal with one "Vector2f" as optional unbound parameter.
Definition Signal.hpp:414
SignalTyped< bool > SignalBool
Signal with one "bool" as optional unbound parameter.
Definition Signal.hpp:410
AnimationType
Type of animation.
Definition Animation.hpp:62
SignalTyped< FloatRect > SignalFloatRect
Signal with one "FloatRect" as optional unbound parameter.
Definition Signal.hpp:415
SignalTyped< const String & > SignalString
Signal with one "String" as optional unbound parameter.
Definition Signal.hpp:413
SignalTyped< float > SignalFloat
Signal with one "float" as optional unbound parameter.
Definition Signal.hpp:411