mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
theme and minor drawin fixes
This commit is contained in:
parent
37cd768e99
commit
5001c4e6a9
@ -2442,7 +2442,7 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
lv_draw_mask_radius_param_t * mp = lv_draw_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
||||
|
||||
lv_draw_mask_radius_init(mp, &obj->coords, style->body.radius, false);
|
||||
/*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be sued by the user*/
|
||||
/*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/
|
||||
lv_draw_mask_add(mp, obj + 8);
|
||||
}
|
||||
}
|
||||
|
@ -413,21 +413,21 @@ static lv_design_res_t lv_bar_design(lv_obj_t * bar, const lv_area_t * clip_area
|
||||
static void draw_bg(lv_obj_t * bar, const lv_area_t * clip_area, lv_design_mode_t mode, lv_opa_t opa)
|
||||
{
|
||||
|
||||
const lv_style_t * style_bg = lv_bar_get_style(bar, LV_BAR_STYLE_BG);
|
||||
#if LV_USE_GROUP == 0
|
||||
/*Simply draw the background*/
|
||||
ancestor_design_f(bar, mask, mode);
|
||||
lv_draw_rect(&bar->coords, clip_area, style_bg, opa);
|
||||
#else
|
||||
/* Draw the borders later if the bar is focused.
|
||||
* At value = 100% the indicator can cover to whole background and the focused style won't
|
||||
* be visible*/
|
||||
if(lv_obj_is_focused(bar)) {
|
||||
const lv_style_t * style_bg = lv_bar_get_style(bar, LV_BAR_STYLE_BG);
|
||||
lv_style_t style_tmp;
|
||||
lv_style_copy(&style_tmp, style_bg);
|
||||
style_tmp.body.border.width = 0;
|
||||
lv_draw_rect(&bar->coords, clip_area, &style_tmp, opa);
|
||||
} else {
|
||||
ancestor_design_f(bar, clip_area, mode);
|
||||
lv_draw_rect(&bar->coords, clip_area, style_bg, opa);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -526,11 +526,6 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area, lv_design_mo
|
||||
/*Do not draw a zero length indicator*/
|
||||
if(!sym && indic_length == 0) return;
|
||||
|
||||
/*If the indicator has a gradient along the longed side,
|
||||
* mask out only the current indicator area from the big gradient.*/
|
||||
if((style_indic->body.main_color.full != style_indic->body.grad_color.full) &&
|
||||
((objw > objh && style_indic->body.grad_dir == LV_GRAD_DIR_HOR) ||
|
||||
(objh > objw && style_indic->body.grad_dir == LV_GRAD_DIR_VER))) {
|
||||
|
||||
lv_style_t style_indic_tmp;
|
||||
lv_style_copy(&style_indic_tmp, style_indic);
|
||||
@ -541,6 +536,10 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area, lv_design_mo
|
||||
lv_draw_rect(&ext->indic_area, clip_area, &style_indic_tmp, opa);
|
||||
|
||||
/*Draw_only the background*/
|
||||
style_indic_tmp.body.shadow.width = 0;
|
||||
style_indic_tmp.body.border.width = style_indic->body.border.width;
|
||||
style_indic_tmp.body.opa = style_indic->body.opa;
|
||||
|
||||
/*Get the max possible indicator area. The gradient should be applied on this*/
|
||||
lv_area_t mask_indic_max_area;
|
||||
lv_area_copy(&mask_indic_max_area, &bar->coords);
|
||||
@ -553,23 +552,8 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area, lv_design_mo
|
||||
lv_draw_mask_radius_param_t mask_indic_param;
|
||||
lv_draw_mask_radius_init(&mask_indic_param, &ext->indic_area, style_indic->body.radius, false);
|
||||
int16_t mask_indic_id = lv_draw_mask_add(&mask_indic_param, NULL);
|
||||
|
||||
style_indic_tmp.body.shadow.width = 0;
|
||||
style_indic_tmp.body.opa = style_indic->body.opa;
|
||||
lv_draw_rect(&mask_indic_max_area, clip_area, &style_indic_tmp, opa);
|
||||
|
||||
lv_draw_mask_remove_id(mask_indic_id);
|
||||
|
||||
/*Draw only the border*/
|
||||
style_indic_tmp.body.opa = LV_OPA_TRANSP;
|
||||
style_indic_tmp.body.border.width = style_indic->body.border.width;
|
||||
lv_draw_rect(&ext->indic_area, clip_area, &style_indic_tmp, opa);
|
||||
|
||||
}
|
||||
/*If the gradient is along the short side, simply draw a rectangle.*/
|
||||
else {
|
||||
lv_draw_rect(&ext->indic_area, clip_area, style_indic, opa);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -264,6 +264,7 @@ static lv_design_res_t lv_slider_design(lv_obj_t * slider, const lv_area_t * cli
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
return ancestor_design_f(slider, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DESIGN_RES_OK;
|
||||
|
@ -311,10 +311,16 @@ static lv_design_res_t lv_sw_design(lv_obj_t * sw, const lv_area_t * clip_area,
|
||||
knob_area.y1 = sw->coords.y1;
|
||||
knob_area.y2 = sw->coords.y2;
|
||||
|
||||
knob_area.x1 -= style_knob->body.padding.left;
|
||||
knob_area.x2 += style_knob->body.padding.right;
|
||||
knob_area.y1 -= style_knob->body.padding.top;
|
||||
knob_area.y2 += style_knob->body.padding.bottom;
|
||||
|
||||
lv_draw_rect(&knob_area, clip_area, style_knob, opa_scale);
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
return ancestor_design(sw, clip_area, mode);
|
||||
}
|
||||
|
||||
return LV_DESIGN_RES_OK;
|
||||
|
@ -254,6 +254,10 @@ static void slider_init(void)
|
||||
knob.body.border.width = 0;
|
||||
knob.body.main_color = theme.style.bar.indic->body.main_color;
|
||||
knob.body.grad_color = knob.body.main_color;
|
||||
knob.body.padding.left = LV_DPI/25;
|
||||
knob.body.padding.right = LV_DPI/25;
|
||||
knob.body.padding.top = LV_DPI/25;
|
||||
knob.body.padding.bottom = LV_DPI/25;
|
||||
|
||||
theme.style.slider.bg = theme.style.bar.bg;
|
||||
theme.style.slider.indic = theme.style.bar.indic;
|
||||
@ -758,6 +762,7 @@ static void table_init(void)
|
||||
cell.body.padding.right = LV_DPI / 12;
|
||||
cell.body.padding.top = LV_DPI / 12;
|
||||
cell.body.padding.bottom = LV_DPI / 12;
|
||||
cell.body.shadow.width = 0;
|
||||
|
||||
theme.style.table.bg = &lv_style_transp_tight;
|
||||
theme.style.table.cell = &cell;
|
||||
|
@ -217,6 +217,7 @@ static void bar_init(void)
|
||||
bar_bg.body.padding.top = LV_DPI / 16;
|
||||
bar_bg.body.padding.bottom = LV_DPI / 16;
|
||||
bar_bg.body.radius = LV_RADIUS_CIRCLE;
|
||||
bar_bg.body.corner_mask = 1;
|
||||
|
||||
lv_style_copy(&bar_indic, &def);
|
||||
bar_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 80, 70);
|
||||
@ -241,6 +242,10 @@ static void slider_init(void)
|
||||
static lv_style_t slider_knob;
|
||||
lv_style_copy(&slider_knob, theme.style.btn.rel);
|
||||
slider_knob.body.radius = LV_RADIUS_CIRCLE;
|
||||
slider_knob.body.padding.left = LV_DPI/25;
|
||||
slider_knob.body.padding.right = LV_DPI/25;
|
||||
slider_knob.body.padding.top = LV_DPI/25;
|
||||
slider_knob.body.padding.bottom = LV_DPI/25;
|
||||
|
||||
theme.style.slider.bg = theme.style.bar.bg;
|
||||
theme.style.slider.indic = theme.style.bar.indic;
|
||||
|
Loading…
x
Reference in New Issue
Block a user