mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
lv_bar and lv_slider: fix indicator size at amy value
This commit is contained in:
parent
4cf6a4c22e
commit
a482132652
@ -317,11 +317,11 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
|
||||
lv_coord_t h = lv_area_get_height(&indic_area);
|
||||
|
||||
if(w >= h) {
|
||||
indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value);
|
||||
indic_area.x2 = indic_area.x1 + indic_area.x2;
|
||||
indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value);
|
||||
indic_area.x2 = indic_area.x1 + indic_area.x2 - 1;
|
||||
} else {
|
||||
indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value - 1)) / (ext->max_value - ext->min_value);
|
||||
indic_area.y1 = indic_area.y2 - indic_area.y1;
|
||||
indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value);
|
||||
indic_area.y1 = indic_area.y2 - indic_area.y1 + 1;
|
||||
}
|
||||
|
||||
/*Draw the indicator*/
|
||||
|
@ -349,12 +349,12 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig
|
||||
if(ext->drag_value != LV_SLIDER_NOT_PRESSED) cur_value = ext->drag_value;
|
||||
|
||||
if(slider_w >= slider_h) {
|
||||
area_indic.x2 = (int32_t)((int32_t)(lv_area_get_width(&area_indic) - 1) * (cur_value - min_value)) / (max_value - min_value);
|
||||
area_indic.x2 = area_indic.x1 + area_indic.x2;
|
||||
area_indic.x2 = (int32_t)((int32_t)(lv_area_get_width(&area_indic)) * (cur_value - min_value)) / (max_value - min_value);
|
||||
area_indic.x2 = area_indic.x1 + area_indic.x2 - 1;
|
||||
|
||||
} else {
|
||||
area_indic.y1 = (int32_t)((int32_t)(lv_area_get_height(&area_indic) - 1) * (cur_value - min_value)) / (max_value - min_value);
|
||||
area_indic.y1 = area_indic.y2 - area_indic.y1;
|
||||
area_indic.y1 = (int32_t)((int32_t)(lv_area_get_height(&area_indic)) * (cur_value - min_value)) / (max_value - min_value);
|
||||
area_indic.y1 = area_indic.y2 - area_indic.y1 + 1;
|
||||
}
|
||||
|
||||
if(cur_value != min_value) lv_draw_rect(&area_indic, mask, style_indic, opa_scale);
|
||||
|
Loading…
x
Reference in New Issue
Block a user