feat(event) add LV_SCREEN_(UN)LOAD_START
This commit is contained in:
@@ -110,8 +110,10 @@ The following event codes exist:
|
|||||||
- `LV_EVENT_STYLE_CHANGED` Object's style has changed
|
- `LV_EVENT_STYLE_CHANGED` Object's style has changed
|
||||||
- `LV_EVENT_BASE_DIR_CHANGED` The base dir has changed
|
- `LV_EVENT_BASE_DIR_CHANGED` The base dir has changed
|
||||||
- `LV_EVENT_GET_SELF_SIZE` Get the internal size of a widget
|
- `LV_EVENT_GET_SELF_SIZE` Get the internal size of a widget
|
||||||
- `LV_EVENT_SCREEN_LOADED` A screen was loaded
|
- `LV_EVENT_SCREEN_UNLOAD_START` A screen unload started, fired immediately when lv_scr_load/lv_scr_load_anim is called
|
||||||
- `LV_EVENT_SCREEN_UNLOADED` A screen was unloaded
|
- `LV_EVENT_SCREEN_LOAD_START` A screen load started, fired when the screen change delay is expired
|
||||||
|
- `LV_EVENT_SCREEN_LOADED` A screen was loaded, called when all animations are finished
|
||||||
|
- `LV_EVENT_SCREEN_UNLOADED` A screen was unloaded, called when all animations are finished
|
||||||
|
|
||||||
### Special events
|
### Special events
|
||||||
- `LV_EVENT_VALUE_CHANGED` The object's value has changed (i.e. slider moved)
|
- `LV_EVENT_VALUE_CHANGED` The object's value has changed (i.e. slider moved)
|
||||||
|
|||||||
@@ -83,11 +83,15 @@ void lv_disp_load_scr(lv_obj_t * scr)
|
|||||||
lv_disp_t * d = lv_obj_get_disp(scr);
|
lv_disp_t * d = lv_obj_get_disp(scr);
|
||||||
if(!d) return; /*Shouldn't happen, just to be sure*/
|
if(!d) return; /*Shouldn't happen, just to be sure*/
|
||||||
|
|
||||||
if(d->act_scr) lv_event_send(d->act_scr, LV_EVENT_SCREEN_UNLOADED, NULL);
|
lv_obj_t * old_scr = d->act_scr;
|
||||||
|
|
||||||
|
if(d->act_scr) lv_event_send(old_scr, LV_EVENT_SCREEN_UNLOAD_START, NULL);
|
||||||
|
if(d->act_scr) lv_event_send(scr, LV_EVENT_SCREEN_LOAD_START, NULL);
|
||||||
|
|
||||||
d->act_scr = scr;
|
d->act_scr = scr;
|
||||||
|
|
||||||
if(d->act_scr) lv_event_send(d->act_scr, LV_EVENT_SCREEN_LOADED, NULL);
|
if(d->act_scr) lv_event_send(scr, LV_EVENT_SCREEN_LOADED, NULL);
|
||||||
|
if(d->act_scr) lv_event_send(old_scr, LV_EVENT_SCREEN_UNLOADED, NULL);
|
||||||
|
|
||||||
lv_obj_invalidate(scr);
|
lv_obj_invalidate(scr);
|
||||||
}
|
}
|
||||||
@@ -227,6 +231,8 @@ void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t
|
|||||||
lv_disp_t * d = lv_obj_get_disp(new_scr);
|
lv_disp_t * d = lv_obj_get_disp(new_scr);
|
||||||
lv_obj_t * act_scr = lv_scr_act();
|
lv_obj_t * act_scr = lv_scr_act();
|
||||||
|
|
||||||
|
/*If an other screen load animation is in progress
|
||||||
|
*make target screen loaded immediately. */
|
||||||
if(d->scr_to_load && act_scr != d->scr_to_load) {
|
if(d->scr_to_load && act_scr != d->scr_to_load) {
|
||||||
lv_disp_load_scr(d->scr_to_load);
|
lv_disp_load_scr(d->scr_to_load);
|
||||||
lv_anim_del(d->scr_to_load, NULL);
|
lv_anim_del(d->scr_to_load, NULL);
|
||||||
@@ -329,8 +335,11 @@ void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lv_event_send(act_scr, LV_EVENT_SCREEN_UNLOAD_START, NULL);
|
||||||
|
|
||||||
lv_anim_start(&a_new);
|
lv_anim_start(&a_new);
|
||||||
lv_anim_start(&a_old);
|
lv_anim_start(&a_old);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -409,9 +418,11 @@ lv_timer_t * _lv_disp_get_refr_timer(lv_disp_t * disp)
|
|||||||
static void scr_load_anim_start(lv_anim_t * a)
|
static void scr_load_anim_start(lv_anim_t * a)
|
||||||
{
|
{
|
||||||
lv_disp_t * d = lv_obj_get_disp(a->var);
|
lv_disp_t * d = lv_obj_get_disp(a->var);
|
||||||
d->prev_scr = lv_scr_act();
|
|
||||||
|
|
||||||
lv_disp_load_scr(a->var);
|
d->prev_scr = lv_scr_act();
|
||||||
|
d->act_scr = a->var;
|
||||||
|
|
||||||
|
lv_event_send(d->act_scr, LV_EVENT_SCREEN_LOAD_START, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void opa_scale_anim(void * obj, int32_t v)
|
static void opa_scale_anim(void * obj, int32_t v)
|
||||||
@@ -433,6 +444,9 @@ static void scr_anim_ready(lv_anim_t * a)
|
|||||||
{
|
{
|
||||||
lv_disp_t * d = lv_obj_get_disp(a->var);
|
lv_disp_t * d = lv_obj_get_disp(a->var);
|
||||||
|
|
||||||
|
lv_event_send(d->act_scr, LV_EVENT_SCREEN_LOADED, NULL);
|
||||||
|
lv_event_send(d->prev_scr, LV_EVENT_SCREEN_UNLOADED, NULL);
|
||||||
|
|
||||||
if(d->prev_scr && d->del_prev) lv_obj_del(d->prev_scr);
|
if(d->prev_scr && d->del_prev) lv_obj_del(d->prev_scr);
|
||||||
d->prev_scr = NULL;
|
d->prev_scr = NULL;
|
||||||
d->scr_to_load = NULL;
|
d->scr_to_load = NULL;
|
||||||
|
|||||||
@@ -75,9 +75,10 @@ typedef enum {
|
|||||||
LV_EVENT_CHILD_CHANGED, /**< Child was removed, added, or its size, position were changed */
|
LV_EVENT_CHILD_CHANGED, /**< Child was removed, added, or its size, position were changed */
|
||||||
LV_EVENT_CHILD_CREATED, /**< Child was created, always bubbles up to all parents*/
|
LV_EVENT_CHILD_CREATED, /**< Child was created, always bubbles up to all parents*/
|
||||||
LV_EVENT_CHILD_DELETED, /**< Child was deleted, always bubbles up to all parents*/
|
LV_EVENT_CHILD_DELETED, /**< Child was deleted, always bubbles up to all parents*/
|
||||||
|
LV_EVENT_SCREEN_UNLOAD_START, /**< A screen unload started, fired immediately when scr_load is called*/
|
||||||
|
LV_EVENT_SCREEN_LOAD_START, /**< A screen load started, fired when the screen change delay is expired*/
|
||||||
LV_EVENT_SCREEN_LOADED, /**< A screen was loaded*/
|
LV_EVENT_SCREEN_LOADED, /**< A screen was loaded*/
|
||||||
LV_EVENT_SCREEN_UNLOADED, /**< A screen was unloaded*/
|
LV_EVENT_SCREEN_UNLOADED, /**< A screen was unloaded*/
|
||||||
|
|
||||||
LV_EVENT_SIZE_CHANGED, /**< Object coordinates/size have changed*/
|
LV_EVENT_SIZE_CHANGED, /**< Object coordinates/size have changed*/
|
||||||
LV_EVENT_STYLE_CHANGED, /**< Object's style has changed*/
|
LV_EVENT_STYLE_CHANGED, /**< Object's style has changed*/
|
||||||
LV_EVENT_LAYOUT_CHANGED, /**< The children position has changed due to a layout recalculation*/
|
LV_EVENT_LAYOUT_CHANGED, /**< The children position has changed due to a layout recalculation*/
|
||||||
|
|||||||
Reference in New Issue
Block a user