mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-18 02:41:36 +03:00
3571b58d0a
* gui: refactore ViewNavigator -> SceneManager * view_dispatcher: remove scene controller, add custom and navigation cb * scene_manager: rework scene controller, move AppScene from lib * nfc: rework nfc scenes with new scene controller API * view_dispatcher: crash on free if not all views were freed * nfc: introduce scene declaration * scene_manager: allocate and configure application scenes * nfc: rework nfc with new Scene Manager API * scene_manager: remove dublicated scene handlers allocation * nfc: rework nfc app with new scene manager API * view_dispatcher: add tick event * scene_manager: add tick event type and handler * nfc: rework notifications with tick event * scene_manager: remove scene id from scene structure * scene_manager: rename array -> stack, add documentation * api-hal-nfc: remove listen activation processing * nfc_scene_start: shorter submenu call * nfc: fix nfc file name * nfc: fix Retry in mifare ul success read * nfc_cli: fix read timeout in nfc_detect CLI command Co-authored-by: あく <alleteam@gmail.com>
59 lines
1.6 KiB
C
59 lines
1.6 KiB
C
#pragma once
|
|
|
|
#include <furi.h>
|
|
#include <m-dict.h>
|
|
|
|
#include "view_dispatcher.h"
|
|
#include "view_i.h"
|
|
#include "gui_i.h"
|
|
|
|
DICT_DEF2(ViewDict, uint32_t, M_DEFAULT_OPLIST, View*, M_PTR_OPLIST)
|
|
|
|
struct ViewDispatcher {
|
|
osMessageQueueId_t queue;
|
|
Gui* gui;
|
|
ViewPort* view_port;
|
|
ViewDict_t views;
|
|
View* current_view;
|
|
ViewDispatcherCustomEventCallback custom_event_callback;
|
|
ViewDispatcherNavigationEventCallback navigation_event_callback;
|
|
ViewDispatcherTickEventCallback tick_event_callback;
|
|
uint32_t tick_period;
|
|
void* event_context;
|
|
};
|
|
|
|
typedef enum {
|
|
ViewDispatcherMessageTypeInput,
|
|
ViewDispatcherMessageTypeCustomEvent,
|
|
ViewDispatcherMessageTypeStop,
|
|
} ViewDispatcherMessageType;
|
|
|
|
typedef struct {
|
|
ViewDispatcherMessageType type;
|
|
union {
|
|
InputEvent input;
|
|
uint32_t custom_event;
|
|
};
|
|
} ViewDispatcherMessage;
|
|
|
|
/* ViewPort Draw Callback */
|
|
void view_dispatcher_draw_callback(Canvas* canvas, void* context);
|
|
|
|
/* ViewPort Input Callback */
|
|
void view_dispatcher_input_callback(InputEvent* event, void* context);
|
|
|
|
/* Input handler */
|
|
void view_dispatcher_handle_input(ViewDispatcher* view_dispatcher, InputEvent* event);
|
|
|
|
/* Tick handler */
|
|
void view_dispatcher_handle_tick_event(ViewDispatcher* view_dispatcher);
|
|
|
|
/* Custom event handler */
|
|
void view_dispatcher_handle_custom_event(ViewDispatcher* view_dispatcher, uint32_t event);
|
|
|
|
/* Set current view, dispatches view enter and exit */
|
|
void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* view);
|
|
|
|
/* ViewDispatcher update event */
|
|
void view_dispatcher_update(View* view, void* context);
|