Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(event) add LV_EVENT_SCREEN_LOADED/UNLOADED events
  • Loading branch information
kisvegabor committed Oct 13, 2021
1 parent 7124ef7 commit ee5369e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/overview/event.md
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/core/lv_disp.c
Expand Up @@ -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);
}

Expand Down
3 changes: 3 additions & 0 deletions src/core/lv_event.h
Expand Up @@ -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*/
Expand Down

0 comments on commit ee5369e

Please sign in to comment.