mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Merge pull request #1317 from littlevgl/dd_num_options
Add public API for retrieving option_cnt from ddlist/roller
This commit is contained in:
commit
c2d254ff2d
@ -375,6 +375,20 @@ uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist)
|
||||
return ext->sel_opt_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of options
|
||||
* @param ddlist pointer to drop down list object
|
||||
* @return the total number of options in the list
|
||||
*/
|
||||
uint16_t lv_ddlist_get_option_cnt(const lv_obj_t * ddlist)
|
||||
{
|
||||
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
|
||||
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
return ext->option_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current selected option as a string
|
||||
* @param ddlist pointer to ddlist object
|
||||
|
@ -176,6 +176,13 @@ const char * lv_ddlist_get_options(const lv_obj_t * ddlist);
|
||||
*/
|
||||
uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist);
|
||||
|
||||
/**
|
||||
* Get the total number of options
|
||||
* @param ddlist pointer to drop down list object
|
||||
* @return the total number of options in the list
|
||||
*/
|
||||
uint16_t lv_ddlist_get_option_cnt(const lv_obj_t * ddlist);
|
||||
|
||||
/**
|
||||
* Get the current selected option as a string
|
||||
* @param ddlist pointer to ddlist object
|
||||
|
@ -276,6 +276,24 @@ uint16_t lv_roller_get_selected(const lv_obj_t * roller)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of options
|
||||
* @param roller pointer to a roller object
|
||||
* @return the total number of options
|
||||
*/
|
||||
uint16_t lv_roller_get_option_cnt(const lv_obj_t * roller)
|
||||
{
|
||||
LV_ASSERT_OBJ(roller, LV_OBJX_NAME);
|
||||
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
if(ext->mode == LV_ROLLER_MODE_INIFINITE) {
|
||||
uint16_t real_id_cnt = ext->ddlist.option_cnt / LV_ROLLER_INF_PAGES;
|
||||
return real_id_cnt;
|
||||
} else {
|
||||
return ext->ddlist.option_cnt;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the align attribute. Default alignment after _create is LV_LABEL_ALIGN_CENTER
|
||||
* @param roller pointer to a roller object
|
||||
|
@ -146,6 +146,13 @@ void lv_roller_set_style(lv_obj_t * roller, lv_roller_style_t type, const lv_sty
|
||||
*/
|
||||
uint16_t lv_roller_get_selected(const lv_obj_t * roller);
|
||||
|
||||
/**
|
||||
* Get the total number of options
|
||||
* @param roller pointer to a roller object
|
||||
* @return the total number of options in the list
|
||||
*/
|
||||
uint16_t lv_roller_get_option_cnt(const lv_obj_t * roller);
|
||||
|
||||
/**
|
||||
* Get the current selected option as a string
|
||||
* @param roller pointer to roller object
|
||||
|
Loading…
x
Reference in New Issue
Block a user