mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Merge branch 'dev-5.2' of https://github.com/littlevgl/lvgl into dev-5.2
This commit is contained in:
commit
a89548ed48
@ -1123,7 +1123,7 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
|
||||
uint16_t col;
|
||||
#if LV_COMPILER_VLA_SUPPORTED
|
||||
lv_opa_t line_2d_blur[radius + swidth];
|
||||
lv_opa_t line_2d_blur[radius + swidth + 1];
|
||||
#else
|
||||
# if LV_HOR_RES > LV_VER_RES
|
||||
lv_opa_t line_2d_blur[LV_HOR_RES];
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "../lv_hal/lv_hal_indev.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_core/lv_indev.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -48,7 +49,7 @@ static uint8_t is_leap_year(uint32_t year);
|
||||
**********************/
|
||||
static lv_signal_func_t ancestor_signal;
|
||||
static lv_design_func_t ancestor_design;
|
||||
static const char * day_name[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||
static const char * day_name[7] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};
|
||||
static const char * month_name[12] = {"January", "February", "March", "April",
|
||||
"May", "June", "July", "August",
|
||||
"September", "October", "November", "December"
|
||||
@ -99,7 +100,7 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->month_names = NULL;
|
||||
ext->style_header = &lv_style_plain_color;
|
||||
ext->style_header_pr = &lv_style_pretty_color;
|
||||
ext->style_highlighted = &lv_style_plain_color;
|
||||
ext->style_highlighted_days = &lv_style_plain_color;
|
||||
ext->style_inactive_days = &lv_style_btn_ina;
|
||||
ext->style_week_box = &lv_style_plain_color;
|
||||
ext->style_today_box = &lv_style_pretty_color;
|
||||
@ -114,6 +115,28 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_set_size(new_calendar, LV_DPI * 2, LV_DPI * 2);
|
||||
lv_obj_set_style(new_calendar, &lv_style_pretty);
|
||||
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->calendar.bg);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->calendar.header);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->calendar.header_pr);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->calendar.day_names);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->calendar.week_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->calendar.today_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, th->calendar.highlighted_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->calendar.inactive_days);
|
||||
} else {
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, &lv_style_pretty);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, ext->style_header);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, ext->style_header_pr);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, ext->style_day_names);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, ext->style_week_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, ext->style_today_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, ext->style_highlighted_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, ext->style_inactive_days);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/*Copy an existing calendar*/
|
||||
else {
|
||||
@ -132,7 +155,7 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->month_names = copy_ext->month_names;
|
||||
ext->style_header = copy_ext->style_header;
|
||||
ext->style_header_pr = copy_ext->style_header_pr;
|
||||
ext->style_highlighted = copy_ext->style_highlighted;
|
||||
ext->style_highlighted_days = copy_ext->style_highlighted_days;
|
||||
ext->style_inactive_days = copy_ext->style_inactive_days;
|
||||
ext->style_week_box = copy_ext->style_week_box;
|
||||
ext->style_today_box = copy_ext->style_today_box;
|
||||
@ -255,7 +278,7 @@ void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, lv_sty
|
||||
ext->style_header_pr = style;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS:
|
||||
ext->style_highlighted = style;
|
||||
ext->style_highlighted_days = style;
|
||||
break;
|
||||
case LV_CALENDAR_STYLE_INACTIVE_DAYS:
|
||||
ext->style_inactive_days = style;
|
||||
@ -362,7 +385,7 @@ lv_style_t * lv_calendar_get_style(const lv_obj_t * calendar, lv_calendar_style_
|
||||
case LV_CALENDAR_STYLE_DAY_NAMES:
|
||||
return ext->style_day_names;
|
||||
case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS:
|
||||
return ext->style_highlighted;
|
||||
return ext->style_highlighted_days;
|
||||
case LV_CALENDAR_STYLE_INACTIVE_DAYS:
|
||||
return ext->style_inactive_days;
|
||||
case LV_CALENDAR_STYLE_WEEK_BOX:
|
||||
@ -549,9 +572,14 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
|
||||
lv_draw_rect(&header_area, mask, ext->style_header, opa_scale);
|
||||
|
||||
/*Add the month name*/
|
||||
/*Add the year + month name*/
|
||||
char txt_buf[64];
|
||||
lv_math_num_to_str(ext->today.year, txt_buf);
|
||||
txt_buf[4] = ' ';
|
||||
txt_buf[5] = '\0';
|
||||
strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month));
|
||||
header_area.y1 += ext->style_header->body.padding.ver;
|
||||
lv_draw_label(&header_area, mask, ext->style_header, opa_scale, get_month_name(calendar, ext->showed_date.month), LV_TXT_FLAG_CENTER, NULL);
|
||||
lv_draw_label(&header_area, mask, ext->style_header, opa_scale, txt_buf , LV_TXT_FLAG_CENTER, NULL);
|
||||
|
||||
/*Add the left arrow*/
|
||||
lv_style_t * arrow_style = ext->btn_pressing < 0 ? ext->style_header_pr : ext->style_header;
|
||||
@ -701,17 +729,17 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
is_highlighted(calendar, ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0),
|
||||
ext->showed_date.month == 1 ? 12 : ext->showed_date.month - 1,
|
||||
day_cnt)) {
|
||||
final_style = ext->style_highlighted;
|
||||
final_style = ext->style_highlighted_days;
|
||||
} else if(draw_state == DAY_DRAW_ACT_MONTH &&
|
||||
is_highlighted(calendar, ext->showed_date.year,
|
||||
ext->showed_date.month,
|
||||
day_cnt)) {
|
||||
final_style = ext->style_highlighted;
|
||||
final_style = ext->style_highlighted_days;
|
||||
} else if(draw_state == DAY_DRAW_NEXT_MONTH &&
|
||||
is_highlighted(calendar, ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0),
|
||||
ext->showed_date.month == 12 ? 1 : ext->showed_date.month + 1,
|
||||
day_cnt)) {
|
||||
final_style = ext->style_highlighted;
|
||||
final_style = ext->style_highlighted_days;
|
||||
} else if(month_of_today_shown && day_cnt == ext->today.day && draw_state == DAY_DRAW_ACT_MONTH) final_style = ext->style_today_box;
|
||||
else if(in_week_box && draw_state == DAY_DRAW_ACT_MONTH) final_style = ext->style_week_box;
|
||||
else final_style = act_style;
|
||||
|
@ -53,7 +53,7 @@ typedef struct {
|
||||
lv_style_t * style_header;
|
||||
lv_style_t * style_header_pr;
|
||||
lv_style_t * style_day_names;
|
||||
lv_style_t * style_highlighted;
|
||||
lv_style_t * style_highlighted_days;
|
||||
lv_style_t * style_inactive_days;
|
||||
lv_style_t * style_week_box;
|
||||
lv_style_t * style_today_box;
|
||||
|
@ -229,6 +229,28 @@ void lv_win_set_btn_size(lv_obj_t * win, lv_coord_t size)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the layout of the window
|
||||
* @param win pointer to a window object
|
||||
* @param layout the layout from 'lv_layout_t'
|
||||
*/
|
||||
void lv_win_set_layout(lv_obj_t *win, lv_layout_t layout)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
lv_page_set_scrl_layout(ext->page, layout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scroll bar mode of a window
|
||||
* @param win pointer to a window object
|
||||
* @param sb_mode the new scroll bar mode from 'lv_sb_mode_t'
|
||||
*/
|
||||
void lv_win_set_sb_mode(lv_obj_t *win, lv_sb_mode_t sb_mode)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
lv_page_set_sb_mode(ext->page, sb_mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a style of a window
|
||||
* @param win pointer to a window object
|
||||
@ -276,7 +298,6 @@ void lv_win_set_style(lv_obj_t * win, lv_win_style_t type, lv_style_t * style)
|
||||
btn = lv_obj_get_child_back(ext->header, btn);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -331,6 +352,42 @@ lv_obj_t * lv_win_get_from_btn(const lv_obj_t * ctrl_btn)
|
||||
return win;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the layout of a window
|
||||
* @param win pointer to a window object
|
||||
* @return the layout of the window (from 'lv_layout_t')
|
||||
*/
|
||||
lv_layout_t lv_win_get_layout(lv_obj_t *win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
return lv_page_get_scrl_layout(ext->page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the scroll bar mode of a window
|
||||
* @param win pointer to a window object
|
||||
* @return the scroll bar mode of the window (from 'lv_sb_mode_t')
|
||||
*/
|
||||
lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t *win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
return lv_page_get_sb_mode(ext->page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get width of the content area (page scrollable) of the window
|
||||
* @param win pointer to a window object
|
||||
* @return the width of the content_bg area
|
||||
*/
|
||||
lv_coord_t lv_win_get_width(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
||||
|
||||
return lv_obj_get_width(scrl) - 2 * style_scrl->body.padding.hor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a style of a window
|
||||
* @param win pointer to a button object
|
||||
|
@ -176,6 +176,27 @@ lv_coord_t lv_win_get_btn_size(const lv_obj_t * win);
|
||||
*/
|
||||
lv_obj_t * lv_win_get_from_btn(const lv_obj_t * ctrl_btn);
|
||||
|
||||
/**
|
||||
* Get the layout of a window
|
||||
* @param win pointer to a window object
|
||||
* @return the layout of the window (from 'lv_layout_t')
|
||||
*/
|
||||
lv_layout_t lv_win_get_layout(lv_obj_t *win);
|
||||
|
||||
/**
|
||||
* Get the scroll bar mode of a window
|
||||
* @param win pointer to a window object
|
||||
* @return the scroll bar mode of the window (from 'lv_sb_mode_t')
|
||||
*/
|
||||
lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t *win);
|
||||
|
||||
/**
|
||||
* Get width of the content area (page scrollable) of the window
|
||||
* @param win pointer to a window object
|
||||
* @return the width of the content area
|
||||
*/
|
||||
lv_coord_t lv_win_get_width(lv_obj_t * win);
|
||||
|
||||
/**
|
||||
* Get a style of a window
|
||||
* @param win pointer to a button object
|
||||
|
@ -107,6 +107,19 @@ typedef struct {
|
||||
lv_style_t *chart;
|
||||
#endif
|
||||
|
||||
#if USE_LV_CALENDAR != 0
|
||||
struct {
|
||||
lv_style_t *bg;
|
||||
lv_style_t *header;
|
||||
lv_style_t *header_pr;
|
||||
lv_style_t *day_names;
|
||||
lv_style_t *highlighted_days;
|
||||
lv_style_t *inactive_days;
|
||||
lv_style_t *week_box;
|
||||
lv_style_t *today_box;
|
||||
}calendar;
|
||||
#endif
|
||||
|
||||
#if USE_LV_CB != 0
|
||||
struct {
|
||||
lv_style_t *bg;
|
||||
|
@ -386,6 +386,46 @@ static void chart_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void calendar_init(void)
|
||||
{
|
||||
#if USE_LV_CALENDAR
|
||||
static lv_style_t header;
|
||||
static lv_style_t color_text;
|
||||
static lv_style_t gray_text;
|
||||
static lv_style_t today_box;
|
||||
|
||||
lv_style_copy(&header, &def);
|
||||
header.body.radius = 0;
|
||||
header.body.padding.hor = LV_DPI / 12;
|
||||
header.body.padding.ver = LV_DPI / 14;
|
||||
header.body.main_color = lv_color_hsv_to_rgb(_hue, 30, 60);
|
||||
header.body.grad_color = header.body.main_color;
|
||||
header.body.border.opa = panel.body.border.opa;
|
||||
header.body.border.width = panel.body.border.width;
|
||||
header.body.border.color = lv_color_hsv_to_rgb(_hue, 20, 80);
|
||||
header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100);
|
||||
|
||||
lv_style_copy(&today_box, &header);
|
||||
today_box.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 70);
|
||||
today_box.body.grad_color = today_box.body.main_color;
|
||||
today_box.body.empty = 1;
|
||||
|
||||
lv_style_copy(&color_text, &def);
|
||||
color_text.text.color = lv_color_hsv_to_rgb(_hue, 30, 80);
|
||||
|
||||
lv_style_copy(&gray_text, &def);
|
||||
gray_text.text.color = lv_color_hsv_to_rgb(_hue, 10, 65);
|
||||
|
||||
theme.calendar.bg = &panel;
|
||||
theme.calendar.header = &header;
|
||||
theme.calendar.week_box = &header;
|
||||
theme.calendar.today_box = &today_box;
|
||||
theme.calendar.day_names = &color_text;
|
||||
theme.calendar.highlighted_days = &color_text;
|
||||
theme.calendar.inactive_days= &gray_text;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cb_init(void)
|
||||
{
|
||||
#if USE_LV_CB != 0
|
||||
@ -667,23 +707,23 @@ static void tabview_init(void)
|
||||
static void win_init(void)
|
||||
{
|
||||
#if USE_LV_WIN != 0
|
||||
static lv_style_t win_header;
|
||||
static lv_style_t header;
|
||||
|
||||
lv_style_copy(&win_header, &def);
|
||||
win_header.body.radius = 0;
|
||||
win_header.body.padding.hor = LV_DPI / 12;
|
||||
win_header.body.padding.ver = LV_DPI / 20;
|
||||
win_header.body.main_color = lv_color_hsv_to_rgb(_hue, 20, 50);
|
||||
win_header.body.grad_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 = lv_color_hsv_to_rgb(_hue, 20, 80);
|
||||
win_header.body.border.part = LV_BORDER_BOTTOM;
|
||||
win_header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100);
|
||||
lv_style_copy(&header, &def);
|
||||
header.body.radius = 0;
|
||||
header.body.padding.hor = LV_DPI / 12;
|
||||
header.body.padding.ver = LV_DPI / 20;
|
||||
header.body.main_color = lv_color_hsv_to_rgb(_hue, 30, 60);
|
||||
header.body.grad_color = header.body.main_color;
|
||||
header.body.border.opa = panel.body.border.opa;
|
||||
header.body.border.width = panel.body.border.width;
|
||||
header.body.border.color = lv_color_hsv_to_rgb(_hue, 20, 80);
|
||||
header.body.border.part = LV_BORDER_BOTTOM;
|
||||
header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100);
|
||||
|
||||
theme.win.bg = &bg;
|
||||
theme.win.sb = &sb;
|
||||
theme.win.header = &win_header;
|
||||
theme.win.header = &header;
|
||||
theme.win.content.bg = &lv_style_transp;
|
||||
theme.win.content.scrl = &lv_style_transp;
|
||||
theme.win.btn.rel = &btn_rel;
|
||||
@ -728,6 +768,7 @@ lv_theme_t * lv_theme_alien_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