1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

merge beta

This commit is contained in:
Gabor Kiss-Vamosi 2018-06-19 09:06:42 +02:00
commit dc918930ab
10 changed files with 58 additions and 40 deletions

View File

@ -58,7 +58,7 @@ lv_group_t * lv_group_create(void)
*/
void lv_group_del(lv_group_t * group)
{
/*Defocus the the currently focussed object*/
/*Defocus the the currently focused object*/
if(group->obj_focus != NULL) {
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
lv_obj_invalidate(*group->obj_focus);
@ -81,6 +81,8 @@ void lv_group_del(lv_group_t * group)
*/
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
{
if(group == NULL) return;
obj->group_p = group;
lv_obj_t ** next = lv_ll_ins_tail(&group->obj_ll);
*next = obj;
@ -100,10 +102,17 @@ void lv_group_remove_obj(lv_obj_t * obj)
{
lv_group_t * g = obj->group_p;
if(g == NULL) return;
if(g->obj_focus == NULL) return; /*Just to be sure (Not possible if there is at least one object in the group)*/
if(*g->obj_focus == obj) {
lv_group_focus_next(g);
}
}
/* If the focuses object is still the same then it was the only object in the group but it will be deleted.
* Set the `obj_focus` to NULL to get back to the initial state of the group with zero objects*/
if(*g->obj_focus == obj) {
g->obj_focus = NULL;
}
/*Search the object and remove it from its group */
lv_obj_t ** i;

View File

@ -45,7 +45,7 @@ typedef struct _lv_group_t
{
lv_ll_t obj_ll; /*Linked list to store the objects in the group */
lv_obj_t ** obj_focus; /*The object in focus*/
lv_group_style_mod_func_t style_mod; /*A function which modifies the style of the focused object*/
lv_group_style_mod_func_t style_mod; /*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 */
uint8_t frozen:1; /*1: can't focus to new object*/

View File

@ -367,6 +367,8 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
lv_group_send_data(i->group, data->key);
}
if(i->proc.reset_query) return; /*The object might be deleted in `focus_cb` or due to any other user event*/
i->proc.pr_timestamp = 0;
i->proc.long_pr_sent = 0;
}

View File

@ -271,6 +271,16 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
{
lv_obj_invalidate(obj);
/*Delete from the group*/
#if USE_LV_GROUP
if(obj->group_p != NULL) lv_group_remove_obj(obj);
#endif
/*Remove the animations from this object*/
#if USE_LV_ANIMATION
lv_anim_del(obj, NULL);
#endif
/*Recursively delete the children*/
lv_obj_t * i;
lv_obj_t * i_next;
@ -278,32 +288,13 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
while(i != NULL) {
/*Get the next object before delete this*/
i_next = lv_ll_get_next(&(obj->child_ll), i);
/*Call the recursive del to the child too*/
delete_children(i);
/*Set i to the next node*/
i = i_next;
}
#if USE_LV_ANIMATION
/*Remove the animations from this object*/
lv_anim_del(obj, NULL);
#endif
/*Delete from the group*/
#if USE_LV_GROUP
if(obj->group_p != NULL) lv_group_remove_obj(obj);
#endif
/* Reset all input devices if
* the currently pressed object is deleted*/
lv_indev_t * indev = lv_indev_next(NULL);
while(indev) {
if(indev->proc.act_obj == obj || indev->proc.last_obj == obj) {
lv_indev_reset(indev);
}
indev = lv_indev_next(indev);
}
/*Remove the object from parent's children list*/
lv_obj_t * par = lv_obj_get_parent(obj);
@ -313,6 +304,16 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
lv_ll_rem(&(par->child_ll), obj);
}
/* Reset all input devices if
* the currently pressed object is deleted*/
lv_indev_t * indev = lv_indev_next(NULL);
while(indev) {
if(indev->proc.act_obj == obj || indev->proc.last_obj == obj) {
lv_indev_reset(indev);
}
indev = lv_indev_next(indev);
}
/* All children deleted.
* Now clean up the object specific data*/
obj->signal_func(obj, LV_SIGNAL_CLEANUP, NULL);

View File

@ -291,11 +291,11 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
lv_coord_t h = lv_area_get_height(&indic_area);
if(w >= h) {
indic_area.x2 = (int32_t) ((int32_t)w * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value);
indic_area.x2 = indic_area.x1 + indic_area.x2 - 1;
indic_area.x2 = (int32_t) ((int32_t)w * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value);
indic_area.x2 = indic_area.x1 + indic_area.x2;
} else {
indic_area.y1 = (int32_t) ((int32_t)h * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value);
indic_area.y1 = indic_area.y2 - indic_area.y1 + 1;
indic_area.y1 = (int32_t) ((int32_t)h * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value);
indic_area.y1 = indic_area.y2 - indic_area.y1;
}
/*Draw the indicator*/

View File

@ -683,6 +683,7 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
if(anim_en == 0) {
lv_obj_set_height(ddlist, new_height);
lv_ddlist_pos_current_option(ddlist);
lv_anim_del(ddlist, (lv_anim_fp_t)lv_obj_set_height); /*If an animation is in progress then it will overwrite this changes*/
} else {
#if USE_LV_ANIMATION
lv_anim_t a;

View File

@ -313,9 +313,9 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
else if((obj_h <= page_h && bot_err > 0) ||
(obj_h > page_h && top_err >= bot_err)) {
/*Calculate a new position and let some space below*/
scrlable_y = -obj_y;
scrlable_y += page_h - obj_h;
scrlable_y = -(obj_y + style_scrl->body.padding.ver + style->body.padding.ver);
scrlable_y -= style_scrl->body.padding.ver;
scrlable_y += page_h - obj_h;
} else {
/*Already in focus*/
return;

View File

@ -320,12 +320,12 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
if(ext->drag_value != LV_SLIDER_NOT_PRESSED) cur_value = ext->drag_value;
if(slider_w >= slider_h) {
area_indic.x2 = (int32_t) ((int32_t)lv_area_get_width(&area_indic) * (cur_value - min_value)) / (max_value - min_value);
area_indic.x2 = area_indic.x1 + area_indic.x2 - 1;
area_indic.x2 = (int32_t) ((int32_t)(lv_area_get_width(&area_indic) - 1) * (cur_value - min_value)) / (max_value - min_value);
area_indic.x2 += area_indic.x1 + area_indic.x2;
} else {
area_indic.y1 = (int32_t) ((int32_t)lv_area_get_height(&area_indic) * (cur_value - min_value)) / (max_value - min_value);
area_indic.y1 = area_indic.y2 - area_indic.y1 + 1;
area_indic.y1 = (int32_t) ((int32_t)(lv_area_get_height(&area_indic) - 1) * (cur_value - min_value)) / (max_value - min_value);
area_indic.y1 = area_indic.y2 - area_indic.y1;
}
if(cur_value != min_value) lv_draw_rect(&area_indic, mask, style_indic, lv_obj_get_opa_scale(slider));
@ -339,7 +339,7 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
knob_area.x1 = area_indic.x2 - slider_h / 2;
knob_area.x2 = knob_area.x1 + slider_h;
} else {
knob_area.x1 = (int32_t) ((int32_t)(slider_w - slider_h) * (cur_value - min_value)) / (max_value - min_value);
knob_area.x1 = (int32_t) ((int32_t)(slider_w - slider_h - 1) * (cur_value - min_value)) / (max_value - min_value);
knob_area.x1 += slider->coords.x1;
knob_area.x2 = knob_area.x1 + slider_h;
}
@ -351,7 +351,7 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
knob_area.y1 = area_indic.y1 - slider_w / 2;
knob_area.y2 = knob_area.y1 + slider_w;
} else {
knob_area.y2 = (int32_t) ((int32_t)(slider_h - slider_w) * (cur_value - min_value)) / (max_value - min_value);
knob_area.y2 = (int32_t) ((int32_t)(slider_h - slider_w - 1) * (cur_value - min_value)) / (max_value - min_value);
knob_area.y2 = slider->coords.y2 - knob_area.y2;
knob_area.y1 = knob_area.y2 - slider_w;
}

View File

@ -724,7 +724,7 @@ static void tabpage_press_lost_handler(lv_obj_t * tabview, lv_obj_t * tabpage)
if(tab_cur < ext->tab_cnt - 1) tab_cur++;
}
lv_tabview_set_tab_act(tabview, tab_cur, true);
if(tab_cur != ext->tab_cur) lv_tabview_set_tab_act(tabview, tab_cur, true);
}
/**

View File

@ -39,6 +39,7 @@ static lv_style_t dark_frame;
static uint16_t _hue;
static lv_font_t * _font;
/**********************
* MACROS
**********************/
@ -345,9 +346,11 @@ static void list_init(void)
static void ddlist_init(void)
{
#if USE_LV_DDLIST != 0
static lv_style_t bg;
lv_style_copy(&bg, &light_frame);
bg.text.line_space = LV_DPI / 12;
theme.ddlist.bg = &light_frame;
theme.ddlist.bg = &bg;
theme.ddlist.sel = &dark_plain;
theme.ddlist.sb = &dark_frame;
#endif
@ -356,9 +359,11 @@ static void ddlist_init(void)
static void roller_init(void)
{
#if USE_LV_ROLLER != 0
static lv_style_t bg;
lv_style_copy(&bg, &light_frame);
bg.text.line_space = LV_DPI / 12;
theme.roller.bg = &light_frame;
theme.roller.bg = &bg;
theme.roller.sel = &dark_frame;
#endif
}