diff --git a/docs/overview/event.md b/docs/overview/event.md index d2fb2b974..a31be161e 100644 --- a/docs/overview/event.md +++ b/docs/overview/event.md @@ -110,6 +110,8 @@ The following event codes exist: - `LV_EVENT_STYLE_CHANGED` Object's style 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_SCREEN_LOADED` A screen was loaded +- `LV_EVENT_SCREEN_UNLOADED` A screen was unloaded ### Special events - `LV_EVENT_VALUE_CHANGED` The object's value has changed (i.e. slider moved) diff --git a/src/core/lv_disp.c b/src/core/lv_disp.c index c81a6ca0b..91206c619 100644 --- a/src/core/lv_disp.c +++ b/src/core/lv_disp.c @@ -82,8 +82,13 @@ void lv_disp_load_scr(lv_obj_t * scr) { lv_disp_t * d = lv_obj_get_disp(scr); 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); + d->act_scr = scr; + if(d->act_scr) lv_event_send(d->act_scr, LV_EVENT_SCREEN_LOADED, NULL); + lv_obj_invalidate(scr); } diff --git a/src/core/lv_event.h b/src/core/lv_event.h index a7115dbc5..6035a9a50 100644 --- a/src/core/lv_event.h +++ b/src/core/lv_event.h @@ -75,6 +75,9 @@ typedef enum { 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_DELETED, /**< Child was deleted, always bubbles up to all parents*/ + LV_EVENT_SCREEN_LOADED, /**< A screen was loaded*/ + LV_EVENT_SCREEN_UNLOADED, /**< A screen was unloaded*/ + LV_EVENT_SIZE_CHANGED, /**< Object coordinates/size have changed*/ LV_EVENT_STYLE_CHANGED, /**< Object's style has changed*/ LV_EVENT_LAYOUT_CHANGED, /**< The children position has changed due to a layout recalculation*/