1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

feat(dropdown) make the dropdown's list use the max_height style proeprty

Instead of a widget property
This commit is contained in:
Gabor Kiss-Vamosi 2021-05-03 17:34:15 +02:00
parent 05252b7fe8
commit 7b8de7af8a
2 changed files with 0 additions and 36 deletions

View File

@ -289,16 +289,6 @@ void lv_dropdown_set_dir(lv_obj_t * obj, lv_dir_t dir)
lv_obj_invalidate(obj);
}
void lv_dropdown_set_max_height(lv_obj_t * obj, lv_coord_t h)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_dropdown_t * dropdown = (lv_dropdown_t *)obj;
if(dropdown->max_height == h) return;
dropdown->max_height = h;
}
void lv_dropdown_set_symbol(lv_obj_t * obj, const void * symbol)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
@ -390,13 +380,6 @@ void lv_dropdown_get_selected_str(const lv_obj_t * obj, char * buf, uint32_t buf
buf[c] = '\0';
}
lv_coord_t lv_dropdown_get_max_height(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_dropdown_t * dropdown = (lv_dropdown_t *)obj;
return dropdown->max_height;
}
const char * lv_dropdown_get_symbol(lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
@ -453,7 +436,6 @@ void lv_dropdown_open(lv_obj_t * dropdown_obj)
lv_coord_t list_fit_h = label_h + top + bottom;
lv_coord_t list_h = list_fit_h;
if(list_h > dropdown->max_height) list_h = dropdown->max_height;
lv_dir_t dir = dropdown->dir;
/*No space on the bottom? See if top is better.*/
@ -484,8 +466,6 @@ void lv_dropdown_open(lv_obj_t * dropdown_obj)
}
if(list_h > list_fit_h) list_h = list_fit_h;
if(list_h > dropdown->max_height) list_h = dropdown->max_height;
lv_obj_set_height(dropdown->list, list_h);
position_to_selected(dropdown_obj);
@ -557,7 +537,6 @@ static void lv_dropdown_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
dropdown->pr_opt_id = LV_DROPDOWN_PR_NONE;
dropdown->option_cnt = 0;
dropdown->dir = LV_DIR_BOTTOM;
dropdown->max_height = (3 * lv_disp_get_ver_res(NULL)) / 4;
lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
lv_dropdown_set_options_static(obj, "Option 1\nOption 2\nOption 3");

View File

@ -41,7 +41,6 @@ typedef struct {
const char * text; /**< Text to display on the dropdown's button*/
const void * symbol; /**< Arrow or other icon when the drop-down list is closed*/
char * options; /**< Options in a a '\n' separated list*/
lv_coord_t max_height; /**< Maximal height of the list when opened. (0: no max. height)*/
uint16_t option_cnt; /**< Number of options*/
uint16_t sel_opt_id; /**< Index of the currently selected option*/
uint16_t sel_opt_id_orig; /**< Store the original index on focus*/
@ -127,13 +126,6 @@ void lv_dropdown_set_selected(lv_obj_t * obj, uint16_t sel_opt);
*/
void lv_dropdown_set_dir(lv_obj_t * obj, lv_dir_t dir);
/**
* Set the maximal height for the drop-down list
* @param obj pointer to a drop-down list
* @param h the maximal height
*/
void lv_dropdown_set_max_height(lv_obj_t * obj, lv_coord_t h);
/**
* Set an arrow or other symbol to display when on drop-down list's button. Typically a down caret or arrow.
* @param obj pointer to drop-down list object
@ -197,13 +189,6 @@ uint16_t lv_dropdown_get_option_cnt(const lv_obj_t * obj);
*/
void lv_dropdown_get_selected_str(const lv_obj_t * obj, char * buf, uint32_t buf_size);
/**
* Get the maximal height of the list.
* @param obj pointer to a drop-down list object
* @return the maximal height of the list
*/
lv_coord_t lv_dropdown_get_max_height(const lv_obj_t * obj);
/**
* Get the symbol on the drop-down list. Typically a down caret or arrow.
* @param obj pointer to drop-down list object