From 27d23dbeea693fcedfd15859190f3567dd7fcad4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 31 Jan 2020 06:45:33 +0100 Subject: [PATCH] improve calendar --- src/lv_core/lv_refr.c | 3 ++ src/lv_draw/lv_draw_img.c | 1 + src/lv_draw/lv_draw_line.c | 1 + src/lv_draw/lv_draw_rect.c | 7 ++- src/lv_draw/lv_draw_rect.h | 3 -- src/lv_objx/lv_calendar.c | 96 ++++++++++++++++++---------------- src/lv_objx/lv_cb.c | 6 +-- src/lv_themes/lv_theme.h | 5 +- src/lv_themes/lv_theme_alien.c | 68 ++++++++++++++++-------- 9 files changed, 112 insertions(+), 78 deletions(-) diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index 25bba8d2c..12429ce88 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -543,6 +543,9 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p) lv_draw_rect(&obj_ext_mask, &obj_ext_mask, &draw_dsc); debug_color.full *= 17; debug_color.full += 0xA1; +#if LV_COLOR_DEPTH == 32 + debug_color.ch.alpha = 0xff; +#endif #endif /*Create a new 'obj_mask' without 'ext_size' because the children can't be visible there*/ lv_obj_get_coords(obj, &obj_area); diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 60c49552b..ebbeb418d 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -46,6 +46,7 @@ void show_error(const lv_area_t * coords, const lv_area_t * clip_area, const cha void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc) { memset(dsc, 0x00, sizeof(lv_draw_img_dsc_t)); + dsc->recolor = LV_COLOR_BLACK; dsc->opa = LV_OPA_COVER; dsc->zoom = LV_IMG_ZOOM_NONE; dsc->antialias = LV_ANTIALIAS; diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index 56b992430..a18fca3df 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -47,6 +47,7 @@ void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc) memset(dsc, 0x00, sizeof(lv_draw_line_dsc_t)); dsc->width = 1; dsc->opa = LV_OPA_COVER; + dsc->color = LV_COLOR_BLACK; } /** diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index f544af712..24d75a3c3 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -49,13 +49,18 @@ static void draw_img(const lv_area_t * coords, const lv_area_t * clip, lv_draw_r void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc) { memset(dsc, 0x00, sizeof(lv_draw_rect_dsc_t)); + dsc->bg_color = LV_COLOR_WHITE; + dsc->bg_grad_color = LV_COLOR_BLACK; + dsc->border_color = LV_COLOR_BLACK; + dsc->pattern_recolor = LV_COLOR_BLACK; + dsc->shadow_color = LV_COLOR_BLACK; dsc->bg_grad_color_stop = 0xFF; dsc->bg_opa = LV_OPA_COVER; dsc->border_opa = LV_OPA_COVER; - dsc->overlay_opa = LV_OPA_TRANSP; dsc->pattern_font = LV_FONT_DEFAULT; dsc->shadow_opa = LV_OPA_COVER; dsc->border_side = LV_BORDER_SIDE_FULL; + } /** diff --git a/src/lv_draw/lv_draw_rect.h b/src/lv_draw/lv_draw_rect.h index 01bb09af1..8d2b34fb2 100644 --- a/src/lv_draw/lv_draw_rect.h +++ b/src/lv_draw/lv_draw_rect.h @@ -60,9 +60,6 @@ typedef struct { lv_color_t pattern_recolor; uint8_t pattern_repeate :1; - /*Overlay*/ - lv_opa_t overlay_opa; - lv_color_t overlay_color; }lv_draw_rect_dsc_t; /********************** diff --git a/src/lv_objx/lv_calendar.c b/src/lv_objx/lv_calendar.c index 642f45f1d..e712528c7 100644 --- a/src/lv_objx/lv_calendar.c +++ b/src/lv_objx/lv_calendar.c @@ -80,27 +80,27 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy) LV_LOG_TRACE("calendar create started"); /*Create the ancestor of calendar*/ - lv_obj_t * new_calendar = lv_obj_create(par, copy); - LV_ASSERT_MEM(new_calendar); - if(new_calendar == NULL) return NULL; + lv_obj_t * calendar = lv_obj_create(par, copy); + LV_ASSERT_MEM(calendar); + if(calendar == NULL) return NULL; /*Allocate the calendar type specific extended data*/ - lv_calendar_ext_t * ext = lv_obj_allocate_ext_attr(new_calendar, sizeof(lv_calendar_ext_t)); + lv_calendar_ext_t * ext = lv_obj_allocate_ext_attr(calendar, sizeof(lv_calendar_ext_t)); LV_ASSERT_MEM(ext); if(ext == NULL) { - lv_obj_del(new_calendar); + lv_obj_del(calendar); return NULL; } - if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_calendar); - if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_calendar); + if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(calendar); + if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(calendar); /*Initialize the allocated 'ext' */ - ext->today.year = 2018; + ext->today.year = 2020; ext->today.month = 1; ext->today.day = 1; - ext->showed_date.year = 2018; + ext->showed_date.year = 2020; ext->showed_date.month = 1; ext->showed_date.day = 1; @@ -121,22 +121,14 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy) lv_style_list_init(&ext->style_header); /*The signal and design functions are not copied so set them here*/ - lv_obj_set_signal_cb(new_calendar, lv_calendar_signal); - lv_obj_set_design_cb(new_calendar, lv_calendar_design); + lv_obj_set_signal_cb(calendar, lv_calendar_signal); + lv_obj_set_design_cb(calendar, lv_calendar_design); /*Init the new calendar calendar*/ if(copy == NULL) { + lv_theme_apply(calendar, LV_THEME_CALENDAR); - /*Different styles will be used from the styles while rendering so disable caching*/ - lv_style_list_reset(&new_calendar->style_list); - lv_style_list_add_style(&new_calendar->style_list, lv_theme_get_style(LV_THEME_CALENDAR_BG)); - lv_style_list_add_style(&ext->style_date_nums, lv_theme_get_style(LV_THEME_CALENDAR_DATE_NUMS)); - lv_style_list_add_style(&ext->style_day_names, lv_theme_get_style(LV_THEME_CALENDAR_DAY_NAMES)); - lv_style_list_add_style(&ext->style_header, lv_theme_get_style(LV_THEME_CALENDAR_HEADER)); - - lv_obj_refresh_style(new_calendar); - - lv_obj_set_size(new_calendar, LV_DPI * 2, LV_DPI * 2); + lv_obj_set_size(calendar, LV_DPI * 4, LV_DPI * 3); } /*Copy an existing calendar*/ @@ -163,7 +155,7 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy) LV_LOG_INFO("calendar created"); - return new_calendar; + return calendar; } /*====================== @@ -580,10 +572,12 @@ static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touche lv_style_int_t left = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_BG, LV_STYLE_PAD_LEFT); lv_style_int_t right = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_BG, LV_STYLE_PAD_RIGHT); lv_style_int_t top = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_BG, LV_STYLE_PAD_TOP); + lv_style_int_t bottom = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_BG, LV_STYLE_PAD_BOTTOM); days_area.x1 += left; days_area.x2 -= right; - days_area.y1 = calendar->coords.y1 + get_header_height(calendar) + get_day_names_height(calendar) - top; + days_area.y1 = calendar->coords.y1 + top + get_header_height(calendar) + get_day_names_height(calendar); + days_area.y2 -= bottom; if(lv_area_is_point_on(&days_area, touched_point, 0)) { lv_coord_t w = (days_area.x2 - days_area.x1 + 1) / 7; @@ -656,9 +650,11 @@ static lv_coord_t get_day_names_height(lv_obj_t * calendar) static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) { - lv_style_int_t top = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_HEADER, LV_STYLE_PAD_TOP); - lv_style_int_t left = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_HEADER, LV_STYLE_PAD_LEFT); - lv_style_int_t right = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_HEADER, LV_STYLE_PAD_RIGHT); + + lv_style_int_t bg_top = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_BG, LV_STYLE_PAD_TOP); + lv_style_int_t header_top = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_HEADER, LV_STYLE_PAD_TOP); + lv_style_int_t header_left = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_HEADER, LV_STYLE_PAD_LEFT); + lv_style_int_t header_right = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_HEADER, LV_STYLE_PAD_RIGHT); const lv_font_t * font = lv_obj_get_style_ptr(calendar, LV_CALENDAR_PART_HEADER, LV_STYLE_FONT); lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); @@ -666,7 +662,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) lv_area_t header_area; header_area.x1 = calendar->coords.x1; header_area.x2 = calendar->coords.x2; - header_area.y1 = calendar->coords.y1; + header_area.y1 = calendar->coords.y1 + bg_top; header_area.y2 = calendar->coords.y1 + get_header_height(calendar); lv_draw_rect_dsc_t header_rect_dsc; @@ -680,7 +676,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) txt_buf[4] = ' '; txt_buf[5] = '\0'; strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month)); - header_area.y1 += top; + header_area.y1 += header_top; lv_draw_label_dsc_t label_dsc; lv_draw_label_dsc_init(&label_dsc); @@ -689,9 +685,6 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) lv_draw_label(&header_area, mask, &label_dsc,txt_buf, NULL); /*Add the left arrow*/ - - /*The state changes without re-caching the styles, disable the use of cache*/ -// calendar->style_dsc.cache.enabled = 0; lv_obj_state_dsc_t state_ori = calendar->state_dsc; if(ext->btn_pressing < 0) calendar->state_dsc.act |= LV_OBJ_STATE_PRESSED; @@ -699,7 +692,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) calendar->state_dsc.prev = calendar->state_dsc.act; - header_area.x1 += left; + header_area.x1 += header_left; lv_draw_label_dsc_init(&label_dsc); lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_HEADER, &label_dsc); @@ -713,7 +706,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) calendar->state_dsc.prev = calendar->state_dsc.act; - header_area.x1 = header_area.x2 - right - lv_txt_get_width(LV_SYMBOL_RIGHT, (uint16_t)strlen(LV_SYMBOL_RIGHT), font, 0, LV_TXT_FLAG_NONE); + header_area.x1 = header_area.x2 - header_right - lv_txt_get_width(LV_SYMBOL_RIGHT, (uint16_t)strlen(LV_SYMBOL_RIGHT), font, 0, LV_TXT_FLAG_NONE); lv_draw_label_dsc_init(&label_dsc); lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_HEADER, &label_dsc); @@ -729,6 +722,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) */ static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask) { + lv_style_int_t bg_top = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_BG, LV_STYLE_PAD_TOP); lv_style_int_t left = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DAY_NAMES, LV_STYLE_PAD_LEFT); lv_style_int_t right = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DAY_NAMES, LV_STYLE_PAD_RIGHT); lv_style_int_t top = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DAY_NAMES, LV_STYLE_PAD_TOP); @@ -736,7 +730,7 @@ static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask) lv_coord_t w = lv_obj_get_width(calendar) - left - right; lv_coord_t box_w = w / 7; lv_area_t label_area; - label_area.y1 = calendar->coords.y1 + get_header_height(calendar) + top; + label_area.y1 = calendar->coords.y1 + get_header_height(calendar) + bg_top + top; label_area.y2 = label_area.y1 + lv_font_get_line_height(font); lv_draw_label_dsc_t label_dsc; @@ -744,11 +738,18 @@ static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask) lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_DAY_NAMES, &label_dsc); label_dsc.flag = LV_TXT_FLAG_CENTER; + lv_draw_rect_dsc_t rd; + lv_draw_rect_dsc_init(&rd); + uint32_t i; for(i = 0; i < 7; i++) { label_area.x1 = calendar->coords.x1 + (w * i) / 7 + left; label_area.x2 = label_area.x1 + box_w - 1; + + lv_draw_rect(&label_area, mask, &rd); + lv_draw_label(&label_area, mask, &label_dsc, get_day_name(calendar, i), NULL); + } } @@ -761,28 +762,28 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask) { lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); - - lv_style_int_t daynames_top = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DAY_NAMES, LV_STYLE_PAD_TOP); - lv_style_int_t daynames_bottom = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DAY_NAMES, LV_STYLE_PAD_BOTTOM); - const lv_font_t * daynames_font = lv_obj_get_style_ptr(calendar, LV_CALENDAR_PART_DAY_NAMES, LV_STYLE_FONT); - const lv_font_t * nums_font = lv_obj_get_style_ptr(calendar, LV_CALENDAR_PART_DATE_NUMS, LV_STYLE_FONT); + lv_style_int_t bg_top = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_BG, LV_STYLE_PAD_TOP); lv_style_int_t bg_bottom = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_BG, LV_STYLE_PAD_BOTTOM); lv_style_int_t bg_left = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_BG, LV_STYLE_PAD_LEFT); lv_style_int_t bg_right = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_BG, LV_STYLE_PAD_RIGHT); - lv_coord_t days_y1 = calendar->coords.y1 + get_header_height(calendar) + daynames_top + - lv_font_get_line_height(daynames_font) + daynames_bottom;; - lv_coord_t days_h = calendar->coords.y2 - days_y1 - bg_bottom; + lv_style_int_t days_inner = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE_NUMS, LV_STYLE_PAD_INNER); + + lv_coord_t days_y1 = calendar->coords.y1 + bg_top + get_header_height(calendar) + get_day_names_height(calendar); + + lv_coord_t days_h = calendar->coords.y2 - days_y1 - bg_bottom - 5 * days_inner; /*The state changes without re-caching the styles, disable the use of cache*/ lv_obj_state_dsc_t state_ori = calendar->state_dsc; + calendar->state_dsc.act = LV_OBJ_STATE_NORMAL; + calendar->state_dsc.prev = LV_OBJ_STATE_NORMAL; lv_obj_state_t month_state = LV_OBJ_STATE_DISABLED; uint8_t day_cnt; - lv_coord_t w = lv_obj_get_width(calendar) - bg_left - bg_right; + lv_coord_t w = lv_obj_get_width(calendar) - bg_left - bg_right - days_inner * 6; lv_coord_t box_w = w / 7; uint8_t month_start_day = get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1); @@ -819,6 +820,9 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask) box_area.y1 = days_y1 + (week * days_h) / 6; box_area.y2 = days_y1 + ((week + 1) * days_h) / 6; + box_area.y1 += days_inner * week; + box_area.y2 += days_inner * week; + lv_area_t label_area; label_area.y1 = box_area.y1 + (lv_area_get_height(&box_area) - lv_font_get_line_height(nums_font)) / 2; label_area.y2 = label_area.y1 + lv_font_get_line_height(nums_font); @@ -869,11 +873,15 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask) label_area.x1 = calendar->coords.x1 + (w * day) / 7 + bg_left; label_area.x2 = label_area.x1 + box_w - 1; + label_area.x1 += days_inner * day; + label_area.x2 += days_inner * day; + + box_area.x1 = label_area.x1; box_area.x2 = label_area.x2; - lv_draw_rect(&label_area, mask, &rect_dsc); + lv_draw_rect(&box_area, mask, &rect_dsc); /*Write the day's number*/ lv_utils_num_to_str(day_cnt, buf); diff --git a/src/lv_objx/lv_cb.c b/src/lv_objx/lv_cb.c index e285d954d..da4e39034 100644 --- a/src/lv_objx/lv_cb.c +++ b/src/lv_objx/lv_cb.c @@ -185,13 +185,11 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param) } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS) { lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CB_PART_BG)); - } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED) { - - }else if(sign == LV_SIGNAL_CONTROL) { + } else if(sign == LV_SIGNAL_CONTROL) { char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN || c == LV_KEY_LEFT || c == LV_KEY_UP) { /*Follow the backgrounds state with the bullet*/ - lv_btn_set_state(ext->bullet, lv_btn_get_state(cb)); + lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CB_PART_BG)); } } diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 0c6399354..8199aa6a8 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -86,10 +86,7 @@ typedef enum { LV_THEME_LIST_BTN, - LV_THEME_CALENDAR_BG, - LV_THEME_CALENDAR_HEADER, - LV_THEME_CALENDAR_DAY_NAMES, - LV_THEME_CALENDAR_DATE_NUMS, + LV_THEME_CALENDAR, LV_THEME_ARC_BG, LV_THEME_ARC, diff --git a/src/lv_themes/lv_theme_alien.c b/src/lv_themes/lv_theme_alien.c index 79bc4833e..eb2e42df4 100644 --- a/src/lv_themes/lv_theme_alien.c +++ b/src/lv_themes/lv_theme_alien.c @@ -95,7 +95,7 @@ static lv_style_t arc_bg; #endif #if LV_USE_CALENDAR -static lv_style_t calendar_date_nums; +static lv_style_t calendar_date_nums, calendar_header, calendar_daynames; #endif @@ -145,7 +145,7 @@ static void basic_init(void) lv_style_set_color(&panel, LV_STYLE_IMAGE_RECOLOR, lv_color_hex(0x979a9f)); lv_style_set_color(&panel, LV_STYLE_LINE_COLOR, lv_color_hex(0x979a9f)); lv_style_set_int(&panel, LV_STYLE_LINE_WIDTH, 1); - lv_style_set_color(&panel, LV_STYLE_BG_COLOR | LV_STYLE_STATE_FOCUS, LV_COLOR_RED); + lv_style_set_color(&panel, LV_STYLE_BG_COLOR | LV_STYLE_STATE_FOCUS, lv_color_mix(COLOR_CONTAINER, LV_COLOR_RED, LV_OPA_50)); lv_style_init(&btn); lv_style_set_int(&btn, LV_STYLE_RADIUS, LV_RADIUS_CIRCLE); @@ -163,7 +163,7 @@ static void basic_init(void) lv_style_set_int(&btn, LV_STYLE_PAD_BOTTOM, LV_DPI / 10); lv_style_set_int(&btn, LV_STYLE_PAD_INNER, LV_DPI / 10); lv_style_set_int(&btn, LV_STYLE_TRANSITION_TIME, 500); - lv_style_set_color(&btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_FOCUS, LV_COLOR_RED); + lv_style_set_color(&btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_FOCUS, lv_color_mix(LV_COLOR_RED, COLOR_ACCENT, LV_OPA_50)); } static void cont_init(void) @@ -338,19 +338,31 @@ static void chart_init(void) static void calendar_init(void) { #if LV_USE_CALENDAR - lv_style_init(&calendar_date_nums); - lv_style_set_color(&calendar_date_nums, LV_STYLE_TEXT_COLOR, LV_COLOR_RED); - lv_style_set_color(&calendar_date_nums, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_DISABLED, LV_COLOR_GRAY); -// lv_style_set_color(&calendar_date_nums, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_PRESSED, LV_COLOR_GRAY); - lv_style_set_color(&calendar_date_nums, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_CHECKED, LV_COLOR_NAVY); - lv_style_set_opa(&calendar_date_nums, LV_STYLE_BG_OPA , LV_OPA_TRANSP); - lv_style_set_opa(&calendar_date_nums, LV_STYLE_BG_OPA | LV_STYLE_STATE_FOCUS , LV_OPA_COVER); - lv_style_set_opa(&calendar_date_nums, LV_STYLE_BG_OPA | LV_STYLE_STATE_CHECKED , LV_OPA_COVER); - lv_style_set_opa(&calendar_date_nums, LV_STYLE_BG_OPA | LV_STYLE_STATE_PRESSED , LV_OPA_50); - lv_style_set_color(&calendar_date_nums, LV_STYLE_BG_COLOR | LV_STYLE_STATE_CHECKED, LV_COLOR_GREEN); + lv_style_init(&calendar_header); + lv_style_set_int(&calendar_header, LV_STYLE_PAD_LEFT , LV_DPI / 5); + lv_style_set_int(&calendar_header, LV_STYLE_PAD_RIGHT , LV_DPI / 5); + lv_style_set_int(&calendar_header, LV_STYLE_PAD_BOTTOM , LV_DPI / 5); + lv_style_set_color(&calendar_header, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_PRESSED, LV_COLOR_WHITE); + + lv_style_init(&calendar_daynames); + lv_style_set_int(&calendar_daynames, LV_STYLE_PAD_LEFT , LV_DPI / 5); + lv_style_set_int(&calendar_daynames, LV_STYLE_PAD_RIGHT , LV_DPI / 5); + lv_style_set_int(&calendar_daynames, LV_STYLE_PAD_BOTTOM , LV_DPI / 5); + + lv_style_init(&calendar_date_nums); + lv_style_set_int(&calendar_date_nums, LV_STYLE_RADIUS, LV_DPI / 50); + lv_style_set_color(&calendar_date_nums, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_CHECKED, LV_COLOR_WHITE); + lv_style_set_color(&calendar_date_nums, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_FOCUS, COLOR_ACCENT); + + lv_style_set_opa(&calendar_date_nums, LV_STYLE_BG_OPA | LV_STYLE_STATE_CHECKED , LV_OPA_20); + lv_style_set_opa(&calendar_date_nums, LV_STYLE_BG_OPA | LV_STYLE_STATE_PRESSED , LV_OPA_20); + lv_style_set_opa(&calendar_date_nums, LV_STYLE_BG_OPA | LV_STYLE_STATE_PRESSED | LV_STYLE_STATE_CHECKED , LV_OPA_40); + lv_style_set_color(&calendar_date_nums, LV_STYLE_BG_COLOR | LV_STYLE_STATE_CHECKED, LV_COLOR_WHITE); lv_style_set_int(&calendar_date_nums, LV_STYLE_BORDER_WIDTH | LV_STYLE_STATE_CHECKED , 2); lv_style_set_int(&calendar_date_nums, LV_STYLE_BORDER_SIDE| LV_STYLE_STATE_CHECKED , LV_BORDER_SIDE_LEFT); + lv_style_set_color(&calendar_date_nums, LV_STYLE_BORDER_COLOR | LV_STYLE_STATE_CHECKED, COLOR_ACCENT); + lv_style_set_int(&calendar_date_nums, LV_STYLE_PAD_INNER, LV_DPI / 20); #endif } @@ -500,7 +512,7 @@ static void tabview_init(void) lv_style_set_opa(&tabview_btns, LV_STYLE_BG_OPA | LV_STYLE_STATE_PRESSED, LV_OPA_COVER); lv_style_set_color(&tabview_btns, LV_STYLE_BG_COLOR | LV_STYLE_STATE_PRESSED, lv_color_hex(0x444444)); lv_style_set_color(&tabview_btns, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_CHECKED, COLOR_ACCENT); - lv_style_set_color(&tabview_btns, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_FOCUS, LV_COLOR_RED); + lv_style_set_color(&tabview_btns, LV_STYLE_TEXT_COLOR | LV_STYLE_STATE_FOCUS, LV_COLOR_GREEN); lv_style_set_int(&tabview_btns, LV_STYLE_PAD_TOP, LV_DPI / 5); lv_style_set_int(&tabview_btns, LV_STYLE_PAD_BOTTOM, LV_DPI / 5); @@ -870,6 +882,26 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name) lv_style_list_add_style(list, &sb); break; #endif + +#if LV_USE_TA + case LV_THEME_CALENDAR: + list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG); + lv_style_list_reset(list); + lv_style_list_add_style(list, &panel); + + list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE_NUMS); + lv_style_list_reset(list); + lv_style_list_add_style(list, &calendar_date_nums); + + list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER); + lv_style_list_reset(list); + lv_style_list_add_style(list, &calendar_header); + + list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES); + lv_style_list_reset(list); + lv_style_list_add_style(list, &calendar_daynames); + break; +#endif } @@ -895,14 +927,6 @@ lv_style_t * lv_theme_alien_get_style(lv_theme_style_t name) case LV_THEME_LIST_BTN: return &btn; #endif -#if LV_USE_CALENDAR - case LV_THEME_CALENDAR_BG: - return &panel; - case LV_THEME_CALENDAR_HEADER: - return &btn; - case LV_THEME_CALENDAR_DATE_NUMS: - return &calendar_date_nums; -#endif #if LV_USE_ARC case LV_THEME_ARC: return &arc;