1
0
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:
Gabor Kiss-Vamosi 2019-12-19 23:14:17 +01:00 committed by GitHub
commit c2d254ff2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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