Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bar): mask the brackground to fix it on value adjustment #5426

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/widgets/bar/lv_bar.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,17 +469,19 @@ static void draw_indic(lv_event_t * e)
*
*/

bool gradient = false;
if(hor && draw_rect_dsc.bg_grad.dir == LV_GRAD_DIR_HOR) gradient = true;
else if(!hor && draw_rect_dsc.bg_grad.dir == LV_GRAD_DIR_VER) gradient = true;
bool mask_needed = false;
if(hor && draw_rect_dsc.bg_grad.dir == LV_GRAD_DIR_HOR) mask_needed = true;
else if(!hor && draw_rect_dsc.bg_grad.dir == LV_GRAD_DIR_VER) mask_needed = true;

if(draw_rect_dsc.bg_image_src) mask_needed = true;

bool radius_issue = true;
/*The indicator is fully drawn if it's larger than the bg*/
if((bg_left < 0 || bg_right < 0 || bg_top < 0 || bg_bottom < 0)) radius_issue = false;
else if(indic_radius >= bg_radius) radius_issue = false;
else if(_lv_area_is_in(&indic_area, &bar_coords, bg_radius)) radius_issue = false;

if(radius_issue || gradient) {
if(radius_issue || mask_needed) {
if(!radius_issue) {
/*Draw only the shadow*/
lv_draw_rect_dsc_t draw_tmp_dsc = draw_rect_dsc;
Expand All @@ -495,14 +497,14 @@ static void draw_indic(lv_event_t * e)
}
draw_rect_dsc.shadow_opa = 0;

/*If clipped for any reason can the border, outline, and shadow
*would be clipped and looked ugly so don't draw them*/
/*If clipped for any reason cannot the border, outline, and shadow
*as they would be clipped and looked ugly*/
lv_draw_rect_dsc_t draw_tmp_dsc = draw_rect_dsc;
draw_tmp_dsc.border_opa = 0;
draw_tmp_dsc.outline_opa = 0;
draw_tmp_dsc.shadow_opa = 0;
lv_area_t indic_draw_area = indic_area;
if(gradient) {
if(mask_needed) {
if(hor) {
indic_draw_area.x1 = bar_coords.x1 + bg_left;
indic_draw_area.x2 = bar_coords.x2 - bg_right;
Expand All @@ -526,7 +528,7 @@ static void draw_indic(lv_event_t * e)
lv_draw_mask_rect(layer_indic, &mask_dsc);
}

if(gradient) {
if(mask_needed) {
mask_dsc.area = indic_area;
mask_dsc.radius = indic_radius;
lv_draw_mask_rect(layer_indic, &mask_dsc);
Expand Down
Loading