view_dispatcher: add custom events (#526)

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich
2021-06-20 11:15:48 +03:00
committed by GitHub
parent 6e6df5e806
commit 8605f53c28
3 changed files with 54 additions and 1 deletions

18
applications/gui/view_dispatcher.h Normal file → Executable file
View File

@@ -7,6 +7,10 @@
extern "C" {
#endif
/** Prototype for custom event callback
*/
typedef void (*CustomEventCallback)(uint32_t custom_event, void* context);
/** ViewDispatcher view_port placement
*/
typedef enum {
@@ -28,11 +32,23 @@ ViewDispatcher* view_dispatcher_alloc();
void view_dispatcher_free(ViewDispatcher* view_dispatcher);
/** Enable queue support
* If queue enabled all input events will be dispatched throw internal queue
* If queue enabled all input and custom events will be dispatched throw internal queue
* @param view_dispatcher ViewDispatcher instance
*/
void view_dispatcher_enable_queue(ViewDispatcher* view_dispatcher);
/** Set custom event callback
* Custom callback is called when custom event in internal queue received
*/
void view_dispatcher_set_custom_callback(
ViewDispatcher* view_dispatcher,
CustomEventCallback callback,
void* context);
/** Send custom event
*/
void view_dispatcher_send_custom_event(ViewDispatcher* view_dispatcher, uint32_t event);
/** Run ViewDispatcher
* Use only after queue enabled
* @param view_dispatcher ViewDispatcher instance