8#define _DERIVE_EVENT(T, FUNC_NAME) \
9 inline void FUNC_NAME(std::function<void(T &, const Event &)> callback) { \
10 Widget::FUNC_NAME([callback](Widget &widget, const Event &event) { callback(reinterpret_cast<T &>(widget), event); }); \
12 inline void FUNC_NAME(std::function<void(T &)> callback) { \
13 Widget::FUNC_NAME([callback](Widget &widget, const Event &) { callback(reinterpret_cast<T &>(widget)); }); \
16#define _DERIVE_EVENT_TIME(T, FUNC_NAME) \
17 inline void FUNC_NAME(std::function<void(T &, const Event &, time_t)> callback) { \
18 Widget::FUNC_NAME([callback](Widget &widget, const Event &event, time_t time) { callback(reinterpret_cast<T &>(widget), event, time); }); \
20 inline void FUNC_NAME(std::function<void(T &, const Event &)> callback) { \
21 Widget::FUNC_NAME([callback](Widget &widget, const Event &event, time_t) { callback(reinterpret_cast<T &>(widget), event); }); \
23 inline void FUNC_NAME(std::function<void(T &, time_t)> callback) { \
24 Widget::FUNC_NAME([callback](Widget &widget, const Event &, time_t time) { callback(reinterpret_cast<T &>(widget), time); }); \
26 inline void FUNC_NAME(std::function<void(T &)> callback) { \
27 Widget::FUNC_NAME([callback](Widget &widget, const Event &, time_t) { callback(reinterpret_cast<T &>(widget)); }); \
30#define DERIVE_EVENT_HANDLERS(T) \
31 using Widget::onpress; \
32 _DERIVE_EVENT(T, onpress) \
33 using Widget::onrelease; \
34 _DERIVE_EVENT(T, onrelease) \
35 using Widget::onblur; \
36 _DERIVE_EVENT(T, onblur) \
37 using Widget::onclick; \
38 _DERIVE_EVENT(T, onclick) \
39 using Widget::onhold; \
40 _DERIVE_EVENT_TIME(T, onhold)
56 virtual void onpress(std::function<
void(T &,
const Event &)> callback) = 0;
63 virtual void onrelease(std::function<
void(T &,
const Event &)> callback) = 0;
70 virtual void onblur(std::function<
void(T &,
const Event &)> callback) = 0;
77 virtual void onhold(std::function<
void(T &,
const Event &, time_t)> callback) = 0;
87 inline void onclick(std::function<
void(T &,
const Event &)> callback) {
110 inline void onpress(std::function<
void(T &)> callback) {
111 onpress([callback](T &widget,
const Event &) { callback(widget); });
120 onpress([callback](T &,
const Event &event) { callback(event); });
128 inline void onpress(std::function<
void()> callback) {
129 onpress([callback](T &,
const Event &) { callback(); });
137 inline void onrelease(std::function<
void(T &)> callback) {
138 onrelease([callback](T &widget,
const Event &) { callback(widget); });
147 onrelease([callback](T &,
const Event &event) { callback(event); });
164 inline void onblur(std::function<
void(T &)> callback) {
165 onblur([callback](T &widget,
const Event &) { callback(widget); });
174 onblur([callback](T &,
const Event &event) { callback(event); });
182 inline void onblur(std::function<
void()> callback) {
183 onblur([callback](T &,
const Event &) { callback(); });
191 inline void onhold(std::function<
void(T &, time_t)> callback) {
192 onhold([callback](T &widget,
const Event &, time_t time) { callback(widget, time); });
200 inline void onhold(std::function<
void(
const Event &, time_t)> callback) {
201 onhold([callback](T &,
const Event &event, time_t time) { callback(event, time); });
209 inline void onhold(std::function<
void(time_t)> callback) {
210 onhold([callback](T &,
const Event &, time_t time) { callback(time); });
218 inline void onhold(std::function<
void(T &)> callback) {
219 onhold([callback](T &widget,
const Event &, time_t) { callback(widget); });
228 onhold([callback](T &,
const Event &event, time_t) { callback(event); });
236 inline void onhold(std::function<
void()> callback) {
237 onhold([callback](T &,
const Event &, time_t) { callback(); });
248 inline void onclick(std::function<
void(T &)> callback) {
249 onclick([callback](T &widget,
const Event &) { callback(widget); });
261 onclick([callback](T &,
const Event &event) { callback(event); });
272 inline void onclick(std::function<
void()> callback) {
273 onclick([callback](T &,
const Event &) { callback(); });
Virtual function definitions for default event handler functions.
Definition event_handlers.hpp:49
void onclick(std::function< void(T &, const Event &)> callback)
Register a touchscreen event handler that triggers on release.
Definition event_handlers.hpp:87
virtual void onblur(std::function< void(T &, const Event &)> callback)=0
Register a touchscreen event handler that triggers when the widget stops being pressed.
virtual void onhold(std::function< void(T &, const Event &, time_t)> callback)=0
Register a touchscreen event handler that repeatedly triggers when the widget is held for a while.
virtual void onpress(std::function< void(T &, const Event &)> callback)=0
Register a touchscreen event handler that triggers on press.
virtual void onrelease(std::function< void(T &, const Event &)> callback)=0
Register a touchscreen event handler that triggers when the widget stops being pressed.
Extended definitions for widget event handler functions.
Definition event_handlers.hpp:97
void onblur(std::function< void(const Event &)> callback)
Register a touchscreen event handler that triggers when the widget stops being pressed.
Definition event_handlers.hpp:173
void onrelease(std::function< void(const Event &)> callback)
Register a touchscreen event handler that triggers when the widget stops being pressed.
Definition event_handlers.hpp:146
void onrelease(std::function< void(T &)> callback)
Register a touchscreen event handler that triggers when the widget stops being pressed.
Definition event_handlers.hpp:137
void onpress(std::function< void(T &)> callback)
Register a touchscreen event handler that triggers on press.
Definition event_handlers.hpp:110
void onpress(std::function< void(const Event &)> callback)
Register a touchscreen event handler that triggers on press.
Definition event_handlers.hpp:119
void onrelease(std::function< void()> callback)
Register a touchscreen event handler that triggers when the widget stops being pressed.
Definition event_handlers.hpp:155
void onclick(std::function< void(const Event &)> callback)
Register a touchscreen event handler that triggers on release.
Definition event_handlers.hpp:260
void onhold(std::function< void(const Event &)> callback)
Register a touchscreen event handler that repeatedly triggers when the widget is held for a while.
Definition event_handlers.hpp:227
void onblur(std::function< void(T &)> callback)
Register a touchscreen event handler that triggers when the widget stops being pressed.
Definition event_handlers.hpp:164
void onclick(std::function< void()> callback)
Register a touchscreen event handler that triggers on release.
Definition event_handlers.hpp:272
void onhold(std::function< void()> callback)
Register a touchscreen event handler that repeatedly triggers when the widget is held for a while.
Definition event_handlers.hpp:236
void onblur(std::function< void()> callback)
Register a touchscreen event handler that triggers when the widget stops being pressed.
Definition event_handlers.hpp:182
void onhold(std::function< void(time_t)> callback)
Register a touchscreen event handler that repeatedly triggers when the widget is held for a while.
Definition event_handlers.hpp:209
void onhold(std::function< void(T &, time_t)> callback)
Register a touchscreen event handler that repeatedly triggers when the widget is held for a while.
Definition event_handlers.hpp:191
void onclick(std::function< void(T &)> callback)
Register a touchscreen event handler that triggers on release.
Definition event_handlers.hpp:248
void onhold(std::function< void(T &)> callback)
Register a touchscreen event handler that repeatedly triggers when the widget is held for a while.
Definition event_handlers.hpp:218
void onpress(std::function< void()> callback)
Register a touchscreen event handler that triggers on press.
Definition event_handlers.hpp:128
void onhold(std::function< void(const Event &, time_t)> callback)
Register a touchscreen event handler that repeatedly triggers when the widget is held for a while.
Definition event_handlers.hpp:200
A touchscreen event.
Definition event.hpp:26