lv_list: api update

This commit is contained in:
Gabor Kiss-Vamosi
2017-11-07 14:31:35 +01:00
parent 0671556002
commit f7baf2716a
4 changed files with 322 additions and 175 deletions

View File

@@ -188,12 +188,12 @@ uint16_t lv_ddlist_get_anim_time(lv_obj_t * ddlist);
/** /**
* Set the scroll bar mode of a drop down list * Set the scroll bar mode of a drop down list
* @param ta pointer to a drop down list object * @param ddlist pointer to a drop down list object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum * @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
*/ */
static inline void lv_ddlist_set_sb_mode(lv_obj_t * ta, lv_page_sb_mode_t mode) static inline void lv_ddlist_set_sb_mode(lv_obj_t * ddlist, lv_page_sb_mode_t mode)
{ {
lv_page_set_sb_mode(ta, mode); lv_page_set_sb_mode(ddlist, mode);
} }
/** /**
@@ -201,9 +201,9 @@ static inline void lv_ddlist_set_sb_mode(lv_obj_t * ta, lv_page_sb_mode_t mode)
* @param ddlist pointer to a drop down list object * @param ddlist pointer to a drop down list object
* @return scrollbar mode from 'lv_page_sb_mode_t' enum * @return scrollbar mode from 'lv_page_sb_mode_t' enum
*/ */
static inline lv_page_sb_mode_t lv_ddlist_get_sb_mode(lv_obj_t * ta) static inline lv_page_sb_mode_t lv_ddlist_get_sb_mode(lv_obj_t * ddlist)
{ {
return lv_page_get_sb_mode(ta); return lv_page_get_sb_mode(ddlist);
} }
/** /**
@@ -218,7 +218,7 @@ static inline lv_style_t * lv_ddlist_get_style_bg(lv_obj_t * ddlist)
/** /**
* Get the style of the scrollbars of a drop down list * Get the style of the scrollbars of a drop down list
* @param ddlist pointer to a text area object * @param ddlist pointer to a drop down list object
* @return pointer to the style of the scrollbars * @return pointer to the style of the scrollbars
*/ */
static inline lv_style_t * lv_ddlist_get_style_sb(lv_obj_t * ddlist) static inline lv_style_t * lv_ddlist_get_style_sb(lv_obj_t * ddlist)

View File

@@ -29,11 +29,9 @@
/********************** /**********************
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
#if 0 static lv_res_t lv_list_signal(lv_obj_t *list, lv_signal_t sign, void *param);
static bool lv_list_design(lv_obj_t * list, const area_t * mask, lv_design_mode_t mode); static lv_obj_t * get_next_btn(lv_obj_t *list, lv_obj_t *prev_btn);
#endif static void refr_btn_width(lv_obj_t *list);
static lv_obj_t * lv_list_get_next_btn(lv_obj_t * list, lv_obj_t * prev_btn);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
@@ -77,6 +75,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
ext->styles_btn[LV_BTN_STATE_TGL_RELEASED] = &lv_style_btn_on_released; ext->styles_btn[LV_BTN_STATE_TGL_RELEASED] = &lv_style_btn_on_released;
ext->styles_btn[LV_BTN_STATE_PRESSED] = &lv_style_btn_on_pressed; ext->styles_btn[LV_BTN_STATE_PRESSED] = &lv_style_btn_on_pressed;
ext->styles_btn[LV_BTN_STATE_INACTIVE] = &lv_style_btn_inactive; ext->styles_btn[LV_BTN_STATE_INACTIVE] = &lv_style_btn_inactive;
ext->anim_time = LV_LIST_FOCUS_TIME;
lv_obj_set_signal_func(new_list, lv_list_signal); lv_obj_set_signal_func(new_list, lv_list_signal);
@@ -84,16 +83,26 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
if(copy == NULL) { if(copy == NULL) {
lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI); lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI);
lv_page_set_scrl_layout(new_list, LV_LIST_LAYOUT_DEF); lv_page_set_scrl_layout(new_list, LV_LIST_LAYOUT_DEF);
lv_list_set_style_bg(new_list, &lv_style_transp_fit, &lv_style_pretty, NULL); lv_list_set_style(new_list, &lv_style_transp_fit, &lv_style_pretty, NULL);
lv_page_set_sb_mode(new_list, LV_PAGE_SB_MODE_DRAG); lv_page_set_sb_mode(new_list, LV_PAGE_SB_MODE_DRAG);
} else { } else {
lv_list_ext_t * copy_ext = lv_obj_get_ext_attr(copy); lv_list_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_list_set_style_btn(new_list, copy_ext->styles_btn[LV_BTN_STATE_RELEASED], lv_list_set_style_btn(new_list, copy_ext->styles_btn[LV_BTN_STATE_RELEASED],
copy_ext->styles_btn[LV_BTN_STATE_PRESSED], copy_ext->styles_btn[LV_BTN_STATE_PRESSED],
copy_ext->styles_btn[LV_BTN_STATE_TGL_RELEASED], copy_ext->styles_btn[LV_BTN_STATE_TGL_RELEASED],
copy_ext->styles_btn[LV_BTN_STATE_TGL_PRESSED], copy_ext->styles_btn[LV_BTN_STATE_TGL_PRESSED],
copy_ext->styles_btn[LV_BTN_STATE_INACTIVE]); copy_ext->styles_btn[LV_BTN_STATE_INACTIVE]);
lv_obj_t *copy_btn = lv_obj_get_child_back(lv_page_get_scrl(copy), NULL);
lv_obj_t *new_btn;
while(copy_btn) {
new_btn = lv_btn_create(new_list, copy_btn);
lv_obj_t *copy_img = lv_list_get_btn_img(copy_btn);
if(copy_img) lv_img_create(new_btn, copy_img);
lv_label_create(new_btn, lv_list_get_btn_label(copy_btn));
copy_btn = lv_obj_get_child_back(lv_page_get_scrl(copy), copy_btn);
}
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(new_list); lv_obj_refresh_style(new_list);
@@ -102,101 +111,6 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
return new_list; return new_list;
} }
/**
* Signal function of the list
* @param list pointer to a list object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
{
bool valid;
/* Include the ancient signal function */
valid = ancestor_signal(list, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
if(sign == LV_SIGNAL_FOCUS) {
/*Get the first button*/
lv_obj_t * btn = NULL;
lv_obj_t * btn_prev = NULL;
btn = lv_list_get_next_btn(list, btn);
while(btn != NULL) {
btn_prev = btn;
btn = lv_list_get_next_btn(list, btn);
}
if(btn_prev != NULL) {
lv_btn_set_state(btn_prev, LV_BTN_STATE_PRESSED);
}
} else if(sign == LV_SIGNAL_DEFOCUS) {
/*Get the 'pressed' button*/
lv_obj_t * btn = NULL;
btn = lv_list_get_next_btn(list, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PRESSED) break;
btn = lv_list_get_next_btn(list, btn);
}
if(btn != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_RELEASED);
}
} else if(sign == LV_SIGNAL_CONTROLL) {
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
/*Get the last pressed button*/
lv_obj_t * btn = NULL;
lv_obj_t * btn_prev = NULL;
btn = lv_list_get_next_btn(list, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PRESSED) break;
btn_prev = btn;
btn = lv_list_get_next_btn(list, btn);
}
if(btn_prev != NULL && btn != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_RELEASED);
lv_btn_set_state(btn_prev, LV_BTN_STATE_PRESSED);
lv_page_focus(list, btn_prev, LV_LIST_FOCUS_TIME);
}
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
/*Get the last pressed button*/
lv_obj_t * btn = NULL;
btn = lv_list_get_next_btn(list, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PRESSED) break;
btn = lv_list_get_next_btn(list, btn);
}
if(btn != NULL) {
lv_obj_t * btn_prev = lv_list_get_next_btn(list, btn);
if(btn_prev != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_RELEASED);
lv_btn_set_state(btn_prev, LV_BTN_STATE_PRESSED);
lv_page_focus(list, btn_prev, LV_LIST_FOCUS_TIME);
}
}
} else if(c == LV_GROUP_KEY_ENTER) {
/*Get the 'pressed' button*/
lv_obj_t * btn = NULL;
btn = lv_list_get_next_btn(list, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PRESSED) break;
btn = lv_list_get_next_btn(list, btn);
}
if(btn != NULL) {
lv_action_t rel_action;
rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_RELEASE);
if(rel_action != NULL) rel_action(btn);
}
}
}
}
return valid;
}
/** /**
* Add a list element to the list * Add a list element to the list
* @param list pointer to list object * @param list pointer to list object
@@ -264,14 +178,56 @@ void lv_list_up(lv_obj_t * list)
lv_obj_t * scrl = lv_page_get_scrl(list); lv_obj_t * scrl = lv_page_get_scrl(list);
lv_obj_t * e; lv_obj_t * e;
lv_obj_t * e_prev = NULL; lv_obj_t * e_prev = NULL;
e = lv_list_get_next_btn(list, NULL); e = get_next_btn(list, NULL);
while(e != NULL) { while(e != NULL) {
if(e->coords.y2 <= list->coords.y2) { if(e->coords.y2 <= list->coords.y2) {
if(e_prev != NULL) { if(e_prev != NULL) {
cord_t new_y = lv_obj_get_height(list) - (lv_obj_get_y(e_prev) + lv_obj_get_height(e_prev)); cord_t new_y = lv_obj_get_height(list) - (lv_obj_get_y(e_prev) + lv_obj_get_height(e_prev));
#if LV_LIST_FOCUS_TIME == 0 lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
lv_obj_set_y(scrl, new_y); if(ext->anim_time == 0) {
#else lv_obj_set_y(scrl, new_y);
} else {
anim_t a;
a.var = scrl;
a.start = lv_obj_get_y(scrl);
a.end = new_y;
a.fp = (anim_fp_t)lv_obj_set_y;
a.path = anim_get_path(ANIM_PATH_LIN);
a.end_cb = NULL;
a.act_time = 0;
a.time = LV_LIST_FOCUS_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
anim_create(&a);
}
}
break;
}
e_prev = e;
e = get_next_btn(list, e);
}
}
/**
* Move the list elements down by one
* @param list pointer to a list object
*/
void lv_list_down(lv_obj_t * list)
{
/*Search the first list element which 'y' coordinate is above the parent
* and position the list to show this element on the top*/
lv_obj_t * scrl = lv_page_get_scrl(list);
lv_obj_t * e;
e = get_next_btn(list, NULL);
while(e != NULL) {
if(e->coords.y1 < list->coords.y1) {
cord_t new_y = -lv_obj_get_y(e);
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
if(ext->anim_time == 0) {
lv_obj_set_y(scrl, new_y);
} else {
anim_t a; anim_t a;
a.var = scrl; a.var = scrl;
a.start = lv_obj_get_y(scrl); a.start = lv_obj_get_y(scrl);
@@ -286,51 +242,23 @@ void lv_list_up(lv_obj_t * list)
a.repeat = 0; a.repeat = 0;
a.repeat_pause = 0; a.repeat_pause = 0;
anim_create(&a); anim_create(&a);
#endif }
}
break; break;
} }
e_prev = e; e = get_next_btn(list, e);
e = lv_list_get_next_btn(list, e);
} }
} }
/** /**
* Move the list elements down by one * Focus on a list button. It ensures that the button will be visible on the list.
* @param list pointer to a list object * @param btn pointer to a list button to focus
* @param anim_en true: scroll with animation, false: without animation
*/ */
void lv_list_down(lv_obj_t * list) void lv_list_focus(lv_obj_t *btn, bool anim_en)
{ {
/*Search the first list element which 'y' coordinate is above the parent lv_obj_t *list = lv_obj_get_parent(lv_obj_get_parent(btn));
* and position the list to show this element on the top*/
lv_obj_t * scrl = lv_page_get_scrl(list); lv_page_focus(list, btn, anim_en == false ? 0 :lv_list_get_anim_time(list));
lv_obj_t * e;
e = lv_list_get_next_btn(list, NULL);
while(e != NULL) {
if(e->coords.y1 < list->coords.y1) {
cord_t new_y = -lv_obj_get_y(e);
#if LV_LIST_FOCUS_TIME == 0
lv_obj_set_y(scrl, new_y);
#else
anim_t a;
a.var = scrl;
a.start = lv_obj_get_y(scrl);
a.end = new_y;
a.fp = (anim_fp_t)lv_obj_set_y;
a.path = anim_get_path(ANIM_PATH_LIN);
a.end_cb = NULL;
a.act_time = 0;
a.time = LV_LIST_FOCUS_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
anim_create(&a);
#endif
break;
}
e = lv_list_get_next_btn(list, e);
}
} }
/*===================== /*=====================
@@ -359,14 +287,25 @@ void lv_list_set_style_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr,
if(ina != NULL) ext->styles_btn[LV_BTN_STATE_INACTIVE] = ina; if(ina != NULL) ext->styles_btn[LV_BTN_STATE_INACTIVE] = ina;
/*Refresh all existing buttons*/ /*Refresh all existing buttons*/
lv_obj_t * liste = lv_list_get_next_btn(list, NULL); lv_obj_t * liste = get_next_btn(list, NULL);
while(liste != NULL) while(liste != NULL)
{ {
lv_btn_set_style(liste, rel, pr, tgl_rel, tgl_pr, ina); lv_btn_set_style(liste, rel, pr, tgl_rel, tgl_pr, ina);
liste = lv_list_get_next_btn(list, liste); liste = get_next_btn(list, liste);
} }
} }
/**
* Set scroll animation duration on 'list_up()' 'list_down()' 'list_focus()'
* @param list pointer to a list object
* @param anim_time duration of animation [ms]
*/
void lv_list_set_anim_time(lv_obj_t *list, uint16_t anim_time)
{
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
ext->anim_time = anim_time;
}
/*===================== /*=====================
* Getter functions * Getter functions
*====================*/ *====================*/
@@ -438,17 +377,141 @@ lv_style_t * lv_list_get_style_btn(lv_obj_t * list, lv_btn_state_t state)
return ext->styles_btn[state]; return ext->styles_btn[state];
} }
/**
* Get scroll animation duration
* @param list pointer to a list object
* @return duration of animation [ms]
*/
uint16_t lv_list_get_anim_time(lv_obj_t *list)
{
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
return ext->anim_time;
}
/********************** /**********************
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/
/**
* Signal function of the list
* @param list pointer to a list object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
{
lv_res_t res;
/* Include the ancient signal function */
res = ancestor_signal(list, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(res == LV_RES_OK) {
if(sign == LV_SIGNAL_CORD_CHG) {
/*Be sure the width of the buttons are correct*/
cord_t w = lv_obj_get_width(list);
if(w != area_get_width(param)) { /*Width changed*/
refr_btn_width(list);
}
}
else if(sign == LV_SIGNAL_STYLE_CHG) {
/*Because of the possible change of horizontal and vertical padding refresh buttons width */
refr_btn_width(list);
}
else if(sign == LV_SIGNAL_FOCUS) {
/*Get the first button*/
lv_obj_t * btn = NULL;
lv_obj_t * btn_prev = NULL;
btn = get_next_btn(list, btn);
while(btn != NULL) {
btn_prev = btn;
btn = get_next_btn(list, btn);
}
if(btn_prev != NULL) {
lv_btn_set_state(btn_prev, LV_BTN_STATE_PRESSED);
}
}
else if(sign == LV_SIGNAL_DEFOCUS) {
/*Get the 'pressed' button*/
lv_obj_t * btn = NULL;
btn = get_next_btn(list, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PRESSED) break;
btn = get_next_btn(list, btn);
}
if(btn != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_RELEASED);
}
}
else if(sign == LV_SIGNAL_CONTROLL) {
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
/*Get the last pressed button*/
lv_obj_t * btn = NULL;
lv_obj_t * btn_prev = NULL;
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
btn = get_next_btn(list, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PRESSED) break;
btn_prev = btn;
btn = get_next_btn(list, btn);
}
if(btn_prev != NULL && btn != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_RELEASED);
lv_btn_set_state(btn_prev, LV_BTN_STATE_PRESSED);
lv_page_focus(list, btn_prev, ext->anim_time);
}
}
else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
/*Get the last pressed button*/
lv_obj_t * btn = NULL;
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
btn = get_next_btn(list, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PRESSED) break;
btn = get_next_btn(list, btn);
}
if(btn != NULL) {
lv_obj_t * btn_prev = get_next_btn(list, btn);
if(btn_prev != NULL) {
lv_btn_set_state(btn, LV_BTN_STATE_RELEASED);
lv_btn_set_state(btn_prev, LV_BTN_STATE_PRESSED);
lv_page_focus(list, btn_prev, ext->anim_time);
}
}
} else if(c == LV_GROUP_KEY_ENTER) {
/*Get the 'pressed' button*/
lv_obj_t * btn = NULL;
btn = get_next_btn(list, btn);
while(btn != NULL) {
if(lv_btn_get_state(btn) == LV_BTN_STATE_PRESSED) break;
btn = get_next_btn(list, btn);
}
if(btn != NULL) {
lv_action_t rel_action;
rel_action = lv_btn_get_action(btn, LV_BTN_ACTION_RELEASE);
if(rel_action != NULL) rel_action(btn);
}
}
}
}
return res;
}
/** /**
* Get the next button from list * Get the next button from list
* @param list pointer to a list object * @param list pointer to a list object
* @param prev_btn pointer to button. Search the next after it. * @param prev_btn pointer to button. Search the next after it.
* @return pointer to the next button or NULL * @return pointer to the next button or NULL
*/ */
static lv_obj_t * lv_list_get_next_btn(lv_obj_t * list, lv_obj_t * prev_btn) static lv_obj_t * get_next_btn(lv_obj_t * list, lv_obj_t * prev_btn)
{ {
/* Not a good practice but user can add/create objects to the lists manually. /* Not a good practice but user can add/create objects to the lists manually.
* When getting the next button try to be sure that it is at least a button */ * When getting the next button try to be sure that it is at least a button */
@@ -467,4 +530,26 @@ static lv_obj_t * lv_list_get_next_btn(lv_obj_t * list, lv_obj_t * prev_btn)
return btn; return btn;
} }
static void refr_btn_width(lv_obj_t *list)
{
lv_style_t *style = lv_list_get_style_bg(list);
lv_style_t *style_scrl = lv_obj_get_style(lv_page_get_scrl(list));
cord_t w = lv_obj_get_width(list);
cord_t btn_w = w - (style->body.padding.hor + style_scrl->body.padding.hor) * 2;
lv_obj_t *btn = get_next_btn(list, NULL);
while(btn) {
/*Make the size adjustment for each buttons*/
if(lv_obj_get_width(btn) != btn_w) {
lv_obj_set_width(btn, btn_w);
/*Set the label size to roll its text*/
lv_obj_t *label = lv_list_get_btn_label(btn);
lv_obj_set_width(label, btn->coords.x2 - label->coords.x1);
lv_label_set_text(label, NULL);
}
btn = get_next_btn(list, btn);
}
}
#endif #endif

View File

@@ -48,8 +48,9 @@ typedef struct
{ {
lv_page_ext_t page; /*Ext. of ancestor*/ lv_page_ext_t page; /*Ext. of ancestor*/
/*New data for this type */ /*New data for this type */
uint16_t anim_time; /*Scroll animation time*/
lv_style_t *styles_btn[LV_BTN_STATE_NUM]; /*Styles of the list element buttons*/ lv_style_t *styles_btn[LV_BTN_STATE_NUM]; /*Styles of the list element buttons*/
lv_style_t *style_img; /*Style of the list element images on buttons*/ lv_style_t *style_img; /*Style of the list element images on buttons*/
}lv_list_ext_t; }lv_list_ext_t;
/********************** /**********************
@@ -62,15 +63,7 @@ typedef struct
* @param copy pointer to a list object, if not NULL then the new object will be copied from it * @param copy pointer to a list object, if not NULL then the new object will be copied from it
* @return pointer to the created list * @return pointer to the created list
*/ */
lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy); lv_obj_t * lv_list_create(lv_obj_t *par, lv_obj_t * copy);
/**
* Signal function of the list
* @param list pointer to a list object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
/** /**
* Add a list element to the list * Add a list element to the list
@@ -80,27 +73,26 @@ bool lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
* @param rel_action pointer to release action function (like with lv_btn) * @param rel_action pointer to release action function (like with lv_btn)
* @return pointer to the new list element which can be customized (a button) * @return pointer to the new list element which can be customized (a button)
*/ */
lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, lv_action_t rel_action); lv_obj_t * lv_list_add(lv_obj_t *list, const char * img_fn, const char * txt, lv_action_t rel_action);
/** /**
* Move the list elements up by one * Move the list elements up by one
* @param list pointer a to list object * @param list pointer a to list object
*/ */
void lv_list_up(lv_obj_t * list); void lv_list_up(lv_obj_t *list);
/** /**
* Move the list elements down by one * Move the list elements down by one
* @param list pointer to a list object * @param list pointer to a list object
*/ */
void lv_list_down(lv_obj_t * list); void lv_list_down(lv_obj_t *list);
/** /**
* Enable/Disable to scrollbar outside attribute * Focus on a list button. It ensures that the button will be visible on the list.
* @param list pointer to list object * @param btn pointer to a list button to focus
* @param out true: reduce the buttons width therefore scroll bar will be out of the buttons, * @param anim_en true: scroll with animation, false: without animation
* false: keep button size and place scroll bar on the buttons
*/ */
void lv_list_set_sscrollbar_out(lv_obj_t * list, bool out); void lv_list_focus(lv_obj_t *btn, bool anim_en);
/** /**
* Set styles of the list elements of a list in each state * Set styles of the list elements of a list in each state
@@ -115,6 +107,13 @@ void lv_list_set_style_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr,
lv_style_t * trel, lv_style_t * tpr, lv_style_t * trel, lv_style_t * tpr,
lv_style_t * ina); lv_style_t * ina);
/**
* Set scroll animation duration on 'list_up()' 'list_down()' 'list_focus()'
* @param list pointer to a list object
* @param anim_time duration of animation [ms]
*/
void lv_list_set_anim_time(lv_obj_t *list, uint16_t anim_time);
/** /**
* Get the text of a list element * Get the text of a list element
* @param liste pointer to list element * @param liste pointer to list element
@@ -149,7 +148,14 @@ bool lv_list_get_sb_out(lv_obj_t * list, bool en);
* @param state a state from 'lv_btn_state_t' in which style should be get * @param state a state from 'lv_btn_state_t' in which style should be get
* @return pointer to the style in the given state * @return pointer to the style in the given state
*/ */
lv_style_t * lv_list_get_style_btne(lv_obj_t * list, lv_btn_state_t state); lv_style_t * lv_list_get_style_btn(lv_obj_t * list, lv_btn_state_t state);
/**
* Get scroll animation duration
* @param list pointer to a list object
* @return duration of animation [ms]
*/
uint16_t lv_list_get_anim_time(lv_obj_t *list);
/**************************** /****************************
* TRANSPARENT API FUNCTIONS * TRANSPARENT API FUNCTIONS
@@ -162,11 +168,62 @@ lv_style_t * lv_list_get_style_btne(lv_obj_t * list, lv_btn_state_t state);
* @param scrl pointer to a style for the scrollable area * @param scrl pointer to a style for the scrollable area
* @param sb pointer to a style for the scroll bars * @param sb pointer to a style for the scroll bars
*/ */
static inline void lv_list_set_style_bg(lv_obj_t *list, lv_style_t *bg, lv_style_t *scrl, lv_style_t *sb) static inline void lv_list_set_style(lv_obj_t *list, lv_style_t *bg, lv_style_t *scrl, lv_style_t *sb)
{ {
lv_page_set_style(list, bg, scrl, sb); lv_page_set_style(list, bg, scrl, sb);
} }
/**
* Set the scroll bar mode of a list
* @param list pointer to a list object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
*/
static inline void lv_list_set_sb_mode(lv_obj_t * list, lv_page_sb_mode_t mode)
{
lv_page_set_sb_mode(list, mode);
}
/**
* Get the scroll bar mode of a list
* @param list pointer to a list object
* @return scrollbar mode from 'lv_page_sb_mode_t' enum
*/
static inline lv_page_sb_mode_t lv_list_get_sb_mode(lv_obj_t * list)
{
return lv_page_get_sb_mode(list);
}
/**
* Get a style of a list's background
* @param list pointer to a list object
* @return pointer to the background's style
*/
static inline lv_style_t * lv_list_get_style_bg(lv_obj_t *list)
{
return lv_page_get_style_bg(list);
}
/**
* Get a style of a list's scrollable part
* @param list pointer to a list object
* @return pointer to the scrollable"s style
*/
static inline lv_style_t * lv_list_get_style_scrl(lv_obj_t *list)
{
return lv_page_get_style_scrl(list);
}
/**
* Get the style of the scrollbars of a list
* @param list pointer to a list object
* @return pointer to the style of the scrollbars
*/
static inline lv_style_t * lv_list_get_style_sb(lv_obj_t *list)
{
return lv_page_get_style_sb(list);
}
/********************** /**********************
* MACROS * MACROS
**********************/ **********************/

View File

@@ -173,6 +173,11 @@ void lv_page_set_style(lv_obj_t *page, lv_style_t *bg, lv_style_t *scrl, lv_styl
area_set_height(&ext->sb.hor_area, ext->sb.style->body.padding.inner); area_set_height(&ext->sb.hor_area, ext->sb.style->body.padding.inner);
area_set_width(&ext->sb.ver_area, ext->sb.style->body.padding.inner); area_set_width(&ext->sb.ver_area, ext->sb.style->body.padding.inner);
lv_page_sb_refresh(page); lv_page_sb_refresh(page);
if(bg == NULL) {
/*If scrollbars are positioned out of page then ext. size is needed to draw it*/
/*Page's style change signal will handle it but if no bg. style specified do it manually*/
lv_obj_refresh_ext_size(page);
}
lv_obj_invalidate(page); lv_obj_invalidate(page);
} }
if(scrl != NULL) lv_obj_set_style(ext->scrl, scrl); if(scrl != NULL) lv_obj_set_style(ext->scrl, scrl);