mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
preloader and arc theme and design updates
This commit is contained in:
parent
044194c64e
commit
fa683200b5
@ -238,31 +238,32 @@ static bool lv_arc_design(lv_obj_t * arc, const lv_area_t * mask, lv_design_mode
|
||||
|
||||
/*Draw circle on the ends if enabled */
|
||||
if(style->line.rounded) {
|
||||
lv_coord_t thick_2 = style->line.width / 2;
|
||||
lv_coord_t cir_x = ((r - thick_2) * lv_trigo_sin(ext->angle_start) >> LV_TRIGO_SHIFT);
|
||||
lv_coord_t cir_y = ((r - thick_2) * lv_trigo_sin(ext->angle_start + 90) >> LV_TRIGO_SHIFT);
|
||||
lv_coord_t thick_half = style->line.width / 2;
|
||||
lv_coord_t cir_x = ((r - thick_half) * lv_trigo_sin(ext->angle_start) >> LV_TRIGO_SHIFT);
|
||||
lv_coord_t cir_y = ((r - thick_half) * lv_trigo_sin(ext->angle_start + 90) >> LV_TRIGO_SHIFT);
|
||||
|
||||
lv_style_t cir_style;
|
||||
lv_style_copy(&cir_style, style);
|
||||
cir_style.body.empty = 0;
|
||||
lv_style_copy(&cir_style, &lv_style_plain);
|
||||
cir_style.body.grad_color = style->line.color;
|
||||
cir_style.body.main_color = cir_style.body.grad_color;
|
||||
cir_style.body.radius = LV_RADIUS_CIRCLE;
|
||||
lv_area_t cir_area;
|
||||
cir_area.x1 = cir_x + x - thick_2;
|
||||
cir_area.y1 = cir_y + y - thick_2;
|
||||
cir_area.x2 = cir_x + x + thick_2;
|
||||
cir_area.y2 = cir_y + y + thick_2;
|
||||
cir_area.x1 = cir_x + x - thick_half;
|
||||
cir_area.y1 = cir_y + y - thick_half;
|
||||
cir_area.x2 = cir_x + x + thick_half;
|
||||
cir_area.y2 = cir_y + y + thick_half;
|
||||
|
||||
lv_draw_rect(&cir_area, mask, &cir_style, lv_obj_get_opa_scale(arc));
|
||||
lv_draw_rect(&cir_area, mask, &cir_style, opa_scale);
|
||||
|
||||
cir_x = ((r - thick_2) * lv_trigo_sin(ext->angle_end) >> LV_TRIGO_SHIFT);
|
||||
cir_y = ((r - thick_2) * lv_trigo_sin(ext->angle_end + 90) >> LV_TRIGO_SHIFT);
|
||||
cir_x = ((r - thick_half) * lv_trigo_sin(ext->angle_end) >> LV_TRIGO_SHIFT);
|
||||
cir_y = ((r - thick_half) * lv_trigo_sin(ext->angle_end + 90) >> LV_TRIGO_SHIFT);
|
||||
|
||||
cir_area.x1 = cir_x + x - thick_2;
|
||||
cir_area.y1 = cir_y + y - thick_2;
|
||||
cir_area.x2 = cir_x + x + thick_2;
|
||||
cir_area.y2 = cir_y + y + thick_2;
|
||||
cir_area.x1 = cir_x + x - thick_half;
|
||||
cir_area.y1 = cir_y + y - thick_half;
|
||||
cir_area.x2 = cir_x + x + thick_half;
|
||||
cir_area.y2 = cir_y + y + thick_half;
|
||||
|
||||
lv_draw_rect(&cir_area, mask, &cir_style, lv_obj_get_opa_scale(arc));
|
||||
lv_draw_rect(&cir_area, mask, &cir_style, opa_scale);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -278,25 +278,28 @@ static bool lv_preload_design(lv_obj_t * preload, const lv_area_t * mask, lv_des
|
||||
|
||||
/*Draw a circle as background*/
|
||||
lv_style_t * style = lv_arc_get_style(preload, LV_ARC_STYLE_MAIN);
|
||||
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(preload), lv_obj_get_height(preload))) / 2;
|
||||
lv_coord_t x = preload->coords.x1 + lv_obj_get_width(preload) / 2;
|
||||
lv_coord_t y = preload->coords.y1 + lv_obj_get_height(preload) / 2;
|
||||
if(style->body.border.width > 0) {
|
||||
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(preload), lv_obj_get_height(preload))) / 2;
|
||||
r -= LV_MATH_MIN(style->body.padding.hor, style->body.padding.ver);
|
||||
|
||||
lv_style_t bg_style;
|
||||
lv_style_copy(&bg_style, &lv_style_plain);
|
||||
bg_style.body.empty = 1;
|
||||
bg_style.body.radius = LV_RADIUS_CIRCLE;
|
||||
bg_style.body.border.color = style->body.border.color;
|
||||
bg_style.body.border.width = style->body.border.width;
|
||||
lv_coord_t x = preload->coords.x1 + lv_obj_get_width(preload) / 2;
|
||||
lv_coord_t y = preload->coords.y1 + lv_obj_get_height(preload) / 2;
|
||||
|
||||
lv_area_t bg_area;
|
||||
bg_area.x1 = x - r;
|
||||
bg_area.y1 = y - r;
|
||||
bg_area.x2 = x + r;
|
||||
bg_area.y2 = y + r;
|
||||
lv_style_t bg_style;
|
||||
lv_style_copy(&bg_style, &lv_style_plain);
|
||||
bg_style.body.empty = 1;
|
||||
bg_style.body.radius = LV_RADIUS_CIRCLE;
|
||||
bg_style.body.border.color = style->body.border.color;
|
||||
bg_style.body.border.width = style->body.border.width;
|
||||
|
||||
if(style->body.empty == 0) lv_draw_rect(&bg_area, mask, &bg_style, lv_obj_get_opa_scale(preload));
|
||||
lv_area_t bg_area;
|
||||
bg_area.x1 = x - r;
|
||||
bg_area.y1 = y - r;
|
||||
bg_area.x2 = x + r;
|
||||
bg_area.y2 = y + r;
|
||||
|
||||
lv_draw_rect(&bg_area, mask, &bg_style, lv_obj_get_opa_scale(preload));
|
||||
}
|
||||
/*Draw the arc above the background circle */
|
||||
ancestor_design(preload, mask, mode);
|
||||
}
|
||||
|
@ -379,6 +379,34 @@ static void gauge_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void arc_init(void)
|
||||
{
|
||||
#if USE_LV_ARC != 0
|
||||
|
||||
static lv_style_t arc;
|
||||
lv_style_copy(&arc, &def);
|
||||
arc.line.width = 8;
|
||||
arc.line.color = lv_color_hsv_to_rgb(_hue, 70, 90);
|
||||
arc.line.rounded = 1;
|
||||
|
||||
/*For preloader*/
|
||||
arc.body.border.width = 2;
|
||||
arc.body.border.color = LV_COLOR_HEX3(0x555);
|
||||
arc.body.padding.hor = 3;
|
||||
arc.body.padding.ver = 3;
|
||||
|
||||
theme.arc = &arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void preload_init(void)
|
||||
{
|
||||
#if USE_LV_PRELOAD != 0
|
||||
|
||||
theme.preload = theme.arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
@ -767,6 +795,8 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font)
|
||||
sw_init();
|
||||
lmeter_init();
|
||||
gauge_init();
|
||||
arc_init();
|
||||
preload_init();
|
||||
chart_init();
|
||||
calendar_init();
|
||||
cb_init();
|
||||
|
@ -322,8 +322,12 @@ static void arc_init(void)
|
||||
lv_style_copy(&arc, &def);
|
||||
arc.line.width = 10;
|
||||
arc.line.color = lv_color_hsv_to_rgb(_hue, 90, 90);
|
||||
|
||||
/*For prelaoder*/
|
||||
arc.body.border.width = 10;
|
||||
arc.body.border.color = lv_color_hsv_to_rgb(_hue, 30, 90);
|
||||
arc.body.padding.hor = 0;
|
||||
arc.body.padding.ver = 0;
|
||||
|
||||
theme.arc = &arc;
|
||||
#endif
|
||||
|
@ -382,6 +382,31 @@ static void gauge_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void arc_init(void)
|
||||
{
|
||||
#if USE_LV_ARC != 0
|
||||
|
||||
static lv_style_t arc;
|
||||
lv_style_copy(&arc, &def);
|
||||
arc.line.width = 10;
|
||||
arc.line.color = lv_color_hsv_to_rgb(_hue, 70, 90);
|
||||
arc.line.rounded = 1;
|
||||
|
||||
/*For preloader*/
|
||||
arc.body.border.width = 0;
|
||||
|
||||
theme.arc = &arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void preload_init(void)
|
||||
{
|
||||
#if USE_LV_PRELOAD != 0
|
||||
|
||||
theme.preload = theme.arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
@ -761,6 +786,8 @@ lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t *font)
|
||||
sw_init();
|
||||
lmeter_init();
|
||||
gauge_init();
|
||||
arc_init();
|
||||
preload_init();
|
||||
chart_init();
|
||||
calendar_init();
|
||||
cb_init();
|
||||
|
@ -300,6 +300,9 @@ static void arc_init(void)
|
||||
lv_style_copy(&arc, &def);
|
||||
arc.line.width = 10;
|
||||
arc.line.color = lv_color_hsv_to_rgb(_hue, 40, 90);
|
||||
arc.line.rounded = 1;
|
||||
|
||||
/*For preloader*/
|
||||
arc.body.border.width = 0;
|
||||
|
||||
theme.arc = &arc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user