TGUI  1.6
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#ifndef TGUI_SIGNAL_HPP
26#define TGUI_SIGNAL_HPP
27
29
30#include <TGUI/Global.hpp>
31#include <TGUI/String.hpp>
32#include <TGUI/Color.hpp>
33#include <TGUI/Vector2.hpp>
34#include <TGUI/Animation.hpp>
35#include <TGUI/Filesystem.hpp>
36
37#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
38 #include <unordered_map>
39 #include <type_traits>
40 #include <functional>
41 #include <typeindex>
42 #include <memory>
43 #include <vector>
44 #include <deque>
45#endif
46
47#undef MessageBox // windows.h defines MessageBox when NOMB isn't defined before including windows.h
48
50
51TGUI_MODULE_EXPORT namespace tgui
52{
53 class Widget;
54 class ChildWindow;
55 class Panel;
56
60 class TGUI_API Signal
61 {
62 public:
63
67 virtual ~Signal() = default;
68
75 Signal(String&& name, std::size_t extraParameters = 0) :
76 m_name{std::move(name)}
77 {
78 if (1 + extraParameters > m_parameters.size())
79 m_parameters.resize(1 + extraParameters);
80 }
81
85 Signal(const Signal& other);
86
90 Signal(Signal&& other) noexcept = default;
91
95 Signal& operator=(const Signal& other);
96
100 Signal& operator=(Signal&& other) noexcept = default;
101
110 template <typename Func, typename... BoundArgs>
111 unsigned int operator()(const Func& func, const BoundArgs&... args)
112 {
113 return connect(func, args...);
114 }
115
124 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
125 unsigned int connect(const Func& func, const BoundArgs&... args)
126 {
127 const auto id = ++m_lastSignalId;
128#if defined(__cpp_if_constexpr) && (__cpp_if_constexpr >= 201606L)
129 if constexpr(sizeof...(BoundArgs) == 0)
130 m_handlers[id] = func;
131 else
132#endif
133 {
134 m_handlers[id] = [=]{ invokeFunc(func, args...); };
135 }
136
137 return id;
138 }
139
148 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>
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...](){ invokeFunc(func, args..., getWidget(), name); });
153 }
154
162 bool disconnect(unsigned int id);
163
168
176 bool emit(const Widget* widget);
177
183 TGUI_NODISCARD String getName() const
184 {
185 return m_name;
186 }
187
196 void setEnabled(bool enabled)
197 {
198 m_enabled = enabled;
199 }
200
209 TGUI_NODISCARD bool isEnabled() const
210 {
211 return m_enabled;
212 }
213
215 protected:
216
220 static std::shared_ptr<Widget> getWidget();
221
225 template <typename Type>
226 TGUI_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
231#if defined(__cpp_lib_invoke) && (__cpp_lib_invoke >= 201411L)
232 template <typename Func, typename... Args>
233 static void invokeFunc(Func&& func, Args&&... args)
234 {
235 std::invoke(std::forward<Func>(func), std::forward<Args>(args)...);
236 }
237#else
238 // std::invoke only exists in c++17 so we use our own implementation to support c++14 compilers
239 template <typename Func, typename... Args, typename std::enable_if_t<std::is_member_pointer<std::decay_t<Func>>::value>* = nullptr>
240 static void invokeFunc(Func&& func, Args&&... args)
241 {
242 (std::mem_fn(func))(std::forward<Args>(args)...);
243 }
244
245 template <typename Func, typename... Args, typename std::enable_if_t<!std::is_member_pointer<std::decay_t<Func>>::value>* = nullptr>
246 static void invokeFunc(Func&& func, Args&&... args)
247 {
248 std::forward<Func>(func)(std::forward<Args>(args)...);
249 }
250#endif
251
253 protected:
254
255 bool m_enabled = true;
256 String m_name;
257 std::unordered_map<unsigned int, std::function<void()>> m_handlers;
258
259 static unsigned int m_lastSignalId;
260 static std::deque<const void*> m_parameters;
261 };
262
269 template <typename T>
270 class SignalTyped : public Signal
271 {
272 public:
273
278 Signal{std::move(name), 1}
279 {
280 }
281
290 template <typename Func, typename... BoundArgs>
291 unsigned int operator()(const Func& func, const BoundArgs&... args)
292 {
293 return connect(func, args...);
294 }
295
304 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
305 unsigned int connect(const Func& func, const BoundArgs&... args)
306 {
307 return Signal::connect(func, args...);
308 }
309
318 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., T)>>::value>* = nullptr>
319 unsigned int connect(const Func& func, const BoundArgs&... args)
320 {
321 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<T>(1)); });
322 }
323
332 bool emit(const Widget* widget, T param)
333 {
334 if (m_handlers.empty())
335 return false;
336
337 m_parameters[1] = static_cast<const void*>(&param);
338 return Signal::emit(widget);
339 }
340 };
341
348 template <typename T1, typename T2>
349 class SignalTyped2 : public Signal
350 {
351 public:
352
357 Signal{std::move(name), 2}
358 {
359 }
360
369 template <typename Func, typename... BoundArgs>
370 unsigned int operator()(const Func& func, const BoundArgs&... args)
371 {
372 return connect(func, args...);
373 }
374
383 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
384 unsigned int connect(const Func& func, const BoundArgs&... args)
385 {
386 return Signal::connect(func, args...);
387 }
388
397 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., T1, T2)>>::value>* = nullptr>
398 unsigned int connect(const Func& func, const BoundArgs&... args)
399 {
400 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<T1>(1), dereferenceParam<T2>(2)); });
401 }
402
412 bool emit(const Widget* widget, T1 param1, T2 param2)
413 {
414 if (m_handlers.empty())
415 return false;
416
417 m_parameters[1] = static_cast<const void*>(&param1);
418 m_parameters[2] = static_cast<const void*>(&param2);
419 return Signal::emit(widget);
420 }
421 };
422
432
439 class TGUI_API SignalChildWindow : public Signal
440 {
441 public:
442
447 Signal{std::move(name), 1}
448 {
449 }
450
459 template <typename Func, typename... BoundArgs>
460 unsigned int operator()(const Func& func, const BoundArgs&... args)
461 {
462 return connect(func, args...);
463 }
464
473 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
474 unsigned int connect(const Func& func, const BoundArgs&... args)
475 {
476 return Signal::connect(func, args...);
477 }
478
487 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>
488 unsigned int connect(const Func& func, const BoundArgs&... args)
489 {
490 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceChildWindow()); });
491 }
492
500 bool emit(ChildWindow* param);
501
503 private:
504
508 static std::shared_ptr<ChildWindow> dereferenceChildWindow();
509
511 };
512
521 class TGUI_API SignalItem : public Signal
522 {
523 public:
524
529 Signal{std::move(name), 3}
530 {
531 }
532
541 template <typename Func, typename... BoundArgs>
542 unsigned int operator()(const Func& func, const BoundArgs&... args)
543 {
544 return connect(func, args...);
545 }
546
555 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
556 unsigned int connect(const Func& func, const BoundArgs&... args)
557 {
558 return Signal::connect(func, args...);
559 }
560
569 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., int)>>::value>* = nullptr>
570 unsigned int connect(const Func& func, const BoundArgs&... args)
571 {
572 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<int>(1)); });
573 }
574
583 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const String&)>>::value>* = nullptr>
584 unsigned int connect(const Func& func, const BoundArgs&... args)
585 {
586 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<String>(2)); });
587 }
588
597 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>
598 unsigned int connect(const Func& func, const BoundArgs&... args)
599 {
600 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<String>(2), dereferenceParam<String>(3)); });
601 }
602
613 bool emit(const Widget* widget, int index, const String& item, const String& id);
614
616 };
617
629 class TGUI_API SignalPanelListBoxItem : public Signal
630 {
631 public:
636 Signal{std::move(name), 3}
637 { }
638
647 template<typename Func, typename... BoundArgs>
648 unsigned int operator()(const Func& func, const BoundArgs&... args)
649 {
650 return connect(func, args...);
651 }
652
661 template<typename Func, typename... BoundArgs, std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
662 unsigned int connect(const Func& func, const BoundArgs&... args)
663 {
664 return Signal::connect(func, args...);
665 }
666
675 template<typename Func, typename... BoundArgs, std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., int)>>::value>* = nullptr>
676 unsigned int connect(const Func& func, const BoundArgs&... args)
677 {
678 return Signal::connect([=] { invokeFunc(func, args..., dereferenceParam<int>(1)); });
679 }
680
689 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>
690 unsigned int connect(const Func& func, const BoundArgs&... args)
691 {
692 return Signal::connect([=] { invokeFunc(func, args..., dereferencePanel()); });
693 }
694
703 template<typename Func, typename... BoundArgs, std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const String&)>>::value>* = nullptr>
704 unsigned int connect(const Func& func, const BoundArgs&... args)
705 {
706 return Signal::connect([=] { invokeFunc(func, args..., dereferenceParam<String>(3)); });
707 }
708
717 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>
718 unsigned int connect(const Func& func, const BoundArgs&... args)
719 {
720 return Signal::connect([=] { invokeFunc(func, args..., dereferenceParam<int>(1), dereferencePanel()); });
721 }
722
731 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>
732 unsigned int connect(const Func& func, const BoundArgs&... args)
733 {
734 return Signal::connect([=] { invokeFunc(func, args..., dereferencePanel(), dereferenceParam<String>(3)); });
735 }
736
745 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>
746 unsigned int connect(const Func& func, const BoundArgs&... args)
747 {
748 return Signal::connect([=] { invokeFunc(func, args..., dereferenceParam<int>(1), dereferencePanel(), dereferenceParam<String>(3)); });
749 }
750
761 bool emit(const Widget* widget, int index, const std::shared_ptr<Panel>& panel, const String& id);
762
764 private:
765
769 static std::shared_ptr<Panel> dereferencePanel();
770
772 };
773
782 class TGUI_API SignalFileDialogPaths : public Signal
783 {
784 public:
785
790 Signal{std::move(name), 3}
791 {
792 }
793
802 template <typename Func, typename... BoundArgs>
803 unsigned int operator()(const Func& func, const BoundArgs&... args)
804 {
805 return connect(func, args...);
806 }
807
816 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
817 unsigned int connect(const Func& func, const BoundArgs&... args)
818 {
819 return Signal::connect(func, args...);
820 }
821
830 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const String&)>>::value>* = nullptr>
831 unsigned int connect(const Func& func, const BoundArgs&... args)
832 {
833 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<String>(1)); });
834 }
835
844 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const Filesystem::Path&)>>::value>* = nullptr>
845 unsigned int connect(const Func& func, const BoundArgs&... args)
846 {
847 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<Filesystem::Path>(2)); });
848 }
849
858 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>
859 unsigned int connect(const Func& func, const BoundArgs&... args)
860 {
861 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<std::vector<Filesystem::Path>>(3)); });
862 }
863
872 bool emit(const Widget* widget, const std::vector<Filesystem::Path>& paths);
873 };
874
883 class TGUI_API SignalShowEffect : public Signal
884 {
885 public:
886
891 Signal{std::move(name), 2}
892 {
893 }
894
903 template <typename Func, typename... BoundArgs>
904 unsigned int operator()(const Func& func, const BoundArgs&... args)
905 {
906 return connect(func, args...);
907 }
908
917 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
918 unsigned int connect(const Func& func, const BoundArgs&... args)
919 {
920 return Signal::connect(func, args...);
921 }
922
931 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., ShowEffectType)>>::value>* = nullptr>
932 unsigned int connect(const Func& func, const BoundArgs&... args)
933 {
934 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<ShowEffectType>(1)); });
935 }
936
945 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., bool)>>::value>* = nullptr>
946 unsigned int connect(const Func& func, const BoundArgs&... args)
947 {
948 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<bool>(2)); });
949 }
950
959 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., ShowEffectType, bool)>>::value>* = nullptr>
960 unsigned int connect(const Func& func, const BoundArgs&... args)
961 {
962 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<ShowEffectType>(1), dereferenceParam<bool>(2)); });
963 }
964
974 bool emit(const Widget* widget, ShowEffectType type, bool visible);
975
977 };
978
985 class TGUI_API SignalAnimationType : public Signal
986 {
987 public:
988
993 Signal{std::move(name), 1}
994 {
995 }
996
1005 template <typename Func, typename... BoundArgs>
1006 unsigned int operator()(const Func& func, const BoundArgs&... args)
1007 {
1008 return connect(func, args...);
1009 }
1010
1019 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
1020 unsigned int connect(const Func& func, const BoundArgs&... args)
1021 {
1022 return Signal::connect(func, args...);
1023 }
1024
1033 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., AnimationType)>>::value>* = nullptr>
1034 unsigned int connect(const Func& func, const BoundArgs&... args)
1035 {
1036 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<AnimationType>(1)); });
1037 }
1038
1047 bool emit(const Widget* widget, AnimationType type);
1048
1050 };
1051
1059 class TGUI_API SignalItemHierarchy : public Signal
1060 {
1061 public:
1062
1067 Signal{std::move(name), 2}
1068 {
1069 }
1070
1079 template <typename Func, typename... BoundArgs>
1080 unsigned int operator()(const Func& func, const BoundArgs&... args)
1081 {
1082 return connect(func, args...);
1083 }
1084
1093 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&...)>>::value>* = nullptr>
1094 unsigned int connect(const Func& func, const BoundArgs&... args)
1095 {
1096 return Signal::connect(func, args...);
1097 }
1098
1107 template <typename Func, typename... BoundArgs, typename std::enable_if_t<std::is_convertible<Func, std::function<void(const BoundArgs&..., const String&)>>::value>* = nullptr>
1108 unsigned int connect(const Func& func, const BoundArgs&... args)
1109 {
1110 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<String>(1)); });
1111 }
1112
1121 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>
1122 unsigned int connect(const Func& func, const BoundArgs&... args)
1123 {
1124 return Signal::connect([=]{ invokeFunc(func, args..., dereferenceParam<std::vector<String>>(2)); });
1125 }
1126
1136 bool emit(const Widget* widget, const String& item, const std::vector<String>& fullItem);
1137
1139 };
1140
1142}
1143
1145
1146#endif // TGUI_SIGNAL_HPP
Child window widget.
Definition ChildWindow.hpp:45
Object to represent paths on a filesystem.
Definition Filesystem.hpp:58
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:986
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:1020
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:1006
SignalAnimationType(String &&name)
Constructor.
Definition Signal.hpp:992
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:440
SignalChildWindow(String &&name)
Constructor.
Definition Signal.hpp:446
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:488
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:460
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:474
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:783
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: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: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:859
bool emit(const Widget *widget, const std::vector< Filesystem::Path > &paths)
Call all connected signal handlers.
SignalFileDialogPaths(String &&name)
Constructor.
Definition Signal.hpp:789
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:1060
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:1122
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:1094
SignalItemHierarchy(String &&name)
Constructor.
Definition Signal.hpp:1066
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:1080
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:522
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:542
SignalItem(String &&name)
Constructor.
Definition Signal.hpp:528
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:556
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:630
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:690
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:635
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:648
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:884
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:918
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:904
bool emit(const Widget *widget, ShowEffectType type, bool visible)
Call all connected signal handlers.
SignalShowEffect(String &&name)
Constructor.
Definition Signal.hpp:890
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:350
bool emit(const Widget *widget, T1 param1, T2 param2)
Call all connected signal handlers.
Definition Signal.hpp:412
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:384
SignalTyped2(String &&name)
Constructor.
Definition Signal.hpp:356
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:370
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:271
SignalTyped(String &&name)
Constructor.
Definition Signal.hpp:277
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:291
bool emit(const Widget *widget, T param)
Call all connected signal handlers.
Definition Signal.hpp:332
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:305
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:61
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:111
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:125
virtual ~Signal()=default
Default destructor.
Signal(String &&name, std::size_t extraParameters=0)
Constructor.
Definition Signal.hpp:75
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:96
The parent class for every widget.
Definition Widget.hpp:83
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
ShowEffectType
Type of effect to show/hide widget.
Definition Animation.hpp:46
AnimationType
Type of animation.
Definition Animation.hpp:64