Compare commits

...

101 Commits

Author SHA1 Message Date
Gabor Kiss-Vamosi
ec9de515b3 Release v7.11.0 2021-03-16 16:31:32 +01:00
Gabor Kiss-Vamosi
fa2c817681 Update lv_port_disp_template.c 2021-03-12 14:12:12 +01:00
Gabor Kiss-Vamosi
9a447883c1 fix(draw) consider style opa for outline too 2021-03-09 11:43:04 +01:00
Gabor Kiss-Vamosi
c908cc98b6 add lv_anim_del_all() 2021-03-09 10:31:17 +01:00
Petteri Aimonen
607e02e52a Cleanup LV_SIGNAL_GET_TYPE implementations (#2127)
Remove dead code in lv_label and lv_spinbox, there is already lv_obj_handle_get_type_signal() call higher up.
Change lv_led to use lv_obj_handle_get_type_signal() like other widgets do.
2021-03-08 15:01:59 +01:00
Kamranaghl
a4c33bb16e feat(label) decide text animation's direction based on base_dir (#2112) 2021-03-02 12:51:37 -05:00
Gabor Kiss-Vamosi
b8b66c6929 Update lv_label.h 2021-03-02 12:23:31 +01:00
Gabor Kiss-Vamosi
2618326f24 fix(txt): fix global buffer overflow in lv_txt_utf8_get_byte_id
fixes #2089
2021-03-01 16:07:59 +01:00
Gabor Kiss-Vamosi
58708ca771 fix(gauge): fix needle invalidation 2021-03-01 14:01:13 +01:00
Carlos Diaz
b55ee6aaf3 fix(esp32) adjust COMPONENT_SRCDIRS and COMPONENT_ADD_INCLUDEDIRS in component.mk (#2108) 2021-02-26 21:03:32 -05:00
Gabor Kiss-Vamosi
add5ce9ddb fix typo 2021-02-26 09:49:14 +01:00
Gabor Kiss-Vamosi
c4dc6ff940 Merge branch 'master' of https://github.com/littlevgl/lvgl 2021-02-26 09:47:49 +01:00
Gabor Kiss-Vamosi
9f1fbadf9d fix(bar, slider): fix with negative padding on bar and slider background
It allows making the indicator larger
2021-02-26 09:47:35 +01:00
embeddedt
b47a982510 fix(bar) correct symmetric handling for vertical bars (#2085) 2021-02-24 07:52:04 -05:00
Gabor Kiss-Vamosi
af98c9a9c0 Merge branch 'master' of https://github.com/littlevgl/lvgl 2021-02-23 11:18:20 +01:00
Gabor Kiss-Vamosi
8cfba6ae39 fix(shadow): fix overlapping shadow parts on small objects 2021-02-23 11:18:11 +01:00
Xiang Xiao
dcf0339747 Fix issues found in image cache (#2081)
* fix(image cache): don't need zero dec_dsc field individually

since the next _lv_memset_00 cover this field too and

* fix(image cache): shouldn't call lv_img_decoder_close when lv_img_decoder_open fail

* fix(image cache): fix the cache match algo

1.check cache entry is LV_IMG_SRC_FILE before invoke strcmp
2.ensure lv_img_cache_invalidate_src use the same algo
2021-02-22 12:18:37 +01:00
Gabor Kiss-Vamosi
3ddf26923f fix warning 2021-02-22 09:54:38 +01:00
Gabor Kiss-Vamosi
b252998b62 fix(anim) handle edge cases in lv_anim_path_bounce 2021-02-22 09:48:23 +01:00
Xiang Xiao
700c1290ba Fix the minor issue in style module (#2071)
* fix(style): correct the comment and alignment

* fix(style): remove the unused macro and inclusion

* fix(style): correct _lv_style_get_xxx with the right pointer type

* fix(style): handle the out of memory gracefully

* fix(style): unify the term usage(class->style)

* fix(style): remove the unnecessary mask in _lv_style_get_xxx

since get_property_index ensure the returned state is a subset of required

* fix(style): centralize the style validation in one place

* fix(style): reuse the new_prop_size in _lv_style_set_xxx

* fix(style): correct the return value of get_style_prop in big endian machine
2021-02-19 15:02:16 +01:00
Xiang Xiao
06917a6ec3 Fix issues found in image decoder (#2083)
* fix(image decoder): replace lv_style.h with lv_color.h

since image decoder doesn't depends on style subsystem
and correct the related comment and some error handling

* fix(image decoder): fix memory leak when no decoder can be used

and handle the out of memory gracefully

* fix(image decoder): zero the output fields after each iteration

to clean the stale info saved by try failed decoder and remove img_data
zero from lv_img_decoder_built_in_open since it has be done in the loop

* fix(image decoder): check .bin suffix in lv_img_decoder_built_in_info

align with what has done in lv_img_decoder_built_in_open

* fix(image decoder): embed lv_fs_file_t directly to save the memory

and handle the abnormal case gracefully(avoid crash or leak)

* fix(image decoder): simplify decode builtin alpha/index bitmap
2021-02-19 13:56:59 +01:00
Gabor Kiss-Vamosi
2edc95d7cd fix(fix): gauge
fix needle invalidation
2021-02-19 13:50:43 +01:00
Alex Kalmuk
0bdcf362ff feat(cmake) build a static liblvgl.a library by default (#2079) 2021-02-18 07:41:54 -05:00
Xiang Xiao
faf45419ca Try to fix the various issue found in animation module again (#2073)
* fix(anim): relayout lv_anim_t to save 4 bytes

and fix the minor comment issue

* fix(anim): unify the type of time and animation to int32_t or uint32_t

since lv_anim_t use these types internally

* fix(anim): Don't need initialize last_task_run

since lv_anim_start will do this if the list is empty
and remove -1 to improve the accuracy

* fix(anim): remove the return value from anim_ready_handler

since no caller really use the return value

* fix(math): _lv_map check x >= max_in first

_lv_map return max_out when min_in equals max_in,
since the animation module require this behaviour

* fix(anim): normalize the time elapse by lv_map

* fix(anim): avoid iterate the list twice in anim_task
2021-02-17 16:10:36 +01:00
embeddedt
339b3de2dc fix(list) scroll list when button is focused using LV_KEY_NEXT/PREV (#2061) 2021-02-17 09:51:41 -05:00
Gabor Kiss-Vamosi
de58ee2784 fix(gauge): consider paddigns for needle images 2021-02-17 11:39:52 +01:00
Gabor Kiss-Vamosi
351008edcc Merge branch 'master' into dev 2021-02-16 15:25:31 +01:00
Gabor Kiss-Vamosi
5247094727 Release v7.10.1 2021-02-16 15:25:31 +01:00
github-actions[bot]
b8ac56b7e8 Merge 11a2f82027 into dev 2021-02-15 19:59:38 +00:00
Xiang Xiao
11a2f82027 fix(theme): fix the memory leak when lv_theme_xxx_init is called twice (#2074)
* fix(theme): the minor typo error

* fix(style): make lv_style_reset work with zerod memory

* fix(theme): fix the memory leak when lv_theme_xxx_init is called twice

due to inited variable forget to set to 1

* fix(theme): empty theme should call lv_obj_refresh_style too

and remove lv_obj_clean_style_list since the same thing is
already done in the common code(clear_styles)
2021-02-15 20:59:11 +01:00
github-actions[bot]
af61cc4afd Merge 626f47f87b into dev 2021-02-15 19:48:01 +00:00
Themba Dube
626f47f87b feat(ci) add GCC problem matcher 2021-02-15 14:47:24 -05:00
github-actions[bot]
2e00a075d8 Merge 211a895008 into dev 2021-02-15 19:45:25 +00:00
Themba Dube
211a895008 ci(tests) add pedantic to compiler options 2021-02-15 14:44:43 -05:00
github-actions[bot]
bad50d05e1 Merge 85c75c2f34 into dev 2021-02-15 14:40:19 +00:00
Xiang Xiao
85c75c2f34 fix(color): simplify the current color depth macro definition (#2076)
the change also simplify the addition of new color format
2021-02-15 09:39:49 -05:00
github-actions[bot]
5e25a432b8 Merge 87a8be3624 into dev 2021-02-15 08:39:53 +00:00
Xiang Xiao
87a8be3624 fix(style): merge scaler and noscalar variant into one (#2072)
since there is no real difference between these two version
2021-02-15 09:39:22 +01:00
github-actions[bot]
e0cf4c3845 Merge 6b3452dc7b into dev 2021-02-15 08:28:04 +00:00
Xiang Xiao
6b3452dc7b fix(release/com.py): fail to update Kconfig version (#2075) 2021-02-15 09:27:30 +01:00
github-actions[bot]
68688fba26 Merge 0f48c62b17 into dev 2021-02-12 21:34:26 +00:00
Themba Dube
0f48c62b17 fix(calendar) force no wrapping on day numbers and names
Fixes #1850
2021-02-12 16:33:32 -05:00
embeddedt
4b151cc885 feat(rotation) add full 90-degree rotation support, incl. software rotation (#2055) 2021-02-12 09:57:58 -05:00
github-actions[bot]
11afa125b4 Merge 681cf0dc57 into dev 2021-02-12 14:16:42 +00:00
embeddedt
681cf0dc57 fix(draw) overlap outline with background to prevent aliasing artifacts (#2067)
* fix(draw) overlap outline with background to prevent aliasing artifacts

* fix(draw) only overlap outline if padding == 0
2021-02-12 15:16:10 +01:00
github-actions[bot]
830d341b50 Merge 1566e6fab1 into dev 2021-02-12 10:02:50 +00:00
Gabor Kiss-Vamosi
1566e6fab1 Update Makefile 2021-02-12 11:02:20 +01:00
github-actions[bot]
c94ce67015 Merge 3cec3964dd into dev 2021-02-12 10:00:40 +00:00
Gabor Kiss-Vamosi
3cec3964dd Revert "Fix the various issue found in animation module (#2063)"
This reverts commit a62ecda760.
2021-02-12 10:59:53 +01:00
github-actions[bot]
0350f29cab Merge c4b46706c3 into dev 2021-02-12 01:01:52 +00:00
Xiang Xiao
c4b46706c3 fix(fs): correct the document for lv_fs_get_last (#2068) 2021-02-11 20:01:26 -05:00
github-actions[bot]
8ccc17f9cc Merge 4cb3f01b9d into dev 2021-02-11 22:08:28 +00:00
Xiang Xiao
4cb3f01b9d fix(font): add the new font to lv_font.mk (#2069)
and order the item to find the difference from file system quickly
2021-02-11 17:07:59 -05:00
github-actions[bot]
06520e38af Merge 84600a78db into dev 2021-02-11 17:53:27 +00:00
alsaleem00
84600a78db fix(text) improve Arabic contextual analysis (#2062)
Adds hyphen processing and proper handling of lam-alef sequence
2021-02-11 12:53:00 -05:00
github-actions[bot]
bd141df9af Merge 5d0a06b6fa into dev 2021-02-11 14:59:28 +00:00
Gabor Kiss-Vamosi
5d0a06b6fa add -Wno-error=cast-function-type to build 2021-02-11 15:58:41 +01:00
Gabor Kiss-Vamosi
29867b46fe Merge branch 'dev' of https://github.com/littlevgl/lvgl into dev 2021-02-11 14:55:29 +01:00
Gabor Kiss-Vamosi
a6b86578df fix conflicts 2021-02-11 14:54:41 +01:00
Gabor Kiss-Vamosi
f9c73fe69d update CHANGELOG 2021-02-11 14:53:05 +01:00
Gabor Kiss-Vamosi
ab14266f67 Merge branch 'master' of https://github.com/littlevgl/lvgl 2021-02-11 14:42:54 +01:00
Gabor Kiss-Vamosi
0591dec33a fix(delete): delete animation after the children are deleted
New animation can be added during child delete
2021-02-11 14:42:48 +01:00
Xiang Xiao
9b52db0531 fix(conf): remove esp specific inclusion from lv_conf_internal.h (#2065)
* fix(lv_conf_internal.h): remove esp specific inclusion

since the same thing is already included in lv_conf_kconfig.h

* fix(library.json): change space to tab
2021-02-11 11:49:50 +01:00
github-actions[bot]
835ee48699 Merge a62ecda760 into dev 2021-02-11 10:12:23 +00:00
Xiang Xiao
a62ecda760 Fix the various issue found in animation module (#2063)
* fix(anim): relayout lv_anim_t to save 4 bytes

and fix the minor comment issue

* fix(anim): unify the type of time and animation to int32_t or uint32_t

since lv_anim_t use these types internally

* fix(anim): Don't need initialize last_task_run

since lv_anim_start will do this if the list is empty
and remove -1 to improve the accuracy

* fix(anim): remove the return value from anim_ready_handler

since no caller really use the return value

* fix(anim): normalize the time elapse by lv_map

* fix(anim): avoid iterate the list twice in anim_task
2021-02-11 11:11:49 +01:00
github-actions[bot]
41ac65039a Merge e6de537952 into dev 2021-02-08 15:16:30 +00:00
Carlos Diaz
e6de537952 Add component.mk file for esp-idf make based commands (#2056)
* Add component.mk file for esp-idf make commands

* component.mk: Check for IDF_VER

Checks for IDF_VER when adding COMPONENT_SRCDIRS and COMPONENT_ADD_INCLUDEDIRS
to avoid definig them when not using LVGL as ESP-IDF component.

* component.mk: Remove info messages
2021-02-08 16:15:59 +01:00
github-actions[bot]
bc30cf40c9 Merge 5d3fce8208 into dev 2021-02-08 09:46:02 +00:00
embeddedt
5d3fce8208 fix(gauge,linemeter) draw critical sections/end value in correct spot (#2059)
Revert be4f7a76d4 and
20d56ee6e9 as they both have issues.
2021-02-08 10:45:32 +01:00
github-actions[bot]
49cee3298c Merge fd74f6985a into dev 2021-02-08 09:42:24 +00:00
Carlos Diaz
fd74f6985a Kconfig: Add comments to primary and secondary colors (#2048) 2021-02-08 10:41:51 +01:00
github-actions[bot]
efcd88a4e4 Merge dfc6719479 into dev 2021-02-03 13:54:53 +00:00
Vitaly Puzrin
dfc6719479 Improve OpenCollective link (#2054)
Will show better icon
2021-02-03 08:54:17 -05:00
github-actions[bot]
b7fdffad0c Merge 2181dd858b into dev 2021-02-03 10:46:41 +00:00
Gabor Kiss-Vamosi
2181dd858b Update FUNDING.yml 2021-02-03 11:46:08 +01:00
Gabor Kiss-Vamosi
315f03f8b6 merge master 2021-02-03 10:33:22 +01:00
Gabor Kiss-Vamosi
7cbcc878cc Merge branch 'dev' of https://github.com/littlevgl/lvgl into dev 2021-02-03 10:31:33 +01:00
Gabor Kiss-Vamosi
fe47caf161 update CHANGELOG 2021-02-03 10:31:20 +01:00
Gabor Kiss-Vamosi
8b78688c79 fix(text): fix out of bounds read in _lv_txt_get_width 2021-02-03 10:29:45 +01:00
Gabor Kiss-Vamosi
1b25649483 Merge branch 'fix/indev' 2021-02-03 10:06:18 +01:00
Gabor Kiss-Vamosi
0631b17076 fix(indev): clear the indev's act_obj in lv_indev_reset
fixes #2052
2021-02-03 10:06:07 +01:00
Gabor Kiss-Vamosi
cc8b564352 Update master version 2021-02-02 15:17:59 +01:00
Gabor Kiss-Vamosi
21051b8d60 Merge branch 'master' into dev 2021-02-02 15:12:11 +01:00
github-actions[bot]
890ef3fde2 Merge 222afe9e9b into dev 2021-02-02 14:01:26 +00:00
github-actions[bot]
28778c7bd7 Merge b38ceb52eb into dev 2021-02-01 13:55:35 +00:00
github-actions[bot]
24cd0f981b Merge ced4f2a61f into dev 2021-02-01 11:09:46 +00:00
github-actions[bot]
138d20440e Merge 5e8d053adf into dev 2021-01-31 18:11:53 +00:00
github-actions[bot]
7911730dbd Merge 9fa5216263 into dev 2021-01-31 17:51:52 +00:00
github-actions[bot]
0db0bcca1b Merge 27154b632c into dev 2021-01-31 16:41:22 +00:00
github-actions[bot]
0daec88c1d Merge 9003f4a9e3 into dev 2021-01-28 08:48:58 +00:00
github-actions[bot]
b74b200485 Merge 1e91569763 into dev 2021-01-27 10:21:10 +00:00
github-actions[bot]
4f9c79a374 Merge df3cf24db4 into dev 2021-01-27 09:38:14 +00:00
github-actions[bot]
413b9003b9 Merge b6db434c21 into dev 2021-01-27 09:00:46 +00:00
github-actions[bot]
fe377d5b36 Merge 19f769f1d7 into dev 2021-01-26 17:19:03 +00:00
github-actions[bot]
c117dcadd0 Merge dacca6eeb8 into dev 2021-01-26 17:17:17 +00:00
github-actions[bot]
9e2fcfd1d0 Merge eaacde6722 into dev 2021-01-20 10:58:03 +00:00
github-actions[bot]
040e30020a Merge 762c0a3274 into dev 2021-01-20 10:57:29 +00:00
github-actions[bot]
cd815e2aa7 Merge f6fe3dcc8c into dev 2021-01-19 14:58:02 +00:00
github-actions[bot]
9ec84e2662 Merge 011f105038 into dev 2021-01-19 14:10:00 +00:00
Gabor Kiss-Vamosi
9c1d81db90 Update dev version 2021-01-19 14:50:06 +01:00
Gabor Kiss-Vamosi
4c93793fe5 Merge branch 'master' of https://github.com/littlevgl/lvgl into dev 2021-01-12 19:27:21 +01:00
59 changed files with 1196 additions and 879 deletions

2
.github/FUNDING.yml vendored
View File

@@ -1 +1 @@
custom: ["https://paypal.me/littlevgl?locale.x=en_US"]
open_collective: lvgl

View File

@@ -13,5 +13,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: ammaraskar/gcc-problem-matcher@master
- name: Run tests
run: sudo apt-get install libpng-dev; cd tests; python ./build.py

View File

@@ -1,6 +1,27 @@
# Changelog
## v7.10.0 (Planned for 02.02.2021)
## v7.11.0 (Planned for 19.02.2021)
### New features
- Add better screen orientation management with software rotation support
- Decide text animation's direction based on base_dir (when using LV_USE_BIDI)
### Bugfixes
- fix(gauge) fix needle invalidation
- fix(bar) correct symmetric handling for vertical sliders
## v7.10.1 (Planned for 16.02.2021)
### Bugfixes
- fix(draw) overlap outline with background to prevent aliasing artifacts
- fix(indev) clear the indev's `act_obj` in `lv_indev_reset`
- fix(text) fix out of bounds read in `_lv_txt_get_width`
- fix(list) scroll list when button is focused using LV_KEY_NEXT/PREV
- fix(text) improve Arabic contextual analysis by adding hyphen processing and proper handling of lam-alef sequence
- fix(delete) delete animation after the children are deleted
- fix(gauge) consider paddigns for needle images
## v7.10.0
### New features
- feat(indev) allow input events to be passed to disabled objects

View File

@@ -60,5 +60,8 @@ zephyr_library_sources(${SOURCES})
endif() # CONFIG_LVGL
else()
message(FATAL_ERROR "Unknown platform.")
file(GLOB_RECURSE SOURCES src/*.c)
add_library(lvgl STATIC ${SOURCES})
endif()

12
Kconfig
View File

@@ -1,4 +1,4 @@
# Kconfig file for LVGL v7.8.1
# Kconfig file for LVGL v7.11.0
menu "LVGL configuration"
@@ -846,6 +846,11 @@ menu "LVGL configuration"
default 0x000000 if LV_THEME_DEFAULT_INIT_MONO
help
See lv_misc/lv_color.h for some color values examples.
When using LV_THEME_MONO the suggested values to use are
0x000000 (LV_COLOR_BLACK) or 0xFFFFFF (LV_COLOR_WHITE).
If LV_THEME_DEFAULT_COLOR_PRIMARY is 0x000000 (LV_COLOR_BLACK)
the texts and borders will be black and the background will be
white, otherwise the colors are inverted.
config LV_THEME_DEFAULT_COLOR_SECONDARY
hex "Select theme default secondary color"
@@ -854,6 +859,11 @@ menu "LVGL configuration"
default 0xFFFFFF if LV_THEME_DEFAULT_INIT_MONO
help
See lv_misc/lv_color.h for some color values examples.
When using LV_THEME_MONO the suggested values to use are
0x000000 (LV_COLOR_BLACK) or 0xFFFFFF (LV_COLOR_WHITE).
If LV_THEME_DEFAULT_COLOR_PRIMARY is 0x000000 (LV_COLOR_BLACK)
the texts and borders will be black and the background will be
white, otherwise the colors are inverted.
choice LV_THEME_DEFAULT_FLAG
depends on LV_THEME_MATERIAL

23
component.mk Normal file
View File

@@ -0,0 +1,23 @@
# ESP-IDF component file for make based commands
COMPONENT_SRCDIRS := .
COMPONENT_SRCDIRS += src
COMPONENT_SRCDIRS += src/lv_core
COMPONENT_SRCDIRS += src/lv_draw
COMPONENT_SRCDIRS += src/lv_font
COMPONENT_SRCDIRS += src/lv_gpu
COMPONENT_SRCDIRS += src/lv_hal
COMPONENT_SRCDIRS += src/lv_misc
COMPONENT_SRCDIRS += src/lv_themes
COMPONENT_SRCDIRS += src/lv_widgets
COMPONENT_ADD_INCLUDEDIRS := .
COMPONENT_ADD_INCLUDEDIRS += src
COMPONENT_ADD_INCLUDEDIRS += src/lv_core
COMPONENT_ADD_INCLUDEDIRS += src/lv_draw
COMPONENT_ADD_INCLUDEDIRS += src/lv_font
COMPONENT_ADD_INCLUDEDIRS += src/lv_gpu
COMPONENT_ADD_INCLUDEDIRS += src/lv_hal
COMPONENT_ADD_INCLUDEDIRS += src/lv_misc
COMPONENT_ADD_INCLUDEDIRS += src/lv_themes
COMPONENT_ADD_INCLUDEDIRS += src/lv_widgets

View File

@@ -82,13 +82,13 @@ void lv_port_disp_init(void)
/* Example for 2) */
static lv_disp_buf_t draw_buf_dsc_2;
static lv_color_t draw_buf_2_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/
static lv_color_t draw_buf_2_1[LV_HOR_RES_MAX * 10]; /*An other buffer for 10 rows*/
lv_disp_buf_init(&draw_buf_dsc_2, draw_buf_2_1, draw_buf_2_1, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
static lv_color_t draw_buf_2_2[LV_HOR_RES_MAX * 10]; /*An other buffer for 10 rows*/
lv_disp_buf_init(&draw_buf_dsc_2, draw_buf_2_1, draw_buf_2_2, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
/* Example for 3) */
static lv_disp_buf_t draw_buf_dsc_3;
static lv_color_t draw_buf_3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*A screen sized buffer*/
static lv_color_t draw_buf_3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*An other screen sized buffer*/
static lv_color_t draw_buf_3_2[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*An other screen sized buffer*/
lv_disp_buf_init(&draw_buf_dsc_3, draw_buf_3_1, draw_buf_3_2, LV_HOR_RES_MAX * LV_VER_RES_MAX); /*Initialize the display buffer*/
/*-----------------------------------

View File

@@ -1,6 +1,6 @@
{
"name": "lvgl",
"version": "7.10.0",
"version": "7.11.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": {

View File

@@ -1,5 +1,5 @@
name=lvgl
version=7.10.0
version=7.11.0
author=kisvegabor
maintainer=kisvegabor,embeddedt,pete-pjb
sentence=Full-featured Graphics Library for Embedded Systems

View File

@@ -1,6 +1,6 @@
/**
* @file lv_conf.h
* Configuration file for v7.10.0
* Configuration file for v7.11.0
*/
/*
@@ -69,6 +69,9 @@
/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */
typedef int16_t lv_coord_t;
/* Maximum buffer size to allocate for rotation. Only used if software rotation is enabled. */
#define LV_DISP_ROT_MAX_BUF (10U * 1024U)
/*=========================
Memory manager settings
*=========================*/

2
lvgl.h
View File

@@ -14,7 +14,7 @@ extern "C" {
* CURRENT VERSION OF LVGL
***************************/
#define LVGL_VERSION_MAJOR 7
#define LVGL_VERSION_MINOR 10
#define LVGL_VERSION_MINOR 11
#define LVGL_VERSION_PATCH 0
#define LVGL_VERSION_INFO ""

View File

@@ -27,12 +27,6 @@ fout.write(
#include <stdint.h>
/* Add ESP-IDF related includes */
#if defined (ESP_PLATFORM)
# include "sdkconfig.h"
# include "esp_attr.h"
#endif
/* Handle special Kconfig options */
#include "lv_conf_kconfig.h"

View File

@@ -98,10 +98,10 @@ def update_version(ver):
cmd("sed -i -r 's/version=[0-9]+\.[0-9]+\.[0-9]+/"+ "version=" + ver_num + "/' library.properties")
if path.exists("conf.py"):
cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" conf.py")
cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+.*/" + ver_str + "/' conf.py")
if path.exists("Kconfig"):
cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" Kconfig")
cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+.*/" + ver_str + "/' Kconfig")
if path.exists("lvgl.h"):
define_set("./lvgl.h", "LVGL_VERSION_MAJOR", str(ver[0]))

View File

@@ -10,12 +10,6 @@
#include <stdint.h>
/* Add ESP-IDF related includes */
#if defined (ESP_PLATFORM)
# include "sdkconfig.h"
# include "esp_attr.h"
#endif
/* Handle special Kconfig options */
#include "lv_conf_kconfig.h"
@@ -176,6 +170,15 @@
/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */
/* Maximum buffer size to allocate for rotation. Only used if software rotation is enabled. */
#ifndef LV_DISP_ROT_MAX_BUF
# ifdef CONFIG_LV_DISP_ROT_MAX_BUF
# define LV_DISP_ROT_MAX_BUF CONFIG_LV_DISP_ROT_MAX_BUF
# else
# define LV_DISP_ROT_MAX_BUF (10U * 1024U)
# endif
#endif
/*=========================
Memory manager settings
*=========================*/

View File

@@ -164,6 +164,12 @@ void lv_indev_reset(lv_indev_t * indev, lv_obj_t * obj)
if(obj == NULL || indev->proc.types.pointer.last_pressed == obj) {
indev->proc.types.pointer.last_pressed = NULL;
}
if(obj == NULL || indev->proc.types.pointer.act_obj == obj) {
indev->proc.types.pointer.act_obj = NULL;
}
if(obj == NULL || indev->proc.types.pointer.last_obj == obj) {
indev->proc.types.pointer.last_obj = NULL;
}
}
else {
lv_indev_t * i = lv_indev_get_next(NULL);
@@ -173,6 +179,12 @@ void lv_indev_reset(lv_indev_t * indev, lv_obj_t * obj)
if(obj == NULL || i->proc.types.pointer.last_pressed == obj) {
i->proc.types.pointer.last_pressed = NULL;
}
if(obj == NULL || i->proc.types.pointer.act_obj == obj) {
i->proc.types.pointer.act_obj = NULL;
}
if(obj == NULL || i->proc.types.pointer.last_obj == obj) {
i->proc.types.pointer.last_obj = NULL;
}
i = lv_indev_get_next(i);
}
}
@@ -401,6 +413,16 @@ lv_task_t * lv_indev_get_read_task(lv_disp_t * indev)
*/
static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data)
{
lv_disp_t * disp = i->driver.disp;
if(disp->driver.rotated == LV_DISP_ROT_180 || disp->driver.rotated == LV_DISP_ROT_270) {
data->point.x = disp->driver.hor_res - data->point.x - 1;
data->point.y = disp->driver.ver_res - data->point.y - 1;
}
if(disp->driver.rotated == LV_DISP_ROT_90 || disp->driver.rotated == LV_DISP_ROT_270) {
lv_coord_t tmp = data->point.y;
data->point.y = data->point.x;
data->point.x = disp->driver.ver_res - tmp - 1;
}
/*Move the cursor if set and moved*/
if(i->cursor != NULL &&
(i->proc.types.pointer.last_point.x != data->point.x || i->proc.types.pointer.last_point.y != data->point.y)) {

View File

@@ -1743,7 +1743,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
lv_style_int_t time = lv_obj_get_style_transition_time(obj, part);
lv_style_property_t props[LV_STYLE_TRANS_NUM_MAX];
lv_style_int_t delay = lv_obj_get_style_transition_delay(obj, part);
lv_anim_path_t * path = lv_obj_get_style_transition_path(obj, part);
const lv_anim_path_t * path = lv_obj_get_style_transition_path(obj, part);
props[0] = lv_obj_get_style_transition_prop_1(obj, part);
props[1] = lv_obj_get_style_transition_prop_2(obj, part);
props[2] = lv_obj_get_style_transition_prop_3(obj, part);
@@ -3474,6 +3474,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
if(opa_scale < LV_OPA_MAX) {
draw_dsc->bg_opa = (uint16_t)((uint16_t)draw_dsc->bg_opa * opa_scale) >> 8;
draw_dsc->border_opa = (uint16_t)((uint16_t)draw_dsc->border_opa * opa_scale) >> 8;
draw_dsc->outline_opa = (uint16_t)((uint16_t)draw_dsc->outline_opa * opa_scale) >> 8;
draw_dsc->shadow_opa = (uint16_t)((uint16_t)draw_dsc->shadow_opa * opa_scale) >> 8;
draw_dsc->pattern_opa = (uint16_t)((uint16_t)draw_dsc->pattern_opa * opa_scale) >> 8;
draw_dsc->value_opa = (uint16_t)((uint16_t)draw_dsc->value_opa * opa_scale) >> 8;
@@ -3764,12 +3765,6 @@ static void obj_del_core(lv_obj_t * obj)
if(group) lv_group_remove_obj(obj);
#endif
/*Remove the animations from this object*/
#if LV_USE_ANIMATION
lv_anim_del(obj, NULL);
trans_del(obj, 0xFF, 0xFF, NULL);
#endif
/*Delete the user data*/
#if LV_USE_USER_DATA
#if LV_USE_USER_DATA_FREE
@@ -3788,6 +3783,12 @@ static void obj_del_core(lv_obj_t * obj)
i = _lv_ll_get_head(&(obj->child_ll));
}
/*Remove the animations from this object*/
#if LV_USE_ANIMATION
lv_anim_del(obj, NULL);
trans_del(obj, 0xFF, 0xFF, NULL);
#endif
lv_event_mark_deleted(obj);
/* Reset all input devices if the object to delete is used*/

View File

@@ -58,147 +58,140 @@ extern "C" {
* `lv_style_set_border_width(&style1, LV_STATE_PRESSED, 2);`
*/
#define _OBJ_GET_STYLE_scalar(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
#ifdef __cplusplus
#define _OBJ_GET_STYLE(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name(const lv_obj_t * obj, uint8_t part) \
{ \
return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
return (value_type)_lv_obj_get_style##style_type(obj, part, LV_STYLE_##prop_name); \
}
#define _OBJ_GET_STYLE_nonscalar(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
#else
#define _OBJ_GET_STYLE(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name(const lv_obj_t * obj, uint8_t part) \
{ \
return _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
return _lv_obj_get_style##style_type(obj, part, LV_STYLE_##prop_name); \
}
#endif
#define _OBJ_SET_STYLE_LOCAL_scalar(prop_name, func_name, value_type, style_type) \
static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
#define _OBJ_SET_STYLE_LOCAL(prop_name, func_name, value_type, style_type) \
static inline void lv_obj_set_style_local_##func_name(lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
{ \
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
_lv_obj_set_style_local##style_type(obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
#define _OBJ_SET_STYLE_LOCAL_nonscalar(prop_name, func_name, value_type, style_type) \
static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
{ \
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
#define _OBJ_SET_STYLE_scalar(prop_name, func_name, value_type, style_type) \
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
#define _OBJ_SET_STYLE(prop_name, func_name, value_type, style_type) \
static inline void lv_style_set_##func_name(lv_style_t * style, lv_state_t state, value_type value) \
{ \
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
_lv_style_set##style_type(style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
#define _OBJ_SET_STYLE_nonscalar(prop_name, func_name, value_type, style_type) \
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
{ \
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
#define _LV_OBJ_STYLE_SET_GET_DECLARE(prop_name, func_name, value_type, style_type) \
_OBJ_GET_STYLE(prop_name, func_name, value_type, style_type) \
_OBJ_SET_STYLE_LOCAL(prop_name, func_name, value_type, style_type) \
_OBJ_SET_STYLE(prop_name, func_name, value_type, style_type)
#define _LV_OBJ_STYLE_SET_GET_DECLARE(prop_name, func_name, value_type, style_type, scalar) \
_OBJ_GET_STYLE_##scalar(prop_name, func_name, value_type, style_type) \
_OBJ_SET_STYLE_LOCAL_##scalar(prop_name, func_name, value_type, style_type) \
_OBJ_SET_STYLE_##scalar(prop_name, func_name, value_type, style_type)
_LV_OBJ_STYLE_SET_GET_DECLARE(RADIUS, radius, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(CLIP_CORNER, clip_corner, bool, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SIZE, size, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_WIDTH, transform_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_HEIGHT, transform_height, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_ANGLE, transform_angle, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_ZOOM, transform_zoom, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(OPA_SCALE, opa_scale, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_TOP, pad_top, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_BOTTOM, pad_bottom, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_LEFT, pad_left, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_RIGHT, pad_right, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_INNER, pad_inner, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_TOP, margin_top, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_BOTTOM, margin_bottom, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_LEFT, margin_left, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_RIGHT, margin_right, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_BLEND_MODE, bg_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_MAIN_STOP, bg_main_stop, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_STOP, bg_grad_stop, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_DIR, bg_grad_dir, lv_grad_dir_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_COLOR, bg_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_COLOR, bg_grad_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_OPA, bg_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_WIDTH, border_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_SIDE, border_side, lv_border_side_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_BLEND_MODE, border_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_POST, border_post, bool, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_COLOR, border_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_OPA, border_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_WIDTH, outline_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_PAD, outline_pad, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_BLEND_MODE, outline_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_COLOR, outline_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_OPA, outline_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_WIDTH, shadow_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OFS_X, shadow_ofs_x, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OFS_Y, shadow_ofs_y, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_SPREAD, shadow_spread, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_BLEND_MODE, shadow_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_COLOR, shadow_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OPA, shadow_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_REPEAT, pattern_repeat, bool, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_BLEND_MODE, pattern_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_RECOLOR, pattern_recolor, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_OPA, pattern_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_RECOLOR_OPA, pattern_recolor_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_IMAGE, pattern_image, const void *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_LETTER_SPACE, value_letter_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_LINE_SPACE, value_line_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_BLEND_MODE, value_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OFS_X, value_ofs_x, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OFS_Y, value_ofs_y, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_ALIGN, value_align, lv_align_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_COLOR, value_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OPA, value_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LETTER_SPACE, text_letter_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LINE_SPACE, text_line_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_DECOR, text_decor, lv_text_decor_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_BLEND_MODE, text_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_COLOR, text_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_COLOR, text_sel_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_BG_COLOR, text_sel_bg_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_OPA, text_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_WIDTH, line_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_BLEND_MODE, line_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_DASH_WIDTH, line_dash_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_DASH_GAP, line_dash_gap, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_ROUNDED, line_rounded, bool, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_COLOR, line_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_OPA, line_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_BLEND_MODE, image_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_RECOLOR, image_recolor, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_OPA, image_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_RECOLOR_OPA, image_recolor_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_TIME, transition_time, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_DELAY, transition_delay, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_1, transition_prop_1, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_2, transition_prop_2, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_3, transition_prop_3, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_4, transition_prop_4, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_5, transition_prop_5, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_6, transition_prop_6, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(RADIUS, radius, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(CLIP_CORNER, clip_corner, bool, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(SIZE, size, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_WIDTH, transform_width, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_HEIGHT, transform_height, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_ANGLE, transform_angle, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSFORM_ZOOM, transform_zoom, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(OPA_SCALE, opa_scale, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_TOP, pad_top, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_BOTTOM, pad_bottom, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_LEFT, pad_left, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_RIGHT, pad_right, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_INNER, pad_inner, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_TOP, margin_top, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_BOTTOM, margin_bottom, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_LEFT, margin_left, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(MARGIN_RIGHT, margin_right, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_BLEND_MODE, bg_blend_mode, lv_blend_mode_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_MAIN_STOP, bg_main_stop, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_STOP, bg_grad_stop, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_DIR, bg_grad_dir, lv_grad_dir_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_COLOR, bg_color, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_GRAD_COLOR, bg_grad_color, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(BG_OPA, bg_opa, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_WIDTH, border_width, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_SIDE, border_side, lv_border_side_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_BLEND_MODE, border_blend_mode, lv_blend_mode_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_POST, border_post, bool, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_COLOR, border_color, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(BORDER_OPA, border_opa, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_WIDTH, outline_width, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_PAD, outline_pad, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_BLEND_MODE, outline_blend_mode, lv_blend_mode_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_COLOR, outline_color, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_OPA, outline_opa, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_WIDTH, shadow_width, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OFS_X, shadow_ofs_x, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OFS_Y, shadow_ofs_y, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_SPREAD, shadow_spread, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_BLEND_MODE, shadow_blend_mode, lv_blend_mode_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_COLOR, shadow_color, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OPA, shadow_opa, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_REPEAT, pattern_repeat, bool, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_BLEND_MODE, pattern_blend_mode, lv_blend_mode_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_RECOLOR, pattern_recolor, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_OPA, pattern_opa, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_RECOLOR_OPA, pattern_recolor_opa, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_IMAGE, pattern_image, const void *, _ptr)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_LETTER_SPACE, value_letter_space, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_LINE_SPACE, value_line_space, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_BLEND_MODE, value_blend_mode, lv_blend_mode_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OFS_X, value_ofs_x, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OFS_Y, value_ofs_y, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_ALIGN, value_align, lv_align_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_COLOR, value_color, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OPA, value_opa, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t *, _ptr)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char *, _ptr)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LETTER_SPACE, text_letter_space, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LINE_SPACE, text_line_space, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_DECOR, text_decor, lv_text_decor_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_BLEND_MODE, text_blend_mode, lv_blend_mode_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_COLOR, text_color, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_COLOR, text_sel_color, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_BG_COLOR, text_sel_bg_color, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_OPA, text_opa, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t *, _ptr)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_WIDTH, line_width, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_BLEND_MODE, line_blend_mode, lv_blend_mode_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_DASH_WIDTH, line_dash_width, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_DASH_GAP, line_dash_gap, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_ROUNDED, line_rounded, bool, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_COLOR, line_color, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_OPA, line_opa, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_BLEND_MODE, image_blend_mode, lv_blend_mode_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_RECOLOR, image_recolor, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_OPA, image_opa, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_RECOLOR_OPA, image_recolor_opa, lv_opa_t, _opa)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_TIME, transition_time, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_DELAY, transition_delay, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_1, transition_prop_1, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_2, transition_prop_2, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_3, transition_prop_3, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_4, transition_prop_4, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_5, transition_prop_5, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_6, transition_prop_6, lv_style_int_t, _int)
#if LV_USE_ANIMATION
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_anim_path_t *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, const lv_anim_path_t *, _ptr)
#else
/*For compatibility*/
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, const void *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, const void *, _ptr)
#endif
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_WIDTH, scale_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_BORDER_WIDTH, scale_border_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_BORDER_WIDTH, scale_end_border_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_LINE_WIDTH, scale_end_line_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_GRAD_COLOR, scale_grad_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_COLOR, scale_end_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_WIDTH, scale_width, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_BORDER_WIDTH, scale_border_width, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_BORDER_WIDTH, scale_end_border_width, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_LINE_WIDTH, scale_end_line_width, lv_style_int_t, _int)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_GRAD_COLOR, scale_grad_color, lv_color_t, _color)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_COLOR, scale_end_color, lv_color_t, _color)
#undef _LV_OBJ_STYLE_SET_GET_DECLARE
#undef _OBJ_SET_STYLE_LOCAL
#undef _OBJ_SET_STYLE
#undef _OBJ_GET_STYLE
static inline void lv_obj_set_style_local_pad_all(lv_obj_t * obj, uint8_t part, lv_state_t state, lv_style_int_t value)
{
@@ -287,4 +280,4 @@ static inline void lv_style_set_margin_ver(lv_style_t * style, lv_state_t state,
} /* extern "C" */
#endif
#endif /*LV_OBJ_H*/
#endif /*LV_OBJ_STYLE_DEC_H*/

View File

@@ -741,12 +741,182 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
}
}
static void lv_refr_vdb_rotate_180(lv_disp_drv_t * drv, lv_area_t * area, lv_color_t * color_p)
{
lv_coord_t area_w = lv_area_get_width(area);
lv_coord_t area_h = lv_area_get_height(area);
uint32_t total = area_w * area_h;
/* Swap the beginning and end values */
lv_color_t tmp;
uint32_t i = total - 1, j = 0;
while(i > j) {
tmp = color_p[i];
color_p[i] = color_p[j];
color_p[j] = tmp;
i--;
j++;
}
lv_coord_t tmp_coord;
tmp_coord = area->y2;
area->y2 = drv->ver_res - area->y1 - 1;
area->y1 = drv->ver_res - tmp_coord - 1;
tmp_coord = area->x2;
area->x2 = drv->hor_res - area->x1 - 1;
area->x1 = drv->hor_res - tmp_coord - 1;
}
static LV_ATTRIBUTE_FAST_MEM void lv_refr_vdb_rotate_90(bool invert_i, lv_coord_t area_w, lv_coord_t area_h,
lv_color_t * orig_color_p, lv_color_t * rot_buf)
{
uint32_t invert = (area_w * area_h) - 1;
uint32_t initial_i = ((area_w - 1) * area_h);
for(lv_coord_t y = 0; y < area_h; y++) {
uint32_t i = initial_i + y;
if(invert_i)
i = invert - i;
for(lv_coord_t x = 0; x < area_w; x++) {
rot_buf[i] = *(orig_color_p++);
if(invert_i)
i += area_h;
else
i -= area_h;
}
}
}
/**
* Helper function for lv_refr_vdb_rotate_90_sqr. Given a list of four numbers, rotate the entire list to the left.
*/
static inline void lv_vdb_rotate4(lv_color_t * a, lv_color_t * b, lv_color_t * c, lv_color_t * d)
{
lv_color_t tmp;
tmp = *a;
*a = *b;
*b = *c;
*c = *d;
*d = tmp;
}
/**
* Rotate a square image 90/270 degrees in place.
* @note inspired by https://stackoverflow.com/a/43694906
*/
static void lv_refr_vdb_rotate_90_sqr(bool is_270, lv_coord_t w, lv_color_t * color_p)
{
for(lv_coord_t i = 0; i < w / 2; i++) {
for(lv_coord_t j = 0; j < (w + 1) / 2; j++) {
lv_coord_t inv_i = (w - 1) - i;
lv_coord_t inv_j = (w - 1) - j;
if(is_270) {
lv_vdb_rotate4(
&color_p[i * w + j],
&color_p[inv_j * w + i],
&color_p[inv_i * w + inv_j],
&color_p[j * w + inv_i]
);
}
else {
lv_vdb_rotate4(
&color_p[i * w + j],
&color_p[j * w + inv_i],
&color_p[inv_i * w + inv_j],
&color_p[inv_j * w + i]
);
}
}
}
}
/**
* Rotate the VDB to the display's native orientation.
*/
static void lv_refr_vdb_rotate(lv_area_t * area, lv_color_t * color_p)
{
lv_disp_drv_t * drv = &disp_refr->driver;
if(lv_disp_is_true_double_buf(disp_refr) && drv->sw_rotate) {
LV_LOG_ERROR("cannot rotate a true double-buffered display!");
return;
}
if(drv->rotated == LV_DISP_ROT_180) {
lv_refr_vdb_rotate_180(drv, area, color_p);
drv->flush_cb(drv, area, color_p);
}
else if(drv->rotated == LV_DISP_ROT_90 || drv->rotated == LV_DISP_ROT_270) {
/*Allocate a temporary buffer to store rotated image */
lv_color_t * rot_buf = NULL;
lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
lv_coord_t area_w = lv_area_get_width(area);
lv_coord_t area_h = lv_area_get_height(area);
/*Determine the maximum number of rows that can be rotated at a time*/
lv_coord_t max_row = LV_MATH_MIN((lv_coord_t)((LV_DISP_ROT_MAX_BUF / sizeof(lv_color_t)) / area_w), area_h);
lv_coord_t init_y_off;
init_y_off = area->y1;
if(drv->rotated == LV_DISP_ROT_90) {
area->y2 = drv->ver_res - area->x1 - 1;
area->y1 = area->y2 - area_w + 1;
}
else {
area->y1 = area->x1;
area->y2 = area->y1 + area_w - 1;
}
vdb->flushing = 0;
/*Rotate the screen in chunks, flushing after each one*/
lv_coord_t row = 0;
while(row < area_h) {
lv_coord_t height = LV_MATH_MIN(max_row, area_h - row);
vdb->flushing = 1;
if((row == 0) && (area_h >= area_w)) {
/*Rotate the initial area as a square*/
height = area_w;
lv_refr_vdb_rotate_90_sqr(drv->rotated == LV_DISP_ROT_270, area_w, color_p);
if(drv->rotated == LV_DISP_ROT_90) {
area->x1 = init_y_off;
area->x2 = init_y_off + area_w - 1;
}
else {
area->x2 = drv->hor_res - 1 - init_y_off;
area->x1 = area->x2 - area_w + 1;
}
}
else {
/*Rotate other areas using a maximum buffer size*/
if(rot_buf == NULL)
rot_buf = _lv_mem_buf_get(LV_DISP_ROT_MAX_BUF);
lv_refr_vdb_rotate_90(drv->rotated == LV_DISP_ROT_270, area_w, height, color_p, rot_buf);
if(drv->rotated == LV_DISP_ROT_90) {
area->x1 = init_y_off + row;
area->x2 = init_y_off + row + height - 1;
}
else {
area->x2 = drv->hor_res - 1 - init_y_off - row;
area->x1 = area->x2 - height + 1;
}
}
/*Flush the completed area to the display*/
drv->flush_cb(drv, area, rot_buf == NULL ? color_p : rot_buf);
/*FIXME: Rotation forces legacy behavior where rendering and flushing are done serially*/
while(vdb->flushing) {
if(drv->wait_cb) drv->wait_cb(drv);
}
color_p += area_w * height;
row += height;
}
/*Free the allocated buffer at the end if necessary*/
if(rot_buf != NULL)
_lv_mem_buf_release(rot_buf);
}
}
/**
* Flush the content of the VDB
*/
static void lv_refr_vdb_flush(void)
{
lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
lv_color_t * color_p = vdb->buf_act;
/*In double buffered mode wait until the other buffer is flushed before flushing the current
* one*/
@@ -765,8 +935,15 @@ static void lv_refr_vdb_flush(void)
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
if(disp->driver.gpu_wait_cb) disp->driver.gpu_wait_cb(&disp->driver);
if(disp->driver.flush_cb) disp->driver.flush_cb(&disp->driver, &vdb->area, vdb->buf_act);
if(disp->driver.flush_cb) {
/*Rotate the buffer to the display's native orientation if necessary*/
if(disp->driver.rotated != LV_DISP_ROT_NONE && disp->driver.sw_rotate) {
lv_refr_vdb_rotate(&vdb->area, vdb->buf_act);
}
else {
disp->driver.flush_cb(&disp->driver, &vdb->area, color_p);
}
}
if(vdb->buf1 && vdb->buf2) {
if(vdb->buf_act == vdb->buf1)
vdb->buf_act = vdb->buf2;

View File

@@ -6,26 +6,12 @@
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
#include "lv_style.h"
#include "../lv_misc/lv_mem.h"
#include "../lv_misc/lv_anim.h"
/*********************
* DEFINES
*********************/
#define STYLE_MIX_MAX 256
#define STYLE_MIX_SHIFT 8 /*log2(STYLE_MIX_MAX)*/
#define VAL_PROP(v1, v2, r) v1 + (((v2 - v1) * r) >> STYLE_MIX_SHIFT)
#define STYLE_ATTR_MIX(attr, r) \
if(start->attr != end->attr) { \
res->attr = VAL_PROP(start->attr, end->attr, r); \
} else { \
res->attr = start->attr; \
}
#define LV_STYLE_PROP_TO_ID(prop) (prop & 0xFF);
#define LV_STYLE_PROP_GET_TYPE(prop) ((prop >> 8) & 0xFF);
/**********************
* TYPEDEFS
@@ -36,7 +22,7 @@
**********************/
LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop);
static lv_style_t * get_alloc_local_style(lv_style_list_t * list);
static inline void style_resize(lv_style_t * style, size_t sz);
static inline bool style_resize(lv_style_t * style, size_t sz);
static inline lv_style_property_t get_style_prop(const lv_style_t * style, size_t idx);
static inline uint8_t get_style_prop_id(const lv_style_t * style, size_t idx);
static inline uint8_t get_style_prop_attr(const lv_style_t * style, size_t idx);
@@ -78,16 +64,14 @@ void lv_style_init(lv_style_t * style)
*/
void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src)
{
if(style_src == NULL) return;
LV_ASSERT_STYLE(style_dest);
LV_ASSERT_STYLE(style_src);
if(style_src->map == NULL) return;
uint16_t size = _lv_style_get_mem_size(style_src);
if(size == 0) return;
style_dest->map = lv_mem_alloc(size);
_lv_memcpy(style_dest->map, style_src->map, size);
if(style_dest->map)
_lv_memcpy(style_dest->map, style_src->map, size);
}
/**
@@ -99,9 +83,6 @@ void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src)
*/
bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop)
{
if(style == NULL) return false;
LV_ASSERT_STYLE(style);
int32_t id = get_property_index(style, prop);
/*The property exists but not sure it's state is the same*/
if(id >= 0) {
@@ -154,35 +135,44 @@ void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * lis
_lv_style_list_reset(list_dest);
if(list_src->style_list == NULL) return;
if(list_src == NULL || list_src->style_list == NULL) return;
/*Copy the styles but skip the transitions*/
if(list_src->has_local == 0) {
if(list_src->has_trans) {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *));
_lv_memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 1;
if(list_dest->style_list) {
_lv_memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 1;
}
}
else {
list_dest->style_list = lv_mem_alloc(list_src->style_cnt * sizeof(lv_style_t *));
_lv_memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt;
if(list_dest->style_list) {
_lv_memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt;
}
}
}
else {
if(list_src->has_trans) {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 2) * sizeof(lv_style_t *));
_lv_memcpy(list_dest->style_list, list_src->style_list + 2, (list_src->style_cnt - 2) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 2;
if(list_dest->style_list) {
_lv_memcpy(list_dest->style_list, list_src->style_list + 2, (list_src->style_cnt - 2) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 2;
}
}
else {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *));
_lv_memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 1;
if(list_dest->style_list) {
_lv_memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 1;
}
}
lv_style_t * local_style = get_alloc_local_style(list_dest);
lv_style_copy(local_style, get_alloc_local_style((lv_style_list_t *)list_src));
if(local_style)
lv_style_copy(local_style, get_alloc_local_style((lv_style_list_t *)list_src));
}
}
@@ -203,12 +193,12 @@ void _lv_style_list_add_style(lv_style_list_t * list, lv_style_t * style)
/*Remove the style first if already exists*/
_lv_style_list_remove_style(list, style);
lv_style_t ** new_classes;
if(list->style_cnt == 0) new_classes = lv_mem_alloc(sizeof(lv_style_t *));
else new_classes = lv_mem_realloc(list->style_list, sizeof(lv_style_t *) * (list->style_cnt + 1));
LV_ASSERT_MEM(new_classes);
if(new_classes == NULL) {
LV_LOG_WARN("lv_style_list_add_style: couldn't add the class");
lv_style_t ** new_styles;
if(list->style_cnt == 0) new_styles = lv_mem_alloc(sizeof(lv_style_t *));
else new_styles = lv_mem_realloc(list->style_list, sizeof(lv_style_t *) * (list->style_cnt + 1));
LV_ASSERT_MEM(new_styles);
if(new_styles == NULL) {
LV_LOG_WARN("lv_style_list_add_style: couldn't add the style");
return;
}
@@ -218,12 +208,12 @@ void _lv_style_list_add_style(lv_style_list_t * list, lv_style_t * style)
if(list->has_trans) first_style++;
if(list->has_local) first_style++;
for(i = list->style_cnt; i > first_style; i--) {
new_classes[i] = new_classes[i - 1];
new_styles[i] = new_styles[i - 1];
}
new_classes[first_style] = style;
new_styles[first_style] = style;
list->style_cnt++;
list->style_list = new_classes;
list->style_list = new_styles;
}
/**
@@ -257,24 +247,22 @@ void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style)
return;
}
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");
lv_style_t ** new_styles = lv_mem_alloc(sizeof(lv_style_t *) * (list->style_cnt - 1));
LV_ASSERT_MEM(new_styles);
if(new_styles == NULL) {
LV_LOG_WARN("lv_style_list_remove_style: couldn't reallocate style list");
return;
}
uint8_t j;
for(i = 0, j = 0; i < list->style_cnt; i++) {
if(list->style_list[i] == style) continue;
new_classes[j] = list->style_list[i];
j++;
new_styles[j++] = list->style_list[i];
}
lv_mem_free(list->style_list);
list->style_cnt--;
list->style_list = new_classes;
list->style_list = new_styles;
}
/**
@@ -321,10 +309,8 @@ void _lv_style_list_reset(lv_style_list_t * list)
*/
void lv_style_reset(lv_style_t * style)
{
LV_ASSERT_STYLE(style);
lv_mem_free(style->map);
style->map = NULL;
lv_style_init(style);
}
/**
@@ -336,7 +322,7 @@ uint16_t _lv_style_get_mem_size(const lv_style_t * style)
{
LV_ASSERT_STYLE(style);
if(style->map == NULL) return 0;
if(style == NULL || style->map == NULL) return 0;
size_t i = 0;
uint8_t prop_id;
@@ -359,8 +345,6 @@ uint16_t _lv_style_get_mem_size(const lv_style_t * style)
*/
void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_int_t value)
{
LV_ASSERT_STYLE(style);
int32_t id = get_property_index(style, prop);
/*The property already exists but not sure it's state is the same*/
if(id >= 0) {
@@ -377,16 +361,15 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in
}
/*Add new property if not exists yet*/
uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(lv_style_int_t));
uint8_t new_prop_size = sizeof(lv_style_property_t) + sizeof(lv_style_int_t);
lv_style_property_t end_mark = _LV_STYLE_CLOSING_PROP;
uint8_t end_mark_size = sizeof(end_mark);
uint16_t size = _lv_style_get_mem_size(style);
if(size == 0) size += end_mark_size;
size += sizeof(lv_style_property_t) + sizeof(lv_style_int_t);
style_resize(style, size);
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
size += new_prop_size;
if(!style_resize(style, size)) return;
_lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
_lv_memcpy_small(style->map + size - sizeof(lv_style_int_t) - end_mark_size, &value, sizeof(lv_style_int_t));
@@ -405,8 +388,6 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in
*/
void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_t color)
{
LV_ASSERT_STYLE(style);
int32_t id = get_property_index(style, prop);
/*The property already exists but not sure it's state is the same*/
if(id >= 0) {
@@ -423,17 +404,15 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_
}
/*Add new property if not exists yet*/
uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(lv_color_t));
uint8_t new_prop_size = sizeof(lv_style_property_t) + sizeof(lv_color_t);
lv_style_property_t end_mark = _LV_STYLE_CLOSING_PROP;
uint8_t end_mark_size = sizeof(end_mark);
uint16_t size = _lv_style_get_mem_size(style);
if(size == 0) size += end_mark_size;
size += sizeof(lv_style_property_t) + sizeof(lv_color_t);
style_resize(style, size);
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
size += new_prop_size;
if(!style_resize(style, size)) return;
_lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
_lv_memcpy_small(style->map + size - sizeof(lv_color_t) - end_mark_size, &color, sizeof(lv_color_t));
@@ -452,8 +431,6 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_
*/
void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t opa)
{
LV_ASSERT_STYLE(style);
int32_t id = get_property_index(style, prop);
/*The property already exists but not sure it's state is the same*/
if(id >= 0) {
@@ -470,17 +447,15 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op
}
/*Add new property if not exists yet*/
uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(lv_opa_t));
uint8_t new_prop_size = sizeof(lv_style_property_t) + sizeof(lv_opa_t);
lv_style_property_t end_mark = _LV_STYLE_CLOSING_PROP;
uint8_t end_mark_size = sizeof(end_mark);
uint16_t size = _lv_style_get_mem_size(style);
if(size == 0) size += end_mark_size;
size += sizeof(lv_style_property_t) + sizeof(lv_opa_t);
style_resize(style, size);
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
size += new_prop_size;
if(!style_resize(style, size)) return;
_lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
_lv_memcpy_small(style->map + size - sizeof(lv_opa_t) - end_mark_size, &opa, sizeof(lv_opa_t));
@@ -499,8 +474,6 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op
*/
void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void * p)
{
LV_ASSERT_STYLE(style);
int32_t id = get_property_index(style, prop);
/*The property already exists but not sure it's state is the same*/
if(id >= 0) {
@@ -517,17 +490,15 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void
}
/*Add new property if not exists yet*/
uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(const void *));
uint8_t new_prop_size = sizeof(lv_style_property_t) + sizeof(const void *);
lv_style_property_t end_mark = _LV_STYLE_CLOSING_PROP;
uint8_t end_mark_size = sizeof(end_mark);
uint16_t size = _lv_style_get_mem_size(style);
if(size == 0) size += end_mark_size;
size += sizeof(lv_style_property_t) + sizeof(const void *);
style_resize(style, size);
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
size += new_prop_size;
if(!style_resize(style, size)) return;
_lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
_lv_memcpy_small(style->map + size - sizeof(const void *) - end_mark_size, &p, sizeof(const void *));
@@ -535,7 +506,7 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void
}
/**
* Get the a property from a style.
* Get an integer typed property from a style.
* Take into account the style state and return the property which matches the best.
* @param style pointer to a style where to search
* @param prop the property, might contain ORed style states too
@@ -544,14 +515,8 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void
* Higher number is means better fit
* -1 if the not found (`res` will be undefined)
*/
int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, void * v_res)
int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, lv_style_int_t * res)
{
lv_style_int_t * res = (lv_style_int_t *)v_res;
LV_ASSERT_STYLE(style);
if(style == NULL) return -1;
if(style->map == NULL) return -1;
int32_t id = get_property_index(style, prop);
if(id < 0) {
return -1;
@@ -561,10 +526,7 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo
lv_style_attr_t attr_act;
attr_act = get_style_prop_attr(style, id);
lv_style_attr_t attr_goal;
attr_goal = (prop >> 8) & 0xFF;
return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal);
return LV_STYLE_ATTR_GET_STATE(attr_act);
}
}
@@ -581,14 +543,8 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo
* For example: `lv_style_get_border_opa()`
* @note for performance reasons it's not checked if the property really has opacity type
*/
int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, void * v_res)
int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, lv_opa_t * res)
{
lv_opa_t * res = (lv_opa_t *)v_res;
LV_ASSERT_STYLE(style);
if(style == NULL) return -1;
if(style->map == NULL) return -1;
int32_t id = get_property_index(style, prop);
if(id < 0) {
return -1;
@@ -598,10 +554,7 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo
lv_style_attr_t attr_act;
attr_act = get_style_prop_attr(style, id);
lv_style_attr_t attr_goal;
attr_goal = (prop >> 8) & 0xFF;
return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal);
return LV_STYLE_ATTR_GET_STATE(attr_act);
}
}
@@ -618,11 +571,8 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo
* For example: `lv_style_get_border_color()`
* @note for performance reasons it's not checked if the property really has color type
*/
int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop, void * v_res)
int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop, lv_color_t * res)
{
lv_color_t * res = (lv_color_t *)v_res;
if(style == NULL) return -1;
if(style->map == NULL) return -1;
int32_t id = get_property_index(style, prop);
if(id < 0) {
return -1;
@@ -632,10 +582,7 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop,
lv_style_attr_t attr_act;
attr_act = get_style_prop_attr(style, id);
lv_style_attr_t attr_goal;
attr_goal = (prop >> 8) & 0xFF;
return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal);
return LV_STYLE_ATTR_GET_STATE(attr_act);
}
}
@@ -652,12 +599,8 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop,
* For example: `lv_style_get_text_font()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void * v_res)
int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, const void ** res)
{
const void ** res = (const void **)v_res;
if(style == NULL) return -1;
if(style->map == NULL) return -1;
int32_t id = get_property_index(style, prop);
if(id < 0) {
return -1;
@@ -667,10 +610,7 @@ int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, vo
lv_style_attr_t attr_act;
attr_act = get_style_prop_attr(style, id);
lv_style_attr_t attr_goal;
attr_goal = (prop >> 8) & 0xFF;
return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal);
return LV_STYLE_ATTR_GET_STATE(attr_act);
}
}
@@ -824,9 +764,8 @@ lv_res_t _lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop
int16_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
/* changed class to _class to allow compilation as c++ */
lv_style_t * _class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_int(_class, prop, &value_act);
lv_style_t * style = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_int(style, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
@@ -846,7 +785,6 @@ lv_res_t _lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop
if(weight >= 0) return LV_RES_OK;
else return LV_RES_INV;
}
/**
@@ -878,8 +816,8 @@ lv_res_t _lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t pr
int16_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
lv_style_t * _class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_color(_class, prop, &value_act);
lv_style_t * style = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_color(style, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*res = value_act;
@@ -928,8 +866,8 @@ lv_res_t _lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop
int16_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
lv_style_t * _class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_opa(_class, prop, &value_act);
lv_style_t * style = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_opa(style, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*res = value_act;
@@ -978,8 +916,8 @@ lv_res_t _lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop
int16_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
lv_style_t * _class = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_ptr(_class, prop, &value_act);
lv_style_t * style = lv_style_list_get_style(list, ci);
int16_t weight_act = _lv_style_get_ptr(style, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*res = value_act;
@@ -1054,6 +992,7 @@ LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t
{
LV_ASSERT_STYLE(style);
if(style == NULL) return -1;
if(style->map == NULL) return -1;
uint8_t id_to_find = prop & 0xFF;
@@ -1094,7 +1033,7 @@ LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t
}
/**
* Get he local style from a style list. Allocate it if not exists yet.
* Get the local style from a style list. Allocate it if not exists yet.
* @param list pointer to a style list
* @return pointer to the local style
*/
@@ -1124,9 +1063,12 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list)
* @param style pointer to the style to be resized.
* @param size new size
*/
static inline void style_resize(lv_style_t * style, size_t sz)
static inline bool style_resize(lv_style_t * style, size_t sz)
{
style->map = lv_mem_realloc(style->map, sz);
uint8_t * new_map = lv_mem_realloc(style->map, sz);
if(sz && new_map == NULL) return false;
style->map = new_map;
return true;
}
/**
@@ -1138,9 +1080,7 @@ static inline void style_resize(lv_style_t * style, size_t sz)
static inline lv_style_property_t get_style_prop(const lv_style_t * style, size_t idx)
{
lv_style_property_t prop;
uint8_t * prop_p = (uint8_t *)&prop;
prop_p[0] = style->map[idx];
prop_p[1] = style->map[idx + 1];
_lv_memcpy_small(&prop, &style->map[idx], sizeof(lv_style_property_t));
return prop;
}
@@ -1169,8 +1109,7 @@ static inline uint8_t get_style_prop_attr(const lv_style_t * style, size_t idx)
/**
* Get property size.
* @param prop_id property id.
* @param idx index of the style in style->map
* @return attribute of property in style->map + idx
* @return size of property
*/
static inline size_t get_prop_size(uint8_t prop_id)
{

View File

@@ -100,7 +100,7 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_HEIGHT, 0x0, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ANGLE, 0x0, LV_STYLE_ID_VALUE + 6, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_ZOOM, 0x0, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OPA_SCALE, 0x0, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_OPA_SCALE, 0x0, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_PAD_TOP, 0x1, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PAD_BOTTOM, 0x1, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
@@ -127,11 +127,11 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_BORDER_COLOR, 0x3, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_BORDER_OPA, 0x3, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_WIDTH, 0x4, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_PAD, 0x4, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_BLEND_MODE, 0x4, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_COLOR, 0x4, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_OPA, 0x4, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_WIDTH, 0x4, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_PAD, 0x4, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_BLEND_MODE, 0x4, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_COLOR, 0x4, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_OPA, 0x4, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_WIDTH, 0x5, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_X, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
@@ -141,33 +141,33 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_COLOR, 0x5, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OPA, 0x5, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_BLEND_MODE, 0x6, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_REPEAT, 0x6, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_RECOLOR, 0x6, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_OPA, 0x6, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_RECOLOR_OPA, 0x6, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_IMAGE, 0x6, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_BLEND_MODE, 0x6, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_REPEAT, 0x6, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_RECOLOR, 0x6, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_OPA, 0x6, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_RECOLOR_OPA, 0x6, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_PATTERN_IMAGE, 0x6, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_LETTER_SPACE, 0x7, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_LINE_SPACE, 0x7, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_BLEND_MODE, 0x7, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_OFS_X, 0x7, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_OFS_Y, 0x7, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_ALIGN, 0x7, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_COLOR, 0x7, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_OPA, 0x7, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_FONT, 0x7, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_STR, 0x7, LV_STYLE_ID_PTR + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_LETTER_SPACE, 0x7, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_LINE_SPACE, 0x7, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_BLEND_MODE, 0x7, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_OFS_X, 0x7, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_OFS_Y, 0x7, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_ALIGN, 0x7, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_COLOR, 0x7, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_OPA, 0x7, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_FONT, 0x7, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_VALUE_STR, 0x7, LV_STYLE_ID_PTR + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LETTER_SPACE, 0x8, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LINE_SPACE, 0x8, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_DECOR, 0x8, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_BLEND_MODE, 0x8, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_COLOR, 0x8, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_SEL_COLOR, 0x8, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_SEL_BG_COLOR, 0x8, LV_STYLE_ID_COLOR + 2, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_OPA, 0x8, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_FONT, 0x8, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LETTER_SPACE, 0x8, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_LINE_SPACE, 0x8, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_DECOR, 0x8, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_BLEND_MODE, 0x8, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_COLOR, 0x8, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_SEL_COLOR, 0x8, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_SEL_BG_COLOR, 0x8, LV_STYLE_ID_COLOR + 2, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_OPA, 0x8, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_TEXT_FONT, 0x8, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_LINE_WIDTH, 0x9, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_LINE_BLEND_MODE, 0x9, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
@@ -190,7 +190,7 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_4, 0xB, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_5, 0xB, LV_STYLE_ID_VALUE + 6, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PROP_6, 0xB, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PATH, 0xB, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_PATH, 0xB, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_BORDER_WIDTH, 0xC, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
@@ -231,9 +231,9 @@ typedef struct {
uint32_t ignore_cache : 1; /*1: Ignore cache while getting value of properties*/
uint32_t radius_zero : 1;
uint32_t opa_scale_cover : 1;
uint32_t clip_corner_off : 1;
uint32_t transform_all_zero : 1;
uint32_t opa_scale_cover : 1;
uint32_t clip_corner_off : 1;
uint32_t transform_all_zero : 1;
uint32_t pad_all_zero : 1;
uint32_t margin_all_zero : 1;
uint32_t blend_mode_all_normal : 1;
@@ -405,7 +405,7 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void
* For example: `lv_style_get_border_width()`
* @note for performance reasons it's not checked if the property really has integer type
*/
int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, void * res);
int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, lv_style_int_t * res);
/**
* Get a color typed property from a style.
@@ -420,7 +420,7 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo
* For example: `lv_style_get_border_color()`
* @note for performance reasons it's not checked if the property really has color type
*/
int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop, void * res);
int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop, lv_color_t * res);
/**
* Get an opacity typed property from a style.
@@ -435,7 +435,7 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop,
* For example: `lv_style_get_border_opa()`
* @note for performance reasons it's not checked if the property really has opacity type
*/
int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, void * res);
int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, lv_opa_t * res);
/**
* Get a pointer typed property from a style.
@@ -450,7 +450,7 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo
* For example: `lv_style_get_text_font()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void * res);
int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, const void ** res);
/**
* Get the local style of a style list
@@ -461,7 +461,7 @@ lv_style_t * lv_style_list_get_local_style(lv_style_list_t * list);
/**
* Get the transition style of a style list
* @param list pointer to a style list where the local property should be set
* @param list pointer to a style list where the transition property should be set
* @return pointer to the transition style if exists else `NULL`.
*/
lv_style_t * _lv_style_list_get_transition_style(lv_style_list_t * list);
@@ -574,7 +574,7 @@ bool lv_debug_check_style(const lv_style_t * style);
/**
* Check whether a style list is valid (initialized correctly)
* @param style pointer to a style
* @param list pointer to a style list
* @return true: valid
*/
bool lv_debug_check_style_list(const lv_style_list_t * list);
@@ -596,7 +596,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_p);
#define LV_STYLE_CREATE(name, copy_p) static lv_style_t name; lv_style_init(&name); lv_style_copy(&name, copy_p)
#if LV_USE_DEBUG

View File

@@ -15,6 +15,7 @@ extern "C" {
*********************/
#include "lv_img_decoder.h"
#include "lv_img_buf.h"
#include "../lv_core/lv_style.h"
/*********************
* DEFINES

View File

@@ -716,6 +716,9 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
has_com = _lv_area_intersect(&ca, &a, clip);
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
/*Avoid overlap in the middle with large radius*/
if(ca.x1 <= w_half) ca.x1 = w_half + 1;
if(simple_mode) ca.x1 = LV_MATH_MAX(ca.x1, coords->x2);
/*Draw horizontal lines*/
lv_coord_t w = lv_area_get_width(&ca);
@@ -841,6 +844,9 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
has_com = _lv_area_intersect(&ca, &a, clip);
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
/*Avoid overlap in the middle with large radius*/
if(ca.x2 > w_half) ca.x2 = w_half;
if(simple_mode) ca.x2 = LV_MATH_MIN(coords->x1, ca.x2);
/*Draw vertical lines*/
lv_coord_t w = lv_area_get_width(&ca);
@@ -879,6 +885,9 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
has_com = _lv_area_intersect(&ca, &a, clip);
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
/*Avoid overlap in the middle with large radius*/
if(ca.y2 > h_half) ca.y2 = h_half;
if(simple_mode) ca.y2 = LV_MATH_MIN(ca.y2, coords->y1);
/*Draw horizontal lines*/
lv_coord_t w = lv_area_get_width(&ca);
@@ -920,6 +929,9 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
has_com = _lv_area_intersect(&ca, &a, clip);
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
/*Avoid overlap in the middle with large radius*/
if(ca.y1 <= h_half) ca.y1 = h_half + 1;
if(simple_mode) ca.y1 = LV_MATH_MAX(ca.y1, coords->y2);
/*Draw horizontal lines*/
lv_coord_t w = lv_area_get_width(&ca);
@@ -1160,18 +1172,22 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const
/*Get the inner radius*/
lv_area_t area_inner;
lv_area_copy(&area_inner, coords);
area_inner.x1 -= dsc->outline_pad;
area_inner.y1 -= dsc->outline_pad;
area_inner.x2 += dsc->outline_pad;
area_inner.y2 += dsc->outline_pad;
/*Extend the outline into the background area if it's overlapping the edge*/
lv_coord_t pad = (dsc->outline_pad == 0 ? (dsc->outline_pad - 1) : dsc->outline_pad);
area_inner.x1 -= pad;
area_inner.y1 -= pad;
area_inner.x2 += pad;
area_inner.y2 += pad;
lv_area_t area_outer;
lv_area_copy(&area_outer, &area_inner);
area_outer.x1 -= dsc->outline_width;
area_outer.x2 += dsc->outline_width;
area_outer.y1 -= dsc->outline_width;
area_outer.y2 += dsc->outline_width;
lv_coord_t width = (dsc->outline_pad == 0 ? (dsc->outline_width + 1) : dsc->outline_width);
area_outer.x1 -= width;
area_outer.x2 += width;
area_outer.y1 -= width;
area_outer.y2 += width;
draw_full_border(&area_inner, &area_outer, clip, dsc->radius, true, dsc->outline_color, dsc->outline_opa,
dsc->outline_blend_mode);

View File

@@ -33,6 +33,10 @@
/**********************
* STATIC PROTOTYPES
**********************/
#if LV_IMG_CACHE_DEF_SIZE
static bool lv_img_cache_match(const void * src1, const void * src2);
#endif
#if LV_IMG_CACHE_DEF_SIZE == 0
static lv_img_cache_entry_t cache_temp;
#endif
@@ -82,16 +86,8 @@ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color)
}
for(i = 0; i < entry_cnt; i++) {
bool match = false;
lv_img_src_t src_type = lv_img_src_get_type(cache[i].dec_dsc.src);
if(src_type == LV_IMG_SRC_VARIABLE) {
if(cache[i].dec_dsc.src == src && cache[i].dec_dsc.color.full == color.full) match = true;
}
else if(src_type == LV_IMG_SRC_FILE) {
if(strcmp(cache[i].dec_dsc.src, src) == 0) match = true;
}
if(match) {
if(color.full == cache[i].dec_dsc.color.full &&
lv_img_cache_match(src, cache[i].dec_dsc.src)) {
/* If opened increment its life.
* Image difficult to open should live longer to keep avoid frequent their recaching.
* Therefore increase `life` with `time_to_open`*/
@@ -122,19 +118,14 @@ lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color)
else {
LV_LOG_INFO("image draw: cache miss, cached to an empty entry");
}
#else
cached_src = &cache_temp;
#endif
/*Open the image and measure the time to open*/
uint32_t t_start;
t_start = lv_tick_get();
cached_src->dec_dsc.time_to_open = 0;
lv_res_t open_res = lv_img_decoder_open(&cached_src->dec_dsc, src, color);
uint32_t t_start = lv_tick_get();
lv_res_t open_res = lv_img_decoder_open(&cached_src->dec_dsc, src, color);
if(open_res == LV_RES_INV) {
LV_LOG_WARN("Image draw cannot open the image resource");
lv_img_decoder_close(&cached_src->dec_dsc);
_lv_memset_00(&cached_src->dec_dsc, sizeof(lv_img_decoder_dsc_t));
_lv_memset_00(cached_src, sizeof(lv_img_cache_entry_t));
cached_src->life = INT32_MIN; /*Make the empty entry very "weak" to force its use */
return NULL;
@@ -180,11 +171,7 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt)
entry_cnt = new_entry_cnt;
/*Clean the cache*/
uint16_t i;
for(i = 0; i < entry_cnt; i++) {
_lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i].dec_dsc, sizeof(lv_img_decoder_dsc_t));
_lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i], sizeof(lv_img_cache_entry_t));
}
_lv_memset_00(LV_GC_ROOT(_lv_img_cache_array), entry_cnt * sizeof(lv_img_cache_entry_t));
#endif
}
@@ -200,12 +187,11 @@ void lv_img_cache_invalidate_src(const void * src)
uint16_t i;
for(i = 0; i < entry_cnt; i++) {
if(cache[i].dec_dsc.src == src || src == NULL) {
if(src == NULL || lv_img_cache_match(src, cache[i].dec_dsc.src)) {
if(cache[i].dec_dsc.src != NULL) {
lv_img_decoder_close(&cache[i].dec_dsc);
}
_lv_memset_00(&cache[i].dec_dsc, sizeof(lv_img_decoder_dsc_t));
_lv_memset_00(&cache[i], sizeof(lv_img_cache_entry_t));
}
}
@@ -215,3 +201,17 @@ void lv_img_cache_invalidate_src(const void * src)
/**********************
* STATIC FUNCTIONS
**********************/
#if LV_IMG_CACHE_DEF_SIZE
static bool lv_img_cache_match(const void * src1, const void * src2)
{
lv_img_src_t src_type = lv_img_src_get_type(src1);
if(src_type == LV_IMG_SRC_VARIABLE)
return src1 == src2;
if(src_type != LV_IMG_SRC_FILE)
return false;
if(lv_img_src_get_type(src2) != LV_IMG_SRC_FILE)
return false;
return strcmp(src1, src2) == 0;
}
#endif

View File

@@ -31,7 +31,7 @@ extern "C" {
typedef struct {
lv_img_decoder_dsc_t dec_dsc; /**< Image information */
/** Count the cache entries's life. Add `time_tio_open` to `life` when the entry is used.
/** Count the cache entries's life. Add `time_to_open` to `life` when the entry is used.
* Decrement all lifes by one every in every ::lv_img_cache_open.
* If life == 0 the entry can be reused */
int32_t life;

View File

@@ -10,7 +10,6 @@
#include "../lv_misc/lv_debug.h"
#include "../lv_draw/lv_draw_img.h"
#include "../lv_misc/lv_ll.h"
#include "../lv_misc/lv_color.h"
#include "../lv_misc/lv_gc.h"
/*********************
@@ -24,7 +23,7 @@
**********************/
typedef struct {
#if LV_USE_FILESYSTEM
lv_fs_file_t * f;
lv_fs_file_t f;
#endif
lv_color_t * palette;
lv_opa_t * opa;
@@ -63,9 +62,9 @@ void _lv_img_decoder_init(void)
/*Create a decoder for the built in color format*/
decoder = lv_img_decoder_create();
LV_ASSERT_MEM(decoder);
if(decoder == NULL) {
LV_LOG_WARN("lv_img_decoder_init: out of memory");
LV_ASSERT_MEM(decoder);
return;
}
@@ -84,15 +83,11 @@ void _lv_img_decoder_init(void)
*/
lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header)
{
header->always_zero = 0;
header->h = 0;
header->w = 0;
header->cf = LV_IMG_CF_UNKNOWN;
_lv_memset_00(header, sizeof(lv_img_header_t));
lv_res_t res = LV_RES_INV;
lv_img_decoder_t * d;
_LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) {
res = LV_RES_INV;
if(d->info_cb) {
res = d->info_cb(d, src, header);
if(res == LV_RES_OK) break;
@@ -116,39 +111,53 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header)
*/
lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_color_t color)
{
dsc->color = color;
dsc->src_type = lv_img_src_get_type(src);
dsc->user_data = NULL;
_lv_memset_00(dsc, sizeof(lv_img_decoder_dsc_t));
dsc->color = color;
dsc->src_type = lv_img_src_get_type(src);
if(dsc->src_type == LV_IMG_SRC_FILE) {
size_t fnlen = strlen(src);
dsc->src = lv_mem_alloc(fnlen + 1);
LV_ASSERT_MEM(dsc->src);
if(dsc->src == NULL) {
LV_LOG_WARN("lv_img_decoder_open: out of memory");
return LV_RES_INV;
}
strcpy((char *)dsc->src, src);
}
else {
dsc->src = src;
dsc->src = src;
}
lv_res_t res = LV_RES_INV;
lv_img_decoder_t * d;
_LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) {
/*Info an Open callbacks are required*/
/*Info and Open callbacks are required*/
if(d->info_cb == NULL || d->open_cb == NULL) continue;
res = d->info_cb(d, src, &dsc->header);
if(res != LV_RES_OK) continue;
dsc->error_msg = NULL;
dsc->img_data = NULL;
dsc->decoder = d;
dsc->decoder = d;
res = d->open_cb(d, dsc);
/*Opened successfully. It is a good decoder to for this image source*/
if(res == LV_RES_OK) break;
if(res == LV_RES_OK) return res;
/*Prepare for the next loop*/
_lv_memset_00(&dsc->header, sizeof(lv_img_header_t));
dsc->error_msg = NULL;
dsc->img_data = NULL;
dsc->user_data = NULL;
dsc->time_to_open = 0;
}
if(dsc->src_type == LV_IMG_SRC_FILE)
lv_mem_free(dsc->src);
return res;
}
@@ -273,6 +282,9 @@ lv_res_t lv_img_decoder_built_in_info(lv_img_decoder_t * decoder, const void * s
}
#if LV_USE_FILESYSTEM
else if(src_type == LV_IMG_SRC_FILE) {
/*Support only "*.bin" files*/
if(strcmp(lv_fs_get_ext(src), "bin")) return LV_RES_INV;
lv_fs_file_t file;
lv_fs_res_t res;
uint32_t rn;
@@ -287,7 +299,6 @@ lv_res_t lv_img_decoder_built_in_info(lv_img_decoder_t * decoder, const void * s
}
if(header->cf < CF_BUILT_IN_FIRST || header->cf > CF_BUILT_IN_LAST) return LV_RES_INV;
}
#endif
else if(src_type == LV_IMG_SRC_SYMBOL) {
@@ -309,7 +320,7 @@ lv_res_t lv_img_decoder_built_in_info(lv_img_decoder_t * decoder, const void * s
/**
* Open a built in image
* @param decoder the decoder where this function belongs
* @param dsc pointer to decoder descriptor. `src`, `style` are already initialized in it.
* @param dsc pointer to decoder descriptor. `src`, `color` are already initialized in it.
* @return LV_RES_OK: the info is successfully stored in `header`; LV_RES_INV: unknown format or other error.
*/
lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc)
@@ -317,7 +328,6 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
/*Open the file if it's a file*/
if(dsc->src_type == LV_IMG_SRC_FILE) {
#if LV_USE_FILESYSTEM
/*Support only "*.bin" files*/
if(strcmp(lv_fs_get_ext(dsc->src), "bin")) return LV_RES_INV;
@@ -334,22 +344,14 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
LV_ASSERT_MEM(dsc->user_data);
if(dsc->user_data == NULL) {
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
lv_fs_close(&f);
return LV_RES_INV;
}
_lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t));
}
lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
user_data->f = lv_mem_alloc(sizeof(f));
LV_ASSERT_MEM(user_data->f);
if(user_data->f == NULL) {
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
lv_img_decoder_built_in_close(decoder, dsc);
return LV_RES_INV;
}
_lv_memcpy_small(user_data->f, &f, sizeof(f));
_lv_memcpy_small(&user_data->f, &f, sizeof(f));
#else
LV_LOG_WARN("Image built-in decoder cannot read file because LV_USE_FILESYSTEM = 0");
return LV_RES_INV;
@@ -373,14 +375,12 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
}
else {
/*If it's a file it need to be read line by line later*/
dsc->img_data = NULL;
return LV_RES_OK;
}
}
/*Process indexed images. Build a palette*/
else if(cf == LV_IMG_CF_INDEXED_1BIT || cf == LV_IMG_CF_INDEXED_2BIT || cf == LV_IMG_CF_INDEXED_4BIT ||
cf == LV_IMG_CF_INDEXED_8BIT) {
#if LV_IMG_CF_INDEXED
uint8_t px_size = lv_img_cf_get_px_size(cf);
uint32_t palette_size = 1 << px_size;
@@ -391,7 +391,6 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
LV_ASSERT_MEM(dsc->user_data);
if(dsc->user_data == NULL) {
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
lv_img_decoder_built_in_close(decoder, dsc);
return LV_RES_INV;
}
_lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t));
@@ -411,11 +410,11 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
if(dsc->src_type == LV_IMG_SRC_FILE) {
/*Read the palette from file*/
#if LV_USE_FILESYSTEM
lv_fs_seek(user_data->f, 4); /*Skip the header*/
lv_fs_seek(&user_data->f, 4); /*Skip the header*/
lv_color32_t cur_color;
uint32_t i;
for(i = 0; i < palette_size; i++) {
lv_fs_read(user_data->f, &cur_color, sizeof(lv_color32_t), NULL);
lv_fs_read(&user_data->f, &cur_color, sizeof(lv_color32_t), NULL);
user_data->palette[i] = lv_color_make(cur_color.ch.red, cur_color.ch.green, cur_color.ch.blue);
user_data->opa[i] = cur_color.ch.alpha;
}
@@ -435,10 +434,10 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
}
}
dsc->img_data = NULL;
return LV_RES_OK;
#else
LV_LOG_WARN("Indexed (palette) images are not enabled in lv_conf.h. See LV_IMG_CF_INDEXED");
lv_img_decoder_built_in_close(decoder, dsc);
return LV_RES_INV;
#endif
}
@@ -446,10 +445,10 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
else if(cf == LV_IMG_CF_ALPHA_1BIT || cf == LV_IMG_CF_ALPHA_2BIT || cf == LV_IMG_CF_ALPHA_4BIT ||
cf == LV_IMG_CF_ALPHA_8BIT) {
#if LV_IMG_CF_ALPHA
dsc->img_data = NULL;
return LV_RES_OK; /*Nothing to process*/
#else
LV_LOG_WARN("Alpha indexed images are not enabled in lv_conf.h. See LV_IMG_CF_ALPHA");
lv_img_decoder_built_in_close(decoder, dsc);
return LV_RES_INV;
#endif
}
@@ -491,7 +490,6 @@ lv_res_t lv_img_decoder_built_in_read_line(lv_img_decoder_t * decoder, lv_img_de
}
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT ||
dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) {
res = lv_img_decoder_built_in_line_alpha(dsc, x, y, len, buf);
}
else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT || dsc->header.cf == LV_IMG_CF_INDEXED_2BIT ||
@@ -518,16 +516,13 @@ void lv_img_decoder_built_in_close(lv_img_decoder_t * decoder, lv_img_decoder_ds
lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
if(user_data) {
#if LV_USE_FILESYSTEM
if(user_data->f) {
lv_fs_close(user_data->f);
lv_mem_free(user_data->f);
}
if(dsc->src_type == LV_IMG_SRC_FILE)
lv_fs_close(&user_data->f);
#endif
if(user_data->palette) lv_mem_free(user_data->palette);
if(user_data->opa) lv_mem_free(user_data->opa);
lv_mem_free(user_data);
dsc->user_data = NULL;
}
}
@@ -546,14 +541,14 @@ static lv_res_t lv_img_decoder_built_in_line_true_color(lv_img_decoder_dsc_t * d
uint32_t pos = ((y * dsc->header.w + x) * px_size) >> 3;
pos += 4; /*Skip the header*/
res = lv_fs_seek(user_data->f, pos);
res = lv_fs_seek(&user_data->f, pos);
if(res != LV_FS_RES_OK) {
LV_LOG_WARN("Built-in image decoder seek failed");
return LV_RES_INV;
}
uint32_t btr = len * (px_size >> 3);
uint32_t br = 0;
res = lv_fs_read(user_data->f, buf, btr, &br);
res = lv_fs_read(&user_data->f, buf, btr, &br);
if(res != LV_FS_RES_OK || btr != br) {
LV_LOG_WARN("Built-in image decoder read failed");
return LV_RES_INV;
@@ -574,7 +569,6 @@ static lv_res_t lv_img_decoder_built_in_line_true_color(lv_img_decoder_dsc_t * d
static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y,
lv_coord_t len, uint8_t * buf)
{
#if LV_IMG_CF_ALPHA
const lv_opa_t alpha1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
const lv_opa_t alpha2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
@@ -608,24 +602,21 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
int8_t pos = 0;
switch(dsc->header.cf) {
case LV_IMG_CF_ALPHA_1BIT:
w = (dsc->header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/
if(dsc->header.w & 0x7) w++;
w = (dsc->header.w + 7) >> 3; /*E.g. w = 20 -> w = 2 + 1*/
ofs += w * y + (x >> 3); /*First pixel*/
pos = 7 - (x & 0x7);
pos = 7 - (x & 0x7);
opa_table = alpha1_opa_table;
break;
case LV_IMG_CF_ALPHA_2BIT:
w = (dsc->header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/
if(dsc->header.w & 0x3) w++;
w = (dsc->header.w + 3) >> 2; /*E.g. w = 13 -> w = 3 + 1 (bytes)*/
ofs += w * y + (x >> 2); /*First pixel*/
pos = 6 - ((x & 0x3) * 2);
pos = 6 - (x & 0x3) * 2;
opa_table = alpha2_opa_table;
break;
case LV_IMG_CF_ALPHA_4BIT:
w = (dsc->header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/
if(dsc->header.w & 0x1) w++;
w = (dsc->header.w + 1) >> 1; /*E.g. w = 13 -> w = 6 + 1 (bytes)*/
ofs += w * y + (x >> 1); /*First pixel*/
pos = 4 - ((x & 0x1) * 4);
pos = 4 - (x & 0x1) * 4;
opa_table = alpha4_opa_table;
break;
case LV_IMG_CF_ALPHA_8BIT:
@@ -638,6 +629,7 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
#if LV_USE_FILESYSTEM
lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
uint8_t * fs_buf = _lv_mem_buf_get(w);
if(fs_buf == NULL) return LV_RES_INV;
#endif
const uint8_t * data_tmp = NULL;
@@ -648,8 +640,8 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
}
else {
#if LV_USE_FILESYSTEM
lv_fs_seek(user_data->f, ofs + 4); /*+4 to skip the header*/
lv_fs_read(user_data->f, fs_buf, w, NULL);
lv_fs_seek(&user_data->f, ofs + 4); /*+4 to skip the header*/
lv_fs_read(&user_data->f, fs_buf, w, NULL);
data_tmp = fs_buf;
#else
LV_LOG_WARN("Image built-in alpha line reader can't read file because LV_USE_FILESYSTEM = 0");
@@ -659,7 +651,7 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
}
for(i = 0; i < len; i++) {
uint8_t val_act = (*data_tmp & (mask << pos)) >> pos;
uint8_t val_act = (*data_tmp >> pos) & mask;
buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + LV_IMG_PX_SIZE_ALPHA_BYTE - 1] =
dsc->header.cf == LV_IMG_CF_ALPHA_8BIT ? val_act : opa_table[val_act];
@@ -674,7 +666,6 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
_lv_mem_buf_release(fs_buf);
#endif
return LV_RES_OK;
#else
LV_LOG_WARN("Image built-in alpha line reader failed because LV_IMG_CF_ALPHA is 0 in lv_conf.h");
return LV_RES_INV;
@@ -684,7 +675,6 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y,
lv_coord_t len, uint8_t * buf)
{
#if LV_IMG_CF_INDEXED
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf);
uint16_t mask = (1 << px_size) - 1; /*E.g. px_size = 2; mask = 0x03*/
@@ -694,25 +684,22 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc,
uint32_t ofs = 0;
switch(dsc->header.cf) {
case LV_IMG_CF_INDEXED_1BIT:
w = (dsc->header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/
if(dsc->header.w & 0x7) w++;
w = (dsc->header.w + 7) >> 3; /*E.g. w = 20 -> w = 2 + 1*/
ofs += w * y + (x >> 3); /*First pixel*/
ofs += 8; /*Skip the palette*/
pos = 7 - (x & 0x7);
break;
case LV_IMG_CF_INDEXED_2BIT:
w = (dsc->header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/
if(dsc->header.w & 0x3) w++;
w = (dsc->header.w + 3) >> 2; /*E.g. w = 13 -> w = 3 + 1 (bytes)*/
ofs += w * y + (x >> 2); /*First pixel*/
ofs += 16; /*Skip the palette*/
pos = 6 - ((x & 0x3) * 2);
pos = 6 - (x & 0x3) * 2;
break;
case LV_IMG_CF_INDEXED_4BIT:
w = (dsc->header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/
if(dsc->header.w & 0x1) w++;
w = (dsc->header.w + 1) >> 1; /*E.g. w = 13 -> w = 6 + 1 (bytes)*/
ofs += w * y + (x >> 1); /*First pixel*/
ofs += 64; /*Skip the palette*/
pos = 4 - ((x & 0x1) * 4);
pos = 4 - (x & 0x1) * 4;
break;
case LV_IMG_CF_INDEXED_8BIT:
w = dsc->header.w; /*E.g. x = 7 -> w = 7 (bytes)*/
@@ -726,6 +713,7 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc,
#if LV_USE_FILESYSTEM
uint8_t * fs_buf = _lv_mem_buf_get(w);
if(fs_buf == NULL) return LV_RES_INV;
#endif
const uint8_t * data_tmp = NULL;
if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
@@ -734,8 +722,8 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc,
}
else {
#if LV_USE_FILESYSTEM
lv_fs_seek(user_data->f, ofs + 4); /*+4 to skip the header*/
lv_fs_read(user_data->f, fs_buf, w, NULL);
lv_fs_seek(&user_data->f, ofs + 4); /*+4 to skip the header*/
lv_fs_read(&user_data->f, fs_buf, w, NULL);
data_tmp = fs_buf;
#else
LV_LOG_WARN("Image built-in indexed line reader can't read file because LV_USE_FILESYSTEM = 0");
@@ -746,7 +734,7 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc,
lv_coord_t i;
for(i = 0; i < len; i++) {
uint8_t val_act = (*data_tmp & (mask << pos)) >> pos;
uint8_t val_act = (*data_tmp >> pos) & mask;
lv_color_t color = user_data->palette[val_act];
#if LV_COLOR_DEPTH == 8 || LV_COLOR_DEPTH == 1

View File

@@ -20,7 +20,7 @@ extern "C" {
#include "../lv_misc/lv_fs.h"
#include "../lv_misc/lv_types.h"
#include "../lv_misc/lv_area.h"
#include "../lv_core/lv_style.h"
#include "../lv_misc/lv_color.h"
/*********************
* DEFINES
@@ -59,7 +59,7 @@ typedef lv_res_t (*lv_img_decoder_info_f_t)(struct _lv_img_decoder * decoder, co
/**
* Open an image for decoding. Prepare it as it is required to read it later
* @param decoder pointer to the decoder the function associated with
* @param dsc pointer to decoder descriptor. `src`, `style` are already initialized in it.
* @param dsc pointer to decoder descriptor. `src`, `color` are already initialized in it.
*/
typedef lv_res_t (*lv_img_decoder_open_f_t)(struct _lv_img_decoder * decoder, struct _lv_img_decoder_dsc * dsc);

View File

@@ -1,9 +1,12 @@
CSRCS += lv_font.c
CSRCS += lv_font_fmt_txt.c
CSRCS += lv_font_loader.c
CSRCS += lv_font_dejavu_16_persian_hebrew.c
CSRCS += lv_font_montserrat_8.c
CSRCS += lv_font_montserrat_10.c
CSRCS += lv_font_montserrat_12.c
CSRCS += lv_font_montserrat_12_subpx.c
CSRCS += lv_font_montserrat_14.c
CSRCS += lv_font_montserrat_16.c
CSRCS += lv_font_montserrat_18.c
@@ -12,6 +15,7 @@ CSRCS += lv_font_montserrat_22.c
CSRCS += lv_font_montserrat_24.c
CSRCS += lv_font_montserrat_26.c
CSRCS += lv_font_montserrat_28.c
CSRCS += lv_font_montserrat_28_compressed.c
CSRCS += lv_font_montserrat_30.c
CSRCS += lv_font_montserrat_32.c
CSRCS += lv_font_montserrat_34.c
@@ -22,10 +26,9 @@ CSRCS += lv_font_montserrat_42.c
CSRCS += lv_font_montserrat_44.c
CSRCS += lv_font_montserrat_46.c
CSRCS += lv_font_montserrat_48.c
CSRCS += lv_font_montserrat_12_subpx.c
CSRCS += lv_font_montserrat_28_compressed.c
CSRCS += lv_font_simsun_16_cjk.c
CSRCS += lv_font_unscii_8.c
CSRCS += lv_font_dejavu_16_persian_hebrew.c
CSRCS += lv_font_unscii_16.c
DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_font
VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_font

View File

@@ -58,7 +58,8 @@ void lv_disp_drv_init(lv_disp_drv_t * driver)
driver->hor_res = LV_HOR_RES_MAX;
driver->ver_res = LV_VER_RES_MAX;
driver->buffer = NULL;
driver->rotated = 0;
driver->rotated = LV_DISP_ROT_NONE;
driver->sw_rotate = 0;
driver->color_chroma_key = LV_COLOR_TRANSP;
driver->dpi = LV_DPI;
@@ -178,12 +179,25 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
*/
void lv_disp_drv_update(lv_disp_t * disp, lv_disp_drv_t * new_drv)
{
memcpy(&disp->driver, new_drv, sizeof(lv_disp_drv_t));
if(new_drv != &disp->driver)
memcpy(&disp->driver, new_drv, sizeof(lv_disp_drv_t));
lv_obj_t * scr;
_LV_LL_READ(disp->scr_ll, scr) {
lv_obj_set_size(scr, lv_disp_get_hor_res(disp), lv_disp_get_ver_res(disp));
}
/*
* This method is usually called upon orientation change, thus the screen is now a
* different size.
* The object invalidated its previous area. That area is now out of the screen area
* so we reset all invalidated areas and invalidate the active screen's new area only.
*/
_lv_memset_00(disp->inv_areas, sizeof(disp->inv_areas));
_lv_memset_00(disp->inv_area_joined, sizeof(disp->inv_area_joined));
disp->inv_p = 0;
if(disp->act_scr != NULL)
lv_obj_invalidate(disp->act_scr);
}
/**
@@ -240,8 +254,15 @@ lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp)
if(disp == NULL)
return LV_HOR_RES_MAX;
else
return disp->driver.rotated == 0 ? disp->driver.hor_res : disp->driver.ver_res;
else {
switch(disp->driver.rotated) {
case LV_DISP_ROT_90:
case LV_DISP_ROT_270:
return disp->driver.ver_res;
default:
return disp->driver.hor_res;
}
}
}
/**
@@ -255,8 +276,15 @@ lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp)
if(disp == NULL)
return LV_VER_RES_MAX;
else
return disp->driver.rotated == 0 ? disp->driver.ver_res : disp->driver.hor_res;
else {
switch(disp->driver.rotated) {
case LV_DISP_ROT_90:
case LV_DISP_ROT_270:
return disp->driver.hor_res;
default:
return disp->driver.ver_res;
}
}
}
/**
@@ -416,6 +444,31 @@ bool lv_disp_is_true_double_buf(lv_disp_t * disp)
}
}
/**
* Set the rotation of this display.
* @param disp pointer to a display (NULL to use the default display)
* @param rotation rotation angle
*/
void lv_disp_set_rotation(lv_disp_t * disp, lv_disp_rot_t rotation)
{
if(disp == NULL) disp = lv_disp_get_default();
disp->driver.rotated = rotation;
lv_disp_drv_update(disp, &disp->driver);
}
/**
* Get the current rotation of this display.
* @param disp pointer to a display (NULL to use the default display)
* @return rotation angle
*/
lv_disp_rot_t lv_disp_get_rotation(lv_disp_t * disp)
{
if(disp == NULL) disp = lv_disp_get_default();
return disp->driver.rotated;
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -60,6 +60,14 @@ typedef struct {
volatile uint32_t last_part : 1; /*1: the last part of the current area is being rendered*/
} lv_disp_buf_t;
typedef enum {
LV_DISP_ROT_NONE = 0,
LV_DISP_ROT_90,
LV_DISP_ROT_180,
LV_DISP_ROT_270
} lv_disp_rot_t;
/**
* Display Driver structure to be registered by HAL
*/
@@ -75,7 +83,8 @@ typedef struct _disp_drv_t {
#if LV_ANTIALIAS
uint32_t antialiasing : 1; /**< 1: antialiasing is enabled on this display. */
#endif
uint32_t rotated : 1; /**< 1: turn the display by 90 degree. @warning Does not update coordinates for you!*/
uint32_t rotated : 2;
uint32_t sw_rotate : 1; /**< 1: use software rotation (slower) */
#if LV_COLOR_SCREEN_TRANSP
/**Handle if the screen doesn't have a solid (opa == LV_OPA_COVER) background.
@@ -281,6 +290,20 @@ lv_coord_t lv_disp_get_dpi(lv_disp_t * disp);
*/
lv_disp_size_t lv_disp_get_size_category(lv_disp_t * disp);
/**
* Set the rotation of this display.
* @param disp pointer to a display (NULL to use the default display)
* @param rotation rotation angle
*/
void lv_disp_set_rotation(lv_disp_t * disp, lv_disp_rot_t rotation);
/**
* Get the current rotation of this display.
* @param disp pointer to a display (NULL to use the default display)
* @return rotation angle
*/
lv_disp_rot_t lv_disp_get_rotation(lv_disp_t * disp);
//! @cond Doxygen_Suppress
/**

View File

@@ -1,5 +1,5 @@
/**
* @file anim.c
* @file lv_anim.c
*
*/
@@ -33,13 +33,14 @@
**********************/
static void anim_task(lv_task_t * param);
static void anim_mark_list_change(void);
static bool anim_ready_handler(lv_anim_t * a);
static void anim_ready_handler(lv_anim_t * a);
/**********************
* STATIC VARIABLES
**********************/
static uint32_t last_task_run;
static bool anim_list_changed;
static bool anim_run_round;
static lv_task_t * _lv_anim_task;
const lv_anim_path_t lv_anim_path_def = {.cb = lv_anim_path_linear};
@@ -57,7 +58,6 @@ const lv_anim_path_t lv_anim_path_def = {.cb = lv_anim_path_linear};
void _lv_anim_core_init(void)
{
_lv_ll_init(&LV_GC_ROOT(_lv_anim_ll), sizeof(lv_anim_t));
last_task_run = lv_tick_get();
_lv_anim_task = lv_task_create(anim_task, LV_DISP_DEF_REFR_PERIOD, LV_ANIM_TASK_PRIO, NULL);
anim_mark_list_change(); /*Turn off the animation task*/
anim_list_changed = false; /*The list has not actually changed*/
@@ -93,7 +93,7 @@ void lv_anim_start(lv_anim_t * a)
/*If the list is empty the anim task was suspended and it's last run measure is invalid*/
if(_lv_ll_is_empty(&LV_GC_ROOT(_lv_anim_ll))) {
last_task_run = lv_tick_get() - 1;
last_task_run = lv_tick_get();
}
/*Add the new animation to the animation linked list*/
@@ -103,6 +103,7 @@ void lv_anim_start(lv_anim_t * a)
/*Initialize the animation descriptor*/
a->time_orig = a->time;
a->run_round = anim_run_round;
_lv_memcpy(new_anim, a, sizeof(lv_anim_t));
/*Set the start value*/
@@ -148,6 +149,15 @@ bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb)
return del;
}
/**
* Delete all the animations animation
*/
void lv_anim_del_all(void)
{
_lv_ll_clear(&LV_GC_ROOT(_lv_anim_ll));
anim_mark_list_change();
}
/**
* Get the animation of a variable and its `exec_cb`.
* @param var pointer to variable
@@ -187,12 +197,10 @@ uint16_t lv_anim_count_running(void)
* @param end end value of the animation
* @return the required time [ms] for the animation with the given parameters
*/
uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end)
uint32_t lv_anim_speed_to_time(uint32_t speed, lv_anim_value_t start, lv_anim_value_t end)
{
int32_t d = LV_MATH_ABS((int32_t)start - end);
uint32_t time = (int32_t)((int32_t)(d * 1000) / speed);
if(time > UINT16_MAX) time = UINT16_MAX;
uint32_t d = LV_MATH_ABS(start - end);
uint32_t time = (d * 1000) / speed;
if(time == 0) {
time++;
@@ -222,22 +230,16 @@ lv_anim_value_t lv_anim_path_linear(const lv_anim_path_t * path, const lv_anim_t
LV_UNUSED(path);
/*Calculate the current step*/
uint32_t step;
if(a->time == a->act_time) {
step = LV_ANIM_RESOLUTION; /*Use the last value if the time fully elapsed*/
}
else {
step = ((int32_t)a->act_time * LV_ANIM_RESOLUTION) / a->time;
}
int32_t step = _lv_map(a->act_time, 0, a->time, 0, LV_ANIM_RESOLUTION);
/* Get the new value which will be proportional to `step`
* and the `start` and `end` values*/
int32_t new_value;
new_value = (int32_t)step * (a->end - a->start);
new_value = step * (a->end - a->start);
new_value = new_value >> LV_ANIM_RES_SHIFT;
new_value += a->start;
return (lv_anim_value_t)new_value;
return new_value;
}
/**
@@ -250,20 +252,16 @@ lv_anim_value_t lv_anim_path_ease_in(const lv_anim_path_t * path, const lv_anim_
LV_UNUSED(path);
/*Calculate the current step*/
uint32_t t;
if(a->time == a->act_time)
t = 1024;
else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
uint32_t t = _lv_map(a->act_time, 0, a->time, 0, 1024);
int32_t step = _lv_bezier3(t, 0, 1, 1, 1024);
int32_t new_value;
new_value = (int32_t)step * (a->end - a->start);
new_value = step * (a->end - a->start);
new_value = new_value >> 10;
new_value += a->start;
return (lv_anim_value_t)new_value;
return new_value;
}
/**
@@ -277,20 +275,15 @@ lv_anim_value_t lv_anim_path_ease_out(const lv_anim_path_t * path, const lv_anim
/*Calculate the current step*/
uint32_t t;
if(a->time == a->act_time)
t = 1024;
else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
uint32_t t = _lv_map(a->act_time, 0, a->time, 0, 1024);
int32_t step = _lv_bezier3(t, 0, 1023, 1023, 1024);
int32_t new_value;
new_value = (int32_t)step * (a->end - a->start);
new_value = step * (a->end - a->start);
new_value = new_value >> 10;
new_value += a->start;
return (lv_anim_value_t)new_value;
return new_value;
}
/**
@@ -304,20 +297,15 @@ lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_path_t * path, const lv_a
/*Calculate the current step*/
uint32_t t;
if(a->time == a->act_time)
t = 1024;
else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
uint32_t t = _lv_map(a->act_time, 0, a->time, 0, 1024);
int32_t step = _lv_bezier3(t, 0, 100, 924, 1024);
int32_t new_value;
new_value = (int32_t)step * (a->end - a->start);
new_value = step * (a->end - a->start);
new_value = new_value >> 10;
new_value += a->start;
return (lv_anim_value_t)new_value;
return new_value;
}
/**
@@ -331,20 +319,15 @@ lv_anim_value_t lv_anim_path_overshoot(const lv_anim_path_t * path, const lv_ani
/*Calculate the current step*/
uint32_t t;
if(a->time == a->act_time)
t = 1024;
else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
uint32_t t = _lv_map(a->act_time, 0, a->time, 0, 1024);
int32_t step = _lv_bezier3(t, 0, 1000, 1300, 1024);
int32_t new_value;
new_value = (int32_t)step * (a->end - a->start);
new_value = step * (a->end - a->start);
new_value = new_value >> 10;
new_value += a->start;
return (lv_anim_value_t)new_value;
return new_value;
}
/**
@@ -357,12 +340,8 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t
LV_UNUSED(path);
/*Calculate the current step*/
int32_t t;
if(a->time == a->act_time)
t = 1024;
else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
uint32_t t = _lv_map(a->act_time, 0, a->time, 0, 1024);
int32_t diff = (a->end - a->start);
/*3 bounces has 5 parts: 3 down and 2 up. One part is t / 5 long*/
@@ -399,16 +378,16 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t
}
if(t > 1024) t = 1024;
if(t < 0) t = 0;
int32_t step = _lv_bezier3(t, 1024, 800, 500, 0);
int32_t new_value;
new_value = (int32_t)step * diff;
new_value = step * diff;
new_value = new_value >> 10;
new_value = a->end - new_value;
return (lv_anim_value_t)new_value;
return new_value;
}
/**
@@ -439,14 +418,12 @@ static void anim_task(lv_task_t * param)
{
(void)param;
lv_anim_t * a;
_LV_LL_READ(LV_GC_ROOT(_lv_anim_ll), a) {
a->has_run = 0;
}
uint32_t elaps = lv_tick_elaps(last_task_run);
a = _lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll));
/*Flip the run round*/
anim_run_round = anim_run_round ? false : true;
lv_anim_t * a = _lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll));
while(a != NULL) {
/*It can be set by `lv_anim_del()` typically in `end_cb`. If set then an animation delete
@@ -455,8 +432,8 @@ static void anim_task(lv_task_t * param)
*/
anim_list_changed = false;
if(!a->has_run) {
a->has_run = 1; /*The list readying might be reset so need to know which anim has run already*/
if(a->run_round != anim_run_round) {
a->run_round = anim_run_round; /*The list readying might be reset so need to know which anim has run already*/
/*The animation will run now for the first time. Call `start_cb`*/
int32_t new_act_time = a->act_time + elaps;
@@ -499,9 +476,8 @@ static void anim_task(lv_task_t * param)
* Called when an animation is ready to do the necessary thinks
* e.g. repeat, play back, delete etc.
* @param a pointer to an animation descriptor
* @return true: animation delete occurred and the `LV_GC_ROOT(_lv_anim_ll)` has changed
* */
static bool anim_ready_handler(lv_anim_t * a)
*/
static void anim_ready_handler(lv_anim_t * a)
{
/*In the end of a forward anim decrement repeat cnt.*/
if(a->playback_now == 0 && a->repeat_cnt > 0 && a->repeat_cnt != LV_ANIM_REPEAT_INFINITE) {
@@ -544,8 +520,6 @@ static bool anim_ready_handler(lv_anim_t * a)
a->time = a->playback_now == 0 ? a->time_orig : a->playback_time;
}
}
return anim_list_changed;
}
static void anim_mark_list_change(void)
{

View File

@@ -1,10 +1,10 @@
/**
* @file anim.h
* @file lv_anim.h
*
*/
#ifndef ANIM_H
#define ANIM_H
#ifndef LV_ANIM_H
#define LV_ANIM_H
#ifdef __cplusplus
extern "C" {
@@ -74,28 +74,28 @@ typedef void (*lv_anim_start_cb_t)(struct _lv_anim_t *);
/** Describes an animation*/
typedef struct _lv_anim_t {
void * var; /**<Variable to animate*/
lv_anim_exec_xcb_t exec_cb; /**< Function to execute to animate*/
lv_anim_exec_xcb_t exec_cb; /**< Function to execute to animate*/
lv_anim_start_cb_t start_cb; /**< Call it when the animation is starts (considering `delay`)*/
lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/
#if LV_USE_USER_DATA
lv_anim_user_data_t user_data; /**< Custom user data*/
#endif
lv_anim_path_t path; /**< Describe the path (curve) of animations*/
int32_t start; /**< Start value*/
int32_t current; /**< Current value */
int32_t end; /**< End value*/
int32_t time; /**< Animation time in ms*/
int32_t time; /**< Animation time in ms*/
int32_t act_time; /**< Current time in animation. Set to negative to make delay.*/
uint32_t playback_delay; /**< Wait before play back*/
uint32_t playback_time; /**< Duration of playback animation*/
uint32_t repeat_delay; /**< Wait before repeat*/
uint16_t repeat_cnt; /**< Repeat count for the animation*/
uint8_t early_apply : 1; /**< 1: Apply start value immediately even is there is `delay` */
#if LV_USE_USER_DATA
lv_anim_user_data_t user_data; /**< Custom user data*/
#endif
/*Animation system use these - user shouldn't set*/
uint32_t time_orig;
uint8_t playback_now : 1; /**< Play back is in progress*/
uint32_t has_run : 1; /**< Indicates the animation has run in this round*/
uint8_t run_round : 1; /**< Indicates the animation has run in this round*/
uint32_t time_orig;
} lv_anim_t;
/**********************
@@ -124,7 +124,7 @@ void lv_anim_init(lv_anim_t * a);
*/
static inline void lv_anim_set_var(lv_anim_t * a, void * var)
{
a->var = var;
a->var = var;
}
/**
@@ -146,7 +146,7 @@ static inline void lv_anim_set_exec_cb(lv_anim_t * a, lv_anim_exec_xcb_t exec_cb
*/
static inline void lv_anim_set_time(lv_anim_t * a, uint32_t duration)
{
a->time = duration;
a->time = duration;
}
/**
@@ -169,7 +169,7 @@ static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_a
{
a->start = start;
a->current = start;
a->end = end;
a->end = end;
}
/**
@@ -190,8 +190,8 @@ static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec
/**
* Set the path (curve) of the animation.
* @param a pointer to an initialized `lv_anim_t` variable
* @param path_cb a function the get the current value of the animation.
* The built in functions starts with `lv_anim_path_...`
* @param path a function the get the current value of the animation.
* The built in functions starts with `lv_anim_path_...`
*/
static inline void lv_anim_set_path(lv_anim_t * a, const lv_anim_path_t * path)
{
@@ -223,7 +223,7 @@ static inline void lv_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_
* @param a pointer to an initialized `lv_anim_t` variable
* @param time the duration of the playback animation in in milliseconds. 0: disable playback
*/
static inline void lv_anim_set_playback_time(lv_anim_t * a, uint16_t time)
static inline void lv_anim_set_playback_time(lv_anim_t * a, uint32_t time)
{
a->playback_time = time;
}
@@ -233,7 +233,7 @@ static inline void lv_anim_set_playback_time(lv_anim_t * a, uint16_t time)
* @param a pointer to an initialized `lv_anim_t` variable
* @param delay delay in milliseconds before starting the playback animation.
*/
static inline void lv_anim_set_playback_delay(lv_anim_t * a, uint16_t delay)
static inline void lv_anim_set_playback_delay(lv_anim_t * a, uint32_t delay)
{
a->playback_delay = delay;
}
@@ -245,7 +245,7 @@ static inline void lv_anim_set_playback_delay(lv_anim_t * a, uint16_t delay)
*/
static inline void lv_anim_set_repeat_count(lv_anim_t * a, uint16_t cnt)
{
a->repeat_cnt = cnt;
a->repeat_cnt = cnt;
}
/**
@@ -253,7 +253,7 @@ static inline void lv_anim_set_repeat_count(lv_anim_t * a, uint16_t cnt)
* @param a pointer to an initialized `lv_anim_t` variable
* @param delay delay in milliseconds before repeating the animation.
*/
static inline void lv_anim_set_repeat_delay(lv_anim_t * a, uint16_t delay)
static inline void lv_anim_set_repeat_delay(lv_anim_t * a, uint32_t delay)
{
a->repeat_delay = delay;
}
@@ -298,7 +298,7 @@ static inline void lv_anim_path_set_user_data(lv_anim_path_t * path, void * user
* @param a pointer to an initialized `lv_anim_t` variable
* @return delay before the animation in milliseconds
*/
static inline int32_t lv_anim_get_delay(lv_anim_t * a)
static inline uint32_t lv_anim_get_delay(lv_anim_t * a)
{
return -a->act_time;
}
@@ -312,6 +312,11 @@ static inline int32_t lv_anim_get_delay(lv_anim_t * a)
*/
bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb);
/**
* Delete all the animations animation
*/
void lv_anim_del_all(void);
/**
* Get the animation of a variable and its `exec_cb`.
* @param var pointer to variable
@@ -350,7 +355,7 @@ uint16_t lv_anim_count_running(void);
* @param end end value of the animation
* @return the required time [ms] for the animation with the given parameters
*/
uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end);
uint32_t lv_anim_speed_to_time(uint32_t speed, lv_anim_value_t start, lv_anim_value_t end);
/**
* Manually refresh the state of the animations.

View File

@@ -15,6 +15,7 @@ extern "C" {
*********************/
#include "../lv_conf_internal.h"
#include "lv_math.h"
#include "lv_types.h"
/*Error checking*/
#if LV_COLOR_DEPTH == 24
@@ -103,6 +104,34 @@ enum {
#endif
#endif
#if defined(__cplusplus) && !defined(_LV_COLOR_HAS_MODERN_CPP)
/**
* MSVC compiler's definition of the __cplusplus indicating 199711L regardless to C++ standard version
* see https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-cplusplus
* so we use _MSC_VER macro instead of __cplusplus
*/
#ifdef _MSC_VER
#if _MSC_VER >= 1900 /* Visual Studio 2015 */
#define _LV_COLOR_HAS_MODERN_CPP 1
#endif
#else
#if __cplusplus >= 201103L
#define _LV_COLOR_HAS_MODERN_CPP 1
#endif
#endif
#endif /* __cplusplus */
#ifndef _LV_COLOR_HAS_MODERN_CPP
#define _LV_COLOR_HAS_MODERN_CPP 0
#endif
#if _LV_COLOR_HAS_MODERN_CPP
/* Fix msvc compiler error C4576 inside C++ code */
#define _LV_COLOR_MAKE_TYPE_HELPER lv_color_t
#else
#define _LV_COLOR_MAKE_TYPE_HELPER (lv_color_t)
#endif
/*---------------------------------------
* Macros for all existing color depths
* to set/get values of the color channels
@@ -117,6 +146,9 @@ enum {
# define LV_COLOR_GET_B1(c) (c).ch.blue
# define LV_COLOR_GET_A1(c) 0xFF
# define _LV_COLOR_ZERO_INITIALIZER1 {0x00}
# define LV_COLOR_MAKE1(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{(uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))})
# define LV_COLOR_SET_R8(c, v) (c).ch.red = (uint8_t)((v) & 0x7U)
# define LV_COLOR_SET_G8(c, v) (c).ch.green = (uint8_t)((v) & 0x7U)
# define LV_COLOR_SET_B8(c, v) (c).ch.blue = (uint8_t)((v) & 0x3U)
@@ -127,6 +159,9 @@ enum {
# define LV_COLOR_GET_B8(c) (c).ch.blue
# define LV_COLOR_GET_A8(c) 0xFF
# define _LV_COLOR_ZERO_INITIALIZER8 {{0x00, 0x00, 0x00}}
# define LV_COLOR_MAKE8(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}})
# define LV_COLOR_SET_R16(c, v) (c).ch.red = (uint8_t)((v) & 0x1FU)
#if LV_COLOR_16_SWAP == 0
# define LV_COLOR_SET_G16(c, v) (c).ch.green = (uint8_t)((v) & 0x3FU)
@@ -145,6 +180,14 @@ enum {
# define LV_COLOR_GET_B16(c) (c).ch.blue
# define LV_COLOR_GET_A16(c) 0xFF
#if LV_COLOR_16_SWAP == 0
# define _LV_COLOR_ZERO_INITIALIZER16 {{0x00, 0x00, 0x00}}
# define LV_COLOR_MAKE16(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((b8 >> 3) & 0x1FU), (uint8_t)((g8 >> 2) & 0x3FU), (uint8_t)((r8 >> 3) & 0x1FU)}})
#else
# define _LV_COLOR_ZERO_INITIALIZER16 {{0x00, 0x00, 0x00, 0x00}}
# define LV_COLOR_MAKE16(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 3) & 0x1FU), (uint8_t)((b8 >> 3) & 0x1FU), (uint8_t)((g8 >> 2) & 0x7U)}})
#endif
# define LV_COLOR_SET_R32(c, v) (c).ch.red = (uint8_t)((v) & 0xFF)
# define LV_COLOR_SET_G32(c, v) (c).ch.green = (uint8_t)((v) & 0xFF)
# define LV_COLOR_SET_B32(c, v) (c).ch.blue = (uint8_t)((v) & 0xFF)
@@ -155,54 +198,25 @@ enum {
# define LV_COLOR_GET_B32(c) (c).ch.blue
# define LV_COLOR_GET_A32(c) (c).ch.alpha
# define _LV_COLOR_ZERO_INITIALIZER32 {{0x00, 0x00, 0x00, 0x00}}
# define LV_COLOR_MAKE32(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/
/*---------------------------------------
* Macros for the current color depth
* to set/get values of the color channels
*------------------------------------------*/
#if LV_COLOR_DEPTH == 1
# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R1(c,v)
# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G1(c,v)
# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B1(c,v)
# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A1(c,v)
#define LV_COLOR_SET_R(c, v) LV_CONCAT(LV_COLOR_SET_R, LV_COLOR_DEPTH)(c, v)
#define LV_COLOR_SET_G(c, v) LV_CONCAT(LV_COLOR_SET_G, LV_COLOR_DEPTH)(c, v)
#define LV_COLOR_SET_B(c, v) LV_CONCAT(LV_COLOR_SET_B, LV_COLOR_DEPTH)(c, v)
#define LV_COLOR_SET_A(c, v) LV_CONCAT(LV_COLOR_SET_A, LV_COLOR_DEPTH)(c, v)
# define LV_COLOR_GET_R(c) LV_COLOR_GET_R1(c)
# define LV_COLOR_GET_G(c) LV_COLOR_GET_G1(c)
# define LV_COLOR_GET_B(c) LV_COLOR_GET_B1(c)
# define LV_COLOR_GET_A(c) LV_COLOR_GET_A1(c)
#define LV_COLOR_GET_R(c) LV_CONCAT(LV_COLOR_GET_R, LV_COLOR_DEPTH)(c)
#define LV_COLOR_GET_G(c) LV_CONCAT(LV_COLOR_GET_G, LV_COLOR_DEPTH)(c)
#define LV_COLOR_GET_B(c) LV_CONCAT(LV_COLOR_GET_B, LV_COLOR_DEPTH)(c)
#define LV_COLOR_GET_A(c) LV_CONCAT(LV_COLOR_GET_A, LV_COLOR_DEPTH)(c)
#elif LV_COLOR_DEPTH == 8
# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R8(c,v)
# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G8(c,v)
# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B8(c,v)
# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A8(c,v)
# define LV_COLOR_GET_R(c) LV_COLOR_GET_R8(c)
# define LV_COLOR_GET_G(c) LV_COLOR_GET_G8(c)
# define LV_COLOR_GET_B(c) LV_COLOR_GET_B8(c)
# define LV_COLOR_GET_A(c) LV_COLOR_GET_A8(c)
#elif LV_COLOR_DEPTH == 16
# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R16(c,v)
# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G16(c,v)
# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B16(c,v)
# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A16(c,v)
# define LV_COLOR_GET_R(c) LV_COLOR_GET_R16(c)
# define LV_COLOR_GET_G(c) LV_COLOR_GET_G16(c)
# define LV_COLOR_GET_B(c) LV_COLOR_GET_B16(c)
# define LV_COLOR_GET_A(c) LV_COLOR_GET_A16(c)
#elif LV_COLOR_DEPTH == 32
# define LV_COLOR_SET_R(c, v) LV_COLOR_SET_R32(c,v)
# define LV_COLOR_SET_G(c, v) LV_COLOR_SET_G32(c,v)
# define LV_COLOR_SET_B(c, v) LV_COLOR_SET_B32(c,v)
# define LV_COLOR_SET_A(c, v) LV_COLOR_SET_A32(c,v)
# define LV_COLOR_GET_R(c) LV_COLOR_GET_R32(c)
# define LV_COLOR_GET_G(c) LV_COLOR_GET_G32(c)
# define LV_COLOR_GET_B(c) LV_COLOR_GET_B32(c)
# define LV_COLOR_GET_A(c) LV_COLOR_GET_A32(c)
#endif
#define _LV_COLOR_ZERO_INITIALIZER LV_CONCAT(_LV_COLOR_ZERO_INITIALIZER, LV_COLOR_DEPTH)
#define LV_COLOR_MAKE(r8, g8, b8) LV_CONCAT(LV_COLOR_MAKE, LV_COLOR_DEPTH)(r8, g8, b8)
/**********************
* TYPEDEFS
@@ -252,29 +266,8 @@ typedef union {
uint32_t full;
} lv_color32_t;
#if LV_COLOR_DEPTH == 1
typedef uint8_t lv_color_int_t;
typedef lv_color1_t lv_color_t;
#define _LV_COLOR_ZERO_INITIALIZER {0x00}
#elif LV_COLOR_DEPTH == 8
typedef uint8_t lv_color_int_t;
typedef lv_color8_t lv_color_t;
#define _LV_COLOR_ZERO_INITIALIZER {{0x00, 0x00, 0x00}}
#elif LV_COLOR_DEPTH == 16
typedef uint16_t lv_color_int_t;
typedef lv_color16_t lv_color_t;
# if LV_COLOR_16_SWAP == 0
# define _LV_COLOR_ZERO_INITIALIZER {{0x00, 0x00, 0x00}}
# else
# define _LV_COLOR_ZERO_INITIALIZER {{0x00, 0x00, 0x00, 0x00}}
# endif
#elif LV_COLOR_DEPTH == 32
typedef uint32_t lv_color_int_t;
typedef lv_color32_t lv_color_t;
#define _LV_COLOR_ZERO_INITIALIZER {{0x00, 0x00, 0x00, 0x00}}
#else
#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!"
#endif
typedef LV_CONCAT3(uint, LV_COLOR_SIZE, _t) lv_color_int_t;
typedef LV_CONCAT3(lv_color, LV_COLOR_DEPTH, _t) lv_color_t;
typedef struct {
uint16_t h;
@@ -587,49 +580,6 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
return (uint8_t)(bright >> 3);
}
#if defined(__cplusplus) && !defined(_LV_COLOR_HAS_MODERN_CPP)
/**
* MSVC compiler's definition of the __cplusplus indicating 199711L regardless to C++ standard version
* see https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-cplusplus
* so we use _MSC_VER macro instead of __cplusplus
*/
#ifdef _MSC_VER
#if _MSC_VER >= 1900 /* Visual Studio 2015 */
#define _LV_COLOR_HAS_MODERN_CPP 1
#endif
#else
#if __cplusplus >= 201103L
#define _LV_COLOR_HAS_MODERN_CPP 1
#endif
#endif
#endif /* __cplusplus */
#ifndef _LV_COLOR_HAS_MODERN_CPP
#define _LV_COLOR_HAS_MODERN_CPP 0
#endif
#if _LV_COLOR_HAS_MODERN_CPP
/* Fix msvc compiler error C4576 inside C++ code */
#define _LV_COLOR_MAKE_TYPE_HELPER lv_color_t
#else
#define _LV_COLOR_MAKE_TYPE_HELPER (lv_color_t)
#endif
/* The most simple macro to create a color from R,G and B values */
#if LV_COLOR_DEPTH == 1
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{(uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))})
#elif LV_COLOR_DEPTH == 8
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}})
#elif LV_COLOR_DEPTH == 16
#if LV_COLOR_16_SWAP == 0
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((b8 >> 3) & 0x1FU), (uint8_t)((g8 >> 2) & 0x3FU), (uint8_t)((r8 >> 3) & 0x1FU)}})
#else
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 3) & 0x1FU), (uint8_t)((b8 >> 3) & 0x1FU), (uint8_t)((g8 >> 2) & 0x7U)}})
#endif
#elif LV_COLOR_DEPTH == 32
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/
#endif
static inline lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b)
{
return LV_COLOR_MAKE(r, g, b);

View File

@@ -275,7 +275,7 @@ char * lv_fs_up(char * path);
/**
* Get the last element of a path (e.g. U:/folder/file -> file)
* @param buf buffer to store the letters ('\0' added after the last letter)
* @param path pointer to a file name
* @return pointer to the beginning of the last element in the path
*/
const char * lv_fs_get_last(const char * path);

View File

@@ -240,8 +240,8 @@ int64_t _lv_pow(int64_t base, int8_t exp)
*/
int32_t _lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out)
{
if(x <= min_in) return min_out;
if(x >= max_in) return max_out;
if(x <= min_in) return min_out;
/* The equation should be:
* ((x - min_in) / delta in) * delta_out + min_out

View File

@@ -10,6 +10,7 @@
#include "lv_mem.h"
#include "lv_math.h"
#include "lv_gc.h"
#include "lv_debug.h"
#include <string.h>
#if LV_MEM_CUSTOM != 0

View File

@@ -357,6 +357,7 @@ lv_coord_t _lv_txt_get_width(const char * txt, uint32_t length, const lv_font_t
{
if(txt == NULL) return 0;
if(font == NULL) return 0;
if(txt[0] == '\0') return 0;
uint32_t i = 0;
lv_coord_t width = 0;
@@ -723,7 +724,7 @@ static uint32_t lv_txt_utf8_get_byte_id(const char * txt, uint32_t utf8_id)
{
uint32_t i;
uint32_t byte_cnt = 0;
for(i = 0; i < utf8_id; i++) {
for(i = 0; i < utf8_id && txt[byte_cnt] != '\0'; i++) {
uint8_t c_size = _lv_txt_encoded_size(&txt[byte_cnt]);
byte_cnt += c_size > 0 ? c_size : 1;
}

View File

@@ -25,6 +25,7 @@
**********************/
#if LV_USE_ARABIC_PERSIAN_CHARS == 1
static uint32_t lv_ap_get_char_index(uint16_t c);
static uint32_t lv_txt_lam_alef(uint32_t ch_curr, uint32_t ch_next);
/**********************
* STATIC VARIABLES
@@ -58,6 +59,7 @@ const ap_chars_map_t ap_chars_map[] = {
{22, 0xFEC6, 1, 2, -1, {1, 1}}, // ظ
{23, 0xFECA, 1, 2, -1, {1, 1}}, // ع
{24, 0xFECE, 1, 2, -1, {1, 1}}, // غ
{30, 0x0640, 0, 0, 0, {1, 1}}, // - (mad, hyphen)
{31, 0xFED2, 1, 2, -1, {1, 1}}, // ف
{32, 0xFED6, 1, 2, -1, {1, 1}}, // ق
{135, 0xFB8F, 1, 2, -1, {1, 1}}, // ک
@@ -130,11 +132,13 @@ void _lv_txt_ap_proc(const char * txt, char * txt_out)
uint32_t txt_length = 0;
uint32_t index_current, idx_next, idx_previous, i, j;
uint32_t * ch_enc;
uint32_t * ch_fin;
char * txt_out_temp;
txt_length = _lv_txt_get_encoded_length(txt);
ch_enc = (uint32_t *)lv_mem_alloc(sizeof(uint32_t) * (txt_length + 1));
ch_fin = (uint32_t *)lv_mem_alloc(sizeof(uint32_t) * (txt_length + 1));
i = 0;
j = 0;
@@ -144,12 +148,15 @@ void _lv_txt_ap_proc(const char * txt, char * txt_out)
ch_enc[j] = 0;
i = 0;
j = 0;
idx_previous = LV_UNDEF_ARABIC_PERSIAN_CHARS;
while(i < txt_length) {
index_current = lv_ap_get_char_index(ch_enc[i]);
idx_next = lv_ap_get_char_index(ch_enc[i + 1]);
if(index_current == LV_UNDEF_ARABIC_PERSIAN_CHARS) {
ch_fin[j] = ch_enc[i];
j++;
i++;
idx_previous = LV_UNDEF_ARABIC_PERSIAN_CHARS;
continue;
@@ -160,17 +167,36 @@ void _lv_txt_ap_proc(const char * txt, char * txt_out)
uint8_t conjunction_to_next = ((i == txt_length - 1) ||
idx_next == LV_UNDEF_ARABIC_PERSIAN_CHARS) ? 0 : ap_chars_map[idx_next].ap_chars_conjunction.conj_to_previous;
uint32_t lam_alef = lv_txt_lam_alef(index_current, idx_next);
if(lam_alef) {
if(conjunction_to_previuse) {
lam_alef ++;
}
ch_fin[j] = lam_alef;
idx_previous = LV_UNDEF_ARABIC_PERSIAN_CHARS;
i += 2;
j++;
continue;
}
if(conjunction_to_previuse && conjunction_to_next)
ch_enc[i] = ap_chars_map[index_current].char_end_form + ap_chars_map[index_current].char_middle_form_offset;
ch_fin[j] = ap_chars_map[index_current].char_end_form + ap_chars_map[index_current].char_middle_form_offset;
else if(!conjunction_to_previuse && conjunction_to_next)
ch_enc[i] = ap_chars_map[index_current].char_end_form + ap_chars_map[index_current].char_begining_form_offset;
ch_fin[j] = ap_chars_map[index_current].char_end_form + ap_chars_map[index_current].char_begining_form_offset;
else if(conjunction_to_previuse && !conjunction_to_next)
ch_enc[i] = ap_chars_map[index_current].char_end_form;
ch_fin[j] = ap_chars_map[index_current].char_end_form;
else
ch_enc[i] = ap_chars_map[index_current].char_end_form + ap_chars_map[index_current].char_isolated_form_offset;
ch_fin[j] = ap_chars_map[index_current].char_end_form + ap_chars_map[index_current].char_isolated_form_offset;
idx_previous = index_current;
i++;
j++;
}
ch_fin[j] = 0;
for(i = 0; i < txt_length; i++)
ch_enc[i] = 0;
for(i = 0; i < j; i++)
ch_enc[i] = ch_fin[i];
lv_mem_free(ch_fin);
txt_out_temp = txt_out;
i = 0;
@@ -219,4 +245,29 @@ static uint32_t lv_ap_get_char_index(uint16_t c)
return LV_UNDEF_ARABIC_PERSIAN_CHARS;
}
static uint32_t lv_txt_lam_alef(uint32_t ch_curr, uint32_t ch_next)
{
uint32_t ch_code = 0;
if(ap_chars_map[ch_curr].char_offset != 34) {
return 0;
}
if(ch_next == LV_UNDEF_ARABIC_PERSIAN_CHARS) {
return 0;
}
ch_code = ap_chars_map[ch_next].char_offset + LV_AP_ALPHABET_BASE_CODE;
if(ch_code == 0x0622) {
return 0xFEF5; // (lam-alef) mad
}
if(ch_code == 0x0623) {
return 0xFEF7; // (lam-alef) top hamza
}
if(ch_code == 0x0625) {
return 0xFEF9; // (lam-alef) bot hamza
}
if(ch_code == 0x0627) {
return 0xFEFB; // (lam-alef) alef
}
return 0;
}
#endif

View File

@@ -74,6 +74,12 @@ typedef uint32_t lv_uintptr_t;
#define LV_UNUSED(x) ((void) x)
#define _LV_CONCAT(x, y) x ## y
#define LV_CONCAT(x, y) _LV_CONCAT(x, y)
#define _LV_CONCAT3(x, y, z) x ## y ## z
#define LV_CONCAT3(x, y, z) _LV_CONCAT3(x, y, z)
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@@ -91,7 +91,6 @@ void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy)
theme->apply_cb = copy->apply_cb;
theme->apply_xcb = copy->apply_xcb;
}
}
/**
@@ -471,5 +470,4 @@ static void clear_styles(lv_obj_t * obj, lv_theme_style_t name)
default:
break;
}
}

View File

@@ -1,10 +1,10 @@
/**
*@file lv_themes.h
*@file lv_theme.h
*
*/
#ifndef LV_THEMES_H
#define LV_THEMES_H
#ifndef LV_THEME_H
#define LV_THEME_H
#ifdef __cplusplus
extern "C" {
@@ -272,4 +272,4 @@ uint32_t lv_theme_get_flags(void);
} /* extern "C" */
#endif
#endif /*LV_THEMES_H*/
#endif /*LV_THEME_H*/

View File

@@ -6,7 +6,6 @@
/*********************
* INCLUDES
*********************/
#include <stdint.h>
#include "../../lvgl.h" /*To see all the widgets*/
#if LV_USE_THEME_EMPTY
@@ -28,7 +27,6 @@ typedef struct {
* STATIC PROTOTYPES
**********************/
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
static void style_init_reset(lv_style_t * style);
/**********************
* STATIC VARIABLES
@@ -36,8 +34,6 @@ static void style_init_reset(lv_style_t * style);
static lv_theme_t theme;
static theme_styles_t * styles;
static bool inited;
/**********************
* MACROS
**********************/
@@ -68,9 +64,11 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco
/* This trick is required only to avoid the garbage collection of
* styles' data if LVGL is used in a binding (e.g. Micropython)
* In a general case styles could be simple `static lv_style_t my style` variables*/
if(!inited) {
LV_GC_ROOT(_lv_theme_empty_styles) = lv_mem_alloc(sizeof(theme_styles_t));
styles = (theme_styles_t *)LV_GC_ROOT(_lv_theme_empty_styles);
if(styles == NULL) {
styles = lv_mem_alloc(sizeof(theme_styles_t));
if(styles == NULL) return NULL;
_lv_memset_00(styles, sizeof(theme_styles_t));
LV_GC_ROOT(_lv_theme_empty_styles) = styles;
}
theme.color_primary = color_primary;
@@ -81,7 +79,7 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco
theme.font_title = font_title;
theme.flags = flags;
style_init_reset(&styles->opa_cover);
lv_style_reset(&styles->opa_cover);
lv_style_set_bg_opa(&styles->opa_cover, LV_STATE_DEFAULT, LV_OPA_COVER);
theme.apply_xcb = NULL;
@@ -89,23 +87,17 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco
return &theme;
}
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
{
LV_UNUSED(th);
if(name == LV_THEME_SCR) {
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &styles->opa_cover);
}
}
/**********************
* STATIC FUNCTIONS
**********************/
static void style_init_reset(lv_style_t * style)
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
{
if(inited) lv_style_reset(style);
else lv_style_init(style);
LV_UNUSED(th);
if(name == LV_THEME_SCR) {
lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &styles->opa_cover);
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
}
#endif

View File

@@ -1,5 +1,5 @@
/**
* @file lv_theme_material.h
* @file lv_theme_empty.h
*
*/
@@ -53,4 +53,4 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco
} /* extern "C" */
#endif
#endif /*LV_THEME_ALIEN_H*/
#endif /*LV_THEME_EMPTY_H*/

View File

@@ -175,7 +175,6 @@ typedef struct {
* STATIC PROTOTYPES
**********************/
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
static void style_init_reset(lv_style_t * style);
/**********************
* STATIC VARIABLES
@@ -183,8 +182,6 @@ static void style_init_reset(lv_style_t * style);
static lv_theme_t theme;
static theme_styles_t * styles;
static bool inited;
/**********************
* MACROS
**********************/
@@ -195,7 +192,7 @@ static bool inited;
static void basic_init(void)
{
style_init_reset(&styles->scr);
lv_style_reset(&styles->scr);
lv_style_set_bg_opa(&styles->scr, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR);
lv_style_set_text_color(&styles->scr, LV_STATE_DEFAULT, COLOR_SCR_TEXT);
@@ -204,7 +201,7 @@ static void basic_init(void)
lv_style_set_text_sel_bg_color(&styles->scr, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_value_font(&styles->scr, LV_STATE_DEFAULT, theme.font_normal);
style_init_reset(&styles->bg);
lv_style_reset(&styles->bg);
lv_style_set_radius(&styles->bg, LV_STATE_DEFAULT, LV_DPX(8));
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);
@@ -228,7 +225,7 @@ static void basic_init(void)
lv_style_set_transition_time(&styles->bg, LV_STATE_DEFAULT, TRANSITION_TIME);
lv_style_set_transition_prop_6(&styles->bg, LV_STATE_DEFAULT, LV_STYLE_BORDER_COLOR);
style_init_reset(&styles->bg_sec);
lv_style_reset(&styles->bg_sec);
lv_style_copy(&styles->bg_sec, &styles->bg);
lv_style_set_bg_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC);
lv_style_set_border_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_BORDER);
@@ -237,7 +234,7 @@ static void basic_init(void)
lv_style_set_image_recolor(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
lv_style_set_line_color(&styles->bg_sec, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
style_init_reset(&styles->bg_click);
lv_style_reset(&styles->bg_click);
lv_style_set_bg_color(&styles->bg_click, LV_STATE_PRESSED, COLOR_BG_PR);
lv_style_set_bg_color(&styles->bg_click, LV_STATE_CHECKED, COLOR_BG_CHK);
lv_style_set_bg_color(&styles->bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_PR_CHK);
@@ -259,7 +256,7 @@ static void basic_init(void)
lv_style_set_image_recolor(&styles->bg_click, LV_STATE_DISABLED, COLOR_BG_TEXT_DIS);
lv_style_set_transition_prop_5(&styles->bg_click, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR);
style_init_reset(&styles->btn);
lv_style_reset(&styles->btn);
lv_style_set_radius(&styles->btn, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_bg_opa(&styles->btn, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->btn, LV_STATE_DEFAULT, COLOR_BTN);
@@ -309,12 +306,12 @@ static void basic_init(void)
lv_style_set_transition_delay(&styles->btn, LV_STATE_DEFAULT, TRANSITION_TIME);
lv_style_set_transition_delay(&styles->btn, LV_STATE_PRESSED, 0);
style_init_reset(&styles->pad_inner);
lv_style_reset(&styles->pad_inner);
lv_style_set_pad_inner(&styles->pad_inner, LV_STATE_DEFAULT,
lv_disp_get_size_category(NULL) <= LV_DISP_SIZE_MEDIUM ? LV_DPX(20) : LV_DPX(40));
style_init_reset(&styles->pad_small);
lv_style_reset(&styles->pad_small);
lv_style_int_t pad_small_value = lv_disp_get_size_category(NULL) <= LV_DISP_SIZE_MEDIUM ? LV_DPX(10) : LV_DPX(20);
lv_style_set_pad_left(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value);
lv_style_set_pad_right(&styles->pad_small, LV_STATE_DEFAULT, pad_small_value);
@@ -347,7 +344,7 @@ static void label_init(void)
static void bar_init(void)
{
#if LV_USE_BAR
style_init_reset(&styles->bar_bg);
lv_style_reset(&styles->bar_bg);
lv_style_set_radius(&styles->bar_bg, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_bg_opa(&styles->bar_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->bar_bg, LV_STATE_DEFAULT, COLOR_BG_SEC);
@@ -360,7 +357,7 @@ static void bar_init(void)
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);
style_init_reset(&styles->bar_indic);
lv_style_reset(&styles->bar_indic);
lv_style_set_bg_opa(&styles->bar_indic, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_radius(&styles->bar_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_bg_color(&styles->bar_indic, LV_STATE_DEFAULT, theme.color_primary);
@@ -386,7 +383,7 @@ static void line_init(void)
static void led_init(void)
{
#if LV_USE_LED != 0
style_init_reset(&styles->led);
lv_style_reset(&styles->led);
lv_style_set_bg_opa(&styles->led, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->led, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_border_width(&styles->led, LV_STATE_DEFAULT, 2);
@@ -402,7 +399,7 @@ static void led_init(void)
static void slider_init(void)
{
#if LV_USE_SLIDER != 0
style_init_reset(&styles->slider_knob);
lv_style_reset(&styles->slider_knob);
lv_style_set_bg_opa(&styles->slider_knob, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->slider_knob, LV_STATE_DEFAULT, IS_LIGHT ? theme.color_primary : LV_COLOR_WHITE);
lv_style_set_value_color(&styles->slider_knob, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE);
@@ -412,7 +409,7 @@ static void slider_init(void)
lv_style_set_pad_top(&styles->slider_knob, LV_STATE_DEFAULT, LV_DPX(7));
lv_style_set_pad_bottom(&styles->slider_knob, LV_STATE_DEFAULT, LV_DPX(7));
style_init_reset(&styles->slider_bg);
lv_style_reset(&styles->slider_bg);
lv_style_set_margin_left(&styles->slider_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_margin_right(&styles->slider_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_margin_top(&styles->slider_bg, LV_STATE_DEFAULT, LV_DPX(10));
@@ -424,7 +421,7 @@ static void slider_init(void)
static void switch_init(void)
{
#if LV_USE_SWITCH != 0
style_init_reset(&styles->sw_knob);
lv_style_reset(&styles->sw_knob);
lv_style_set_bg_opa(&styles->sw_knob, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->sw_knob, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_style_set_radius(&styles->sw_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
@@ -438,7 +435,7 @@ static void switch_init(void)
static void linemeter_init(void)
{
#if LV_USE_LINEMETER != 0
style_init_reset(&styles->lmeter);
lv_style_reset(&styles->lmeter);
lv_style_set_radius(&styles->lmeter, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_pad_left(&styles->lmeter, LV_STATE_DEFAULT, LV_DPX(20));
lv_style_set_pad_right(&styles->lmeter, LV_STATE_DEFAULT, LV_DPX(20));
@@ -457,7 +454,7 @@ static void linemeter_init(void)
static void gauge_init(void)
{
#if LV_USE_GAUGE != 0
style_init_reset(&styles->gauge_main);
lv_style_reset(&styles->gauge_main);
lv_style_set_line_color(&styles->gauge_main, LV_STATE_DEFAULT, lv_color_hex3(0x888));
lv_style_set_scale_grad_color(&styles->gauge_main, LV_STATE_DEFAULT, lv_color_hex3(0x888));
lv_style_set_scale_end_color(&styles->gauge_main, LV_STATE_DEFAULT, theme.color_primary);
@@ -471,7 +468,7 @@ static void gauge_init(void)
lv_style_set_scale_width(&styles->gauge_main, LV_STATE_DEFAULT, LV_DPX(15));
lv_style_set_radius(&styles->gauge_main, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
style_init_reset(&styles->gauge_strong);
lv_style_reset(&styles->gauge_strong);
lv_style_set_line_color(&styles->gauge_strong, LV_STATE_DEFAULT, lv_color_hex3(0x888));
lv_style_set_scale_grad_color(&styles->gauge_strong, LV_STATE_DEFAULT, lv_color_hex3(0x888));
lv_style_set_scale_end_color(&styles->gauge_strong, LV_STATE_DEFAULT, theme.color_primary);
@@ -479,7 +476,7 @@ static void gauge_init(void)
lv_style_set_scale_end_line_width(&styles->gauge_strong, LV_STATE_DEFAULT, LV_DPX(8));
lv_style_set_scale_width(&styles->gauge_strong, LV_STATE_DEFAULT, LV_DPX(25));
style_init_reset(&styles->gauge_needle);
lv_style_reset(&styles->gauge_needle);
lv_style_set_line_color(&styles->gauge_needle, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x464b5b) : LV_COLOR_WHITE);
lv_style_set_line_width(&styles->gauge_needle, LV_STATE_DEFAULT, LV_DPX(8));
lv_style_set_bg_opa(&styles->gauge_needle, LV_STATE_DEFAULT, LV_OPA_COVER);
@@ -493,17 +490,17 @@ static void gauge_init(void)
static void arc_init(void)
{
#if LV_USE_ARC != 0
style_init_reset(&styles->arc_indic);
lv_style_reset(&styles->arc_indic);
lv_style_set_line_color(&styles->arc_indic, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_line_width(&styles->arc_indic, LV_STATE_DEFAULT, LV_DPX(25));
lv_style_set_line_rounded(&styles->arc_indic, LV_STATE_DEFAULT, true);
style_init_reset(&styles->arc_bg);
lv_style_reset(&styles->arc_bg);
lv_style_set_line_color(&styles->arc_bg, LV_STATE_DEFAULT, COLOR_BG_SEC);
lv_style_set_line_width(&styles->arc_bg, LV_STATE_DEFAULT, LV_DPX(25));
lv_style_set_line_rounded(&styles->arc_bg, LV_STATE_DEFAULT, true);
style_init_reset(&styles->arc_knob);
lv_style_reset(&styles->arc_knob);
lv_style_set_radius(&styles->arc_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_pad_top(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
lv_style_set_pad_bottom(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
@@ -522,16 +519,16 @@ static void spinner_init(void)
static void chart_init(void)
{
#if LV_USE_CHART
style_init_reset(&styles->chart_bg);
lv_style_reset(&styles->chart_bg);
lv_style_set_text_color(&styles->chart_bg, LV_STATE_DEFAULT, IS_LIGHT ? COLOR_BG_TEXT_DIS : lv_color_hex(0xa1adbd));
style_init_reset(&styles->chart_series_bg);
lv_style_reset(&styles->chart_series_bg);
lv_style_set_line_width(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(1));
lv_style_set_line_dash_width(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_line_dash_gap(&styles->chart_series_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_line_color(&styles->chart_series_bg, LV_STATE_DEFAULT, COLOR_BG_BORDER);
style_init_reset(&styles->chart_series);
lv_style_reset(&styles->chart_series);
lv_style_set_line_width(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(3));
lv_style_set_size(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(4));
lv_style_set_pad_inner(&styles->chart_series, LV_STATE_DEFAULT, LV_DPX(2)); /*Space between columns*/
@@ -544,7 +541,7 @@ static void calendar_init(void)
{
#if LV_USE_CALENDAR
style_init_reset(&styles->calendar_header);
lv_style_reset(&styles->calendar_header);
lv_style_set_pad_top(&styles->calendar_header, LV_STATE_DEFAULT, 0);
lv_style_set_pad_left(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_right(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
@@ -553,14 +550,14 @@ static void calendar_init(void)
lv_style_set_margin_bottom(&styles->calendar_header, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_text_color(&styles->calendar_header, LV_STATE_PRESSED, IS_LIGHT ? lv_color_hex(0x888888) : LV_COLOR_WHITE);
style_init_reset(&styles->calendar_daynames);
lv_style_reset(&styles->calendar_daynames);
lv_style_set_text_color(&styles->calendar_daynames, LV_STATE_DEFAULT,
IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex3(0xeee));
lv_style_set_pad_left(&styles->calendar_daynames, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_right(&styles->calendar_daynames, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_bottom(&styles->calendar_daynames, LV_STATE_DEFAULT, PAD_DEF);
style_init_reset(&styles->calendar_date_nums);
lv_style_reset(&styles->calendar_date_nums);
lv_style_set_radius(&styles->calendar_date_nums, LV_STATE_DEFAULT, LV_DPX(4));
lv_style_set_text_color(&styles->calendar_date_nums, LV_STATE_CHECKED,
IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE);
@@ -586,14 +583,14 @@ static void calendar_init(void)
static void cpicker_init(void)
{
#if LV_USE_CPICKER
style_init_reset(&styles->cpicker_bg);
lv_style_reset(&styles->cpicker_bg);
lv_style_set_scale_width(&styles->cpicker_bg, LV_STATE_DEFAULT, LV_DPX(30));
lv_style_set_bg_opa(&styles->cpicker_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->cpicker_bg, LV_STATE_DEFAULT, COLOR_SCR);
lv_style_set_pad_inner(&styles->cpicker_bg, LV_STATE_DEFAULT, LV_DPX(20));
lv_style_set_radius(&styles->cpicker_bg, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
style_init_reset(&styles->cpicker_indic);
lv_style_reset(&styles->cpicker_indic);
lv_style_set_radius(&styles->cpicker_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_style_set_bg_color(&styles->cpicker_indic, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_style_set_bg_opa(&styles->cpicker_indic, LV_STATE_DEFAULT, LV_OPA_COVER);
@@ -611,7 +608,7 @@ static void cpicker_init(void)
static void checkbox_init(void)
{
#if LV_USE_CHECKBOX != 0
style_init_reset(&styles->cb_bg);
lv_style_reset(&styles->cb_bg);
lv_style_set_radius(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(4));
lv_style_set_pad_inner(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_outline_color(&styles->cb_bg, LV_STATE_DEFAULT, theme.color_primary);
@@ -622,7 +619,7 @@ static void checkbox_init(void)
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);
style_init_reset(&styles->cb_bullet);
lv_style_reset(&styles->cb_bullet);
lv_style_set_outline_opa(&styles->cb_bullet, LV_STATE_FOCUSED, LV_OPA_TRANSP);
lv_style_set_radius(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(4));
lv_style_set_pattern_image(&styles->cb_bullet, LV_STATE_CHECKED, LV_SYMBOL_OK);
@@ -645,7 +642,7 @@ static void btnmatrix_init(void)
static void keyboard_init(void)
{
#if LV_USE_KEYBOARD
style_init_reset(&styles->kb_bg);
lv_style_reset(&styles->kb_bg);
lv_style_set_radius(&styles->kb_bg, LV_STATE_DEFAULT, 0);
lv_style_set_border_width(&styles->kb_bg, LV_STATE_DEFAULT, LV_DPX(4));
lv_style_set_border_side(&styles->kb_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP);
@@ -662,7 +659,7 @@ static void keyboard_init(void)
static void msgbox_init(void)
{
#if LV_USE_MSGBOX
style_init_reset(&styles->mbox_bg);
lv_style_reset(&styles->mbox_bg);
lv_style_set_shadow_width(&styles->mbox_bg, LV_STATE_DEFAULT, LV_DPX(50));
lv_style_set_shadow_color(&styles->mbox_bg, LV_STATE_DEFAULT, IS_LIGHT ? LV_COLOR_SILVER : lv_color_hex3(0x999));
@@ -672,7 +669,7 @@ static void msgbox_init(void)
static void page_init(void)
{
#if LV_USE_PAGE
style_init_reset(&styles->sb);
lv_style_reset(&styles->sb);
lv_style_set_bg_opa(&styles->sb, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->sb, LV_STATE_DEFAULT, (IS_LIGHT ? lv_color_hex(0xcccfd1) : lv_color_hex(0x777f85)));
lv_style_set_radius(&styles->sb, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
@@ -681,7 +678,7 @@ static void page_init(void)
lv_style_set_pad_bottom(&styles->sb, LV_STATE_DEFAULT, LV_DPX(7));
#if LV_USE_ANIMATION
style_init_reset(&styles->edge_flash);
lv_style_reset(&styles->edge_flash);
lv_style_set_bg_opa(&styles->edge_flash, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->edge_flash, LV_STATE_DEFAULT, lv_color_hex3(0x888));
#endif
@@ -691,13 +688,13 @@ static void page_init(void)
static void textarea_init(void)
{
#if LV_USE_TEXTAREA
style_init_reset(&styles->ta_cursor);
lv_style_reset(&styles->ta_cursor);
lv_style_set_border_color(&styles->ta_cursor, LV_STATE_DEFAULT, COLOR_BG_SEC_TEXT);
lv_style_set_border_width(&styles->ta_cursor, LV_STATE_DEFAULT, LV_DPX(2));
lv_style_set_pad_left(&styles->ta_cursor, LV_STATE_DEFAULT, LV_DPX(1));
lv_style_set_border_side(&styles->ta_cursor, LV_STATE_DEFAULT, LV_BORDER_SIDE_LEFT);
style_init_reset(&styles->ta_placeholder);
lv_style_reset(&styles->ta_placeholder);
lv_style_set_text_color(&styles->ta_placeholder, LV_STATE_DEFAULT,
IS_LIGHT ? COLOR_BG_TEXT_DIS : lv_color_hex(0xa1adbd));
#endif
@@ -707,7 +704,7 @@ static void spinbox_init(void)
{
#if LV_USE_SPINBOX
style_init_reset(&styles->spinbox_cursor);
lv_style_reset(&styles->spinbox_cursor);
lv_style_set_bg_opa(&styles->spinbox_cursor, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->spinbox_cursor, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_text_color(&styles->spinbox_cursor, LV_STATE_DEFAULT, LV_COLOR_WHITE);
@@ -720,7 +717,7 @@ static void spinbox_init(void)
static void list_init(void)
{
#if LV_USE_LIST != 0
style_init_reset(&styles->list_bg);
lv_style_reset(&styles->list_bg);
lv_style_set_clip_corner(&styles->list_bg, LV_STATE_DEFAULT, true);
lv_style_set_pad_left(&styles->list_bg, LV_STATE_DEFAULT, 0);
lv_style_set_pad_right(&styles->list_bg, LV_STATE_DEFAULT, 0);
@@ -728,7 +725,7 @@ static void list_init(void)
lv_style_set_pad_bottom(&styles->list_bg, LV_STATE_DEFAULT, 0);
lv_style_set_pad_inner(&styles->list_bg, LV_STATE_DEFAULT, 0);
style_init_reset(&styles->list_btn);
lv_style_reset(&styles->list_btn);
lv_style_set_bg_opa(&styles->list_btn, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->list_btn, LV_STATE_DEFAULT, COLOR_BG);
lv_style_set_bg_color(&styles->list_btn, LV_STATE_PRESSED, COLOR_BG_PR);
@@ -775,11 +772,11 @@ static void ddlist_init(void)
{
#if LV_USE_DROPDOWN != 0
style_init_reset(&styles->ddlist_page);
lv_style_reset(&styles->ddlist_page);
lv_style_set_text_line_space(&styles->ddlist_page, LV_STATE_DEFAULT, LV_DPX(20));
lv_style_set_clip_corner(&styles->ddlist_page, LV_STATE_DEFAULT, true);
style_init_reset(&styles->ddlist_sel);
lv_style_reset(&styles->ddlist_sel);
lv_style_set_bg_opa(&styles->ddlist_sel, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->ddlist_sel, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_text_color(&styles->ddlist_sel, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex3(0xfff) : lv_color_hex3(0xfff));
@@ -791,10 +788,10 @@ static void ddlist_init(void)
static void roller_init(void)
{
#if LV_USE_ROLLER != 0
style_init_reset(&styles->roller_bg);
lv_style_reset(&styles->roller_bg);
lv_style_set_text_line_space(&styles->roller_bg, LV_STATE_DEFAULT, LV_DPX(25));
style_init_reset(&styles->roller_sel);
lv_style_reset(&styles->roller_sel);
lv_style_set_bg_opa(&styles->roller_sel, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->roller_sel, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_text_color(&styles->roller_sel, LV_STATE_DEFAULT, LV_COLOR_WHITE);
@@ -816,7 +813,7 @@ static void tileview_init(void)
static void table_init(void)
{
#if LV_USE_TABLE != 0
style_init_reset(&styles->table_cell);
lv_style_reset(&styles->table_cell);
lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, COLOR_BG_BORDER);
lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1);
lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM);
@@ -837,7 +834,7 @@ static void win_init(void)
static void tabview_win_shared_init(void)
{
#if LV_USE_TABVIEW || LV_USE_WIN
style_init_reset(&styles->tabview_btns_bg);
lv_style_reset(&styles->tabview_btns_bg);
lv_style_set_bg_opa(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->tabview_btns_bg, LV_STATE_DEFAULT, COLOR_BG);
lv_style_set_text_color(&styles->tabview_btns_bg, LV_STATE_DEFAULT, COLOR_SCR_TEXT);
@@ -846,7 +843,7 @@ static void tabview_win_shared_init(void)
lv_style_set_pad_left(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_DPX(7));
lv_style_set_pad_right(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_DPX(7));
style_init_reset(&styles->tabview_btns);
lv_style_reset(&styles->tabview_btns);
lv_style_set_bg_opa(&styles->tabview_btns, LV_STATE_PRESSED, LV_OPA_50);
lv_style_set_bg_color(&styles->tabview_btns, LV_STATE_PRESSED, lv_color_hex3(0x888));
lv_style_set_text_color(&styles->tabview_btns, LV_STATE_CHECKED, COLOR_SCR_TEXT);
@@ -855,14 +852,14 @@ static void tabview_win_shared_init(void)
lv_style_set_text_color(&styles->tabview_btns, LV_STATE_FOCUSED, theme.color_primary);
lv_style_set_text_color(&styles->tabview_btns, LV_STATE_EDITED, theme.color_secondary);
style_init_reset(&styles->tabview_indic);
lv_style_reset(&styles->tabview_indic);
lv_style_set_bg_opa(&styles->tabview_indic, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->tabview_indic, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_bg_color(&styles->tabview_indic, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_size(&styles->tabview_indic, LV_STATE_DEFAULT, LV_DPX(5));
lv_style_set_radius(&styles->tabview_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
style_init_reset(&styles->tabview_page_scrl);
lv_style_reset(&styles->tabview_page_scrl);
lv_style_set_pad_top(&styles->tabview_page_scrl, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_bottom(&styles->tabview_page_scrl, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_left(&styles->tabview_page_scrl, LV_STATE_DEFAULT, PAD_DEF);
@@ -894,9 +891,11 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s
/* This trick is required only to avoid the garbage collection of
* styles' data if LVGL is used in a binding (e.g. Micropython)
* In a general case styles could be simple `static lv_style_t my style` variables*/
if(!inited) {
LV_GC_ROOT(_lv_theme_material_styles) = lv_mem_alloc(sizeof(theme_styles_t));
styles = (theme_styles_t *)LV_GC_ROOT(_lv_theme_material_styles);
if(styles == NULL) {
styles = lv_mem_alloc(sizeof(theme_styles_t));
if(styles == NULL) return NULL;
_lv_memset_00(styles, sizeof(theme_styles_t));
LV_GC_ROOT(_lv_theme_material_styles) = styles;
}
theme.color_primary = color_primary;
@@ -943,13 +942,15 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s
theme.apply_xcb = NULL;
theme.apply_cb = theme_apply;
inited = true;
lv_obj_report_style_mod(NULL);
return &theme;
}
/**********************
* STATIC FUNCTIONS
**********************/
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
{
LV_UNUSED(th);
@@ -1376,14 +1377,4 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
/**********************
* STATIC FUNCTIONS
**********************/
static void style_init_reset(lv_style_t * style)
{
if(inited) lv_style_reset(style);
else lv_style_init(style);
}
#endif

View File

@@ -81,17 +81,13 @@ typedef struct {
* STATIC PROTOTYPES
**********************/
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
static void style_init_reset(lv_style_t * style);
/**********************
* STATIC VARIABLES
**********************/
static lv_theme_t theme;
static theme_styles_t * styles;
static bool inited;
/**********************
* MACROS
**********************/
@@ -107,7 +103,7 @@ static bool inited;
static void basic_init(void)
{
style_init_reset(&styles->scr);
lv_style_reset(&styles->scr);
lv_style_set_bg_opa(&styles->scr, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->scr, LV_STATE_DEFAULT, BG_COLOR);
lv_style_set_text_color(&styles->scr, LV_STATE_DEFAULT, FG_COLOR);
@@ -115,7 +111,7 @@ static void basic_init(void)
lv_style_set_text_sel_bg_color(&styles->scr, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_value_color(&styles->scr, LV_STATE_DEFAULT, FG_COLOR);
style_init_reset(&styles->bg);
lv_style_reset(&styles->bg);
lv_style_set_border_post(&styles->bg, LV_STATE_DEFAULT, true);
lv_style_set_radius(&styles->bg, LV_STATE_DEFAULT, RADIUS);
lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER);
@@ -137,10 +133,10 @@ static void basic_init(void)
lv_style_set_pad_bottom(&styles->bg, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_set_pad_inner(&styles->bg, LV_STATE_DEFAULT, LV_DPI / 10);
style_init_reset(&styles->clip_corner);
lv_style_reset(&styles->clip_corner);
lv_style_set_clip_corner(&styles->clip_corner, LV_STATE_DEFAULT, true);
style_init_reset(&styles->btn);
lv_style_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);
@@ -163,60 +159,60 @@ static void basic_init(void)
lv_style_set_image_recolor(&styles->btn, LV_STATE_CHECKED, BG_COLOR);
lv_style_set_image_recolor(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, FG_COLOR);
style_init_reset(&styles->round);
lv_style_reset(&styles->round);
lv_style_set_radius(&styles->round, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
style_init_reset(&styles->no_radius);
lv_style_reset(&styles->no_radius);
lv_style_set_radius(&styles->no_radius, LV_STATE_DEFAULT, 0);
style_init_reset(&styles->border_none);
lv_style_reset(&styles->border_none);
lv_style_set_border_width(&styles->border_none, LV_STATE_DEFAULT, 0);
style_init_reset(&styles->fg_color);
lv_style_reset(&styles->fg_color);
lv_style_set_bg_color(&styles->fg_color, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_text_color(&styles->fg_color, LV_STATE_DEFAULT, BG_COLOR);
lv_style_set_image_recolor(&styles->fg_color, LV_STATE_DEFAULT, BG_COLOR);
lv_style_set_line_color(&styles->fg_color, LV_STATE_DEFAULT, FG_COLOR);
style_init_reset(&styles->big_line_space);
lv_style_reset(&styles->big_line_space);
lv_style_set_text_line_space(&styles->big_line_space, LV_STATE_DEFAULT, LV_DPI / 10);
style_init_reset(&styles->pad_none);
lv_style_reset(&styles->pad_none);
lv_style_set_pad_left(&styles->pad_none, LV_STATE_DEFAULT, 0);
lv_style_set_pad_right(&styles->pad_none, LV_STATE_DEFAULT, 0);
lv_style_set_pad_top(&styles->pad_none, LV_STATE_DEFAULT, 0);
lv_style_set_pad_bottom(&styles->pad_none, LV_STATE_DEFAULT, 0);
lv_style_set_pad_inner(&styles->pad_none, LV_STATE_DEFAULT, 0);
style_init_reset(&styles->pad_normal);
lv_style_reset(&styles->pad_normal);
lv_style_set_pad_left(&styles->pad_normal, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_set_pad_right(&styles->pad_normal, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_set_pad_top(&styles->pad_normal, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_set_pad_bottom(&styles->pad_normal, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_set_pad_inner(&styles->pad_normal, LV_STATE_DEFAULT, LV_DPI / 10);
style_init_reset(&styles->pad_small);
lv_style_reset(&styles->pad_small);
lv_style_set_pad_left(&styles->pad_small, LV_STATE_DEFAULT, LV_DPI / 20);
lv_style_set_pad_right(&styles->pad_small, LV_STATE_DEFAULT, LV_DPI / 20);
lv_style_set_pad_top(&styles->pad_small, LV_STATE_DEFAULT, LV_DPI / 20);
lv_style_set_pad_bottom(&styles->pad_small, LV_STATE_DEFAULT, LV_DPI / 20);
lv_style_set_pad_inner(&styles->pad_small, LV_STATE_DEFAULT, LV_DPI / 20);
style_init_reset(&styles->pad_inner);
lv_style_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_reset(&styles->txt_underline);
lv_style_set_text_decor(&styles->txt_underline, LV_STATE_FOCUSED, LV_TEXT_DECOR_UNDERLINE);
}
static void arc_init(void)
{
#if LV_USE_ARC != 0
style_init_reset(&styles->arc_bg);
lv_style_reset(&styles->arc_bg);
lv_style_set_line_width(&styles->arc_bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1));
lv_style_set_line_color(&styles->arc_bg, LV_STATE_DEFAULT, FG_COLOR);
style_init_reset(&styles->arc_indic);
lv_style_reset(&styles->arc_indic);
lv_style_set_line_width(&styles->arc_indic, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 10, 3));
lv_style_set_line_color(&styles->arc_indic, LV_STATE_DEFAULT, FG_COLOR);
#endif
@@ -246,7 +242,7 @@ static void btnmatrix_init(void)
static void calendar_init(void)
{
#if LV_USE_CALENDAR
style_init_reset(&styles->calendar_date);
lv_style_reset(&styles->calendar_date);
lv_style_set_value_str(&styles->calendar_date, LV_STATE_CHECKED, LV_SYMBOL_BULLET);
lv_style_set_value_font(&styles->calendar_date, LV_STATE_CHECKED, LV_THEME_DEFAULT_FONT_TITLE);
lv_style_set_value_align(&styles->calendar_date, LV_STATE_CHECKED, LV_ALIGN_IN_TOP_RIGHT);
@@ -267,7 +263,7 @@ static void calendar_init(void)
static void chart_init(void)
{
#if LV_USE_CHART
style_init_reset(&styles->chart_series);
lv_style_reset(&styles->chart_series);
lv_style_set_size(&styles->chart_series, LV_STATE_DEFAULT, 0);
lv_style_set_bg_opa(&styles->chart_series, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_line_width(&styles->chart_series, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 50, 1));
@@ -299,7 +295,7 @@ static void cont_init(void)
static void gauge_init(void)
{
#if LV_USE_GAUGE != 0
style_init_reset(&styles->gauge_needle);
lv_style_reset(&styles->gauge_needle);
lv_style_set_line_width(&styles->gauge_needle, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 30, 2));
lv_style_set_line_color(&styles->gauge_needle, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_size(&styles->gauge_needle, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 10, 4));
@@ -307,7 +303,7 @@ static void gauge_init(void)
lv_style_set_bg_color(&styles->gauge_needle, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_radius(&styles->gauge_needle, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
style_init_reset(&styles->gauge_major);
lv_style_reset(&styles->gauge_major);
lv_style_set_line_width(&styles->gauge_major, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 25, 2));
lv_style_set_line_color(&styles->gauge_major, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_scale_end_color(&styles->gauge_major, LV_STATE_DEFAULT, FG_COLOR);
@@ -334,7 +330,7 @@ static void label_init(void)
static void linemeter_init(void)
{
#if LV_USE_LINEMETER != 0
style_init_reset(&styles->linemeter);
lv_style_reset(&styles->linemeter);
lv_style_set_line_width(&styles->linemeter, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 25, 2));
lv_style_set_scale_end_line_width(&styles->linemeter, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 70, 1));
#endif
@@ -371,7 +367,7 @@ static void slider_init(void)
static void switch_init(void)
{
#if LV_USE_SWITCH != 0
style_init_reset(&styles->sb);
lv_style_reset(&styles->sb);
lv_style_set_bg_opa(&styles->sb, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->sb, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_radius(&styles->sb, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
@@ -412,7 +408,7 @@ static void msgbox_init(void)
static void textarea_init(void)
{
#if LV_USE_TEXTAREA
style_init_reset(&styles->ta_cursor);
lv_style_reset(&styles->ta_cursor);
lv_style_set_bg_opa(&styles->ta_cursor, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_border_width(&styles->ta_cursor, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1));
lv_style_set_border_side(&styles->ta_cursor, LV_STATE_DEFAULT, LV_BORDER_SIDE_LEFT);
@@ -424,7 +420,7 @@ static void textarea_init(void)
static void list_init(void)
{
#if LV_USE_LIST != 0
style_init_reset(&styles->list_btn);
lv_style_reset(&styles->list_btn);
lv_style_set_bg_opa(&styles->list_btn, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_bg_opa(&styles->list_btn, LV_STATE_PRESSED, LV_OPA_COVER);
lv_style_set_bg_opa(&styles->list_btn, LV_STATE_CHECKED, LV_OPA_COVER);
@@ -450,7 +446,7 @@ static void roller_init(void)
static void tabview_init(void)
{
#if LV_USE_TABVIEW != 0
style_init_reset(&styles->tab_bg);
lv_style_reset(&styles->tab_bg);
lv_style_set_border_width(&styles->tab_bg, LV_STATE_DEFAULT, BORDER_WIDTH);
lv_style_set_border_color(&styles->tab_bg, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_border_side(&styles->tab_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_BOTTOM);
@@ -501,9 +497,11 @@ lv_theme_t * lv_theme_mono_init(lv_color_t color_primary, lv_color_t color_secon
/* This trick is required only to avoid the garbage collection of
* styles' data if LVGL is used in a binding (e.g. Micropython)
* In a general case styles could be simple `static lv_style_t my style` variables*/
if(!inited) {
LV_GC_ROOT(_lv_theme_mono_styles) = lv_mem_alloc(sizeof(theme_styles_t));
styles = (theme_styles_t *)LV_GC_ROOT(_lv_theme_mono_styles);
if(styles == NULL) {
styles = lv_mem_alloc(sizeof(theme_styles_t));
if(styles == NULL) return NULL;
_lv_memset_00(styles, sizeof(theme_styles_t));
LV_GC_ROOT(_lv_theme_mono_styles) = styles;
}
theme.color_primary = color_primary;
@@ -552,6 +550,10 @@ lv_theme_t * lv_theme_mono_init(lv_color_t color_primary, lv_color_t color_secon
return &theme;
}
/**********************
* STATIC FUNCTIONS
**********************/
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
{
LV_UNUSED(th);
@@ -1004,14 +1006,4 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
}
/**********************
* STATIC FUNCTIONS
**********************/
static void style_init_reset(lv_style_t * style)
{
if(inited) lv_style_reset(style);
else lv_style_init(style);
}
#endif

View File

@@ -53,4 +53,4 @@ lv_theme_t * lv_theme_mono_init(lv_color_t color_primary, lv_color_t color_secon
} /* extern "C" */
#endif
#endif /*LV_THEME_TEMPLATE_H*/
#endif /*LV_THEME_MONO_H*/

View File

@@ -42,8 +42,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
static lv_theme_t theme;
static theme_styles_t * styles;
static bool inited;
/**********************
* MACROS
**********************/
@@ -51,11 +49,10 @@ static bool inited;
/**********************
* STATIC FUNCTIONS
**********************/
static void style_init_reset(lv_style_t * style);
static void basic_init(void)
{
style_init_reset(&styles->bg);
lv_style_reset(&styles->bg);
lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, 1);
lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED, 2);
@@ -71,7 +68,7 @@ static void basic_init(void)
lv_style_set_pad_bottom(&styles->bg, LV_STATE_DEFAULT, LV_DPI / 10);
lv_style_set_pad_inner(&styles->bg, LV_STATE_DEFAULT, LV_DPI / 10);
style_init_reset(&styles->btn);
lv_style_reset(&styles->btn);
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,
@@ -80,24 +77,24 @@ static void basic_init(void)
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);
style_init_reset(&styles->round);
lv_style_reset(&styles->round);
lv_style_set_radius(&styles->round, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
style_init_reset(&styles->color);
lv_style_reset(&styles->color);
lv_style_set_bg_color(&styles->color, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_line_color(&styles->color, LV_STATE_DEFAULT, theme.color_primary);
style_init_reset(&styles->gray);
lv_style_reset(&styles->gray);
lv_style_set_bg_color(&styles->gray, LV_STATE_DEFAULT, LV_COLOR_SILVER);
lv_style_set_line_color(&styles->gray, LV_STATE_DEFAULT, LV_COLOR_SILVER);
lv_style_set_text_color(&styles->gray, LV_STATE_DEFAULT, LV_COLOR_GRAY);
style_init_reset(&styles->tick_line);
lv_style_reset(&styles->tick_line);
lv_style_set_line_width(&styles->tick_line, LV_STATE_DEFAULT, 5);
lv_style_set_scale_end_line_width(&styles->tick_line, LV_STATE_DEFAULT, 5);
lv_style_set_scale_end_color(&styles->tick_line, LV_STATE_DEFAULT, theme.color_primary);
style_init_reset(&styles->tight);
lv_style_reset(&styles->tight);
lv_style_set_pad_left(&styles->tight, LV_STATE_DEFAULT, 0);
lv_style_set_pad_right(&styles->tight, LV_STATE_DEFAULT, 0);
lv_style_set_pad_top(&styles->tight, LV_STATE_DEFAULT, 0);
@@ -337,9 +334,11 @@ lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_s
/* This trick is required only to avoid the garbage collection of
* styles' data if LVGL is used in a binding (e.g. Micropython)
* In a general case styles could be simple `static lv_style_t my style` variables or allocated directly into `styles`*/
if(!inited) {
LV_GC_ROOT(_lv_theme_template_styles) = lv_mem_alloc(sizeof(theme_styles_t));
styles = (theme_styles_t *)LV_GC_ROOT(_lv_theme_template_styles);
if(styles == NULL) {
styles = lv_mem_alloc(sizeof(theme_styles_t));
if(styles == NULL) return NULL;
_lv_memset_00(styles, sizeof(theme_styles_t));
LV_GC_ROOT(_lv_theme_template_styles) = styles;
}
theme.color_primary = color_primary;
@@ -388,7 +387,11 @@ lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_s
return &theme;
}
void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
/**********************
* STATIC FUNCTIONS
**********************/
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
{
LV_UNUSED(th);
@@ -832,14 +835,4 @@ void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
/**********************
* STATIC FUNCTIONS
**********************/
static void style_init_reset(lv_style_t * style)
{
if(inited) lv_style_reset(style);
else lv_style_init(style);
}
#endif

View File

@@ -1,7 +1,8 @@
CSRCS += lv_theme.c
CSRCS += lv_theme_empty.c
CSRCS += lv_theme_material.c
CSRCS += lv_theme_mono.c
CSRCS += lv_theme_empty.c
CSRCS += lv_theme_template.c
DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_themes

View File

@@ -419,8 +419,8 @@ static void draw_bg(lv_obj_t * bar, const lv_area_t * clip_area)
/*value will be drawn later*/
draw_dsc.value_opa = LV_OPA_TRANSP;
lv_obj_init_draw_rect_dsc(bar, LV_BAR_PART_BG, &draw_dsc);
lv_draw_rect(&bar->coords, clip_area, &draw_dsc);
lv_draw_rect(&bar->coords, clip_area, &draw_dsc);
}
static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
@@ -531,17 +531,35 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
*axis1 += anim_start_value_x;
}
else {
*axis1 = *axis2 - anim_cur_value_x;
*axis1 = *axis2 - anim_cur_value_x + 1;
*axis2 -= anim_start_value_x;
}
if(sym) {
lv_coord_t zero;
zero = *axis1 + (-ext->min_value * anim_length) / range;
if(*axis2 > zero)
*axis1 = zero;
lv_coord_t zero, shift;
shift = (-ext->min_value * anim_length) / range;
if(hor) {
zero = *axis1 + shift;
if(*axis2 > zero)
*axis1 = zero;
else {
*axis1 = *axis2;
*axis2 = zero;
}
}
else {
*axis1 = *axis2;
*axis2 = zero;
zero = *axis2 - shift + 1;
if(*axis1 > zero)
*axis2 = zero;
else {
*axis2 = *axis1;
*axis1 = zero;
}
if(*axis2 < *axis1) {
/* swap */
zero = *axis1;
*axis1 = *axis2;
*axis2 = zero;
}
}
}
@@ -576,11 +594,16 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
draw_indic_dsc.border_opa = border_opa;
draw_indic_dsc.value_opa = value_opa;
draw_indic_dsc.pattern_image = pattern_src;
}
lv_draw_mask_radius_param_t mask_bg_param;
lv_draw_mask_radius_init(&mask_bg_param, &bar->coords, bg_radius, false);
lv_area_t bg_mask_area;
bg_mask_area.x1 = bar->coords.x1 + bg_left;
bg_mask_area.x2 = bar->coords.x2 - bg_right;
bg_mask_area.y1 = bar->coords.y1 + bg_top;
bg_mask_area.y2 = bar->coords.y2 - bg_bottom;
lv_draw_mask_radius_init(&mask_bg_param, &bg_mask_area, bg_radius, false);
int16_t mask_bg_id = lv_draw_mask_add(&mask_bg_param, NULL);
/*Draw_only the background and the pattern*/
@@ -665,6 +688,16 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
/*Bg size is handled by lv_obj*/
bar->ext_draw_pad = LV_MATH_MAX(bar->ext_draw_pad, indic_size);
/*Calculate the indicator area*/
lv_style_int_t bg_left = lv_obj_get_style_pad_left(bar, LV_BAR_PART_BG);
lv_style_int_t bg_right = lv_obj_get_style_pad_right(bar, LV_BAR_PART_BG);
lv_style_int_t bg_top = lv_obj_get_style_pad_top(bar, LV_BAR_PART_BG);
lv_style_int_t bg_bottom = lv_obj_get_style_pad_bottom(bar, LV_BAR_PART_BG);
lv_coord_t pad = LV_MATH_MIN4(bg_left, bg_right, bg_top, bg_bottom);
if(pad < 0) {
bar->ext_draw_pad = LV_MATH_MAX(bar->ext_draw_pad, -pad);
}
}
if(sign == LV_SIGNAL_CLEANUP) {
lv_obj_clean_style_list(bar, LV_BAR_PART_INDIC);

View File

@@ -800,7 +800,7 @@ static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask)
lv_draw_label_dsc_t label_dsc;
lv_draw_label_dsc_init(&label_dsc);
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_DAY_NAMES, &label_dsc);
label_dsc.flag = LV_TXT_FLAG_CENTER;
label_dsc.flag = LV_TXT_FLAG_CENTER | LV_TXT_FLAG_EXPAND;
uint32_t i;
for(i = 0; i < 7; i++) {
@@ -925,7 +925,7 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area)
if(prev_state != day_state) {
lv_draw_rect_dsc_init(&rect_dsc);
lv_draw_label_dsc_init(&label_dsc);
label_dsc.flag = LV_TXT_FLAG_CENTER;
label_dsc.flag = LV_TXT_FLAG_CENTER | LV_TXT_FLAG_EXPAND;
calendar->state = day_state;
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_DATE, &label_dsc);

View File

@@ -197,9 +197,13 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int32_t value)
int32_t old_value = ext->values[needle_id];
ext->values[needle_id] = value;
lv_coord_t r = lv_obj_get_width(gauge) / 2;
lv_coord_t x_ofs = gauge->coords.x1 + r;
lv_coord_t y_ofs = gauge->coords.y1 + r;
lv_style_int_t pad = lv_obj_get_style_pad_inner(gauge, LV_GAUGE_PART_NEEDLE);
lv_style_int_t left = lv_obj_get_style_pad_left(gauge, LV_GAUGE_PART_MAIN);
lv_style_int_t right = lv_obj_get_style_pad_right(gauge, LV_GAUGE_PART_MAIN);
lv_style_int_t top = lv_obj_get_style_pad_top(gauge, LV_GAUGE_PART_MAIN);
lv_coord_t r = (lv_obj_get_width(gauge) - left - right) / 2 - pad;
lv_coord_t x_ofs = gauge->coords.x1 + r + left + pad;
lv_coord_t y_ofs = gauge->coords.y1 + r + top + pad;
uint16_t angle = lv_linemeter_get_scale_angle(gauge);
int16_t angle_ofs = 90 + (360 - angle) / 2 + lv_gauge_get_angle_offset(gauge);
lv_point_t p_mid;
@@ -240,6 +244,33 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle_id, int32_t value)
a.y2 = LV_MATH_MAX(p_mid.y, p_end.y) + needle_w;
lv_obj_invalidate_area(gauge, &a);
/*The image might have long "end" on the opposite side ant it also needs to be invalidated*/
if(ext->needle_img) {
needle_angle = (old_value - min) * angle / (max - min) + angle_ofs;
needle_angle += 180;
r = LV_MATH_MAX(ext->needle_img_pivot.x, ext->needle_img_pivot.y);
p_end.y = (_lv_trigo_sin(needle_angle) * r) / LV_TRIGO_SIN_MAX + y_ofs;
p_end.x = (_lv_trigo_sin(needle_angle + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
a.x1 = LV_MATH_MIN(p_mid.x, p_end.x) - needle_w;
a.y1 = LV_MATH_MIN(p_mid.y, p_end.y) - needle_w;
a.x2 = LV_MATH_MAX(p_mid.x, p_end.x) + needle_w;
a.y2 = LV_MATH_MAX(p_mid.y, p_end.y) + needle_w;
lv_obj_invalidate_area(gauge, &a);
needle_angle = (value - min) * angle / (max - min) + angle_ofs;
needle_angle += 180;
p_end.y = (_lv_trigo_sin(needle_angle) * r) / LV_TRIGO_SIN_MAX + y_ofs;
p_end.x = (_lv_trigo_sin(needle_angle + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs;
a.x1 = LV_MATH_MIN(p_mid.x, p_end.x) - needle_w;
a.y1 = LV_MATH_MIN(p_mid.y, p_end.y) - needle_w;
a.x2 = LV_MATH_MAX(p_mid.x, p_end.x) + needle_w;
a.y2 = LV_MATH_MAX(p_mid.y, p_end.y) + needle_w;
lv_obj_invalidate_area(gauge, &a);
}
}
/**
@@ -611,8 +642,8 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area)
lv_img_decoder_get_info(ext->needle_img, &info);
lv_area_t a;
a.x1 = gauge->coords.x1 + lv_area_get_width(&gauge->coords) / 2 - ext->needle_img_pivot.x;
a.y1 = gauge->coords.y1 + lv_area_get_height(&gauge->coords) / 2 - ext->needle_img_pivot.y;
a.x1 = x_ofs - ext->needle_img_pivot.x;
a.y1 = y_ofs - ext->needle_img_pivot.y;
a.x2 = a.x1 + info.w - 1;
a.y2 = a.y1 + info.h - 1;
img_dsc.pivot.x = ext->needle_img_pivot.x;

View File

@@ -112,7 +112,7 @@ static inline void lv_gauge_set_range(lv_obj_t * gauge, int32_t min, int32_t max
*/
static inline void lv_gauge_set_critical_value(lv_obj_t * gauge, int32_t value)
{
lv_linemeter_set_value(gauge, value);
lv_linemeter_set_value(gauge, value - 1);
}
/**

View File

@@ -1,4 +1,4 @@
/**
/**
* @file lv_label.c
*
*/
@@ -1034,7 +1034,26 @@ void lv_label_refr_text(lv_obj_t * label)
bool hor_anim = false;
if(size.x > lv_area_get_width(&txt_coords)) {
#if LV_USE_BIDI
lv_anim_value_t start, end;
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(label);
if(base_dir == LV_BIDI_DIR_AUTO)
base_dir = _lv_bidi_detect_base_dir(ext->text);
if(base_dir == LV_BIDI_DIR_RTL) {
start = lv_area_get_width(&txt_coords) - size.x;
end = 0;
}
else {
start = 0;
end = lv_area_get_width(&txt_coords) - size.x;
}
lv_anim_set_values(&a, start, end);
#else
lv_anim_set_values(&a, 0, lv_area_get_width(&txt_coords) - size.x);
#endif
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_label_set_offset_x);
lv_anim_set_time(&a, lv_anim_speed_to_time(ext->anim_speed, a.start, a.end));
lv_anim_set_playback_time(&a, a.time);
@@ -1113,7 +1132,27 @@ void lv_label_refr_text(lv_obj_t * label)
bool hor_anim = false;
if(size.x > lv_area_get_width(&txt_coords)) {
#if LV_USE_BIDI
lv_anim_value_t start, end;
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(label);
if(base_dir == LV_BIDI_DIR_AUTO)
base_dir = _lv_bidi_detect_base_dir(ext->text);
if(base_dir == LV_BIDI_DIR_RTL) {
start = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
end = 0;
}
else {
start = 0;
end = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
}
lv_anim_set_values(&a, start, end);
#else
lv_anim_set_values(&a, 0, -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT);
#endif
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_label_set_offset_x);
lv_anim_set_time(&a, lv_anim_speed_to_time(ext->anim_speed, a.start, a.end));
@@ -1382,14 +1421,6 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
if(ext->static_txt == 0) lv_label_set_text(label, NULL);
#endif
}
else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_label";
}
return res;
}

View File

@@ -155,7 +155,7 @@ void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode);
/**
* Set the align of the label (left or center)
* @param label pointer to a label object
* @param align 'LV_LABEL_ALIGN_LEFT' or 'LV_LABEL_ALIGN_LEFT'
* @param align LV_LABEL_ALIGN_LEFT/RIGHT/CENTER
*/
void lv_label_set_align(lv_obj_t * label, lv_label_align_t align);
@@ -207,7 +207,7 @@ lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * label);
/**
* Get the align attribute
* @param label pointer to a label object
* @return LV_LABEL_ALIGN_LEFT or LV_LABEL_ALIGN_CENTER
* @return LV_LABEL_ALIGN_LEFT/RIGHT/CENTER
*/
lv_label_align_t lv_label_get_align(const lv_obj_t * label);

View File

@@ -237,14 +237,7 @@ static lv_res_t lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param)
res = ancestor_signal(led, sign, param);
if(res != LV_RES_OK) return res;
if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_led";
}
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
return res;
}

View File

@@ -446,7 +446,7 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
p1.y = y_out_extra;
/* Set the color of the lines */
if((!ext->mirrored && i >= level) || (ext->mirrored && i <= level)) {
if((!ext->mirrored && i > level) || (ext->mirrored && i < level)) {
line_dsc.color = end_color;
line_dsc.width = end_line_width;
}
@@ -465,12 +465,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 && level < ext->line_cnt - 1) {
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;
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);

View File

@@ -293,7 +293,6 @@ void lv_list_focus_btn(lv_obj_t * list, lv_obj_t * btn)
* It will be restored when the list is focused again.*/
if(btn) ext->last_sel_btn = btn;
#endif
/*Focus the new button*/
ext->act_sel_btn = btn;
@@ -741,7 +740,6 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
#endif
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
@@ -835,6 +833,12 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para
if(ext->last_sel_btn == btn) ext->last_sel_btn = NULL;
#endif
}
else if(sign == LV_SIGNAL_FOCUS) {
#if LV_USE_GROUP
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
lv_list_focus_btn(list, btn);
#endif
}
return res;
}

View File

@@ -399,14 +399,6 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
}
else if(sign == LV_SIGNAL_GET_TYPE) {
lv_obj_type_t * buf = param;
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
if(buf->type[i] == NULL) break;
}
buf->type[i] = "lv_spinbox";
}
else if(sign == LV_SIGNAL_RELEASED) {
/*If released with an ENCODER then move to the next digit*/
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);

View File

@@ -8,8 +8,8 @@ LVGL_DIR_NAME ?= lvgl
WARNINGS = -Werror -Wall -Wextra \
-Wshadow -Wundef -Wmaybe-uninitialized -Wmissing-prototypes -Wpointer-arith -Wuninitialized \
-Wunreachable-code -Wreturn-type -Wmultichar -Wformat-security -Wdouble-promotion -Wclobbered -Wdeprecated \
-Wempty-body -Wshift-negative-value -Wstack-usage=2048 \
-Wtype-limits -Wsizeof-pointer-memaccess
-Wempty-body -Wshift-negative-value -Wstack-usage=2048 -pedantic-errors \
-Wtype-limits -Wsizeof-pointer-memaccess -Wpedantic -Wmissing-prototypes -Wno-discarded-qualifiers
#-Wno-unused-value -Wno-unused-parameter
OPTIMIZATION ?= -O3 -g0

View File

@@ -16,6 +16,9 @@
#include "lv_test_font_loader.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
/*********************
* DEFINES
*********************/
@@ -212,6 +215,7 @@ static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
}
#endif
#pragma GCC diagnostic pop
/**********************
* STATIC FUNCTIONS
**********************/