mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-21 06:53:01 +08:00
Merge branch 'dev-6.0' of https://github.com/littlevgl/lvgl into dev-6.0
This commit is contained in:
commit
ec787b92ba
@ -44,6 +44,8 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void *
|
|||||||
static lv_res_t release_handler(lv_obj_t * ddlist);
|
static lv_res_t release_handler(lv_obj_t * ddlist);
|
||||||
static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en);
|
static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en);
|
||||||
static void lv_ddlist_pos_current_option(lv_obj_t * ddlist);
|
static void lv_ddlist_pos_current_option(lv_obj_t * ddlist);
|
||||||
|
static void lv_ddlist_anim_cb(lv_obj_t * ddlist);
|
||||||
|
static void lv_ddlist_adjust_height(lv_obj_t * ddlist, int32_t height);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
@ -523,7 +525,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
|||||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(ddlist);
|
lv_opa_t opa_scale = lv_obj_get_opa_scale(ddlist);
|
||||||
/*If the list is opened draw a rectangle under the selected item*/
|
/*If the list is opened draw a rectangle under the selected item*/
|
||||||
if(ext->opened != 0) {
|
if(ext->opened != 0 || ext->force_sel) {
|
||||||
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||||
const lv_font_t * font = style->text.font;
|
const lv_font_t * font = style->text.font;
|
||||||
lv_coord_t font_h = lv_font_get_height(font);
|
lv_coord_t font_h = lv_font_get_height(font);
|
||||||
@ -548,7 +550,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
|||||||
lv_opa_t opa_scale = lv_obj_get_opa_scale(ddlist);
|
lv_opa_t opa_scale = lv_obj_get_opa_scale(ddlist);
|
||||||
|
|
||||||
/*Redraw only in opened state*/
|
/*Redraw only in opened state*/
|
||||||
if(ext->opened) {
|
if(ext->opened || ext->force_sel) {
|
||||||
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
|
||||||
const lv_font_t * font = style->text.font;
|
const lv_font_t * font = style->text.font;
|
||||||
lv_coord_t font_h = lv_font_get_height(font);
|
lv_coord_t font_h = lv_font_get_height(font);
|
||||||
@ -839,7 +841,6 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
|||||||
style->body.padding.top + style->body.padding.bottom;
|
style->body.padding.top + style->body.padding.bottom;
|
||||||
else new_height = ext->fix_height;
|
else new_height = ext->fix_height;
|
||||||
|
|
||||||
lv_page_set_sb_mode(ddlist, LV_SB_MODE_UNHIDE);
|
|
||||||
} else { /*Close the list*/
|
} else { /*Close the list*/
|
||||||
const lv_font_t * font = style->text.font;
|
const lv_font_t * font = style->text.font;
|
||||||
lv_style_t * label_style = lv_obj_get_style(ext->label);
|
lv_style_t * label_style = lv_obj_get_style(ext->label);
|
||||||
@ -852,6 +853,7 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
|||||||
if(anim_en == 0) {
|
if(anim_en == 0) {
|
||||||
lv_obj_set_height(ddlist, new_height);
|
lv_obj_set_height(ddlist, new_height);
|
||||||
lv_ddlist_pos_current_option(ddlist);
|
lv_ddlist_pos_current_option(ddlist);
|
||||||
|
if(ext->opened) lv_page_set_sb_mode(ddlist, LV_SB_MODE_UNHIDE);
|
||||||
#if LV_USE_ANIMATION
|
#if LV_USE_ANIMATION
|
||||||
lv_anim_del(ddlist, (lv_anim_fp_t)lv_obj_set_height); /*If an animation is in progress then it will overwrite this changes*/
|
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 {
|
} else {
|
||||||
@ -859,9 +861,9 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
|||||||
a.var = ddlist;
|
a.var = ddlist;
|
||||||
a.start = lv_obj_get_height(ddlist);
|
a.start = lv_obj_get_height(ddlist);
|
||||||
a.end = new_height;
|
a.end = new_height;
|
||||||
a.fp = (lv_anim_fp_t)lv_obj_set_height;
|
a.fp = (lv_anim_fp_t)lv_ddlist_adjust_height;
|
||||||
a.path = lv_anim_path_linear;
|
a.path = lv_anim_path_linear;
|
||||||
a.end_cb = (lv_anim_cb_t)lv_ddlist_pos_current_option;
|
a.end_cb = (lv_anim_cb_t)lv_ddlist_anim_cb;
|
||||||
a.act_time = 0;
|
a.act_time = 0;
|
||||||
a.time = ext->anim_time;
|
a.time = ext->anim_time;
|
||||||
a.playback = 0;
|
a.playback = 0;
|
||||||
@ -869,11 +871,38 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
|||||||
a.repeat = 0;
|
a.repeat = 0;
|
||||||
a.repeat_pause = 0;
|
a.repeat_pause = 0;
|
||||||
|
|
||||||
|
ext->force_sel = 1; /*Keep the list item selected*/
|
||||||
lv_anim_create(&a);
|
lv_anim_create(&a);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Position the list and remove the selection highlight if it's closed.
|
||||||
|
* Called at end of list animation.
|
||||||
|
* @param ddlist pointer to a drop down list
|
||||||
|
*/
|
||||||
|
static void lv_ddlist_anim_cb(lv_obj_t * ddlist) {
|
||||||
|
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||||
|
|
||||||
|
lv_ddlist_pos_current_option(ddlist);
|
||||||
|
|
||||||
|
ext->force_sel = 0; /*Turn off drawing of selection*/
|
||||||
|
|
||||||
|
if(ext->opened) lv_page_set_sb_mode(ddlist, LV_SB_MODE_UNHIDE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjusts the ddlist's height and then positions the option within it's new height.
|
||||||
|
* This keeps the option visible during animation.
|
||||||
|
* @param ddlist Drop down list object
|
||||||
|
* @param height New drop down list height
|
||||||
|
*/
|
||||||
|
static void lv_ddlist_adjust_height(lv_obj_t * ddlist, int32_t height) {
|
||||||
|
lv_obj_set_height(ddlist, height);
|
||||||
|
lv_ddlist_pos_current_option(ddlist);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the position of list when it is closed to show the selected item
|
* Set the position of list when it is closed to show the selected item
|
||||||
* @param ddlist pointer to a drop down list
|
* @param ddlist pointer to a drop down list
|
||||||
|
@ -53,6 +53,7 @@ typedef struct
|
|||||||
uint16_t sel_opt_id_ori; /*Store the original index on focus*/
|
uint16_t sel_opt_id_ori; /*Store the original index on focus*/
|
||||||
uint16_t anim_time; /*Open/Close animation time [ms]*/
|
uint16_t anim_time; /*Open/Close animation time [ms]*/
|
||||||
uint8_t opened :1; /*1: The list is opened (handled by the library)*/
|
uint8_t opened :1; /*1: The list is opened (handled by the library)*/
|
||||||
|
uint8_t force_sel :1; /*1: Keep the selection highlight even if the list is closed*/
|
||||||
uint8_t draw_arrow :1; /*1: Draw arrow*/
|
uint8_t draw_arrow :1; /*1: Draw arrow*/
|
||||||
uint8_t stay_open :1; /*1: Don't close the list when a new item is selected*/
|
uint8_t stay_open :1; /*1: Don't close the list when a new item is selected*/
|
||||||
lv_coord_t fix_height; /*Height of the ddlist when opened. (0: auto-size)*/
|
lv_coord_t fix_height; /*Height of the ddlist when opened. (0: auto-size)*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user