revert(style) revert the usage of transform width/height

This commit is contained in:
Gabor Kiss-Vamosi
2021-04-18 20:28:06 +02:00
parent 32bd067778
commit 6db12e4997
17 changed files with 127 additions and 152 deletions

View File

@@ -641,9 +641,14 @@ static void lv_obj_draw(lv_event_t * e)
/*Most trivial test. Is the mask fully IN the object? If no it surely doesn't cover it*/
lv_coord_t r = lv_obj_get_style_radius(obj, LV_PART_MAIN);
lv_coord_t zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
lv_coord_t h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
lv_area_t coords;
lv_area_zoom(zoom, &obj->coords, &coords);
lv_area_copy(&coords, &obj->coords);
coords.x1 -= w;
coords.x2 += w;
coords.y1 -= h;
coords.y2 += h;
if(_lv_area_is_in(info->area, &coords, r) == false) {
info->res = LV_DRAW_RES_NOT_COVER;
@@ -680,9 +685,14 @@ static void lv_obj_draw(lv_event_t * e)
lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &draw_dsc);
lv_coord_t zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
lv_coord_t h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
lv_area_t coords;
lv_area_zoom(zoom, &obj->coords, &coords);
lv_area_copy(&coords, &obj->coords);
coords.x1 -= w;
coords.x2 += w;
coords.y1 -= h;
coords.y2 += h;
lv_draw_rect(&coords, clip_area, &draw_dsc);
@@ -716,10 +726,14 @@ static void lv_obj_draw(lv_event_t * e)
draw_dsc.shadow_opa = LV_OPA_TRANSP;
lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &draw_dsc);
lv_coord_t zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
lv_coord_t h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
lv_area_t coords;
lv_area_zoom(zoom, &obj->coords, &coords);
lv_area_copy(&coords, &obj->coords);
coords.x1 -= w;
coords.x2 += w;
coords.y1 -= h;
coords.y2 += h;
lv_draw_rect(&coords, clip_area, &draw_dsc);
}
}
@@ -898,14 +912,6 @@ static void lv_obj_event_cb(lv_event_t * e)
lv_coord_t * s = lv_event_get_param(e);
lv_coord_t d = lv_obj_calculate_ext_draw_size(obj, LV_PART_MAIN);
*s = LV_MAX(*s, d);
lv_area_t zoomed_coords;
lv_area_zoom(lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN), &obj->coords, &zoomed_coords);
*s = LV_MAX(*s, obj->coords.x1 - zoomed_coords.x1);
*s = LV_MAX(*s, obj->coords.y1 - zoomed_coords.y1);
*s = LV_MAX(*s, zoomed_coords.x2 - obj->coords.x2);
*s = LV_MAX(*s, zoomed_coords.x2 - obj->coords.x2);
}
else if(code == LV_EVENT_STYLE_CHANGED) {
/*Padding might have changed so the layout should be recalculated*/
@@ -1129,6 +1135,7 @@ static bool event_is_bubbled(lv_event_code_t e)
case LV_EVENT_DELETE:
case LV_EVENT_CHILD_CHANGED:
case LV_EVENT_SIZE_CHANGED:
case LV_EVENT_STYLE_CHANGED:
case LV_EVENT_GET_SELF_SIZE:
return false;
default:

View File

@@ -315,6 +315,11 @@ lv_coord_t lv_obj_calculate_ext_draw_size(lv_obj_t * obj, uint32_t part)
}
}
lv_coord_t w = lv_obj_get_style_transform_width(obj, part);
lv_coord_t h = lv_obj_get_style_transform_height(obj, part);
lv_coord_t wh = LV_MAX(w, h);
if(wh > 0) s += wh;
return s;
}

View File

@@ -116,8 +116,6 @@ void lv_obj_refr_size(lv_obj_t * obj)
lv_coord_t parent_w = lv_obj_get_width_fit(parent);
if(pct_w) w = (LV_COORD_GET_PCT(w) * parent_w) / 100;
w += lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
lv_coord_t minw = lv_obj_get_style_min_width(obj, LV_PART_MAIN);
lv_coord_t maxw = lv_obj_get_style_max_width(obj, LV_PART_MAIN);
w = lv_clamp_width(w, minw, maxw, parent_w);
@@ -143,8 +141,6 @@ void lv_obj_refr_size(lv_obj_t * obj)
lv_coord_t parent_h = lv_obj_get_height_fit(parent);
if(pct_h) h = (LV_COORD_GET_PCT(h) * parent_h) / 100;
h += lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
lv_coord_t minh = lv_obj_get_style_min_height(obj, LV_PART_MAIN);
lv_coord_t maxh = lv_obj_get_style_max_height(obj, LV_PART_MAIN);
h = lv_clamp_width(h, minh, maxh, parent_h);

View File

@@ -425,45 +425,43 @@ void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t *
lv_coord_t hor_req_space = hor_draw ? tickness + side_space : 0;
lv_coord_t rem;
if(lv_obj_get_style_bg_opa(obj, LV_PART_SCROLLBAR) < LV_OPA_MIN &&
lv_obj_get_style_border_opa(obj, LV_PART_SCROLLBAR) < LV_OPA_MIN) {
return;
}
/*Draw horizontal scrollbar if the mode is ON or can be scrolled in this direction*/
lv_coord_t content_h = obj_h + st + sb;
if(ver_draw && content_h) {
ver_area->y1 = obj->coords.y1;
ver_area->y2 = obj->coords.y2;
ver_area->x2 = obj->coords.x2 - side_space;
ver_area->x1 = ver_area->x2 - tickness;
ver_area->y1 = obj->coords.y1;
ver_area->y2 = obj->coords.y2;
ver_area->x2 = obj->coords.x2 - side_space;
ver_area->x1 =ver_area->x2 - tickness;
lv_coord_t sb_h = ((obj_h - end_space * 2 - hor_req_space) * obj_h) / content_h;
sb_h = LV_MAX(sb_h, SCROLLBAR_MIN_SIZE);
rem = (obj_h - end_space * 2 - hor_req_space) - sb_h; /*Remaining size from the scrollbar track that is not the scrollbar itself*/
lv_coord_t scroll_h = content_h - obj_h; /*The size of the content which can be really scrolled*/
if(scroll_h <= 0) {
ver_area->y1 = obj->coords.y1 + end_space;
ver_area->y2 = obj->coords.y2 - end_space - hor_req_space - 1;
ver_area->x2 = obj->coords.x2 - side_space;
ver_area->x1 = ver_area->x2 - tickness + 1;
ver_area->y1 = obj->coords.y1 + end_space;
ver_area->y2 = obj->coords.y2 - end_space - hor_req_space - 1;
ver_area->x2 = obj->coords.x2 - side_space;
ver_area->x1 =ver_area->x2 - tickness + 1;
} else {
lv_coord_t sb_y = (rem * sb) / scroll_h;
sb_y = rem - sb_y;
ver_area->y1 = obj->coords.y1 + sb_y + end_space;
ver_area->y2 = ver_area->y1 + sb_h - 1;
ver_area->x2 = obj->coords.x2 - side_space;
ver_area->x1 = ver_area->x2 - tickness;
if(ver_area->y1 < obj->coords.y1 + end_space) {
ver_area->y1 = obj->coords.y1 + end_space;
if(ver_area->y1 + SCROLLBAR_MIN_SIZE > ver_area->y2) ver_area->y2 = ver_area->y1 + SCROLLBAR_MIN_SIZE;
ver_area->y1 = obj->coords.y1 + sb_y + end_space;
ver_area->y2 =ver_area->y1 + sb_h - 1;
ver_area->x2 = obj->coords.x2 - side_space;
ver_area->x1 =ver_area->x2 - tickness;
if(hor_area->y1 < obj->coords.y1 + end_space) {
ver_area->y1 = obj->coords.y1 + end_space;
if(hor_area->y1 + SCROLLBAR_MIN_SIZE >ver_area->y2)ver_area->y2 =ver_area->y1 + SCROLLBAR_MIN_SIZE;
}
if(ver_area->y2 > obj->coords.y2 - hor_req_space - end_space) {
ver_area->y2 = obj->coords.y2 - hor_req_space - end_space;
if(ver_area->y2 - SCROLLBAR_MIN_SIZE < ver_area->y1) ver_area->y1 = ver_area->y2 - SCROLLBAR_MIN_SIZE;
if(hor_area->y2 > obj->coords.y2 - hor_req_space - end_space) {
ver_area->y2 = obj->coords.y2 - hor_req_space - end_space;
if(hor_area->y2 - SCROLLBAR_MIN_SIZE <ver_area->y1)ver_area->y1 =ver_area->y2 - SCROLLBAR_MIN_SIZE;
}
}
}

View File

@@ -173,7 +173,8 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_selector_t selector, lv_style
lv_part_t part = lv_obj_style_get_selector_part(selector);
if((part == LV_PART_ANY || part == LV_PART_MAIN) && (prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_PROP_LAYOUT_REFR))) {
lv_event_send(obj, LV_EVENT_STYLE_CHANGED, NULL); /*To update layout and sizes*/
lv_event_send(obj, LV_EVENT_STYLE_CHANGED, NULL); /*To update layout*/
if(obj->parent) obj->parent->layout_inv = 1;
}
if((part == LV_PART_ANY || part == LV_PART_MAIN) && (prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_PROP_PARENT_LAYOUT_REFR))) {
lv_obj_t * parent = lv_obj_get_parent(obj);
@@ -223,7 +224,7 @@ lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, lv_part_t part, lv_
}
if(!found) {
if(part == LV_PART_MAIN && (prop == LV_STYLE_WIDTH || prop == LV_STYLE_HEIGHT)) {
if(prop == LV_STYLE_WIDTH || prop == LV_STYLE_HEIGHT) {
const lv_obj_class_t * cls = obj->class_p;
while(cls) {
if(prop == LV_STYLE_WIDTH) {

View File

@@ -191,7 +191,7 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
#if LV_USE_PERF_MONITOR == 0
/**
* Ensure the timer does not run again automatically.
* This is done before refreshing because invalidations later should restart the timer.
* This is done before refreshing in case refreshing invalidates something else.
*/
lv_timer_pause(tmr, true);
#endif

View File

@@ -206,16 +206,12 @@ static void flex_update(lv_obj_t * cont)
*cross_pos += t.track_cross_size + gap + track_gap;
}
}
LV_ASSERT_MEM_INTEGRITY();
if(w_set == LV_SIZE_CONTENT || h_set == LV_SIZE_CONTENT) {
lv_obj_refr_size(cont);
}
/*To update e.g. scrollbars */
lv_obj_invalidate(cont);
LV_ASSERT_MEM_INTEGRITY();
LV_TRACE_LAYOUT("finished");
}

View File

@@ -180,9 +180,6 @@ static void grid_update(lv_obj_t * cont)
lv_obj_refr_size(cont);
}
/*To update e.g. scrollbars */
lv_obj_invalidate(cont);
LV_TRACE_LAYOUT("finished");
}

View File

@@ -107,7 +107,7 @@ typedef struct {
#endif
#if LV_USE_METER
lv_style_t meter_indic;
lv_style_t meter_marker, meter_indic;
#endif
#if LV_USE_TEXTAREA
@@ -225,7 +225,7 @@ static void style_init(void)
lv_style_set_radius(&styles->scrollbar, LV_RADIUS_CIRCLE);
lv_style_set_pad_right(&styles->scrollbar, LV_DPX(7));
lv_style_set_pad_top(&styles->scrollbar, LV_DPX(7));
lv_style_set_width(&styles->scrollbar, LV_DPX(5));
lv_style_set_size(&styles->scrollbar, LV_DPX(5));
lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_40);
lv_style_set_transition(&styles->scrollbar, &trans_normal);
@@ -363,7 +363,8 @@ static void style_init(void)
#if LV_THEME_DEFAULT_GROW
style_init_reset(&styles->grow);
lv_style_set_transform_zoom(&styles->grow, 400);
lv_style_set_transform_width(&styles->grow, LV_DPX(3));
lv_style_set_transform_height(&styles->grow, LV_DPX(3));
#endif
style_init_reset(&styles->knob);
@@ -434,12 +435,17 @@ static void style_init(void)
#endif
#if LV_USE_METER
style_init_reset(&styles->meter_marker);
lv_style_set_line_width(&styles->meter_marker, LV_DPX(5));
lv_style_set_line_color(&styles->meter_marker, lv_color_grey_darken_4());
lv_style_set_size(&styles->meter_marker, LV_DPX(20));
lv_style_set_pad_left(&styles->meter_marker, LV_DPX(15));
style_init_reset(&styles->meter_indic);
lv_style_set_radius(&styles->meter_indic, LV_RADIUS_CIRCLE);
lv_style_set_bg_color(&styles->meter_indic, lv_color_grey_darken_4());
lv_style_set_bg_opa(&styles->meter_indic, LV_OPA_COVER);
lv_style_set_width(&styles->meter_indic, LV_DPX(15));
lv_style_set_height(&styles->meter_indic, LV_DPX(15));
lv_style_set_size(&styles->meter_indic, LV_DPX(15));
#endif
#if LV_USE_TABLE

View File

@@ -73,6 +73,21 @@ void lv_area_set_height(lv_area_t * area_p, lv_coord_t h)
area_p->y2 = area_p->y1 + h - 1;
}
/**
* Set the position of an area (width and height will be kept)
* @param area_p pointer to an area
* @param x the new x coordinate of the area
* @param y the new y coordinate of the area
*/
void _lv_area_set_pos(lv_area_t * area_p, lv_coord_t x, lv_coord_t y)
{
lv_coord_t w = lv_area_get_width(area_p);
lv_coord_t h = lv_area_get_height(area_p);
area_p->x1 = x;
area_p->y1 = y;
lv_area_set_width(area_p, w);
lv_area_set_height(area_p, h);
}
/**
* Return with area of an area (x * y)
@@ -88,43 +103,6 @@ uint32_t lv_area_get_size(const lv_area_t * area_p)
return size;
}
void lv_area_zoom(int32_t zoom, const lv_area_t * area_in, lv_area_t * area_out)
{
if(zoom == 256) {
lv_area_copy(area_out, area_in);
return;
} else {
/* Zoom symmetrically
* extra_width_on_left = (((w * zoom) >> 8) - w) / 2
* extra_width_on_left = (w * (zoom >> 8) - 1) / 2
* extra_width_on_left = (w * (zoom - 256) >> 8) / 2 */
lv_coord_t w = lv_area_get_width(area_in);
lv_coord_t h = lv_area_get_height(area_in);
lv_coord_t w_extra = (w * (zoom - 256) >> 8) / 2;
lv_coord_t h_extra = (h * (zoom - 256) >> 8) / 2;
lv_area_copy(area_out, area_in);
lv_area_increase(area_out, w_extra, h_extra);
}
}
void lv_area_increase(lv_area_t * area, lv_coord_t w_extra, lv_coord_t h_extra)
{
area->x1 -= w_extra;
area->x2 += w_extra;
area->y1 -= h_extra;
area->y2 += h_extra;
}
void lv_area_move(lv_area_t * area, lv_coord_t x_ofs, lv_coord_t y_ofs)
{
area->x1 += x_ofs;
area->x2 += x_ofs;
area->y1 += y_ofs;
area->y2 += y_ofs;
}
/**
* Get the common parts of two areas
* @param res_p pointer to an area, the result will be stored here

View File

@@ -158,6 +158,14 @@ void lv_area_set_width(lv_area_t * area_p, lv_coord_t w);
*/
void lv_area_set_height(lv_area_t * area_p, lv_coord_t h);
/**
* Set the position of an area (width and height will be kept)
* @param area_p pointer to an area
* @param x the new x coordinate of the area
* @param y the new y coordinate of the area
*/
void _lv_area_set_pos(lv_area_t * area_p, lv_coord_t x, lv_coord_t y);
/**
* Return with area of an area (x * y)
* @param area_p pointer to an area
@@ -165,12 +173,6 @@ void lv_area_set_height(lv_area_t * area_p, lv_coord_t h);
*/
uint32_t lv_area_get_size(const lv_area_t * area_p);
void lv_area_zoom(int32_t zoom, const lv_area_t * area_in, lv_area_t * area_out);
void lv_area_increase(lv_area_t * area, lv_coord_t w_extra, lv_coord_t h_extra);
void lv_area_move(lv_area_t * area, lv_coord_t x_ofs, lv_coord_t y_ofs);
/**
* Get the common parts of two areas
* @param res_p pointer to an area, the result will be stored her

View File

@@ -237,6 +237,9 @@ lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop)
case LV_STYLE_TEXT_FONT:
value.ptr = LV_FONT_DEFAULT;
break;
case LV_STYLE_SIZE:
value.num = 5;
break;
case LV_STYLE_MAX_WIDTH:
case LV_STYLE_MAX_HEIGHT:
value.num = LV_COORD_MAX;

View File

@@ -114,10 +114,10 @@ typedef enum {
/*Group 0*/
LV_STYLE_RADIUS = 1,
LV_STYLE_CLIP_CORNER = 2,
LV_STYLE_TRANSFORM_WIDTH = 3 | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_TRANSFORM_HEIGHT = 4 | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_TRANSFORM_X = 5 | LV_STYLE_PROP_LAYOUT_REFR | LV_STYLE_PROP_PARENT_LAYOUT_REFR,
LV_STYLE_TRANSFORM_Y = 6 | LV_STYLE_PROP_LAYOUT_REFR | LV_STYLE_PROP_PARENT_LAYOUT_REFR,
LV_STYLE_TRANSFORM_WIDTH = 3 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_TRANSFORM_HEIGHT = 4 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_TRANSFORM_X = 5 | LV_STYLE_PROP_PARENT_LAYOUT_REFR,
LV_STYLE_TRANSFORM_Y = 6 | LV_STYLE_PROP_PARENT_LAYOUT_REFR,
LV_STYLE_TRANSFORM_ZOOM = 7 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_TRANSFORM_ANGLE = 8 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_OPA = 9 | LV_STYLE_PROP_INHERIT,
@@ -126,7 +126,8 @@ typedef enum {
LV_STYLE_COLOR_FILTER_OPA = 11,
LV_STYLE_ANIM_TIME = 12,
LV_STYLE_TRANSITION = 13,
LV_STYLE_BLEND_MODE = 14,
LV_STYLE_SIZE = 14,
LV_STYLE_BLEND_MODE = 15,
/*Group 1*/
LV_STYLE_PAD_TOP = 16 | LV_STYLE_PROP_LAYOUT_REFR,

View File

@@ -239,9 +239,14 @@ static void draw_indic(lv_event_t * e)
const lv_area_t * clip_area = lv_event_get_param(e);
lv_area_t bar_coords;
lv_area_zoom(lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN), &obj->coords, &bar_coords);
lv_obj_get_coords(obj, &bar_coords);
lv_coord_t transf_w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
lv_coord_t transf_h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
bar_coords.x1 -= transf_w;
bar_coords.x2 += transf_w;
bar_coords.y1 -= transf_h;
bar_coords.y2 += transf_h;
lv_coord_t barw = lv_area_get_width(&bar_coords);
lv_coord_t barh = lv_area_get_height(&bar_coords);
int32_t range = bar->max_value - bar->min_value;

View File

@@ -728,29 +728,18 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
bool mask_ret = _lv_area_intersect(&series_mask, &obj->coords, clip_area);
if(mask_ret == false) return;
lv_state_t state_ori = obj->state;
obj->state = LV_STATE_DEFAULT;
obj->skip_trans = 1;
lv_draw_line_dsc_t line_dsc_default;
lv_draw_line_dsc_init(&line_dsc_default);
lv_obj_init_draw_line_dsc(obj, LV_PART_ITEMS, &line_dsc_default);
lv_draw_rect_dsc_t point_dsc_default;
lv_draw_rect_dsc_init(&point_dsc_default);
point_dsc_default.radius = LV_RADIUS_CIRCLE;
lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEMS, &point_dsc_default);
lv_coord_t point_w = lv_obj_get_style_width(obj, LV_PART_CURSOR) / 2;
lv_coord_t point_h = lv_obj_get_style_width(obj, LV_PART_CURSOR) / 2;
lv_coord_t point_w = lv_obj_get_style_width(obj, LV_PART_ITEMS) / 2;
lv_coord_t point_h = lv_obj_get_style_height(obj, LV_PART_ITEMS) / 2;
obj->state = LV_STATE_PRESSED;
lv_coord_t point_w_pr = lv_obj_get_style_width(obj, LV_PART_CURSOR) / 2;
lv_coord_t point_h_pr = lv_obj_get_style_width(obj, LV_PART_CURSOR) / 2;
obj->state = state_ori;
obj->skip_trans = 0;
lv_coord_t point_w_act;
lv_coord_t point_h_act;
/*Do not bother with line ending is the point will over it*/
if(LV_MIN(point_w, point_h) > line_dsc_default.width / 2) line_dsc_default.raw_end = 1;
@@ -790,10 +779,7 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
p1.x = p2.x;
p1.y = p2.y;
point_w_act = p_act == chart->pressed_point_id ? point_w_pr : point_w;
point_h_act = p_act == chart->pressed_point_id ? point_h_pr : point_h;
if(p1.x > clip_area->x2 + point_w_act + 1) break;
if(p1.x > clip_area->x2 + point_w + 1) break;
p2.x = ((w * i) / (chart->point_cnt - 1)) + x_ofs;
p_act = (start_point + i) % chart->point_cnt;
@@ -802,7 +788,7 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
y_tmp = y_tmp / (chart->ymax[ser->y_axis] - chart->ymin[ser->y_axis]);
p2.y = h - y_tmp + y_ofs;
if(p2.x < clip_area->x1 - point_w_act - 1) {
if(p2.x < clip_area->x1 - point_w - 1) {
p_prev = p_act;
continue;
}
@@ -829,10 +815,10 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
}
} else {
lv_area_t point_area;
point_area.x1 = p1.x - point_w_act;
point_area.x2 = p1.x + point_w_act;
point_area.y1 = p1.y - point_h_act;
point_area.y2 = p1.y + point_h_act;
point_area.x1 = p1.x - point_w;
point_area.x2 = p1.x + point_w;
point_area.y1 = p1.y - point_h;
point_area.y2 = p1.y + point_h;
dsc.id = i - 1;
dsc.p1 = ser->points[p_prev] != LV_CHART_POINT_NONE ? &p1 : NULL;
@@ -846,7 +832,7 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
lv_draw_line(&p1, &p2, &series_mask, &line_dsc_default);
}
if(point_w_act && point_h_act && ser->points[p_act] != LV_CHART_POINT_NONE) {
if(point_w && point_h && ser->points[p_act] != LV_CHART_POINT_NONE) {
lv_draw_rect(&point_area, &series_mask, &point_dsc_default);
}
@@ -858,16 +844,14 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
}
/*Draw the last point*/
point_w_act = p_act == chart->pressed_point_id ? point_w_pr : point_w;
point_h_act = p_act == chart->pressed_point_id ? point_h_pr : point_h;
if(!crowded_mode && point_w_act && point_h_act && i == chart->point_cnt) {
if(!crowded_mode && i == chart->point_cnt) {
if(ser->points[p_act] != LV_CHART_POINT_NONE) {
lv_area_t point_area;
point_area.x1 = p2.x - point_w_act;
point_area.x2 = p2.x + point_w_act;
point_area.y1 = p2.y - point_h_act;
point_area.y2 = p2.y + point_h_act;
point_area.x1 = p2.x - point_w;
point_area.x2 = p2.x + point_w;
point_area.y1 = p2.y - point_h;
point_area.y2 = p2.y + point_h;
dsc.id = i - 1;
dsc.p1 = NULL;
@@ -1284,23 +1268,22 @@ static void invalidate_point(lv_obj_t * obj, uint16_t i)
if(chart->type == LV_CHART_TYPE_LINE) {
lv_coord_t x_ofs = obj->coords.x1 + lv_obj_get_style_pad_left(obj, LV_PART_MAIN) - scroll_left;
lv_coord_t line_width = lv_obj_get_style_line_width(obj, LV_PART_ITEMS);
lv_coord_t point_w = lv_obj_get_style_width(obj, LV_PART_ITEMS) / 2 + 1;
lv_coord_t point_h = lv_obj_get_style_height(obj, LV_PART_ITEMS) / 2 + 1;
lv_coord_t point_radius = lv_obj_get_style_width(obj, LV_PART_ITEMS);
lv_area_t coords;
lv_area_copy(&coords, &obj->coords);
coords.y1 -= LV_MAX(line_width, point_h);
coords.y2 += LV_MAX(line_width, point_h);
coords.y1 -= line_width + point_radius;
coords.y2 += line_width + point_radius;
if(i < chart->point_cnt - 1) {
coords.x1 = ((w * i) / (chart->point_cnt - 1)) + x_ofs - LV_MAX(line_width, point_w);
coords.x2 = ((w * (i + 1)) / (chart->point_cnt - 1)) + x_ofs + LV_MAX(line_width, point_w);
coords.x1 = ((w * i) / (chart->point_cnt - 1)) + x_ofs - line_width - point_radius;
coords.x2 = ((w * (i + 1)) / (chart->point_cnt - 1)) + x_ofs + line_width + point_radius;
lv_obj_invalidate_area(obj, &coords);
}
if(i > 0) {
coords.x1 = ((w * (i - 1)) / (chart->point_cnt - 1)) + x_ofs - LV_MAX(line_width, point_w);
coords.x2 = ((w * i) / (chart->point_cnt - 1)) + x_ofs + LV_MAX(line_width, point_w);
coords.x1 = ((w * (i - 1)) / (chart->point_cnt - 1)) + x_ofs - line_width - point_radius;
coords.x2 = ((w * i) / (chart->point_cnt - 1)) + x_ofs + line_width + point_radius;
lv_obj_invalidate_area(obj, &coords);
}
}

View File

@@ -302,13 +302,13 @@ static void lv_meter_event(lv_event_t * e)
lv_draw_rect_dsc_t mid_dsc;
lv_draw_rect_dsc_init(&mid_dsc);
lv_obj_init_draw_rect_dsc(obj, LV_PART_INDICATOR, &mid_dsc);
lv_coord_t point_w = lv_obj_get_style_width(obj, LV_PART_INDICATOR) / 2;
lv_coord_t point_h = lv_obj_get_style_height(obj, LV_PART_INDICATOR) / 2;
lv_coord_t w = lv_obj_get_style_width(obj, LV_PART_INDICATOR) / 2;
lv_coord_t h = lv_obj_get_style_height(obj, LV_PART_INDICATOR) / 2;
lv_area_t nm_cord;
nm_cord.x1 = scale_center.x - point_w;
nm_cord.y1 = scale_center.y - point_w;
nm_cord.x2 = scale_center.x + point_h;
nm_cord.y2 = scale_center.y + point_h;
nm_cord.x1 = scale_center.x - w;
nm_cord.y1 = scale_center.y - h;
nm_cord.x2 = scale_center.x + w;
nm_cord.y2 = scale_center.y + h;
lv_draw_rect(&nm_cord, clip_area, &mid_dsc);
}
}

View File

@@ -420,9 +420,6 @@ static void position_knob(lv_obj_t * obj, lv_area_t * knob_area, lv_coord_t knob
knob_area->x2 = obj->coords.x2;
}
lv_coord_t zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_KNOB);
lv_area_zoom(zoom, knob_area, knob_area);
lv_coord_t knob_left = lv_obj_get_style_pad_left(obj, LV_PART_KNOB);
lv_coord_t knob_right = lv_obj_get_style_pad_right(obj, LV_PART_KNOB);
lv_coord_t knob_top = lv_obj_get_style_pad_top(obj, LV_PART_KNOB);