BigW Consortium Gitlab

Commit 63d54b02 by Gabor Kiss-Vamosi

some api updates and style border.part added

parent b973dd34
......@@ -108,7 +108,7 @@ void lv_draw_rect(const area_t * coords, const area_t * mask, const lv_style_t *
}
}
if(style->body.border.width != 0) {
if(style->body.border.width != 0 && style->body.border.part != LV_BORDER_NONE) {
lv_draw_rect_border_straight(coords, mask, style);
if(style->body.radius != 0) {
......@@ -324,7 +324,7 @@ void lv_draw_label(const area_t * coords,const area_t * mask, const lv_style_t *
if(cmd_state == CMD_STATE_IN) color = recolor;
letter_fp(&pos, mask, font, letter, color, style->text.opa);
pos.x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->text.letter_space;
pos.x += font_get_width_scale(font, letter) + style->text.letter_space;
}
/*Go to next line*/
......@@ -592,8 +592,8 @@ static void lv_draw_rect_main_mid(const area_t * coords, const area_t * mask, co
{
uint16_t radius = style->body.radius;
color_t mcolor = style->body.color_main;
color_t gcolor = style->body.color_gradient;
color_t mcolor = style->body.main_color;
color_t gcolor = style->body.gradient_color;
uint8_t mix;
opa_t opa = style->body.opa;
cord_t height = area_get_height(coords);
......@@ -642,8 +642,8 @@ static void lv_draw_rect_main_corner(const area_t * coords, const area_t * mask,
{
uint16_t radius = style->body.radius;
color_t mcolor = style->body.color_main;
color_t gcolor = style->body.color_gradient;
color_t mcolor = style->body.main_color;
color_t gcolor = style->body.gradient_color;
color_t act_color;
opa_t opa = style->body.opa;
uint8_t mix;
......@@ -816,7 +816,9 @@ static void lv_draw_rect_border_straight(const area_t * coords, const area_t * m
cord_t width = area_get_width(coords);
cord_t height = area_get_height(coords);
uint16_t bwidth = style->body.border.width;
opa_t bopa = style->body.border.opa;//(uint32_t)((uint32_t) style->opa * style->body.border.opa) >> 8;
opa_t opa = style->body.border.opa;
lv_border_part_t part = style->body.border.part;
color_t color = style->body.border.color;
area_t work_area;
cord_t length_corr = 0;
cord_t corner_size = 0;
......@@ -836,84 +838,122 @@ static void lv_draw_rect_border_straight(const area_t * coords, const area_t * m
/* Modify the corner_size if corner is drawn */
corner_size ++;
color_t b_color = style->body.border.color;
/*Depending one which part's are drawn modify the area lengths */
if(part & LV_BORDER_TOP) work_area.y1 = coords->y1 + corner_size;
else work_area.y1 = coords->y1 + radius;
if(part & LV_BORDER_BOTTOM) work_area.y2 = coords->y2 - corner_size;
else work_area.y2 = coords->y2 - radius;
/*Left border*/
work_area.x1 = coords->x1;
work_area.x2 = work_area.x1 + bwidth;
work_area.y1 = coords->y1 + corner_size;
work_area.y2 = coords->y2 - corner_size;
fill_fp(&work_area, mask, b_color, bopa);
if(part & LV_BORDER_LEFT) {
work_area.x1 = coords->x1;
work_area.x2 = work_area.x1 + bwidth;
fill_fp(&work_area, mask, color, opa);
}
/*Right border*/
work_area.x2 = coords->x2;
work_area.x1 = work_area.x2 - bwidth;
fill_fp(&work_area, mask, b_color, bopa);
if(part & LV_BORDER_RIGHT) {
work_area.x2 = coords->x2;
work_area.x1 = work_area.x2 - bwidth;
fill_fp(&work_area, mask, color, opa);
}
/*Upper border*/
work_area.x1 = coords->x1 + corner_size - length_corr;
work_area.x2 = coords->x2 - corner_size + length_corr;
work_area.y1 = coords->y1;
work_area.y2 = coords->y1 + bwidth;
fill_fp(&work_area, mask, b_color, bopa);
/*Upper border*/
if(part & LV_BORDER_TOP) {
work_area.y1 = coords->y1;
work_area.y2 = coords->y1 + bwidth;
fill_fp(&work_area, mask, color, opa);
}
/*Lower border*/
work_area.y2 = coords->y2;
work_area.y1 = work_area.y2 - bwidth;
fill_fp(&work_area, mask, b_color, bopa);
if(part & LV_BORDER_BOTTOM) {
work_area.y2 = coords->y2;
work_area.y1 = work_area.y2 - bwidth;
fill_fp(&work_area, mask, color, opa);
}
/*Draw the a remaining rectangles if the radius is smaller then b_width */
if(length_corr != 0) {
work_area.x1 = coords->x1;
work_area.x2 = coords->x1 + radius;
work_area.y1 = coords->y1 + radius + 1;
work_area.y2 = coords->y1 + bwidth;
fill_fp(&work_area, mask, b_color, bopa);
/*Left top correction*/
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
work_area.x1 = coords->x1;
work_area.x2 = coords->x1 + radius;
work_area.y1 = coords->y1 + radius + 1;
work_area.y2 = coords->y1 + bwidth;
fill_fp(&work_area, mask, color, opa);
}
work_area.x1 = coords->x2 - radius;
work_area.x2 = coords->x2;
work_area.y1 = coords->y1 + radius + 1;
work_area.y2 = coords->y1 + bwidth;
fill_fp(&work_area, mask, b_color, bopa);
/*Right top correction*/
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
work_area.x1 = coords->x2 - radius;
work_area.x2 = coords->x2;
work_area.y1 = coords->y1 + radius + 1;
work_area.y2 = coords->y1 + bwidth;
fill_fp(&work_area, mask, color, opa);
}
work_area.x1 = coords->x1;
work_area.x2 = coords->x1 + radius;
work_area.y1 = coords->y2 - bwidth;
work_area.y2 = coords->y2 - radius - 1;
fill_fp(&work_area, mask, b_color, bopa);
/*Left bottom correction*/
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
work_area.x1 = coords->x1;
work_area.x2 = coords->x1 + radius;
work_area.y1 = coords->y2 - bwidth;
work_area.y2 = coords->y2 - radius - 1;
fill_fp(&work_area, mask, color, opa);
}
work_area.x1 = coords->x2 - radius;
work_area.x2 = coords->x2;
work_area.y1 = coords->y2 - bwidth;
work_area.y2 = coords->y2 - radius - 1;
fill_fp(&work_area, mask, b_color, bopa);
/*Right bottom correction*/
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
work_area.x1 = coords->x2 - radius;
work_area.x2 = coords->x2;
work_area.y1 = coords->y2 - bwidth;
work_area.y2 = coords->y2 - radius - 1;
fill_fp(&work_area, mask, color, opa);
}
}
/*If radius == 0 one px on the corners are not drawn*/
if(radius == 0) {
work_area.x1 = coords->x1;
work_area.x2 = coords->x1;
work_area.y1 = coords->y1;
work_area.y2 = coords->y1;
fill_fp(&work_area, mask, b_color, bopa);
work_area.x1 = coords->x2;
work_area.x2 = coords->x2;
work_area.y1 = coords->y1;
work_area.y2 = coords->y1;
fill_fp(&work_area, mask, b_color, bopa);
/*Left top corner*/
if(part & (LV_BORDER_TOP | LV_BORDER_LEFT)) {
work_area.x1 = coords->x1;
work_area.x2 = coords->x1;
work_area.y1 = coords->y1;
work_area.y2 = coords->y1;
fill_fp(&work_area, mask, color, opa);
}
work_area.x1 = coords->x1;
work_area.x2 = coords->x1;
work_area.y1 = coords->y2;
work_area.y2 = coords->y2;
fill_fp(&work_area, mask, b_color, bopa);
/*Right top corner*/
if(part & (LV_BORDER_TOP | LV_BORDER_RIGHT)) {
work_area.x1 = coords->x2;
work_area.x2 = coords->x2;
work_area.y1 = coords->y1;
work_area.y2 = coords->y1;
fill_fp(&work_area, mask, color, opa);
}
work_area.x1 = coords->x2;
work_area.x2 = coords->x2;
work_area.y1 = coords->y2;
work_area.y2 = coords->y2;
fill_fp(&work_area, mask, b_color, bopa);
/*Left bottom corner*/
if(part & (LV_BORDER_BOTTOM | LV_BORDER_LEFT)) {
work_area.x1 = coords->x1;
work_area.x2 = coords->x1;
work_area.y1 = coords->y2;
work_area.y2 = coords->y2;
fill_fp(&work_area, mask, color, opa);
}
/*Right bottom corner*/
if(part & (LV_BORDER_BOTTOM | LV_BORDER_RIGHT)) {
work_area.x1 = coords->x2;
work_area.x2 = coords->x2;
work_area.y1 = coords->y2;
work_area.y2 = coords->y2;
fill_fp(&work_area, mask, color, opa);
}
}
}
......@@ -929,8 +969,9 @@ static void lv_draw_rect_border_corner(const area_t * coords, const area_t * mas
{
uint16_t radius = style->body.radius;
uint16_t bwidth = style->body.border.width;
color_t bcolor = style->body.border.color;
opa_t bopa = style->body.border.opa;//(uint32_t)((uint32_t) style->opa * style->body.border.opa ) >> 8;
color_t color = style->body.border.color;
opa_t opa = style->body.border.opa;
lv_border_part_t part = style->body.border.part;
/*0 px border width drawn as 1 px, so decrement the bwidth*/
bwidth--;
......@@ -987,63 +1028,70 @@ static void lv_draw_rect_border_corner(const area_t * coords, const area_t * mas
}
/*Draw the octets to the right bottom corner*/
circ_area.x1 = rb_origo.x + CIRC_OCT1_X(cir_out) - act_w2;
circ_area.x2 = rb_origo.x + CIRC_OCT1_X(cir_out);
circ_area.y1 = rb_origo.y + CIRC_OCT1_Y(cir_out);
circ_area.y2 = rb_origo.y + CIRC_OCT1_Y(cir_out);
fill_fp(&circ_area, mask, bcolor, bopa);
circ_area.x1 = rb_origo.x + CIRC_OCT2_X(cir_out);
circ_area.x2 = rb_origo.x + CIRC_OCT2_X(cir_out);
circ_area.y1 = rb_origo.y + CIRC_OCT2_Y(cir_out)- act_w1;
circ_area.y2 = rb_origo.y + CIRC_OCT2_Y(cir_out);
fill_fp(&circ_area, mask, bcolor, bopa);
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
circ_area.x1 = rb_origo.x + CIRC_OCT1_X(cir_out) - act_w2;
circ_area.x2 = rb_origo.x + CIRC_OCT1_X(cir_out);
circ_area.y1 = rb_origo.y + CIRC_OCT1_Y(cir_out);
circ_area.y2 = rb_origo.y + CIRC_OCT1_Y(cir_out);
fill_fp(&circ_area, mask, color, opa);
circ_area.x1 = rb_origo.x + CIRC_OCT2_X(cir_out);
circ_area.x2 = rb_origo.x + CIRC_OCT2_X(cir_out);
circ_area.y1 = rb_origo.y + CIRC_OCT2_Y(cir_out)- act_w1;
circ_area.y2 = rb_origo.y + CIRC_OCT2_Y(cir_out);
fill_fp(&circ_area, mask, color, opa);
}
/*Draw the octets to the left bottom corner*/
circ_area.x1 = lb_origo.x + CIRC_OCT3_X(cir_out);
circ_area.x2 = lb_origo.x + CIRC_OCT3_X(cir_out);
circ_area.y1 = lb_origo.y + CIRC_OCT3_Y(cir_out) - act_w2;
circ_area.y2 = lb_origo.y + CIRC_OCT3_Y(cir_out);
fill_fp(&circ_area, mask, bcolor, bopa);
circ_area.x1 = lb_origo.x + CIRC_OCT4_X(cir_out);
circ_area.x2 = lb_origo.x + CIRC_OCT4_X(cir_out) + act_w1;
circ_area.y1 = lb_origo.y + CIRC_OCT4_Y(cir_out);
circ_area.y2 = lb_origo.y + CIRC_OCT4_Y(cir_out);
fill_fp(&circ_area, mask, bcolor, bopa);
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
circ_area.x1 = lb_origo.x + CIRC_OCT3_X(cir_out);
circ_area.x2 = lb_origo.x + CIRC_OCT3_X(cir_out);
circ_area.y1 = lb_origo.y + CIRC_OCT3_Y(cir_out) - act_w2;
circ_area.y2 = lb_origo.y + CIRC_OCT3_Y(cir_out);
fill_fp(&circ_area, mask, color, opa);
circ_area.x1 = lb_origo.x + CIRC_OCT4_X(cir_out);
circ_area.x2 = lb_origo.x + CIRC_OCT4_X(cir_out) + act_w1;
circ_area.y1 = lb_origo.y + CIRC_OCT4_Y(cir_out);
circ_area.y2 = lb_origo.y + CIRC_OCT4_Y(cir_out);
fill_fp(&circ_area, mask, color, opa);
}
/*Draw the octets to the left top corner*/
/*Don't draw if the lines are common in the middle*/
if(lb_origo.y + CIRC_OCT4_Y(cir_out) > lt_origo.y + CIRC_OCT5_Y(cir_out)) {
circ_area.x1 = lt_origo.x + CIRC_OCT5_X(cir_out);
circ_area.x2 = lt_origo.x + CIRC_OCT5_X(cir_out) + act_w2;
circ_area.y1 = lt_origo.y + CIRC_OCT5_Y(cir_out);
circ_area.y2 = lt_origo.y + CIRC_OCT5_Y(cir_out);
fill_fp(&circ_area, mask, bcolor, bopa);
}
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
if(lb_origo.y + CIRC_OCT4_Y(cir_out) > lt_origo.y + CIRC_OCT5_Y(cir_out)) {
/*Don't draw if the lines are common in the middle*/
circ_area.x1 = lt_origo.x + CIRC_OCT5_X(cir_out);
circ_area.x2 = lt_origo.x + CIRC_OCT5_X(cir_out) + act_w2;
circ_area.y1 = lt_origo.y + CIRC_OCT5_Y(cir_out);
circ_area.y2 = lt_origo.y + CIRC_OCT5_Y(cir_out);
fill_fp(&circ_area, mask, color, opa);
}
circ_area.x1 = lt_origo.x + CIRC_OCT6_X(cir_out);
circ_area.x2 = lt_origo.x + CIRC_OCT6_X(cir_out);
circ_area.y1 = lt_origo.y + CIRC_OCT6_Y(cir_out);
circ_area.y2 = lt_origo.y + CIRC_OCT6_Y(cir_out) + act_w1;
fill_fp(&circ_area, mask, bcolor, bopa);
circ_area.x1 = lt_origo.x + CIRC_OCT6_X(cir_out);
circ_area.x2 = lt_origo.x + CIRC_OCT6_X(cir_out);
circ_area.y1 = lt_origo.y + CIRC_OCT6_Y(cir_out);
circ_area.y2 = lt_origo.y + CIRC_OCT6_Y(cir_out) + act_w1;
fill_fp(&circ_area, mask, color, opa);
}
/*Draw the octets to the right top corner*/
circ_area.x1 = rt_origo.x + CIRC_OCT7_X(cir_out);
circ_area.x2 = rt_origo.x + CIRC_OCT7_X(cir_out);
circ_area.y1 = rt_origo.y + CIRC_OCT7_Y(cir_out);
circ_area.y2 = rt_origo.y + CIRC_OCT7_Y(cir_out) + act_w2;
fill_fp(&circ_area, mask, bcolor, bopa);
/*Don't draw if the lines are common in the middle*/
if(rb_origo.y + CIRC_OCT1_Y(cir_out) > rt_origo.y + CIRC_OCT8_Y(cir_out)) {
circ_area.x1 = rt_origo.x + CIRC_OCT8_X(cir_out) - act_w1;
circ_area.x2 = rt_origo.x + CIRC_OCT8_X(cir_out);
circ_area.y1 = rt_origo.y + CIRC_OCT8_Y(cir_out);
circ_area.y2 = rt_origo.y + CIRC_OCT8_Y(cir_out);
fill_fp(&circ_area, mask, bcolor, bopa);
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
circ_area.x1 = rt_origo.x + CIRC_OCT7_X(cir_out);
circ_area.x2 = rt_origo.x + CIRC_OCT7_X(cir_out);
circ_area.y1 = rt_origo.y + CIRC_OCT7_Y(cir_out);
circ_area.y2 = rt_origo.y + CIRC_OCT7_Y(cir_out) + act_w2;
fill_fp(&circ_area, mask, color, opa);
/*Don't draw if the lines are common in the middle*/
if(rb_origo.y + CIRC_OCT1_Y(cir_out) > rt_origo.y + CIRC_OCT8_Y(cir_out)) {
circ_area.x1 = rt_origo.x + CIRC_OCT8_X(cir_out) - act_w1;
circ_area.x2 = rt_origo.x + CIRC_OCT8_X(cir_out);
circ_area.y1 = rt_origo.y + CIRC_OCT8_Y(cir_out);
circ_area.y2 = rt_origo.y + CIRC_OCT8_Y(cir_out);
fill_fp(&circ_area, mask, color, opa);
}
}
circ_next(&cir_out, &tmp_out);
/*The internal circle will be ready faster
......@@ -1111,6 +1159,7 @@ static void lv_draw_cont_shadow_full(const area_t * coords, const area_t * mask,
uint16_t opa_h_result[LV_HOR_RES];
int16_t filter_size = 2 * style->body.shadow.width + 1;
/*TODO recalculate only values are changed*/
for(row = 0; row < filter_size; row++) {
opa_h_result[row] = (uint32_t)((uint32_t)(filter_size - row) * style->body.opa * 2) / (filter_size);
}
......
......@@ -257,8 +257,8 @@ static void style_mod_def(lv_style_t * style)
style->body.border.opa = OPA_COVER;
if(style->body.border.width == 0 && style->body.empty == 0) style->body.border.width = 2 << LV_ANTIALIAS; /*Add border to not transparent styles*/
else style->body.border.width = style->body.border.width * 2; /*Make the border thicker*/
style->body.color_main = color_mix(style->body.color_main, COLOR_ORANGE, OPA_80);
style->body.color_gradient = color_mix(style->body.color_gradient, COLOR_ORANGE, OPA_80);
style->body.main_color = color_mix(style->body.main_color, COLOR_ORANGE, OPA_80);
style->body.gradient_color = color_mix(style->body.gradient_color, COLOR_ORANGE, OPA_80);
}
#endif /*LV_OBJ_GROUP != 0*/
......@@ -70,17 +70,17 @@ void lv_style_init (void)
/*Screen style*/
lv_style_scr.glass = 0;
lv_style_scr.body.opa = OPA_COVER;
lv_style_scr.body.color_main = COLOR_WHITE;
lv_style_scr.body.color_gradient = COLOR_WHITE;
lv_style_scr.body.main_color = COLOR_WHITE;
lv_style_scr.body.gradient_color = COLOR_WHITE;
lv_style_scr.body.radius = 0;
lv_style_scr.body.padding.ver = LV_DPI / 12;
lv_style_scr.body.padding.hor = LV_DPI / 12;
lv_style_scr.body.padding.inner = LV_DPI / 12;
lv_style_scr.body.empty = 0;
lv_style_scr.body.border.color = COLOR_BLACK;
lv_style_scr.body.border.opa = OPA_COVER;
lv_style_scr.body.border.width = 0;
lv_style_scr.body.border.part = LV_BORDER_FULL;
lv_style_scr.body.shadow.color = COLOR_GRAY;
lv_style_scr.body.shadow.type = LV_SHADOW_FULL;
......@@ -108,16 +108,16 @@ void lv_style_init (void)
lv_style_plain_color.text.color = COLOR_MAKE(0xf0, 0xf0, 0xf0);
lv_style_plain_color.image.color = COLOR_MAKE(0xf0, 0xf0, 0xf0);
lv_style_plain_color.line.color = COLOR_MAKE(0xf0, 0xf0, 0xf0);
lv_style_plain_color.body.color_main = COLOR_MAKE(0x55, 0x96, 0xd8);
lv_style_plain_color.body.color_gradient = lv_style_plain_color.body.color_main;
lv_style_plain_color.body.main_color = COLOR_MAKE(0x55, 0x96, 0xd8);
lv_style_plain_color.body.gradient_color = lv_style_plain_color.body.main_color;
/*Pretty style */
memcpy(&lv_style_pretty, &lv_style_plain, sizeof(lv_style_t));
lv_style_pretty.text.color = COLOR_MAKE(0x20, 0x20, 0x20);
lv_style_pretty.image.color = COLOR_MAKE(0x20, 0x20, 0x20);
lv_style_pretty.line.color = COLOR_MAKE(0x20, 0x20, 0x20);
lv_style_pretty.body.color_main = COLOR_WHITE;
lv_style_pretty.body.color_gradient = COLOR_SILVER;
lv_style_pretty.body.main_color = COLOR_WHITE;
lv_style_pretty.body.gradient_color = COLOR_SILVER;
lv_style_pretty.body.radius = LV_DPI / 15;
lv_style_pretty.body.border.color = COLOR_MAKE(0x40, 0x40, 0x40);
lv_style_pretty.body.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
......@@ -128,8 +128,8 @@ void lv_style_init (void)
lv_style_pretty_color.text.color = COLOR_MAKE(0xe0, 0xe0, 0xe0);
lv_style_pretty_color.image.color = COLOR_MAKE(0xe0, 0xe0, 0xe0);
lv_style_pretty_color.line.color = COLOR_MAKE(0xe0, 0xe0, 0xe0);
lv_style_pretty_color.body.color_main = COLOR_MAKE(0x6b, 0x9a, 0xc7);
lv_style_pretty_color.body.color_gradient = COLOR_MAKE(0x2b, 0x59, 0x8b);
lv_style_pretty_color.body.main_color = COLOR_MAKE(0x6b, 0x9a, 0xc7);
lv_style_pretty_color.body.gradient_color = COLOR_MAKE(0x2b, 0x59, 0x8b);
lv_style_pretty_color.body.border.color = COLOR_MAKE(0x15, 0x2c, 0x42);
/*Transparent style*/
......@@ -149,8 +149,8 @@ void lv_style_init (void)
/*Button released style*/
memcpy(&lv_style_btn_released, &lv_style_plain, sizeof(lv_style_t));
lv_style_btn_released.body.color_main = COLOR_MAKE(0x76, 0xa2, 0xd0);
lv_style_btn_released.body.color_gradient = COLOR_MAKE(0x19, 0x3a, 0x5d);
lv_style_btn_released.body.main_color = COLOR_MAKE(0x76, 0xa2, 0xd0);
lv_style_btn_released.body.gradient_color = COLOR_MAKE(0x19, 0x3a, 0x5d);
lv_style_btn_released.body.radius = LV_DPI / 15;
lv_style_btn_released.body.padding.hor = LV_DPI / 4;
lv_style_btn_released.body.padding.ver = LV_DPI / 6;
......@@ -164,16 +164,16 @@ void lv_style_init (void)
/*Button pressed style*/
memcpy(&lv_style_btn_pressed, &lv_style_btn_released, sizeof(lv_style_t));
lv_style_btn_pressed.body.color_main = COLOR_MAKE(0x33, 0x62, 0x94);
lv_style_btn_pressed.body.color_gradient = COLOR_MAKE(0x10, 0x26, 0x3c);
lv_style_btn_pressed.body.main_color = COLOR_MAKE(0x33, 0x62, 0x94);
lv_style_btn_pressed.body.gradient_color = COLOR_MAKE(0x10, 0x26, 0x3c);
lv_style_btn_pressed.text.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_pressed.image.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_pressed.line.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
/*Button toggle released style*/
memcpy(&lv_style_btn_tgl_released, &lv_style_btn_released, sizeof(lv_style_t));
lv_style_btn_tgl_released.body.color_main = COLOR_MAKE(0x0a, 0x11, 0x22);
lv_style_btn_tgl_released.body.color_gradient = COLOR_MAKE(0x37, 0x62, 0x90);
lv_style_btn_tgl_released.body.main_color = COLOR_MAKE(0x0a, 0x11, 0x22);
lv_style_btn_tgl_released.body.gradient_color = COLOR_MAKE(0x37, 0x62, 0x90);
lv_style_btn_tgl_released.body.border.color = COLOR_MAKE(0x01, 0x07, 0x0d);
lv_style_btn_tgl_released.text.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
lv_style_btn_tgl_released.image.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
......@@ -181,16 +181,16 @@ void lv_style_init (void)
/*Button toggle pressed style*/
memcpy(&lv_style_btn_tgl_pressed, &lv_style_btn_tgl_released, sizeof(lv_style_t));
lv_style_btn_tgl_pressed.body.color_main = COLOR_MAKE(0x02, 0x14, 0x27);
lv_style_btn_tgl_pressed.body.color_gradient = COLOR_MAKE(0x2b, 0x4c, 0x70);
lv_style_btn_tgl_pressed.body.main_color = COLOR_MAKE(0x02, 0x14, 0x27);
lv_style_btn_tgl_pressed.body.gradient_color = COLOR_MAKE(0x2b, 0x4c, 0x70);
lv_style_btn_tgl_pressed.text.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_tgl_pressed.image.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_tgl_pressed.line.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
/*Button inactive style*/
memcpy(&lv_style_btn_inactive, &lv_style_btn_released, sizeof(lv_style_t));
lv_style_btn_inactive.body.color_main = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_inactive.body.color_gradient = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_inactive.body.main_color = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_inactive.body.gradient_color = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_inactive.body.border.color = COLOR_MAKE(0x90, 0x90, 0x90);
lv_style_btn_inactive.text.color = COLOR_MAKE(0x70, 0x70, 0x70);
lv_style_btn_inactive.image.color = COLOR_MAKE(0x70, 0x70, 0x70);
......@@ -264,8 +264,8 @@ static void lv_style_aimator(lv_style_anim_dsc_t * dsc, int32_t val)
STYLE_ATTR_ANIM(line.width, val);
STYLE_ATTR_ANIM(image.intense, val);
act->body.color_main = color_mix(end->body.color_main, start->body.color_main, val);
act->body.color_gradient = color_mix(end->body.color_gradient, start->body.color_gradient, val);
act->body.main_color = color_mix(end->body.main_color, start->body.main_color, val);
act->body.gradient_color = color_mix(end->body.gradient_color, start->body.gradient_color, val);
act->body.border.color = color_mix(end->body.border.color, start->body.border.color, val);
act->body.shadow.color = color_mix(end->body.shadow.color, start->body.shadow.color, val);
act->text.color = color_mix(end->text.color, start->text.color, val);
......
......@@ -28,6 +28,18 @@ extern "C" {
* TYPEDEFS
**********************/
/*Border types (Use 'OR'ed values)*/
typedef enum
{
LV_BORDER_NONE = 0x00,
LV_BORDER_BOTTOM = 0x01,
LV_BORDER_TOP = 0x02,
LV_BORDER_LEFT = 0x04,
LV_BORDER_RIGHT = 0x08,
LV_BORDER_FULL = 0x0F,
}lv_border_part_t;
/*Shadow types*/
typedef enum
{
......@@ -40,14 +52,15 @@ typedef struct
uint8_t glass :1; /*1: Do not inherit this style*/
struct {
color_t color_main;
color_t color_gradient;
color_t main_color;
color_t gradient_color;
cord_t radius;
opa_t opa;
struct {
color_t color;
cord_t width;
lv_border_part_t part;
opa_t opa;
}border;
......
......@@ -81,16 +81,16 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
/*If no copy do the basic initialization*/
if(copy == NULL) {
lv_btn_set_layout(new_btn, LV_CONT_LAYOUT_CENTER);
lv_btn_set_layout(new_btn, LV_LAYOUT_CENTER);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->btn.md.rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->btn.md.pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->btn.md.tgl_rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->btn.md.tgl_pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->btn.md.ina);
lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->btn.rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->btn.pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->btn.tgl_rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->btn.tgl_pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->btn.ina);
} else {
lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_REL]);
}
......
......@@ -121,7 +121,7 @@ void lv_btn_set_action(lv_obj_t * btn, lv_btn_action_t type, lv_action_t action)
* @param btn pointer to a button object
* @param layout a layout from 'lv_cont_layout_t'
*/
static inline void lv_btn_set_layout(lv_obj_t * btn, lv_cont_layout_t layout)
static inline void lv_btn_set_layout(lv_obj_t * btn, lv_layout_t layout)
{
lv_cont_set_layout(btn, layout);
}
......@@ -177,7 +177,7 @@ lv_action_t lv_btn_get_action(lv_obj_t * btn, lv_btn_action_t type);
* @param btn pointer to button object
* @return the layout from 'lv_cont_layout_t'
*/
static inline lv_cont_layout_t lv_btn_get_layout(lv_obj_t * btn)
static inline lv_layout_t lv_btn_get_layout(lv_obj_t * btn)
{
return lv_cont_get_layout(btn);
}
......
......@@ -74,7 +74,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
ext->label = lv_label_create(new_cb, NULL);
lv_cb_set_text(new_cb, "Check box");
lv_btn_set_layout(new_cb, LV_CONT_LAYOUT_ROW_M);
lv_btn_set_layout(new_cb, LV_LAYOUT_ROW_M);
lv_btn_set_fit(new_cb, true, true);
lv_btn_set_toggle(new_cb, true);
......
......@@ -553,8 +553,8 @@ static void lv_chart_draw_points(lv_obj_t * chart, const area_t * mask)
/*Go through all data lines*/
LL_READ_BACK(ext->series_ll, ser) {
style_point.body.color_main = ser->color;
style_point.body.color_gradient = color_mix(COLOR_BLACK, ser->color, ext->series.dark);
style_point.body.main_color = ser->color;
style_point.body.gradient_color = color_mix(COLOR_BLACK, ser->color, ext->series.dark);
for(i = 0; i < ext->point_cnt; i ++) {
cir_a.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
......@@ -611,8 +611,8 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const area_t * mask)
/*Draw the current point of all data line*/
LL_READ_BACK(ext->series_ll, ser) {
rects.body.color_main = ser->color;
rects.body.color_gradient = color_mix(COLOR_BLACK, ser->color, ext->series.dark);
rects.body.main_color = ser->color;
rects.body.gradient_color = color_mix(COLOR_BLACK, ser->color, ext->series.dark);
col_a.x1 = x_act;
col_a.x2 = col_a.x1 + col_w;
x_act += col_w;
......
......@@ -74,7 +74,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy)
dm_assert(ext);
ext->hor_fit = 0;
ext->ver_fit = 0;
ext->layout = LV_CONT_LAYOUT_OFF;
ext->layout = LV_LAYOUT_OFF;
lv_obj_set_signal_func(new_cont, lv_cont_signal);
......@@ -111,7 +111,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy)
* @param cont pointer to a container object
* @param layout a layout from 'lv_cont_layout_t'
*/
void lv_cont_set_layout(lv_obj_t * cont, lv_cont_layout_t layout)
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
{
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
ext->layout = layout;
......@@ -148,7 +148,7 @@ void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en)
* @param cont pointer to container object
* @return the layout from 'lv_cont_layout_t'
*/
lv_cont_layout_t lv_cont_get_layout(lv_obj_t * cont)
lv_layout_t lv_cont_get_layout(lv_obj_t * cont)
{
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
return ext->layout;
......@@ -219,22 +219,22 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
*/
static void lv_cont_refr_layout(lv_obj_t * cont)
{
lv_cont_layout_t type = lv_cont_get_layout(cont);
lv_layout_t type = lv_cont_get_layout(cont);
/*'cont' has to be at least 1 child*/
if(lv_obj_get_child(cont, NULL) == NULL) return;
if(type == LV_CONT_LAYOUT_OFF) return;
if(type == LV_LAYOUT_OFF) return;
if(type == LV_CONT_LAYOUT_CENTER) {
if(type == LV_LAYOUT_CENTER) {
lv_cont_layout_center(cont);
} else if(type == LV_CONT_LAYOUT_COL_L || type == LV_CONT_LAYOUT_COL_M || type == LV_CONT_LAYOUT_COL_R) {
} else if(type == LV_LAYOUT_COL_L || type == LV_LAYOUT_COL_M || type == LV_LAYOUT_COL_R) {
lv_cont_layout_col(cont);
} else if(type == LV_CONT_LAYOUT_ROW_T || type == LV_CONT_LAYOUT_ROW_M || type == LV_CONT_LAYOUT_ROW_B) {
} else if(type == LV_LAYOUT_ROW_T || type == LV_LAYOUT_ROW_M || type == LV_LAYOUT_ROW_B) {
lv_cont_layout_row(cont);
} else if(type == LV_CONT_LAYOUT_PRETTY) {
} else if(type == LV_LAYOUT_PRETTY) {
lv_cont_layout_pretty(cont);
} else if(type == LV_CONT_LAYOUT_GRID) {
} else if(type == LV_LAYOUT_GRID) {
lv_cont_layout_grid(cont);
}
}
......@@ -245,7 +245,7 @@ static void lv_cont_refr_layout(lv_obj_t * cont)
*/
static void lv_cont_layout_col(lv_obj_t * cont)
{
lv_cont_layout_t type = lv_cont_get_layout(cont);
lv_layout_t type = lv_cont_get_layout(cont);
lv_obj_t * child;
/*Adjust margin and get the alignment type*/
......@@ -254,15 +254,15 @@ static void lv_cont_layout_col(lv_obj_t * cont)
cord_t hpad_corr;
switch(type) {
case LV_CONT_LAYOUT_COL_L:
case LV_LAYOUT_COL_L:
hpad_corr = style->body.padding.hor;
align = LV_ALIGN_IN_TOP_LEFT;
break;
case LV_CONT_LAYOUT_COL_M:
case LV_LAYOUT_COL_M:
hpad_corr = 0;
align = LV_ALIGN_IN_TOP_MID;
break;
case LV_CONT_LAYOUT_COL_R:
case LV_LAYOUT_COL_R:
hpad_corr = -style->body.padding.hor;
align = LV_ALIGN_IN_TOP_RIGHT;
break;
......@@ -294,7 +294,7 @@ static void lv_cont_layout_col(lv_obj_t * cont)
*/
static void lv_cont_layout_row(lv_obj_t * cont)
{
lv_cont_layout_t type = lv_cont_get_layout(cont);
lv_layout_t type = lv_cont_get_layout(cont);
lv_obj_t * child;
/*Adjust margin and get the alignment type*/
......@@ -303,15 +303,15 @@ static void lv_cont_layout_row(lv_obj_t * cont)
cord_t vpad_corr = style->body.padding.ver;
switch(type) {
case LV_CONT_LAYOUT_ROW_T:
case LV_LAYOUT_ROW_T:
vpad_corr = style->body.padding.ver;
align = LV_ALIGN_IN_TOP_LEFT;
break;
case LV_CONT_LAYOUT_ROW_M:
case LV_LAYOUT_ROW_M:
vpad_corr = 0;
align = LV_ALIGN_IN_LEFT_MID;
break;
case LV_CONT_LAYOUT_ROW_B:
case LV_LAYOUT_ROW_B:
vpad_corr = -style->body.padding.ver;
align = LV_ALIGN_IN_BOTTOM_LEFT;
break;
......
......@@ -29,17 +29,17 @@ extern "C" {
/*Layout options*/
typedef enum
{
LV_CONT_LAYOUT_OFF = 0,
LV_CONT_LAYOUT_CENTER,
LV_CONT_LAYOUT_COL_L, /*Column left align*/
LV_CONT_LAYOUT_COL_M, /*Column middle align*/
LV_CONT_LAYOUT_COL_R, /*Column right align*/
LV_CONT_LAYOUT_ROW_T, /*Row top align*/
LV_CONT_LAYOUT_ROW_M, /*Row middle align*/
LV_CONT_LAYOUT_ROW_B, /*Row bottom align*/
LV_CONT_LAYOUT_PRETTY, /*Put as many object as possible in row and begin a new row*/
LV_CONT_LAYOUT_GRID, /*Align same-sized object into a grid*/
}lv_cont_layout_t;
LV_LAYOUT_OFF = 0,
LV_LAYOUT_CENTER,
LV_LAYOUT_COL_L, /*Column left align*/
LV_LAYOUT_COL_M, /*Column middle align*/
LV_LAYOUT_COL_R, /*Column right align*/
LV_LAYOUT_ROW_T, /*Row top align*/
LV_LAYOUT_ROW_M, /*Row middle align*/
LV_LAYOUT_ROW_B, /*Row bottom align*/
LV_LAYOUT_PRETTY, /*Put as many object as possible in row and begin a new row*/
LV_LAYOUT_GRID, /*Align same-sized object into a grid*/
}lv_layout_t;
typedef struct
{
......@@ -71,7 +71,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy);
* @param cont pointer to a container object
* @param layout a layout from 'lv_cont_layout_t'
*/
void lv_cont_set_layout(lv_obj_t * cont, lv_cont_layout_t layout);
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout);
/**
......@@ -102,7 +102,7 @@ static inline void lv_cont_set_style(lv_obj_t *cont, lv_style_t * style)
* @param cont pointer to container object
* @return the layout from 'lv_cont_layout_t'
*/
lv_cont_layout_t lv_cont_get_layout(lv_obj_t * cont);
lv_layout_t lv_cont_get_layout(lv_obj_t * cont);
/**
* Get horizontal fit enable attribute of a container
......
......@@ -185,7 +185,7 @@ void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action)
}
/**
* Set the fix height value.
* Set the fix height for the drop down list
* If 0 then the opened ddlist will be auto. sized else the set height will be applied.
* @param ddlist pointer to a drop down list
* @param h the height when the list is opened (0: auto size)
......@@ -194,10 +194,33 @@ void lv_ddlist_set_fix_height(lv_obj_t * ddlist, cord_t h)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->fix_height = h;
lv_ddlist_refr_size(ddlist, 0);
}
/**
* Set the fix width for the drop down list
* If 0 then the ddlist will be auto. sized else the set width will be applied.
* @param ddlist pointer to a drop down list
* @param w the new width (0: auto size)
*/
void lv_ddlist_set_fix_width(lv_obj_t * ddlist, cord_t w)
{
if(w) {
lv_cont_set_fit(ddlist, false, lv_cont_get_ver_fit(ddlist));
lv_page_set_scrl_fit(ddlist, false, lv_page_get_scrl_fit_ver(ddlist));
lv_obj_set_width(ddlist, w);
} else {
lv_cont_set_fit(ddlist, true, lv_cont_get_ver_fit(ddlist));
lv_page_set_scrl_fit(ddlist, true, lv_page_get_scrl_fit_ver(ddlist));
}
lv_ddlist_refr_size(ddlist, 0);
}
/**
* Set the open/close animation time.
* @param ddlist pointer to a drop down list
* @param anim_time: open/close animation time [ms]
......
......@@ -94,7 +94,7 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action);
/**
* Set the fix height value.
* Set the fix height for the drop down list
* If 0 then the opened ddlist will be auto. sized else the set height will be applied.
* @param ddlist pointer to a drop down list
* @param h the height when the list is opened (0: auto size)
......@@ -102,6 +102,14 @@ void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action);
void lv_ddlist_set_fix_height(lv_obj_t * ddlist, cord_t h);
/**
* Set the fix width for the drop down list
* If 0 then the ddlist will be auto. sized else the set width will be applied.
* @param ddlist pointer to a drop down list
* @param w the new width (0: auto size)
*/
void lv_ddlist_set_fix_width(lv_obj_t * ddlist, cord_t w);
/**
* Set the scroll bar mode of a drop down list
* @param ddlist pointer to a drop down list object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
......
......@@ -406,8 +406,8 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask)
/*Draw the needle middle area*/
lv_style_t style_neddle_mid;
lv_style_copy(&style_neddle_mid, &lv_style_plain);
style_neddle_mid.body.color_main = style->body.border.color;
style_neddle_mid.body.color_gradient = style->body.border.color;
style_neddle_mid.body.main_color = style->body.border.color;
style_neddle_mid.body.gradient_color = style->body.border.color;
style_neddle_mid.body.radius = LV_RADIUS_CIRCLE;
area_t nm_cord;
......
......@@ -453,7 +453,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
continue; /*Skip the letter is it is part of a command*/
}
}
x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->text.letter_space;
x += font_get_width_scale(font, letter) + style->text.letter_space;
}
if(ext->align == LV_LABEL_ALIGN_CENTER) {
......@@ -528,7 +528,7 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos)
}
}
x += (font_get_width(font, letter) >> FONT_ANTIALIAS);
x += font_get_width_scale(font, letter);
if(pos->x < x) {
i = i_current;
break;
......@@ -739,17 +739,17 @@ static void lv_label_refr_text(lv_obj_t * label)
anim.var = label;
anim.repeat = 1;
anim.playback = 1;
anim.start = font_get_width(font, ' ') >> FONT_ANTIALIAS;
anim.start = font_get_width_scale(font, ' ');
anim.act_time = 0;
anim.end_cb = NULL;
anim.path = anim_get_path(ANIM_PATH_LIN);
anim.time = 3000;
anim.playback_pause = (((font_get_width(style->text.font, ' ') + style->text.letter_space) * 1000) / ext->anim_speed) * ANIM_WAIT_CHAR_COUNT;
anim.playback_pause = (((font_get_width_scale(style->text.font, ' ') + style->text.letter_space) * 1000) /ext->anim_speed)
* ANIM_WAIT_CHAR_COUNT;
anim.repeat_pause = anim.playback_pause;
if(lv_obj_get_width(label) > lv_obj_get_width(parent)) {
anim.end = lv_obj_get_width(parent) - lv_obj_get_width(label) -
(font_get_width(font, ' ') >> FONT_ANTIALIAS);
anim.end = lv_obj_get_width(parent) - lv_obj_get_width(label) - font_get_width_scale(font, ' ');
anim.fp = (anim_fp_t) lv_obj_set_x;
anim.time = anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
anim_create(&anim);
......@@ -767,17 +767,16 @@ static void lv_label_refr_text(lv_obj_t * label)
anim.var = label;
anim.repeat = 1;
anim.playback = 1;
anim.start = font_get_width(font, ' ') >> FONT_ANTIALIAS;
anim.start = font_get_width_scale(font, ' ');
anim.act_time = 0;
anim.end_cb = NULL;
anim.path = anim_get_path(ANIM_PATH_LIN);
anim.playback_pause = (((font_get_width(style->text.font, ' ') + style->text.letter_space) * 1000) / ext->anim_speed) * ANIM_WAIT_CHAR_COUNT;;
anim.playback_pause = (((font_get_width_scale(style->text.font, ' ') + style->text.letter_space) * 1000) / ext->anim_speed) * ANIM_WAIT_CHAR_COUNT;;
anim.repeat_pause = anim.playback_pause;
bool hor_anim = false;
if(size.x > lv_obj_get_width(label)) {
anim.end = lv_obj_get_width(label) - size.x -
(font_get_width(font, ' ') >> FONT_ANTIALIAS);
anim.end = lv_obj_get_width(label) - size.x - font_get_width_scale(font, ' ');
anim.fp = (anim_fp_t) lv_label_set_offset_x;
anim.time = anim_speed_to_time(LV_LABEL_SCROLL_SPEED, anim.start, anim.end);
anim_create(&anim);
......
......@@ -184,8 +184,8 @@ static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t
memcpy(&leds_tmp, style, sizeof(leds_tmp));
/*Mix. the color with black proportionally with brightness*/
leds_tmp.body.color_main = color_mix(leds_tmp.body.color_main, COLOR_BLACK, ext->bright);
leds_tmp.body.color_gradient = color_mix(leds_tmp.body.color_gradient, COLOR_BLACK, ext->bright);
leds_tmp.body.main_color = color_mix(leds_tmp.body.main_color, COLOR_BLACK, ext->bright);
leds_tmp.body.gradient_color = color_mix(leds_tmp.body.gradient_color, COLOR_BLACK, ext->bright);
leds_tmp.body.border.color = color_mix(leds_tmp.body.border.color, COLOR_BLACK, ext->bright);
/*Set the current swidth according to brightness proportionally between LV_LED_BRIGHT_OFF and LV_LED_BRIGHT_ON*/
......
......@@ -18,7 +18,7 @@
/*********************
* DEFINES
*********************/
#define LV_LIST_LAYOUT_DEF LV_CONT_LAYOUT_COL_M
#define LV_LIST_LAYOUT_DEF LV_LAYOUT_COL_M
#ifndef LV_LIST_FOCUS_TIME
#define LV_LIST_FOCUS_TIME 100 /*Animation time of focusing to the a list element [ms] (0: no animation) */
#endif
......@@ -151,7 +151,7 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, l
lv_btn_set_action(liste, LV_BTN_ACTION_REL, rel_action);
lv_page_glue_obj(liste, true);
lv_btn_set_layout(liste, LV_CONT_LAYOUT_ROW_M);
lv_btn_set_layout(liste, LV_LAYOUT_ROW_M);
lv_btn_set_fit(liste, false, true);
if(btn_signal == NULL) btn_signal = lv_obj_get_signal_func(liste);
......
......@@ -248,7 +248,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_m
int16_t level = (int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
uint8_t i;
style_tmp.line.color = style->body.color_main;
style_tmp.line.color = style->body.main_color;
for(i = 0; i < ext->line_cnt; i++) {
/*Calculate the position a scale label*/
......@@ -270,7 +270,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_m
if(i > level) style_tmp.line.color = style->line.color;
else {
style_tmp.line.color = color_mix(style->body.color_gradient, style->body.color_main, (255 * i) / ext->line_cnt);
style_tmp.line.color = color_mix(style->body.gradient_color, style->body.main_color, (255 * i) / ext->line_cnt);
}
lv_draw_line(&p1, &p2, mask, &style_tmp);
......
......@@ -75,7 +75,7 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
lv_label_set_long_mode(ext->text, LV_LABEL_LONG_BREAK);
lv_label_set_text(ext->text, "Message");
lv_cont_set_layout(new_mbox, LV_CONT_LAYOUT_COL_M);
lv_cont_set_layout(new_mbox, LV_LAYOUT_COL_M);
lv_cont_set_fit(new_mbox, false, true);
lv_obj_set_width(new_mbox, LV_HOR_RES / 3);
lv_obj_align(new_mbox, NULL, LV_ALIGN_CENTER, 0, 0);
......@@ -105,21 +105,24 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
return new_mbox;
}
/*======================
* Add/remove functions
*=====================*/
/**
* Set button to the message box
* Add button to the message box
* @param mbox pointer to message box object
* @param btn_map button descriptor (button matrix map).
* E.g. a const char *txt[] = {"ok", "close", ""} (Can not be local variable)
* @param action a function which will be called when a button is released
*/
void lv_mbox_set_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t action)
void lv_mbox_add_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t action)
{
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
/*Create a button matrix if not exists yet*/
if(ext->btnm == NULL) {
ext->btnm = lv_btnm_create(mbox, NULL);
lv_obj_set_height(ext->btnm, LV_DPI / 2);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
......@@ -362,8 +365,17 @@ static void mbox_realign(lv_obj_t *mbox)
lv_style_t *style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BG);
cord_t w = lv_obj_get_width(mbox) - 2 * style->body.padding.hor;
if(ext->btnm) lv_obj_set_width(ext->btnm, w);
if(ext->text) lv_obj_set_width(ext->text, w);
if(ext->text) {
lv_obj_set_width(ext->text, w);
}
if(ext->btnm) {
lv_style_t *btn_bg_style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BTN_BG);
lv_style_t *btn_rel_style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BTN_REL);
cord_t font_h = font_get_height_scale(btn_rel_style->text.font);
lv_obj_set_size(ext->btnm, w, font_h + 2 * btn_rel_style->body.padding.ver + 2 * btn_bg_style->body.padding.ver);
}
}
static lv_res_t lv_mbox_close_action(lv_obj_t *btn, const char *txt)
......
......@@ -75,14 +75,18 @@ typedef enum {
*/
lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy);
/*======================
* Add/remove functions
*=====================*/
/**
* Set button to the message box
* Add button to the message box
* @param mbox pointer to message box object
* @param btn_map button descriptor (button matrix map).
* E.g. a const char *txt[] = {"ok", "close", ""} (Can not be local variable)
* @param action a function which will be called when a button is released
*/
void lv_mbox_set_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t action);
void lv_mbox_add_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t action);
/*=====================
* Setter functions
......
......@@ -150,7 +150,7 @@ static inline void lv_page_set_scrl_height(lv_obj_t *page, cord_t h)
* @param page pointer to a page object
* @param layout a layout from 'lv_cont_layout_t'
*/
static inline void lv_page_set_scrl_layout(lv_obj_t * page, lv_cont_layout_t layout)
static inline void lv_page_set_scrl_layout(lv_obj_t * page, lv_layout_t layout)
{
lv_cont_set_layout(lv_page_get_scrl(page), layout);
}
......@@ -199,7 +199,7 @@ static inline cord_t lv_page_get_scrl_height(lv_obj_t *page)
* @param page pointer to page object
* @return the layout from 'lv_cont_layout_t'
*/
static inline lv_cont_layout_t lv_page_get_scrl_layout(lv_obj_t * page)
static inline lv_layout_t lv_page_get_scrl_layout(lv_obj_t * page)
{
return lv_cont_get_layout(lv_page_get_scrl(page));
}
......
......@@ -119,17 +119,6 @@ void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en)
}
/**
* Enable/disable to set the width of the roller manually (by lv_obj_Set_width())
* @param roller pointer to a roller object
* @param fit_en: true: enable auto size; false: use manual width settings
*/
void lv_roller_set_hor_fit(lv_obj_t *roller, bool fit_en)
{
lv_page_set_scrl_fit(roller, fit_en ,false);
lv_cont_set_fit(roller, fit_en ,false);
}
/**
* Set a style of a roller
* @param roller pointer to a roller object
* @param type which style should be set
......@@ -382,14 +371,14 @@ static void draw_bg(lv_obj_t *roller, const area_t *mask)
half_roller.y1 -= style->body.radius;
if(union_ok){
color_t main_tmp = style->body.color_main;
color_t grad_tmp = style->body.color_gradient;
color_t main_tmp = style->body.main_color;
color_t grad_tmp = style->body.gradient_color;
style->body.color_main = grad_tmp;
style->body.color_gradient = main_tmp;
style->body.main_color = grad_tmp;
style->body.gradient_color = main_tmp;
lv_draw_rect(&half_roller, &half_mask, style);
style->body.color_main = main_tmp;
style->body.color_gradient = grad_tmp;
style->body.main_color = main_tmp;
style->body.gradient_color = grad_tmp;
}
}
......
......@@ -72,6 +72,17 @@ static inline void lv_roller_set_options(lv_obj_t * roller, const char * options
void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en);
/**
* Set the fix width for the roller
* If 0 then the roller will be auto. sized else the set width will be applied.
* @param roller pointer to a drop down list
* @param w the new width (0: auto size)
*/
static inline void lv_roller_set_fix_width(lv_obj_t * roller, cord_t w)
{
lv_ddlist_set_fix_width(roller, w);
}
/**
* Set the open/close animation time.
* @param roller pointer to a roller object
* @param anim_time: open/close animation time [ms]
......@@ -81,12 +92,6 @@ static inline void lv_roller_set_anim_time(lv_obj_t *roller, uint16_t anim_time)
lv_ddlist_set_anim_time(roller, anim_time);
}
/**
* Enable/disable to set the width of the roller manually (by lv_obj_Set_width())
* @param roller pointer to a roller object
* @param fit_en: true: enable auto size; false: use manual width settings
*/
void lv_roller_set_hor_fit(lv_obj_t *roller, bool fit_en);
/**
* Set a style of a roller
......
......@@ -84,14 +84,13 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
/*Allocate the object type specific extended data*/
lv_ta_ext_t * ext = lv_obj_allocate_ext_attr(new_ta, sizeof(lv_ta_ext_t));
dm_assert(ext);
ext->cursor_show = 1;
ext->cursor_state = 0;
ext->cursor.state = 0;
ext->pwd_mode = 0;
ext->pwd_tmp = NULL;
ext->cursor_style = NULL;
ext->cursor_pos = 0;
ext->cursor_type = LV_TA_CURSOR_LINE;
ext->cursor_valid_x = 0;
ext->cursor.style = NULL;
ext->cursor.pos = 0;
ext->cursor.type = LV_CURSOR_LINE;
ext->cursor.valid_x = 0;
ext->label = NULL;
......@@ -126,11 +125,11 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrollable_design);
lv_ta_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->label = lv_label_create(new_ta, copy_ext->label);
ext->cursor_show = copy_ext->cursor_show;
ext->pwd_mode = copy_ext->pwd_mode;
ext->cursor_style = copy_ext->cursor_style;
ext->cursor_pos = copy_ext->cursor_pos;
ext->cursor_valid_x = copy_ext->cursor_valid_x;
ext->cursor.style = copy_ext->cursor.style;
ext->cursor.pos = copy_ext->cursor.pos;
ext->cursor.valid_x = copy_ext->cursor.valid_x;
ext->cursor.type = copy_ext->cursor.type;
if(copy_ext->one_line) lv_ta_set_one_line(new_ta, true);
lv_ta_set_style(new_ta, LV_TA_STYLE_CURSOR, lv_ta_get_style(copy, LV_TA_STYLE_CURSOR));
......@@ -176,13 +175,13 @@ void lv_ta_add_char(lv_obj_t * ta, char c)
letter_buf[0] = c;
letter_buf[1] = '\0';
lv_label_ins_text(ext->label, ext->cursor_pos, letter_buf); /*Insert the character*/
lv_label_ins_text(ext->label, ext->cursor.pos, letter_buf); /*Insert the character*/
if(ext->pwd_mode != 0) {
ext->pwd_tmp = dm_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */
dm_assert(ext->pwd_tmp);
txt_ins(ext->pwd_tmp, ext->cursor_pos, letter_buf);
txt_ins(ext->pwd_tmp, ext->cursor.pos, letter_buf);
anim_t a;
a.var = ta;
......@@ -217,12 +216,12 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/
/*Insert the text*/
lv_label_ins_text(ext->label, ext->cursor_pos, txt);
lv_label_ins_text(ext->label, ext->cursor.pos, txt);
if(ext->pwd_mode != 0) {
ext->pwd_tmp = dm_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + strlen(txt) + 1);
dm_assert(ext->pwd_tmp);
txt_ins(ext->pwd_tmp, ext->cursor_pos, txt);
txt_ins(ext->pwd_tmp, ext->cursor.pos, txt);
anim_t a;
a.var = ta;
......@@ -251,13 +250,13 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
void lv_ta_del_char(lv_obj_t * ta)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
uint16_t cur_pos = ext->cursor_pos;
uint16_t cur_pos = ext->cursor.pos;
if(cur_pos == 0) return;
char * label_txt = lv_label_get_text(ext->label);
/*Delete a character*/
txt_cut(label_txt, ext->cursor_pos - 1, 1);
txt_cut(label_txt, ext->cursor.pos - 1, 1);
/*Refresh the label*/
lv_label_set_text(ext->label, label_txt);
......@@ -269,17 +268,17 @@ void lv_ta_del_char(lv_obj_t * ta)
if(ext->pwd_mode != 0) {
#if TXT_UTF8 == 0
txt_cut(ext->pwd_tmp, ext->cursor_pos - 1, 1);
txt_cut(ext->pwd_tmp, ext->cursor.pos - 1, 1);
#else
uint32_t byte_pos = txt_utf8_get_byte_id(ext->pwd_tmp, ext->cursor_pos - 1);
txt_cut(ext->pwd_tmp, ext->cursor_pos - 1, txt_utf8_size(label_txt[byte_pos]));
uint32_t byte_pos = txt_utf8_get_byte_id(ext->pwd_tmp, ext->cursor.pos - 1);
txt_cut(ext->pwd_tmp, ext->cursor.pos - 1, txt_utf8_size(label_txt[byte_pos]));
#endif
ext->pwd_tmp = dm_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 1);
dm_assert(ext->pwd_tmp);
}
/*Move the cursor to the place of the deleted character*/
lv_ta_set_cursor_pos(ta, ext->cursor_pos - 1);
lv_ta_set_cursor_pos(ta, ext->cursor.pos - 1);
}
/*=====================
......@@ -300,7 +299,7 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt)
/*Don't let 'width == 0' because cursor will not be visible*/
if(lv_obj_get_width(ext->label) == 0) {
lv_style_t * style = lv_obj_get_style(ext->label);
lv_obj_set_width(ext->label, font_get_width(style->text.font, ' '));
lv_obj_set_width(ext->label, font_get_width_scale(style->text.font, ' '));
}
if(ext->pwd_mode != 0) {
......@@ -340,7 +339,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
if(pos > len || pos == LV_TA_CURSOR_LAST) pos = len;
ext->cursor_pos = pos;
ext->cursor.pos = pos;
/*Position the label to make the cursor visible*/
lv_obj_t * label_par = lv_obj_get_parent(ext->label);
......@@ -375,7 +374,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
font_h + 2 * style->body.padding.hor));
}
ext->cursor_valid_x = cur_pos.x;
ext->cursor.valid_x = cur_pos.x;
/*Reset cursor blink animation*/
anim_t a;
......@@ -397,27 +396,14 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
}
/**
* Set the cursor visibility.
* @param ta pointer to a text area object
* @return show true: show the cursor and blink it, false: hide cursor
*/
void lv_ta_set_cursor_show(lv_obj_t * ta, bool show)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
ext->cursor_show = show == false ? 0 : 1;
ext->cursor_state = 0;
lv_obj_invalidate(ta);
}
/**
* Set the cursor type.
* @param ta pointer to a text area object
* @param cur_type: element of 'lv_ta_cursor_type_t'
*/
void lv_ta_set_cursor_type(lv_obj_t * ta, lv_ta_cursor_type_t cur_type)
void lv_ta_set_cursor_type(lv_obj_t * ta, lv_cursor_type_t cur_type)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
ext->cursor_type = cur_type;
ext->cursor.type = cur_type;
lv_obj_invalidate(ta);
}
......@@ -506,7 +492,7 @@ void lv_ta_set_style(lv_obj_t *ta, lv_ta_style_t type, lv_style_t *style)
lv_page_set_style(ta, LV_PAGE_STYLE_SB, style);
break;
case LV_TA_STYLE_CURSOR:
ext->cursor_style = style;
ext->cursor.style = style;
lv_obj_refresh_ext_size(lv_page_get_scrl(ta)); /*Refresh ext. size because of cursor drawing*/
break;
}
......@@ -556,18 +542,7 @@ lv_obj_t * lv_ta_get_label(lv_obj_t * ta)
uint16_t lv_ta_get_cursor_pos(lv_obj_t * ta)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
return ext->cursor_pos;
}
/**
* Get the current cursor visibility.
* @param ta pointer to a text area object
* @return true: the cursor is drawn, false: the cursor is hidden
*/
bool lv_ta_get_cursor_show(lv_obj_t * ta)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
return ext->cursor_show;
return ext->cursor.pos;
}
/**
......@@ -575,10 +550,10 @@ bool lv_ta_get_cursor_show(lv_obj_t * ta)
* @param ta pointer to a text area object
* @return element of 'lv_ta_cursor_type_t'
*/
lv_ta_cursor_type_t lv_ta_get_cursor_type(lv_obj_t * ta)
lv_cursor_type_t lv_ta_get_cursor_type(lv_obj_t * ta)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
return ext->cursor_type;
return ext->cursor.type;
}
/**
......@@ -616,7 +591,7 @@ lv_style_t * lv_ta_get_style(lv_obj_t *ta, lv_ta_style_t type)
switch (type) {
case LV_TA_STYLE_BG: return lv_page_get_style(ta, LV_PAGE_STYLE_BG);
case LV_TA_STYLE_SB: return lv_page_get_style(ta, LV_PAGE_STYLE_SB);
case LV_TA_STYLE_CURSOR: return ext->cursor_style; /*TODO in 'ext' all cursor attributes into a struct*/
case LV_TA_STYLE_CURSOR: return ext->cursor.style;
default: return NULL;
}
......@@ -669,16 +644,16 @@ void lv_ta_cursor_down(lv_obj_t * ta)
const font_t * font_p = label_style->text.font;
cord_t font_h = font_get_height_scale(font_p);
pos.y += font_h + label_style->text.line_space + 1;
pos.x = ext->cursor_valid_x;
pos.x = ext->cursor.valid_x;
/*Do not go below the last line*/
if(pos.y < lv_obj_get_height(ext->label)) {
/*Get the letter index on the new cursor position and set it*/
uint16_t new_cur_pos = lv_label_get_letter_on(ext->label, &pos);
cord_t cur_valid_x_tmp = ext->cursor_valid_x; /*Cursor position set overwrites the valid positon */
cord_t cur_valid_x_tmp = ext->cursor.valid_x; /*Cursor position set overwrites the valid positon */
lv_ta_set_cursor_pos(ta, new_cur_pos);
ext->cursor_valid_x = cur_valid_x_tmp;
ext->cursor.valid_x = cur_valid_x_tmp;
}
}
......@@ -699,14 +674,14 @@ void lv_ta_cursor_up(lv_obj_t * ta)
const font_t * font = label_style->text.font;
cord_t font_h = font_get_height_scale(font);
pos.y -= font_h + label_style->text.line_space - 1;
pos.x = ext->cursor_valid_x;
pos.x = ext->cursor.valid_x;
/*Get the letter index on the new cursor position and set it*/
uint16_t new_cur_pos = lv_label_get_letter_on(ext->label, &pos);
cord_t cur_valid_x_tmp = ext->cursor_valid_x; /*Cursor position set overwrites the valid positon */
cord_t cur_valid_x_tmp = ext->cursor.valid_x; /*Cursor position set overwrites the valid positon */
lv_ta_set_cursor_pos(ta, new_cur_pos);
ext->cursor_valid_x = cur_valid_x_tmp;
ext->cursor.valid_x = cur_valid_x_tmp;
}
/**********************
......@@ -763,20 +738,25 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const area_t * mask, lv_des
lv_obj_t * ta = lv_obj_get_parent(scrl);
lv_ta_ext_t * ta_ext = lv_obj_get_ext_attr(ta);
lv_style_t * label_style = lv_obj_get_style(ta_ext->label);
if(ta_ext->cursor_show == 0 || ta_ext->cursor_state == 0 || label_style->body.opa == OPA_TRANSP) return true; /*The cursor is not visible now*/
if(ta_ext->cursor.type == LV_CURSOR_NONE ||
ta_ext->cursor.state == 0 ||
label_style->body.opa == OPA_TRANSP)
{
return true; /*The cursor is not visible now*/
}
lv_style_t cur_style;
if(ta_ext->cursor_style != NULL) {
lv_style_copy(&cur_style, ta_ext->cursor_style);
if(ta_ext->cursor.style != NULL) {
lv_style_copy(&cur_style, ta_ext->cursor.style);
}
else {
/*If cursor style is not specified then use the modified label style */
lv_style_copy(&cur_style, label_style);
color_t ccolor_tmp = cur_style.text.color; /*Make letter color to cursor color*/
cur_style.text.color = cur_style.body.color_main; /*In block mode the letter color will be current background color*/
cur_style.body.color_main = ccolor_tmp;
cur_style.body.color_gradient = ccolor_tmp;
cur_style.text.color = cur_style.body.main_color; /*In block mode the letter color will be current background color*/
cur_style.body.main_color = ccolor_tmp;
cur_style.body.gradient_color = ccolor_tmp;
cur_style.body.border.color = ccolor_tmp;
cur_style.body.border.opa = OPA_COVER;
cur_style.body.border.width = 1 << LV_ANTIALIAS;
......@@ -803,9 +783,9 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const area_t * mask, lv_des
/*Set letter_w (set not 0 on non printable but valid chars)*/
cord_t letter_w;
if(letter == '\0' || letter == '\n' || letter == '\r') {
letter_w = font_get_width(label_style->text.font, ' ');
letter_w = font_get_width_scale(label_style->text.font, ' ');
} else {
letter_w = font_get_width(label_style->text.font, letter);
letter_w = font_get_width_scale(label_style->text.font, letter);
}
point_t letter_pos;
......@@ -822,21 +802,21 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const area_t * mask, lv_des
}
if(letter == '\0' || letter == '\n' || letter == '\r') {
letter_w = font_get_width(label_style->text.font, ' ');
letter_w = font_get_width_scale(label_style->text.font, ' ');
} else {
letter_w = font_get_width(label_style->text.font, letter);
letter_w = font_get_width_scale(label_style->text.font, letter);
}
}
/*Draw he cursor according to the type*/
area_t cur_area;
if(ta_ext->cursor_type == LV_TA_CURSOR_LINE) {
if(ta_ext->cursor.type == LV_CURSOR_LINE) {
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor - (cur_style.line.width >> 1) - (cur_style.line.width & 0x1);
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver;
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + (cur_style.line.width >> 1);
cur_area.y2 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h;
lv_draw_rect(&cur_area, mask, &cur_style);
} else if(ta_ext->cursor_type == LV_TA_CURSOR_BLOCK) {
} else if(ta_ext->cursor.type == LV_CURSOR_BLOCK) {
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 - cur_style.body.padding.hor;
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 - cur_style.body.padding.ver;
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + letter_w;
......@@ -857,7 +837,7 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const area_t * mask, lv_des
cur_area.y1 += cur_style.body.padding.ver;
lv_draw_label(&cur_area, mask, &cur_style, letter_buf, TXT_FLAG_NONE, 0);
} else if(ta_ext->cursor_type == LV_TA_CURSOR_OUTLINE) {
} else if(ta_ext->cursor.type == LV_CURSOR_OUTLINE) {
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 - cur_style.body.padding.hor;
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 - cur_style.body.padding.ver;
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + letter_w;
......@@ -866,7 +846,7 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const area_t * mask, lv_des
cur_style.body.empty = 1;
if(cur_style.body.border.width == 0) cur_style.body.border.width = 1 << LV_ANTIALIAS; /*Be sure the border will be drawn*/
lv_draw_rect(&cur_area, mask, &cur_style);
} else if(ta_ext->cursor_type == LV_TA_CURSOR_UNDERLINE) {
} else if(ta_ext->cursor.type == LV_CURSOR_UNDERLINE) {
cur_area.x1 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor;
cur_area.y1 = letter_pos.y + ta_ext->label->coords.y1 + cur_style.body.padding.ver + letter_h - (cur_style.line.width >> 1);
cur_area.x2 = letter_pos.x + ta_ext->label->coords.x1 + cur_style.body.padding.hor + letter_w;
......@@ -982,9 +962,9 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void
static void cursor_blink_anim(lv_obj_t * ta, uint8_t show)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
if(show != ext->cursor_state) {
ext->cursor_state = show == 0 ? 0 : 1;
if(ext->cursor_show != 0) lv_obj_invalidate(ta);
if(show != ext->cursor.state) {
ext->cursor.state = show == 0 ? 0 : 1;
if(ext->cursor.show != 0) lv_obj_invalidate(ta);
}
}
......
......@@ -39,11 +39,12 @@ extern "C" {
**********************/
typedef enum {
LV_TA_CURSOR_LINE,
LV_TA_CURSOR_BLOCK,
LV_TA_CURSOR_OUTLINE,
LV_TA_CURSOR_UNDERLINE,
}lv_ta_cursor_type_t;
LV_CURSOR_NONE,
LV_CURSOR_LINE,
LV_CURSOR_BLOCK,
LV_CURSOR_OUTLINE,
LV_CURSOR_UNDERLINE,
}lv_cursor_type_t;
/*Data of text area*/
typedef struct
......@@ -51,15 +52,16 @@ typedef struct
lv_page_ext_t page; /*Ext. of ancestor*/
/*New data for this type */
lv_obj_t * label; /*Label of the text area*/
lv_style_t * cursor_style; /*Style of the cursor (NULL to use label's style)*/
char * pwd_tmp; /*Used to store the original text in password mode*/
cord_t cursor_valid_x; /*Used when stepping up/down in text area when stepping to a shorter line. (Handled by the library)*/
uint16_t cursor_pos; /*The current cursor position (0: before 1. letter; 1: before 2. letter etc.)*/
lv_ta_cursor_type_t cursor_type; /*Shape of the cursor*/
uint8_t cursor_show :1; /*Show or hide cursor */
uint8_t pwd_mode :1; /*Replace characters with '*' */
uint8_t one_line :1; /*One line mode (ignore line breaks)*/
uint8_t cursor_state :1; /*Indicates that the cursor is visible now or not (Handled by the library)*/
struct {
lv_style_t *style; /*Style of the cursor (NULL to use label's style)*/
cord_t valid_x; /*Used when stepping up/down in text area when stepping to a shorter line. (Handled by the library)*/
uint16_t pos; /*The current cursor position (0: before 1. letter; 1: before 2. letter etc.)*/
lv_cursor_type_t type; /*Shape of the cursor*/
uint8_t state :1; /*Indicates that the cursor is visible now or not (Handled by the library)*/
}cursor;
}lv_ta_ext_t;
typedef enum {
......@@ -127,18 +129,11 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt);
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos);
/**
* Set the cursor visibility.
* @param ta pointer to a text area object
* @return show true: show the cursor and blink it, false: hide cursor
*/
void lv_ta_set_cursor_show(lv_obj_t * ta, bool show);
/**
* Set the cursor type.
* @param ta pointer to a text area object
* @param cur_type: element of 'lv_ta_cursor_type_t'
* @param cur_type: element of 'lv_cursor_type_t'
*/
void lv_ta_set_cursor_type(lv_obj_t * ta, lv_ta_cursor_type_t cur_type);
void lv_ta_set_cursor_type(lv_obj_t * ta, lv_cursor_type_t cur_type);
/**
* Enable/Disable password mode
* @param ta pointer to a text area object
......@@ -206,9 +201,9 @@ bool lv_ta_get_cursor_show(lv_obj_t * ta);
/**
* Get the current cursor type.
* @param ta pointer to a text area object
* @return element of 'lv_ta_cursor_type_t'
* @return element of 'lv_cursor_type_t'
*/
lv_ta_cursor_type_t lv_ta_get_cursor_type(lv_obj_t * ta);
lv_cursor_type_t lv_ta_get_cursor_type(lv_obj_t * ta);
/**
* Get the password mode attribute
......
......@@ -103,7 +103,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
ext->content = lv_cont_create(new_tabview, NULL);
lv_cont_set_fit(ext->content, true, false);
lv_cont_set_layout(ext->content, LV_CONT_LAYOUT_ROW_T);
lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T);
lv_cont_set_style(ext->content, &lv_style_transp_tight);
lv_obj_set_height(ext->content, LV_VER_RES - lv_obj_get_height(ext->btns));
lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
......
......@@ -20,9 +20,6 @@
/**********************
* STATIC PROTOTYPES
**********************/
static void create_tab1(lv_theme_t * th, lv_obj_t *parent);
static void create_tab2(lv_theme_t * th, lv_obj_t *parent);
static void create_tab3(lv_theme_t * th, lv_obj_t *parent);
/**********************
* STATIC VARIABLES
......@@ -56,249 +53,6 @@ lv_theme_t * lv_theme_get_current(void)
return current_theme;
}
/**
* Create a test screen with a lot objects and apply the given theme on them
* @param th pointer to a theme
*/
void lv_theme_create_test_screen(lv_theme_t *th)
{
lv_theme_set_current(th);
lv_obj_t *scr = lv_cont_create(NULL, NULL);
lv_scr_load(scr);
lv_cont_set_style(scr, th->bg);
lv_obj_t *tv = lv_tabview_create(scr, NULL);
lv_obj_set_size(tv, LV_HOR_RES, LV_VER_RES);
lv_obj_t *tab1 = lv_tabview_add_tab(tv, "Tab 1");
lv_obj_t *tab2 = lv_tabview_add_tab(tv, "Tab 2");
lv_obj_t *tab3 = lv_tabview_add_tab(tv, "Tab 3");
create_tab1(th, tab1);
create_tab2(th, tab2);
create_tab3(th, tab3);
lv_tabview_set_current_tab(tv, 2, false);
}
/**********************
* STATIC FUNCTIONS
**********************/
static void create_tab1(lv_theme_t * th, lv_obj_t *parent)
{
lv_page_set_scrl_layout(parent, LV_CONT_LAYOUT_PRETTY);
static lv_style_t h_style;
lv_style_copy(&h_style, &lv_style_transp);
h_style.body.padding.inner = LV_DPI / 4;
h_style.body.padding.hor = LV_DPI / 4;
h_style.body.padding.ver = LV_DPI / 6;
lv_obj_t *h = lv_cont_create(parent, NULL);
lv_obj_set_style(h, &h_style);
lv_cont_set_fit(h, true, true);
lv_cont_set_layout(h, LV_CONT_LAYOUT_COL_M);
lv_obj_t *btn = lv_btn_create(h, NULL);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, th->btn.sm.rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, th->btn.sm.pr);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_REL, th->btn.sm.tgl_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_PR, th->btn.sm.tgl_pr);
lv_btn_set_style(btn, LV_BTN_STYLE_INA, th->btn.sm.ina);
lv_btn_set_fit(btn, true, true);
lv_btn_set_toggle(btn, true);
lv_obj_t *btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Small");
btn = lv_btn_create(h, btn);
lv_btn_toggle(btn);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Toggled");
btn = lv_btn_create(h, btn);
lv_btn_set_state(btn, LV_BTN_STATE_INA);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Inactive");
btn = lv_btn_create(h, btn);
lv_btn_set_state(btn, LV_BTN_STATE_REL);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Medium");
btn = lv_btn_create(h, btn);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, th->btn.lg.rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, th->btn.lg.pr);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_REL, th->btn.lg.tgl_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_PR, th->btn.lg.tgl_pr);
lv_btn_set_style(btn, LV_BTN_STYLE_INA, th->btn.lg.ina);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Large");
lv_obj_t *label = lv_label_create(h, NULL);
lv_label_set_text(label, "Small");
lv_obj_set_style(label, th->label.sm);
label = lv_label_create(h, NULL);
lv_label_set_text(label, "Medium");
lv_obj_set_style(label, th->label.md);
label = lv_label_create(h, NULL);
lv_label_set_text(label, "Large");
lv_obj_set_style(label, th->label.lg);
lv_obj_set_protect(label, LV_PROTECT_FOLLOW);
h = lv_cont_create(parent, h);
lv_obj_t *sw_h = lv_cont_create(h, NULL);
lv_cont_set_style(sw_h, &lv_style_transp);
lv_cont_set_fit(sw_h, false, true);
lv_obj_set_width(sw_h, LV_HOR_RES / 4);
lv_cont_set_layout(sw_h, LV_CONT_LAYOUT_PRETTY);
lv_obj_t *sw = lv_sw_create(sw_h, NULL);
sw = lv_sw_create(sw_h, sw);
lv_sw_set_on(sw);
lv_obj_t *bar = lv_bar_create(h, NULL);
lv_bar_set_value(bar, 70);
lv_obj_t *slider = lv_slider_create(h, NULL);
lv_obj_set_height(slider, LV_DPI / 2);
lv_bar_set_value(slider, 70);
lv_obj_t *line = lv_line_create(h, NULL);
static const point_t line_p[] = {{0,0},{LV_HOR_RES / 5, 0}};
lv_line_set_points(line, line_p, 2);
lv_line_set_style(line, th->line.decor);
lv_obj_t *ta = lv_ta_create(h, NULL);
lv_obj_set_style(ta, th->ta.oneline);
lv_ta_set_text(ta, "Some text");
lv_ta_set_one_line(ta, true);
lv_obj_t *cb = lv_cb_create(h, NULL);
cb = lv_cb_create(h, cb);
lv_btn_set_state(cb, LV_BTN_STATE_TGL_REL);
lv_obj_t *ddlist = lv_ddlist_create(h, NULL);
lv_ddlist_open(ddlist, false);
lv_ddlist_set_selected(ddlist, 1);
static const char *btnm_str[] = {"1", "2", "3", SYMBOL_OK, SYMBOL_CLOSE, ""};
lv_obj_t *btnm = lv_btnm_create(h, NULL);
lv_obj_set_size(btnm,LV_HOR_RES / 4, 2 * LV_DPI / 3);
lv_btnm_set_map(btnm, btnm_str);
((lv_btnm_ext_t *) btnm->ext_attr)->btn_id_pr = 3; /*Hack to show a button pressed*/
h = lv_cont_create(parent, h);
lv_obj_t * list = lv_list_create(h, NULL);
lv_list_add(list, SYMBOL_GPS, "GPS", NULL);
lv_list_add(list, SYMBOL_WIFI, "WiFi", NULL);
lv_list_add(list, SYMBOL_CALL, "Call", NULL);
lv_list_add(list, SYMBOL_BELL, "Bell", NULL);
lv_list_add(list, SYMBOL_FILE, "File", NULL);
lv_list_add(list, SYMBOL_EDIT, "Edit", NULL);
lv_list_add(list, SYMBOL_CUT, "Cut", NULL);
lv_list_add(list, SYMBOL_COPY, "Copy", NULL);
lv_obj_t *roller = lv_roller_create(h, NULL);
lv_roller_set_options(roller, "Monday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\nSunday");
lv_obj_set_height(roller, LV_DPI);
lv_obj_t *gauge = lv_gauge_create(h, NULL);
lv_gauge_set_value(gauge, 0, 40);
lv_obj_set_size(gauge, 3 * LV_DPI / 2, 3 * LV_DPI / 2);
}
static void create_tab2(lv_theme_t * th, lv_obj_t *parent)
{
cord_t w = lv_page_get_scrl_width(parent);
lv_obj_t *chart = lv_chart_create(parent, NULL);
lv_chart_series_t * s1 = lv_chart_add_series(chart, COLOR_RED);
lv_chart_set_next(chart, s1, 30);
lv_chart_set_next(chart, s1, 20);
lv_chart_set_next(chart, s1, 10);
lv_chart_set_next(chart, s1, 12);
lv_chart_set_next(chart, s1, 20);
lv_chart_set_next(chart, s1, 27);
lv_chart_set_next(chart, s1, 35);
lv_chart_set_next(chart, s1, 55);
lv_chart_set_next(chart, s1, 70);
lv_chart_set_next(chart, s1, 75);
lv_obj_t *ta = lv_ta_create(parent, NULL);
lv_obj_set_size(ta, w / 3, LV_VER_RES / 4);
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
lv_ta_set_cursor_type(ta, LV_TA_CURSOR_BLOCK);
lv_obj_t *kb = lv_kb_create(parent, NULL);
lv_obj_set_size(kb, w / 2, LV_VER_RES / 3);
lv_obj_align(kb, ta, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, LV_DPI / 4);
lv_kb_set_ta(kb, ta);
}
static void create_tab3(lv_theme_t * th, lv_obj_t *parent)
{
lv_obj_t *win = lv_win_create(parent, NULL);
lv_win_add_btn(win, SYMBOL_CLOSE, lv_win_close_action);
lv_win_add_btn(win, SYMBOL_DOWN, NULL);
lv_obj_set_size(win, LV_HOR_RES / 2, LV_VER_RES / 2);
lv_obj_set_top(win, true);
lv_obj_t *label = lv_label_create(win, NULL);
lv_label_set_text(label, "Label in the window");
lv_obj_t *lmeter = lv_lmeter_create(win, NULL);
lv_obj_align(lmeter, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 2);
lv_lmeter_set_value(lmeter, 70);
lv_obj_t *led1 = lv_led_create(win, NULL);
lv_obj_align(led1, lmeter, LV_ALIGN_OUT_BOTTOM_MID, 0, LV_DPI / 2);
lv_led_on(led1);
lv_obj_t *led2 = lv_led_create(win, NULL);
lv_obj_align(led2, led1, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 2, 0);
lv_led_off(led2);
lv_obj_t *page = lv_page_create(parent, NULL);
lv_obj_set_size(page, LV_HOR_RES / 3, LV_VER_RES / 2);
lv_obj_set_top(page, true);
lv_obj_align(page, win, LV_ALIGN_IN_TOP_RIGHT, LV_DPI, LV_DPI);
label = lv_label_create(page, NULL);
lv_label_set_text(label, "Lorem ipsum dolor sit amet, repudiare voluptatibus pri cu. "
"Ei mundi pertinax posidonium eum, cum tempor maiorum at, "
"mea fuisset assentior ad. Usu cu suas civibus iudicabit. "
"Eum eu congue tempor facilisi. Tale hinc unum te vim. "
"Te cum populo animal eruditi, labitur inciderint at nec.\n\n"
"Eius corpora et quo. Everti voluptaria instructior est id, "
"vel in falli primis. Mea ei porro essent admodum, "
"his ei malis quodsi, te quis aeterno his. "
"Qui tritani recusabo reprehendunt ne, "
"per duis explicari at. Simul mediocritatem mei et.");
lv_label_set_long_mode(label, LV_LABEL_LONG_BREAK);
lv_obj_set_width(label, lv_page_get_scrl_width(page));
static const char * mbox_btn_map[] = {"\211", "\222Got it!", "\211", ""};
lv_obj_t *mbox = lv_mbox_create(parent, NULL);
lv_mbox_set_text(mbox, "Click on the window or the page to bring it to the foreground");
lv_mbox_set_btns(mbox, mbox_btn_map, NULL);
lv_obj_set_top(mbox, true);
}
......@@ -36,37 +36,19 @@ typedef struct {
#endif
#if USE_LV_BTN != 0
struct {
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}sm;
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}md;
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}lg;
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}btn;
#endif
#if USE_LV_LABEL != 0
struct {
lv_style_t *sm;
lv_style_t *md;
lv_style_t *lg;
lv_style_t *prim;
lv_style_t *sec;
lv_style_t *hint;
}label;
#endif
......@@ -265,12 +247,6 @@ void lv_theme_set_current(lv_theme_t *th);
*/
lv_theme_t * lv_theme_get_current(void);
/**
* Create a test screen with a lot objects and apply the given theme on them
* @param th pointer to a theme
*/
void lv_theme_create_test_screen(lv_theme_t *th);
/**********************
* MACROS
**********************/
......@@ -278,6 +254,7 @@ void lv_theme_create_test_screen(lv_theme_t *th);
/**********************
* POST INCLUDE
*********************/
#include "lv_theme_templ.h"
#include "lv_theme_alien.h"
#ifdef __cplusplus
......
......@@ -33,10 +33,8 @@ static lv_style_t def;
static lv_style_t bg;
static lv_style_t panel; /*General fancy background (for e.g. chart or ta)*/
static lv_style_t sb;
static lv_style_t label_sm, label_md, label_lg;
static lv_style_t btn_sm_rel, btn_sm_pr, btn_sm_trel, btn_sm_tpr, btn_sm_ina;
static lv_style_t btn_md_rel, btn_md_pr, btn_md_trel, btn_md_tpr, btn_md_ina;
static lv_style_t btn_lg_rel, btn_lg_pr, btn_lg_trel, btn_lg_tpr, btn_lg_ina;
static lv_style_t label_prim, label_sec, label_hint;
static lv_style_t btn_rel, btn_pr, btn_trel, btn_tpr, btn_ina;
static lv_style_t img_light, img_dark;
static lv_style_t line_decor;
static lv_style_t led;
......@@ -50,14 +48,14 @@ static lv_style_t ddlist_bg, ddlist_sel;
static lv_style_t roller_bg, roller_sel;
static lv_style_t cb_bg, cb_rel, cb_pr, cb_trel, cb_tpr, cb_ina;
static lv_style_t btnm_bg, btnm_rel, btnm_pr, btnm_trel, btnm_ina;
static lv_style_t mbox_bg, mbox_btn_rel, mbox_btn_pr;
static lv_style_t mbox_bg;
static lv_style_t tab_rel, tab_pr, tab_trel, tab_tpr, tab_indic;
static lv_style_t win_header;
static uint16_t _hue;
static font_t * _font_sm;
static font_t * _font_md;
static font_t * _font_lg;
static font_t * _font;
static font_t * _font;
static font_t * _font;
/**********************
* MACROS
......@@ -75,8 +73,8 @@ static void basic_init(void)
def.glass = 0;
def.body.empty = 0;
def.body.color_main = COLOR_HEX3(0x222);
def.body.color_gradient = COLOR_HEX3(0x222);
def.body.main_color = COLOR_HEX3(0x222);
def.body.gradient_color = COLOR_HEX3(0x222);
def.body.radius = 0;
def.body.padding.hor = LV_DPI / 8;
def.body.padding.ver = LV_DPI / 8;
......@@ -89,7 +87,7 @@ static void basic_init(void)
def.body.shadow.type = LV_SHADOW_FULL;
def.text.color = COLOR_HEX3(0xDDD);
def.text.font = _font_sm;
def.text.font = _font;
def.text.letter_space = 1 << LV_ANTIALIAS;
def.text.line_space = 2 << LV_ANTIALIAS;
......@@ -101,8 +99,8 @@ static void basic_init(void)
/*Background*/
lv_style_copy(&bg, &def);
bg.body.color_main = COLOR_HEX3(0x333);
bg.body.color_gradient = COLOR_HEX3(0x333);
bg.body.main_color = COLOR_HEX3(0x333);
bg.body.gradient_color = COLOR_HEX3(0x333);
bg.body.border.width = 0;
bg.body.border.opa = OPA_70;
bg.body.shadow.color = COLOR_SILVER;
......@@ -110,8 +108,8 @@ static void basic_init(void)
/*Panel*/
lv_style_copy(&panel, &def);
panel.body.radius = LV_DPI / 10;
panel.body.color_main = COLOR_HEX3(0x666);
panel.body.color_gradient = COLOR_HEX3(0x666);
panel.body.main_color = COLOR_HEX3(0x666);
panel.body.gradient_color = COLOR_HEX3(0x666);
panel.body.border.color = COLOR_HEX3(0xccc);
panel.body.border.width = 2 << LV_ANTIALIAS;
panel.body.border.opa = OPA_60;
......@@ -125,8 +123,8 @@ static void basic_init(void)
sb.body.border.color = COLOR_SILVER;
sb.body.border.opa = OPA_40;
sb.body.border.width = 1 << LV_ANTIALIAS;
sb.body.color_main = color_hsv_to_rgb(_hue, 33, 92);
sb.body.color_gradient = color_hsv_to_rgb(_hue, 33, 92);
sb.body.main_color = color_hsv_to_rgb(_hue, 33, 92);
sb.body.gradient_color = color_hsv_to_rgb(_hue, 33, 92);
sb.body.padding.hor = 1 << LV_ANTIALIAS;
sb.body.padding.ver = 1 << LV_ANTIALIAS;
sb.body.padding.inner = LV_DPI / 15; /*Scrollbar width*/
......@@ -139,129 +137,59 @@ static void basic_init(void)
static void btn_init(void)
{
#if USE_LV_BTN != 0
lv_style_copy(&btn_sm_rel, &def);
btn_sm_rel.glass = 0;
btn_sm_rel.body.empty = 1;
btn_sm_rel.body.radius = LV_RADIUS_CIRCLE;
btn_sm_rel.body.border.width = 2 << LV_ANTIALIAS;
btn_sm_rel.body.border.color = color_hsv_to_rgb(_hue, 70, 90);
btn_sm_rel.body.border.opa = OPA_80;
btn_sm_rel.body.padding.hor = LV_DPI / 4;
btn_sm_rel.body.padding.ver = LV_DPI / 6;
btn_sm_rel.body.padding.inner = LV_DPI / 10;
btn_sm_rel.text.color = color_hsv_to_rgb(_hue, 8, 96);
btn_sm_rel.text.font = _font_sm;
lv_style_copy(&btn_sm_pr, &btn_sm_rel);
btn_sm_pr.body.opa = OPA_COVER;
btn_sm_pr.body.empty = 0;
btn_sm_pr.body.color_main = color_hsv_to_rgb(_hue, 50, 50);
btn_sm_pr.body.color_gradient = color_hsv_to_rgb(_hue, 50, 50);
btn_sm_pr.body.border.opa = OPA_60;
btn_sm_pr.text.font = _font_sm;
btn_sm_pr.text.color = color_hsv_to_rgb(_hue, 10, 100);
lv_style_copy(&btn_sm_trel, &btn_sm_pr);
btn_sm_trel.body.opa = OPA_COVER;
btn_sm_trel.body.empty = 0;
btn_sm_trel.body.color_main = color_hsv_to_rgb(_hue, 50, 60);
btn_sm_trel.body.color_gradient = color_hsv_to_rgb(_hue, 50, 60);
btn_sm_trel.body.border.opa = OPA_60;
btn_sm_trel.body.border.color = color_hsv_to_rgb(_hue, 80, 90);
btn_sm_trel.text.font = _font_sm;
btn_sm_trel.text.color = color_hsv_to_rgb(_hue, 0, 100);
lv_style_copy(&btn_sm_tpr, &btn_sm_trel);
btn_sm_tpr.body.opa = OPA_COVER;
btn_sm_tpr.body.empty = 0;
btn_sm_tpr.body.color_main = color_hsv_to_rgb(_hue, 50, 50);
btn_sm_tpr.body.color_gradient = color_hsv_to_rgb(_hue, 50, 50);
btn_sm_tpr.body.border.opa = OPA_60;
btn_sm_tpr.body.border.color = color_hsv_to_rgb(_hue, 80, 70);
btn_sm_tpr.text.font = _font_sm;
btn_sm_tpr.text.color = color_hsv_to_rgb(_hue, 10, 90);
lv_style_copy(&btn_sm_ina, &btn_sm_rel);
btn_sm_ina.body.border.opa = OPA_60;
btn_sm_ina.body.border.color = color_hsv_to_rgb(_hue, 10, 50);
btn_sm_ina.text.font = _font_sm;
btn_sm_ina.text.color = color_hsv_to_rgb(_hue, 10, 90);
lv_style_copy(&btn_md_rel, &btn_sm_rel);
btn_md_rel.body.padding.hor = LV_DPI / 3;
btn_md_rel.body.padding.ver = LV_DPI / 5;
btn_md_rel.body.padding.inner = LV_DPI / 8;
btn_md_rel.text.font = _font_md;
lv_style_copy(&btn_md_pr, &btn_sm_pr);
btn_md_pr.body.padding.hor = LV_DPI / 3;
btn_md_pr.body.padding.ver = LV_DPI / 5;
btn_md_pr.body.padding.inner = LV_DPI / 8;
btn_md_pr.text.font = _font_md;
lv_style_copy(&btn_md_trel, &btn_sm_trel);
btn_md_trel.body.padding.hor = LV_DPI / 3;
btn_md_trel.body.padding.ver = LV_DPI / 5;
btn_md_trel.body.padding.inner = LV_DPI / 8;
btn_md_trel.text.font = _font_md;
lv_style_copy(&btn_md_tpr, &btn_sm_tpr);
btn_md_tpr.body.padding.hor = LV_DPI / 3;
btn_md_tpr.body.padding.ver = LV_DPI / 5;
btn_md_tpr.body.padding.inner = LV_DPI / 8;
btn_md_tpr.text.font = _font_md;
lv_style_copy(&btn_md_ina, &btn_sm_ina);
btn_md_ina.body.padding.hor = LV_DPI / 3;
btn_md_ina.body.padding.ver = LV_DPI / 5;
btn_md_ina.body.padding.inner = LV_DPI / 8;
btn_md_ina.text.font = _font_md;
lv_style_copy(&btn_lg_rel, &btn_sm_rel);
btn_lg_rel.body.padding.hor = LV_DPI / 2;
btn_lg_rel.body.padding.ver = LV_DPI / 4;
btn_lg_rel.body.padding.inner = LV_DPI / 6;
btn_lg_rel.text.font = _font_lg;
lv_style_copy(&btn_lg_pr, &btn_sm_pr);
btn_lg_pr.body.padding.hor = LV_DPI / 2;
btn_lg_pr.body.padding.ver = LV_DPI / 4;
btn_lg_pr.body.padding.inner = LV_DPI / 6;
btn_lg_pr.text.font = _font_lg;
lv_style_copy(&btn_lg_trel, &btn_sm_trel);
btn_lg_trel.body.padding.hor = LV_DPI / 2;
btn_lg_trel.body.padding.ver = LV_DPI / 4;
btn_lg_trel.body.padding.inner = LV_DPI / 6;
btn_lg_trel.text.font = _font_lg;
lv_style_copy(&btn_lg_tpr, &btn_sm_tpr);
btn_lg_tpr.body.padding.hor = LV_DPI / 2;
btn_lg_tpr.body.padding.ver = LV_DPI / 4;
btn_lg_tpr.body.padding.inner = LV_DPI / 6;
btn_lg_tpr.text.font = _font_lg;
lv_style_copy(&btn_lg_ina, &btn_sm_ina);
btn_lg_ina.body.padding.hor = LV_DPI / 2;
btn_lg_ina.body.padding.ver = LV_DPI / 4;
btn_lg_ina.body.padding.inner = LV_DPI / 6;
btn_lg_ina.text.font = _font_lg;
theme.btn.sm.rel = &btn_sm_rel;
theme.btn.sm.pr = &btn_sm_pr;
theme.btn.sm.tgl_rel = &btn_sm_trel;
theme.btn.sm.tgl_pr = &btn_sm_tpr;
theme.btn.sm.ina = &btn_sm_ina;
theme.btn.md.rel = &btn_md_rel;
theme.btn.md.pr = &btn_md_pr;
theme.btn.md.tgl_rel = &btn_md_trel;
theme.btn.md.tgl_pr = &btn_md_tpr;
theme.btn.md.ina = &btn_md_ina;
theme.btn.lg.rel = &btn_lg_rel;
theme.btn.lg.pr = &btn_lg_pr;
theme.btn.lg.tgl_rel = &btn_lg_trel;
theme.btn.lg.tgl_pr = &btn_lg_tpr;
theme.btn.lg.ina = &btn_lg_ina;
lv_style_copy(&btn_rel, &def);
btn_rel.glass = 0;
btn_rel.body.empty = 1;
btn_rel.body.radius = LV_RADIUS_CIRCLE;
btn_rel.body.border.width = 2 << LV_ANTIALIAS;
btn_rel.body.border.color = color_hsv_to_rgb(_hue, 70, 90);
btn_rel.body.border.opa = OPA_80;
btn_rel.body.padding.hor = LV_DPI / 4;
btn_rel.body.padding.ver = LV_DPI / 6;
btn_rel.body.padding.inner = LV_DPI / 10;
btn_rel.text.color = color_hsv_to_rgb(_hue, 8, 96);
btn_rel.text.font = _font;
lv_style_copy(&btn_pr, &btn_rel);
btn_pr.body.opa = OPA_COVER;
btn_pr.body.empty = 0;
btn_pr.body.main_color = color_hsv_to_rgb(_hue, 50, 50);
btn_pr.body.gradient_color = color_hsv_to_rgb(_hue, 50, 50);
btn_pr.body.border.opa = OPA_60;
btn_pr.text.font = _font;
btn_pr.text.color = color_hsv_to_rgb(_hue, 10, 100);
lv_style_copy(&btn_trel, &btn_pr);
btn_trel.body.opa = OPA_COVER;
btn_trel.body.empty = 0;
btn_trel.body.main_color = color_hsv_to_rgb(_hue, 50, 60);
btn_trel.body.gradient_color = color_hsv_to_rgb(_hue, 50, 60);
btn_trel.body.border.opa = OPA_60;
btn_trel.body.border.color = color_hsv_to_rgb(_hue, 80, 90);
btn_trel.text.font = _font;
btn_trel.text.color = color_hsv_to_rgb(_hue, 0, 100);
lv_style_copy(&btn_tpr, &btn_trel);
btn_tpr.body.opa = OPA_COVER;
btn_tpr.body.empty = 0;
btn_tpr.body.main_color = color_hsv_to_rgb(_hue, 50, 50);
btn_tpr.body.gradient_color = color_hsv_to_rgb(_hue, 50, 50);
btn_tpr.body.border.opa = OPA_60;
btn_tpr.body.border.color = color_hsv_to_rgb(_hue, 80, 70);
btn_tpr.text.font = _font;
btn_tpr.text.color = color_hsv_to_rgb(_hue, 10, 90);
lv_style_copy(&btn_ina, &btn_rel);
btn_ina.body.border.opa = OPA_60;
btn_ina.body.border.color = color_hsv_to_rgb(_hue, 10, 50);
btn_ina.text.font = _font;
btn_ina.text.color = color_hsv_to_rgb(_hue, 10, 90);
theme.btn.rel = &btn_rel;
theme.btn.pr = &btn_pr;
theme.btn.tgl_rel = &btn_trel;
theme.btn.tgl_pr = &btn_tpr;
theme.btn.ina = &btn_ina;
#endif
}
......@@ -269,19 +197,19 @@ static void btn_init(void)
static void label_init(void)
{
#if USE_LV_LABEL != 0
lv_style_copy(&label_sm, &def);
label_sm.text.font = _font_sm;
label_sm.text.color = color_hsv_to_rgb(_hue, 8, 96);
lv_style_copy(&label_prim, &def);
label_prim.text.font = _font;
label_prim.text.color = color_hsv_to_rgb(_hue, 80, 96);
lv_style_copy(&label_md, &label_sm);
label_md.text.font = _font_md;
lv_style_copy(&label_sec, &label_prim);
label_sec.text.color = color_hsv_to_rgb(_hue, 40, 85);
lv_style_copy(&label_lg, &label_sm);
label_lg.text.font = _font_lg;
lv_style_copy(&label_hint, &label_prim);
label_hint.text.color = color_hsv_to_rgb(_hue, 20, 70);
theme.label.sm = &label_sm;
theme.label.md = &label_md;
theme.label.lg = &label_lg;
theme.label.prim = &label_prim;
theme.label.sec = &label_sec;
theme.label.hint = &label_hint;
#endif
}
......@@ -292,8 +220,8 @@ static void bar_init(void)
lv_style_copy(&bar_bg, &def);
bar_bg.body.opa = OPA_30;
bar_bg.body.radius = LV_RADIUS_CIRCLE;
bar_bg.body.color_main = COLOR_WHITE;
bar_bg.body.color_gradient = COLOR_SILVER;
bar_bg.body.main_color = COLOR_WHITE;
bar_bg.body.gradient_color = COLOR_SILVER;
bar_bg.body.border.width = 2 << LV_ANTIALIAS;
bar_bg.body.border.color = COLOR_SILVER;
bar_bg.body.border.opa = OPA_20;
......@@ -308,9 +236,9 @@ static void bar_init(void)
bar_indic.body.border.opa = OPA_70;
bar_indic.body.padding.hor = 0;
bar_indic.body.padding.ver = 0;
bar_indic.body.shadow.width = LV_DPI / 12;
bar_indic.body.color_main = color_hsv_to_rgb(_hue, 40, 80);
bar_indic.body.color_gradient = color_hsv_to_rgb(_hue, 40, 80);
bar_indic.body.shadow.width = LV_DPI / 20;
bar_indic.body.main_color = color_hsv_to_rgb(_hue, 40, 80);
bar_indic.body.gradient_color = color_hsv_to_rgb(_hue, 40, 80);
theme.bar.bg = &bar_bg;
theme.bar.indic = &bar_indic;
......@@ -352,8 +280,8 @@ static void led_init(void)
led.body.radius = LV_RADIUS_CIRCLE;
led.body.border.width= LV_DPI / 30;
led.body.border.opa = OPA_30;
led.body.color_main = color_hsv_to_rgb(_hue, 100, 100);
led.body.color_gradient = color_hsv_to_rgb(_hue, 100, 40);
led.body.main_color = color_hsv_to_rgb(_hue, 100, 100);
led.body.gradient_color = color_hsv_to_rgb(_hue, 100, 40);
led.body.border.color = color_hsv_to_rgb(_hue, 60, 60);
led.body.shadow.color = color_hsv_to_rgb(_hue, 100, 100);
......@@ -367,8 +295,8 @@ static void slider_init(void)
lv_style_copy(&slider_knob, &def);
slider_knob.body.opa = OPA_60;
slider_knob.body.radius = LV_RADIUS_CIRCLE;
slider_knob.body.color_main = COLOR_WHITE;
slider_knob.body.color_gradient = COLOR_SILVER;
slider_knob.body.main_color = COLOR_WHITE;
slider_knob.body.gradient_color = COLOR_SILVER;
slider_knob.body.border.width = 1 << LV_ANTIALIAS;
slider_knob.body.border.color = COLOR_GRAY;
slider_knob.body.border.opa = OPA_50;
......@@ -386,13 +314,13 @@ static void sw_init(void)
sw_bg.body.opa = OPA_COVER;
sw_bg.body.padding.ver = -2 << LV_ANTIALIAS;
sw_bg.body.padding.hor = -2 << LV_ANTIALIAS;
sw_bg.body.color_main = COLOR_HEX3(0x666);
sw_bg.body.color_gradient = COLOR_HEX3(0x999);
sw_bg.body.main_color = COLOR_HEX3(0x666);
sw_bg.body.gradient_color = COLOR_HEX3(0x999);
sw_bg.body.border.width = 2 << LV_ANTIALIAS;
sw_bg.body.border.opa = OPA_50;
lv_style_copy(&sw_indic, &bar_indic);
sw_indic.body.shadow .width = LV_DPI / 12;
sw_indic.body.shadow .width = LV_DPI / 20;
sw_indic.body.padding.ver = 0;
sw_indic.body.padding.hor = 0;
......@@ -411,8 +339,8 @@ static void lmeter_init(void)
{
#if USE_LV_LMETER != 0
lv_style_copy(&lmeter_bg, &def);
lmeter_bg.body.color_main = color_hsv_to_rgb(_hue, 10, 70);
lmeter_bg.body.color_gradient = color_hsv_to_rgb(_hue, 80, 80);
lmeter_bg.body.main_color = color_hsv_to_rgb(_hue, 10, 70);
lmeter_bg.body.gradient_color = color_hsv_to_rgb(_hue, 80, 80);
lmeter_bg.body.padding.hor = LV_DPI / 8; /*Scale line length*/
lmeter_bg.line.color = COLOR_HEX3(0x555);
lmeter_bg.line.width = 2 << LV_ANTIALIAS;
......@@ -426,8 +354,8 @@ static void gauge_init(void)
{
#if USE_LV_GAUGE != 0
lv_style_copy(&gauge_bg, &def);
gauge_bg.body.color_main = color_hsv_to_rgb(_hue, 10, 70);
gauge_bg.body.color_gradient = color_hsv_to_rgb(_hue, 80, 80);
gauge_bg.body.main_color = color_hsv_to_rgb(_hue, 10, 70);
gauge_bg.body.gradient_color = color_hsv_to_rgb(_hue, 80, 80);
gauge_bg.body.padding.hor = LV_DPI / 12; /*Scale line length*/
gauge_bg.body.padding.ver = LV_DPI / 10; /*Needle center size*/
gauge_bg.body.padding.inner = LV_DPI / 8; /*Label - scale distance*/
......@@ -435,7 +363,7 @@ static void gauge_init(void)
gauge_bg.line.color = COLOR_HEX3(0x555);
gauge_bg.line.width = 2 << LV_ANTIALIAS;
gauge_bg.text.color = color_hsv_to_rgb(_hue, 10, 90);
gauge_bg.text.font = _font_sm;
gauge_bg.text.font = _font;
theme.gauge = &gauge_bg;
#endif
......@@ -456,8 +384,8 @@ static void cb_init(void)
cb_rel.body.radius = LV_DPI / 20;
cb_rel.body.border.width = 1 << LV_ANTIALIAS;
cb_rel.body.border.color = COLOR_GRAY;
cb_rel.body.color_main = COLOR_WHITE;
cb_rel.body.color_gradient = COLOR_SILVER;
cb_rel.body.main_color = COLOR_WHITE;
cb_rel.body.gradient_color = COLOR_SILVER;
lv_style_copy(&cb_bg, &bg);
cb_bg.body.empty = 1;
......@@ -465,30 +393,30 @@ static void cb_init(void)
cb_bg.body.padding.inner = LV_DPI / 8;
cb_bg.body.padding.hor = 0;
cb_bg.body.padding.ver = 0;
cb_bg.text.font = _font_sm;
cb_bg.text.font = _font;
lv_style_copy(&cb_pr, &cb_rel);
cb_pr.body.color_main = color_hsv_to_rgb(_hue, 10, 90);
cb_pr.body.color_main = color_hsv_to_rgb(_hue, 10, 82);
cb_pr.body.main_color = color_hsv_to_rgb(_hue, 10, 90);
cb_pr.body.main_color = color_hsv_to_rgb(_hue, 10, 82);
lv_style_copy(&cb_trel, &cb_rel);
cb_trel.body.border.width = 4 << LV_ANTIALIAS;
cb_trel.body.border.color = COLOR_WHITE;
cb_trel.body.border.opa = OPA_60;
cb_trel.body.color_main = color_hsv_to_rgb(_hue, 50, 82);
cb_trel.body.color_gradient = color_hsv_to_rgb(_hue, 50, 62);
cb_trel.body.main_color = color_hsv_to_rgb(_hue, 50, 82);
cb_trel.body.gradient_color = color_hsv_to_rgb(_hue, 50, 62);
lv_style_copy(&cb_tpr, &cb_trel);
cb_tpr.body.border.color = COLOR_SILVER;
cb_tpr.body.border.opa = OPA_70;
cb_tpr.body.color_main = color_hsv_to_rgb(_hue, 50, 72);
cb_tpr.body.color_gradient = color_hsv_to_rgb(_hue, 50, 52);
cb_tpr.body.main_color = color_hsv_to_rgb(_hue, 50, 72);
cb_tpr.body.gradient_color = color_hsv_to_rgb(_hue, 50, 52);
lv_style_copy(&cb_ina, &cb_trel);
cb_ina.body.border.width = 1 << LV_ANTIALIAS;
cb_ina.body.border.color = COLOR_GRAY;
cb_ina.body.color_main = COLOR_SILVER;
cb_ina.body.color_gradient = COLOR_SILVER;
cb_ina.body.main_color = COLOR_SILVER;
cb_ina.body.gradient_color = COLOR_SILVER;
theme.cb.bg = &cb_bg;
theme.cb.box.rel = &cb_rel;
......@@ -513,14 +441,14 @@ static void btnm_init(void)
btnm_rel.body.empty = 1;
btnm_rel.body.radius = LV_DPI / 8;
btnm_rel.text.color = color_hsv_to_rgb(_hue, 60, 80);
btnm_rel.text.font = _font_md;
btnm_rel.text.font = _font;
lv_style_copy(&btnm_pr, &lv_style_plain);
btnm_pr.body.color_main = color_hsv_to_rgb(_hue, 40, 70);
btnm_pr.body.color_gradient = color_hsv_to_rgb(_hue, 40, 70);
btnm_pr.body.main_color = color_hsv_to_rgb(_hue, 40, 70);
btnm_pr.body.gradient_color = color_hsv_to_rgb(_hue, 40, 70);
btnm_pr.body.radius = LV_DPI / 8;
btnm_pr.text.color = color_hsv_to_rgb(_hue, 40, 40);
btnm_pr.text.font = _font_md;
btnm_pr.text.font = _font;
lv_style_copy(&btnm_trel, &btnm_rel);
btnm_trel.body.border.color = color_hsv_to_rgb(_hue, 80, 80);
......@@ -559,8 +487,8 @@ static void mbox_init(void)
theme.mbox.bg = &mbox_bg;
theme.mbox.btn.bg = &lv_style_transp;
theme.mbox.btn.rel = &btn_sm_trel;
theme.mbox.btn.pr = &btn_sm_tpr;
theme.mbox.btn.rel = &btn_trel;
theme.mbox.btn.pr = &btn_tpr;
#endif
}
......@@ -591,13 +519,13 @@ static void list_init(void)
list_rel.body.border.color = color_hsv_to_rgb(_hue, 50, 85);
list_rel.body.border.opa = OPA_COVER;
list_rel.text.color = color_hsv_to_rgb(_hue, 10, 94);
list_rel.text.font = _font_sm;
list_rel.text.font = _font;
lv_style_copy(&list_pr, &list_rel);
list_pr.body.empty = 0;
list_pr.body.opa = OPA_COVER;
list_pr.body.color_main = color_hsv_to_rgb(_hue, 34, 41);
list_pr.body.color_gradient = color_hsv_to_rgb(_hue, 34, 41);
list_pr.body.main_color = color_hsv_to_rgb(_hue, 34, 41);
list_pr.body.gradient_color = color_hsv_to_rgb(_hue, 34, 41);
list_pr.text.color = color_hsv_to_rgb(_hue, 7, 96);
lv_style_copy(&list_trel, &list_rel);
......@@ -626,8 +554,8 @@ static void ddlist_init(void)
ddlist_bg.text.line_space = LV_DPI / 10;
lv_style_copy(&ddlist_sel, &panel);
ddlist_sel.body.color_main = color_hsv_to_rgb(_hue, 45, 70);
ddlist_sel.body.color_gradient = color_hsv_to_rgb(_hue, 45, 70);
ddlist_sel.body.main_color = color_hsv_to_rgb(_hue, 45, 70);
ddlist_sel.body.gradient_color = color_hsv_to_rgb(_hue, 45, 70);
ddlist_sel.body.opa = OPA_COVER;
ddlist_sel.body.radius = 0;
......@@ -643,8 +571,8 @@ static void roller_init(void)
lv_style_copy(&roller_bg, &ddlist_bg);
roller_bg.text.line_space = LV_DPI / 6;
roller_bg.body.radius = LV_DPI / 20;
roller_bg.body.color_main = COLOR_HEX3(0x222);
roller_bg.body.color_gradient = COLOR_HEX3(0x999);
roller_bg.body.main_color = COLOR_HEX3(0x222);
roller_bg.body.gradient_color = COLOR_HEX3(0x999);
roller_bg.body.border.opa = OPA_30;
roller_bg.text.opa = OPA_70;
roller_bg.text.color = color_hsv_to_rgb(_hue, 20, 70);
......@@ -654,7 +582,7 @@ static void roller_init(void)
lv_style_copy(&roller_sel, &panel);
roller_sel.body.empty = 1;
roller_sel.body.radius = 0;
roller_sel.text.color = color_hsv_to_rgb(_hue, 55, 90);
roller_sel.text.color = color_hsv_to_rgb(_hue, 70, 95);
theme.roller.bg = &roller_bg;
theme.roller.sel = &roller_sel;
......@@ -665,8 +593,8 @@ static void tabview_init(void)
{
#if USE_LV_TABVIEW != 0
lv_style_copy(&tab_rel, &def);
tab_rel.body.color_main = COLOR_HEX3(0x666);
tab_rel.body.color_gradient = COLOR_HEX3(0x666);
tab_rel.body.main_color = COLOR_HEX3(0x666);
tab_rel.body.gradient_color = COLOR_HEX3(0x666);
tab_rel.body.padding.hor = 0;
tab_rel.body.padding.ver = 0;
tab_rel.body.padding.inner = 0;
......@@ -674,11 +602,11 @@ static void tabview_init(void)
tab_rel.body.border.color = COLOR_SILVER;
tab_rel.body.border.opa = OPA_40;
tab_rel.text.color = COLOR_HEX3(0xDDD);
tab_rel.text.font = _font_sm;
tab_rel.text.font = _font;
lv_style_copy(&tab_pr, &tab_rel);
tab_pr.body.color_main = COLOR_HEX3(0x444);
tab_pr.body.color_gradient = COLOR_HEX3(0x444);
tab_pr.body.main_color = COLOR_HEX3(0x444);
tab_pr.body.gradient_color = COLOR_HEX3(0x444);
lv_style_copy(&tab_trel, &def);
tab_trel.body.empty = 1;
......@@ -689,11 +617,11 @@ static void tabview_init(void)
tab_trel.body.border.color = COLOR_SILVER;
tab_trel.body.border.opa = OPA_40;
tab_trel.text.color = color_hsv_to_rgb(_hue, 10, 94);
tab_trel.text.font = _font_md;
tab_trel.text.font = _font;
lv_style_copy(&tab_tpr, &def);
tab_tpr.body.color_main = COLOR_GRAY;
tab_tpr.body.color_gradient = COLOR_GRAY;
tab_tpr.body.main_color = COLOR_GRAY;
tab_tpr.body.gradient_color = COLOR_GRAY;
tab_tpr.body.padding.hor = 0;
tab_tpr.body.padding.ver = 0;
tab_tpr.body.padding.inner = 0;
......@@ -701,12 +629,12 @@ static void tabview_init(void)
tab_tpr.body.border.color = COLOR_SILVER;
tab_tpr.body.border.opa = OPA_40;
tab_tpr.text.color = color_hsv_to_rgb(_hue, 10, 94);
tab_tpr.text.font = _font_md;
tab_tpr.text.font = _font;
lv_style_copy(&tab_indic, &def);
tab_indic.body.border.width = 0;
tab_indic.body.color_main = color_hsv_to_rgb(_hue, 80, 87);
tab_indic.body.color_gradient = color_hsv_to_rgb(_hue, 80, 87);
tab_indic.body.main_color = color_hsv_to_rgb(_hue, 80, 87);
tab_indic.body.gradient_color = color_hsv_to_rgb(_hue, 80, 87);
tab_indic.body.padding.inner = LV_DPI / 10; /*Indicator height*/
theme.tabview.bg = &bg;
......@@ -719,27 +647,27 @@ static void tabview_init(void)
#endif
}
static void win_init(void)
{
#if USE_LV_WIN != 0
lv_style_copy(&win_header, &def);
win_header.body.radius = panel.body.radius;
win_header.body.radius = 0;
win_header.body.padding.hor = LV_DPI / 12;
win_header.body.padding.ver = LV_DPI / 12;
win_header.body.color_main = color_hsv_to_rgb(_hue, 20, 50);
win_header.body.color_gradient = win_header.body.color_main;
win_header.body.padding.ver = LV_DPI / 20;
win_header.body.main_color = color_hsv_to_rgb(_hue, 20, 50);
win_header.body.gradient_color = win_header.body.main_color;
win_header.body.border.opa = panel.body.border.opa;
win_header.body.border.width = panel.body.border.width;
win_header.body.border.color = color_hsv_to_rgb(_hue, 20, 80);
win_header.body.border.part = LV_BORDER_BOTTOM;
win_header.text.color = color_hsv_to_rgb(_hue, 5, 100);
theme.win.bg = &panel;
theme.win.sb = &sb;
theme.win.header = &win_header;
theme.win.content = &lv_style_transp;
theme.win.btn.rel = &btn_sm_rel;
theme.win.btn.pr = &btn_sm_pr;
theme.win.btn.rel = &btn_rel;
theme.win.btn.pr = &btn_pr;
#endif
}
......@@ -748,23 +676,17 @@ static void win_init(void)
**********************/
/**
* Initalize the alien theme
* Initialize the alien theme
* @param hue [0..360] hue value from HSV color space to define the theme's base color
* @param font_sm pointer to a small font (NULL to use the default)
* @param font_md pointer to a medium font (NULL to use the default)
* @param font_lg pointer to a large font (NULL to use the default)
* @param font pointer to a font (NULL to use the default)
* @return pointer to the initialized theme
*/
void lv_theme_alien_init(uint16_t hue, font_t *font_sm, font_t *font_md, font_t *font_lg)
lv_theme_t * lv_theme_alien_init(uint16_t hue, font_t *font)
{
if(font_sm == NULL) font_sm = FONT_DEFAULT;
if(font_md == NULL) font_md = FONT_DEFAULT;
if(font_lg == NULL) font_lg = FONT_DEFAULT;
if(font == NULL) font = FONT_DEFAULT;
_hue = hue;
_font_sm = font_sm;
_font_md = font_md;
_font_lg = font_lg;
_font = font;
/*For backward compatibility initialize all theme elements with a default style */
uint16_t i;
......@@ -797,6 +719,8 @@ void lv_theme_alien_init(uint16_t hue, font_t *font_sm, font_t *font_md, font_t
roller_init();
tabview_init();
win_init();
return &theme;
}
/**
......
......@@ -28,15 +28,14 @@ extern "C" {
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initalize the alien theme
* Initialize the alien theme
* @param hue [0..360] hue value from HSV color space to define the theme's base color
* @param font_sm pointer to a small font (NULL to use the default)
* @param font_md pointer to a medium font (NULL to use the default)
* @param font_lg pointer to a large font (NULL to use the default)
* @param font pointer to a font (NULL to use the default)
* @return pointer to the initialized theme
*/
void lv_theme_alien_init(uint16_t hue, font_t *font_sm, font_t *font_md, font_t *font_lg);
lv_theme_t * lv_theme_alien_init(uint16_t hue, font_t *font);
/**
* Get a pointer to the theme
* @return pointer to the theme
......
/**
* @file lv_theme_alien.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lvgl/lvgl.h"
#include "lv_theme.h"
#include "lv_conf.h"
#if USE_LV_THEME_ALIEN
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
static lv_theme_t theme;
static lv_style_t def;
/*Static style definitions*/
/*Saved input parameters*/
static uint16_t _hue;
static font_t * _font;
/**********************
* MACROS
**********************/
/**********************
* STATIC FUNCTIONS
**********************/
static void basic_init(void)
{
lv_style_copy(&def, &lv_style_pretty); /*Initialize the default style*/
theme.bg = &def;
theme.panel = &def;
}
static void btn_init(void)
{
#if USE_LV_BTN != 0
theme.btn.rel = &def;
theme.btn.pr = &def;
theme.btn.tgl_rel = &def;
theme.btn.tgl_pr = &def;
theme.btn.ina = &def;
#endif
}
static void label_init(void)
{
#if USE_LV_LABEL != 0
theme.label.prim = &def;
theme.label.sec = &def;
theme.label.hint = &def;
#endif
}
static void bar_init(void)
{
#if USE_LV_BAR
theme.bar.bg = &def;
theme.bar.indic = &def;
#endif
}
static void img_init(void)
{
#if USE_LV_IMG != 0
theme.img.light = &def;
theme.img.dark = &def;
#endif
}
static void line_init(void)
{
#if USE_LV_LINE != 0
theme.line.decor = &def;
#endif
}
static void led_init(void)
{
#if USE_LV_LED != 0
theme.led = &def;
#endif
}
static void slider_init(void)
{
#if USE_LV_SLIDER != 0
theme.slider.bg = &def;
theme.slider.indic = &def;
theme.slider.knob = &def;
#endif
}
static void sw_init(void)
{
#if USE_LV_SW != 0
theme.sw.bg = &def;
theme.sw.indic = &def;
theme.sw.knob_off = &def;
theme.sw.knob_on = &def;
#endif
}
static void lmeter_init(void)
{
#if USE_LV_LMETER != 0
theme.lmeter = &def;
#endif
}
static void gauge_init(void)
{
#if USE_LV_GAUGE != 0
theme.gauge = &def;
#endif
}
static void chart_init(void)
{
#if USE_LV_CHART
theme.chart = &def;
#endif
}
static void cb_init(void)
{
#if USE_LV_CB != 0
theme.cb.bg = &def;
theme.cb.box.rel = &def;
theme.cb.box.pr = &def;
theme.cb.box.tgl_rel = &def;
theme.cb.box.tgl_pr = &def;
theme.cb.box.ina = &def;
#endif
}
static void btnm_init(void)
{
#if USE_LV_BTNM
theme.btnm.bg = &def;
theme.btnm.btn.rel = &def;
theme.btnm.btn.pr = &def;
theme.btnm.btn.tgl_rel = &def;
theme.btnm.btn.tgl_pr = &def;
theme.btnm.btn.ina = &def;
#endif
}
static void kb_init(void)
{
#if USE_LV_KB
theme.kb.bg = &def;
theme.kb.btn.rel = &def;
theme.kb.btn.pr = &def;
theme.kb.btn.tgl_rel = &def;
theme.kb.btn.tgl_pr = &def;
theme.kb.btn.ina = &def;
#endif
}
static void mbox_init(void)
{
#if USE_LV_MBOX
theme.mbox.bg = &def;
theme.mbox.btn.bg = &def;
theme.mbox.btn.rel = &def;
theme.mbox.btn.pr = &def;
#endif
}
static void page_init(void)
{
#if USE_LV_PAGE
theme.page.bg = &def;
theme.page.scrl = &def;
theme.page.sb = &def;
#endif
}
static void ta_init(void)
{
#if USE_LV_TA
theme.ta.area = &def;
theme.ta.oneline = &def;
theme.ta.sb = &def;
#endif
}
static void list_init(void)
{
#if USE_LV_LIST != 0
theme.list.sb = &def;
theme.list.bg = &def;
theme.list.scrl = &def;
theme.list.btn.rel = &def;
theme.list.btn.pr = &def;
theme.list.btn.tgl_rel = &def;
theme.list.btn.tgl_pr = &def;
theme.list.btn.ina = &def;
#endif
}
static void ddlist_init(void)
{
#if USE_LV_DDLIST != 0
theme.ddlist.bg = &def;
theme.ddlist.sel = &def;
theme.ddlist.sb = &def;
#endif
}
static void roller_init(void)
{
#if USE_LV_ROLLER != 0
theme.roller.bg = &def;
theme.roller.sel = &def;
#endif
}
static void tabview_init(void)
{
#if USE_LV_TABVIEW != 0
theme.tabview.bg = &def;
theme.tabview.indic = &def;
theme.tabview.btn.bg = &def;
theme.tabview.btn.rel = &def;
theme.tabview.btn.pr = &def;
theme.tabview.btn.tgl_rel = &def;
theme.tabview.btn.tgl_pr = &def;
#endif
}
static void win_init(void)
{
#if USE_LV_WIN != 0
theme.win.bg = &def;
theme.win.sb = &def;
theme.win.header = &def;
theme.win.content = &def;
theme.win.btn.rel = &def;
theme.win.btn.pr = &def;
#endif
}
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Initialize the alien theme
* @param hue [0..360] hue value from HSV color space to define the theme's base color
* @param font pointer to a font (NULL to use the default)
* @return pointer to the initialized theme
*/
lv_theme_t * lv_theme_templ_init(uint16_t hue, font_t *font)
{
if(font == NULL) font = FONT_DEFAULT;
_hue = hue;
_font = font;
/*For backward compatibility initialize all theme elements with a default style */
uint16_t i;
lv_style_t **style_p = (lv_style_t**) &theme;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
*style_p = &def;
style_p++;
}
basic_init();
btn_init();
label_init();
bar_init();
img_init();
line_init();
led_init();
slider_init();
sw_init();
lmeter_init();
gauge_init();
chart_init();
cb_init();
btnm_init();
kb_init();
mbox_init();
page_init();
ta_init();
list_init();
ddlist_init();
roller_init();
tabview_init();
win_init();
return &theme;
}
/**
* Get a pointer to the theme
* @return pointer to the theme
*/
lv_theme_t * lv_theme_get_templ(void)
{
return &theme;
}
/**********************
* STATIC FUNCTIONS
**********************/
#endif
/**
* @file lv_theme_alien.h
*
*/
#ifndef LV_THEME_TEMPL_H
#define LV_THEME_TEMPL_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_THEME_TEMPL
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the alien theme
* @param hue [0..360] hue value from HSV color space to define the theme's base color
* @param font pointer to a font (NULL to use the default)
* @return pointer to the initialized theme
*/
lv_theme_t * lv_theme_templ_init(uint16_t hue, font_t *font);
/**
* Get a pointer to the theme
* @return pointer to the theme
*/
lv_theme_t * lv_theme_get_templ(void);
/**********************
* MACROS
**********************/
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_THEME_TEMPL_H*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment