[FL-1092] Make View reusable outside of dispatcher (#396)
* View: replace direct View to ViewDispatcher link with callback. ViewDispatcher: update View usage. ViewHandler: update View usage, handle update signal.
This commit is contained in:
@@ -20,6 +20,9 @@ extern "C" {
|
||||
*/
|
||||
#define VIEW_DESTROY 0xFFFFFFFA
|
||||
|
||||
/* View, anonymous type */
|
||||
typedef struct View View;
|
||||
|
||||
/* View Draw callback
|
||||
* @param canvas, pointer to canvas
|
||||
* @param view_model, pointer to context
|
||||
@@ -48,6 +51,14 @@ typedef uint32_t (*ViewNavigationCallback)(void* context);
|
||||
*/
|
||||
typedef void (*ViewCallback)(void* context);
|
||||
|
||||
/* View Update Callback
|
||||
* Called upon model change, need to be propagated to GUI throw ViewPort update
|
||||
* @param view, pointer to view
|
||||
* @param context, pointer to context
|
||||
* @warning called from GUI thread
|
||||
*/
|
||||
typedef void (*ViewUpdateCallback)(View* view, void* context);
|
||||
|
||||
/* View model types */
|
||||
typedef enum {
|
||||
/* Model is not allocated */
|
||||
@@ -62,8 +73,6 @@ typedef enum {
|
||||
ViewModelTypeLocking,
|
||||
} ViewModelType;
|
||||
|
||||
typedef struct View View;
|
||||
|
||||
/* Allocate and init View
|
||||
* @return pointer to View
|
||||
*/
|
||||
@@ -110,6 +119,18 @@ void view_set_enter_callback(View* view, ViewCallback callback);
|
||||
*/
|
||||
void view_set_exit_callback(View* view, ViewCallback callback);
|
||||
|
||||
/* Set Update callback
|
||||
* @param view, pointer to View
|
||||
* @param callback, callback
|
||||
*/
|
||||
void view_set_update_callback(View* view, ViewUpdateCallback callback);
|
||||
|
||||
/* Set View Draw callback
|
||||
* @param view, pointer to View
|
||||
* @param context, context for callbacks
|
||||
*/
|
||||
void view_set_update_callback_context(View* view, void* context);
|
||||
|
||||
/* Set View Draw callback
|
||||
* @param view, pointer to View
|
||||
* @param context, context for callbacks
|
||||
|
Reference in New Issue
Block a user