|
@@ -1,6 +1,8 @@
|
|
|
#pragma once
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <input/input.h>
|
|
#include <input/input.h>
|
|
|
|
|
+
|
|
|
|
|
+#include "icon_animation.h"
|
|
|
#include "canvas.h"
|
|
#include "canvas.h"
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
#include <stddef.h>
|
|
@@ -10,9 +12,10 @@
|
|
|
extern "C" {
|
|
extern "C" {
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
-/* Hides drawing view_port */
|
|
|
|
|
|
|
+/** Hides drawing view_port */
|
|
|
#define VIEW_NONE 0xFFFFFFFF
|
|
#define VIEW_NONE 0xFFFFFFFF
|
|
|
-/* Ignore navigation event */
|
|
|
|
|
|
|
+
|
|
|
|
|
+/** Ignore navigation event */
|
|
|
#define VIEW_IGNORE 0xFFFFFFFE
|
|
#define VIEW_IGNORE 0xFFFFFFFE
|
|
|
|
|
|
|
|
typedef enum {
|
|
typedef enum {
|
|
@@ -20,17 +23,17 @@ typedef enum {
|
|
|
ViewOrientationVertical,
|
|
ViewOrientationVertical,
|
|
|
} ViewOrientation;
|
|
} ViewOrientation;
|
|
|
|
|
|
|
|
-/* View, anonymous type */
|
|
|
|
|
|
|
+/** View, anonymous type */
|
|
|
typedef struct View View;
|
|
typedef struct View View;
|
|
|
|
|
|
|
|
-/* View Draw callback
|
|
|
|
|
|
|
+/** View Draw callback
|
|
|
* @param canvas, pointer to canvas
|
|
* @param canvas, pointer to canvas
|
|
|
* @param view_model, pointer to context
|
|
* @param view_model, pointer to context
|
|
|
* @warning called from GUI thread
|
|
* @warning called from GUI thread
|
|
|
*/
|
|
*/
|
|
|
typedef void (*ViewDrawCallback)(Canvas* canvas, void* model);
|
|
typedef void (*ViewDrawCallback)(Canvas* canvas, void* model);
|
|
|
|
|
|
|
|
-/* View Input callback
|
|
|
|
|
|
|
+/** View Input callback
|
|
|
* @param event, pointer to input event data
|
|
* @param event, pointer to input event data
|
|
|
* @param context, pointer to context
|
|
* @param context, pointer to context
|
|
|
* @return true if event handled, false if event ignored
|
|
* @return true if event handled, false if event ignored
|
|
@@ -38,27 +41,27 @@ typedef void (*ViewDrawCallback)(Canvas* canvas, void* model);
|
|
|
*/
|
|
*/
|
|
|
typedef bool (*ViewInputCallback)(InputEvent* event, void* context);
|
|
typedef bool (*ViewInputCallback)(InputEvent* event, void* context);
|
|
|
|
|
|
|
|
-/* View Custom callback
|
|
|
|
|
|
|
+/** View Custom callback
|
|
|
* @param event, number of custom event
|
|
* @param event, number of custom event
|
|
|
* @param context, pointer to context
|
|
* @param context, pointer to context
|
|
|
* @return true if event handled, false if event ignored
|
|
* @return true if event handled, false if event ignored
|
|
|
*/
|
|
*/
|
|
|
typedef bool (*ViewCustomCallback)(uint32_t event, void* context);
|
|
typedef bool (*ViewCustomCallback)(uint32_t event, void* context);
|
|
|
|
|
|
|
|
-/* View navigation callback
|
|
|
|
|
|
|
+/** View navigation callback
|
|
|
* @param context, pointer to context
|
|
* @param context, pointer to context
|
|
|
* @return next view id
|
|
* @return next view id
|
|
|
* @warning called from GUI thread
|
|
* @warning called from GUI thread
|
|
|
*/
|
|
*/
|
|
|
typedef uint32_t (*ViewNavigationCallback)(void* context);
|
|
typedef uint32_t (*ViewNavigationCallback)(void* context);
|
|
|
|
|
|
|
|
-/* View callback
|
|
|
|
|
|
|
+/** View callback
|
|
|
* @param context, pointer to context
|
|
* @param context, pointer to context
|
|
|
* @warning called from GUI thread
|
|
* @warning called from GUI thread
|
|
|
*/
|
|
*/
|
|
|
typedef void (*ViewCallback)(void* context);
|
|
typedef void (*ViewCallback)(void* context);
|
|
|
|
|
|
|
|
-/* View Update Callback
|
|
|
|
|
|
|
+/** View Update Callback
|
|
|
* Called upon model change, need to be propagated to GUI throw ViewPort update
|
|
* Called upon model change, need to be propagated to GUI throw ViewPort update
|
|
|
* @param view, pointer to view
|
|
* @param view, pointer to view
|
|
|
* @param context, pointer to context
|
|
* @param context, pointer to context
|
|
@@ -66,7 +69,7 @@ typedef void (*ViewCallback)(void* context);
|
|
|
*/
|
|
*/
|
|
|
typedef void (*ViewUpdateCallback)(View* view, void* context);
|
|
typedef void (*ViewUpdateCallback)(View* view, void* context);
|
|
|
|
|
|
|
|
-/* View model types */
|
|
|
|
|
|
|
+/** View model types */
|
|
|
typedef enum {
|
|
typedef enum {
|
|
|
/* Model is not allocated */
|
|
/* Model is not allocated */
|
|
|
ViewModelTypeNone,
|
|
ViewModelTypeNone,
|
|
@@ -80,97 +83,103 @@ typedef enum {
|
|
|
ViewModelTypeLocking,
|
|
ViewModelTypeLocking,
|
|
|
} ViewModelType;
|
|
} ViewModelType;
|
|
|
|
|
|
|
|
-/* Allocate and init View
|
|
|
|
|
- * @return pointer to View
|
|
|
|
|
|
|
+/** Allocate and init View
|
|
|
|
|
+ * @return View instance
|
|
|
*/
|
|
*/
|
|
|
View* view_alloc();
|
|
View* view_alloc();
|
|
|
|
|
|
|
|
-/* Free View
|
|
|
|
|
- * @param pointer to View
|
|
|
|
|
|
|
+/** Free View
|
|
|
|
|
+ * @param View instance
|
|
|
*/
|
|
*/
|
|
|
void view_free(View* view);
|
|
void view_free(View* view);
|
|
|
|
|
|
|
|
-/* Set View Draw callback
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Tie IconAnimation with View
|
|
|
|
|
+ * @param view, View instance
|
|
|
|
|
+ * @param icon_animation, IconAnimation instance
|
|
|
|
|
+ */
|
|
|
|
|
+void view_tie_icon_animation(View* view, IconAnimation* icon_animation);
|
|
|
|
|
+
|
|
|
|
|
+/** Set View Draw callback
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param callback, draw callback
|
|
* @param callback, draw callback
|
|
|
*/
|
|
*/
|
|
|
void view_set_draw_callback(View* view, ViewDrawCallback callback);
|
|
void view_set_draw_callback(View* view, ViewDrawCallback callback);
|
|
|
|
|
|
|
|
-/* Set View Input callback
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Set View Input callback
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param callback, input callback
|
|
* @param callback, input callback
|
|
|
*/
|
|
*/
|
|
|
void view_set_input_callback(View* view, ViewInputCallback callback);
|
|
void view_set_input_callback(View* view, ViewInputCallback callback);
|
|
|
|
|
|
|
|
-/* Set View Custom callback
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Set View Custom callback
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param callback, input callback
|
|
* @param callback, input callback
|
|
|
*/
|
|
*/
|
|
|
void view_set_custom_callback(View* view, ViewCustomCallback callback);
|
|
void view_set_custom_callback(View* view, ViewCustomCallback callback);
|
|
|
|
|
|
|
|
-/* Set Navigation Previous callback
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Set Navigation Previous callback
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param callback, input callback
|
|
* @param callback, input callback
|
|
|
*/
|
|
*/
|
|
|
void view_set_previous_callback(View* view, ViewNavigationCallback callback);
|
|
void view_set_previous_callback(View* view, ViewNavigationCallback callback);
|
|
|
|
|
|
|
|
-/* Set Enter callback
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Set Enter callback
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param callback, callback
|
|
* @param callback, callback
|
|
|
*/
|
|
*/
|
|
|
void view_set_enter_callback(View* view, ViewCallback callback);
|
|
void view_set_enter_callback(View* view, ViewCallback callback);
|
|
|
|
|
|
|
|
-/* Set Exit callback
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Set Exit callback
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param callback, callback
|
|
* @param callback, callback
|
|
|
*/
|
|
*/
|
|
|
void view_set_exit_callback(View* view, ViewCallback callback);
|
|
void view_set_exit_callback(View* view, ViewCallback callback);
|
|
|
|
|
|
|
|
-/* Set Update callback
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Set Update callback
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param callback, callback
|
|
* @param callback, callback
|
|
|
*/
|
|
*/
|
|
|
void view_set_update_callback(View* view, ViewUpdateCallback callback);
|
|
void view_set_update_callback(View* view, ViewUpdateCallback callback);
|
|
|
|
|
|
|
|
-/* Set View Draw callback
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Set View Draw callback
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param context, context for callbacks
|
|
* @param context, context for callbacks
|
|
|
*/
|
|
*/
|
|
|
void view_set_update_callback_context(View* view, void* context);
|
|
void view_set_update_callback_context(View* view, void* context);
|
|
|
|
|
|
|
|
-/* Set View Draw callback
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Set View Draw callback
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param context, context for callbacks
|
|
* @param context, context for callbacks
|
|
|
*/
|
|
*/
|
|
|
void view_set_context(View* view, void* context);
|
|
void view_set_context(View* view, void* context);
|
|
|
|
|
|
|
|
-/* Set View Orientation
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Set View Orientation
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param orientation, either vertical or horizontal
|
|
* @param orientation, either vertical or horizontal
|
|
|
*/
|
|
*/
|
|
|
void view_set_orientation(View* view, ViewOrientation orientation);
|
|
void view_set_orientation(View* view, ViewOrientation orientation);
|
|
|
|
|
|
|
|
-/* Allocate view model.
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Allocate view model.
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param type, View Model Type
|
|
* @param type, View Model Type
|
|
|
* @param size, size
|
|
* @param size, size
|
|
|
*/
|
|
*/
|
|
|
void view_allocate_model(View* view, ViewModelType type, size_t size);
|
|
void view_allocate_model(View* view, ViewModelType type, size_t size);
|
|
|
|
|
|
|
|
-/* Free view model data memory.
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Free view model data memory.
|
|
|
|
|
+ * @param view, View instance
|
|
|
*/
|
|
*/
|
|
|
void view_free_model(View* view);
|
|
void view_free_model(View* view);
|
|
|
|
|
|
|
|
-/* Get view model data
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Get view model data
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @return pointer to model data
|
|
* @return pointer to model data
|
|
|
* @warning Don't forget to commit model changes
|
|
* @warning Don't forget to commit model changes
|
|
|
*/
|
|
*/
|
|
|
void* view_get_model(View* view);
|
|
void* view_get_model(View* view);
|
|
|
|
|
|
|
|
-/* Commit view model
|
|
|
|
|
- * @param view, pointer to View
|
|
|
|
|
|
|
+/** Commit view model
|
|
|
|
|
+ * @param view, View instance
|
|
|
* @param update, true if you want to emit view update, false otherwise
|
|
* @param update, true if you want to emit view update, false otherwise
|
|
|
*/
|
|
*/
|
|
|
void view_commit_model(View* view, bool update);
|
|
void view_commit_model(View* view, bool update);
|
|
@@ -187,7 +196,7 @@ void view_commit_model(View* view, bool update);
|
|
|
view_commit_model(view, update); \
|
|
view_commit_model(view, update); \
|
|
|
}
|
|
}
|
|
|
#else
|
|
#else
|
|
|
-/*
|
|
|
|
|
|
|
+/**
|
|
|
* With clause for view model
|
|
* With clause for view model
|
|
|
* @param view, View instance pointer
|
|
* @param view, View instance pointer
|
|
|
* @param function_body a (){} lambda declaration, executed within you parent function context
|
|
* @param function_body a (){} lambda declaration, executed within you parent function context
|