From e4676860026afe79180021c4f3af121bdbd5e5ea Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sat, 20 Feb 2021 01:51:03 -0500 Subject: [PATCH] fix(v8) handle most compiler warnings (#2086) --- examples/widgets/bar/lv_example_bar_6.c | 7 +- examples/widgets/meter/lv_example_meter_1.c | 2 +- examples/widgets/meter/lv_example_meter_2.c | 2 +- examples/widgets/meter/lv_example_meter_3.c | 2 +- scripts/style_api_gen.py | 13 +- src/lv_core/lv_obj_style.h | 22 ++++ src/lv_core/lv_obj_style_gen.h | 139 ++++++++------------ src/lv_draw/lv_draw_mask.c | 4 + src/lv_misc/lv_style.c | 38 +++--- src/lv_misc/lv_style.h | 33 ++++- src/lv_misc/lv_style_gen.h | 138 ++++++++----------- src/lv_widgets/lv_meter.c | 60 ++++----- src/lv_widgets/lv_meter.h | 2 +- src/lv_widgets/lv_textarea.c | 8 +- 14 files changed, 241 insertions(+), 229 deletions(-) diff --git a/examples/widgets/bar/lv_example_bar_6.c b/examples/widgets/bar/lv_example_bar_6.c index f9695d810..7e19945e1 100644 --- a/examples/widgets/bar/lv_example_bar_6.c +++ b/examples/widgets/bar/lv_example_bar_6.c @@ -1,6 +1,11 @@ #include "../../../lvgl.h" #if LV_USE_BAR && LV_BUILD_EXAMPLES +static void set_value(lv_obj_t *bar, lv_anim_value_t v) +{ + lv_bar_set_value(bar, v, LV_ANIM_OFF); +} + static void event_cb(lv_obj_t * obj, lv_event_t e) { if(e == LV_EVENT_DRAW_POST_END) { @@ -57,7 +62,7 @@ void lv_example_bar_6(void) lv_anim_init(&a); lv_anim_set_var(&a, bar); lv_anim_set_values(&a, 0, 100); - lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t) lv_bar_set_value); + lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t) set_value); lv_anim_set_time(&a, 2000); lv_anim_set_playback_time(&a, 2000); lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE); diff --git a/examples/widgets/meter/lv_example_meter_1.c b/examples/widgets/meter/lv_example_meter_1.c index 814c9e218..934a9032d 100644 --- a/examples/widgets/meter/lv_example_meter_1.c +++ b/examples/widgets/meter/lv_example_meter_1.c @@ -3,7 +3,7 @@ static lv_obj_t * meter; -static void set_value(lv_meter_indicator_t * indic, int32_t v) +static void set_value(lv_meter_indicator_t * indic, lv_anim_value_t v) { lv_meter_set_indicator_value(meter, indic, v); } diff --git a/examples/widgets/meter/lv_example_meter_2.c b/examples/widgets/meter/lv_example_meter_2.c index 8707d377a..9b9df06bf 100644 --- a/examples/widgets/meter/lv_example_meter_2.c +++ b/examples/widgets/meter/lv_example_meter_2.c @@ -3,7 +3,7 @@ static lv_obj_t * meter; -static void set_value(lv_meter_indicator_t * indic, int32_t v) +static void set_value(lv_meter_indicator_t * indic, lv_anim_value_t v) { lv_meter_set_indicator_end_value(meter, indic, v); } diff --git a/examples/widgets/meter/lv_example_meter_3.c b/examples/widgets/meter/lv_example_meter_3.c index 8b7fab20b..5c56f7550 100644 --- a/examples/widgets/meter/lv_example_meter_3.c +++ b/examples/widgets/meter/lv_example_meter_3.c @@ -3,7 +3,7 @@ static lv_obj_t * meter; -static void set_value(lv_meter_indicator_t * indic, int32_t v) +static void set_value(lv_meter_indicator_t * indic, lv_anim_value_t v) { lv_meter_set_indicator_end_value(meter, indic, v); } diff --git a/scripts/style_api_gen.py b/scripts/style_api_gen.py index 9a815b1e1..856f57eb9 100755 --- a/scripts/style_api_gen.py +++ b/scripts/style_api_gen.py @@ -99,16 +99,23 @@ def obj_style_get(i): print(" lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_" + props[i]['name'] + "); return " + cast + " v." + props[i]['style_type'] + "; }") print("") - +def get_func_cast(style): + func_cast = "" + if style['style_type'] == 'func': + func_cast = "(void (*)(void))" + elif style['style_type'] == 'num': + func_cast = "(int32_t)" + return func_cast + def style_set(i): print("static inline void lv_style_set_" + props[i]['name'].lower() +"(lv_style_t * style, "+ props[i]['var_type'] +" value) {") - func_cast = "(void (*)(void))" if props[i]['style_type'] == 'func' else "" + func_cast = get_func_cast(props[i]) print(" lv_style_value_t v = {." + props[i]['style_type'] +" = " + func_cast + "value}; lv_style_set_prop(style, LV_STYLE_" + props[i]['name'] +", v); }") print("") def local_style_set(i): print("static inline void lv_obj_set_style_" + props[i]['name'].lower() + "(struct _lv_obj_t * obj, uint32_t part, uint32_t state, " + props[i]['var_type'] +" value) {") - func_cast = "(void (*)(void))" if props[i]['style_type'] == 'func' else "" + func_cast = get_func_cast(props[i]) print(" lv_style_value_t v = {." + props[i]['style_type'] +" = " + func_cast + "value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_" + props[i]['name'] +", v); }") print("") diff --git a/src/lv_core/lv_obj_style.h b/src/lv_core/lv_obj_style.h index 44752e3bc..22f451b9c 100644 --- a/src/lv_core/lv_obj_style.h +++ b/src/lv_core/lv_obj_style.h @@ -207,6 +207,28 @@ void lv_obj_fade_out(struct _lv_obj_t * obj, uint32_t time, uint32_t delay); #include "lv_obj_style_gen.h" +static inline void lv_obj_set_pad_all(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { + lv_obj_set_style_pad_left(obj, part, state, value); + lv_obj_set_style_pad_right(obj, part, state, value); + lv_obj_set_style_pad_top(obj, part, state, value); + lv_obj_set_style_pad_bottom(obj, part, state, value); +} + +static inline void lv_obj_set_pad_hor(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { + lv_obj_set_style_pad_left(obj, part, state, value); + lv_obj_set_style_pad_right(obj, part, state, value); +} + +static inline void lv_obj_set_pad_ver(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { + lv_obj_set_style_pad_top(obj, part, state, value); + lv_obj_set_style_pad_bottom(obj, part, state, value); +} + +static inline void lv_obj_set_pad_gap(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { + lv_obj_set_style_pad_row(obj, part, state, value); + lv_obj_set_style_pad_column(obj, part, state, value); +} + /********************** * MACROS **********************/ diff --git a/src/lv_core/lv_obj_style_gen.h b/src/lv_core/lv_obj_style_gen.h index dc780d325..5521df82e 100644 --- a/src/lv_core/lv_obj_style_gen.h +++ b/src/lv_core/lv_obj_style_gen.h @@ -260,61 +260,61 @@ static inline lv_text_decor_t lv_obj_get_style_content_decor(const struct _lv_ob lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_DECOR); return (lv_text_decor_t) v.num; } static inline void lv_obj_set_style_radius(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_RADIUS, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_RADIUS, v); } static inline void lv_obj_set_style_clip_corner(struct _lv_obj_t * obj, uint32_t part, uint32_t state, bool value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CLIP_CORNER, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CLIP_CORNER, v); } static inline void lv_obj_set_style_transform_width(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TRANSFORM_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TRANSFORM_WIDTH, v); } static inline void lv_obj_set_style_transform_height(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TRANSFORM_HEIGHT, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TRANSFORM_HEIGHT, v); } static inline void lv_obj_set_style_transform_zoom(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TRANSFORM_ZOOM, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TRANSFORM_ZOOM, v); } static inline void lv_obj_set_style_transform_angle(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TRANSFORM_ANGLE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TRANSFORM_ANGLE, v); } static inline void lv_obj_set_style_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_OPA, v); } static inline void lv_obj_set_style_color_filter_cb(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_filter_cb_t value) { lv_style_value_t v = {.func = (void (*)(void))value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_COLOR_FILTER_CB, v); } static inline void lv_obj_set_style_color_filter_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_COLOR_FILTER_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_COLOR_FILTER_OPA, v); } static inline void lv_obj_set_style_anim_time(struct _lv_obj_t * obj, uint32_t part, uint32_t state, uint32_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ANIM_TIME, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ANIM_TIME, v); } static inline void lv_obj_set_style_transition(struct _lv_obj_t * obj, uint32_t part, uint32_t state, const lv_style_transition_dsc_t * value) { lv_style_value_t v = {.ptr = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TRANSITION, v); } static inline void lv_obj_set_style_size(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SIZE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SIZE, v); } static inline void lv_obj_set_style_blend_mode(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_blend_mode_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BLEND_MODE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BLEND_MODE, v); } static inline void lv_obj_set_style_pad_top(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_TOP, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_TOP, v); } static inline void lv_obj_set_style_pad_bottom(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_BOTTOM, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_BOTTOM, v); } static inline void lv_obj_set_style_pad_left(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_LEFT, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_LEFT, v); } static inline void lv_obj_set_style_pad_right(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_RIGHT, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_RIGHT, v); } static inline void lv_obj_set_style_pad_row(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_ROW, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_ROW, v); } static inline void lv_obj_set_style_pad_column(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_COLUMN, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_PAD_COLUMN, v); } static inline void lv_obj_set_style_bg_color(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_COLOR, v); } @@ -323,7 +323,7 @@ static inline void lv_obj_set_style_bg_color_filtered(struct _lv_obj_t * obj, ui lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_COLOR_FILTERED, v); } static inline void lv_obj_set_style_bg_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_OPA, v); } static inline void lv_obj_set_style_bg_grad_color(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_GRAD_COLOR, v); } @@ -332,19 +332,19 @@ static inline void lv_obj_set_style_bg_grad_color_filtered(struct _lv_obj_t * ob lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_GRAD_COLOR_FILTERED, v); } static inline void lv_obj_set_style_bg_grad_dir(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_grad_dir_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_GRAD_DIR, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_GRAD_DIR, v); } static inline void lv_obj_set_style_bg_main_stop(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_MAIN_STOP, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_MAIN_STOP, v); } static inline void lv_obj_set_style_bg_grad_stop(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_GRAD_STOP, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_GRAD_STOP, v); } static inline void lv_obj_set_style_bg_img_src(struct _lv_obj_t * obj, uint32_t part, uint32_t state, const void * value) { lv_style_value_t v = {.ptr = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_IMG_SRC, v); } static inline void lv_obj_set_style_bg_img_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_IMG_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_IMG_OPA, v); } static inline void lv_obj_set_style_bg_img_recolor(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_IMG_RECOLOR, v); } @@ -353,10 +353,10 @@ static inline void lv_obj_set_style_bg_img_recolor_filtered(struct _lv_obj_t * o lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_IMG_RECOLOR_FILTERED, v); } static inline void lv_obj_set_style_bg_img_recolor_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_IMG_RECOLOR_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_IMG_RECOLOR_OPA, v); } static inline void lv_obj_set_style_bg_img_tiled(struct _lv_obj_t * obj, uint32_t part, uint32_t state, bool value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_IMG_TILED, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BG_IMG_TILED, v); } static inline void lv_obj_set_style_border_color(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BORDER_COLOR, v); } @@ -365,16 +365,16 @@ static inline void lv_obj_set_style_border_color_filtered(struct _lv_obj_t * obj lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BORDER_COLOR_FILTERED, v); } static inline void lv_obj_set_style_border_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BORDER_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BORDER_OPA, v); } static inline void lv_obj_set_style_border_width(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BORDER_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BORDER_WIDTH, v); } static inline void lv_obj_set_style_border_side(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_border_side_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BORDER_SIDE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BORDER_SIDE, v); } static inline void lv_obj_set_style_border_post(struct _lv_obj_t * obj, uint32_t part, uint32_t state, bool value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BORDER_POST, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_BORDER_POST, v); } static inline void lv_obj_set_style_text_color(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_COLOR, v); } @@ -383,25 +383,25 @@ static inline void lv_obj_set_style_text_color_filtered(struct _lv_obj_t * obj, lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_COLOR_FILTERED, v); } static inline void lv_obj_set_style_text_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_OPA, v); } static inline void lv_obj_set_style_text_font(struct _lv_obj_t * obj, uint32_t part, uint32_t state, const lv_font_t * value) { lv_style_value_t v = {.ptr = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_FONT, v); } static inline void lv_obj_set_style_text_letter_space(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_LETTER_SPACE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_LETTER_SPACE, v); } static inline void lv_obj_set_style_text_line_space(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_LINE_SPACE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_LINE_SPACE, v); } static inline void lv_obj_set_style_text_decor(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_text_decor_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_DECOR, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_DECOR, v); } static inline void lv_obj_set_style_text_align(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_text_align_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_ALIGN, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_TEXT_ALIGN, v); } static inline void lv_obj_set_style_img_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_IMG_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_IMG_OPA, v); } static inline void lv_obj_set_style_img_recolor(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_IMG_RECOLOR, v); } @@ -410,10 +410,10 @@ static inline void lv_obj_set_style_img_recolor_filtered(struct _lv_obj_t * obj, lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_IMG_RECOLOR_FILTERED, v); } static inline void lv_obj_set_style_img_recolor_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_IMG_RECOLOR_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_IMG_RECOLOR_OPA, v); } static inline void lv_obj_set_style_outline_width(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_OUTLINE_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_OUTLINE_WIDTH, v); } static inline void lv_obj_set_style_outline_color(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_OUTLINE_COLOR, v); } @@ -422,22 +422,22 @@ static inline void lv_obj_set_style_outline_color_filtered(struct _lv_obj_t * ob lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_OUTLINE_COLOR_FILTERED, v); } static inline void lv_obj_set_style_outline_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_OUTLINE_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_OUTLINE_OPA, v); } static inline void lv_obj_set_style_outline_pad(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_OUTLINE_PAD, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_OUTLINE_PAD, v); } static inline void lv_obj_set_style_shadow_width(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_WIDTH, v); } static inline void lv_obj_set_style_shadow_ofs_x(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_OFS_X, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_OFS_X, v); } static inline void lv_obj_set_style_shadow_ofs_y(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_OFS_Y, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_OFS_Y, v); } static inline void lv_obj_set_style_shadow_spread(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_SPREAD, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_SPREAD, v); } static inline void lv_obj_set_style_shadow_color(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_COLOR, v); } @@ -446,19 +446,19 @@ static inline void lv_obj_set_style_shadow_color_filtered(struct _lv_obj_t * obj lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_COLOR_FILTERED, v); } static inline void lv_obj_set_style_shadow_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_SHADOW_OPA, v); } static inline void lv_obj_set_style_line_width(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_WIDTH, v); } static inline void lv_obj_set_style_line_dash_width(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_DASH_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_DASH_WIDTH, v); } static inline void lv_obj_set_style_line_dash_gap(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_DASH_GAP, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_DASH_GAP, v); } static inline void lv_obj_set_style_line_rounded(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_ROUNDED, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_ROUNDED, v); } static inline void lv_obj_set_style_line_color(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_COLOR, v); } @@ -467,13 +467,13 @@ static inline void lv_obj_set_style_line_color_filtered(struct _lv_obj_t * obj, lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_COLOR_FILTERED, v); } static inline void lv_obj_set_style_line_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_LINE_OPA, v); } static inline void lv_obj_set_style_arc_width(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ARC_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ARC_WIDTH, v); } static inline void lv_obj_set_style_arc_rounded(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ARC_ROUNDED, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ARC_ROUNDED, v); } static inline void lv_obj_set_style_arc_color(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ARC_COLOR, v); } @@ -482,7 +482,7 @@ static inline void lv_obj_set_style_arc_color_filtered(struct _lv_obj_t * obj, u lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ARC_COLOR_FILTERED, v); } static inline void lv_obj_set_style_arc_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ARC_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ARC_OPA, v); } static inline void lv_obj_set_style_arc_img_src(struct _lv_obj_t * obj, uint32_t part, uint32_t state, const void * value) { lv_style_value_t v = {.ptr = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_ARC_IMG_SRC, v); } @@ -491,16 +491,16 @@ static inline void lv_obj_set_style_content_text(struct _lv_obj_t * obj, uint32_ lv_style_value_t v = {.ptr = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_TEXT, v); } static inline void lv_obj_set_style_content_align(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_align_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_ALIGN, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_ALIGN, v); } static inline void lv_obj_set_style_content_ofs_x(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_OFS_X, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_OFS_X, v); } static inline void lv_obj_set_style_content_ofs_y(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_OFS_Y, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_OFS_Y, v); } static inline void lv_obj_set_style_content_opa(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_OPA, v); } static inline void lv_obj_set_style_content_font(struct _lv_obj_t * obj, uint32_t part, uint32_t state, const lv_font_t * value) { lv_style_value_t v = {.ptr = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_FONT, v); } @@ -512,34 +512,11 @@ static inline void lv_obj_set_style_content_color_filtered(struct _lv_obj_t * ob lv_style_value_t v = {.color = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_COLOR_FILTERED, v); } static inline void lv_obj_set_style_content_letter_space(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_LETTER_SPACE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_LETTER_SPACE, v); } static inline void lv_obj_set_style_content_line_space(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_LINE_SPACE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_LINE_SPACE, v); } static inline void lv_obj_set_style_content_decor(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_text_decor_t value) { - lv_style_value_t v = {.num = value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_DECOR, v); } - - -static inline void lv_obj_set_pad_all(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_obj_set_style_pad_left(obj, part, state, value); - lv_obj_set_style_pad_right(obj, part, state, value); - lv_obj_set_style_pad_top(obj, part, state, value); - lv_obj_set_style_pad_bottom(obj, part, state, value); -} - -static inline void lv_obj_set_pad_hor(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_obj_set_style_pad_left(obj, part, state, value); - lv_obj_set_style_pad_right(obj, part, state, value); -} - -static inline void lv_obj_set_pad_ver(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_obj_set_style_pad_top(obj, part, state, value); - lv_obj_set_style_pad_bottom(obj, part, state, value); -} - -static inline void lv_obj_set_pad_gap(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) { - lv_obj_set_style_pad_row(obj, part, state, value); - lv_obj_set_style_pad_column(obj, part, state, value); -} + lv_style_value_t v = {.num = (int32_t)value}; lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_CONTENT_DECOR, v); } diff --git a/src/lv_draw/lv_draw_mask.c b/src/lv_draw/lv_draw_mask.c index 3b8e0a64e..41929c19f 100644 --- a/src/lv_draw/lv_draw_mask.c +++ b/src/lv_draw/lv_draw_mask.c @@ -339,6 +339,8 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert else if(start_angle >= 180 && start_angle < 360) { start_side = LV_DRAW_MASK_LINE_SIDE_RIGHT; } + else + start_side = LV_DRAW_MASK_LINE_SIDE_RIGHT; /* silence compiler */ LV_ASSERT_MSG(end_angle >= 0 && start_angle <= 360, "Unexpected end angle"); @@ -348,6 +350,8 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert else if(end_angle >= 180 && end_angle < 360) { end_side = LV_DRAW_MASK_LINE_SIDE_LEFT; } + else + end_side = LV_DRAW_MASK_LINE_SIDE_RIGHT; /* silence compiler */ lv_draw_mask_line_angle_init(¶m->start_line, vertex_x, vertex_y, start_angle, start_side); lv_draw_mask_line_angle_init(¶m->end_line, vertex_x, vertex_y, end_angle, end_side); diff --git a/src/lv_misc/lv_style.c b/src/lv_misc/lv_style.c index 09200fec5..e420efb03 100644 --- a/src/lv_misc/lv_style.c +++ b/src/lv_misc/lv_style.c @@ -41,7 +41,7 @@ void lv_style_init(lv_style_t * style) { #if LV_USE_ASSERT_STYLE - if(style->sentinel == LV_STYLE_SENTINEL_VALUE && style->allocated && style->values_and_props != NULL) { + if(style->sentinel == LV_STYLE_SENTINEL_VALUE && style->allocated && style->v_p.values_and_props != NULL) { LV_LOG_WARN("Style might be already inited. (Potential memory leak)") } #endif @@ -57,7 +57,7 @@ void lv_style_reset(lv_style_t * style) { LV_ASSERT_STYLE(style); - if(style->allocated) lv_mem_free(style->values_and_props); + if(style->allocated) lv_mem_free(style->v_p.values_and_props); lv_memset_00(style, sizeof(lv_style_t)); #if LV_USE_ASSERT_STYLE style->sentinel = LV_STYLE_SENTINEL_VALUE; @@ -85,12 +85,12 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop) return false; } - uint8_t * tmp = style->values_and_props + style->prop_cnt * sizeof(lv_style_value_t); + uint8_t * tmp = style->v_p.values_and_props + style->prop_cnt * sizeof(lv_style_value_t); uint16_t * props = (uint16_t *) tmp; uint32_t i; for(i = 0; i < style->prop_cnt; i++) { if(props[i] == prop) { - lv_style_value_t * values = (lv_style_value_t *)style->values_and_props; + lv_style_value_t * values = (lv_style_value_t *)style->v_p.values_and_props; style->prop_cnt--; size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t)); uint8_t * new_values_and_props = lv_mem_alloc(size); @@ -110,8 +110,8 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop) } } - lv_mem_free(style->values_and_props); - style->values_and_props = new_values_and_props; + lv_mem_free(style->v_p.values_and_props); + style->v_p.values_and_props = new_values_and_props; return true; } } @@ -127,12 +127,12 @@ void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_ style->has_group |= 1 << group; if(style->allocated) { - uint8_t * tmp = style->values_and_props + style->prop_cnt * sizeof(lv_style_value_t); + uint8_t * tmp = style->v_p.values_and_props + style->prop_cnt * sizeof(lv_style_value_t); uint16_t * props = (uint16_t *) tmp; int32_t i; for(i = 0; i < style->prop_cnt; i++) { if(props[i] == prop) { - lv_style_value_t * values = (lv_style_value_t *)style->values_and_props; + lv_style_value_t * values = (lv_style_value_t *)style->v_p.values_and_props; values[i] = value; return; } @@ -140,8 +140,8 @@ void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_ style->prop_cnt++; size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t)); - style->values_and_props = lv_mem_realloc(style->values_and_props, size); - tmp = style->values_and_props + (style->prop_cnt - 1) * sizeof(lv_style_value_t); + style->v_p.values_and_props = lv_mem_realloc(style->v_p.values_and_props, size); + tmp = style->v_p.values_and_props + (style->prop_cnt - 1) * sizeof(lv_style_value_t); props = (uint16_t *) tmp; /*Shift all props to make place for the value before them*/ for(i = style->prop_cnt - 2; i >= 0; i--) { @@ -149,16 +149,16 @@ void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_ } /*Go to the new position wit the props*/ - tmp = style->values_and_props + (style->prop_cnt) * sizeof(lv_style_value_t); + tmp = style->v_p.values_and_props + (style->prop_cnt) * sizeof(lv_style_value_t); props = (uint16_t *) tmp; - lv_style_value_t * values = (lv_style_value_t *)style->values_and_props; + lv_style_value_t * values = (lv_style_value_t *)style->v_p.values_and_props; /*Set the new property and value*/ props[style->prop_cnt - 1] = prop; values[style->prop_cnt - 1] = value; } else if(style->prop_cnt == 1) { if(style->prop1 == prop) { - style->value1 = value; + style->v_p.value1 = value; return; } style->prop_cnt++; @@ -169,16 +169,16 @@ void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_ lv_style_value_t * values = (lv_style_value_t *)values_and_props; props[0] = style->prop1; props[1] = prop; - values[0] = style->value1; + values[0] = style->v_p.value1; values[1] = value; - style->values_and_props = values_and_props; + style->v_p.values_and_props = values_and_props; style->allocated = 1; } else if (style->prop_cnt == 0) { style->prop_cnt++; style->prop1 = prop; - style->value1 = value; + style->v_p.value1 = value; } } @@ -187,19 +187,19 @@ bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_ if(style->prop_cnt == 0) return false; if(style->allocated) { - uint8_t * tmp = style->values_and_props + style->prop_cnt * sizeof(lv_style_value_t); + uint8_t * tmp = style->v_p.values_and_props + style->prop_cnt * sizeof(lv_style_value_t); uint16_t * props = (uint16_t *) tmp; uint32_t i; for(i = 0; i < style->prop_cnt; i++) { if(props[i] == prop) { - lv_style_value_t * values = (lv_style_value_t *)style->values_and_props; + lv_style_value_t * values = (lv_style_value_t *)style->v_p.values_and_props; *value = values[i]; return true; } } } else { if(style->prop1 == prop) { - *value = style->value1; + *value = style->v_p.value1; return true; } } diff --git a/src/lv_misc/lv_style.h b/src/lv_misc/lv_style.h index 703b5614f..3ea7bfb12 100644 --- a/src/lv_misc/lv_style.h +++ b/src/lv_misc/lv_style.h @@ -254,13 +254,9 @@ typedef struct { /* If there is only one property store it directly. * For more properties allocate an array */ union { - struct { - lv_style_value_t value1; - }; - struct { - uint8_t * values_and_props; - }; - }; + lv_style_value_t value1; + uint8_t * values_and_props; + } v_p; uint16_t prop1; uint8_t has_group; @@ -370,6 +366,29 @@ uint8_t _lv_style_get_prop_group(lv_style_prop_t prop); #include "lv_style_gen.h" +static inline void lv_style_set_pad_all(lv_style_t * style, lv_coord_t value) { + lv_style_set_pad_left(style, value); + lv_style_set_pad_right(style, value); + lv_style_set_pad_top(style, value); + lv_style_set_pad_bottom(style, value); +} + +static inline void lv_style_set_pad_hor(lv_style_t * style, lv_coord_t value) { + lv_style_set_pad_left(style, value); + lv_style_set_pad_right(style, value); +} + +static inline void lv_style_set_pad_ver(lv_style_t * style, lv_coord_t value) { + lv_style_set_pad_top(style, value); + lv_style_set_pad_bottom(style, value); +} + +static inline void lv_style_set_pad_gap(lv_style_t * style, lv_coord_t value) { + lv_style_set_pad_row(style, value); + lv_style_set_pad_column(style, value); +} + + /************************* * GLOBAL VARIABLES *************************/ diff --git a/src/lv_misc/lv_style_gen.h b/src/lv_misc/lv_style_gen.h index 12fe1032b..e4f1410b5 100644 --- a/src/lv_misc/lv_style_gen.h +++ b/src/lv_misc/lv_style_gen.h @@ -1,59 +1,59 @@ static inline void lv_style_set_radius(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_RADIUS, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_RADIUS, v); } static inline void lv_style_set_clip_corner(lv_style_t * style, bool value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CLIP_CORNER, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_CLIP_CORNER, v); } static inline void lv_style_set_transform_width(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_WIDTH, v); } static inline void lv_style_set_transform_height(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_HEIGHT, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_HEIGHT, v); } static inline void lv_style_set_transform_zoom(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_ZOOM, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_ZOOM, v); } static inline void lv_style_set_transform_angle(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_ANGLE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_TRANSFORM_ANGLE, v); } static inline void lv_style_set_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_OPA, v); } static inline void lv_style_set_color_filter_cb(lv_style_t * style, lv_color_filter_cb_t value) { lv_style_value_t v = {.func = (void (*)(void))value}; lv_style_set_prop(style, LV_STYLE_COLOR_FILTER_CB, v); } static inline void lv_style_set_color_filter_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_COLOR_FILTER_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_COLOR_FILTER_OPA, v); } static inline void lv_style_set_anim_time(lv_style_t * style, uint32_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_ANIM_TIME, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_ANIM_TIME, v); } static inline void lv_style_set_transition(lv_style_t * style, const lv_style_transition_dsc_t * value) { lv_style_value_t v = {.ptr = value}; 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 = value}; lv_style_set_prop(style, LV_STYLE_SIZE, v); } + 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 = {.num = value}; lv_style_set_prop(style, LV_STYLE_BLEND_MODE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BLEND_MODE, v); } static inline void lv_style_set_pad_top(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_TOP, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_PAD_TOP, v); } static inline void lv_style_set_pad_bottom(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_BOTTOM, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_PAD_BOTTOM, v); } static inline void lv_style_set_pad_left(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_LEFT, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_PAD_LEFT, v); } static inline void lv_style_set_pad_right(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_RIGHT, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_PAD_RIGHT, v); } static inline void lv_style_set_pad_row(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_ROW, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_PAD_ROW, v); } static inline void lv_style_set_pad_column(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_COLUMN, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_PAD_COLUMN, v); } static inline void lv_style_set_bg_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_COLOR, v); } @@ -62,7 +62,7 @@ static inline void lv_style_set_bg_color_filtered(lv_style_t * style, lv_color_t lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_COLOR_FILTERED, v); } static inline void lv_style_set_bg_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BG_OPA, v); } static inline void lv_style_set_bg_grad_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_COLOR, v); } @@ -71,19 +71,19 @@ static inline void lv_style_set_bg_grad_color_filtered(lv_style_t * style, lv_co lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_COLOR_FILTERED, v); } static inline void lv_style_set_bg_grad_dir(lv_style_t * style, lv_grad_dir_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_DIR, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_DIR, v); } static inline void lv_style_set_bg_main_stop(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_MAIN_STOP, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BG_MAIN_STOP, v); } static inline void lv_style_set_bg_grad_stop(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_STOP, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_STOP, v); } static inline void lv_style_set_bg_img_src(lv_style_t * style, const void * value) { lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_SRC, v); } static inline void lv_style_set_bg_img_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_OPA, v); } static inline void lv_style_set_bg_img_recolor(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_RECOLOR, v); } @@ -92,10 +92,10 @@ static inline void lv_style_set_bg_img_recolor_filtered(lv_style_t * style, lv_c lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_RECOLOR_FILTERED, v); } static inline void lv_style_set_bg_img_recolor_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_RECOLOR_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_RECOLOR_OPA, v); } static inline void lv_style_set_bg_img_tiled(lv_style_t * style, bool value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_TILED, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_TILED, v); } static inline void lv_style_set_border_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BORDER_COLOR, v); } @@ -104,16 +104,16 @@ static inline void lv_style_set_border_color_filtered(lv_style_t * style, lv_col lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BORDER_COLOR_FILTERED, v); } static inline void lv_style_set_border_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BORDER_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BORDER_OPA, v); } static inline void lv_style_set_border_width(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BORDER_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BORDER_WIDTH, v); } static inline void lv_style_set_border_side(lv_style_t * style, lv_border_side_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BORDER_SIDE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BORDER_SIDE, v); } static inline void lv_style_set_border_post(lv_style_t * style, bool value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BORDER_POST, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_BORDER_POST, v); } static inline void lv_style_set_text_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_TEXT_COLOR, v); } @@ -122,25 +122,25 @@ static inline void lv_style_set_text_color_filtered(lv_style_t * style, lv_color lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_TEXT_COLOR_FILTERED, v); } static inline void lv_style_set_text_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_TEXT_OPA, v); } static inline void lv_style_set_text_font(lv_style_t * style, const lv_font_t * value) { lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_TEXT_FONT, v); } static inline void lv_style_set_text_letter_space(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_LETTER_SPACE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_TEXT_LETTER_SPACE, v); } static inline void lv_style_set_text_line_space(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_LINE_SPACE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_TEXT_LINE_SPACE, v); } static inline void lv_style_set_text_decor(lv_style_t * style, lv_text_decor_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_DECOR, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_TEXT_DECOR, v); } static inline void lv_style_set_text_align(lv_style_t * style, lv_text_align_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_ALIGN, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_TEXT_ALIGN, v); } static inline void lv_style_set_img_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_IMG_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_IMG_OPA, v); } static inline void lv_style_set_img_recolor(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_IMG_RECOLOR, v); } @@ -149,10 +149,10 @@ static inline void lv_style_set_img_recolor_filtered(lv_style_t * style, lv_colo lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_IMG_RECOLOR_FILTERED, v); } static inline void lv_style_set_img_recolor_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_IMG_RECOLOR_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_IMG_RECOLOR_OPA, v); } static inline void lv_style_set_outline_width(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_WIDTH, v); } static inline void lv_style_set_outline_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_COLOR, v); } @@ -161,22 +161,22 @@ static inline void lv_style_set_outline_color_filtered(lv_style_t * style, lv_co lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_COLOR_FILTERED, v); } static inline void lv_style_set_outline_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_OPA, v); } static inline void lv_style_set_outline_pad(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_PAD, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_PAD, v); } static inline void lv_style_set_shadow_width(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_SHADOW_WIDTH, v); } static inline void lv_style_set_shadow_ofs_x(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_OFS_X, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_SHADOW_OFS_X, v); } static inline void lv_style_set_shadow_ofs_y(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_OFS_Y, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_SHADOW_OFS_Y, v); } static inline void lv_style_set_shadow_spread(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_SPREAD, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_SHADOW_SPREAD, v); } static inline void lv_style_set_shadow_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_COLOR, v); } @@ -185,19 +185,19 @@ static inline void lv_style_set_shadow_color_filtered(lv_style_t * style, lv_col lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_COLOR_FILTERED, v); } static inline void lv_style_set_shadow_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_SHADOW_OPA, v); } static inline void lv_style_set_line_width(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_LINE_WIDTH, v); } static inline void lv_style_set_line_dash_width(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_DASH_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_LINE_DASH_WIDTH, v); } static inline void lv_style_set_line_dash_gap(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_DASH_GAP, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_LINE_DASH_GAP, v); } static inline void lv_style_set_line_rounded(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_ROUNDED, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_LINE_ROUNDED, v); } static inline void lv_style_set_line_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_LINE_COLOR, v); } @@ -206,13 +206,13 @@ static inline void lv_style_set_line_color_filtered(lv_style_t * style, lv_color lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_LINE_COLOR_FILTERED, v); } static inline void lv_style_set_line_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_LINE_OPA, v); } static inline void lv_style_set_arc_width(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_ARC_WIDTH, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_ARC_WIDTH, v); } static inline void lv_style_set_arc_rounded(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_ARC_ROUNDED, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_ARC_ROUNDED, v); } static inline void lv_style_set_arc_color(lv_style_t * style, lv_color_t value) { lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_ARC_COLOR, v); } @@ -221,7 +221,7 @@ static inline void lv_style_set_arc_color_filtered(lv_style_t * style, lv_color_ lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_ARC_COLOR_FILTERED, v); } static inline void lv_style_set_arc_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_ARC_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_ARC_OPA, v); } static inline void lv_style_set_arc_img_src(lv_style_t * style, const void * value) { lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_ARC_IMG_SRC, v); } @@ -230,16 +230,16 @@ static inline void lv_style_set_content_text(lv_style_t * style, const char * va lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_TEXT, v); } static inline void lv_style_set_content_align(lv_style_t * style, lv_align_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_ALIGN, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_CONTENT_ALIGN, v); } static inline void lv_style_set_content_ofs_x(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OFS_X, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OFS_X, v); } static inline void lv_style_set_content_ofs_y(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OFS_Y, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OFS_Y, v); } static inline void lv_style_set_content_opa(lv_style_t * style, lv_opa_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OPA, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OPA, v); } static inline void lv_style_set_content_font(lv_style_t * style, const lv_font_t * value) { lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_FONT, v); } @@ -251,33 +251,11 @@ static inline void lv_style_set_content_color_filtered(lv_style_t * style, lv_co lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_COLOR_FILTERED, v); } static inline void lv_style_set_content_letter_space(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_LETTER_SPACE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_CONTENT_LETTER_SPACE, v); } static inline void lv_style_set_content_line_space(lv_style_t * style, lv_coord_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_LINE_SPACE, v); } + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_CONTENT_LINE_SPACE, v); } static inline void lv_style_set_content_decor(lv_style_t * style, lv_text_decor_t value) { - lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_DECOR, v); } - -static inline void lv_style_set_pad_all(lv_style_t * style, lv_coord_t value) { - lv_style_set_pad_left(style, value); - lv_style_set_pad_right(style, value); - lv_style_set_pad_top(style, value); - lv_style_set_pad_bottom(style, value); -} - -static inline void lv_style_set_pad_hor(lv_style_t * style, lv_coord_t value) { - lv_style_set_pad_left(style, value); - lv_style_set_pad_right(style, value); -} - -static inline void lv_style_set_pad_ver(lv_style_t * style, lv_coord_t value) { - lv_style_set_pad_top(style, value); - lv_style_set_pad_bottom(style, value); -} - -static inline void lv_style_set_pad_gap(lv_style_t * style, lv_coord_t value) { - lv_style_set_pad_row(style, value); - lv_style_set_pad_column(style, value); -} + lv_style_value_t v = {.num = (int32_t)value}; lv_style_set_prop(style, LV_STYLE_CONTENT_DECOR, v); } diff --git a/src/lv_widgets/lv_meter.c b/src/lv_widgets/lv_meter.c index a5fa20a6a..e7299464b 100644 --- a/src/lv_widgets/lv_meter.c +++ b/src/lv_widgets/lv_meter.c @@ -123,9 +123,9 @@ lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, lv_meter_scale_t indic->opa = LV_OPA_COVER; indic->type = LV_METER_INDICATOR_TYPE_NEEDLE_LINE; - indic->needle_line.width = width; - indic->needle_line.color = color; - indic->needle_line.r_mod = r_mod; + indic->type_data.needle_line.width = width; + indic->type_data.needle_line.color = color; + indic->type_data.needle_line.r_mod = r_mod; lv_obj_invalidate(obj); return indic; @@ -139,9 +139,9 @@ lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, lv_meter_scale_t indic->opa = LV_OPA_COVER; indic->type = LV_METER_INDICATOR_TYPE_NEEDLE_IMG; - indic->needle_img.src = src; - indic->needle_img.pivot.x = pivot_x; - indic->needle_img.pivot.y = pivot_y; + indic->type_data.needle_img.src = src; + indic->type_data.needle_img.pivot.x = pivot_x; + indic->type_data.needle_img.pivot.y = pivot_y; lv_obj_invalidate(obj); return indic; @@ -155,9 +155,9 @@ lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, lv_meter_scale_t * scale indic->opa = LV_OPA_COVER; indic->type = LV_METER_INDICATOR_TYPE_ARC; - indic->arc.width = width; - indic->arc.color = color; - indic->arc.r_mod = r_mod; + indic->type_data.arc.width = width; + indic->type_data.arc.color = color; + indic->type_data.arc.r_mod = r_mod; lv_obj_invalidate(obj); return indic; @@ -171,10 +171,10 @@ lv_meter_indicator_t * lv_meter_add_scale_lines(lv_obj_t * obj, lv_meter_scale_t indic->opa = LV_OPA_COVER; indic->type = LV_METER_INDICATOR_TYPE_SCALE_LINES; - indic->scale_lines.color_start = color_start; - indic->scale_lines.color_end = color_end; - indic->scale_lines.local_grad = local; - indic->scale_lines.width_mod = width_mod; + indic->type_data.scale_lines.color_start = color_start; + indic->type_data.scale_lines.color_end = color_end; + indic->type_data.scale_lines.local_grad = local; + indic->type_data.scale_lines.width_mod = width_mod; lv_obj_invalidate(obj); return indic; @@ -316,13 +316,13 @@ static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area _LV_LL_READ(&scale->indicator_ll, indic) { if(indic->type != LV_METER_INDICATOR_TYPE_ARC) continue; - arc_dsc.color = indic->arc.color; - arc_dsc.width = indic->arc.width; + arc_dsc.color = indic->type_data.arc.color; + arc_dsc.width = indic->type_data.arc.width; arc_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8; int32_t start_angle = lv_map(indic->start_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range); int32_t end_angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range); - lv_draw_arc(scale_center.x, scale_center.y, r_out + indic->arc.r_mod, start_angle, end_angle, clip_area, &arc_dsc); + lv_draw_arc(scale_center.x, scale_center.y, r_out + indic->type_data.arc.r_mod, start_angle, end_angle, clip_area, &arc_dsc); } } } @@ -415,18 +415,18 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c _LV_LL_READ(&scale->indicator_ll, indic) { if(indic->type != LV_METER_INDICATOR_TYPE_SCALE_LINES) continue; if(value_of_line >= indic->start_value && value_of_line <= indic->end_value) { - line_width += indic->scale_lines.width_mod; + line_width += indic->type_data.scale_lines.width_mod; - if(indic->scale_lines.color_start.full == indic->scale_lines.color_end.full) { - line_color = indic->scale_lines.color_start; + if(indic->type_data.scale_lines.color_start.full == indic->type_data.scale_lines.color_end.full) { + line_color = indic->type_data.scale_lines.color_start; } else { lv_opa_t ratio; - if(indic->scale_lines.local_grad) { + if(indic->type_data.scale_lines.local_grad) { ratio = lv_map(value_of_line, indic->start_value, indic->end_value, LV_OPA_TRANSP, LV_OPA_COVER); } else { ratio = lv_map(value_of_line, scale->min, scale->max, LV_OPA_TRANSP, LV_OPA_COVER); } - line_color = lv_color_mix(indic->scale_lines.color_end, indic->scale_lines.color_start, ratio); + line_color = lv_color_mix(indic->type_data.scale_lines.color_end, indic->type_data.scale_lines.color_start, ratio); } } } @@ -545,12 +545,12 @@ static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_a _LV_LL_READ_BACK(&scale->indicator_ll, indic) { if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_LINE) { int32_t angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range); - lv_coord_t r_out = r_edge + scale->r_mod + indic->needle_line.r_mod; + lv_coord_t r_out = r_edge + scale->r_mod + indic->type_data.needle_line.r_mod; lv_point_t p_end; p_end.y = (lv_trigo_sin(angle) * (r_out)) / LV_TRIGO_SIN_MAX + scale_center.y; p_end.x = (lv_trigo_cos(angle) * (r_out)) / LV_TRIGO_SIN_MAX + scale_center.x; - line_dsc.color = indic->needle_line.color; - line_dsc.width = indic->needle_line.width; + line_dsc.color = indic->type_data.needle_line.color; + line_dsc.width = indic->type_data.needle_line.width; line_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8; lv_draw_line(&scale_center, &p_end, clip_area, &line_dsc); @@ -558,20 +558,20 @@ static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_a else if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_IMG) { int32_t angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range); lv_img_header_t info; - lv_img_decoder_get_info(indic->needle_img.src, &info); + lv_img_decoder_get_info(indic->type_data.needle_img.src, &info); lv_area_t a; - a.x1 = scale_center.x - indic->needle_img.pivot.x; - a.y1 = scale_center.y - indic->needle_img.pivot.y; + a.x1 = scale_center.x - indic->type_data.needle_img.pivot.x; + a.y1 = scale_center.y - indic->type_data.needle_img.pivot.y; a.x2 = a.x1 + info.w - 1; a.y2 = a.y1 + info.h - 1; img_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8; - img_dsc.pivot.x = indic->needle_img.pivot.x; - img_dsc.pivot.y = indic->needle_img.pivot.y; + img_dsc.pivot.x = indic->type_data.needle_img.pivot.x; + img_dsc.pivot.y = indic->type_data.needle_img.pivot.y; angle = angle * 10; if(angle > 3600) angle -= 3600; img_dsc.angle = angle; - lv_draw_img(&a, clip_area, indic->needle_img.src, &img_dsc); + lv_draw_img(&a, clip_area, indic->type_data.needle_img.src, &img_dsc); } } } diff --git a/src/lv_widgets/lv_meter.h b/src/lv_widgets/lv_meter.h index 16239bd42..7e22eacfe 100644 --- a/src/lv_widgets/lv_meter.h +++ b/src/lv_widgets/lv_meter.h @@ -61,7 +61,7 @@ typedef struct { lv_color_t color_end; uint8_t local_grad :1; }scale_lines; - }; + } type_data; }lv_meter_indicator_t; typedef struct { diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 7db868b48..744678d90 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -619,7 +619,7 @@ void lv_textarea_set_text_sel(lv_obj_t * obj, bool en) if(!en) lv_textarea_clear_selection(obj); #else - (void)ta; /*Unused*/ + (void)obj; /*Unused*/ (void)en; /*Unused*/ #endif } @@ -789,7 +789,7 @@ bool lv_textarea_text_is_selected(const lv_obj_t * obj) return false; } #else - (void)ta; /*Unused*/ + (void)obj; /*Unused*/ return false; #endif } @@ -807,7 +807,7 @@ bool lv_textarea_get_text_sel_en(lv_obj_t * obj) lv_textarea_t * ta = (lv_textarea_t *) obj; return ta->text_sel_en; #else - (void)ta; /*Unused*/ + (void)obj; /*Unused*/ return false; #endif } @@ -847,7 +847,7 @@ void lv_textarea_clear_selection(lv_obj_t * obj) lv_label_set_text_sel_end(ta->label, LV_DRAW_LABEL_NO_TXT_SEL); } #else - (void)ta; /*Unused*/ + (void)obj; /*Unused*/ #endif }