diff --git a/docs/widgets/core/roller.md b/docs/widgets/core/roller.md index 33dfe042a..8588c7a11 100644 --- a/docs/widgets/core/roller.md +++ b/docs/widgets/core/roller.md @@ -28,7 +28,9 @@ The get the currently selected option use `lv_roller_get_selected(roller)` it wi `lv_roller_get_selected_str(roller, buf, buf_size)` copy the name of the selected option to `buf`. ### Visible rows -The number of visible rows can be adjusted with `lv_roller_set_visible_row_count(roller, num)` +The number of visible rows can be adjusted with `lv_roller_set_visible_row_count(roller, num)`. + +This function calculates the height with the current style. If the font, line space, border width, etc of the roller changes this function needs to be called again. ## Events - `LV_EVENT_VALUE_CHANGED` Sent when a new option is selected. diff --git a/src/misc/lv_style.h b/src/misc/lv_style.h index ed0eb4c83..72fb5512c 100644 --- a/src/misc/lv_style.h +++ b/src/misc/lv_style.h @@ -175,7 +175,7 @@ typedef enum { LV_STYLE_BORDER_COLOR = 48, LV_STYLE_BORDER_COLOR_FILTERED = 48 | LV_STYLE_PROP_FILTER, LV_STYLE_BORDER_OPA = 49, - LV_STYLE_BORDER_WIDTH = 50, + LV_STYLE_BORDER_WIDTH = 50 | LV_STYLE_PROP_LAYOUT_REFR, LV_STYLE_BORDER_SIDE = 51, LV_STYLE_BORDER_POST = 52, diff --git a/src/widgets/lv_roller.c b/src/widgets/lv_roller.c index 09e31e0fb..21b9d7723 100644 --- a/src/widgets/lv_roller.c +++ b/src/widgets/lv_roller.c @@ -190,7 +190,8 @@ void lv_roller_set_visible_row_count(lv_obj_t * obj, uint8_t row_cnt) const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN); lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); - lv_obj_set_height(obj, (lv_font_get_line_height(font) + line_space) * row_cnt); + lv_coord_t border_width = lv_obj_get_style_border_width(obj, LV_PART_MAIN); + lv_obj_set_height(obj, (lv_font_get_line_height(font) + line_space) * row_cnt + 2 * border_width); } /*=====================