diff --git a/lv_conf_checker.h b/lv_conf_checker.h index f899fa568..323483350 100644 --- a/lv_conf_checker.h +++ b/lv_conf_checker.h @@ -195,8 +195,6 @@ #endif #endif /*LV_TICK_CUSTOM*/ -typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ -typedef void * lv_indev_drv_user_data_t; /*Type of user data in the display driver*/ /*Log settings*/ #ifndef USE_LV_LOG @@ -332,12 +330,6 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in t /*=================== * LV_OBJ SETTINGS *==================*/ -#ifndef LV_OBJ_FREE_NUM_TYPE -#define LV_OBJ_FREE_NUM_TYPE uint32_t /*Type of free number attribute (comment out disable free number)*/ -#endif -#ifndef LV_OBJ_FREE_PTR -#define LV_OBJ_FREE_PTR 1 /*Enable the free pointer attribute*/ -#endif #ifndef LV_OBJ_REALIGN #define LV_OBJ_REALIGN 1 /*Enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/ #endif diff --git a/lv_conf_checker.py b/lv_conf_checker.py index 64fd2c8c0..1c9cb421a 100644 --- a/lv_conf_checker.py +++ b/lv_conf_checker.py @@ -42,6 +42,8 @@ for i in inlines: fout.write('#ifndef ' + splitted[1] + '\n') fout.write(i + '\n') fout.write('#endif\n') + elif(re.search('^ *typedef .*;.*$', i)): + continue; #igonre typedefs to avoide redeclaration else: fout.write(i + '\n') diff --git a/lv_core/lv_group.c b/lv_core/lv_group.c index 6a4550890..c53078399 100644 --- a/lv_core/lv_group.c +++ b/lv_core/lv_group.c @@ -23,8 +23,8 @@ /********************** * STATIC PROTOTYPES **********************/ -static void style_mod_def(lv_style_t * style); -static void style_mod_edit_def(lv_style_t * style); +static void style_mod_def(lv_group_t * group, lv_style_t * style); +static void style_mod_edit_def(lv_group_t * group, lv_style_t * style); static void refresh_theme(lv_group_t * g, lv_theme_t * th); static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *), void * (*move)(const lv_ll_t *, const void *)); static void lv_group_refocus(lv_group_t * g); @@ -68,6 +68,9 @@ lv_group_t * lv_group_create(void) group->refocus_policy = LV_GROUP_REFOCUS_POLICY_PREV; group->wrap = 1; + + + /*Initialize style modification callbacks from current theme*/ refresh_theme(group, lv_theme_get_current()); @@ -187,6 +190,7 @@ void lv_group_focus_obj(lv_obj_t * obj) if(g->obj_focus == i) return; /*Don't focus the already focused object again*/ if(g->obj_focus != NULL) { (*g->obj_focus)->signal_cb(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL); + lv_obj_send_event(*g->obj_focus, LV_EVENT_DEFOCUSED); lv_obj_invalidate(*g->obj_focus); } @@ -195,6 +199,7 @@ void lv_group_focus_obj(lv_obj_t * obj) if(g->obj_focus != NULL) { (*g->obj_focus)->signal_cb(*g->obj_focus, LV_SIGNAL_FOCUS, NULL); if(g->focus_cb) g->focus_cb(g); + lv_obj_send_event(*g->obj_focus, LV_EVENT_FOCUSED); lv_obj_invalidate(*g->obj_focus); } break; @@ -291,7 +296,10 @@ void lv_group_set_editing(lv_group_t * group, bool edit) group->editing = en_val; lv_obj_t * focused = lv_group_get_focused(group); - if(focused) focused->signal_cb(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave edit mode*/ + if(focused) { + focused->signal_cb(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave/open edit/navigate mode*/ + lv_obj_send_event(*group->obj_focus, LV_EVENT_FOCUSED); + } lv_obj_invalidate(focused); } @@ -341,12 +349,13 @@ void lv_group_set_wrap(lv_group_t * group, bool en) */ lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style) { + /*Load the current style. It will be modified by the callback*/ lv_style_copy(&group->style_tmp, style); if(group->editing) { - if(group->style_mod_edit) group->style_mod_edit(&group->style_tmp); + if(group->style_mod_edit) group->style_mod_edit(group, &group->style_tmp); } else { - if(group->style_mod) group->style_mod(&group->style_tmp); + if(group->style_mod) group->style_mod(group, &group->style_tmp); } return &group->style_tmp; } @@ -455,10 +464,12 @@ void lv_group_report_style_mod(lv_group_t * group) /** * Default style modifier function + * @param group pointer to the caller group * @param style pointer to a style to modify. (Typically group.style_tmp) It will be OVERWRITTEN. */ -static void style_mod_def(lv_style_t * style) +static void style_mod_def(lv_group_t * group, lv_style_t * style) { + (void)group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ @@ -484,10 +495,12 @@ static void style_mod_def(lv_style_t * style) /** * Default style modifier function + * @param group pointer to the caller group * @param style pointer to a style to modify. (Typically group.style_tmp) It will be OVERWRITTEN. */ -static void style_mod_edit_def(lv_style_t * style) +static void style_mod_edit_def(lv_group_t * group, lv_style_t * style) { + (void)group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ @@ -569,12 +582,14 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *) if(group->obj_focus) { (*group->obj_focus)->signal_cb(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL); + lv_obj_send_event(*group->obj_focus, LV_EVENT_DEFOCUSED); lv_obj_invalidate(*group->obj_focus); } group->obj_focus = obj_next; (*group->obj_focus)->signal_cb(*group->obj_focus, LV_SIGNAL_FOCUS, NULL); + lv_obj_send_event(*group->obj_focus, LV_EVENT_FOCUSED); lv_obj_invalidate(*group->obj_focus); if(group->focus_cb) group->focus_cb(group); diff --git a/lv_core/lv_group.h b/lv_core/lv_group.h index 7b3a6d482..710dd0583 100644 --- a/lv_core/lv_group.h +++ b/lv_core/lv_group.h @@ -45,7 +45,7 @@ extern "C" { **********************/ struct _lv_group_t; -typedef void (*lv_group_style_mod_func_t)(lv_style_t *); +typedef void (*lv_group_style_mod_func_t)(struct _lv_group_t *, lv_style_t *); typedef void (*lv_group_focus_cb_t)(struct _lv_group_t *); typedef struct _lv_group_t @@ -56,6 +56,16 @@ typedef struct _lv_group_t lv_group_style_mod_func_t style_mod_edit;/*A function which modifies the style of the focused object*/ lv_group_focus_cb_t focus_cb; /*A function to call when a new object is focused (optional)*/ lv_style_t style_tmp; /*Stores the modified style of the focused object */ +#if USE_LV_USER_DATA_SINGLE + lv_group_user_data_t user_data; +#endif + +#if USE_LV_USER_DATA_MULTI + lv_group_user_data_t focus_user_data; + lv_group_user_data_t style_mod_user_data; + lv_group_user_data_t style_mod_edit_user_data; +#endif + uint8_t frozen :1; /*1: can't focus to new object*/ uint8_t editing :1; /*1: Edit mode, 0: Navigate mode*/ uint8_t click_focus :1; /*1: If an object in a group is clicked by an indev then it will be focused */ diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index 3dfaabbde..107ecc8eb 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -661,6 +661,7 @@ static void indev_proc_press(lv_indev_proc_t * proc) if(proc->types.pointer.act_obj != NULL) { proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_PRESS_LOST, indev_act); lv_obj_send_event(proc->types.pointer.act_obj, LV_EVENT_PRESS_LOST); + if(proc->reset_query != 0) return; } @@ -770,8 +771,8 @@ static void indev_proc_release(lv_indev_proc_t * proc) proc->types.pointer.wait_unil_release = 0; } - /*Forgot the act obj and send a released signal */ - if(proc->types.pointer.act_obj != NULL) { + /*Forget the act obj and send a released signal */ + if(proc->types.pointer.act_obj) { /* If the object was protected against press lost then it possible that * the object is already not pressed but still it is the `act_obj`. * In this case send the `LV_SIGNAL_RELEASED/CLICKED` of `LV_SIGNAL_PRESS_LOST` if the indev is ON the `types.pointer.act_obj` */ @@ -800,14 +801,11 @@ static void indev_proc_release(lv_indev_proc_t * proc) /*Handle click focus*/ #if USE_LV_GROUP /*Edit mode is not used by POINTER devices. So leave edit mode if we are in it*/ - lv_group_t * act_g = lv_obj_get_group(proc->types.pointer.act_obj); - if(lv_group_get_editing(act_g)) { - lv_group_set_editing(act_g, false); - } + lv_group_t * g = lv_obj_get_group(proc->types.pointer.act_obj); + if(lv_group_get_editing(g)) lv_group_set_editing(g, false); /*Check, if the parent is in a group focus on it.*/ - if(lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_CLICK_FOCUS) == false) { /*Respect the click protection*/ - lv_group_t * g = lv_obj_get_group(proc->types.pointer.act_obj); + if(lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_CLICK_FOCUS) == false) { /*Respect the click focus protection*/ lv_obj_t * parent = proc->types.pointer.act_obj; while(g == NULL) { @@ -820,13 +818,25 @@ static void indev_proc_release(lv_indev_proc_t * proc) g = lv_obj_get_group(parent); } - if(g != NULL && parent != NULL) + /* If a pareit is in a group make it focused. + * `LV_EVENT_FOCUSED/DEFOCUSED` will be sent by `lv_group_focus_obj`*/ + if(g && parent) { if(lv_group_get_click_focus(g)) { lv_group_focus_obj(parent); } + } } #endif + /* Send defocus to the lastly "active" object and foucus to the new one. + * If the one of them is in group then it possible that `lv_group_focus_obj` alraedy sent + * a focus/defucus signal because of `click focus`*/ + if(proc->types.pointer.last_pressed != proc->types.pointer.act_obj) { + lv_obj_send_event(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED); + lv_obj_send_event(proc->types.pointer.act_obj, LV_EVENT_FOCUSED); + proc->types.pointer.last_pressed = proc->types.pointer.act_obj; + } + if(proc->reset_query != 0) return; proc->types.pointer.act_obj = NULL; proc->pr_timestamp = 0; @@ -853,6 +863,7 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev) if(indev->proc.reset_query) { indev->proc.types.pointer.act_obj = NULL; indev->proc.types.pointer.last_obj = NULL; + indev->proc.types.pointer.last_pressed = NULL; indev->proc.types.pointer.drag_limit_out = 0; indev->proc.types.pointer.drag_in_prog = 0; indev->proc.long_pr_sent = 0; diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index 2c057e6f0..9a11b12f7 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -1161,6 +1161,8 @@ void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t cb) */ void lv_obj_send_event(lv_obj_t * obj, lv_event_t event) { + if(obj == NULL) return; + if(obj->event_cb) obj->event_cb(obj, event); if(obj->event_parent && obj->par) { diff --git a/lv_hal/lv_hal_indev.h b/lv_hal/lv_hal_indev.h index 11b903891..63ad23068 100644 --- a/lv_hal/lv_hal_indev.h +++ b/lv_hal/lv_hal_indev.h @@ -92,8 +92,9 @@ typedef struct _lv_indev_proc_t { lv_point_t vect; lv_point_t drag_sum; /*Count the dragged pixels to check LV_INDEV_DRAG_LIMIT*/ lv_point_t drag_throw_vect; - struct _lv_obj_t * act_obj; - struct _lv_obj_t * last_obj; + struct _lv_obj_t * act_obj; /*The object being pressed*/ + struct _lv_obj_t * last_obj; /*The last obejct which was pressed (used by dragthrow and other post-release event)*/ + struct _lv_obj_t * last_pressed; /*The lastly pressed object*/ /*Flags*/ uint8_t drag_limit_out :1; diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index 2b6247f6b..b2fef00bb 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -1024,7 +1024,9 @@ static void scrl_def_event_cb(lv_obj_t * scrl, lv_event_t event) event == LV_EVENT_LONG_PRESSED || event == LV_EVENT_LONG_PRESSED_REPEAT || event == LV_EVENT_LONG_HOVER_IN || - event == LV_EVENT_LONG_HOVER_OUT) + event == LV_EVENT_LONG_HOVER_OUT || + event == LV_EVENT_FOCUSED || + event == LV_EVENT_DEFOCUSED) { lv_obj_send_event(page, event); } diff --git a/lv_themes/lv_theme_alien.c b/lv_themes/lv_theme_alien.c index c4efff0b3..a66f15d39 100644 --- a/lv_themes/lv_theme_alien.c +++ b/lv_themes/lv_theme_alien.c @@ -803,8 +803,9 @@ static void win_init(void) #if USE_LV_GROUP -static void style_mod(lv_style_t * style) +static void style_mod(lv_group_t * group, lv_style_t * style) { + (void) group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; @@ -816,8 +817,9 @@ static void style_mod(lv_style_t * style) #endif } -static void style_mod_edit(lv_style_t * style) +static void style_mod_edit(lv_group_t * group, lv_style_t * style) { + (void) group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; diff --git a/lv_themes/lv_theme_default.c b/lv_themes/lv_theme_default.c index fe87a6a6b..427532cf5 100644 --- a/lv_themes/lv_theme_default.c +++ b/lv_themes/lv_theme_default.c @@ -357,8 +357,9 @@ static void win_init(void) #if USE_LV_GROUP -static void style_mod(lv_style_t * style) +static void style_mod(lv_group_t * group, lv_style_t * style) { + (void)group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; @@ -379,8 +380,9 @@ static void style_mod(lv_style_t * style) #endif } -static void style_mod_edit(lv_style_t * style) +static void style_mod_edit(lv_group_t * group, lv_style_t * style) { + (void)group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; diff --git a/lv_themes/lv_theme_material.c b/lv_themes/lv_theme_material.c index aab198013..6c8f71183 100644 --- a/lv_themes/lv_theme_material.c +++ b/lv_themes/lv_theme_material.c @@ -786,8 +786,9 @@ static void win_init(void) #if USE_LV_GROUP -static void style_mod(lv_style_t * style) +static void style_mod(lv_group_t * group, lv_style_t * style) { + (void) group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; @@ -808,8 +809,9 @@ static void style_mod(lv_style_t * style) #endif } -static void style_mod_edit(lv_style_t * style) +static void style_mod_edit(lv_group_t * group, lv_style_t * style) { + (void) group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; diff --git a/lv_themes/lv_theme_mono.c b/lv_themes/lv_theme_mono.c index b498db514..51bd7f8e5 100644 --- a/lv_themes/lv_theme_mono.c +++ b/lv_themes/lv_theme_mono.c @@ -414,8 +414,9 @@ static void win_init(void) #if USE_LV_GROUP -static void style_mod(lv_style_t * style) +static void style_mod(lv_group_t * group, lv_style_t * style) { + (void) group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; @@ -430,8 +431,9 @@ static void style_mod(lv_style_t * style) #endif } -static void style_mod_edit(lv_style_t * style) +static void style_mod_edit(lv_group_t * group, lv_style_t * style) { + (void) group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; diff --git a/lv_themes/lv_theme_nemo.c b/lv_themes/lv_theme_nemo.c index c2204c234..96a5d6fc2 100644 --- a/lv_themes/lv_theme_nemo.c +++ b/lv_themes/lv_theme_nemo.c @@ -777,8 +777,9 @@ static void win_init(void) #if USE_LV_GROUP -static void style_mod(lv_style_t * style) +static void style_mod(lv_group_t * group, lv_style_t * style) { + (void) group; /*Unused*/ #if LV_COLOR_DEPTH != 1 style->body.border.width = 2; style->body.border.color = LV_COLOR_SILVER; @@ -796,6 +797,29 @@ static void style_mod(lv_style_t * style) #endif } +static void style_mod_edit(lv_group_t * group, lv_style_t * style) +{ + (void) group; /*Unused*/ +#if LV_COLOR_DEPTH != 1 + /*Make the style to be a little bit orange*/ + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_GREEN; + + /*If not empty or has border then emphasis the border*/ + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + + style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60); + + style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70); +#else + style->body.border.opa = LV_OPA_COVER; + style->body.border.color = LV_COLOR_BLACK; + style->body.border.width = 3; +#endif +} + #endif /*USE_LV_GROUP*/ /********************** @@ -855,7 +879,7 @@ lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t * font) #if USE_LV_GROUP theme.group.style_mod = style_mod; - theme.group.style_mod_edit = style_mod; + theme.group.style_mod_edit = style_mod_edit; #endif return &theme; diff --git a/lv_themes/lv_theme_night.c b/lv_themes/lv_theme_night.c index ef01ed4b0..5bd30cc90 100644 --- a/lv_themes/lv_theme_night.c +++ b/lv_themes/lv_theme_night.c @@ -697,8 +697,9 @@ static void win_init(void) #if USE_LV_GROUP -static void style_mod(lv_style_t * style) +static void style_mod(lv_group_t * group, lv_style_t * style) { + (void)group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER; @@ -713,8 +714,9 @@ static void style_mod(lv_style_t * style) #endif } -static void style_mod_edit(lv_style_t * style) +static void style_mod_edit(lv_group_t * group, lv_style_t * style) { + (void)group; /*Unused*/ #if LV_COLOR_DEPTH != 1 /*Make the style to be a little bit orange*/ style->body.border.opa = LV_OPA_COVER;