fix(roller) make lv_roller_set_visible_row_count consider border width
This commit is contained in:
@@ -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`.
|
`lv_roller_get_selected_str(roller, buf, buf_size)` copy the name of the selected option to `buf`.
|
||||||
|
|
||||||
### Visible rows
|
### 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
|
## Events
|
||||||
- `LV_EVENT_VALUE_CHANGED` Sent when a new option is selected.
|
- `LV_EVENT_VALUE_CHANGED` Sent when a new option is selected.
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ typedef enum {
|
|||||||
LV_STYLE_BORDER_COLOR = 48,
|
LV_STYLE_BORDER_COLOR = 48,
|
||||||
LV_STYLE_BORDER_COLOR_FILTERED = 48 | LV_STYLE_PROP_FILTER,
|
LV_STYLE_BORDER_COLOR_FILTERED = 48 | LV_STYLE_PROP_FILTER,
|
||||||
LV_STYLE_BORDER_OPA = 49,
|
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_SIDE = 51,
|
||||||
LV_STYLE_BORDER_POST = 52,
|
LV_STYLE_BORDER_POST = 52,
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
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_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*=====================
|
/*=====================
|
||||||
|
|||||||
Reference in New Issue
Block a user