diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 9c6d3af73..1b34d7088 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -custom: ["https://littlevgl.com/donate"] +custom: ["https://www.paypal.com/paypalme/my/profile"] diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a11e0bd8..62fc6fec0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,42 @@ # Changelog -## v7.3.0 (planned on 04.08.2020) -Available in the `dev` branch +## v7.4.0 (planned on 01.09.2020) +*Available in the `dev` branch* + +## 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 + +## v7.3.0 (04.08.2020) ### New features - Add `lv_task_get_next` -- Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive`, `lv_event_queue_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object +- Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object +- 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`, `LV_FONT_USE_SUBPX`, `LV_USE_OUTLINE`, `LV_USE_PATTERN`, `LV_USE_VALUE_STR` and applying some optimization +- Add `LV_MEMCPY_MEMSET_STD` to use standard `memcpy` and `memset` -## v7.2.0 (planned on 21.07.2020) -*Available in the `master` branch* + +### Bugfixes +- Do not print warning for missing glyph if its height OR width is zero. +- Prevent duplicated sending of `LV_EVENT_INSERT` from text area +- Tidy outer edges of cpicker widget. +- Remove duplicated lines from `lv_tabview_add_tab` +- btnmatrix: hadle combined states of buttons (e.g. chacked + disabled) +- textarea: fix typo in lv_textarea_set_sscrollbar_mode +- gauge: fix image needle drawing +- fix using freed memory in _lv_style_list_remove_style + + +## v7.2.0 (21.07.2020) ### New features +- Add screen transitions with `lv_scr_load_anim()` +- Add display background color, wallpaper and opacity. Shown when the screen is transparent. Can be used with `lv_disp_set_bg_opa/color/image()`. - Add `LV_CALENDAR_WEEK_STARTS_MONDAY` - Add `lv_chart_set_x_start_point()` function - Set the index of the x-axis start point in the data array - Add `lv_chart_set_ext_array()` function - Set an external array of data points to use for the chart @@ -29,6 +55,10 @@ Available in the `dev` branch ### Bugfixes - `tileview` fix navigation when not screen sized - Use 14px font by default to for better compatibility with smaller displays +- `linemeter` fix conversation of current value to "level" +- Fix drawing on right border +- Set the cursor image non clickable by default +- Improve mono theme when used with keyboard or encoder ## v7.1.0 (07.07.2020) diff --git a/README.md b/README.md index 9ee6eb709..af3a4cde5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,4 @@

LVGL - Light and Versatile Graphics Library

-

- - -

@@ -16,65 +12,107 @@ LVGL provides everything you need to create embedded GUI with easy-to-use graphi Website · Online demo · Docs · -Forum · +Forum --- ## Features -* Powerful building blocks: buttons, charts, lists, sliders, images, etc. +* Powerful [building blocks](https://docs.lvgl.io/latest/en/html/widgets/index.html): buttons, charts, lists, sliders, images, etc. * Advanced graphics: animations, anti-aliasing, opacity, smooth scrolling -* Simultaneously use various input devices: touchscreen, mouse, keyboard, encoder, buttons, etc. -* Simultaneously use multiple displays: e.g. monochrome and color display -* Multi-language support with UTF-8 encoding, Bidirectional support, and Arabic text handling -* Fully customizable graphical elements via CSS-like styles +* Use [various input devices](https://docs.lvgl.io/latest/en/html/overview/indev.html): touchscreen, mouse, keyboard, encoder, buttons, etc. +* Use [multiple displays](https://docs.lvgl.io/latest/en/html/overview/display.html): e.g. monochrome and color display * Hardware independent to use with any microcontroller or display * Scalable to operate with little memory (64 kB Flash, 10 kB RAM) +* Multi-language support with UTF-8 handling, Bidirectional and Arabic script support +* Fully customizable graphical elements via [CSS-like styles](https://docs.lvgl.io/latest/en/html/overview/style.html) * OS, External memory and GPU are supported but not required -* Single frame buffer operation even with advances graphical effects +* Smooth rendering even with a [single frame buffer](https://docs.lvgl.io/latest/en/html/porting/display.html) * Written in C for maximal compatibility (C++ compatible) * Micropython Binding exposes [LVGL API in Micropython](https://blog.lvgl.io/2019-02-20/micropython-bindings) -* Simulator to develop on PC without embedded hardware -* Tutorials, examples, themes for rapid development -* Documentation and API references +* [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) to develop on PC without embedded hardware +* [Examples](lv_examples) and tutorials for rapid development +* [Documentation](http://docs.lvgl.io/) and API references -## Supported devices +## Requirements Basically, every modern controller (which is able to drive a display) is suitable to run LVGL. The minimal requirements are: -- 16, 32 or 64 bit microcontroller or processor -- > 16 MHz clock speed is recommended -- Flash/ROM: > 64 kB for the very essential components (> 180 kB is recommended) -- RAM: - - Static RAM usage: ~2 kB depending on the used features and objects types - - Stack: > 2kB (> 8 kB is recommended) - - Dynamic data (heap): > 2 KB (> 16 kB is recommended if using several objects). - Set by `LV_MEM_SIZE` in *lv_conf.h*. - - Display buffer: > *"Horizontal resolution"* pixels (> 10 × *"Horizontal resolution"* is recommended) -- C99 or newer compiler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name MinimalRecommended
Architecture16, 32 or 64 bit microcontroller or processor
Clock > 16 MHz > 48 MHz
Flash/ROM > 64 kB > 180 kB
Static RAM > 2 kB > 4 kB
Stack > 2 kB > 8 kB
Heap > 2 kB > 8 kB
Display buffer > 1 × hor. res. pixels > 10 × hor. res. pixels
Compiler C99 or newer
*Note that the memory usage might vary depending on the architecture, compiler and build options.* Just to mention some platforms: -- STM32F1, STM32F3, [STM32F4](https://blog.lvgl.io/2017-07-15/stm32f429_disco_port), [STM32F7](https://github.com/lvgl/lv_port_stm32f746_disco_sw4stm32), STM32L4 +- STM32F1, STM32F3, STM32F4, STM32F7, STM32L4, STM32L5, STM32H7 - Microchip dsPIC33, PIC24, PIC32MX, PIC32MZ - NXP: Kinetis, LPC, iMX, iMX RT - [Linux frame buffer](https://blog.lvgl.io/2018-01-03/linux_fb) (/dev/fb) -- [Raspberry PI](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl) +- [Raspberry Pi](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl) - [Espressif ESP32](https://github.com/lvgl/lv_port_esp32) -- [Infineon aurix](https://github.com/lvgl/lv_port_aurix) -- Nordic NRF52 -- Quectell M66 +- [Infineon Aurix](https://github.com/lvgl/lv_port_aurix) +- Nordic NRF52 Bluetooth modules +- Quectel modems ## Get started -his list shows the recommended way of learning the library: +This list shows the recommended way of learning the library: 1. Check the [Online demos](https://lvgl.io/demos) to see LVGL in action (3 minutes) 2. Read the [Introduction](https://docs.lvgl.io/latest/en/html/intro/index.html) page of the documentation (5 minutes) -3. Read the [Quick overview](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html) page of the documentation (15 minutes) +3. Get familiar with the basics on the [Quick overview](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html) page (15 minutes) 4. Set up a [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) (10 minutes) 5. Try out some [Examples](https://github.com/lvgl/lv_examples/) 6. Port LVGL to a board. See the [Porting](https://docs.lvgl.io/latest/en/html/porting/index.html) guide or check the ready to use [Projects](https://github.com/lvgl?q=lv_port_&type=&language=) -7. Read the [Overview](https://docs.lvgl.io/latest/en/html/overview/index.html) page to get a better understanding of the library. (2-3 hours) +7. Read the [Overview](https://docs.lvgl.io/latest/en/html/overview/index.html) page to get a better understanding of the library (2-3 hours) 8. Check the documentation of the [Widgets](https://docs.lvgl.io/latest/en/html/widgets/index.html) to see their features and usage -9. If you have questions got to the [Forum](http://forum.lvgl.io/) +9. If you have questions go to the [Forum](http://forum.lvgl.io/) 10. Read the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) guide to see how you can help to improve LVGL (15 minutes) ## Examples @@ -103,7 +141,7 @@ void btn_event_cb(lv_obj_t * btn, lv_event_t event) ![LVGL button with label example](https://raw.githubusercontent.com/lvgl/docs/latest/misc/simple_button_example.gif) ### LVGL from Micropython -Learn more about [Micropython](https://docs.lvgl.io/en/html/get-started/micropython). +Learn more about [Micropython](https://docs.lvgl.io/latest/en/html/get-started/micropython.html). ```python # Create a Button and a Label scr = lv.obj() @@ -117,4 +155,6 @@ lv.scr_load(scr) ``` ## Contributing +LVGL is an open project and contribution is very welcome. There are many ways to contribute from simply speaking about your project, through writing examples, improving the documentation, fixing bugs to hosing your own project under in LVGL. + For a detailed description of contribution opportunities visit the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) section of the documentation. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md new file mode 100644 index 000000000..5affba5f7 --- /dev/null +++ b/docs/ROADMAP.md @@ -0,0 +1,35 @@ +# Roadmap + +This is a summary for thenew fatures of the major releases and a collection of ideas. + +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. + - 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) + - Remove `lv_drag`. Similar effect can be achieved by setting the position in `LV_EVENT_PRESSING` + - Add snapping? + - Already working +- New layouts: + - See [#1615](https://github.com/lvgl/lvgl/issues/1615) issue + - [CSS Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)-like layout support + - Besides setting width/height in `px` add support to `partent percentage` and `screen percentage`. + - Work in progress +- Simplified File system interface ([feat/new_fs_api](https://github.com/lvgl/lvgl/tree/feat/new-fs-api) branch) to make porting easier + - Work in progress +- Add new label alignment modes + - See [#1656](https://github.com/lvgl/lvgl/issues/1656) + +## 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 ed34d7fff..6cb9ab8b3 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "lvgl", - "version": "v7.1.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 36a55ee15..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.1.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 @@ -391,11 +404,20 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i * but with > 10,000 characters if you see issues probably you need to enable it.*/ #define LV_FONT_FMT_TXT_LARGE 0 +/* Enables/disables support for compressed fonts. If it's disabled, compressed + * glyphs cannot be processed by the library and won't be rendered. + */ +#define LV_USE_FONT_COMPRESSED 1 + +/* Enable subpixel rendering */ +#define LV_USE_FONT_SUBPX 1 +#if LV_USE_FONT_SUBPX /* Set the pixel order of the display. * Important only if "subpx fonts" are used. * With "normal" font it doesn't matter. */ #define LV_FONT_SUBPX_BGR 0 +#endif /*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/ typedef void * lv_font_user_data_t; @@ -417,7 +439,10 @@ typedef void * lv_font_user_data_t; /* 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) + * */ #define LV_USE_THEME_MATERIAL 1 /* Mono-color theme for monochrome displays. diff --git a/lvgl.h b/lvgl.h index f90729d7b..bc3c00c70 100644 --- a/lvgl.h +++ b/lvgl.h @@ -78,7 +78,7 @@ extern "C" { /*Current version of LVGL*/ #define LVGL_VERSION_MAJOR 7 #define LVGL_VERSION_MINOR 3 -#define LVGL_VERSION_PATCH 0 +#define LVGL_VERSION_PATCH 1 #define LVGL_VERSION_INFO "dev" /********************** diff --git a/scripts/release.py b/scripts/release.py index 568bfeab2..0b5946584 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -80,13 +80,13 @@ def lvgl_update_library_json(v): title("lvgl: Update version number in library.json") f = open("./library.json", "r") - + vn = v[1:] outbuf = "" for i in f.read().splitlines(): r = re.search(r'"version": ', i) if r: - i = ' "version": "' + v + '",' + i = ' "version": "' + vn + '",' outbuf += i + '\n' @@ -171,7 +171,7 @@ def drivers_merge_to_release_branch(v): def docs_clone(): title("docs: Clone") - #cmd("git clone --recursive https://github.com/lvgl/docs.git") + cmd("git clone --recursive https://github.com/lvgl/docs.git") os.chdir("./docs") def docs_get_api(): @@ -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 135e8c374..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 @@ -589,6 +610,18 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #define LV_FONT_FMT_TXT_LARGE 0 #endif +/* Enables/disables support for compressed fonts. If it's disabled, compressed + * glyphs cannot be processed by the library and won't be rendered. + */ +#ifndef LV_USE_FONT_COMPRESSED +#define LV_USE_FONT_COMPRESSED 1 +#endif + +/* Enable subpixel rendering */ +#ifndef LV_USE_FONT_SUBPX +#define LV_USE_FONT_SUBPX 1 +#endif +#if LV_USE_FONT_SUBPX /* Set the pixel order of the display. * Important only if "subpx fonts" are used. * With "normal" font it doesn't matter. @@ -596,6 +629,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ #ifndef LV_FONT_SUBPX_BGR #define LV_FONT_SUBPX_BGR 0 #endif +#endif /*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/ @@ -620,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_disp.c b/src/lv_core/lv_disp.c index d3c6321f4..6cf6283ef 100644 --- a/src/lv_core/lv_disp.c +++ b/src/lv_core/lv_disp.c @@ -23,9 +23,9 @@ **********************/ #if LV_USE_ANIMATION -static void scr_load_anim_start(lv_anim_t * a); -static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v); -static void scr_anim_ready(lv_anim_t * a); + static void scr_load_anim_start(lv_anim_t * a); + static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v); + static void scr_anim_ready(lv_anim_t * a); #endif /********************** @@ -166,7 +166,7 @@ void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color) * @param disp pointer to a display * @param img_src path to file or pointer to an `lv_img_dsc_t` variable */ -void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src) +void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src) { if(!disp) disp = lv_disp_get_default(); if(!disp) { @@ -248,60 +248,60 @@ void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t lv_anim_set_delay(&a_old, delay); switch(anim_type) { - case LV_SCR_LOAD_ANIM_NONE: - /* Create a dummy animation to apply the delay*/ - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_new, 0, 0); - break; - case LV_SCR_LOAD_ANIM_OVER_LEFT: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0); - break; - case LV_SCR_LOAD_ANIM_OVER_RIGHT: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0); - break; - case LV_SCR_LOAD_ANIM_OVER_TOP: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0); - break; - case LV_SCR_LOAD_ANIM_OVER_BOTTOM: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0); - break; - case LV_SCR_LOAD_ANIM_MOVE_LEFT: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0); + case LV_SCR_LOAD_ANIM_NONE: + /* Create a dummy animation to apply the delay*/ + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, 0, 0); + break; + case LV_SCR_LOAD_ANIM_OVER_LEFT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_OVER_RIGHT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_OVER_TOP: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_OVER_BOTTOM: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0); + break; + case LV_SCR_LOAD_ANIM_MOVE_LEFT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0); - lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_old, 0, -lv_disp_get_hor_res(d)); - break; - case LV_SCR_LOAD_ANIM_MOVE_RIGHT: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0); + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_old, 0, -lv_disp_get_hor_res(d)); + break; + case LV_SCR_LOAD_ANIM_MOVE_RIGHT: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0); - lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x); - lv_anim_set_values(&a_old, 0, lv_disp_get_hor_res(d)); - break; - case LV_SCR_LOAD_ANIM_MOVE_TOP: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0); + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x); + lv_anim_set_values(&a_old, 0, lv_disp_get_hor_res(d)); + break; + case LV_SCR_LOAD_ANIM_MOVE_TOP: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0); - lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_old, 0, -lv_disp_get_ver_res(d)); - break; - case LV_SCR_LOAD_ANIM_MOVE_BOTTOM: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0); + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_old, 0, -lv_disp_get_ver_res(d)); + break; + case LV_SCR_LOAD_ANIM_MOVE_BOTTOM: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0); - lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y); - lv_anim_set_values(&a_old, 0, lv_disp_get_ver_res(d)); - break; + lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y); + lv_anim_set_values(&a_old, 0, lv_disp_get_ver_res(d)); + break; - case LV_SCR_LOAD_ANIM_FADE_ON: - lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) opa_scale_anim); - lv_anim_set_values(&a_new, LV_OPA_TRANSP, LV_OPA_COVER); - break; + case LV_SCR_LOAD_ANIM_FADE_ON: + lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) opa_scale_anim); + lv_anim_set_values(&a_new, LV_OPA_TRANSP, LV_OPA_COVER); + break; } lv_anim_start(&a_new); diff --git a/src/lv_core/lv_disp.h b/src/lv_core/lv_disp.h index d29978c5c..a0757accf 100644 --- a/src/lv_core/lv_disp.h +++ b/src/lv_core/lv_disp.h @@ -35,7 +35,7 @@ typedef enum { LV_SCR_LOAD_ANIM_MOVE_TOP, LV_SCR_LOAD_ANIM_MOVE_BOTTOM, LV_SCR_LOAD_ANIM_FADE_ON, -}lv_scr_load_anim_t; +} lv_scr_load_anim_t; /********************** * GLOBAL PROTOTYPES @@ -98,7 +98,7 @@ void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color); * @param disp pointer to a display * @param img_src path to file or pointer to an `lv_img_dsc_t` variable */ -void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src); +void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src); /** * Opacity of the background diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index 4159326fd..af756f4b5 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -212,6 +212,7 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj) indev->cursor = cur_obj; lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp)); lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y); + lv_obj_set_click(indev->cursor, false); } #if LV_USE_GROUP diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 59c151e58..0436c8cb3 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -86,8 +86,10 @@ static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coor static void report_style_mod_core(void * style_p, lv_obj_t * obj); 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, lv_coord_t x_ofs, lv_coord_t y_ofs); +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_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, lv_state_t new_state); @@ -101,7 +103,6 @@ static void scroll_anim_x_cb(lv_obj_t * obj, lv_anim_value_t v); static void scroll_anim_y_cb(lv_obj_t * obj, lv_anim_value_t v); #endif static void lv_event_mark_deleted(lv_obj_t * obj); -static void refresh_event_task_cb(lv_task_t * t); static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find); static void lv_obj_del_async_cb(void * obj); static void obj_del_core(lv_obj_t * obj); @@ -911,7 +912,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 +960,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 +971,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 +979,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 +990,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 +1001,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 +1012,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 +1023,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 +1035,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 @@ -1906,7 +1907,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*/ @@ -1920,26 +1922,6 @@ void lv_event_send_refresh_recursive(lv_obj_t * obj) } } -/** - * Queue the sending of LV_EVENT_REFRESH event to an object and all of its children. - * The events won't be sent immediately but after `LV_DISP_DEF_REFR_PERIOD` delay. - * It is useful to refresh object only on a reasonable rate if this function is called very often. - * @param obj pointer to an object or NULL to refresh all objects of all displays - */ -void lv_event_queue_refresh_recursive(lv_obj_t * obj) -{ - lv_task_t * t = lv_task_get_next(NULL); - while(t) { - /* REturn if a refresh is already queued for this object*/ - if(t->task_cb == refresh_event_task_cb && t->user_data == obj) return; - t = lv_task_get_next(t); - } - - /*No queued task for this object so create one now*/ - t = lv_task_create(refresh_event_task_cb, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, obj); - lv_task_set_repeat_count(t, 1); -} - /** * Call an event function with an object, event, and data. @@ -3299,7 +3281,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) { @@ -3313,7 +3295,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) { @@ -3334,6 +3318,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); @@ -3352,6 +3338,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) { @@ -3370,6 +3357,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) { @@ -3815,6 +3803,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); @@ -4044,7 +4033,8 @@ 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_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_point_t new_pos; _lv_area_align(&base->coords, &obj->coords, align, &new_pos); @@ -4063,7 +4053,8 @@ 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, lv_coord_t x_ofs, lv_coord_t y_ofs) +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); lv_coord_t new_y = lv_obj_get_y(obj); @@ -4467,11 +4458,6 @@ static void lv_event_mark_deleted(lv_obj_t * obj) } } -static void refresh_event_task_cb(lv_task_t * t) -{ - lv_event_send_refresh_recursive(t->user_data); -} - static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find) { /*Check all children of `parent`*/ diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 87286ec6a..ff8e36aa3 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -164,7 +164,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 @@ -502,7 +502,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); /** @@ -512,7 +512,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. @@ -521,7 +521,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. @@ -901,14 +901,6 @@ lv_res_t lv_event_send_refresh(lv_obj_t * obj); */ void lv_event_send_refresh_recursive(lv_obj_t * obj); -/** - * Queue the sending of LV_EVENT_REFRESH event to an object and all of its children. - * The events won't be sent immediately but after `LV_DISP_DEF_REFR_PERIOD` delay. - * It is useful to refresh object only on a reasonable rate if this function is called very often. - * @param obj pointer to an object or NULL to refresh all objects of all displays - */ -void lv_event_queue_refresh_recursive(lv_obj_t * obj); - /** * Call an event function with an object, event, and data. * @param event_xcb an event callback function. If `NULL` `LV_RES_OK` will return without any actions. diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index 9644a0459..0765fba27 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -517,10 +517,12 @@ static void lv_refr_area_part(const lv_area_t * area_p) lv_area_t a; lv_area_set(&a, 0, 0, header.w - 1, header.h - 1); lv_draw_img(&a, &start_mask, disp_refr->bg_img, &dsc); - } else { + } + else { LV_LOG_WARN("Can't draw the background image") } - } else { + } + else { lv_draw_rect_dsc_t dsc; lv_draw_rect_dsc_init(&dsc); dsc.bg_color = disp_refr->bg_color; @@ -542,8 +544,8 @@ static void lv_refr_area_part(const lv_area_t * area_p) if(top_act_scr == NULL) { - top_act_scr = disp_refr->act_scr; - } + top_act_scr = disp_refr->act_scr; + } /*Do the refreshing from the top object*/ lv_refr_obj_and_children(top_act_scr, &start_mask); diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index ce3665e0d..df1debc4d 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -257,7 +257,7 @@ void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style) return; } - lv_style_t ** new_classes = lv_mem_realloc(list->style_list, sizeof(lv_style_t *) * (list->style_cnt - 1)); + lv_style_t ** new_classes = lv_mem_alloc(sizeof(lv_style_t *) * (list->style_cnt - 1)); LV_ASSERT_MEM(new_classes); if(new_classes == NULL) { LV_LOG_WARN("lv_style_list_remove_style: couldn't reallocate class list"); @@ -271,6 +271,8 @@ void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style) } + lv_mem_free(list->style_list); + list->style_cnt--; list->style_list = new_classes; } diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index 5af62ec3f..e2bdd6b77 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -580,7 +580,7 @@ bool lv_debug_check_style_list(const lv_style_list_t * list); * lv_style_init(&my_style); * lv_style_copy(&my_style, &style_to_copy); */ -#define LV_STYLE_CREATE(name, copy_p) static lv_style_t name; lv_style_init(&name); lv_style_copy(&name, copy); +#define LV_STYLE_CREATE(name, copy_p) static lv_style_t name; lv_style_init(&name); lv_style_copy(&name, copy_p); diff --git a/src/lv_draw/lv_draw_blend.c b/src/lv_draw/lv_draw_blend.c index 375bee819..a7d9e0d1d 100644 --- a/src/lv_draw/lv_draw_blend.c +++ b/src/lv_draw/lv_draw_blend.c @@ -36,9 +36,11 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co lv_color_t color, lv_opa_t opa, const lv_opa_t * mask, lv_draw_mask_res_t mask_res); +#if LV_USE_BLEND_MODES static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area, lv_color_t color, lv_opa_t opa, const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode); +#endif static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area, const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa, @@ -49,12 +51,14 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa, const lv_opa_t * mask, lv_draw_mask_res_t mask_res); +#if LV_USE_BLEND_MODES static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area, const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa, const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode); static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color_t bg, lv_opa_t opa); static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_color_t bg, lv_opa_t opa); +#endif /********************** * STATIC VARIABLES @@ -167,9 +171,11 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_fill(const lv_area_t * clip_area, const lv_ else if(mode == LV_BLEND_MODE_NORMAL) { fill_normal(disp_area, disp_buf, &draw_area, color, opa, mask, mask_res); } +#if LV_USE_BLEND_MODES else { fill_blended(disp_area, disp_buf, &draw_area, color, opa, mask, mask_res, mode); } +#endif } /** @@ -230,9 +236,11 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_map(const lv_area_t * clip_area, const lv_a else if(mode == LV_BLEND_MODE_NORMAL) { map_normal(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res); } +#if LV_USE_BLEND_MODES else { map_blended(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res, mode); } +#endif } @@ -515,7 +523,7 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co } } - +#if LV_USE_BLEND_MODES /** * Fill an area with a color but apply blending algorithms * @param disp_area the current display area (destination area) @@ -606,6 +614,7 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co } } } +#endif static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area, const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa, @@ -845,7 +854,7 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col } } } - +#if LV_USE_BLEND_MODES static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area, const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa, const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode) @@ -996,3 +1005,4 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co return lv_color_mix(fg, bg, opa); } +#endif diff --git a/src/lv_draw/lv_draw_blend.h b/src/lv_draw/lv_draw_blend.h index 2d5e349d7..a5f57ed88 100644 --- a/src/lv_draw/lv_draw_blend.h +++ b/src/lv_draw/lv_draw_blend.h @@ -26,8 +26,10 @@ extern "C" { **********************/ enum { LV_BLEND_MODE_NORMAL, +#if LV_USE_BLEND_MODES LV_BLEND_MODE_ADDITIVE, LV_BLEND_MODE_SUBTRACTIVE, +#endif }; typedef uint8_t lv_blend_mode_t; diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 1c6dcee93..b447d615e 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -407,7 +407,6 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const return; } #endif - /*Build the image and a mask line-by-line*/ uint32_t mask_buf_size = lv_area_get_size(&draw_area) > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : lv_area_get_size(&draw_area); lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); @@ -420,7 +419,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const lv_opa_t px_opa = map_px[LV_IMG_PX_SIZE_ALPHA_BYTE - 1]; mask_buf[px_i] = px_opa; if(px_opa) { -#if LV_COLOR_DEPTH == 8 +#if LV_COLOR_DEPTH == 8 || LV_COLOR_DEPTH == 1 map2[px_i].full = map_px[0]; #elif LV_COLOR_DEPTH == 16 map2[px_i].full = map_px[0] + (map_px[1] << 8); diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 136b4d0d7..3f5ac09da 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -213,12 +213,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; + dsc->decor = LV_TEXT_DECOR_UNDERLINE; 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; line_dsc.opa = dsc->opa; line_dsc.blend_mode = dsc->blend_mode; } @@ -342,7 +342,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); @@ -420,7 +420,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_letter(const lv_point_t * pos_p, const } /* Don't draw anything if the character is empty. E.g. space */ - if((g.box_h == 0) && (g.box_w == 0)) return; + if((g.box_h == 0) || (g.box_w == 0)) return; int32_t pos_x = pos_p->x + g.ofs_x; int32_t pos_y = pos_p->y + (font_p->line_height - font_p->base_line) - g.box_h - g.ofs_y; @@ -607,6 +607,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area, const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode) { +#if LV_USE_FONT_SUBPX const uint8_t * bpp_opa_table; uint32_t bitmask_init; uint32_t bitmask; @@ -806,6 +807,9 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_ _lv_mem_buf_release(mask_buf); _lv_mem_buf_release(color_buf); +#else + LV_LOG_WARN("Can't draw sub-pixel rendered letter because LV_USE_FONT_SUBPX == 0 in lv_conf.h"); +#endif } diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 161b8e433..d2d31d148 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -30,8 +30,10 @@ 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_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); + +#if LV_USE_OUTLINE + static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, 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); @@ -39,8 +41,17 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord 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); + +#if LV_USE_PATTERN + static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, 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, 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(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i); /********************** * STATIC VARIABLES @@ -95,10 +106,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(); } @@ -370,41 +390,6 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv if(dsc->border_width == 0) return; if(dsc->border_side == LV_BORDER_SIDE_NONE) return; - lv_opa_t opa = dsc->border_opa; - - if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; - - lv_disp_t * disp = _lv_refr_get_disp_refreshing(); - lv_disp_buf_t * vdb = lv_disp_get_buf(disp); - - /* Get clipped fill area which is the real draw area. - * It is always the same or inside `fill_area` */ - lv_area_t draw_area; - bool is_common; - is_common = _lv_area_intersect(&draw_area, coords, clip); - if(is_common == false) return; - - const lv_area_t * disp_area = &vdb->area; - - /* Now `draw_area` has absolute coordinates. - * Make it relative to `disp_area` to simplify draw to `disp_buf`*/ - draw_area.x1 -= disp_area->x1; - draw_area.y1 -= disp_area->y1; - draw_area.x2 -= disp_area->x1; - draw_area.y2 -= disp_area->y1; - - int32_t draw_area_w = lv_area_get_width(&draw_area); - - /*Create a mask if there is a radius*/ - lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); - - uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); - bool simple_mode = true; - if(other_mask_cnt) simple_mode = false; - else if(dsc->border_side != LV_BORDER_SIDE_FULL) simple_mode = false; - - int16_t mask_rout_id = LV_MASK_ID_INV; - int32_t coords_w = lv_area_get_width(coords); int32_t coords_h = lv_area_get_height(coords); @@ -413,140 +398,80 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv int32_t short_side = LV_MATH_MIN(coords_w, coords_h); if(rout > short_side >> 1) rout = short_side >> 1; - /*Get the outer area*/ - lv_draw_mask_radius_param_t mask_rout_param; - if(rout > 0) { - lv_draw_mask_radius_init(&mask_rout_param, coords, rout, false); - mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); - } - - /*Get the inner radius*/ - int32_t rin = rout - dsc->border_width; - if(rin < 0) rin = 0; - /*Get the inner area*/ - lv_area_t area_small; - lv_area_copy(&area_small, coords); - area_small.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? dsc->border_width : - (dsc->border_width + rout)); - area_small.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? dsc->border_width : - (dsc->border_width + rout)); - area_small.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? dsc->border_width : - (dsc->border_width + rout)); - area_small.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? dsc->border_width : - (dsc->border_width + rout)); + lv_area_t area_inner; + lv_area_copy(&area_inner, coords); + area_inner.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? dsc->border_width : - (dsc->border_width + rout)); + area_inner.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? dsc->border_width : - (dsc->border_width + rout)); + area_inner.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? dsc->border_width : - (dsc->border_width + rout)); + area_inner.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? dsc->border_width : - (dsc->border_width + rout)); - /*Create inner the mask*/ - lv_draw_mask_radius_param_t mask_rin_param; - lv_draw_mask_radius_init(&mask_rin_param, &area_small, rout - dsc->border_width, true); - int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL); - - int32_t corner_size = LV_MATH_MAX(rout, dsc->border_width - 1); - - int32_t h; - lv_draw_mask_res_t mask_res; - lv_area_t fill_area; - - lv_color_t color = dsc->border_color; - lv_blend_mode_t blend_mode = dsc->border_blend_mode; - - /*Apply some optimization if there is no other mask*/ - if(simple_mode) { - /*Draw the upper corner area*/ - int32_t upper_corner_end = coords->y1 - disp_area->y1 + corner_size; - upper_corner_end = LV_MATH_MIN(upper_corner_end, draw_area.y2); - fill_area.x1 = coords->x1; - fill_area.x2 = coords->x2; - fill_area.y1 = disp_area->y1 + draw_area.y1; - fill_area.y2 = fill_area.y1; - for(h = draw_area.y1; h <= upper_corner_end; h++) { - _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_area_t fill_area2; - fill_area2.y1 = fill_area.y1; - fill_area2.y2 = fill_area.y2; - - fill_area2.x1 = coords->x1; - fill_area2.x2 = coords->x1 + rout - 1; - - _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); - - /*Draw the top horizontal line*/ - if(fill_area2.y2 < coords->y1 + dsc->border_width) { - fill_area2.x1 = coords->x1 + rout; - fill_area2.x2 = coords->x2 - rout; - - _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - } - - fill_area2.x1 = coords->x2 - rout + 1; - fill_area2.x2 = coords->x2; - - int32_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); - if(mask_ofs < 0) mask_ofs = 0; - _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); - - fill_area.y1++; - fill_area.y2++; - } - - /*Draw the lower corner area */ - int32_t lower_corner_end = coords->y2 - disp_area->y1 - corner_size; - lower_corner_end = LV_MATH_MAX(lower_corner_end, draw_area.y1); - if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1; - fill_area.y1 = disp_area->y1 + lower_corner_end; - fill_area.y2 = fill_area.y1; - for(h = lower_corner_end; h <= draw_area.y2; h++) { - _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_area_t fill_area2; - fill_area2.x1 = coords->x1; - fill_area2.x2 = coords->x1 + rout - 1; - fill_area2.y1 = fill_area.y1; - fill_area2.y2 = fill_area.y2; - - _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); - - /*Draw the bottom horizontal line*/ - if(fill_area2.y2 > coords->y2 - dsc->border_width) { - fill_area2.x1 = coords->x1 + rout; - fill_area2.x2 = coords->x2 - rout; - - _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - } - fill_area2.x1 = coords->x2 - rout + 1; - fill_area2.x2 = coords->x2; - - int32_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); - if(mask_ofs < 0) mask_ofs = 0; - _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); - - - fill_area.y1++; - fill_area.y2++; - } - - /*Draw the left vertical border part*/ - fill_area.y1 = coords->y1 + corner_size + 1; - fill_area.y2 = coords->y2 - corner_size - 1; - - fill_area.x1 = coords->x1; - fill_area.x2 = coords->x1 + dsc->border_width - 1; - _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - - /*Draw the right vertical border*/ - fill_area.x1 = coords->x2 - dsc->border_width + 1; - fill_area.x2 = coords->x2; - - _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); + if(dsc->border_side == LV_BORDER_SIDE_FULL) { + draw_full_border(&area_inner, coords, clip, dsc->radius, dsc->border_color, dsc->border_opa, dsc->border_blend_mode); } - /*Process line by line if there is other mask too*/ else { + lv_opa_t opa = dsc->border_opa; + if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; + + lv_disp_t * disp = _lv_refr_get_disp_refreshing(); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp); + + /* Get clipped fill area which is the real draw area. + * It is always the same or inside `fill_area` */ + lv_area_t draw_area; + bool is_common; + is_common = _lv_area_intersect(&draw_area, coords, clip); + if(is_common == false) return; + + const lv_area_t * disp_area = &vdb->area; + + /* Now `draw_area` has absolute coordinates. + * Make it relative to `disp_area` to simplify draw to `disp_buf`*/ + draw_area.x1 -= disp_area->x1; + draw_area.y1 -= disp_area->y1; + draw_area.x2 -= disp_area->x1; + draw_area.y2 -= disp_area->y1; + + int32_t draw_area_w = lv_area_get_width(&draw_area); + + /*Create a mask if there is a radius*/ + lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); + + /*Create mask for the outer area*/ + int16_t mask_rout_id = LV_MASK_ID_INV; + lv_draw_mask_radius_param_t mask_rout_param; + if(rout > 0) { + lv_draw_mask_radius_init(&mask_rout_param, coords, rout, false); + mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); + } + + /*Create mask for the inner mask*/ + int32_t rin = rout - dsc->border_width; + if(rin < 0) rin = 0; + lv_draw_mask_radius_param_t mask_rin_param; + lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rout - dsc->border_width, true); + int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL); + + int32_t corner_size = LV_MATH_MAX(rout, dsc->border_width - 1); + + int32_t h; + lv_draw_mask_res_t mask_res; + lv_area_t fill_area; + + lv_color_t color = dsc->border_color; + lv_blend_mode_t blend_mode = dsc->border_blend_mode; + fill_area.x1 = coords->x1; fill_area.x2 = coords->x2; fill_area.y1 = disp_area->y1 + draw_area.y1; fill_area.y2 = fill_area.y1; + uint32_t buf_ofs = 0; if(dsc->border_side == LV_BORDER_SIDE_LEFT) fill_area.x2 = coords->x1 + corner_size; - else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) fill_area.x1 = coords->x2 - corner_size; + else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) { + fill_area.x1 = coords->x2 - corner_size; + buf_ofs = fill_area.x1 - coords->x1; + } volatile bool top_only = false; volatile bool bottom_only = false; @@ -565,16 +490,16 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv (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, mask_res, opa, blend_mode); + _lv_blend_fill(clip, &fill_area, color, mask_buf + buf_ofs, mask_res, opa, blend_mode); } fill_area.y1++; fill_area.y2++; } + lv_draw_mask_remove_id(mask_rin_id); + lv_draw_mask_remove_id(mask_rout_id); + _lv_mem_buf_release(mask_buf); } - lv_draw_mask_remove_id(mask_rin_id); - lv_draw_mask_remove_id(mask_rout_id); - _lv_mem_buf_release(mask_buf); } 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) @@ -1222,6 +1147,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t #endif +#if LV_USE_OUTLINE static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) { if(dsc->outline_opa <= LV_OPA_MIN) return; @@ -1231,10 +1157,6 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; - uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); - bool simple_mode = true; - if(other_mask_cnt) simple_mode = false; - /*Get the inner radius*/ lv_area_t area_inner; lv_area_copy(&area_inner, coords); @@ -1243,16 +1165,6 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr area_inner.x2 += dsc->outline_pad; area_inner.y2 += dsc->outline_pad; - int32_t inner_w = lv_area_get_width(&area_inner); - int32_t inner_h = lv_area_get_height(&area_inner); - - int32_t rin = dsc->radius; - int32_t short_side = LV_MATH_MIN(inner_w, inner_h); - if(rin > short_side >> 1) rin = short_side >> 1; - - /*Get the outer area*/ - int32_t rout = rin + dsc->outline_width; - lv_area_t area_outer; lv_area_copy(&area_outer, &area_inner); @@ -1261,165 +1173,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; - int32_t coords_out_w = lv_area_get_width(&area_outer); - int32_t coords_out_h = lv_area_get_height(&area_outer); - short_side = LV_MATH_MIN(coords_out_w, coords_out_h); - if(rout > short_side >> 1) rout = short_side >> 1; - - lv_disp_t * disp = _lv_refr_get_disp_refreshing(); - lv_disp_buf_t * vdb = lv_disp_get_buf(disp); - - /* Get clipped fill area which is the real draw area. - * It is always the same or inside `fill_area` */ - lv_area_t draw_area; - bool is_common; - is_common = _lv_area_intersect(&draw_area, &area_outer, clip); - if(is_common == false) return; - - const lv_area_t * disp_area = &vdb->area; - - /* Now `draw_area` has absolute coordinates. - * Make it relative to `disp_area` to simplify draw to `disp_buf`*/ - draw_area.x1 -= disp_area->x1; - draw_area.y1 -= disp_area->y1; - draw_area.x2 -= disp_area->x1; - draw_area.y2 -= disp_area->y1; - - int32_t draw_area_w = lv_area_get_width(&draw_area); - - /*Create inner the mask*/ - lv_draw_mask_radius_param_t mask_rin_param; - lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rin, true); - int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL); - - lv_draw_mask_radius_param_t mask_rout_param; - lv_draw_mask_radius_init(&mask_rout_param, &area_outer, rout, false); - int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); - - lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); - - int32_t corner_size = LV_MATH_MAX(rout, dsc->outline_width - 1); - - int32_t h; - lv_draw_mask_res_t mask_res; - lv_area_t fill_area; - - lv_color_t color = dsc->outline_color; - lv_blend_mode_t blend_mode = dsc->outline_blend_mode; - - /*Apply some optimization if there is no other mask*/ - if(simple_mode) { - /*Draw the upper corner area*/ - int32_t upper_corner_end = area_outer.y1 - disp_area->y1 + corner_size; - - fill_area.x1 = area_outer.x1; - fill_area.x2 = area_outer.x2; - fill_area.y1 = disp_area->y1 + draw_area.y1; - fill_area.y2 = fill_area.y1; - for(h = draw_area.y1; h <= upper_corner_end; h++) { - _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_area_t fill_area2; - fill_area2.y1 = fill_area.y1; - fill_area2.y2 = fill_area.y2; - - fill_area2.x1 = area_outer.x1; - fill_area2.x2 = area_outer.x1 + rout - 1; - - _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); - - /*Draw the top horizontal line*/ - if(fill_area2.y2 < area_outer.y1 + dsc->outline_width) { - fill_area2.x1 = area_outer.x1 + rout; - fill_area2.x2 = area_outer.x2 - rout; - - _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - } - - fill_area2.x1 = area_outer.x2 - rout + 1; - fill_area2.x2 = area_outer.x2; - - int32_t mask_ofs = (area_outer.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); - if(mask_ofs < 0) mask_ofs = 0; - _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); - - fill_area.y1++; - fill_area.y2++; - } - - /*Draw the lower corner area */ - int32_t lower_corner_end = area_outer.y2 - disp_area->y1 - corner_size; - if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1; - fill_area.y1 = disp_area->y1 + lower_corner_end; - fill_area.y2 = fill_area.y1; - for(h = lower_corner_end; h <= draw_area.y2; h++) { - _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_area_t fill_area2; - fill_area2.x1 = area_outer.x1; - fill_area2.x2 = area_outer.x1 + rout - 1; - fill_area2.y1 = fill_area.y1; - fill_area2.y2 = fill_area.y2; - - _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); - - /*Draw the bottom horizontal line*/ - if(fill_area2.y2 > area_outer.y2 - dsc->outline_width) { - fill_area2.x1 = area_outer.x1 + rout; - fill_area2.x2 = area_outer.x2 - rout; - - _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - } - fill_area2.x1 = area_outer.x2 - rout + 1; - fill_area2.x2 = area_outer.x2; - - int32_t mask_ofs = (area_outer.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); - if(mask_ofs < 0) mask_ofs = 0; - _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); - - - fill_area.y1++; - fill_area.y2++; - } - - /*Draw the left vertical part*/ - fill_area.y1 = area_outer.y1 + corner_size + 1; - fill_area.y2 = area_outer.y2 - corner_size - 1; - - fill_area.x1 = area_outer.x1; - fill_area.x2 = area_outer.x1 + dsc->outline_width - 1; - _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - - /*Draw the right vertical border*/ - fill_area.x1 = area_outer.x2 - dsc->outline_width + 1; - fill_area.x2 = area_outer.x2; - - _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); - } - /*Process line by line if there is other mask too*/ - else { - fill_area.x1 = area_outer.x1; - fill_area.x2 = area_outer.x2; - fill_area.y1 = disp_area->y1 + draw_area.y1; - fill_area.y2 = fill_area.y1; - - for(h = draw_area.y1; h <= draw_area.y2; h++) { - _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, mask_res, opa, blend_mode); - fill_area.y1++; - fill_area.y2++; - - } - } - lv_draw_mask_remove_id(mask_rin_id); - lv_draw_mask_remove_id(mask_rout_id); - _lv_mem_buf_release(mask_buf); + draw_full_border(&area_inner, &area_outer, clip, dsc->radius, dsc->outline_color, dsc->outline_opa, + dsc->outline_blend_mode); } +#endif + +#if LV_USE_PATTERN static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc) { if(dsc->pattern_image == NULL) return; @@ -1520,9 +1280,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, lv_draw_rect_dsc_t * dsc) { if(dsc->value_str == NULL) return; if(dsc->value_opa <= LV_OPA_MIN) return; @@ -1555,4 +1317,179 @@ 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) +{ + uint8_t other_mask_cnt = lv_draw_mask_get_cnt(); + bool simple_mode = true; + if(other_mask_cnt) simple_mode = false; + + int32_t inner_w = lv_area_get_width(area_inner); + int32_t inner_h = lv_area_get_height(area_inner); + lv_coord_t border_width = area_outer->x2 - area_inner->x2; + int32_t rin = radius; + + int32_t short_side = LV_MATH_MIN(inner_w, inner_h); + if(rin > short_side >> 1) rin = short_side >> 1; + + /*Get the outer area*/ + int32_t rout = rin + border_width; + + int32_t coords_out_w = lv_area_get_width(area_outer); + int32_t coords_out_h = lv_area_get_height(area_outer); + short_side = LV_MATH_MIN(coords_out_w, coords_out_h); + if(rout > short_side >> 1) rout = short_side >> 1; + + lv_disp_t * disp = _lv_refr_get_disp_refreshing(); + lv_disp_buf_t * vdb = lv_disp_get_buf(disp); + + /* Get clipped fill area which is the real draw area. + * It is always the same or inside `fill_area` */ + lv_area_t draw_area; + bool is_common; + is_common = _lv_area_intersect(&draw_area, area_outer, clip); + if(is_common == false) return; + + const lv_area_t * disp_area = &vdb->area; + + /* Now `draw_area` has absolute coordinates. + * Make it relative to `disp_area` to simplify draw to `disp_buf`*/ + draw_area.x1 -= disp_area->x1; + draw_area.y1 -= disp_area->y1; + draw_area.x2 -= disp_area->x1; + draw_area.y2 -= disp_area->y1; + + int32_t draw_area_w = lv_area_get_width(&draw_area); + + /*Create inner the mask*/ + lv_draw_mask_radius_param_t mask_rin_param; + lv_draw_mask_radius_init(&mask_rin_param, area_inner, rin, true); + int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL); + + lv_draw_mask_radius_param_t mask_rout_param; + lv_draw_mask_radius_init(&mask_rout_param, area_outer, rout, false); + int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); + + lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); + + int32_t corner_size = LV_MATH_MAX(rout, border_width - 1); + + int32_t h; + lv_draw_mask_res_t mask_res; + lv_area_t fill_area; + + /*Apply some optimization if there is no other mask*/ + if(simple_mode) { + /*Draw the upper corner area*/ + int32_t upper_corner_end = area_outer->y1 - disp_area->y1 + corner_size; + + fill_area.x1 = area_outer->x1; + fill_area.x2 = area_outer->x2; + fill_area.y1 = disp_area->y1 + draw_area.y1; + fill_area.y2 = fill_area.y1; + for(h = draw_area.y1; h <= upper_corner_end; h++) { + _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_area_t fill_area2; + fill_area2.y1 = fill_area.y1; + fill_area2.y2 = fill_area.y2; + + fill_area2.x1 = area_outer->x1; + fill_area2.x2 = area_outer->x1 + rout - 1; + + _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); + + /*Draw the top horizontal line*/ + if(fill_area2.y2 < area_outer->y1 + border_width) { + fill_area2.x1 = area_outer->x1 + rout; + fill_area2.x2 = area_outer->x2 - rout; + + _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); + } + + fill_area2.x1 = area_outer->x2 - rout + 1; + fill_area2.x2 = area_outer->x2; + + int32_t mask_ofs = (area_outer->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); + if(mask_ofs < 0) mask_ofs = 0; + _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); + + fill_area.y1++; + fill_area.y2++; + } + + /*Draw the lower corner area */ + int32_t lower_corner_end = area_outer->y2 - disp_area->y1 - corner_size; + if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1; + fill_area.y1 = disp_area->y1 + lower_corner_end; + fill_area.y2 = fill_area.y1; + for(h = lower_corner_end; h <= draw_area.y2; h++) { + _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_area_t fill_area2; + fill_area2.x1 = area_outer->x1; + fill_area2.x2 = area_outer->x1 + rout - 1; + fill_area2.y1 = fill_area.y1; + fill_area2.y2 = fill_area.y2; + + _lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode); + + /*Draw the bottom horizontal line*/ + if(fill_area2.y2 > area_outer->y2 - border_width) { + fill_area2.x1 = area_outer->x1 + rout; + fill_area2.x2 = area_outer->x2 - rout; + + _lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); + } + fill_area2.x1 = area_outer->x2 - rout + 1; + fill_area2.x2 = area_outer->x2; + + int32_t mask_ofs = (area_outer->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); + if(mask_ofs < 0) mask_ofs = 0; + _lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode); + + + fill_area.y1++; + fill_area.y2++; + } + + /*Draw the left vertical part*/ + fill_area.y1 = area_outer->y1 + corner_size + 1; + fill_area.y2 = area_outer->y2 - corner_size - 1; + + fill_area.x1 = area_outer->x1; + fill_area.x2 = area_outer->x1 + border_width - 1; + _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); + + /*Draw the right vertical border*/ + fill_area.x1 = area_outer->x2 - border_width + 1; + fill_area.x2 = area_outer->x2; + + _lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode); + } + /*Process line by line if there is other mask too*/ + else { + fill_area.x1 = area_outer->x1; + fill_area.x2 = area_outer->x2; + fill_area.y1 = disp_area->y1 + draw_area.y1; + fill_area.y2 = fill_area.y1; + + for(h = draw_area.y1; h <= draw_area.y2; h++) { + _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, mask_res, opa, blend_mode); + fill_area.y1++; + fill_area.y2++; + + } + } + lv_draw_mask_remove_id(mask_rin_id); + lv_draw_mask_remove_id(mask_rout_id); + _lv_mem_buf_release(mask_buf); +} 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_font/lv_font_fmt_txt.c b/src/lv_font/lv_font_fmt_txt.c index 403fe26ee..7ac5e1e42 100644 --- a/src/lv_font/lv_font_fmt_txt.c +++ b/src/lv_font/lv_font_fmt_txt.c @@ -88,6 +88,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic } /*Handle compressed bitmap*/ else { +#if LV_USE_FONT_COMPRESSED uint32_t gsize = gdsc->box_w * gdsc->box_h; if(gsize == 0) return NULL; @@ -115,8 +116,12 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic } bool prefilter = fdsc->bitmap_format == LV_FONT_FMT_TXT_COMPRESSED ? true : false; - decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp, prefilter); + decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp, + prefilter); return decompr_buf; +#else /* !LV_USE_FONT_COMPRESSED */ + return NULL; +#endif } /*If not returned earlier then the letter is not found in this font*/ @@ -349,7 +354,7 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord uint8_t * line_buf2 = NULL; if(prefilter) { - line_buf2= _lv_mem_buf_get(w); + line_buf2 = _lv_mem_buf_get(w); } decompress_line(line_buf1, w); @@ -371,7 +376,8 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord bits_write(out, wrp, line_buf1[x], bpp); wrp += wr_size; } - } else { + } + else { decompress_line(line_buf1, w); for(x = 0; x < w; x++) { diff --git a/src/lv_font/lv_font_fmt_txt.h b/src/lv_font/lv_font_fmt_txt.h index 549c7f5e6..863b19269 100644 --- a/src/lv_font/lv_font_fmt_txt.h +++ b/src/lv_font/lv_font_fmt_txt.h @@ -150,7 +150,7 @@ typedef struct { typedef enum { LV_FONT_FMT_TXT_PLAIN = 0, LV_FONT_FMT_TXT_COMPRESSED = 1, - LV_FONT_FMT_TXT_COMPRESSED_NO_PREFILTER= 1, + LV_FONT_FMT_TXT_COMPRESSED_NO_PREFILTER = 1, } lv_font_fmt_txt_bitmap_format_t; diff --git a/src/lv_hal/lv_hal_disp.h b/src/lv_hal/lv_hal_disp.h index a3c627489..e99830b19 100644 --- a/src/lv_hal/lv_hal_disp.h +++ b/src/lv_hal/lv_hal_disp.h @@ -151,7 +151,8 @@ typedef struct _disp_t { struct _lv_obj_t * top_layer; /**< @see lv_disp_get_layer_top */ struct _lv_obj_t * sys_layer; /**< @see lv_disp_get_layer_sys */ - uint8_t del_prev :1; /**< 1: Automatically delete the previous screen when the screen load animation is ready */ +uint8_t del_prev : + 1; /**< 1: Automatically delete the previous screen when the screen load animation is ready */ lv_color_t bg_color; /**< Default display color when screens are transparent*/ const void * bg_img; /**< An image source to display as wallpaper*/ diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 168f48bb5..1b557788c 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -390,7 +390,7 @@ static inline uint32_t lv_color_to32(lv_color_t color) { #if LV_COLOR_DEPTH == 1 if(color.full == 0) - return 0; + return 0xFF000000; else return 0xFFFFFFFF; #elif LV_COLOR_DEPTH == 8 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.c b/src/lv_themes/lv_theme.c index eddeebd83..a13527f38 100644 --- a/src/lv_themes/lv_theme.c +++ b/src/lv_themes/lv_theme.c @@ -191,7 +191,7 @@ static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) } /*apply_xcb is deprecated, use apply_cb instead*/ - if (th->apply_xcb) { + if(th->apply_xcb) { th->apply_xcb(obj, name); } else if(th->apply_cb) { diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 01e79bf8b..ceca127bd 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -64,8 +64,9 @@ #define COLOR_BG_SEC_TEXT (IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xa5a8ad)) #define COLOR_BG_SEC_TEXT_DIS (IS_LIGHT ? lv_color_hex(0xaaaaaa) : lv_color_hex(0xa5a8ad)) -#define TRANSITION_TIME 150 +#define TRANSITION_TIME ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_TRANSITION) ? 0 : 150) #define BORDER_WIDTH LV_DPX(2) +#define OUTLINE_WIDTH ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) ? 0 : LV_DPX(2)) #define IS_LIGHT (theme.flags & LV_THEME_MATERIAL_FLAG_LIGHT) #define PAD_DEF (lv_disp_get_size_category(NULL) <= LV_DISP_SIZE_MEDIUM ? LV_DPX(15) : (LV_DPX(30))) @@ -210,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); - 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); @@ -306,7 +308,7 @@ static void basic_init(void) lv_style_set_pad_top(&styles->btn, LV_STATE_DEFAULT, LV_DPX(15)); lv_style_set_pad_bottom(&styles->btn, LV_STATE_DEFAULT, LV_DPX(15)); lv_style_set_pad_inner(&styles->btn, LV_STATE_DEFAULT, LV_DPX(20)); - lv_style_set_outline_width(&styles->btn, LV_STATE_DEFAULT, 3); + lv_style_set_outline_width(&styles->btn, LV_STATE_DEFAULT, OUTLINE_WIDTH); lv_style_set_outline_opa(&styles->btn, LV_STATE_DEFAULT, LV_OPA_0); lv_style_set_outline_opa(&styles->btn, LV_STATE_FOCUSED, LV_OPA_50); lv_style_set_outline_color(&styles->btn, LV_STATE_DEFAULT, theme.color_primary); @@ -365,7 +367,7 @@ static void bar_init(void) lv_style_set_outline_color(&styles->bar_bg, LV_STATE_EDITED, theme.color_secondary); lv_style_set_outline_opa(&styles->bar_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP); lv_style_set_outline_opa(&styles->bar_bg, LV_STATE_FOCUSED, LV_OPA_50); - lv_style_set_outline_width(&styles->bar_bg, LV_STATE_DEFAULT, 3); + lv_style_set_outline_width(&styles->bar_bg, LV_STATE_DEFAULT, OUTLINE_WIDTH); lv_style_set_transition_time(&styles->bar_bg, LV_STATE_DEFAULT, TRANSITION_TIME); lv_style_set_transition_prop_6(&styles->bar_bg, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA); @@ -616,7 +618,7 @@ static void checkbox_init(void) lv_style_set_outline_color(&styles->cb_bg, LV_STATE_DEFAULT, theme.color_primary); lv_style_set_outline_opa(&styles->cb_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP); lv_style_set_outline_opa(&styles->cb_bg, LV_STATE_FOCUSED, LV_OPA_50); - lv_style_set_outline_width(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(3)); + lv_style_set_outline_width(&styles->cb_bg, LV_STATE_DEFAULT, OUTLINE_WIDTH); lv_style_set_outline_pad(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(10)); lv_style_set_transition_time(&styles->cb_bg, LV_STATE_DEFAULT, TRANSITION_TIME); lv_style_set_transition_prop_6(&styles->cb_bg, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA); @@ -746,7 +748,7 @@ static void list_init(void) lv_style_set_border_width(&styles->list_btn, LV_STATE_DEFAULT, 1); lv_style_set_outline_color(&styles->list_btn, LV_STATE_FOCUSED, theme.color_secondary); - lv_style_set_outline_width(&styles->list_btn, LV_STATE_FOCUSED, BORDER_WIDTH); + lv_style_set_outline_width(&styles->list_btn, LV_STATE_FOCUSED, OUTLINE_WIDTH); lv_style_set_outline_pad(&styles->list_btn, LV_STATE_FOCUSED, -BORDER_WIDTH); lv_style_set_pad_left(&styles->list_btn, LV_STATE_DEFAULT, PAD_DEF); diff --git a/src/lv_themes/lv_theme_material.h b/src/lv_themes/lv_theme_material.h index ed0ab6162..5ee7283cc 100644 --- a/src/lv_themes/lv_theme_material.h +++ b/src/lv_themes/lv_theme_material.h @@ -24,6 +24,7 @@ typedef enum { LV_THEME_MATERIAL_FLAG_DARK = 0x01, LV_THEME_MATERIAL_FLAG_LIGHT = 0x02, LV_THEME_MATERIAL_FLAG_NO_TRANSITION = 0x10, + LV_THEME_MATERIAL_FLAG_NO_FOCUS = 0x20, } lv_theme_material_flag_t; /********************** diff --git a/src/lv_themes/lv_theme_mono.c b/src/lv_themes/lv_theme_mono.c index 466f84064..ba5357088 100644 --- a/src/lv_themes/lv_theme_mono.c +++ b/src/lv_themes/lv_theme_mono.c @@ -38,6 +38,7 @@ typedef struct { lv_style_t pad_normal; lv_style_t pad_small; lv_style_t pad_inner; + lv_style_t txt_underline; #if LV_USE_ARC lv_style_t arc_bg, arc_indic; @@ -122,6 +123,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, BG_COLOR); lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH); + lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED, BORDER_WIDTH * 2); + lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED | LV_STATE_EDITED, BORDER_WIDTH * 3); lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); lv_style_set_scale_end_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); @@ -139,10 +142,11 @@ static void basic_init(void) style_init_reset(&styles->clip_corner); lv_style_set_clip_corner(&styles->clip_corner, LV_STATE_DEFAULT, true); - style_init_reset(&styles->btn); lv_style_set_radius(&styles->btn, LV_STATE_DEFAULT, RADIUS); lv_style_set_border_width(&styles->btn, LV_STATE_DEFAULT, BORDER_WIDTH); + lv_style_set_border_width(&styles->btn, LV_STATE_FOCUSED, BORDER_WIDTH + 1); + lv_style_set_border_width(&styles->btn, LV_STATE_FOCUSED | LV_STATE_EDITED, BORDER_WIDTH + 2); lv_style_set_border_color(&styles->btn, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_bg_color(&styles->btn, LV_STATE_DEFAULT, BG_COLOR); lv_style_set_bg_color(&styles->btn, LV_STATE_PRESSED, FG_COLOR); @@ -204,6 +208,9 @@ static void basic_init(void) style_init_reset(&styles->pad_inner); lv_style_set_pad_inner(&styles->pad_inner, LV_STATE_DEFAULT, LV_DPI / 15); + + style_init_reset(&styles->txt_underline); + lv_style_set_text_decor(&styles->txt_underline, LV_STATE_FOCUSED, LV_TEXT_DECOR_UNDERLINE); } static void arc_init(void) @@ -589,6 +596,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; #endif @@ -600,6 +608,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; #endif @@ -714,6 +723,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->round); _lv_style_list_add_style(list, &styles->pad_small); + _lv_style_list_add_style(list, &styles->fg_color); break; #endif @@ -725,6 +735,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->pad_small); break; #endif @@ -741,6 +752,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; #endif @@ -775,6 +787,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; case LV_THEME_TABVIEW_PAGE: @@ -834,6 +847,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); _lv_style_list_add_style(list, &styles->list_btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; #endif @@ -940,12 +954,14 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) _lv_style_list_add_style(list, &styles->fg_color); _lv_style_list_add_style(list, &styles->pad_none); _lv_style_list_add_style(list, &styles->no_radius); + _lv_style_list_add_style(list, &styles->txt_underline); break; case LV_THEME_SPINBOX_BTN: list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); _lv_style_list_add_style(list, &styles->bg); _lv_style_list_add_style(list, &styles->btn); + _lv_style_list_add_style(list, &styles->txt_underline); break; #endif diff --git a/src/lv_themes/lv_theme_template.c b/src/lv_themes/lv_theme_template.c index bd65d7a7b..2a22fad4e 100644 --- a/src/lv_themes/lv_theme_template.c +++ b/src/lv_themes/lv_theme_template.c @@ -81,7 +81,7 @@ static void basic_init(void) lv_style_set_bg_color(&styles->btn, LV_STATE_PRESSED, lv_color_hex3(0xccc)); lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED, theme.color_primary); lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_darken(theme.color_primary, - LV_OPA_30)); + LV_OPA_30)); lv_style_set_bg_color(&styles->btn, LV_STATE_DISABLED, LV_COLOR_SILVER); lv_style_set_text_color(&styles->btn, LV_STATE_DISABLED, LV_COLOR_GRAY); lv_style_set_image_recolor(&styles->btn, LV_STATE_DISABLED, LV_COLOR_GRAY); @@ -345,8 +345,8 @@ static void win_init(void) * @return a pointer to reference this theme later */ lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, - const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, - const lv_font_t * font_title) + const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, + const lv_font_t * font_title) { /* This trick is required only to avoid the garbage collection of diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 5501fcfa6..842d6421b 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -658,7 +658,6 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl lv_draw_rect_dsc_t draw_rect_tmp_dsc; lv_draw_label_dsc_t draw_label_tmp_dsc; - /*The state changes without re-caching the styles, disable the use of cache*/ lv_state_t state_ori = btnm->state; btnm->state = LV_STATE_DEFAULT; lv_draw_rect_dsc_init(&draw_rect_rel_dsc); @@ -695,9 +694,20 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl /*Choose the style*/ lv_draw_rect_dsc_t * draw_rect_dsc_act; lv_draw_label_dsc_t * draw_label_dsc_act; - bool tgl_state = button_get_tgl_state(ext->ctrl_bits[btn_i]); + lv_state_t btn_state = LV_STATE_DEFAULT; + if(button_get_tgl_state(ext->ctrl_bits[btn_i])) btn_state |= LV_STATE_CHECKED; + if(button_is_inactive(ext->ctrl_bits[btn_i])) btn_state |= LV_STATE_DISABLED; + if(btn_i == ext->btn_id_pr) btn_state |= LV_STATE_PRESSED; + if(btn_i == ext->btn_id_focused) { + btn_state |= LV_STATE_FOCUSED; + if(state_ori & LV_STATE_EDITED) btn_state |= LV_STATE_EDITED; + } - if(tgl_state) { + 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) { if(!chk_inited) { btnm->state = LV_STATE_CHECKED; lv_draw_rect_dsc_init(&draw_rect_chk_dsc); @@ -708,9 +718,10 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl btnm->state = state_ori; chk_inited = true; } + draw_rect_dsc_act = &draw_rect_chk_dsc; + draw_label_dsc_act = &draw_label_chk_dsc; } - - if(button_is_inactive(ext->ctrl_bits[btn_i])) { + else if(btn_state == LV_STATE_CHECKED) { if(!disabled_inited) { btnm->state = LV_STATE_DISABLED; lv_draw_rect_dsc_init(&draw_rect_ina_dsc); @@ -724,21 +735,9 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl draw_rect_dsc_act = &draw_rect_ina_dsc; draw_label_dsc_act = &draw_label_ina_dsc; } - /*Simple released or checked buttons button*/ - else if(btn_i != ext->btn_id_pr && btn_i != ext->btn_id_focused) { - draw_rect_dsc_act = tgl_state ? &draw_rect_chk_dsc : &draw_rect_rel_dsc; - draw_label_dsc_act = tgl_state ? &draw_label_chk_dsc : &draw_label_rel_dsc; - } - /*Focused and/or pressed + checked or released button*/ + /*In other cases get the styles directly without caching them*/ else { - btnm->state = LV_STATE_DEFAULT; - if(tgl_state) btnm->state = LV_STATE_CHECKED; - if(ext->btn_id_pr == btn_i) btnm->state |= LV_STATE_PRESSED; - if(ext->btn_id_focused == btn_i) { - btnm->state |= LV_STATE_FOCUSED; - if(state_ori & LV_STATE_EDITED) btnm->state |= LV_STATE_EDITED; - } - + btnm->state = btn_state; lv_draw_rect_dsc_init(&draw_rect_tmp_dsc); lv_draw_label_dsc_init(&draw_label_tmp_dsc); lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_tmp_dsc); diff --git a/src/lv_widgets/lv_calendar.c b/src/lv_widgets/lv_calendar.c index 54fc831e2..9936b624b 100644 --- a/src/lv_widgets/lv_calendar.c +++ b/src/lv_widgets/lv_calendar.c @@ -1070,11 +1070,11 @@ static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day) uint32_t a = month < 3 ? 1 : 0; uint32_t b = year - a; - #if LV_CALENDAR_WEEK_STARTS_MONDAY +#if LV_CALENDAR_WEEK_STARTS_MONDAY uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400) - 1) % 7; - #else +#else uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7; - #endif +#endif return day_of_week; } diff --git a/src/lv_widgets/lv_canvas.h b/src/lv_widgets/lv_canvas.h index 7d60855df..ce4cca2f7 100644 --- a/src/lv_widgets/lv_canvas.h +++ b/src/lv_widgets/lv_canvas.h @@ -60,7 +60,7 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy); /** * Set a buffer for the canvas. * @param buf a buffer where the content of the canvas will be. - * The required size is (lv_img_color_format_get_px_size(cf) * w * h) / 8) + * The required size is (lv_img_color_format_get_px_size(cf) * w) / 8 * h) * It can be allocated with `lv_mem_alloc()` or * it can be statically allocated array (e.g. static lv_color_t buf[100*50]) or * it can be an address in RAM or external SRAM diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 96b09e402..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; } /*===================== @@ -311,44 +311,44 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt) if(point_cnt < 1) point_cnt = 1; _LV_LL_READ_BACK(ext->series_ll, ser) { - if( !ser->ext_buf_assigned ) { - if(ser->start_point != 0) { - lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt); - LV_ASSERT_MEM(new_points); - if(new_points == NULL) return; + if(!ser->ext_buf_assigned) { + if(ser->start_point != 0) { + lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt); + LV_ASSERT_MEM(new_points); + if(new_points == NULL) return; - if(point_cnt >= point_cnt_old) { - for(i = 0; i < point_cnt_old; i++) { - new_points[i] = - ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ - } - for(i = point_cnt_old; i < point_cnt; i++) { - new_points[i] = def; /*Fill up the rest with default value*/ - } - } - else { - for(i = 0; i < point_cnt; i++) { - new_points[i] = - ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ - } - } + if(point_cnt >= point_cnt_old) { + for(i = 0; i < point_cnt_old; i++) { + new_points[i] = + ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ + } + for(i = point_cnt_old; i < point_cnt; i++) { + new_points[i] = def; /*Fill up the rest with default value*/ + } + } + else { + for(i = 0; i < point_cnt; i++) { + new_points[i] = + ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ + } + } - /*Switch over pointer from old to new*/ - lv_mem_free(ser->points); - ser->points = new_points; - } - else { - ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt); - LV_ASSERT_MEM(ser->points); - if(ser->points == NULL) return; - /*Initialize the new points*/ - if(point_cnt > point_cnt_old) { - for(i = point_cnt_old - 1; i < point_cnt; i++) { - ser->points[i] = def; - } - } - } - } + /*Switch over pointer from old to new*/ + lv_mem_free(ser->points); + ser->points = new_points; + } + else { + ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt); + LV_ASSERT_MEM(ser->points); + if(ser->points == NULL) return; + /*Initialize the new points*/ + if(point_cnt > point_cnt_old) { + for(i = point_cnt_old - 1; i < point_cnt; i++) { + ser->points[i] = def; + } + } + } + } ser->start_point = 0; } @@ -552,8 +552,8 @@ void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_ /** * Set the index of the x-axis start point in the data array * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param id the index of the x point in the data array + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the data array */ void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id) { @@ -563,7 +563,7 @@ void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint1 if(chart == NULL || ser == NULL) return; lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); if(ext == NULL) return; - if( id >= ext->point_cnt ) return; + if(id >= ext->point_cnt) return; ser->start_point = id; } @@ -571,9 +571,9 @@ void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint1 * Set an external array of data points to use for the chart * NOTE: It is the users responsibility to make sure the point_cnt matches the external array size. * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param array external array of points for chart - * @param point_cnt number of external points in the array + * @param ser pointer to a data series on 'chart' + * @param array external array of points for chart + * @param point_cnt number of external points in the array */ void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt) { @@ -582,7 +582,7 @@ void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_ if(chart == NULL || ser == NULL) return; lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); - if( !ser->ext_buf_assigned && ser->points ) lv_mem_free(ser->points); + if(!ser->ext_buf_assigned && ser->points) lv_mem_free(ser->points); ser->ext_buf_assigned = true; ser->points = array; ext->point_cnt = point_cnt; @@ -591,9 +591,9 @@ void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_ /** * Set an individual point y value in the chart series directly based on index * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param value value to assign to array point - * @param id the index of the x point in the array + * @param ser pointer to a data series on 'chart' + * @param value value to assign to array point + * @param id the index of the x point in the array */ void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id) { @@ -603,7 +603,7 @@ void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t if(chart == NULL || ser == NULL) return; lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); if(ext == NULL) return; - if( id >= ext->point_cnt ) return; + if(id >= ext->point_cnt) return; ser->points[id] = value; } @@ -623,7 +623,7 @@ void lv_chart_set_series_axis(lv_obj_t * chart, lv_chart_series_t * ser, lv_char return; } - if( ser->y_axis == axis) return; + if(ser->y_axis == axis) return; ser->y_axis = axis; lv_chart_refresh(chart); @@ -661,8 +661,8 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * chart) /** * Get the current index of the x-axis start point in the data array - * @param ser pointer to a data series on 'chart' - * @return the index of the current x start point in the data array + * @param ser pointer to a data series on 'chart' + * @return the index of the current x start point in the data array */ uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser) { @@ -674,9 +674,9 @@ uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser) /** * Get an individual point y value in the chart series directly based on index * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param id the index of the x point in the array - * @return value of array point at index id + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the array + * @return value of array point at index id */ lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id) { @@ -684,7 +684,7 @@ lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint LV_ASSERT_NULL(ser); lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); - if( id >= ext->point_cnt ) id = 0; + if(id >= ext->point_cnt) id = 0; return(ser->points[id]); } @@ -783,10 +783,12 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param if(sign == LV_SIGNAL_CLEANUP) { lv_chart_series_t * ser; - _LV_LL_READ(ext->series_ll, ser) { + while(ext->series_ll.head != NULL) { + ser = _lv_ll_get_head(&ext->series_ll); if(!ser->ext_buf_assigned) lv_mem_free(ser->points); + _lv_ll_remove(&ext->series_ll, ser); lv_mem_free(ser); } _lv_ll_clear(&ext->series_ll); @@ -1505,6 +1507,9 @@ static void invalidate_lines(lv_obj_t * chart, uint16_t i) lv_area_t coords; lv_area_copy(&coords, &series_area); + coords.y1 -= line_width + point_radius; + coords.y2 += line_width + point_radius; + if(i < ext->point_cnt - 1) { coords.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs - line_width - point_radius; coords.x2 = ((w * (i + 1)) / (ext->point_cnt - 1)) + x_ofs + line_width + point_radius; diff --git a/src/lv_widgets/lv_chart.h b/src/lv_widgets/lv_chart.h index c7f68284c..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 @@ -276,8 +276,8 @@ void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, ui /** * Set the index of the x-axis start point in the data array * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param id the index of the x point in the data array + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the data array */ void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id); @@ -285,17 +285,17 @@ void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint1 * Set an external array of data points to use for the chart * NOTE: It is the users responsibility to make sure the point_cnt matches the external array size. * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param array external array of points for chart + * @param ser pointer to a data series on 'chart' + * @param array external array of points for chart */ -void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt ); +void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt); /** * Set an individual point value in the chart series directly based on index * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param value value to assign to array point - * @param id the index of the x point in the array + * @param ser pointer to a data series on 'chart' + * @param value value to assign to array point + * @param id the index of the x point in the array */ void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id); @@ -327,17 +327,17 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * chart); /** * get the current index of the x-axis start point in the data array - * @param ser pointer to a data series on 'chart' - * @return the index of the current x start point in the data array + * @param ser pointer to a data series on 'chart' + * @return the index of the current x start point in the data array */ uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser); /** * Get an individual point value in the chart series directly based on index * @param chart pointer to a chart object - * @param ser pointer to a data series on 'chart' - * @param id the index of the x point in the array - * @return value of array point at index id + * @param ser pointer to a data series on 'chart' + * @param id the index of the x point in the array + * @return value of array point at index id */ lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id); diff --git a/src/lv_widgets/lv_checkbox.h b/src/lv_widgets/lv_checkbox.h index cb083733f..96bb0f1e2 100644 --- a/src/lv_widgets/lv_checkbox.h +++ b/src/lv_widgets/lv_checkbox.h @@ -113,7 +113,7 @@ static inline void lv_checkbox_set_disabled(lv_obj_t * cb) */ static inline void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state) { - lv_btn_set_state(cb, state); + lv_btn_set_state(cb, state); } /*===================== * Getter functions @@ -153,7 +153,7 @@ static inline bool lv_checkbox_is_inactive(const lv_obj_t * cb) */ static inline lv_btn_state_t lv_checkbox_get_state(const lv_obj_t * cb) { - return lv_btn_get_state(cb); + return lv_btn_get_state(cb); } /********************** diff --git a/src/lv_widgets/lv_cont.c b/src/lv_widgets/lv_cont.c index 6aa4d0305..ffb716832 100644 --- a/src/lv_widgets/lv_cont.c +++ b/src/lv_widgets/lv_cont.c @@ -628,7 +628,7 @@ static void lv_cont_layout_grid(lv_obj_t * cont) _LV_LL_READ_BACK(cont->child_ll, child) { if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue; lv_coord_t obj_w = lv_obj_get_width(child); - if(act_x + inner + obj_w > w_fit) { + if(act_x + obj_w > w_fit + left) { act_x = left; act_y += y_ofs; } diff --git a/src/lv_widgets/lv_cpicker.c b/src/lv_widgets/lv_cpicker.c index 21d1c09c2..cd8c9e17e 100644 --- a/src/lv_widgets/lv_cpicker.c +++ b/src/lv_widgets/lv_cpicker.c @@ -48,6 +48,13 @@ #define TRI_OFFSET 2 +/* The OUTER_MASK_WIDTH define is required to assist with the placing of a mask over the outer ring of the widget as when the + * multicoloured radial lines are calculated for the outer ring of the widget their lengths are jittering because of the + * integer based arithmetic. From tests the maximum delta was found to be 2 so the current value is set to 3 to achieve + * appropriate masking. + */ +#define OUTER_MASK_WIDTH 3 + /********************** * TYPEDEFS **********************/ @@ -483,6 +490,17 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask) uint16_t i; lv_coord_t cir_w = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN); + /* 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); + mask_area_out.x1 += OUTER_MASK_WIDTH; + mask_area_out.x2 -= OUTER_MASK_WIDTH; + mask_area_out.y1 += OUTER_MASK_WIDTH; + mask_area_out.y2 -= OUTER_MASK_WIDTH; + lv_draw_mask_radius_param_t mask_out_param; + lv_draw_mask_radius_init(&mask_out_param, &mask_area_out, LV_RADIUS_CIRCLE, false); + int16_t mask_out_id = lv_draw_mask_add(&mask_out_param, 0); + /* The inner line ends will be masked out. * So make lines a little bit longer because the masking makes a more even result */ lv_coord_t cir_w_extra = cir_w + line_dsc.width; @@ -498,7 +516,8 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask) lv_draw_line(&p[0], &p[1], mask, &line_dsc); } - + /* Now remove mask to continue with inner part */ + lv_draw_mask_remove_id(mask_out_id); /*Mask out the inner area*/ lv_draw_rect_dsc_t bg_dsc; diff --git a/src/lv_widgets/lv_gauge.c b/src/lv_widgets/lv_gauge.c index ad7cb32e1..df2d5c0ea 100644 --- a/src/lv_widgets/lv_gauge.c +++ b/src/lv_widgets/lv_gauge.c @@ -589,15 +589,6 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area) lv_draw_line_dsc_init(&line_dsc); lv_obj_init_draw_line_dsc(gauge, LV_GAUGE_PART_NEEDLE, &line_dsc); - lv_draw_img_dsc_t img_dsc; - if(ext->needle_img == NULL) { - lv_draw_img_dsc_init(&img_dsc); - lv_obj_init_draw_img_dsc(gauge, LV_GAUGE_PART_MAIN, &img_dsc); - img_dsc.recolor_opa = LV_OPA_COVER; - img_dsc.pivot.x = ext->needle_img_pivot.x; - img_dsc.pivot.y = ext->needle_img_pivot.y; - } - p_mid.x = x_ofs; p_mid.y = y_ofs; for(i = 0; i < ext->needle_count; i++) { @@ -625,10 +616,18 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area) a.y1 = gauge->coords.y1 + lv_area_get_height(&gauge->coords) / 2 - ext->needle_img_pivot.y; a.x2 = a.x1 + info.w - 1; a.y2 = a.y1 + info.h - 1; + lv_draw_img_dsc_t img_dsc; + lv_draw_img_dsc_init(&img_dsc); + lv_obj_init_draw_img_dsc(gauge, LV_GAUGE_PART_MAIN, &img_dsc); + img_dsc.recolor_opa = LV_OPA_COVER; + img_dsc.pivot.x = ext->needle_img_pivot.x; + img_dsc.pivot.y = ext->needle_img_pivot.y; if(ext->needle_colors != NULL) img_dsc.recolor = ext->needle_colors[i]; + needle_angle = (needle_angle * 10); + if(needle_angle > 3600) needle_angle -= 3600; img_dsc.angle = needle_angle; lv_draw_img(&a, clip_area, ext->needle_img, &img_dsc); } diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index f29d848c3..d8043f876 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -126,9 +126,9 @@ void lv_linemeter_set_value(lv_obj_t * lmeter, int32_t value) ext->cur_value = ext->cur_value < ext->min_value ? ext->min_value : ext->cur_value; int16_t level_old = - (int32_t)((int32_t)(old_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value); + (int32_t)((int32_t)(old_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value); int16_t level_new = - (int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (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); if(level_new == level_old) { return; @@ -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) / (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); @@ -519,11 +519,12 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin p1.x = x_out_extra; p1.y = y_out_extra; - if(i >= level) { + /* Set the color of the lines */ + uint16_t index = ext->mirrored ? ext->line_cnt - i : i; + 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); } @@ -538,12 +539,12 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin lv_draw_mask_remove_id(mask_out_id); #endif - if(part == LV_LINEMETER_PART_MAIN) { + if(part == LV_LINEMETER_PART_MAIN && level + 1 < ext->line_cnt - 1) { lv_style_int_t border_width = lv_obj_get_style_scale_border_width(lmeter, part); lv_style_int_t end_border_width = lv_obj_get_style_scale_end_border_width(lmeter, part); if(border_width || end_border_width) { - int16_t end_angle = (level * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs - 1; + int16_t end_angle = ((level + 1) * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs; lv_draw_line_dsc_t arc_dsc; lv_draw_line_dsc_init(&arc_dsc); lv_obj_init_draw_line_dsc(lmeter, part, &arc_dsc); @@ -559,8 +560,6 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin arc_dsc.color = end_color; lv_draw_arc(x_ofs, y_ofs, r_out, end_angle, (angle_ofs + ext->scale_angle) % 360, clip_area, &arc_dsc); } - - } } @@ -570,7 +569,6 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin /********************** * STATIC FUNCTIONS **********************/ -#include /** * Handle the drawing related tasks of the line meters diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index d1d370a87..55b5646f6 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -495,7 +495,7 @@ uint16_t lv_list_get_size(const lv_obj_t * list) lv_obj_t * btn = lv_list_get_next_btn(list, NULL); while(btn) { size++; - btn = lv_list_get_next_btn(list, NULL); + btn = lv_list_get_next_btn(list, btn); } return size; } @@ -767,6 +767,11 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) if(btn) lv_list_focus_btn(list, btn); } } + else if(c == LV_KEY_ESC) { + lv_list_ext_t * ext = lv_obj_get_ext_attr(list); + /* Handle ESC/Cancel event */ + res = lv_event_send(ext->act_sel_btn, LV_EVENT_CANCEL, NULL); + } #endif } return res; diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index f7e1a8e34..f2330de78 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -402,7 +402,7 @@ lv_coord_t lv_page_get_width_grid(lv_obj_t * page, uint8_t div, uint8_t span) } /** - * Divide the height of the object and get the width of a given number of columns. + * Divide the height of the object and get the height of a given number of rows. * Take into account the paddings of the background and scrollable too. * @param obj pointer to an object * @param div indicates how many rows are assumed. @@ -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_roller.c b/src/lv_widgets/lv_roller.c index 9b1672ceb..ac49b6df3 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -474,12 +474,15 @@ static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * cli /*Get the size of the "selected text"*/ lv_point_t res_p; - _lv_txt_get_size(&res_p, lv_label_get_text(label), label_dsc.font, label_dsc.letter_space, label_dsc.line_space, lv_obj_get_width(roller), LV_TXT_FLAG_EXPAND); + _lv_txt_get_size(&res_p, lv_label_get_text(label), label_dsc.font, label_dsc.letter_space, label_dsc.line_space, + lv_obj_get_width(roller), LV_TXT_FLAG_EXPAND); /*Move the selected label proportionally with the background label*/ lv_coord_t roller_h = lv_obj_get_height(roller); - int32_t label_y_prop = label->coords.y1 - (roller_h / 2 + roller->coords.y1); /*label offset from the middle line of the roller*/ - label_y_prop = (label_y_prop << 14) / lv_obj_get_height(label); /*Proportional position from the middle line (upscaled)*/ + int32_t label_y_prop = label->coords.y1 - (roller_h / 2 + + roller->coords.y1); /*label offset from the middle line of the roller*/ + label_y_prop = (label_y_prop << 14) / lv_obj_get_height( + label); /*Proportional position from the middle line (upscaled)*/ /*Apply a correction with different line heights*/ const lv_font_t * normal_label_font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG); diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index 9e51d59dc..0e35e3798 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -230,20 +230,6 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name) ext->tab_cnt++; - switch(ext->btns_pos) { - case LV_TABVIEW_TAB_POS_TOP: - case LV_TABVIEW_TAB_POS_BOTTOM: - ext->tab_name_ptr = lv_mem_realloc((void *)ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt + 1)); - break; - case LV_TABVIEW_TAB_POS_LEFT: - case LV_TABVIEW_TAB_POS_RIGHT: - ext->tab_name_ptr = lv_mem_realloc((void *)ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt * 2)); - break; - } - - LV_ASSERT_MEM(ext->tab_name_ptr); - if(ext->tab_name_ptr == NULL) return NULL; - /* FIXME: It is not possible yet to switch tab button position from/to top/bottom from/to left/right at runtime. * Method: clean extra \n when switch from LV_TABVIEW_BTNS_POS_LEFT or LV_TABVIEW_BTNS_POS_RIGHT * to LV_TABVIEW_BTNS_POS_TOP or LV_TABVIEW_BTNS_POS_BOTTOM. @@ -448,6 +434,35 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an lv_btnmatrix_set_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNMATRIX_CTRL_CHECK_STATE); } +/** + * Set the name of a tab. + * @param tabview pointer to Tab view object + * @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) +{ + 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); + + /* 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; + + /* force redrawing of the tab headers */ + lv_obj_invalidate(ext->btns); + } +} + /** * Set the animation time of tab view when a new tab is loaded * @param tabview pointer to Tab view object diff --git a/src/lv_widgets/lv_tabview.h b/src/lv_widgets/lv_tabview.h index 50530ee85..eca985e62 100644 --- a/src/lv_widgets/lv_tabview.h +++ b/src/lv_widgets/lv_tabview.h @@ -119,6 +119,14 @@ void lv_tabview_clean_tab(lv_obj_t * tab); */ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t anim); +/** + * Set the name of a tab. + * @param tabview pointer to Tab view object + * @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); + /** * Set the animation time of tab view when a new tab is loaded * @param tabview pointer to Tab view object diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 9cf859f82..da622df65 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -60,6 +60,7 @@ static void pwd_char_hider(lv_obj_t * ta); static bool char_is_accepted(lv_obj_t * ta, uint32_t c); static void refr_cursor_area(lv_obj_t * ta); static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, lv_indev_t * click_source); +static lv_res_t insert_handler(lv_obj_t * ta, const char * txt); /********************** * STATIC VARIABLES @@ -148,7 +149,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy) lv_label_set_text(ext->label, "Text area"); lv_obj_set_click(ext->label, false); lv_obj_set_size(ta, LV_TEXTAREA_DEF_WIDTH, LV_TEXTAREA_DEF_HEIGHT); - lv_textarea_set_sscrollbar_mode(ta, LV_SCROLLBAR_MODE_DRAG); + lv_textarea_set_scrollbar_mode(ta, LV_SCROLLBAR_MODE_DRAG); lv_obj_reset_style_list(ta, LV_PAGE_PART_SCROLLABLE); lv_theme_apply(ta, LV_THEME_TEXTAREA); @@ -243,17 +244,8 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) if(c != 0) while(*letter_buf == 0) ++letter_buf; #endif - ta_insert_replace = NULL; - lv_event_send(ta, LV_EVENT_INSERT, letter_buf); - if(ta_insert_replace) { - if(ta_insert_replace[0] == '\0') return; /*Drop this text*/ - - /*Add the replaced text directly it's different from the original*/ - if(strcmp(ta_insert_replace, letter_buf)) { - lv_textarea_add_text(ta, ta_insert_replace); - return; - } - } + 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"); @@ -268,6 +260,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c) return; } + /*If a new line was added it shouldn't show edge flash effect*/ bool edge_flash_en = lv_textarea_get_edge_flash(ta); lv_textarea_set_edge_flash(ta, false); @@ -333,18 +326,6 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt) lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta); - ta_insert_replace = NULL; - lv_event_send(ta, LV_EVENT_INSERT, txt); - if(ta_insert_replace) { - if(ta_insert_replace[0] == '\0') return; /*Drop this text*/ - - /*Add the replaced text directly it's different from the original*/ - if(strcmp(ta_insert_replace, txt)) { - lv_textarea_add_text(ta, ta_insert_replace); - return; - } - } - if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/ /*Add the character one-by-one if not all characters are accepted or there is character limit.*/ @@ -357,6 +338,9 @@ 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; + /*If a new line was added it shouldn't show edge flash effect*/ bool edge_flash_en = lv_textarea_get_edge_flash(ta); lv_textarea_set_edge_flash(ta, false); @@ -419,18 +403,10 @@ void lv_textarea_del_char(lv_obj_t * ta) if(cur_pos == 0) return; - ta_insert_replace = NULL; char del_buf[2] = {LV_KEY_DEL, '\0'}; - lv_event_send(ta, LV_EVENT_INSERT, del_buf); - if(ta_insert_replace) { - if(ta_insert_replace[0] == '\0') return; /*Drop this text*/ - /*Add the replaced text directly it's different from the original*/ - if(strcmp(ta_insert_replace, del_buf)) { - lv_textarea_add_text(ta, ta_insert_replace); - return; - } - } + lv_res_t res = insert_handler(ta, del_buf); + if(res != LV_RES_OK) return; char * label_txt = lv_label_get_text(ext->label); @@ -1915,4 +1891,21 @@ static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, lv_ #endif } +static lv_res_t insert_handler(lv_obj_t * ta, const char * txt) +{ + ta_insert_replace = NULL; + lv_event_send(ta, LV_EVENT_INSERT, txt); + if(ta_insert_replace) { + if(ta_insert_replace[0] == '\0') return LV_RES_INV; /*Drop this text*/ + + /*Add the replaced text directly it's different from the original*/ + if(strcmp(ta_insert_replace, txt)) { + lv_textarea_add_text(ta, ta_insert_replace); + return LV_RES_INV; + } + } + + return LV_RES_OK; +} + #endif diff --git a/src/lv_widgets/lv_textarea.h b/src/lv_widgets/lv_textarea.h index 49cfc9b7d..dbca0db45 100644 --- a/src/lv_widgets/lv_textarea.h +++ b/src/lv_widgets/lv_textarea.h @@ -224,7 +224,7 @@ void lv_textarea_set_insert_replace(lv_obj_t * ta, const char * txt); * @param ta pointer to a text area object * @param sb_mode the new mode from 'lv_scrollbar_mode_t' enum */ -static inline void lv_textarea_set_sscrollbar_mode(lv_obj_t * ta, lv_scrollbar_mode_t mode) +static inline void lv_textarea_set_scrollbar_mode(lv_obj_t * ta, lv_scrollbar_mode_t mode) { lv_page_set_scrollbar_mode(ta, mode); }