Compare commits

..

678 Commits

Author SHA1 Message Date
Gabor Kiss-Vamosi
c5bacff2fa prepare to release v7.5.0 2020-09-15 11:14:32 +02:00
Gabor Kiss-Vamosi
5a6da9a2ef fix selectiion of options with non-ASCII letters in dropdown list 2020-09-14 21:48:57 +02:00
Gabor Kiss-Vamosi
d99ea10213 fix drawing images with 1 px height or width 2020-09-14 21:16:43 +02:00
Gabor Kiss-Vamosi
5566935a5d Update CHANGELOG.md 2020-09-14 20:27:35 +02:00
Gabor Kiss-Vamosi
b947465da1 fix divisioin by zero in draw_pattern (lv_draw_rect.c) if the image or letter is not found 2020-09-14 20:14:33 +02:00
Sergei Kolotovchenkov
d44b8d47d3 Improve compatibility with ARM Compiler V6 with C++98 mode (#1788)
* Fixed infinite loop during calculation size of lv_list

* Fixed msvc 2019 compiler error C4576 when using the LVGL inside C++ code

* Refactoring to make autocomplete less noisy

* Improve compatibility with ARM Compiler V6 with C++98 mode

* Replaced non-ascii symbol

* Fixed CI build error

* Refactoring, added ability to override _LV_COLOR_HAS_MODERN_CPP
2020-09-14 12:45:53 +02:00
liebman
96e0de063a fix lv_align_y/mid_y to align y and not x (#1792) 2020-09-14 12:44:28 +02:00
Gabor Kiss-Vamosi
81ec2d1b10 add LV_GC_ROOT prefix to _lv_font_decompr_buf 2020-09-14 10:46:20 +02:00
embeddedt
55d05c2eb3 Fix #1791: add NULL check for group->obj_focus 2020-09-12 19:15:21 -04:00
Michael Simon
e236cf7f73 Do not use an anim if pwd_show_time is 0 (#1786) 2020-09-11 14:25:33 +02:00
Gabor Kiss-Vamosi
38cf5c0b3e remove code accidentally merged from dev branch 2020-09-11 14:07:56 +02:00
Gabor Kiss-Vamosi
e2183750f2 fix warnings 2020-09-11 13:42:57 +02:00
Gabor Kiss-Vamosi
c55b165150 add font decompr_buf to GC roots 2020-09-11 13:39:05 +02:00
Gabor Kiss-Vamosi
50b5e3c477 add rounding to btnmatrix line height calculation
Fixes #1776
2020-09-11 13:28:34 +02:00
Amir Gonnen
1b3e1c4331 Fix submodule checkout in both push and PR (#1783) 2020-09-10 19:20:59 -04:00
Gabor Kiss-Vamosi
3f36139469 Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-09-10 16:08:03 +02:00
Gabor Kiss-Vamosi
125e6e95f6 fix color bleeding on corner clipping
Fixes #1777
2020-09-10 16:07:42 +02:00
梁永祥
c683a3612d group fix calling lv_obj_invalidate() when focuse is NULL (#1774) 2020-09-08 15:56:51 +02:00
Gabor Kiss-Vamosi
50594851f6 Update ROADMAP.md 2020-09-08 14:57:38 +02:00
Gabor Kiss-Vamosi
a2685363e8 Update ROADMAP.md 2020-09-08 14:47:56 +02:00
Gabor Kiss-Vamosi
8b7ffccd64 Update ROADMAP.md 2020-09-08 13:45:22 +02:00
Gabor Kiss-Vamosi
81884401d2 style change check 2020-09-08 13:20:29 +02:00
Gabor Kiss-Vamosi
b87d16fc6e fix textra focus event sending 2020-09-07 10:18:37 +02:00
Gabor Kiss-Vamosi
b1c43d329d update comments in lv_port_disp_template 2020-09-07 10:13:17 +02:00
Gabor Kiss-Vamosi
710ec7d417 Update ROADMAP.md 2020-09-07 09:20:41 +02:00
Gabor Kiss-Vamosi
176eb9fd46 Update ROADMAP.md 2020-09-06 12:50:08 +02:00
Amir Gonnen
a6150ea78f CI - Build Micropython with LVGL submodule (#1771) 2020-09-05 13:46:07 +02:00
tgillbe
35c7197d1c Fix button matrix button width (#1768) 2020-09-04 07:30:39 -04:00
Gabor Kiss-Vamosi
15e692d596 fix conflicts 2020-09-04 13:10:44 +02:00
Gabor Kiss-Vamosi
1ab87eda09 update CHANGELOG 2020-09-04 13:07:29 +02:00
Gabor Kiss-Vamosi
804c3c7994 fix unexpeted DEFOCUS on lv_page
Fixes #1762
2020-09-04 13:06:19 +02:00
Gabor Kiss-Vamosi
0596088544 remove unused variable 2020-09-01 19:19:25 +02:00
Gabor Kiss-Vamosi
85bd12a794 fix lv_obj_del and lv_obj_clean if the children list changed during deletion
https://forum.lvgl.io/t/lv-obj-del-and-kin-wrongly-assume-that-child-ll-wont-change-while-deleting/3091
2020-09-01 19:14:39 +02:00
Gabor Kiss-Vamosi
4613811c45 lmeter: fix uninitialized 'mirror' property 2020-09-01 19:14:34 +02:00
Gabor Kiss-Vamosi
03c3838605 arc: use value_update in lv_arc_set_value
it was overwritten on merge
2020-09-01 16:45:36 +02:00
Gabor Kiss-Vamosi
fb6e7deadf Update CHANGELOG.md 2020-09-01 12:24:18 +02:00
Gabor Kiss-Vamosi
d941461052 release script fixes 2020-09-01 12:20:28 +02:00
Gabor Kiss-Vamosi
3d32290ee4 fix version number 2020-09-01 11:59:50 +02:00
Gabor Kiss-Vamosi
6932b6c1da Merge branch 'master' into dev 2020-09-01 11:42:11 +02:00
Gabor Kiss-Vamosi
6d7bd355ed fix version lv_conf_template.h 2020-09-01 11:39:54 +02:00
Gabor Kiss-Vamosi
343605ebac prepare to release v7.4.0 2020-09-01 11:34:10 +02:00
Gabor Kiss-Vamosi
beec11565c update changelog 2020-09-01 11:29:08 +02:00
Gabor Kiss-Vamosi
26b36dfea1 release.py minor update to run in debugger 2020-09-01 10:45:27 +02:00
Gabor Kiss-Vamosi
289fd95c3d release.py: remove debug statements 2020-09-01 10:42:58 +02:00
Gabor Kiss-Vamosi
2f79133685 release.py: remove debug statements 2020-09-01 10:42:32 +02:00
Gabor Kiss-Vamosi
e42128e937 minor release related fixes 2020-09-01 10:18:35 +02:00
Gabor Kiss-Vamosi
de38ee4a21 fix typo 2020-09-01 09:40:16 +02:00
Gabor Kiss-Vamosi
612308f281 lv_img: check blend modes in cover check 2020-09-01 09:38:25 +02:00
Gabor Kiss-Vamosi
f545a24bbd gauge: allow not recoling the image needle 2020-09-01 09:38:25 +02:00
Gabor Kiss-Vamosi
1102cfdf82 lv_arc_set_value: be sure the 'fixed' angle is corerct 2020-09-01 09:38:25 +02:00
Gabor Kiss-Vamosi
775f1a59df lv_refr: take opa_scale into account in cover check 2020-09-01 09:38:25 +02:00
github-actions[bot]
1906a623fb Merge 35ae1a28d4 into dev 2020-09-01 07:27:19 +00:00
Gabor Kiss-Vamosi
35ae1a28d4 fixes in release.py 2020-09-01 09:26:41 +02:00
Gabor Kiss-Vamosi
842eb11448 release.py: add projec update 2020-08-31 19:48:59 +02:00
github-actions[bot]
ca9c36e081 Merge 5976973111 into dev 2020-08-31 12:18:35 +00:00
Alex-I-B
5976973111 Proposed fix for roller widget crash when LV_USE_GROUP=0 (#1761)
Removed LV_USE_GROUP guard macro for signals != LV_SIGNAL_CONTROL in signal functions of roller and spinbox to allow signal propagating to ancestors
2020-08-31 14:18:07 +02:00
github-actions[bot]
b7baa01bc1 Merge 91cfb70856 into dev 2020-08-31 12:10:04 +00:00
Gabor Kiss-Vamosi
91cfb70856 fix ci 2020-08-31 14:04:23 +02:00
github-actions[bot]
5ee4d14788 Merge 09ce595239 into dev 2020-08-31 12:03:15 +00:00
Gabor Kiss-Vamosi
09ce595239 fix ci 2020-08-31 14:02:43 +02:00
github-actions[bot]
5d02b27b1f Merge d4c3567f84 into dev 2020-08-31 12:01:26 +00:00
Gabor Kiss-Vamosi
d4c3567f84 install libpng for test 2020-08-31 14:00:49 +02:00
Gabor Kiss-Vamosi
39bf116e07 fix screenshot testing 2020-08-31 13:58:51 +02:00
Gabor Kiss-Vamosi
10eeeb2490 image cover check: minor reordering for better performance 2020-08-31 13:58:51 +02:00
github-actions[bot]
eb7f0d8eeb Merge 694d9eff19 into dev 2020-08-31 09:06:49 +00:00
Gabor Kiss-Vamosi
694d9eff19 Update ROADMAP.md 2020-08-31 11:06:04 +02:00
tgillbe
d4e40fce63 Fix position of 0 in special keyboard (#1758) 2020-08-31 10:15:16 +02:00
github-actions[bot]
6e000c97f8 Merge 9b9cd36dc9 into dev 2020-08-28 14:00:44 +00:00
Gabor Kiss-Vamosi
9b9cd36dc9 fix roller width if selected text is larger than the normal 2020-08-28 16:00:04 +02:00
rabbitsaviola
8df8700bed Add async gpu wait interface (#1736)
Add async gpu wait interface
Closes #1708
2020-08-28 15:31:30 +02:00
Gabor Kiss-Vamosi
c17f2f7e84 fix conflicts 2020-08-28 10:25:34 +02:00
Gabor Kiss-Vamosi
c3953f478f fix conflicts 2020-08-28 10:20:34 +02:00
Gabor Kiss-Vamosi
adf65b6761 Fix _lv_txt_ins with zero length insert text
Closes #1754
2020-08-28 09:53:56 +02:00
Adam Martini
cb5faa64ac Add update_value private function to lv_arc to prevent set_value return checks in the event of… (#1748)
Add update_value to lv_arc to update the value on range change.
2020-08-27 09:51:11 +02:00
Gabor Kiss-Vamosi
832000ad34 Merge pull request #1743 from lvgl/dcache_cb
lv_disp: add `clean_dcache_cb` callback
2020-08-27 09:48:56 +02:00
Gabor Kiss-Vamosi
037d3d9090 run code formatter 2020-08-26 15:21:24 +02:00
github-actions[bot]
6772ceb7e2 Merge e7364f321d into dev 2020-08-25 13:22:04 +00:00
Gabor Kiss-Vamosi
e7364f321d update CHANGELOG 2020-08-25 15:21:25 +02:00
github-actions[bot]
d9afdb5316 Merge 14a2a60bf9 into dev 2020-08-25 13:19:24 +00:00
Gabor Kiss-Vamosi
14a2a60bf9 Fix btnmatrix to not send event when CLICK_TRIG = true and the cursor slid from a pressed button
Fixes: https://forum.lvgl.io/t/v7-3-register-button-in-button-matrix-only-after-touch-release-not-button-release/3117
2020-08-25 15:18:45 +02:00
Themba Dube
350269c3d4 Update CHANGELOG.md 2020-08-25 07:38:08 -04:00
Gabor Kiss-Vamosi
52c61b115f minor image zoom fixes 2020-08-25 11:54:12 +02:00
Themba Dube
7ca806ddff Use CMSIS cache functions if custom callback is not registered 2020-08-24 10:51:09 -04:00
github-actions[bot]
c8be0df768 Merge 78f2451b2a into dev 2020-08-24 14:01:31 +00:00
Gabor Kiss-Vamosi
78f2451b2a imporve image zoom precision 2020-08-24 16:00:53 +02:00
Themba Dube
36433c2144 Rename function to lv_disp_clean_dcache and use currently refreshing display 2020-08-24 07:36:44 -04:00
github-actions[bot]
2224ce95cb Merge 54b3ba39fb into dev 2020-08-24 08:53:19 +00:00
Gabor Kiss-Vamosi
54b3ba39fb Fix deleting tabview with LEFT/RIGHT tab position 2020-08-24 10:52:48 +02:00
github-actions[bot]
9a2d2b5392 Merge ede6085429 into dev 2020-08-24 08:14:36 +00:00
Gabor Kiss-Vamosi
ede6085429 img: imporve zoom precision 2020-08-24 10:14:01 +02:00
github-actions[bot]
3ea4418727 Merge 961f295b94 into dev 2020-08-24 07:51:36 +00:00
Gabor Kiss-Vamosi
961f295b94 img: fix zooming and rotateing mosaic images 2020-08-24 09:50:52 +02:00
github-actions[bot]
12b1f1f590 Merge 848c468b06 into dev 2020-08-24 04:40:41 +00:00
Gabor Kiss-Vamosi
848c468b06 Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-08-24 06:40:08 +02:00
Gabor Kiss-Vamosi
ba94b9cc94 fix croping of last column/row if an image is zoomed
Fixes #1742
2020-08-24 06:39:57 +02:00
Themba Dube
a1f47e9051 Add lv_arc_set_adjustable and lv_arc_get_adjustable 2020-08-23 07:46:00 -04:00
Themba Dube
ff357db938 Merge branch 'dev' into dcache_cb 2020-08-23 07:43:49 -04:00
github-actions[bot]
2f26d0a511 Merge 851493a188 into dev 2020-08-23 11:20:37 +00:00
Ali Rostami
851493a188 Update lv_obj_refresh_style description (#1746) 2020-08-23 07:20:07 -04:00
github-actions[bot]
5f35e46be8 Merge 7e4769e319 into dev 2020-08-23 06:50:03 +00:00
Gabor Kiss-Vamosi
7e4769e319 fix using LV_SCROLLBAR_UNHIDE after LV_SCROLLBAR_ON
Fixes https://forum.lvgl.io/t/lv-sb-mode-unhide-has-an-unsuitable-value/3081
2020-08-23 08:49:27 +02:00
github-actions[bot]
75a0a5e6d6 Merge c0f6ff4d42 into dev 2020-08-23 05:45:08 +00:00
Gabor Kiss-Vamosi
c0f6ff4d42 fix color bleeding on border drawing
Fixes https://forum.lvgl.io/t/border-dont-cover-calendar/3029/4
2020-08-23 07:44:34 +02:00
github-actions[bot]
fef3a069d6 Merge 35e09885fb into dev 2020-08-22 21:38:06 +00:00
Themba Dube
35e09885fb lv_arc: use rotation when calculating drag angle
fixes #1745
2020-08-22 17:37:29 -04:00
Themba Dube
24c2921c21 lv_disp: add clean_dcache_cb callback 2020-08-21 09:53:13 -04:00
github-actions[bot]
001fabbb18 Merge f4b4df8a17 into dev 2020-08-20 21:53:52 +00:00
Amir Gonnen
f4b4df8a17 lv_arc_set_reverse: remove prototype with no implementation (#1741)
Required for Micropython
2020-08-20 17:53:23 -04:00
github-actions[bot]
41d093ea76 Merge 953753263c into dev 2020-08-20 05:07:01 +00:00
Gabor Kiss-Vamosi
953753263c fix warning 2020-08-20 07:06:23 +02:00
github-actions[bot]
8990544b42 Merge 809497f707 into dev 2020-08-19 21:31:30 +00:00
Gabor Kiss-Vamosi
809497f707 release.py: fix blog post name 2020-08-19 23:30:57 +02:00
github-actions[bot]
148e6d12fd Merge 45cc51d48c into dev 2020-08-19 21:29:09 +00:00
Gabor Kiss-Vamosi
45cc51d48c release.py: publish blog post 2020-08-19 23:28:34 +02:00
github-actions[bot]
187f4be2ee Merge 677ce48bea into dev 2020-08-18 15:03:21 +00:00
Gabor Kiss-Vamosi
677ce48bea tabview: fix press state style update
fixes: #1728
2020-08-18 17:02:42 +02:00
github-actions[bot]
6023bb4372 Merge d0cc9283e7 into dev 2020-08-18 09:58:04 +00:00
Gabor Kiss-Vamosi
d0cc9283e7 merge dev 2020-08-18 11:57:26 +02:00
Gabor Kiss-Vamosi
71e5618380 upadte release.py 2020-08-18 11:32:43 +02:00
Gabor Kiss-Vamosi
bcb6d02acf fix version 2020-08-18 10:54:43 +02:00
Gabor Kiss-Vamosi
f116073baf fix version 2020-08-18 10:54:10 +02:00
Gabor Kiss-Vamosi
6e884615d8 fix version 2020-08-18 10:53:37 +02:00
Gabor Kiss-Vamosi
d665294669 fix release script 2020-08-18 10:53:08 +02:00
Gabor Kiss-Vamosi
cc43762030 Update dev version 2020-08-18 10:45:41 +02:00
Gabor Kiss-Vamosi
9c7c395cc7 Merge branch 'dev' of https://github.com/lvgl/lvgl into dev 2020-08-18 10:45:36 +02:00
Gabor Kiss-Vamosi
9680d5bbb2 Update dev version 2020-08-18 10:43:47 +02:00
Gabor Kiss-Vamosi
96534d58e5 Merge branch 'master' into dev 2020-08-18 10:40:39 +02:00
Gabor Kiss-Vamosi
1088492449 prepare to release v7.3.1 2020-08-18 10:28:35 +02:00
github-actions[bot]
9b154d12c1 Merge e9ee46f302 into dev 2020-08-18 08:26:00 +00:00
Gabor Kiss-Vamosi
e9ee46f302 Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-08-18 10:25:28 +02:00
Gabor Kiss-Vamosi
c0714d9c6b fix release script 2020-08-18 10:25:19 +02:00
Gabor Kiss-Vamosi
e728ba1928 remove debug statements from release.py 2020-08-18 10:22:02 +02:00
github-actions[bot]
b94ca2bf80 Merge 74aae39e4e into dev 2020-08-18 08:13:00 +00:00
Gabor Kiss-Vamosi
74aae39e4e Update CHANGELOG.md 2020-08-18 10:12:32 +02:00
github-actions[bot]
b9bd436b89 Merge 6eab2adfc1 into dev 2020-08-18 08:12:25 +00:00
Gabor Kiss-Vamosi
6eab2adfc1 Merge pull request #1732 from ali-rostami/gray_day_calendar
init disabled days to gray color in calendar
2020-08-18 10:11:56 +02:00
Gabor Kiss-Vamosi
209e1c4d38 fix conflicts 2020-08-18 08:50:31 +02:00
Gabor Kiss-Vamosi
056da0f922 fix color picker invalidation in rectangle mode 2020-08-18 08:47:08 +02:00
Gabor Kiss-Vamosi
e1a84f2cfe Merge pull request #1734 from daiyinger/dev
Reduced animation callback interface calls
2020-08-18 06:41:24 +02:00
Gabor Kiss-Vamosi
b77bd763c0 merge master 2020-08-18 06:36:42 +02:00
xiaobo
437e6d35eb Reduced animation callback interface calls 2020-08-18 11:25:40 +08:00
Gabor Kiss-Vamosi
3b06d4ab84 rewrite the release script 2020-08-17 23:51:23 +02:00
Ali Rostami
3a5ad7712e init disabled days to gray color in calendar
In ver6 we saw that disabled days in `calendar` were gray, which was a good thing and seemed was missed in new versions.
2020-08-17 16:10:44 +04:30
Gabor Kiss-Vamosi
28eb766904 comment updates 2020-08-17 09:20:35 +02:00
Gabor Kiss-Vamosi
4af6c62146 Merge pull request #1726 from upbeat27/lv_btnmatrix_set_one_check_fix
Fix `lv_btnmatrix_set_one_check` not forcing one button to be checked
2020-08-17 09:11:12 +02:00
Josh McAtee
96eba8e0ff Fix lv_btnmatrix_set_one_check not forcing one button to be checked 2020-08-14 09:06:44 -07:00
github-actions[bot]
95ccd877a8 Merge 1815ff4b99 into dev 2020-08-14 04:58:44 +00:00
Gabor Kiss-Vamosi
1815ff4b99 Limit extra button click area of button matrix's buttons. Fixes #1712 2020-08-14 06:58:00 +02:00
Gabor Kiss-Vamosi
c8cc9db7f0 table: fix typo 2020-08-14 06:58:00 +02:00
Gabor Kiss-Vamosi
b8ebca8d6c update CHANGELOG 2020-08-14 00:03:14 +02:00
Gabor Kiss-Vamosi
245a47a848 Merge branch 'dev' of https://github.com/littlevgl/lvgl into dev 2020-08-13 23:56:40 +02:00
Gabor Kiss-Vamosi
c46f12b97a fix conflicts 2020-08-13 23:55:48 +02:00
github-actions[bot]
db2ddd6033 Merge de1ccc269c into dev 2020-08-13 21:28:29 +00:00
Gabor Kiss-Vamosi
de1ccc269c Update README.md 2020-08-13 23:28:03 +02:00
Gabor Kiss-Vamosi
cd9f53c4b4 Merge pull request #1717 from fabiowguerra/feat/dynamic-font-loading
Feat/dynamic font loading
2020-08-13 22:46:23 +02:00
github-actions[bot]
25afed1d58 Merge f3e91634f8 into dev 2020-08-13 19:09:24 +00:00
Gabor Kiss-Vamosi
f3e91634f8 fix crash if 'lv_table_set_col_cnt' is called before 'lv_table_set_row_cnt' for the first time
Fixes #1716
2020-08-13 21:08:50 +02:00
Gabor Kiss-Vamosi
6980277aca Update CHANGELOG 2020-08-13 20:09:43 +02:00
Gabor Kiss-Vamosi
f59a206ab0 send gesture with dragging too.
User can test dragging manually with  lv_indev_is_dragging
2020-08-13 20:07:18 +02:00
Gabor Kiss-Vamosi
4eb3283342 Merge pull request #1592 from acumartini/feature/1568_lv_rotary
Feature/1568 lv rotary
2020-08-13 20:05:13 +02:00
Gabor Kiss-Vamosi
c2b5979e91 arc: fix event sending 2020-08-13 12:00:57 +02:00
Gabor Kiss-Vamosi
cfee7e8b8a arc knob invalidation fix 2020-08-13 11:03:04 +02:00
Fabio Guerra
6fcca7dd44 Better comments, explaining memory allocation strategy when parsing fonts. 2020-08-12 11:02:43 -03:00
Fabio Guerra
f1edd3a1ea Removing #ifdef for LVGL version 6 on binary font parser. 2020-08-12 11:02:43 -03:00
Gabor Kiss-Vamosi
d321e0e4fc fix tests 2020-08-12 14:29:50 +02:00
Gabor Kiss-Vamosi
8d89bf9ed0 fix CHANGELOG 2020-08-12 14:23:53 +02:00
Gabor Kiss-Vamosi
f8b991731f Merge branch 'dev' into feat/dynamic-font-loading 2020-08-12 14:20:47 +02:00
github-actions[bot]
77b57ba035 Merge 08684b31ee into dev 2020-08-12 04:58:43 +00:00
Ali Rostami
08684b31ee Patch 1 (#1714)
update comments
2020-08-12 06:58:15 +02:00
Gabor Kiss-Vamosi
977f6d210d Merge pull request #1715 from lvgl/checkbox_anim
Fade in checkmark for material theme
2020-08-12 06:22:21 +02:00
Fabio Guerra
e399b7a085 Code format with astyle. 2020-08-12 00:45:06 -03:00
Fabio Guerra
b3634790cd Implementing missing formats for font loading. 2020-08-12 00:11:02 -03:00
Themba Dube
3dad4c724e Fade in checkmark for material theme 2020-08-11 10:49:57 -04:00
Gabor Kiss-Vamosi
d95cf0a3d6 arc: rework knob to indicate the current positoin 2020-08-11 15:03:57 +02:00
Gabor Kiss-Vamosi
14a4c190c9 merge rotary to arc 2020-08-11 14:17:05 +02:00
Gabor Kiss-Vamosi
461619411d Merge branch 'dev' into acumartini-feature/1568_lv_rotary 2020-08-11 12:31:32 +02:00
Gabor Kiss-Vamosi
c36c8e11f7 Merge branch 'master' into acumartini-feature/1568_lv_rotary 2020-08-11 12:31:24 +02:00
github-actions[bot]
11a9dedbaa Merge 2068ab3211 into dev 2020-08-11 08:38:47 +00:00
Gabor Kiss-Vamosi
2068ab3211 bar, switch, slider: fix drawing background's 'value_str' twice 2020-08-11 10:38:16 +02:00
github-actions[bot]
d94bbd4f91 Merge 28807b6a77 into dev 2020-08-11 08:34:41 +00:00
Gabor Kiss-Vamosi
28807b6a77 lv_img_design: fix cover check if angle != 0 2020-08-11 10:34:04 +02:00
github-actions[bot]
d71f664fbb Merge f066f0b8d8 into dev 2020-08-11 08:10:17 +00:00
Gabor Kiss-Vamosi
f066f0b8d8 fix overflow in large image transformations 2020-08-11 10:09:41 +02:00
github-actions[bot]
e30055674d Merge d2e1094159 into dev 2020-08-10 18:14:00 +00:00
Sergei Kolotovchenkov
d2e1094159 Fix Visual Studio 2019 compile errors (#1711)
Fixed msvc 2019 compiler error C4576 when using the LVGL inside C++ code
2020-08-10 14:13:26 -04:00
github-actions[bot]
73a918ce13 Merge 6fd7bcf172 into dev 2020-08-10 09:37:17 +00:00
Gabor Kiss-Vamosi
6fd7bcf172 allow adding extra label to list buttons 2020-08-10 11:36:43 +02:00
github-actions[bot]
b88ee8e430 Merge ebaeb1bf7c into dev 2020-08-10 04:18:01 +00:00
Gabor Kiss-Vamosi
ebaeb1bf7c Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-08-10 06:17:17 +02:00
Gabor Kiss-Vamosi
bd8ac58b6b add missing background drawing and radius handling to image button 2020-08-10 06:17:03 +02:00
github-actions[bot]
fcca7fff60 Merge b6c18ed171 into dev 2020-08-09 10:41:53 +00:00
Gabor Kiss-Vamosi
b6c18ed171 Update ROADMAP.md 2020-08-09 12:41:25 +02:00
github-actions[bot]
872030fb77 Merge 90be42c493 into dev 2020-08-08 14:22:34 +00:00
Gabor Kiss-Vamosi
90be42c493 Fix setting local style property multiple times
Realted to https://forum.lvgl.io/t/how-to-change-button-object-color-on-demand/2922/2
2020-08-08 16:22:00 +02:00
Fabio Guerra
c4e7254aed Some changes to support binary fonts without the kernel table. 2020-08-07 10:56:37 -03:00
github-actions[bot]
1b40c2a495 Merge 81caeaa725 into dev 2020-08-07 11:32:00 +00:00
embeddedt
81caeaa725 Fix lv_obj_set_height_fit 2020-08-07 07:31:31 -04:00
github-actions[bot]
1ca9dc6c4e Merge 8af9e96299 into dev 2020-08-06 12:57:04 +00:00
Gabor Kiss-Vamosi
8af9e96299 Merge pull request #1706 from satirebird/code-fixes
Make several descriptor parameters const
2020-08-06 14:56:36 +02:00
github-actions[bot]
70ac65793f Merge 5d981f56ad into dev 2020-08-06 12:55:23 +00:00
Gabor Kiss-Vamosi
5d981f56ad remove unused variable 2020-08-06 14:54:51 +02:00
github-actions[bot]
e16eb8e830 Merge cda21694c4 into dev 2020-08-06 12:51:07 +00:00
Gabor Kiss-Vamosi
58d86cff71 Merge branch 'master' into code-fixes 2020-08-06 14:51:05 +02:00
Gabor Kiss-Vamosi
cda21694c4 Fix text decor (udnerline strikethrough) with older versions of font converter 2020-08-06 14:50:30 +02:00
Gabor Kiss-Vamosi
7af20516a5 add linemeter's mirror feature again
the drawing part was somehow removed
2020-08-06 14:50:30 +02:00
github-actions[bot]
2cab9d12d6 Merge 21985e9a14 into dev 2020-08-06 09:40:58 +00:00
Gabor Kiss-Vamosi
21985e9a14 Update FUNDING.yml 2020-08-06 11:40:30 +02:00
Sven Krauß
7827d948d8 Fix evaluation of return value 2020-08-05 11:18:56 +02:00
Sven Krauß
3b7fa645fb Merge tag 'v7.3.0' into code-fixes
Conflicts:
	src/lv_draw/lv_draw_rect.c
2020-08-05 11:14:27 +02:00
Sven Krauß
28f74bd91d Make several descriptor parameters const, update parameter docs.
Making the descriptor const allows to use static initialized variables.
2020-08-05 10:53:03 +02:00
github-actions[bot]
0e1fda5c37 Merge 1f0a4918f2 into dev 2020-08-05 08:04:45 +00:00
Gabor Kiss-Vamosi
1f0a4918f2 Update ROADMAP.md 2020-08-05 10:04:16 +02:00
Fabio Guerra
004adac31d Adding changes to changelog and replacing line style comments with block comments. 2020-08-05 01:29:54 -03:00
Fabio Guerra
f58d97d990 Adding support to dynamic font loading. 2020-08-04 18:59:49 -03:00
github-actions[bot]
4b1a0d590f Merge bd4db19aee into dev 2020-08-04 16:53:12 +00:00
Gabor Kiss-Vamosi
bd4db19aee rename lv_chart_clear_serie to lv_chart_clear_series and lv_obj_align_origo to lv_obj_align_mid 2020-08-04 18:52:37 +02:00
github-actions[bot]
5c3640868c Merge b4955f0b6e into dev 2020-08-04 16:44:11 +00:00
Gabor Kiss-Vamosi
b4955f0b6e Fix drawing value string twice
Fixes #1704
2020-08-04 18:43:34 +02:00
github-actions[bot]
cdb99b3588 Merge acb46aaed1 into dev 2020-08-04 15:37:37 +00:00
Gabor Kiss-Vamosi
acb46aaed1 Update README.md 2020-08-04 17:37:07 +02:00
github-actions[bot]
525c3bd829 Merge 7caa2bf9ad into dev 2020-08-04 15:36:56 +00:00
Gabor Kiss-Vamosi
7caa2bf9ad Update README.md 2020-08-04 17:36:27 +02:00
Gabor Kiss-Vamosi
0a9cc2a3b5 update version number 2020-08-04 17:35:17 +02:00
Gabor Kiss-Vamosi
62f4ced294 update version number 2020-08-04 17:34:44 +02:00
github-actions[bot]
2a6815c451 Merge a0f338eb6f into dev 2020-08-04 15:34:16 +00:00
Gabor Kiss-Vamosi
a0f338eb6f update changlelog 2020-08-04 17:33:39 +02:00
Gabor Kiss-Vamosi
0f0d57d855 Merge branch 'dev' of https://github.com/littlevgl/lvgl into dev 2020-08-04 17:30:46 +02:00
github-actions[bot]
5d42f92c86 Merge 5810baa021 into dev 2020-08-04 15:12:23 +00:00
github-actions[bot]
42a7fda05d Merge f36f8fe253 into dev 2020-08-04 15:11:53 +00:00
Gabor Kiss-Vamosi
5810baa021 Update library.properties 2020-08-04 17:11:51 +02:00
Gabor Kiss-Vamosi
f36f8fe253 Update library.properties 2020-08-04 17:11:19 +02:00
github-actions[bot]
d56708b45e Merge d0b408d679 into dev 2020-08-04 15:09:01 +00:00
Gabor Kiss-Vamosi
d0b408d679 Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-08-04 17:08:21 +02:00
Gabor Kiss-Vamosi
7e3739576f add back library.proeprties 2020-08-04 17:07:54 +02:00
github-actions[bot]
565633828c Merge 061c6325b7 into dev 2020-08-04 12:59:36 +00:00
Gabor Kiss-Vamosi
061c6325b7 Merge pull request #1697 from Droup67/focus_padding
page: Use padding when focus an child item
2020-08-04 14:59:07 +02:00
github-actions[bot]
66c184a84d Merge e3a07ed58c into dev 2020-08-04 09:24:50 +00:00
Gabor Kiss-Vamosi
e3a07ed58c update release.py 2020-08-04 11:24:13 +02:00
github-actions[bot]
e1963a4a3d Merge eb76519d25 into dev 2020-08-04 08:08:03 +00:00
github-actions[bot]
05f6b67b5f Merge 48f8d83bdc into dev 2020-08-04 08:07:32 +00:00
Gabor Kiss-Vamosi
eb76519d25 Release v7.3.0 2020-08-04 10:07:30 +02:00
Gabor Kiss-Vamosi
7b0a0ef4a7 Run code formatter 2020-08-04 10:07:29 +02:00
Gabor Kiss-Vamosi
48f8d83bdc update release.py 2020-08-04 10:06:57 +02:00
github-actions[bot]
a728817fb5 Merge ad422250db into dev 2020-08-04 07:58:01 +00:00
Gabor Kiss-Vamosi
ad422250db update release.py 2020-08-04 09:57:29 +02:00
github-actions[bot]
243c448df9 Merge ec7397e4a0 into dev 2020-08-04 07:50:33 +00:00
Gabor Kiss-Vamosi
ec7397e4a0 update release.py 2020-08-04 09:49:57 +02:00
github-actions[bot]
245de140f4 Merge 0ec409f83e into dev 2020-08-04 07:28:49 +00:00
Gabor Kiss-Vamosi
0ec409f83e fix version nnumber 2020-08-04 09:28:16 +02:00
github-actions[bot]
cc505a3cb2 Merge b58f9c6021 into dev 2020-08-04 07:20:47 +00:00
Gabor Kiss-Vamosi
b58f9c6021 Add LV_USE_OUTLINE/PATTERN/VALUE_STR and LV_MEMCPY_MEMSET_STD 2020-08-04 09:19:59 +02:00
github-actions[bot]
4560a72c32 Merge 85d375b128 into dev 2020-08-03 11:40:16 +00:00
Gabor Kiss-Vamosi
85d375b128 Update ROADMAP.md 2020-08-03 13:39:51 +02:00
github-actions[bot]
99f49f9097 Merge a0e6f7f022 into dev 2020-08-03 11:37:40 +00:00
Gabor Kiss-Vamosi
a0e6f7f022 Update ROADMAP.md 2020-08-03 13:37:11 +02:00
Droup
1c3bbc9f6c Fix focus move
Signed-off-by: Droup <droup@pm.me>
2020-08-03 10:38:18 +02:00
Gabor Kiss-Vamosi
07cb113c0a add radius, border_side and boder_post to style cache 2020-08-03 09:37:01 +02:00
Gabor Kiss-Vamosi
61a5cb44b8 optimze style asking order in lv_obj_init_draw_xxx_dsc function 2020-08-03 07:17:21 +02:00
Gabor Kiss-Vamosi
6ccfd0101a style cache: add missing LV_STYLE_FONT_TEXT to cachable proeprties 2020-08-03 07:03:54 +02:00
Gabor Kiss-Vamosi
1b29814e1e improve style caching 2020-08-03 06:43:25 +02:00
Gabor Kiss-Vamosi
ae0e855d91 style cache fixes 2020-08-02 20:49:21 +02:00
github-actions[bot]
0aa4591021 Merge c85295b5ea into dev 2020-08-02 10:05:44 +00:00
Gabor Kiss-Vamosi
c85295b5ea update CHANGELOG 2020-08-02 12:05:00 +02:00
Gabor Kiss-Vamosi
28213adfa6 -fix using freed memory in _lv_style_list_remove_style
Fixes: #1694
2020-08-02 12:05:00 +02:00
Gabor Kiss-Vamosi
11cab40103 import style caching 2020-08-02 11:36:27 +02:00
Gabor Kiss-Vamosi
41fd83e1d3 implement caching on style lists 2020-08-02 10:14:29 +02:00
github-actions[bot]
25b0b994a0 Merge 2b60f4496f into dev 2020-08-01 17:36:31 +00:00
DefinPlusPlus
2b60f4496f Fixed infinite loop during calculation size of lv_list (#1700) 2020-08-01 13:36:07 -04:00
github-actions[bot]
1d714bfed7 Merge b7d7bf7dd5 into dev 2020-07-31 20:14:15 +00:00
Gabor Kiss-Vamosi
b7d7bf7dd5 Update README.md 2020-07-31 22:13:46 +02:00
Droup
373af97472 page: Use padding when focus an child item
Signed-off-by: Droup <droup@pm.me>
2020-07-31 14:32:17 +02:00
github-actions[bot]
3e9495a074 Merge 1072b71ea0 into dev 2020-07-30 09:12:45 +00:00
Gabor Kiss-Vamosi
1072b71ea0 gauge: fix image needle drawing 2020-07-30 11:11:54 +02:00
Sven Krauß
b0e3f11da1 Make lv_draw_line_dsc_t parameters constant 2020-07-28 17:08:21 +02:00
github-actions[bot]
cb0d6f40c9 Merge 0f69469eee into dev 2020-07-28 10:19:14 +00:00
Seth Itow
0f69469eee README.md: Update link to Micropython documentation (#1693) 2020-07-28 06:18:42 -04:00
github-actions[bot]
f2a59c23f1 Merge cac6f92964 into dev 2020-07-27 18:19:43 +00:00
Gabor Kiss-Vamosi
cac6f92964 fix warning 2020-07-27 20:19:02 +02:00
github-actions[bot]
0d2784a13e Merge 80a4c6ff14 into dev 2020-07-27 15:58:55 +00:00
Gabor Kiss-Vamosi
80a4c6ff14 update CHANGELOG 2020-07-27 17:58:10 +02:00
Gabor Kiss-Vamosi
013ae48221 Merge branch 'size_reduction' 2020-07-27 17:47:25 +02:00
github-actions[bot]
daec3626bc Merge fd695c9ad3 into dev 2020-07-27 15:47:05 +00:00
Gabor Kiss-Vamosi
fd695c9ad3 textarea: fix typo in lv_textarea_set_sscrollbar_mode
Fixes #1691
2020-07-27 17:46:10 +02:00
github-actions[bot]
88ce04cea3 Merge 06d7a6d006 into dev 2020-07-27 14:01:19 +00:00
Gabor Kiss-Vamosi
06d7a6d006 btnmatrix: hadle combined states of buttons (e.g. chacked + disabled) 2020-07-27 15:57:28 +02:00
github-actions[bot]
529fee1e20 Merge ca9dfb7063 into dev 2020-07-27 12:30:52 +00:00
Gabor Kiss-Vamosi
ca9dfb7063 Update FUNDING.yml 2020-07-27 14:30:22 +02:00
github-actions[bot]
83ca45e0c8 Merge fd411e200f into dev 2020-07-27 12:30:13 +00:00
Gabor Kiss-Vamosi
fd411e200f Update and rename _FUNDING.yml to FUNDING.yml 2020-07-27 14:29:41 +02:00
github-actions[bot]
3592a2ac17 Merge 8cc951202c into dev 2020-07-27 12:18:37 +00:00
Gabor Kiss-Vamosi
8cc951202c Rename FUNDING.yml to _FUNDING.yml 2020-07-27 14:17:58 +02:00
github-actions[bot]
ac89d1245b Merge 2172ec93a2 into dev 2020-07-27 12:16:37 +00:00
Gabor Kiss-Vamosi
2172ec93a2 material theme minor fix
Fixes #1689
2020-07-27 14:16:06 +02:00
Gabor Kiss-Vamosi
c173f28a3f add underline properties to the fonts 2020-07-27 12:47:07 +02:00
github-actions[bot]
a5a7329d41 Merge ed10c1da67 into dev 2020-07-26 19:15:06 +00:00
Gabor Kiss-Vamosi
ed10c1da67 Add LV_THEME_MATERIAL_FLAG_NO_TRANSITION and LV_THEME_MATERIAL_FLAG_NO_FOCUS flags 2020-07-26 21:14:10 +02:00
github-actions[bot]
bb730735f2 Merge 834b498aec into dev 2020-07-24 19:51:40 +00:00
Gabor Kiss-Vamosi
834b498aec Update ROADMAP.md 2020-07-24 21:51:08 +02:00
github-actions[bot]
2fb690b3b9 Merge 28a668ce09 into dev 2020-07-24 19:50:15 +00:00
Gabor Kiss-Vamosi
28a668ce09 Create ROADMAP.md 2020-07-24 21:49:44 +02:00
github-actions[bot]
5a2cf28c54 Merge ed480e821c into dev 2020-07-24 14:32:06 +00:00
Gabor Kiss-Vamosi
ed480e821c Merge pull request #1684 from lvgl/pete-pjb-cpicker
Tidy up the edges of the colour picker widget.
2020-07-24 16:31:35 +02:00
Gabor Kiss-Vamosi
f11f7c5223 Merge branch 'master' into pete-pjb-cpicker 2020-07-24 16:30:39 +02:00
github-actions[bot]
3b4bff79c2 Merge f30dc5d186 into dev 2020-07-24 14:16:54 +00:00
Gabor Kiss-Vamosi
f30dc5d186 remove duplicated lines from lv_tabview_add_tab 2020-07-24 16:16:18 +02:00
pete-pjb
da5c9dd424 Add define and comment to explain magic number used in previous fix. 2020-07-24 13:50:35 +01:00
pete-pjb
89adfbc816 Fix ragged edge of Colour Picker. 2020-07-24 10:15:29 +01:00
pete-pjb
d125472e81 Update change log. 2020-07-23 14:24:28 +01:00
pete-pjb
28495b9eb9 Tidy up the edges of the colour picker widget. 2020-07-23 14:15:34 +01:00
github-actions[bot]
4fefa2ee28 Merge 00e93a5d30 into dev 2020-07-22 16:24:25 +00:00
Gabor Kiss-Vamosi
00e93a5d30 Update CHANGELOG.md 2020-07-22 18:23:56 +02:00
github-actions[bot]
95ef03baa8 Merge dae3ebdb66 into dev 2020-07-22 16:23:36 +00:00
Gabor Kiss-Vamosi
dae3ebdb66 Merge pull request #1679 from lvgl/embeddedt-patch-1
textarea: don't call LV_EVENT_INSERT too far before insertion
2020-07-22 18:22:57 +02:00
Gabor Kiss-Vamosi
fb3e6ec1f4 textarea: add insert handler functions 2020-07-22 16:28:03 +02:00
github-actions[bot]
bb4e4a9e53 Merge 4df27fc5b2 into dev 2020-07-22 14:26:22 +00:00
Gabor Kiss-Vamosi
4df27fc5b2 Update CHANGELOG.md 2020-07-22 16:25:42 +02:00
github-actions[bot]
f7870310dc Merge 3c3fe46447 into dev 2020-07-22 14:19:34 +00:00
Gabor Kiss-Vamosi
3c3fe46447 Update CHANGELOG.md 2020-07-22 16:18:49 +02:00
embeddedt
806f3a9bbf textarea: don't call LV_EVENT_INSERT too far before insertion 2020-07-21 11:16:26 -04:00
github-actions[bot]
dca7cedb28 Merge 557342cc08 into dev 2020-07-21 14:39:50 +00:00
Gabor Kiss-Vamosi
557342cc08 Do not print for missing glyph if its height OR width is zero
Fixes: #1674
2020-07-21 16:39:04 +02:00
Gabor Kiss-Vamosi
eb725a3a68 add LV_USE_FONT_SUBPX option and draw_full_border() to avoid duplication in outline and border drawing 2020-07-21 16:06:14 +02:00
Gabor Kiss-Vamosi
53f002c3f8 Merge branch 'dev' into size_reduction 2020-07-21 16:03:54 +02:00
Gabor Kiss-Vamosi
b48120947f Merge branch 'master' into size_reduction 2020-07-21 14:44:11 +02:00
Gabor Kiss-Vamosi
4659289924 Merge branch 'dev' of https://github.com/littlevgl/lvgl into dev 2020-07-21 13:43:16 +02:00
Gabor Kiss-Vamosi
cc0ea22903 increment version number to v7.4-dev 2020-07-21 13:43:05 +02:00
github-actions[bot]
c0ca1a025b Merge 35b3a1f2a4 into dev 2020-07-21 11:42:42 +00:00
Gabor Kiss-Vamosi
35b3a1f2a4 merge dev 2020-07-21 13:42:02 +02:00
Gabor Kiss-Vamosi
6731e44503 Merge branch 'dev' 2020-07-21 13:40:36 +02:00
Gabor Kiss-Vamosi
7b68e6e426 Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-07-21 13:38:24 +02:00
Gabor Kiss-Vamosi
c36a96914b fix release script 2020-07-21 13:38:04 +02:00
github-actions[bot]
ab6f93db24 Merge 57079452b0 into dev 2020-07-21 11:30:20 +00:00
Gabor Kiss-Vamosi
57079452b0 Release v7.2.0 2020-07-21 13:29:37 +02:00
Gabor Kiss-Vamosi
960bca7807 Run code formatter 2020-07-21 13:29:36 +02:00
github-actions[bot]
67400d1d72 Merge ecfef570ea into dev 2020-07-17 15:35:14 +00:00
Gabor Kiss-Vamosi
ecfef570ea Merge pull request #1672 from adamhan2/fix_issue_1671
fixes #1671 lv_cont_layout_grid() fails to calculate available space in a row
2020-07-17 17:34:43 +02:00
Adam Han
75875e244d fixes #1671 lv_cont_layout_grid() fails to calculate available space in a row
this issue results in space waste in right side of container
  the size of wasted space in each row is pad_left plus pad_inner
2020-07-17 15:51:09 +01:00
github-actions[bot]
1db33435c1 Merge 2d984da893 into dev 2020-07-17 12:09:30 +00:00
Gabor Kiss-Vamosi
2d984da893 improve mono theme when used with keyboard or encoder 2020-07-17 14:08:42 +02:00
github-actions[bot]
5b062a0d8d Merge c0a7cf76b9 into dev 2020-07-17 09:42:43 +00:00
Gabor Kiss-Vamosi
c0a7cf76b9 minor fixes with LV_COLOR_DEPTH == 1 2020-07-17 11:42:08 +02:00
github-actions[bot]
44e57aaaf5 Merge d06fe5100e into dev 2020-07-17 08:26:44 +00:00
Gabor Kiss-Vamosi
d06fe5100e Merge pull request #1670 from mentha/patch-1
Fix lv_canvas_set_buffer document
2020-07-17 10:26:00 +02:00
mentha
ae94302f4d Fix lv_canvas_set_buffer doc
Lines in canvas buffers are byte aligned so buffers might request larger size and contain unused bits.
The previous documented calc method would often result in a buffer size smaller than what was expected by LVGL, leading to memory corruption and program crash.
2020-07-17 16:09:24 +08:00
Themba Dube
b26b4435a5 Add LV_USE_FONT_COMPRESSED to lv_conf_template.h 2020-07-16 18:58:28 -04:00
Themba Dube
da9a5f58d0 Don't include blending code if LV_USE_BLEND_MODES is disabled 2020-07-16 18:55:35 -04:00
Themba Dube
a4774ccc72 Add LV_USE_FONT_COMPRESSED to control support for compressed fonts 2020-07-16 18:55:25 -04:00
github-actions[bot]
a6289f5e85 Merge dd56e9a013 into dev 2020-07-16 11:09:48 +00:00
Gabor Kiss-Vamosi
dd56e9a013 set the cursor object non clickable by default
Fixes: #1664
2020-07-16 13:09:09 +02:00
github-actions[bot]
e31993bdf2 Merge 6dac633235 into dev 2020-07-15 06:58:39 +00:00
Gabor Kiss-Vamosi
6dac633235 Merge pull request #1663 from diegoherranz/readme_typos
Fix README typos
2020-07-15 08:58:10 +02:00
Diego Herranz
1d5300e02f Fix README typos 2020-07-15 07:55:27 +01:00
github-actions[bot]
b646365e2c Merge 798f3177f2 into dev 2020-07-14 15:37:09 +00:00
Gabor Kiss-Vamosi
798f3177f2 Update README.md 2020-07-14 17:36:41 +02:00
github-actions[bot]
0921cf6e3b Merge ac5f1998e4 into dev 2020-07-14 15:16:11 +00:00
Gabor Kiss-Vamosi
ac5f1998e4 Update README.md 2020-07-14 17:15:30 +02:00
github-actions[bot]
433435889a Merge a66afca68e into dev 2020-07-14 15:07:16 +00:00
Gabor Kiss-Vamosi
a66afca68e Update README.md 2020-07-14 17:06:33 +02:00
Gabor Kiss-Vamosi
b1213dcc59 remove lv_event_queue_refresh_recursive
keep only the synchronous functions for refresh for easier maintanance
2020-07-14 15:25:56 +02:00
github-actions[bot]
f8c8c4040a Merge 2f33670b4f into dev 2020-07-14 11:37:37 +00:00
Gabor Kiss-Vamosi
2f33670b4f Merge pull request #1661 from tehkillerbee/master
Handle LV_EVENT_CANCEL in list/group
2020-07-14 13:37:10 +02:00
Johannes Linde
d8e10c41cf Handle ESC/Cancel event in list 2020-07-14 12:04:53 +02:00
Gabor Kiss-Vamosi
7e38ac68e3 Update CHANGELOG.md 2020-07-13 19:59:53 +02:00
Gabor Kiss-Vamosi
abff805509 Merge pull request #1653 from mibcat/tabview-set-tab-name
widget tableview: add new function lv_tabview_set_tab_name() to change a tab name during runtime
2020-07-13 19:57:25 +02:00
Michael Katzenberger
18072b3dd4 update CHANGELOG.md 2020-07-13 19:56:06 +02:00
github-actions[bot]
4640611758 Merge baeda1998f into dev 2020-07-13 13:31:40 +00:00
pete-pjb
baeda1998f Fix chart linked list free before use bug. 2020-07-13 14:26:04 +01:00
Gabor Kiss-Vamosi
e1a09551ce fix drawing on right border 2020-07-13 09:43:18 +02:00
Michael Katzenberger
ba7a86de74 implement review findings: use C-style comments 2020-07-12 14:22:09 +02:00
Michael Katzenberger
6cb79914a8 widget tableview: add function lv_tabview_set_tab_name() to change a tab name 2020-07-12 11:46:12 +02:00
github-actions[bot]
f1f0aa621a Merge 43a77d8699 into dev 2020-07-10 13:04:49 +00:00
Gabor Kiss-Vamosi
43a77d8699 linemeter: fix arc drawing if the value is close to max value 2020-07-10 15:04:02 +02:00
github-actions[bot]
58b88bf1fb Merge 96bc397821 into dev 2020-07-10 12:57:43 +00:00
Gabor Kiss-Vamosi
96bc397821 linemeter: fix conversation of current value to "level"
Related to #1648
2020-07-10 14:57:03 +02:00
github-actions[bot]
fd508065dd Merge 416ef9e251 into dev 2020-07-09 12:42:08 +00:00
Gabor Kiss-Vamosi
416ef9e251 fix chart series area invalidation 2020-07-09 14:41:24 +02:00
Gabor Kiss-Vamosi
09250d0a92 Delete queued refresh queries 2020-07-09 14:13:21 +02:00
github-actions[bot]
822e06be39 Merge c07ef75ac5 into dev 2020-07-08 13:03:31 +00:00
Gabor Kiss-Vamosi
c07ef75ac5 update release script 2020-07-08 15:02:53 +02:00
github-actions[bot]
2a6f5d46ab Merge e3f6a3327d into dev 2020-07-08 12:59:42 +00:00
Gabor Kiss-Vamosi
e3f6a3327d Update library.json 2020-07-08 14:59:02 +02:00
github-actions[bot]
6227aaee96 Merge 08591a8e8c into dev 2020-07-08 11:43:18 +00:00
Pete Bone
08591a8e8c Merge pull request #1646 from DaPa/master
Fix lv_page_get_height_grid comment
2020-07-08 12:42:51 +01:00
DaPa
106e023c80 Fix lv_page_get_height_grid comment 2020-07-08 14:36:13 +03:00
Gabor Kiss-Vamosi
a5de71933b fix typoe in comments 2020-07-08 10:31:52 +02:00
github-actions[bot]
e85888908a Merge 1a3b6d4cb3 into dev 2020-07-08 07:36:08 +00:00
Gabor Kiss-Vamosi
1a3b6d4cb3 update lv_conf_internal.h 2020-07-08 09:35:25 +02:00
github-actions[bot]
e587ceb22e Merge b769463d39 into dev 2020-07-08 07:32:39 +00:00
Gabor Kiss-Vamosi
b769463d39 update CHANGELONG and lv_conf_internal.h 2020-07-08 09:31:52 +02:00
Gabor Kiss-Vamosi
cbc88285d3 change default fot to 14 px for better compatibility with small displays
Related to #1602
2020-07-08 09:31:52 +02:00
Gabor Kiss-Vamosi
ec64820272 tileview: fix navigation when not screen sized 2020-07-08 09:31:52 +02:00
Gabor Kiss-Vamosi
15b7ea6614 Add lv_event_send_refresh, lv_event_send_refresh_recursive, lv_event_queue_refresh_recursive
Used to easily send LV_EVENT_REFRESH to objects
2020-07-08 09:29:48 +02:00
Gabor Kiss-Vamosi
843555a4b1 Add lv_task_get_next 2020-07-08 09:29:48 +02:00
github-actions[bot]
5f4c26cb79 Merge 019042297d into dev 2020-07-08 04:27:23 +00:00
Gabor Kiss-Vamosi
019042297d Update library.json 2020-07-08 06:26:56 +02:00
github-actions[bot]
46a4469a9c Merge 646cb71a9d into dev 2020-07-07 18:41:18 +00:00
Gabor Kiss-Vamosi
646cb71a9d Update library.json 2020-07-07 20:40:33 +02:00
github-actions[bot]
ad262172de Merge 343b70b19c into dev 2020-07-07 11:09:52 +00:00
Gabor Kiss-Vamosi
343b70b19c Update auto-comment.yml 2020-07-07 13:09:26 +02:00
github-actions[bot]
b802e7e775 Merge 2cecd01b30 into dev 2020-07-07 11:07:33 +00:00
Gabor Kiss-Vamosi
2cecd01b30 Update auto-comment.yml 2020-07-07 13:07:02 +02:00
github-actions[bot]
2ba1fc625f Merge aff7a22ac5 into dev 2020-07-07 11:04:10 +00:00
Gabor Kiss-Vamosi
aff7a22ac5 Update auto-comment.yml 2020-07-07 13:03:30 +02:00
github-actions[bot]
5a23fd569b Merge 234e74202c into dev 2020-07-07 10:58:47 +00:00
Gabor Kiss-Vamosi
234e74202c image decoder open bug described in #1638 2020-07-07 12:58:13 +02:00
github-actions[bot]
914c874ada Merge a6793b2695 into dev 2020-07-07 10:45:11 +00:00
Gabor Kiss-Vamosi
a6793b2695 Update auto-comment.yml 2020-07-07 12:44:42 +02:00
Gabor Kiss-Vamosi
cae5132038 rotary: fix with low chg_rate 2020-07-07 12:35:23 +02:00
github-actions[bot]
45bf6a3862 Merge c599a59f05 into dev 2020-07-07 09:31:48 +00:00
github-actions[bot]
f00a6a118d Merge c97a0684cf into dev 2020-07-07 09:31:03 +00:00
Gabor Kiss-Vamosi
c599a59f05 Update README.md 2020-07-07 11:31:00 +02:00
Gabor Kiss-Vamosi
c97a0684cf Create auto-comment.yml 2020-07-07 11:30:35 +02:00
github-actions[bot]
418413e334 Merge faf56680f8 into dev 2020-07-07 09:30:07 +00:00
github-actions[bot]
815e0afdaf Merge b2d78dcca7 into dev 2020-07-07 09:29:50 +00:00
Gabor Kiss-Vamosi
faf56680f8 Delete auto-comment.yml 2020-07-07 11:29:41 +02:00
Gabor Kiss-Vamosi
b2d78dcca7 Create auto-comment.yml 2020-07-07 11:29:20 +02:00
Gabor Kiss-Vamosi
38e68eeb7a update version number 2020-07-07 10:06:49 +02:00
github-actions[bot]
0f69cbf087 Merge 039080fc26 into dev 2020-07-07 08:06:19 +00:00
Gabor Kiss-Vamosi
039080fc26 update changlog 2020-07-07 10:05:29 +02:00
Gabor Kiss-Vamosi
7e9cf858d6 update version number 2020-07-07 10:03:52 +02:00
Gabor Kiss-Vamosi
a740af4afb fix conflicts 2020-07-07 10:02:50 +02:00
Gabor Kiss-Vamosi
a117b3cead update relaese script 2020-07-07 10:01:28 +02:00
Gabor Kiss-Vamosi
e30efb716f Release v7.1.0 2020-07-07 09:37:00 +02:00
Gabor Kiss-Vamosi
43f5e4d2e0 Run code formatter 2020-07-07 09:36:59 +02:00
github-actions[bot]
e178bcc9f3 Merge d8585d2ea3 into dev 2020-07-07 07:32:59 +00:00
Gabor Kiss-Vamosi
d8585d2ea3 update release.py 2020-07-07 09:32:21 +02:00
Gabor Kiss-Vamosi
96728e7ed9 rotary: minor refactoring 2020-07-06 11:51:26 +02:00
Adam Martini
83bdb6c347 Reverse angle delta logic 2020-07-05 14:44:11 -07:00
Adam Martini
085a6499a7 Comment updates for clarity 2020-07-05 13:59:03 -07:00
Adam Martini
b371bd3d05 Capture tick at drap start 2020-07-05 13:50:05 -07:00
Adam Martini
cf39677dfa Use tick elps 2020-07-05 13:30:07 -07:00
Adam Martini
a0bf57f529 tick type 2020-07-05 13:22:37 -07:00
Adam Martini
7a10b700e2 Remove use of tick_elaspe 2020-07-05 13:21:54 -07:00
Adam Martini
aea84d8d79 Cache timestamp for slew rate limit interation 2020-07-05 13:18:08 -07:00
Adam Martini
e3f4c11500 Remove previous thresholding and add creation defaults. Move angle caching to set value to cache last angel for type changes and external value setters. 2020-07-05 12:49:27 -07:00
Adam Martini
e256a27b5a Add slew rate limited angle delta based on threshold of degress/sec 2020-07-05 12:25:44 -07:00
github-actions[bot]
41c4c25315 Merge 9e56f750a7 into dev 2020-07-04 23:50:42 +00:00
Amir Gonnen
9e56f750a7 Prevent compiler warning in lv_draw_rect.c (#1637) 2020-07-04 19:50:14 -04:00
github-actions[bot]
4396196889 Merge e6fe8436f4 into dev 2020-07-04 11:30:45 +00:00
guoweilkd
e6fe8436f4 Fix #1634: bug in lv_tileview_scrl_signal (#1636) 2020-07-04 07:30:07 -04:00
github-actions[bot]
f3f1c606b6 Merge e9d3001dbf into dev 2020-07-03 12:49:29 +00:00
Gabor Kiss-Vamosi
e9d3001dbf img: improve hit test for transformed images 2020-07-03 14:48:54 +02:00
Gabor Kiss-Vamosi
fd186eeb15 roller: fix copy 2020-07-03 14:24:23 +02:00
github-actions[bot]
25607ceaee Merge 4b2c3e560b into dev 2020-07-01 14:14:54 +00:00
Petri HARRI
4b2c3e560b lv_slider: add knob-only feature and fix bug with symmetrical slider (#1578) 2020-07-01 10:14:14 -04:00
Gabor Kiss-Vamosi
989016dff3 fix conflicts 2020-07-01 15:21:14 +02:00
Gabor Kiss-Vamosi
c54788fae4 fix conflicts 2020-07-01 15:19:29 +02:00
Themba Dube
c7fb2ad12c Merge branch 'master' into dev 2020-07-01 09:19:17 -04:00
Gabor Kiss-Vamosi
2fdeaf5599 fix conflicts 2020-07-01 15:18:48 +02:00
Gabor Kiss-Vamosi
1051e3f5a4 roller: fix copy. Closes #1628 2020-07-01 15:15:12 +02:00
Gabor Kiss-Vamosi
0b68c21840 Merge pull request #1627 from xiaogangly/master
Fix a memory leak bug in function "lv_objmask_remove_mask" .
2020-07-01 15:09:10 +02:00
jbamaral
ac26442ca6 Fix lv_textarea_add_char on big endian (#1620) 2020-07-01 09:08:45 -04:00
Pete Bone
b539e6dc46 Merge pull request #1630 from pete-pjb/dev
New functions for Check Box and a minor bug fix
2020-07-01 12:44:41 +01:00
pete-pjb
06603a9c84 New functions for Check Box and a minor bug fix
Remove use of c++ keyword 'new' from function parameter in
lv_theme_set_base() function.
Add function lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state).
Add function lv_checkbox_get_state(const lv_obj_t * cb)
Update Change log.
2020-07-01 12:13:46 +01:00
github-actions[bot]
6b45f3ade5 Merge 6b246b2fed into dev 2020-07-01 08:53:55 +00:00
Gabor Kiss-Vamosi
6b246b2fed fix default theme colors 2020-07-01 10:53:23 +02:00
xiaogangly
86f74e3da2 Fix a memory leak bug in function "lv_objmask_remove_mask" .
There is a little memory leak When you call function "lv_objmask_remove_mask" to remove a specified mask.
It's need free the memory of list's node.
2020-07-01 15:26:37 +08:00
Gabor Kiss-Vamosi
c4e7d7cb83 Merge branch 'dev' of https://github.com/littlevgl/lvgl into dev 2020-06-30 17:09:57 +02:00
github-actions[bot]
43b69a88a9 Merge 6d1da27b3c into dev 2020-06-30 07:44:39 +00:00
Gabor Kiss-Vamosi
6d1da27b3c Create merge-to-dev.yml 2020-06-30 09:43:58 +02:00
Gabor Kiss-Vamosi
bae04005d3 update old function name in comment 2020-06-29 20:47:55 +02:00
Gabor Kiss-Vamosi
edeca8c01b Merge pull request #1619 from liangyongxiang/master
Add conditional macro LV_USE_GROUP to more GROUP related singles:
2020-06-29 14:52:18 +02:00
Gabor Kiss-Vamosi
3aa35a77cb rotary: minor fixes on dragging 2020-06-28 22:03:20 +02:00
Gabor Kiss-Vamosi
069e24bdb2 add examples folder with arduio examples and move porting folder there 2020-06-28 20:37:32 +02:00
Gabor Kiss-Vamosi
d0db0bab5c add Arduino library files 2020-06-28 20:10:30 +02:00
Themba Dube
421f1b2c01 lv_gpu: fix #1617 by renaming internal macros
This avoids conflicts with STM32Cube.
2020-06-28 09:16:25 -04:00
Gabor Kiss-Vamosi
92027cc06f lv_hal_tick: revert using uint32_t as tick_irq_flag
uint8_t surely can be written in 1 instruction even on 16 bit MCUs
2020-06-28 13:32:40 +02:00
Gabor Kiss-Vamosi
ddbeb212b7 Add support to compressed fonts without pre-filter to gain some speed by sacrificing some memory 2020-06-28 13:29:01 +02:00
liangyongxiang
d055944ebb Add conditional macro LV_USE_GROUP to more GROUP related singles:
- LV_SIGNAL_CONTROL
- LV_SIGNAL_GET_EDITABLE
2020-06-28 12:48:37 +08:00
Amir Gonnen
40daa7195d lv_theme: add lv_theme_set_apply_cb (#1616) 2020-06-27 17:46:22 -04:00
Gabor Kiss-Vamosi
3e8b39c404 Merge pull request #1613 from 3096/lv_win-style-fix
material theme: fix lv_win uninitialed styles
2020-06-27 10:35:18 +02:00
3096
e06201f042 material theme: fix lv_win uninitialed styles 2020-06-26 22:27:52 -07:00
Gabor Kiss-Vamosi
2d7423100a fix conflicts 2020-06-27 06:57:28 +02:00
Gabor Kiss-Vamosi
6971d603d2 add lv_theme_copy 2020-06-27 06:54:47 +02:00
Adam Martini
3af55796d9 Remove uneeded point manupulaton 2020-06-26 19:39:10 -07:00
Adam Martini
200c1e788f Second pass at angle based drag. Working with proper threshold setting with knowledge of rotary range. 2020-06-26 16:54:36 -07:00
Amir Gonnen
aad9f4f0c1 Add lv_dpx inline function (#1612)
Identical to LV_DPX (no code additions)
2020-06-26 18:04:46 -04:00
Adam Martini
d271fd6108 Adjust click area extension 2020-06-26 12:35:41 -07:00
Gabor Kiss-Vamosi
76625adec2 fix typo in lv_obj_align_origo_x/y 2020-06-26 21:02:06 +02:00
Gabor Kiss-Vamosi
8b3f9f19f6 add lv_obj_align_origo_x() and lv_obj_align_origo_y() functions 2020-06-26 20:59:57 +02:00
Gabor Kiss-Vamosi
97f999ed9f add lv_obj_align_x() and lv_obj_align_y() functions 2020-06-26 20:52:21 +02:00
Gabor Kiss-Vamosi
e678a2c599 chart: add lv_chart_set_series_axis and lv_chart_set_y_range 2020-06-26 20:31:20 +02:00
Adam Martini
7e4b8aa49b Second attempt arc drag 2020-06-26 09:46:55 -07:00
Adam Martini
c36f731316 Only drag in one dimension because its too jumpy 2020-06-26 08:50:24 -07:00
Adam Martini
849d3d3255 Use point as last point 2020-06-26 08:48:12 -07:00
Adam Martini
ec4cc14bf9 Remove unsec x setter 2020-06-26 08:46:56 -07:00
Adam Martini
7de60867ef Set last drag point based on diffs 2020-06-26 08:45:41 -07:00
Adam Martini
4011d54668 Use the max x and y drag diff to control drag 2020-06-26 08:40:30 -07:00
Gabor Kiss-Vamosi
6056bc3b95 clraify the tricky loop in lv_tick_get 2020-06-26 14:35:30 +02:00
Gabor Kiss-Vamosi
91f64c8662 Add lv_theme_set_base() to allow easy extension of built-in (or any) themes 2020-06-26 14:05:34 +02:00
Gabor Kiss-Vamosi
274d0b522d Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-06-26 09:39:29 +02:00
Gabor Kiss-Vamosi
ac7527fecf minor optimization in lv_obj_init_draw_img_dsc 2020-06-26 09:39:19 +02:00
Adam Martini
8bcbceef08 Send event on if the value really does change 2020-06-25 23:05:48 -07:00
Adam Martini
7ce9a969c8 Rever drag limit integration as it makes rotary control too granular 2020-06-25 22:43:54 -07:00
Adam Martini
f836e90869 Account for indev drag limit 2020-06-25 22:40:03 -07:00
Adam Martini
6d07effbc3 Revert arc tracking 2020-06-25 21:39:19 -07:00
Adam Martini
a73b316681 Remove undeclared 2020-06-25 21:27:18 -07:00
Adam Martini
70a2287568 Remove undeclared 2020-06-25 21:24:19 -07:00
Adam Martini
9e3d8c9090 Remove undeclared 2020-06-25 21:23:14 -07:00
Adam Martini
2d4c709a88 Get area width using pointer 2020-06-25 21:22:37 -07:00
Adam Martini
92ecff3fc0 WIP: dragging on ring only using lv_atan 2020-06-25 21:18:42 -07:00
Gabor Kiss-Vamosi
2ed6b4e2f5 Merge pull request #1607 from jbamaral/fix-img-big-endian-pr
fix image demos on big endian systems
2020-06-25 17:11:46 +02:00
embeddedt
3761db65e0 Fix spelling issue 2020-06-25 07:32:45 -04:00
Gabor Kiss-Vamosi
eb006b3d39 finialze screen animations 2020-06-25 12:43:45 +02:00
Gabor Kiss-Vamosi
f10f94bea3 use void * as theme user data for backward compatibility 2020-06-25 12:43:44 +02:00
Gabor Kiss-Vamosi
710226c6db add user_data to themes 2020-06-25 12:43:44 +02:00
Gabor Kiss-Vamosi
44a96df9fb initial implementation of screen load animation 2020-06-25 12:43:44 +02:00
embeddedt
cd788da47a Fix #1610: don't assert an expected null pointer 2020-06-25 12:43:44 +02:00
Gabor Kiss-Vamosi
c4eec78a02 lv_textarea fix cursor alignment with empty textarea when the text alignment is center or right 2020-06-25 12:43:44 +02:00
Gabor Kiss-Vamosi
1e33359d0c fix build error 2020-06-25 12:43:44 +02:00
Gabor Kiss-Vamosi
cf8357e004 fix focusing/defocusing for pages 2020-06-25 12:43:44 +02:00
Gabor Kiss-Vamosi
8f243c01d5 style: minor fix on getting style attributes + formatting 2020-06-25 12:43:44 +02:00
Gabor Kiss-Vamosi
e2aa68394c update changelog 2020-06-25 12:43:44 +02:00
Gabor Kiss-Vamosi
2828582c7a lv_img: fix invalidation area when angle or zoom changes 2020-06-25 12:43:44 +02:00
jbamaral
f6a2c635fd Improve big endian support (#1599) 2020-06-25 12:43:44 +02:00
Gabor Kiss-Vamosi
db24bf1d18 In lv_init test if the the strings are UTF-8 encoded 2020-06-25 12:42:06 +02:00
Deon Marais
8c151a2d43 Add missing lv_font_montserrat_34
if you do not mind me asking, and on matters of fonts why was Roboto changed to Montserrat when V7 was released ?
2020-06-25 12:42:06 +02:00
Gabor Kiss-Vamosi
52cca1dd9b use void * as theme user data for backward compatibility 2020-06-25 06:38:17 +02:00
Gabor Kiss-Vamosi
859f72eb84 add user_data to themes 2020-06-25 06:25:40 +02:00
embeddedt
b77d484a27 Fix #1610: don't assert an expected null pointer 2020-06-24 12:25:16 -04:00
jbamaral
1733508e9a move bug logs to their right position in changelog 2020-06-24 10:01:42 -03:00
jbamaral
5f6c7743ad update internal configuration 2020-06-24 08:38:44 -03:00
jbamaral
2550368d30 fix image demos on big endian systems 2020-06-24 08:30:45 -03:00
Gabor Kiss-Vamosi
63aba1b3de lv_textarea fix cursor alignment with empty textarea when the text alignment is center or right 2020-06-24 11:36:35 +02:00
Gabor Kiss-Vamosi
42f79763e1 fix build error 2020-06-24 11:28:51 +02:00
Gabor Kiss-Vamosi
be19e91e91 fix focusing/defocusing for pages 2020-06-24 11:24:07 +02:00
Gabor Kiss-Vamosi
9561aa767d style: minor fix on getting style attributes + formatting 2020-06-24 10:45:32 +02:00
Gabor Kiss-Vamosi
4c629ec23f update changelog 2020-06-24 10:04:30 +02:00
Gabor Kiss-Vamosi
8864cd87ee lv_img: fix invalidation area when angle or zoom changes 2020-06-24 10:03:37 +02:00
Adam Martini
f75428e52b Match rotary_bg line width to indicator width 2020-06-23 23:06:56 -07:00
Adam Martini
b414aa755d int32 fix to mapping logic 2020-06-23 13:33:25 -07:00
Adam Martini
5961800fe0 Fix map contract 2020-06-23 12:56:07 -07:00
Adam Martini
663af3dfb3 Shift mapping math out of floating point 2020-06-23 12:54:06 -07:00
jbamaral
916f5b343a Improve big endian support (#1599) 2020-06-23 08:30:33 -04:00
Gabor Kiss-Vamosi
c0223977d1 roller: fix misaligned option after setting new options 2020-06-23 11:44:06 +02:00
Gabor Kiss-Vamosi
e1c5d8950f Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-06-23 11:11:57 +02:00
Gabor Kiss-Vamosi
20c46ca640 In lv_init test if the the strings are UTF-8 encoded 2020-06-23 11:11:45 +02:00
Adam Martini
0aeb49d28a Fix Set sym end angle 2020-06-22 22:53:58 -07:00
Adam Martini
83d05f945f Fix bg_end init 2020-06-22 22:49:23 -07:00
Adam Martini
f0cae00574 Rearrange type call for clarity. Fix symmetric arc setters 2020-06-22 22:47:01 -07:00
Adam Martini
46f7dff9e2 Fix statement declaration 2020-06-22 21:56:31 -07:00
Adam Martini
9ede4ba707 typo 2020-06-22 21:54:47 -07:00
Adam Martini
1c071530ad Remove sym references 2020-06-22 21:54:03 -07:00
Adam Martini
ba10671b2b Rotary types. Add symmetric value setter 2020-06-22 21:50:21 -07:00
Gabor Kiss-Vamosi
188205399b Merge pull request #1598 from DeonMarais64/patch-1
Add missing lv_font_montserrat_34
2020-06-22 10:08:22 +02:00
Adam Martini
af7134269e Force set_value handling in reverse 2020-06-21 11:15:48 -07:00
Adam Martini
19a1afbd89 Fix reverse mapping 2020-06-21 11:05:24 -07:00
Adam Martini
5359a762b8 Reverse min and max in mapping reverse 2020-06-21 10:59:41 -07:00
Themba Dube
0d0427f8bc Merge remote-tracking branch 'origin/master' into dev 2020-06-21 08:32:48 -04:00
Adam Martini
0d6b8a86d4 Try reverse mapping 2020-06-21 00:36:39 -07:00
Adam Martini
6c01490372 Use value setter for reverse start angle setting 2020-06-21 00:34:08 -07:00
Adam Martini
4ab8520bfb Use lv math abs 2020-06-21 00:29:03 -07:00
Adam Martini
d60a6cbc76 Add reverse value mapping and arc tracking 2020-06-21 00:26:20 -07:00
Adam Martini
4bedc57b7d Add setter for threshold 2020-06-21 00:08:49 -07:00
Adam Martini
e1761d50a1 Test threshold for value jupming 2020-06-21 00:05:09 -07:00
Adam Martini
856368284e Test sensitivity threshold for value jumping 2020-06-20 23:58:03 -07:00
Adam Martini
ad990994d0 Fix release drag hoping better checking for -1 last drag x 2020-06-20 23:54:25 -07:00
Adam Martini
247b5b6f0c Fix drag diff calc 2020-06-20 23:43:40 -07:00
Adam Martini
6836947e67 typo 2020-06-20 23:33:50 -07:00
Adam Martini
dc873966e9 Make sensitivity an int 2020-06-20 23:33:18 -07:00
Adam Martini
fe483e8e21 Add sensitivity default explicit 2020-06-20 23:26:22 -07:00
Adam Martini
3a31577592 Add sesitivty setter 2020-06-20 23:20:12 -07:00
Adam Martini
3721fc52a8 Typo 2020-06-20 17:25:14 -07:00
Adam Martini
a7350282f0 Use drag diff for value setting 2020-06-20 17:24:34 -07:00
Adam Martini
c93ef97ab9 Remove NULL comp 2020-06-20 17:18:53 -07:00
Adam Martini
866e088f98 Copy knob_area to ext 2020-06-20 17:16:57 -07:00
Adam Martini
15ec0f8e2f Remove value_to_set remnant. Do not override checked opacity 2020-06-20 17:15:09 -07:00
Adam Martini
fc14c2c01c Remove chechable and toggle 2020-06-20 17:11:12 -07:00
Adam Martini
71f8497ee6 Add knob_area ext 2020-06-20 16:47:23 -07:00
Adam Martini
5a0c0e2e97 Add value change event calls for dragging 2020-06-20 16:43:53 -07:00
Adam Martini
3e079a47ae Pull btn functionality out for now, make checked state make DEAFULT. Add dragging value setters. 2020-06-20 16:40:47 -07:00
Adam Martini
35c0cfcfea Use custom event as data is not transfered to CB 2020-06-20 12:23:24 -07:00
Adam Martini
fa8deb524d Mising ; 2020-06-20 12:18:53 -07:00
Adam Martini
f3773694bc Remove custom event in favor or NULL diff 2020-06-20 12:17:15 -07:00
Adam Martini
1860742c13 Fix missing ;. Add custom event last 2020-06-20 12:14:17 -07:00
Adam Martini
f6d75e759c Add btn like signal handling for knob part. Add custom event to distuinguish from VALUE_CHANGED 2020-06-20 12:12:42 -07:00
Adam Martini
9b38b35420 Static state setter 2020-06-20 11:13:37 -07:00
Adam Martini
b1afc3f34d Add rotary state 2020-06-20 11:11:26 -07:00
Adam Martini
1dfdabd638 Test btn extension 2020-06-20 11:06:06 -07:00
Deon Marais
f9512f55cc Add missing lv_font_montserrat_34
if you do not mind me asking, and on matters of fonts why was Roboto changed to Montserrat when V7 was released ?
2020-06-20 09:08:59 +02:00
Adam Martini
446b0b6429 Floats working fro value mapping 2020-06-19 18:05:55 -07:00
Adam Martini
cf4db99206 Test float for mapping 2020-06-19 18:01:15 -07:00
Adam Martini
c854670062 Test float for mapping 2020-06-19 18:00:28 -07:00
Adam Martini
e100565c67 Move map function to proper func to avoid recalc of slope 2020-06-19 17:49:02 -07:00
Adam Martini
f5d9e4bff4 Fix range mapping for value setter assuming left to right indic 2020-06-19 17:39:50 -07:00
Adam Martini
7a7e1668fa Make value setter indic mapping from arc start to bg end. 2020-06-19 17:15:15 -07:00
Adam Martini
4e13d6ae4d Cast ext 2020-06-19 15:59:04 -07:00
Gabor Kiss-Vamosi
201d38c574 Add theme->apply_cb to replace theme->apply_xcb to make it compatible with the Micropython binding 2020-06-20 00:01:33 +02:00
Gabor Kiss-Vamosi
75a27e4cc7 rotary: leave the default size from arc + fix style get 2020-06-19 23:41:29 +02:00
Gabor Kiss-Vamosi
95b07a2d23 rotary: clean up 2020-06-19 23:25:17 +02:00
Gabor Kiss-Vamosi
94a710a5e1 Merge branch 'feature/1568_lv_rotary' of https://github.com/acumartini/lvgl into acumartini-feature/1568_lv_rotary 2020-06-19 23:00:03 +02:00
Adam Martini
b9dc9e81de Missing ; 2020-06-19 11:44:29 -07:00
Adam Martini
1396fce961 Fix debug import 2020-06-19 11:42:55 -07:00
Adam Martini
884be64d17 Fix rotary type getter. 2020-06-19 11:38:22 -07:00
embeddedt
8dbd685a90 Fix #1596: typo in lv_api_map.h 2020-06-19 10:13:53 -04:00
Gabor Kiss-Vamosi
4345e05e32 test
Signed-off-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
2020-06-19 15:12:17 +02:00
Gabor Kiss-Vamosi
24b1a7735a roller: allow setting different font for the selected text 2020-06-19 13:17:45 +02:00
Adam Martini
168a7c4c45 Add theme define 2020-06-18 22:46:30 -07:00
Adam Martini
a696aef959 Use rotary param in type getter 2020-06-18 22:43:38 -07:00
Adam Martini
6dddbde387 Add ifndef to internal conf 2020-06-18 22:27:51 -07:00
Adam Martini
b9d92236e3 Add rotary to build.py defines 2020-06-18 22:25:41 -07:00
Adam Martini
2dc14fc7e5 Add missing rotary widget import 2020-06-18 22:22:22 -07:00
Adam Martini
2908a74b42 Reduce knob pad get logic 2020-06-18 17:11:15 -07:00
Adam Martini
1a41f13fd6 Initial lv_rotary work extending lv_arc with stubbed signal handler. 2020-06-18 17:06:24 -07:00
Gabor Kiss-Vamosi
b16f3ff8e7 Merge branch 'dev' of https://github.com/littlevgl/lvgl into dev 2020-06-18 16:32:14 +02:00
Gabor Kiss-Vamosi
0f4aeede79 Update README.md 2020-06-18 16:29:18 +02:00
Gabor Kiss-Vamosi
5d4873aa95 Update README.md 2020-06-18 16:19:57 +02:00
Gabor Kiss-Vamosi
8ac337d515 Update README.md 2020-06-18 16:13:04 +02:00
Gabor Kiss-Vamosi
2678068a86 Update CONTRIBUTING.md 2020-06-18 16:09:07 +02:00
Gabor Kiss-Vamosi
64be5e2096 Update CONTRIBUTING.md 2020-06-18 16:08:17 +02:00
Pete Bone
6b3d7759cc Merge pull request #1587 from pete-pjb/dev
Finalise chart function updates
2020-06-18 14:59:19 +01:00
Pete Bone
765b6c4015 Update CHANGELOG.md 2020-06-18 14:38:07 +01:00
Gabor Kiss-Vamosi
1521d64784 _lv_img_buf_get_transformed_area: do not calculate trivial case 2020-06-18 15:17:03 +02:00
Amir Gonnen
25fbcea31a Ensure mem_max_size is only used on non custom mem (#1588) 2020-06-18 06:40:39 -04:00
Gabor Kiss-Vamosi
51e064d836 Update CHANGELOG.md 2020-06-18 12:37:02 +02:00
Gabor Kiss-Vamosi
6ae7f67ef5 Update CHANGELOG.md 2020-06-18 12:36:05 +02:00
Gabor Kiss-Vamosi
156a3c005d Update CHANGELOG.md 2020-06-18 12:35:38 +02:00
Gabor Kiss-Vamosi
295337ac7e Merge pull request #1590 from diegoherranz/lv_conf_checker
lv_conf_checker.py: change requirement of python 3.6 to >=3.6
2020-06-18 12:32:13 +02:00
Gabor Kiss-Vamosi
a39f51a571 Merge branch 'dev' into dev 2020-06-18 07:41:54 +02:00
Gabor Kiss-Vamosi
d050c99161 Merge branch 'dev' of https://github.com/littlevgl/lvgl into dev 2020-06-18 06:04:02 +02:00
Gabor Kiss-Vamosi
1523cc0634 fix typo 2020-06-18 06:03:52 +02:00
Diego Herranz
65d029279b lv_calendar: add option to start week on Monday (#1589) 2020-06-17 16:09:40 -04:00
Diego Herranz
d2d664a69b lv_conf_checker.py: change requirement of python 3.6 to >=3.6
Many current OSes ship newer versions (e.g. 3.8) and they work OK
for this, so I don't think 3.6 is required specifically.
Versions older than 3.6 wouldn't work, though, since f-strings
are used.
2020-06-17 21:04:46 +01:00
pete-pjb
4a953b9d9d Free memory for series_ll 2020-06-16 18:24:05 +01:00
pete-pjb
ae748cfffa Fix initialisation problem.
Found that new structure parmaeter ext_buf_assigned needs to be
initialised to false in lv_chart_add_series() as sometimes is set true
depending on what was previously in the heap where it was allocated.
2020-06-16 18:04:36 +01:00
PeterB
ad215c5b4b Finalise changes for new Chart Functions 2020-06-16 16:24:37 +01:00
Gabor Kiss-Vamosi
2dd84e6de1 Merge branch 'master' into dev 2020-06-16 16:52:18 +02:00
pete-pjb
05d249d5ee Merge branch 'master' into dev 2020-06-16 15:10:56 +01:00
Pete Bone
f746ac8542 Added functions to extend chart functionality (#1581) 2020-06-16 09:53:21 -04:00
Gabor Kiss-Vamosi
7af64df008 upadte version numer to v7.1.0-dev 2020-06-16 13:57:20 +02:00
Gabor Kiss-Vamosi
975ab3f4cc Merge branch 'dev' 2020-06-16 13:56:42 +02:00
Gabor Kiss-Vamosi
122ef1d862 Merge branch 'master' of https://github.com/littlevgl/lvgl 2020-06-16 13:56:00 +02:00
Gabor Kiss-Vamosi
4174ad844c relase.py minor fixes 2020-06-16 13:55:45 +02:00
Gabor Kiss-Vamosi
41e65d9df1 Run code formatter 2020-06-16 13:47:04 +02:00
Gabor Kiss-Vamosi
df9801eac3 Merge pull request #1584 from BesitzeRuf/dev
Fixes drawing of the image border
2020-06-16 13:10:36 +02:00
besitzeruf
ae93ee067c Merge branch 'dev-fix-Asymmetric-border-thickness-on-image-objects' into dev 2020-06-16 11:22:30 +02:00
besitzeruf
59165f077e - Fix when border of the image (bottom and right sides) are drawn with different width ( decreased by 1) 2020-06-16 11:18:45 +02:00
pete-pjb
832dbd644b Remove redundant assert 2020-06-16 09:31:37 +01:00
Themba Dube
10ee9e5e99 Merge branch 'dev' of github.com:littlevgl/lvgl into dev 2020-06-15 17:06:39 -04:00
pete-pjb
fe5663908c Fix unused variable 2020-06-15 17:29:33 +01:00
pete-pjb
f23873e3f5 Added Functions to extend chart functionality as follows:
/**
 * Set the index of the x-axis start point in the data array
 * @param chart             pointer to a chart object
 * @param ser 				pointer to a data series on 'chart'
 * @param id    			the index of the x point in the data array
 */
void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t *
ser, uint16_t id);

/**
 * Set an external array of data points to use for the chart
 * NOTE: It is the users responsibility to make sure the point_cnt
matches the external array size.
 * @param chart             pointer to a chart object
 * @param ser 				pointer to a data series on 'chart'
 * @param array				external array of points for chart
 */
void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser,
lv_coord_t array[], uint16_t point_cnt );

/**
 * Set an individual point value in the chart series directly based on
index
 * @param chart             pointer to a chart object
 * @param ser 				pointer to a data series on 'chart'
 * @param value				value to assign to array point
 * @param id				the index of the x point in the array
 */
void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser,
lv_coord_t value, uint16_t id);


/**
 * get the current index of the x-axis start point in the data array
 * @param chart             pointer to a chart object
 * @param ser 				pointer to a data series on 'chart'
 * @return 					the index of the current x start point in the data array
 */
uint16_t lv_chart_get_x_start_point(lv_obj_t * chart, lv_chart_series_t
* ser);

/**
 * Get an individual point value in the chart series directly based on
index
 * @param chart             pointer to a chart object
 * @param ser 				pointer to a data series on 'chart'
 * @param id				the index of the x point in the array
 * @return					value of array point at index id
 */
lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t *
ser, uint16_t id);
2020-06-15 17:15:05 +01:00
OH1BDF
43cc512e5a Added functions to set multiple paddings and margins at once (#1565) 2020-06-12 07:28:11 -04:00
Carlos Diaz
a265165038 Add lv_win_add_btn_left (#1566)
Closes #1535
2020-06-12 07:26:59 -04:00
Themba Dube
8117a70608 Merge branch 'master' into dev 2020-06-12 07:23:47 -04:00
Gabor Kiss-Vamosi
dca12fcd7a Update CHANGELOG.md 2020-06-10 10:14:12 +02:00
Gabor Kiss-Vamosi
e2dabe167d Merge pull request #1562 from arturv2000/MaxMemUsed
Added max_used propriety to lv_mem_monitor_t struct
2020-06-10 10:13:34 +02:00
Gabor Kiss-Vamosi
14a359679a Update CHANGELOG.md 2020-06-09 13:41:24 +02:00
Gabor Kiss-Vamosi
3b111c794c Merge pull request #1561 from microwavesafe/master
Remove dependency on ST CubeMX Hal
2020-06-09 13:40:41 +02:00
arturv2000
ce8d333407 Update src/lv_misc/lv_mem.c
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
2020-06-09 09:46:42 +01:00
microwavesafe
71e23c4e13 Added example include defines 2020-06-09 09:45:12 +01:00
arturv2000
91acf877c6 Attempt to correct error in tests 2020-06-08 21:00:12 +01:00
artur.vieira
0ebcf7e266 Added Max Used propriety to lv_mem_monitor_t struct 2020-06-08 20:22:06 +01:00
andrew
3c70a1b5a2 Fixed typo in include define
Added help in lv_conf_template.h
2020-06-08 18:36:30 +01:00
Gabor Kiss-Vamosi
94b2e0f1a3 Update CHANGELOG.md 2020-06-08 14:16:25 +02:00
Gabor Kiss-Vamosi
a62b03743d Merge pull request #1560 from DeonMarais64/master
Add lv_btnmatrix_set/get_align capability
2020-06-08 14:15:49 +02:00
Gabor Kiss-Vamosi
4754935038 Update CHANGELOG.md 2020-06-08 14:15:14 +02:00
Gabor Kiss-Vamosi
ee44433f86 Merge pull request #1522 from fhorinek/encoder-buttons
Encoder input proc support for buttons
2020-06-08 14:14:32 +02:00
Gabor Kiss-Vamosi
9c8c8aee72 update CHANGLEOG 2020-06-08 14:13:33 +02:00
Gabor Kiss-Vamosi
2739753f20 Merge pull request #1509 from fhorinek/master
Added focus parent for v7
2020-06-08 14:11:40 +02:00
Gabor Kiss-Vamosi
14de809fa5 fix warings 2020-06-08 14:10:30 +02:00
Gabor Kiss-Vamosi
06fa5b3b8f fix conflicts 2020-06-08 14:02:04 +02:00
andrew
0867f72cb9 Rename attribute define to match existing options style
Moved static array declaration to top of file
Added attribute define to template and checker headers
2020-06-08 08:40:50 +01:00
andrew
bb5c6437ff Added GPU init to lv_init
Changed blend buffer attr to more general LV_DMA_ATTR
Added define for CMSIS header
Fixed bug with turning on peripheral clock
2020-06-05 14:04:52 +01:00
andrew
cd9f34076e Modified DMA2D fill, copy and blend functions to use direct
register writes
2020-06-05 11:10:51 +01:00
andrew
0d897136c9 Added LV_BLEND_BUF_ATTR as blend_buf MUST be in DMA accessible RAM 2020-06-05 11:10:11 +01:00
Deon Marais
0e1b02e328 Add lv_btnmatrix_set/gett_align capability 2020-06-05 12:05:34 +02:00
Deon Marais
e3b5a14275 Add align-member and set/get functions 2020-06-05 11:58:33 +02:00
Gabor Kiss-Vamosi
2be22d3bef list: leaving edit mode with encoder 2020-05-27 11:22:01 +02:00
Gabor Kiss-Vamosi
6a35a384b8 Merge branch 'encoder-buttons' of https://github.com/fhorinek/lvgl into fhorinek-encoder-buttons 2020-05-27 10:35:58 +02:00
František Horínek
691ce77800 Modified version for encoder input proc.
Now you can also pass buttons LEFT/RIGHT to emulate the encoder, good for joysticks or small keypads.
All other keys are passed trought.
2020-05-25 15:51:20 +02:00
Gabor Kiss-Vamosi
7e4e5b7271 Merge branch 'master' of https://github.com/fhorinek/lvgl into fhorinek-master 2020-05-23 14:54:18 +02:00
Gabor Kiss-Vamosi
1666c8cb4f handle focus_parent in pointer indevs 2020-05-23 14:53:23 +02:00
František Horínek
8f19010b17 Update src/lv_core/lv_obj.c
Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
2020-05-21 17:27:37 +02:00
Gabor Kiss-Vamosi
4fade082e5 Merge branch 'master' of https://github.com/fhorinek/lvgl into fhorinek-master 2020-05-21 15:17:19 +02:00
František Horínek
b23d945ed4 changed behavior to focus_parent flag 2020-05-21 14:09:56 +02:00
František Horínek
10ca6d4215 replaced #ifdef to #if 2020-05-19 15:45:09 +02:00
František Horínek
2712f0aeaa Added macro LV_USE_GROUP_FOCUS_PARENT to automatic tests 2020-05-19 15:31:34 +02:00
František Horínek
aaa78ba949 Added focus parent for v7 2020-05-19 15:22:38 +02:00
149 changed files with 11435 additions and 2709 deletions

2
.github/FUNDING.yml vendored
View File

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

12
.github/auto-comment.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# Comment to a new issue.
pullRequestOpened: |
Thank you for raising your pull request.
To ensure that all licensing criteria is met all repositories of the LVGL project apply a process called DCO (Developer's Certificate of Origin).
The text of DCO can be read here: https://developercertificate.org/
For a more detailed description see the [Documentation](https://docs.lvgl.io/latest/en/html/contributing/index.html#developer-certification-of-origin-dco) site.
By contributing to any repositories of the LVGL project you state that your contribution corresponds with the DCO.
No further action is required if your contribution fulfills the DCO. If you are not sure about it feel free to ask us in a comment.

42
.github/workflows/build_micropython.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Build Micropython with LVGL submodule
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install SDL
run: |
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse"
sudo apt-get update -y -qq
sudo apt-get install libsdl2-dev
- name: Clone lv_micropython
run: git clone https://github.com/lvgl/lv_micropython.git .
- name: Update submodules
run: git submodule update --init --recursive
- name: Checkout LVGL submodule
working-directory: ./lib/lv_bindings/lvgl
run: |
git fetch --force ${{ github.event.repository.git_url }} "+refs/heads/*:refs/remotes/origin/*"
git fetch --force ${{ github.event.repository.git_url }} "+refs/pull/*/head:refs/remotes/origin/pr/*"
git checkout ${{ github.sha }} || git checkout ${{ github.event.pull_request.head.sha }}
git submodule update --init --recursive
- name: Build mpy-cross
run: make -j $(nproc) -C mpy-cross
- name: Build the unix port
run: make -j $(nproc) -C ports/unix
- name: Run advanced_demo
run: >
echo "import gc,utime;
utime.sleep(5);
gc.collect();
utime.sleep(5)" |
ports/unix/micropython -i lib/lv_bindings/examples/advanced_demo.py

View File

@@ -14,4 +14,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Run tests
run: cd tests; python ./build.py
run: sudo apt-get install libpng-dev; cd tests; python ./build.py

17
.github/workflows/merge-to-dev.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: Merge master branch to dev
on:
push:
branches:
- 'master'
jobs:
merge-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Merge to dev branch
uses: devmasx/merge-branch@v1.1.0
with:
type: now
target_branch: 'dev'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

View File

@@ -1,8 +1,133 @@
# Changelog
## v7.5.0 (planned at 15.09.2020)
### New features
- Add `clean_dcache_cb` and `lv_disp_clean_dcache` to enable users to use their own cache management function
- Add `gpu_wait_cb` to wait until the GPU is working. It allows to run CPU a wait only when the rendered data is needed.
### Bugfixes
- Fix unexpeted DEFOCUS on lv_page when clicking to bg after the scrollable
- Fix `lv_obj_del` and `lv_obj_clean` if the children list changed during deletion.
- Adjust button matrix button width to include padding when spanning multiple units.
- Add rounding to btnmatrix line height calculation
- Add `decmopr_buf` to GC roots
- Fix divisioin by zero in draw_pattern (lv_draw_rect.c) if the image or letter is not found
- Fix drawing images with 1 px height or width
- Fix selectiion of options with non-ASCII letters in dropdown list
## v7.4.0 (01.09.2020)
The main new features of v7.4 are run-time font loading, style caching and arc knob with value setting by click.
### New features
- Add `lv_font_load()` function - Loads a `lv_font_t` object from a binary font file
- Add `lv_font_free()` function - Frees the memory allocated by the `lv_font_load()` function
- Add style caching to reduce acces time of properties with default value
- arc: add set value by click feature
- arc: add `LV_ARC_PART_KNOB` similarly to slider
- send gestures even if the the obejct was dragged. User can check dragging with `lv_indev_is_dragging(lv_indev_act())` in the event function.
### Bugfixes
- Fix color bleeding on border drawing
- Fix using 'LV_SCROLLBAR_UNHIDE' after 'LV_SCROLLBAR_ON'
- Fix croping of last column/row if an image is zoomed
- Fix zooming and rotateing mosaic images
- Fix deleting tabview with LEFT/RIGHT tab position
- Fix btnmatrix to not send event when CLICK_TRIG = true and the cursor slid from a pressed button
- Fix roller width if selected text is larger than the normal
## v7.3.1 (18.08.2020)
### Bugfixes
- Fix drawing value string twice
- Rename `lv_chart_clear_serie` to `lv_chart_clear_series` and `lv_obj_align_origo` to `lv_obj_align_mid`
- Add linemeter's mirror feature again
- Fix text decor (udnerline strikethrough) with older versions of font converter
- Fix setting local style property multiple times
- Add missing background drawing and radius handling to image button
- Allow adding extra label to list buttons
- Fix crash if `lv_table_set_col_cnt` is called before `lv_table_set_row_cnt` for the first time
- Fix overflow in large image transformations
- Limit extra button click area of button matrix's buttons. With large paddings it was counter intuitive. (Gaps are mapped to button when clicked).
- Fix `lv_btnmatrix_set_one_check` not forcing exactly one button to be checked
- Fix color picker invalidation in rectangle mode
- Init disabled days to gray color in calendar
## v7.3.0 (04.08.2020)
### New features
- Add `lv_task_get_next`
- Add `lv_event_send_refresh`, `lv_event_send_refresh_recursive` to easily send `LV_EVENT_REFRESH` to object
- Add `lv_tabview_set_tab_name()` function - used to change a tab's name
- Add `LV_THEME_MATERIAL_FLAG_NO_TRANSITION` and `LV_THEME_MATERIAL_FLAG_NO_FOCUS` flags
- Reduce code size by adding: `LV_USE_FONT_COMPRESSED` and `LV_FONT_USE_SUBPX` and applying some optimization
- Add `LV_MEMCPY_MEMSET_STD` to use standard `memcpy` and `memset`
### Bugfixes
- Do not print warning for missing glyph if its height OR width is zero.
- Prevent duplicated sending of `LV_EVENT_INSERT` from text area
- Tidy outer edges of cpicker widget.
- Remove duplicated lines from `lv_tabview_add_tab`
- btnmatrix: hadle combined states of buttons (e.g. chacked + disabled)
- textarea: fix typo in lv_textarea_set_sscrollbar_mode
- gauge: fix image needle drawing
- fix using freed memory in _lv_style_list_remove_style
## v7.2.0 (21.07.2020)
### New features
- Add screen transitions with `lv_scr_load_anim()`
- Add display background color, wallpaper and opacity. Shown when the screen is transparent. Can be used with `lv_disp_set_bg_opa/color/image()`.
- Add `LV_CALENDAR_WEEK_STARTS_MONDAY`
- Add `lv_chart_set_x_start_point()` function - Set the index of the x-axis start point in the data array
- Add `lv_chart_set_ext_array()` function - Set an external array of data points to use for the chart
- Add `lv_chart_set_point_id()` function - Set an individual point value in the chart series directly based on index
- Add `lv_chart_get_x_start_point()` function - Get the current index of the x-axis start point in the data array
- Add `lv_chart_get_point_id()` function - Get an individual point value in the chart series directly based on index
- Add `ext_buf_assigned` bit field to `lv_chart_series_t` structure - it's true if external buffer is assigned to series
- Add `lv_chart_set_series_axis()` to assign series to primary or secondary axis
- Add `lv_chart_set_y_range()` to allow setting range of secondary y axis (based on `lv_chart_set_range` but extended with an axis parameter)
- Allow setting different font for the selected text in `lv_roller`
- Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the MicroPython binding
- Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes
- Add `lv_obj_align_x()` and `lv_obj_align_y()` functions
- Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions
### Bugfixes
- `tileview` fix navigation when not screen sized
- Use 14px font by default to for better compatibility with smaller displays
- `linemeter` fix conversation of current value to "level"
- Fix drawing on right border
- Set the cursor image non clickable by default
- Improve mono theme when used with keyboard or encoder
## v7.1.0 (07.07.2020)
### New features
- Add `focus_parent` attribute to `lv_obj`
- Allow using buttons in encoder input device
- Add lv_btnmatrix_set/get_align capability
- DMA2D: Remove dependency on ST CubeMX HAL
- Added `max_used` propriety to `lv_mem_monitor_t` struct
- In `lv_init` test if the the strings are UTF-8 encoded.
- Add `user_data` to themes
- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems.
- Add inline function lv_checkbox_get_state(const lv_obj_t * cb) to extend the checkbox functionality.
- Add inline function lv_checkbox_set_state(const lv_obj_t * cb, lv_btn_state_t state ) to extend the checkbox functionality.
### Bugfixes
- `lv_img` fix invalidation area when angle or zoom changes
- Update the style handling to support Big endian MCUs
- Change some methods to support big endian hardware.
- remove use of c++ keyword 'new' in parameter of function lv_theme_set_base().
- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems.
- Fix inserting chars in text area in big endian hardware.
## v7.0.2 (16.06.2020)
### Bugfixes
- `lv_textarea` fix wrong cursor position when clicked after the last character
- Change all text related indices from 16-bit to 32-bit integers throughout whole library. #1545
- Fix gestures
@@ -23,6 +148,7 @@
- `tabview` by default allow auto expanding the page only to right and bottom (#1573)
- fix crash when drawing gradient to the same color
- chart: fix memory leak
- `img`: improve hit test for transformed images
## v7.0.1 (01.06.2020)

335
README.md
View File

@@ -1,8 +1,4 @@
<h1 align="center"> LVGL - Light and Versatile Graphics Library</h1>
<p align="center">
<a href="https://github.com/lvgl/lvgl/blob/master/LICENCE.txt"><img src="https://img.shields.io/badge/licence-MIT-blue.svg"></a>
<a href="https://github.com/lvgl/lvgl/releases/tag/v7.0.0"><img src="https://img.shields.io/badge/version-7.0.0-blue.svg"></a>
</p>
<p align="center">
<img src="https://lvgl.io/assets/images/img_1.png">
@@ -14,221 +10,115 @@ LVGL provides everything you need to create embedded GUI with easy-to-use graphi
<h4 align="center">
<a href="https://lvgl.io">Website </a> &middot;
<a href="https://lvgl.io/demos">Live demo</a> &middot;
<a href="https://lvgl.io/demos">Online demo</a> &middot;
<a href="https://docs.lvgl.io/">Docs</a> &middot;
<a href="https://forum.lvgl.io">Forum</a> &middot;
<a href="https://blog.lvgl.io/">Blog</a>
<a href="https://forum.lvgl.io">Forum</a>
</h4>
---
- [Features](#features)
- [Supported devices](#supported-devices)
- [Quick start in a simulator](#quick-start-in-a-simulator)
- [Add LVGL to your project](#add-lvgl-to-your-project)
- [Learn the basics](#learn-the-basics)
- [Examples](#examples)
- [Release policy](#release-policy)
- [Contributing](#contributing)
## Features
* **Powerful building blocks** buttons, charts, lists, sliders, images, etc.
* **Advanced graphics** with animations, anti-aliasing, opacity, smooth scrolling
* **Simultaneously use various input devices** touchscreen, mouse, keyboard, encoder, buttons, etc.
* **Simultaneously use multiple displays** i.e. monochrome and color display
* **Multi-language support** with UTF-8 encoding, Bidirectional support, and Arabic text handling
* **Fully customizable** graphical elements
* **Hardware independent** to use with any microcontroller or display
* **Scalable** to operate with little memory (64 kB Flash, 10 kB RAM)
* **OS, External memory and GPU** supported but not required
* **Single frame buffer** operation even with advances graphical effects
* **Written in C** for maximal compatibility (C++ compatible)
* **Micropython Binding** exposes [LVGL API in Micropython](https://blog.lvgl.io/2019-02-20/micropython-bindings)
* **Simulator** to develop on PC without embedded hardware
* **Tutorials, examples, themes** for rapid development
* **Documentation** and API references
* Powerful [building blocks](https://docs.lvgl.io/latest/en/html/widgets/index.html): buttons, charts, lists, sliders, images, etc.
* Advanced graphics: animations, anti-aliasing, opacity, smooth scrolling
* Use [various input devices](https://docs.lvgl.io/latest/en/html/overview/indev.html): touchscreen, mouse, keyboard, encoder, buttons, etc.
* Use [multiple displays](https://docs.lvgl.io/latest/en/html/overview/display.html): e.g. monochrome and color display
* Hardware independent to use with any microcontroller or display
* Scalable to operate with little memory (64 kB Flash, 10 kB RAM)
* Multi-language support with UTF-8 handling, Bidirectional and Arabic script support
* Fully customizable graphical elements via [CSS-like styles](https://docs.lvgl.io/latest/en/html/overview/style.html)
* OS, External memory and GPU are supported but not required
* Smooth rendering even with a [single frame buffer](https://docs.lvgl.io/latest/en/html/porting/display.html)
* Written in C for maximal compatibility (C++ compatible)
* Micropython Binding exposes [LVGL API in Micropython](https://blog.lvgl.io/2019-02-20/micropython-bindings)
* [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) to develop on PC without embedded hardware
* [Examples](lv_examples) and tutorials for rapid development
* [Documentation](http://docs.lvgl.io/) and API references
## Supported devices
Basically, every modern controller (which is able to drive a display) is suitable to run LVGL. The minimal requirements are:
- 16, 32 or 64 bit microcontroller or processor
- &gt; 16 MHz clock speed is recommended
- Flash/ROM: &gt; 64 kB for the very essential components (&gt; 180 kB is recommended)
- RAM:
- Static RAM usage: ~2 kB depending on the used features and objects types
- Stack: &gt; 2kB (&gt; 8 kB is recommended)
- Dynamic data (heap): &gt; 2 KB (&gt; 16 kB is recommended if using several objects).
Set by `LV_MEM_SIZE` in *lv_conf.h*.
- Display buffer: &gt; *"Horizontal resolution"* pixels (&gt; 10 &times; *"Horizontal resolution"* is recommended)
- C99 or newer compiler
## Requirements
Basically, every modern controller (which is able to drive a display) is suitable to run LVGL. The minimal requirements are:
<table>
<tr>
<td> <strong>Name</strong> </td>
<td><strong>Minimal</strong></td>
<td><strong>Recommended</strong></td>
</tr>
<tr>
<td><strong>Architecture</strong></td>
<td colspan="2">16, 32 or 64 bit microcontroller or processor</td>
</tr>
<tr>
<td> <strong>Clock</strong></td>
<td> &gt; 16 MHz </td>
<td> &gt; 48 MHz</td>
</tr>
<tr>
<td> <strong>Flash/ROM</strong></td>
<td> &gt; 64 kB </td>
<td> &gt; 180 kB</td>
</tr>
<tr>
<td> <strong>Static RAM</strong></td>
<td> &gt; 2 kB </td>
<td> &gt; 4 kB</td>
</tr>
<tr>
<td> <strong>Stack</strong></td>
<td> &gt; 2 kB </td>
<td> &gt; 8 kB</td>
</tr>
<tr>
<td> <strong>Heap</strong></td>
<td> &gt; 2 kB </td>
<td> &gt; 8 kB</td>
</tr>
<tr>
<td> <strong>Display buffer</strong></td>
<td> &gt; 1 &times; <em>hor. res.</em> pixels </td>
<td> &gt; 10 &times; <em>hor. res.</em> pixels </td>
</tr>
<tr>
<td> <strong>Compiler</strong></td>
<td colspan="2"> C99 or newer </td>
</tr>
</table>
*Note that the memory usage might vary depending on the architecture, compiler and build options.*
Just to mention some **platforms**:
- STM32F1, STM32F3, [STM32F4](https://blog.lvgl.io/2017-07-15/stm32f429_disco_port), [STM32F7](https://github.com/lvgl/lv_port_stm32f746_disco_sw4stm32)
Just to mention some platforms:
- STM32F1, STM32F3, STM32F4, STM32F7, STM32L4, STM32L5, STM32H7
- Microchip dsPIC33, PIC24, PIC32MX, PIC32MZ
- NXP Kinetis, LPC, iMX
- NXP: Kinetis, LPC, iMX, iMX RT
- [Linux frame buffer](https://blog.lvgl.io/2018-01-03/linux_fb) (/dev/fb)
- [Raspberry PI](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl)
- [Raspberry Pi](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl)
- [Espressif ESP32](https://github.com/lvgl/lv_port_esp32)
- Nordic nrf52
- Quectell M66
## Quick start in a simulator
The easiest way to get started with LVGL is to run it in a simulator on your PC without any embedded hardware.
Choose a project with your favourite IDE:
| Eclipse | CodeBlocks | Visual Studio | PlatformIO | Qt Creator |
|-------------|-------------|---------------|-----------|------------|
| [![Eclipse](https://raw.githubusercontent.com/lvgl/docs/master/v7/misc//eclipse.jpg)](https://github.com/lvgl/lv_sim_eclipse_sdl) | [![CodeBlocks](https://raw.githubusercontent.com/lvgl/docs/master/v7/misc//codeblocks.jpg)](https://github.com/lvgl/lv_sim_codeblocks_win) | [![VisualStudio](https://raw.githubusercontent.com/lvgl/docs/master/v7/misc//visualstudio.jpg)](https://github.com/lvgl/lv_sim_visual_studio_sdl) | [![PlatformIO](https://raw.githubusercontent.com/lvgl/docs/master/v7/misc//platformio.jpg)](https://github.com/lvgl/lv_platformio) | [![QtCreator](https://raw.githubusercontent.com/lvgl/docs/master/v7/misc//qtcreator.jpg)](https://blog.lvgl.io/2019-01-03/qt-creator) |
| Cross-platform<br>with SDL<br>(Recommended on<br>Linux and Mac) | Native Windows | Windows<br>with SDL | Cross-platform<br>with SDL | Cross-platform<br>with SDL |
## Add LVGL to your project
The steps below show how to setup LVGL on an embedded system with a display and a touchpad.
You can use the [Simulators](https://docs.lvgl.io/v7/en/html/get-started/pc-simulator) to get ready to use projects which can be run on your PC.
1. [Download](https://github.com/lvgl/lvgl/archive/master.zip) or [Clone](https://github.com/lvgl/lvgl) the library
2. Copy the `lvgl` folder into your project
3. Copy `lvgl/lv_conf_template.h` as `lv_conf.h` next to the `lvgl` folder, change the `#if 0` statement near the top of the file to `#if 1` and set at least `LV_HOR_RES_MAX`, `LV_VER_RES_MAX` and `LV_COLOR_DEPTH`.
4. Include `lvgl/lvgl.h` where you need to use LVGL related functions.
5. Call `lv_tick_inc(x)` every `x` milliseconds (should be 1..10) in a Timer or Task. It is required for the internal timing of LVGL.
6. Call `lv_init()`
7. Create a display buffer for LVGL
```c
static lv_disp_buf_t disp_buf;
static lv_color_t buf[LV_HOR_RES_MAX * 10]; /*Declare a buffer for 10 lines*/
lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
```
8. Implement and register a function which can copy a pixel array to an area of your display:
```c
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
disp_drv.flush_cb = my_disp_flush; /*Set your driver function*/
disp_drv.buffer = &disp_buf; /*Assign the buffer to the display*/
lv_disp_drv_register(&disp_drv); /*Finally register the driver*/
void my_disp_flush(lv_disp_t * disp, const lv_area_t * area, lv_color_t * color_p)
{
int32_t x, y;
for(y = area->y1; y <= area->y2; y++) {
for(x = area->x1; x <= area->x2; x++) {
my_set_pixel(x, y, *color_p); /* Put a pixel to the display.*/
color_p++;
}
}
lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/
}
```
9. Implement and register a function which can read an input device. E.g. for a touch pad:
```c
lv_indev_drv_init(&indev_drv); /*Descriptor of a input device driver*/
indev_drv.type = LV_INDEV_TYPE_POINTER; /*Touch pad is a pointer-like device*/
indev_drv.read_cb = my_touchpad_read; /*Set your driver function*/
lv_indev_drv_register(&indev_drv); /*Finally register the driver*/
bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
{
data->state = my_touchpad_is_pressed() ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL;
if(data->state == LV_INDEV_STATE_PR) touchpad_get_xy(&data->point.x, &data->point.y);
return false; /*Return `false` because we are not buffering and no more data to read*/
}
```
10. Call `lv_task_handler()` periodically every few milliseconds in the main `while(1)` loop, in Timer interrupt or in an Operation system task.
It will redraw the screen if required, handle input devices etc.
For more detailed desription visit the [Porting](https://docs.lvgl.io/v7/en/html/porting/index.html) section of the documentation.
## Learn the basics
In this section you can read the very basics of LVGL.
For a more detailed guide check the [Quick overview](https://docs.lvgl.io/v7/en/html/get-started/quick-overview.html#learn-the-basics) in the documentation.
### Widgets (Objects)
The graphical elements like Buttons, Labels, Sliders, Charts etc are called objects or widgets in LVGL. Go to [Widgets](https://docs.lvgl.io/v7/en/html/widgets/index) to see the full list of available types.
Every object has a parent object. The child object moves with the parent and if you delete the parent the children will be deleted too. Children can be visible only on their parent.
The *screen* are the "root" parents. To get the current screen call `lv_scr_act()`.
You can create a new object with `lv_<type>_create(parent, obj_to_copy)`. It will return an `lv_obj_t *` variable which should be used as a reference to the object to set its parameters later.
The first parameter is the desired *parent*, the second parameters can be an object to copy (`NULL` if unused).
For example:
```c
lv_obj_t * slider1 = lv_slider_create(lv_scr_act(), NULL);
```
To set some basic attribute `lv_obj_set_<paramters_name>(obj, <value>)` function can be used. For example:
```c
lv_obj_set_x(btn1, 30);
lv_obj_set_y(btn1, 10);
lv_obj_set_size(btn1, 200, 50);
```
The objects have type specific parameters too which can be set by `lv_<type>_set_<paramters_name>(obj, <value>)` functions. For example:
```c
lv_slider_set_value(slider1, 70, LV_ANIM_ON);
```
To see the full API visit the documentation of the object types or the related header file (e.g. `lvgl/src/lv_objx/lv_slider.h`).
To create a new screen pass `NULL` as the fisrt paramater of a *create* function:
```c
lv_obj_t * scr2 = lv_obj_create(NULL, NULL); /*Create a screen*/
lv_scr_load(scr2); /*Load the new screen*/
```
### Styles
Widgets are created with a default appearance but it can be changed by adding new styles to them. A new style can be created like this:
```c
static lv_style_t style1; /*Should be static, global or dynamically allocated*/
lv_style_init(&style1);
lv_style_set_bg_color(&style1, LV_STATE_DEFAULT, LV_COLOR_RED); /*Default background color*/
lv_style_set_bg_color(&style1, LV_STATE_PRESSED, LV_COLOR_BLUE); /*Pressed background color*/
```
The wigedt have *parts* which can be referenced via `LV_<TYPE>_PART_<PART_NAME>`. E.g. `LV_BTN_PART_MAIN` or `LV_SLIDER_PART_KNOB`. See the documentation of the widgets to see the exisitng parts.
To add the style to a button:
```c
lv_obj_add_style(btn1, LV_BTN_PART_MAIN, &style1);
```
To remove all styles from a part of an object:
```cc
lv_obj_reset_style_list(obj, LV_OBJ_PART_MAIN);
```
Learn more in [Style overview](https://docs.lvgl.io/v7/en/html/overview/style) section.
### Events
Events are used to inform the user if something has happened with an object. You can assign a callback to an object which will be called if the object is clicked, released, dragged, being deleted etc. It should look like this:
```c
lv_obj_set_event_cb(btn, btn_event_cb); /*Assign a callback to the button*/
...
void btn_event_cb(lv_obj_t * btn, lv_event_t event)
{
if(event == LV_EVENT_CLICKED) {
printf("Clicked\n");
}
}
```
Learn more about the events in the [Event overview](https://docs.lvgl.io/v7/en/html/overview/event) section.
- [Infineon Aurix](https://github.com/lvgl/lv_port_aurix)
- Nordic NRF52 Bluetooth modules
- Quectel modems
## Get started
This list shows the recommended way of learning the library:
1. Check the [Online demos](https://lvgl.io/demos) to see LVGL in action (3 minutes)
2. Read the [Introduction](https://docs.lvgl.io/latest/en/html/intro/index.html) page of the documentation (5 minutes)
3. Get familiar with the basics on the [Quick overview](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html) page (15 minutes)
4. Set up a [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) (10 minutes)
5. Try out some [Examples](https://github.com/lvgl/lv_examples/)
6. Port LVGL to a board. See the [Porting](https://docs.lvgl.io/latest/en/html/porting/index.html) guide or check the ready to use [Projects](https://github.com/lvgl?q=lv_port_&type=&language=)
7. Read the [Overview](https://docs.lvgl.io/latest/en/html/overview/index.html) page to get a better understanding of the library (2-3 hours)
8. Check the documentation of the [Widgets](https://docs.lvgl.io/latest/en/html/widgets/index.html) to see their features and usage
9. If you have questions go to the [Forum](http://forum.lvgl.io/)
10. Read the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) guide to see how you can help to improve LVGL (15 minutes)
## Examples
For more examples see the [lv_examples](https://github.com/lvgl/lv_examples) repository.
### Button with label
```c
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button the current screen*/
@@ -248,10 +138,10 @@ void btn_event_cb(lv_obj_t * btn, lv_event_t event)
}
}
```
![LVGL button with label example](https://docs.lvgl.io/v7/en/misc/simple_button_example.gif)
![LVGL button with label example](https://raw.githubusercontent.com/lvgl/docs/latest/misc/simple_button_example.gif)
### Use LVGL from Micropython
Learn more about [Micropython](https://docs.lvgl.io/en/html/get-started/micropython).
### LVGL from Micropython
Learn more about [Micropython](https://docs.lvgl.io/latest/en/html/get-started/micropython.html).
```python
# Create a Button and a Label
scr = lv.obj()
@@ -264,38 +154,7 @@ label.set_text("Button")
lv.scr_load(scr)
```
## Release policy
LVGL follows the rules of [Semantic versioning](https://semver.org/):
- Major versions for incompatible API changes. E.g. v5.0.0, v6.0.0
- Minor version for new but backward-compatible functionalities. E.g. v6.1.0, v6.2.0
- Patch version for backward-compatible bug fixes. E.g. v6.1.1, v6.1.2
Branches:
- `master` most recent version, patches are merged directly here.
- `dev` merge new features here until they are merged into `master`.
- `release/vX` there is a branch for every major version to allow adding specific, not forward compatible fixes.
LVGL has a monthly periodic release cycle.
- **1st Tuesday of the month**
  - Make a major, minor, or patch release from `master` depending on the new features.
  - After that merge only patches into `master` and add new features into the `dev`.
- **3rd Tuesday of the month**
  - Make a patch release from `master`.
  - After that merge the new features from the `dev` to `master` branch.
  - In the rest of the month merge only patches into `master` and new features into `dev` branch.
## Contributing
To ask questions please use the [Forum](https://forum.lvgl.io).
For development-related things (bug reports, feature suggestions) use [GitHub's Issue tracker](https://github.com/lvgl/lvgl/issues).
LVGL is an open project and contribution is very welcome. There are many ways to contribute from simply speaking about your project, through writing examples, improving the documentation, fixing bugs to hosing your own project under in LVGL.
If you are interested in contributing to LVGL you can
- **Help others** in the [Forum](https://forum.lvgl.io).
- **Inspire people** by speaking about your project in [My project](https://forum.lvgl.io/c/my-projects) category in the Forum.
- **Improve and/or translate the documentation.** Go to the [Documentation](https://github.com/lvgl/docs) repository to learn more
- **Write a blog post** about your experiences. See how to do it in the [Blog](https://github.com/lvgl/blog) repository
- **Report and/or fix bugs** in [GitHub's issue tracker](https://github.com/lvgl/lvgl/issues)
- **Help in the developement**. Check the [Open issues](https://github.com/lvgl/lvgl/issues) especially the ones with [Help wanted](https://github.com/lvgl/lvgl/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) label and tell your ideas about a topic or implement a feature.
Before sending Pull requests, please read the following guides:
- [Contributing guide](https://github.com/lvgl/lvgl/blob/master/docs/CONTRIBUTING.md)
- [Coding style guide](https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md)
For a detailed description of contribution opportunities visit the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) section of the documentation.

29
a.patch Normal file
View File

@@ -0,0 +1,29 @@
diff --git a/scripts/release.py b/scripts/release.py
index 28370c66..bc5234e7 100755
--- a/scripts/release.py
+++ b/scripts/release.py
@@ -395,12 +395,12 @@ def docs_update_dev_version():
os.chdir("../")
-def publish_dev():
+def publish_dev_and_master():
pub_cmd = "git checkout dev; git push origin dev"
cmd("cd lvgl; " + pub_cmd)
+ pub_cmd = "git checkout master; git push origin master"
+ cmd("cd lvgl; " + pub_cmd)
- pub_cmd = "git checkout dev; git push origin dev"
- cmd("cd docs; " + pub_cmd)
cmd("cd docs; git checkout master; ./update.py latest dev")
def cleanup():
@@ -463,7 +463,7 @@ if __name__ == '__main__':
lvgl_update_dev_version()
docs_update_dev_version()
- publish_dev()
+ publish_dev_and_master()
cleanup()

View File

@@ -1,114 +1,5 @@
# Contributing to LVGL
Thank you for considering contributing to LVGL. If you have some spare time to spend with programming you will certainly find a way to helpimproving LVGL. Do not afraid to take the first step! Everybody is welcome independently from gender, age, color, location, or skill level. So don't be shy, pick a point from the list below that you are interested in, and let's go! :rocket:
Thank you for considering contributing to LVGL.
- [Overview](#overview)
- [How to send a pull request?](#how-to-send-a-pull-request)
- [Help others in the Forum](help-others-in-the-forum)
- [Improve or translate the documentation](#improve-or-translate-the-documentation)
- [Write a blog post](#write-a-blog-post)
- [Report or fix bugs](#report-or-fix-bugs)
- [Suggest or implement new features](#suggest-or-implement-new-features)
- [Summary](#summary)
## Overview
There are many ways to join the community. If you have some time to work with us you will surely find something that fits you! You can:
- **Help others** in the [Forum](https://forum.lvgl.io).
- **Inspire people** by speaking about your project in [My project](https://forum.lvgl.io/c/my-projects) category in the Forum.
- **Improve and/or translate the documentation.** Go to the [Documentation](https://github.com/lvgl/docs) repository to learn more.
- **Write a blog post** about your experiences. See how to do it in the [Blog](https://github.com/lvgl/blog) repository
- **Report and/or fix bugs** in [GitHub's issue tracker](https://github.com/lvgl/lvgl/issues)
- **Help the development**. Check the [Open issues](https://github.com/lvgl/lvgl/issues) especially the ones with [Help wanted](https://github.com/lvgl/lvgl/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) label and tell your ideas about a topic or implement a feature.
We have some simple rules:
- Be kind and friendly.
- Speak about one thing in one issue/topic.
- Give feedback and close the issue or mark the topic as solved if your question is answered.
- Tell what you experience or expect. _"The button is not working"_ is not enough info to get help.
- Use [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to format your post.
- We use the [Forum](https://forum.lvgl.io/) to ask and answer questions and [GitHub's issue tracker](https://github.com/lvgl/lvgl/issues) for development-related discussion.
- If possible send an absolute minimal code example in order to reproduce the issue
## How to send a pull request?
Merging new code into LVGL, documentation, blog, and examples happens via *Pull requests*. If you are still not familiar with Pull Requests (PR for short) here is a short guide. It's about the `lvgl` repository but it works the same way for other repositories too.
1. **Fork** the [lvgl repository](https://github.com/lvgl/lvgl). To do this click the "Fork" button in the top right corner. It will "copy" the `lvgl` repository to your GitHub account (`https://github.com/your_name?tab=repositories`)
2. **Clone** the forked repository and add your changes
3. **Create a PR** on GitHub from the page of your `lvgl` repository (`https://github.com/your_name/lvgl`) by hitting the "New pull request" button
4. **Set the base branch**. It means where you want to merge your update. Fixes go to `master`, new features to feature branch.
5. **Describe** what is in the update. An example code is welcome if applicable.
6. **Update** your `lvgl` branch with new commits. They will appear in the PR too.
Some advice:
- For non-trivial fixes and features it's better open an issue first to discuss the details.
- Maybe your fix or update won't be perfect at first. Don't be afraid, just improve it and push the new commits. The PR will be updated accordingly.
- If your update needs some extra work it's okay to say: _"I'm busy now and I will improve it soon"_ or _"Sorry, I don't have time to improve it, I hope it helps in this form too"_.
So it's better to say don't have time to continue than saying nothing.
- Please read and follow this [guide about the coding style](https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md)
## Help others in the Forum
It's a great way to contribute to the library if you already use it.
Just go to [https://forum.lvgl.io/](https://forum.lvgl.io/) a register (Google and GitHub login also works).
Log in, read the titles and if you are already familiar with a topic, don't be shy, and write your suggestion.
## Improve or translate the documentation
If you would like to contribute to LVGL the documentation is the best place to start.
### Fix typos, add missing parts
If you find a typo, an obscure sentence or something which is not explained well enough in the [English documentation](https://docs.lvgl.io/en/html/index.html)
click the *"Edit on GitHub"* button in the top right corner and fix the issue by sending a Pull Request.
### Translate the documentation
If you have time and interest you can translate the documentation to your native language or any language you speak well.
You can join others to work on an already existing language or you can start a new one.
To translate the documentation we use [Zanata](https://zanata.org) which is an online translation platform.
You will find the LVGL project here: [LVGL on Zanata](https://translate.zanata.org/iteration/view/littlevgl-docs/v6.0-doc1?dswid=3430)
To get started you need to:
- register at [Zanata](https://zanata.org) which is an online translation platform.
- comment to [this post](https://forum.lvgl.io/t/translate-the-documentation/238?u=kisvegabor)
- tell your username at *Zanata* and your selected language(s) to get permission the edit the translations
Note that a translation will be added to the documentation only if the following parts are translated:
- [Home page](https://docs.lvgl.io/en/v7/)
- [Porting section](https://docs.lvgl.io/en/v7/html/porting/index.html)
- [Quick overview](https://docs.lvgl.io/v7/en/html/get-started/quick-overview.html)
## Write a blog post
Have you ported LVGL to a new platform or created a fancy GUI? Do you know a great trick?
You can share your knowledge on LVGL's blog! It's super easy to add your own post:
- Fork and clone the [blog repository](https://github.com/lvgl/blog)
- Add your post in Markdown to the `_posts` folder.
- Store the images and other resources in a dedicated folder in `assets`
- Create a Pull Request
The blog uses [Jekyll](https://jekyllrb.com/) to convert the `.md` files to a webpage. You can easily [run Jekyll offline](https://jekyllrb.com/docs/) to check your post before creating the Pull request
## Report or fix bugs
For simple bugfixes (typos, missing error handling, fixing a warning) it's fine to send a Pull request directly. However, for more complex bugs it's better to open an issue first. In the issue, you should describe how to reproduce the bug and add the minimal code snippet.
## Suggest or implement new features
If you have a good idea don't hesitate to share with us. It's even better if you have time to deal with its implementation. Don't be afraid if you still don't know LVGL well enough. We will help you to get started.
To share your ideas use [Feature request](https://forum.lvgl.io/c/feature-request/9) category of the forum.
If you are ready to get involved into the development of this faetures feel free to pen a [new issue](https://github.com/lvgl/lvgl/issues) for it on GitHub.
During the implementation don't forget the [Code style guide](https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md).
If you implemented a new feature it's important to record it in the documentation and if applicable create an example for it:
- Go to the [docs](https://github.com/lvgl/docs/tree/master/v7/en) repository and update the relevant part of the English documentation.
- Go to the [examples](https://github.com/lvgl/lv_examples) repository and add a new file about the new feature in the related directory.
## Summary
I hope you have taken a liking to contribute to LVGL. A helpful and friendly community is waiting for you! :)
For a detailed description of contribution opportunities, please visit the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) section of the documentation.

42
docs/ROADMAP.md Normal file
View File

@@ -0,0 +1,42 @@
# Roadmap
This is a summary for thenew fatures of the major releases and a collection of ideas.
This list indicates only the current intention and can be changed.
## v8
Planned to September/October 2020
- New scrolling:
- See [feat/new-scroll](https://github.com/lvgl/lvgl/tree/feat/new-scroll) branch and [#1614](https://github.com/lvgl/lvgl/issues/1614)) issue.
- Remove `lv_page` and support scrolling on `lv_obj`
- Support "elastic" scrolling when scrolled in
- Support scroll chaining among any objects types (not only `lv_pages`s)
- Remove `lv_drag`. Similar effect can be achieved by setting the position in `LV_EVENT_PRESSING`
- Add snapping
- Add snap stop to scroll max 1 snap point
- Already working
- New layouts:
- See [#1615](https://github.com/lvgl/lvgl/issues/1615) issue
- [CSS Grid](https://css-tricks.com/snippets/css/a-guide-to-grid/)-like layout support
- Work in progress
- Simplified File system interface ([feat/new_fs_api](https://github.com/lvgl/lvgl/tree/feat/new-fs-api) branch) to make porting easier
- Work in progress
- Remove the align parameter from `lv_canvas_draw_text`
- RGB888 support [#1722](https://github.com/lvgl/lvgl/issues/1722)
## v8.1
- Add radio button widget
## v9
- Simplify `group`s. Discussion is [here](https://forum.lvgl.io/t/lv-group-tabindex/2927/3).7
- Unit testing (gtest?). See [#1658](https://github.com/lvgl/lvgl/issues/1658)
- Benchmarking (gem5?). See [#1660](https://github.com/lvgl/lvgl/issues/1660)
## Ideas
- CPP binding. See [Forum](https://forum.lvgl.io/t/is-it-possible-to-officially-support-optional-cpp-api/2736)
- Optmize font decompression
- Switch to RGBA colors in styles
- Need coverage report for tests
- Need static analize (via coverity.io or somehing else)
- Support dot_begin and dot_middle long modes for labels
- Add new label alignment modes. [#1656](https://github.com/lvgl/lvgl/issues/1656)

View File

@@ -0,0 +1,119 @@
#include <lvgl.h>
#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI(); /* TFT instance */
static lv_disp_buf_t disp_buf;
static lv_color_t buf[LV_HOR_RES_MAX * 10];
#if USE_LV_LOG != 0
/* Serial debugging */
void my_print(lv_log_level_t level, const char * file, uint32_t line, const char * dsc)
{
Serial.printf("%s@%d->%s\r\n", file, line, dsc);
Serial.flush();
}
#endif
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);
tft.startWrite();
tft.setAddrWindow(area->x1, area->y1, w, h);
tft.pushColors(&color_p->full, w * h, true);
tft.endWrite();
lv_disp_flush_ready(disp);
}
/*Read the touchpad*/
bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
{
uint16_t touchX, touchY;
bool touched = tft.getTouch(&touchX, &touchY, 600);
if(!touched)
{
data->state = LV_INDEV_STATE_REL;
return false;
}
else
{
data->state = LV_INDEV_STATE_PR;
}
if(touchX>screenWidth || touchY > screenHeight)
{
Serial.println("Y or y outside of expected parameters..");
Serial.print("y:");
Serial.print(touchX);
Serial.print(" x:");
Serial.print(touchY);
}
else
{
/*Set the coordinates*/
data->point.x = touchX;
data->point.y = touchY;
Serial.print("Data x");
Serial.println(touchX);
Serial.print("Data y");
Serial.println(touchY);
}
return false; /*Return `false` because we are not buffering and no more data to read*/
}
void setup()
{
Serial.begin(115200); /* prepare for possible serial debug */
lv_init();
#if USE_LV_LOG != 0
lv_log_register_print_cb(my_print); /* register print function for debugging */
#endif
tft.begin(); /* TFT init */
tft.setRotation(1); /* Landscape orientation */
uint16_t calData[5] = { 275, 3620, 264, 3532, 1 };
tft.setTouch(calData);
lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10);
/*Initialize the display*/
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.hor_res = 320;
disp_drv.ver_res = 240;
disp_drv.flush_cb = my_disp_flush;
disp_drv.buffer = &disp_buf;
lv_disp_drv_register(&disp_drv);
/*Initialize the (dummy) input device driver*/
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_touchpad_read;
lv_indev_drv_register(&indev_drv);
/* Try an example from the lv_examples repository
* https://github.com/lvgl/lv_examples*/
lv_ex_btn_1();
}
void loop()
{
lv_task_handler(); /* let the GUI do its work */
delay(5);
}

View File

@@ -0,0 +1,44 @@
# Example for lv_arduino using a slider
This example has the screen set to 320x480 (ILI9488), change this by altering the following lines in the main ino file:
```C
int screenWidth = 480;
int screenHeight = 320;
```
## Backlight
Change pin 32 to your preferred backlight pin using a PNP transistor (2N3906) or remove the following code and connect directly to +ve:
```C
ledcSetup(10, 5000/*freq*/, 10 /*resolution*/);
ledcAttachPin(32, 10);
analogReadResolution(10);
ledcWrite(10,768);
```
## Theme selection
Change the following to change the theme:
```C
lv_theme_t * th = lv_theme_night_init(210, NULL); //Set a HUE value and a Font for the Night Theme
lv_theme_set_current(th);
```
## Calibration
This is using the bodmer tft_espi driver for touch. To correctly set the calibration load the calibration sketch and replace the following with your values:
```C
uint16_t calData[5] = { 275, 3620, 264, 3532, 1 };
```
## Screen rotation
Check the following if you need to alter your screen rotation:
```C
tft.setRotation(3);
```

View File

@@ -0,0 +1,37 @@
# LVGL Arduino examples
LVGL can be installed via Arduino IDE Library Manager or as an .ZIP library.
It will install [lv_exmaples](https://github.com/lvgl/lv_examples) which contains a lot of examples and demos to try LVGL.
## Example
There are simple examples which use the [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) library as a TFT driver to simplify testing.
To get all this to work you have to setup TFT_eSPI to work with your TFT display type via editing the `User_Setup.h` file in TFT_eSPI library folder, or by selecting your own configurtion in the `User_Setup_Select.h` file in TFT_eSPI library folder.
LVGL library has its own configuration file called `lv_conf.h`. When LVGL is installed to followings needs to be done to configure it:
1. Go to directory of the installed Arduno libraries
2. Go to `lvgl` and copy `lv_conf_template.h` as `lv_conf.h` next to the `src` folder.
3. Open `lv_conf.h` and change the first `#if 0` to `#if 1`
4. Set the resolution of your display in `LV_HOR_RES_MAX` and `LV_VER_RES_MAX`
5. Set the color depth of you display in `LV_COLOR_DEPTH`
6. Set `LV_TICK_CUSTOM 1`
## Debugging
In case of trouble there are debug informations inside LVGL. In the `ESP32_TFT_eSPI` example there is `my_print` method, which allow to send this debug informations to the serial interface. To enable this feature you have to edit `lv_conf.h` file and enable logging in section `log settings`:
```c
/*Log settings*/
#define USE_LV_LOG 1 /*Enable/disable the log module*/
#if LV_USE_LOG
/* How important log should be added:
* LV_LOG_LEVEL_TRACE A lot of logs to give detailed information
* LV_LOG_LEVEL_INFO Log important events
* LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem
* LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
* LV_LOG_LEVEL_NONE Do not log anything
*/
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
```
After enabling log module and setting LV_LOG_LEVEL accordingly the output log is sent to the `Serial` port @ 115200 Bd.

View File

@@ -54,7 +54,9 @@ void lv_port_disp_init(void)
* Create a buffer for drawing
*----------------------------*/
/* LVGL requires a buffer where it draws the objects. The buffer's has to be greater than 1 display row
/* LVGL requires a buffer where it internally draws the widgets.
* Later this buffer will passed your display drivers `flush_cb` to copy its content to your dispay.
* The buffer has to be greater than 1 display row
*
* There are three buffering configurations:
* 1. Create ONE buffer with some rows:
@@ -73,21 +75,21 @@ void lv_port_disp_init(void)
* */
/* Example for 1) */
static lv_disp_buf_t disp_buf_1;
static lv_color_t buf1_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/
lv_disp_buf_init(&disp_buf_1, buf1_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
static lv_disp_buf_t draw_buf_dsc_1;
static lv_color_t draw_buf_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/
lv_disp_buf_init(&draw_buf_dsc_1, draw_buf_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
/* Example for 2) */
static lv_disp_buf_t disp_buf_2;
static lv_color_t buf2_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/
static lv_color_t buf2_2[LV_HOR_RES_MAX * 10]; /*An other buffer for 10 rows*/
lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
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*/
/* Example for 3) */
static lv_disp_buf_t disp_buf_3;
static lv_color_t buf3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*A screen sized buffer*/
static lv_color_t buf3_2[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*An other screen sized buffer*/
lv_disp_buf_init(&disp_buf_3, buf3_1, buf3_2, LV_HOR_RES_MAX * LV_VER_RES_MAX); /*Initialize the display buffer*/
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*/
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*/
/*-----------------------------------
@@ -107,7 +109,7 @@ void lv_port_disp_init(void)
disp_drv.flush_cb = disp_flush;
/*Set a display buffer*/
disp_drv.buffer = &disp_buf_2;
disp_drv.buffer = &draw_buf_dsc_1;
#if LV_USE_GPU
/*Optionally add functions to access the GPU. (Only in buffered mode, LV_VDB_SIZE != 0)*/

View File

@@ -1,14 +1,17 @@
{
"name": "lvgl",
"version": "v7.0.2",
"keywords": "graphics, gui, embedded, littlevgl",
"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":
{
"type": "git",
"url": "https://github.com/lvgl/lvgl.git"
},
"build": {
"includeDir": "."
}
"name": "lvgl",
"version": "7.5.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": {
"type": "git",
"url": "https://github.com/lvgl/lvgl.git"
},
"build": {
"includeDir": "."
},
"license": "MIT",
"homepage": "https://lvgl.io",
"frameworks": "*",
"platforms": "*"
}

10
library.properties Normal file
View File

@@ -0,0 +1,10 @@
name=lvgl
version=7.5.0
author=kisvegabor
maintainer=kisvegabor,embeddedt,pete-pjb
sentence=Full-featured Graphics Library for Embedded Systems
paragraph=Powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash).
category=Display
url=https://lvgl.io
architectures=*
includes=lvgl.h

View File

@@ -1,6 +1,6 @@
/**
* @file lv_conf.h
* Configuration file for LVGL v7.0.2
* Configuration file for v7.5.0-dev
*/
/*
@@ -97,6 +97,10 @@ typedef int16_t lv_coord_t;
# define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
#endif /*LV_MEM_CUSTOM*/
/* Use the standard memcpy and memset instead of LVGL's own functions.
* The standard functions might or might not be faster depending on their implementation. */
#define LV_MEMCPY_MEMSET_STD 0
/* Garbage Collector settings
* Used if lvgl is binded to higher level language and the memory is managed by that language */
#define LV_ENABLE_GC 0
@@ -150,7 +154,7 @@ typedef void * lv_anim_user_data_t;
#endif
/* 1: Enable shadow drawing*/
/* 1: Enable shadow drawing on rectangles*/
#define LV_USE_SHADOW 1
#if LV_USE_SHADOW
/* Allow buffering some shadow calculation
@@ -160,6 +164,15 @@ typedef void * lv_anim_user_data_t;
#define LV_SHADOW_CACHE_SIZE 0
#endif
/*1: enable outline drawing on rectangles*/
#define LV_USE_OUTLINE 1
/*1: enable pattern drawing on rectangles*/
#define LV_USE_PATTERN 1
/*1: enable value string drawing on rectangles*/
#define LV_USE_VALUE_STR 1
/* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`)*/
#define LV_USE_BLEND_MODES 1
@@ -178,6 +191,9 @@ typedef void * lv_group_user_data_t;
/* 1: Enable GPU interface*/
#define LV_USE_GPU 1 /*Only enables `gpu_fill_cb` and `gpu_blend_cb` in the disp. drv- */
#define LV_USE_GPU_STM32_DMA2D 0
/*If enabling LV_USE_GPU_STM32_DMA2D, LV_GPU_DMA2D_CMSIS_INCLUDE must be defined to include path of CMSIS header of target processor
e.g. "stm32f769xx.h" or "stm32f429xx.h" */
#define LV_GPU_DMA2D_CMSIS_INCLUDE
/* 1: Enable file system (might be required for images */
#define LV_USE_FILESYSTEM 1
@@ -194,6 +210,7 @@ typedef void * lv_fs_drv_user_data_t;
/*1: Use the functions and types from the older API if possible */
#define LV_USE_API_EXTENSION_V6 1
#define LV_USE_API_EXTENSION_V7 1
/*========================
* Image decoder and cache
@@ -219,6 +236,10 @@ typedef void * lv_img_decoder_user_data_t;
/*=====================
* Compiler settings
*====================*/
/* For big endian systems set to 1 */
#define LV_BIG_ENDIAN_SYSTEM 0
/* Define a custom attribute to `lv_tick_inc` function */
#define LV_ATTRIBUTE_TICK_INC
@@ -249,6 +270,10 @@ typedef void * lv_img_decoder_user_data_t;
*/
#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning
/* Prefix variables that are used in GPU accelerated operations, often these need to be
* placed in RAM sections that are DMA accessible */
#define LV_ATTRIBUTE_DMA
/*===================
* HAL settings
*==================*/
@@ -257,8 +282,8 @@ typedef void * lv_img_decoder_user_data_t;
* It removes the need to manually update the tick with `lv_tick_inc`) */
#define LV_TICK_CUSTOM 0
#if LV_TICK_CUSTOM == 1
#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
#endif /*LV_TICK_CUSTOM*/
typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/
@@ -337,8 +362,8 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
/* Montserrat fonts with bpp = 4
* https://fonts.google.com/specimen/Montserrat */
#define LV_FONT_MONTSERRAT_12 0
#define LV_FONT_MONTSERRAT_14 0
#define LV_FONT_MONTSERRAT_16 1
#define LV_FONT_MONTSERRAT_14 1
#define LV_FONT_MONTSERRAT_16 0
#define LV_FONT_MONTSERRAT_18 0
#define LV_FONT_MONTSERRAT_20 0
#define LV_FONT_MONTSERRAT_22 0
@@ -379,11 +404,20 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
* but with > 10,000 characters if you see issues probably you need to enable it.*/
#define LV_FONT_FMT_TXT_LARGE 0
/* Enables/disables support for compressed fonts. If it's disabled, compressed
* glyphs cannot be processed by the library and won't be rendered.
*/
#define LV_USE_FONT_COMPRESSED 1
/* Enable subpixel rendering */
#define LV_USE_FONT_SUBPX 1
#if LV_USE_FONT_SUBPX
/* Set the pixel order of the display.
* Important only if "subpx fonts" are used.
* With "normal" font it doesn't matter.
*/
#define LV_FONT_SUBPX_BGR 0
#endif
/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/
typedef void * lv_font_user_data_t;
@@ -405,7 +439,10 @@ typedef void * lv_font_user_data_t;
/* A fast and impressive theme.
* Flags:
* LV_THEME_MATERIAL_FLAG_LIGHT: light theme
* LV_THEME_MATERIAL_FLAG_DARK: dark theme*/
* LV_THEME_MATERIAL_FLAG_DARK: dark theme
* LV_THEME_MATERIAL_FLAG_NO_TRANSITION: disable transitions (state change animations)
* LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state)
* */
#define LV_USE_THEME_MATERIAL 1
/* Mono-color theme for monochrome displays.
@@ -417,13 +454,13 @@ typedef void * lv_font_user_data_t;
#define LV_THEME_DEFAULT_INCLUDE <stdint.h> /*Include a header for the init. function*/
#define LV_THEME_DEFAULT_INIT lv_theme_material_init
#define LV_THEME_DEFAULT_COLOR_PRIMARY LV_COLOR_RED
#define LV_THEME_DEFAULT_COLOR_SECONDARY LV_COLOR_BLUE
#define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0x01a2b1)
#define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0x44d1b6)
#define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_14
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_14
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_14
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_14
/*=================
* Text settings
@@ -529,6 +566,9 @@ typedef void * lv_obj_user_data_t;
/*Calendar (dependencies: -)*/
#define LV_USE_CALENDAR 1
#if LV_USE_CALENDAR
# define LV_CALENDAR_WEEK_STARTS_MONDAY 0
#endif
/*Canvas (dependencies: lv_img)*/
#define LV_USE_CANVAS 1
@@ -613,7 +653,7 @@ typedef void * lv_obj_user_data_t;
* 1: Some extra precision
* 2: Best precision
*/
# define LV_LINEMETER_PRECISE 0
# define LV_LINEMETER_PRECISE 1
#endif
/*Mask (dependencies: -)*/

19
lvgl.h
View File

@@ -2,7 +2,7 @@
* @file lvgl.h
* Include all LittleV GL related headers
*/
#ifndef LVGL_H
#define LVGL_H
@@ -10,6 +10,15 @@
extern "C" {
#endif
/***************************
* CURRENT VERSION OF LVGL
***************************/
#define LVGL_VERSION_MAJOR 7
#define LVGL_VERSION_MINOR 5
#define LVGL_VERSION_PATCH 0
#define LVGL_VERSION_INFO ""
/*********************
* INCLUDES
*********************/
@@ -31,6 +40,7 @@ extern "C" {
#include "src/lv_themes/lv_theme.h"
#include "src/lv_font/lv_font.h"
#include "src/lv_font/lv_font_loader.h"
#include "src/lv_font/lv_font_fmt_txt.h"
#include "src/lv_misc/lv_printf.h"
@@ -72,14 +82,11 @@ extern "C" {
#include "src/lv_api_map.h"
//#define LV_BUILD_TEST 1
/*********************
* DEFINES
*********************/
/*Current version of LVGL*/
#define LVGL_VERSION_MAJOR 7
#define LVGL_VERSION_MINOR 0
#define LVGL_VERSION_PATCH 2
#define LVGL_VERSION_INFO ""
/**********************
* TYPEDEFS

View File

@@ -1,12 +1,17 @@
#!/usr/bin/env python3.6
#!/usr/bin/env python3
'''
Generates a checker file for lv_conf.h from lv_conf_templ.h define all the not defined values
'''
import sys
import re
if sys.version_info < (3,6,0):
print("Python >=3.6 is required", file=sys.stderr)
exit(1)
fin = open("../lv_conf_template.h", "r")
fout = open("../src/lv_conf_internal.h", "w")

744
scripts/release.py Normal file → Executable file
View File

@@ -1,263 +1,525 @@
#!/usr/bin/env python
# Release lvgl, lv_examples, lv_drivers. docs, blog and prepare the development of the next major, minoror bugfix release
# Usage: ./release,py bugfix | minor | major
# The option means what type of versin to prepare for development after release
#
# STEPS:
# - clone all 5 repos
# - get the version numnber from lvgl.h
# - set release branch (e.g. "release/v7")
# - prepare lvgl
# - run lv_conf_internal.py
# - run code formatter
# - clear LVGL_VERSION_INFO (set to "")
# - run Doxygen
# - update the version in lvgl's library.json, library.properties, lv_conf_template.h
# - update CHANGELOG.md
# - commit changes
# - prepare lv_examples
# - upadte the required LVGL version in lv_examples.h (LV_VERSION_CHECK)
# - update the version in lv_ex_conf_template.h
# - prepare lv_drivers
# - update the version in library.json, lv_drv_conf_template.h
# - prepare docs
# - update API XML
# - clear the versiopn info (should be plain vx.y.z)
# - tag all repos with the new version
# - merge to release branches
# - blog: add release post
# - push tags and commits
# - docs: run ./updade.py release/vX
#
# If --patch
# - merge master to dev branches
# - increment patch version by 1 and append "-dev". E.g. "vX.Y.(Z+1)-dev"
# - update version numbers in lvgl and docs
# - commit and push
# - docs: run ./updade.py latest dev
#
# Else (not --patch)
# - merge master to dev
# - merge the dev to master
# - increment version number like "vX.(Y+1).0-dev"
# - apply the new version in dev branches of lvgl, lv_examples, lv_drivers, docs
# - commit and push to dev branches
# - docs: run ./updade.py latest dev
import re
import os
lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+')
import os, fnmatch
import os.path
from os import path
from datetime import date
import sys
def title(t):
print("\n---------------------------------")
print(t)
print("---------------------------------")
upstream_org_url = "https://github.com/lvgl/"
workdir = "./release_tmp"
proj_list = [ "lv_sim_eclipse_sdl"]
def cmd(c):
print("\n" + c)
os.system(c)
ver_major = -1
ver_minor = -1
ver_patch = -1
def increment(s):
""" look for the last sequence of number(s) in a string and increment """
m = lastNum.search(s)
if m:
next = str(int(m.group(1))+1)
start, end = m.span(1)
s = s[:max(end-len(next), start)] + next + s[end:]
return s, str(next)
ver_str = ""
dev_ver_str = ""
release_br = ""
release_note = ""
prepare_type = ['major', 'minor', 'bugfix']
def lvgl_clone():
title("lvgl: Clone")
cmd("git clone https://github.com/lvgl/lvgl.git")
os.chdir("./lvgl")
cmd("git co master")
dev_prepare = 'minor'
def lvgl_format():
title("lvgl: Run code formatter")
os.chdir("./scripts")
cmd("./code-formatter.sh")
cmd("git ci -am 'Run code formatter'")
os.chdir("..")
def upstream(repo):
return upstream_org_url + repo + ".git"
def lvgl_update_version():
title("lvgl: Update version number")
f = open("./lvgl.h", "r")
outbuf = ""
major_ver = -1
minor_ver = -1
patch_ver = -1
for i in f.read().splitlines():
r = re.search(r'^#define LVGL_VERSION_MAJOR ', i)
if r:
m = lastNum.search(i)
if m: major_ver = m.group(1)
r = re.search(r'^#define LVGL_VERSION_MINOR ', i)
if r:
m = lastNum.search(i)
if m: minor_ver = m.group(1)
r = re.search(r'^#define LVGL_VERSION_PATCH ', i)
if r:
m = lastNum.search(i)
if m: patch_ver = m.group(1)
r = re.search(r'^#define LVGL_VERSION_INFO ', i)
if r:
i = "#define LVGL_VERSION_INFO \"\""
outbuf += i + '\n'
f.close()
f = open("./lvgl.h", "w")
f.write(outbuf)
f.close()
def cmd(c, exit_on_err = True):
print("\n" + c)
r = os.system(c)
if r:
print("### Error: " + str(r))
if exit_on_err: exit(int(r))
s = "v" + str(major_ver) + "." + str(minor_ver) + "." + str(patch_ver)
print("New version:" + s)
return s
def define_set(fn, name, value):
print("In " + fn + " set " + name + " to " + value)
new_content = ""
s = r'^ *# *define +' + str(name).rstrip()
f = open(fn, "r")
for i in f.read().splitlines():
r = re.search(s, i)
if r:
d = i.split("define")
i = d[0] + "define " + name + " " + value
new_content += i + '\n'
f.close()
f = open(fn, "w")
f.write(new_content)
f.close()
def clone_repos():
cmd("rm -fr " + workdir)
cmd("mkdir " + workdir)
os.chdir(workdir)
#For debuging just copy the repos
#cmd("cp -a ../repos/. .")
#return
cmd("git clone " + upstream("lvgl") + "; cd lvgl; git checkout master")
cmd("git clone " + upstream("lv_examples") + "; cd lv_examples; git checkout master")
cmd("git clone " + upstream("lv_drivers") + "; cd lv_drivers; git checkout master")
cmd("git clone --recurse-submodules " + upstream("docs") + "; cd docs; git checkout master")
cmd("git clone " + upstream("blog") + "; cd blog; git checkout master")
for p in proj_list:
cmd("git clone " + upstream(p) + " --recurse-submodules ; cd " + p + "; git checkout master")
def get_lvgl_version(br):
print("Get LVGL's version")
global ver_str, ver_major, ver_minor, ver_patch, release_br
os.chdir("./lvgl")
cmd("git checkout " + br)
f = open("./lvgl.h", "r")
lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+')
for i in f.read().splitlines():
r = re.search(r'^#define LVGL_VERSION_MAJOR ', i)
if r:
m = lastNum.search(i)
if m: ver_major = m.group(1)
r = re.search(r'^#define LVGL_VERSION_MINOR ', i)
if r:
m = lastNum.search(i)
if m: ver_minor = m.group(1)
r = re.search(r'^#define LVGL_VERSION_PATCH ', i)
if r:
m = lastNum.search(i)
if m: ver_patch = m.group(1)
f.close()
cmd("git checkout master")
ver_str = "v" + str(ver_major) + "." + str(ver_minor) + "." + str(ver_patch)
print("New version:" + ver_str)
release_br = "release/v" + ver_major
os.chdir("../")
def update_version():
templ = fnmatch.filter(os.listdir('.'), '*templ*')
if templ[0]:
print("Updating version in " + templ[0])
cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+/"+ ver_str +"/' " + templ[0])
if os.path.exists("library.json"):
print("Updating version in library.json")
cmd("sed -i -r 's/[0-9]+\.[0-9]+\.[0-9]+/"+ ver_str[1:] +"/' library.json")
if path.exists("library.properties"):
print("Updating version in library.properties")
cmd("sed -i -r 's/version=[0-9]+\.[0-9]+\.[0-9]+/"+ "version=" + ver_str[1:] + "/' library.properties")
def lvgl_prepare():
print("Prepare lvgl")
global ver_str, ver_major, ver_minor, ver_patch
os.chdir("./lvgl")
define_set("./lvgl.h", "LVGL_VERSION_INFO", '\"\"')
# Run some scripts
os.chdir("./scripts")
cmd("./code-format.sh")
cmd("./lv_conf_checker.py")
cmd("doxygen")
os.chdir("../")
update_version()
#update CHANGLELOG
new_content = ""
f = open("./CHANGELOG.md", "r")
global release_note
release_note = ""
note_state = 0
for i in f.read().splitlines():
if note_state == 0:
r = re.search(r'^## ' + ver_str, i)
if r:
i = i.replace("planned on ", "")
note_state+=1
elif note_state == 1:
r = re.search(r'^## ', i)
if r:
note_state+=1
else:
release_note += i + '\n'
new_content += i + '\n'
f.close()
f = open("./CHANGELOG.md", "w")
f.write(new_content)
f.close()
cmd('git commit -am "prepare to release ' + ver_str + '"')
os.chdir("../")
def lv_examples_prepare():
print("Prepare lv_examples")
global ver_str, ver_major, ver_minor, ver_patch
os.chdir("./lv_examples")
update_version()
cmd("sed -i -r 's/LV_VERSION_CHECK\([0-9]+, *[0-9]+, *[0-9]+\)/"+ "LV_VERSION_CHECK(" + ver_major + ", " + ver_minor + ", " + ver_patch + ")/' lv_examples.h")
cmd('git commit -am "prepare to release ' + ver_str + '"')
os.chdir("../")
def lv_drivers_prepare():
print("Prepare lv_drivers")
global ver_str, ver_major, ver_minor, ver_patch
os.chdir("./lv_drivers")
update_version()
cmd('git commit -am "prepare to release ' + ver_str + '"')
os.chdir("../")
def docs_prepare():
print("Prepare docs")
global ver_str, ver_major, ver_minor, ver_patch
os.chdir("./docs")
cmd("git co latest --")
cmd("rm -rf xml");
cmd("cp -r ../lvgl/docs/api_doc/xml .");
cmd("git add xml");
cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" conf.py")
cmd('git commit -am "prepare to release ' + ver_str + '"')
os.chdir("../")
def blog_add_post():
global ver_str, release_note
os.chdir("./blog/_posts")
post = "---\nlayout: post\ntitle: " + ver_str + " is released\nauthor: \"kisvegabor\"\ncover: /assets/release_cover.png\n---\n\n"
post += release_note
today = date.today()
d = today.strftime("%Y-%m-%d")
f = open(d + "-release_" + ver_str + ".md", "w")
f.write(post)
f.close()
cmd("git add .")
cmd("git commit -am 'Add " + ver_str + " release post'")
os.chdir("../../")
def add_tags():
global ver_str
tag_cmd = " git tag -a " + ver_str + " -m 'Release " + ver_str + "' "
cmd("cd lvgl; " + tag_cmd)
cmd("cd lv_examples; " + tag_cmd)
cmd("cd lv_drivers; " + tag_cmd)
cmd("cd docs; " + tag_cmd)
def update_release_branches():
global release_br
merge_cmd = " git checkout " + release_br + "; git pull origin " + release_br + "; git merge master -X ours; git push origin " + release_br + "; git checkout master"
cmd("cd lvgl; " + merge_cmd)
cmd("cd lv_examples; " + merge_cmd)
cmd("cd lv_drivers; " + merge_cmd)
merge_cmd = " git checkout " + release_br + "; git pull origin " + release_br + "; git merge latest -X ours; git push origin " + release_br + "; git checkout latest"
cmd("cd docs; " + merge_cmd)
def publish_master():
#Merge LVGL master to dev first to avoid "merge-to-dev.yml" running asynchronous
os.chdir("./lvgl")
cmd("git checkout dev")
cmd("git merge master -X theirs")
cmd("git add .")
cmd("git commit -am 'Merge master'", False)
cmd("git push origin dev")
cmd("git checkout master")
os.chdir("../")
pub_cmd = "git push origin master; git push origin " + ver_str
cmd("cd lvgl; " + pub_cmd)
cmd("cd lv_examples; " + pub_cmd)
cmd("cd lv_drivers; " + pub_cmd)
pub_cmd = "git push origin latest; git push origin " + ver_str
cmd("cd docs; " + pub_cmd)
cmd("cd docs; git checkout master; python 2.7 ./update.py " + release_br)
pub_cmd = "git push origin master"
cmd("cd blog; " + pub_cmd)
def merge_to_dev():
merge_cmd = "git checkout dev; git pull origin dev; git merge master -X ours; git checkout master"
cmd("cd lvgl; " + merge_cmd)
merge_cmd = "git checkout dev --; git pull origin dev; git merge latest -X ours; git checkout master"
cmd("cd docs; " + merge_cmd)
def merge_from_dev():
merge_cmd = "git checkout master; git merge dev;"
cmd("cd lvgl; " + merge_cmd)
merge_cmd = "git checkout latest -- ; git merge dev;"
cmd("cd docs; " + merge_cmd)
def lvgl_update_master_version():
global ver_major, ver_minor, ver_patch, ver_str
os.chdir("./lvgl")
cmd("git checkout master")
define_set("./lvgl.h", "LVGL_VERSION_MAJOR", ver_major)
define_set("./lvgl.h", "LVGL_VERSION_MINOR", ver_minor)
define_set("./lvgl.h", "LVGL_VERSION_PATCH", ver_patch)
define_set("./lvgl.h", "LVGL_VERSION_INFO", "dev")
templ = fnmatch.filter(os.listdir('.'), '*templ*')
if templ[0]:
print("Updating version in " + templ[0])
cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+.*/"+ ver_str +"/' " + templ[0])
cmd("git commit -am 'Update version'")
os.chdir("../")
def docs_update_latest_version():
global ver_str
os.chdir("./docs")
cmd("git checkout latest --")
cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" conf.py")
cmd("git commit -am 'Update version'")
cmd("git checkout master --")
os.chdir("../")
def lvgl_update_dev_version():
global ver_major, ver_minor, ver_patch, dev_ver_str
os.chdir("./lvgl")
cmd("git checkout dev")
define_set("./lvgl.h", "LVGL_VERSION_MAJOR", str(ver_major))
define_set("./lvgl.h", "LVGL_VERSION_MINOR", str(ver_minor))
define_set("./lvgl.h", "LVGL_VERSION_PATCH", str(ver_patch))
define_set("./lvgl.h", "LVGL_VERSION_INFO", "\"dev\"")
templ = fnmatch.filter(os.listdir('.'), '*templ*')
if templ[0]:
print("Updating version in " + templ[0])
cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+.*/"+ dev_ver_str +"/' " + templ[0])
cmd("git commit -am 'Update dev version'")
cmd("git checkout master")
os.chdir("../")
def docs_update_dev_version():
global dev_ver_str
os.chdir("./docs")
cmd("git checkout dev --")
cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + dev_ver_str + "'/\" conf.py")
cmd("git commit -am 'Update dev version'")
cmd("git checkout master --")
os.chdir("../")
def publish_dev_and_master():
pub_cmd = "git checkout dev; git push origin dev"
cmd("cd lvgl; " + pub_cmd)
pub_cmd = "git checkout master; git push origin master"
cmd("cd lvgl; " + pub_cmd)
def lvgl_update_library_json(v):
title("lvgl: Update version number in library.json")
cmd("cd docs; git checkout master; python 2.7 ./update.py latest dev")
f = open("./library.json", "r")
outbuf = ""
for i in f.read().splitlines():
r = re.search(r'"version": ', i)
if r:
i = ' "version": "' + v + '",'
outbuf += i + '\n'
f.close()
def projs_update():
global proj_list, release_br, ver_str
for p in proj_list:
os.chdir("./" + p)
cmd('git checkout master')
print(p + ": upadte lvgl");
cmd("cd lvgl; git co " + release_br + "; git pull origin " + release_br)
cmd("cp -f lvgl/lv_conf_template.h lv_conf.h")
cmd("sed -i -r 's/#if 0/#if 1/' lv_conf.h") # Enable lv_conf.h
d = {}
with open("confdef.txt") as f:
for line in f:
(key, val) = line.rstrip().split('\t')
d[key] = val
f = open("./library.json", "w")
f.write(outbuf)
f.close()
for k,v in d.items():
define_set("lv_conf.h", str(k), str(v))
if os.path.exists("lv_examples"):
print(p + ": upadte lv_examples");
cmd("cd lv_examples; git co " + release_br + "; git pull origin " + release_br)
if os.path.exists("lv_drivers"):
print(p + ": upadte lv_drivers");
cmd("cd lv_drivers " + release_br + "; git pull origin " + release_br)
def lvgl_update_lv_conf_templ(ver_str):
title("lvgl: Update version number in lv_conf_template.h")
cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+/"+ ver_str +"/' lv_conf_template.h ")
msg = 'Update to ' + ver_str
cmd("git add .")
cmd('git commit -am "' + msg + '"')
cmd('git push origin master')
cmd("git tag -a " + ver_str + " -m '" + msg + "' " )
cmd('git push origin ' + ver_str)
os.chdir("../")
def cleanup():
os.chdir("../")
cmd("rm -fr " + workdir)
def lvgl_commit_push(v):
title("lvgl: commit and push release")
if __name__ == '__main__':
dev_prepare = 'minor'
if(len(sys.argv) != 2):
print("Missing argument. Usage ./release.py bugfix | minor | major")
print("Use minor by deafult")
else:
dev_prepare = sys.argv[1]
if not (dev_prepare in prepare_type):
print("Invalid argument. Usage ./release.py bugfix | minor | major")
exit(1)
clone_repos()
get_lvgl_version("master")
lvgl_prepare()
lv_examples_prepare()
lv_drivers_prepare()
docs_prepare()
blog_add_post()
add_tags()
update_release_branches()
publish_master()
if dev_prepare == 'bugfix':
ver_patch = str(int(ver_patch) + 1)
ver_str = "v" + ver_major + "." + ver_minor + "." + ver_patch + "-dev"
cmd('git ci -am "Release ' + v + '"')
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
cmd('git push origin master')
cmd('git push origin ' + v)
print("Prepare bugfix version " + ver_str)
lvgl_update_master_version()
docs_update_latest_version()
def lvgl_merge_to_release_branch(v):
title("lvgl: merge to release branch")
cmd('git co release/v7')
cmd('git merge master')
cmd('git push origin release/v7')
def lvgl_update_api_docs():
title("lvgl: Update API with Doxygen")
get_lvgl_version("dev")
dev_ver_str = "v" + ver_major + "." + ver_minor + "." + ver_patch + "-dev"
merge_to_dev()
lvgl_update_dev_version()
docs_update_dev_version()
publish_dev()
else:
get_lvgl_version("dev")
if dev_prepare == 'minor':
ver_minor = str(int(ver_minor) + 1)
ver_patch = "0"
else:
ver_major = str(int(ver_major) + 1)
ver_minor = "0"
ver_patch = "0"
dev_ver_str = "v" + str(ver_major) + "." + str(ver_minor) + "." + str(ver_patch) + "-dev"
print("Prepare minor version " + dev_ver_str)
cmd("cd scripts; doxygen");
os.chdir("../")
merge_to_dev()
merge_from_dev()
def examples_clone():
title("examples: Clone")
cmd("git clone https://github.com/lvgl/lv_examples.git")
os.chdir("./lv_examples")
cmd("git co master")
def examples_commit_push(v):
title("examples: commit and push release")
cmd('git ci -am "Release ' + v + '"')
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
cmd('git push origin master')
cmd('git push origin ' + v)
def examples_merge_to_release_branch(v):
title("examples: merge to release branch")
cmd('git co release/v7')
cmd('git merge master')
cmd('git push origin release/v7')
os.chdir("../")
def drivers_clone():
title("drivers: Clone")
cmd("git clone https://github.com/lvgl/lv_drivers.git")
os.chdir("./lv_drivers")
cmd("git co master")
def drivers_commit_push(v):
title("drivers: commit and push release")
cmd('git ci -am "Release ' + v + '"')
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
cmd('git push origin master')
cmd('git push origin ' + v)
def drivers_merge_to_release_branch(v):
title("drivers: merge to release branch")
cmd('git co release/v7')
cmd('git merge master')
cmd('git push origin release/v7')
os.chdir("../")
def docs_clone():
title("docs: Clone")
cmd("git clone --recursive https://github.com/lvgl/docs.git")
os.chdir("./docs/v7")
cmd("git co master")
def docs_get_api():
title("docs: Get API files")
cmd("rm -rf xml");
cmd("cp -r ../../lvgl/docs/api_doc/xml .");
def docs_update_version(v):
title("docs: Update version number")
f = open("./conf.py", "r")
outbuf = ""
for i in f.read().splitlines():
r = re.search(r'^version = ', i)
if r:
i = "version = '" + v + "'"
r = re.search(r'^release = ', i)
if r:
i = "version = '" + v + "'"
outbuf += i + '\n'
f.close()
f = open("./conf.py", "w")
f.write(outbuf)
f.close()
def docs_update_trans():
title("docs: Update translations")
cmd("cd en && ./trans_push.py && ./trans_pull.py")
def docs_build():
title("docs: Build")
cmd("./build.py clean")
def docs_commit_push(v):
title("docs: Commit release")
cmd('git add .')
cmd('git ci -am "Release ' + v + '"')
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
cmd('git push origin master')
cmd('git push origin ' + v)
def clean_up():
title("Clean up repos")
os.chdir("../..")
cmd("rm -rf lvgl docs lv_examples lv_drivers")
lvgl_clone()
lvgl_format()
lvgl_update_api_docs()
ver_str = lvgl_update_version()
lvgl_update_library_json(ver_str)
lvgl_update_lv_conf_templ(ver_str)
lvgl_commit_push(ver_str)
lvgl_merge_to_release_branch(ver_str)
examples_clone()
examples_commit_push(ver_str)
examples_merge_to_release_branch(ver_str)
drivers_clone()
drivers_commit_push(ver_str)
drivers_merge_to_release_branch(ver_str)
docs_clone()
docs_get_api()
docs_update_version(ver_str)
#docs_update_trans() # Zanata is not working now
docs_build()
docs_commit_push(ver_str)
clean_up()
lvgl_update_dev_version()
docs_update_dev_version()
publish_dev_and_master()
projs_update()
cleanup()

View File

@@ -153,7 +153,7 @@ static inline void lv_roller_set_fix_width(lv_obj_t * roller, lv_coord_t w)
#define lv_scrlbar_mode_t lv_scrollbar_mode_t
#define LV_SCRLBAR_MODE_OFF LV_SCROLLBAR_MODE_OFF
#define LV_SCRLBAR_MODE_ON LV_SCRILLBAR_MODE_ON
#define LV_SCRLBAR_MODE_ON LV_SCROLLBAR_MODE_ON
#define LV_SCRLBAR_MODE_DRAG LV_SCROLLBAR_MODE_DRAG
#define LV_SCRLBAR_MODE_AUTO LV_SCROLLBAR_MODE_AUTO
#define LV_SCRLBAR_MODE_HIDE LV_SCROLLBAR_MODE_HIDE
@@ -176,8 +176,56 @@ static inline lv_obj_t * lv_page_get_scrl(lv_obj_t * page)
}
#endif
#endif /*LV_USE_API_EXTENSION_V6*/
/*---------------------
* V7.0 COMPATIBILITY
*--------------------*/
#if LV_USE_API_EXTENSION_V7
#if LV_USE_WIN
static inline lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src)
{
return lv_win_add_btn_right(win, img_src);
}
#endif
#if LV_USE_CHART
static inline void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax)
{
lv_chart_set_y_range(chart, LV_CHART_AXIS_PRIMARY_Y, ymin, ymax);
}
static inline void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * series)
{
lv_chart_clear_series(chart, series);
}
#endif
static inline void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs,
lv_coord_t y_ofs)
{
lv_obj_align_mid(obj, base, align, x_ofs, y_ofs);
}
static inline void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs)
{
lv_obj_align_mid_y(obj, base, align, x_ofs);
}
static inline void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs)
{
lv_obj_align_mid_y(obj, base, align, y_ofs);
}
#endif /*LV_USE_API_EXTENSION_V6*/
/**********************
* MACROS
**********************/

View File

@@ -147,6 +147,12 @@
#endif
#endif /*LV_MEM_CUSTOM*/
/* Use the standard memcpy and memset instead of LVGL's own functions.
* The standard functions might or might not be faster depending on their implementation. */
#ifndef LV_MEMCPY_MEMSET_STD
#define LV_MEMCPY_MEMSET_STD 0
#endif
/* Garbage Collector settings
* Used if lvgl is binded to higher level language and the memory is managed by that language */
#ifndef LV_ENABLE_GC
@@ -223,7 +229,7 @@
#endif
/* 1: Enable shadow drawing*/
/* 1: Enable shadow drawing on rectangles*/
#ifndef LV_USE_SHADOW
#define LV_USE_SHADOW 1
#endif
@@ -237,6 +243,21 @@
#endif
#endif
/*1: enable outline drawing on rectangles*/
#ifndef LV_USE_OUTLINE
#define LV_USE_OUTLINE 1
#endif
/*1: enable pattern drawing on rectangles*/
#ifndef LV_USE_PATTERN
#define LV_USE_PATTERN 1
#endif
/*1: enable value string drawing on rectangles*/
#ifndef LV_USE_VALUE_STR
#define LV_USE_VALUE_STR 1
#endif
/* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`)*/
#ifndef LV_USE_BLEND_MODES
#define LV_USE_BLEND_MODES 1
@@ -266,6 +287,11 @@
#ifndef LV_USE_GPU_STM32_DMA2D
#define LV_USE_GPU_STM32_DMA2D 0
#endif
/*If enabling LV_USE_GPU_STM32_DMA2D, LV_GPU_DMA2D_CMSIS_INCLUDE must be defined to include path of CMSIS header of target processor
e.g. "stm32f769xx.h" or "stm32f429xx.h" */
#ifndef LV_GPU_DMA2D_CMSIS_INCLUDE
#define LV_GPU_DMA2D_CMSIS_INCLUDE
#endif
/* 1: Enable file system (might be required for images */
#ifndef LV_USE_FILESYSTEM
@@ -289,6 +315,9 @@
#ifndef LV_USE_API_EXTENSION_V6
#define LV_USE_API_EXTENSION_V6 1
#endif
#ifndef LV_USE_API_EXTENSION_V7
#define LV_USE_API_EXTENSION_V7 1
#endif
/*========================
* Image decoder and cache
@@ -319,6 +348,12 @@
/*=====================
* Compiler settings
*====================*/
/* For big endian systems set to 1 */
#ifndef LV_BIG_ENDIAN_SYSTEM
#define LV_BIG_ENDIAN_SYSTEM 0
#endif
/* Define a custom attribute to `lv_tick_inc` function */
#ifndef LV_ATTRIBUTE_TICK_INC
#define LV_ATTRIBUTE_TICK_INC
@@ -363,6 +398,12 @@
#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning
#endif
/* Prefix variables that are used in GPU accelerated operations, often these need to be
* placed in RAM sections that are DMA accessible */
#ifndef LV_ATTRIBUTE_DMA
#define LV_ATTRIBUTE_DMA
#endif
/*===================
* HAL settings
*==================*/
@@ -374,10 +415,10 @@
#endif
#if LV_TICK_CUSTOM == 1
#ifndef LV_TICK_CUSTOM_INCLUDE
#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
#endif
#ifndef LV_TICK_CUSTOM_SYS_TIME_EXPR
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
#endif
#endif /*LV_TICK_CUSTOM*/
@@ -468,7 +509,7 @@
/* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel.
* The symbols are available via `LV_SYMBOL_...` defines
* More info about fonts: https://docs.lvgl.com/#Fonts
* More info about fonts: https://docs.lvgl.io/v7/en/html/overview/font.html
* To create a new font go to: https://lvgl.com/ttf-font-to-c-array
*/
@@ -478,10 +519,10 @@
#define LV_FONT_MONTSERRAT_12 0
#endif
#ifndef LV_FONT_MONTSERRAT_14
#define LV_FONT_MONTSERRAT_14 0
#define LV_FONT_MONTSERRAT_14 1
#endif
#ifndef LV_FONT_MONTSERRAT_16
#define LV_FONT_MONTSERRAT_16 1
#define LV_FONT_MONTSERRAT_16 0
#endif
#ifndef LV_FONT_MONTSERRAT_18
#define LV_FONT_MONTSERRAT_18 0
@@ -569,6 +610,18 @@
#define LV_FONT_FMT_TXT_LARGE 0
#endif
/* Enables/disables support for compressed fonts. If it's disabled, compressed
* glyphs cannot be processed by the library and won't be rendered.
*/
#ifndef LV_USE_FONT_COMPRESSED
#define LV_USE_FONT_COMPRESSED 1
#endif
/* Enable subpixel rendering */
#ifndef LV_USE_FONT_SUBPX
#define LV_USE_FONT_SUBPX 1
#endif
#if LV_USE_FONT_SUBPX
/* Set the pixel order of the display.
* Important only if "subpx fonts" are used.
* With "normal" font it doesn't matter.
@@ -576,6 +629,7 @@
#ifndef LV_FONT_SUBPX_BGR
#define LV_FONT_SUBPX_BGR 0
#endif
#endif
/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/
@@ -600,7 +654,10 @@
/* A fast and impressive theme.
* Flags:
* LV_THEME_MATERIAL_FLAG_LIGHT: light theme
* LV_THEME_MATERIAL_FLAG_DARK: dark theme*/
* LV_THEME_MATERIAL_FLAG_DARK: dark theme
* LV_THEME_MATERIAL_FLAG_NO_TRANSITION: disable transitions (state change animations)
* LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state)
* */
#ifndef LV_USE_THEME_MATERIAL
#define LV_USE_THEME_MATERIAL 1
#endif
@@ -621,25 +678,25 @@
#define LV_THEME_DEFAULT_INIT lv_theme_material_init
#endif
#ifndef LV_THEME_DEFAULT_COLOR_PRIMARY
#define LV_THEME_DEFAULT_COLOR_PRIMARY LV_COLOR_RED
#define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0x01a2b1)
#endif
#ifndef LV_THEME_DEFAULT_COLOR_SECONDARY
#define LV_THEME_DEFAULT_COLOR_SECONDARY LV_COLOR_BLUE
#define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0x44d1b6)
#endif
#ifndef LV_THEME_DEFAULT_FLAG
#define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT
#endif
#ifndef LV_THEME_DEFAULT_FONT_SMALL
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_14
#endif
#ifndef LV_THEME_DEFAULT_FONT_NORMAL
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_14
#endif
#ifndef LV_THEME_DEFAULT_FONT_SUBTITLE
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_14
#endif
#ifndef LV_THEME_DEFAULT_FONT_TITLE
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_14
#endif
/*=================
@@ -678,14 +735,14 @@
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3
#endif
/* The control character to use for signaling text recoloring. */
/* The control character to use for signalling text recoloring. */
#ifndef LV_TXT_COLOR_CMD
#define LV_TXT_COLOR_CMD "#"
#endif
/* Support bidirectional texts.
* Allows mixing Left-to-Right and Right-to-Left texts.
* The direction will be processed according to the Unicode Bidirectional Algorithm:
* The direction will be processed according to the Unicode Bidirectioanl Algorithm:
* https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/
#ifndef LV_USE_BIDI
#define LV_USE_BIDI 0
@@ -793,6 +850,11 @@
#ifndef LV_USE_CALENDAR
#define LV_USE_CALENDAR 1
#endif
#if LV_USE_CALENDAR
#ifndef LV_CALENDAR_WEEK_STARTS_MONDAY
# define LV_CALENDAR_WEEK_STARTS_MONDAY 0
#endif
#endif
/*Canvas (dependencies: lv_img)*/
#ifndef LV_USE_CANVAS
@@ -928,7 +990,7 @@
* 2: Best precision
*/
#ifndef LV_LINEMETER_PRECISE
# define LV_LINEMETER_PRECISE 0
# define LV_LINEMETER_PRECISE 1
#endif
#endif

View File

@@ -8,6 +8,7 @@
*********************/
#include "lv_disp.h"
#include "../lv_misc/lv_math.h"
#include "../lv_core/lv_refr.h"
/*********************
* DEFINES
@@ -21,6 +22,12 @@
* STATIC PROTOTYPES
**********************/
#if LV_USE_ANIMATION
static void scr_load_anim_start(lv_anim_t * a);
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v);
static void scr_anim_ready(lv_anim_t * a);
#endif
/**********************
* STATIC VARIABLES
**********************/
@@ -43,13 +50,30 @@ lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("lv_scr_act: no display registered to get its act. screen");
LV_LOG_WARN("no display registered to get its active screen");
return NULL;
}
return disp->act_scr;
}
/**
* Return with a pointer to the previous screen. Only used during screen transitions.
* @param disp pointer to display which previous screen should be get. (NULL to use the default
* screen)
* @return pointer to the previous screen object or NULL if not used now
*/
lv_obj_t * lv_disp_get_scr_prev(lv_disp_t * disp)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("no display registered to get its previous screen");
return NULL;
}
return disp->prev_scr;
}
/**
* Make a screen active
* @param scr pointer to a screen
@@ -96,6 +120,7 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp)
return disp->sys_layer;
}
/**
* Assign a screen to a display.
* @param disp pointer to a display where to assign the screen
@@ -115,6 +140,176 @@ void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr)
_lv_ll_chg_list(&old_disp->scr_ll, &disp->scr_ll, scr, true);
}
/**
* Set the background color of a display
* @param disp pointer to a display
* @param color color of the background
*/
void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("no display registered");
return;
}
disp->bg_color = color;
lv_area_t a;
lv_area_set(&a, 0, 0, lv_disp_get_hor_res(disp) - 1, lv_disp_get_ver_res(disp) - 1);
_lv_inv_area(disp, &a);
}
/**
* Set the background image of a display
* @param disp pointer to a display
* @param img_src path to file or pointer to an `lv_img_dsc_t` variable
*/
void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("no display registered");
return;
}
disp->bg_img = img_src;
lv_area_t a;
lv_area_set(&a, 0, 0, lv_disp_get_hor_res(disp) - 1, lv_disp_get_ver_res(disp) - 1);
_lv_inv_area(disp, &a);
}
/**
* Opacity of the background
* @param disp pointer to a display
* @param opa opacity (0..255)
*/
void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("no display registered");
return;
}
disp->bg_opa = opa;
lv_area_t a;
lv_area_set(&a, 0, 0, lv_disp_get_hor_res(disp) - 1, lv_disp_get_ver_res(disp) - 1);
_lv_inv_area(disp, &a);
}
#if LV_USE_ANIMATION
/**
* Switch screen with animation
* @param scr pointer to the new screen to load
* @param anim_type type of the animation from `lv_scr_load_anim_t`. E.g. `LV_SCR_LOAD_ANIM_MOVE_LEFT`
* @param time time of the animation
* @param delay delay before the transition
* @param auto_del true: automatically delete the old screen
*/
void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del)
{
lv_disp_t * d = lv_obj_get_disp(new_scr);
if(d->prev_scr && d->del_prev) {
lv_obj_del(d->prev_scr);
d->prev_scr = NULL;
}
d->del_prev = auto_del;
/*Be sure there is no other animation on the screens*/
lv_anim_del(new_scr, NULL);
lv_anim_del(lv_scr_act(), NULL);
/*Be sure both screens are in a normal position*/
lv_obj_set_pos(new_scr, 0, 0);
lv_obj_set_pos(lv_scr_act(), 0, 0);
lv_style_remove_prop(lv_obj_get_local_style(new_scr, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE);
lv_style_remove_prop(lv_obj_get_local_style(lv_scr_act(), LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE);
lv_anim_t a_new;
lv_anim_init(&a_new);
lv_anim_set_var(&a_new, new_scr);
lv_anim_set_start_cb(&a_new, scr_load_anim_start);
lv_anim_set_ready_cb(&a_new, scr_anim_ready);
lv_anim_set_time(&a_new, time);
lv_anim_set_delay(&a_new, delay);
lv_anim_t a_old;
lv_anim_init(&a_old);
lv_anim_set_var(&a_old, d->act_scr);
lv_anim_set_time(&a_old, time);
lv_anim_set_delay(&a_old, delay);
switch(anim_type) {
case LV_SCR_LOAD_ANIM_NONE:
/* Create a dummy animation to apply the delay*/
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x);
lv_anim_set_values(&a_new, 0, 0);
break;
case LV_SCR_LOAD_ANIM_OVER_LEFT:
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x);
lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0);
break;
case LV_SCR_LOAD_ANIM_OVER_RIGHT:
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x);
lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0);
break;
case LV_SCR_LOAD_ANIM_OVER_TOP:
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y);
lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0);
break;
case LV_SCR_LOAD_ANIM_OVER_BOTTOM:
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y);
lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0);
break;
case LV_SCR_LOAD_ANIM_MOVE_LEFT:
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x);
lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0);
lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x);
lv_anim_set_values(&a_old, 0, -lv_disp_get_hor_res(d));
break;
case LV_SCR_LOAD_ANIM_MOVE_RIGHT:
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x);
lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0);
lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x);
lv_anim_set_values(&a_old, 0, lv_disp_get_hor_res(d));
break;
case LV_SCR_LOAD_ANIM_MOVE_TOP:
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y);
lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0);
lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y);
lv_anim_set_values(&a_old, 0, -lv_disp_get_ver_res(d));
break;
case LV_SCR_LOAD_ANIM_MOVE_BOTTOM:
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y);
lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0);
lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y);
lv_anim_set_values(&a_old, 0, lv_disp_get_ver_res(d));
break;
case LV_SCR_LOAD_ANIM_FADE_ON:
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) opa_scale_anim);
lv_anim_set_values(&a_new, LV_OPA_TRANSP, LV_OPA_COVER);
break;
}
lv_anim_start(&a_new);
lv_anim_start(&a_old);
}
#endif
/**
* Get elapsed time since last user activity on a display (e.g. click)
* @param disp pointer to an display (NULL to get the overall smallest inactivity)
@@ -157,6 +352,21 @@ void lv_disp_trig_activity(lv_disp_t * disp)
disp->last_activity_time = lv_tick_get();
}
/**
* Clean any CPU cache that is related to the display.
* @param disp pointer to an display (NULL to use the default display)
*/
void lv_disp_clean_dcache(lv_disp_t * disp)
{
if(!disp) disp = lv_disp_get_default();
if(!disp) {
LV_LOG_WARN("lv_disp_clean_dcache: no display registered");
return;
}
if(disp->driver.clean_dcache_cb)
disp->driver.clean_dcache_cb(&disp->driver);
}
/**
* Get a pointer to the screen refresher task to
@@ -178,3 +388,28 @@ lv_task_t * _lv_disp_get_refr_task(lv_disp_t * disp)
/**********************
* STATIC FUNCTIONS
**********************/
#if LV_USE_ANIMATION
static void scr_load_anim_start(lv_anim_t * a)
{
lv_disp_t * d = lv_obj_get_disp(a->var);
d->prev_scr = lv_scr_act();
lv_disp_load_scr(a->var);
}
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v)
{
lv_obj_set_style_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v);
}
static void scr_anim_ready(lv_anim_t * a)
{
lv_disp_t * d = lv_obj_get_disp(a->var);
if(d->prev_scr && d->del_prev) lv_obj_del(d->prev_scr);
d->prev_scr = NULL;
lv_style_remove_prop(lv_obj_get_local_style(a->var, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE);
}
#endif

View File

@@ -24,6 +24,19 @@ extern "C" {
* TYPEDEFS
**********************/
typedef enum {
LV_SCR_LOAD_ANIM_NONE,
LV_SCR_LOAD_ANIM_OVER_LEFT,
LV_SCR_LOAD_ANIM_OVER_RIGHT,
LV_SCR_LOAD_ANIM_OVER_TOP,
LV_SCR_LOAD_ANIM_OVER_BOTTOM,
LV_SCR_LOAD_ANIM_MOVE_LEFT,
LV_SCR_LOAD_ANIM_MOVE_RIGHT,
LV_SCR_LOAD_ANIM_MOVE_TOP,
LV_SCR_LOAD_ANIM_MOVE_BOTTOM,
LV_SCR_LOAD_ANIM_FADE_ON,
} lv_scr_load_anim_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
@@ -36,6 +49,14 @@ extern "C" {
*/
lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp);
/**
* Return with a pointer to the previous screen. Only used during screen transitions.
* @param disp pointer to display which previous screen should be get. (NULL to use the default
* screen)
* @return pointer to the previous screen object or NULL if not used now
*/
lv_obj_t * lv_disp_get_scr_prev(lv_disp_t * disp);
/**
* Make a screen active
* @param scr pointer to a screen
@@ -64,6 +85,41 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp);
*/
void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr);
/**
* Set the background color of a display
* @param disp pointer to a display
* @param color color of the background
*/
void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color);
/**
* Set the background image of a display
* @param disp pointer to a display
* @param img_src path to file or pointer to an `lv_img_dsc_t` variable
*/
void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src);
/**
* Opacity of the background
* @param disp pointer to a display
* @param opa opacity (0..255)
*/
void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa);
#if LV_USE_ANIMATION
/**
* Switch screen with animation
* @param scr pointer to the new screen to load
* @param anim_type type of the animation from `lv_scr_load_anim_t`. E.g. `LV_SCR_LOAD_ANIM_MOVE_LEFT`
* @param time time of the animation
* @param delay delay before the transition
* @param auto_del true: automatically delete the old screen
*/
void lv_scr_load_anim(lv_obj_t * scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del);
#endif
/**
* Get elapsed time since last user activity on a display (e.g. click)
* @param disp pointer to an display (NULL to get the overall smallest inactivity)
@@ -77,6 +133,12 @@ uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp);
*/
void lv_disp_trig_activity(lv_disp_t * disp);
/**
* Clean any CPU cache that is related to the display.
* @param disp pointer to an display (NULL to use the default display)
*/
void lv_disp_clean_dcache(lv_disp_t * disp);
/**
* Get a pointer to the screen refresher task to
* modify its parameters with `lv_task_...` functions.
@@ -122,6 +184,7 @@ static inline void lv_scr_load(lv_obj_t * scr)
lv_disp_load_scr(scr);
}
/**********************
* MACROS
**********************/
@@ -152,7 +215,12 @@ static inline void lv_scr_load(lv_obj_t * scr)
* 1 dip is 2 px on a 320 DPI screen
* https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dip-dp-and-sp
*/
#define LV_DPX(n) LV_MATH_MAX((( lv_disp_get_dpi(NULL) * (n) + 80) / 160), 1) /*+80 for rounding*/
#define LV_DPX(n) (n == 0 ? 0 :LV_MATH_MAX((( lv_disp_get_dpi(NULL) * (n) + 80) / 160), 1)) /*+80 for rounding*/
static inline lv_coord_t lv_dpx(lv_coord_t n)
{
return LV_DPX(n);
}
#ifdef __cplusplus
} /* extern "C" */

View File

@@ -218,7 +218,7 @@ void lv_group_focus_obj(lv_obj_t * obj)
if(g->frozen != 0) return;
if(obj == *g->obj_focus) return;
if(g->obj_focus != NULL && obj == *g->obj_focus) return;
/*On defocus edit mode must be leaved*/
lv_group_set_editing(g, false);
@@ -332,9 +332,9 @@ void lv_group_set_editing(lv_group_t * group, bool edit)
focused->signal_cb(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave/open edit/navigate mode*/
lv_res_t res = lv_event_send(*group->obj_focus, LV_EVENT_FOCUSED, NULL);
if(res != LV_RES_OK) return;
}
lv_obj_invalidate(focused);
lv_obj_invalidate(focused);
}
}
/**

View File

@@ -213,6 +213,7 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj)
indev->cursor = cur_obj;
lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp));
lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y);
lv_obj_set_click(indev->cursor, false);
}
#if LV_USE_GROUP
@@ -607,8 +608,163 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
indev_obj_act = lv_group_get_focused(g);
if(indev_obj_act == NULL) return;
/*Process the steps first. They are valid only with released button*/
if(data->state == LV_INDEV_STATE_REL) {
/*Process the steps they are valid only with released button*/
if(data->state != LV_INDEV_STATE_REL) {
data->enc_diff = 0;
}
/*Refresh the focused object. It might change due to lv_group_focus_prev/next*/
indev_obj_act = lv_group_get_focused(g);
if(indev_obj_act == NULL) return;
/*Button press happened*/
if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_REL) {
i->proc.pr_timestamp = lv_tick_get();
if(data->key == LV_KEY_ENTER) {
bool editable = false;
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable);
if(lv_group_get_editing(g) == true || editable == false) {
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_PRESSED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL);
if(indev_reset_check(&i->proc)) return;
}
}
else if(data->key == LV_KEY_LEFT) {
/*emulate encoder left*/
data->enc_diff--;
}
else if(data->key == LV_KEY_RIGHT) {
/*emulate encoder right*/
data->enc_diff++;
}
else if(data->key == LV_KEY_ESC) {
/*Send the ESC as a normal KEY*/
lv_group_send_data(g, LV_KEY_ESC);
lv_event_send(indev_obj_act, LV_EVENT_CANCEL, NULL);
if(indev_reset_check(&i->proc)) return;
}
/*Just send other keys to the object (e.g. 'A' or `LV_GROUP_KEY_RIGHT`)*/
else {
lv_group_send_data(g, data->key);
}
}
/*Pressing*/
else if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_PR) {
/* Long press*/
if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) {
i->proc.long_pr_sent = 1;
i->proc.longpr_rep_timestamp = lv_tick_get();
if(data->key == LV_KEY_ENTER) {
bool editable = false;
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable);
/*On enter long press toggle edit mode.*/
if(editable) {
/*Don't leave edit mode if there is only one object (nowhere to navigate)*/
if(_lv_ll_is_empty(&g->obj_ll) == false) {
lv_group_set_editing(g, lv_group_get_editing(g) ? false : true); /*Toggle edit mode on long press*/
}
}
/*If not editable then just send a long press signal*/
else {
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL);
if(indev_reset_check(&i->proc)) return;
}
}
i->proc.long_pr_sent = 1;
}
/*Long press repeated time has elapsed?*/
else if(i->proc.long_pr_sent != 0 && lv_tick_elaps(i->proc.longpr_rep_timestamp) > i->driver.long_press_rep_time) {
i->proc.longpr_rep_timestamp = lv_tick_get();
if(data->key == LV_KEY_ENTER) {
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS_REP, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
if(indev_reset_check(&i->proc)) return;
}
else if(data->key == LV_KEY_LEFT) {
/*emulate encoder left*/
data->enc_diff--;
}
else if(data->key == LV_KEY_RIGHT) {
/*emulate encoder right*/
data->enc_diff++;
}
else {
lv_group_send_data(g, data->key);
if(indev_reset_check(&i->proc)) return;
}
}
}
/*Release happened*/
else if(data->state == LV_INDEV_STATE_REL && last_state == LV_INDEV_STATE_PR) {
if(data->key == LV_KEY_ENTER) {
bool editable = false;
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable);
/*The button was released on a non-editable object. Just send enter*/
if(editable == false) {
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL);
if(indev_reset_check(&i->proc)) return;
if(i->proc.long_pr_sent == 0) lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL);
if(indev_reset_check(&i->proc)) return;
}
/*An object is being edited and the button is released. */
else if(g->editing) {
/*Ignore long pressed enter release because it comes from mode switch*/
if(!i->proc.long_pr_sent || _lv_ll_is_empty(&g->obj_ll)) {
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_group_send_data(g, LV_KEY_ENTER);
}
}
/*If the focused object is editable and now in navigate mode then on enter switch edit
mode*/
else if(editable && !g->editing && !i->proc.long_pr_sent) {
lv_group_set_editing(g, true); /*Set edit mode*/
}
}
i->proc.pr_timestamp = 0;
i->proc.long_pr_sent = 0;
}
indev_obj_act = NULL;
/*if encoder steps or simulated steps via left/right keys*/
if(data->enc_diff != 0) {
/*In edit mode send LEFT/RIGHT keys*/
if(lv_group_get_editing(g)) {
int32_t s;
@@ -631,96 +787,6 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
}
}
/*Refresh the focused object. It might change due to lv_group_focus_prev/next*/
indev_obj_act = lv_group_get_focused(g);
if(indev_obj_act == NULL) return;
/*Button press happened*/
if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_REL) {
bool editable = false;
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable);
i->proc.pr_timestamp = lv_tick_get();
if(lv_group_get_editing(g) == true || editable == false) {
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_PRESSED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL);
if(indev_reset_check(&i->proc)) return;
}
}
/*Pressing*/
else if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_PR) {
if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) {
bool editable = false;
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable);
/*On enter long press toggle edit mode.*/
if(editable) {
/*Don't leave edit mode if there is only one object (nowhere to navigate)*/
if(_lv_ll_is_empty(&g->obj_ll) == false) {
lv_group_set_editing(g, lv_group_get_editing(g) ? false : true); /*Toggle edit mode on long press*/
}
}
/*If not editable then just send a long press signal*/
else {
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL);
if(indev_reset_check(&i->proc)) return;
}
i->proc.long_pr_sent = 1;
}
}
/*Release happened*/
else if(data->state == LV_INDEV_STATE_REL && last_state == LV_INDEV_STATE_PR) {
bool editable = false;
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable);
/*The button was released on a non-editable object. Just send enter*/
if(editable == false) {
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL);
if(indev_reset_check(&i->proc)) return;
if(i->proc.long_pr_sent == 0) lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL);
if(indev_reset_check(&i->proc)) return;
}
/*An object is being edited and the button is released. */
else if(g->editing) {
/*Ignore long pressed enter release because it comes from mode switch*/
if(!i->proc.long_pr_sent || _lv_ll_is_empty(&g->obj_ll)) {
indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL);
if(indev_reset_check(&i->proc)) return;
lv_group_send_data(g, LV_KEY_ENTER);
}
}
/*If the focused object is editable and now in navigate mode then on enter switch edit
mode*/
else if(editable && !g->editing && !i->proc.long_pr_sent) {
lv_group_set_editing(g, true); /*Set edit mode*/
}
i->proc.pr_timestamp = 0;
i->proc.long_pr_sent = 0;
}
indev_obj_act = NULL;
#else
(void)data; /*Unused*/
(void)i; /*Unused*/
@@ -1092,8 +1158,9 @@ lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point)
static void indev_click_focus(lv_indev_proc_t * proc)
{
/*Handle click focus*/
lv_obj_t * obj_to_focus = lv_obj_get_focused_obj(indev_obj_act);
if(lv_obj_is_protected(indev_obj_act, LV_PROTECT_CLICK_FOCUS) == false &&
proc->types.pointer.last_pressed != indev_obj_act) {
proc->types.pointer.last_pressed != obj_to_focus) {
#if LV_USE_GROUP
lv_group_t * g_act = lv_obj_get_group(indev_obj_act);
lv_group_t * g_prev = proc->types.pointer.last_pressed ? lv_obj_get_group(proc->types.pointer.last_pressed) : NULL;
@@ -1114,19 +1181,14 @@ static void indev_click_focus(lv_indev_proc_t * proc)
if(indev_reset_check(proc)) return;
}
lv_signal_send(indev_obj_act, LV_SIGNAL_FOCUS, NULL);
lv_signal_send(obj_to_focus, LV_SIGNAL_FOCUS, NULL);
if(indev_reset_check(proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, NULL);
lv_event_send(obj_to_focus, LV_EVENT_FOCUSED, NULL);
if(indev_reset_check(proc)) return;
}
}
/*The object are not in the same group (in different group or one in not a group)*/
else {
/*Focus to the act. its group*/
if(g_act) {
lv_group_focus_obj(indev_obj_act);
if(indev_reset_check(proc)) return;
}
/*If the prev. obj. is not in a group then defocus it.*/
if(g_prev == NULL && proc->types.pointer.last_pressed) {
lv_signal_send(proc->types.pointer.last_pressed, LV_SIGNAL_DEFOCUS, NULL);
@@ -1152,10 +1214,17 @@ static void indev_click_focus(lv_indev_proc_t * proc)
if(indev_reset_check(proc)) return;
}
}
}
lv_signal_send(indev_obj_act, LV_SIGNAL_FOCUS, NULL);
/*Focus to the act. in its group*/
if(g_act) {
lv_group_focus_obj(indev_obj_act);
if(indev_reset_check(proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, NULL);
}
else {
lv_signal_send(obj_to_focus, LV_SIGNAL_FOCUS, NULL);
if(indev_reset_check(proc)) return;
lv_event_send(obj_to_focus, LV_EVENT_FOCUSED, NULL);
if(indev_reset_check(proc)) return;
}
}
@@ -1172,7 +1241,7 @@ static void indev_click_focus(lv_indev_proc_t * proc)
lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, NULL);
if(indev_reset_check(proc)) return;
#endif
proc->types.pointer.last_pressed = indev_obj_act;
proc->types.pointer.last_pressed = obj_to_focus;
}
}
@@ -1421,7 +1490,6 @@ static lv_obj_t * get_dragged_obj(lv_obj_t * obj)
static void indev_gesture(lv_indev_proc_t * proc)
{
if(proc->types.pointer.drag_in_prog) return;
if(proc->types.pointer.gesture_sent) return;
lv_obj_t * gesture_obj = proc->types.pointer.act_obj;

File diff suppressed because it is too large Load Diff

View File

@@ -47,6 +47,9 @@ extern "C" {
#define LV_EXT_CLICK_AREA_TINY 1
#define LV_EXT_CLICK_AREA_FULL 2
#define _LV_OBJ_PART_VIRTUAL_FIRST 0x01
#define _LV_OBJ_PART_REAL_FIRST 0x40
/**********************
* TYPEDEFS
**********************/
@@ -102,6 +105,7 @@ enum {
LV_EVENT_APPLY, /**< "Ok", "Apply" or similar specific button has clicked*/
LV_EVENT_CANCEL, /**< "Close", "Cancel" or similar specific button has clicked*/
LV_EVENT_DELETE, /**< Object is being deleted */
_LV_EVENT_LAST /** Number of events*/
};
typedef uint8_t lv_event_t; /**< Type of event being sent to the object. */
@@ -159,7 +163,7 @@ typedef struct {
lv_coord_t yofs;
lv_align_t align;
uint8_t auto_realign : 1;
uint8_t origo_align : 1; /**< 1: the origo (center of the object) was aligned with
uint8_t mid_align : 1; /**< 1: the origo (center of the object) was aligned with
`lv_obj_align_origo`*/
} lv_realign_t;
#endif
@@ -221,7 +225,8 @@ typedef struct _lv_obj_t {
uint8_t top : 1; /**< 1: If the object or its children is clicked it goes to the foreground*/
uint8_t parent_event : 1; /**< 1: Send the object's events to the parent too. */
uint8_t adv_hittest : 1; /**< 1: Use advanced hit-testing (slower) */
uint8_t gesture_parent : 1; /**< 1: Parent will be gesture instead*/
uint8_t gesture_parent : 1; /**< 1: Parent will be gesture instead*/
uint8_t focus_parent : 1; /**< 1: Parent will be focused instead*/
lv_drag_dir_t drag_dir : 3; /**< Which directions the object can be dragged in */
lv_bidi_dir_t base_dir : 2; /**< Base direction of texts related to this object */
@@ -246,8 +251,8 @@ typedef struct _lv_obj_t {
enum {
LV_OBJ_PART_MAIN,
_LV_OBJ_PART_VIRTUAL_LAST = 0x01,
_LV_OBJ_PART_REAL_LAST = 0x40,
_LV_OBJ_PART_VIRTUAL_LAST = _LV_OBJ_PART_VIRTUAL_FIRST,
_LV_OBJ_PART_REAL_LAST = _LV_OBJ_PART_REAL_FIRST,
LV_OBJ_PART_ALL = 0xFF,
};
@@ -349,6 +354,22 @@ void lv_obj_invalidate_area(const lv_obj_t * obj, const lv_area_t * area);
*/
void lv_obj_invalidate(const lv_obj_t * obj);
/**
* Tell whether an area of an object is visible (even partially) now or not
* @param obj pointer to an object
* @param area the are to check. The visible part of the area will be written back here.
* @return true: visible; false: not visible (hidden, out of parent, on other screen, etc)
*/
bool lv_obj_area_is_visible(const lv_obj_t * obj, lv_area_t * area);
/**
* Tell whether an object is visible (even partially) now or not
* @param obj pointer to an object
* @return true: visible; false: not visible (hidden, out of parent, on other screen, etc)
*/
bool lv_obj_is_visible(const lv_obj_t * obj);
/*=====================
* Setter functions
*====================*/
@@ -464,6 +485,24 @@ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h);
*/
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs);
/**
* Align an object to an other object horizontally.
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param x_ofs x coordinate offset after alignment
*/
void lv_obj_align_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs);
/**
* Align an object to an other object vertically.
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param y_ofs y coordinate offset after alignment
*/
void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs);
/**
* Align an object to an other object.
* @param obj pointer to an object to align
@@ -472,7 +511,26 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
* @param x_ofs x coordinate offset after alignment
* @param y_ofs y coordinate offset after alignment
*/
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs);
void lv_obj_align_mid(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs);
/**
* Align an object's middle point to an other object horizontally.
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param x_ofs x coordinate offset after alignment
*/
void lv_obj_align_mid_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs);
/**
* Align an object's middle point to an other object vertically.
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param y_ofs y coordinate offset after alignment
*/
void lv_obj_align_mid_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs);
/**
* Realign the object based on the last `lv_obj_align` parameters.
@@ -545,7 +603,7 @@ void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part);
* @param obj pointer to an object
* @param prop `LV_STYLE_PROP_ALL` or an `LV_STYLE_...` property. It is used to optimize what needs to be refreshed.
*/
void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop);
void lv_obj_refresh_style(lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
/**
* Notify all object if a style is modified
@@ -623,6 +681,13 @@ void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t type, lv_style_property
*/
bool lv_obj_remove_style_local_prop(lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
/**
* Enable/disable the use of style cahche for an object
* @param obj pointer to an object
* @param dis true: disable; false: enable (re-enable)
*/
void _lv_obj_disable_style_caching(lv_obj_t * obj, bool dis);
/*-----------------
* Attribute set
*----------------*/
@@ -685,6 +750,14 @@ void lv_obj_set_drag_throw(lv_obj_t * obj, bool en);
*/
void lv_obj_set_drag_parent(lv_obj_t * obj, bool en);
/**
* Enable to use parent for focus state.
* When object is focused the parent will get the state instead (visual only)
* @param obj pointer to an object
* @param en true: enable the 'focus parent' for the object
*/
void lv_obj_set_focus_parent(lv_obj_t * obj, bool en);
/**
* Enable to use parent for gesture related operations.
* If trying to gesture the object the parent will be moved instead
@@ -774,6 +847,20 @@ void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb);
*/
lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data);
/**
* Send LV_EVENT_REFRESH event to an object
* @param obj point to an obejct. (Can NOT be NULL)
* @return LV_RES_OK: success, LV_RES_INV: to object become invalid (e.g. deleted) due to this event.
*/
lv_res_t lv_event_send_refresh(lv_obj_t * obj);
/**
* Send LV_EVENT_REFRESH event to an object and all of its children
* @param obj pointer to an object or NULL to refresh all objects of all displays
*/
void lv_event_send_refresh_recursive(lv_obj_t * obj);
/**
* Call an event function with an object, event, and data.
* @param event_xcb an event callback function. If `NULL` `LV_RES_OK` will return without any actions.
@@ -1187,6 +1274,15 @@ bool lv_obj_get_drag_throw(const lv_obj_t * obj);
*/
bool lv_obj_get_drag_parent(const lv_obj_t * obj);
/**
* Get the focus parent attribute of an object
* @param obj pointer to an object
* @return true: focus parent is enabled
*/
bool lv_obj_get_focus_parent(const lv_obj_t * obj);
/**
* Get the drag parent attribute of an object
* @param obj pointer to an object
@@ -1318,6 +1414,13 @@ void * lv_obj_get_group(const lv_obj_t * obj);
*/
bool lv_obj_is_focused(const lv_obj_t * obj);
/**
* Get the really focused object by taking `focus_parent` into account.
* @param obj the start object
* @return the object to really focus
*/
lv_obj_t * lv_obj_get_focused_obj(const lv_obj_t * obj);
/*-------------------
* OTHER FUNCTIONS
*------------------*/
@@ -1411,8 +1514,8 @@ bool lv_debug_check_obj_valid(const lv_obj_t * obj);
# ifndef LV_DEBUG_IS_OBJ
# define LV_DEBUG_IS_OBJ(obj_p, obj_type) (lv_debug_check_null(obj_p) && \
lv_debug_check_obj_valid(obj_p) && \
lv_debug_check_obj_type(obj_p, obj_type))
lv_debug_check_obj_valid(obj_p) && \
lv_debug_check_obj_type(obj_p, obj_type))
# endif

View File

@@ -199,6 +199,102 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_COLOR, scale_end_color, lv_color_t, _col
#undef _LV_OBJ_STYLE_SET_GET_DECLARE
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)
{
lv_obj_set_style_local_pad_top(obj, part, state, value);
lv_obj_set_style_local_pad_bottom(obj, part, state, value);
lv_obj_set_style_local_pad_left(obj, part, state, value);
lv_obj_set_style_local_pad_right(obj, part, state, value);
}
static inline void lv_style_set_pad_all(lv_style_t * style, lv_state_t state, lv_style_int_t value)
{
lv_style_set_pad_top(style, state, value);
lv_style_set_pad_bottom(style, state, value);
lv_style_set_pad_left(style, state, value);
lv_style_set_pad_right(style, state, value);
}
static inline void lv_obj_set_style_local_pad_hor(lv_obj_t * obj, uint8_t part, lv_state_t state, lv_style_int_t value)
{
lv_obj_set_style_local_pad_left(obj, part, state, value);
lv_obj_set_style_local_pad_right(obj, part, state, value);
}
static inline void lv_style_set_pad_hor(lv_style_t * style, lv_state_t state, lv_style_int_t value)
{
lv_style_set_pad_left(style, state, value);
lv_style_set_pad_right(style, state, value);
}
static inline void lv_obj_set_style_local_pad_ver(lv_obj_t * obj, uint8_t part, lv_state_t state, lv_style_int_t value)
{
lv_obj_set_style_local_pad_top(obj, part, state, value);
lv_obj_set_style_local_pad_bottom(obj, part, state, value);
}
static inline void lv_style_set_pad_ver(lv_style_t * style, lv_state_t state, lv_style_int_t value)
{
lv_style_set_pad_top(style, state, value);
lv_style_set_pad_bottom(style, state, value);
}
static inline void lv_obj_set_style_local_margin_all(lv_obj_t * obj, uint8_t part, lv_state_t state,
lv_style_int_t value)
{
lv_obj_set_style_local_margin_top(obj, part, state, value);
lv_obj_set_style_local_margin_bottom(obj, part, state, value);
lv_obj_set_style_local_margin_left(obj, part, state, value);
lv_obj_set_style_local_margin_right(obj, part, state, value);
}
static inline void lv_style_set_margin_all(lv_style_t * style, lv_state_t state, lv_style_int_t value)
{
lv_style_set_margin_top(style, state, value);
lv_style_set_margin_bottom(style, state, value);
lv_style_set_margin_left(style, state, value);
lv_style_set_margin_right(style, state, value);
}
static inline void lv_obj_set_style_local_margin_hor(lv_obj_t * obj, uint8_t part, lv_state_t state,
lv_style_int_t value)
{
lv_obj_set_style_local_margin_left(obj, part, state, value);
lv_obj_set_style_local_margin_right(obj, part, state, value);
}
static inline void lv_style_set_margin_hor(lv_style_t * style, lv_state_t state, lv_style_int_t value)
{
lv_style_set_margin_left(style, state, value);
lv_style_set_margin_right(style, state, value);
}
static inline void lv_obj_set_style_local_margin_ver(lv_obj_t * obj, uint8_t part, lv_state_t state,
lv_style_int_t value)
{
lv_obj_set_style_local_margin_top(obj, part, state, value);
lv_obj_set_style_local_margin_bottom(obj, part, state, value);
}
static inline void lv_style_set_margin_ver(lv_style_t * style, lv_state_t state, lv_style_int_t value)
{
lv_style_set_margin_top(style, state, value);
lv_style_set_margin_bottom(style, state, value);
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@@ -205,7 +205,8 @@ void _lv_disp_refr_task(lv_task_t * task)
if(lv_disp_is_true_double_buf(disp_refr)) {
if(disp_refr->driver.set_px_cb) {
LV_LOG_WARN("Can't handle 2 screen sized buffers with set_px_cb. Display is not refreshed.");
} else {
}
else {
lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
/*Flush the content of the VDB*/
@@ -217,11 +218,11 @@ void _lv_disp_refr_task(lv_task_t * task)
while(vdb->flushing);
lv_color_t * copy_buf = NULL;
#if LV_USE_GPU_STM32_DMA2D
#if LV_USE_GPU_STM32_DMA2D
LV_UNUSED(copy_buf);
#else
#else
copy_buf = _lv_mem_buf_get(disp_refr->driver.hor_res * sizeof(lv_color_t));
#endif
#endif
uint8_t * buf_act = (uint8_t *)vdb->buf_act;
uint8_t * buf_ina = (uint8_t *)vdb->buf_act == vdb->buf1 ? vdb->buf2 : vdb->buf1;
@@ -232,12 +233,12 @@ void _lv_disp_refr_task(lv_task_t * task)
if(disp_refr->inv_area_joined[a] == 0) {
uint32_t start_offs =
(hres * disp_refr->inv_areas[a].y1 + disp_refr->inv_areas[a].x1) * sizeof(lv_color_t);
#if LV_USE_GPU_STM32_DMA2D
#if LV_USE_GPU_STM32_DMA2D
lv_gpu_stm32_dma2d_copy((lv_color_t *)(buf_act + start_offs), disp_refr->driver.hor_res,
(lv_color_t *)(buf_ina + start_offs), disp_refr->driver.hor_res,
lv_area_get_width(&disp_refr->inv_areas[a]),
lv_area_get_height(&disp_refr->inv_areas[a]));
#else
#else
lv_coord_t y;
uint32_t line_length = lv_area_get_width(&disp_refr->inv_areas[a]) * sizeof(lv_color_t);
@@ -249,7 +250,7 @@ void _lv_disp_refr_task(lv_task_t * task)
_lv_memcpy(buf_act + start_offs, copy_buf, line_length);
start_offs += hres * sizeof(lv_color_t);
}
#endif
#endif
}
}
@@ -489,7 +490,8 @@ static void lv_refr_area_part(const lv_area_t * area_p)
}
}
lv_obj_t * top_p;
lv_obj_t * top_act_scr = NULL;
lv_obj_t * top_prev_scr = NULL;
/*Get the new mask from the original area and the act. VDB
It will be a part of 'area_p'*/
@@ -497,10 +499,55 @@ static void lv_refr_area_part(const lv_area_t * area_p)
_lv_area_intersect(&start_mask, area_p, &vdb->area);
/*Get the most top object which is not covered by others*/
top_p = lv_refr_get_top_obj(&start_mask, lv_disp_get_scr_act(disp_refr));
top_act_scr = lv_refr_get_top_obj(&start_mask, lv_disp_get_scr_act(disp_refr));
if(disp_refr->prev_scr) {
top_prev_scr = lv_refr_get_top_obj(&start_mask, disp_refr->prev_scr);
}
/*Draw a display background if there is no top object*/
if(top_act_scr == NULL && top_prev_scr == NULL) {
if(disp_refr->bg_img) {
lv_draw_img_dsc_t dsc;
lv_draw_img_dsc_init(&dsc);
dsc.opa = disp_refr->bg_opa;
lv_img_header_t header;
lv_res_t res;
res = lv_img_decoder_get_info(disp_refr->bg_img, &header);
if(res == LV_RES_OK) {
lv_area_t a;
lv_area_set(&a, 0, 0, header.w - 1, header.h - 1);
lv_draw_img(&a, &start_mask, disp_refr->bg_img, &dsc);
}
else {
LV_LOG_WARN("Can't draw the background image")
}
}
else {
lv_draw_rect_dsc_t dsc;
lv_draw_rect_dsc_init(&dsc);
dsc.bg_color = disp_refr->bg_color;
dsc.bg_opa = disp_refr->bg_opa;
lv_draw_rect(&start_mask, &start_mask, &dsc);
}
}
/*Refresh the previous screen if any*/
if(disp_refr->prev_scr) {
/*Get the most top object which is not covered by others*/
if(top_prev_scr == NULL) {
top_prev_scr = disp_refr->prev_scr;
}
/*Do the refreshing from the top object*/
lv_refr_obj_and_children(top_prev_scr, &start_mask);
}
if(top_act_scr == NULL) {
top_act_scr = disp_refr->act_scr;
}
/*Do the refreshing from the top object*/
lv_refr_obj_and_children(top_p, &start_mask);
lv_refr_obj_and_children(top_act_scr, &start_mask);
/*Also refresh top and sys layer unconditionally*/
lv_refr_obj_and_children(lv_disp_get_layer_top(disp_refr), &start_mask);
@@ -525,10 +572,15 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
/*If this object is fully cover the draw area check the children too */
if(_lv_area_is_in(area_p, &obj->coords, 0) && obj->hidden == 0) {
lv_design_res_t design_res = obj->design_cb ? obj->design_cb(obj, area_p,
LV_DESIGN_COVER_CHK) : LV_DESIGN_RES_NOT_COVER;
lv_design_res_t design_res = obj->design_cb(obj, area_p, LV_DESIGN_COVER_CHK);
if(design_res == LV_DESIGN_RES_MASKED) return NULL;
#if LV_USE_OPA_SCALE
if(design_res == LV_DESIGN_RES_COVER && lv_obj_get_style_opa_scale(obj, LV_OBJ_PART_MAIN) != LV_OPA_COVER) {
design_res = LV_DESIGN_RES_NOT_COVER;
}
#endif
lv_obj_t * i;
_LV_LL_READ(obj->child_ll, i) {
found_p = lv_refr_get_top_obj(area_p, i);
@@ -694,6 +746,8 @@ static void lv_refr_vdb_flush(void)
/*Flush the rendered content to the display*/
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(vdb->buf1 && vdb->buf2) {

View File

@@ -36,6 +36,12 @@
**********************/
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 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);
static inline size_t get_prop_size(uint8_t prop_id);
static inline size_t get_next_prop_index(uint8_t prop_id, size_t id);
/**********************
* GLOABAL VARIABLES
@@ -102,16 +108,12 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop)
lv_style_attr_t attr_found;
lv_style_attr_t attr_goal;
attr_found.full = *(style->map + id + 1);
attr_goal.full = (prop >> 8) & 0xFFU;
attr_found = get_style_prop_attr(style, id);
attr_goal = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) {
if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) {
uint32_t map_size = _lv_style_get_mem_size(style);
uint8_t prop_size = sizeof(lv_style_property_t);
if((prop & 0xF) < LV_STYLE_ID_COLOR) prop_size += sizeof(lv_style_int_t);
else if((prop & 0xF) < LV_STYLE_ID_OPA) prop_size += sizeof(lv_color_t);
else if((prop & 0xF) < LV_STYLE_ID_PTR) prop_size += sizeof(lv_opa_t);
else prop_size += sizeof(const void *);
uint8_t prop_size = get_prop_size(prop);
/*Move the props to fill the space of the property to delete*/
uint32_t i;
@@ -119,7 +121,7 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop)
style->map[i] = style->map[i + prop_size];
}
style->map = lv_mem_realloc(style->map, map_size - prop_size);
style_resize(style, map_size - prop_size);
return true;
}
@@ -255,7 +257,7 @@ void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style)
return;
}
lv_style_t ** new_classes = lv_mem_realloc(list->style_list, sizeof(lv_style_t *) * (list->style_cnt - 1));
lv_style_t ** new_classes = lv_mem_alloc(sizeof(lv_style_t *) * (list->style_cnt - 1));
LV_ASSERT_MEM(new_classes);
if(new_classes == NULL) {
LV_LOG_WARN("lv_style_list_remove_style: couldn't reallocate class list");
@@ -269,6 +271,8 @@ void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style)
}
lv_mem_free(list->style_list);
list->style_cnt--;
list->style_list = new_classes;
}
@@ -335,14 +339,9 @@ uint16_t _lv_style_get_mem_size(const lv_style_t * style)
if(style->map == NULL) return 0;
size_t i = 0;
while(style->map[i] != _LV_STYLE_CLOSEING_PROP) {
/*Go to the next property*/
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t);
else i += sizeof(const void *);
i += sizeof(lv_style_property_t);
uint8_t prop_id;
while((prop_id = get_style_prop_id(style, i)) != _LV_STYLE_CLOSEING_PROP) {
i = get_next_prop_index(prop_id, i);
}
return i + sizeof(lv_style_property_t);
@@ -368,10 +367,10 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in
lv_style_attr_t attr_found;
lv_style_attr_t attr_goal;
attr_found.full = *(style->map + id + 1);
attr_goal.full = (prop >> 8) & 0xFFU;
attr_found = get_style_prop_attr(style, id);
attr_goal = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) {
if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) {
_lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &value, sizeof(lv_style_int_t));
return;
}
@@ -385,7 +384,7 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in
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->map = lv_mem_realloc(style->map, size);
style_resize(style, size);
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
@@ -414,10 +413,10 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_
lv_style_attr_t attr_found;
lv_style_attr_t attr_goal;
attr_found.full = *(style->map + id + 1);
attr_goal.full = (prop >> 8) & 0xFFU;
attr_found = get_style_prop_attr(style, id);
attr_goal = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) {
if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) {
_lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &color, sizeof(lv_color_t));
return;
}
@@ -432,7 +431,7 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_
if(size == 0) size += end_mark_size;
size += sizeof(lv_style_property_t) + sizeof(lv_color_t);
style->map = lv_mem_realloc(style->map, size);
style_resize(style, size);
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
@@ -461,10 +460,10 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op
lv_style_attr_t attr_found;
lv_style_attr_t attr_goal;
attr_found.full = *(style->map + id + 1);
attr_goal.full = (prop >> 8) & 0xFFU;
attr_found = get_style_prop_attr(style, id);
attr_goal = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) {
if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) {
_lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &opa, sizeof(lv_opa_t));
return;
}
@@ -479,7 +478,7 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op
if(size == 0) size += end_mark_size;
size += sizeof(lv_style_property_t) + sizeof(lv_opa_t);
style->map = lv_mem_realloc(style->map, size);
style_resize(style, size);
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
@@ -508,10 +507,10 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void
lv_style_attr_t attr_found;
lv_style_attr_t attr_goal;
attr_found.full = *(style->map + id + 1);
attr_goal.full = (prop >> 8) & 0xFFU;
attr_found = get_style_prop_attr(style, id);
attr_goal = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) {
if(LV_STYLE_ATTR_GET_STATE(attr_found) == LV_STYLE_ATTR_GET_STATE(attr_goal)) {
_lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &p, sizeof(const void *));
return;
}
@@ -526,7 +525,7 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void
if(size == 0) size += end_mark_size;
size += sizeof(lv_style_property_t) + sizeof(const void *);
style->map = lv_mem_realloc(style->map, size);
style_resize(style, size);
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
@@ -560,12 +559,12 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo
else {
_lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
attr_act = get_style_prop_attr(style, id);
lv_style_attr_t attr_goal;
attr_goal.full = (prop >> 8) & 0xFF;
attr_goal = (prop >> 8) & 0xFF;
return attr_act.bits.state & attr_goal.bits.state;
return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal);
}
}
@@ -597,12 +596,12 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo
else {
_lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_opa_t));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
attr_act = get_style_prop_attr(style, id);
lv_style_attr_t attr_goal;
attr_goal.full = (prop >> 8) & 0xFF;
attr_goal = (prop >> 8) & 0xFF;
return attr_act.bits.state & attr_goal.bits.state;
return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal);
}
}
@@ -631,12 +630,12 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop,
else {
_lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_color_t));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
attr_act = get_style_prop_attr(style, id);
lv_style_attr_t attr_goal;
attr_goal.full = (prop >> 8) & 0xFF;
attr_goal = (prop >> 8) & 0xFF;
return attr_act.bits.state & attr_goal.bits.state;
return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal);
}
}
@@ -666,12 +665,12 @@ int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, vo
else {
_lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(const void *));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
attr_act = get_style_prop_attr(style, id);
lv_style_attr_t attr_goal;
attr_goal.full = (prop >> 8) & 0xFF;
attr_goal = (prop >> 8) & 0xFF;
return attr_act.bits.state & attr_goal.bits.state;
return LV_STYLE_ATTR_GET_STATE(attr_act) & LV_STYLE_ATTR_GET_STATE(attr_goal);
}
}
@@ -819,8 +818,8 @@ lv_res_t _lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop
if(list->style_list == NULL) return LV_RES_INV;
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight_goal = attr.full;
attr = prop >> 8;
int16_t weight_goal = attr;
int16_t weight = -1;
@@ -871,12 +870,13 @@ lv_res_t _lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t pr
if(list->style_list == NULL) return LV_RES_INV;
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight_goal = attr.full;
attr = prop >> 8;
int16_t weight_goal = attr;
int16_t weight = -1;
lv_color_t value_act = { 0 };
lv_color_t value_act;
value_act.full = 0;
int16_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
@@ -921,8 +921,8 @@ lv_res_t _lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop
if(list->style_list == NULL) return LV_RES_INV;
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight_goal = attr.full;
attr = prop >> 8;
int16_t weight_goal = attr;
int16_t weight = -1;
@@ -971,8 +971,8 @@ lv_res_t _lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop
if(list->style_list == NULL) return LV_RES_INV;
lv_style_attr_t attr;
attr.full = prop >> 8;
int16_t weight_goal = attr.full;
attr = prop >> 8;
int16_t weight_goal = attr;
int16_t weight = -1;
@@ -1040,7 +1040,6 @@ bool lv_debug_check_style_list(const lv_style_list_t * list)
return true;
}
/**********************
* STATIC FUNCTIONS
**********************/
@@ -1061,40 +1060,36 @@ LV_ATTRIBUTE_FAST_MEM static inline int32_t get_property_index(const lv_style_t
uint8_t id_to_find = prop & 0xFF;
lv_style_attr_t attr;
attr.full = (prop >> 8) & 0xFF;
attr = (prop >> 8) & 0xFF;
int16_t weight = -1;
int16_t id_guess = -1;
size_t i = 0;
while(style->map[i] != _LV_STYLE_CLOSEING_PROP) {
if(style->map[i] == id_to_find) {
uint8_t prop_id;
while((prop_id = get_style_prop_id(style, i)) != _LV_STYLE_CLOSEING_PROP) {
if(prop_id == id_to_find) {
lv_style_attr_t attr_i;
attr_i.full = style->map[i + 1];
attr_i = get_style_prop_attr(style, i);
/*If the state perfectly matches return this property*/
if(attr_i.bits.state == attr.bits.state) {
if(LV_STYLE_ATTR_GET_STATE(attr_i) == LV_STYLE_ATTR_GET_STATE(attr)) {
return i;
}
/* Be sure the property not specifies other state than the requested.
* E.g. For HOVER+PRESS, HOVER only is OK, but HOVER+FOCUS not*/
else if((attr_i.bits.state & (~attr.bits.state)) == 0) {
else if((LV_STYLE_ATTR_GET_STATE(attr_i) & (~LV_STYLE_ATTR_GET_STATE(attr))) == 0) {
/* Use this property if it describes better the requested state than the current candidate.
* E.g. for HOVER+FOCUS+PRESS prefer HOVER+FOCUS over FOCUS*/
if(attr_i.bits.state > weight) {
weight = attr_i.bits.state;
if(LV_STYLE_ATTR_GET_STATE(attr_i) > weight) {
weight = LV_STYLE_ATTR_GET_STATE(attr_i);
id_guess = i;
}
}
}
/*Go to the next property*/
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t);
else i += sizeof(const void *);
i += sizeof(lv_style_property_t);
i = get_next_prop_index(prop_id, i);
}
return id_guess;
@@ -1109,7 +1104,7 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list)
{
LV_ASSERT_STYLE_LIST(list);
if(list->has_local) return lv_style_list_get_style(list, 0);
if(list->has_local) return lv_style_list_get_style(list, list->has_trans ? 1 : 0);
lv_style_t * local_style = lv_mem_alloc(sizeof(lv_style_t));
LV_ASSERT_MEM(local_style);
@@ -1125,3 +1120,79 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list)
return local_style;
}
/**
* Resizes a style map. Useful entry point for debugging.
* @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)
{
style->map = lv_mem_realloc(style->map, sz);
}
/**
* Get style property in index.
* @param style pointer to style.
* @param idx index of the style in style->map
* @return property in style->map + idx
*/
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];
return prop;
}
/**
* Get style property id in index.
* @param style pointer to style.
* @param idx index of the style in style->map
* @return id of property in style->map + idx
*/
static inline uint8_t get_style_prop_id(const lv_style_t * style, size_t idx)
{
return get_style_prop(style, idx) & 0xFF;
}
/**
* Get style property attributes for index.
* @param style pointer to style.
* @param idx index of the style in style->map
* @return attribute of property in style->map + idx
*/
static inline uint8_t get_style_prop_attr(const lv_style_t * style, size_t idx)
{
return ((get_style_prop(style, idx) >> 8) & 0xFFU);
}
/**
* 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
*/
static inline size_t get_prop_size(uint8_t prop_id)
{
prop_id &= 0xF;
size_t size = sizeof(lv_style_property_t);
if(prop_id < LV_STYLE_ID_COLOR) size += sizeof(lv_style_int_t);
else if(prop_id < LV_STYLE_ID_OPA) size += sizeof(lv_color_t);
else if(prop_id < LV_STYLE_ID_PTR) size += sizeof(lv_opa_t);
else size += sizeof(const void *);
return size;
}
/**
* Get next property index, given current property and index.
* @param prop_id property id.
* @param idx index of the style in style->map
* @return index of next property in style->map
*/
static inline size_t get_next_prop_index(uint8_t prop_id, size_t idx)
{
return idx + get_prop_size(prop_id);
}

View File

@@ -81,13 +81,10 @@ enum {
typedef uint8_t lv_text_decor_t;
typedef union {
struct {
uint8_t state : 7; /* To which state the property refers to*/
uint8_t inherit : 1; /*1: The property can be inherited*/
} bits;
uint8_t full;
} lv_style_attr_t;
typedef uint8_t lv_style_attr_t;
#define LV_STYLE_ATTR_GET_INHERIT(f) ((f)&0x80)
#define LV_STYLE_ATTR_GET_STATE(f) ((f)&0x7F)
#define LV_STYLE_ID_VALUE 0x0 /*max 9 pcs*/
#define LV_STYLE_ID_COLOR 0x9 /*max 3 pcs*/
@@ -102,7 +99,7 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_TRANSFORM_WIDTH, 0x0, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE),
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_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_PAD_TOP, 0x1, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
@@ -137,8 +134,8 @@ enum {
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),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_Y, 0x5, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_X, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_Y, 0x5, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_SPREAD, 0x5, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_BLEND_MODE, 0x5, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_COLOR, 0x5, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
@@ -194,12 +191,12 @@ enum {
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_SCALE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 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),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_BORDER_WIDTH, 0xC, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_LINE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xC, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xC, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_LINE_WIDTH, 0xC, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xC, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xC, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE),
};
typedef uint16_t lv_style_property_t;
@@ -224,11 +221,37 @@ typedef struct {
#if LV_USE_ASSERT_STYLE
uint32_t sentinel;
#endif
uint8_t style_cnt;
uint8_t has_local : 1;
uint8_t has_trans : 1;
uint8_t skip_trans : 1; /*1: Temporally skip the transition style if any*/
uint8_t ignore_trans : 1; /*1: Mark that this style list shouldn't receive transitions at all*/
uint32_t style_cnt : 6;
uint32_t has_local : 1;
uint32_t has_trans : 1;
uint32_t skip_trans : 1; /*1: Temporally skip the transition style if any*/
uint32_t ignore_trans : 1; /*1: Mark that this style list shouldn't receive transitions at all*/
uint32_t valid_cache : 1; /*1: The cache is valid and can be used*/
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 pad_all_zero : 1;
uint32_t blend_mode_all_normal : 1;
uint32_t bg_opa_transp : 1;
uint32_t bg_opa_cover : 1;
uint32_t bg_grad_dir_none : 1;
uint32_t border_width_zero : 1;
uint32_t border_side_full : 1;
uint32_t border_post_off : 1;
uint32_t outline_width_zero : 1;
uint32_t pattern_img_null : 1;
uint32_t shadow_width_zero : 1;
uint32_t value_txt_str : 1;
uint32_t img_recolor_opa_transp : 1;
uint32_t text_space_zero : 1;
uint32_t text_decor_none : 1;
uint32_t text_font_normal : 1;
} lv_style_list_t;
/**********************
@@ -573,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);
#define LV_STYLE_CREATE(name, copy_p) static lv_style_t name; lv_style_init(&name); lv_style_copy(&name, copy_p);

View File

@@ -65,17 +65,18 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness,
* @param mask the arc will be drawn only in this mask
* @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right)
* @param end_angle the end angle of the arc
* @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used)
* @param opa_scale scale down all opacities by the factor
* @param clip_area the arc will be drawn only in this area
* @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc)
const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc)
{
if(dsc->opa <= LV_OPA_MIN) return;
if(dsc->width == 0) return;
if(start_angle == end_angle) return;
if(dsc->width > radius) dsc->width = radius;
lv_style_int_t width = dsc->width;
if(width > radius) width = radius;
lv_draw_rect_dsc_t cir_dsc;
lv_draw_rect_dsc_init(&cir_dsc);
@@ -83,7 +84,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
cir_dsc.bg_opa = LV_OPA_TRANSP;
cir_dsc.border_opa = dsc->opa;
cir_dsc.border_color = dsc->color;
cir_dsc.border_width = dsc->width;
cir_dsc.border_width = width;
cir_dsc.border_blend_mode = dsc->blend_mode;
lv_area_t area;
@@ -123,7 +124,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
q_dsc.end_angle = end_angle;
q_dsc.start_quarter = (start_angle / 90) & 0x3;
q_dsc.end_quarter = (end_angle / 90) & 0x3;
q_dsc.width = dsc->width;
q_dsc.width = width;
q_dsc.draw_dsc = &cir_dsc;
q_dsc.draw_area = &area;
q_dsc.clip_area = clip_area;
@@ -146,7 +147,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
lv_area_t round_area;
if(dsc->round_start) {
get_rounded_area(start_angle, radius, dsc->width, &round_area);
get_rounded_area(start_angle, radius, width, &round_area);
round_area.x1 += center_x;
round_area.x2 += center_x;
round_area.y1 += center_y;
@@ -156,7 +157,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
}
if(dsc->round_end) {
get_rounded_area(end_angle, radius, dsc->width, &round_area);
get_rounded_area(end_angle, radius, width, &round_area);
round_area.x1 += center_x;
round_area.x2 += center_x;
round_area.y1 += center_y;

View File

@@ -35,11 +35,11 @@ extern "C" {
* @param mask the arc will be drawn only in this mask
* @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right)
* @param end_angle the end angle of the arc
* @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used)
* @param opa_scale scale down all opacities by the factor
* @param clip_area the arc will be drawn only in this area
* @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc);
const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc);
/**********************
* MACROS

View File

@@ -36,9 +36,11 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
#if LV_USE_BLEND_MODES
static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
lv_color_t color, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
#endif
static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
@@ -49,17 +51,23 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
#if LV_USE_BLEND_MODES
static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
#endif
/**********************
* STATIC VARIABLES
**********************/
#if LV_USE_GPU || LV_USE_GPU_STM32_DMA2D
LV_ATTRIBUTE_DMA static lv_color_t blend_buf[LV_HOR_RES_MAX];
#endif
/**********************
* MACROS
**********************/
@@ -130,6 +138,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_fill(const lv_area_t * clip_area, const lv_
const lv_area_t * disp_area = &vdb->area;
lv_color_t * disp_buf = vdb->buf_act;
if(disp->driver.gpu_wait_cb) disp->driver.gpu_wait_cb(&disp->driver);
/* Get clipped fill area which is the real draw area.
* It is always the same or inside `fill_area` */
@@ -163,9 +172,11 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_fill(const lv_area_t * clip_area, const lv_
else if(mode == LV_BLEND_MODE_NORMAL) {
fill_normal(disp_area, disp_buf, &draw_area, color, opa, mask, mask_res);
}
#if LV_USE_BLEND_MODES
else {
fill_blended(disp_area, disp_buf, &draw_area, color, opa, mask, mask_res, mode);
}
#endif
}
/**
@@ -202,6 +213,8 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_map(const lv_area_t * clip_area, const lv_a
const lv_area_t * disp_area = &vdb->area;
lv_color_t * disp_buf = vdb->buf_act;
if(disp->driver.gpu_wait_cb) disp->driver.gpu_wait_cb(&disp->driver);
/* Now `draw_area` has absolute coordinates.
* Make it relative to `disp_area` to simplify draw to `disp_buf`*/
draw_area.x1 -= disp_area->x1;
@@ -226,9 +239,11 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_map(const lv_area_t * clip_area, const lv_a
else if(mode == LV_BLEND_MODE_NORMAL) {
map_normal(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res);
}
#if LV_USE_BLEND_MODES
else {
map_blended(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res, mode);
}
#endif
}
@@ -269,7 +284,7 @@ static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, con
for(x = draw_area->x1; x <= draw_area->x2; x++) {
if(mask_tmp[x]) {
disp->driver.set_px_cb(&disp->driver, (void *)disp_buf, disp_w, x, y, color,
(uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
(uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
}
}
mask_tmp += draw_area_w;
@@ -338,7 +353,6 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
else {
#if LV_USE_GPU
if(disp->driver.gpu_blend_cb && lv_area_get_size(draw_area) > GPU_SIZE_LIMIT) {
static lv_color_t blend_buf[LV_HOR_RES_MAX];
for(x = 0; x < draw_area_w ; x++) blend_buf[x].full = color.full;
for(y = draw_area->y1; y <= draw_area->y2; y++) {
@@ -352,7 +366,6 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
#if LV_USE_GPU_STM32_DMA2D
if(lv_area_get_size(draw_area) >= 240) {
static lv_color_t blend_buf[LV_HOR_RES_MAX] = {0};
if(blend_buf[0].full != color.full) lv_color_fill(blend_buf, color, LV_HOR_RES_MAX);
lv_coord_t line_h = LV_HOR_RES_MAX / draw_area_w;
@@ -513,7 +526,7 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
}
}
#if LV_USE_BLEND_MODES
/**
* Fill an area with a color but apply blending algorithms
* @param disp_area the current display area (destination area)
@@ -604,6 +617,7 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
}
}
}
#endif
static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
@@ -843,7 +857,7 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
}
}
}
#if LV_USE_BLEND_MODES
static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode)
@@ -994,3 +1008,4 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co
return lv_color_mix(fg, bg, opa);
}
#endif

View File

@@ -26,8 +26,10 @@ extern "C" {
**********************/
enum {
LV_BLEND_MODE_NORMAL,
#if LV_USE_BLEND_MODES
LV_BLEND_MODE_ADDITIVE,
LV_BLEND_MODE_SUBTRACTIVE,
#endif
};
typedef uint8_t lv_blend_mode_t;

View File

@@ -29,11 +29,11 @@
**********************/
LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * clip_area,
const void * src,
lv_draw_img_dsc_t * draw_dsc);
const lv_draw_img_dsc_t * draw_dsc);
LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
const uint8_t * map_p,
lv_draw_img_dsc_t * draw_dsc,
const lv_draw_img_dsc_t * draw_dsc,
bool chroma_key, bool alpha_byte);
static void show_error(const lv_area_t * coords, const lv_area_t * clip_area, const char * msg);
@@ -65,13 +65,9 @@ void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc)
* @param coords the coordinates of the image
* @param mask the image will be drawn only in this area
* @param src pointer to a lv_color_t array which contains the pixels of the image
* @param style style of the image
* @param angle rotation angle of the image
* @param center rotation center of the image
* @param antialias anti-alias transformations (rotate, zoom) or not
* @param opa_scale scale down all opacities by the factor
* @param dsc pointer to an initialized `lv_draw_img_dsc_t` variable
*/
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * dsc)
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_draw_img_dsc_t * dsc)
{
if(src == NULL) {
LV_LOG_WARN("Image draw: src is NULL");
@@ -232,7 +228,7 @@ lv_img_src_t lv_img_src_get_type(const void * src)
LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * clip_area,
const void * src,
lv_draw_img_dsc_t * draw_dsc)
const lv_draw_img_dsc_t * draw_dsc)
{
if(draw_dsc->opa <= LV_OPA_MIN) return LV_RES_OK;
@@ -327,18 +323,14 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords,
* @param cords_p coordinates the color map
* @param mask_p the map will drawn only on this area (truncated to VDB area)
* @param map_p pointer to a lv_color_t array
* @param opa opacity of the map
* @param draw_dsc pointer to an initialized `lv_draw_img_dsc_t` variable
* @param chroma_keyed true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels
* @param alpha_byte true: extra alpha byte is inserted for every pixel
* @param style style of the image
* @param angle angle in degree
* @param pivot center of rotation
* @param zoom zoom factor
* @param antialias anti-alias transformations (rotate, zoom) or not
*/
LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
const uint8_t * map_p,
lv_draw_img_dsc_t * draw_dsc, bool chroma_key, bool alpha_byte)
const lv_draw_img_dsc_t * draw_dsc,
bool chroma_key, bool alpha_byte)
{
/* Use the clip area as draw area*/
lv_area_t draw_area;
@@ -407,7 +399,6 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
return;
}
#endif
/*Build the image and a mask line-by-line*/
uint32_t mask_buf_size = lv_area_get_size(&draw_area) > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : lv_area_get_size(&draw_area);
lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t));
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size);
@@ -420,7 +411,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
lv_opa_t px_opa = map_px[LV_IMG_PX_SIZE_ALPHA_BYTE - 1];
mask_buf[px_i] = px_opa;
if(px_opa) {
#if LV_COLOR_DEPTH == 8
#if LV_COLOR_DEPTH == 8 || LV_COLOR_DEPTH == 1
map2[px_i].full = map_px[0];
#elif LV_COLOR_DEPTH == 16
map2[px_i].full = map_px[0] + (map_px[1] << 8);
@@ -458,9 +449,9 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
/*Most complicated case: transform or other mask or chroma keyed*/
else {
/*Build the image and a mask line-by-line*/
uint32_t mask_buf_size = lv_area_get_size(&draw_area) > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : lv_area_get_size(&draw_area);
lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t));
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size);
uint32_t mask_buf_size = lv_area_get_size(&draw_area) > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : lv_area_get_size(&draw_area);
lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t));
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size);
#if LV_USE_IMG_TRANSFORM
lv_img_transform_dsc_t trans_dsc;

View File

@@ -53,13 +53,9 @@ void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc);
* @param coords the coordinates of the image
* @param mask the image will be drawn only in this area
* @param src pointer to a lv_color_t array which contains the pixels of the image
* @param style style of the image
* @param angle rotation angle of the image
* @param center rotation center of the image
* @param antialias anti-alias transformations (rotate, zoom) or not
* @param opa_scale scale down all opacities by the factor
* @param dsc pointer to an initialized `lv_draw_img_dsc_t` variable
*/
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * dsc);
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_draw_img_dsc_t * dsc);
/**
* Get the type of an image source

View File

@@ -111,8 +111,10 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
* @param hint pointer to a `lv_draw_label_hint_t` variable.
* It is managed by the drawer to speed up the drawing of very long texts (thousands of lines).
*/
LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_label_dsc_t * dsc,
const char * txt, lv_draw_label_hint_t * hint)
LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask,
const lv_draw_label_dsc_t * dsc,
const char * txt,
lv_draw_label_hint_t * hint)
{
if(dsc->opa <= LV_OPA_MIN) return;
@@ -213,12 +215,12 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
sel_start = sel_end;
sel_end = tmp;
}
lv_draw_line_dsc_t line_dsc;
if((dsc->decor & LV_TEXT_DECOR_UNDERLINE) || (dsc->decor & LV_TEXT_DECOR_STRIKETHROUGH)) {
lv_draw_line_dsc_init(&line_dsc);
line_dsc.color = dsc->color;
line_dsc.width = (dsc->font->line_height + 5) / 10; /*+5 for rounding*/
line_dsc.width = font->underline_thickness ? font->underline_thickness : LV_MATH_MAX(font->line_height / 10, 1);
line_dsc.opa = dsc->opa;
line_dsc.blend_mode = dsc->blend_mode;
}
@@ -342,7 +344,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
lv_point_t p1;
lv_point_t p2;
p1.x = pos_x_start;
p1.y = pos.y + dsc->font->line_height - dsc->font->base_line + line_dsc.width / 2 + 1;
p1.y = pos.y + dsc->font->line_height - dsc->font->base_line - font->underline_position;
p2.x = pos.x;
p2.y = p1.y;
lv_draw_line(&p1, &p2, mask, &line_dsc);
@@ -420,7 +422,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_letter(const lv_point_t * pos_p, const
}
/* Don't draw anything if the character is empty. E.g. space */
if((g.box_h == 0) && (g.box_w == 0)) return;
if((g.box_h == 0) || (g.box_w == 0)) return;
int32_t pos_x = pos_p->x + g.ofs_x;
int32_t pos_y = pos_p->y + (font_p->line_height - font_p->base_line) - g.box_h - g.ofs_y;
@@ -607,6 +609,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
{
#if LV_USE_FONT_SUBPX
const uint8_t * bpp_opa_table;
uint32_t bitmask_init;
uint32_t bitmask;
@@ -758,7 +761,7 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
}
/*Go to the next column*/
if(col_bit < (int32_t) (8 - bpp)) {
if(col_bit < (int32_t)(8 - bpp)) {
col_bit += bpp;
bitmask = bitmask >> bpp;
}
@@ -806,6 +809,9 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
_lv_mem_buf_release(mask_buf);
_lv_mem_buf_release(color_buf);
#else
LV_LOG_WARN("Can't draw sub-pixel rendered letter because LV_USE_FONT_SUBPX == 0 in lv_conf.h");
#endif
}

View File

@@ -77,7 +77,8 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc);
* @param hint pointer to a `lv_draw_label_hint_t` variable.
* It is managed by the drawer to speed up the drawing of very long texts (thousands of lines).
*/
LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_label_dsc_t * dsc,
LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask,
const lv_draw_label_dsc_t * dsc,
const char * txt, lv_draw_label_hint_t * hint);
//! @endcond

View File

@@ -26,13 +26,13 @@
**********************/
LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
const lv_area_t * clip,
lv_draw_line_dsc_t * dsc);
const lv_draw_line_dsc_t * dsc);
LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2,
const lv_area_t * clip,
lv_draw_line_dsc_t * dsc);
const lv_draw_line_dsc_t * dsc);
LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2,
const lv_area_t * clip,
lv_draw_line_dsc_t * dsc);
const lv_draw_line_dsc_t * dsc);
/**********************
* STATIC VARIABLES
@@ -58,12 +58,11 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc)
* Draw a line
* @param point1 first point of the line
* @param point2 second point of the line
* @param mask the line will be drawn only on this area
* @param style pointer to a line's style
* @param opa_scale scale down all opacities by the factor
* @param clip the line will be drawn only in this area
* @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/
LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
lv_draw_line_dsc_t * dsc)
const lv_draw_line_dsc_t * dsc)
{
if(dsc->width == 0) return;
if(dsc->opa <= LV_OPA_MIN) return;
@@ -120,7 +119,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_poin
LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2,
const lv_area_t * clip,
lv_draw_line_dsc_t * dsc)
const lv_draw_line_dsc_t * dsc)
{
lv_opa_t opa = dsc->opa;
@@ -221,7 +220,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const
LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2,
const lv_area_t * clip,
lv_draw_line_dsc_t * dsc)
const lv_draw_line_dsc_t * dsc)
{
lv_opa_t opa = dsc->opa;
@@ -316,7 +315,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const
LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2,
const lv_area_t * clip,
lv_draw_line_dsc_t * dsc)
const lv_draw_line_dsc_t * dsc)
{
/*Keep the great y in p1*/
lv_point_t p1;

View File

@@ -43,12 +43,11 @@ typedef struct {
* Draw a line
* @param point1 first point of the line
* @param point2 second point of the line
* @param mask the line will be drawn only on this area
* @param style pointer to a line's style
* @param opa_scale scale down all opacities by the factor
* @param clip the line will be drawn only in this area
* @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/
LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask,
lv_draw_line_dsc_t * dsc);
LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip,
const lv_draw_line_dsc_t * dsc);
LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc);

View File

@@ -27,20 +27,32 @@
/**********************
* STATIC PROTOTYPES
**********************/
LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip,
const lv_draw_rect_dsc_t * dsc);
LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip,
lv_draw_rect_dsc_t * dsc);
static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i);
const lv_draw_rect_dsc_t * dsc);
#if LV_USE_OUTLINE
static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc);
#endif
#if LV_USE_SHADOW
LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip,
lv_draw_rect_dsc_t * dsc);
const lv_draw_rect_dsc_t * dsc);
LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf, lv_coord_t s,
lv_coord_t r);
LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups_buf);
#endif
static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
#if LV_USE_PATTERN
static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc);
#endif
#if LV_USE_VALUE_STR
static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc);
#endif
static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip,
lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(const lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i);
/**********************
* STATIC VARIABLES
@@ -85,9 +97,9 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
* Draw a rectangle
* @param coords the coordinates of the rectangle
* @param mask the rectangle will be drawn only in this mask
* @param style pointer to a style
* @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc)
{
if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return;
#if LV_USE_SHADOW
@@ -95,10 +107,19 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect
#endif
draw_bg(coords, clip, dsc);
#if LV_USE_PATTERN
draw_pattern(coords, clip, dsc);
#endif
draw_border(coords, clip, dsc);
draw_value(coords, clip, dsc);
#if LV_USE_VALUE_STR
draw_value_str(coords, clip, dsc);
#endif
#if LV_USE_OUTLINE
draw_outline(coords, clip, dsc);
#endif
LV_ASSERT_MEM_INTEGRITY();
}
@@ -142,7 +163,8 @@ void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_
* STATIC FUNCTIONS
**********************/
LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip,
const lv_draw_rect_dsc_t * dsc)
{
if(dsc->bg_opa <= LV_OPA_MIN) return;
@@ -364,46 +386,12 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
}
LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip,
lv_draw_rect_dsc_t * dsc)
const lv_draw_rect_dsc_t * dsc)
{
if(dsc->border_opa <= LV_OPA_MIN) return;
if(dsc->border_width == 0) return;
if(dsc->border_side == LV_BORDER_SIDE_NONE) return;
lv_opa_t opa = dsc->border_opa;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
/* Get clipped fill area which is the real draw area.
* It is always the same or inside `fill_area` */
lv_area_t draw_area;
bool is_common;
is_common = _lv_area_intersect(&draw_area, coords, clip);
if(is_common == false) return;
const lv_area_t * disp_area = &vdb->area;
/* Now `draw_area` has absolute coordinates.
* Make it relative to `disp_area` to simplify draw to `disp_buf`*/
draw_area.x1 -= disp_area->x1;
draw_area.y1 -= disp_area->y1;
draw_area.x2 -= disp_area->x1;
draw_area.y2 -= disp_area->y1;
int32_t draw_area_w = lv_area_get_width(&draw_area);
/*Create a mask if there is a radius*/
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w);
uint8_t other_mask_cnt = lv_draw_mask_get_cnt();
bool simple_mode = true;
if(other_mask_cnt) simple_mode = false;
else if(dsc->border_side != LV_BORDER_SIDE_FULL) simple_mode = false;
int16_t mask_rout_id = LV_MASK_ID_INV;
if(dsc->border_post) return;
int32_t coords_w = lv_area_get_width(coords);
int32_t coords_h = lv_area_get_height(coords);
@@ -413,140 +401,80 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
int32_t short_side = LV_MATH_MIN(coords_w, coords_h);
if(rout > short_side >> 1) rout = short_side >> 1;
/*Get the outer area*/
lv_draw_mask_radius_param_t mask_rout_param;
if(rout > 0) {
lv_draw_mask_radius_init(&mask_rout_param, coords, rout, false);
mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL);
}
/*Get the inner radius*/
int32_t rin = rout - dsc->border_width;
if(rin < 0) rin = 0;
/*Get the inner area*/
lv_area_t area_small;
lv_area_copy(&area_small, coords);
area_small.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? dsc->border_width : - (dsc->border_width + rout));
area_small.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? dsc->border_width : - (dsc->border_width + rout));
area_small.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? dsc->border_width : - (dsc->border_width + rout));
area_small.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? dsc->border_width : - (dsc->border_width + rout));
lv_area_t area_inner;
lv_area_copy(&area_inner, coords);
area_inner.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? dsc->border_width : - (dsc->border_width + rout));
area_inner.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? dsc->border_width : - (dsc->border_width + rout));
area_inner.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? dsc->border_width : - (dsc->border_width + rout));
area_inner.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? dsc->border_width : - (dsc->border_width + rout));
/*Create inner the mask*/
lv_draw_mask_radius_param_t mask_rin_param;
lv_draw_mask_radius_init(&mask_rin_param, &area_small, rout - dsc->border_width, true);
int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL);
int32_t corner_size = LV_MATH_MAX(rout, dsc->border_width - 1);
int32_t h;
lv_draw_mask_res_t mask_res;
lv_area_t fill_area;
lv_color_t color = dsc->border_color;
lv_blend_mode_t blend_mode = dsc->border_blend_mode;
/*Apply some optimization if there is no other mask*/
if(simple_mode) {
/*Draw the upper corner area*/
int32_t upper_corner_end = coords->y1 - disp_area->y1 + corner_size;
upper_corner_end = LV_MATH_MIN(upper_corner_end, draw_area.y2);
fill_area.x1 = coords->x1;
fill_area.x2 = coords->x2;
fill_area.y1 = disp_area->y1 + draw_area.y1;
fill_area.y2 = fill_area.y1;
for(h = draw_area.y1; h <= upper_corner_end; h++) {
_lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_area_t fill_area2;
fill_area2.y1 = fill_area.y1;
fill_area2.y2 = fill_area.y2;
fill_area2.x1 = coords->x1;
fill_area2.x2 = coords->x1 + rout - 1;
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
/*Draw the top horizontal line*/
if(fill_area2.y2 < coords->y1 + dsc->border_width) {
fill_area2.x1 = coords->x1 + rout;
fill_area2.x2 = coords->x2 - rout;
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
}
fill_area2.x1 = coords->x2 - rout + 1;
fill_area2.x2 = coords->x2;
int32_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
if(mask_ofs < 0) mask_ofs = 0;
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
fill_area.y1++;
fill_area.y2++;
}
/*Draw the lower corner area */
int32_t lower_corner_end = coords->y2 - disp_area->y1 - corner_size;
lower_corner_end = LV_MATH_MAX(lower_corner_end, draw_area.y1);
if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1;
fill_area.y1 = disp_area->y1 + lower_corner_end;
fill_area.y2 = fill_area.y1;
for(h = lower_corner_end; h <= draw_area.y2; h++) {
_lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_area_t fill_area2;
fill_area2.x1 = coords->x1;
fill_area2.x2 = coords->x1 + rout - 1;
fill_area2.y1 = fill_area.y1;
fill_area2.y2 = fill_area.y2;
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
/*Draw the bottom horizontal line*/
if(fill_area2.y2 > coords->y2 - dsc->border_width) {
fill_area2.x1 = coords->x1 + rout;
fill_area2.x2 = coords->x2 - rout;
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
}
fill_area2.x1 = coords->x2 - rout + 1;
fill_area2.x2 = coords->x2;
int32_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
if(mask_ofs < 0) mask_ofs = 0;
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
fill_area.y1++;
fill_area.y2++;
}
/*Draw the left vertical border part*/
fill_area.y1 = coords->y1 + corner_size + 1;
fill_area.y2 = coords->y2 - corner_size - 1;
fill_area.x1 = coords->x1;
fill_area.x2 = coords->x1 + dsc->border_width - 1;
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
/*Draw the right vertical border*/
fill_area.x1 = coords->x2 - dsc->border_width + 1;
fill_area.x2 = coords->x2;
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
if(dsc->border_side == LV_BORDER_SIDE_FULL) {
draw_full_border(&area_inner, coords, clip, dsc->radius, dsc->border_color, dsc->border_opa, dsc->border_blend_mode);
}
/*Process line by line if there is other mask too*/
else {
lv_opa_t opa = dsc->border_opa;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
/* Get clipped fill area which is the real draw area.
* It is always the same or inside `fill_area` */
lv_area_t draw_area;
bool is_common;
is_common = _lv_area_intersect(&draw_area, coords, clip);
if(is_common == false) return;
const lv_area_t * disp_area = &vdb->area;
/* Now `draw_area` has absolute coordinates.
* Make it relative to `disp_area` to simplify draw to `disp_buf`*/
draw_area.x1 -= disp_area->x1;
draw_area.y1 -= disp_area->y1;
draw_area.x2 -= disp_area->x1;
draw_area.y2 -= disp_area->y1;
int32_t draw_area_w = lv_area_get_width(&draw_area);
/*Create a mask if there is a radius*/
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w);
/*Create mask for the outer area*/
int16_t mask_rout_id = LV_MASK_ID_INV;
lv_draw_mask_radius_param_t mask_rout_param;
if(rout > 0) {
lv_draw_mask_radius_init(&mask_rout_param, coords, rout, false);
mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL);
}
/*Create mask for the inner mask*/
int32_t rin = rout - dsc->border_width;
if(rin < 0) rin = 0;
lv_draw_mask_radius_param_t mask_rin_param;
lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rout - dsc->border_width, true);
int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL);
int32_t corner_size = LV_MATH_MAX(rout, dsc->border_width - 1);
int32_t h;
lv_draw_mask_res_t mask_res;
lv_area_t fill_area;
lv_color_t color = dsc->border_color;
lv_blend_mode_t blend_mode = dsc->border_blend_mode;
fill_area.x1 = coords->x1;
fill_area.x2 = coords->x2;
fill_area.y1 = disp_area->y1 + draw_area.y1;
fill_area.y2 = fill_area.y1;
uint32_t buf_ofs = 0;
if(dsc->border_side == LV_BORDER_SIDE_LEFT) fill_area.x2 = coords->x1 + corner_size;
else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) fill_area.x1 = coords->x2 - corner_size;
else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) {
fill_area.x1 = coords->x2 - corner_size;
buf_ofs = fill_area.x1 - coords->x1;
}
volatile bool top_only = false;
volatile bool bottom_only = false;
@@ -565,19 +493,19 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
(bottom_only && fill_area.y1 >= coords->y2 - corner_size)) {
_lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
_lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
_lv_blend_fill(clip, &fill_area, color, mask_buf + buf_ofs, mask_res, opa, blend_mode);
}
fill_area.y1++;
fill_area.y2++;
}
lv_draw_mask_remove_id(mask_rin_id);
lv_draw_mask_remove_id(mask_rout_id);
_lv_mem_buf_release(mask_buf);
}
lv_draw_mask_remove_id(mask_rin_id);
lv_draw_mask_remove_id(mask_rout_id);
_lv_mem_buf_release(mask_buf);
}
LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i)
LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(const lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i)
{
int32_t min = (dsc->bg_main_color_stop * s) >> 8;
if(i <= min) return dsc->bg_color;
@@ -594,7 +522,7 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc
#if LV_USE_SHADOW
LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip,
lv_draw_rect_dsc_t * dsc)
const lv_draw_rect_dsc_t * dsc)
{
/*Check whether the shadow is visible*/
if(dsc->shadow_width == 0) return;
@@ -1047,7 +975,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
_lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf,
mask_res, LV_OPA_COVER, dsc->shadow_blend_mode);
mask_res, LV_OPA_COVER, dsc->shadow_blend_mode);
fa.y1++;
fa.y2++;
}
@@ -1111,7 +1039,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord
_lv_mem_buf_release(mask_line);
if(sw == 1) {
uint32_t i;
int32_t i;
lv_opa_t * res_buf = (lv_opa_t *)sh_buf;
for(i = 0; i < size * size; i++) {
res_buf[i] = (sh_buf[i] >> SHADOW_UPSACALE_SHIFT);
@@ -1140,7 +1068,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord
shadow_blur_corner(size, sw, sh_buf);
}
uint32_t x;
int32_t x;
lv_opa_t * res_buf = (lv_opa_t *)sh_buf;
for(x = 0; x < size * size; x++) {
res_buf[x] = sh_buf[x];
@@ -1222,7 +1150,8 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t
#endif
static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
#if LV_USE_OUTLINE
static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc)
{
if(dsc->outline_opa <= LV_OPA_MIN) return;
if(dsc->outline_width == 0) return;
@@ -1231,10 +1160,6 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
uint8_t other_mask_cnt = lv_draw_mask_get_cnt();
bool simple_mode = true;
if(other_mask_cnt) simple_mode = false;
/*Get the inner radius*/
lv_area_t area_inner;
lv_area_copy(&area_inner, coords);
@@ -1243,16 +1168,6 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr
area_inner.x2 += dsc->outline_pad;
area_inner.y2 += dsc->outline_pad;
int32_t inner_w = lv_area_get_width(&area_inner);
int32_t inner_h = lv_area_get_height(&area_inner);
int32_t rin = dsc->radius;
int32_t short_side = LV_MATH_MIN(inner_w, inner_h);
if(rin > short_side >> 1) rin = short_side >> 1;
/*Get the outer area*/
int32_t rout = rin + dsc->outline_width;
lv_area_t area_outer;
lv_area_copy(&area_outer, &area_inner);
@@ -1261,166 +1176,13 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr
area_outer.y1 -= dsc->outline_width;
area_outer.y2 += dsc->outline_width;
int32_t coords_out_w = lv_area_get_width(&area_outer);
int32_t coords_out_h = lv_area_get_height(&area_outer);
short_side = LV_MATH_MIN(coords_out_w, coords_out_h);
if(rout > short_side >> 1) rout = short_side >> 1;
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
/* Get clipped fill area which is the real draw area.
* It is always the same or inside `fill_area` */
lv_area_t draw_area;
bool is_common;
is_common = _lv_area_intersect(&draw_area, &area_outer, clip);
if(is_common == false) return;
const lv_area_t * disp_area = &vdb->area;
/* Now `draw_area` has absolute coordinates.
* Make it relative to `disp_area` to simplify draw to `disp_buf`*/
draw_area.x1 -= disp_area->x1;
draw_area.y1 -= disp_area->y1;
draw_area.x2 -= disp_area->x1;
draw_area.y2 -= disp_area->y1;
int32_t draw_area_w = lv_area_get_width(&draw_area);
/*Create inner the mask*/
lv_draw_mask_radius_param_t mask_rin_param;
lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rin, true);
int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL);
lv_draw_mask_radius_param_t mask_rout_param;
lv_draw_mask_radius_init(&mask_rout_param, &area_outer, rout, false);
int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL);
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w);
int32_t corner_size = LV_MATH_MAX(rout, dsc->outline_width - 1);
int32_t h;
lv_draw_mask_res_t mask_res;
lv_area_t fill_area;
lv_color_t color = dsc->outline_color;
lv_blend_mode_t blend_mode = dsc->outline_blend_mode;
/*Apply some optimization if there is no other mask*/
if(simple_mode) {
/*Draw the upper corner area*/
int32_t upper_corner_end = area_outer.y1 - disp_area->y1 + corner_size;
fill_area.x1 = area_outer.x1;
fill_area.x2 = area_outer.x2;
fill_area.y1 = disp_area->y1 + draw_area.y1;
fill_area.y2 = fill_area.y1;
for(h = draw_area.y1; h <= upper_corner_end; h++) {
_lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_area_t fill_area2;
fill_area2.y1 = fill_area.y1;
fill_area2.y2 = fill_area.y2;
fill_area2.x1 = area_outer.x1;
fill_area2.x2 = area_outer.x1 + rout - 1;
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
/*Draw the top horizontal line*/
if(fill_area2.y2 < area_outer.y1 + dsc->outline_width) {
fill_area2.x1 = area_outer.x1 + rout;
fill_area2.x2 = area_outer.x2 - rout;
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
}
fill_area2.x1 = area_outer.x2 - rout + 1;
fill_area2.x2 = area_outer.x2;
int32_t mask_ofs = (area_outer.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
if(mask_ofs < 0) mask_ofs = 0;
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
fill_area.y1++;
fill_area.y2++;
}
/*Draw the lower corner area */
int32_t lower_corner_end = area_outer.y2 - disp_area->y1 - corner_size;
if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1;
fill_area.y1 = disp_area->y1 + lower_corner_end;
fill_area.y2 = fill_area.y1;
for(h = lower_corner_end; h <= draw_area.y2; h++) {
_lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_area_t fill_area2;
fill_area2.x1 = area_outer.x1;
fill_area2.x2 = area_outer.x1 + rout - 1;
fill_area2.y1 = fill_area.y1;
fill_area2.y2 = fill_area.y2;
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
/*Draw the bottom horizontal line*/
if(fill_area2.y2 > area_outer.y2 - dsc->outline_width) {
fill_area2.x1 = area_outer.x1 + rout;
fill_area2.x2 = area_outer.x2 - rout;
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
}
fill_area2.x1 = area_outer.x2 - rout + 1;
fill_area2.x2 = area_outer.x2;
int32_t mask_ofs = (area_outer.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
if(mask_ofs < 0) mask_ofs = 0;
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
fill_area.y1++;
fill_area.y2++;
}
/*Draw the left vertical part*/
fill_area.y1 = area_outer.y1 + corner_size + 1;
fill_area.y2 = area_outer.y2 - corner_size - 1;
fill_area.x1 = area_outer.x1;
fill_area.x2 = area_outer.x1 + dsc->outline_width - 1;
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
/*Draw the right vertical border*/
fill_area.x1 = area_outer.x2 - dsc->outline_width + 1;
fill_area.x2 = area_outer.x2;
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
}
/*Process line by line if there is other mask too*/
else {
fill_area.x1 = area_outer.x1;
fill_area.x2 = area_outer.x2;
fill_area.y1 = disp_area->y1 + draw_area.y1;
fill_area.y2 = fill_area.y1;
for(h = draw_area.y1; h <= draw_area.y2; h++) {
_lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
_lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
fill_area.y1++;
fill_area.y2++;
}
}
lv_draw_mask_remove_id(mask_rin_id);
lv_draw_mask_remove_id(mask_rout_id);
_lv_mem_buf_release(mask_buf);
draw_full_border(&area_inner, &area_outer, clip, dsc->radius, dsc->outline_color, dsc->outline_opa,
dsc->outline_blend_mode);
}
#endif
static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
#if LV_USE_PATTERN
static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc)
{
if(dsc->pattern_image == NULL) return;
if(dsc->pattern_opa <= LV_OPA_MIN) return;
@@ -1467,6 +1229,9 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr
return;
}
/*Can't draw zero sized images*/
if(img_w == 0 || img_h == 0) return;
lv_area_t coords_tmp;
if(dsc->pattern_repeat) {
@@ -1520,9 +1285,11 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr
lv_draw_mask_remove_id(radius_mask_id);
}
}
#endif
static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
#if LV_USE_VALUE_STR
static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc)
{
if(dsc->value_str == NULL) return;
if(dsc->value_opa <= LV_OPA_MIN) return;
@@ -1555,4 +1322,179 @@ static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw
lv_draw_label(&value_area, clip, &label_dsc, dsc->value_str, NULL);
}
#endif
static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip,
lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
{
uint8_t other_mask_cnt = lv_draw_mask_get_cnt();
bool simple_mode = true;
if(other_mask_cnt) simple_mode = false;
int32_t inner_w = lv_area_get_width(area_inner);
int32_t inner_h = lv_area_get_height(area_inner);
lv_coord_t border_width = area_outer->x2 - area_inner->x2;
int32_t rin = radius;
int32_t short_side = LV_MATH_MIN(inner_w, inner_h);
if(rin > short_side >> 1) rin = short_side >> 1;
/*Get the outer area*/
int32_t rout = rin + border_width;
int32_t coords_out_w = lv_area_get_width(area_outer);
int32_t coords_out_h = lv_area_get_height(area_outer);
short_side = LV_MATH_MIN(coords_out_w, coords_out_h);
if(rout > short_side >> 1) rout = short_side >> 1;
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
/* Get clipped fill area which is the real draw area.
* It is always the same or inside `fill_area` */
lv_area_t draw_area;
bool is_common;
is_common = _lv_area_intersect(&draw_area, area_outer, clip);
if(is_common == false) return;
const lv_area_t * disp_area = &vdb->area;
/* Now `draw_area` has absolute coordinates.
* Make it relative to `disp_area` to simplify draw to `disp_buf`*/
draw_area.x1 -= disp_area->x1;
draw_area.y1 -= disp_area->y1;
draw_area.x2 -= disp_area->x1;
draw_area.y2 -= disp_area->y1;
int32_t draw_area_w = lv_area_get_width(&draw_area);
/*Create inner the mask*/
lv_draw_mask_radius_param_t mask_rin_param;
lv_draw_mask_radius_init(&mask_rin_param, area_inner, rin, true);
int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL);
lv_draw_mask_radius_param_t mask_rout_param;
lv_draw_mask_radius_init(&mask_rout_param, area_outer, rout, false);
int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL);
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w);
int32_t corner_size = LV_MATH_MAX(rout, border_width - 1);
int32_t h;
lv_draw_mask_res_t mask_res;
lv_area_t fill_area;
/*Apply some optimization if there is no other mask*/
if(simple_mode) {
/*Draw the upper corner area*/
int32_t upper_corner_end = area_outer->y1 - disp_area->y1 + corner_size;
fill_area.x1 = area_outer->x1;
fill_area.x2 = area_outer->x2;
fill_area.y1 = disp_area->y1 + draw_area.y1;
fill_area.y2 = fill_area.y1;
for(h = draw_area.y1; h <= upper_corner_end; h++) {
_lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_area_t fill_area2;
fill_area2.y1 = fill_area.y1;
fill_area2.y2 = fill_area.y2;
fill_area2.x1 = area_outer->x1;
fill_area2.x2 = area_outer->x1 + rout - 1;
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
/*Draw the top horizontal line*/
if(fill_area2.y2 < area_outer->y1 + border_width) {
fill_area2.x1 = area_outer->x1 + rout;
fill_area2.x2 = area_outer->x2 - rout;
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
}
fill_area2.x1 = area_outer->x2 - rout + 1;
fill_area2.x2 = area_outer->x2;
int32_t mask_ofs = (area_outer->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
if(mask_ofs < 0) mask_ofs = 0;
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
fill_area.y1++;
fill_area.y2++;
}
/*Draw the lower corner area */
int32_t lower_corner_end = area_outer->y2 - disp_area->y1 - corner_size;
if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1;
fill_area.y1 = disp_area->y1 + lower_corner_end;
fill_area.y2 = fill_area.y1;
for(h = lower_corner_end; h <= draw_area.y2; h++) {
_lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_area_t fill_area2;
fill_area2.x1 = area_outer->x1;
fill_area2.x2 = area_outer->x1 + rout - 1;
fill_area2.y1 = fill_area.y1;
fill_area2.y2 = fill_area.y2;
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
/*Draw the bottom horizontal line*/
if(fill_area2.y2 > area_outer->y2 - border_width) {
fill_area2.x1 = area_outer->x1 + rout;
fill_area2.x2 = area_outer->x2 - rout;
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
}
fill_area2.x1 = area_outer->x2 - rout + 1;
fill_area2.x2 = area_outer->x2;
int32_t mask_ofs = (area_outer->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
if(mask_ofs < 0) mask_ofs = 0;
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
fill_area.y1++;
fill_area.y2++;
}
/*Draw the left vertical part*/
fill_area.y1 = area_outer->y1 + corner_size + 1;
fill_area.y2 = area_outer->y2 - corner_size - 1;
fill_area.x1 = area_outer->x1;
fill_area.x2 = area_outer->x1 + border_width - 1;
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
/*Draw the right vertical border*/
fill_area.x1 = area_outer->x2 - border_width + 1;
fill_area.x2 = area_outer->x2;
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
}
/*Process line by line if there is other mask too*/
else {
fill_area.x1 = area_outer->x1;
fill_area.x2 = area_outer->x2;
fill_area.y1 = disp_area->y1 + draw_area.y1;
fill_area.y2 = fill_area.y1;
for(h = draw_area.y1; h <= draw_area.y2; h++) {
_lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
_lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
fill_area.y1++;
fill_area.y2++;
}
}
lv_draw_mask_remove_id(mask_rin_id);
lv_draw_mask_remove_id(mask_rout_id);
_lv_mem_buf_release(mask_buf);
}

View File

@@ -41,6 +41,7 @@ typedef struct {
lv_style_int_t border_side;
lv_opa_t border_opa;
lv_blend_mode_t border_blend_mode;
uint8_t border_post : 1; /*There is a border it will be drawn later. */
/*Outline*/
lv_color_t outline_color;
@@ -92,9 +93,9 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc);
* Draw a rectangle
* @param coords the coordinates of the rectangle
* @param mask the rectangle will be drawn only in this mask
* @param style pointer to a style
* @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, lv_draw_rect_dsc_t * dsc);
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_draw_rect_dsc_t * dsc);
/**
* Draw a pixel

View File

@@ -40,7 +40,7 @@
* @param clip_area the triangle will be drawn only in this area
* @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip_area, lv_draw_rect_dsc_t * draw_dsc)
void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip_area, const lv_draw_rect_dsc_t * draw_dsc)
{
lv_draw_polygon(points, 3, clip_area, draw_dsc);
}
@@ -53,7 +53,7 @@ void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip_area, lv
* @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_area_t * clip_area,
lv_draw_rect_dsc_t * draw_dsc)
const lv_draw_rect_dsc_t * draw_dsc)
{
if(point_cnt < 3) return;
if(points == NULL) return;

View File

@@ -33,7 +33,7 @@ extern "C" {
* @param clip_area the triangle will be drawn only in this area
* @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, lv_draw_rect_dsc_t * draw_dsc);
void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, const lv_draw_rect_dsc_t * draw_dsc);
/**
* Draw a polygon. Only convex polygons are supported.
@@ -43,7 +43,7 @@ void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, lv_draw
* @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_area_t * mask,
lv_draw_rect_dsc_t * draw_dsc);
const lv_draw_rect_dsc_t * draw_dsc);
/**********************
* MACROS

View File

@@ -435,6 +435,10 @@ void _lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc)
dsc->tmp.sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10;
dsc->tmp.cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10;
/*Use smaller value to avoid overflow*/
dsc->tmp.sinma = dsc->tmp.sinma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT);
dsc->tmp.cosma = dsc->tmp.cosma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT);
dsc->tmp.chroma_keyed = lv_img_cf_is_chroma_keyed(dsc->cfg.cf) ? 1 : 0;
dsc->tmp.has_alpha = lv_img_cf_has_alpha(dsc->cfg.cf) ? 1 : 0;
if(dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR || dsc->cfg.cf == LV_IMG_CF_TRUE_COLOR_ALPHA ||
@@ -451,7 +455,9 @@ void _lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc)
dsc->tmp.img_dsc.header.w = dsc->cfg.src_w;
dsc->tmp.img_dsc.header.h = dsc->cfg.src_h;
dsc->tmp.zoom_inv = (256 * 256) / dsc->cfg.zoom;
/* The inverse of the zoom will be sued during the transformation
* + dsc->cfg.zoom / 2 for rounding*/
dsc->tmp.zoom_inv = (((256 * 256) << _LV_ZOOM_INV_UPSCALE) + dsc->cfg.zoom / 2) / dsc->cfg.zoom;
dsc->res.opa = LV_OPA_COVER;
dsc->res.color = dsc->cfg.color;
@@ -468,9 +474,31 @@ void _lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc)
* @param pivot x,y pivot coordinates of rotation
*/
void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom,
lv_point_t * pivot)
const lv_point_t * pivot)
{
#if LV_USE_IMG_TRANSFORM
if(angle == 0 && zoom == LV_IMG_ZOOM_NONE) {
res->x1 = 0;
res->y1 = 0;
res->x2 = w - 1;
res->y2 = h - 1;
return;
}
res->x1 = (((-pivot->x) * zoom) >> 8) - 1;
res->y1 = (((-pivot->y) * zoom) >> 8) - 1;
res->x2 = (((w - pivot->x) * zoom) >> 8) + 2;
res->y2 = (((h - pivot->y) * zoom) >> 8) + 2;
if(angle == 0) {
res->x1 += pivot->x;
res->y1 += pivot->y;
res->x2 += pivot->x;
res->y2 += pivot->y;
return;
}
int32_t angle_low = angle / 10;
int32_t angle_hight = angle_low + 1;
int32_t angle_rem = angle - (angle_low * 10);
@@ -484,6 +512,10 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t
int32_t sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10;
int32_t cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10;
/*Use smaller value to avoid overflow*/
sinma = sinma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT);
cosma = cosma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT);
lv_point_t lt;
lv_point_t rt;
lv_point_t lb;
@@ -492,31 +524,25 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t
lv_coord_t xt;
lv_coord_t yt;
lv_area_t a;
a.x1 = ((-pivot->x) * zoom) >> 8;
a.y1 = ((-pivot->y) * zoom) >> 8;
a.x2 = ((w - pivot->x) * zoom) >> 8;
a.y2 = ((h - pivot->y) * zoom) >> 8;
xt = res->x1;
yt = res->y1;
lt.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x;
lt.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y;
xt = a.x1;
yt = a.y1;
lt.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x;
lt.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y;
xt = res->x2;
yt = res->y1;
rt.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x;
rt.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y;
xt = a.x2;
yt = a.y1;
rt.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x;
rt.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y;
xt = res->x1;
yt = res->y2;
lb.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x;
lb.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y;
xt = a.x1;
yt = a.y2;
lb.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x;
lb.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y;
xt = a.x2;
yt = a.y2;
rb.x = ((cosma * xt - sinma * yt) >> LV_TRIGO_SHIFT) + pivot->x;
rb.y = ((sinma * xt + cosma * yt) >> LV_TRIGO_SHIFT) + pivot->y;
xt = res->x2;
yt = res->y2;
rb.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x;
rb.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y;
res->x1 = LV_MATH_MIN4(lb.x, lt.x, rb.x, rt.x);
res->x2 = LV_MATH_MAX4(lb.x, lt.x, rb.x, rt.x);
@@ -528,8 +554,8 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t
LV_UNUSED(pivot);
res->x1 = 0;
res->y1 = 0;
res->x2 = w;
res->y2 = h;
res->x2 = w - 1;
res->y2 = h - 1;
#endif
}

View File

@@ -48,6 +48,9 @@ extern "C" {
#define LV_IMG_ZOOM_NONE 256
#define _LV_TRANSFORM_TRIGO_SHIFT 10
#define _LV_ZOOM_INV_UPSCALE 5
/**********************
* TYPEDEFS
**********************/
@@ -102,10 +105,26 @@ typedef uint8_t lv_img_cf_t;
/**
* LVGL image header
*/
/* The first 8 bit is very important to distinguish the different source types.
* For more info see `lv_img_get_src_type()` in lv_img.c
* On big endian systems the order is reversed so cf and always_zero must be at
* the end of the struct.
* */
#if LV_BIG_ENDIAN_SYSTEM
typedef struct {
uint32_t h : 11; /*Height of the image map*/
uint32_t w : 11; /*Width of the image map*/
uint32_t reserved : 2; /*Reserved to be used later*/
uint32_t always_zero : 3; /*It the upper bits of the first byte. Always zero to look like a
non-printable character*/
uint32_t cf : 5; /* Color format: See `lv_img_color_format_t`*/
} lv_img_header_t;
#else
typedef struct {
/* The first 8 bit is very important to distinguish the different source types.
* For more info see `lv_img_get_src_type()` in lv_img.c */
uint32_t cf : 5; /* Color format: See `lv_img_color_format_t`*/
uint32_t always_zero : 3; /*It the upper bits of the first byte. Always zero to look like a
non-printable character*/
@@ -115,7 +134,7 @@ typedef struct {
uint32_t w : 11; /*Width of the image map*/
uint32_t h : 11; /*Height of the image map*/
} lv_img_header_t;
#endif
/** Image header it is compatible with
* the result from image converter utility*/
@@ -156,7 +175,7 @@ typedef struct {
uint8_t has_alpha : 1;
uint8_t native_color : 1;
uint16_t zoom_inv;
uint32_t zoom_inv;
/*Runtime data*/
lv_coord_t xs;
@@ -285,20 +304,20 @@ static inline bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_
int32_t ys;
if(dsc->cfg.zoom == LV_IMG_ZOOM_NONE) {
/*Get the source pixel from the upscaled image*/
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (LV_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256;
ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (LV_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256;
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256;
ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256;
}
else if(dsc->cfg.angle == 0) {
xt *= dsc->tmp.zoom_inv;
yt *= dsc->tmp.zoom_inv;
xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
xs = xt + dsc->tmp.pivot_x_256;
ys = yt + dsc->tmp.pivot_y_256;
}
else {
xt *= dsc->tmp.zoom_inv;
yt *= dsc->tmp.zoom_inv;
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (LV_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256;
ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (LV_TRIGO_SHIFT)) + dsc->tmp.pivot_y_256;
xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256;
ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_y_256;
}
/*Get the integer part of the source pixel*/
@@ -364,7 +383,7 @@ static inline bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_
* @param pivot x,y pivot coordinates of rotation
*/
void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom,
lv_point_t * pivot);
const lv_point_t * pivot);
/**********************
* MACROS

View File

@@ -59,7 +59,7 @@ static uint16_t entry_cnt;
* The image will be left open meaning if the image decoder open callback allocated memory then it will remain.
* The image is closed if a new image is opened and the new image takes its place in the cache.
* @param src source of the image. Path to file or pointer to an `lv_img_dsc_t` variable
* @param style style of the image
* @param color color The color of the image with `LV_IMG_CF_ALPHA_...`
* @return pointer to the cache entry or NULL if can open the image
*/
lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color)

View File

@@ -46,7 +46,7 @@ typedef struct {
* The image will be left open meaning if the image decoder open callback allocated memory then it will remain.
* The image is closed if a new image is opened and the new image takes its place in the cache.
* @param src source of the image. Path to file or pointer to an `lv_img_dsc_t` variable
* @param style style of the image
* @param color The color of the image with `LV_IMG_CF_ALPHA_...`
* @return pointer to the cache entry or NULL if can open the image
*/
lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color);

View File

@@ -89,6 +89,9 @@ 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_res_t res = LV_RES_INV;
lv_img_decoder_t * d;
@@ -111,7 +114,7 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header)
* 1) File name: E.g. "S:folder/img1.png" (The drivers needs to registered via `lv_fs_add_drv()`)
* 2) Variable: Pointer to an `lv_img_dsc_t` variable
* 3) Symbol: E.g. `LV_SYMBOL_OK`
* @param style the style of the image
* @param color The color of the image with `LV_IMG_CF_ALPHA_...`
* @return LV_RES_OK: opened the image. `dsc->img_data` and `dsc->header` are set.
* LV_RES_INV: none of the registered image decoders were able to open the image.
*/
@@ -150,10 +153,6 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co
if(res == LV_RES_OK) break;
}
if(res == LV_RES_INV) {
_lv_memset_00(dsc, sizeof(lv_img_decoder_dsc_t));
}
return res;
}
@@ -560,7 +559,7 @@ static lv_res_t lv_img_decoder_built_in_line_true_color(lv_img_decoder_dsc_t * d
}
uint32_t btr = len * (px_size >> 3);
uint32_t br = 0;
lv_fs_read(user_data->f, buf, btr, &br);
res = lv_fs_read(user_data->f, buf, btr, &br);
if(res != LV_FS_RES_OK || btr != br) {
LV_LOG_WARN("Built-in image decoder read failed");
return LV_RES_INV;

View File

@@ -157,7 +157,7 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header);
* 1) File name: E.g. "S:folder/img1.png" (The drivers needs to registered via `lv_fs_add_drv()`)
* 2) Variable: Pointer to an `lv_img_dsc_t` variable
* 3) Symbol: E.g. `LV_SYMBOL_OK`
* @param style the style of the image
* @param color The color of the image with `LV_IMG_CF_ALPHA_...`
* @return LV_RES_OK: opened the image. `dsc->img_data` and `dsc->header` are set.
* LV_RES_INV: none of the registered image decoders were able to open the image.
*/

View File

@@ -71,6 +71,10 @@ typedef struct _lv_font_struct {
lv_coord_t line_height; /**< The real line height where any text fits*/
lv_coord_t base_line; /**< Base line measured from the top of the line_height*/
uint8_t subpx : 2; /**< An element of `lv_font_subpx_t`*/
int8_t underline_position; /**< Distance between the top of the underline and base line (< 0 means below the base line)*/
int8_t underline_thickness; /**< Thickness of the underline*/
void * dsc; /**< Store implementation specific or run_time data or caching here*/
#if LV_USE_USER_DATA
lv_font_user_data_t user_data; /**< Custom user data for font. */
@@ -171,6 +175,10 @@ LV_FONT_DECLARE(lv_font_montserrat_30)
LV_FONT_DECLARE(lv_font_montserrat_32)
#endif
#if LV_FONT_MONTSERRAT_34
LV_FONT_DECLARE(lv_font_montserrat_34)
#endif
#if LV_FONT_MONTSERRAT_36
LV_FONT_DECLARE(lv_font_montserrat_36)
#endif

View File

@@ -1,5 +1,6 @@
CSRCS += lv_font.c
CSRCS += lv_font_fmt_txt.c
CSRCS += lv_font_loader.c
CSRCS += lv_font_montserrat_12.c
CSRCS += lv_font_montserrat_14.c
CSRCS += lv_font_montserrat_16.c

View File

@@ -11,10 +11,15 @@
#include "../lv_misc/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_misc/lv_types.h"
#include "../lv_misc/lv_gc.h"
#include "../lv_misc/lv_log.h"
#include "../lv_misc/lv_utils.h"
#include "../lv_misc/lv_mem.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
* DEFINES
*********************/
@@ -37,18 +42,16 @@ static int32_t unicode_list_compare(const void * ref, const void * element);
static int32_t kern_pair_8_compare(const void * ref, const void * element);
static int32_t kern_pair_16_compare(const void * ref, const void * element);
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp);
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp, bool prefilter);
static inline void decompress_line(uint8_t * out, lv_coord_t w);
static inline uint8_t get_bits(const uint8_t * in, uint32_t bit_pos, uint8_t len);
static inline void bits_write(uint8_t * out, uint32_t bit_pos, uint8_t val, uint8_t len);
static inline void rle_init(const uint8_t * in, uint8_t bpp);
static inline uint8_t rle_next(void);
/**********************
* STATIC VARIABLES
**********************/
static uint8_t * decompr_buf;
static uint32_t rle_rdp;
static const uint8_t * rle_in;
static uint8_t rle_bpp;
@@ -89,6 +92,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
}
/*Handle compressed bitmap*/
else {
#if LV_USE_FONT_COMPRESSED
uint32_t gsize = gdsc->box_w * gdsc->box_h;
if(gsize == 0) return NULL;
@@ -109,14 +113,20 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
break;
}
if(_lv_mem_get_size(decompr_buf) < buf_size) {
decompr_buf = lv_mem_realloc(decompr_buf, buf_size);
LV_ASSERT_MEM(decompr_buf);
if(decompr_buf == NULL) return NULL;
if(_lv_mem_get_size(LV_GC_ROOT(_lv_font_decompr_buf)) < buf_size) {
LV_GC_ROOT(_lv_font_decompr_buf) = lv_mem_realloc(LV_GC_ROOT(_lv_font_decompr_buf), buf_size);
LV_ASSERT_MEM(LV_GC_ROOT(_lv_font_decompr_buf));
if(LV_GC_ROOT(_lv_font_decompr_buf) == NULL) return NULL;
}
decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp);
return decompr_buf;
bool prefilter = fdsc->bitmap_format == LV_FONT_FMT_TXT_COMPRESSED ? true : false;
decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], LV_GC_ROOT(_lv_font_decompr_buf), gdsc->box_w, gdsc->box_h,
(uint8_t)fdsc->bpp,
prefilter);
return LV_GC_ROOT(_lv_font_decompr_buf);
#else /* !LV_USE_FONT_COMPRESSED */
return NULL;
#endif
}
/*If not returned earlier then the letter is not found in this font*/
@@ -179,9 +189,9 @@ bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t *
*/
void _lv_font_clean_up_fmt_txt(void)
{
if(decompr_buf) {
lv_mem_free(decompr_buf);
decompr_buf = NULL;
if(LV_GC_ROOT(_lv_font_decompr_buf)) {
lv_mem_free(LV_GC_ROOT(_lv_font_decompr_buf));
LV_GC_ROOT(_lv_font_decompr_buf) = NULL;
}
}
@@ -214,7 +224,8 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_8[rcp];
}
else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_TINY) {
uint8_t * p = _lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length,
uint16_t key = rcp;
uint8_t * p = _lv_utils_bsearch(&key, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length,
sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);
if(p) {
@@ -224,7 +235,8 @@ static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
}
}
else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_FULL) {
uint8_t * p = _lv_utils_bsearch(&rcp, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length,
uint16_t key = rcp;
uint8_t * p = _lv_utils_bsearch(&key, fdsc->cmaps[i].unicode_list, fdsc->cmaps[i].list_length,
sizeof(fdsc->cmaps[i].unicode_list[0]), unicode_list_compare);
if(p) {
@@ -332,8 +344,9 @@ static int32_t kern_pair_16_compare(const void * ref, const void * element)
* @param out buffer to store the result
* @param px_num number of pixels in the glyph (width * height)
* @param bpp bit per pixel (bpp = 3 will be converted to bpp = 4)
* @param prefilter true: the lines are XORed
*/
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp)
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp, bool prefilter)
{
uint32_t wrp = 0;
uint8_t wr_size = bpp;
@@ -342,7 +355,12 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
rle_init(in, bpp);
uint8_t * line_buf1 = _lv_mem_buf_get(w);
uint8_t * line_buf2 = _lv_mem_buf_get(w);
uint8_t * line_buf2 = NULL;
if(prefilter) {
line_buf2 = _lv_mem_buf_get(w);
}
decompress_line(line_buf1, w);
@@ -355,12 +373,22 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
}
for(y = 1; y < h; y++) {
decompress_line(line_buf2, w);
if(prefilter) {
decompress_line(line_buf2, w);
for(x = 0; x < w; x++) {
line_buf1[x] = line_buf2[x] ^ line_buf1[x];
bits_write(out, wrp, line_buf1[x], bpp);
wrp += wr_size;
for(x = 0; x < w; x++) {
line_buf1[x] = line_buf2[x] ^ line_buf1[x];
bits_write(out, wrp, line_buf1[x], bpp);
wrp += wr_size;
}
}
else {
decompress_line(line_buf1, w);
for(x = 0; x < w; x++) {
bits_write(out, wrp, line_buf1[x], bpp);
wrp += wr_size;
}
}
}

View File

@@ -150,6 +150,7 @@ typedef struct {
typedef enum {
LV_FONT_FMT_TXT_PLAIN = 0,
LV_FONT_FMT_TXT_COMPRESSED = 1,
LV_FONT_FMT_TXT_COMPRESSED_NO_PREFILTER = 1,
} lv_font_fmt_txt_bitmap_format_t;

View File

@@ -0,0 +1,694 @@
/**
* @file lv_font_loader.c
*
*/
/*********************
* INCLUDES
*********************/
#include <stdint.h>
#include <stdbool.h>
#include "../lvgl.h"
#include "../lv_misc/lv_fs.h"
#include "lv_font_loader.h"
#if LV_USE_FILESYSTEM
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_fs_file_t * fp;
int8_t bit_pos;
uint8_t byte_value;
} bit_iterator_t;
typedef struct font_header_bin {
uint32_t version;
uint16_t tables_count;
uint16_t font_size;
uint16_t ascent;
int16_t descent;
uint16_t typo_ascent;
int16_t typo_descent;
uint16_t typo_line_gap;
int16_t min_y;
int16_t max_y;
uint16_t default_advance_width;
uint16_t kerning_scale;
uint8_t index_to_loc_format;
uint8_t glyph_id_format;
uint8_t advance_width_format;
uint8_t bits_per_pixel;
uint8_t xy_bits;
uint8_t wh_bits;
uint8_t advance_width_bits;
uint8_t compression_id;
uint8_t subpixels_mode;
uint8_t padding;
} font_header_bin_t;
typedef struct cmap_table_bin {
uint32_t data_offset;
uint32_t range_start;
uint16_t range_length;
uint16_t glyph_id_start;
uint16_t data_entries_count;
uint8_t format_type;
uint8_t padding;
} cmap_table_bin_t;
/**********************
* STATIC PROTOTYPES
**********************/
static bit_iterator_t init_bit_iterator(lv_fs_file_t * fp);
static bool lvgl_load_font(lv_fs_file_t * fp, lv_font_t * font);
int32_t load_kern(lv_fs_file_t * fp, lv_font_fmt_txt_dsc_t * font_dsc, uint8_t format, uint32_t start);
static int read_bits_signed(bit_iterator_t * it, int n_bits, lv_fs_res_t * res);
static int read_bits(bit_iterator_t * it, int n_bits, lv_fs_res_t * res);
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Loads a `lv_font_t` object from a binary font file
* @param font_name filename where the font file is located
* @return a pointer to the font or NULL in case of error
*/
lv_font_t * lv_font_load(const char * font_name)
{
bool success = false;
lv_font_t * font = lv_mem_alloc(sizeof(lv_font_t));
memset(font, 0, sizeof(lv_font_t));
lv_fs_file_t file;
lv_fs_res_t res = lv_fs_open(&file, font_name, LV_FS_MODE_RD);
if(res == LV_FS_RES_OK) {
success = lvgl_load_font(&file, font);
}
if(!success) {
LV_LOG_WARN("Error loading font file: %s\n", font_name);
/*
* When `lvgl_load_font` fails it can leak some pointers.
* All non-null pointers can be assumed as allocated and
* `lv_font_free` should free them correctly.
*/
lv_font_free(font);
font = NULL;
}
lv_fs_close(&file);
return font;
}
/**
* Frees the memory allocated by the `lv_font_load()` function
* @param font lv_font_t object created by the lv_font_load function
*/
void lv_font_free(lv_font_t * font)
{
if(NULL != font) {
lv_font_fmt_txt_dsc_t * dsc = (lv_font_fmt_txt_dsc_t *) font->dsc;
if(NULL != dsc) {
if(dsc->kern_classes == 0) {
lv_font_fmt_txt_kern_pair_t * kern_dsc =
(lv_font_fmt_txt_kern_pair_t *) dsc->kern_dsc;
if(NULL != kern_dsc) {
if(kern_dsc->glyph_ids)
lv_mem_free((void *) kern_dsc->glyph_ids);
if(kern_dsc->values)
lv_mem_free((void *) kern_dsc->values);
lv_mem_free((void *) kern_dsc);
}
}
else {
lv_font_fmt_txt_kern_classes_t * kern_dsc =
(lv_font_fmt_txt_kern_classes_t *) dsc->kern_dsc;
if(NULL != kern_dsc) {
if(kern_dsc->class_pair_values)
lv_mem_free((void *) kern_dsc->class_pair_values);
if(kern_dsc->left_class_mapping)
lv_mem_free((void *) kern_dsc->left_class_mapping);
if(kern_dsc->right_class_mapping)
lv_mem_free((void *) kern_dsc->right_class_mapping);
lv_mem_free((void *) kern_dsc);
}
}
lv_font_fmt_txt_cmap_t * cmaps =
(lv_font_fmt_txt_cmap_t *) dsc->cmaps;
if(NULL != cmaps) {
for(int i = 0; i < dsc->cmap_num; ++i) {
if(NULL != cmaps[i].glyph_id_ofs_list)
lv_mem_free((void *) cmaps[i].glyph_id_ofs_list);
if(NULL != cmaps[i].unicode_list)
lv_mem_free((void *) cmaps[i].unicode_list);
}
lv_mem_free(cmaps);
}
if(NULL != dsc->glyph_bitmap) {
lv_mem_free((void *) dsc->glyph_bitmap);
}
if(NULL != dsc->glyph_dsc) {
lv_mem_free((void *) dsc->glyph_dsc);
}
lv_mem_free(dsc);
}
lv_mem_free(font);
}
}
/**********************
* STATIC FUNCTIONS
**********************/
static bit_iterator_t init_bit_iterator(lv_fs_file_t * fp)
{
bit_iterator_t it;
it.fp = fp;
it.bit_pos = -1;
it.byte_value = 0;
return it;
}
static int read_bits(bit_iterator_t * it, int n_bits, lv_fs_res_t * res)
{
int value = 0;
while(n_bits--) {
it->byte_value = it->byte_value << 1;
it->bit_pos--;
if(it->bit_pos < 0) {
it->bit_pos = 7;
*res = lv_fs_read(it->fp, &(it->byte_value), 1, NULL);
if(*res != LV_FS_RES_OK) {
return -1;
}
}
int8_t bit = (it->byte_value & 0x80) ? 1 : 0;
value |= (bit << n_bits);
}
*res = LV_FS_RES_OK;
return value;
}
static int read_bits_signed(bit_iterator_t * it, int n_bits, lv_fs_res_t * res)
{
int value = read_bits(it, n_bits, res);
if(value & (1 << (n_bits - 1))) {
for(int bit = n_bits; bit < 8; ++bit) {
value |= (1 << bit);
}
}
return value;
}
static int read_label(lv_fs_file_t * fp, int start, const char * label)
{
lv_fs_seek(fp, start);
uint32_t length;
char buf[4];
if(lv_fs_read(fp, &length, 4, NULL) != LV_FS_RES_OK
|| lv_fs_read(fp, buf, 4, NULL) != LV_FS_RES_OK
|| memcmp(label, buf, 4) != 0) {
LV_LOG_WARN("Error reading '%s' label.", label);
return -1;
}
return length;
}
static bool load_cmaps_tables(lv_fs_file_t * fp, lv_font_fmt_txt_dsc_t * font_dsc,
uint32_t cmaps_start, cmap_table_bin_t * cmap_table)
{
for(unsigned int i = 0; i < font_dsc->cmap_num; ++i) {
if(lv_fs_read(fp, &cmap_table[i], sizeof(cmap_table_bin_t), NULL) != LV_FS_RES_OK) {
return false;
}
lv_font_fmt_txt_cmap_t * cmap = (lv_font_fmt_txt_cmap_t *) & (font_dsc->cmaps[i]);
cmap->range_start = cmap_table[i].range_start;
cmap->range_length = cmap_table[i].range_length;
cmap->glyph_id_start = cmap_table[i].glyph_id_start;
}
for(unsigned int i = 0; i < font_dsc->cmap_num; ++i) {
lv_fs_res_t res = lv_fs_seek(fp, cmaps_start + cmap_table[i].data_offset);
if(res != LV_FS_RES_OK) {
return false;
}
lv_font_fmt_txt_cmap_t * cmap = (lv_font_fmt_txt_cmap_t *) & (font_dsc->cmaps[i]);
switch(cmap_table[i].format_type) {
case 0: {
uint8_t ids_size = sizeof(uint8_t) * cmap_table[i].data_entries_count;
uint8_t * glyph_id_ofs_list = lv_mem_alloc(ids_size);
cmap->glyph_id_ofs_list = glyph_id_ofs_list;
if(lv_fs_read(fp, glyph_id_ofs_list, ids_size, NULL) != LV_FS_RES_OK) {
return false;
}
cmap->type = LV_FONT_FMT_TXT_CMAP_FORMAT0_FULL;
cmap->list_length = cmap->range_length;
cmap->unicode_list = NULL;
break;
}
case 2:
cmap->type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY;
cmap->list_length = 0;
cmap->unicode_list = NULL;
cmap->glyph_id_ofs_list = NULL;
break;
case 1:
case 3: {
uint32_t list_size = sizeof(uint16_t) * cmap_table[i].data_entries_count;
uint16_t * unicode_list = (uint16_t *) lv_mem_alloc(list_size);
cmap->unicode_list = unicode_list;
cmap->list_length = cmap_table[i].data_entries_count;
if(lv_fs_read(fp, unicode_list, list_size, NULL) != LV_FS_RES_OK) {
return false;
}
if(cmap_table[i].format_type == 1) {
uint16_t * buf = lv_mem_alloc(sizeof(uint16_t) * cmap->list_length);
cmap->type = LV_FONT_FMT_TXT_CMAP_SPARSE_FULL;
cmap->glyph_id_ofs_list = buf;
if(lv_fs_read(fp, buf, sizeof(uint16_t) * cmap->list_length, NULL) != LV_FS_RES_OK) {
return false;
}
}
else {
cmap->type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY;
cmap->glyph_id_ofs_list = NULL;
}
break;
}
default:
LV_LOG_WARN("Unknown cmaps format type %d.", cmap_table[i].format_type);
return false;
}
}
return true;
}
static int32_t load_cmaps(lv_fs_file_t * fp, lv_font_fmt_txt_dsc_t * font_dsc, uint32_t cmaps_start)
{
int32_t cmaps_length = read_label(fp, cmaps_start, "cmap");
if(cmaps_length < 0) {
return -1;
}
uint32_t cmaps_subtables_count;
if(lv_fs_read(fp, &cmaps_subtables_count, sizeof(uint32_t), NULL) != LV_FS_RES_OK) {
return -1;
}
lv_font_fmt_txt_cmap_t * cmaps =
lv_mem_alloc(cmaps_subtables_count * sizeof(lv_font_fmt_txt_cmap_t));
memset(cmaps, 0, cmaps_subtables_count * sizeof(lv_font_fmt_txt_cmap_t));
font_dsc->cmaps = cmaps;
font_dsc->cmap_num = cmaps_subtables_count;
cmap_table_bin_t * cmaps_tables = lv_mem_alloc(sizeof(cmap_table_bin_t) * font_dsc->cmap_num);
bool success = load_cmaps_tables(fp, font_dsc, cmaps_start, cmaps_tables);
lv_mem_free(cmaps_tables);
return success ? cmaps_length : -1;
}
static int32_t load_glyph(lv_fs_file_t * fp, lv_font_fmt_txt_dsc_t * font_dsc,
uint32_t start, uint32_t * glyph_offset, uint32_t loca_count, font_header_bin_t * header)
{
int32_t glyph_length = read_label(fp, start, "glyf");
if(glyph_length < 0) {
return -1;
}
lv_font_fmt_txt_glyph_dsc_t * glyph_dsc = (lv_font_fmt_txt_glyph_dsc_t *)
lv_mem_alloc(loca_count * sizeof(lv_font_fmt_txt_glyph_dsc_t));
memset(glyph_dsc, 0, loca_count * sizeof(lv_font_fmt_txt_glyph_dsc_t));
font_dsc->glyph_dsc = glyph_dsc;
int cur_bmp_size = 0;
for(unsigned int i = 0; i < loca_count; ++i) {
lv_font_fmt_txt_glyph_dsc_t * gdsc = &glyph_dsc[i];
lv_fs_res_t res = lv_fs_seek(fp, start + glyph_offset[i]);
if(res != LV_FS_RES_OK) {
return -1;
}
bit_iterator_t bit_it = init_bit_iterator(fp);
if(header->advance_width_bits == 0) {
gdsc->adv_w = header->default_advance_width;
}
else {
gdsc->adv_w = read_bits(&bit_it, header->advance_width_bits, &res);
if(res != LV_FS_RES_OK) {
return -1;
}
}
if(header->advance_width_format == 0) {
gdsc->adv_w *= 16;
}
gdsc->ofs_x = read_bits_signed(&bit_it, header->xy_bits, &res);
if(res != LV_FS_RES_OK) {
return -1;
}
gdsc->ofs_y = read_bits_signed(&bit_it, header->xy_bits, &res);
if(res != LV_FS_RES_OK) {
return -1;
}
gdsc->box_w = read_bits(&bit_it, header->wh_bits, &res);
if(res != LV_FS_RES_OK) {
return -1;
}
gdsc->box_h = read_bits(&bit_it, header->wh_bits, &res);
if(res != LV_FS_RES_OK) {
return -1;
}
int nbits = header->advance_width_bits + 2 * header->xy_bits + 2 * header->wh_bits;
int next_offset = (i < loca_count - 1) ? glyph_offset[i + 1] : (uint32_t)(glyph_length - 1);
int bmp_size = next_offset - glyph_offset[i] - nbits / 8;
if(i == 0) {
gdsc->adv_w = 0;
gdsc->box_w = 0;
gdsc->box_h = 0;
gdsc->ofs_x = 0;
gdsc->ofs_y = 0;
}
gdsc->bitmap_index = cur_bmp_size;
if(gdsc->box_w * gdsc->box_h != 0) {
cur_bmp_size += bmp_size;
}
}
uint8_t * glyph_bmp = (uint8_t *) lv_mem_alloc(sizeof(uint8_t) * cur_bmp_size);
font_dsc->glyph_bitmap = glyph_bmp;
cur_bmp_size = 0;
for(unsigned int i = 1; i < loca_count; ++i) {
lv_fs_res_t res = lv_fs_seek(fp, start + glyph_offset[i]);
if(res != LV_FS_RES_OK) {
return -1;
}
bit_iterator_t bit_it = init_bit_iterator(fp);
int nbits = header->advance_width_bits + 2 * header->xy_bits + 2 * header->wh_bits;
read_bits(&bit_it, nbits, &res);
if(res != LV_FS_RES_OK) {
return -1;
}
if(glyph_dsc[i].box_w * glyph_dsc[i].box_h == 0) {
continue;
}
int next_offset = (i < loca_count - 1) ? glyph_offset[i + 1] : (uint32_t)(glyph_length - 1);
int bmp_size = next_offset - glyph_offset[i] - nbits / 8;
for(int k = 0; k < bmp_size; ++k) {
glyph_bmp[cur_bmp_size + k] = read_bits(&bit_it, 8, &res);
if(res != LV_FS_RES_OK) {
return -1;
}
}
cur_bmp_size += bmp_size;
}
return glyph_length;
}
/*
* Loads a `lv_font_t` from a binary file, given a `lv_fs_file_t`.
*
* Memory allocations on `lvgl_load_font` should be immediately zeroed and
* the pointer should be set on the `lv_font_t` data before any possible return.
*
* When something fails, it returns `false` and the memory on the `lv_font_t`
* still needs to be freed using `lv_font_free`.
*
* `lv_font_free` will assume that all non-null pointers are allocated and
* should be freed.
*/
static bool lvgl_load_font(lv_fs_file_t * fp, lv_font_t * font)
{
lv_font_fmt_txt_dsc_t * font_dsc = (lv_font_fmt_txt_dsc_t *)
lv_mem_alloc(sizeof(lv_font_fmt_txt_dsc_t));
memset(font_dsc, 0, sizeof(lv_font_fmt_txt_dsc_t));
font->dsc = font_dsc;
/* header */
int32_t header_length = read_label(fp, 0, "head");
if(header_length < 0) {
return false;
}
font_header_bin_t font_header;
if(lv_fs_read(fp, &font_header, sizeof(font_header_bin_t), NULL) != LV_FS_RES_OK) {
return false;
}
font->base_line = -font_header.descent;
font->line_height = font_header.ascent - font_header.descent;
font->get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt;
font->get_glyph_bitmap = lv_font_get_bitmap_fmt_txt;
font->subpx = LV_FONT_SUBPX_NONE;
font_dsc->bpp = font_header.bits_per_pixel;
font_dsc->kern_scale = font_header.kerning_scale;
font_dsc->bitmap_format = font_header.compression_id;
/* cmaps */
uint32_t cmaps_start = header_length;
int32_t cmaps_length = load_cmaps(fp, font_dsc, cmaps_start);
if(cmaps_length < 0) {
return false;
}
/* loca */
uint32_t loca_start = cmaps_start + cmaps_length;
int32_t loca_length = read_label(fp, loca_start, "loca");
if(loca_length < 0) {
return false;
}
uint32_t loca_count;
if(lv_fs_read(fp, &loca_count, sizeof(uint32_t), NULL) != LV_FS_RES_OK) {
return false;
}
bool failed = false;
uint32_t * glyph_offset = lv_mem_alloc(sizeof(uint32_t) * (loca_count + 1));
for(unsigned int i = 0; i < loca_count; ++i) {
if(font_header.index_to_loc_format == 0) {
uint16_t offset;
if(lv_fs_read(fp, &offset, sizeof(uint16_t), NULL) != LV_FS_RES_OK) {
failed = true;
break;
}
glyph_offset[i] = offset;
}
else if(font_header.index_to_loc_format == 1) {
uint32_t offset;
if(lv_fs_read(fp, &offset, sizeof(uint32_t), NULL) != LV_FS_RES_OK) {
failed = true;
break;
}
glyph_offset[i] = offset;
}
else {
LV_LOG_WARN("Unknown index_to_loc_format: %d.", font_header.index_to_loc_format);
failed = true;
break;
}
}
if(failed) {
lv_mem_free(glyph_offset);
return false;
}
/* glyph */
uint32_t glyph_start = loca_start + loca_length;
int32_t glyph_length = load_glyph(
fp, font_dsc, glyph_start, glyph_offset, loca_count, &font_header);
lv_mem_free(glyph_offset);
if(glyph_length < 0) {
return false;
}
if(font_header.tables_count < 4) {
font_dsc->kern_dsc = NULL;
font_dsc->kern_classes = 0;
font_dsc->kern_scale = 0;
return true;
}
uint32_t kern_start = glyph_start + glyph_length;
int32_t kern_length = load_kern(fp, font_dsc, font_header.glyph_id_format, kern_start);
return kern_length >= 0;
}
int32_t load_kern(lv_fs_file_t * fp, lv_font_fmt_txt_dsc_t * font_dsc, uint8_t format, uint32_t start)
{
int32_t kern_length = read_label(fp, start, "kern");
if(kern_length < 0) {
return -1;
}
uint8_t kern_format_type;
int32_t padding;
if(lv_fs_read(fp, &kern_format_type, sizeof(uint8_t), NULL) != LV_FS_RES_OK ||
lv_fs_read(fp, &padding, 3 * sizeof(uint8_t), NULL) != LV_FS_RES_OK) {
return -1;
}
if(0 == kern_format_type) { /* sorted pairs */
lv_font_fmt_txt_kern_pair_t * kern_pair = lv_mem_alloc(sizeof(lv_font_fmt_txt_kern_pair_t));
memset(kern_pair, 0, sizeof(lv_font_fmt_txt_kern_pair_t));
font_dsc->kern_dsc = kern_pair;
font_dsc->kern_classes = 0;
uint32_t glyph_entries;
if(lv_fs_read(fp, &glyph_entries, sizeof(uint32_t), NULL) != LV_FS_RES_OK) {
return -1;
}
int ids_size;
if(format == 0) {
ids_size = sizeof(int8_t) * 2 * glyph_entries;
}
else {
ids_size = sizeof(int16_t) * 2 * glyph_entries;
}
uint8_t * glyph_ids = lv_mem_alloc(ids_size);
int8_t * values = lv_mem_alloc(glyph_entries);
kern_pair->glyph_ids_size = format;
kern_pair->pair_cnt = glyph_entries;
kern_pair->glyph_ids = glyph_ids;
kern_pair->values = values;
if(lv_fs_read(fp, glyph_ids, ids_size, NULL) != LV_FS_RES_OK) {
return -1;
}
if(lv_fs_read(fp, values, glyph_entries, NULL) != LV_FS_RES_OK) {
return -1;
}
}
else if(3 == kern_format_type) { /* array M*N of classes */
lv_font_fmt_txt_kern_classes_t * kern_classes = lv_mem_alloc(sizeof(lv_font_fmt_txt_kern_classes_t));
memset(kern_classes, 0, sizeof(lv_font_fmt_txt_kern_classes_t));
font_dsc->kern_dsc = kern_classes;
font_dsc->kern_classes = 1;
uint16_t kern_class_mapping_length;
uint8_t kern_table_rows;
uint8_t kern_table_cols;
if(lv_fs_read(fp, &kern_class_mapping_length, sizeof(uint16_t), NULL) != LV_FS_RES_OK ||
lv_fs_read(fp, &kern_table_rows, sizeof(uint8_t), NULL) != LV_FS_RES_OK ||
lv_fs_read(fp, &kern_table_cols, sizeof(uint8_t), NULL) != LV_FS_RES_OK) {
return -1;
}
int kern_values_length = sizeof(int8_t) * kern_table_rows * kern_table_cols;
uint8_t * kern_left = lv_mem_alloc(kern_class_mapping_length);
uint8_t * kern_right = lv_mem_alloc(kern_class_mapping_length);
int8_t * kern_values = lv_mem_alloc(kern_values_length);
kern_classes->left_class_mapping = kern_left;
kern_classes->right_class_mapping = kern_right;
kern_classes->left_class_cnt = kern_table_rows;
kern_classes->right_class_cnt = kern_table_cols;
kern_classes->class_pair_values = kern_values;
if(lv_fs_read(fp, kern_left, kern_class_mapping_length, NULL) != LV_FS_RES_OK ||
lv_fs_read(fp, kern_right, kern_class_mapping_length, NULL) != LV_FS_RES_OK ||
lv_fs_read(fp, kern_values, kern_values_length, NULL) != LV_FS_RES_OK) {
return -1;
}
}
else {
LV_LOG_WARN("Unknown kern_format_type: %d", kern_format_type);
return -1;
}
return kern_length;
}
#endif /*LV_USE_FILESYSTEM*/

View File

@@ -0,0 +1,44 @@
/**
* @file lv_font_loader.h
*
*/
#ifndef LV_FONT_LOADER_H
#define LV_FONT_LOADER_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
#if LV_USE_FILESYSTEM
lv_font_t * lv_font_load(const char * fontName);
void lv_font_free(lv_font_t * font);
#endif
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_FONT_LOADER_H*/

View File

@@ -7,23 +7,19 @@
* INCLUDES
*********************/
#include "lv_gpu_stm32_dma2d.h"
#include "../lv_core/lv_disp.h"
#include "../lv_core/lv_refr.h"
#if LV_USE_GPU_STM32_DMA2D
#if defined(STM32F4)
#include "stm32f4xx_hal.h"
#elif defined(STM32F7)
#include "stm32f7xx_hal.h"
#else
#error "Not supported STM32 family to use DMA2D"
#endif
#include LV_GPU_DMA2D_CMSIS_INCLUDE
/*********************
* DEFINES
*********************/
#if LV_COLOR_16_SWAP
// TODO: F7 has red blue swap bit in control register for all layers and output
#error "Can't use DMA2D with LV_COLOR_16_SWAP 1"
#endif
@@ -32,11 +28,9 @@
#endif
#if LV_COLOR_DEPTH == 16
#define DMA2D_OUTPUT_FORMAT DMA2D_OUTPUT_RGB565
#define DMA2D_INPUT_FORMAT DMA2D_INPUT_RGB565
#define LV_DMA2D_COLOR_FORMAT LV_DMA2D_RGB565
#elif LV_COLOR_DEPTH == 32
#define DMA2D_OUTPUT_FORMAT DMA2D_OUTPUT_ARGB8888
#define DMA2D_INPUT_FORMAT DMA2D_INPUT_ARGB8888
#define LV_DMA2D_COLOR_FORMAT LV_DMA2D_ARGB8888
#else
/*Can't use GPU with other formats*/
#endif
@@ -54,7 +48,6 @@ static void dma2d_wait(void);
/**********************
* STATIC VARIABLES
**********************/
static DMA2D_HandleTypeDef hdma2d;
/**********************
* MACROS
@@ -64,6 +57,21 @@ static DMA2D_HandleTypeDef hdma2d;
* GLOBAL FUNCTIONS
**********************/
/**
* Turn on the peripheral and set output color mode, this only needs to be done once
*/
void lv_gpu_stm32_dma2d_init(void)
{
/* Enable DMA2D clock */
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2DEN;
/* Delay after setting peripheral clock */
volatile uint32_t temp = RCC->AHB1ENR;
/* set output colour mode */
DMA2D->OPFCCR = LV_DMA2D_COLOR_FORMAT;
}
/**
* Fill an area in the buffer with a color
* @param buf a buffer which should be filled
@@ -77,18 +85,16 @@ void lv_gpu_stm32_dma2d_fill(lv_color_t * buf, lv_coord_t buf_w, lv_color_t colo
{
invalidate_cache();
hdma2d.Instance = DMA2D;
hdma2d.Init.Mode = DMA2D_R2M;
hdma2d.Init.ColorMode = DMA2D_OUTPUT_FORMAT;
hdma2d.Init.OutputOffset = buf_w - fill_w;
hdma2d.LayerCfg[1].InputAlpha = DMA2D_NO_MODIF_ALPHA;
hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_FORMAT;
hdma2d.LayerCfg[1].InputOffset = 0;
DMA2D->CR = 0x30000;
DMA2D->OMAR = (uint32_t)buf;
/* as input color mode is same as output we don't need to convert here do we? */
DMA2D->OCOLR = color.full;
DMA2D->OOR = buf_w - fill_w;
DMA2D->NLR = (fill_w << DMA2D_NLR_PL_Pos) | (fill_h << DMA2D_NLR_NL_Pos);
/* start transfer */
DMA2D->CR |= DMA2D_CR_START_Msk;
/* DMA2D Initialization */
HAL_DMA2D_Init(&hdma2d);
HAL_DMA2D_ConfigLayer(&hdma2d, 1);
HAL_DMA2D_Start(&hdma2d, (uint32_t)lv_color_to32(color), (uint32_t)buf, fill_w, fill_h);
dma2d_wait();
}
@@ -106,6 +112,7 @@ void lv_gpu_stm32_dma2d_fill(lv_color_t * buf, lv_coord_t buf_w, lv_color_t colo
void lv_gpu_stm32_dma2d_fill_mask(lv_color_t * buf, lv_coord_t buf_w, lv_color_t color, const lv_opa_t * mask,
lv_opa_t opa, lv_coord_t fill_w, lv_coord_t fill_h)
{
#if 0
invalidate_cache();
/* Configure the DMA2D Mode, Color Mode and line output offset */
@@ -134,6 +141,7 @@ void lv_gpu_stm32_dma2d_fill_mask(lv_color_t * buf, lv_coord_t buf_w, lv_color_t
HAL_DMA2D_ConfigLayer(&hdma2d, 1);
HAL_DMA2D_BlendingStart(&hdma2d, (uint32_t) mask, (uint32_t) buf, (uint32_t)buf, fill_w, fill_h);
dma2d_wait();
#endif
}
/**
@@ -151,22 +159,17 @@ void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_
{
invalidate_cache();
hdma2d.Instance = DMA2D;
hdma2d.Init.Mode = DMA2D_M2M;
hdma2d.Init.ColorMode = DMA2D_OUTPUT_FORMAT;
hdma2d.Init.OutputOffset = buf_w - copy_w;
DMA2D->CR = 0;
/* copy output colour mode, this register controls both input and output colour format */
DMA2D->FGPFCCR = LV_DMA2D_COLOR_FORMAT;
DMA2D->FGMAR = (uint32_t)map;
DMA2D->FGOR = map_w - copy_w;
DMA2D->OMAR = (uint32_t)buf;
DMA2D->OOR = buf_w - copy_w;
DMA2D->NLR = (copy_w << DMA2D_NLR_PL_Pos) | (copy_h << DMA2D_NLR_NL_Pos);
/* Foreground layer */
hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
hdma2d.LayerCfg[1].InputAlpha = 0xFF;
hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_FORMAT;
hdma2d.LayerCfg[1].InputOffset = map_w - copy_w;
/* DMA2D Initialization */
HAL_DMA2D_Init(&hdma2d);
HAL_DMA2D_ConfigLayer(&hdma2d, 0);
HAL_DMA2D_ConfigLayer(&hdma2d, 1);
HAL_DMA2D_Start(&hdma2d, (uint32_t)map, (uint32_t)buf, copy_w, copy_h);
/* start transfer */
DMA2D->CR |= DMA2D_CR_START_Msk;
dma2d_wait();
}
@@ -185,28 +188,26 @@ void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color
lv_coord_t map_w, lv_coord_t copy_w, lv_coord_t copy_h)
{
invalidate_cache();
DMA2D->CR = 0x20000;
hdma2d.Instance = DMA2D;
hdma2d.Init.Mode = DMA2D_M2M_BLEND;
hdma2d.Init.ColorMode = DMA2D_OUTPUT_FORMAT;
hdma2d.Init.OutputOffset = buf_w - copy_w;
DMA2D->BGPFCCR = LV_DMA2D_COLOR_FORMAT;
DMA2D->BGMAR = (uint32_t)buf;
DMA2D->BGOR = buf_w - copy_w;
/* Background layer */
hdma2d.LayerCfg[0].AlphaMode = DMA2D_NO_MODIF_ALPHA;
hdma2d.LayerCfg[0].InputColorMode = DMA2D_INPUT_FORMAT;
hdma2d.LayerCfg[0].InputOffset = buf_w - copy_w;
DMA2D->FGPFCCR = (uint32_t)LV_DMA2D_COLOR_FORMAT
/* alpha mode 2, replace with foreground * alpha value */
| (2 << DMA2D_FGPFCCR_AM_Pos)
/* alpha value */
| (opa << DMA2D_FGPFCCR_ALPHA_Pos);
DMA2D->FGMAR = (uint32_t)map;
DMA2D->FGOR = map_w - copy_w;
/* Foreground layer */
hdma2d.LayerCfg[1].AlphaMode = DMA2D_COMBINE_ALPHA;
hdma2d.LayerCfg[1].InputAlpha = opa;
hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_FORMAT;
hdma2d.LayerCfg[1].InputOffset = map_w - copy_w;
DMA2D->OMAR = (uint32_t)buf;
DMA2D->OOR = buf_w - copy_w;
DMA2D->NLR = (copy_w << DMA2D_NLR_PL_Pos) | (copy_h << DMA2D_NLR_NL_Pos);
/* DMA2D Initialization */
HAL_DMA2D_Init(&hdma2d);
HAL_DMA2D_ConfigLayer(&hdma2d, 0);
HAL_DMA2D_ConfigLayer(&hdma2d, 1);
HAL_DMA2D_BlendingStart(&hdma2d, (uint32_t)map, (uint32_t)buf, (uint32_t)buf, copy_w, copy_h);
/* start transfer */
DMA2D->CR |= DMA2D_CR_START_Msk;
dma2d_wait();
}
@@ -216,17 +217,16 @@ void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color
static void invalidate_cache(void)
{
#if __DCACHE_PRESENT
if(SCB->CCR & (uint32_t)SCB_CCR_DC_Msk) {
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
if(disp->driver.clean_dcache_cb) disp->driver.clean_dcache_cb(&disp->driver);
else
SCB_CleanInvalidateDCache();
}
#endif
}
static void dma2d_wait(void)
{
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
while(HAL_DMA2D_PollForTransfer(&hdma2d, 0) == HAL_TIMEOUT) {
while(DMA2D->CR & DMA2D_CR_START_Msk) {
if(disp->driver.wait_cb) disp->driver.wait_cb(&disp->driver);
}
}

View File

@@ -20,6 +20,12 @@ extern "C" {
* DEFINES
*********************/
#define LV_DMA2D_ARGB8888 0
#define LV_DMA2D_RGB888 1
#define LV_DMA2D_RGB565 2
#define LV_DMA2D_ARGB1555 3
#define LV_DMA2D_ARGB4444 4
/**********************
* TYPEDEFS
**********************/
@@ -28,6 +34,11 @@ extern "C" {
* GLOBAL PROTOTYPES
**********************/
/**
* Turn on the peripheral and set output color mode, this only needs to be done once
*/
void lv_gpu_stm32_dma2d_init(void);
/**
* Fill an area in the buffer with a color
* @param buf a buffer which should be filled

View File

@@ -144,6 +144,15 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
disp->inv_p = 0;
disp->last_activity_time = 0;
disp->bg_color = LV_COLOR_WHITE;
disp->bg_img = NULL;
#if LV_COLOR_SCREEN_TRANSP
disp->bg_opa = LV_OPA_TRANSP;
#else
disp->bg_opa = LV_OPA_COVER;
#endif
disp->prev_scr = NULL;
disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/
disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
disp->sys_layer = lv_obj_create(NULL, NULL); /*Create sys layer on the display*/

View File

@@ -52,10 +52,10 @@ typedef struct {
void * buf_act;
uint32_t size; /*In pixel count*/
lv_area_t area;
volatile int
flushing; /*1: flushing is in progress. (It can't be a bitfield because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
volatile int
flushing_last; /*1: It was the last chunk to flush. (It can't be a bitfield because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
/*1: flushing is in progress. (It can't be a bit field because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
volatile int flushing;
/*1: It was the last chunk to flush. (It can't be a bi tfield because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
volatile int flushing_last;
volatile uint32_t last_area : 1; /*1: the last area is being rendered*/
volatile uint32_t last_part : 1; /*1: the last part of the current area is being rendered*/
} lv_disp_buf_t;
@@ -111,7 +111,14 @@ typedef struct _disp_drv_t {
* User can execute very simple tasks here or yield the task */
void (*wait_cb)(struct _disp_drv_t * disp_drv);
/** OPTIONAL: Called when lvgl needs any CPU cache that affects rendering to be cleaned */
void (*clean_dcache_cb)(struct _disp_drv_t * disp_drv);
/** OPTIONAL: called to wait while the gpu is working */
void (*gpu_wait_cb)(struct _disp_drv_t * disp_drv);
#if LV_USE_GPU
/** OPTIONAL: Blend two memories using opacity (GPU only)*/
void (*gpu_blend_cb)(struct _disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length,
lv_opa_t opa);
@@ -146,10 +153,18 @@ typedef struct _disp_t {
/** Screens of the display*/
lv_ll_t scr_ll;
struct _lv_obj_t * act_scr; /**< Currently active screen on this display */
struct _lv_obj_t * act_scr; /**< Currently active screen on this display */
struct _lv_obj_t * prev_scr; /**< Previous screen. Used during screen animations */
struct _lv_obj_t * top_layer; /**< @see lv_disp_get_layer_top */
struct _lv_obj_t * sys_layer; /**< @see lv_disp_get_layer_sys */
uint8_t del_prev :
1; /**< 1: Automatically delete the previous screen when the screen load animation is ready */
lv_color_t bg_color; /**< Default display color when screens are transparent*/
const void * bg_img; /**< An image source to display as wallpaper*/
lv_opa_t bg_opa; /**<Opacity of the background color or wallpaper */
/** Invalidated (marked to redraw) areas*/
lv_area_t inv_areas[LV_INV_BUF_SIZE];
uint8_t inv_area_joined[LV_INV_BUF_SIZE];

View File

@@ -143,6 +143,11 @@ bool _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
else if(indev->driver.type == LV_INDEV_TYPE_KEYPAD) {
data->key = indev->proc.types.keypad.last_key;
}
/*For compatibility assume that used button was enter (encoder push) */
else if(indev->driver.type == LV_INDEV_TYPE_ENCODER) {
data->key = LV_KEY_ENTER;
data->enc_diff = 0;
}
if(indev->driver.read_cb) {
LV_LOG_TRACE("idnev read started");

View File

@@ -56,12 +56,17 @@ LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period)
uint32_t lv_tick_get(void)
{
#if LV_TICK_CUSTOM == 0
/* If `lv_tick_inc` is called from an interrupt while `sys_time` is read
* the result might be corrupted.
* This loop detects if `lv_tick_inc` was called while reading `sys_time`.
* If `tick_irq_flag` was cleared in `lv_tick_inc` try to read again
* until `tick_irq_flag` remains `1`. */
uint32_t result;
do {
tick_irq_flag = 1;
result = sys_time;
} while(!tick_irq_flag); /*'lv_tick_inc()' clears this flag which can be in an interrupt.
Continue until make a non interrupted cycle */
} while(!tick_irq_flag); /*Continue until see a non interrupted cycle */
return result;
#else

View File

@@ -475,8 +475,11 @@ static void anim_task(lv_task_t * param)
if(a->path.cb) new_value = a->path.cb(&a->path, a);
else new_value = lv_anim_path_linear(&a->path, a);
/*Apply the calculated value*/
if(a->exec_cb) a->exec_cb(a->var, new_value);
if(new_value != a->current) {
a->current = new_value;
/*Apply the calculated value*/
if(a->exec_cb) a->exec_cb(a->var, new_value);
}
/*If the time is elapsed the animation is ready*/
if(a->act_time >= a->time) {

View File

@@ -82,6 +82,7 @@ typedef struct _lv_anim_t {
lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/
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 act_time; /**< Current time in animation. Set to negative to make delay.*/
@@ -171,6 +172,7 @@ static inline void lv_anim_set_delay(lv_anim_t * a, uint32_t delay)
static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_anim_value_t end)
{
a->start = start;
a->current = start;
a->end = end;
}

View File

@@ -390,7 +390,7 @@ static inline uint32_t lv_color_to32(lv_color_t color)
{
#if LV_COLOR_DEPTH == 1
if(color.full == 0)
return 0;
return 0xFF000000;
else
return 0xFFFFFFFF;
#elif LV_COLOR_DEPTH == 8
@@ -456,9 +456,12 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t lv_color_mix(lv_color_t c1, lv_co
lv_color_t ret;
#if LV_COLOR_DEPTH != 1
/*LV_COLOR_DEPTH == 8, 16 or 32*/
LV_COLOR_SET_R(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) * (255 - mix) + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_G(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) * (255 - mix) + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_B(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) * (255 - mix) + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_R(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) *
(255 - mix) + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_G(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) *
(255 - mix) + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_B(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) *
(255 - mix) + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_A(ret, 0xFF);
#else
/*LV_COLOR_DEPTH == 1*/
@@ -593,19 +596,47 @@ 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 unstead 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_t){.full = (uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))})
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{.full = (uint8_t)((b8 >> 7) | (g8 >> 7) | (r8 >> 7))})
#elif LV_COLOR_DEPTH == 8
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}})
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((b8 >> 6) & 0x3U), (uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 5) & 0x7U)}})
#elif LV_COLOR_DEPTH == 16
#if LV_COLOR_16_SWAP == 0
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x3FU), (uint16_t)((r8 >> 3) & 0x1FU)}})
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x3FU), (uint16_t)((r8 >> 3) & 0x1FU)}})
#else
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint16_t)((g8 >> 5) & 0x7U), (uint16_t)((r8 >> 3) & 0x1FU), (uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x7U)}})
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{(uint16_t)((g8 >> 5) & 0x7U), (uint16_t)((r8 >> 3) & 0x1FU), (uint16_t)((b8 >> 3) & 0x1FU), (uint16_t)((g8 >> 2) & 0x7U)}})
#endif
#elif LV_COLOR_DEPTH == 32
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/
#define LV_COLOR_MAKE(r8, g8, b8) (_LV_COLOR_MAKE_TYPE_HELPER{{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/
#endif
static inline lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b)

View File

@@ -43,6 +43,8 @@ extern "C" {
f(void * , _lv_theme_template_styles) \
f(void * , _lv_theme_mono_styles) \
f(void * , _lv_theme_empty_styles) \
f(uint8_t *, _lv_font_decompr_buf) \
#define LV_DEFINE_ROOT(root_type, root_name) root_type root_name;
#define LV_ROOTS LV_ITERATE_ROOTS(LV_DEFINE_ROOT)

View File

@@ -128,7 +128,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask
q->f = (uint32_t)(root & 0xf) << 4;
}
/**
* Calculate the atan2 of a vector.
* @param x
@@ -232,6 +231,32 @@ int64_t _lv_pow(int64_t base, int8_t exp)
return result;
}
/**
* Get the mapped of a number given an input and output range
* @param x integer which mapped value should be calculated
* @param min_in min input range
* @param max_in max input range
* @param min_out max output range
* @param max_out max output range
* @return the mapped number
*/
int16_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;
/* The equation should be:
* ((x - min_in) / delta in) * delta_out + min_out
* To avoid rounding error reorder the operations:
* (((x - min_in) * delta_out) / delta in) + min_out
*/
int32_t delta_in = max_in - min_in;
int32_t delta_out = max_out - min_out;
return ((x - min_in) * delta_out) / delta_in + min_out;
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -112,6 +112,17 @@ LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask
*/
int64_t _lv_pow(int64_t base, int8_t exp);
/**
* Get the mapped of a number given an input and output range
* @param x integer which mapped value should be calculated
* @param min_in min input range
* @param max_in max input range
* @param min_out max output range
* @param max_out max output range
* @return the mapped number
*/
int16_t _lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min, int32_t max);
/**********************
* MACROS
**********************/

View File

@@ -86,6 +86,9 @@ typedef struct {
static uint32_t zero_mem; /*Give the address of this variable if 0 byte should be allocated*/
#if LV_MEM_CUSTOM == 0
static uint32_t mem_max_size; /*Tracks the maximum total size of memory ever used from the internal heap*/
#endif
static uint8_t mem_buf1_32[MEM_BUF_SMALL_SIZE];
static uint8_t mem_buf2_32[MEM_BUF_SMALL_SIZE];
@@ -118,6 +121,7 @@ void _lv_mem_init(void)
/*Allocate a large array to store the dynamically allocated data*/
static LV_MEM_ATTR MEM_UNIT work_mem_int[LV_MEM_SIZE / sizeof(MEM_UNIT)];
work_mem = (uint8_t *)work_mem_int;
mem_max_size = 0;
#else
work_mem = (uint8_t *)LV_MEM_ADR;
#endif
@@ -200,7 +204,19 @@ void * lv_mem_alloc(size_t size)
if(alloc != NULL) _lv_memset(alloc, 0xaa, size);
#endif
if(alloc == NULL) LV_LOG_WARN("Couldn't allocate memory");
if(alloc == NULL) {
LV_LOG_WARN("Couldn't allocate memory");
}
else {
#if LV_MEM_CUSTOM == 0
/* just a safety check, should always be true */
if((uintptr_t) alloc > (uintptr_t) work_mem) {
if((((uintptr_t) alloc - (uintptr_t) work_mem) + size) > mem_max_size) {
mem_max_size = ((uintptr_t) alloc - (uintptr_t) work_mem) + size;
}
}
#endif
}
return alloc;
}
@@ -424,6 +440,7 @@ void lv_mem_monitor(lv_mem_monitor_t * mon_p)
e = ent_get_next(e);
}
mon_p->total_size = LV_MEM_SIZE;
mon_p->max_used = mem_max_size;
mon_p->used_pct = 100 - (100U * mon_p->free_size) / mon_p->total_size;
if(mon_p->free_size > 0) {
mon_p->frag_pct = (uint32_t)mon_p->free_biggest_size * 100U / mon_p->free_size;
@@ -569,6 +586,7 @@ void _lv_mem_buf_free_all(void)
}
}
#if LV_MEMCPY_MEMSET_STD == 0
/**
* Same as `memcpy` but optimized for 4 byte operation.
* @param dst pointer to the destination buffer
@@ -635,7 +653,6 @@ LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len
/**
* Same as `memset` but optimized for 4 byte operation.
* `dst` should be word aligned else normal `memcpy` will be used
* @param dst pointer to the destination buffer
* @param v value to set [0..255]
* @param len number of byte to set
@@ -690,7 +707,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len)
/**
* Same as `memset(dst, 0x00, len)` but optimized for 4 byte operation.
* `dst` should be word aligned else normal `memcpy` will be used
* @param dst pointer to the destination buffer
* @param len number of byte to set
*/
@@ -740,7 +756,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len)
/**
* Same as `memset(dst, 0xFF, len)` but optimized for 4 byte operation.
* `dst` should be word aligned else normal `memcpy` will be used
* @param dst pointer to the destination buffer
* @param len number of byte to set
*/
@@ -788,6 +803,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len)
}
}
#endif /*LV_MEMCPY_MEMSET_STD*/
/**********************
* STATIC FUNCTIONS

View File

@@ -20,6 +20,10 @@ extern "C" {
#include "lv_log.h"
#include "lv_types.h"
#if LV_MEMCPY_MEMSET_STD
#include <string.h>
#endif
/*********************
* DEFINES
*********************/
@@ -41,6 +45,7 @@ typedef struct {
uint32_t free_size; /**< Size of available memory */
uint32_t free_biggest_size;
uint32_t used_cnt;
uint32_t max_used; /**< Max size of Heap memory used */
uint8_t used_pct; /**< Percentage used */
uint8_t frag_pct; /**< Amount of fragmentation */
} lv_mem_monitor_t;
@@ -136,6 +141,62 @@ void _lv_mem_buf_free_all(void);
//! @cond Doxygen_Suppress
#if LV_MEMCPY_MEMSET_STD
/**
* Wrapper for the standard memcpy
* @param dst pointer to the destination buffer
* @param src pointer to the source buffer
* @param len number of byte to copy
*/
static inline void * _lv_memcpy(void * dst, const void * src, size_t len)
{
return memcpy(dst, src, len);
}
/**
* Wrapper for the standard memcpy
* @param dst pointer to the destination buffer
* @param src pointer to the source buffer
* @param len number of byte to copy
*/
static inline void * _lv_memcpy_small(void * dst, const void * src, size_t len)
{
return memcpy(dst, src, len);
}
/**
* Wrapper for the standard memset
* @param dst pointer to the destination buffer
* @param v value to set [0..255]
* @param len number of byte to set
*/
static inline void _lv_memset(void * dst, uint8_t v, size_t len)
{
memset(dst, v, len);
}
/**
* Wrapper for the standard memset with fixed 0x00 value
* @param dst pointer to the destination buffer
* @param len number of byte to set
*/
static inline void _lv_memset_00(void * dst, size_t len)
{
memset(dst, 0x00, len);
}
/**
* Wrapper for the standard memset with fixed 0xFF value
* @param dst pointer to the destination buffer
* @param len number of byte to set
*/
static inline void _lv_memset_ff(void * dst, size_t len)
{
memset(dst, 0xFF, len);
}
#else
/**
* Same as `memcpy` but optimized for 4 byte operation.
* @param dst pointer to the destination buffer
@@ -167,7 +228,6 @@ LV_ATTRIBUTE_FAST_MEM static inline void * _lv_memcpy_small(void * dst, const vo
/**
* Same as `memset` but optimized for 4 byte operation.
* `dst` should be word aligned else normal `memcpy` will be used
* @param dst pointer to the destination buffer
* @param v value to set [0..255]
* @param len number of byte to set
@@ -176,7 +236,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len);
/**
* Same as `memset(dst, 0x00, len)` but optimized for 4 byte operation.
* `dst` should be word aligned else normal `memcpy` will be used
* @param dst pointer to the destination buffer
* @param len number of byte to set
*/
@@ -184,7 +243,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len);
/**
* Same as `memset(dst, 0xFF, len)` but optimized for 4 byte operation.
* `dst` should be word aligned else normal `memcpy` will be used
* @param dst pointer to the destination buffer
* @param len number of byte to set
*/
@@ -192,6 +250,9 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len);
//! @endcond
#endif
/**********************
* MACROS
**********************/

View File

@@ -378,6 +378,17 @@ uint8_t lv_task_get_idle(void)
return idle_last;
}
/**
* Iterate through the tasks
* @param task NULL to start iteration or the previous return value to get the next task
* @return the next task or NULL if there is no more task
*/
lv_task_t * lv_task_get_next(lv_task_t * task)
{
if(task == NULL) return _lv_ll_get_head(&LV_GC_ROOT(_lv_task_ll));
else return _lv_ll_get_next(&LV_GC_ROOT(_lv_task_ll), task);
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@@ -165,6 +165,13 @@ void lv_task_enable(bool en);
*/
uint8_t lv_task_get_idle(void);
/**
* Iterate through the tasks
* @param task NULL to start iteration or the previous return value to get the next task
* @return the next task or NULL if there is no more task
*/
lv_task_t * lv_task_get_next(lv_task_t * task);
/**********************
* MACROS
**********************/

View File

@@ -436,6 +436,8 @@ void _lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt)
{
size_t old_len = strlen(txt_buf);
size_t ins_len = strlen(ins_txt);
if(ins_len == 0) return;
size_t new_len = ins_len + old_len;
pos = _lv_txt_encoded_get_byte_id(txt_buf, pos); /*Convert to byte index instead of letter index*/
@@ -534,6 +536,7 @@ static uint32_t lv_txt_unicode_to_utf8(uint32_t letter_uni)
*/
static uint32_t lv_txt_utf8_conv_wc(uint32_t c)
{
#if LV_BIG_ENDIAN_SYSTEM == 0
/*Swap the bytes (UTF-8 is big endian, but the MCUs are little endian)*/
if((c & 0x80) != 0) {
uint32_t swapped;
@@ -547,7 +550,7 @@ static uint32_t lv_txt_utf8_conv_wc(uint32_t c)
}
c = swapped;
}
#endif
return c;
}

View File

@@ -6,8 +6,7 @@
/*********************
* INCLUDES
*********************/
#include "lv_theme.h"
#include "../lv_core/lv_obj.h"
#include "../../lvgl.h"
/*********************
* DEFINES
@@ -20,6 +19,8 @@
/**********************
* STATIC PROTOTYPES
**********************/
static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
static void clear_styles(lv_obj_t * obj, lv_theme_style_t name);
/**********************
* STATIC VARIABLES
@@ -53,6 +54,69 @@ lv_theme_t * lv_theme_get_act(void)
return act_theme;
}
/**
* Apply the active theme on an object
* @param obj pointer to an object
* @param name the name of the theme element to apply. E.g. `LV_THEME_BTN`
*/
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name)
{
/* Remove the existing styles from all part of the object. */
clear_styles(obj, name);
/*Apply the theme including the base theme(s)*/
apply_theme(act_theme, obj, name);
}
/**
* Copy a theme to an other or initialize a theme
* @param theme pointer to a theme to initialize
* @param copy pointer to a theme to copy
* or `NULL` to initialize `theme` to empty
*/
void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy)
{
_lv_memset_00(theme, sizeof(lv_theme_t));
if(copy) {
theme->font_small = copy->font_small;
theme->font_normal = copy->font_normal;
theme->font_subtitle = copy->font_subtitle;
theme->font_title = copy->font_title;
theme->color_primary = copy->color_primary;
theme->color_secondary = copy->color_secondary;
theme->flags = copy->flags;
theme->base = copy->base;
theme->apply_cb = copy->apply_cb;
theme->apply_xcb = copy->apply_xcb;
}
}
/**
* Set a base theme for a theme.
* The styles from the base them will be added before the styles of the current theme.
* Arbitrary long chain of themes can be created by setting base themes.
* @param new_theme pointer to theme which base should be set
* @param base pointer to the base theme
*/
void lv_theme_set_base(lv_theme_t * new_theme, lv_theme_t * base)
{
new_theme->base = base;
}
/**
* Set a callback for a theme.
* The callback is used to add styles to different objects
* @param theme pointer to theme which callback should be set
* @param cb pointer to the callback
*/
void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb)
{
theme->apply_cb = apply_cb;
}
/**
* Get the small font of the theme
* @return pointer to the font
@@ -116,12 +180,299 @@ uint32_t lv_theme_get_flags(void)
return act_theme->flags;
}
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name)
{
act_theme->apply_xcb(obj, name);
}
/**********************
* STATIC FUNCTIONS
**********************/
static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
{
if(th->base) {
apply_theme(th->base, obj, name);
}
/*apply_xcb is deprecated, use apply_cb instead*/
if(th->apply_xcb) {
th->apply_xcb(obj, name);
}
else if(th->apply_cb) {
th->apply_cb(act_theme, obj, name);
}
}
static void clear_styles(lv_obj_t * obj, lv_theme_style_t name)
{
switch(name) {
case LV_THEME_NONE:
break;
case LV_THEME_SCR:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
break;
case LV_THEME_OBJ:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
break;
#if LV_USE_CONT
case LV_THEME_CONT:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
break;
#endif
#if LV_USE_BTN
case LV_THEME_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
break;
#endif
#if LV_USE_BTNMATRIX
case LV_THEME_BTNMATRIX:
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG);
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN);
break;
#endif
#if LV_USE_KEYBOARD
case LV_THEME_KEYBOARD:
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG);
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN);
break;
#endif
#if LV_USE_BAR
case LV_THEME_BAR:
lv_obj_clean_style_list(obj, LV_BAR_PART_BG);
lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC);
break;
#endif
#if LV_USE_SWITCH
case LV_THEME_SWITCH:
lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG);
lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC);
lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB);
break;
#endif
#if LV_USE_CANVAS
case LV_THEME_CANVAS:
lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN);
break;
#endif
#if LV_USE_IMG
case LV_THEME_IMAGE:
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
break;
#endif
#if LV_USE_IMGBTN
case LV_THEME_IMGBTN:
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
break;
#endif
#if LV_USE_LABEL
case LV_THEME_LABEL:
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
break;
#endif
#if LV_USE_LINE
case LV_THEME_LINE:
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
break;
#endif
#if LV_USE_ARC
case LV_THEME_ARC:
lv_obj_clean_style_list(obj, LV_ARC_PART_BG);
lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC);
break;
#endif
#if LV_USE_SPINNER
case LV_THEME_SPINNER:
lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG);
lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC);
break;
#endif
#if LV_USE_SLIDER
case LV_THEME_SLIDER:
lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG);
lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC);
lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB);
break;
#endif
#if LV_USE_CHECKBOX
case LV_THEME_CHECKBOX:
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG);
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET);
break;
#endif
#if LV_USE_MSGBOX
case LV_THEME_MSGBOX:
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG);
break;
case LV_THEME_MSGBOX_BTNS:
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG);
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN);
break;
#endif
#if LV_USE_LED
case LV_THEME_LED:
lv_obj_clean_style_list(obj, LV_LED_PART_MAIN);
break;
#endif
#if LV_USE_PAGE
case LV_THEME_PAGE:
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR);
break;
#endif
#if LV_USE_TABVIEW
case LV_THEME_TABVIEW:
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
break;
case LV_THEME_TABVIEW_PAGE:
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
break;
#endif
#if LV_USE_TILEVIEW
case LV_THEME_TILEVIEW:
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG);
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
break;
#endif
#if LV_USE_ROLLER
case LV_THEME_ROLLER:
lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG);
lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED);
break;
#endif
#if LV_USE_OBJMASK
case LV_THEME_OBJMASK:
lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN);
break;
#endif
#if LV_USE_LIST
case LV_THEME_LIST:
lv_obj_clean_style_list(obj, LV_LIST_PART_BG);
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE);
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR);
break;
case LV_THEME_LIST_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
break;
#endif
#if LV_USE_DROPDOWN
case LV_THEME_DROPDOWN:
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED);
break;
#endif
#if LV_USE_CHART
case LV_THEME_CHART:
lv_obj_clean_style_list(obj, LV_CHART_PART_BG);
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG);
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES);
break;
#endif
#if LV_USE_TABLE
case LV_THEME_TABLE:
lv_obj_clean_style_list(obj, LV_TABLE_PART_BG);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4);
break;
#endif
#if LV_USE_WIN
case LV_THEME_WIN:
lv_obj_clean_style_list(obj, LV_WIN_PART_BG);
lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR);
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER);
break;
case LV_THEME_WIN_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
break;
#endif
#if LV_USE_TEXTAREA
case LV_THEME_TEXTAREA:
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
break;
#endif
#if LV_USE_SPINBOX
case LV_THEME_SPINBOX:
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG);
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR);
break;
case LV_THEME_SPINBOX_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
break;
#endif
#if LV_USE_CALENDAR
case LV_THEME_CALENDAR:
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
break;
#endif
#if LV_USE_CPICKER
case LV_THEME_CPICKER:
lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN);
lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB);
break;
#endif
#if LV_USE_LINEMETER
case LV_THEME_LINEMETER:
lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN);
break;
#endif
#if LV_USE_GAUGE
case LV_THEME_GAUGE:
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN);
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR);
lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE);
break;
#endif
default:
break;
}
}

View File

@@ -114,7 +114,7 @@ typedef enum {
#endif
#if LV_USE_SPINBOX
LV_THEME_SPINBOX,
LV_THEME_SPINBOX_BTN, /*Button extra for spinbox*/
LV_THEME_SPINBOX_BTN, /*Control button for the spinbox*/
#endif
#if LV_USE_SPINNER
LV_THEME_SPINNER,
@@ -141,13 +141,20 @@ typedef enum {
#endif
_LV_THEME_BUILTIN_LAST,
_LV_THEME_CUSTOM_START = _LV_THEME_BUILTIN_LAST,
LV_THEME_CUSTOM_START = _LV_THEME_BUILTIN_LAST,
_LV_THEME_CUSTOM_LAST = 0xFFFF,
} lv_theme_style_t;
typedef struct {
void (*apply_xcb)(lv_obj_t *, lv_theme_style_t);
struct _lv_theme_t;
typedef void (*lv_theme_apply_cb_t)(struct _lv_theme_t *, lv_obj_t *, lv_theme_style_t);
typedef void (*lv_theme_apply_xcb_t)(lv_obj_t *, lv_theme_style_t); /*Deprecated: use `apply_cb` instead*/
typedef struct _lv_theme_t {
lv_theme_apply_cb_t apply_cb;
lv_theme_apply_xcb_t apply_xcb; /*Deprecated: use `apply_cb` instead*/
struct _lv_theme_t * base; /**< Apply the current theme's style on top of this theme.*/
lv_color_t color_primary;
lv_color_t color_secondary;
const lv_font_t * font_small;
@@ -155,6 +162,7 @@ typedef struct {
const lv_font_t * font_subtitle;
const lv_font_t * font_title;
uint32_t flags;
void * user_data;
} lv_theme_t;
/**********************
@@ -174,9 +182,37 @@ void lv_theme_set_act(lv_theme_t * th);
*/
lv_theme_t * lv_theme_get_act(void);
/**
* Apply the active theme on an object
* @param obj pointer to an object
* @param name the name of the theme element to apply. E.g. `LV_THEME_BTN`
*/
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name);
/**
* Copy a theme to an other or initialize a theme
* @param theme pointer to a theme to initialize
* @param copy pointer to a theme to copy
* or `NULL` to initialize `theme` to empty
*/
void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy);
/**
* Set a base theme for a theme.
* The styles from the base them will be added before the styles of the current theme.
* Arbitrary long chain of themes can be created by setting base themes.
* @param new_theme pointer to theme which base should be set
* @param base pointer to the base theme
*/
void lv_theme_set_base(lv_theme_t * new_theme, lv_theme_t * base);
/**
* Set an apply callback for a theme.
* The apply callback is used to add styles to different objects
* @param theme pointer to theme which callback should be set
* @param apply_cb pointer to the callback
*/
void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb);
/**
* Get the small font of the theme
@@ -220,7 +256,6 @@ lv_color_t lv_theme_get_color_secondary(void);
*/
uint32_t lv_theme_get_flags(void);
/**********************
* MACROS
**********************/

View File

@@ -26,12 +26,12 @@
**********************/
typedef struct {
lv_style_t opa_cover;
}theme_styles_t;
} theme_styles_t;
/**********************
* STATIC PROTOTYPES
**********************/
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name);
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
static void style_init_reset(lv_style_t * style);
/**********************
@@ -89,13 +89,15 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco
style_init_reset(&styles->opa_cover);
lv_style_set_bg_opa(&styles->opa_cover, LV_STATE_DEFAULT, LV_OPA_COVER);
theme.apply_xcb = theme_apply;
theme.apply_xcb = NULL;
theme.apply_cb = theme_apply;
return &theme;
}
void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
{
LV_UNUSED(th);
if(name == LV_THEME_SCR) {
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &styles->opa_cover);

View File

@@ -64,8 +64,9 @@
#define COLOR_BG_SEC_TEXT (IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex(0xa5a8ad))
#define COLOR_BG_SEC_TEXT_DIS (IS_LIGHT ? lv_color_hex(0xaaaaaa) : lv_color_hex(0xa5a8ad))
#define TRANSITION_TIME 150
#define TRANSITION_TIME ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_TRANSITION) ? 0 : 150)
#define BORDER_WIDTH LV_DPX(2)
#define OUTLINE_WIDTH ((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) ? 0 : LV_DPX(2))
#define IS_LIGHT (theme.flags & LV_THEME_MATERIAL_FLAG_LIGHT)
#define PAD_DEF (lv_disp_get_size_category(NULL) <= LV_DISP_SIZE_MEDIUM ? LV_DPX(15) : (LV_DPX(30)))
@@ -73,8 +74,7 @@
/**********************
* TYPEDEFS
**********************/
typedef struct
{
typedef struct {
lv_style_t scr;
lv_style_t bg;
lv_style_t bg_click;
@@ -83,101 +83,102 @@ typedef struct
lv_style_t pad_inner;
lv_style_t pad_small;
#if LV_USE_ARC
lv_style_t arc_indic;
lv_style_t arc_bg;
#endif
#if LV_USE_ARC
lv_style_t arc_indic;
lv_style_t arc_bg;
lv_style_t arc_knob;
#endif
#if LV_USE_BAR
lv_style_t bar_bg;
lv_style_t bar_indic;
#endif
#if LV_USE_BAR
lv_style_t bar_bg;
lv_style_t bar_indic;
#endif
#if LV_USE_CALENDAR
lv_style_t calendar_date_nums, calendar_header, calendar_daynames;
#endif
#if LV_USE_CALENDAR
lv_style_t calendar_date_nums, calendar_header, calendar_daynames;
#endif
#if LV_USE_CPICKER
lv_style_t cpicker_bg, cpicker_indic;
#endif
#if LV_USE_CPICKER
lv_style_t cpicker_bg, cpicker_indic;
#endif
#if LV_USE_CHART
lv_style_t chart_bg, chart_series_bg, chart_series;
#endif
#if LV_USE_CHART
lv_style_t chart_bg, chart_series_bg, chart_series;
#endif
#if LV_USE_CHECKBOX
lv_style_t cb_bg, cb_bullet;
#endif
#if LV_USE_CHECKBOX
lv_style_t cb_bg, cb_bullet;
#endif
#if LV_USE_DROPDOWN
lv_style_t ddlist_page, ddlist_sel;
#endif
#if LV_USE_DROPDOWN
lv_style_t ddlist_page, ddlist_sel;
#endif
#if LV_USE_GAUGE
lv_style_t gauge_main, gauge_strong, gauge_needle;
#endif
#if LV_USE_GAUGE
lv_style_t gauge_main, gauge_strong, gauge_needle;
#endif
#if LV_USE_KEYBOARD
lv_style_t kb_bg;
#endif
#if LV_USE_KEYBOARD
lv_style_t kb_bg;
#endif
#if LV_USE_LED
lv_style_t led;
#endif
#if LV_USE_LED
lv_style_t led;
#endif
#if LV_USE_LINEMETER
lv_style_t lmeter;
#endif
#if LV_USE_LINEMETER
lv_style_t lmeter;
#endif
#if LV_USE_LIST
lv_style_t list_bg, list_btn;
#endif
#if LV_USE_LIST
lv_style_t list_bg, list_btn;
#endif
#if LV_USE_MSGBOX
lv_style_t mbox_bg;
#endif
#if LV_USE_MSGBOX
lv_style_t mbox_bg;
#endif
#if LV_USE_PAGE
lv_style_t sb;
#if LV_USE_ANIMATION
lv_style_t edge_flash;
#endif
#endif
#if LV_USE_PAGE
lv_style_t sb;
#if LV_USE_ANIMATION
lv_style_t edge_flash;
#endif
#endif
#if LV_USE_ROLLER
lv_style_t roller_bg, roller_sel;
#endif
#if LV_USE_ROLLER
lv_style_t roller_bg, roller_sel;
#endif
#if LV_USE_SLIDER
lv_style_t slider_knob, slider_bg;
#endif
#if LV_USE_SLIDER
lv_style_t slider_knob, slider_bg;
#endif
#if LV_USE_SPINBOX
lv_style_t spinbox_cursor;
#endif
#if LV_USE_SPINBOX
lv_style_t spinbox_cursor;
#endif
#if LV_USE_SWITCH
lv_style_t sw_knob;
#endif
#if LV_USE_SWITCH
lv_style_t sw_knob;
#endif
#if LV_USE_TABLE
lv_style_t table_cell;
#endif
#if LV_USE_TABLE
lv_style_t table_cell;
#endif
#if LV_USE_TABVIEW || LV_USE_WIN
lv_style_t tabview_btns, tabview_btns_bg, tabview_indic, tabview_page_scrl;
#endif
#if LV_USE_TABVIEW || LV_USE_WIN
lv_style_t tabview_btns, tabview_btns_bg, tabview_indic, tabview_page_scrl;
#endif
#if LV_USE_TEXTAREA
lv_style_t ta_cursor, ta_placeholder;
#endif
#if LV_USE_TEXTAREA
lv_style_t ta_cursor, ta_placeholder;
#endif
}theme_styles_t;
} theme_styles_t;
/**********************
* STATIC PROTOTYPES
**********************/
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name);
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
static void style_init_reset(lv_style_t * style);
/**********************
@@ -211,7 +212,8 @@ static void basic_init(void)
lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG);
lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_BORDER);
lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, theme.color_primary);
if((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) == 0)lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED,
theme.color_primary);
lv_style_set_border_color(&styles->bg, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH);
lv_style_set_border_post(&styles->bg, LV_STATE_DEFAULT, true);
@@ -246,7 +248,7 @@ static void basic_init(void)
lv_style_set_bg_color(&styles->bg_click, LV_STATE_DISABLED, COLOR_BG_DIS);
lv_style_set_border_width(&styles->bg_click, LV_STATE_CHECKED, 0);
lv_style_set_border_color(&styles->bg_click, LV_STATE_FOCUSED | LV_STATE_PRESSED, lv_color_darken(theme.color_primary,
LV_OPA_20));
LV_OPA_20));
lv_style_set_border_color(&styles->bg_click, LV_STATE_PRESSED, COLOR_BG_BORDER_PR);
lv_style_set_border_color(&styles->bg_click, LV_STATE_CHECKED, COLOR_BG_BORDER_CHK);
lv_style_set_border_color(&styles->bg_click, LV_STATE_PRESSED | LV_STATE_CHECKED, COLOR_BG_BORDER_CHK_PR);
@@ -299,7 +301,7 @@ static void basic_init(void)
lv_style_set_pad_top(&styles->btn, LV_STATE_DEFAULT, LV_DPX(15));
lv_style_set_pad_bottom(&styles->btn, LV_STATE_DEFAULT, LV_DPX(15));
lv_style_set_pad_inner(&styles->btn, LV_STATE_DEFAULT, LV_DPX(20));
lv_style_set_outline_width(&styles->btn, LV_STATE_DEFAULT, 3);
lv_style_set_outline_width(&styles->btn, LV_STATE_DEFAULT, OUTLINE_WIDTH);
lv_style_set_outline_opa(&styles->btn, LV_STATE_DEFAULT, LV_OPA_0);
lv_style_set_outline_opa(&styles->btn, LV_STATE_FOCUSED, LV_OPA_50);
lv_style_set_outline_color(&styles->btn, LV_STATE_DEFAULT, theme.color_primary);
@@ -358,7 +360,7 @@ static void bar_init(void)
lv_style_set_outline_color(&styles->bar_bg, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_outline_opa(&styles->bar_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_outline_opa(&styles->bar_bg, LV_STATE_FOCUSED, LV_OPA_50);
lv_style_set_outline_width(&styles->bar_bg, LV_STATE_DEFAULT, 3);
lv_style_set_outline_width(&styles->bar_bg, LV_STATE_DEFAULT, OUTLINE_WIDTH);
lv_style_set_transition_time(&styles->bar_bg, LV_STATE_DEFAULT, TRANSITION_TIME);
lv_style_set_transition_prop_6(&styles->bar_bg, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA);
@@ -504,6 +506,14 @@ static void arc_init(void)
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_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));
lv_style_set_pad_left(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
lv_style_set_pad_right(&styles->arc_knob, LV_STATE_DEFAULT, LV_DPX(0));
#endif
}
@@ -546,21 +556,24 @@ static void calendar_init(void)
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_set_text_color(&styles->calendar_daynames, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : lv_color_hex3(0xeee));
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_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);
lv_style_set_text_color(&styles->calendar_date_nums, LV_STATE_CHECKED,
IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE);
lv_style_set_text_color(&styles->calendar_date_nums, LV_STATE_DISABLED, LV_COLOR_GRAY);
lv_style_set_bg_opa(&styles->calendar_date_nums, LV_STATE_CHECKED, IS_LIGHT ? LV_OPA_20 : LV_OPA_40);
lv_style_set_bg_opa(&styles->calendar_date_nums, LV_STATE_PRESSED, LV_OPA_20);
lv_style_set_bg_opa(&styles->calendar_date_nums, LV_STATE_FOCUSED, LV_OPA_COVER);
lv_style_set_text_color(&styles->calendar_date_nums, LV_STATE_FOCUSED, LV_COLOR_WHITE);
lv_style_set_bg_color(&styles->calendar_date_nums, LV_STATE_FOCUSED, theme.color_primary);
lv_style_set_bg_color(&styles->calendar_date_nums, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x666666) : LV_COLOR_WHITE);
lv_style_set_bg_color(&styles->calendar_date_nums, LV_STATE_DEFAULT,
IS_LIGHT ? lv_color_hex(0x666666) : LV_COLOR_WHITE);
lv_style_set_bg_color(&styles->calendar_date_nums, LV_STATE_CHECKED, theme.color_primary);
lv_style_set_border_width(&styles->calendar_date_nums, LV_STATE_CHECKED, 2);
lv_style_set_border_side(&styles->calendar_date_nums, LV_STATE_CHECKED, LV_BORDER_SIDE_LEFT);
@@ -606,7 +619,7 @@ static void checkbox_init(void)
lv_style_set_outline_color(&styles->cb_bg, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_outline_opa(&styles->cb_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_outline_opa(&styles->cb_bg, LV_STATE_FOCUSED, LV_OPA_50);
lv_style_set_outline_width(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(3));
lv_style_set_outline_width(&styles->cb_bg, LV_STATE_DEFAULT, OUTLINE_WIDTH);
lv_style_set_outline_pad(&styles->cb_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_transition_time(&styles->cb_bg, LV_STATE_DEFAULT, TRANSITION_TIME);
lv_style_set_transition_prop_6(&styles->cb_bg, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA);
@@ -616,6 +629,9 @@ static void checkbox_init(void)
lv_style_set_radius(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(4));
lv_style_set_pattern_image(&styles->cb_bullet, LV_STATE_CHECKED, LV_SYMBOL_OK);
lv_style_set_pattern_recolor(&styles->cb_bullet, LV_STATE_CHECKED, LV_COLOR_WHITE);
lv_style_set_pattern_opa(&styles->cb_bullet, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_pattern_opa(&styles->cb_bullet, LV_STATE_CHECKED, LV_OPA_COVER);
lv_style_set_transition_prop_3(&styles->cb_bullet, LV_STATE_DEFAULT, LV_STYLE_PATTERN_OPA);
lv_style_set_text_font(&styles->cb_bullet, LV_STATE_CHECKED, theme.font_small);
lv_style_set_pad_left(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
lv_style_set_pad_right(&styles->cb_bullet, LV_STATE_DEFAULT, LV_DPX(3));
@@ -684,7 +700,8 @@ static void textarea_init(void)
lv_style_set_border_side(&styles->ta_cursor, LV_STATE_DEFAULT, LV_BORDER_SIDE_LEFT);
style_init_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));
lv_style_set_text_color(&styles->ta_placeholder, LV_STATE_DEFAULT,
IS_LIGHT ? COLOR_BG_TEXT_DIS : lv_color_hex(0xa1adbd));
#endif
}
@@ -735,7 +752,7 @@ static void list_init(void)
lv_style_set_border_width(&styles->list_btn, LV_STATE_DEFAULT, 1);
lv_style_set_outline_color(&styles->list_btn, LV_STATE_FOCUSED, theme.color_secondary);
lv_style_set_outline_width(&styles->list_btn, LV_STATE_FOCUSED, BORDER_WIDTH);
lv_style_set_outline_width(&styles->list_btn, LV_STATE_FOCUSED, OUTLINE_WIDTH);
lv_style_set_outline_pad(&styles->list_btn, LV_STATE_FOCUSED, -BORDER_WIDTH);
lv_style_set_pad_left(&styles->list_btn, LV_STATE_DEFAULT, PAD_DEF);
@@ -789,6 +806,39 @@ static void roller_init(void)
static void tabview_init(void)
{
#if LV_USE_TABVIEW != 0
#endif
}
static void tileview_init(void)
{
#if LV_USE_TILEVIEW != 0
#endif
}
static void table_init(void)
{
#if LV_USE_TABLE != 0
style_init_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);
lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_right(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_top(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_bottom(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
#endif
}
static void win_init(void)
{
#if LV_USE_WIN != 0
#endif
}
static void tabview_win_shared_init(void)
{
#if LV_USE_TABVIEW || LV_USE_WIN
style_init_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);
@@ -828,34 +878,6 @@ static void tabview_init(void)
#endif
}
static void tileview_init(void)
{
#if LV_USE_TILEVIEW != 0
#endif
}
static void table_init(void)
{
#if LV_USE_TABLE != 0
style_init_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);
lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_right(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_top(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_bottom(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
#endif
}
static void win_init(void)
{
#if LV_USE_WIN != 0
#endif
}
/**********************
* GLOBAL FUNCTIONS
@@ -924,8 +946,10 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s
tileview_init();
table_init();
win_init();
tabview_win_shared_init();
theme.apply_xcb = theme_apply;
theme.apply_xcb = NULL;
theme.apply_cb = theme_apply;
inited = true;
@@ -935,8 +959,10 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s
}
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
{
LV_UNUSED(th);
lv_style_list_t * list;
switch(name) {
@@ -944,18 +970,15 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
case LV_THEME_SCR:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
_lv_style_list_add_style(list, &styles->scr);
break;
case LV_THEME_OBJ:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
break;
#if LV_USE_CONT
case LV_THEME_CONT:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
break;
@@ -963,7 +986,6 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_BTN
case LV_THEME_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->btn);
break;
@@ -971,12 +993,10 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_BTNMATRIX
case LV_THEME_BTNMATRIX:
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG);
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->pad_small);
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN);
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->bg_click);
@@ -985,12 +1005,10 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_KEYBOARD
case LV_THEME_KEYBOARD:
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG);
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG);
_lv_style_list_add_style(list, &styles->scr);
_lv_style_list_add_style(list, &styles->kb_bg);
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN);
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->bg_click);
@@ -999,11 +1017,9 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_BAR
case LV_THEME_BAR:
lv_obj_clean_style_list(obj, LV_BAR_PART_BG);
list = lv_obj_get_style_list(obj, LV_BAR_PART_BG);
_lv_style_list_add_style(list, &styles->bar_bg);
lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC);
_lv_style_list_add_style(list, &styles->bar_indic);
break;
@@ -1011,15 +1027,12 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_SWITCH
case LV_THEME_SWITCH:
lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG);
_lv_style_list_add_style(list, &styles->bar_bg);
lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC);
_lv_style_list_add_style(list, &styles->bar_indic);
lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB);
_lv_style_list_add_style(list, &styles->sw_knob);
break;
@@ -1027,54 +1040,50 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_CANVAS
case LV_THEME_CANVAS:
lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN);
break;
#endif
#if LV_USE_IMG
case LV_THEME_IMAGE:
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
break;
#endif
#if LV_USE_IMGBTN
case LV_THEME_IMGBTN:
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
break;
#endif
#if LV_USE_LABEL
case LV_THEME_LABEL:
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
break;
#endif
#if LV_USE_LINE
case LV_THEME_LINE:
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
break;
#endif
#if LV_USE_ARC
case LV_THEME_ARC:
lv_obj_clean_style_list(obj, LV_ARC_PART_BG);
list = lv_obj_get_style_list(obj, LV_ARC_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->arc_bg);
lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
_lv_style_list_add_style(list, &styles->arc_indic);
list = lv_obj_get_style_list(obj, LV_ARC_PART_KNOB);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->bg_click);
_lv_style_list_add_style(list, &styles->arc_knob);
break;
#endif
#if LV_USE_SPINNER
case LV_THEME_SPINNER:
lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG);
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG);
_lv_style_list_add_style(list, &styles->arc_bg);
lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC);
_lv_style_list_add_style(list, &styles->arc_indic);
break;
@@ -1082,16 +1091,13 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_SLIDER
case LV_THEME_SLIDER:
lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG);
_lv_style_list_add_style(list, &styles->bar_bg);
_lv_style_list_add_style(list, &styles->slider_bg);
lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC);
_lv_style_list_add_style(list, &styles->bar_indic);
lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB);
_lv_style_list_add_style(list, &styles->slider_knob);
break;
@@ -1099,11 +1105,9 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_CHECKBOX
case LV_THEME_CHECKBOX:
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG);
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG);
_lv_style_list_add_style(list, &styles->cb_bg);
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET);
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET);
_lv_style_list_add_style(list, &styles->btn);
_lv_style_list_add_style(list, &styles->cb_bullet);
@@ -1112,18 +1116,15 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_MSGBOX
case LV_THEME_MSGBOX:
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->mbox_bg);
break;
case LV_THEME_MSGBOX_BTNS:
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG);
_lv_style_list_add_style(list, &styles->pad_small);
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN);
_lv_style_list_add_style(list, &styles->btn);
break;
@@ -1131,27 +1132,22 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#endif
#if LV_USE_LED
case LV_THEME_LED:
lv_obj_clean_style_list(obj, LV_LED_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN);
_lv_style_list_add_style(list, &styles->led);
break;
#endif
#if LV_USE_PAGE
case LV_THEME_PAGE:
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
_lv_style_list_add_style(list, &styles->pad_inner);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
#if LV_USE_ANIMATION
lv_obj_clean_style_list(obj, LV_PAGE_PART_EDGE_FLASH);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_EDGE_FLASH);
_lv_style_list_add_style(list, &styles->edge_flash);
#endif
@@ -1159,29 +1155,20 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#endif
#if LV_USE_TABVIEW
case LV_THEME_TABVIEW:
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG);
_lv_style_list_add_style(list, &styles->scr);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG);
_lv_style_list_add_style(list, &styles->tabview_btns_bg);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC);
_lv_style_list_add_style(list, &styles->tabview_indic);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
_lv_style_list_add_style(list, &styles->tabview_btns);
break;
case LV_THEME_TABVIEW_PAGE:
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
_lv_style_list_add_style(list, &styles->tabview_page_scrl);
@@ -1190,16 +1177,13 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_TILEVIEW
case LV_THEME_TILEVIEW:
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG);
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG);
_lv_style_list_add_style(list, &styles->scr);
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
#if LV_USE_ANIMATION
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
_lv_style_list_add_style(list, &styles->edge_flash);
#endif
@@ -1209,41 +1193,33 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_ROLLER
case LV_THEME_ROLLER:
lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG);
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->roller_bg);
lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED);
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED);
_lv_style_list_add_style(list, &styles->roller_sel);
break;
#endif
#if LV_USE_OBJMASK
case LV_THEME_OBJMASK:
lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN);
break;
#endif
#if LV_USE_LIST
case LV_THEME_LIST:
lv_obj_clean_style_list(obj, LV_LIST_PART_BG);
list = lv_obj_get_style_list(obj, LV_LIST_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->list_bg);
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE);
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
break;
case LV_THEME_LIST_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->list_btn);
break;
@@ -1251,22 +1227,18 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_DROPDOWN
case LV_THEME_DROPDOWN:
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->bg_click);
_lv_style_list_add_style(list, &styles->pad_small);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->ddlist_page);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED);
_lv_style_list_add_style(list, &styles->ddlist_sel);
break;
@@ -1274,41 +1246,33 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_CHART
case LV_THEME_CHART:
lv_obj_clean_style_list(obj, LV_CHART_PART_BG);
list = lv_obj_get_style_list(obj, LV_CHART_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->chart_bg);
_lv_style_list_add_style(list, &styles->pad_small);
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG);
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG);
_lv_style_list_add_style(list, &styles->pad_small);
_lv_style_list_add_style(list, &styles->chart_series_bg);
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES);
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
_lv_style_list_add_style(list, &styles->chart_series);
break;
#endif
#if LV_USE_TABLE
case LV_THEME_TABLE:
lv_obj_clean_style_list(obj, LV_TABLE_PART_BG);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1);
_lv_style_list_add_style(list, &styles->table_cell);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2);
_lv_style_list_add_style(list, &styles->table_cell);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3);
_lv_style_list_add_style(list, &styles->table_cell);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4);
_lv_style_list_add_style(list, &styles->table_cell);
break;
@@ -1316,25 +1280,20 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_WIN
case LV_THEME_WIN:
lv_obj_clean_style_list(obj, LV_WIN_PART_BG);
list = lv_obj_get_style_list(obj, LV_WIN_PART_BG);
_lv_style_list_add_style(list, &styles->scr);
lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
_lv_style_list_add_style(list, &styles->tabview_page_scrl);
lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER);
list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER);
_lv_style_list_add_style(list, &styles->tabview_btns_bg);
break;
case LV_THEME_WIN_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->tabview_btns);
break;
@@ -1342,20 +1301,16 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_TEXTAREA
case LV_THEME_TEXTAREA:
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->pad_small);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
_lv_style_list_add_style(list, &styles->ta_placeholder);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR);
_lv_style_list_add_style(list, &styles->ta_cursor);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
break;
@@ -1365,18 +1320,15 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_SPINBOX
case LV_THEME_SPINBOX:
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG);
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->pad_small);
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR);
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR);
_lv_style_list_add_style(list, &styles->spinbox_cursor);
break;
case LV_THEME_SPINBOX_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->bg_click);
@@ -1385,30 +1337,24 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_CALENDAR
case LV_THEME_CALENDAR:
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE);
_lv_style_list_add_style(list, &styles->calendar_date_nums);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER);
_lv_style_list_add_style(list, &styles->calendar_header);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
_lv_style_list_add_style(list, &styles->calendar_daynames);
break;
#endif
#if LV_USE_CPICKER
case LV_THEME_CPICKER:
lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
_lv_style_list_add_style(list, &styles->cpicker_bg);
lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB);
_lv_style_list_add_style(list, &styles->cpicker_indic);
break;
@@ -1416,7 +1362,6 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_LINEMETER
case LV_THEME_LINEMETER:
lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->lmeter);
@@ -1424,16 +1369,13 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#endif
#if LV_USE_GAUGE
case LV_THEME_GAUGE:
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->gauge_main);
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR);
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR);
_lv_style_list_add_style(list, &styles->gauge_strong);
lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE);
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE);
_lv_style_list_add_style(list, &styles->gauge_needle);
break;
@@ -1442,7 +1384,7 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
}
lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
/**********************

View File

@@ -24,6 +24,7 @@ typedef enum {
LV_THEME_MATERIAL_FLAG_DARK = 0x01,
LV_THEME_MATERIAL_FLAG_LIGHT = 0x02,
LV_THEME_MATERIAL_FLAG_NO_TRANSITION = 0x10,
LV_THEME_MATERIAL_FLAG_NO_FOCUS = 0x20,
} lv_theme_material_flag_t;
/**********************

View File

@@ -24,21 +24,21 @@
* TYPEDEFS
**********************/
typedef struct
{
lv_style_t scr;
lv_style_t bg;
lv_style_t clip_corner;
lv_style_t btn;
lv_style_t round;
lv_style_t no_radius;
lv_style_t fg_color;
lv_style_t border_none;
lv_style_t big_line_space; /*In roller or dropdownlist*/
lv_style_t pad_none;
lv_style_t pad_normal;
lv_style_t pad_small;
lv_style_t pad_inner;
typedef struct {
lv_style_t scr;
lv_style_t bg;
lv_style_t clip_corner;
lv_style_t btn;
lv_style_t round;
lv_style_t no_radius;
lv_style_t fg_color;
lv_style_t border_none;
lv_style_t big_line_space; /*In roller or dropdownlist*/
lv_style_t pad_none;
lv_style_t pad_normal;
lv_style_t pad_small;
lv_style_t pad_inner;
lv_style_t txt_underline;
#if LV_USE_ARC
lv_style_t arc_bg, arc_indic;
@@ -79,12 +79,12 @@ lv_style_t pad_inner;
#if LV_USE_TABVIEW
lv_style_t tab_bg;
#endif
}theme_styles_t;
} theme_styles_t;
/**********************
* STATIC PROTOTYPES
**********************/
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name);
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
static void style_init_reset(lv_style_t * style);
/**********************
@@ -123,6 +123,8 @@ static void basic_init(void)
lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->bg, LV_STATE_DEFAULT, BG_COLOR);
lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH);
lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED, BORDER_WIDTH * 2);
lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED | LV_STATE_EDITED, BORDER_WIDTH * 3);
lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1));
lv_style_set_scale_end_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1));
@@ -140,10 +142,11 @@ static void basic_init(void)
style_init_reset(&styles->clip_corner);
lv_style_set_clip_corner(&styles->clip_corner, LV_STATE_DEFAULT, true);
style_init_reset(&styles->btn);
lv_style_set_radius(&styles->btn, LV_STATE_DEFAULT, RADIUS);
lv_style_set_border_width(&styles->btn, LV_STATE_DEFAULT, BORDER_WIDTH);
lv_style_set_border_width(&styles->btn, LV_STATE_FOCUSED, BORDER_WIDTH + 1);
lv_style_set_border_width(&styles->btn, LV_STATE_FOCUSED | LV_STATE_EDITED, BORDER_WIDTH + 2);
lv_style_set_border_color(&styles->btn, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_bg_color(&styles->btn, LV_STATE_DEFAULT, BG_COLOR);
lv_style_set_bg_color(&styles->btn, LV_STATE_PRESSED, FG_COLOR);
@@ -205,6 +208,9 @@ static void basic_init(void)
style_init_reset(&styles->pad_inner);
lv_style_set_pad_inner(&styles->pad_inner, LV_STATE_DEFAULT, LV_DPI / 15);
style_init_reset(&styles->txt_underline);
lv_style_set_text_decor(&styles->txt_underline, LV_STATE_FOCUSED, LV_TEXT_DECOR_UNDERLINE);
}
static void arc_init(void)
@@ -553,14 +559,17 @@ lv_theme_t * lv_theme_mono_init(lv_color_t color_primary, lv_color_t color_secon
table_init();
win_init();
theme.apply_xcb = theme_apply;
theme.apply_xcb = NULL;
theme.apply_cb = theme_apply;
return &theme;
}
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
{
LV_UNUSED(th);
lv_style_list_t * list;
switch(name) {
@@ -568,18 +577,15 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
case LV_THEME_SCR:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
_lv_style_list_add_style(list, &styles->scr);
break;
case LV_THEME_OBJ:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
break;
#if LV_USE_CONT
case LV_THEME_CONT:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
break;
@@ -587,34 +593,31 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_BTN
case LV_THEME_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
_lv_style_list_add_style(list, &styles->txt_underline);
break;
#endif
#if LV_USE_BTNMATRIX
case LV_THEME_BTNMATRIX:
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG);
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN);
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
_lv_style_list_add_style(list, &styles->txt_underline);
break;
#endif
#if LV_USE_KEYBOARD
case LV_THEME_KEYBOARD:
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG);
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->pad_small);
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN);
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
@@ -623,13 +626,11 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_BAR
case LV_THEME_BAR:
lv_obj_clean_style_list(obj, LV_BAR_PART_BG);
list = lv_obj_get_style_list(obj, LV_BAR_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->pad_none);
_lv_style_list_add_style(list, &styles->round);
lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->fg_color);
@@ -639,18 +640,15 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_SWITCH
case LV_THEME_SWITCH:
lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->pad_none);
_lv_style_list_add_style(list, &styles->round);
lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->fg_color);
lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->pad_none);
@@ -660,46 +658,39 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_CANVAS
case LV_THEME_CANVAS:
lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN);
break;
#endif
#if LV_USE_IMG
case LV_THEME_IMAGE:
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
break;
#endif
#if LV_USE_IMGBTN
case LV_THEME_IMGBTN:
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
break;
#endif
#if LV_USE_LABEL
case LV_THEME_LABEL:
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
break;
#endif
#if LV_USE_LINE
case LV_THEME_LINE:
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
break;
#endif
#if LV_USE_ARC
case LV_THEME_ARC:
lv_obj_clean_style_list(obj, LV_ARC_PART_BG);
list = lv_obj_get_style_list(obj, LV_ARC_PART_BG);
_lv_style_list_add_style(list, &styles->arc_bg);
lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
_lv_style_list_add_style(list, &styles->arc_indic);
break;
@@ -707,12 +698,10 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_SPINNER
case LV_THEME_SPINNER:
lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG);
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->tick_line);
lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->fg_color);
@@ -722,59 +711,53 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_SLIDER
case LV_THEME_SLIDER:
lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->pad_none);
lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->fg_color);
lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->round);
_lv_style_list_add_style(list, &styles->pad_small);
_lv_style_list_add_style(list, &styles->fg_color);
break;
#endif
#if LV_USE_CHECKBOX
case LV_THEME_CHECKBOX:
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG);
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG);
_lv_style_list_add_style(list, &styles->pad_small);
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET);
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
_lv_style_list_add_style(list, &styles->pad_small);
break;
#endif
#if LV_USE_MSGBOX
case LV_THEME_MSGBOX:
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
break;
case LV_THEME_MSGBOX_BTNS:
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG);
_lv_style_list_add_style(list, &styles->pad_inner);
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
_lv_style_list_add_style(list, &styles->txt_underline);
break;
#endif
#if LV_USE_LED
case LV_THEME_LED:
lv_obj_clean_style_list(obj, LV_LED_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->round);
@@ -782,45 +765,32 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#endif
#if LV_USE_PAGE
case LV_THEME_PAGE:
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
_lv_style_list_add_style(list, &styles->pad_inner);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
break;
#endif
#if LV_USE_TABVIEW
case LV_THEME_TABVIEW:
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG);
_lv_style_list_add_style(list, &styles->scr);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG);
_lv_style_list_add_style(list, &styles->tab_bg);
_lv_style_list_add_style(list, &styles->pad_small);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
_lv_style_list_add_style(list, &styles->txt_underline);
break;
case LV_THEME_TABVIEW_PAGE:
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
_lv_style_list_add_style(list, &styles->pad_normal);
@@ -829,15 +799,12 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_TILEVIEW
case LV_THEME_TILEVIEW:
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG);
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
_lv_style_list_add_style(list, &styles->bg);
break;
@@ -846,12 +813,10 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_ROLLER
case LV_THEME_ROLLER:
lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG);
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->big_line_space);
lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED);
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->fg_color);
@@ -862,53 +827,44 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_OBJMASK
case LV_THEME_OBJMASK:
lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN);
break;
#endif
#if LV_USE_LIST
case LV_THEME_LIST:
lv_obj_clean_style_list(obj, LV_LIST_PART_BG);
list = lv_obj_get_style_list(obj, LV_LIST_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->pad_none);
_lv_style_list_add_style(list, &styles->clip_corner);
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE);
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
break;
case LV_THEME_LIST_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
_lv_style_list_add_style(list, &styles->list_btn);
_lv_style_list_add_style(list, &styles->txt_underline);
break;
#endif
#if LV_USE_DROPDOWN
case LV_THEME_DROPDOWN:
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->big_line_space);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->fg_color);
@@ -918,42 +874,34 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_CHART
case LV_THEME_CHART:
lv_obj_clean_style_list(obj, LV_CHART_PART_BG);
list = lv_obj_get_style_list(obj, LV_CHART_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG);
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->border_none);
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES);
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
_lv_style_list_add_style(list, &styles->chart_series);
break;
#endif
#if LV_USE_TABLE
case LV_THEME_TABLE:
lv_obj_clean_style_list(obj, LV_TABLE_PART_BG);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->no_radius);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->no_radius);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->no_radius);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->no_radius);
@@ -962,25 +910,20 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_WIN
case LV_THEME_WIN:
lv_obj_clean_style_list(obj, LV_WIN_PART_BG);
list = lv_obj_get_style_list(obj, LV_WIN_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER);
list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER);
_lv_style_list_add_style(list, &styles->bg);
break;
case LV_THEME_WIN_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
@@ -989,17 +932,12 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_TEXTAREA
case LV_THEME_TEXTAREA:
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR);
_lv_style_list_add_style(list, &styles->ta_cursor);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->sb);
break;
@@ -1008,33 +946,30 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_SPINBOX
case LV_THEME_SPINBOX:
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG);
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR);
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->fg_color);
_lv_style_list_add_style(list, &styles->pad_none);
_lv_style_list_add_style(list, &styles->no_radius);
_lv_style_list_add_style(list, &styles->txt_underline);
break;
case LV_THEME_SPINBOX_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
_lv_style_list_add_style(list, &styles->txt_underline);
break;
#endif
#if LV_USE_CALENDAR
case LV_THEME_CALENDAR:
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
@@ -1042,12 +977,10 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
_lv_style_list_add_style(list, &styles->border_none);
_lv_style_list_add_style(list, &styles->calendar_date);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER);
_lv_style_list_add_style(list, &styles->pad_normal);
_lv_style_list_add_style(list, &styles->border_none);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->pad_small);
@@ -1055,11 +988,9 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#endif
#if LV_USE_CPICKER
case LV_THEME_CPICKER:
lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->round);
@@ -1068,7 +999,6 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_LINEMETER
case LV_THEME_LINEMETER:
lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->round);
@@ -1077,16 +1007,13 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#endif
#if LV_USE_GAUGE
case LV_THEME_GAUGE:
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->round);
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR);
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR);
_lv_style_list_add_style(list, &styles->gauge_major);
lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE);
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE);
_lv_style_list_add_style(list, &styles->gauge_needle);
break;
@@ -1096,7 +1023,7 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
}
lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}

View File

@@ -37,7 +37,7 @@ typedef struct {
/**********************
* STATIC PROTOTYPES
**********************/
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name);
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
/**********************
* STATIC VARIABLES
@@ -80,7 +80,8 @@ static void basic_init(void)
style_init_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, LV_OPA_30));
lv_style_set_bg_color(&styles->btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_darken(theme.color_primary,
LV_OPA_30));
lv_style_set_bg_color(&styles->btn, LV_STATE_DISABLED, LV_COLOR_SILVER);
lv_style_set_text_color(&styles->btn, LV_STATE_DISABLED, LV_COLOR_GRAY);
lv_style_set_image_recolor(&styles->btn, LV_STATE_DISABLED, LV_COLOR_GRAY);
@@ -401,14 +402,17 @@ lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_s
table_init();
win_init();
theme.apply_xcb = theme_apply;
theme.apply_xcb = NULL;
theme.apply_cb = theme_apply;
return &theme;
}
void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
{
LV_UNUSED(th);
lv_style_list_t * list;
switch(name) {
@@ -416,19 +420,16 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
case LV_THEME_SCR:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->tight);
break;
case LV_THEME_OBJ:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
break;
#if LV_USE_CONT
case LV_THEME_CONT:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
break;
@@ -436,7 +437,6 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_BTN
case LV_THEME_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
@@ -445,11 +445,9 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_BTNMATRIX
case LV_THEME_BTNMATRIX:
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG);
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN);
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
@@ -458,11 +456,9 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_KEYBOARD
case LV_THEME_KEYBOARD:
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG);
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN);
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
@@ -471,12 +467,10 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_BAR
case LV_THEME_BAR:
lv_obj_clean_style_list(obj, LV_BAR_PART_BG);
list = lv_obj_get_style_list(obj, LV_BAR_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->tight);
lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->color);
@@ -485,18 +479,15 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_SWITCH
case LV_THEME_SWITCH:
lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->tight);
_lv_style_list_add_style(list, &styles->round);
lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->color);
lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->tight);
@@ -506,48 +497,41 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_CANVAS
case LV_THEME_CANVAS:
lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN);
break;
#endif
#if LV_USE_IMG
case LV_THEME_IMAGE:
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
break;
#endif
#if LV_USE_IMGBTN
case LV_THEME_IMGBTN:
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
break;
#endif
#if LV_USE_LABEL
case LV_THEME_LABEL:
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
break;
#endif
#if LV_USE_LINE
case LV_THEME_LINE:
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
break;
#endif
#if LV_USE_ARC
case LV_THEME_ARC:
lv_obj_clean_style_list(obj, LV_ARC_PART_BG);
list = lv_obj_get_style_list(obj, LV_ARC_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->tick_line);
_lv_style_list_add_style(list, &styles->round);
lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->color);
@@ -557,12 +541,10 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_SPINNER
case LV_THEME_SPINNER:
lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG);
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->tick_line);
lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->color);
@@ -572,16 +554,13 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_SLIDER
case LV_THEME_SLIDER:
lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->color);
lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->round);
@@ -590,10 +569,8 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_CHECKBOX
case LV_THEME_CHECKBOX:
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG);
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG);
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET);
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
@@ -602,17 +579,14 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_MSGBOX
case LV_THEME_MSGBOX:
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
break;
case LV_THEME_MSGBOX_BTNS:
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN);
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
@@ -621,7 +595,6 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#endif
#if LV_USE_LED
case LV_THEME_LED:
lv_obj_clean_style_list(obj, LV_LED_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->color);
@@ -630,53 +603,43 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#endif
#if LV_USE_PAGE
case LV_THEME_PAGE:
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->gray);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->bg);
break;
#endif
#if LV_USE_TABVIEW
case LV_THEME_TABVIEW:
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->color);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->color);
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
break;
case LV_THEME_TABVIEW_PAGE:
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->gray);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
_lv_style_list_add_style(list, &styles->bg);
@@ -685,15 +648,12 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_TILEVIEW
case LV_THEME_TILEVIEW:
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG);
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
_lv_style_list_add_style(list, &styles->bg);
break;
@@ -702,11 +662,9 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_ROLLER
case LV_THEME_ROLLER:
lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG);
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED);
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->color);
@@ -716,27 +674,22 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_OBJMASK
case LV_THEME_OBJMASK:
lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN);
break;
#endif
#if LV_USE_LIST
case LV_THEME_LIST:
lv_obj_clean_style_list(obj, LV_LIST_PART_BG);
list = lv_obj_get_style_list(obj, LV_LIST_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLABLE);
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->bg);
break;
case LV_THEME_LIST_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
@@ -745,20 +698,16 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_DROPDOWN
case LV_THEME_DROPDOWN:
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED);
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->color);
@@ -767,15 +716,12 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_CHART
case LV_THEME_CHART:
lv_obj_clean_style_list(obj, LV_CHART_PART_BG);
list = lv_obj_get_style_list(obj, LV_CHART_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG);
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES);
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->tight);
@@ -783,23 +729,18 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#endif
#if LV_USE_TABLE
case LV_THEME_TABLE:
lv_obj_clean_style_list(obj, LV_TABLE_PART_BG);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4);
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4);
_lv_style_list_add_style(list, &styles->bg);
break;
@@ -807,25 +748,20 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_WIN
case LV_THEME_WIN:
lv_obj_clean_style_list(obj, LV_WIN_PART_BG);
list = lv_obj_get_style_list(obj, LV_WIN_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER);
list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER);
_lv_style_list_add_style(list, &styles->bg);
break;
case LV_THEME_WIN_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
@@ -834,20 +770,16 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_TEXTAREA
case LV_THEME_TEXTAREA:
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
_lv_style_list_add_style(list, &styles->gray);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->tight);
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
_lv_style_list_add_style(list, &styles->bg);
break;
@@ -856,17 +788,14 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_SPINBOX
case LV_THEME_SPINBOX:
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG);
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR);
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR);
_lv_style_list_add_style(list, &styles->bg);
break;
case LV_THEME_SPINBOX_BTN:
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
@@ -875,21 +804,17 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_CALENDAR
case LV_THEME_CALENDAR:
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->btn);
_lv_style_list_add_style(list, &styles->tight);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->tight);
@@ -897,11 +822,9 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#endif
#if LV_USE_CPICKER
case LV_THEME_CPICKER:
lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->round);
@@ -910,7 +833,6 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#if LV_USE_LINEMETER
case LV_THEME_LINEMETER:
lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->round);
@@ -918,16 +840,13 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
#endif
#if LV_USE_GAUGE
case LV_THEME_GAUGE:
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN);
_lv_style_list_add_style(list, &styles->bg);
_lv_style_list_add_style(list, &styles->round);
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR);
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR);
_lv_style_list_add_style(list, &styles->tick_line);
lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE);
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE);
_lv_style_list_add_style(list, &styles->bg);
break;
@@ -936,10 +855,7 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
}
lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
/**********************

View File

@@ -9,6 +9,8 @@
#include "lv_arc.h"
#if LV_USE_ARC != 0
#include "../lv_core/lv_group.h"
#include "../lv_core/lv_indev.h"
#include "../lv_misc/lv_debug.h"
#include "../lv_misc/lv_math.h"
#include "../lv_draw/lv_draw_arc.h"
@@ -29,7 +31,10 @@
static lv_design_res_t lv_arc_design(lv_obj_t * arc, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param);
static lv_style_list_t * lv_arc_get_style(lv_obj_t * arc, uint8_t part);
static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angle);
static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angle, lv_arc_part_t part);
static void get_center(lv_obj_t * arc, lv_point_t * center, lv_coord_t * arc_r);
static void get_knob_area(lv_obj_t * arc, const lv_point_t * center, lv_coord_t r, lv_area_t * knob_area);
static void value_update(lv_obj_t * arc);
/**********************
* STATIC VARIABLES
@@ -78,7 +83,17 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
ext->bg_angle_end = 45;
ext->arc_angle_start = 135;
ext->arc_angle_end = 270;
ext->type = LV_ARC_TYPE_NORMAL;
ext->cur_value = -1;
ext->min_value = 0;
ext->max_value = 100;
ext->dragging = false;
ext->adjustable = false;
ext->chg_rate = 540;
ext->last_tick = lv_tick_get();
ext->last_angle = ext->arc_angle_end;
lv_style_list_init(&ext->style_arc);
lv_style_list_init(&ext->style_knob);
lv_obj_set_size(arc, LV_DPI, LV_DPI);
@@ -88,6 +103,10 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new arc arc*/
if(copy == NULL) {
lv_obj_set_click(arc, true);
lv_obj_add_protect(arc, LV_PROTECT_PRESS_LOST);
lv_obj_set_ext_click_area(arc, LV_DPI / 10, LV_DPI / 10, LV_DPI / 10, LV_DPI / 10);
lv_arc_set_value(arc, ext->min_value);
lv_theme_apply(arc, LV_THEME_ARC);
}
/*Copy an existing arc*/
@@ -97,11 +116,20 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
ext->arc_angle_end = copy_ext->arc_angle_end;
ext->bg_angle_start = copy_ext->bg_angle_start;
ext->bg_angle_end = copy_ext->bg_angle_end;
ext->type = copy_ext->type;
ext->cur_value = copy_ext->cur_value;
ext->min_value = copy_ext->min_value;
ext->max_value = copy_ext->max_value;
ext->dragging = copy_ext->dragging;
ext->adjustable = copy_ext->adjustable;
ext->chg_rate = copy_ext->chg_rate;
ext->last_tick = copy_ext->last_tick;
ext->last_angle = copy_ext->last_angle;
lv_style_list_copy(&ext->style_knob, &copy_ext->style_knob);
lv_style_list_copy(&ext->style_arc, &copy_ext->style_arc);
/*Refresh the style with new signal function*/
lv_obj_refresh_style(arc, LV_STYLE_PROP_ALL);
lv_obj_refresh_style(arc, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
LV_LOG_INFO("arc created");
@@ -140,11 +168,13 @@ void lv_arc_set_start_angle(lv_obj_t * arc, uint16_t start)
}
/*Only a smaller incremental move*/
else if(ext->arc_angle_start > ext->arc_angle_end && start > ext->arc_angle_end) {
inv_arc_area(arc, LV_MATH_MIN(ext->arc_angle_start, start), LV_MATH_MAX(ext->arc_angle_start, start));
inv_arc_area(arc, LV_MATH_MIN(ext->arc_angle_start, start), LV_MATH_MAX(ext->arc_angle_start, start),
LV_ARC_PART_INDIC);
}
/*Only a smaller incremental move*/
else if(ext->arc_angle_start < ext->arc_angle_end && start < ext->arc_angle_end) {
inv_arc_area(arc, LV_MATH_MIN(ext->arc_angle_start, start), LV_MATH_MAX(ext->arc_angle_start, start));
inv_arc_area(arc, LV_MATH_MIN(ext->arc_angle_start, start), LV_MATH_MAX(ext->arc_angle_start, start),
LV_ARC_PART_INDIC);
}
/*Crossing the start angle makes the whole arc change*/
else {
@@ -173,11 +203,11 @@ void lv_arc_set_end_angle(lv_obj_t * arc, uint16_t end)
}
/*Only a smaller incremental move*/
else if(ext->arc_angle_end > ext->arc_angle_start && end > ext->arc_angle_start) {
inv_arc_area(arc, LV_MATH_MIN(ext->arc_angle_end, end), LV_MATH_MAX(ext->arc_angle_end, end));
inv_arc_area(arc, LV_MATH_MIN(ext->arc_angle_end, end), LV_MATH_MAX(ext->arc_angle_end, end), LV_ARC_PART_INDIC);
}
/*Only a smaller incremental move*/
else if(ext->arc_angle_end < ext->arc_angle_start && end < ext->arc_angle_start) {
inv_arc_area(arc, LV_MATH_MIN(ext->arc_angle_end, end), LV_MATH_MAX(ext->arc_angle_end, end));
inv_arc_area(arc, LV_MATH_MIN(ext->arc_angle_end, end), LV_MATH_MAX(ext->arc_angle_end, end), LV_ARC_PART_INDIC);
}
/*Crossing the end angle makes the whole arc change*/
else {
@@ -203,12 +233,12 @@ void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end)
if(start > 360) start -= 360;
if(end > (start + 360)) end = start + 360;
inv_arc_area(arc, ext->arc_angle_start, ext->arc_angle_end);
inv_arc_area(arc, ext->arc_angle_start, ext->arc_angle_end, LV_ARC_PART_INDIC);
ext->arc_angle_start = start;
ext->arc_angle_end = end;
inv_arc_area(arc, ext->arc_angle_start, ext->arc_angle_end);
inv_arc_area(arc, ext->arc_angle_start, ext->arc_angle_end, LV_ARC_PART_INDIC);
}
/**
@@ -230,11 +260,11 @@ void lv_arc_set_bg_start_angle(lv_obj_t * arc, uint16_t start)
}
/*Only a smaller incremental move*/
else if(ext->bg_angle_start > ext->bg_angle_end && start > ext->bg_angle_end) {
inv_arc_area(arc, LV_MATH_MIN(ext->bg_angle_start, start), LV_MATH_MAX(ext->bg_angle_start, start));
inv_arc_area(arc, LV_MATH_MIN(ext->bg_angle_start, start), LV_MATH_MAX(ext->bg_angle_start, start), LV_ARC_PART_BG);
}
/*Only a smaller incremental move*/
else if(ext->bg_angle_start < ext->bg_angle_end && start < ext->bg_angle_end) {
inv_arc_area(arc, LV_MATH_MIN(ext->bg_angle_start, start), LV_MATH_MAX(ext->bg_angle_start, start));
inv_arc_area(arc, LV_MATH_MIN(ext->bg_angle_start, start), LV_MATH_MAX(ext->bg_angle_start, start), LV_ARC_PART_BG);
}
/*Crossing the start angle makes the whole arc change*/
else {
@@ -263,11 +293,11 @@ void lv_arc_set_bg_end_angle(lv_obj_t * arc, uint16_t end)
}
/*Only a smaller incremental move*/
else if(ext->bg_angle_end > ext->bg_angle_start && end > ext->bg_angle_start) {
inv_arc_area(arc, LV_MATH_MIN(ext->bg_angle_end, end), LV_MATH_MAX(ext->bg_angle_end, end));
inv_arc_area(arc, LV_MATH_MIN(ext->bg_angle_end, end), LV_MATH_MAX(ext->bg_angle_end, end), LV_ARC_PART_BG);
}
/*Only a smaller incremental move*/
else if(ext->bg_angle_end < ext->bg_angle_start && end < ext->bg_angle_start) {
inv_arc_area(arc, LV_MATH_MIN(ext->bg_angle_end, end), LV_MATH_MAX(ext->bg_angle_end, end));
inv_arc_area(arc, LV_MATH_MIN(ext->bg_angle_end, end), LV_MATH_MAX(ext->bg_angle_end, end), LV_ARC_PART_BG);
}
/*Crossing the end angle makes the whole arc change*/
else {
@@ -292,12 +322,12 @@ void lv_arc_set_bg_angles(lv_obj_t * arc, uint16_t start, uint16_t end)
if(start > 360) start -= 360;
if(end > (start + 360)) end = start + 360;
inv_arc_area(arc, ext->bg_angle_start, ext->bg_angle_end);
inv_arc_area(arc, ext->bg_angle_start, ext->bg_angle_end, LV_ARC_PART_BG);
ext->bg_angle_start = start;
ext->bg_angle_end = end;
inv_arc_area(arc, ext->bg_angle_start, ext->bg_angle_end);
inv_arc_area(arc, ext->bg_angle_start, ext->bg_angle_end, LV_ARC_PART_BG);
}
/**
@@ -316,6 +346,122 @@ void lv_arc_set_rotation(lv_obj_t * arc, uint16_t rotation_angle)
lv_obj_invalidate(arc);
}
/**
* Set the type of arc.
* @param arc pointer to arc object
* @param type arc type
*/
void lv_arc_set_type(lv_obj_t * arc, lv_arc_type_t type)
{
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc);
int16_t val = ext->cur_value;
ext->type = type;
ext->cur_value = -1; /** Force set_value handling*/
int16_t bg_midpoint, bg_end = ext->bg_angle_end;
if(ext->bg_angle_end < ext->bg_angle_start) bg_end = ext->bg_angle_end + 360;
switch(ext->type) {
case LV_ARC_TYPE_SYMMETRIC:
bg_midpoint = (ext->bg_angle_start + bg_end) / 2;
lv_arc_set_start_angle(arc, bg_midpoint);
lv_arc_set_end_angle(arc, bg_midpoint);
break;
case LV_ARC_TYPE_REVERSE:
lv_arc_set_end_angle(arc, ext->bg_angle_end);
break;
default: /** LV_ARC_TYPE_NORMAL*/
lv_arc_set_start_angle(arc, ext->bg_angle_start);
}
lv_arc_set_value(arc, val);
}
/**
* Set a new value on the arc
* @param arc pointer to a arc object
* @param value new value
*/
void lv_arc_set_value(lv_obj_t * arc, int16_t value)
{
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc);
if(ext->cur_value == value) return;
int16_t new_value;
new_value = value > ext->max_value ? ext->max_value : value;
new_value = new_value < ext->min_value ? ext->min_value : new_value;
if(ext->cur_value == new_value) return;
ext->cur_value = new_value;
value_update(arc);
}
/**
* Set minimum and the maximum values of a arc
* @param arc pointer to the arc object
* @param min minimum value
* @param max maximum value
*/
void lv_arc_set_range(lv_obj_t * arc, int16_t min, int16_t max)
{
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc);
if(ext->min_value == min && ext->max_value == max) return;
ext->min_value = min;
ext->max_value = max;
if(ext->cur_value < min) {
ext->cur_value = min;
}
if(ext->cur_value > max) {
ext->cur_value = max;
}
value_update(arc); /* value has changed relative to the new range */
}
/**
* Set the threshold of arc knob increments
* position.
* @param arc pointer to a arc object
* @param threshold increment threshold
*/
void lv_arc_set_chg_rate(lv_obj_t * arc, uint16_t rate)
{
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc);
ext->chg_rate = rate;
}
/**
* Set whether the arc is adjustable.
* @param arc pointer to a arc object
* @param adjustable whether the arc has a knob that can be dragged
*/
void lv_arc_set_adjustable(lv_obj_t * arc, bool adjustable)
{
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc);
if(ext->adjustable == adjustable)
return;
ext->adjustable = adjustable;
if(!adjustable)
ext->dragging = false;
lv_obj_invalidate(arc);
}
/*=====================
* Getter functions
*====================*/
@@ -376,6 +522,85 @@ uint16_t lv_arc_get_bg_angle_end(lv_obj_t * arc)
return ext->bg_angle_end;
}
/**
* Get the value of a arc
* @param arc pointer to a arc object
* @return the value of the arc
*/
int16_t lv_arc_get_value(const lv_obj_t * arc)
{
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
return ext->cur_value;
}
/**
* Get the minimum value of a arc
* @param arc pointer to a arc object
* @return the minimum value of the arc
*/
int16_t lv_arc_get_min_value(const lv_obj_t * arc)
{
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc);
return ext->min_value;
}
/**
* Get the maximum value of a arc
* @param arc pointer to a arc object
* @return the maximum value of the arc
*/
int16_t lv_arc_get_max_value(const lv_obj_t * arc)
{
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc);
return ext->max_value;
}
/**
* Give the arc is being dragged or not
* @param arc pointer to a arc object
* @return true: drag in progress false: not dragged
*/
bool lv_arc_is_dragged(const lv_obj_t * arc)
{
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
return ext->dragging;
}
/**
* Get whether the arc is type or not.
* @param arc pointer to a arc object
* @return arc type
*/
lv_arc_type_t lv_arc_get_type(const lv_obj_t * arc)
{
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc);
return ext->type;
}
/**
* Get whether the arc is adjustable.
* @param arc pointer to a arc object
* @return whether the arc has a knob that can be dragged
*/
bool lv_arc_get_adjustable(lv_obj_t * arc)
{
LV_ASSERT_OBJ(arc, LV_OBJX_NAME);
lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc);
return ext->adjustable;
}
/*=====================
* Other functions
*====================*/
@@ -414,21 +639,18 @@ static lv_design_res_t lv_arc_design(lv_obj_t * arc, const lv_area_t * clip_area
lv_draw_rect(&arc->coords, clip_area, &bg_dsc);
lv_coord_t left_bg = lv_obj_get_style_pad_left(arc, LV_ARC_PART_BG);
lv_coord_t right_bg = lv_obj_get_style_pad_right(arc, LV_ARC_PART_BG);
lv_coord_t top_bg = lv_obj_get_style_pad_top(arc, LV_ARC_PART_BG);
lv_coord_t bottom_bg = lv_obj_get_style_pad_bottom(arc, LV_ARC_PART_BG);
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(arc) - left_bg - right_bg,
lv_obj_get_height(arc) - top_bg - bottom_bg)) / 2;
lv_draw_line_dsc_t arc_dsc;
lv_coord_t x = arc->coords.x1 + r + left_bg;
lv_coord_t y = arc->coords.y1 + r + top_bg;
lv_point_t center;
lv_coord_t arc_r;
get_center(arc, &center, &arc_r);
if(r > 0) {
/*Draw the background arc*/
lv_draw_line_dsc_t arc_dsc;
if(arc_r > 0) {
lv_draw_line_dsc_init(&arc_dsc);
lv_obj_init_draw_line_dsc(arc, LV_ARC_PART_BG, &arc_dsc);
lv_draw_arc(x, y, r, ext->bg_angle_start + ext->rotation_angle, ext->bg_angle_end + ext->rotation_angle, clip_area,
lv_draw_arc(center.x, center.y, arc_r, ext->bg_angle_start + ext->rotation_angle,
ext->bg_angle_end + ext->rotation_angle, clip_area,
&arc_dsc);
}
@@ -438,15 +660,28 @@ static lv_design_res_t lv_arc_design(lv_obj_t * arc, const lv_area_t * clip_area
lv_coord_t right_indic = lv_obj_get_style_pad_right(arc, LV_ARC_PART_INDIC);
lv_coord_t top_indic = lv_obj_get_style_pad_top(arc, LV_ARC_PART_INDIC);
lv_coord_t bottom_indic = lv_obj_get_style_pad_bottom(arc, LV_ARC_PART_INDIC);
r -= LV_MATH_MAX4(left_indic, right_indic, top_indic, bottom_indic);
lv_coord_t indic_r = arc_r - LV_MATH_MAX4(left_indic, right_indic, top_indic, bottom_indic);
if(r > 0) {
if(indic_r > 0) {
lv_draw_line_dsc_init(&arc_dsc);
lv_obj_init_draw_line_dsc(arc, LV_ARC_PART_INDIC, &arc_dsc);
lv_draw_arc(x, y, r, ext->arc_angle_start + ext->rotation_angle, ext->arc_angle_end + ext->rotation_angle, clip_area,
lv_draw_arc(center.x, center.y, indic_r, ext->arc_angle_start + ext->rotation_angle,
ext->arc_angle_end + ext->rotation_angle, clip_area,
&arc_dsc);
}
if(ext->adjustable) {
lv_area_t knob_area;
get_knob_area(arc, &center, arc_r, &knob_area);
lv_draw_rect_dsc_t knob_rect_dsc;
lv_draw_rect_dsc_init(&knob_rect_dsc);
lv_obj_init_draw_rect_dsc(arc, LV_ARC_PART_KNOB, &knob_rect_dsc);
lv_draw_rect(&knob_area, clip_area, &knob_rect_dsc);
}
}
/*Post draw when the children are drawn*/
else if(mode == LV_DESIGN_DRAW_POST) {
@@ -478,7 +713,126 @@ static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param)
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
if(sign == LV_SIGNAL_CLEANUP) {
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
if(sign == LV_SIGNAL_PRESSING) {
/* Only adjustable arcs can be dragged */
if(!ext->adjustable) return res;
lv_indev_t * indev = lv_indev_get_act();
if(indev == NULL) return res;
/*Handle only pointers here*/
lv_indev_type_t indev_type = lv_indev_get_type(indev);
if(indev_type != LV_INDEV_TYPE_POINTER) return res;
lv_point_t p;
lv_indev_get_point(indev, &p);
/*Make point relative to the arc's center*/
lv_point_t center;
lv_coord_t r;
get_center(arc, &center, &r);
p.x -= center.x;
p.y -= center.y;
/*Enter dragging mode if pressed out of the knob*/
if(ext->dragging == false) {
lv_coord_t indic_width = lv_obj_get_style_line_width(arc, LV_ARC_PART_INDIC);
r -= indic_width;
r -= r / 2; /*Add some more sensitive area*/
if(p.x * p.x + p.y * p.y > r * r) {
ext->dragging = true;
ext->last_tick = lv_tick_get(); /*Capture timestamp at dragging start*/
}
}
/*It must be in "dragging" mode to turn the arc*/
if(ext->dragging == false) return res;
/*Calculate the angle of the pressed point*/
int16_t angle;
int16_t bg_end = ext->bg_angle_end;
if(ext->bg_angle_end < ext->bg_angle_start) {
bg_end = ext->bg_angle_end + 360;
}
angle = 360 - _lv_atan2(p.x, p.y) + 90; /*Some transformation is required*/
angle -= ext->rotation_angle;
if(angle < ext->bg_angle_start) angle = ext->bg_angle_start;
if(angle > bg_end) angle = bg_end;
/*Calculate the slew rate limited angle based on change rate (degrees/sec)*/
int16_t delta_angle = angle - ext->last_angle;
uint32_t delta_tick = lv_tick_elaps(ext->last_tick);
int16_t delta_angle_max = (ext->chg_rate * delta_tick) / 1000;
if(delta_angle > delta_angle_max) {
delta_angle = delta_angle_max;
}
else if(delta_angle < -delta_angle_max) {
delta_angle = -delta_angle_max;
}
angle = ext->last_angle + delta_angle; /*Apply the limited angle change*/
/*Rounding for symmetry*/
int32_t round = ((bg_end - ext->bg_angle_start) * 8) / (ext->max_value - ext->min_value);
round = (round + 4) >> 4;
angle += round;
/*Set the new value*/
int16_t old_value = ext->cur_value;
int16_t new_value = _lv_map(angle, ext->bg_angle_start, bg_end, ext->min_value, ext->max_value);
if(new_value != lv_arc_get_value(arc)) {
ext->last_tick = lv_tick_get(); /*Cache timestamp for the next iteration*/
lv_arc_set_value(arc, new_value); /*set_value caches the last_angle for the next iteration*/
if(new_value != old_value) {
res = lv_event_send(arc, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
}
}
/*Don1't let the elapsed time to big while sitting on an end point*/
if(new_value == ext->min_value || new_value == ext->max_value) {
ext->last_tick = lv_tick_get(); /*Cache timestamp for the next iteration*/
}
}
else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
ext->dragging = false;
#if LV_USE_GROUP
/*Leave edit mode if released. (No need to wait for LONG_PRESS) */
lv_group_t * g = lv_obj_get_group(arc);
bool editing = lv_group_get_editing(g);
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
if(indev_type == LV_INDEV_TYPE_ENCODER) {
if(editing) lv_group_set_editing(g, false);
}
#endif
}
else if(sign == LV_SIGNAL_CONTROL) {
if(!ext->adjustable) return res;
char c = *((char *)param);
int16_t old_value = ext->cur_value;
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
lv_arc_set_value(arc, lv_arc_get_value(arc) + 1);
}
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
lv_arc_set_value(arc, lv_arc_get_value(arc) - 1);
}
if(old_value != ext->cur_value) {
res = lv_event_send(arc, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
}
}
else if(sign == LV_SIGNAL_CLEANUP) {
lv_obj_clean_style_list(arc, LV_ARC_PART_KNOB);
lv_obj_clean_style_list(arc, LV_ARC_PART_INDIC);
}
@@ -506,6 +860,9 @@ static lv_style_list_t * lv_arc_get_style(lv_obj_t * arc, uint8_t part)
case LV_ARC_PART_INDIC:
style_dsc_p = &ext->style_arc;
break;
case LV_ARC_PART_KNOB:
style_dsc_p = &ext->style_knob;
break;
default:
style_dsc_p = NULL;
}
@@ -513,8 +870,11 @@ static lv_style_list_t * lv_arc_get_style(lv_obj_t * arc, uint8_t part)
return style_dsc_p;
}
static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angle)
static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angle, lv_arc_part_t part)
{
/*Skip this complicated invalidation if the arc is not visible*/
if(lv_obj_is_visible(arc) == false) return;
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
start_angle += ext->rotation_angle;
@@ -533,10 +893,26 @@ static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angl
lv_coord_t rout = (LV_MATH_MIN(lv_obj_get_width(arc) - left - right, lv_obj_get_height(arc) - top - bottom)) / 2;
lv_coord_t x = arc->coords.x1 + rout + left;
lv_coord_t y = arc->coords.y1 + rout + top;
lv_style_int_t w = lv_obj_get_style_line_width(arc, LV_ARC_PART_INDIC);
lv_style_int_t rounded = lv_obj_get_style_line_rounded(arc, LV_ARC_PART_INDIC);
lv_style_int_t w = lv_obj_get_style_line_width(arc, part);
lv_style_int_t rounded = lv_obj_get_style_line_rounded(arc, part);
lv_coord_t rin = rout - w;
lv_coord_t extra_area = rounded ? w / 2 + 2 : 0;
lv_coord_t extra_area = 0;
extra_area = rounded ? w / 2 + 2 : 0;
if(part == LV_ARC_PART_INDIC && lv_style_list_get_style(&ext->style_knob, 0) != NULL) {
lv_coord_t knob_extra_size = lv_obj_get_draw_rect_ext_pad_size(arc, LV_ARC_PART_KNOB);
lv_coord_t knob_left = lv_obj_get_style_pad_left(arc, LV_ARC_PART_KNOB);
lv_coord_t knob_right = lv_obj_get_style_pad_right(arc, LV_ARC_PART_KNOB);
lv_coord_t knob_top = lv_obj_get_style_pad_top(arc, LV_ARC_PART_KNOB);
lv_coord_t knob_bottom = lv_obj_get_style_pad_bottom(arc, LV_ARC_PART_KNOB);
knob_extra_size += LV_MATH_MAX4(knob_left, knob_right, knob_top, knob_bottom);
extra_area = LV_MATH_MAX(extra_area, w / 2 + 2 + knob_extra_size);
}
lv_area_t inv_area;
@@ -617,4 +993,97 @@ static void inv_arc_area(lv_obj_t * arc, uint16_t start_angle, uint16_t end_angl
lv_obj_invalidate(arc);
}
}
static void get_center(lv_obj_t * arc, lv_point_t * center, lv_coord_t * arc_r)
{
lv_coord_t left_bg = lv_obj_get_style_pad_left(arc, LV_ARC_PART_BG);
lv_coord_t right_bg = lv_obj_get_style_pad_right(arc, LV_ARC_PART_BG);
lv_coord_t top_bg = lv_obj_get_style_pad_top(arc, LV_ARC_PART_BG);
lv_coord_t bottom_bg = lv_obj_get_style_pad_bottom(arc, LV_ARC_PART_BG);
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(arc) - left_bg - right_bg,
lv_obj_get_height(arc) - top_bg - bottom_bg)) / 2;
*arc_r = r;
center->x = arc->coords.x1 + r + left_bg;
center->y = arc->coords.y1 + r + top_bg;
lv_coord_t indic_width = lv_obj_get_style_line_width(arc, LV_ARC_PART_INDIC);
r -= indic_width;
}
static void get_knob_area(lv_obj_t * arc, const lv_point_t * center, lv_coord_t r, lv_area_t * knob_area)
{
lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc);
lv_coord_t indic_width = lv_obj_get_style_line_width(arc, LV_ARC_PART_INDIC);
lv_coord_t indic_width_half = indic_width / 2;
r -= indic_width_half;
uint16_t angle = ext->rotation_angle;
if(ext->type == LV_ARC_TYPE_NORMAL) {
angle += ext->arc_angle_end;
}
else if(ext->type == LV_ARC_TYPE_REVERSE) {
angle += ext->arc_angle_start;
}
else if(ext->type == LV_ARC_TYPE_SYMMETRIC) {
int32_t range_midpoint = (int32_t)(ext->min_value + ext->max_value) / 2;
if(ext->cur_value < range_midpoint) angle += ext->arc_angle_start;
else angle += ext->arc_angle_end;
}
lv_coord_t knob_x = (r * _lv_trigo_sin(angle + 90)) >> LV_TRIGO_SHIFT;
lv_coord_t knob_y = (r * _lv_trigo_sin(angle)) >> LV_TRIGO_SHIFT;
lv_coord_t left_knob = lv_obj_get_style_pad_left(arc, LV_ARC_PART_KNOB);
lv_coord_t right_knob = lv_obj_get_style_pad_right(arc, LV_ARC_PART_KNOB);
lv_coord_t top_knob = lv_obj_get_style_pad_top(arc, LV_ARC_PART_KNOB);
lv_coord_t bottom_knob = lv_obj_get_style_pad_bottom(arc, LV_ARC_PART_KNOB);
knob_area->x1 = center->x + knob_x - left_knob - indic_width_half;
knob_area->x2 = center->x + knob_x + right_knob + indic_width_half;
knob_area->y1 = center->y + knob_y - top_knob - indic_width_half;
knob_area->y2 = center->y + knob_y + bottom_knob + indic_width_half;
}
/**
* Used internally to update arc angles after a value change
* @param arc pointer to a arc object
*/
static void value_update(lv_obj_t * arc)
{
lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc);
int16_t bg_midpoint, range_midpoint, bg_end = ext->bg_angle_end;
if(ext->bg_angle_end < ext->bg_angle_start) bg_end = ext->bg_angle_end + 360;
int16_t angle;
switch(ext->type) {
case LV_ARC_TYPE_SYMMETRIC:
bg_midpoint = (ext->bg_angle_start + bg_end) / 2;
range_midpoint = (int32_t)(ext->min_value + ext->max_value) / 2;
if(ext->cur_value < range_midpoint) {
angle = _lv_map(ext->cur_value, ext->min_value, range_midpoint, ext->bg_angle_start, bg_midpoint);
lv_arc_set_start_angle(arc, angle);
lv_arc_set_end_angle(arc, bg_midpoint);
}
else {
angle = _lv_map(ext->cur_value, range_midpoint, ext->max_value, bg_midpoint, bg_end);
lv_arc_set_start_angle(arc, bg_midpoint);
lv_arc_set_end_angle(arc, angle);
}
break;
case LV_ARC_TYPE_REVERSE:
angle = _lv_map(ext->cur_value, ext->min_value, ext->max_value, ext->bg_angle_start, bg_end);
lv_arc_set_start_angle(arc, angle);
break;
default: /** LV_ARC_TYPE_NORMAL*/
angle = _lv_map(ext->cur_value, ext->min_value, ext->max_value, ext->bg_angle_start, bg_end);
lv_arc_set_end_angle(arc, angle);
}
ext->last_angle = angle; /*Cache angle for slew rate limiting*/
}
#endif

View File

@@ -26,6 +26,14 @@ extern "C" {
/**********************
* TYPEDEFS
**********************/
enum {
LV_ARC_TYPE_NORMAL,
LV_ARC_TYPE_SYMMETRIC,
LV_ARC_TYPE_REVERSE
};
typedef uint8_t lv_arc_type_t;
/*Data of arc*/
typedef struct {
/*New data for this type */
@@ -35,14 +43,25 @@ typedef struct {
uint16_t bg_angle_start;
uint16_t bg_angle_end;
lv_style_list_t style_arc;
lv_style_list_t style_knob; /* Style of the knob */
int16_t cur_value; /*Current value of the arc*/
int16_t min_value; /*Minimum value of the arc*/
int16_t max_value; /*Maximum value of the arc*/
uint16_t dragging : 1;
uint16_t type : 2;
uint16_t adjustable : 1;
uint16_t chg_rate; /*Drag angle rate of change of the arc (degrees/sec)*/
uint32_t last_tick; /*Last dragging event timestamp of the arc*/
int16_t last_angle; /*Last dragging angle of the arc*/
} lv_arc_ext_t;
/*Parts of the arc*/
enum {
LV_ARC_PART_BG = LV_OBJ_PART_MAIN,
LV_ARC_PART_INDIC,
LV_ARC_PART_KNOB,
_LV_ARC_PART_VIRTUAL_LAST,
_LV_ARC_PART_REAL_LAST = _LV_OBJ_PART_REAL_LAST,
};
typedef uint8_t lv_arc_part_t;
@@ -118,6 +137,44 @@ void lv_arc_set_bg_angles(lv_obj_t * arc, uint16_t start, uint16_t end);
*/
void lv_arc_set_rotation(lv_obj_t * arc, uint16_t rotation_angle);
/**
* Set the type of arc.
* @param arc pointer to arc object
* @param type arc type
*/
void lv_arc_set_type(lv_obj_t * arc, lv_arc_type_t type);
/**
* Set a new value on the arc
* @param arc pointer to a arc object
* @param value new value
*/
void lv_arc_set_value(lv_obj_t * arc, int16_t value);
/**
* Set minimum and the maximum values of a arc
* @param arc pointer to the arc object
* @param min minimum value
* @param max maximum value
*/
void lv_arc_set_range(lv_obj_t * arc, int16_t min, int16_t max);
/**
* Set the threshold of arc knob increments
* position.
* @param arc pointer to a arc object
* @param threshold increment threshold
*/
void lv_arc_set_chg_rate(lv_obj_t * arc, uint16_t threshold);
/**
* Set whether the arc is adjustable.
* @param arc pointer to a arc object
* @param adjustable whether the arc has a knob that can be dragged
*/
void lv_arc_set_adjustable(lv_obj_t * arc, bool adjustable);
/*=====================
* Getter functions
*====================*/
@@ -150,6 +207,48 @@ uint16_t lv_arc_get_bg_angle_start(lv_obj_t * arc);
*/
uint16_t lv_arc_get_bg_angle_end(lv_obj_t * arc);
/**
* Get whether the arc is type or not.
* @param arc pointer to a arc object
* @return arc type
*/
lv_arc_type_t lv_arc_get_type(const lv_obj_t * arc);
/**
* Get the value of the of a arc
* @param arc pointer to a arc object
* @return the value of the of the arc
*/
int16_t lv_arc_get_value(const lv_obj_t * arc);
/**
* Get the minimum value of a arc
* @param arc pointer to a arc object
* @return the minimum value of the arc
*/
int16_t lv_arc_get_min_value(const lv_obj_t * arc);
/**
* Get the maximum value of a arc
* @param arc pointer to a arc object
* @return the maximum value of the arc
*/
int16_t lv_arc_get_max_value(const lv_obj_t * arc);
/**
* Give the arc is being dragged or not
* @param arc pointer to a arc object
* @return true: drag in progress false: not dragged
*/
bool lv_arc_is_dragged(const lv_obj_t * arc);
/**
* Get whether the arc is adjustable.
* @param arc pointer to a arc object
* @return whether the arc has a knob that can be dragged
*/
bool lv_arc_get_adjustable(lv_obj_t * arc);
/*=====================
* Other functions
*====================*/

View File

@@ -130,7 +130,7 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
lv_style_list_copy(&ext->style_indic, &ext_copy->style_indic);
/*Refresh the style with new signal function*/
lv_obj_refresh_style(bar, LV_STYLE_PROP_ALL);
lv_obj_refresh_style(bar, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
lv_bar_set_value(bar, ext->cur_value, LV_ANIM_OFF);
}
@@ -395,7 +395,9 @@ static lv_design_res_t lv_bar_design(lv_obj_t * bar, const lv_area_t * clip_area
lv_draw_rect_dsc_init(&draw_dsc);
draw_dsc.bg_opa = LV_OPA_TRANSP;
draw_dsc.pattern_opa = LV_OPA_TRANSP;
draw_dsc.outline_opa = LV_OPA_TRANSP;
draw_dsc.shadow_opa = LV_OPA_TRANSP;
draw_dsc.value_opa = LV_OPA_TRANSP;
lv_obj_init_draw_rect_dsc(bar, LV_OBJ_PART_MAIN, &draw_dsc);
lv_draw_rect(&bar->coords, clip_area, &draw_dsc);
@@ -414,6 +416,8 @@ static void draw_bg(lv_obj_t * bar, const lv_area_t * clip_area)
draw_dsc.border_opa = LV_OPA_TRANSP;
}
/*value will be drawn later*/
draw_dsc.value_opa = LV_OPA_TRANSP;
lv_obj_init_draw_rect_dsc(bar, LV_BAR_PART_BG, &draw_dsc);
lv_draw_rect(&bar->coords, clip_area, &draw_dsc);

View File

@@ -100,7 +100,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
ext->checkable = copy_ext->checkable;
/*Refresh the style with new signal function*/
lv_obj_refresh_style(btn, LV_STYLE_PROP_ALL);
lv_obj_refresh_style(btn, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
LV_LOG_INFO("button created");
@@ -202,7 +202,8 @@ lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn)
if(obj_state & LV_STATE_CHECKED) {
if(obj_state & LV_STATE_PRESSED) return LV_BTN_STATE_CHECKED_PRESSED;
else return LV_BTN_STATE_CHECKED_RELEASED;
} else {
}
else {
if(obj_state & LV_STATE_PRESSED) return LV_BTN_STATE_PRESSED;
else return LV_BTN_STATE_RELEASED;
}
@@ -288,6 +289,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
}
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
if(lv_btn_get_checkable(btn)) {
@@ -308,6 +310,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
if(res != LV_RES_OK) return res;
}
}
#endif
}
return res;

View File

@@ -20,6 +20,7 @@
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_btnmatrix"
#define BTN_EXTRA_CLICK_AREA_MAX (LV_DPI / 4)
/**********************
* TYPEDEFS
@@ -177,7 +178,7 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[])
}
lv_coord_t btn_h = max_h - ((line_cnt - 1) * inner);
btn_h = btn_h / line_cnt;
btn_h = (btn_h + line_cnt / 2) / line_cnt;
btn_h--; /*-1 because e.g. height = 100 means 101 pixels (0..100)*/
/* Count the units and the buttons in a line
@@ -207,7 +208,7 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[])
/*Only deal with the non empty lines*/
if(btn_cnt != 0) {
/*Calculate the width of all units*/
lv_coord_t all_unit_w = max_w - ((btn_cnt - 1) * inner);
lv_coord_t all_unit_w = max_w - ((unit_cnt - 1) * inner);
/*Set the button size and positions and set the texts*/
uint16_t i;
@@ -215,19 +216,20 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[])
unit_act_cnt = 0;
for(i = 0; i < btn_cnt; i++) {
uint8_t btn_unit_w = get_button_width(ext->ctrl_bits[btn_i]);
/* one_unit_w = all_unit_w / unit_cnt
* act_unit_w = one_unit_w * button_width
* do this two operations but the multiply first to divide a greater number */
lv_coord_t act_unit_w = (all_unit_w * get_button_width(ext->ctrl_bits[btn_i])) / unit_cnt;
lv_coord_t act_unit_w = (all_unit_w * btn_unit_w) / unit_cnt + inner * (btn_unit_w - 1);
act_unit_w--; /*-1 because e.g. width = 100 means 101 pixels (0..100)*/
/*Always recalculate act_x because of rounding errors */
if(base_dir == LV_BIDI_DIR_RTL) {
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * inner;
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + unit_act_cnt * inner;
act_x = lv_obj_get_width(btnm) - right - act_x - act_unit_w - 1;
}
else {
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * inner +
act_x = (unit_act_cnt * all_unit_w) / unit_cnt + unit_act_cnt * inner +
left;
}
/* Set the button's area.
@@ -242,7 +244,7 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[])
lv_area_set(&ext->button_areas[btn_i], act_x, act_y, act_x + act_unit_w, act_y + btn_h);
}
unit_act_cnt += get_button_width(ext->ctrl_bits[btn_i]);
unit_act_cnt += btn_unit_w;
i_tot++;
btn_i++;
@@ -422,6 +424,23 @@ void lv_btnmatrix_set_one_check(lv_obj_t * btnm, bool one_chk)
make_one_button_toggled(btnm, 0);
}
/**
* Set the align of the map text (left, right or center)
* @param btnm pointer to a btnmatrix object
* @param align LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
*/
void lv_btnmatrix_set_align(lv_obj_t * btnm, lv_label_align_t align)
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(ext->align == align) return;
ext->align = align;
lv_obj_invalidate(btnm);
}
/*=====================
* Getter functions
*====================*/
@@ -563,6 +582,32 @@ bool lv_btnmatrix_get_one_check(const lv_obj_t * btnm)
return ext->one_check;
}
/**
* Get the align attribute
* @param btnm pointer to a btnmatrix object
* @return LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
*/
lv_label_align_t lv_btnmatrix_get_align(const lv_obj_t * btnm)
{
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_label_align_t align = ext->align;
if(align == LV_LABEL_ALIGN_AUTO) {
#if LV_USE_BIDI
lv_bidi_dir_t base_dir = lv_obj_get_base_dir(btnm);
if(base_dir == LV_BIDI_DIR_RTL) align = LV_LABEL_ALIGN_RIGHT;
else align = LV_LABEL_ALIGN_LEFT;
#else
align = LV_LABEL_ALIGN_LEFT;
#endif
}
return align;
}
/**********************
* STATIC FUNCTIONS
**********************/
@@ -598,7 +643,10 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
uint16_t btn_i = 0;
uint16_t txt_i = 0;
lv_txt_flag_t txt_flag = LV_TXT_FLAG_NONE;
if(ext->recolor) txt_flag = LV_TXT_FLAG_RECOLOR;
if(ext->recolor) txt_flag |= LV_TXT_FLAG_RECOLOR;
lv_label_align_t align = lv_btnmatrix_get_align(btnm);
if(align == LV_LABEL_ALIGN_CENTER) txt_flag |= LV_TXT_FLAG_CENTER;
if(align == LV_LABEL_ALIGN_RIGHT) txt_flag |= LV_TXT_FLAG_RIGHT;
lv_draw_rect_dsc_t draw_rect_rel_dsc;
lv_draw_label_dsc_t draw_label_rel_dsc;
@@ -612,8 +660,8 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
lv_draw_rect_dsc_t draw_rect_tmp_dsc;
lv_draw_label_dsc_t draw_label_tmp_dsc;
/*The state changes without re-caching the styles, disable the use of cache*/
lv_state_t state_ori = btnm->state;
_lv_obj_disable_style_caching(btnm, true);
btnm->state = LV_STATE_DEFAULT;
lv_draw_rect_dsc_init(&draw_rect_rel_dsc);
lv_draw_label_dsc_init(&draw_label_rel_dsc);
@@ -621,6 +669,7 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_rel_dsc);
draw_label_rel_dsc.flag = txt_flag;
btnm->state = state_ori;
_lv_obj_disable_style_caching(btnm, false);
bool chk_inited = false;
bool disabled_inited = false;
@@ -649,50 +698,55 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
/*Choose the style*/
lv_draw_rect_dsc_t * draw_rect_dsc_act;
lv_draw_label_dsc_t * draw_label_dsc_act;
bool tgl_state = button_get_tgl_state(ext->ctrl_bits[btn_i]);
lv_state_t btn_state = LV_STATE_DEFAULT;
if(button_get_tgl_state(ext->ctrl_bits[btn_i])) btn_state |= LV_STATE_CHECKED;
if(button_is_inactive(ext->ctrl_bits[btn_i])) btn_state |= LV_STATE_DISABLED;
if(btn_i == ext->btn_id_pr) btn_state |= LV_STATE_PRESSED;
if(btn_i == ext->btn_id_focused) {
btn_state |= LV_STATE_FOCUSED;
if(state_ori & LV_STATE_EDITED) btn_state |= LV_STATE_EDITED;
}
if(tgl_state) {
if(btn_state == LV_STATE_DEFAULT) {
draw_rect_dsc_act = &draw_rect_rel_dsc;
draw_label_dsc_act = &draw_label_rel_dsc;
}
else if(btn_state == LV_STATE_CHECKED) {
if(!chk_inited) {
btnm->state = LV_STATE_CHECKED;
_lv_obj_disable_style_caching(btnm, true);
lv_draw_rect_dsc_init(&draw_rect_chk_dsc);
lv_draw_label_dsc_init(&draw_label_chk_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_chk_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_chk_dsc);
draw_label_chk_dsc.flag = txt_flag;
btnm->state = state_ori;
_lv_obj_disable_style_caching(btnm, false);
chk_inited = true;
}
draw_rect_dsc_act = &draw_rect_chk_dsc;
draw_label_dsc_act = &draw_label_chk_dsc;
}
if(button_is_inactive(ext->ctrl_bits[btn_i])) {
else if(btn_state == LV_STATE_DISABLED) {
if(!disabled_inited) {
btnm->state = LV_STATE_DISABLED;
_lv_obj_disable_style_caching(btnm, true);
lv_draw_rect_dsc_init(&draw_rect_ina_dsc);
lv_draw_label_dsc_init(&draw_label_ina_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_ina_dsc);
lv_obj_init_draw_label_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_label_ina_dsc);
draw_label_ina_dsc.flag = txt_flag;
btnm->state = state_ori;
_lv_obj_disable_style_caching(btnm, false);
disabled_inited = true;
}
draw_rect_dsc_act = &draw_rect_ina_dsc;
draw_label_dsc_act = &draw_label_ina_dsc;
}
/*Simple released or checked buttons button*/
else if(btn_i != ext->btn_id_pr && btn_i != ext->btn_id_focused) {
draw_rect_dsc_act = tgl_state ? &draw_rect_chk_dsc : &draw_rect_rel_dsc;
draw_label_dsc_act = tgl_state ? &draw_label_chk_dsc : &draw_label_rel_dsc;
}
/*Focused and/or pressed + checked or released button*/
/*In other cases get the styles directly without caching them*/
else {
btnm->state = LV_STATE_DEFAULT;
if(tgl_state) btnm->state = LV_STATE_CHECKED;
if(ext->btn_id_pr == btn_i) btnm->state |= LV_STATE_PRESSED;
if(ext->btn_id_focused == btn_i) {
btnm->state |= LV_STATE_FOCUSED;
if(state_ori & LV_STATE_EDITED) btnm->state |= LV_STATE_EDITED;
}
btnm->state = btn_state;
_lv_obj_disable_style_caching(btnm, true);
lv_draw_rect_dsc_init(&draw_rect_tmp_dsc);
lv_draw_label_dsc_init(&draw_label_tmp_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_tmp_dsc);
@@ -700,8 +754,8 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
draw_label_tmp_dsc.flag = txt_flag;
draw_rect_dsc_act = &draw_rect_tmp_dsc;
draw_label_dsc_act = &draw_label_tmp_dsc;
btnm->state = state_ori;
_lv_obj_disable_style_caching(btnm, false);
}
lv_style_int_t border_part_ori = draw_rect_dsc_act->border_side;
@@ -852,11 +906,11 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
if(btn_pr != LV_BTNMATRIX_BTN_NONE &&
button_is_inactive(ext->ctrl_bits[btn_pr]) == false &&
button_is_hidden(ext->ctrl_bits[btn_pr]) == false) {
invalidate_button_area(btnm, btn_pr);
/* Send VALUE_CHANGED for the newly pressed button */
uint32_t b = btn_pr;
res = lv_event_send(btnm, LV_EVENT_VALUE_CHANGED, &b);
if(res == LV_RES_OK) {
invalidate_button_area(btnm, btn_pr);
if(button_is_click_trig(ext->ctrl_bits[btn_pr]) == false) {
uint32_t b = btn_pr;
lv_event_send(btnm, LV_EVENT_VALUE_CHANGED, &b);
}
}
}
@@ -866,7 +920,7 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
/*Toggle the button if enabled*/
if(button_is_tgl_enabled(ext->ctrl_bits[ext->btn_id_pr]) &&
!button_is_inactive(ext->ctrl_bits[ext->btn_id_pr])) {
if(button_get_tgl_state(ext->ctrl_bits[ext->btn_id_pr])) {
if(button_get_tgl_state(ext->ctrl_bits[ext->btn_id_pr]) && !ext->one_check) {
ext->ctrl_bits[ext->btn_id_pr] &= (~LV_BTNMATRIX_CTRL_CHECK_STATE);
}
else {
@@ -946,6 +1000,7 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
ext->btn_id_act = LV_BTNMATRIX_BTN_NONE;
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param);
if(c == LV_KEY_RIGHT) {
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE)
@@ -1013,10 +1068,13 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
ext->btn_id_act = ext->btn_id_focused;
lv_obj_invalidate(btnm);
}
#endif
}
else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param;
*editable = true;
#endif
}
return res;
}
@@ -1154,18 +1212,25 @@ static uint16_t get_button_from_point(lv_obj_t * btnm, lv_point_t * p)
/*Get the half inner padding. Button look larger with this value. (+1 for rounding error)*/
pinner = (pinner / 2) + 1 + (pinner & 1);
pinner = LV_MATH_MIN(pinner, BTN_EXTRA_CLICK_AREA_MAX);
pright = LV_MATH_MIN(pright, BTN_EXTRA_CLICK_AREA_MAX);
ptop = LV_MATH_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX);
pbottom = LV_MATH_MIN(pbottom, BTN_EXTRA_CLICK_AREA_MAX);
for(i = 0; i < ext->btn_cnt; i++) {
lv_area_copy(&btn_area, &ext->button_areas[i]);
if(btn_area.x1 <= pleft) btn_area.x1 = btnm_cords.x1;
if(btn_area.x1 <= pleft) btn_area.x1 += btnm_cords.x1 - LV_MATH_MIN(pleft, BTN_EXTRA_CLICK_AREA_MAX);
else btn_area.x1 += btnm_cords.x1 - pinner;
if(btn_area.y1 <= ptop) btn_area.y1 = btnm_cords.y1;
if(btn_area.y1 <= ptop) btn_area.y1 += btnm_cords.y1 - LV_MATH_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX);
else btn_area.y1 += btnm_cords.y1 - pinner;
if(btn_area.x2 >= w - pright - 2) btn_area.x2 = btnm_cords.x2; /*-2 for rounding error*/
if(btn_area.x2 >= w - pright - 2) btn_area.x2 += btnm_cords.x1 + LV_MATH_MIN(pright,
BTN_EXTRA_CLICK_AREA_MAX); /*-2 for rounding error*/
else btn_area.x2 += btnm_cords.x1 + pinner;
if(btn_area.y2 >= h - pbottom - 2) btn_area.y2 = btnm_cords.y2; /*-2 for rounding error*/
if(btn_area.y2 >= h - pbottom - 2) btn_area.y2 += btnm_cords.y1 + LV_MATH_MIN(pbottom,
BTN_EXTRA_CLICK_AREA_MAX); /*-2 for rounding error*/
else btn_area.y2 += btnm_cords.y1 + pinner;
if(_lv_area_is_point_on(&btn_area, p, 0) != false) {

View File

@@ -59,6 +59,7 @@ typedef struct {
uint16_t btn_id_act; /*Index of the active button (being pressed/released etc) or LV_BTNMATRIX_BTN_NONE */
uint8_t recolor : 1; /*Enable button recoloring*/
uint8_t one_check : 1; /*Single button toggled at once*/
uint8_t align : 2; /*Align type from 'lv_label_align_t'*/
} lv_btnmatrix_ext_t;
enum {
@@ -170,6 +171,13 @@ void lv_btnmatrix_set_btn_width(lv_obj_t * btnm, uint16_t btn_id, uint8_t width)
*/
void lv_btnmatrix_set_one_check(lv_obj_t * btnm, bool one_chk);
/**
* Set the align of the map text (left, right or center)
* @param btnm pointer to a btnmatrix object
* @param align LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
*/
void lv_btnmatrix_set_align(lv_obj_t * btnm, lv_label_align_t align);
/*=====================
* Getter functions
*====================*/
@@ -236,6 +244,14 @@ bool lv_btnmatrix_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnmatrix_ct
* @return whether "one toggle" mode is enabled
*/
bool lv_btnmatrix_get_one_check(const lv_obj_t * btnm);
/**
* Get the align attribute
* @param btnm pointer to a btnmatrix object
* @return LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
*/
lv_label_align_t lv_btnmatrix_get_align(const lv_obj_t * btnm);
/**********************
* MACROS
**********************/

View File

@@ -57,7 +57,11 @@ static uint8_t is_leap_year(uint32_t year);
**********************/
static lv_signal_cb_t ancestor_signal;
static lv_design_cb_t ancestor_design;
#if LV_CALENDAR_WEEK_STARTS_MONDAY != 0
static const char * day_name[7] = {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"};
#else
static const char * day_name[7] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};
#endif
static const char * month_name[12] = {"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
@@ -515,6 +519,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
lv_obj_invalidate(calendar);
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
uint8_t c = *((uint8_t *)param);
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
@@ -537,6 +542,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
}
lv_obj_invalidate(calendar);
}
#endif
}
return res;
@@ -699,6 +705,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month));
calendar->state = LV_STATE_DEFAULT;
_lv_obj_disable_style_caching(calendar, true);
lv_draw_label_dsc_t label_dsc;
lv_draw_label_dsc_init(&label_dsc);
@@ -732,6 +739,7 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
lv_draw_label(&header_area, mask, &label_dsc, LV_SYMBOL_RIGHT, NULL);
calendar->state = state_ori; /*Restore the state*/
_lv_obj_disable_style_caching(calendar, false);
}
/**
@@ -804,6 +812,7 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area)
/*The state changes without re-caching the styles, disable the use of cache*/
lv_state_t state_ori = calendar->state;
calendar->state = LV_STATE_DEFAULT;
_lv_obj_disable_style_caching(calendar, true);
lv_state_t month_state = LV_STATE_DISABLED;
@@ -850,6 +859,7 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area)
if(box_area.y1 > clip_area->y2) {
calendar->state = state_ori;
_lv_obj_disable_style_caching(calendar, false);
return;
}
@@ -920,6 +930,7 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area)
}
}
calendar->state = state_ori;
_lv_obj_disable_style_caching(calendar, false);
}
@@ -1057,14 +1068,18 @@ static uint8_t is_leap_year(uint32_t year)
* @param year a year
* @param month a month
* @param day a day
* @return [0..6] which means [Sun..Sat]
* @return [0..6] which means [Sun..Sat] or [Mon..Sun] depending on LV_CALENDAR_WEEK_STARTS_MONDAY
*/
static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day)
{
uint32_t a = month < 3 ? 1 : 0;
uint32_t b = year - a;
#if LV_CALENDAR_WEEK_STARTS_MONDAY
uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400) - 1) % 7;
#else
uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7;
#endif
return day_of_week;
}

View File

@@ -657,6 +657,7 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
* Fill the canvas with color
* @param canvas pointer to a canvas
* @param color the background color
* @param opa the desired opacity
*/
void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa)
{
@@ -694,10 +695,10 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa)
* @param y top coordinate of the rectangle
* @param w width of the rectangle
* @param h height of the rectangle
* @param style style of the rectangle (`body` properties are used except `padding`)
* @param rect_dsc descriptor of the rectangle
*/
void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h,
lv_draw_rect_dsc_t * rect_dsc)
const lv_draw_rect_dsc_t * rect_dsc)
{
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
@@ -763,7 +764,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
* @param x left coordinate of the text
* @param y top coordinate of the text
* @param max_w max width of the text. The text will be wrapped to fit into this size
* @param style style of the text (`text` properties are used)
* @param label_draw_dsc pointer to a valid label descriptor `lv_draw_label_dsc_t`
* @param txt text to display
* @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`)
*/
@@ -841,10 +842,10 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
* Draw an image on the canvas
* @param canvas pointer to a canvas object
* @param src image source. Can be a pointer an `lv_img_dsc_t` variable or a path an image.
* @param style style of the image (`image` properties are used)
* @param img_draw_dsc pointer to a valid label descriptor `lv_draw_img_dsc_t`
*/
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src,
lv_draw_img_dsc_t * img_draw_dsc)
const lv_draw_img_dsc_t * img_draw_dsc)
{
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
@@ -906,10 +907,10 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi
* @param canvas pointer to a canvas object
* @param points point of the line
* @param point_cnt number of points
* @param style style of the line (`line` properties are used)
* @param line_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt,
lv_draw_line_dsc_t * line_draw_dsc)
const lv_draw_line_dsc_t * line_draw_dsc)
{
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
@@ -969,10 +970,10 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t
* @param canvas pointer to a canvas object
* @param points point of the polygon
* @param point_cnt number of points
* @param style style of the polygon (`body.main_color` and `body.opa` is used)
* @param poly_draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt,
lv_draw_rect_dsc_t * poly_draw_dsc)
const lv_draw_rect_dsc_t * poly_draw_dsc)
{
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
@@ -1033,10 +1034,10 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32
* @param r radius of the arc
* @param start_angle start angle in degrees
* @param end_angle end angle in degrees
* @param style style of the polygon (`body.main_color` and `body.opa` is used)
* @param arc_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/
void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle,
int32_t end_angle, lv_draw_line_dsc_t * arc_draw_dsc)
int32_t end_angle, const lv_draw_line_dsc_t * arc_draw_dsc)
{
LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);

View File

@@ -60,7 +60,7 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy);
/**
* Set a buffer for the canvas.
* @param buf a buffer where the content of the canvas will be.
* The required size is (lv_img_color_format_get_px_size(cf) * w * h) / 8)
* The required size is (lv_img_color_format_get_px_size(cf) * w) / 8 * h)
* It can be allocated with `lv_mem_alloc()` or
* it can be statically allocated array (e.g. static lv_color_t buf[100*50]) or
* it can be an address in RAM or external SRAM
@@ -153,6 +153,7 @@ void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, u
/**
* Apply horizontal blur on the canvas
* @param canvas pointer to a canvas object
* @param area the area to blur. If `NULL` the whole canvas will be blurred.
* @param r radius of the blur
*/
void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r);
@@ -169,6 +170,7 @@ void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r);
* Fill the canvas with color
* @param canvas pointer to a canvas
* @param color the background color
* @param opa the desired opacity
*/
void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa);
@@ -179,10 +181,10 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa);
* @param y top coordinate of the rectangle
* @param w width of the rectangle
* @param h height of the rectangle
* @param style style of the rectangle (`body` properties are used except `padding`)
* @param rect_dsc descriptor of the rectangle
*/
void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h,
lv_draw_rect_dsc_t * rect_dsc);
const lv_draw_rect_dsc_t * rect_dsc);
/**
* Draw a text on the canvas.
@@ -190,7 +192,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
* @param x left coordinate of the text
* @param y top coordinate of the text
* @param max_w max width of the text. The text will be wrapped to fit into this size
* @param style style of the text (`text` properties are used)
* @param label_draw_dsc pointer to a valid label descriptor `lv_draw_label_dsc_t`
* @param txt text to display
* @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`)
*/
@@ -201,31 +203,33 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
/**
* Draw an image on the canvas
* @param canvas pointer to a canvas object
* @param x left coordinate of the image
* @param y top coordinate of the image
* @param src image source. Can be a pointer an `lv_img_dsc_t` variable or a path an image.
* @param style style of the image (`image` properties are used)
* @param img_draw_dsc pointer to a valid label descriptor `lv_draw_img_dsc_t`
*/
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src,
lv_draw_img_dsc_t * img_draw_dsc);
const lv_draw_img_dsc_t * img_draw_dsc);
/**
* Draw a line on the canvas
* @param canvas pointer to a canvas object
* @param points point of the line
* @param point_cnt number of points
* @param style style of the line (`line` properties are used)
* @param line_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt,
lv_draw_line_dsc_t * line_draw_dsc);
const lv_draw_line_dsc_t * line_draw_dsc);
/**
* Draw a polygon on the canvas
* @param canvas pointer to a canvas object
* @param points point of the polygon
* @param point_cnt number of points
* @param style style of the polygon (`body.main_color` and `body.opa` is used)
* @param poly_draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt,
lv_draw_rect_dsc_t * poly_draw_dsc);
const lv_draw_rect_dsc_t * poly_draw_dsc);
/**
* Draw an arc on the canvas
@@ -235,10 +239,10 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32
* @param r radius of the arc
* @param start_angle start angle in degrees
* @param end_angle end angle in degrees
* @param style style of the polygon (`body.main_color` and `body.opa` is used)
* @param arc_draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/
void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle,
int32_t end_angle, lv_draw_line_dsc_t * arc_draw_dsc);
int32_t end_angle, const lv_draw_line_dsc_t * arc_draw_dsc);
/**********************
* MACROS

View File

@@ -27,8 +27,6 @@
#define LV_CHART_PNUM_DEF 10
#define LV_CHART_AXIS_MAJOR_TICK_LEN_COE 1 / 15
#define LV_CHART_AXIS_MINOR_TICK_LEN_COE 2 / 3
#define LV_CHART_AXIS_PRIMARY_Y 1
#define LV_CHART_AXIS_SECONDARY_Y 0
#define LV_CHART_LABEL_ITERATOR_FORWARD 1
#define LV_CHART_LABEL_ITERATOR_REVERSE 0
@@ -101,8 +99,12 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
_lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t));
ext->ymin = LV_CHART_YMIN_DEF;
ext->ymax = LV_CHART_YMAX_DEF;
uint8_t i;
for(i = 0; i < _LV_CHART_AXIS_LAST; i++) {
ext->ymin[i] = LV_CHART_YMIN_DEF;
ext->ymax[i] = LV_CHART_YMAX_DEF;
}
ext->hdiv_cnt = LV_CHART_HDIV_DEF;
ext->vdiv_cnt = LV_CHART_VDIV_DEF;
ext->point_cnt = LV_CHART_PNUM_DEF;
@@ -118,7 +120,6 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
ext->secondary_y_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO;
ext->secondary_y_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO;
lv_style_list_init(&ext->style_series_bg);
lv_style_list_init(&ext->style_series);
@@ -133,7 +134,6 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_size(chart, LV_DPI * 3, LV_DPI * 2);
lv_theme_apply(chart, LV_THEME_CHART);
}
else {
lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
@@ -142,17 +142,17 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
lv_style_list_copy(&ext->style_series_bg, &ext_copy->style_series_bg);
ext->type = ext_copy->type;
ext->ymin = ext_copy->ymin;
ext->ymax = ext_copy->ymax;
ext->hdiv_cnt = ext_copy->hdiv_cnt;
ext->vdiv_cnt = ext_copy->vdiv_cnt;
ext->point_cnt = ext_copy->point_cnt;
_lv_memcpy_small(ext->ymin, ext_copy->ymin, sizeof(ext->ymin));
_lv_memcpy_small(ext->ymax, ext_copy->ymax, sizeof(ext->ymax));
_lv_memcpy(&ext->x_axis, &ext_copy->x_axis, sizeof(lv_chart_axis_cfg_t));
_lv_memcpy(&ext->y_axis, &ext_copy->y_axis, sizeof(lv_chart_axis_cfg_t));
_lv_memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t));
/*Refresh the style with new signal function*/
lv_obj_refresh_style(chart, LV_STYLE_PROP_ALL);
lv_obj_refresh_style(chart, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
}
LV_LOG_INFO("chart created");
@@ -191,6 +191,8 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
}
ser->start_point = 0;
ser->ext_buf_assigned = false;
ser->y_axis = LV_CHART_AXIS_PRIMARY_Y;
uint16_t i;
lv_coord_t * p_tmp = ser->points;
@@ -205,23 +207,23 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
/**
* Clear the point of a series
* @param chart pointer to a chart object
* @param serie pointer to the chart's series to clear
* @param series pointer to the chart's series to clear
*/
void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie)
void lv_chart_clear_series(lv_obj_t * chart, lv_chart_series_t * series)
{
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
LV_ASSERT_NULL(serie);
LV_ASSERT_NULL(series);
if(chart == NULL || serie == NULL) return;
if(chart == NULL || series == NULL) return;
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(ext == NULL) return;
uint32_t i;
for(i = 0; i < ext->point_cnt; i++) {
serie->points[i] = LV_CHART_POINT_DEF;
series->points[i] = LV_CHART_POINT_DEF;
}
serie->start_point = 0;
series->start_point = 0;
}
/*=====================
@@ -248,20 +250,26 @@ void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv)
}
/**
* Set the minimal and maximal y values
* Set the minimal and maximal y values on an axis
* @param chart pointer to a graph background object
* @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
* @param ymin y minimum value
* @param ymax y maximum value
*/
void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax)
void lv_chart_set_y_range(lv_obj_t * chart, lv_chart_axis_t axis, lv_coord_t ymin, lv_coord_t ymax)
{
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(ext->ymin == ymin && ext->ymax == ymax) return;
if(axis >= _LV_CHART_AXIS_LAST) {
LV_LOG_WARN("Invalid axis: %d", axis);
return;
}
ext->ymin = ymin;
ext->ymax = ymax;
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(ext->ymin[axis] == ymin && ext->ymax[axis] == ymax) return;
ext->ymin[axis] = ymin;
ext->ymax[axis] = ymax;
lv_chart_refresh(chart);
}
@@ -303,43 +311,44 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
if(point_cnt < 1) point_cnt = 1;
_LV_LL_READ_BACK(ext->series_ll, ser) {
if(ser->start_point != 0) {
lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt);
LV_ASSERT_MEM(new_points);
if(new_points == NULL) return;
if(!ser->ext_buf_assigned) {
if(ser->start_point != 0) {
lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt);
LV_ASSERT_MEM(new_points);
if(new_points == NULL) return;
if(point_cnt >= point_cnt_old) {
for(i = 0; i < point_cnt_old; i++) {
new_points[i] =
ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
if(point_cnt >= point_cnt_old) {
for(i = 0; i < point_cnt_old; i++) {
new_points[i] =
ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
}
for(i = point_cnt_old; i < point_cnt; i++) {
new_points[i] = def; /*Fill up the rest with default value*/
}
}
for(i = point_cnt_old; i < point_cnt; i++) {
new_points[i] = def; /*Fill up the rest with default value*/
else {
for(i = 0; i < point_cnt; i++) {
new_points[i] =
ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
}
}
/*Switch over pointer from old to new*/
lv_mem_free(ser->points);
ser->points = new_points;
}
else {
for(i = 0; i < point_cnt; i++) {
new_points[i] =
ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
}
}
/*Switch over pointer from old to new*/
lv_mem_free(ser->points);
ser->points = new_points;
}
else {
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
LV_ASSERT_MEM(ser->points);
if(ser->points == NULL) return;
/*Initialize the new points*/
if(point_cnt > point_cnt_old) {
for(i = point_cnt_old - 1; i < point_cnt; i++) {
ser->points[i] = def;
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
LV_ASSERT_MEM(ser->points);
if(ser->points == NULL) return;
/*Initialize the new points*/
if(point_cnt > point_cnt_old) {
for(i = point_cnt_old - 1; i < point_cnt; i++) {
ser->points[i] = def;
}
}
}
}
ser->start_point = 0;
}
@@ -540,6 +549,86 @@ void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_
ext->secondary_y_axis.options = options;
}
/**
* Set the index of the x-axis start point in the data array
* @param chart pointer to a chart object
* @param ser pointer to a data series on 'chart'
* @param id the index of the x point in the data array
*/
void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id)
{
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
LV_ASSERT_NULL(ser);
if(chart == NULL || ser == NULL) return;
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(ext == NULL) return;
if(id >= ext->point_cnt) return;
ser->start_point = id;
}
/**
* Set an external array of data points to use for the chart
* NOTE: It is the users responsibility to make sure the point_cnt matches the external array size.
* @param chart pointer to a chart object
* @param ser pointer to a data series on 'chart'
* @param array external array of points for chart
* @param point_cnt number of external points in the array
*/
void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt)
{
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
LV_ASSERT_NULL(ser);
if(chart == NULL || ser == NULL) return;
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(!ser->ext_buf_assigned && ser->points) lv_mem_free(ser->points);
ser->ext_buf_assigned = true;
ser->points = array;
ext->point_cnt = point_cnt;
}
/**
* Set an individual point y value in the chart series directly based on index
* @param chart pointer to a chart object
* @param ser pointer to a data series on 'chart'
* @param value value to assign to array point
* @param id the index of the x point in the array
*/
void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id)
{
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
LV_ASSERT_NULL(ser);
if(chart == NULL || ser == NULL) return;
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(ext == NULL) return;
if(id >= ext->point_cnt) return;
ser->points[id] = value;
}
/**
* Set the Y axis of a series
* @param chart pointer to a chart object
* @param ser pointer to series
* @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
*/
void lv_chart_set_series_axis(lv_obj_t * chart, lv_chart_series_t * ser, lv_chart_axis_t axis)
{
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
LV_ASSERT_NULL(ser);
if(axis >= _LV_CHART_AXIS_LAST) {
LV_LOG_WARN("Invalid axis: %d", axis);
return;
}
if(ser->y_axis == axis) return;
ser->y_axis = axis;
lv_chart_refresh(chart);
}
/*=====================
* Getter functions
*====================*/
@@ -570,6 +659,49 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * chart)
return ext->point_cnt;
}
/**
* Get the current index of the x-axis start point in the data array
* @param ser pointer to a data series on 'chart'
* @return the index of the current x start point in the data array
*/
uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser)
{
LV_ASSERT_NULL(ser);
return(ser->start_point);
}
/**
* Get an individual point y value in the chart series directly based on index
* @param chart pointer to a chart object
* @param ser pointer to a data series on 'chart'
* @param id the index of the x point in the array
* @return value of array point at index id
*/
lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id)
{
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
LV_ASSERT_NULL(ser);
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
if(id >= ext->point_cnt) id = 0;
return(ser->points[id]);
}
/**
* Get the Y axis of a series
* @param chart pointer to a chart object
* @param ser pointer to series
* @return `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
*/
lv_chart_axis_t lv_chart_get_series_axis(lv_obj_t * chart, lv_chart_series_t * ser)
{
LV_ASSERT_NULL(ser);
LV_UNUSED(chart);
return ser->y_axis;
}
/*=====================
* Other functions
*====================*/
@@ -651,8 +783,12 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param
if(sign == LV_SIGNAL_CLEANUP) {
lv_chart_series_t * ser;
_LV_LL_READ(ext->series_ll, ser) {
lv_mem_free(ser->points);
while(ext->series_ll.head != NULL) {
ser = _lv_ll_get_head(&ext->series_ll);
if(!ser->ext_buf_assigned) lv_mem_free(ser->points);
_lv_ll_remove(&ext->series_ll, ser);
lv_mem_free(ser);
}
_lv_ll_clear(&ext->series_ll);
@@ -837,8 +973,8 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co
lv_coord_t p_act = start_point;
lv_coord_t p_prev = start_point;
int32_t y_tmp = (int32_t)((int32_t)ser->points[p_prev] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
int32_t y_tmp = (int32_t)((int32_t)ser->points[p_prev] - ext->ymin[ser->y_axis]) * h;
y_tmp = y_tmp / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]);
p2.y = h - y_tmp + y_ofs;
for(i = 0; i < ext->point_cnt; i++) {
@@ -849,8 +985,8 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co
p_act = (start_point + i) % ext->point_cnt;
y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin[ser->y_axis]) * h;
y_tmp = y_tmp / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]);
p2.y = h - y_tmp + y_ofs;
/*Don't draw the first point. A second point is also required to draw the line*/
@@ -973,8 +1109,8 @@ static void draw_series_column(lv_obj_t * chart, const lv_area_t * series_area,
col_dsc.bg_color = ser->color;
lv_coord_t p_act = (start_point + i) % ext->point_cnt;
y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin) * h;
y_tmp = y_tmp / (ext->ymax - ext->ymin);
y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin[ser->y_axis]) * h;
y_tmp = y_tmp / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]);
col_a.y1 = h - y_tmp + series_area->y1;
if(ser->points[p_act] != LV_CHART_POINT_DEF) {
@@ -1371,6 +1507,9 @@ static void invalidate_lines(lv_obj_t * chart, uint16_t i)
lv_area_t coords;
lv_area_copy(&coords, &series_area);
coords.y1 -= line_width + point_radius;
coords.y2 += line_width + point_radius;
if(i < ext->point_cnt - 1) {
coords.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs - line_width - point_radius;
coords.x2 = ((w * (i + 1)) / (ext->point_cnt - 1)) + x_ofs + line_width + point_radius;

View File

@@ -42,6 +42,7 @@ enum {
LV_CHART_TYPE_NONE = 0x00, /**< Don't draw the series*/
LV_CHART_TYPE_LINE = 0x01, /**< Connect the points with lines*/
LV_CHART_TYPE_COLUMN = 0x02, /**< Draw columns*/
LV_CHART_TYPE_SCATTER = 0x03, /**< X/Y chart, points and/or lines*/
};
typedef uint8_t lv_chart_type_t;
@@ -52,17 +53,27 @@ enum {
};
typedef uint8_t lv_chart_update_mode_t;
enum {
LV_CHART_AXIS_PRIMARY_Y,
LV_CHART_AXIS_SECONDARY_Y,
_LV_CHART_AXIS_LAST,
};
typedef uint8_t lv_chart_axis_t;
typedef struct {
lv_coord_t * points;
lv_color_t color;
uint16_t start_point;
uint8_t ext_buf_assigned : 1;
lv_chart_axis_t y_axis : 1;
} lv_chart_series_t;
/** Data of axis */
enum {
LV_CHART_AXIS_SKIP_LAST_TICK = 0x00, /**< don't draw the last tick */
LV_CHART_AXIS_DRAW_LAST_TICK = 0x01, /**< draw the last tick */
LV_CHART_AXIS_INVERSE_LABELS_ORDER = 0x02 /**< draw tick labels in an inversed order*/
LV_CHART_AXIS_INVERSE_LABELS_ORDER = 0x02 /**< draw tick labels in an inverted order*/
};
typedef uint8_t lv_chart_axis_options_t;
@@ -79,8 +90,8 @@ typedef struct {
/*No inherited ext*/ /*Ext. of ancestor*/
/*New data for this type */
lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_series_t)*/
lv_coord_t ymin; /*y min value (used to scale the data)*/
lv_coord_t ymax; /*y max value (used to scale the data)*/
lv_coord_t ymin[_LV_CHART_AXIS_LAST]; /*y min values for both axis (used to scale the data)*/
lv_coord_t ymax[_LV_CHART_AXIS_LAST]; /*y max values for both axis (used to scale the data)*/
uint8_t hdiv_cnt; /*Number of horizontal division lines*/
uint8_t vdiv_cnt; /*Number of vertical division lines*/
uint16_t point_cnt; /*Point number in a data line*/
@@ -128,14 +139,15 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color);
/**
* Clear the point of a series
* @param chart pointer to a chart object
* @param serie pointer to the chart's series to clear
* @param series pointer to the chart's series to clear
*/
void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie);
void lv_chart_clear_series(lv_obj_t * chart, lv_chart_series_t * series);
/*=====================
* Setter functions
*====================*/
/**
* Set the number of horizontal and vertical division lines
* @param chart pointer to a graph background object
@@ -145,12 +157,13 @@ void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie);
void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv);
/**
* Set the minimal and maximal y values
* Set the minimal and maximal y values on an axis
* @param chart pointer to a graph background object
* @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
* @param ymin y minimum value
* @param ymax y maximum value
*/
void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax);
void lv_chart_set_y_range(lv_obj_t * chart, lv_chart_axis_t axis, lv_coord_t ymin, lv_coord_t ymax);
/**
* Set a new type for a chart
@@ -260,6 +273,40 @@ void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_
void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
lv_chart_axis_options_t options);
/**
* Set the index of the x-axis start point in the data array
* @param chart pointer to a chart object
* @param ser pointer to a data series on 'chart'
* @param id the index of the x point in the data array
*/
void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id);
/**
* Set an external array of data points to use for the chart
* NOTE: It is the users responsibility to make sure the point_cnt matches the external array size.
* @param chart pointer to a chart object
* @param ser pointer to a data series on 'chart'
* @param array external array of points for chart
*/
void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt);
/**
* Set an individual point value in the chart series directly based on index
* @param chart pointer to a chart object
* @param ser pointer to a data series on 'chart'
* @param value value to assign to array point
* @param id the index of the x point in the array
*/
void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id);
/**
* Set the Y axis of a series
* @param chart pointer to a chart object
* @param ser pointer to series
* @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
*/
void lv_chart_set_series_axis(lv_obj_t * chart, lv_chart_series_t * ser, lv_chart_axis_t axis);
/*=====================
* Getter functions
*====================*/
@@ -278,6 +325,30 @@ lv_chart_type_t lv_chart_get_type(const lv_obj_t * chart);
*/
uint16_t lv_chart_get_point_count(const lv_obj_t * chart);
/**
* get the current index of the x-axis start point in the data array
* @param ser pointer to a data series on 'chart'
* @return the index of the current x start point in the data array
*/
uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser);
/**
* Get an individual point value in the chart series directly based on index
* @param chart pointer to a chart object
* @param ser pointer to a data series on 'chart'
* @param id the index of the x point in the array
* @return value of array point at index id
*/
lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id);
/**
* Get the Y axis of a series
* @param chart pointer to a chart object
* @param ser pointer to series
* @return `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
*/
lv_chart_axis_t lv_chart_get_series_axis(lv_obj_t * chart, lv_chart_series_t * ser);
/*=====================
* Other functions
*====================*/

View File

@@ -193,11 +193,13 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * cb, lv_signal_t sign, void * param
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
}
else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN || c == LV_KEY_LEFT || c == LV_KEY_UP) {
/*Follow the backgrounds state with the bullet*/
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
}
#endif
}
return res;

View File

@@ -106,6 +106,15 @@ static inline void lv_checkbox_set_disabled(lv_obj_t * cb)
lv_btn_set_state(cb, LV_BTN_STATE_DISABLED);
}
/**
* Set the state of a check box
* @param cb pointer to a check box object
* @param state the new state of the check box (from lv_btn_state_t enum)
*/
static inline void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state)
{
lv_btn_set_state(cb, state);
}
/*=====================
* Getter functions
*====================*/
@@ -137,6 +146,15 @@ static inline bool lv_checkbox_is_inactive(const lv_obj_t * cb)
return lv_btn_get_state(cb) == LV_BTN_STATE_DISABLED ? true : false;
}
/**
* Get the current state of a check box
* @param cb pointer to a check box object
* @return the state of the check box (from lv_btn_state_t enum)
*/
static inline lv_btn_state_t lv_checkbox_get_state(const lv_obj_t * cb)
{
return lv_btn_get_state(cb);
}
/**********************
* MACROS

Some files were not shown because too many files have changed in this diff Show More