mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
add lv_calendar to themes
This commit is contained in:
parent
17785070a4
commit
89e946cc51
@ -574,7 +574,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
|
||||
/*Add the year + month name*/
|
||||
char txt_buf[64];
|
||||
lv_math_num_to_str(ext->today.year, txt_buf);
|
||||
lv_math_num_to_str(ext->showed_date.year, txt_buf);
|
||||
txt_buf[4] = ' ';
|
||||
txt_buf[5] = '\0';
|
||||
strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month));
|
||||
|
@ -36,6 +36,7 @@ typedef struct {
|
||||
#if USE_LV_CONT != 0
|
||||
lv_style_t *cont;
|
||||
#endif
|
||||
|
||||
#if USE_LV_BTN != 0
|
||||
struct {
|
||||
lv_style_t *rel;
|
||||
@ -46,6 +47,17 @@ typedef struct {
|
||||
} btn;
|
||||
#endif
|
||||
|
||||
|
||||
#if USE_LV_IMGBTN != 0
|
||||
struct {
|
||||
lv_style_t *rel;
|
||||
lv_style_t *pr;
|
||||
lv_style_t *tgl_rel;
|
||||
lv_style_t *tgl_pr;
|
||||
lv_style_t *ina;
|
||||
} imgbtn;
|
||||
#endif
|
||||
|
||||
#if USE_LV_LABEL != 0
|
||||
struct {
|
||||
lv_style_t *prim;
|
||||
|
@ -288,7 +288,7 @@ static void lmeter_init(void)
|
||||
lmeter.body.grad_color = lmeter.body.main_color;
|
||||
lmeter.body.padding.hor = LV_DPI / 10; /*Scale line length*/
|
||||
lmeter.line.color = LV_COLOR_HEX3(0x999);
|
||||
lmeter.line.width = 3;
|
||||
lmeter.line.width = 2;
|
||||
|
||||
theme.lmeter = &lmeter;
|
||||
#endif
|
||||
@ -316,12 +316,48 @@ static void gauge_init(void)
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
|
||||
|
||||
theme.chart = theme.panel;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void calendar_init(void)
|
||||
{
|
||||
#if USE_LV_CALENDAR
|
||||
static lv_style_t ina_days;
|
||||
lv_style_copy(&ina_days, &def);
|
||||
ina_days.text.color = lv_color_hsv_to_rgb(_hue, 0, 70);
|
||||
|
||||
static lv_style_t high_days;
|
||||
lv_style_copy(&high_days, &def);
|
||||
high_days.text.color = lv_color_hsv_to_rgb(_hue, 80, 90);
|
||||
|
||||
static lv_style_t week_box;
|
||||
lv_style_copy(&week_box, &def);
|
||||
week_box.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 100);
|
||||
week_box.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 100);
|
||||
week_box.body.padding.ver = LV_DPI / 20;
|
||||
week_box.body.padding.hor = theme.panel->body.padding.hor;
|
||||
week_box.body.border.color = theme.panel->body.border.color;
|
||||
week_box.body.border.width = theme.panel->body.border.width;
|
||||
week_box.body.border.part = LV_BORDER_LEFT | LV_BORDER_RIGHT;
|
||||
week_box.body.radius = 0;
|
||||
|
||||
static lv_style_t today_box;
|
||||
lv_style_copy(&today_box, &def);
|
||||
today_box.body.main_color = LV_COLOR_WHITE;
|
||||
today_box.body.grad_color = LV_COLOR_WHITE;
|
||||
today_box.body.padding.ver = LV_DPI / 20;
|
||||
today_box.body.radius = 0;
|
||||
|
||||
theme.calendar.bg = theme.panel;
|
||||
theme.calendar.header = &lv_style_transp;
|
||||
theme.calendar.inactive_days = &ina_days;
|
||||
theme.calendar.highlighted_days = &high_days;
|
||||
theme.calendar.week_box = &week_box;
|
||||
theme.calendar.today_box = &today_box;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cb_init(void)
|
||||
{
|
||||
#if USE_LV_CB != 0
|
||||
@ -723,6 +759,7 @@ lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t * font)
|
||||
lmeter_init();
|
||||
gauge_init();
|
||||
chart_init();
|
||||
calendar_init();
|
||||
cb_init();
|
||||
btnm_init();
|
||||
kb_init();
|
||||
|
@ -244,12 +244,23 @@ static void gauge_init(void)
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
|
||||
|
||||
theme.chart = &light_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void calendar_init(void)
|
||||
{
|
||||
#if USE_LV_CALENDAR
|
||||
static lv_style_t box;
|
||||
lv_style_copy(&box, &light_plain);
|
||||
box.body.padding.ver = LV_DPI / 20;
|
||||
|
||||
/*Can't handle highlighted dates in this theme*/
|
||||
theme.calendar.week_box = &box;
|
||||
theme.calendar.today_box = &box;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cb_init(void)
|
||||
{
|
||||
#if USE_LV_CB != 0
|
||||
@ -442,6 +453,7 @@ lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font)
|
||||
lmeter_init();
|
||||
gauge_init();
|
||||
chart_init();
|
||||
calendar_init();
|
||||
cb_init();
|
||||
btnm_init();
|
||||
kb_init();
|
||||
|
@ -160,16 +160,6 @@ static void label_init(void)
|
||||
#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
|
||||
@ -197,6 +187,16 @@ static void led_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void img_init(void)
|
||||
{
|
||||
#if USE_LV_IMG != 0
|
||||
|
||||
|
||||
theme.img.light = &def;
|
||||
theme.img.dark = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void bar_init(void)
|
||||
{
|
||||
#if USE_LV_BAR
|
||||
@ -281,11 +281,68 @@ static void gauge_init(void)
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
|
||||
theme.chart = &panel;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void calendar_init(void)
|
||||
{
|
||||
#if USE_LV_CALENDAR
|
||||
static lv_style_t cal_bg;
|
||||
lv_style_copy(&cal_bg, &bg);
|
||||
cal_bg.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 40);
|
||||
cal_bg.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 40);
|
||||
cal_bg.body.border.color = LV_COLOR_HEX3(0x333);
|
||||
cal_bg.body.border.width = 1;
|
||||
cal_bg.body.radius = LV_DPI / 20;
|
||||
cal_bg.body.padding.hor = LV_DPI/10;
|
||||
cal_bg.body.padding.ver = LV_DPI/10;
|
||||
|
||||
static lv_style_t cal_header;
|
||||
lv_style_copy(&cal_header, &bg);
|
||||
cal_header.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 20);
|
||||
cal_header.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 20);
|
||||
cal_header.body.radius = 0;
|
||||
cal_header.body.border.width = 1;
|
||||
cal_header.body.border.color = LV_COLOR_HEX3(0x333);
|
||||
cal_header.body.padding.hor = LV_DPI/10;
|
||||
cal_header.body.padding.ver = LV_DPI/10;
|
||||
|
||||
static lv_style_t week_box;
|
||||
lv_style_copy(&week_box, &panel);
|
||||
week_box.body.main_color = lv_color_hsv_to_rgb(_hue, 30, 45);
|
||||
week_box.body.grad_color = lv_color_hsv_to_rgb(_hue, 30, 45);
|
||||
week_box.body.radius = LV_DPI / 20;
|
||||
week_box.body.border.width = 1;
|
||||
week_box.body.padding.hor = LV_DPI / 20;
|
||||
week_box.body.padding.ver = LV_DPI / 25;
|
||||
|
||||
static lv_style_t today_box;
|
||||
lv_style_copy(&today_box, &week_box);
|
||||
today_box.body.main_color = lv_color_hsv_to_rgb(_hue, 80, 70);
|
||||
today_box.body.grad_color = lv_color_hsv_to_rgb(_hue, 80, 70);
|
||||
today_box.body.radius = LV_DPI / 20;
|
||||
today_box.body.padding.hor = LV_DPI / 14;
|
||||
today_box.body.padding.ver = LV_DPI / 14;
|
||||
|
||||
static lv_style_t highlighted_days;
|
||||
lv_style_copy(&highlighted_days, &bg);
|
||||
highlighted_days.text.color = lv_color_hsv_to_rgb(_hue, 40, 80);
|
||||
|
||||
static lv_style_t ina_days;
|
||||
lv_style_copy(&ina_days, &bg);
|
||||
ina_days.text.color = lv_color_hsv_to_rgb(_hue, 0, 60);
|
||||
|
||||
theme.calendar.bg = &cal_bg;
|
||||
theme.calendar.header = &cal_header;
|
||||
theme.calendar.week_box = &week_box;
|
||||
theme.calendar.today_box = &today_box;
|
||||
theme.calendar.highlighted_days = &highlighted_days;
|
||||
theme.calendar.day_names = &cal_bg;
|
||||
theme.calendar.inactive_days = &ina_days;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cb_init(void)
|
||||
{
|
||||
#if USE_LV_CB != 0
|
||||
@ -611,6 +668,7 @@ lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t * font)
|
||||
lmeter_init();
|
||||
gauge_init();
|
||||
chart_init();
|
||||
calendar_init();
|
||||
cb_init();
|
||||
btnm_init();
|
||||
kb_init();
|
||||
|
@ -74,6 +74,16 @@ static void btn_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void imgbtn_init(void)
|
||||
{
|
||||
#if USE_LV_IMGBTN != 0
|
||||
theme.imgbtn.rel = &def;
|
||||
theme.imgbtn.pr = &def;
|
||||
theme.imgbtn.tgl_rel = &def;
|
||||
theme.imgbtn.tgl_pr = &def;
|
||||
theme.imgbtn.ina = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void label_init(void)
|
||||
{
|
||||
@ -170,11 +180,25 @@ static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
|
||||
|
||||
theme.chart = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void calendar_init(void)
|
||||
{
|
||||
#if USE_LV_CALENDAR
|
||||
|
||||
theme.calendar.bg = theme.panel;
|
||||
theme.calendar.header = &def;
|
||||
theme.calendar.inactive_days = &def;
|
||||
theme.calendar.highlighted_days = &def;
|
||||
theme.calendar.week_box = &def;
|
||||
theme.calendar.today_box = &def;
|
||||
theme.calendar.header_pr = &def;
|
||||
theme.calendar.day_names = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cb_init(void)
|
||||
{
|
||||
#if USE_LV_CB != 0
|
||||
@ -352,6 +376,7 @@ lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t * font)
|
||||
basic_init();
|
||||
cont_init();
|
||||
btn_init();
|
||||
imgbtn_init();
|
||||
label_init();
|
||||
img_init();
|
||||
line_init();
|
||||
|
@ -128,7 +128,6 @@ static void btn_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void label_init(void)
|
||||
{
|
||||
#if USE_LV_LABEL != 0
|
||||
@ -296,12 +295,43 @@ static void gauge_init(void)
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
|
||||
|
||||
theme.chart = theme.panel;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void calendar_init(void)
|
||||
{
|
||||
#if USE_LV_CALENDAR != 0
|
||||
static lv_style_t ina_days;
|
||||
lv_style_copy(&ina_days, &def);
|
||||
ina_days.text.color = lv_color_hsv_to_rgb(_hue, 0, 70);
|
||||
|
||||
static lv_style_t high_days;
|
||||
lv_style_copy(&high_days, &def);
|
||||
high_days.text.color = lv_color_hsv_to_rgb(_hue, 50, 90);
|
||||
|
||||
static lv_style_t week_box;
|
||||
lv_style_copy(&week_box, &def);
|
||||
week_box.body.empty = 1;
|
||||
week_box.body.border.color = theme.panel->body.border.color;
|
||||
week_box.body.padding.ver = LV_DPI / 20;
|
||||
|
||||
static lv_style_t today_box;
|
||||
lv_style_copy(&today_box, &def);
|
||||
today_box.body.main_color = LV_COLOR_WHITE;
|
||||
today_box.body.grad_color = LV_COLOR_WHITE;
|
||||
today_box.body.padding.ver = LV_DPI / 20;
|
||||
today_box.body.radius = 0;
|
||||
|
||||
theme.calendar.bg = theme.panel;
|
||||
theme.calendar.header = &lv_style_transp;
|
||||
theme.calendar.inactive_days = &ina_days;
|
||||
theme.calendar.highlighted_days = &high_days;
|
||||
theme.calendar.week_box = &week_box;
|
||||
theme.calendar.today_box = &week_box;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cb_init(void)
|
||||
{
|
||||
#if USE_LV_CB != 0
|
||||
@ -704,6 +734,7 @@ lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t * font)
|
||||
lmeter_init();
|
||||
gauge_init();
|
||||
chart_init();
|
||||
calendar_init();
|
||||
cb_init();
|
||||
btnm_init();
|
||||
kb_init();
|
||||
|
Loading…
x
Reference in New Issue
Block a user