You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
2.8 KiB
118 lines
2.8 KiB
/**
|
|
* Scene struct
|
|
*
|
|
* Created on 2020/01/05.
|
|
*/
|
|
|
|
#ifndef LIQUID_SCENE_TYPE_H
|
|
#define LIQUID_SCENE_TYPE_H
|
|
|
|
#include <stdint.h>
|
|
|
|
struct Scene;
|
|
struct InputEvent;
|
|
|
|
/**
|
|
* Scene::onInput fp type - handle user input
|
|
*
|
|
* @param scene - self
|
|
* @param event - the input event
|
|
* @return follow-up scene event, can be SceneEvent_None() if not used.
|
|
*/
|
|
typedef struct SceneEvent (*Scene_onInput_t)(struct Scene *scene, struct InputEvent event);
|
|
|
|
/**
|
|
* Scene::onChildReturn fp type
|
|
*
|
|
* @param scene - self
|
|
* @param tag - child's tag
|
|
* @param status - status code returned from the child
|
|
* @param data - data returned from the child, must be heap-allocated if not NULL.
|
|
* @return follow-up scene event, can be SceneEvent_None() if not used.
|
|
*/
|
|
typedef struct SceneEvent (*Scene_onChildReturn_t)(struct Scene *scene, uint32_t tag, int32_t status, void *data);
|
|
|
|
/**
|
|
* Scene::onTick fp type
|
|
*
|
|
* @param scene - self
|
|
* @return follow-up scene event, can be SceneEvent_None() if not used.
|
|
*/
|
|
typedef struct SceneEvent (*Scene_onTick_t)(struct Scene *scene, uint32_t millis);
|
|
|
|
/**
|
|
* Scene::init fp type
|
|
*
|
|
* @param scene - self
|
|
* @return follow-up scene event, can be SceneEvent_None() if not used.
|
|
*/
|
|
typedef struct SceneEvent (*Scene_init_t)(struct Scene *scene);
|
|
|
|
/**
|
|
* Scene::paint fp type
|
|
*
|
|
* @param scene - self
|
|
*/
|
|
typedef void (*Scene_paint_t)(struct Scene *scene);
|
|
|
|
/**
|
|
* Scene::free fp type.
|
|
* Release internally allocated resources.
|
|
* This is called by the GUI engine when the scene is closed.
|
|
*
|
|
* @param scene - self
|
|
*/
|
|
typedef void (*Scene_free_t)(struct Scene *scene);
|
|
|
|
/**
|
|
* Scene instance in the framework
|
|
*/
|
|
struct Scene {
|
|
/**
|
|
* Tag given to the scene by its parent to identify its close event.
|
|
*/
|
|
uint32_t tag;
|
|
|
|
/**
|
|
* Init function, called once after the scene has been opened.
|
|
* Nullable field.
|
|
*/
|
|
Scene_init_t init;
|
|
|
|
/**
|
|
* Handle input event.
|
|
* Can return a follow-up scene event, e.g. repaint request.
|
|
* Nullable field.
|
|
*/
|
|
Scene_onInput_t onInput;
|
|
|
|
/**
|
|
* Child scene closed, handle its return value and data, if any.
|
|
* Can return a follow-up scene event.
|
|
* In any case, the scene will be re-painted, if it stays open and on top.
|
|
* Nullable field.
|
|
*/
|
|
Scene_onChildReturn_t onChildReturn;
|
|
|
|
/**
|
|
* Handle a periodic tick (10ms).
|
|
* Can return a follow-up scene event, e.g. repaint request.
|
|
* Nullable field.
|
|
*/
|
|
Scene_onTick_t onTick;
|
|
|
|
/**
|
|
* Draw the scene to the LCD buffer.
|
|
* DO NOT write to the display yet, it will be done by the GUI engine.
|
|
* Nullable field.
|
|
*/
|
|
Scene_paint_t paint;
|
|
|
|
/**
|
|
* Release internally allocated resources, if any. Called on close.
|
|
* Nullable field.
|
|
*/
|
|
Scene_free_t free;
|
|
};
|
|
|
|
#endif //LIQUID_SCENE_TYPE_H
|
|
|