feat(style) add transform_x/y

This commit is contained in:
Gabor Kiss-Vamosi
2021-04-17 17:33:57 +02:00
parent a9d0de5998
commit e1355dbeee
20 changed files with 179 additions and 187 deletions
-1
View File
@@ -16,7 +16,6 @@ props = [
{'name': 'COLOR_FILTER_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'ANIM_TIME', 'style_type': 'num', 'var_type': 'uint32_t' },
{'name': 'TRANSITION', 'style_type': 'ptr', 'var_type': 'const lv_style_transition_dsc_t *' },
{'name': 'SIZE', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'BLEND_MODE', 'style_type': 'num', 'var_type': 'lv_blend_mode_t' },
{'name': 'PAD_TOP', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'PAD_BOTTOM', 'style_type': 'num', 'var_type': 'lv_coord_t' },
+15 -22
View File
@@ -649,14 +649,9 @@ 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 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_coord_t zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
lv_area_t coords;
lv_area_copy(&coords, &obj->coords);
coords.x1 -= w;
coords.x2 += w;
coords.y1 -= h;
coords.y2 += h;
lv_area_zoom(zoom, &obj->coords, &coords);
if(_lv_area_is_in(info->area, &coords, r) == false) {
info->res = LV_DRAW_RES_NOT_COVER;
@@ -693,14 +688,9 @@ static void lv_obj_draw(lv_event_t * e)
lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &draw_dsc);
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_coord_t zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
lv_area_t coords;
lv_area_copy(&coords, &obj->coords);
coords.x1 -= w;
coords.x2 += w;
coords.y1 -= h;
coords.y2 += h;
lv_area_zoom(zoom, &obj->coords, &coords);
lv_draw_rect(&coords, clip_area, &draw_dsc);
@@ -734,14 +724,10 @@ 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 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_coord_t zoom = lv_obj_get_style_transform_zoom(obj, LV_PART_MAIN);
lv_area_t coords;
lv_area_copy(&coords, &obj->coords);
coords.x1 -= w;
coords.x2 += w;
coords.y1 -= h;
coords.y2 += h;
lv_area_zoom(zoom, &obj->coords, &coords);
lv_draw_rect(&coords, clip_area, &draw_dsc);
}
}
@@ -920,6 +906,14 @@ 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*/
@@ -1140,7 +1134,6 @@ 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:
-5
View File
@@ -315,11 +315,6 @@ 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;
}
+3
View File
@@ -125,6 +125,9 @@ void lv_obj_refr_size(lv_obj_t * obj)
if(pct_w) w = (LV_COORD_GET_PCT(w) * parent_w) / 100;
if(pct_h) h = (LV_COORD_GET_PCT(h) * parent_h) / 100;
w += lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
h += lv_obj_get_style_transform_height(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);
+38 -37
View File
@@ -420,7 +420,7 @@ void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t *
lv_coord_t end_space = lv_obj_get_style_pad_top(obj, LV_PART_SCROLLBAR);
lv_coord_t side_space = lv_obj_get_style_pad_right(obj, LV_PART_SCROLLBAR);
lv_coord_t tickness = lv_obj_get_style_size(obj, LV_PART_SCROLLBAR);
lv_coord_t tickness = lv_obj_get_style_width(obj, LV_PART_SCROLLBAR);
lv_coord_t obj_h = lv_obj_get_height(obj);
lv_coord_t obj_w = lv_obj_get_width(obj);
@@ -439,35 +439,35 @@ void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t *
/*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) {
hor_area->y1 = obj->coords.y1;
hor_area->y2 = obj->coords.y2;
hor_area->x2 = obj->coords.x2 - side_space;
hor_area->x1 = hor_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) {
hor_area->y1 = obj->coords.y1 + end_space;
hor_area->y2 = obj->coords.y2 - end_space - hor_req_space - 1;
hor_area->x2 = obj->coords.x2 - side_space;
hor_area->x1 = hor_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;
hor_area->y1 = obj->coords.y1 + sb_y + end_space;
hor_area->y2 = hor_area->y1 + sb_h - 1;
hor_area->x2 = obj->coords.x2 - side_space;
hor_area->x1 = hor_area->x2 - tickness;
if(hor_area->y1 < obj->coords.y1 + end_space) {
hor_area->y1 = obj->coords.y1 + end_space;
if(hor_area->y1 + SCROLLBAR_MIN_SIZE > hor_area->y2) hor_area->y2 = hor_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(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;
}
if(hor_area->y2 > obj->coords.y2 - hor_req_space - end_space) {
hor_area->y2 = obj->coords.y2 - hor_req_space - end_space;
if(hor_area->y2 - SCROLLBAR_MIN_SIZE < hor_area->y1) hor_area->y1 = hor_area->y2 - 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;
}
}
}
@@ -475,35 +475,35 @@ void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t *
/*Draw horizontal scrollbar if the mode is ON or can be scrolled in this direction*/
lv_coord_t content_w = obj_w + sl + sr;
if(hor_draw && content_w) {
ver_area->y2 = obj->coords.y2 - side_space;
ver_area->y1 = ver_area->y2 - tickness;
ver_area->x1 = obj->coords.x1;
ver_area->x2 = obj->coords.x2;
hor_area->y2 = obj->coords.y2 - side_space;
hor_area->y1 = hor_area->y2 - tickness;
hor_area->x1 = obj->coords.x1;
hor_area->x2 = obj->coords.x2;
lv_coord_t sb_w = ((obj_w - end_space * 2 - ver_reg_space) * obj_w) / content_w;
sb_w = LV_MAX(sb_w, SCROLLBAR_MIN_SIZE);
rem = (obj_w - end_space * 2 - ver_reg_space) - sb_w; /*Remaining size from the scrollbar track that is not the scrollbar itself*/
lv_coord_t scroll_w = content_w - obj_w; /*The size of the content which can be really scrolled*/
if(scroll_w <= 0) {
ver_area->y2 = obj->coords.y2 - side_space;
ver_area->y1 = ver_area->y2 - tickness + 1;
ver_area->x1 = obj->coords.x1 + end_space;
ver_area->x2 = obj->coords.x2 - end_space - ver_reg_space - 1;
hor_area->y2 = obj->coords.y2 - side_space;
hor_area->y1 = hor_area->y2 - tickness + 1;
hor_area->x1 = obj->coords.x1 + end_space;
hor_area->x2 = obj->coords.x2 - end_space - ver_reg_space - 1;
} else {
lv_coord_t sb_x = (rem * sr) / scroll_w;
sb_x = rem - sb_x;
ver_area->x1 = obj->coords.x1 + sb_x + end_space;
ver_area->x2 = ver_area->x1 + sb_w - 1;
ver_area->y2 = obj->coords.y2 - side_space;
ver_area->y1 = ver_area->y2 - tickness;
if(ver_area->x1 < obj->coords.x1 + end_space) {
ver_area->x1 = obj->coords.x1 + end_space;
if(ver_area->x1 + SCROLLBAR_MIN_SIZE > ver_area->x2) ver_area->x2 = ver_area->x1 + SCROLLBAR_MIN_SIZE;
hor_area->x1 = obj->coords.x1 + sb_x + end_space;
hor_area->x2 = hor_area->x1 + sb_w - 1;
hor_area->y2 = obj->coords.y2 - side_space;
hor_area->y1 = hor_area->y2 - tickness;
if(hor_area->x1 < obj->coords.x1 + end_space) {
hor_area->x1 = obj->coords.x1 + end_space;
if(hor_area->x1 + SCROLLBAR_MIN_SIZE > hor_area->x2) hor_area->x2 = hor_area->x1 + SCROLLBAR_MIN_SIZE;
}
if(ver_area->x2 > obj->coords.x2 - ver_reg_space - end_space) {
ver_area->x2 = obj->coords.x2 - ver_reg_space - end_space;
if(ver_area->x2 - SCROLLBAR_MIN_SIZE < ver_area->x1) ver_area->x1 = ver_area->x2 - SCROLLBAR_MIN_SIZE;
if(hor_area->x2 > obj->coords.x2 - ver_reg_space - end_space) {
hor_area->x2 = obj->coords.x2 - ver_reg_space - end_space;
if(hor_area->x2 - SCROLLBAR_MIN_SIZE < hor_area->x1) hor_area->x1 = hor_area->x2 - SCROLLBAR_MIN_SIZE;
}
}
}
@@ -517,6 +517,7 @@ void lv_obj_scrollbar_invalidate(lv_obj_t * obj)
if(lv_area_get_size(&hor_area) <= 0 && lv_area_get_size(&ver_area) <= 0) return;
printf("h: %d\n", hor_area.x2);
if(lv_area_get_size(&hor_area) > 0) lv_obj_invalidate_area(obj, &hor_area);
if(lv_area_get_size(&ver_area) > 0) lv_obj_invalidate_area(obj, &ver_area);
}
+2 -3
View File
@@ -173,8 +173,7 @@ 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*/
if(obj->parent) obj->parent->layout_inv = 1;
lv_event_send(obj, LV_EVENT_STYLE_CHANGED, NULL); /*To update layout and sizes*/
}
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);
@@ -224,7 +223,7 @@ lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, lv_part_t part, lv_
}
if(!found) {
if(prop == LV_STYLE_WIDTH || prop == LV_STYLE_HEIGHT) {
if(part == LV_PART_MAIN && (prop == LV_STYLE_WIDTH || prop == LV_STYLE_HEIGHT)) {
const lv_obj_class_t * cls = obj->class_p;
while(cls) {
if(prop == LV_STYLE_WIDTH) {
+5
View File
@@ -208,6 +208,11 @@ static inline void lv_obj_set_style_pad_gap(struct _lv_obj_t * obj, lv_coord_t
lv_obj_set_style_pad_column(obj, value, selector);
}
static inline void lv_obj_set_style_size(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) {
lv_obj_set_style_width(obj, value, selector);
lv_obj_set_style_height(obj, value, selector);
}
/**********************
* MACROS
**********************/
-14
View File
@@ -76,12 +76,6 @@ static inline const lv_style_transition_dsc_t * lv_obj_get_style_transition(cons
return (const lv_style_transition_dsc_t *)v.ptr;
}
static inline lv_coord_t lv_obj_get_style_size(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SIZE);
return (lv_coord_t)v.num;
}
static inline lv_blend_mode_t lv_obj_get_style_blend_mode(const struct _lv_obj_t * obj, uint32_t part)
{
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BLEND_MODE);
@@ -630,14 +624,6 @@ static inline void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSITION, v, selector);
}
static inline void lv_obj_set_style_size(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
{
lv_style_value_t v = {
.num = (int32_t)value
};
lv_obj_set_local_style_prop(obj, LV_STYLE_SIZE, v, selector);
}
static inline void lv_obj_set_style_blend_mode(struct _lv_obj_t * obj, lv_blend_mode_t value, lv_style_selector_t selector)
{
lv_style_value_t v = {
+1 -1
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 in case refreshing invalidates something else.
* This is done before refreshing because invalidations later should restart the timer.
*/
lv_timer_pause(tmr, true);
#endif
+5 -1
View File
@@ -206,12 +206,16 @@ 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");
}
+3
View File
@@ -180,6 +180,9 @@ 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");
}
+6 -11
View File
@@ -107,7 +107,7 @@ typedef struct {
#endif
#if LV_USE_METER
lv_style_t meter_marker, meter_indic;
lv_style_t 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_size(&styles->scrollbar, LV_DPX(5));
lv_style_set_width(&styles->scrollbar, LV_DPX(5));
lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_40);
lv_style_set_transition(&styles->scrollbar, &trans_normal);
@@ -363,8 +363,8 @@ static void style_init(void)
#if LV_THEME_DEFAULT_GROW
style_init_reset(&styles->grow);
lv_style_set_transform_width(&styles->grow, LV_DPX(3));
lv_style_set_transform_height(&styles->grow, LV_DPX(3));
lv_style_set_transform_width(&styles->grow, 20);
lv_style_set_transform_height(&styles->grow, 20);
#endif
style_init_reset(&styles->knob);
@@ -435,17 +435,12 @@ 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_size(&styles->meter_indic, LV_DPX(15));
lv_style_set_width(&styles->meter_indic, LV_DPX(15));
lv_style_set_height(&styles->meter_indic, LV_DPX(15));
#endif
#if LV_USE_TABLE
+37 -15
View File
@@ -73,21 +73,6 @@ 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)
@@ -103,6 +88,43 @@ 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
+6 -8
View File
@@ -158,14 +158,6 @@ 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
@@ -173,6 +165,12 @@ void _lv_area_set_pos(lv_area_t * area_p, lv_coord_t x, lv_coord_t y);
*/
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
-3
View File
@@ -237,9 +237,6 @@ 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;
+10 -6
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_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_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_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,8 +126,7 @@ typedef enum {
LV_STYLE_COLOR_FILTER_OPA = 11,
LV_STYLE_ANIM_TIME = 12,
LV_STYLE_TRANSITION = 13,
LV_STYLE_SIZE = 14,
LV_STYLE_BLEND_MODE = 15,
LV_STYLE_BLEND_MODE = 14,
/*Group 1*/
LV_STYLE_PAD_TOP = 16 | LV_STYLE_PROP_LAYOUT_REFR,
@@ -418,6 +417,11 @@ static inline void lv_style_set_pad_gap(lv_style_t * style, lv_coord_t value) {
lv_style_set_pad_column(style, value);
}
static inline void lv_style_set_size(lv_style_t * style, lv_coord_t value) {
lv_style_set_width(style, value);
lv_style_set_height(style, value);
}
/*************************
* GLOBAL VARIABLES
-8
View File
@@ -102,14 +102,6 @@ static inline void lv_style_set_transition(lv_style_t * style, const lv_style_tr
lv_style_set_prop(style, LV_STYLE_TRANSITION, v);
}
static inline void lv_style_set_size(lv_style_t * style, lv_coord_t value)
{
lv_style_value_t v = {
.num = (int32_t)value
};
lv_style_set_prop(style, LV_STYLE_SIZE, v);
}
static inline void lv_style_set_blend_mode(lv_style_t * style, lv_blend_mode_t value)
{
lv_style_value_t v = {
+4 -13
View File
@@ -238,17 +238,8 @@ 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_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);
lv_coord_t barw = lv_obj_get_width(obj);
lv_coord_t barh = lv_obj_get_height(obj);
int32_t range = bar->max_value - bar->min_value;
bool hor = barw >= barh ? true : false;
bool sym = false;
@@ -261,7 +252,7 @@ static void draw_indic(lv_event_t * e)
lv_coord_t bg_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
lv_coord_t bg_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
/*Respect padding and minimum width/height too*/
lv_area_copy(&bar->indic_area, &bar_coords);
lv_area_copy(&bar->indic_area, &obj->coords);
bar->indic_area.x1 += bg_left;
bar->indic_area.x2 -= bg_right;
bar->indic_area.y1 += bg_top;
@@ -429,7 +420,7 @@ static void draw_indic(lv_event_t * e)
/*Get the max possible indicator area. The gradient should be applied on this*/
lv_area_t mask_indic_max_area;
lv_area_copy(&mask_indic_max_area, &bar_coords);
lv_area_copy(&mask_indic_max_area, &obj->coords);
mask_indic_max_area.x1 += bg_left;
mask_indic_max_area.y1 += bg_top;
mask_indic_max_area.x2 -= bg_right;
+38 -34
View File
@@ -739,18 +739,21 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
lv_draw_rect_dsc_init(&point_dsc_default);
point_dsc_default.radius = LV_RADIUS_CIRCLE;
lv_coord_t point_size = lv_obj_get_style_size(obj, LV_PART_ITEMS);
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;
obj->state = LV_STATE_PRESSED;
lv_coord_t point_size_pr = lv_obj_get_style_size(obj, LV_PART_ITEMS);
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_size_act;
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(point_size > line_dsc_default.width / 2) line_dsc_default.raw_end = 1;
if(LV_MIN(point_w, point_h) > line_dsc_default.width / 2) line_dsc_default.raw_end = 1;
if(line_dsc_default.width == 1) line_dsc_default.raw_end = 1;
/*If there are mire points than pixels draw only vertical lines*/
@@ -787,9 +790,10 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
p1.x = p2.x;
p1.y = p2.y;
point_size_act = p_act == chart->pressed_point_id ? point_size_pr : point_size;
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_size_act + 1) break;
if(p1.x > clip_area->x2 + point_w_act + 1) break;
p2.x = ((w * i) / (chart->point_cnt - 1)) + x_ofs;
p_act = (start_point + i) % chart->point_cnt;
@@ -798,7 +802,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_size_act - 1) {
if(p2.x < clip_area->x1 - point_w_act - 1) {
p_prev = p_act;
continue;
}
@@ -825,10 +829,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_size_act;
point_area.x2 = p1.x + point_size_act;
point_area.y1 = p1.y - point_size_act;
point_area.y2 = p1.y + point_size_act;
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;
dsc.id = i - 1;
dsc.p1 = ser->points[p_prev] != LV_CHART_POINT_NONE ? &p1 : NULL;
@@ -842,7 +846,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_size_act && ser->points[p_act] != LV_CHART_POINT_NONE) {
if(point_w_act && point_h_act && ser->points[p_act] != LV_CHART_POINT_NONE) {
lv_draw_rect(&point_area, &series_mask, &point_dsc_default);
}
@@ -854,15 +858,16 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
}
/*Draw the last point*/
point_size_act = p_act == chart->pressed_point_id ? point_size_pr : point_size;
if(!crowded_mode && point_size_act && i == chart->point_cnt) {
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(ser->points[p_act] != LV_CHART_POINT_NONE) {
lv_area_t point_area;
point_area.x1 = p2.x - point_size_act;
point_area.x2 = p2.x + point_size_act;
point_area.y1 = p2.y - point_size_act;
point_area.y2 = p2.y + point_size_act;
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;
dsc.id = i - 1;
dsc.p1 = NULL;
@@ -978,10 +983,8 @@ static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area)
lv_draw_line_dsc_t line_dsc_tmp;
lv_draw_rect_dsc_t point_dsc_tmp;
lv_coord_t point_radius = lv_obj_get_style_size(obj, LV_PART_CURSOR);
/*Do not bother with line ending is the point will over it*/
if(point_radius > line_dsc_ori.width / 2) line_dsc_ori.raw_end = 1;
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_obj_draw_dsc_t dsc;
lv_obj_draw_dsc_init(&dsc, clip_area);
@@ -1025,13 +1028,13 @@ static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area)
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
}
if(point_radius) {
if(point_w && point_h) {
lv_area_t point_area;
point_area.x1 = cx - point_radius;
point_area.x2 = cx + point_radius;
point_area.y1 = cy - point_radius;
point_area.y2 = cy + point_radius;
point_area.x1 = cx - point_w;
point_area.x2 = cx + point_w;
point_area.y1 = cy - point_h;
point_area.y2 = cy + point_h;
dsc.draw_area = &point_area;
dsc.p1 = NULL;
@@ -1281,22 +1284,23 @@ 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_radius = lv_obj_get_style_size(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_area_t coords;
lv_area_copy(&coords, &obj->coords);
coords.y1 -= line_width + point_radius;
coords.y2 += line_width + point_radius;
coords.y1 -= LV_MAX(line_width, point_h);
coords.y2 += LV_MAX(line_width, point_h);
if(i < chart->point_cnt - 1) {
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;
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);
lv_obj_invalidate_area(obj, &coords);
}
if(i > 0) {
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;
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);
lv_obj_invalidate_area(obj, &coords);
}
}
+6 -5
View File
@@ -302,12 +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 size = lv_obj_get_style_size(obj, LV_PART_INDICATOR) / 2;
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_area_t nm_cord;
nm_cord.x1 = scale_center.x - size;
nm_cord.y1 = scale_center.y - size;
nm_cord.x2 = scale_center.x + size;
nm_cord.y2 = scale_center.y + size;
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;
lv_draw_rect(&nm_cord, clip_area, &mid_dsc);
}
}