diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 1b34d7088..0c08541e1 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -custom: ["https://www.paypal.com/paypalme/my/profile"] +custom: ["https://paypal.me/littlevgl?locale.x=en_US"] diff --git a/CHANGELOG.md b/CHANGELOG.md index c54f12402..215bf82b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,24 @@ # Changelog -## v7.4.0 (planned on 18.08.2020) +## v7.4.0 (planned on 01.09.2020) *Available in the `dev` branch* -## v7.3.0 (planned on 04.08.2020) -*Available in the `master` branch* +- Add `lv_font_load()` function - Loads a `lv_font_t` object from a binary font file +- Add `lv_font_free()` function - Frees the memory allocated by the `lv_font_load()` function + +## v7.3.1 (planned on 18.08.2020) + +### Bugfixes +- Fix drawing value string twice +- Rename `lv_chart_clear_serie` to `lv_chart_clear_series` and `lv_obj_align_origo` to `lv_obj_align_mid` +- Add linemeter's mirror feature again +- Fix text decor (udnerline strikethrough) with older versions of font converter +- Fix setting local style property multiple times +- Add missing background drawing and radius handling to image button +- Allow adding extra label to list buttons +- Fix overflow in large image transformations + +## v7.3.0 (04.08.2020) ### New features - Add `lv_task_get_next` @@ -12,9 +26,6 @@ - Add `lv_tabview_set_tab_name()` function - used to change a tab's name - Add `LV_THEME_MATERIAL_FLAG_NO_TRANSITION` and `LV_THEME_MATERIAL_FLAG_NO_FOCUS` flags - Reduce code size by adding: `LV_USE_FONT_COMPRESSED` and `LV_FONT_USE_SUBPX` and applying some optimization -- Add `lv_font_load()` function - Loads a `lv_font_t` object from a binary font file -- Add `lv_font_free()` function - Frees the memory allocated by the `lv_font_load()` function - ### Bugfixes - Do not print warning for missing glyph if its height OR width is zero. diff --git a/README.md b/README.md index eeb9f47f2..af3a4cde5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,4 @@

LVGL - Light and Versatile Graphics Library

-

- - -

diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 66aae962d..9b5914e58 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -7,7 +7,7 @@ This list indicates only the current intention and can be changed. ## v8 Planned to September/October 2020 - New scrolling: - - See [feat/new-scroll]((https://github.com/lvgl/lvgl/tree/feat/new-scroll) branch and [#1614](https://github.com/lvgl/lvgl/issues/1614)) issue. + - See [feat/new-scroll](https://github.com/lvgl/lvgl/tree/feat/new-scroll) branch and [#1614](https://github.com/lvgl/lvgl/issues/1614)) issue. - Remove `lv_page` and support scrolling on `lv_obj` - Support "elastic" scrolling when scrolled in - Support scroll chaining among any objects types (not only `lv_pages`s) @@ -23,6 +23,17 @@ Planned to September/October 2020 - Work in progress - Add new label alignment modes - See [#1656](https://github.com/lvgl/lvgl/issues/1656) +- Remove the align parameter from `lv_canvas_draw_text` + +## v9 +- Simplify `group`s. Discussion is [here](https://forum.lvgl.io/t/lv-group-tabindex/2927/3). ## Ideas -- ... +- Unit testing (gtest?). See [#1658](https://github.com/lvgl/lvgl/issues/1658) +- Benchmarking (gem5?). See [#1660](https://github.com/lvgl/lvgl/issues/1660) +- CPP binding. See [Forum](https://forum.lvgl.io/t/is-it-possible-to-officially-support-optional-cpp-api/2736) +- Optmize font decompression +- Switch to RGBA colors in styles +- Need coverage report for tests +- Need static analize (via coverity.io or somehing else) +- Support dot_begin and dot_middle long modes for labels diff --git a/library.json b/library.json index a2c5dd2b9..6cb9ab8b3 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "lvgl", - "version": "7.2.0", + "version": "7.3.0", "keywords": "graphics, gui, embedded, tft, lvgl", "description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.", "repository": { diff --git a/library.properties b/library.properties new file mode 100644 index 000000000..712c77392 --- /dev/null +++ b/library.properties @@ -0,0 +1,10 @@ +name=lvgl +version=7.3.0 +author=kisvegabor +maintainer=kisvegabor,embeddedt,pete-pjb +sentence=Full-featured Graphics Library for Embedded Systems +paragraph=Powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash). +category=Display +url=https://lvgl.io +architectures=* +includes=lvgl.h diff --git a/lv_conf_template.h b/lv_conf_template.h index aab9f497f..4032f5ab0 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -1,6 +1,6 @@ /** * @file lv_conf.h - * Configuration file for LVGL v7.2.0 + * Configuration file for LVGL v7.3.0 */ /* @@ -97,6 +97,10 @@ typedef int16_t lv_coord_t; # define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/ #endif /*LV_MEM_CUSTOM*/ +/* Use the standard memcpy and memset instead of LVGL's own functions. + * The standard functions might or might not be faster depending on their implementation. */ +#define LV_MEMCPY_MEMSET_STD 0 + /* Garbage Collector settings * Used if lvgl is binded to higher level language and the memory is managed by that language */ #define LV_ENABLE_GC 0 @@ -150,7 +154,7 @@ typedef void * lv_anim_user_data_t; #endif -/* 1: Enable shadow drawing*/ +/* 1: Enable shadow drawing on rectangles*/ #define LV_USE_SHADOW 1 #if LV_USE_SHADOW /* Allow buffering some shadow calculation @@ -160,6 +164,15 @@ typedef void * lv_anim_user_data_t; #define LV_SHADOW_CACHE_SIZE 0 #endif +/*1: enable outline drawing on rectangles*/ +#define LV_USE_OUTLINE 1 + +/*1: enable pattern drawing on rectangles*/ +#define LV_USE_PATTERN 1 + +/*1: enable value string drawing on rectangles*/ +#define LV_USE_VALUE_STR 1 + /* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`)*/ #define LV_USE_BLEND_MODES 1 diff --git a/scripts/release.py b/scripts/release.py index e64c13bdc..0b5946584 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -210,10 +210,19 @@ def docs_update_version(v): cmd("git add conf.py") cmd('git ci -m "update conf.py to ' + v + '"') + +def docs_merge_to_release_branch(v): + title("docs: merge to release branch") + cmd('git co release/v7 --') + cmd('git clean -fd .') + cmd('rm -f LVGL.pdf') #To avoide possible merge conflict + cmd('git merge latest') + cmd('git push origin release/v7') + def docs_build(): title("docs: Build") cmd("git checkout master") - cmd("./update.py latest") + cmd("./update.py latest release/v7") def clean_up(): title("Clean up repos") @@ -240,6 +249,7 @@ drivers_merge_to_release_branch(ver_str) docs_clone() docs_get_api() docs_update_version(ver_str) +docs_merge_to_release_branch(ver_str) docs_build() clean_up() diff --git a/src/lv_api_map.h b/src/lv_api_map.h index 926e9ec47..d8e904e8a 100644 --- a/src/lv_api_map.h +++ b/src/lv_api_map.h @@ -200,8 +200,30 @@ static inline void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coor { lv_chart_set_y_range(chart, LV_CHART_AXIS_PRIMARY_Y, ymin, ymax); } + + +static inline void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * series) +{ + lv_chart_clear_series(chart, series); +} + #endif +static inline void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) +{ + lv_obj_align_mid(obj, base, align, x_ofs, y_ofs); +} + +static inline void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs) +{ + lv_obj_align_mid_y(obj, base, align, x_ofs); +} + +static inline void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs) +{ + lv_obj_align_mid_y(obj, base, align, y_ofs); +} + #endif /*LV_USE_API_EXTENSION_V6*/ /********************** * MACROS diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 7f86b0eae..d43134241 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -147,6 +147,12 @@ #endif #endif /*LV_MEM_CUSTOM*/ +/* Use the standard memcpy and memset instead of LVGL's own functions. + * The standard functions might or might not be faster depending on their implementation. */ +#ifndef LV_MEMCPY_MEMSET_STD +#define LV_MEMCPY_MEMSET_STD 0 +#endif + /* Garbage Collector settings * Used if lvgl is binded to higher level language and the memory is managed by that language */ #ifndef LV_ENABLE_GC @@ -223,7 +229,7 @@ #endif -/* 1: Enable shadow drawing*/ +/* 1: Enable shadow drawing on rectangles*/ #ifndef LV_USE_SHADOW #define LV_USE_SHADOW 1 #endif @@ -237,6 +243,21 @@ #endif #endif +/*1: enable outline drawing on rectangles*/ +#ifndef LV_USE_OUTLINE +#define LV_USE_OUTLINE 1 +#endif + +/*1: enable pattern drawing on rectangles*/ +#ifndef LV_USE_PATTERN +#define LV_USE_PATTERN 1 +#endif + +/*1: enable value string drawing on rectangles*/ +#ifndef LV_USE_VALUE_STR +#define LV_USE_VALUE_STR 1 +#endif + /* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`)*/ #ifndef LV_USE_BLEND_MODES #define LV_USE_BLEND_MODES 1 @@ -633,7 +654,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ /* A fast and impressive theme. * Flags: * LV_THEME_MATERIAL_FLAG_LIGHT: light theme - * LV_THEME_MATERIAL_FLAG_DARK: dark theme*/ + * LV_THEME_MATERIAL_FLAG_DARK: dark theme + * LV_THEME_MATERIAL_FLAG_NO_TRANSITION: disable transitions (state change animations) + * LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state) + * */ #ifndef LV_USE_THEME_MATERIAL #define LV_USE_THEME_MATERIAL 1 #endif diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 8eedc3da0..c20904733 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -87,7 +87,7 @@ static void refresh_children_style(lv_obj_t * obj); static void base_dir_refr_children(lv_obj_t * obj); static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs); -static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, +static void obj_align_mid_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs); #if LV_USE_ANIMATION static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, @@ -856,7 +856,7 @@ void lv_obj_set_height_fit(lv_obj_t * obj, lv_coord_t h) lv_style_int_t ptop = lv_obj_get_style_pad_top(obj, LV_OBJ_PART_MAIN); lv_style_int_t pbottom = lv_obj_get_style_pad_bottom(obj, LV_OBJ_PART_MAIN); - lv_obj_set_width(obj, h - ptop - pbottom); + lv_obj_set_height(obj, h - ptop - pbottom); } /** @@ -911,7 +911,7 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co obj->realign.xofs = x_ofs; obj->realign.yofs = y_ofs; obj->realign.base = base; - obj->realign.origo_align = 0; + obj->realign.mid_align = 0; #endif } @@ -959,7 +959,7 @@ void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_ * @param x_ofs x coordinate offset after alignment * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) +void lv_obj_align_mid(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); @@ -970,7 +970,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, LV_ASSERT_OBJ(base, LV_OBJX_NAME); - obj_align_origo_core(obj, base, align, true, true, x_ofs, y_ofs); + obj_align_mid_core(obj, base, align, true, true, x_ofs, y_ofs); #if LV_USE_OBJ_REALIGN /*Save the last align parameters to use them in `lv_obj_realign`*/ @@ -978,7 +978,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, obj->realign.xofs = x_ofs; obj->realign.yofs = y_ofs; obj->realign.base = base; - obj->realign.origo_align = 1; + obj->realign.mid_align = 1; #endif } @@ -989,7 +989,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, * @param align type of alignment (see 'lv_align_t' enum) * @param x_ofs x coordinate offset after alignment */ -void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs) +void lv_obj_align_mid_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); @@ -1000,7 +1000,7 @@ void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig LV_ASSERT_OBJ(base, LV_OBJX_NAME); - obj_align_origo_core(obj, base, align, true, false, x_ofs, 0); + obj_align_mid_core(obj, base, align, true, false, x_ofs, 0); } @@ -1011,7 +1011,7 @@ void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig * @param align type of alignment (see 'lv_align_t' enum) * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs) +void lv_obj_align_mid_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); @@ -1022,7 +1022,7 @@ void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig LV_ASSERT_OBJ(base, LV_OBJX_NAME); - obj_align_origo_core(obj, base, align, true, false, 0, y_ofs); + obj_align_mid_core(obj, base, align, true, false, 0, y_ofs); } /** @@ -1034,8 +1034,8 @@ void lv_obj_realign(lv_obj_t * obj) LV_ASSERT_OBJ(obj, LV_OBJX_NAME); #if LV_USE_OBJ_REALIGN - if(obj->realign.origo_align) - lv_obj_align_origo(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs); + if(obj->realign.mid_align) + lv_obj_align_mid(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs); else lv_obj_align(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs); #else @@ -1783,7 +1783,8 @@ void lv_event_send_refresh_recursive(lv_obj_t * obj) d = lv_disp_get_next(d); } - } else { + } + else { lv_res_t res = lv_event_send_refresh(obj); if(res != LV_RES_OK) return; /*If invalid returned do not check the children*/ @@ -3157,7 +3158,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t } } - +#if LV_USE_OUTLINE if(draw_dsc->outline_opa != LV_OPA_TRANSP) { draw_dsc->outline_width = lv_obj_get_style_outline_width(obj, part); if(draw_dsc->outline_width) { @@ -3171,7 +3172,9 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t #endif } } +#endif +#if LV_USE_PATTERN if(draw_dsc->pattern_opa != LV_OPA_TRANSP) { draw_dsc->pattern_image = lv_obj_get_style_pattern_image(obj, part); if(draw_dsc->pattern_image) { @@ -3192,6 +3195,8 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t } } } +#endif + #if LV_USE_SHADOW if(draw_dsc->shadow_opa > LV_OPA_MIN) { draw_dsc->shadow_width = lv_obj_get_style_shadow_width(obj, part); @@ -3210,6 +3215,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t } #endif +#if LV_USE_VALUE_STR if(draw_dsc->value_opa > LV_OPA_MIN) { draw_dsc->value_str = lv_obj_get_style_value_str(obj, part); if(draw_dsc->value_str) { @@ -3228,6 +3234,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t } } } +#endif #if LV_USE_OPA_SCALE if(opa_scale < LV_OPA_MAX) { @@ -3669,6 +3676,7 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area draw_dsc.bg_opa = LV_OPA_TRANSP; draw_dsc.pattern_opa = LV_OPA_TRANSP; draw_dsc.shadow_opa = LV_OPA_TRANSP; + draw_dsc.value_opa = LV_OPA_TRANSP; lv_obj_init_draw_rect_dsc(obj, LV_OBJ_PART_MAIN, &draw_dsc); lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_OBJ_PART_MAIN); @@ -3885,7 +3893,7 @@ static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t ali else if(y_set) lv_obj_set_y(obj, new_pos.y); } -static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, +static void obj_align_mid_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set, lv_coord_t x_ofs, lv_coord_t y_ofs) { lv_coord_t new_x = lv_obj_get_x(obj); diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 9815d3b9b..5d10eb3bc 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -162,7 +162,7 @@ typedef struct { lv_coord_t yofs; lv_align_t align; uint8_t auto_realign : 1; - uint8_t origo_align : 1; /**< 1: the origo (center of the object) was aligned with + uint8_t mid_align : 1; /**< 1: the origo (center of the object) was aligned with `lv_obj_align_origo`*/ } lv_realign_t; #endif @@ -494,7 +494,7 @@ void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_ * @param x_ofs x coordinate offset after alignment * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); +void lv_obj_align_mid(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs); /** @@ -504,7 +504,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, * @param align type of alignment (see 'lv_align_t' enum) * @param x_ofs x coordinate offset after alignment */ -void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs); +void lv_obj_align_mid_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs); /** * Align an object's middle point to an other object vertically. @@ -513,7 +513,7 @@ void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig * @param align type of alignment (see 'lv_align_t' enum) * @param y_ofs y coordinate offset after alignment */ -void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs); +void lv_obj_align_mid_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs); /** * Realign the object based on the last `lv_obj_align` parameters. diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index df1debc4d..887c4733b 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -1104,7 +1104,7 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list) { LV_ASSERT_STYLE_LIST(list); - if(list->has_local) return lv_style_list_get_style(list, 0); + if(list->has_local) return lv_style_list_get_style(list, list->has_trans ? 1 : 0); lv_style_t * local_style = lv_mem_alloc(sizeof(lv_style_t)); LV_ASSERT_MEM(local_style); diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index 27f6f1667..bcf94d000 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -65,17 +65,18 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, * @param mask the arc will be drawn only in this mask * @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right) * @param end_angle the end angle of the arc - * @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used) - * @param opa_scale scale down all opacities by the factor + * @param clip_area the arc will be drawn only in this area + * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, - const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc) + const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc) { if(dsc->opa <= LV_OPA_MIN) return; if(dsc->width == 0) return; if(start_angle == end_angle) return; - if(dsc->width > radius) dsc->width = radius; + lv_style_int_t width = dsc->width; + if(width > radius) width = radius; lv_draw_rect_dsc_t cir_dsc; lv_draw_rect_dsc_init(&cir_dsc); @@ -83,7 +84,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin cir_dsc.bg_opa = LV_OPA_TRANSP; cir_dsc.border_opa = dsc->opa; cir_dsc.border_color = dsc->color; - cir_dsc.border_width = dsc->width; + cir_dsc.border_width = width; cir_dsc.border_blend_mode = dsc->blend_mode; lv_area_t area; @@ -123,7 +124,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin q_dsc.end_angle = end_angle; q_dsc.start_quarter = (start_angle / 90) & 0x3; q_dsc.end_quarter = (end_angle / 90) & 0x3; - q_dsc.width = dsc->width; + q_dsc.width = width; q_dsc.draw_dsc = &cir_dsc; q_dsc.draw_area = &area; q_dsc.clip_area = clip_area; @@ -146,7 +147,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin lv_area_t round_area; if(dsc->round_start) { - get_rounded_area(start_angle, radius, dsc->width, &round_area); + get_rounded_area(start_angle, radius, width, &round_area); round_area.x1 += center_x; round_area.x2 += center_x; round_area.y1 += center_y; @@ -156,7 +157,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin } if(dsc->round_end) { - get_rounded_area(end_angle, radius, dsc->width, &round_area); + get_rounded_area(end_angle, radius, width, &round_area); round_area.x1 += center_x; round_area.x2 += center_x; round_area.y1 += center_y; diff --git a/src/lv_draw/lv_draw_arc.h b/src/lv_draw/lv_draw_arc.h index 7e1352eb9..a4b182410 100644 --- a/src/lv_draw/lv_draw_arc.h +++ b/src/lv_draw/lv_draw_arc.h @@ -35,11 +35,11 @@ extern "C" { * @param mask the arc will be drawn only in this mask * @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right) * @param end_angle the end angle of the arc - * @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used) - * @param opa_scale scale down all opacities by the factor + * @param clip_area the arc will be drawn only in this area + * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, - const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc); + const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc); /********************** * MACROS diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index b447d615e..47615724a 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -29,11 +29,11 @@ **********************/ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * clip_area, const void * src, - lv_draw_img_dsc_t * draw_dsc); + const lv_draw_img_dsc_t * draw_dsc); LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p, - lv_draw_img_dsc_t * draw_dsc, + const lv_draw_img_dsc_t * draw_dsc, bool chroma_key, bool alpha_byte); static void show_error(const lv_area_t * coords, const lv_area_t * clip_area, const char * msg); @@ -65,13 +65,9 @@ void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc) * @param coords the coordinates of the image * @param mask the image will be drawn only in this area * @param src pointer to a lv_color_t array which contains the pixels of the image - * @param style style of the image - * @param angle rotation angle of the image - * @param center rotation center of the image - * @param antialias anti-alias transformations (rotate, zoom) or not - * @param opa_scale scale down all opacities by the factor + * @param dsc pointer to an initialized `lv_draw_img_dsc_t` variable */ -void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * dsc) +void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_draw_img_dsc_t * dsc) { if(src == NULL) { LV_LOG_WARN("Image draw: src is NULL"); @@ -232,7 +228,7 @@ lv_img_src_t lv_img_src_get_type(const void * src) LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * clip_area, const void * src, - lv_draw_img_dsc_t * draw_dsc) + const lv_draw_img_dsc_t * draw_dsc) { if(draw_dsc->opa <= LV_OPA_MIN) return LV_RES_OK; @@ -327,18 +323,14 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, * @param cords_p coordinates the color map * @param mask_p the map will drawn only on this area (truncated to VDB area) * @param map_p pointer to a lv_color_t array - * @param opa opacity of the map + * @param draw_dsc pointer to an initialized `lv_draw_img_dsc_t` variable * @param chroma_keyed true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels * @param alpha_byte true: extra alpha byte is inserted for every pixel - * @param style style of the image - * @param angle angle in degree - * @param pivot center of rotation - * @param zoom zoom factor - * @param antialias anti-alias transformations (rotate, zoom) or not */ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, const uint8_t * map_p, - lv_draw_img_dsc_t * draw_dsc, bool chroma_key, bool alpha_byte) + const lv_draw_img_dsc_t * draw_dsc, + bool chroma_key, bool alpha_byte) { /* Use the clip area as draw area*/ lv_area_t draw_area; diff --git a/src/lv_draw/lv_draw_img.h b/src/lv_draw/lv_draw_img.h index 735777684..e4531d725 100644 --- a/src/lv_draw/lv_draw_img.h +++ b/src/lv_draw/lv_draw_img.h @@ -53,13 +53,9 @@ void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc); * @param coords the coordinates of the image * @param mask the image will be drawn only in this area * @param src pointer to a lv_color_t array which contains the pixels of the image - * @param style style of the image - * @param angle rotation angle of the image - * @param center rotation center of the image - * @param antialias anti-alias transformations (rotate, zoom) or not - * @param opa_scale scale down all opacities by the factor + * @param dsc pointer to an initialized `lv_draw_img_dsc_t` variable */ -void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * dsc); +void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_draw_img_dsc_t * dsc); /** * Get the type of an image source diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 1cf8f6320..113393e34 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -111,8 +111,10 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc) * @param hint pointer to a `lv_draw_label_hint_t` variable. * It is managed by the drawer to speed up the drawing of very long texts (thousands of lines). */ -LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_label_dsc_t * dsc, - const char * txt, lv_draw_label_hint_t * hint) +LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, + const lv_draw_label_dsc_t * dsc, + const char * txt, + lv_draw_label_hint_t * hint) { if(dsc->opa <= LV_OPA_MIN) return; @@ -213,12 +215,12 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area sel_start = sel_end; sel_end = tmp; } - lv_draw_line_dsc_t line_dsc; + if((dsc->decor & LV_TEXT_DECOR_UNDERLINE) || (dsc->decor & LV_TEXT_DECOR_STRIKETHROUGH)) { lv_draw_line_dsc_init(&line_dsc); line_dsc.color = dsc->color; - line_dsc.width = (dsc->font->line_height + 5) / 10; /*+5 for rounding*/ + line_dsc.width = font->underline_thickness ? font->underline_thickness : LV_MATH_MAX(font->line_height / 10, 1); line_dsc.opa = dsc->opa; line_dsc.blend_mode = dsc->blend_mode; } @@ -342,7 +344,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area lv_point_t p1; lv_point_t p2; p1.x = pos_x_start; - p1.y = pos.y + dsc->font->line_height - dsc->font->base_line + line_dsc.width / 2 + 1; + p1.y = pos.y + dsc->font->line_height - dsc->font->base_line - font->underline_position; p2.x = pos.x; p2.y = p1.y; lv_draw_line(&p1, &p2, mask, &line_dsc); diff --git a/src/lv_draw/lv_draw_label.h b/src/lv_draw/lv_draw_label.h index a81aeae74..b28381002 100644 --- a/src/lv_draw/lv_draw_label.h +++ b/src/lv_draw/lv_draw_label.h @@ -77,7 +77,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc); * @param hint pointer to a `lv_draw_label_hint_t` variable. * It is managed by the drawer to speed up the drawing of very long texts (thousands of lines). */ -LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_label_dsc_t * dsc, +LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, + const lv_draw_label_dsc_t * dsc, const char * txt, lv_draw_label_hint_t * hint); //! @endcond diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index 2a22ec509..38e29cdfb 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -26,13 +26,13 @@ **********************/ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc); + const lv_draw_line_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc); + const lv_draw_line_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc); + const lv_draw_line_dsc_t * dsc); /********************** * STATIC VARIABLES @@ -58,12 +58,11 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc) * Draw a line * @param point1 first point of the line * @param point2 second point of the line - * @param mask the line will be drawn only on this area - * @param style pointer to a line's style - * @param opa_scale scale down all opacities by the factor + * @param clip the line will be drawn only in this area + * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc) + const lv_draw_line_dsc_t * dsc) { if(dsc->width == 0) return; if(dsc->opa <= LV_OPA_MIN) return; @@ -120,7 +119,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_poin LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc) + const lv_draw_line_dsc_t * dsc) { lv_opa_t opa = dsc->opa; @@ -221,7 +220,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc) + const lv_draw_line_dsc_t * dsc) { lv_opa_t opa = dsc->opa; @@ -316,7 +315,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, - lv_draw_line_dsc_t * dsc) + const lv_draw_line_dsc_t * dsc) { /*Keep the great y in p1*/ lv_point_t p1; diff --git a/src/lv_draw/lv_draw_line.h b/src/lv_draw/lv_draw_line.h index abc2e9819..eb4bbaf58 100644 --- a/src/lv_draw/lv_draw_line.h +++ b/src/lv_draw/lv_draw_line.h @@ -43,12 +43,11 @@ typedef struct { * Draw a line * @param point1 first point of the line * @param point2 second point of the line - * @param mask the line will be drawn only on this area - * @param style pointer to a line's style - * @param opa_scale scale down all opacities by the factor + * @param clip the line will be drawn only in this area + * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ -LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask, - lv_draw_line_dsc_t * dsc); +LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, + const lv_draw_line_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc); diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index f624d99e8..b4ce5a0b4 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -27,21 +27,32 @@ /********************** * STATIC PROTOTYPES **********************/ -LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); +LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, + const lv_draw_rect_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip, - lv_draw_rect_dsc_t * dsc); -static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); -LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i); + const lv_draw_rect_dsc_t * dsc); + +#if LV_USE_OUTLINE + static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc); +#endif #if LV_USE_SHADOW LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, - lv_draw_rect_dsc_t * dsc); + const lv_draw_rect_dsc_t * dsc); LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf, lv_coord_t s, lv_coord_t r); LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups_buf); #endif -static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); -static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc); -static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode); + +#if LV_USE_PATTERN + static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc); +#endif + +#if LV_USE_VALUE_STR + static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc); +#endif +static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, + lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode); +LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(const lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i); /********************** * STATIC VARIABLES @@ -86,9 +97,9 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc) * Draw a rectangle * @param coords the coordinates of the rectangle * @param mask the rectangle will be drawn only in this mask - * @param style pointer to a style + * @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) +void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) { if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return; #if LV_USE_SHADOW @@ -96,10 +107,19 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect #endif draw_bg(coords, clip, dsc); + +#if LV_USE_PATTERN draw_pattern(coords, clip, dsc); +#endif draw_border(coords, clip, dsc); - draw_value(coords, clip, dsc); + +#if LV_USE_VALUE_STR + draw_value_str(coords, clip, dsc); +#endif + +#if LV_USE_OUTLINE draw_outline(coords, clip, dsc); +#endif LV_ASSERT_MEM_INTEGRITY(); } @@ -143,7 +163,8 @@ void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_ * STATIC FUNCTIONS **********************/ -LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) +LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, + const lv_draw_rect_dsc_t * dsc) { if(dsc->bg_opa <= LV_OPA_MIN) return; @@ -365,7 +386,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are } LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip, - lv_draw_rect_dsc_t * dsc) + const lv_draw_rect_dsc_t * dsc) { if(dsc->border_opa <= LV_OPA_MIN) return; if(dsc->border_width == 0) return; @@ -467,8 +488,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv for(h = draw_area.y1; h <= draw_area.y2; h++) { if(normal || - (top_only && fill_area.y1 <= coords->y1 + corner_size) || - (bottom_only && fill_area.y1 >= coords->y2 - corner_size)) { + (top_only && fill_area.y1 <= coords->y1 + corner_size) || + (bottom_only && fill_area.y1 >= coords->y2 - corner_size)) { _lv_memset_ff(mask_buf, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); _lv_blend_fill(clip, &fill_area, color, mask_buf + buf_ofs, mask_res, opa, blend_mode); @@ -483,7 +504,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv } } -LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i) +LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(const lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i) { int32_t min = (dsc->bg_main_color_stop * s) >> 8; if(i <= min) return dsc->bg_color; @@ -500,7 +521,7 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc #if LV_USE_SHADOW LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, - lv_draw_rect_dsc_t * dsc) + const lv_draw_rect_dsc_t * dsc) { /*Check whether the shadow is visible*/ if(dsc->shadow_width == 0) return; @@ -1128,7 +1149,8 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t #endif -static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) +#if LV_USE_OUTLINE +static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) { if(dsc->outline_opa <= LV_OPA_MIN) return; if(dsc->outline_width == 0) return; @@ -1153,10 +1175,13 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr area_outer.y1 -= dsc->outline_width; area_outer.y2 += dsc->outline_width; - draw_full_border(&area_inner, &area_outer, clip, dsc->radius, dsc->outline_color, dsc->outline_opa, dsc->outline_blend_mode); + draw_full_border(&area_inner, &area_outer, clip, dsc->radius, dsc->outline_color, dsc->outline_opa, + dsc->outline_blend_mode); } +#endif -static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) +#if LV_USE_PATTERN +static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) { if(dsc->pattern_image == NULL) return; if(dsc->pattern_opa <= LV_OPA_MIN) return; @@ -1256,9 +1281,11 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr lv_draw_mask_remove_id(radius_mask_id); } } +#endif -static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) +#if LV_USE_VALUE_STR +static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) { if(dsc->value_str == NULL) return; if(dsc->value_opa <= LV_OPA_MIN) return; @@ -1291,8 +1318,10 @@ static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw lv_draw_label(&value_area, clip, &label_dsc, dsc->value_str, NULL); } +#endif -static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode) +static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip, + lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode) { uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); bool simple_mode = true; diff --git a/src/lv_draw/lv_draw_rect.h b/src/lv_draw/lv_draw_rect.h index 3b6dc5bf3..17f4a7248 100644 --- a/src/lv_draw/lv_draw_rect.h +++ b/src/lv_draw/lv_draw_rect.h @@ -92,9 +92,9 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc); * Draw a rectangle * @param coords the coordinates of the rectangle * @param mask the rectangle will be drawn only in this mask - * @param style pointer to a style + * @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, lv_draw_rect_dsc_t * dsc); +void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_draw_rect_dsc_t * dsc); /** * Draw a pixel diff --git a/src/lv_draw/lv_draw_triangle.c b/src/lv_draw/lv_draw_triangle.c index 72a4a7fe2..08bcf6af2 100644 --- a/src/lv_draw/lv_draw_triangle.c +++ b/src/lv_draw/lv_draw_triangle.c @@ -40,7 +40,7 @@ * @param clip_area the triangle will be drawn only in this area * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip_area, lv_draw_rect_dsc_t * draw_dsc) +void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip_area, const lv_draw_rect_dsc_t * draw_dsc) { lv_draw_polygon(points, 3, clip_area, draw_dsc); } @@ -53,7 +53,7 @@ void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip_area, lv * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_area_t * clip_area, - lv_draw_rect_dsc_t * draw_dsc) + const lv_draw_rect_dsc_t * draw_dsc) { if(point_cnt < 3) return; if(points == NULL) return; diff --git a/src/lv_draw/lv_draw_triangle.h b/src/lv_draw/lv_draw_triangle.h index 242ce30f9..64a7b1c81 100644 --- a/src/lv_draw/lv_draw_triangle.h +++ b/src/lv_draw/lv_draw_triangle.h @@ -33,7 +33,7 @@ extern "C" { * @param clip_area the triangle will be drawn only in this area * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ -void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, lv_draw_rect_dsc_t * draw_dsc); +void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, const lv_draw_rect_dsc_t * draw_dsc); /** * Draw a polygon. Only convex polygons are supported. @@ -43,7 +43,7 @@ void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, lv_draw * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_area_t * mask, - lv_draw_rect_dsc_t * draw_dsc); + const lv_draw_rect_dsc_t * draw_dsc); /********************** * MACROS diff --git a/src/lv_draw/lv_img_buf.c b/src/lv_draw/lv_img_buf.c index 8838c32ab..5ddf40577 100644 --- a/src/lv_draw/lv_img_buf.c +++ b/src/lv_draw/lv_img_buf.c @@ -435,6 +435,10 @@ void _lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc) dsc->tmp.sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10; dsc->tmp.cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10; + /*Use smaller value to avoid overflow*/ + dsc->tmp.sinma = dsc->tmp.sinma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); + dsc->tmp.cosma = dsc->tmp.cosma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); + dsc->tmp.chroma_keyed = lv_img_cf_is_chroma_keyed(dsc->cfg.cf) ? 1 : 0; dsc->tmp.has_alpha = lv_img_cf_has_alpha(dsc->cfg.cf) ? 1 : 0; if(dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR || dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR_ALPHA || @@ -468,7 +472,7 @@ void _lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc) * @param pivot x,y pivot coordinates of rotation */ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom, - lv_point_t * pivot) + const lv_point_t * pivot) { #if LV_USE_IMG_TRANSFORM if(angle == 0 && zoom == LV_IMG_ZOOM_NONE) { @@ -493,6 +497,10 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t int32_t sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10; int32_t cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10; + /*Use smaller value to avoid overflow*/ + sinma = sinma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); + cosma = cosma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); + lv_point_t lt; lv_point_t rt; lv_point_t lb; @@ -509,23 +517,23 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t xt = a.x1; yt = a.y1; - lt.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x; - lt.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y; + lt.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; + lt.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; xt = a.x2; yt = a.y1; - rt.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x; - rt.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y; + rt.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; + rt.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; xt = a.x1; yt = a.y2; - lb.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x; - lb.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y; + lb.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; + lb.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; xt = a.x2; yt = a.y2; - rb.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x; - rb.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y; + rb.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; + rb.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; res->x1 = LV_MATH_MIN4(lb.x, lt.x, rb.x, rt.x); res->x2 = LV_MATH_MAX4(lb.x, lt.x, rb.x, rt.x); diff --git a/src/lv_draw/lv_img_buf.h b/src/lv_draw/lv_img_buf.h index 204f3c1d8..d0d3991fc 100644 --- a/src/lv_draw/lv_img_buf.h +++ b/src/lv_draw/lv_img_buf.h @@ -48,6 +48,8 @@ extern "C" { #define LV_IMG_ZOOM_NONE 256 +#define _LV_TRANSFORM_TRIGO_SHIFT 10 + /********************** * TYPEDEFS **********************/ @@ -301,8 +303,8 @@ static inline bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_ int32_t ys; if(dsc->cfg.zoom == LV_IMG_ZOOM_NONE) { /*Get the source pixel from the upscaled image*/ - xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (LV_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256; - ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (LV_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256; + xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256; + ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256; } else if(dsc->cfg.angle == 0) { xt *= dsc->tmp.zoom_inv; @@ -313,8 +315,8 @@ static inline bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_ else { xt *= dsc->tmp.zoom_inv; yt *= dsc->tmp.zoom_inv; - xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (LV_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256; - ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (LV_TRIGO_SHIFT)) + dsc->tmp.pivot_y_256; + xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256; + ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_y_256; } /*Get the integer part of the source pixel*/ @@ -380,7 +382,7 @@ static inline bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_ * @param pivot x,y pivot coordinates of rotation */ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom, - lv_point_t * pivot); + const lv_point_t * pivot); /********************** * MACROS diff --git a/src/lv_draw/lv_img_cache.c b/src/lv_draw/lv_img_cache.c index 8db00b175..cef32144f 100644 --- a/src/lv_draw/lv_img_cache.c +++ b/src/lv_draw/lv_img_cache.c @@ -59,7 +59,7 @@ static uint16_t entry_cnt; * The image will be left open meaning if the image decoder open callback allocated memory then it will remain. * The image is closed if a new image is opened and the new image takes its place in the cache. * @param src source of the image. Path to file or pointer to an `lv_img_dsc_t` variable - * @param style style of the image + * @param color color The color of the image with `LV_IMG_CF_ALPHA_...` * @return pointer to the cache entry or NULL if can open the image */ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color) diff --git a/src/lv_draw/lv_img_cache.h b/src/lv_draw/lv_img_cache.h index 641785f8c..6106aff90 100644 --- a/src/lv_draw/lv_img_cache.h +++ b/src/lv_draw/lv_img_cache.h @@ -46,7 +46,7 @@ typedef struct { * The image will be left open meaning if the image decoder open callback allocated memory then it will remain. * The image is closed if a new image is opened and the new image takes its place in the cache. * @param src source of the image. Path to file or pointer to an `lv_img_dsc_t` variable - * @param style style of the image + * @param color The color of the image with `LV_IMG_CF_ALPHA_...` * @return pointer to the cache entry or NULL if can open the image */ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color); diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index 0c2f67d72..895c064bb 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -114,7 +114,7 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header) * 1) File name: E.g. "S:folder/img1.png" (The drivers needs to registered via `lv_fs_add_drv()`) * 2) Variable: Pointer to an `lv_img_dsc_t` variable * 3) Symbol: E.g. `LV_SYMBOL_OK` - * @param style the style of the image + * @param color The color of the image with `LV_IMG_CF_ALPHA_...` * @return LV_RES_OK: opened the image. `dsc->img_data` and `dsc->header` are set. * LV_RES_INV: none of the registered image decoders were able to open the image. */ @@ -559,7 +559,7 @@ static lv_res_t lv_img_decoder_built_in_line_true_color(lv_img_decoder_dsc_t * d } uint32_t btr = len * (px_size >> 3); uint32_t br = 0; - lv_fs_read(user_data->f, buf, btr, &br); + res = lv_fs_read(user_data->f, buf, btr, &br); if(res != LV_FS_RES_OK || btr != br) { LV_LOG_WARN("Built-in image decoder read failed"); return LV_RES_INV; diff --git a/src/lv_draw/lv_img_decoder.h b/src/lv_draw/lv_img_decoder.h index 980816425..8e3cf2662 100644 --- a/src/lv_draw/lv_img_decoder.h +++ b/src/lv_draw/lv_img_decoder.h @@ -157,7 +157,7 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header); * 1) File name: E.g. "S:folder/img1.png" (The drivers needs to registered via `lv_fs_add_drv()`) * 2) Variable: Pointer to an `lv_img_dsc_t` variable * 3) Symbol: E.g. `LV_SYMBOL_OK` - * @param style the style of the image + * @param color The color of the image with `LV_IMG_CF_ALPHA_...` * @return LV_RES_OK: opened the image. `dsc->img_data` and `dsc->header` are set. * LV_RES_INV: none of the registered image decoders were able to open the image. */ diff --git a/src/lv_font/lv_font.h b/src/lv_font/lv_font.h index 041211acd..b3ecb881c 100644 --- a/src/lv_font/lv_font.h +++ b/src/lv_font/lv_font.h @@ -71,6 +71,10 @@ typedef struct _lv_font_struct { lv_coord_t line_height; /**< The real line height where any text fits*/ lv_coord_t base_line; /**< Base line measured from the top of the line_height*/ uint8_t subpx : 2; /**< An element of `lv_font_subpx_t`*/ + + int8_t underline_position; /**< Distance between the top of the underline and base line (< 0 means below the base line)*/ + int8_t underline_thickness; /**< Thickness of the underline*/ + void * dsc; /**< Store implementation specific or run_time data or caching here*/ #if LV_USE_USER_DATA lv_font_user_data_t user_data; /**< Custom user data for font. */ diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 1b557788c..8268668e6 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -596,19 +596,26 @@ static inline uint8_t lv_color_brightness(lv_color_t color) return (uint8_t)(bright >> 3); } +#ifdef __cplusplus +/* Fix of msvc 2019 compiler error C4576 inside C++ code */ +#define _LV_COLOR_MAKE_TYPE_HELPER lv_color_t +#else +#define _LV_COLOR_MAKE_TYPE_HELPER (lv_color_t) +#endif + /* The most simple macro to create a color from R,G and B values */ #if LV_COLOR_DEPTH == 1 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){.full = (uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))}) +#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{.full = (uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))}) #elif LV_COLOR_DEPTH == 8 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}}) +#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}}) #elif LV_COLOR_DEPTH == 16 #if LV_COLOR_16_SWAP == 0 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x3FU), (uint16_t)((r8 >> 3) & 0x1FU)}}) +#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x3FU), (uint16_t)((r8 >> 3) & 0x1FU)}}) #else -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint16_t)((g8 >> 5) & 0x7U), (uint16_t)((r8 >> 3) & 0x1FU), (uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x7U)}}) +#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint16_t)((g8 >> 5) & 0x7U), (uint16_t)((r8 >> 3) & 0x1FU), (uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x7U)}}) #endif #elif LV_COLOR_DEPTH == 32 -#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/ +#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/ #endif static inline lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b) diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index 8775f39da..7fa3146f8 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -586,6 +586,7 @@ void _lv_mem_buf_free_all(void) } } +#if LV_MEMCPY_MEMSET_STD == 0 /** * Same as `memcpy` but optimized for 4 byte operation. * @param dst pointer to the destination buffer @@ -652,7 +653,6 @@ LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len /** * Same as `memset` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param v value to set [0..255] * @param len number of byte to set @@ -707,7 +707,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len) /** * Same as `memset(dst, 0x00, len)` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param len number of byte to set */ @@ -757,7 +756,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len) /** * Same as `memset(dst, 0xFF, len)` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param len number of byte to set */ @@ -805,6 +803,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len) } } +#endif /*LV_MEMCPY_MEMSET_STD*/ /********************** * STATIC FUNCTIONS diff --git a/src/lv_misc/lv_mem.h b/src/lv_misc/lv_mem.h index 91774133a..f3ca9c6f2 100644 --- a/src/lv_misc/lv_mem.h +++ b/src/lv_misc/lv_mem.h @@ -20,6 +20,10 @@ extern "C" { #include "lv_log.h" #include "lv_types.h" +#if LV_MEMCPY_MEMSET_STD +#include +#endif + /********************* * DEFINES *********************/ @@ -137,6 +141,62 @@ void _lv_mem_buf_free_all(void); //! @cond Doxygen_Suppress +#if LV_MEMCPY_MEMSET_STD + +/** + * Wrapper for the standard memcpy + * @param dst pointer to the destination buffer + * @param src pointer to the source buffer + * @param len number of byte to copy + */ +static inline void * _lv_memcpy(void * dst, const void * src, size_t len) +{ + return memcpy(dst, src, len); +} + +/** + * Wrapper for the standard memcpy + * @param dst pointer to the destination buffer + * @param src pointer to the source buffer + * @param len number of byte to copy + */ +static inline void * _lv_memcpy_small(void * dst, const void * src, size_t len) +{ + return memcpy(dst, src, len); +} + +/** + * Wrapper for the standard memset + * @param dst pointer to the destination buffer + * @param v value to set [0..255] + * @param len number of byte to set + */ +static inline void _lv_memset(void * dst, uint8_t v, size_t len) +{ + memset(dst, v, len); +} + +/** + * Wrapper for the standard memset with fixed 0x00 value + * @param dst pointer to the destination buffer + * @param len number of byte to set + */ +static inline void _lv_memset_00(void * dst, size_t len) +{ + memset(dst, 0x00, len); +} + +/** + * Wrapper for the standard memset with fixed 0xFF value + * @param dst pointer to the destination buffer + * @param len number of byte to set + */ +static inline void _lv_memset_ff(void * dst, size_t len) +{ + memset(dst, 0xFF, len); +} + +#else /** * Same as `memcpy` but optimized for 4 byte operation. * @param dst pointer to the destination buffer @@ -168,7 +228,6 @@ LV_ATTRIBUTE_FAST_MEM static inline void * _lv_memcpy_small(void * dst, const vo /** * Same as `memset` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param v value to set [0..255] * @param len number of byte to set @@ -177,7 +236,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len); /** * Same as `memset(dst, 0x00, len)` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param len number of byte to set */ @@ -185,7 +243,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len); /** * Same as `memset(dst, 0xFF, len)` but optimized for 4 byte operation. - * `dst` should be word aligned else normal `memcpy` will be used * @param dst pointer to the destination buffer * @param len number of byte to set */ @@ -193,6 +250,9 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len); //! @endcond +#endif + + /********************** * MACROS **********************/ diff --git a/src/lv_themes/lv_theme_empty.c b/src/lv_themes/lv_theme_empty.c index 821bbd510..6900ef23c 100644 --- a/src/lv_themes/lv_theme_empty.c +++ b/src/lv_themes/lv_theme_empty.c @@ -95,7 +95,7 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco } -void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) +static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) { LV_UNUSED(th); if(name == LV_THEME_SCR) { diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 893798917..f692b3b66 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -211,7 +211,8 @@ static void basic_init(void) lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG); lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_BORDER); - if((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) == 0)lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, theme.color_primary); + if((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) == 0)lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, + theme.color_primary); lv_style_set_border_color(&styles->bg, LV_STATE_EDITED, theme.color_secondary); lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH); lv_style_set_border_post(&styles->bg, LV_STATE_DEFAULT, true); @@ -619,6 +620,9 @@ static void checkbox_init(void) lv_style_set_radius(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(4)); lv_style_set_pattern_image(&styles->cb_bullet, LV_STATE_CHECKED, LV_SYMBOL_OK); lv_style_set_pattern_recolor(&styles->cb_bullet, LV_STATE_CHECKED, LV_COLOR_WHITE); + lv_style_set_pattern_opa(&styles->cb_bullet, LV_STATE_DEFAULT, LV_OPA_TRANSP); + lv_style_set_pattern_opa(&styles->cb_bullet, LV_STATE_CHECKED, LV_OPA_COVER); + lv_style_set_transition_prop_3(&styles->cb_bullet, LV_STATE_DEFAULT, LV_STYLE_PATTERN_OPA); lv_style_set_text_font(&styles->cb_bullet, LV_STATE_CHECKED, theme.font_small); lv_style_set_pad_left(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3)); lv_style_set_pad_right(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3)); diff --git a/src/lv_widgets/lv_bar.c b/src/lv_widgets/lv_bar.c index f76a2e13f..c30da9f01 100644 --- a/src/lv_widgets/lv_bar.c +++ b/src/lv_widgets/lv_bar.c @@ -395,7 +395,9 @@ static lv_design_res_t lv_bar_design(lv_obj_t * bar, const lv_area_t * clip_area lv_draw_rect_dsc_init(&draw_dsc); draw_dsc.bg_opa = LV_OPA_TRANSP; draw_dsc.pattern_opa = LV_OPA_TRANSP; + draw_dsc.outline_opa = LV_OPA_TRANSP; draw_dsc.shadow_opa = LV_OPA_TRANSP; + draw_dsc.value_opa = LV_OPA_TRANSP; lv_obj_init_draw_rect_dsc(bar, LV_OBJ_PART_MAIN, &draw_dsc); lv_draw_rect(&bar->coords, clip_area, &draw_dsc); @@ -414,6 +416,8 @@ static void draw_bg(lv_obj_t * bar, const lv_area_t * clip_area) draw_dsc.border_opa = LV_OPA_TRANSP; } + /*value will be drawn later*/ + draw_dsc.value_opa = LV_OPA_TRANSP; lv_obj_init_draw_rect_dsc(bar, LV_BAR_PART_BG, &draw_dsc); lv_draw_rect(&bar->coords, clip_area, &draw_dsc); diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 1f2cd6675..842d6421b 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -706,7 +706,8 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl if(btn_state == LV_STATE_DEFAULT) { draw_rect_dsc_act = &draw_rect_rel_dsc; draw_label_dsc_act = &draw_label_rel_dsc; - } else if(btn_state == LV_STATE_CHECKED) { + } + else if(btn_state == LV_STATE_CHECKED) { if(!chk_inited) { btnm->state = LV_STATE_CHECKED; lv_draw_rect_dsc_init(&draw_rect_chk_dsc); @@ -719,7 +720,8 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl } draw_rect_dsc_act = &draw_rect_chk_dsc; draw_label_dsc_act = &draw_label_chk_dsc; - } else if(btn_state == LV_STATE_CHECKED) { + } + else if(btn_state == LV_STATE_CHECKED) { if(!disabled_inited) { btnm->state = LV_STATE_DISABLED; lv_draw_rect_dsc_init(&draw_rect_ina_dsc); diff --git a/src/lv_widgets/lv_canvas.c b/src/lv_widgets/lv_canvas.c index 70571b903..14fb5e023 100644 --- a/src/lv_widgets/lv_canvas.c +++ b/src/lv_widgets/lv_canvas.c @@ -657,6 +657,7 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r) * Fill the canvas with color * @param canvas pointer to a canvas * @param color the background color + * @param opa the desired opacity */ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa) { @@ -694,10 +695,10 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa) * @param y top coordinate of the rectangle * @param w width of the rectangle * @param h height of the rectangle - * @param style style of the rectangle (`body` properties are used except `padding`) + * @param rect_dsc descriptor of the rectangle */ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, - lv_draw_rect_dsc_t * rect_dsc) + const lv_draw_rect_dsc_t * rect_dsc) { LV_ASSERT_OBJ(canvas, LV_OBJX_NAME); @@ -763,7 +764,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord * @param x left coordinate of the text * @param y top coordinate of the text * @param max_w max width of the text. The text will be wrapped to fit into this size - * @param style style of the text (`text` properties are used) + * @param label_draw_dsc pointer to a valid label descriptor `lv_draw_label_dsc_t` * @param txt text to display * @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`) */ @@ -841,10 +842,10 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord * Draw an image on the canvas * @param canvas pointer to a canvas object * @param src image source. Can be a pointer an `lv_img_dsc_t` variable or a path an image. - * @param style style of the image (`image` properties are used) + * @param img_draw_dsc pointer to a valid label descriptor `lv_draw_img_dsc_t` */ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, - lv_draw_img_dsc_t * img_draw_dsc) + const lv_draw_img_dsc_t * img_draw_dsc) { LV_ASSERT_OBJ(canvas, LV_OBJX_NAME); @@ -906,10 +907,10 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi * @param canvas pointer to a canvas object * @param points point of the line * @param point_cnt number of points - * @param style style of the line (`line` properties are used) + * @param line_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, - lv_draw_line_dsc_t * line_draw_dsc) + const lv_draw_line_dsc_t * line_draw_dsc) { LV_ASSERT_OBJ(canvas, LV_OBJX_NAME); @@ -969,10 +970,10 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t * @param canvas pointer to a canvas object * @param points point of the polygon * @param point_cnt number of points - * @param style style of the polygon (`body.main_color` and `body.opa` is used) + * @param poly_draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, - lv_draw_rect_dsc_t * poly_draw_dsc) + const lv_draw_rect_dsc_t * poly_draw_dsc) { LV_ASSERT_OBJ(canvas, LV_OBJX_NAME); @@ -1033,10 +1034,10 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32 * @param r radius of the arc * @param start_angle start angle in degrees * @param end_angle end angle in degrees - * @param style style of the polygon (`body.main_color` and `body.opa` is used) + * @param arc_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle, - int32_t end_angle, lv_draw_line_dsc_t * arc_draw_dsc) + int32_t end_angle, const lv_draw_line_dsc_t * arc_draw_dsc) { LV_ASSERT_OBJ(canvas, LV_OBJX_NAME); diff --git a/src/lv_widgets/lv_canvas.h b/src/lv_widgets/lv_canvas.h index ce4cca2f7..de1a26bf4 100644 --- a/src/lv_widgets/lv_canvas.h +++ b/src/lv_widgets/lv_canvas.h @@ -153,6 +153,7 @@ void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, u /** * Apply horizontal blur on the canvas * @param canvas pointer to a canvas object + * @param area the area to blur. If `NULL` the whole canvas will be blurred. * @param r radius of the blur */ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r); @@ -169,6 +170,7 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r); * Fill the canvas with color * @param canvas pointer to a canvas * @param color the background color + * @param opa the desired opacity */ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa); @@ -179,10 +181,10 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa); * @param y top coordinate of the rectangle * @param w width of the rectangle * @param h height of the rectangle - * @param style style of the rectangle (`body` properties are used except `padding`) + * @param rect_dsc descriptor of the rectangle */ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, - lv_draw_rect_dsc_t * rect_dsc); + const lv_draw_rect_dsc_t * rect_dsc); /** * Draw a text on the canvas. @@ -190,7 +192,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord * @param x left coordinate of the text * @param y top coordinate of the text * @param max_w max width of the text. The text will be wrapped to fit into this size - * @param style style of the text (`text` properties are used) + * @param label_draw_dsc pointer to a valid label descriptor `lv_draw_label_dsc_t` * @param txt text to display * @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`) */ @@ -201,31 +203,33 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord /** * Draw an image on the canvas * @param canvas pointer to a canvas object + * @param x left coordinate of the image + * @param y top coordinate of the image * @param src image source. Can be a pointer an `lv_img_dsc_t` variable or a path an image. - * @param style style of the image (`image` properties are used) + * @param img_draw_dsc pointer to a valid label descriptor `lv_draw_img_dsc_t` */ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, - lv_draw_img_dsc_t * img_draw_dsc); + const lv_draw_img_dsc_t * img_draw_dsc); /** * Draw a line on the canvas * @param canvas pointer to a canvas object * @param points point of the line * @param point_cnt number of points - * @param style style of the line (`line` properties are used) + * @param line_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, - lv_draw_line_dsc_t * line_draw_dsc); + const lv_draw_line_dsc_t * line_draw_dsc); /** * Draw a polygon on the canvas * @param canvas pointer to a canvas object * @param points point of the polygon * @param point_cnt number of points - * @param style style of the polygon (`body.main_color` and `body.opa` is used) + * @param poly_draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable */ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, - lv_draw_rect_dsc_t * poly_draw_dsc); + const lv_draw_rect_dsc_t * poly_draw_dsc); /** * Draw an arc on the canvas @@ -235,10 +239,10 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32 * @param r radius of the arc * @param start_angle start angle in degrees * @param end_angle end angle in degrees - * @param style style of the polygon (`body.main_color` and `body.opa` is used) + * @param arc_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable */ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle, - int32_t end_angle, lv_draw_line_dsc_t * arc_draw_dsc); + int32_t end_angle, const lv_draw_line_dsc_t * arc_draw_dsc); /********************** * MACROS diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index d7308cf88..c77ecd858 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -207,23 +207,23 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color) /** * Clear the point of a series * @param chart pointer to a chart object - * @param serie pointer to the chart's series to clear + * @param series pointer to the chart's series to clear */ -void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie) +void lv_chart_clear_series(lv_obj_t * chart, lv_chart_series_t * series) { LV_ASSERT_OBJ(chart, LV_OBJX_NAME); - LV_ASSERT_NULL(serie); + LV_ASSERT_NULL(series); - if(chart == NULL || serie == NULL) return; + if(chart == NULL || series == NULL) return; lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); if(ext == NULL) return; uint32_t i; for(i = 0; i < ext->point_cnt; i++) { - serie->points[i] = LV_CHART_POINT_DEF; + series->points[i] = LV_CHART_POINT_DEF; } - serie->start_point = 0; + series->start_point = 0; } /*===================== diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index e35c696c7..6f3deed8d 100644 --- a/src/lv_widgets/lv_chart.h +++ b/src/lv_widgets/lv_chart.h @@ -139,9 +139,9 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color); /** * Clear the point of a series * @param chart pointer to a chart object - * @param serie pointer to the chart's series to clear + * @param series pointer to the chart's series to clear */ -void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie); +void lv_chart_clear_series(lv_obj_t * chart, lv_chart_series_t * series); /*===================== * Setter functions diff --git a/src/lv_widgets/lv_cpicker.c b/src/lv_widgets/lv_cpicker.c index db682092a..552b171e4 100644 --- a/src/lv_widgets/lv_cpicker.c +++ b/src/lv_widgets/lv_cpicker.c @@ -492,7 +492,7 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask) /* Mask outer ring of widget to tidy up ragged edges of lines while drawing outer ring */ lv_area_t mask_area_out; - lv_area_copy( &mask_area_out, &cpicker->coords); + lv_area_copy(&mask_area_out, &cpicker->coords); mask_area_out.x1 += OUTER_MASK_WIDTH; mask_area_out.x2 -= OUTER_MASK_WIDTH; mask_area_out.y1 += OUTER_MASK_WIDTH; diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 6c6f65791..aaeb59d5c 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -578,7 +578,7 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area int32_t angle_final = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); angle_final += ext->angle; - if(angle_final == 0) return LV_DESIGN_RES_NOT_COVER; + if(angle_final != 0) return LV_DESIGN_RES_NOT_COVER; int32_t zoom_final = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN); zoom_final = (zoom_final * ext->zoom) >> 8; @@ -620,8 +620,6 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area int32_t zoom_final = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN); zoom_final = (zoom_final * ext->zoom) >> 8; - if(zoom_final == 0) return LV_DESIGN_RES_OK; - int32_t angle_final = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); angle_final += ext->angle; @@ -639,6 +637,8 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area lv_draw_rect(&bg_coords, clip_area, &bg_dsc); + if(zoom_final == 0) return LV_DESIGN_RES_OK; + if(lv_obj_get_style_clip_corner(img, LV_OBJ_PART_MAIN)) { lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); @@ -705,15 +705,33 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area _lv_mem_buf_release(param); } - lv_draw_rect_dsc_t draw_dsc; - lv_draw_rect_dsc_init(&draw_dsc); - /*If the border is drawn later disable loading other properties*/ if(lv_obj_get_style_border_post(img, LV_OBJ_PART_MAIN)) { + lv_draw_rect_dsc_t draw_dsc; + lv_draw_rect_dsc_init(&draw_dsc); draw_dsc.bg_opa = LV_OPA_TRANSP; draw_dsc.pattern_opa = LV_OPA_TRANSP; draw_dsc.shadow_opa = LV_OPA_TRANSP; lv_obj_init_draw_rect_dsc(img, LV_OBJ_PART_MAIN, &draw_dsc); + + int32_t zoom_final = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN); + zoom_final = (zoom_final * ext->zoom) >> 8; + + int32_t angle_final = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN); + angle_final += ext->angle; + + lv_area_t bg_coords; + _lv_img_buf_get_transformed_area(&bg_coords, lv_area_get_width(&img->coords), lv_area_get_height(&img->coords), + angle_final, zoom_final, &ext->pivot); + bg_coords.x1 += img->coords.x1; + bg_coords.y1 += img->coords.y1; + bg_coords.x2 += img->coords.x1; + bg_coords.y2 += img->coords.y1; + bg_coords.x1 -= lv_obj_get_style_pad_left(img, LV_IMG_PART_MAIN); + bg_coords.x2 += lv_obj_get_style_pad_right(img, LV_IMG_PART_MAIN); + bg_coords.y1 -= lv_obj_get_style_pad_top(img, LV_IMG_PART_MAIN); + bg_coords.y2 += lv_obj_get_style_pad_bottom(img, LV_IMG_PART_MAIN); + lv_draw_rect(&img->coords, clip_area, &draw_dsc); } } diff --git a/src/lv_widgets/lv_imgbtn.c b/src/lv_widgets/lv_imgbtn.c index 1c37d92a9..5cdc8e15a 100644 --- a/src/lv_widgets/lv_imgbtn.c +++ b/src/lv_widgets/lv_imgbtn.c @@ -273,7 +273,38 @@ static lv_design_res_t lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * cli } /*Draw the object*/ else if(mode == LV_DESIGN_DRAW_MAIN) { - ancestor_design(imgbtn, clip_area, mode); + lv_area_t img_coords; + + lv_obj_get_coords(imgbtn, &img_coords); + + lv_draw_rect_dsc_t bg_dsc; + lv_draw_rect_dsc_init(&bg_dsc); + lv_obj_init_draw_rect_dsc(imgbtn, LV_IMGBTN_PART_MAIN, &bg_dsc); + + /*If the border is drawn later disable loading its properties*/ + if(lv_obj_get_style_border_post(imgbtn, LV_OBJ_PART_MAIN)) { + bg_dsc.border_opa = LV_OPA_TRANSP; + } + + lv_area_t bg_coords; + lv_area_copy(&bg_coords, &img_coords); + bg_coords.x1 -= lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.x2 += lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.y1 -= lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.y2 += lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN); + + lv_draw_rect(&bg_coords, clip_area, &bg_dsc); + + if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) { + lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); + + lv_coord_t r = lv_obj_get_style_radius(imgbtn, LV_OBJ_PART_MAIN); + + lv_draw_mask_radius_init(mp, &bg_coords, r, false); + /*Add the mask and use `img+8` as custom id. Don't use `obj` directly because it might be used by the user*/ + lv_draw_mask_add(mp, imgbtn + 8); + } + /*Just draw an image*/ lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); lv_btn_state_t state = lv_imgbtn_get_state(imgbtn); @@ -374,6 +405,31 @@ static lv_design_res_t lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * cli } /*Post draw when the children are drawn*/ else if(mode == LV_DESIGN_DRAW_POST) { + if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) { + lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(imgbtn + 8); + _lv_mem_buf_release(param); + } + + lv_draw_rect_dsc_t draw_dsc; + lv_draw_rect_dsc_init(&draw_dsc); + + /*If the border is drawn later disable loading other properties*/ + if(lv_obj_get_style_border_post(imgbtn, LV_OBJ_PART_MAIN)) { + draw_dsc.bg_opa = LV_OPA_TRANSP; + draw_dsc.pattern_opa = LV_OPA_TRANSP; + draw_dsc.shadow_opa = LV_OPA_TRANSP; + lv_obj_init_draw_rect_dsc(imgbtn, LV_OBJ_PART_MAIN, &draw_dsc); + + + lv_area_t bg_coords; + lv_area_copy(&bg_coords, &imgbtn->coords); + bg_coords.x1 -= lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.x2 += lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.y1 -= lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN); + bg_coords.y2 += lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN); + + lv_draw_rect(&bg_coords, clip_area, &draw_dsc); + } } return LV_DESIGN_RES_OK; @@ -400,6 +456,18 @@ static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * par * changed as well Set the new image for the new state.*/ refr_img(imgbtn); } + else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { + /*Handle the padding of the background*/ + lv_style_int_t left = lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN); + lv_style_int_t right = lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN); + lv_style_int_t top = lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN); + lv_style_int_t bottom = lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN); + + imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, left); + imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, right); + imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, top); + imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, bottom); + } else if(sign == LV_SIGNAL_CLEANUP) { /*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/ } diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index c8e7ae724..0de65871c 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -392,15 +392,15 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin lv_coord_t x_ofs = lmeter->coords.x1 + r_out + left; lv_coord_t y_ofs = lmeter->coords.y1 + r_out + top; int16_t angle_ofs = ext->angle_ofs + 90 + (360 - ext->scale_angle) / 2; - int16_t level = - (int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); + int16_t level = ext->mirrored ? + (int32_t)((int32_t)(ext->max_value - ext->cur_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value) : + (int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); uint8_t i; lv_color_t main_color = lv_obj_get_style_line_color(lmeter, part); lv_color_t grad_color = lv_obj_get_style_scale_grad_color(lmeter, part); lv_color_t end_color = lv_obj_get_style_scale_end_color(lmeter, part); - lv_draw_line_dsc_t line_dsc; lv_draw_line_dsc_init(&line_dsc); lv_obj_init_draw_line_dsc(lmeter, part, &line_dsc); @@ -520,11 +520,10 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin p1.y = y_out_extra; /* Set the color of the lines */ - if(i > level) { + if((!ext->mirrored && i >= level) || (ext->mirrored && i <= level)) { line_dsc.color = end_color; line_dsc.width = end_line_width; - } - else { + } else { line_dsc.color = lv_color_mix(grad_color, main_color, (255 * i) / ext->line_cnt); } diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index acb165a81..ecda79c9b 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -365,11 +365,11 @@ lv_obj_t * lv_list_get_btn_label(const lv_obj_t * btn) { LV_ASSERT_OBJ(btn, "lv_btn"); - lv_obj_t * label = lv_obj_get_child(btn, NULL); + lv_obj_t * label = lv_obj_get_child_back(btn, NULL); if(label == NULL) return NULL; while(lv_list_is_list_label(label) == false) { - label = lv_obj_get_child(btn, label); + label = lv_obj_get_child_back(btn, label); if(label == NULL) break; } @@ -386,11 +386,11 @@ lv_obj_t * lv_list_get_btn_img(const lv_obj_t * btn) LV_ASSERT_OBJ(btn, "lv_btn"); #if LV_USE_IMG != 0 - lv_obj_t * img = lv_obj_get_child(btn, NULL); + lv_obj_t * img = lv_obj_get_child_back(btn, NULL); if(img == NULL) return NULL; while(lv_list_is_list_img(img) == false) { - img = lv_obj_get_child(btn, img); + img = lv_obj_get_child_back(btn, img); if(img == NULL) break; } diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 726e404d8..7be8f456f 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -495,14 +495,14 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_ lv_coord_t scrlable_y = lv_obj_get_y(ext->scrl); lv_coord_t page_h = lv_obj_get_height(page); - lv_coord_t top_err = -(scrlable_y + obj_y); - lv_coord_t bot_err = scrlable_y + obj_y + obj_h - page_h; - lv_style_int_t bg_top = lv_obj_get_style_pad_top(page, LV_PAGE_PART_BG); lv_style_int_t bg_bottom = lv_obj_get_style_pad_bottom(page, LV_PAGE_PART_BG); lv_style_int_t scrl_top = lv_obj_get_style_pad_top(ext->scrl, LV_CONT_PART_MAIN); lv_style_int_t scrl_bottom = lv_obj_get_style_pad_bottom(ext->scrl, LV_CONT_PART_MAIN); + lv_coord_t top_err = -((scrlable_y + obj_y) - bg_top); + lv_coord_t bot_err = scrlable_y + obj_y + obj_h - (page_h - bg_bottom); + /*Out of the page on the top*/ if((obj_h <= page_h && top_err > 0) || (obj_h > page_h && top_err < bot_err)) { /*Calculate a new position and let some space above*/ @@ -524,14 +524,14 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_ lv_coord_t scrlable_x = lv_obj_get_x(ext->scrl); lv_coord_t page_w = lv_obj_get_width(page); - lv_coord_t left_err = -(scrlable_x + obj_x); - lv_coord_t right_err = scrlable_x + obj_x + obj_w - page_w; - lv_style_int_t bg_left = lv_obj_get_style_pad_left(page, LV_PAGE_PART_BG); lv_style_int_t bg_right = lv_obj_get_style_pad_right(page, LV_PAGE_PART_BG); lv_style_int_t scrl_left = lv_obj_get_style_pad_top(ext->scrl, LV_CONT_PART_MAIN); lv_style_int_t scrl_right = lv_obj_get_style_pad_bottom(ext->scrl, LV_CONT_PART_MAIN); + lv_coord_t left_err = -((scrlable_x + obj_x) - bg_left); + lv_coord_t right_err = scrlable_x + obj_x + obj_w - (page_w - bg_right); + /*Out of the page on the left*/ if((obj_w <= page_w && left_err > 0) || (obj_w > page_w && left_err < right_err)) { /*Calculate a new position and let some space on the side*/ diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index 475a3f427..0e35e3798 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -440,28 +440,27 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an * @param id index of the tab the name should be set * @param name new tab name */ -void lv_tabview_set_tab_name(lv_obj_t *tabview, uint16_t id, char *name) +void lv_tabview_set_tab_name(lv_obj_t * tabview, uint16_t id, char * name) { - LV_ASSERT_OBJ(tabview, LV_OBJX_NAME); + LV_ASSERT_OBJ(tabview, LV_OBJX_NAME); - /* get tabview's ext pointer which contains the tab name pointer list */ - lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview); + /* get tabview's ext pointer which contains the tab name pointer list */ + lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview); - /* check for valid tab index */ - if (ext->tab_cnt > id) - { - /* reallocate memory for new tab name (use reallocate due to mostly the size didn't change much) */ - char *str = lv_mem_realloc((void *)ext->tab_name_ptr[id], strlen(name) + 1); - LV_ASSERT_MEM(str); + /* check for valid tab index */ + if(ext->tab_cnt > id) { + /* reallocate memory for new tab name (use reallocate due to mostly the size didn't change much) */ + char * str = lv_mem_realloc((void *)ext->tab_name_ptr[id], strlen(name) + 1); + LV_ASSERT_MEM(str); - /* store new tab name at allocated memory */ - strcpy(str, name); - /* update pointer */ - ext->tab_name_ptr[id] = str; + /* store new tab name at allocated memory */ + strcpy(str, name); + /* update pointer */ + ext->tab_name_ptr[id] = str; - /* force redrawing of the tab headers */ - lv_obj_invalidate(ext->btns); - } + /* force redrawing of the tab headers */ + lv_obj_invalidate(ext->btns); + } } /** diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index c82870bf1..da622df65 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -246,7 +246,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) lv_res_t res = insert_handler(ta, letter_buf); if(res != LV_RES_OK) return; - + if(ext->one_line && (c == '\n' || c == '\r')) { LV_LOG_INFO("Text area: line break ignored in one-line mode"); return; @@ -259,7 +259,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) "accepted list)"); return; } - + /*If a new line was added it shouldn't show edge flash effect*/ bool edge_flash_en = lv_textarea_get_edge_flash(ta); @@ -337,7 +337,7 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt) } return; } - + lv_res_t res = insert_handler(ta, txt); if(res != LV_RES_OK) return;