2021-10-03 13:36:05 +03:00
|
|
|
/**
|
|
|
|
* @file view_dispatcher_i.h
|
|
|
|
* GUI: ViewDispatcher API
|
|
|
|
*/
|
|
|
|
|
2021-01-08 07:42:48 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <m-dict.h>
|
|
|
|
|
2021-05-25 13:19:07 +03:00
|
|
|
#include "view_dispatcher.h"
|
|
|
|
#include "view_i.h"
|
|
|
|
#include "gui_i.h"
|
|
|
|
|
2021-01-08 07:42:48 +03:00
|
|
|
DICT_DEF2(ViewDict, uint32_t, M_DEFAULT_OPLIST, View*, M_PTR_OPLIST)
|
|
|
|
|
|
|
|
struct ViewDispatcher {
|
2024-06-10 20:53:08 +03:00
|
|
|
FuriEventLoop* event_loop;
|
|
|
|
FuriMessageQueue* input_queue;
|
|
|
|
FuriMessageQueue* event_queue;
|
|
|
|
|
2021-01-08 07:42:48 +03:00
|
|
|
Gui* gui;
|
2021-01-29 16:52:16 +03:00
|
|
|
ViewPort* view_port;
|
2021-01-08 07:42:48 +03:00
|
|
|
ViewDict_t views;
|
2021-08-30 23:05:09 +03:00
|
|
|
|
2021-01-08 07:42:48 +03:00
|
|
|
View* current_view;
|
2021-08-30 23:05:09 +03:00
|
|
|
|
2021-09-02 00:05:00 +03:00
|
|
|
View* ongoing_input_view;
|
2021-08-31 11:22:52 +03:00
|
|
|
uint8_t ongoing_input;
|
2021-08-30 23:05:09 +03:00
|
|
|
|
2021-07-12 21:56:14 +03:00
|
|
|
ViewDispatcherCustomEventCallback custom_event_callback;
|
|
|
|
ViewDispatcherNavigationEventCallback navigation_event_callback;
|
|
|
|
ViewDispatcherTickEventCallback tick_event_callback;
|
|
|
|
uint32_t tick_period;
|
|
|
|
void* event_context;
|
2021-01-08 07:42:48 +03:00
|
|
|
};
|
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** ViewPort Draw Callback */
|
2021-01-08 07:42:48 +03:00
|
|
|
void view_dispatcher_draw_callback(Canvas* canvas, void* context);
|
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** ViewPort Input Callback */
|
2021-01-08 07:42:48 +03:00
|
|
|
void view_dispatcher_input_callback(InputEvent* event, void* context);
|
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** Input handler */
|
2021-05-25 13:19:07 +03:00
|
|
|
void view_dispatcher_handle_input(ViewDispatcher* view_dispatcher, InputEvent* event);
|
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** Tick handler */
|
2024-06-10 20:53:08 +03:00
|
|
|
void view_dispatcher_handle_tick_event(void* context);
|
2021-07-12 21:56:14 +03:00
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** Custom event handler */
|
2021-06-20 11:15:48 +03:00
|
|
|
void view_dispatcher_handle_custom_event(ViewDispatcher* view_dispatcher, uint32_t event);
|
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** Set current view, dispatches view enter and exit */
|
2021-02-04 15:05:46 +03:00
|
|
|
void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* view);
|
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** ViewDispatcher update event */
|
2021-04-01 15:03:02 +03:00
|
|
|
void view_dispatcher_update(View* view, void* context);
|
2024-06-10 20:53:08 +03:00
|
|
|
|
|
|
|
/** ViewDispatcher run event loop event callback */
|
|
|
|
bool view_dispatcher_run_event_callback(FuriMessageQueue* queue, void* context);
|
|
|
|
|
|
|
|
/** ViewDispatcher run event loop input callback */
|
|
|
|
bool view_dispatcher_run_input_callback(FuriMessageQueue* queue, void* context);
|