mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-21 06:53:01 +08:00
shadow draw fixes
This commit is contained in:
parent
41074a88b8
commit
88e88d7ca7
@ -2189,7 +2189,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||
lv_coord_t shadow = (style->body.shadow.width >> 1) + 1;
|
||||
shadow += style->body.shadow.spread;
|
||||
shadow += LV_MATH_MAX(style->body.shadow.offset.x, style->body.shadow.offset.y);
|
||||
shadow += LV_MATH_MAX(LV_MATH_ABS(style->body.shadow.offset.x), LV_MATH_ABS(style->body.shadow.offset.y));
|
||||
|
||||
if(shadow > obj->ext_draw_pad) obj->ext_draw_pad = shadow;
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
|
@ -177,11 +177,11 @@ void lv_style_init(void)
|
||||
lv_style_btn_rel.body.border.width = 2;//LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
|
||||
lv_style_btn_rel.body.border.opa = LV_OPA_10;
|
||||
lv_style_btn_rel.body.shadow.color = LV_COLOR_BLACK;
|
||||
lv_style_btn_rel.body.shadow.width = 20;
|
||||
lv_style_btn_rel.body.shadow.spread = 10;
|
||||
lv_style_btn_rel.body.shadow.width = 0;
|
||||
lv_style_btn_rel.body.shadow.spread = 6;
|
||||
lv_style_btn_rel.body.shadow.opa = LV_OPA_50;
|
||||
lv_style_btn_rel.body.shadow.offset.x = 5;
|
||||
lv_style_btn_rel.body.shadow.offset.y = 20;
|
||||
lv_style_btn_rel.body.shadow.offset.x = 8;
|
||||
lv_style_btn_rel.body.shadow.offset.y = 10;
|
||||
lv_style_btn_rel.text.color = lv_color_make(0xff, 0xff, 0xff);
|
||||
lv_style_btn_rel.image.color = lv_color_make(0xff, 0xff, 0xff);
|
||||
|
||||
|
@ -612,11 +612,20 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, const
|
||||
}
|
||||
|
||||
/*Fill the top side*/
|
||||
|
||||
a.x1 = sh_area.x1 + corner_size;
|
||||
a.x2 = sh_area.x2 - corner_size;
|
||||
a.y1 = sh_area.y1;
|
||||
a.y2 = a.y1;
|
||||
if(a.x1 < a.x2) {
|
||||
|
||||
|
||||
first_px = 0;
|
||||
if(disp_area->x1 > a.x1) {
|
||||
first_px = disp_area->x1 - a.x1;
|
||||
a.x1 += first_px;
|
||||
}
|
||||
|
||||
if(a.x1 <= a.x2) {
|
||||
|
||||
sh_buf_tmp = sh_buf + corner_size - 1;
|
||||
|
||||
@ -645,7 +654,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, const
|
||||
}
|
||||
|
||||
/*Fill the bottom side*/
|
||||
lv_coord_t y_min = corner_size - (sh_area.y2 - coords->y2);
|
||||
lv_coord_t y_min = simple_mode ? (corner_size - (sh_area.y2 - coords->y2)) : 0;
|
||||
if(y_min < 0) y_min = 0;
|
||||
sh_buf_tmp = sh_buf + corner_size * (corner_size - y_min - 1 ) + corner_size - 1;
|
||||
|
||||
@ -674,11 +683,11 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, const
|
||||
|
||||
/*Finally fill the middle area*/
|
||||
if(simple_mode == false) {
|
||||
a.x1 = sh_area.x1 + corner_size;
|
||||
a.x2 = sh_area.x2 - corner_size;
|
||||
// a.x1 = sh_area.x1 + corner_size + first_px;
|
||||
// a.x2 = sh_area.x2 - corner_size;
|
||||
a.y1 = sh_area.y1 + corner_size;
|
||||
a.y2 = a.y1;
|
||||
|
||||
if(a.x1 <= a.x2) {
|
||||
for(y = 0; y < lv_area_get_height(&sh_area) - corner_size * 2; y++) {
|
||||
memset(mask_buf, 0xFF, lv_area_get_width(&a));
|
||||
mask_res = lv_mask_apply(mask_buf, a.x1, a.y1, lv_area_get_width(&a));
|
||||
@ -689,6 +698,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, const
|
||||
a.y2++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lv_mask_remove_id(mask_rout_id);
|
||||
|
||||
@ -699,11 +709,9 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, const
|
||||
|
||||
static void shadow_draw_corner_buf(const lv_area_t * coords, lv_opa_t * sh_buf, lv_coord_t sw, lv_coord_t r)
|
||||
{
|
||||
|
||||
|
||||
if(sw == 0) sw = 1;
|
||||
lv_coord_t size = sw + r;
|
||||
|
||||
if(sw == 0) sw = 1; /*To avoid divide by zero*/
|
||||
lv_area_t sh_area;
|
||||
lv_area_copy(&sh_area, coords);
|
||||
sh_area.x2 = sw / 2 + r -1 - (sw & 1 ? 0 : 1); //-1
|
||||
|
Loading…
x
Reference in New Issue
Block a user