Compare commits
471 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5bacff2fa | ||
|
|
5a6da9a2ef | ||
|
|
d99ea10213 | ||
|
|
5566935a5d | ||
|
|
b947465da1 | ||
|
|
d44b8d47d3 | ||
|
|
96e0de063a | ||
|
|
81ec2d1b10 | ||
|
|
55d05c2eb3 | ||
|
|
e236cf7f73 | ||
|
|
38cf5c0b3e | ||
|
|
e2183750f2 | ||
|
|
c55b165150 | ||
|
|
50b5e3c477 | ||
|
|
1b3e1c4331 | ||
|
|
3f36139469 | ||
|
|
125e6e95f6 | ||
|
|
c683a3612d | ||
|
|
50594851f6 | ||
|
|
a2685363e8 | ||
|
|
8b7ffccd64 | ||
|
|
81884401d2 | ||
|
|
b87d16fc6e | ||
|
|
b1c43d329d | ||
|
|
710ec7d417 | ||
|
|
176eb9fd46 | ||
|
|
a6150ea78f | ||
|
|
35c7197d1c | ||
|
|
15e692d596 | ||
|
|
1ab87eda09 | ||
|
|
804c3c7994 | ||
|
|
0596088544 | ||
|
|
85bd12a794 | ||
|
|
4613811c45 | ||
|
|
03c3838605 | ||
|
|
fb6e7deadf | ||
|
|
d941461052 | ||
|
|
3d32290ee4 | ||
|
|
6932b6c1da | ||
|
|
6d7bd355ed | ||
|
|
343605ebac | ||
|
|
beec11565c | ||
|
|
26b36dfea1 | ||
|
|
289fd95c3d | ||
|
|
2f79133685 | ||
|
|
e42128e937 | ||
|
|
de38ee4a21 | ||
|
|
612308f281 | ||
|
|
f545a24bbd | ||
|
|
1102cfdf82 | ||
|
|
775f1a59df | ||
|
|
1906a623fb | ||
|
|
35ae1a28d4 | ||
|
|
842eb11448 | ||
|
|
ca9c36e081 | ||
|
|
5976973111 | ||
|
|
b7baa01bc1 | ||
|
|
91cfb70856 | ||
|
|
5ee4d14788 | ||
|
|
09ce595239 | ||
|
|
5d02b27b1f | ||
|
|
d4c3567f84 | ||
|
|
39bf116e07 | ||
|
|
10eeeb2490 | ||
|
|
eb7f0d8eeb | ||
|
|
694d9eff19 | ||
|
|
d4e40fce63 | ||
|
|
6e000c97f8 | ||
|
|
9b9cd36dc9 | ||
|
|
8df8700bed | ||
|
|
c17f2f7e84 | ||
|
|
c3953f478f | ||
|
|
adf65b6761 | ||
|
|
cb5faa64ac | ||
|
|
832000ad34 | ||
|
|
037d3d9090 | ||
|
|
6772ceb7e2 | ||
|
|
e7364f321d | ||
|
|
d9afdb5316 | ||
|
|
14a2a60bf9 | ||
|
|
350269c3d4 | ||
|
|
52c61b115f | ||
|
|
7ca806ddff | ||
|
|
c8be0df768 | ||
|
|
78f2451b2a | ||
|
|
36433c2144 | ||
|
|
2224ce95cb | ||
|
|
54b3ba39fb | ||
|
|
9a2d2b5392 | ||
|
|
ede6085429 | ||
|
|
3ea4418727 | ||
|
|
961f295b94 | ||
|
|
12b1f1f590 | ||
|
|
848c468b06 | ||
|
|
ba94b9cc94 | ||
|
|
a1f47e9051 | ||
|
|
ff357db938 | ||
|
|
2f26d0a511 | ||
|
|
851493a188 | ||
|
|
5f35e46be8 | ||
|
|
7e4769e319 | ||
|
|
75a0a5e6d6 | ||
|
|
c0f6ff4d42 | ||
|
|
fef3a069d6 | ||
|
|
35e09885fb | ||
|
|
24c2921c21 | ||
|
|
001fabbb18 | ||
|
|
f4b4df8a17 | ||
|
|
41d093ea76 | ||
|
|
953753263c | ||
|
|
8990544b42 | ||
|
|
809497f707 | ||
|
|
148e6d12fd | ||
|
|
45cc51d48c | ||
|
|
187f4be2ee | ||
|
|
677ce48bea | ||
|
|
6023bb4372 | ||
|
|
d0cc9283e7 | ||
|
|
71e5618380 | ||
|
|
bcb6d02acf | ||
|
|
f116073baf | ||
|
|
6e884615d8 | ||
|
|
d665294669 | ||
|
|
cc43762030 | ||
|
|
9c7c395cc7 | ||
|
|
9680d5bbb2 | ||
|
|
96534d58e5 | ||
|
|
1088492449 | ||
|
|
9b154d12c1 | ||
|
|
e9ee46f302 | ||
|
|
c0714d9c6b | ||
|
|
e728ba1928 | ||
|
|
b94ca2bf80 | ||
|
|
74aae39e4e | ||
|
|
b9bd436b89 | ||
|
|
6eab2adfc1 | ||
|
|
209e1c4d38 | ||
|
|
056da0f922 | ||
|
|
e1a84f2cfe | ||
|
|
b77bd763c0 | ||
|
|
437e6d35eb | ||
|
|
3b06d4ab84 | ||
|
|
3a5ad7712e | ||
|
|
28eb766904 | ||
|
|
4af6c62146 | ||
|
|
96eba8e0ff | ||
|
|
95ccd877a8 | ||
|
|
1815ff4b99 | ||
|
|
c8cc9db7f0 | ||
|
|
b8ebca8d6c | ||
|
|
245a47a848 | ||
|
|
c46f12b97a | ||
|
|
db2ddd6033 | ||
|
|
de1ccc269c | ||
|
|
cd9f53c4b4 | ||
|
|
25afed1d58 | ||
|
|
f3e91634f8 | ||
|
|
6980277aca | ||
|
|
f59a206ab0 | ||
|
|
4eb3283342 | ||
|
|
c2b5979e91 | ||
|
|
cfee7e8b8a | ||
|
|
6fcca7dd44 | ||
|
|
f1edd3a1ea | ||
|
|
d321e0e4fc | ||
|
|
8d89bf9ed0 | ||
|
|
f8b991731f | ||
|
|
77b57ba035 | ||
|
|
08684b31ee | ||
|
|
977f6d210d | ||
|
|
e399b7a085 | ||
|
|
b3634790cd | ||
|
|
3dad4c724e | ||
|
|
d95cf0a3d6 | ||
|
|
14a4c190c9 | ||
|
|
461619411d | ||
|
|
c36c8e11f7 | ||
|
|
11a9dedbaa | ||
|
|
2068ab3211 | ||
|
|
d94bbd4f91 | ||
|
|
28807b6a77 | ||
|
|
d71f664fbb | ||
|
|
f066f0b8d8 | ||
|
|
e30055674d | ||
|
|
d2e1094159 | ||
|
|
73a918ce13 | ||
|
|
6fd7bcf172 | ||
|
|
b88ee8e430 | ||
|
|
ebaeb1bf7c | ||
|
|
bd8ac58b6b | ||
|
|
fcca7fff60 | ||
|
|
b6c18ed171 | ||
|
|
872030fb77 | ||
|
|
90be42c493 | ||
|
|
c4e7254aed | ||
|
|
1b40c2a495 | ||
|
|
81caeaa725 | ||
|
|
1ca9dc6c4e | ||
|
|
8af9e96299 | ||
|
|
70ac65793f | ||
|
|
5d981f56ad | ||
|
|
e16eb8e830 | ||
|
|
58d86cff71 | ||
|
|
cda21694c4 | ||
|
|
7af20516a5 | ||
|
|
2cab9d12d6 | ||
|
|
21985e9a14 | ||
|
|
7827d948d8 | ||
|
|
3b7fa645fb | ||
|
|
28f74bd91d | ||
|
|
0e1fda5c37 | ||
|
|
1f0a4918f2 | ||
|
|
004adac31d | ||
|
|
f58d97d990 | ||
|
|
4b1a0d590f | ||
|
|
bd4db19aee | ||
|
|
5c3640868c | ||
|
|
b4955f0b6e | ||
|
|
cdb99b3588 | ||
|
|
acb46aaed1 | ||
|
|
525c3bd829 | ||
|
|
7caa2bf9ad | ||
|
|
0a9cc2a3b5 | ||
|
|
62f4ced294 | ||
|
|
2a6815c451 | ||
|
|
a0f338eb6f | ||
|
|
0f0d57d855 | ||
|
|
5d42f92c86 | ||
|
|
42a7fda05d | ||
|
|
5810baa021 | ||
|
|
f36f8fe253 | ||
|
|
d56708b45e | ||
|
|
d0b408d679 | ||
|
|
7e3739576f | ||
|
|
565633828c | ||
|
|
061c6325b7 | ||
|
|
66c184a84d | ||
|
|
e3a07ed58c | ||
|
|
e1963a4a3d | ||
|
|
05f6b67b5f | ||
|
|
eb76519d25 | ||
|
|
7b0a0ef4a7 | ||
|
|
48f8d83bdc | ||
|
|
a728817fb5 | ||
|
|
ad422250db | ||
|
|
243c448df9 | ||
|
|
ec7397e4a0 | ||
|
|
245de140f4 | ||
|
|
0ec409f83e | ||
|
|
cc505a3cb2 | ||
|
|
b58f9c6021 | ||
|
|
4560a72c32 | ||
|
|
85d375b128 | ||
|
|
99f49f9097 | ||
|
|
a0e6f7f022 | ||
|
|
1c3bbc9f6c | ||
|
|
07cb113c0a | ||
|
|
61a5cb44b8 | ||
|
|
6ccfd0101a | ||
|
|
1b29814e1e | ||
|
|
ae0e855d91 | ||
|
|
0aa4591021 | ||
|
|
c85295b5ea | ||
|
|
28213adfa6 | ||
|
|
11cab40103 | ||
|
|
41fd83e1d3 | ||
|
|
25b0b994a0 | ||
|
|
2b60f4496f | ||
|
|
1d714bfed7 | ||
|
|
b7d7bf7dd5 | ||
|
|
373af97472 | ||
|
|
3e9495a074 | ||
|
|
1072b71ea0 | ||
|
|
b0e3f11da1 | ||
|
|
cb0d6f40c9 | ||
|
|
0f69469eee | ||
|
|
f2a59c23f1 | ||
|
|
cac6f92964 | ||
|
|
0d2784a13e | ||
|
|
80a4c6ff14 | ||
|
|
013ae48221 | ||
|
|
daec3626bc | ||
|
|
fd695c9ad3 | ||
|
|
88ce04cea3 | ||
|
|
06d7a6d006 | ||
|
|
529fee1e20 | ||
|
|
ca9dfb7063 | ||
|
|
83ca45e0c8 | ||
|
|
fd411e200f | ||
|
|
3592a2ac17 | ||
|
|
8cc951202c | ||
|
|
ac89d1245b | ||
|
|
2172ec93a2 | ||
|
|
c173f28a3f | ||
|
|
a5a7329d41 | ||
|
|
ed10c1da67 | ||
|
|
bb730735f2 | ||
|
|
834b498aec | ||
|
|
2fb690b3b9 | ||
|
|
28a668ce09 | ||
|
|
5a2cf28c54 | ||
|
|
ed480e821c | ||
|
|
f11f7c5223 | ||
|
|
3b4bff79c2 | ||
|
|
f30dc5d186 | ||
|
|
da5c9dd424 | ||
|
|
89adfbc816 | ||
|
|
d125472e81 | ||
|
|
28495b9eb9 | ||
|
|
4fefa2ee28 | ||
|
|
00e93a5d30 | ||
|
|
95ef03baa8 | ||
|
|
dae3ebdb66 | ||
|
|
fb3e6ec1f4 | ||
|
|
bb4e4a9e53 | ||
|
|
4df27fc5b2 | ||
|
|
f7870310dc | ||
|
|
3c3fe46447 | ||
|
|
806f3a9bbf | ||
|
|
dca7cedb28 | ||
|
|
557342cc08 | ||
|
|
eb725a3a68 | ||
|
|
53f002c3f8 | ||
|
|
b48120947f | ||
|
|
4659289924 | ||
|
|
cc0ea22903 | ||
|
|
c0ca1a025b | ||
|
|
35b3a1f2a4 | ||
|
|
6731e44503 | ||
|
|
7b68e6e426 | ||
|
|
c36a96914b | ||
|
|
ab6f93db24 | ||
|
|
67400d1d72 | ||
|
|
1db33435c1 | ||
|
|
5b062a0d8d | ||
|
|
44e57aaaf5 | ||
|
|
b26b4435a5 | ||
|
|
da9a5f58d0 | ||
|
|
a4774ccc72 | ||
|
|
a6289f5e85 | ||
|
|
e31993bdf2 | ||
|
|
b646365e2c | ||
|
|
0921cf6e3b | ||
|
|
433435889a | ||
|
|
b1213dcc59 | ||
|
|
f8c8c4040a | ||
|
|
7e38ac68e3 | ||
|
|
abff805509 | ||
|
|
18072b3dd4 | ||
|
|
4640611758 | ||
|
|
ba7a86de74 | ||
|
|
6cb79914a8 | ||
|
|
f1f0aa621a | ||
|
|
58b88bf1fb | ||
|
|
fd508065dd | ||
|
|
09250d0a92 | ||
|
|
822e06be39 | ||
|
|
2a6f5d46ab | ||
|
|
6227aaee96 | ||
|
|
a5de71933b | ||
|
|
e85888908a | ||
|
|
e587ceb22e | ||
|
|
15b7ea6614 | ||
|
|
843555a4b1 | ||
|
|
5f4c26cb79 | ||
|
|
46a4469a9c | ||
|
|
ad262172de | ||
|
|
b802e7e775 | ||
|
|
2ba1fc625f | ||
|
|
5a23fd569b | ||
|
|
914c874ada | ||
|
|
cae5132038 | ||
|
|
45bf6a3862 | ||
|
|
f00a6a118d | ||
|
|
418413e334 | ||
|
|
815e0afdaf | ||
|
|
38e68eeb7a | ||
|
|
0f69cbf087 | ||
|
|
96728e7ed9 | ||
|
|
83bdb6c347 | ||
|
|
085a6499a7 | ||
|
|
b371bd3d05 | ||
|
|
cf39677dfa | ||
|
|
a0bf57f529 | ||
|
|
7a10b700e2 | ||
|
|
aea84d8d79 | ||
|
|
e3f4c11500 | ||
|
|
e256a27b5a | ||
|
|
3aa35a77cb | ||
|
|
3af55796d9 | ||
|
|
200c1e788f | ||
|
|
d271fd6108 | ||
|
|
7e4b8aa49b | ||
|
|
c36f731316 | ||
|
|
849d3d3255 | ||
|
|
ec4cc14bf9 | ||
|
|
7de60867ef | ||
|
|
4011d54668 | ||
|
|
8bcbceef08 | ||
|
|
7ce9a969c8 | ||
|
|
f836e90869 | ||
|
|
6d07effbc3 | ||
|
|
a73b316681 | ||
|
|
70a2287568 | ||
|
|
9e3d8c9090 | ||
|
|
2d4c709a88 | ||
|
|
92ecff3fc0 | ||
|
|
f75428e52b | ||
|
|
b414aa755d | ||
|
|
5961800fe0 | ||
|
|
663af3dfb3 | ||
|
|
0aeb49d28a | ||
|
|
83d05f945f | ||
|
|
f0cae00574 | ||
|
|
46f7dff9e2 | ||
|
|
9ede4ba707 | ||
|
|
1c071530ad | ||
|
|
ba10671b2b | ||
|
|
af7134269e | ||
|
|
19a1afbd89 | ||
|
|
5359a762b8 | ||
|
|
0d6b8a86d4 | ||
|
|
6c01490372 | ||
|
|
4ab8520bfb | ||
|
|
d60a6cbc76 | ||
|
|
4bedc57b7d | ||
|
|
e1761d50a1 | ||
|
|
856368284e | ||
|
|
ad990994d0 | ||
|
|
247b5b6f0c | ||
|
|
6836947e67 | ||
|
|
dc873966e9 | ||
|
|
fe483e8e21 | ||
|
|
3a31577592 | ||
|
|
3721fc52a8 | ||
|
|
a7350282f0 | ||
|
|
c93ef97ab9 | ||
|
|
866e088f98 | ||
|
|
15ec0f8e2f | ||
|
|
fc14c2c01c | ||
|
|
71f8497ee6 | ||
|
|
5a0c0e2e97 | ||
|
|
3e079a47ae | ||
|
|
35c0cfcfea | ||
|
|
fa8deb524d | ||
|
|
f3773694bc | ||
|
|
1860742c13 | ||
|
|
f6d75e759c | ||
|
|
9b38b35420 | ||
|
|
b1afc3f34d | ||
|
|
1dfdabd638 | ||
|
|
446b0b6429 | ||
|
|
cf4db99206 | ||
|
|
c854670062 | ||
|
|
e100565c67 | ||
|
|
f5d9e4bff4 | ||
|
|
7a7e1668fa | ||
|
|
4e13d6ae4d | ||
|
|
75a27e4cc7 | ||
|
|
95b07a2d23 | ||
|
|
94a710a5e1 | ||
|
|
b9dc9e81de | ||
|
|
1396fce961 | ||
|
|
884be64d17 | ||
|
|
168a7c4c45 | ||
|
|
a696aef959 | ||
|
|
6dddbde387 | ||
|
|
b9d92236e3 | ||
|
|
2dc14fc7e5 | ||
|
|
2908a74b42 | ||
|
|
1a41f13fd6 |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -1 +1 @@
|
||||
custom: ["https://littlevgl.com/donate"]
|
||||
custom: ["https://paypal.me/littlevgl?locale.x=en_US"]
|
||||
|
||||
42
.github/workflows/build_micropython.yml
vendored
Normal file
42
.github/workflows/build_micropython.yml
vendored
Normal 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
|
||||
|
||||
2
.github/workflows/ccpp.yml
vendored
2
.github/workflows/ccpp.yml
vendored
@@ -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
|
||||
|
||||
83
CHANGELOG.md
83
CHANGELOG.md
@@ -1,12 +1,85 @@
|
||||
# Changelog
|
||||
|
||||
## v7.3.0 (planned on 04.08.2020)
|
||||
Available in the `dev` branch
|
||||
|
||||
## v7.2.0 (planned on 21.07.2020)
|
||||
*Available in the `master` branch*
|
||||
## 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
|
||||
|
||||
@@ -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.1.0-blue.svg"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://lvgl.io/assets/images/img_1.png">
|
||||
@@ -78,7 +74,7 @@ Basically, every modern controller (which is able to drive a display) is suitabl
|
||||
<tr>
|
||||
<td> <strong>Heap</strong></td>
|
||||
<td> > 2 kB </td>
|
||||
<td> > 16 kB</td>
|
||||
<td> > 8 kB</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -145,7 +141,7 @@ void btn_event_cb(lv_obj_t * btn, lv_event_t event)
|
||||

|
||||
|
||||
### LVGL from Micropython
|
||||
Learn more about [Micropython](https://docs.lvgl.io/en/html/get-started/micropython).
|
||||
Learn more about [Micropython](https://docs.lvgl.io/latest/en/html/get-started/micropython.html).
|
||||
```python
|
||||
# Create a Button and a Label
|
||||
scr = lv.obj()
|
||||
|
||||
29
a.patch
Normal file
29
a.patch
Normal 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()
|
||||
|
||||
42
docs/ROADMAP.md
Normal file
42
docs/ROADMAP.md
Normal 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)
|
||||
@@ -10,7 +10,7 @@ To get all this to work you have to setup TFT_eSPI to work with your TFT display
|
||||
|
||||
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 `lvgl.h` next to the `lvgl` folder.
|
||||
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`
|
||||
|
||||
@@ -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)*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lvgl",
|
||||
"version": "7.2.0",
|
||||
"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": {
|
||||
|
||||
10
library.properties
Normal file
10
library.properties
Normal 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
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file lv_conf.h
|
||||
* Configuration file for LVGL v7.2.0
|
||||
* 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
|
||||
|
||||
@@ -391,11 +404,20 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
|
||||
* but with > 10,000 characters if you see issues probably you need to enable it.*/
|
||||
#define LV_FONT_FMT_TXT_LARGE 0
|
||||
|
||||
/* Enables/disables support for compressed fonts. If it's disabled, compressed
|
||||
* glyphs cannot be processed by the library and won't be rendered.
|
||||
*/
|
||||
#define LV_USE_FONT_COMPRESSED 1
|
||||
|
||||
/* Enable subpixel rendering */
|
||||
#define LV_USE_FONT_SUBPX 1
|
||||
#if LV_USE_FONT_SUBPX
|
||||
/* Set the pixel order of the display.
|
||||
* Important only if "subpx fonts" are used.
|
||||
* With "normal" font it doesn't matter.
|
||||
*/
|
||||
#define LV_FONT_SUBPX_BGR 0
|
||||
#endif
|
||||
|
||||
/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/
|
||||
typedef void * lv_font_user_data_t;
|
||||
@@ -417,7 +439,10 @@ typedef void * lv_font_user_data_t;
|
||||
/* A fast and impressive theme.
|
||||
* Flags:
|
||||
* LV_THEME_MATERIAL_FLAG_LIGHT: light theme
|
||||
* LV_THEME_MATERIAL_FLAG_DARK: dark theme*/
|
||||
* LV_THEME_MATERIAL_FLAG_DARK: dark theme
|
||||
* LV_THEME_MATERIAL_FLAG_NO_TRANSITION: disable transitions (state change animations)
|
||||
* LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state)
|
||||
* */
|
||||
#define LV_USE_THEME_MATERIAL 1
|
||||
|
||||
/* Mono-color theme for monochrome displays.
|
||||
@@ -628,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: -)*/
|
||||
|
||||
17
lvgl.h
17
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 2
|
||||
#define LVGL_VERSION_PATCH 0
|
||||
#define LVGL_VERSION_INFO ""
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
||||
@@ -1,245 +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):
|
||||
ver_major = -1
|
||||
ver_minor = -1
|
||||
ver_patch = -1
|
||||
|
||||
ver_str = ""
|
||||
dev_ver_str = ""
|
||||
release_br = ""
|
||||
release_note = ""
|
||||
|
||||
prepare_type = ['major', 'minor', 'bugfix']
|
||||
|
||||
dev_prepare = 'minor'
|
||||
|
||||
def upstream(repo):
|
||||
return upstream_org_url + repo + ".git"
|
||||
|
||||
def cmd(c, exit_on_err = True):
|
||||
print("\n" + c)
|
||||
r = os.system(c)
|
||||
if r:
|
||||
print("### Error: " + str(r))
|
||||
|
||||
def lvgl_clone():
|
||||
title("lvgl: Clone")
|
||||
cmd("git clone https://github.com/lvgl/lvgl.git")
|
||||
os.chdir("./lvgl")
|
||||
cmd("git co master")
|
||||
|
||||
def lvgl_format():
|
||||
title("lvgl: Run code formatter")
|
||||
os.chdir("./scripts")
|
||||
cmd("./code-format.sh")
|
||||
os.system("git ci -am 'Run code formatter'")
|
||||
os.chdir("..")
|
||||
|
||||
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()
|
||||
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")
|
||||
|
||||
def lvgl_update_library_json(v):
|
||||
title("lvgl: Update version number in library.json")
|
||||
for p in proj_list:
|
||||
cmd("git clone " + upstream(p) + " --recurse-submodules ; cd " + p + "; git checkout master")
|
||||
|
||||
|
||||
f = open("./library.json", "r")
|
||||
vn = v[1:]
|
||||
outbuf = ""
|
||||
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")
|
||||
|
||||
for i in f.read().splitlines():
|
||||
r = re.search(r'"version": ', i)
|
||||
if r:
|
||||
i = ' "version": "' + vn + '",'
|
||||
|
||||
outbuf += i + '\n'
|
||||
|
||||
f.close()
|
||||
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)
|
||||
|
||||
f = open("./library.json", "w")
|
||||
r = re.search(r'^#define LVGL_VERSION_MINOR ', i)
|
||||
if r:
|
||||
m = lastNum.search(i)
|
||||
if m: ver_minor = m.group(1)
|
||||
|
||||
f.write(outbuf)
|
||||
f.close()
|
||||
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("../")
|
||||
|
||||
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 ")
|
||||
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 lvgl_commit_push(v):
|
||||
title("lvgl: commit and push release")
|
||||
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)
|
||||
|
||||
os.system('git ci -am "Release ' + v + '"')
|
||||
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
|
||||
cmd('git push origin master')
|
||||
cmd('git push origin ' + v)
|
||||
cmd("cd docs; git checkout master; python 2.7 ./update.py latest dev")
|
||||
|
||||
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
|
||||
|
||||
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')
|
||||
os.chdir("../")
|
||||
|
||||
|
||||
def lvgl_update_api_docs():
|
||||
title("lvgl: Update API with Doxygen")
|
||||
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)
|
||||
|
||||
cmd("cd scripts; doxygen");
|
||||
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 examples_clone():
|
||||
title("examples: Clone")
|
||||
cmd("git clone https://github.com/lvgl/lv_examples.git")
|
||||
os.chdir("./lv_examples")
|
||||
cmd("git co master")
|
||||
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"
|
||||
|
||||
def examples_commit_push(v):
|
||||
title("examples: commit and push release")
|
||||
print("Prepare bugfix version " + ver_str)
|
||||
|
||||
os.system('git ci -am "Release ' + v + '"')
|
||||
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
|
||||
cmd('git push origin master')
|
||||
cmd('git push origin ' + v)
|
||||
lvgl_update_master_version()
|
||||
docs_update_latest_version()
|
||||
|
||||
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)
|
||||
|
||||
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")
|
||||
merge_to_dev()
|
||||
merge_from_dev()
|
||||
|
||||
def drivers_commit_push(v):
|
||||
title("drivers: commit and push release")
|
||||
|
||||
os.system('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")
|
||||
|
||||
def docs_get_api():
|
||||
title("docs: Get API files")
|
||||
|
||||
cmd("git co latest --")
|
||||
cmd("rm -rf xml");
|
||||
cmd("cp -r ../lvgl/docs/api_doc/xml .");
|
||||
cmd("git add xml");
|
||||
cmd('git commit -m "update API"')
|
||||
|
||||
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()
|
||||
cmd("git add conf.py")
|
||||
cmd('git ci -m "update conf.py to ' + v + '"')
|
||||
|
||||
def docs_build():
|
||||
title("docs: Build")
|
||||
cmd("git checkout master")
|
||||
cmd("./update.py latest")
|
||||
|
||||
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_build()
|
||||
|
||||
clean_up()
|
||||
lvgl_update_dev_version()
|
||||
docs_update_dev_version()
|
||||
publish_dev_and_master()
|
||||
|
||||
projs_update()
|
||||
cleanup()
|
||||
|
||||
|
||||
@@ -200,8 +200,31 @@ static inline void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coor
|
||||
{
|
||||
lv_chart_set_y_range(chart, LV_CHART_AXIS_PRIMARY_Y, ymin, ymax);
|
||||
}
|
||||
|
||||
|
||||
static inline void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * series)
|
||||
{
|
||||
lv_chart_clear_series(chart, series);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static inline void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs,
|
||||
lv_coord_t y_ofs)
|
||||
{
|
||||
lv_obj_align_mid(obj, base, align, x_ofs, y_ofs);
|
||||
}
|
||||
|
||||
static inline void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs)
|
||||
{
|
||||
lv_obj_align_mid_y(obj, base, align, x_ofs);
|
||||
}
|
||||
|
||||
static inline void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs)
|
||||
{
|
||||
lv_obj_align_mid_y(obj, base, align, y_ofs);
|
||||
}
|
||||
|
||||
#endif /*LV_USE_API_EXTENSION_V6*/
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -147,6 +147,12 @@
|
||||
#endif
|
||||
#endif /*LV_MEM_CUSTOM*/
|
||||
|
||||
/* Use the standard memcpy and memset instead of LVGL's own functions.
|
||||
* The standard functions might or might not be faster depending on their implementation. */
|
||||
#ifndef LV_MEMCPY_MEMSET_STD
|
||||
#define LV_MEMCPY_MEMSET_STD 0
|
||||
#endif
|
||||
|
||||
/* Garbage Collector settings
|
||||
* Used if lvgl is binded to higher level language and the memory is managed by that language */
|
||||
#ifndef LV_ENABLE_GC
|
||||
@@ -223,7 +229,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
/* 1: Enable shadow drawing*/
|
||||
/* 1: Enable shadow drawing on rectangles*/
|
||||
#ifndef LV_USE_SHADOW
|
||||
#define LV_USE_SHADOW 1
|
||||
#endif
|
||||
@@ -237,6 +243,21 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*1: enable outline drawing on rectangles*/
|
||||
#ifndef LV_USE_OUTLINE
|
||||
#define LV_USE_OUTLINE 1
|
||||
#endif
|
||||
|
||||
/*1: enable pattern drawing on rectangles*/
|
||||
#ifndef LV_USE_PATTERN
|
||||
#define LV_USE_PATTERN 1
|
||||
#endif
|
||||
|
||||
/*1: enable value string drawing on rectangles*/
|
||||
#ifndef LV_USE_VALUE_STR
|
||||
#define LV_USE_VALUE_STR 1
|
||||
#endif
|
||||
|
||||
/* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`)*/
|
||||
#ifndef LV_USE_BLEND_MODES
|
||||
#define LV_USE_BLEND_MODES 1
|
||||
@@ -589,6 +610,18 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
|
||||
#define LV_FONT_FMT_TXT_LARGE 0
|
||||
#endif
|
||||
|
||||
/* Enables/disables support for compressed fonts. If it's disabled, compressed
|
||||
* glyphs cannot be processed by the library and won't be rendered.
|
||||
*/
|
||||
#ifndef LV_USE_FONT_COMPRESSED
|
||||
#define LV_USE_FONT_COMPRESSED 1
|
||||
#endif
|
||||
|
||||
/* Enable subpixel rendering */
|
||||
#ifndef LV_USE_FONT_SUBPX
|
||||
#define LV_USE_FONT_SUBPX 1
|
||||
#endif
|
||||
#if LV_USE_FONT_SUBPX
|
||||
/* Set the pixel order of the display.
|
||||
* Important only if "subpx fonts" are used.
|
||||
* With "normal" font it doesn't matter.
|
||||
@@ -596,6 +629,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
|
||||
#ifndef LV_FONT_SUBPX_BGR
|
||||
#define LV_FONT_SUBPX_BGR 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/
|
||||
|
||||
@@ -620,7 +654,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
|
||||
/* A fast and impressive theme.
|
||||
* Flags:
|
||||
* LV_THEME_MATERIAL_FLAG_LIGHT: light theme
|
||||
* LV_THEME_MATERIAL_FLAG_DARK: dark theme*/
|
||||
* LV_THEME_MATERIAL_FLAG_DARK: dark theme
|
||||
* LV_THEME_MATERIAL_FLAG_NO_TRANSITION: disable transitions (state change animations)
|
||||
* LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state)
|
||||
* */
|
||||
#ifndef LV_USE_THEME_MATERIAL
|
||||
#define LV_USE_THEME_MATERIAL 1
|
||||
#endif
|
||||
@@ -953,7 +990,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
|
||||
* 2: Best precision
|
||||
*/
|
||||
#ifndef LV_LINEMETER_PRECISE
|
||||
# define LV_LINEMETER_PRECISE 0
|
||||
# define LV_LINEMETER_PRECISE 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -352,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
|
||||
|
||||
@@ -133,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.
|
||||
@@ -209,7 +215,7 @@ 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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1181,9 +1181,9 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -1222,9 +1222,9 @@ static void indev_click_focus(lv_indev_proc_t * proc)
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1490,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;
|
||||
|
||||
@@ -87,8 +87,8 @@ static void refresh_children_style(lv_obj_t * obj);
|
||||
static void base_dir_refr_children(lv_obj_t * obj);
|
||||
static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set,
|
||||
lv_coord_t x_ofs, lv_coord_t y_ofs);
|
||||
static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set,
|
||||
lv_coord_t x_ofs, lv_coord_t y_ofs);
|
||||
static void obj_align_mid_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set,
|
||||
lv_coord_t x_ofs, lv_coord_t y_ofs);
|
||||
#if LV_USE_ANIMATION
|
||||
static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state,
|
||||
lv_state_t new_state);
|
||||
@@ -103,6 +103,9 @@ static void lv_event_mark_deleted(lv_obj_t * obj);
|
||||
static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find);
|
||||
static void lv_obj_del_async_cb(void * obj);
|
||||
static void obj_del_core(lv_obj_t * obj);
|
||||
static void update_style_cache(lv_obj_t * obj, uint8_t part, uint16_t prop);
|
||||
static void update_style_cache_children(lv_obj_t * obj);
|
||||
static void invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -390,6 +393,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
|
||||
new_obj->protect = copy->protect;
|
||||
new_obj->gesture_parent = copy->gesture_parent;
|
||||
new_obj->focus_parent = copy->focus_parent;
|
||||
|
||||
#if LV_USE_GROUP
|
||||
/*Add to the same group*/
|
||||
@@ -483,13 +487,9 @@ void lv_obj_clean(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||
lv_obj_t * child_next;
|
||||
while(child) {
|
||||
/* Read the next child before deleting the current
|
||||
* because the next couldn't be read from a deleted (invalid) node*/
|
||||
child_next = lv_obj_get_child(obj, child);
|
||||
lv_obj_del(child);
|
||||
child = child_next;
|
||||
child = lv_obj_get_child(obj, NULL); /*Get the new first child*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,43 +503,11 @@ void lv_obj_invalidate_area(const lv_obj_t * obj, const lv_area_t * area)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
if(lv_obj_get_hidden(obj)) return;
|
||||
lv_area_t area_tmp;
|
||||
lv_area_copy(&area_tmp, area);
|
||||
bool visible = lv_obj_area_is_visible(obj, &area_tmp);
|
||||
|
||||
/*Invalidate the object only if it belongs to the curent or previous'*/
|
||||
lv_obj_t * obj_scr = lv_obj_get_screen(obj);
|
||||
lv_disp_t * disp = lv_obj_get_disp(obj_scr);
|
||||
if(obj_scr == lv_disp_get_scr_act(disp) ||
|
||||
obj_scr == lv_disp_get_scr_prev(disp) ||
|
||||
obj_scr == lv_disp_get_layer_top(disp) ||
|
||||
obj_scr == lv_disp_get_layer_sys(disp)) {
|
||||
|
||||
/*Truncate the area to the object*/
|
||||
lv_area_t obj_coords;
|
||||
lv_coord_t ext_size = obj->ext_draw_pad;
|
||||
lv_area_copy(&obj_coords, &obj->coords);
|
||||
obj_coords.x1 -= ext_size;
|
||||
obj_coords.y1 -= ext_size;
|
||||
obj_coords.x2 += ext_size;
|
||||
obj_coords.y2 += ext_size;
|
||||
|
||||
bool is_common;
|
||||
lv_area_t area_trunc;
|
||||
|
||||
is_common = _lv_area_intersect(&area_trunc, area, &obj_coords);
|
||||
if(is_common == false) return; /*The area is not on the object*/
|
||||
|
||||
/*Truncate recursively to the parents*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
while(par != NULL) {
|
||||
is_common = _lv_area_intersect(&area_trunc, &area_trunc, &par->coords);
|
||||
if(is_common == false) break; /*If no common parts with parent break;*/
|
||||
if(lv_obj_get_hidden(par)) return; /*If the parent is hidden then the child is hidden and won't be drawn*/
|
||||
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
|
||||
if(is_common) _lv_inv_area(disp, &area_trunc);
|
||||
}
|
||||
if(visible) _lv_inv_area(lv_obj_get_disp(obj), &area_tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -562,6 +530,74 @@ void lv_obj_invalidate(const lv_obj_t * obj)
|
||||
lv_obj_invalidate_area(obj, &obj_coords);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if(lv_obj_get_hidden(obj)) return false;
|
||||
|
||||
/*Invalidate the object only if it belongs to the curent or previous'*/
|
||||
lv_obj_t * obj_scr = lv_obj_get_screen(obj);
|
||||
lv_disp_t * disp = lv_obj_get_disp(obj_scr);
|
||||
if(obj_scr == lv_disp_get_scr_act(disp) ||
|
||||
obj_scr == lv_disp_get_scr_prev(disp) ||
|
||||
obj_scr == lv_disp_get_layer_top(disp) ||
|
||||
obj_scr == lv_disp_get_layer_sys(disp)) {
|
||||
|
||||
/*Truncate the area to the object*/
|
||||
lv_area_t obj_coords;
|
||||
lv_coord_t ext_size = obj->ext_draw_pad;
|
||||
lv_area_copy(&obj_coords, &obj->coords);
|
||||
obj_coords.x1 -= ext_size;
|
||||
obj_coords.y1 -= ext_size;
|
||||
obj_coords.x2 += ext_size;
|
||||
obj_coords.y2 += ext_size;
|
||||
|
||||
bool is_common;
|
||||
|
||||
is_common = _lv_area_intersect(area, area, &obj_coords);
|
||||
if(is_common == false) return false; /*The area is not on the object*/
|
||||
|
||||
/*Truncate recursively to the parents*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
while(par != NULL) {
|
||||
is_common = _lv_area_intersect(area, area, &par->coords);
|
||||
if(is_common == false) return false; /*If no common parts with parent break;*/
|
||||
if(lv_obj_get_hidden(par)) return false; /*If the parent is hidden then the child is hidden and won't be drawn*/
|
||||
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_area_t obj_coords;
|
||||
lv_coord_t ext_size = obj->ext_draw_pad;
|
||||
lv_area_copy(&obj_coords, &obj->coords);
|
||||
obj_coords.x1 -= ext_size;
|
||||
obj_coords.y1 -= ext_size;
|
||||
obj_coords.x2 += ext_size;
|
||||
obj_coords.y2 += ext_size;
|
||||
|
||||
return lv_obj_area_is_visible(obj, &obj_coords);
|
||||
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
@@ -856,7 +892,7 @@ void lv_obj_set_height_fit(lv_obj_t * obj, lv_coord_t h)
|
||||
lv_style_int_t ptop = lv_obj_get_style_pad_top(obj, LV_OBJ_PART_MAIN);
|
||||
lv_style_int_t pbottom = lv_obj_get_style_pad_bottom(obj, LV_OBJ_PART_MAIN);
|
||||
|
||||
lv_obj_set_width(obj, h - ptop - pbottom);
|
||||
lv_obj_set_height(obj, h - ptop - pbottom);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -911,7 +947,7 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
|
||||
obj->realign.xofs = x_ofs;
|
||||
obj->realign.yofs = y_ofs;
|
||||
obj->realign.base = base;
|
||||
obj->realign.origo_align = 0;
|
||||
obj->realign.mid_align = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -948,7 +984,7 @@ void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_
|
||||
|
||||
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||
|
||||
obj_align_core(obj, base, align, true, false, 0, y_ofs);
|
||||
obj_align_core(obj, base, align, false, true, 0, y_ofs);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -959,7 +995,7 @@ void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_
|
||||
* @param x_ofs x coordinate offset after alignment
|
||||
* @param y_ofs y coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs)
|
||||
void lv_obj_align_mid(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
@@ -970,7 +1006,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
|
||||
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||
|
||||
|
||||
obj_align_origo_core(obj, base, align, true, true, x_ofs, y_ofs);
|
||||
obj_align_mid_core(obj, base, align, true, true, x_ofs, y_ofs);
|
||||
|
||||
#if LV_USE_OBJ_REALIGN
|
||||
/*Save the last align parameters to use them in `lv_obj_realign`*/
|
||||
@@ -978,7 +1014,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
|
||||
obj->realign.xofs = x_ofs;
|
||||
obj->realign.yofs = y_ofs;
|
||||
obj->realign.base = base;
|
||||
obj->realign.origo_align = 1;
|
||||
obj->realign.mid_align = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -989,7 +1025,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param x_ofs x coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs)
|
||||
void lv_obj_align_mid_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
@@ -1000,7 +1036,7 @@ void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig
|
||||
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||
|
||||
|
||||
obj_align_origo_core(obj, base, align, true, false, x_ofs, 0);
|
||||
obj_align_mid_core(obj, base, align, true, false, x_ofs, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1011,7 +1047,7 @@ void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param y_ofs y coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs)
|
||||
void lv_obj_align_mid_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
@@ -1022,7 +1058,7 @@ void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig
|
||||
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||
|
||||
|
||||
obj_align_origo_core(obj, base, align, true, false, 0, y_ofs);
|
||||
obj_align_mid_core(obj, base, align, false, true, 0, y_ofs);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1034,8 +1070,8 @@ void lv_obj_realign(lv_obj_t * obj)
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
#if LV_USE_OBJ_REALIGN
|
||||
if(obj->realign.origo_align)
|
||||
lv_obj_align_origo(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs);
|
||||
if(obj->realign.mid_align)
|
||||
lv_obj_align_mid(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs);
|
||||
else
|
||||
lv_obj_align(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs);
|
||||
#else
|
||||
@@ -1120,7 +1156,7 @@ void lv_obj_add_style(lv_obj_t * obj, uint8_t part, lv_style_t * style)
|
||||
#if LV_USE_ANIMATION
|
||||
trans_del(obj, part, 0xFF, NULL);
|
||||
#endif
|
||||
lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1144,7 +1180,7 @@ void lv_obj_remove_style(lv_obj_t * obj, uint8_t part, lv_style_t * style)
|
||||
#if LV_USE_ANIMATION
|
||||
trans_del(obj, part, 0xFF, NULL);
|
||||
#endif
|
||||
lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1181,7 +1217,7 @@ void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part)
|
||||
{
|
||||
lv_obj_clean_style_list(obj, part);
|
||||
|
||||
lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1203,7 +1239,7 @@ void _lv_obj_set_style_local_int(lv_obj_t * obj, uint8_t part, lv_style_property
|
||||
#if LV_USE_ANIMATION
|
||||
trans_del(obj, part, prop, NULL);
|
||||
#endif
|
||||
lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK));
|
||||
lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1225,7 +1261,7 @@ void _lv_obj_set_style_local_color(lv_obj_t * obj, uint8_t part, lv_style_proper
|
||||
#if LV_USE_ANIMATION
|
||||
trans_del(obj, part, prop, NULL);
|
||||
#endif
|
||||
lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK));
|
||||
lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1247,7 +1283,7 @@ void _lv_obj_set_style_local_opa(lv_obj_t * obj, uint8_t part, lv_style_property
|
||||
#if LV_USE_ANIMATION
|
||||
trans_del(obj, part, prop, NULL);
|
||||
#endif
|
||||
lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK));
|
||||
lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1269,7 +1305,7 @@ void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t part, lv_style_property
|
||||
#if LV_USE_ANIMATION
|
||||
trans_del(obj, part, prop, NULL);
|
||||
#endif
|
||||
lv_obj_refresh_style(obj, prop & (~LV_STYLE_STATE_MASK));
|
||||
lv_obj_refresh_style(obj, part, prop & (~LV_STYLE_STATE_MASK));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1294,12 +1330,15 @@ bool lv_obj_remove_style_local_prop(lv_obj_t * obj, uint8_t part, lv_style_prope
|
||||
/**
|
||||
* Notify an object (and its children) about its style is modified
|
||||
* @param obj pointer to an object
|
||||
* @param part the part of the object which style property should be refreshed.
|
||||
* @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)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
invalidate_style_cache(obj, part, prop);
|
||||
|
||||
/*If a real style refresh is required*/
|
||||
bool real_refr = false;
|
||||
switch(prop) {
|
||||
@@ -1387,6 +1426,26 @@ void lv_obj_report_style_mod(lv_style_t * style)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
uint8_t part;
|
||||
for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) {
|
||||
lv_style_list_t * list = lv_obj_get_style_list(obj, part);
|
||||
if(list == NULL) break;
|
||||
list->ignore_cache = dis;
|
||||
}
|
||||
for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) {
|
||||
lv_style_list_t * list = lv_obj_get_style_list(obj, part);
|
||||
if(list == NULL) break;
|
||||
list->ignore_cache = dis;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------
|
||||
* Attribute set
|
||||
*----------------*/
|
||||
@@ -1609,12 +1668,12 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
|
||||
|
||||
#if LV_USE_ANIMATION == 0
|
||||
obj->state = new_state;
|
||||
lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
#else
|
||||
lv_state_t prev_state = obj->state;
|
||||
obj->state = new_state;
|
||||
|
||||
uint8_t part;
|
||||
|
||||
for(part = 0; part < _LV_OBJ_PART_REAL_LAST; part++) {
|
||||
lv_style_list_t * style_list = lv_obj_get_style_list(obj, part);
|
||||
if(style_list == NULL) break; /*No more style lists*/
|
||||
@@ -1660,11 +1719,9 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
|
||||
|
||||
}
|
||||
}
|
||||
lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1753,6 +1810,52 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data)
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
return lv_event_send(obj, LV_EVENT_REFRESH, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if(obj == NULL) {
|
||||
/*If no obj specified refresh all screen of all displays */
|
||||
lv_disp_t * d = lv_disp_get_next(NULL);
|
||||
while(d) {
|
||||
lv_obj_t * scr = _lv_ll_get_head(&d->scr_ll);
|
||||
while(scr) {
|
||||
lv_event_send_refresh_recursive(scr);
|
||||
scr = _lv_ll_get_next(&d->scr_ll, scr);
|
||||
}
|
||||
lv_event_send_refresh_recursive(d->top_layer);
|
||||
lv_event_send_refresh_recursive(d->sys_layer);
|
||||
|
||||
d = lv_disp_get_next(d);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
lv_res_t res = lv_event_send_refresh(obj);
|
||||
if(res != LV_RES_OK) return; /*If invalid returned do not check the children*/
|
||||
|
||||
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||
while(child) {
|
||||
lv_event_send_refresh_recursive(child);
|
||||
|
||||
child = lv_obj_get_child(obj, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -2403,12 +2506,74 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl
|
||||
lv_res_t res = LV_RES_INV;
|
||||
const lv_obj_t * parent = obj;
|
||||
while(parent) {
|
||||
lv_style_list_t * dsc = lv_obj_get_style_list(parent, part);
|
||||
lv_style_list_t * list = lv_obj_get_style_list(parent, part);
|
||||
if(!list->ignore_cache && list->style_cnt > 0) {
|
||||
if(!list->valid_cache) update_style_cache((lv_obj_t *)parent, part, prop & (~LV_STYLE_STATE_MASK));
|
||||
|
||||
bool def = false;
|
||||
switch(prop & (~LV_STYLE_STATE_MASK)) {
|
||||
case LV_STYLE_BG_GRAD_DIR:
|
||||
if(list->bg_grad_dir_none) def = true;
|
||||
break;
|
||||
case LV_STYLE_CLIP_CORNER:
|
||||
if(list->clip_corner_off) def = true;
|
||||
break;
|
||||
case LV_STYLE_TEXT_LETTER_SPACE:
|
||||
case LV_STYLE_TEXT_LINE_SPACE:
|
||||
if(list->text_space_zero) def = true;
|
||||
break;
|
||||
case LV_STYLE_TRANSFORM_ANGLE:
|
||||
case LV_STYLE_TRANSFORM_WIDTH:
|
||||
case LV_STYLE_TRANSFORM_HEIGHT:
|
||||
case LV_STYLE_TRANSFORM_ZOOM:
|
||||
if(list->transform_all_zero) def = true;
|
||||
break;
|
||||
case LV_STYLE_BORDER_WIDTH:
|
||||
if(list->border_width_zero) def = true;
|
||||
break;
|
||||
case LV_STYLE_BORDER_SIDE:
|
||||
if(list->border_side_full) def = true;
|
||||
break;
|
||||
case LV_STYLE_BORDER_POST:
|
||||
if(list->border_post_off) def = true;
|
||||
break;
|
||||
case LV_STYLE_OUTLINE_WIDTH:
|
||||
if(list->outline_width_zero) def = true;
|
||||
break;
|
||||
case LV_STYLE_RADIUS:
|
||||
if(list->radius_zero) def = true;
|
||||
break;
|
||||
case LV_STYLE_SHADOW_WIDTH:
|
||||
if(list->shadow_width_zero) def = true;
|
||||
break;
|
||||
case LV_STYLE_PAD_TOP:
|
||||
case LV_STYLE_PAD_BOTTOM:
|
||||
case LV_STYLE_PAD_LEFT:
|
||||
case LV_STYLE_PAD_RIGHT:
|
||||
if(list->pad_all_zero) def = true;
|
||||
break;
|
||||
case LV_STYLE_BG_BLEND_MODE:
|
||||
case LV_STYLE_BORDER_BLEND_MODE:
|
||||
case LV_STYLE_IMAGE_BLEND_MODE:
|
||||
case LV_STYLE_LINE_BLEND_MODE:
|
||||
case LV_STYLE_OUTLINE_BLEND_MODE:
|
||||
case LV_STYLE_PATTERN_BLEND_MODE:
|
||||
case LV_STYLE_SHADOW_BLEND_MODE:
|
||||
case LV_STYLE_TEXT_BLEND_MODE:
|
||||
case LV_STYLE_VALUE_BLEND_MODE:
|
||||
if(list->blend_mode_all_normal) def = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(def) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lv_state_t state = lv_obj_get_state(parent, part);
|
||||
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
|
||||
|
||||
res = _lv_style_list_get_int(dsc, prop, &value_act);
|
||||
res = _lv_style_list_get_int(list, prop, &value_act);
|
||||
if(res == LV_RES_OK) return value_act;
|
||||
|
||||
if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break;
|
||||
@@ -2466,12 +2631,12 @@ lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_
|
||||
lv_res_t res = LV_RES_INV;
|
||||
const lv_obj_t * parent = obj;
|
||||
while(parent) {
|
||||
lv_style_list_t * dsc = lv_obj_get_style_list(parent, part);
|
||||
lv_style_list_t * list = lv_obj_get_style_list(parent, part);
|
||||
|
||||
lv_state_t state = lv_obj_get_state(parent, part);
|
||||
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
|
||||
|
||||
res = _lv_style_list_get_color(dsc, prop, &value_act);
|
||||
res = _lv_style_list_get_color(list, prop, &value_act);
|
||||
if(res == LV_RES_OK) return value_act;
|
||||
|
||||
if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break;
|
||||
@@ -2522,12 +2687,34 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop
|
||||
lv_res_t res = LV_RES_INV;
|
||||
const lv_obj_t * parent = obj;
|
||||
while(parent) {
|
||||
lv_style_list_t * dsc = lv_obj_get_style_list(parent, part);
|
||||
lv_style_list_t * list = lv_obj_get_style_list(parent, part);
|
||||
|
||||
if(!list->ignore_cache && list->style_cnt > 0) {
|
||||
if(!list->valid_cache) update_style_cache((lv_obj_t *)parent, part, prop & (~LV_STYLE_STATE_MASK));
|
||||
bool def = false;
|
||||
switch(prop & (~LV_STYLE_STATE_MASK)) {
|
||||
case LV_STYLE_OPA_SCALE:
|
||||
if(list->opa_scale_cover) def = true;
|
||||
break;
|
||||
case LV_STYLE_BG_OPA:
|
||||
if(list->bg_opa_cover) return LV_OPA_COVER; /*Special case, not the default value is used*/
|
||||
if(list->bg_opa_transp) def = true;
|
||||
break;
|
||||
case LV_STYLE_IMAGE_RECOLOR_OPA:
|
||||
if(list->img_recolor_opa_transp) def = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(def) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lv_state_t state = lv_obj_get_state(parent, part);
|
||||
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
|
||||
|
||||
res = _lv_style_list_get_opa(dsc, prop, &value_act);
|
||||
res = _lv_style_list_get_opa(list, prop, &value_act);
|
||||
if(res == LV_RES_OK) return value_act;
|
||||
|
||||
if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break;
|
||||
@@ -2579,12 +2766,32 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_
|
||||
lv_res_t res = LV_RES_INV;
|
||||
const lv_obj_t * parent = obj;
|
||||
while(parent) {
|
||||
lv_style_list_t * dsc = lv_obj_get_style_list(parent, part);
|
||||
lv_style_list_t * list = lv_obj_get_style_list(parent, part);
|
||||
|
||||
if(!list->ignore_cache && list->style_cnt > 0) {
|
||||
if(!list->valid_cache) update_style_cache((lv_obj_t *)parent, part, prop & (~LV_STYLE_STATE_MASK));
|
||||
bool def = false;
|
||||
switch(prop & (~LV_STYLE_STATE_MASK)) {
|
||||
case LV_STYLE_VALUE_STR:
|
||||
if(list->value_txt_str) def = true;
|
||||
break;
|
||||
case LV_STYLE_PATTERN_IMAGE:
|
||||
if(list->pattern_img_null) def = true;
|
||||
break;
|
||||
case LV_STYLE_TEXT_FONT:
|
||||
if(list->text_font_normal) def = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(def) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lv_state_t state = lv_obj_get_state(parent, part);
|
||||
prop = (uint16_t)prop_ori + ((uint16_t)state << LV_STYLE_STATE_POS);
|
||||
|
||||
res = _lv_style_list_get_ptr(dsc, prop, &value_act);
|
||||
res = _lv_style_list_get_ptr(list, prop, &value_act);
|
||||
if(res == LV_RES_OK) return value_act;
|
||||
|
||||
if(LV_STYLE_ATTR_GET_INHERIT(attr) == 0) break;
|
||||
@@ -3098,9 +3305,9 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
}
|
||||
}
|
||||
|
||||
if(draw_dsc->border_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->border_width = lv_obj_get_style_border_width(obj, part);
|
||||
if(draw_dsc->border_width) {
|
||||
draw_dsc->border_width = lv_obj_get_style_border_width(obj, part);
|
||||
if(draw_dsc->border_width) {
|
||||
if(draw_dsc->border_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->border_opa = lv_obj_get_style_border_opa(obj, part);
|
||||
if(draw_dsc->border_opa > LV_OPA_MIN) {
|
||||
draw_dsc->border_side = lv_obj_get_style_border_side(obj, part);
|
||||
@@ -3112,10 +3319,10 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(draw_dsc->outline_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->outline_width = lv_obj_get_style_outline_width(obj, part);
|
||||
if(draw_dsc->outline_width) {
|
||||
#if LV_USE_OUTLINE
|
||||
draw_dsc->outline_width = lv_obj_get_style_outline_width(obj, part);
|
||||
if(draw_dsc->outline_width) {
|
||||
if(draw_dsc->outline_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->outline_opa = lv_obj_get_style_outline_opa(obj, part);
|
||||
if(draw_dsc->outline_opa > LV_OPA_MIN) {
|
||||
draw_dsc->outline_pad = lv_obj_get_style_outline_pad(obj, part);
|
||||
@@ -3126,10 +3333,12 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(draw_dsc->pattern_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->pattern_image = lv_obj_get_style_pattern_image(obj, part);
|
||||
if(draw_dsc->pattern_image) {
|
||||
#if LV_USE_PATTERN
|
||||
draw_dsc->pattern_image = lv_obj_get_style_pattern_image(obj, part);
|
||||
if(draw_dsc->pattern_image) {
|
||||
if(draw_dsc->pattern_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->pattern_opa = lv_obj_get_style_pattern_opa(obj, part);
|
||||
if(draw_dsc->pattern_opa > LV_OPA_MIN) {
|
||||
draw_dsc->pattern_recolor_opa = lv_obj_get_style_pattern_recolor_opa(obj, part);
|
||||
@@ -3147,10 +3356,12 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_SHADOW
|
||||
if(draw_dsc->shadow_opa > LV_OPA_MIN) {
|
||||
draw_dsc->shadow_width = lv_obj_get_style_shadow_width(obj, part);
|
||||
if(draw_dsc->shadow_width) {
|
||||
draw_dsc->shadow_width = lv_obj_get_style_shadow_width(obj, part);
|
||||
if(draw_dsc->shadow_width) {
|
||||
if(draw_dsc->shadow_opa > LV_OPA_MIN) {
|
||||
draw_dsc->shadow_opa = lv_obj_get_style_shadow_opa(obj, part);
|
||||
if(draw_dsc->shadow_opa > LV_OPA_MIN) {
|
||||
draw_dsc->shadow_ofs_x = lv_obj_get_style_shadow_ofs_x(obj, part);
|
||||
@@ -3165,9 +3376,10 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
}
|
||||
#endif
|
||||
|
||||
if(draw_dsc->value_opa > LV_OPA_MIN) {
|
||||
draw_dsc->value_str = lv_obj_get_style_value_str(obj, part);
|
||||
if(draw_dsc->value_str) {
|
||||
#if LV_USE_VALUE_STR
|
||||
draw_dsc->value_str = lv_obj_get_style_value_str(obj, part);
|
||||
if(draw_dsc->value_str) {
|
||||
if(draw_dsc->value_opa > LV_OPA_MIN) {
|
||||
draw_dsc->value_opa = lv_obj_get_style_value_opa(obj, part);
|
||||
if(draw_dsc->value_opa > LV_OPA_MIN) {
|
||||
draw_dsc->value_ofs_x = lv_obj_get_style_value_ofs_x(obj, part);
|
||||
@@ -3183,6 +3395,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_OPA_SCALE
|
||||
if(opa_scale < LV_OPA_MAX) {
|
||||
@@ -3256,6 +3469,9 @@ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t *
|
||||
|
||||
void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t * draw_dsc)
|
||||
{
|
||||
draw_dsc->width = lv_obj_get_style_line_width(obj, part);
|
||||
if(draw_dsc->width == 0) return;
|
||||
|
||||
draw_dsc->opa = lv_obj_get_style_line_opa(obj, part);
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
@@ -3267,9 +3483,6 @@ void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
#endif
|
||||
|
||||
draw_dsc->width = lv_obj_get_style_line_width(obj, part);
|
||||
if(draw_dsc->width == 0) return;
|
||||
|
||||
draw_dsc->color = lv_obj_get_style_line_color(obj, part);
|
||||
|
||||
draw_dsc->dash_width = lv_obj_get_style_line_dash_width(obj, part);
|
||||
@@ -3492,17 +3705,13 @@ static void obj_del_core(lv_obj_t * obj)
|
||||
|
||||
/*Recursively delete the children*/
|
||||
lv_obj_t * i;
|
||||
lv_obj_t * i_next;
|
||||
i = _lv_ll_get_head(&(obj->child_ll));
|
||||
while(i != NULL) {
|
||||
/*Get the next object before delete this*/
|
||||
i_next = _lv_ll_get_next(&(obj->child_ll), i);
|
||||
|
||||
/*Call the recursive del to the child too*/
|
||||
/*Call the recursive delete to the child too*/
|
||||
obj_del_core(i);
|
||||
|
||||
/*Set i to the next node*/
|
||||
i = i_next;
|
||||
/*Set i to the new head node*/
|
||||
i = _lv_ll_get_head(&(obj->child_ll));
|
||||
}
|
||||
|
||||
lv_event_mark_deleted(obj);
|
||||
@@ -3585,7 +3794,7 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
lv_draw_rect_dsc_init(&draw_dsc);
|
||||
/*If the border is drawn later disable loading its properties*/
|
||||
if(lv_obj_get_style_border_post(obj, LV_OBJ_PART_MAIN)) {
|
||||
draw_dsc.border_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.border_post = 1;
|
||||
}
|
||||
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_OBJ_PART_MAIN, &draw_dsc);
|
||||
@@ -3605,8 +3814,21 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
||||
|
||||
lv_coord_t r = lv_obj_get_style_radius(obj, LV_OBJ_PART_MAIN);
|
||||
/* If it has border make the clip area 1 px smaller to avoid color bleeding
|
||||
* The border will cover the minimal issue on the edges*/
|
||||
if(draw_dsc.border_post && draw_dsc.border_opa >= LV_OPA_MIN && draw_dsc.border_width > 0) {
|
||||
lv_area_t cc_area;
|
||||
cc_area.x1 = obj->coords.x1 + 1;
|
||||
cc_area.y1 = obj->coords.y1 + 1;
|
||||
cc_area.x2 = obj->coords.x2 - 1;
|
||||
cc_area.y2 = obj->coords.y2 - 1;
|
||||
lv_draw_mask_radius_init(mp, &cc_area, r, false);
|
||||
}
|
||||
/*If no border use the full size.*/
|
||||
else {
|
||||
lv_draw_mask_radius_init(mp, &obj->coords, r, false);
|
||||
}
|
||||
|
||||
lv_draw_mask_radius_init(mp, &obj->coords, r, false);
|
||||
/*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/
|
||||
lv_draw_mask_add(mp, obj + 8);
|
||||
}
|
||||
@@ -3624,6 +3846,7 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
|
||||
draw_dsc.bg_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.pattern_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.shadow_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.value_opa = LV_OPA_TRANSP;
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_OBJ_PART_MAIN, &draw_dsc);
|
||||
|
||||
lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_OBJ_PART_MAIN);
|
||||
@@ -3764,16 +3987,16 @@ static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coor
|
||||
*/
|
||||
static void report_style_mod_core(void * style, lv_obj_t * obj)
|
||||
{
|
||||
uint8_t part_sub;
|
||||
for(part_sub = 0; part_sub != _LV_OBJ_PART_REAL_LAST; part_sub++) {
|
||||
lv_style_list_t * dsc = lv_obj_get_style_list(obj, part_sub);
|
||||
if(dsc == NULL) break;
|
||||
uint8_t part;
|
||||
for(part = 0; part != _LV_OBJ_PART_REAL_LAST; part++) {
|
||||
lv_style_list_t * list = lv_obj_get_style_list(obj, part);
|
||||
if(list == NULL) break;
|
||||
|
||||
uint8_t ci;
|
||||
for(ci = 0; ci < dsc->style_cnt; ci++) {
|
||||
lv_style_t * class = lv_style_list_get_style(dsc, ci);
|
||||
for(ci = 0; ci < list->style_cnt; ci++) {
|
||||
lv_style_t * class = lv_style_list_get_style(list, ci);
|
||||
if(class == style || style == NULL) {
|
||||
lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3840,8 +4063,8 @@ static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t ali
|
||||
else if(y_set) lv_obj_set_y(obj, new_pos.y);
|
||||
}
|
||||
|
||||
static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set,
|
||||
lv_coord_t x_ofs, lv_coord_t y_ofs)
|
||||
static void obj_align_mid_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set,
|
||||
lv_coord_t x_ofs, lv_coord_t y_ofs)
|
||||
{
|
||||
lv_coord_t new_x = lv_obj_get_x(obj);
|
||||
lv_coord_t new_y = lv_obj_get_y(obj);
|
||||
@@ -4154,7 +4377,7 @@ static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v)
|
||||
else x = tr->end_value._ptr;
|
||||
_lv_style_set_ptr(style, tr->prop, x);
|
||||
}
|
||||
lv_obj_refresh_style(tr->obj, tr->prop);
|
||||
lv_obj_refresh_style(tr->obj, tr->part, tr->prop);
|
||||
|
||||
}
|
||||
|
||||
@@ -4249,3 +4472,201 @@ static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_fin
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool style_prop_is_cacheble(lv_style_property_t prop)
|
||||
{
|
||||
|
||||
switch(prop) {
|
||||
case LV_STYLE_PROP_ALL:
|
||||
case LV_STYLE_BG_GRAD_DIR:
|
||||
case LV_STYLE_CLIP_CORNER:
|
||||
case LV_STYLE_TEXT_LETTER_SPACE:
|
||||
case LV_STYLE_TEXT_LINE_SPACE:
|
||||
case LV_STYLE_TEXT_FONT:
|
||||
case LV_STYLE_TRANSFORM_ANGLE:
|
||||
case LV_STYLE_TRANSFORM_WIDTH:
|
||||
case LV_STYLE_TRANSFORM_HEIGHT:
|
||||
case LV_STYLE_TRANSFORM_ZOOM:
|
||||
case LV_STYLE_BORDER_WIDTH:
|
||||
case LV_STYLE_OUTLINE_WIDTH:
|
||||
case LV_STYLE_RADIUS:
|
||||
case LV_STYLE_SHADOW_WIDTH:
|
||||
case LV_STYLE_OPA_SCALE:
|
||||
case LV_STYLE_BG_OPA:
|
||||
case LV_STYLE_BORDER_SIDE:
|
||||
case LV_STYLE_BORDER_POST:
|
||||
case LV_STYLE_IMAGE_RECOLOR_OPA:
|
||||
case LV_STYLE_VALUE_STR:
|
||||
case LV_STYLE_PATTERN_IMAGE:
|
||||
case LV_STYLE_PAD_TOP:
|
||||
case LV_STYLE_PAD_BOTTOM:
|
||||
case LV_STYLE_PAD_LEFT:
|
||||
case LV_STYLE_PAD_RIGHT:
|
||||
case LV_STYLE_BG_BLEND_MODE:
|
||||
case LV_STYLE_BORDER_BLEND_MODE:
|
||||
case LV_STYLE_IMAGE_BLEND_MODE:
|
||||
case LV_STYLE_LINE_BLEND_MODE:
|
||||
case LV_STYLE_OUTLINE_BLEND_MODE:
|
||||
case LV_STYLE_PATTERN_BLEND_MODE:
|
||||
case LV_STYLE_SHADOW_BLEND_MODE:
|
||||
case LV_STYLE_TEXT_BLEND_MODE:
|
||||
case LV_STYLE_VALUE_BLEND_MODE:
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the cache of style list
|
||||
* @param obj pointer to an obejct
|
||||
* @param part the part of the object
|
||||
* @param prop the property which triggered the update
|
||||
*/
|
||||
static void update_style_cache(lv_obj_t * obj, uint8_t part, uint16_t prop)
|
||||
{
|
||||
if(style_prop_is_cacheble(prop) == false) return;
|
||||
|
||||
lv_style_list_t * list = lv_obj_get_style_list(obj, part);
|
||||
|
||||
bool ignore_cache_ori = list->ignore_cache;
|
||||
list->ignore_cache = 1;
|
||||
|
||||
#if LV_USE_OPA_SCALE
|
||||
list->opa_scale_cover = lv_obj_get_style_opa_scale(obj, part) == LV_OPA_COVER ? 1 : 0;
|
||||
#else
|
||||
list->opa_scale_cover = 1;
|
||||
#endif
|
||||
list->text_decor_none = lv_obj_get_style_text_decor(obj, part) == LV_TEXT_DECOR_NONE ? 1 : 0;
|
||||
list->text_font_normal = lv_obj_get_style_text_font(obj, part) == LV_THEME_DEFAULT_FONT_NORMAL ? 1 : 0;
|
||||
|
||||
list->text_space_zero = 1;
|
||||
if(lv_obj_get_style_text_letter_space(obj, part) != 0 ||
|
||||
lv_obj_get_style_text_line_space(obj, part) != 0) {
|
||||
list->text_space_zero = 0;
|
||||
}
|
||||
|
||||
|
||||
lv_opa_t bg_opa = lv_obj_get_style_bg_opa(obj, part);
|
||||
list->bg_opa_transp = bg_opa == LV_OPA_TRANSP ? 1 : 0;
|
||||
list->bg_opa_cover = bg_opa == LV_OPA_COVER ? 1 : 0;
|
||||
|
||||
list->bg_grad_dir_none = lv_obj_get_style_bg_grad_dir(obj, part) == LV_GRAD_DIR_NONE ? 1 : 0;
|
||||
list->border_width_zero = lv_obj_get_style_border_width(obj, part) == 0 ? 1 : 0;
|
||||
list->border_side_full = lv_obj_get_style_border_side(obj, part) == LV_BORDER_SIDE_FULL ? 1 : 0;
|
||||
list->border_post_off = lv_obj_get_style_border_post(obj, part) == 0 ? 1 : 0;
|
||||
list->clip_corner_off = lv_obj_get_style_clip_corner(obj, part) == false ? 1 : 0;
|
||||
list->img_recolor_opa_transp = lv_obj_get_style_image_recolor_opa(obj, part) == LV_OPA_TRANSP ? 1 : 0;
|
||||
list->outline_width_zero = lv_obj_get_style_outline_width(obj, part) == 0 ? 1 : 0;
|
||||
list->pattern_img_null = lv_obj_get_style_pattern_image(obj, part) == NULL ? 1 : 0;
|
||||
list->radius_zero = lv_obj_get_style_radius(obj, part) == 0 ? 1 : 0;
|
||||
list->shadow_width_zero = lv_obj_get_style_shadow_width(obj, part) == 0 ? 1 : 0;
|
||||
list->value_txt_str = lv_obj_get_style_value_str(obj, part) == NULL ? 1 : 0;
|
||||
|
||||
|
||||
list->transform_all_zero = 1;
|
||||
if(lv_obj_get_style_transform_angle(obj, part) != 0 ||
|
||||
lv_obj_get_style_transform_width(obj, part) != 0 ||
|
||||
lv_obj_get_style_transform_height(obj, part) != 0 ||
|
||||
lv_obj_get_style_transform_zoom(obj, part) != LV_IMG_ZOOM_NONE) {
|
||||
list->transform_all_zero = 0;
|
||||
}
|
||||
|
||||
list->pad_all_zero = 1;
|
||||
if(lv_obj_get_style_pad_top(obj, part) != 0 ||
|
||||
lv_obj_get_style_pad_bottom(obj, part) != 0 ||
|
||||
lv_obj_get_style_pad_left(obj, part) != 0 ||
|
||||
lv_obj_get_style_pad_right(obj, part) != 0) {
|
||||
list->pad_all_zero = 0;
|
||||
}
|
||||
|
||||
list->blend_mode_all_normal = 1;
|
||||
#if LV_USE_BLEND_MODES
|
||||
if(lv_obj_get_style_bg_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL ||
|
||||
lv_obj_get_style_border_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL ||
|
||||
lv_obj_get_style_pattern_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL ||
|
||||
lv_obj_get_style_outline_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL ||
|
||||
lv_obj_get_style_value_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL ||
|
||||
lv_obj_get_style_text_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL ||
|
||||
lv_obj_get_style_line_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL ||
|
||||
lv_obj_get_style_image_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL ||
|
||||
lv_obj_get_style_shadow_blend_mode(obj, part) != LV_BLEND_MODE_NORMAL) {
|
||||
list->blend_mode_all_normal = 0;
|
||||
}
|
||||
#endif
|
||||
list->ignore_cache = ignore_cache_ori;
|
||||
list->valid_cache = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the cache of style list
|
||||
* @param obj pointer to an object
|
||||
* @param part the part of the object
|
||||
*/
|
||||
static void update_style_cache_children(lv_obj_t * obj)
|
||||
{
|
||||
uint8_t part;
|
||||
for(part = 0; part != _LV_OBJ_PART_REAL_LAST; part++) {
|
||||
lv_style_list_t * list = lv_obj_get_style_list(obj, part);
|
||||
if(list == NULL) break;
|
||||
|
||||
bool ignore_cache_ori = list->ignore_cache;
|
||||
list->ignore_cache = 1;
|
||||
|
||||
list->opa_scale_cover = lv_obj_get_style_opa_scale(obj, part) == LV_OPA_COVER ? 1 : 0;
|
||||
list->text_decor_none = lv_obj_get_style_text_decor(obj, part) == LV_TEXT_DECOR_NONE ? 1 : 0;
|
||||
list->text_font_normal = lv_obj_get_style_text_font(obj, part) == lv_theme_get_font_normal() ? 1 : 0;
|
||||
list->img_recolor_opa_transp = lv_obj_get_style_image_recolor_opa(obj, part) == LV_OPA_TRANSP ? 1 : 0;
|
||||
|
||||
list->text_space_zero = 1;
|
||||
if(lv_obj_get_style_text_letter_space(obj, part) != 0 ||
|
||||
lv_obj_get_style_text_line_space(obj, part) != 0) {
|
||||
list->text_space_zero = 0;
|
||||
}
|
||||
|
||||
list->ignore_cache = ignore_cache_ori;
|
||||
}
|
||||
|
||||
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||
while(child) {
|
||||
update_style_cache_children(child);
|
||||
child = lv_obj_get_child(obj, child);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the object and all of it's children's style lists as invalid.
|
||||
* The cache will be updated when a cached property asked nest time
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
static void invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
|
||||
{
|
||||
if(style_prop_is_cacheble(prop) == false) return;
|
||||
|
||||
if(part != LV_OBJ_PART_ALL) {
|
||||
lv_style_list_t * list = lv_obj_get_style_list(obj, part);
|
||||
if(list == NULL) return;
|
||||
list->valid_cache = 0;
|
||||
}
|
||||
else {
|
||||
|
||||
for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) {
|
||||
lv_style_list_t * list = lv_obj_get_style_list(obj, part);
|
||||
if(list == NULL) break;
|
||||
list->valid_cache = 0;
|
||||
}
|
||||
for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) {
|
||||
lv_style_list_t * list = lv_obj_get_style_list(obj, part);
|
||||
if(list == NULL) break;
|
||||
list->valid_cache = 0;
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||
while(child) {
|
||||
update_style_cache_children(child);
|
||||
child = lv_obj_get_child(obj, child);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,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. */
|
||||
|
||||
@@ -162,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
|
||||
@@ -353,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
|
||||
*====================*/
|
||||
@@ -494,7 +511,7 @@ void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_
|
||||
* @param x_ofs x coordinate offset after alignment
|
||||
* @param y_ofs y coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs);
|
||||
void lv_obj_align_mid(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs);
|
||||
|
||||
|
||||
/**
|
||||
@@ -504,7 +521,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param x_ofs x coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs);
|
||||
void lv_obj_align_mid_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs);
|
||||
|
||||
/**
|
||||
* Align an object's middle point to an other object vertically.
|
||||
@@ -513,7 +530,7 @@ void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t alig
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param y_ofs y coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_origo_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs);
|
||||
void lv_obj_align_mid_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs);
|
||||
|
||||
/**
|
||||
* Realign the object based on the last `lv_obj_align` parameters.
|
||||
@@ -586,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
|
||||
@@ -664,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
|
||||
*----------------*/
|
||||
@@ -823,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.
|
||||
|
||||
@@ -572,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);
|
||||
@@ -741,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) {
|
||||
|
||||
@@ -257,7 +257,7 @@ void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style)
|
||||
return;
|
||||
}
|
||||
|
||||
lv_style_t ** new_classes = lv_mem_realloc(list->style_list, sizeof(lv_style_t *) * (list->style_cnt - 1));
|
||||
lv_style_t ** new_classes = lv_mem_alloc(sizeof(lv_style_t *) * (list->style_cnt - 1));
|
||||
LV_ASSERT_MEM(new_classes);
|
||||
if(new_classes == NULL) {
|
||||
LV_LOG_WARN("lv_style_list_remove_style: couldn't reallocate class list");
|
||||
@@ -271,6 +271,8 @@ void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style)
|
||||
|
||||
}
|
||||
|
||||
lv_mem_free(list->style_list);
|
||||
|
||||
list->style_cnt--;
|
||||
list->style_list = new_classes;
|
||||
}
|
||||
@@ -873,7 +875,8 @@ lv_res_t _lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t pr
|
||||
|
||||
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++) {
|
||||
@@ -1037,7 +1040,6 @@ bool lv_debug_check_style_list(const lv_style_list_t * list)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@@ -1102,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);
|
||||
|
||||
@@ -221,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;
|
||||
|
||||
/**********************
|
||||
@@ -570,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);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -36,9 +36,11 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
|
||||
#if LV_USE_BLEND_MODES
|
||||
static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
|
||||
#endif
|
||||
|
||||
static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
@@ -49,12 +51,14 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
|
||||
#if LV_USE_BLEND_MODES
|
||||
static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
|
||||
|
||||
static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
|
||||
static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -134,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` */
|
||||
@@ -167,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
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,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;
|
||||
@@ -230,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
|
||||
}
|
||||
|
||||
|
||||
@@ -515,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)
|
||||
@@ -606,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,
|
||||
@@ -845,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)
|
||||
@@ -996,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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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,133 +401,69 @@ 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;
|
||||
@@ -575,13 +499,13 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
|
||||
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;
|
||||
@@ -598,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;
|
||||
@@ -1226,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;
|
||||
@@ -1235,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);
|
||||
@@ -1247,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);
|
||||
|
||||
@@ -1265,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;
|
||||
@@ -1471,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) {
|
||||
@@ -1524,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;
|
||||
@@ -1559,3 +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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,7 +474,7 @@ void _lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc)
|
||||
* @param pivot x,y pivot coordinates of rotation
|
||||
*/
|
||||
void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t h, int16_t angle, uint16_t zoom,
|
||||
lv_point_t * pivot)
|
||||
const lv_point_t * pivot)
|
||||
{
|
||||
#if LV_USE_IMG_TRANSFORM
|
||||
if(angle == 0 && zoom == LV_IMG_ZOOM_NONE) {
|
||||
@@ -477,7 +483,20 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t
|
||||
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;
|
||||
@@ -493,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;
|
||||
@@ -501,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);
|
||||
|
||||
@@ -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
|
||||
**********************/
|
||||
@@ -172,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;
|
||||
@@ -301,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*/
|
||||
@@ -380,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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -114,7 +114,7 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header)
|
||||
* 1) File name: E.g. "S:folder/img1.png" (The drivers needs to registered via `lv_fs_add_drv()`)
|
||||
* 2) Variable: Pointer to an `lv_img_dsc_t` variable
|
||||
* 3) Symbol: E.g. `LV_SYMBOL_OK`
|
||||
* @param style the style of the image
|
||||
* @param color The color of the image with `LV_IMG_CF_ALPHA_...`
|
||||
* @return LV_RES_OK: opened the image. `dsc->img_data` and `dsc->header` are set.
|
||||
* LV_RES_INV: none of the registered image decoders were able to open the image.
|
||||
*/
|
||||
@@ -559,7 +559,7 @@ static lv_res_t lv_img_decoder_built_in_line_true_color(lv_img_decoder_dsc_t * d
|
||||
}
|
||||
uint32_t btr = len * (px_size >> 3);
|
||||
uint32_t br = 0;
|
||||
lv_fs_read(user_data->f, buf, btr, &br);
|
||||
res = lv_fs_read(user_data->f, buf, btr, &br);
|
||||
if(res != LV_FS_RES_OK || btr != br) {
|
||||
LV_LOG_WARN("Built-in image decoder read failed");
|
||||
return LV_RES_INV;
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
*********************/
|
||||
@@ -47,7 +52,6 @@ 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;
|
||||
@@ -88,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;
|
||||
|
||||
@@ -108,16 +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;
|
||||
}
|
||||
|
||||
bool prefilter = fdsc->bitmap_format == LV_FONT_FMT_TXT_COMPRESSED ? true : false;
|
||||
decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp,
|
||||
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 decompr_buf;
|
||||
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*/
|
||||
@@ -180,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
694
src/lv_font/lv_font_loader.c
Normal file
694
src/lv_font/lv_font_loader.c
Normal 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*/
|
||||
|
||||
44
src/lv_font/lv_font_loader.h
Normal file
44
src/lv_font/lv_font_loader.h
Normal 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*/
|
||||
@@ -7,6 +7,7 @@
|
||||
* 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
|
||||
@@ -216,11 +217,10 @@ 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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -596,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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
**********************/
|
||||
|
||||
@@ -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
|
||||
**********************/
|
||||
|
||||
@@ -586,6 +586,7 @@ void _lv_mem_buf_free_all(void)
|
||||
}
|
||||
}
|
||||
|
||||
#if LV_MEMCPY_MEMSET_STD == 0
|
||||
/**
|
||||
* Same as `memcpy` but optimized for 4 byte operation.
|
||||
* @param dst pointer to the destination buffer
|
||||
@@ -652,7 +653,6 @@ LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len
|
||||
|
||||
/**
|
||||
* Same as `memset` but optimized for 4 byte operation.
|
||||
* `dst` should be word aligned else normal `memcpy` will be used
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param v value to set [0..255]
|
||||
* @param len number of byte to set
|
||||
@@ -707,7 +707,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len)
|
||||
|
||||
/**
|
||||
* Same as `memset(dst, 0x00, len)` but optimized for 4 byte operation.
|
||||
* `dst` should be word aligned else normal `memcpy` will be used
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param len number of byte to set
|
||||
*/
|
||||
@@ -757,7 +756,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len)
|
||||
|
||||
/**
|
||||
* Same as `memset(dst, 0xFF, len)` but optimized for 4 byte operation.
|
||||
* `dst` should be word aligned else normal `memcpy` will be used
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param len number of byte to set
|
||||
*/
|
||||
@@ -805,6 +803,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*LV_MEMCPY_MEMSET_STD*/
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
|
||||
@@ -20,6 +20,10 @@ extern "C" {
|
||||
#include "lv_log.h"
|
||||
#include "lv_types.h"
|
||||
|
||||
#if LV_MEMCPY_MEMSET_STD
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@@ -137,6 +141,62 @@ void _lv_mem_buf_free_all(void);
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
|
||||
#if LV_MEMCPY_MEMSET_STD
|
||||
|
||||
/**
|
||||
* Wrapper for the standard memcpy
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param src pointer to the source buffer
|
||||
* @param len number of byte to copy
|
||||
*/
|
||||
static inline void * _lv_memcpy(void * dst, const void * src, size_t len)
|
||||
{
|
||||
return memcpy(dst, src, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for the standard memcpy
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param src pointer to the source buffer
|
||||
* @param len number of byte to copy
|
||||
*/
|
||||
static inline void * _lv_memcpy_small(void * dst, const void * src, size_t len)
|
||||
{
|
||||
return memcpy(dst, src, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for the standard memset
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param v value to set [0..255]
|
||||
* @param len number of byte to set
|
||||
*/
|
||||
static inline void _lv_memset(void * dst, uint8_t v, size_t len)
|
||||
{
|
||||
memset(dst, v, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for the standard memset with fixed 0x00 value
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param len number of byte to set
|
||||
*/
|
||||
static inline void _lv_memset_00(void * dst, size_t len)
|
||||
{
|
||||
memset(dst, 0x00, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for the standard memset with fixed 0xFF value
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param len number of byte to set
|
||||
*/
|
||||
static inline void _lv_memset_ff(void * dst, size_t len)
|
||||
{
|
||||
memset(dst, 0xFF, len);
|
||||
}
|
||||
|
||||
#else
|
||||
/**
|
||||
* Same as `memcpy` but optimized for 4 byte operation.
|
||||
* @param dst pointer to the destination buffer
|
||||
@@ -168,7 +228,6 @@ LV_ATTRIBUTE_FAST_MEM static inline void * _lv_memcpy_small(void * dst, const vo
|
||||
|
||||
/**
|
||||
* Same as `memset` but optimized for 4 byte operation.
|
||||
* `dst` should be word aligned else normal `memcpy` will be used
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param v value to set [0..255]
|
||||
* @param len number of byte to set
|
||||
@@ -177,7 +236,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len);
|
||||
|
||||
/**
|
||||
* Same as `memset(dst, 0x00, len)` but optimized for 4 byte operation.
|
||||
* `dst` should be word aligned else normal `memcpy` will be used
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param len number of byte to set
|
||||
*/
|
||||
@@ -185,7 +243,6 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len);
|
||||
|
||||
/**
|
||||
* Same as `memset(dst, 0xFF, len)` but optimized for 4 byte operation.
|
||||
* `dst` should be word aligned else normal `memcpy` will be used
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param len number of byte to set
|
||||
*/
|
||||
@@ -193,6 +250,9 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len);
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
@@ -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
|
||||
**********************/
|
||||
|
||||
@@ -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
|
||||
**********************/
|
||||
|
||||
@@ -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*/
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco
|
||||
}
|
||||
|
||||
|
||||
void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
|
||||
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
|
||||
{
|
||||
LV_UNUSED(th);
|
||||
if(name == LV_THEME_SCR) {
|
||||
|
||||
@@ -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)))
|
||||
@@ -85,6 +86,7 @@ typedef struct {
|
||||
#if LV_USE_ARC
|
||||
lv_style_t arc_indic;
|
||||
lv_style_t arc_bg;
|
||||
lv_style_t arc_knob;
|
||||
#endif
|
||||
|
||||
#if LV_USE_BAR
|
||||
@@ -210,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);
|
||||
@@ -298,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);
|
||||
@@ -357,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);
|
||||
|
||||
@@ -503,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
|
||||
}
|
||||
|
||||
@@ -555,7 +566,7 @@ static void calendar_init(void)
|
||||
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_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);
|
||||
@@ -608,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);
|
||||
@@ -618,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));
|
||||
@@ -738,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);
|
||||
@@ -1057,6 +1071,11 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
list = lv_obj_get_style_list(obj, LV_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
|
||||
|
||||
@@ -1183,7 +1202,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_USE_OBJMASK
|
||||
case LV_THEME_OBJMASK:
|
||||
list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN);
|
||||
@@ -1366,7 +1384,7 @@ static void theme_apply(lv_theme_t * th, 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);
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -1023,7 +1023,7 @@ static void theme_apply(lv_theme_t * th, 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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -855,7 +855,7 @@ void theme_apply(lv_theme_t * th, 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);
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -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, ©_ext->style_knob);
|
||||
lv_style_list_copy(&ext->style_arc, ©_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, ¢er, &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, ¢er, 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, ¢er, &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
|
||||
|
||||
@@ -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
|
||||
*====================*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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++;
|
||||
@@ -658,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);
|
||||
@@ -667,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;
|
||||
@@ -695,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);
|
||||
@@ -746,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;
|
||||
@@ -898,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -912,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 {
|
||||
@@ -1204,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) {
|
||||
|
||||
@@ -705,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);
|
||||
@@ -738,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -810,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;
|
||||
|
||||
@@ -856,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;
|
||||
}
|
||||
|
||||
@@ -926,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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -152,7 +152,7 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
_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");
|
||||
@@ -207,23 +207,23 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
|
||||
/**
|
||||
* Clear the point of a series
|
||||
* @param chart pointer to a chart object
|
||||
* @param serie pointer to the chart's series to clear
|
||||
* @param series pointer to the chart's series to clear
|
||||
*/
|
||||
void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie)
|
||||
void lv_chart_clear_series(lv_obj_t * chart, lv_chart_series_t * series)
|
||||
{
|
||||
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(serie);
|
||||
LV_ASSERT_NULL(series);
|
||||
|
||||
if(chart == NULL || serie == NULL) return;
|
||||
if(chart == NULL || series == NULL) return;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext == NULL) return;
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < ext->point_cnt; i++) {
|
||||
serie->points[i] = LV_CHART_POINT_DEF;
|
||||
series->points[i] = LV_CHART_POINT_DEF;
|
||||
}
|
||||
|
||||
serie->start_point = 0;
|
||||
series->start_point = 0;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
|
||||
@@ -139,9 +139,9 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color);
|
||||
/**
|
||||
* Clear the point of a series
|
||||
* @param chart pointer to a chart object
|
||||
* @param serie pointer to the chart's series to clear
|
||||
* @param series pointer to the chart's series to clear
|
||||
*/
|
||||
void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie);
|
||||
void lv_chart_clear_series(lv_obj_t * chart, lv_chart_series_t * series);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
|
||||
@@ -112,7 +112,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->layout = copy_ext->layout;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(cont, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(cont, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("container created");
|
||||
|
||||
@@ -48,6 +48,13 @@
|
||||
|
||||
#define TRI_OFFSET 2
|
||||
|
||||
/* The OUTER_MASK_WIDTH define is required to assist with the placing of a mask over the outer ring of the widget as when the
|
||||
* multicoloured radial lines are calculated for the outer ring of the widget their lengths are jittering because of the
|
||||
* integer based arithmetic. From tests the maximum delta was found to be 2 so the current value is set to 3 to achieve
|
||||
* appropriate masking.
|
||||
*/
|
||||
#define OUTER_MASK_WIDTH 3
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@@ -144,7 +151,7 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
lv_style_list_copy(&ext->knob.style_list, ©_ext->knob.style_list);
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(cpicker, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(cpicker, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
refr_knob_pos(cpicker);
|
||||
|
||||
@@ -237,9 +244,7 @@ bool lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv)
|
||||
|
||||
refr_knob_pos(cpicker);
|
||||
|
||||
if(ext->type == LV_CPICKER_TYPE_DISC) {
|
||||
lv_obj_invalidate(cpicker);
|
||||
}
|
||||
lv_obj_invalidate(cpicker);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -483,6 +488,17 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask)
|
||||
uint16_t i;
|
||||
lv_coord_t cir_w = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN);
|
||||
|
||||
/* Mask outer ring of widget to tidy up ragged edges of lines while drawing outer ring */
|
||||
lv_area_t mask_area_out;
|
||||
lv_area_copy(&mask_area_out, &cpicker->coords);
|
||||
mask_area_out.x1 += OUTER_MASK_WIDTH;
|
||||
mask_area_out.x2 -= OUTER_MASK_WIDTH;
|
||||
mask_area_out.y1 += OUTER_MASK_WIDTH;
|
||||
mask_area_out.y2 -= OUTER_MASK_WIDTH;
|
||||
lv_draw_mask_radius_param_t mask_out_param;
|
||||
lv_draw_mask_radius_init(&mask_out_param, &mask_area_out, LV_RADIUS_CIRCLE, false);
|
||||
int16_t mask_out_id = lv_draw_mask_add(&mask_out_param, 0);
|
||||
|
||||
/* The inner line ends will be masked out.
|
||||
* So make lines a little bit longer because the masking makes a more even result */
|
||||
lv_coord_t cir_w_extra = cir_w + line_dsc.width;
|
||||
@@ -498,7 +514,8 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask)
|
||||
|
||||
lv_draw_line(&p[0], &p[1], mask, &line_dsc);
|
||||
}
|
||||
|
||||
/* Now remove mask to continue with inner part */
|
||||
lv_draw_mask_remove_id(mask_out_id);
|
||||
|
||||
/*Mask out the inner area*/
|
||||
lv_draw_rect_dsc_t bg_dsc;
|
||||
|
||||
@@ -609,7 +609,7 @@ void lv_dropdown_open(lv_obj_t * ddlist)
|
||||
lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_BG), &ext->style_page);
|
||||
lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCROLLBAR), &ext->style_scrlbar);
|
||||
lv_obj_clean_style_list(ext->page, LV_PAGE_PART_SCROLLABLE);
|
||||
lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(ext->page, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
|
||||
lv_obj_t * label = lv_label_create(ext->page, NULL);
|
||||
lv_label_set_text_static(label, ext->options);
|
||||
@@ -965,7 +965,7 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(ddlist, LV_DROPDOWN_PART_MAIN);
|
||||
lv_obj_set_height(ddlist, top + bottom + lv_font_get_line_height(font));
|
||||
|
||||
if(ext->page) lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL);
|
||||
if(ext->page) lv_obj_refresh_style(ext->page, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROL) {
|
||||
#if LV_USE_GROUP
|
||||
@@ -1134,8 +1134,10 @@ static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id
|
||||
lv_obj_t * page = ext->page;
|
||||
lv_state_t state_orig = page->state;
|
||||
|
||||
page->state = LV_STATE_DEFAULT;
|
||||
page->state |= state;
|
||||
if(state != page->state) {
|
||||
_lv_obj_disable_style_caching(ddlist, true);
|
||||
page->state = state;
|
||||
}
|
||||
|
||||
/*Draw a rectangle under the selected item*/
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(ddlist, LV_DROPDOWN_PART_LIST);
|
||||
@@ -1159,6 +1161,7 @@ static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id
|
||||
lv_draw_rect(&rect_area, clip_area, &sel_rect);
|
||||
|
||||
page->state = state_orig;
|
||||
_lv_obj_disable_style_caching(ddlist, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1169,8 +1172,10 @@ static void draw_box_label(lv_obj_t * ddlist, const lv_area_t * clip_area, uint1
|
||||
lv_obj_t * page = ext->page;
|
||||
lv_state_t state_orig = page->state;
|
||||
|
||||
page->state = LV_STATE_DEFAULT;
|
||||
page->state |= state;
|
||||
if(state != page->state) {
|
||||
page->state = state;
|
||||
_lv_obj_disable_style_caching(ddlist, true);
|
||||
}
|
||||
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
@@ -1204,6 +1209,7 @@ static void draw_box_label(lv_obj_t * ddlist, const lv_area_t * clip_area, uint1
|
||||
lv_draw_label(&label->coords, &mask_sel, &label_dsc, lv_label_get_text(label), NULL);
|
||||
}
|
||||
page->state = state_orig;
|
||||
_lv_obj_disable_style_caching(ddlist, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1275,10 +1281,12 @@ static uint16_t get_id_on_point(lv_obj_t * ddlist, lv_coord_t x, lv_coord_t y)
|
||||
y -= label->coords.y1;
|
||||
uint32_t letter_i;
|
||||
|
||||
const char * txt = lv_label_get_text(label);
|
||||
|
||||
lv_point_t p = {x, y};
|
||||
letter_i = lv_label_get_letter_on(label, &p);
|
||||
uint32_t letter_i_byte_pos = _lv_txt_encoded_get_byte_id(txt, letter_i);
|
||||
uint16_t opt = 0;
|
||||
const char * txt = lv_label_get_text(label);
|
||||
uint32_t i = 0;
|
||||
uint32_t i_prev = 0;
|
||||
|
||||
@@ -1287,7 +1295,7 @@ static uint16_t get_id_on_point(lv_obj_t * ddlist, lv_coord_t x, lv_coord_t y)
|
||||
uint32_t letter = _lv_txt_encoded_next(txt, &i);
|
||||
/*Count the lines to reach the clicked letter. But ignore the last '\n' because it
|
||||
* still belongs to the clicked line*/
|
||||
if(letter == '\n' && i_prev != letter_i) opt++;
|
||||
if(letter == '\n' && i_prev != letter_i_byte_pos) opt++;
|
||||
i_prev = i;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->format_cb = copy_ext->format_cb;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(gauge, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(gauge, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("gauge created");
|
||||
@@ -589,15 +589,6 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area)
|
||||
lv_draw_line_dsc_init(&line_dsc);
|
||||
lv_obj_init_draw_line_dsc(gauge, LV_GAUGE_PART_NEEDLE, &line_dsc);
|
||||
|
||||
lv_draw_img_dsc_t img_dsc;
|
||||
if(ext->needle_img == NULL) {
|
||||
lv_draw_img_dsc_init(&img_dsc);
|
||||
lv_obj_init_draw_img_dsc(gauge, LV_GAUGE_PART_MAIN, &img_dsc);
|
||||
img_dsc.recolor_opa = LV_OPA_COVER;
|
||||
img_dsc.pivot.x = ext->needle_img_pivot.x;
|
||||
img_dsc.pivot.y = ext->needle_img_pivot.y;
|
||||
}
|
||||
|
||||
p_mid.x = x_ofs;
|
||||
p_mid.y = y_ofs;
|
||||
for(i = 0; i < ext->needle_count; i++) {
|
||||
@@ -625,10 +616,17 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area)
|
||||
a.y1 = gauge->coords.y1 + lv_area_get_height(&gauge->coords) / 2 - ext->needle_img_pivot.y;
|
||||
a.x2 = a.x1 + info.w - 1;
|
||||
a.y2 = a.y1 + info.h - 1;
|
||||
lv_draw_img_dsc_t img_dsc;
|
||||
lv_draw_img_dsc_init(&img_dsc);
|
||||
lv_obj_init_draw_img_dsc(gauge, LV_GAUGE_PART_MAIN, &img_dsc);
|
||||
img_dsc.pivot.x = ext->needle_img_pivot.x;
|
||||
img_dsc.pivot.y = ext->needle_img_pivot.y;
|
||||
|
||||
if(ext->needle_colors != NULL)
|
||||
img_dsc.recolor = ext->needle_colors[i];
|
||||
|
||||
needle_angle = (needle_angle * 10);
|
||||
if(needle_angle > 3600) needle_angle -= 3600;
|
||||
img_dsc.angle = needle_angle;
|
||||
lv_draw_img(&a, clip_area, ext->needle_img, &img_dsc);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_img_set_src(img, copy_ext->src);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(img, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(img, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("image created");
|
||||
@@ -303,8 +303,10 @@ void lv_img_set_pivot(lv_obj_t * img, lv_coord_t pivot_x, lv_coord_t pivot_y)
|
||||
lv_style_int_t transf_angle = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN);
|
||||
transf_angle += ext->angle;
|
||||
|
||||
lv_coord_t w = lv_obj_get_width(img);
|
||||
lv_coord_t h = lv_obj_get_height(img);
|
||||
lv_area_t a;
|
||||
_lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot);
|
||||
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, transf_zoom, &ext->pivot);
|
||||
a.x1 += img->coords.x1;
|
||||
a.y1 += img->coords.y1;
|
||||
a.x2 += img->coords.x1;
|
||||
@@ -315,7 +317,7 @@ void lv_img_set_pivot(lv_obj_t * img, lv_coord_t pivot_x, lv_coord_t pivot_y)
|
||||
ext->pivot.y = pivot_y;
|
||||
lv_obj_refresh_ext_draw_pad(img);
|
||||
|
||||
_lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot);
|
||||
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, transf_zoom, &ext->pivot);
|
||||
a.x1 += img->coords.x1;
|
||||
a.y1 += img->coords.y1;
|
||||
a.x2 += img->coords.x1;
|
||||
@@ -341,8 +343,10 @@ void lv_img_set_angle(lv_obj_t * img, int16_t angle)
|
||||
|
||||
lv_style_int_t transf_angle = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN);
|
||||
|
||||
lv_coord_t w = lv_obj_get_width(img);
|
||||
lv_coord_t h = lv_obj_get_height(img);
|
||||
lv_area_t a;
|
||||
_lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle + ext->angle, transf_zoom, &ext->pivot);
|
||||
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle + ext->angle, transf_zoom, &ext->pivot);
|
||||
a.x1 += img->coords.x1;
|
||||
a.y1 += img->coords.y1;
|
||||
a.x2 += img->coords.x1;
|
||||
@@ -352,7 +356,7 @@ void lv_img_set_angle(lv_obj_t * img, int16_t angle)
|
||||
ext->angle = angle;
|
||||
lv_obj_refresh_ext_draw_pad(img);
|
||||
|
||||
_lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle + ext->angle, transf_zoom, &ext->pivot);
|
||||
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle + ext->angle, transf_zoom, &ext->pivot);
|
||||
a.x1 += img->coords.x1;
|
||||
a.y1 += img->coords.y1;
|
||||
a.x2 += img->coords.x1;
|
||||
@@ -382,8 +386,10 @@ void lv_img_set_zoom(lv_obj_t * img, uint16_t zoom)
|
||||
lv_style_int_t transf_angle = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN);
|
||||
transf_angle += ext->angle;
|
||||
|
||||
lv_coord_t w = lv_obj_get_width(img);
|
||||
lv_coord_t h = lv_obj_get_height(img);
|
||||
lv_area_t a;
|
||||
_lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot);
|
||||
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot);
|
||||
a.x1 += img->coords.x1;
|
||||
a.y1 += img->coords.y1;
|
||||
a.x2 += img->coords.x1;
|
||||
@@ -393,7 +399,7 @@ void lv_img_set_zoom(lv_obj_t * img, uint16_t zoom)
|
||||
ext->zoom = zoom;
|
||||
lv_obj_refresh_ext_draw_pad(img);
|
||||
|
||||
_lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot);
|
||||
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, (transf_zoom * ext->zoom) >> 8, &ext->pivot);
|
||||
a.x1 += img->coords.x1;
|
||||
a.y1 += img->coords.y1;
|
||||
a.x2 += img->coords.x1;
|
||||
@@ -567,7 +573,6 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
|
||||
if(lv_obj_get_style_clip_corner(img, LV_IMG_PART_MAIN)) return LV_DESIGN_RES_MASKED;
|
||||
|
||||
if(ext->src_type == LV_IMG_SRC_UNKNOWN || ext->src_type == LV_IMG_SRC_SYMBOL) return LV_DESIGN_RES_NOT_COVER;
|
||||
@@ -575,15 +580,18 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
|
||||
/*Non true color format might have "holes"*/
|
||||
if(ext->cf != LV_IMG_CF_TRUE_COLOR && ext->cf != LV_IMG_CF_RAW) return LV_DESIGN_RES_NOT_COVER;
|
||||
|
||||
/*With not LV_OPA_COVER images acn't cover an area */
|
||||
if(lv_obj_get_style_image_opa(img, LV_IMG_PART_MAIN) != LV_OPA_COVER) return LV_DESIGN_RES_NOT_COVER;
|
||||
|
||||
int32_t angle_final = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN);
|
||||
angle_final += ext->angle;
|
||||
|
||||
if(angle_final == 0) return LV_DESIGN_RES_NOT_COVER;
|
||||
if(angle_final != 0) return LV_DESIGN_RES_NOT_COVER;
|
||||
|
||||
int32_t zoom_final = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN);
|
||||
zoom_final = (zoom_final * ext->zoom) >> 8;
|
||||
|
||||
if(zoom_final != LV_IMG_ZOOM_NONE) {
|
||||
if(zoom_final == LV_IMG_ZOOM_NONE) {
|
||||
if(_lv_area_is_in(clip_area, &img->coords, 0) == false) return LV_DESIGN_RES_NOT_COVER;
|
||||
}
|
||||
else {
|
||||
@@ -597,15 +605,15 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
|
||||
if(_lv_area_is_in(clip_area, &a, 0) == false) return LV_DESIGN_RES_NOT_COVER;
|
||||
}
|
||||
|
||||
if(lv_obj_get_style_image_opa(img, LV_IMG_PART_MAIN) != LV_OPA_COVER) return LV_DESIGN_RES_NOT_COVER;
|
||||
#if LV_USE_BLEND_MODES
|
||||
if(lv_obj_get_style_bg_blend_mode(img, LV_IMG_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DESIGN_RES_NOT_COVER;
|
||||
if(lv_obj_get_style_image_blend_mode(img, LV_IMG_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DESIGN_RES_NOT_COVER;
|
||||
#endif
|
||||
|
||||
return LV_DESIGN_RES_COVER;
|
||||
}
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
if(ext->h == 0 || ext->w == 0) return true;
|
||||
lv_area_t img_coords;
|
||||
|
||||
lv_obj_get_coords(img, &img_coords);
|
||||
|
||||
lv_draw_rect_dsc_t bg_dsc;
|
||||
lv_draw_rect_dsc_init(&bg_dsc);
|
||||
@@ -620,18 +628,19 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
|
||||
int32_t zoom_final = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN);
|
||||
zoom_final = (zoom_final * ext->zoom) >> 8;
|
||||
|
||||
if(zoom_final == 0) return LV_DESIGN_RES_OK;
|
||||
|
||||
int32_t angle_final = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN);
|
||||
angle_final += ext->angle;
|
||||
|
||||
lv_coord_t obj_w = lv_obj_get_width(img);
|
||||
lv_coord_t obj_h = lv_obj_get_height(img);
|
||||
|
||||
lv_area_t bg_coords;
|
||||
_lv_img_buf_get_transformed_area(&bg_coords, lv_area_get_width(&img_coords), lv_area_get_height(&img_coords),
|
||||
_lv_img_buf_get_transformed_area(&bg_coords, obj_w, obj_h,
|
||||
angle_final, zoom_final, &ext->pivot);
|
||||
bg_coords.x1 += img_coords.x1;
|
||||
bg_coords.y1 += img_coords.y1;
|
||||
bg_coords.x2 += img_coords.x1;
|
||||
bg_coords.y2 += img_coords.y1;
|
||||
bg_coords.x1 += img->coords.x1;
|
||||
bg_coords.y1 += img->coords.y1;
|
||||
bg_coords.x2 += img->coords.x1;
|
||||
bg_coords.y2 += img->coords.y1;
|
||||
bg_coords.x1 -= lv_obj_get_style_pad_left(img, LV_IMG_PART_MAIN);
|
||||
bg_coords.x2 += lv_obj_get_style_pad_right(img, LV_IMG_PART_MAIN);
|
||||
bg_coords.y1 -= lv_obj_get_style_pad_top(img, LV_IMG_PART_MAIN);
|
||||
@@ -639,6 +648,8 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
|
||||
|
||||
lv_draw_rect(&bg_coords, clip_area, &bg_dsc);
|
||||
|
||||
if(zoom_final == 0) return LV_DESIGN_RES_OK;
|
||||
|
||||
if(lv_obj_get_style_clip_corner(img, LV_OBJ_PART_MAIN)) {
|
||||
lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
||||
|
||||
@@ -650,12 +661,6 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
|
||||
}
|
||||
|
||||
if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_VARIABLE) {
|
||||
img_coords.x1 += ext->offset.x;
|
||||
img_coords.y1 += ext->offset.y;
|
||||
|
||||
if(img_coords.x1 > img->coords.x1) img_coords.x1 -= ext->w;
|
||||
if(img_coords.y1 > img->coords.y1) img_coords.y1 -= ext->h;
|
||||
|
||||
LV_LOG_TRACE("lv_img_design: start to draw image");
|
||||
|
||||
lv_draw_img_dsc_t img_dsc;
|
||||
@@ -672,15 +677,40 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
|
||||
img_dsc.pivot.y = ext->pivot.y;
|
||||
img_dsc.antialias = ext->antialias;
|
||||
|
||||
lv_area_t cords_tmp;
|
||||
cords_tmp.y1 = img_coords.y1;
|
||||
cords_tmp.y2 = img_coords.y1 + ext->h - 1;
|
||||
lv_coord_t zoomed_src_w = (int32_t)((int32_t)ext->w * zoom_final) >> 8;
|
||||
if(zoomed_src_w <= 0) return LV_DESIGN_RES_OK;
|
||||
lv_coord_t zoomed_src_h = (int32_t)((int32_t)ext->h * zoom_final) >> 8;
|
||||
if(zoomed_src_h <= 0) return LV_DESIGN_RES_OK;
|
||||
lv_area_t zommed_coords;
|
||||
lv_obj_get_coords(img, &zommed_coords);
|
||||
|
||||
for(; cords_tmp.y1 <= img_coords.y2; cords_tmp.y1 += ext->h, cords_tmp.y2 += ext->h) {
|
||||
cords_tmp.x1 = img_coords.x1;
|
||||
cords_tmp.x2 = img_coords.x1 + ext->w - 1;
|
||||
for(; cords_tmp.x1 <= img_coords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) {
|
||||
lv_draw_img(&cords_tmp, clip_area, ext->src, &img_dsc);
|
||||
zommed_coords.x1 += (int32_t)((int32_t)ext->offset.x * zoom_final) >> 8;
|
||||
zommed_coords.y1 += (int32_t)((int32_t)ext->offset.y * zoom_final) >> 8;
|
||||
zommed_coords.x2 = zommed_coords.x1 + ((int32_t)((int32_t)(obj_w - 1) * zoom_final) >> 8);
|
||||
zommed_coords.y2 = zommed_coords.y1 + ((int32_t)((int32_t)(obj_h - 1) * zoom_final) >> 8);
|
||||
|
||||
if(zommed_coords.x1 > img->coords.x1) zommed_coords.x1 -= ext->w;
|
||||
if(zommed_coords.y1 > img->coords.y1) zommed_coords.y1 -= ext->h;
|
||||
|
||||
lv_area_t clip_real;
|
||||
_lv_img_buf_get_transformed_area(&clip_real, lv_obj_get_width(img), lv_obj_get_height(img), angle_final, zoom_final,
|
||||
&ext->pivot);
|
||||
clip_real.x1 += img->coords.x1;
|
||||
clip_real.x2 += img->coords.x1;
|
||||
clip_real.y1 += img->coords.y1;
|
||||
clip_real.y2 += img->coords.y1;
|
||||
|
||||
if(_lv_area_intersect(&clip_real, &clip_real, clip_area) == false) return LV_DESIGN_RES_OK;
|
||||
|
||||
lv_area_t coords_tmp;
|
||||
coords_tmp.y1 = zommed_coords.y1;
|
||||
coords_tmp.y2 = zommed_coords.y1 + ext->h - 1;
|
||||
|
||||
for(; coords_tmp.y1 <= zommed_coords.y2; coords_tmp.y1 += zoomed_src_h, coords_tmp.y2 += zoomed_src_h) {
|
||||
coords_tmp.x1 = zommed_coords.x1;
|
||||
coords_tmp.x2 = zommed_coords.x1 + ext->w - 1;
|
||||
for(; coords_tmp.x1 <= zommed_coords.x2; coords_tmp.x1 += zoomed_src_w, coords_tmp.x2 += zoomed_src_w) {
|
||||
lv_draw_img(&coords_tmp, &clip_real, ext->src, &img_dsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -691,7 +721,7 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
|
||||
lv_obj_init_draw_label_dsc(img, LV_IMG_PART_MAIN, &label_dsc);
|
||||
|
||||
label_dsc.color = lv_obj_get_style_image_recolor(img, LV_IMG_PART_MAIN);
|
||||
lv_draw_label(&img_coords, clip_area, &label_dsc, ext->src, NULL);
|
||||
lv_draw_label(&img->coords, clip_area, &label_dsc, ext->src, NULL);
|
||||
}
|
||||
else {
|
||||
/*Trigger the error handler of image drawer*/
|
||||
@@ -705,15 +735,33 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
|
||||
_lv_mem_buf_release(param);
|
||||
}
|
||||
|
||||
lv_draw_rect_dsc_t draw_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_dsc);
|
||||
|
||||
/*If the border is drawn later disable loading other properties*/
|
||||
if(lv_obj_get_style_border_post(img, LV_OBJ_PART_MAIN)) {
|
||||
lv_draw_rect_dsc_t draw_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_dsc);
|
||||
draw_dsc.bg_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.pattern_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.shadow_opa = LV_OPA_TRANSP;
|
||||
lv_obj_init_draw_rect_dsc(img, LV_OBJ_PART_MAIN, &draw_dsc);
|
||||
|
||||
int32_t zoom_final = lv_obj_get_style_transform_zoom(img, LV_IMG_PART_MAIN);
|
||||
zoom_final = (zoom_final * ext->zoom) >> 8;
|
||||
|
||||
int32_t angle_final = lv_obj_get_style_transform_angle(img, LV_IMG_PART_MAIN);
|
||||
angle_final += ext->angle;
|
||||
|
||||
lv_area_t bg_coords;
|
||||
_lv_img_buf_get_transformed_area(&bg_coords, lv_area_get_width(&img->coords), lv_area_get_height(&img->coords),
|
||||
angle_final, zoom_final, &ext->pivot);
|
||||
bg_coords.x1 += img->coords.x1;
|
||||
bg_coords.y1 += img->coords.y1;
|
||||
bg_coords.x2 += img->coords.x1;
|
||||
bg_coords.y2 += img->coords.y1;
|
||||
bg_coords.x1 -= lv_obj_get_style_pad_left(img, LV_IMG_PART_MAIN);
|
||||
bg_coords.x2 += lv_obj_get_style_pad_right(img, LV_IMG_PART_MAIN);
|
||||
bg_coords.y1 -= lv_obj_get_style_pad_top(img, LV_IMG_PART_MAIN);
|
||||
bg_coords.y2 += lv_obj_get_style_pad_bottom(img, LV_IMG_PART_MAIN);
|
||||
|
||||
lv_draw_rect(&img->coords, clip_area, &draw_dsc);
|
||||
}
|
||||
}
|
||||
@@ -770,12 +818,14 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
|
||||
/*If the image has angle provide enough room for the rotated corners */
|
||||
if(transf_angle || transf_zoom != LV_IMG_ZOOM_NONE) {
|
||||
lv_area_t a;
|
||||
_lv_img_buf_get_transformed_area(&a, ext->w, ext->h, transf_angle, transf_zoom, &ext->pivot);
|
||||
lv_coord_t w = lv_obj_get_width(img);
|
||||
lv_coord_t h = lv_obj_get_height(img);
|
||||
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, transf_zoom, &ext->pivot);
|
||||
lv_coord_t pad_ori = img->ext_draw_pad;
|
||||
img->ext_draw_pad = LV_MATH_MAX(img->ext_draw_pad, pad_ori - a.x1);
|
||||
img->ext_draw_pad = LV_MATH_MAX(img->ext_draw_pad, pad_ori - a.y1);
|
||||
img->ext_draw_pad = LV_MATH_MAX(img->ext_draw_pad, pad_ori + a.x2 - ext->w);
|
||||
img->ext_draw_pad = LV_MATH_MAX(img->ext_draw_pad, pad_ori + a.y2 - ext->h);
|
||||
img->ext_draw_pad = LV_MATH_MAX(img->ext_draw_pad, pad_ori + a.x2 - w);
|
||||
img->ext_draw_pad = LV_MATH_MAX(img->ext_draw_pad, pad_ori + a.y2 - h);
|
||||
}
|
||||
|
||||
/*Handle the padding of the background*/
|
||||
@@ -804,8 +854,10 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
|
||||
if(ext->w == lv_obj_get_width(img) && ext->h == lv_obj_get_height(img) &&
|
||||
(zoom != LV_IMG_ZOOM_NONE || angle != 0 || ext->pivot.x != ext->w / 2 || ext->pivot.y != ext->h / 2)) {
|
||||
|
||||
lv_coord_t w = lv_obj_get_width(img);
|
||||
lv_coord_t h = lv_obj_get_height(img);
|
||||
lv_area_t coords;
|
||||
_lv_img_buf_get_transformed_area(&coords, ext->w, ext->h, angle, zoom, &ext->pivot);
|
||||
_lv_img_buf_get_transformed_area(&coords, w, h, angle, zoom, &ext->pivot);
|
||||
coords.x1 += img->coords.x1;
|
||||
coords.y1 += img->coords.y1;
|
||||
coords.x2 += img->coords.x1;
|
||||
|
||||
@@ -100,7 +100,7 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
#endif
|
||||
ext->tiled = copy_ext->tiled;
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(imgbtn, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(imgbtn, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("image button created");
|
||||
@@ -273,7 +273,38 @@ static lv_design_res_t lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * cli
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
ancestor_design(imgbtn, clip_area, mode);
|
||||
lv_area_t img_coords;
|
||||
|
||||
lv_obj_get_coords(imgbtn, &img_coords);
|
||||
|
||||
lv_draw_rect_dsc_t bg_dsc;
|
||||
lv_draw_rect_dsc_init(&bg_dsc);
|
||||
lv_obj_init_draw_rect_dsc(imgbtn, LV_IMGBTN_PART_MAIN, &bg_dsc);
|
||||
|
||||
/*If the border is drawn later disable loading its properties*/
|
||||
if(lv_obj_get_style_border_post(imgbtn, LV_OBJ_PART_MAIN)) {
|
||||
bg_dsc.border_opa = LV_OPA_TRANSP;
|
||||
}
|
||||
|
||||
lv_area_t bg_coords;
|
||||
lv_area_copy(&bg_coords, &img_coords);
|
||||
bg_coords.x1 -= lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
bg_coords.x2 += lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
bg_coords.y1 -= lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
bg_coords.y2 += lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
|
||||
lv_draw_rect(&bg_coords, clip_area, &bg_dsc);
|
||||
|
||||
if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) {
|
||||
lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
||||
|
||||
lv_coord_t r = lv_obj_get_style_radius(imgbtn, LV_OBJ_PART_MAIN);
|
||||
|
||||
lv_draw_mask_radius_init(mp, &bg_coords, r, false);
|
||||
/*Add the mask and use `img+8` as custom id. Don't use `obj` directly because it might be used by the user*/
|
||||
lv_draw_mask_add(mp, imgbtn + 8);
|
||||
}
|
||||
|
||||
/*Just draw an image*/
|
||||
lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn);
|
||||
lv_btn_state_t state = lv_imgbtn_get_state(imgbtn);
|
||||
@@ -374,6 +405,31 @@ static lv_design_res_t lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * cli
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DESIGN_DRAW_POST) {
|
||||
if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) {
|
||||
lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(imgbtn + 8);
|
||||
_lv_mem_buf_release(param);
|
||||
}
|
||||
|
||||
lv_draw_rect_dsc_t draw_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_dsc);
|
||||
|
||||
/*If the border is drawn later disable loading other properties*/
|
||||
if(lv_obj_get_style_border_post(imgbtn, LV_OBJ_PART_MAIN)) {
|
||||
draw_dsc.bg_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.pattern_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.shadow_opa = LV_OPA_TRANSP;
|
||||
lv_obj_init_draw_rect_dsc(imgbtn, LV_OBJ_PART_MAIN, &draw_dsc);
|
||||
|
||||
|
||||
lv_area_t bg_coords;
|
||||
lv_area_copy(&bg_coords, &imgbtn->coords);
|
||||
bg_coords.x1 -= lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
bg_coords.x2 += lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
bg_coords.y1 -= lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
bg_coords.y2 += lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
|
||||
lv_draw_rect(&bg_coords, clip_area, &draw_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
return LV_DESIGN_RES_OK;
|
||||
@@ -400,6 +456,18 @@ static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * par
|
||||
* changed as well Set the new image for the new state.*/
|
||||
refr_img(imgbtn);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||
/*Handle the padding of the background*/
|
||||
lv_style_int_t left = lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
lv_style_int_t right = lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
lv_style_int_t top = lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN);
|
||||
|
||||
imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, left);
|
||||
imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, right);
|
||||
imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, top);
|
||||
imgbtn->ext_draw_pad = LV_MATH_MAX(imgbtn->ext_draw_pad, bottom);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ static const lv_btnmatrix_ctrl_t default_kb_ctrl_uc_map[] = {
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2
|
||||
};
|
||||
|
||||
static const char * const default_kb_map_spec[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", LV_SYMBOL_BACKSPACE, "\n",
|
||||
static const char * const default_kb_map_spec[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", LV_SYMBOL_BACKSPACE, "\n",
|
||||
"abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
|
||||
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
|
||||
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""
|
||||
|
||||
@@ -161,7 +161,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->dot_end = copy_ext->dot_end;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(new_label, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(new_label, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("label created");
|
||||
@@ -688,10 +688,14 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_
|
||||
* @return the index of the letter on the 'pos_p' point (E.g. on 0;0 is the 0. letter)
|
||||
* Expressed in character index and not byte index (different in UTF-8)
|
||||
*/
|
||||
uint32_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
uint32_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos_in)
|
||||
{
|
||||
LV_ASSERT_OBJ(label, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(pos);
|
||||
LV_ASSERT_NULL(pos_in);
|
||||
|
||||
lv_point_t pos;
|
||||
pos.x = pos_in->x - lv_obj_get_style_pad_left(label, LV_LABEL_PART_MAIN);
|
||||
pos.y = pos_in->y - lv_obj_get_style_pad_top(label, LV_LABEL_PART_MAIN);
|
||||
|
||||
lv_area_t txt_coords;
|
||||
get_txt_coords(label, &txt_coords);
|
||||
@@ -721,7 +725,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
while(txt[line_start] != '\0') {
|
||||
new_line_start += _lv_txt_get_next_line(&txt[line_start], font, letter_space, max_w, flag);
|
||||
|
||||
if(pos->y <= y + letter_height) {
|
||||
if(pos.y <= y + letter_height) {
|
||||
/*The line is found (stored in 'line_start')*/
|
||||
/* Include the NULL terminator in the last line */
|
||||
uint32_t tmp = new_line_start;
|
||||
@@ -780,7 +784,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
lv_coord_t gw = lv_font_get_glyph_width(font, letter, letter_next);
|
||||
|
||||
/*Finish if the x position or the last char of the next line is reached*/
|
||||
if(pos->x < x + (gw >> 1) || i + line_start == new_line_start || txt[i_act + line_start] == '\0') {
|
||||
if(pos.x < x + gw || i + line_start == new_line_start || txt[i_act + line_start] == '\0') {
|
||||
i = i_act;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->bright = copy_ext->bright;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(led, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(led, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("led created");
|
||||
|
||||
@@ -95,7 +95,7 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_line_set_points(line, copy_ext->point_array, copy_ext->point_num);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(line, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(line, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("line created");
|
||||
|
||||
@@ -76,6 +76,7 @@ lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->line_cnt = 18;
|
||||
ext->scale_angle = 240;
|
||||
ext->angle_ofs = 0;
|
||||
ext->mirrored = 0;
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_cb(linemeter, lv_linemeter_signal);
|
||||
@@ -96,7 +97,7 @@ lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->cur_value = copy_ext->cur_value;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(linemeter, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(linemeter, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("line meter created");
|
||||
@@ -392,15 +393,15 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
|
||||
lv_coord_t x_ofs = lmeter->coords.x1 + r_out + left;
|
||||
lv_coord_t y_ofs = lmeter->coords.y1 + r_out + top;
|
||||
int16_t angle_ofs = ext->angle_ofs + 90 + (360 - ext->scale_angle) / 2;
|
||||
int16_t level =
|
||||
(int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value);
|
||||
int16_t level = ext->mirrored ?
|
||||
(int32_t)((int32_t)(ext->max_value - ext->cur_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value) :
|
||||
(int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value);
|
||||
uint8_t i;
|
||||
|
||||
lv_color_t main_color = lv_obj_get_style_line_color(lmeter, part);
|
||||
lv_color_t grad_color = lv_obj_get_style_scale_grad_color(lmeter, part);
|
||||
lv_color_t end_color = lv_obj_get_style_scale_end_color(lmeter, part);
|
||||
|
||||
|
||||
lv_draw_line_dsc_t line_dsc;
|
||||
lv_draw_line_dsc_init(&line_dsc);
|
||||
lv_obj_init_draw_line_dsc(lmeter, part, &line_dsc);
|
||||
@@ -520,7 +521,7 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
|
||||
p1.y = y_out_extra;
|
||||
|
||||
/* Set the color of the lines */
|
||||
if(i > level) {
|
||||
if((!ext->mirrored && i >= level) || (ext->mirrored && i <= level)) {
|
||||
line_dsc.color = end_color;
|
||||
line_dsc.width = end_line_width;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
}
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(list, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(list, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("list created");
|
||||
@@ -365,11 +365,11 @@ lv_obj_t * lv_list_get_btn_label(const lv_obj_t * btn)
|
||||
{
|
||||
LV_ASSERT_OBJ(btn, "lv_btn");
|
||||
|
||||
lv_obj_t * label = lv_obj_get_child(btn, NULL);
|
||||
lv_obj_t * label = lv_obj_get_child_back(btn, NULL);
|
||||
if(label == NULL) return NULL;
|
||||
|
||||
while(lv_list_is_list_label(label) == false) {
|
||||
label = lv_obj_get_child(btn, label);
|
||||
label = lv_obj_get_child_back(btn, label);
|
||||
if(label == NULL) break;
|
||||
}
|
||||
|
||||
@@ -386,11 +386,11 @@ lv_obj_t * lv_list_get_btn_img(const lv_obj_t * btn)
|
||||
LV_ASSERT_OBJ(btn, "lv_btn");
|
||||
|
||||
#if LV_USE_IMG != 0
|
||||
lv_obj_t * img = lv_obj_get_child(btn, NULL);
|
||||
lv_obj_t * img = lv_obj_get_child_back(btn, NULL);
|
||||
if(img == NULL) return NULL;
|
||||
|
||||
while(lv_list_is_list_img(img) == false) {
|
||||
img = lv_obj_get_child(btn, img);
|
||||
img = lv_obj_get_child_back(btn, img);
|
||||
if(img == NULL) break;
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ uint16_t lv_list_get_size(const lv_obj_t * list)
|
||||
lv_obj_t * btn = lv_list_get_next_btn(list, NULL);
|
||||
while(btn) {
|
||||
size++;
|
||||
btn = lv_list_get_next_btn(list, NULL);
|
||||
btn = lv_list_get_next_btn(list, btn);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ lv_obj_t * lv_msgbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
if(copy_ext->btnm) ext->btnm = lv_btnmatrix_create(mbox, copy_ext->btnm);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(mbox, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(mbox, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("message box created");
|
||||
|
||||
@@ -86,7 +86,7 @@ lv_obj_t * lv_objmask_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/* lv_objmask_ext_t * copy_ext = lv_obj_get_ext_attr(copy); */
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(objmask, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(objmask, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("object mask created");
|
||||
|
||||
@@ -118,6 +118,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Init the new page object*/
|
||||
if(copy == NULL) {
|
||||
ext->scrl = lv_cont_create(page, NULL);
|
||||
lv_obj_set_focus_parent(ext->scrl, true);
|
||||
lv_obj_set_drag(ext->scrl, true);
|
||||
lv_obj_set_drag_throw(ext->scrl, true);
|
||||
lv_obj_add_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
|
||||
@@ -131,6 +132,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_set_signal_cb(page, lv_page_signal);
|
||||
lv_obj_set_design_cb(page, lv_page_design);
|
||||
|
||||
|
||||
lv_page_set_scrollbar_mode(page, ext->scrlbar.mode);
|
||||
|
||||
lv_theme_apply(page, LV_THEME_PAGE);
|
||||
@@ -495,14 +497,14 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_
|
||||
lv_coord_t scrlable_y = lv_obj_get_y(ext->scrl);
|
||||
lv_coord_t page_h = lv_obj_get_height(page);
|
||||
|
||||
lv_coord_t top_err = -(scrlable_y + obj_y);
|
||||
lv_coord_t bot_err = scrlable_y + obj_y + obj_h - page_h;
|
||||
|
||||
lv_style_int_t bg_top = lv_obj_get_style_pad_top(page, LV_PAGE_PART_BG);
|
||||
lv_style_int_t bg_bottom = lv_obj_get_style_pad_bottom(page, LV_PAGE_PART_BG);
|
||||
lv_style_int_t scrl_top = lv_obj_get_style_pad_top(ext->scrl, LV_CONT_PART_MAIN);
|
||||
lv_style_int_t scrl_bottom = lv_obj_get_style_pad_bottom(ext->scrl, LV_CONT_PART_MAIN);
|
||||
|
||||
lv_coord_t top_err = -((scrlable_y + obj_y) - bg_top);
|
||||
lv_coord_t bot_err = scrlable_y + obj_y + obj_h - (page_h - bg_bottom);
|
||||
|
||||
/*Out of the page on the top*/
|
||||
if((obj_h <= page_h && top_err > 0) || (obj_h > page_h && top_err < bot_err)) {
|
||||
/*Calculate a new position and let some space above*/
|
||||
@@ -524,14 +526,14 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_
|
||||
lv_coord_t scrlable_x = lv_obj_get_x(ext->scrl);
|
||||
lv_coord_t page_w = lv_obj_get_width(page);
|
||||
|
||||
lv_coord_t left_err = -(scrlable_x + obj_x);
|
||||
lv_coord_t right_err = scrlable_x + obj_x + obj_w - page_w;
|
||||
|
||||
lv_style_int_t bg_left = lv_obj_get_style_pad_left(page, LV_PAGE_PART_BG);
|
||||
lv_style_int_t bg_right = lv_obj_get_style_pad_right(page, LV_PAGE_PART_BG);
|
||||
lv_style_int_t scrl_left = lv_obj_get_style_pad_top(ext->scrl, LV_CONT_PART_MAIN);
|
||||
lv_style_int_t scrl_right = lv_obj_get_style_pad_bottom(ext->scrl, LV_CONT_PART_MAIN);
|
||||
|
||||
lv_coord_t left_err = -((scrlable_x + obj_x) - bg_left);
|
||||
lv_coord_t right_err = scrlable_x + obj_x + obj_w - (page_w - bg_right);
|
||||
|
||||
/*Out of the page on the left*/
|
||||
if((obj_w <= page_w && left_err > 0) || (obj_w > page_w && left_err < right_err)) {
|
||||
/*Calculate a new position and let some space on the side*/
|
||||
@@ -1043,32 +1045,6 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
#if LV_USE_GROUP
|
||||
if(lv_obj_get_group(page)) {
|
||||
lv_group_focus_obj(page);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
res = lv_signal_send(page, LV_SIGNAL_FOCUS, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
res = lv_event_send(page, LV_EVENT_FOCUSED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
bool in_group = false;
|
||||
#if LV_USE_GROUP
|
||||
in_group = lv_obj_get_group(page) ? true : false;
|
||||
#endif
|
||||
if(in_group == false) {
|
||||
res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
res = lv_event_send(page, LV_EVENT_DEFOCUSED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
page_ext->scrl = NULL;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ enum {
|
||||
LV_SCROLLBAR_MODE_DRAG = 0x2, /**< Show scroll bars when page is being dragged*/
|
||||
LV_SCROLLBAR_MODE_AUTO = 0x3, /**< Show scroll bars when the scrollable container is large enough to be scrolled*/
|
||||
LV_SCROLLBAR_MODE_HIDE = 0x4, /**< Hide the scroll bar temporally*/
|
||||
LV_SCROLLBAR_MODE_UNHIDE = 0x5, /**< Unhide the previously hidden scroll bar. Recover original mode too*/
|
||||
LV_SCROLLBAR_MODE_UNHIDE = 0x8, /**< Unhide the previously hidden scroll bar. Recover original mode too*/
|
||||
};
|
||||
typedef uint8_t lv_scrollbar_mode_t;
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_set_signal_cb(scrl, lv_roller_scrl_signal);
|
||||
|
||||
lv_style_list_copy(&ext->style_sel, ©_ext->style_sel);
|
||||
lv_obj_refresh_style(roller, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(roller, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("roller created");
|
||||
@@ -585,10 +585,8 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
|
||||
/* Include the ancient signal function */
|
||||
if(sign != LV_SIGNAL_CONTROL) { /*Don't let the page to scroll on keys*/
|
||||
#if LV_USE_GROUP
|
||||
res = ancestor_signal(roller, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||
@@ -966,6 +964,18 @@ static void refr_width(lv_obj_t * roller)
|
||||
lv_style_int_t left = lv_obj_get_style_pad_left(roller, LV_ROLLER_PART_BG);
|
||||
lv_style_int_t right = lv_obj_get_style_pad_right(roller, LV_ROLLER_PART_BG);
|
||||
|
||||
const lv_font_t * base_font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG);
|
||||
const lv_font_t * sel_font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_SELECTED);
|
||||
|
||||
/*The selected text might be larger to get its size*/
|
||||
if(base_font != sel_font) {
|
||||
lv_coord_t letter_sp = lv_obj_get_style_text_letter_space(roller, LV_ROLLER_PART_SELECTED);
|
||||
lv_coord_t line_sp = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_SELECTED);
|
||||
lv_point_t p;
|
||||
_lv_txt_get_size(&p, lv_label_get_text(label), sel_font, letter_sp, line_sp, LV_COORD_MAX, LV_TXT_FLAG_NONE);
|
||||
if(label_w < p.x)label_w = p.x;
|
||||
}
|
||||
|
||||
lv_obj_set_width(roller, label_w + left + right);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_area_copy(&ext->left_knob_area, ©_ext->left_knob_area);
|
||||
lv_area_copy(&ext->right_knob_area, ©_ext->right_knob_area);
|
||||
|
||||
lv_obj_refresh_style(slider, LV_OBJ_PART_ALL);
|
||||
lv_obj_refresh_style(slider, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("slider created");
|
||||
|
||||
@@ -106,7 +106,7 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_spinbox_set_rollover(spinbox, copy_ext->rollover);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(spinbox, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(spinbox, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
lv_spinbox_updatevalue(spinbox);
|
||||
@@ -390,10 +390,8 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
|
||||
|
||||
/* Include the ancient signal function */
|
||||
if(sign != LV_SIGNAL_CONTROL) {
|
||||
#if LV_USE_GROUP
|
||||
res = ancestor_signal(spinbox, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
#endif
|
||||
}
|
||||
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ lv_obj_t * lv_spinner_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->time = copy_ext->time;
|
||||
ext->anim_dir = copy_ext->anim_dir;
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(spinner, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(spinner, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
lv_spinner_set_type(spinner, ext->anim_type);
|
||||
|
||||
@@ -100,7 +100,7 @@ lv_obj_t * lv_switch_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_switch_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
|
||||
lv_style_list_copy(&ext->style_knob, ©_ext->style_knob);
|
||||
lv_obj_refresh_style(sw, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(sw, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
|
||||
@@ -105,12 +105,12 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_table_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
for(i = 0; i < LV_TABLE_CELL_STYLE_CNT; i++) {
|
||||
lv_style_list_copy(&ext->cell_style[i], ©_ext->cell_style[i]);
|
||||
lv_table_set_row_cnt(table, copy_ext->row_cnt);
|
||||
lv_table_set_col_cnt(table, copy_ext->col_cnt);
|
||||
}
|
||||
lv_table_set_row_cnt(table, copy_ext->row_cnt);
|
||||
lv_table_set_col_cnt(table, copy_ext->col_cnt);
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
lv_obj_refresh_style(table, LV_STYLE_PROP_ALL);
|
||||
lv_obj_refresh_style(table, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL);
|
||||
}
|
||||
|
||||
LV_LOG_INFO("table created");
|
||||
@@ -192,6 +192,16 @@ void lv_table_set_row_cnt(lv_obj_t * table, uint16_t row_cnt)
|
||||
uint16_t old_row_cnt = ext->row_cnt;
|
||||
ext->row_cnt = row_cnt;
|
||||
|
||||
if(ext->row_cnt > 0) {
|
||||
ext->row_h = lv_mem_realloc(ext->row_h, ext->row_cnt * sizeof(ext->row_h[0]));
|
||||
LV_ASSERT_MEM(ext->row_h);
|
||||
if(ext->row_h == NULL) return;
|
||||
}
|
||||
else {
|
||||
lv_mem_free(ext->row_h);
|
||||
ext->row_h = NULL;
|
||||
}
|
||||
|
||||
if(ext->row_cnt > 0 && ext->col_cnt > 0) {
|
||||
ext->cell_data = lv_mem_realloc(ext->cell_data, ext->row_cnt * ext->col_cnt * sizeof(char *));
|
||||
LV_ASSERT_MEM(ext->cell_data);
|
||||
@@ -203,10 +213,6 @@ void lv_table_set_row_cnt(lv_obj_t * table, uint16_t row_cnt)
|
||||
uint32_t new_cell_cnt = ext->col_cnt * ext->row_cnt;
|
||||
_lv_memset_00(&ext->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0]));
|
||||
}
|
||||
|
||||
ext->row_h = lv_mem_realloc(ext->row_h, ext->row_cnt * sizeof(ext->row_h[0]));
|
||||
LV_ASSERT_MEM(ext->cell_data);
|
||||
if(ext->cell_data == NULL) return;
|
||||
}
|
||||
else {
|
||||
lv_mem_free(ext->cell_data);
|
||||
@@ -968,10 +974,15 @@ static lv_style_list_t * lv_table_get_style(lv_obj_t * table, uint8_t part)
|
||||
|
||||
static void refr_size(lv_obj_t * table)
|
||||
{
|
||||
|
||||
lv_coord_t h = 0;
|
||||
lv_coord_t w = 0;
|
||||
|
||||
lv_table_ext_t * ext = lv_obj_get_ext_attr(table);
|
||||
if(ext->row_cnt == 0 || ext->col_cnt == 0) {
|
||||
lv_obj_set_size(table, w, h);
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t i;
|
||||
for(i = 0; i < ext->col_cnt; i++) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user