mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
improve arc invalidation
This commit is contained in:
parent
68e77be7f5
commit
c43704756f
@ -31,18 +31,6 @@ extern "C" {
|
||||
* V6.0 COMPATIBILITY
|
||||
*--------------------*/
|
||||
|
||||
|
||||
#if LV_USE_ARC
|
||||
|
||||
|
||||
static inline void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end)
|
||||
{
|
||||
lv_arc_set_start_angle(arc, start);
|
||||
lv_arc_set_end_angle(arc, end);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if LV_USE_CHART
|
||||
|
||||
#define lv_chart_get_point_cnt lv_chart_get_point_count
|
||||
|
@ -539,7 +539,7 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
||||
style_debug.body.grad_color = debug_color;
|
||||
style_debug.body.border.width = 2;
|
||||
style_debug.body.border.color.full = (debug_color.full + 0x13) * 9;
|
||||
lv_draw_rect(&obj_ext_mask, &obj_ext_mask, &style_debug, LV_OPA_50);
|
||||
lv_draw_rect(&obj_ext_mask, &obj_ext_mask, &style_debug, LV_OPA_20);
|
||||
debug_color.full *= 17;
|
||||
debug_color.full += 0xA1;
|
||||
#endif
|
||||
|
@ -117,7 +117,7 @@ void lv_style_init(void)
|
||||
|
||||
lv_style_scr.line.opa = LV_OPA_COVER;
|
||||
lv_style_scr.line.color = lv_color_make(0x20, 0x20, 0x20);
|
||||
lv_style_scr.line.width = 2;
|
||||
lv_style_scr.line.width = 40;
|
||||
lv_style_scr.line.rounded = 0;
|
||||
lv_style_scr.line.blend_mode = LV_BLEND_MODE_NORMAL;
|
||||
|
||||
|
@ -128,7 +128,6 @@ void lv_arc_set_start_angle(lv_obj_t * arc, int16_t start)
|
||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||
|
||||
if(start > 360) start -= 360;
|
||||
if(start < 0) start += 360;
|
||||
|
||||
ext->angle_start = start;
|
||||
|
||||
@ -147,13 +146,35 @@ void lv_arc_set_end_angle(lv_obj_t * arc, int16_t end)
|
||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||
|
||||
if(end > 360) end -= 360;
|
||||
if(end < 0) end += 360;
|
||||
|
||||
ext->angle_end= end;
|
||||
|
||||
lv_obj_invalidate(arc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the start and end angles
|
||||
* @param arc pointer to an arc object
|
||||
* @param start the start angle
|
||||
* @param end the end angle
|
||||
*/
|
||||
void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end)
|
||||
{
|
||||
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
|
||||
|
||||
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
|
||||
|
||||
if(end > 360) end -= 360;
|
||||
|
||||
if(start > 360) start -= 360;
|
||||
|
||||
ext->angle_start = start;
|
||||
ext->angle_end = end;
|
||||
|
||||
lv_obj_invalidate(arc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a style of a arc.
|
||||
* @param arc pointer to arc object
|
||||
@ -291,4 +312,32 @@ static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angle)
|
||||
{
|
||||
uint8_t start_quarter = start_angle / 90;
|
||||
uint8_t end_quarter = end_angle / 90;
|
||||
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(arc), lv_obj_get_height(arc))) / 2;
|
||||
lv_coord_t x = arc->coords.x1 + lv_obj_get_width(arc) / 2;
|
||||
lv_coord_t y = arc->coords.y1 + lv_obj_get_height(arc) / 2;
|
||||
const lv_style_t style = lv_arc_get_style(arc, LV_ARC_STYLE_MAIN);
|
||||
lv_coord_t w = style->line.width;
|
||||
lv_area_t inv_area;
|
||||
|
||||
if(start_quarter == end_quarter) {
|
||||
if(start_quarter == 3) {
|
||||
/*Small arc here*/
|
||||
inv_area.x1 = x + ((lv_trigo_sin(start_angle + 90) * (r - q->width)) >> LV_TRIGO_SHIFT);
|
||||
inv_area.y1 = y + ((lv_trigo_sin(start_angle) * (r)) >> LV_TRIGO_SHIFT);
|
||||
|
||||
inv_area.x2 = x + ((lv_trigo_sin(end_angle + 90) * (r)) >> LV_TRIGO_SHIFT);
|
||||
inv_area.y2 = y + ((lv_trigo_sin(end_angle) * (r - q->width)) >> LV_TRIGO_SHIFT);
|
||||
|
||||
bool ok = lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
|
||||
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->style, q->opa_scale);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -74,6 +74,15 @@ void lv_arc_set_start_angle(lv_obj_t * arc, int16_t start);
|
||||
*/
|
||||
void lv_arc_set_end_angle(lv_obj_t * arc, int16_t end);
|
||||
|
||||
/**
|
||||
* Set the start and end angles
|
||||
* @param arc pointer to an arc object
|
||||
* @param start the start angle
|
||||
* @param end the end angle
|
||||
*/
|
||||
void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end);
|
||||
|
||||
|
||||
/**
|
||||
* Set a style of a arc.
|
||||
* @param arc pointer to arc object
|
||||
|
@ -87,7 +87,7 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->arc_length = LV_PRELOAD_DEF_ARC_LENGTH;
|
||||
ext->anim_type = LV_PRELOAD_DEF_ANIM;
|
||||
ext->anim_dir = LV_PRELOAD_DIR_FORWARD;
|
||||
ext->time = LV_PRELOAD_DEF_SPIN_TIME;
|
||||
ext->time = LV_PRELOAD_DEF_SPIN_TIME * 5;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_cb(new_preload, lv_preload_signal);
|
||||
@ -362,8 +362,7 @@ void lv_preload_spinner_anim(void * ptr, lv_anim_value_t val)
|
||||
angle_start = angle_start % 360;
|
||||
angle_end = angle_end % 360;
|
||||
|
||||
lv_arc_set_start_angle(preload, angle_start);
|
||||
lv_arc_set_end_angle(preload, angle_end);
|
||||
lv_arc_set_angles(preload, angle_start, angle_end);
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
Loading…
x
Reference in New Issue
Block a user