calendar, list, arc and line improvments
This commit is contained in:
@@ -1467,11 +1467,17 @@ void lv_obj_set_state(lv_obj_t * obj, lv_obj_state_t new_state)
|
||||
obj->state_dsc.anim = 0;
|
||||
lv_obj_refresh_style(obj);
|
||||
}
|
||||
/*Set the new state for prev state too to get the TRANSITION_TIME for the new state*/
|
||||
else {
|
||||
|
||||
bool was_anim = lv_anim_del(obj, obj_state_anim_cb);
|
||||
|
||||
if(obj->state_dsc.anim == 0 && was_anim) {
|
||||
obj->state_dsc.act = new_state;
|
||||
} else {
|
||||
obj->state_dsc.prev = obj->state_dsc.act;
|
||||
obj->state_dsc.act = new_state;
|
||||
obj->state_dsc.anim = 0;
|
||||
}
|
||||
|
||||
lv_anim_t a;
|
||||
lv_anim_init(&a);
|
||||
@@ -1479,6 +1485,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_obj_state_t new_state)
|
||||
lv_anim_set_values(&a, 0, 255);
|
||||
lv_anim_set_time(&a, t, 0);
|
||||
lv_anim_create(&a);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2762,6 +2769,9 @@ void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t
|
||||
if(draw_dsc->dash_width) {
|
||||
draw_dsc->dash_gap = lv_obj_get_style_int(obj, part, LV_STYLE_LINE_DASH_GAP);
|
||||
}
|
||||
|
||||
draw_dsc->round_start = lv_obj_get_style_int(obj, part, LV_STYLE_LINE_ROUNDED);
|
||||
draw_dsc->round_end = draw_dsc->round_start;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -129,6 +129,7 @@ enum {
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_LINE_BLEND_MODE, 0x7, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_LINE_DASH_WIDTH, 0x7, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_LINE_DASH_GAP, 0x7, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_LINE_ROUNDED, 0x7, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_LINE_COLOR, 0x7, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
|
||||
LV_STYLE_PROP_INIT(LV_STYLE_LINE_OPA, 0x7, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
|
||||
|
||||
|
||||
@@ -56,38 +56,36 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
LV_LOG_TRACE("arc create started");
|
||||
|
||||
/*Create the ancestor of arc*/
|
||||
lv_obj_t * new_arc = lv_obj_create(par, copy);
|
||||
LV_ASSERT_MEM(new_arc);
|
||||
if(new_arc == NULL) return NULL;
|
||||
lv_obj_t * arc = lv_obj_create(par, copy);
|
||||
LV_ASSERT_MEM(arc);
|
||||
if(arc == NULL) return NULL;
|
||||
|
||||
/*Allocate the arc type specific extended data*/
|
||||
lv_arc_ext_t * ext = lv_obj_allocate_ext_attr(new_arc, sizeof(lv_arc_ext_t));
|
||||
lv_arc_ext_t * ext = lv_obj_allocate_ext_attr(arc, sizeof(lv_arc_ext_t));
|
||||
LV_ASSERT_MEM(ext);
|
||||
if(ext == NULL) {
|
||||
lv_obj_del(new_arc);
|
||||
lv_obj_del(arc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_arc);
|
||||
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_arc);
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(arc);
|
||||
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(arc);
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->angle_start = 45;
|
||||
ext->angle_end = 315;
|
||||
lv_style_list_init(&ext->style_arc);
|
||||
|
||||
lv_obj_set_size(new_arc, LV_DPI, LV_DPI);
|
||||
|
||||
lv_obj_set_size(arc, LV_DPI, LV_DPI);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_cb(new_arc, lv_arc_signal);
|
||||
lv_obj_set_design_cb(new_arc, lv_arc_design);
|
||||
lv_obj_set_signal_cb(arc, lv_arc_signal);
|
||||
lv_obj_set_design_cb(arc, lv_arc_design);
|
||||
|
||||
/*Init the new arc arc*/
|
||||
if(copy == NULL) {
|
||||
lv_style_list_init(&ext->style_arc);
|
||||
lv_style_list_reset(&new_arc->style_list);
|
||||
_ot(new_arc, LV_ARC_PART_BG, ARC_BG);
|
||||
_ot(new_arc, LV_ARC_PART_ARC, ARC);
|
||||
|
||||
lv_theme_apply(arc, LV_THEME_ARC);
|
||||
}
|
||||
/*Copy an existing arc*/
|
||||
else {
|
||||
@@ -96,12 +94,12 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->angle_end = copy_ext->angle_end;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_arc);
|
||||
lv_obj_refresh_style(arc);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("arc created");
|
||||
|
||||
return new_arc;
|
||||
return arc;
|
||||
}
|
||||
|
||||
/*======================
|
||||
|
||||
@@ -43,7 +43,7 @@ static lv_coord_t get_header_height(lv_obj_t * calendar);
|
||||
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);
|
||||
static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask);
|
||||
static void draw_days(lv_obj_t * calendar, const lv_area_t * mask);
|
||||
static void draw_dates(lv_obj_t * calendar, const lv_area_t * mask);
|
||||
static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day);
|
||||
static bool is_highlighted(lv_obj_t * calendar, day_draw_state_t draw_state, int32_t year, int32_t month, int32_t day);
|
||||
static bool is_pressed(lv_obj_t * calendar, day_draw_state_t draw_state, int32_t year, int32_t month, int32_t day);
|
||||
@@ -128,7 +128,7 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
if(copy == NULL) {
|
||||
lv_theme_apply(calendar, LV_THEME_CALENDAR);
|
||||
|
||||
lv_obj_set_size(calendar, LV_DPI * 4, LV_DPI * 3);
|
||||
lv_obj_set_size(calendar, 5*LV_DPI/2, 5*LV_DPI/2);
|
||||
|
||||
}
|
||||
/*Copy an existing calendar*/
|
||||
@@ -391,7 +391,7 @@ static lv_design_res_t lv_calendar_design(lv_obj_t * calendar, const lv_area_t *
|
||||
|
||||
draw_header(calendar, clip_area);
|
||||
draw_day_names(calendar, clip_area);
|
||||
draw_days(calendar, clip_area);
|
||||
draw_dates(calendar, clip_area);
|
||||
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
@@ -547,7 +547,7 @@ static lv_style_list_t * lv_calendar_get_style(lv_obj_t * calendar, uint8_t part
|
||||
case LV_CALENDAR_PART_DAY_NAMES:
|
||||
style_dsc_p = &ext->style_day_names;
|
||||
break;
|
||||
case LV_CALENDAR_PART_DATE_NUMS:
|
||||
case LV_CALENDAR_PART_DATE:
|
||||
style_dsc_p = &ext->style_date_nums;
|
||||
break;
|
||||
default:
|
||||
@@ -569,14 +569,14 @@ static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touche
|
||||
{
|
||||
lv_area_t days_area;
|
||||
lv_area_copy(&days_area, &calendar->coords);
|
||||
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);
|
||||
lv_style_int_t left = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_LEFT);
|
||||
lv_style_int_t right = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_RIGHT);
|
||||
lv_style_int_t top = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_TOP);
|
||||
lv_style_int_t bottom = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_BOTTOM);
|
||||
|
||||
days_area.x1 += left;
|
||||
days_area.x2 -= right;
|
||||
days_area.y1 = calendar->coords.y1 + top + get_header_height(calendar) + get_day_names_height(calendar);
|
||||
days_area.y1 = calendar->coords.y1 + get_header_height(calendar) + get_day_names_height(calendar) + top;
|
||||
days_area.y2 -= bottom;
|
||||
|
||||
if(lv_area_is_point_on(&days_area, touched_point, 0)) {
|
||||
@@ -649,9 +649,6 @@ 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 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);
|
||||
@@ -662,8 +659,8 @@ 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 + bg_top;
|
||||
header_area.y2 = calendar->coords.y1 + get_header_height(calendar);
|
||||
header_area.y1 = calendar->coords.y1 + header_top;
|
||||
header_area.y2 = calendar->coords.y1 + lv_font_get_line_height(font);
|
||||
|
||||
lv_draw_rect_dsc_t header_rect_dsc;
|
||||
lv_draw_rect_dsc_init(&header_rect_dsc);
|
||||
@@ -676,7 +673,6 @@ 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 += header_top;
|
||||
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
@@ -722,15 +718,30 @@ 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 date_top = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_TOP);
|
||||
lv_style_int_t date_bottom = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_BOTTOM);
|
||||
lv_style_int_t date_left = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_LEFT);
|
||||
lv_style_int_t date_right = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_RIGHT);
|
||||
lv_style_int_t date_inner = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_INNER);
|
||||
|
||||
lv_coord_t days_w = lv_obj_get_width(calendar) - date_left - date_right;
|
||||
lv_coord_t box_w = (days_w - date_inner * 6) / 7;
|
||||
lv_coord_t days_y1 = calendar->coords.y1 + date_top + get_header_height(calendar) + get_day_names_height(calendar);
|
||||
lv_coord_t days_h = calendar->coords.y2 - days_y1 - date_bottom;
|
||||
lv_coord_t box_h = (days_h - 5 * date_inner) / 6;
|
||||
lv_coord_t box_size = LV_MATH_MIN(box_w, box_h);
|
||||
|
||||
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);
|
||||
const lv_font_t * font = lv_obj_get_style_ptr(calendar, LV_CALENDAR_PART_DAY_NAMES, LV_STYLE_FONT);
|
||||
|
||||
lv_coord_t w = lv_obj_get_width(calendar) - left - right;
|
||||
lv_coord_t box_w = w / 7;
|
||||
|
||||
lv_coord_t label_w = w / 6;
|
||||
|
||||
lv_area_t label_area;
|
||||
label_area.y1 = calendar->coords.y1 + get_header_height(calendar) + bg_top + top;
|
||||
label_area.y1 = calendar->coords.y1 + get_header_height(calendar) + top;
|
||||
label_area.y2 = label_area.y1 + lv_font_get_line_height(font);
|
||||
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
@@ -738,18 +749,13 @@ 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);
|
||||
label_area.x1 = calendar->coords.x1 + ((w - box_size) * i) / 6 + box_size / 2 - label_w / 2 + left;
|
||||
label_area.x2 = label_area.x1 + label_w - 1;
|
||||
|
||||
lv_draw_label(&label_area, mask, &label_dsc, get_day_name(calendar, i), NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -758,22 +764,20 @@ static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
* @param calendar point to a calendar
|
||||
* @param mask a mask for drawing
|
||||
*/
|
||||
static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
static void draw_dates(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
{
|
||||
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
|
||||
|
||||
const lv_font_t * nums_font = lv_obj_get_style_ptr(calendar, LV_CALENDAR_PART_DATE_NUMS, LV_STYLE_FONT);
|
||||
const lv_font_t * nums_font = lv_obj_get_style_ptr(calendar, LV_CALENDAR_PART_DATE, 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_style_int_t date_top = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_TOP);
|
||||
lv_style_int_t date_bottom = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_BOTTOM);
|
||||
lv_style_int_t date_left = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_LEFT);
|
||||
lv_style_int_t date_right = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_RIGHT);
|
||||
lv_style_int_t date_inner = lv_obj_get_style_int(calendar, LV_CALENDAR_PART_DATE, LV_STYLE_PAD_INNER);
|
||||
|
||||
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;
|
||||
lv_coord_t days_y1 = calendar->coords.y1 + date_top + get_header_height(calendar) + get_day_names_height(calendar);
|
||||
lv_coord_t days_h = calendar->coords.y2 - days_y1 - date_bottom;
|
||||
|
||||
/*The state changes without re-caching the styles, disable the use of cache*/
|
||||
lv_obj_state_dsc_t state_ori = calendar->state_dsc;
|
||||
@@ -783,13 +787,14 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
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 - days_inner * 6;
|
||||
lv_coord_t box_w = w / 7;
|
||||
lv_coord_t days_w = lv_obj_get_width(calendar) - date_left - date_right;
|
||||
lv_coord_t box_w = (days_w - date_inner * 6) / 7;
|
||||
lv_coord_t box_h = (days_h - 5 * date_inner) / 6;
|
||||
lv_coord_t box_size = LV_MATH_MIN(box_w, box_h);
|
||||
|
||||
uint8_t month_start_day = get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1);
|
||||
|
||||
day_draw_state_t draw_state; /*true: Not the prev. or next month is drawn*/
|
||||
|
||||
day_draw_state_t draw_state;
|
||||
|
||||
/*If starting with the first day of the week then the previous month is not visible*/
|
||||
if(month_start_day == 0) {
|
||||
@@ -817,11 +822,9 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
uint32_t week;
|
||||
for(week = 0; week < 6; week++) {
|
||||
lv_area_t box_area;
|
||||
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;
|
||||
box_area.y1 = days_y1 + ((days_h - box_size) * week) / 5;
|
||||
box_area.y2 = box_area.y1 + box_size - 1;
|
||||
|
||||
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;
|
||||
@@ -863,19 +866,14 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
|
||||
|
||||
calendar->state_dsc.act = day_state;
|
||||
calendar->state_dsc.prev = day_state;
|
||||
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_DATE_NUMS, &label_dsc);
|
||||
lv_obj_init_draw_rect_dsc(calendar, LV_CALENDAR_PART_DATE_NUMS, &rect_dsc);
|
||||
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_DATE, &label_dsc);
|
||||
lv_obj_init_draw_rect_dsc(calendar, LV_CALENDAR_PART_DATE, &rect_dsc);
|
||||
|
||||
prev_state = day_state;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
label_area.x1 = calendar->coords.x1 + ((days_w - box_size) * day) / 6 + date_left;
|
||||
label_area.x2 = label_area.x1 + box_size - 1;
|
||||
|
||||
box_area.x1 = label_area.x1;
|
||||
box_area.x2 = label_area.x2;
|
||||
|
||||
@@ -63,7 +63,7 @@ enum {
|
||||
LV_CALENDAR_PART_BG, /**< Background and "normal" date numbers style */
|
||||
LV_CALENDAR_PART_HEADER, /** Calendar header style */
|
||||
LV_CALENDAR_PART_DAY_NAMES, /** Day name style */
|
||||
LV_CALENDAR_PART_DATE_NUMS, /** Day name style */
|
||||
LV_CALENDAR_PART_DATE, /** Day name style */
|
||||
};
|
||||
typedef uint8_t lv_calendar_part_t;
|
||||
|
||||
|
||||
@@ -61,28 +61,28 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
{
|
||||
LV_LOG_TRACE("image create started");
|
||||
|
||||
lv_obj_t * new_img = NULL;
|
||||
lv_obj_t * img = NULL;
|
||||
|
||||
/*Create a basic object*/
|
||||
new_img = lv_obj_create(par, copy);
|
||||
LV_ASSERT_MEM(new_img);
|
||||
if(new_img == NULL) return NULL;
|
||||
img = lv_obj_create(par, copy);
|
||||
LV_ASSERT_MEM(img);
|
||||
if(img == NULL) return NULL;
|
||||
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_img);
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(img);
|
||||
|
||||
/*Extend the basic object to image object*/
|
||||
lv_img_ext_t * ext = lv_obj_allocate_ext_attr(new_img, sizeof(lv_img_ext_t));
|
||||
lv_img_ext_t * ext = lv_obj_allocate_ext_attr(img, sizeof(lv_img_ext_t));
|
||||
LV_ASSERT_MEM(ext);
|
||||
if(ext == NULL) {
|
||||
lv_obj_del(new_img);
|
||||
lv_obj_del(img);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ext->src = NULL;
|
||||
ext->src_type = LV_IMG_SRC_UNKNOWN;
|
||||
ext->cf = LV_IMG_CF_UNKNOWN;
|
||||
ext->w = lv_obj_get_width(new_img);
|
||||
ext->h = lv_obj_get_height(new_img);
|
||||
ext->w = lv_obj_get_width(img);
|
||||
ext->h = lv_obj_get_height(img);
|
||||
ext->angle = 0;
|
||||
ext->zoom = LV_IMG_ZOOM_NONE;
|
||||
ext->antialias = LV_ANTIALIAS ? 1 : 0;
|
||||
@@ -93,12 +93,13 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->pivot.y = 0;
|
||||
|
||||
/*Init the new object*/
|
||||
lv_obj_set_signal_cb(new_img, lv_img_signal);
|
||||
lv_obj_set_design_cb(new_img, lv_img_design);
|
||||
lv_obj_set_signal_cb(img, lv_img_signal);
|
||||
lv_obj_set_design_cb(img, lv_img_design);
|
||||
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_click(new_img, false);
|
||||
lv_obj_set_adv_hittest(new_img, true); /*Images have fast hit-testing*/
|
||||
lv_theme_apply(img, LV_THEME_IMAGE);
|
||||
lv_obj_set_click(img, false);
|
||||
lv_obj_set_adv_hittest(img, true); /*Images have fast hit-testing*/
|
||||
/* Enable auto size for non screens
|
||||
* because image screens are wallpapers
|
||||
* and must be screen sized*/
|
||||
@@ -110,15 +111,15 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
} else {
|
||||
lv_img_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->auto_size = copy_ext->auto_size;
|
||||
lv_img_set_src(new_img, copy_ext->src);
|
||||
lv_img_set_src(img, copy_ext->src);
|
||||
|
||||
// /*Refresh the style with new signal function*/
|
||||
// lv_obj_refresh_style(new_img);
|
||||
lv_obj_refresh_style(img);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("image created");
|
||||
|
||||
return new_img;
|
||||
return img;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
|
||||
@@ -240,8 +240,6 @@ static lv_design_res_t lv_line_design(lv_obj_t * line, const lv_area_t * clip_ar
|
||||
lv_draw_line_dsc_t line_dsc;
|
||||
lv_draw_line_dsc_init(&line_dsc);
|
||||
lv_obj_init_draw_line_dsc(line, LV_LINE_PART_MAIN, &line_dsc);
|
||||
line_dsc.round_end = 1;
|
||||
line_dsc.round_start = 1;
|
||||
|
||||
/*Read all points and draw the lines*/
|
||||
for(i = 0; i < ext->point_num - 1; i++) {
|
||||
@@ -257,7 +255,7 @@ static lv_design_res_t lv_line_design(lv_obj_t * line, const lv_area_t * clip_ar
|
||||
p2.y = h - ext->point_array[i + 1].y + y_ofs;
|
||||
}
|
||||
lv_draw_line(&p1, &p2, clip_area, &line_dsc);
|
||||
line_dsc.round_start = 0;
|
||||
line_dsc.round_start = 0; /*Draw the rounding only on the end points after the first line*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,16 +72,16 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
LV_LOG_TRACE("list create started");
|
||||
|
||||
/*Create the ancestor basic object*/
|
||||
lv_obj_t * new_list = lv_page_create(par, copy);
|
||||
LV_ASSERT_MEM(new_list);
|
||||
if(new_list == NULL) return NULL;
|
||||
lv_obj_t * list = lv_page_create(par, copy);
|
||||
LV_ASSERT_MEM(list);
|
||||
if(list == NULL) return NULL;
|
||||
|
||||
if(ancestor_page_signal == NULL) ancestor_page_signal = lv_obj_get_signal_cb(new_list);
|
||||
if(ancestor_page_signal == NULL) ancestor_page_signal = lv_obj_get_signal_cb(list);
|
||||
|
||||
lv_list_ext_t * ext = lv_obj_allocate_ext_attr(new_list, sizeof(lv_list_ext_t));
|
||||
lv_list_ext_t * ext = lv_obj_allocate_ext_attr(list, sizeof(lv_list_ext_t));
|
||||
LV_ASSERT_MEM(ext);
|
||||
if(ext == NULL) {
|
||||
lv_obj_del(new_list);
|
||||
lv_obj_del(list);
|
||||
return NULL;
|
||||
}
|
||||
ext->single_mode = 0;
|
||||
@@ -93,15 +93,18 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->last_clicked_btn = NULL;
|
||||
#endif
|
||||
|
||||
lv_obj_set_signal_cb(new_list, lv_list_signal);
|
||||
lv_obj_set_signal_cb(list, lv_list_signal);
|
||||
|
||||
/*Init the new list object*/
|
||||
if(copy == NULL) {
|
||||
lv_page_set_anim_time(new_list, LV_LIST_DEF_ANIM_TIME);
|
||||
lv_page_set_scrl_fit2(new_list, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
||||
lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI);
|
||||
lv_page_set_scrl_layout(new_list, LV_LIST_LAYOUT_DEF);
|
||||
lv_list_set_sb_mode(new_list, LV_SB_MODE_DRAG);
|
||||
lv_page_set_anim_time(list, LV_LIST_DEF_ANIM_TIME);
|
||||
lv_page_set_scrl_fit2(list, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
||||
lv_obj_set_size(list, 2 * LV_DPI, 3 * LV_DPI);
|
||||
lv_page_set_scrl_layout(list, LV_LIST_LAYOUT_DEF);
|
||||
lv_list_set_sb_mode(list, LV_SB_MODE_DRAG);
|
||||
|
||||
lv_theme_apply(list, LV_THEME_LIST);
|
||||
|
||||
} else {
|
||||
lv_list_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
|
||||
@@ -112,17 +115,17 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_t * copy_img = lv_list_get_btn_img(copy_btn);
|
||||
if(copy_img) img_src = lv_img_get_src(copy_img);
|
||||
#endif
|
||||
lv_list_add_btn(new_list, img_src, lv_list_get_btn_text(copy_btn));
|
||||
lv_list_add_btn(list, img_src, lv_list_get_btn_text(copy_btn));
|
||||
copy_btn = lv_list_get_next_btn(copy, copy_btn);
|
||||
}
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
// lv_obj_refresh_style(new_list);
|
||||
lv_obj_refresh_style(list);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("list created");
|
||||
|
||||
return new_list;
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,8 +174,7 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
|
||||
if(ancestor_btn_signal == NULL) ancestor_btn_signal = lv_obj_get_signal_cb(liste);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_style_list_reset(&liste->style_list);
|
||||
_ot(liste, LV_BTN_PART_MAIN, LIST_BTN);
|
||||
lv_theme_apply(liste, LV_THEME_LIST_BTN);
|
||||
|
||||
lv_page_glue_obj(liste, true);
|
||||
lv_btn_set_layout(liste, LV_LAYOUT_ROW_M);
|
||||
|
||||
@@ -47,7 +47,6 @@ typedef enum {
|
||||
LV_THEME_IMAGE,
|
||||
|
||||
LV_THEME_BTNM,
|
||||
LV_THEME_BTNM_BTN,
|
||||
|
||||
LV_THEME_BAR,
|
||||
|
||||
@@ -79,16 +78,12 @@ typedef enum {
|
||||
LV_THEME_TA_SCRLBAR,
|
||||
|
||||
|
||||
LV_THEME_LIST_BG,
|
||||
LV_THEME_LIST_SCRL,
|
||||
LV_THEME_LIST_SCRLBAR,
|
||||
LV_THEME_LIST_EDGE_FLASH,
|
||||
LV_THEME_LIST,
|
||||
LV_THEME_LIST_BTN,
|
||||
|
||||
|
||||
LV_THEME_CALENDAR,
|
||||
|
||||
LV_THEME_ARC_BG,
|
||||
LV_THEME_ARC,
|
||||
|
||||
LV_THEME_LED,
|
||||
|
||||
@@ -81,6 +81,11 @@ static lv_style_t gauge;
|
||||
static lv_style_t gauge_strong;
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_USE_LIST
|
||||
static lv_style_t list_bg, list_btn;
|
||||
#endif
|
||||
|
||||
#if LV_USE_DDLIST
|
||||
static lv_style_t ddlist_bg, ddlist_sel;
|
||||
#endif
|
||||
@@ -157,6 +162,7 @@ static void basic_init(void)
|
||||
lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR| LV_STYLE_STATE_PRESSED, lv_color_darken(lv_color_hex(0xffffff), LV_OPA_20));
|
||||
lv_style_set_color(&btn, LV_STYLE_TEXT_COLOR| LV_STYLE_STATE_DISABLED, lv_color_hex(0x686b70));
|
||||
lv_style_set_color(&btn, LV_STYLE_IMAGE_RECOLOR, LV_COLOR_WHITE);
|
||||
lv_style_set_color(&btn, LV_STYLE_IMAGE_RECOLOR| LV_STYLE_STATE_PRESSED, lv_color_darken(lv_color_hex(0xffffff), LV_OPA_20));
|
||||
lv_style_set_int(&btn, LV_STYLE_PAD_LEFT, LV_DPI / 5);
|
||||
lv_style_set_int(&btn, LV_STYLE_PAD_RIGHT, LV_DPI / 5);
|
||||
lv_style_set_int(&btn, LV_STYLE_PAD_TOP, LV_DPI / 10);
|
||||
@@ -288,12 +294,13 @@ static void arc_init(void)
|
||||
{
|
||||
#if LV_USE_ARC != 0
|
||||
lv_style_init(&arc);
|
||||
lv_style_set_color(&arc, LV_STYLE_LINE_COLOR, LV_COLOR_AQUA);
|
||||
lv_style_set_int(&arc, LV_STYLE_LINE_WIDTH, 4);
|
||||
lv_style_set_color(&arc, LV_STYLE_LINE_COLOR, COLOR_ACCENT);
|
||||
lv_style_set_int(&arc, LV_STYLE_LINE_WIDTH, LV_DPI / 8);
|
||||
lv_style_set_int(&arc, LV_STYLE_LINE_ROUNDED, 1);
|
||||
|
||||
lv_style_init(&arc_bg);
|
||||
lv_style_set_color(&arc_bg, LV_STYLE_BORDER_COLOR, LV_COLOR_GRAY);
|
||||
lv_style_set_int(&arc_bg, LV_STYLE_BORDER_WIDTH, 4);
|
||||
lv_style_set_int(&arc_bg, LV_STYLE_BORDER_WIDTH, LV_DPI / 8);
|
||||
lv_style_set_opa(&arc_bg, LV_STYLE_BG_OPA, LV_OPA_TRANSP);
|
||||
|
||||
#endif
|
||||
@@ -340,15 +347,16 @@ static void calendar_init(void)
|
||||
#if LV_USE_CALENDAR
|
||||
|
||||
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_int(&calendar_header, LV_STYLE_PAD_TOP, LV_DPI / 7);
|
||||
lv_style_set_int(&calendar_header, LV_STYLE_PAD_LEFT , LV_DPI / 7);
|
||||
lv_style_set_int(&calendar_header, LV_STYLE_PAD_RIGHT , LV_DPI / 7);
|
||||
lv_style_set_int(&calendar_header, LV_STYLE_PAD_BOTTOM , LV_DPI / 7);
|
||||
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_set_int(&calendar_daynames, LV_STYLE_PAD_LEFT , LV_DPI / 7);
|
||||
lv_style_set_int(&calendar_daynames, LV_STYLE_PAD_RIGHT , LV_DPI / 7);
|
||||
lv_style_set_int(&calendar_daynames, LV_STYLE_PAD_BOTTOM , LV_DPI / 7);
|
||||
|
||||
lv_style_init(&calendar_date_nums);
|
||||
lv_style_set_int(&calendar_date_nums, LV_STYLE_RADIUS, LV_DPI / 50);
|
||||
@@ -362,7 +370,10 @@ static void calendar_init(void)
|
||||
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);
|
||||
lv_style_set_int(&calendar_date_nums, LV_STYLE_PAD_INNER, LV_DPI / 30);
|
||||
lv_style_set_int(&calendar_date_nums, LV_STYLE_PAD_LEFT , LV_DPI / 7);
|
||||
lv_style_set_int(&calendar_date_nums, LV_STYLE_PAD_RIGHT , LV_DPI / 7);
|
||||
lv_style_set_int(&calendar_date_nums, LV_STYLE_PAD_BOTTOM , LV_DPI / 7);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -476,6 +487,35 @@ static void spinbox_init(void)
|
||||
static void list_init(void)
|
||||
{
|
||||
#if LV_USE_LIST != 0
|
||||
lv_style_init(&list_bg);
|
||||
lv_style_copy(&list_bg, &panel);
|
||||
lv_style_set_int(&list_bg, LV_STYLE_PAD_LEFT, LV_DPI / 10);
|
||||
lv_style_set_int(&list_bg, LV_STYLE_PAD_RIGHT, LV_DPI / 10);
|
||||
lv_style_set_int(&list_bg, LV_STYLE_PAD_TOP, 0);
|
||||
lv_style_set_int(&list_bg, LV_STYLE_PAD_BOTTOM, 0);
|
||||
lv_style_set_int(&list_bg, LV_STYLE_PAD_INNER, 0);
|
||||
|
||||
lv_style_init(&list_btn);
|
||||
lv_style_set_opa(&list_btn, LV_STYLE_BG_OPA| LV_STYLE_STATE_PRESSED, LV_OPA_20);
|
||||
lv_style_set_color(&list_btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_PRESSED, LV_COLOR_WHITE);
|
||||
lv_style_set_color(&list_btn, LV_STYLE_BG_COLOR | LV_STYLE_STATE_DISABLED, COLOR_DISABLED);
|
||||
lv_style_set_color(&list_btn, LV_STYLE_TEXT_COLOR, lv_color_hex(0xffffff));
|
||||
lv_style_set_color(&list_btn, LV_STYLE_TEXT_COLOR| LV_STYLE_STATE_PRESSED, lv_color_darken(lv_color_hex(0xffffff), LV_OPA_20));
|
||||
lv_style_set_color(&list_btn, LV_STYLE_TEXT_COLOR| LV_STYLE_STATE_DISABLED, lv_color_hex(0x686b70));
|
||||
lv_style_set_color(&list_btn, LV_STYLE_TEXT_COLOR| LV_STYLE_STATE_FOCUS, lv_color_hex(0xff0000));
|
||||
lv_style_set_color(&list_btn, LV_STYLE_IMAGE_RECOLOR, LV_COLOR_WHITE);
|
||||
lv_style_set_color(&list_btn, LV_STYLE_IMAGE_RECOLOR| LV_STYLE_STATE_PRESSED, lv_color_darken(lv_color_hex(0xffffff), LV_OPA_20));
|
||||
lv_style_set_opa(&list_btn, LV_STYLE_BORDER_OPA, LV_OPA_COVER);
|
||||
lv_style_set_int(&list_btn, LV_STYLE_BORDER_WIDTH, 1);
|
||||
lv_style_set_int(&list_btn, LV_STYLE_BORDER_SIDE, LV_BORDER_SIDE_BOTTOM);
|
||||
lv_style_set_color(&list_btn, LV_STYLE_BORDER_COLOR, lv_color_hex(0x979a9f));
|
||||
|
||||
lv_style_set_int(&list_btn, LV_STYLE_PAD_LEFT, LV_DPI / 10);
|
||||
lv_style_set_int(&list_btn, LV_STYLE_PAD_RIGHT, LV_DPI / 10);
|
||||
lv_style_set_int(&list_btn, LV_STYLE_PAD_TOP, LV_DPI / 10);
|
||||
lv_style_set_int(&list_btn, LV_STYLE_PAD_BOTTOM, LV_DPI / 10);
|
||||
lv_style_set_int(&list_btn, LV_STYLE_PAD_INNER, LV_DPI / 10);
|
||||
lv_style_set_int(&list_btn, LV_STYLE_TRANSITION_TIME, 500);
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -721,6 +761,18 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_ARC
|
||||
case LV_THEME_ARC:
|
||||
list = lv_obj_get_style_list(obj, LV_ARC_PART_BG);
|
||||
lv_style_list_reset(list);
|
||||
lv_style_list_add_style(list, &arc_bg);
|
||||
|
||||
list = lv_obj_get_style_list(obj, LV_ARC_PART_ARC);
|
||||
lv_style_list_reset(list);
|
||||
lv_style_list_add_style(list, &arc);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_SLIDER
|
||||
case LV_THEME_SLIDER:
|
||||
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG);
|
||||
@@ -805,6 +857,27 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_DDLIST
|
||||
case LV_THEME_LIST:
|
||||
list = lv_obj_get_style_list(obj, LV_LIST_PART_BG);
|
||||
lv_style_list_reset(list);
|
||||
lv_style_list_add_style(list, &list_bg);
|
||||
|
||||
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCRL);
|
||||
lv_style_list_reset(list);
|
||||
|
||||
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCRLBAR);
|
||||
lv_style_list_reset(list);
|
||||
lv_style_list_add_style(list, &sb);
|
||||
break;
|
||||
|
||||
case LV_THEME_LIST_BTN:
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
lv_style_list_reset(list);
|
||||
lv_style_list_add_style(list, &list_btn);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_DDLIST
|
||||
case LV_THEME_DDLIST:
|
||||
list = lv_obj_get_style_list(obj, LV_DDLIST_PART_BTN);
|
||||
@@ -889,7 +962,7 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
lv_style_list_reset(list);
|
||||
lv_style_list_add_style(list, &panel);
|
||||
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE_NUMS);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE);
|
||||
lv_style_list_reset(list);
|
||||
lv_style_list_add_style(list, &calendar_date_nums);
|
||||
|
||||
@@ -927,12 +1000,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_ARC
|
||||
case LV_THEME_ARC:
|
||||
return &arc;
|
||||
case LV_THEME_ARC_BG:
|
||||
return &arc_bg;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LED
|
||||
case LV_THEME_LED:
|
||||
|
||||
Reference in New Issue
Block a user