Foundation classes for a basic GUI implementing simple widgets and events
Dependents: TouchScreenGUIDemo
Events/EventDispatcher.h@18:d849f3ada858, 2016-05-28 (annotated)
- Committer:
- duncanFrance
- Date:
- Sat May 28 14:50:14 2016 +0000
- Revision:
- 18:d849f3ada858
- Parent:
- 12:63db16fea709
Moved the event queue into the EventDispatcher; Improved event handling across Window/Widget
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
duncanFrance | 0:0a590815d51c | 1 | #ifndef SIMPLEGUI_EVENT_DISPATCHER_H |
duncanFrance | 0:0a590815d51c | 2 | #define SIMPLEGUI_EVENT_DISPATCHER_H |
duncanFrance | 0:0a590815d51c | 3 | |
duncanFrance | 18:d849f3ada858 | 4 | #include "rtos.h" |
duncanFrance | 18:d849f3ada858 | 5 | |
duncanFrance | 0:0a590815d51c | 6 | #include "EventListener.h" |
duncanFrance | 12:63db16fea709 | 7 | #include "LinkedList.h" |
duncanFrance | 0:0a590815d51c | 8 | |
duncanFrance | 12:63db16fea709 | 9 | class EventDispatcher |
duncanFrance | 12:63db16fea709 | 10 | { |
duncanFrance | 12:63db16fea709 | 11 | |
duncanFrance | 0:0a590815d51c | 12 | |
duncanFrance | 12:63db16fea709 | 13 | public: |
duncanFrance | 12:63db16fea709 | 14 | |
duncanFrance | 0:0a590815d51c | 15 | EventDispatcher(); |
duncanFrance | 12:63db16fea709 | 16 | |
duncanFrance | 0:0a590815d51c | 17 | void attachListener(EventListener* l); |
duncanFrance | 0:0a590815d51c | 18 | void detachListener(EventListener* l); |
duncanFrance | 0:0a590815d51c | 19 | void dispatchEvent(Event e); |
duncanFrance | 18:d849f3ada858 | 20 | |
duncanFrance | 18:d849f3ada858 | 21 | /** |
duncanFrance | 18:d849f3ada858 | 22 | * Normally called from a separate thread to queue an event for later processing by the main thread |
duncanFrance | 18:d849f3ada858 | 23 | **/ |
duncanFrance | 18:d849f3ada858 | 24 | void queueEvent(const Event e); |
duncanFrance | 18:d849f3ada858 | 25 | |
duncanFrance | 18:d849f3ada858 | 26 | /** |
duncanFrance | 18:d849f3ada858 | 27 | * Should be called on the main thread |
duncanFrance | 18:d849f3ada858 | 28 | **/ |
duncanFrance | 18:d849f3ada858 | 29 | void pumpEvents(); |
duncanFrance | 12:63db16fea709 | 30 | |
duncanFrance | 12:63db16fea709 | 31 | private: |
duncanFrance | 12:63db16fea709 | 32 | |
duncanFrance | 12:63db16fea709 | 33 | LinkedList<EventListener> _listeners; |
duncanFrance | 18:d849f3ada858 | 34 | Mail<Event, 64> _mailbox; |
duncanFrance | 0:0a590815d51c | 35 | |
duncanFrance | 0:0a590815d51c | 36 | }; |
duncanFrance | 0:0a590815d51c | 37 | |
duncanFrance | 0:0a590815d51c | 38 | #endif |