Compare commits
250 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
acb46aaed1 | ||
|
|
7caa2bf9ad | ||
|
|
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 | ||
|
|
0aa4591021 | ||
|
|
c85295b5ea | ||
|
|
28213adfa6 | ||
|
|
25b0b994a0 | ||
|
|
2b60f4496f | ||
|
|
1d714bfed7 | ||
|
|
b7d7bf7dd5 | ||
|
|
373af97472 | ||
|
|
3e9495a074 | ||
|
|
1072b71ea0 | ||
|
|
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 | ||
|
|
57079452b0 | ||
|
|
960bca7807 | ||
|
|
67400d1d72 | ||
|
|
ecfef570ea | ||
|
|
75875e244d | ||
|
|
1db33435c1 | ||
|
|
2d984da893 | ||
|
|
5b062a0d8d | ||
|
|
c0a7cf76b9 | ||
|
|
44e57aaaf5 | ||
|
|
d06fe5100e | ||
|
|
ae94302f4d | ||
|
|
b26b4435a5 | ||
|
|
da9a5f58d0 | ||
|
|
a4774ccc72 | ||
|
|
a6289f5e85 | ||
|
|
dd56e9a013 | ||
|
|
e31993bdf2 | ||
|
|
6dac633235 | ||
|
|
1d5300e02f | ||
|
|
b646365e2c | ||
|
|
798f3177f2 | ||
|
|
0921cf6e3b | ||
|
|
ac5f1998e4 | ||
|
|
433435889a | ||
|
|
a66afca68e | ||
|
|
b1213dcc59 | ||
|
|
f8c8c4040a | ||
|
|
2f33670b4f | ||
|
|
d8e10c41cf | ||
|
|
7e38ac68e3 | ||
|
|
abff805509 | ||
|
|
18072b3dd4 | ||
|
|
4640611758 | ||
|
|
baeda1998f | ||
|
|
e1a09551ce | ||
|
|
ba7a86de74 | ||
|
|
6cb79914a8 | ||
|
|
f1f0aa621a | ||
|
|
43a77d8699 | ||
|
|
58b88bf1fb | ||
|
|
96bc397821 | ||
|
|
fd508065dd | ||
|
|
416ef9e251 | ||
|
|
09250d0a92 | ||
|
|
822e06be39 | ||
|
|
c07ef75ac5 | ||
|
|
2a6f5d46ab | ||
|
|
e3f6a3327d | ||
|
|
6227aaee96 | ||
|
|
08591a8e8c | ||
|
|
106e023c80 | ||
|
|
a5de71933b | ||
|
|
e85888908a | ||
|
|
1a3b6d4cb3 | ||
|
|
e587ceb22e | ||
|
|
b769463d39 | ||
|
|
cbc88285d3 | ||
|
|
ec64820272 | ||
|
|
15b7ea6614 | ||
|
|
843555a4b1 | ||
|
|
5f4c26cb79 | ||
|
|
019042297d | ||
|
|
46a4469a9c | ||
|
|
646cb71a9d | ||
|
|
ad262172de | ||
|
|
343b70b19c | ||
|
|
b802e7e775 | ||
|
|
2cecd01b30 | ||
|
|
2ba1fc625f | ||
|
|
aff7a22ac5 | ||
|
|
5a23fd569b | ||
|
|
234e74202c | ||
|
|
914c874ada | ||
|
|
a6793b2695 | ||
|
|
45bf6a3862 | ||
|
|
f00a6a118d | ||
|
|
c599a59f05 | ||
|
|
c97a0684cf | ||
|
|
418413e334 | ||
|
|
815e0afdaf | ||
|
|
faf56680f8 | ||
|
|
b2d78dcca7 | ||
|
|
38e68eeb7a | ||
|
|
0f69cbf087 | ||
|
|
039080fc26 | ||
|
|
7e9cf858d6 | ||
|
|
a740af4afb | ||
|
|
a117b3cead | ||
|
|
e178bcc9f3 | ||
|
|
41c4c25315 | ||
|
|
4396196889 | ||
|
|
f3f1c606b6 | ||
|
|
25607ceaee | ||
|
|
989016dff3 | ||
|
|
c54788fae4 | ||
|
|
c7fb2ad12c | ||
|
|
2fdeaf5599 | ||
|
|
b539e6dc46 | ||
|
|
06603a9c84 | ||
|
|
6b45f3ade5 | ||
|
|
c4e7d7cb83 | ||
|
|
43b69a88a9 | ||
|
|
ddbeb212b7 | ||
|
|
40daa7195d | ||
|
|
2d7423100a | ||
|
|
6971d603d2 | ||
|
|
aad9f4f0c1 | ||
|
|
76625adec2 | ||
|
|
8b3f9f19f6 | ||
|
|
97f999ed9f | ||
|
|
e678a2c599 | ||
|
|
91f64c8662 | ||
|
|
eb006b3d39 | ||
|
|
f10f94bea3 | ||
|
|
710226c6db | ||
|
|
44a96df9fb | ||
|
|
cd788da47a | ||
|
|
c4eec78a02 | ||
|
|
1e33359d0c | ||
|
|
cf8357e004 | ||
|
|
8f243c01d5 | ||
|
|
e2aa68394c | ||
|
|
2828582c7a | ||
|
|
f6a2c635fd | ||
|
|
db24bf1d18 | ||
|
|
8c151a2d43 | ||
|
|
0d0427f8bc | ||
|
|
201d38c574 | ||
|
|
4345e05e32 | ||
|
|
24b1a7735a | ||
|
|
b16f3ff8e7 | ||
|
|
6b3d7759cc | ||
|
|
765b6c4015 | ||
|
|
6ae7f67ef5 | ||
|
|
156a3c005d | ||
|
|
a39f51a571 | ||
|
|
d050c99161 | ||
|
|
1523cc0634 | ||
|
|
65d029279b | ||
|
|
4a953b9d9d | ||
|
|
ae748cfffa | ||
|
|
ad215c5b4b | ||
|
|
2dd84e6de1 | ||
|
|
05d249d5ee | ||
|
|
f746ac8542 | ||
|
|
832dbd644b | ||
|
|
fe5663908c | ||
|
|
f23873e3f5 |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -1 +1 @@
|
||||
custom: ["https://littlevgl.com/donate"]
|
||||
custom: ["https://www.paypal.com/paypalme/my/profile"]
|
||||
|
||||
12
.github/auto-comment.yml
vendored
Normal file
12
.github/auto-comment.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# Comment to a new issue.
|
||||
pullRequestOpened: |
|
||||
Thank you for raising your pull request.
|
||||
|
||||
To ensure that all licensing criteria is met all repositories of the LVGL project apply a process called DCO (Developer's Certificate of Origin).
|
||||
|
||||
The text of DCO can be read here: https://developercertificate.org/
|
||||
For a more detailed description see the [Documentation](https://docs.lvgl.io/latest/en/html/contributing/index.html#developer-certification-of-origin-dco) site.
|
||||
|
||||
By contributing to any repositories of the LVGL project you state that your contribution corresponds with the DCO.
|
||||
|
||||
No further action is required if your contribution fulfills the DCO. If you are not sure about it feel free to ask us in a comment.
|
||||
61
CHANGELOG.md
61
CHANGELOG.md
@@ -1,8 +1,63 @@
|
||||
# Changelog
|
||||
|
||||
## v7.1.0 (planned on 07.07.2020)
|
||||
## v7.4.0 (planned on 01.09.2020)
|
||||
*Available in the `dev` branch*
|
||||
|
||||
## v7.3.1 (planned on 18.08.2020)
|
||||
*Available in the `master` branch*
|
||||
|
||||
## 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`, `LV_FONT_USE_SUBPX`, `LV_USE_OUTLINE`, `LV_USE_PATTERN`, `LV_USE_VALUE_STR` and applying some optimization
|
||||
- Add `LV_MEMCPY_MEMSET_STD` to use standard `memcpy` and `memset`
|
||||
|
||||
|
||||
### Bugfixes
|
||||
- Do not print warning for missing glyph if its height OR width is zero.
|
||||
- Prevent duplicated sending of `LV_EVENT_INSERT` from text area
|
||||
- Tidy outer edges of cpicker widget.
|
||||
- Remove duplicated lines from `lv_tabview_add_tab`
|
||||
- btnmatrix: hadle combined states of buttons (e.g. chacked + disabled)
|
||||
- textarea: fix typo in lv_textarea_set_sscrollbar_mode
|
||||
- gauge: fix image needle drawing
|
||||
- fix using freed memory in _lv_style_list_remove_style
|
||||
|
||||
|
||||
## v7.2.0 (21.07.2020)
|
||||
|
||||
### New features
|
||||
- Add screen transitions with `lv_scr_load_anim()`
|
||||
- Add display background color, wallpaper and opacity. Shown when the screen is transparent. Can be used with `lv_disp_set_bg_opa/color/image()`.
|
||||
- Add `LV_CALENDAR_WEEK_STARTS_MONDAY`
|
||||
- Add `lv_chart_set_x_start_point()` function - Set the index of the x-axis start point in the data array
|
||||
- Add `lv_chart_set_ext_array()` function - Set an external array of data points to use for the chart
|
||||
- Add `lv_chart_set_point_id()` function - Set an individual point value in the chart series directly based on index
|
||||
- Add `lv_chart_get_x_start_point()` function - Get the current index of the x-axis start point in the data array
|
||||
- Add `lv_chart_get_point_id()` function - Get an individual point value in the chart series directly based on index
|
||||
- Add `ext_buf_assigned` bit field to `lv_chart_series_t` structure - it's true if external buffer is assigned to series
|
||||
- Add `lv_chart_set_series_axis()` to assign series to primary or secondary axis
|
||||
- Add `lv_chart_set_y_range()` to allow setting range of secondary y axis (based on `lv_chart_set_range` but extended with an axis parameter)
|
||||
- Allow setting different font for the selected text in `lv_roller`
|
||||
- Add `theme->apply_cb` to replace `theme->apply_xcb` to make it compatible with the MicroPython binding
|
||||
- Add `lv_theme_set_base()` to allow easy extension of built-in (or any) themes
|
||||
- Add `lv_obj_align_x()` and `lv_obj_align_y()` functions
|
||||
- Add `lv_obj_align_origo_x()` and `lv_obj_align_origo_y()` functions
|
||||
|
||||
### Bugfixes
|
||||
- `tileview` fix navigation when not screen sized
|
||||
- Use 14px font by default to for better compatibility with smaller displays
|
||||
- `linemeter` fix conversation of current value to "level"
|
||||
- Fix drawing on right border
|
||||
- Set the cursor image non clickable by default
|
||||
- Improve mono theme when used with keyboard or encoder
|
||||
|
||||
## v7.1.0 (07.07.2020)
|
||||
|
||||
### New features
|
||||
- Add `focus_parent` attribute to `lv_obj`
|
||||
- Allow using buttons in encoder input device
|
||||
@@ -11,11 +66,15 @@
|
||||
- Added `max_used` propriety to `lv_mem_monitor_t` struct
|
||||
- In `lv_init` test if the the strings are UTF-8 encoded.
|
||||
- Add `user_data` to themes
|
||||
- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems.
|
||||
- Add inline function lv_checkbox_get_state(const lv_obj_t * cb) to extend the checkbox functionality.
|
||||
- Add inline function lv_checkbox_set_state(const lv_obj_t * cb, lv_btn_state_t state ) to extend the checkbox functionality.
|
||||
|
||||
### Bugfixes
|
||||
- `lv_img` fix invalidation area when angle or zoom changes
|
||||
- Update the style handling to support Big endian MCUs
|
||||
- Change some methods to support big endian hardware.
|
||||
- remove use of c++ keyword 'new' in parameter of function lv_theme_set_base().
|
||||
- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems.
|
||||
- Fix inserting chars in text area in big endian hardware.
|
||||
|
||||
|
||||
110
README.md
110
README.md
@@ -1,8 +1,4 @@
|
||||
<h1 align="center"> LVGL - Light and Versatile Graphics Library</h1>
|
||||
<p align="center">
|
||||
<a href="https://github.com/lvgl/lvgl/blob/master/LICENCE.txt"><img src="https://img.shields.io/badge/licence-MIT-blue.svg"></a>
|
||||
<a href="https://github.com/lvgl/lvgl/releases/tag/v7.0.0"><img src="https://img.shields.io/badge/version-7.0.0-blue.svg"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://lvgl.io/assets/images/img_1.png">
|
||||
@@ -16,65 +12,107 @@ LVGL provides everything you need to create embedded GUI with easy-to-use graphi
|
||||
<a href="https://lvgl.io">Website </a> ·
|
||||
<a href="https://lvgl.io/demos">Online demo</a> ·
|
||||
<a href="https://docs.lvgl.io/">Docs</a> ·
|
||||
<a href="https://forum.lvgl.io">Forum</a> ·
|
||||
<a href="https://forum.lvgl.io">Forum</a>
|
||||
</h4>
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
* Powerful building blocks: buttons, charts, lists, sliders, images, etc.
|
||||
* Powerful [building blocks](https://docs.lvgl.io/latest/en/html/widgets/index.html): buttons, charts, lists, sliders, images, etc.
|
||||
* Advanced graphics: animations, anti-aliasing, opacity, smooth scrolling
|
||||
* Simultaneously use various input devices: touchscreen, mouse, keyboard, encoder, buttons, etc.
|
||||
* Simultaneously use multiple displays: e.g. monochrome and color display
|
||||
* Multi-language support with UTF-8 encoding, Bidirectional support, and Arabic text handling
|
||||
* Fully customizable graphical elements via CSS-like styles
|
||||
* Use [various input devices](https://docs.lvgl.io/latest/en/html/overview/indev.html): touchscreen, mouse, keyboard, encoder, buttons, etc.
|
||||
* Use [multiple displays](https://docs.lvgl.io/latest/en/html/overview/display.html): e.g. monochrome and color display
|
||||
* Hardware independent to use with any microcontroller or display
|
||||
* Scalable to operate with little memory (64 kB Flash, 10 kB RAM)
|
||||
* Multi-language support with UTF-8 handling, Bidirectional and Arabic script support
|
||||
* Fully customizable graphical elements via [CSS-like styles](https://docs.lvgl.io/latest/en/html/overview/style.html)
|
||||
* OS, External memory and GPU are supported but not required
|
||||
* Single frame buffer operation even with advances graphical effects
|
||||
* Smooth rendering even with a [single frame buffer](https://docs.lvgl.io/latest/en/html/porting/display.html)
|
||||
* Written in C for maximal compatibility (C++ compatible)
|
||||
* Micropython Binding exposes [LVGL API in Micropython](https://blog.lvgl.io/2019-02-20/micropython-bindings)
|
||||
* Simulator to develop on PC without embedded hardware
|
||||
* Tutorials, examples, themes for rapid development
|
||||
* Documentation and API references
|
||||
* [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) to develop on PC without embedded hardware
|
||||
* [Examples](lv_examples) and tutorials for rapid development
|
||||
* [Documentation](http://docs.lvgl.io/) and API references
|
||||
|
||||
## Supported devices
|
||||
## Requirements
|
||||
Basically, every modern controller (which is able to drive a display) is suitable to run LVGL. The minimal requirements are:
|
||||
- 16, 32 or 64 bit microcontroller or processor
|
||||
- > 16 MHz clock speed is recommended
|
||||
- Flash/ROM: > 64 kB for the very essential components (> 180 kB is recommended)
|
||||
- RAM:
|
||||
- Static RAM usage: ~2 kB depending on the used features and objects types
|
||||
- Stack: > 2kB (> 8 kB is recommended)
|
||||
- Dynamic data (heap): > 2 KB (> 16 kB is recommended if using several objects).
|
||||
Set by `LV_MEM_SIZE` in *lv_conf.h*.
|
||||
- Display buffer: > *"Horizontal resolution"* pixels (> 10 × *"Horizontal resolution"* is recommended)
|
||||
- C99 or newer compiler
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td> <strong>Name</strong> </td>
|
||||
<td><strong>Minimal</strong></td>
|
||||
<td><strong>Recommended</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Architecture</strong></td>
|
||||
<td colspan="2">16, 32 or 64 bit microcontroller or processor</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <strong>Clock</strong></td>
|
||||
<td> > 16 MHz </td>
|
||||
<td> > 48 MHz</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <strong>Flash/ROM</strong></td>
|
||||
<td> > 64 kB </td>
|
||||
<td> > 180 kB</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <strong>Static RAM</strong></td>
|
||||
<td> > 2 kB </td>
|
||||
<td> > 4 kB</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <strong>Stack</strong></td>
|
||||
<td> > 2 kB </td>
|
||||
<td> > 8 kB</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <strong>Heap</strong></td>
|
||||
<td> > 2 kB </td>
|
||||
<td> > 8 kB</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <strong>Display buffer</strong></td>
|
||||
<td> > 1 × <em>hor. res.</em> pixels </td>
|
||||
<td> > 10 × <em>hor. res.</em> pixels </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <strong>Compiler</strong></td>
|
||||
<td colspan="2"> C99 or newer </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
*Note that the memory usage might vary depending on the architecture, compiler and build options.*
|
||||
|
||||
Just to mention some platforms:
|
||||
- STM32F1, STM32F3, [STM32F4](https://blog.lvgl.io/2017-07-15/stm32f429_disco_port), [STM32F7](https://github.com/lvgl/lv_port_stm32f746_disco_sw4stm32), STM32L4
|
||||
- STM32F1, STM32F3, STM32F4, STM32F7, STM32L4, STM32L5, STM32H7
|
||||
- Microchip dsPIC33, PIC24, PIC32MX, PIC32MZ
|
||||
- NXP: Kinetis, LPC, iMX, iMX RT
|
||||
- [Linux frame buffer](https://blog.lvgl.io/2018-01-03/linux_fb) (/dev/fb)
|
||||
- [Raspberry PI](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl)
|
||||
- [Raspberry Pi](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl)
|
||||
- [Espressif ESP32](https://github.com/lvgl/lv_port_esp32)
|
||||
- [Infineon aurix](https://github.com/lvgl/lv_port_aurix)
|
||||
- Nordic NRF52
|
||||
- Quectell M66
|
||||
- [Infineon Aurix](https://github.com/lvgl/lv_port_aurix)
|
||||
- Nordic NRF52 Bluetooth modules
|
||||
- Quectel modems
|
||||
|
||||
## Get started
|
||||
his list shows the recommended way of learning the library:
|
||||
This list shows the recommended way of learning the library:
|
||||
1. Check the [Online demos](https://lvgl.io/demos) to see LVGL in action (3 minutes)
|
||||
2. Read the [Introduction](https://docs.lvgl.io/latest/en/html/intro/index.html) page of the documentation (5 minutes)
|
||||
3. Read the [Quick overview](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html) page of the documentation (15 minutes)
|
||||
3. Get familiar with the basics on the [Quick overview](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html) page (15 minutes)
|
||||
4. Set up a [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) (10 minutes)
|
||||
5. Try out some [Examples](https://github.com/lvgl/lv_examples/)
|
||||
6. Port LVGL to a board. See the [Porting](https://docs.lvgl.io/latest/en/html/porting/index.html) guide or check the ready to use [Projects](https://github.com/lvgl?q=lv_port_&type=&language=)
|
||||
7. Read the [Overview](https://docs.lvgl.io/latest/en/html/overview/index.html) page to get a better understanding of the library. (2-3 hours)
|
||||
7. Read the [Overview](https://docs.lvgl.io/latest/en/html/overview/index.html) page to get a better understanding of the library (2-3 hours)
|
||||
8. Check the documentation of the [Widgets](https://docs.lvgl.io/latest/en/html/widgets/index.html) to see their features and usage
|
||||
9. If you have questions got to the [Forum](http://forum.lvgl.io/)
|
||||
9. If you have questions go to the [Forum](http://forum.lvgl.io/)
|
||||
10. Read the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) guide to see how you can help to improve LVGL (15 minutes)
|
||||
|
||||
## Examples
|
||||
@@ -103,7 +141,7 @@ void btn_event_cb(lv_obj_t * btn, lv_event_t event)
|
||||

|
||||
|
||||
### LVGL from Micropython
|
||||
Learn more about [Micropython](https://docs.lvgl.io/en/html/get-started/micropython).
|
||||
Learn more about [Micropython](https://docs.lvgl.io/latest/en/html/get-started/micropython.html).
|
||||
```python
|
||||
# Create a Button and a Label
|
||||
scr = lv.obj()
|
||||
@@ -117,4 +155,6 @@ lv.scr_load(scr)
|
||||
```
|
||||
|
||||
## Contributing
|
||||
LVGL is an open project and contribution is very welcome. There are many ways to contribute from simply speaking about your project, through writing examples, improving the documentation, fixing bugs to hosing your own project under in LVGL.
|
||||
|
||||
For a detailed description of contribution opportunities visit the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) section of the documentation.
|
||||
|
||||
34
docs/ROADMAP.md
Normal file
34
docs/ROADMAP.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Roadmap
|
||||
|
||||
This is a summary for thenew fatures of the major releases and a collection of ideas.
|
||||
|
||||
This list indicates only the current intention and can be changed.
|
||||
|
||||
## v8
|
||||
Planned to September/October 2020
|
||||
- New scrolling:
|
||||
- See [feat/new-scroll](https://github.com/lvgl/lvgl/tree/feat/new-scroll) branch and [#1614](https://github.com/lvgl/lvgl/issues/1614)) issue.
|
||||
- Remove `lv_page` and support scrolling on `lv_obj`
|
||||
- Support "elastic" scrolling when scrolled in
|
||||
- Support scroll chaining among any objects types (not only `lv_pages`s)
|
||||
- Remove `lv_drag`. Similar effect can be achieved by setting the position in `LV_EVENT_PRESSING`
|
||||
- Add snapping?
|
||||
- Already working
|
||||
- New layouts:
|
||||
- See [#1615](https://github.com/lvgl/lvgl/issues/1615) issue
|
||||
- [CSS Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)-like layout support
|
||||
- Besides setting width/height in `px` add support to `partent percentage` and `screen percentage`.
|
||||
- Work in progress
|
||||
- Simplified File system interface ([feat/new_fs_api](https://github.com/lvgl/lvgl/tree/feat/new-fs-api) branch) to make porting easier
|
||||
- Work in progress
|
||||
- Add new label alignment modes
|
||||
- See [#1656](https://github.com/lvgl/lvgl/issues/1656)
|
||||
|
||||
## Ideas
|
||||
- Unit testing (gtest?). See [#1658](https://github.com/lvgl/lvgl/issues/1658)
|
||||
- Benchmarking (gem5?). See [#1660](https://github.com/lvgl/lvgl/issues/1660)
|
||||
- CPP binding. See [Forum](https://forum.lvgl.io/t/is-it-possible-to-officially-support-optional-cpp-api/2736)
|
||||
- Optmize font decompression
|
||||
- Switch to RGBA colors in styles
|
||||
- Need coverage report for tests
|
||||
- Need static analize (via coverity.io or somehing else).
|
||||
27
library.json
27
library.json
@@ -1,14 +1,17 @@
|
||||
{
|
||||
"name": "lvgl",
|
||||
"version": "v7.1.0",
|
||||
"keywords": "graphics, gui, embedded, littlevgl",
|
||||
"description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.",
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/lvgl/lvgl.git"
|
||||
},
|
||||
"build": {
|
||||
"includeDir": "."
|
||||
}
|
||||
"name": "lvgl",
|
||||
"version": "7.3.0",
|
||||
"keywords": "graphics, gui, embedded, tft, lvgl",
|
||||
"description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/lvgl/lvgl.git"
|
||||
},
|
||||
"build": {
|
||||
"includeDir": "."
|
||||
},
|
||||
"license": "MIT",
|
||||
"homepage": "https://lvgl.io",
|
||||
"frameworks": "*",
|
||||
"platforms": "*"
|
||||
}
|
||||
|
||||
10
library.properties
Normal file
10
library.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
name=lvgl
|
||||
version=7.3.0
|
||||
author=kisvegabor
|
||||
maintainer=kisvegabor,embeddedt,pete-pjb
|
||||
sentence=Full-featured Graphics Library for Embedded Systems
|
||||
paragraph=Powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash).
|
||||
category=Display
|
||||
url=https://lvgl.io
|
||||
architectures=*
|
||||
includes=lvgl.h
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file lv_conf.h
|
||||
* Configuration file for LVGL v7.1.0
|
||||
* Configuration file for LVGL v7.3.0
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -97,6 +97,10 @@ typedef int16_t lv_coord_t;
|
||||
# define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
|
||||
#endif /*LV_MEM_CUSTOM*/
|
||||
|
||||
/* Use the standard memcpy and memset instead of LVGL's own functions.
|
||||
* The standard functions might or might not be faster depending on their implementation. */
|
||||
#define LV_MEMCPY_MEMSET_STD 0
|
||||
|
||||
/* Garbage Collector settings
|
||||
* Used if lvgl is binded to higher level language and the memory is managed by that language */
|
||||
#define LV_ENABLE_GC 0
|
||||
@@ -150,7 +154,7 @@ typedef void * lv_anim_user_data_t;
|
||||
|
||||
#endif
|
||||
|
||||
/* 1: Enable shadow drawing*/
|
||||
/* 1: Enable shadow drawing on rectangles*/
|
||||
#define LV_USE_SHADOW 1
|
||||
#if LV_USE_SHADOW
|
||||
/* Allow buffering some shadow calculation
|
||||
@@ -160,6 +164,15 @@ typedef void * lv_anim_user_data_t;
|
||||
#define LV_SHADOW_CACHE_SIZE 0
|
||||
#endif
|
||||
|
||||
/*1: enable outline drawing on rectangles*/
|
||||
#define LV_USE_OUTLINE 1
|
||||
|
||||
/*1: enable pattern drawing on rectangles*/
|
||||
#define LV_USE_PATTERN 1
|
||||
|
||||
/*1: enable value string drawing on rectangles*/
|
||||
#define LV_USE_VALUE_STR 1
|
||||
|
||||
/* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`)*/
|
||||
#define LV_USE_BLEND_MODES 1
|
||||
|
||||
@@ -197,6 +210,7 @@ typedef void * lv_fs_drv_user_data_t;
|
||||
|
||||
/*1: Use the functions and types from the older API if possible */
|
||||
#define LV_USE_API_EXTENSION_V6 1
|
||||
#define LV_USE_API_EXTENSION_V7 1
|
||||
|
||||
/*========================
|
||||
* Image decoder and cache
|
||||
@@ -348,8 +362,8 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
|
||||
/* Montserrat fonts with bpp = 4
|
||||
* https://fonts.google.com/specimen/Montserrat */
|
||||
#define LV_FONT_MONTSERRAT_12 0
|
||||
#define LV_FONT_MONTSERRAT_14 0
|
||||
#define LV_FONT_MONTSERRAT_16 1
|
||||
#define LV_FONT_MONTSERRAT_14 1
|
||||
#define LV_FONT_MONTSERRAT_16 0
|
||||
#define LV_FONT_MONTSERRAT_18 0
|
||||
#define LV_FONT_MONTSERRAT_20 0
|
||||
#define LV_FONT_MONTSERRAT_22 0
|
||||
@@ -390,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;
|
||||
@@ -416,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.
|
||||
@@ -431,10 +457,10 @@ typedef void * lv_font_user_data_t;
|
||||
#define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0x01a2b1)
|
||||
#define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0x44d1b6)
|
||||
#define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT
|
||||
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16
|
||||
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16
|
||||
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_16
|
||||
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_16
|
||||
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_14
|
||||
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_14
|
||||
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_14
|
||||
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_14
|
||||
|
||||
/*=================
|
||||
* Text settings
|
||||
@@ -540,6 +566,9 @@ typedef void * lv_obj_user_data_t;
|
||||
|
||||
/*Calendar (dependencies: -)*/
|
||||
#define LV_USE_CALENDAR 1
|
||||
#if LV_USE_CALENDAR
|
||||
# define LV_CALENDAR_WEEK_STARTS_MONDAY 0
|
||||
#endif
|
||||
|
||||
/*Canvas (dependencies: lv_img)*/
|
||||
#define LV_USE_CANVAS 1
|
||||
|
||||
8
lvgl.h
8
lvgl.h
@@ -2,7 +2,7 @@
|
||||
* @file lvgl.h
|
||||
* Include all LittleV GL related headers
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LVGL_H
|
||||
#define LVGL_H
|
||||
|
||||
@@ -77,9 +77,9 @@ extern "C" {
|
||||
*********************/
|
||||
/*Current version of LVGL*/
|
||||
#define LVGL_VERSION_MAJOR 7
|
||||
#define LVGL_VERSION_MINOR 1
|
||||
#define LVGL_VERSION_PATCH 0
|
||||
#define LVGL_VERSION_INFO ""
|
||||
#define LVGL_VERSION_MINOR 3
|
||||
#define LVGL_VERSION_PATCH 1
|
||||
#define LVGL_VERSION_INFO "dev"
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
||||
318
scripts/release.py
Normal file → Executable file
318
scripts/release.py
Normal file → Executable file
@@ -1,227 +1,233 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import re
|
||||
import os
|
||||
lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+')
|
||||
|
||||
|
||||
def title(t):
|
||||
print("\n---------------------------------")
|
||||
print(t)
|
||||
print("---------------------------------")
|
||||
print("\n---------------------------------")
|
||||
print(t)
|
||||
print("---------------------------------")
|
||||
|
||||
|
||||
def cmd(c):
|
||||
print("\n" + c)
|
||||
r = os.system(c)
|
||||
print("\n" + c)
|
||||
r = os.system(c)
|
||||
if r:
|
||||
print("Exit due to previous error")
|
||||
exit(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")
|
||||
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")
|
||||
cmd("git ci -am 'Run code formatter'")
|
||||
os.system("git ci -am 'Run code formatter'")
|
||||
os.chdir("..")
|
||||
|
||||
def lvgl_update_version():
|
||||
title("lvgl: Update version number")
|
||||
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)
|
||||
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()
|
||||
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()
|
||||
f = open("./lvgl.h", "w")
|
||||
|
||||
f.write(outbuf)
|
||||
f.close()
|
||||
|
||||
s = "v" + str(major_ver) + "." + str(minor_ver) + "." + str(patch_ver)
|
||||
print("New version:" + s)
|
||||
return s
|
||||
s = "v" + str(major_ver) + "." + str(minor_ver) + "." + str(patch_ver)
|
||||
print("New version:" + s)
|
||||
return s
|
||||
|
||||
|
||||
|
||||
def lvgl_update_library_json(v):
|
||||
title("lvgl: Update version number in library.json")
|
||||
title("lvgl: Update version number in library.json")
|
||||
|
||||
f = open("./library.json", "r")
|
||||
|
||||
outbuf = ""
|
||||
|
||||
for i in f.read().splitlines():
|
||||
r = re.search(r'"version": ', i)
|
||||
if r:
|
||||
i = ' "version": "' + v + '",'
|
||||
|
||||
outbuf += i + '\n'
|
||||
|
||||
f.close()
|
||||
f = open("./library.json", "r")
|
||||
vn = v[1:]
|
||||
outbuf = ""
|
||||
|
||||
for i in f.read().splitlines():
|
||||
r = re.search(r'"version": ', i)
|
||||
if r:
|
||||
i = ' "version": "' + vn + '",'
|
||||
|
||||
outbuf += i + '\n'
|
||||
|
||||
f.close()
|
||||
|
||||
f = open("./library.json", "w")
|
||||
|
||||
f.write(outbuf)
|
||||
f.close()
|
||||
f = open("./library.json", "w")
|
||||
|
||||
f.write(outbuf)
|
||||
f.close()
|
||||
|
||||
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 ")
|
||||
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 ")
|
||||
|
||||
|
||||
def lvgl_commit_push(v):
|
||||
title("lvgl: commit and push release")
|
||||
title("lvgl: commit and push release")
|
||||
|
||||
cmd('git ci -am "Release ' + v + '"')
|
||||
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
|
||||
cmd('git push origin master')
|
||||
cmd('git push origin ' + v)
|
||||
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 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("../")
|
||||
|
||||
|
||||
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")
|
||||
title("lvgl: Update API with Doxygen")
|
||||
|
||||
cmd("cd scripts; doxygen");
|
||||
cmd("cd scripts; doxygen");
|
||||
|
||||
|
||||
def examples_clone():
|
||||
title("examples: Clone")
|
||||
cmd("git clone https://github.com/lvgl/lv_examples.git")
|
||||
os.chdir("./lv_examples")
|
||||
cmd("git co master")
|
||||
title("examples: Clone")
|
||||
cmd("git clone https://github.com/lvgl/lv_examples.git")
|
||||
os.chdir("./lv_examples")
|
||||
cmd("git co master")
|
||||
|
||||
def examples_commit_push(v):
|
||||
title("examples: commit and push release")
|
||||
title("examples: commit and push release")
|
||||
|
||||
cmd('git ci -am "Release ' + v + '"')
|
||||
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
|
||||
cmd('git push origin master')
|
||||
cmd('git push origin ' + v)
|
||||
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 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("../")
|
||||
|
||||
|
||||
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")
|
||||
title("drivers: Clone")
|
||||
cmd("git clone https://github.com/lvgl/lv_drivers.git")
|
||||
os.chdir("./lv_drivers")
|
||||
cmd("git co master")
|
||||
|
||||
def drivers_commit_push(v):
|
||||
title("drivers: commit and push release")
|
||||
title("drivers: commit and push release")
|
||||
|
||||
cmd('git ci -am "Release ' + v + '"')
|
||||
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
|
||||
cmd('git push origin master')
|
||||
cmd('git push origin ' + v)
|
||||
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("../")
|
||||
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")
|
||||
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"')
|
||||
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")
|
||||
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 + "'"
|
||||
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()
|
||||
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 '"')
|
||||
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_update_trans():
|
||||
title("docs: Update translations")
|
||||
cmd("cd en && ./trans_push.py && ./trans_pull.py")
|
||||
|
||||
def docs_merge_to_release_branch(v):
|
||||
title("docs: merge to release branch")
|
||||
cmd('git co release/v7 --')
|
||||
cmd('git clean -fd .')
|
||||
cmd('rm -f LVGL.pdf') #To avoide possible merge conflict
|
||||
cmd('git merge latest')
|
||||
cmd('git push origin release/v7')
|
||||
|
||||
def docs_build():
|
||||
title("docs: Build")
|
||||
cmd("git checkout master")
|
||||
cmd("./update.py latest")
|
||||
|
||||
title("docs: Build")
|
||||
cmd("git checkout master")
|
||||
cmd("./update.py latest release/v7")
|
||||
|
||||
def clean_up():
|
||||
title("Clean up repos")
|
||||
os.chdir("../..")
|
||||
cmd("rm -rf lvgl docs lv_examples lv_drivers")
|
||||
title("Clean up repos")
|
||||
os.chdir("../")
|
||||
cmd("rm -rf lvgl docs lv_examples lv_drivers")
|
||||
|
||||
lvgl_clone()
|
||||
lvgl_format()
|
||||
@@ -243,7 +249,7 @@ drivers_merge_to_release_branch(ver_str)
|
||||
docs_clone()
|
||||
docs_get_api()
|
||||
docs_update_version(ver_str)
|
||||
#docs_update_trans() # Zanata is not working now
|
||||
docs_merge_to_release_branch(ver_str)
|
||||
docs_build()
|
||||
|
||||
clean_up()
|
||||
|
||||
@@ -176,6 +176,16 @@ static inline lv_obj_t * lv_page_get_scrl(lv_obj_t * page)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*LV_USE_API_EXTENSION_V6*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*---------------------
|
||||
* V7.0 COMPATIBILITY
|
||||
*--------------------*/
|
||||
#if LV_USE_API_EXTENSION_V7
|
||||
#if LV_USE_WIN
|
||||
|
||||
static inline lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src)
|
||||
@@ -185,8 +195,14 @@ static inline lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * img_src)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /*LV_USE_API_EXTENSION_V6*/
|
||||
#if LV_USE_CHART
|
||||
static inline void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax)
|
||||
{
|
||||
lv_chart_set_y_range(chart, LV_CHART_AXIS_PRIMARY_Y, ymin, ymax);
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
@@ -294,6 +315,9 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
|
||||
#ifndef LV_USE_API_EXTENSION_V6
|
||||
#define LV_USE_API_EXTENSION_V6 1
|
||||
#endif
|
||||
#ifndef LV_USE_API_EXTENSION_V7
|
||||
#define LV_USE_API_EXTENSION_V7 1
|
||||
#endif
|
||||
|
||||
/*========================
|
||||
* Image decoder and cache
|
||||
@@ -495,10 +519,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
|
||||
#define LV_FONT_MONTSERRAT_12 0
|
||||
#endif
|
||||
#ifndef LV_FONT_MONTSERRAT_14
|
||||
#define LV_FONT_MONTSERRAT_14 0
|
||||
#define LV_FONT_MONTSERRAT_14 1
|
||||
#endif
|
||||
#ifndef LV_FONT_MONTSERRAT_16
|
||||
#define LV_FONT_MONTSERRAT_16 1
|
||||
#define LV_FONT_MONTSERRAT_16 0
|
||||
#endif
|
||||
#ifndef LV_FONT_MONTSERRAT_18
|
||||
#define LV_FONT_MONTSERRAT_18 0
|
||||
@@ -586,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.
|
||||
@@ -593,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`)*/
|
||||
|
||||
@@ -617,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
|
||||
@@ -647,16 +687,16 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
|
||||
#define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT
|
||||
#endif
|
||||
#ifndef LV_THEME_DEFAULT_FONT_SMALL
|
||||
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16
|
||||
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_14
|
||||
#endif
|
||||
#ifndef LV_THEME_DEFAULT_FONT_NORMAL
|
||||
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16
|
||||
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_14
|
||||
#endif
|
||||
#ifndef LV_THEME_DEFAULT_FONT_SUBTITLE
|
||||
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_16
|
||||
#define LV_THEME_DEFAULT_FONT_SUBTITLE &lv_font_montserrat_14
|
||||
#endif
|
||||
#ifndef LV_THEME_DEFAULT_FONT_TITLE
|
||||
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_16
|
||||
#define LV_THEME_DEFAULT_FONT_TITLE &lv_font_montserrat_14
|
||||
#endif
|
||||
|
||||
/*=================
|
||||
@@ -810,6 +850,11 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
|
||||
#ifndef LV_USE_CALENDAR
|
||||
#define LV_USE_CALENDAR 1
|
||||
#endif
|
||||
#if LV_USE_CALENDAR
|
||||
#ifndef LV_CALENDAR_WEEK_STARTS_MONDAY
|
||||
# define LV_CALENDAR_WEEK_STARTS_MONDAY 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*Canvas (dependencies: lv_img)*/
|
||||
#ifndef LV_USE_CANVAS
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*********************/
|
||||
#include "lv_disp.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_core/lv_refr.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -21,6 +22,12 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
static void scr_load_anim_start(lv_anim_t * a);
|
||||
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v);
|
||||
static void scr_anim_ready(lv_anim_t * a);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
@@ -43,13 +50,30 @@ lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp)
|
||||
{
|
||||
if(!disp) disp = lv_disp_get_default();
|
||||
if(!disp) {
|
||||
LV_LOG_WARN("lv_scr_act: no display registered to get its act. screen");
|
||||
LV_LOG_WARN("no display registered to get its active screen");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return disp->act_scr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with a pointer to the previous screen. Only used during screen transitions.
|
||||
* @param disp pointer to display which previous screen should be get. (NULL to use the default
|
||||
* screen)
|
||||
* @return pointer to the previous screen object or NULL if not used now
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_scr_prev(lv_disp_t * disp)
|
||||
{
|
||||
if(!disp) disp = lv_disp_get_default();
|
||||
if(!disp) {
|
||||
LV_LOG_WARN("no display registered to get its previous screen");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return disp->prev_scr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a screen active
|
||||
* @param scr pointer to a screen
|
||||
@@ -96,6 +120,7 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp)
|
||||
return disp->sys_layer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assign a screen to a display.
|
||||
* @param disp pointer to a display where to assign the screen
|
||||
@@ -115,6 +140,176 @@ void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr)
|
||||
_lv_ll_chg_list(&old_disp->scr_ll, &disp->scr_ll, scr, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the background color of a display
|
||||
* @param disp pointer to a display
|
||||
* @param color color of the background
|
||||
*/
|
||||
void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color)
|
||||
{
|
||||
if(!disp) disp = lv_disp_get_default();
|
||||
if(!disp) {
|
||||
LV_LOG_WARN("no display registered");
|
||||
return;
|
||||
}
|
||||
|
||||
disp->bg_color = color;
|
||||
|
||||
lv_area_t a;
|
||||
lv_area_set(&a, 0, 0, lv_disp_get_hor_res(disp) - 1, lv_disp_get_ver_res(disp) - 1);
|
||||
_lv_inv_area(disp, &a);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the background image of a display
|
||||
* @param disp pointer to a display
|
||||
* @param img_src path to file or pointer to an `lv_img_dsc_t` variable
|
||||
*/
|
||||
void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src)
|
||||
{
|
||||
if(!disp) disp = lv_disp_get_default();
|
||||
if(!disp) {
|
||||
LV_LOG_WARN("no display registered");
|
||||
return;
|
||||
}
|
||||
|
||||
disp->bg_img = img_src;
|
||||
|
||||
lv_area_t a;
|
||||
lv_area_set(&a, 0, 0, lv_disp_get_hor_res(disp) - 1, lv_disp_get_ver_res(disp) - 1);
|
||||
_lv_inv_area(disp, &a);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Opacity of the background
|
||||
* @param disp pointer to a display
|
||||
* @param opa opacity (0..255)
|
||||
*/
|
||||
void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa)
|
||||
{
|
||||
if(!disp) disp = lv_disp_get_default();
|
||||
if(!disp) {
|
||||
LV_LOG_WARN("no display registered");
|
||||
return;
|
||||
}
|
||||
|
||||
disp->bg_opa = opa;
|
||||
|
||||
lv_area_t a;
|
||||
lv_area_set(&a, 0, 0, lv_disp_get_hor_res(disp) - 1, lv_disp_get_ver_res(disp) - 1);
|
||||
_lv_inv_area(disp, &a);
|
||||
}
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
|
||||
/**
|
||||
* Switch screen with animation
|
||||
* @param scr pointer to the new screen to load
|
||||
* @param anim_type type of the animation from `lv_scr_load_anim_t`. E.g. `LV_SCR_LOAD_ANIM_MOVE_LEFT`
|
||||
* @param time time of the animation
|
||||
* @param delay delay before the transition
|
||||
* @param auto_del true: automatically delete the old screen
|
||||
*/
|
||||
void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del)
|
||||
{
|
||||
lv_disp_t * d = lv_obj_get_disp(new_scr);
|
||||
|
||||
if(d->prev_scr && d->del_prev) {
|
||||
lv_obj_del(d->prev_scr);
|
||||
d->prev_scr = NULL;
|
||||
}
|
||||
|
||||
d->del_prev = auto_del;
|
||||
|
||||
/*Be sure there is no other animation on the screens*/
|
||||
lv_anim_del(new_scr, NULL);
|
||||
lv_anim_del(lv_scr_act(), NULL);
|
||||
|
||||
/*Be sure both screens are in a normal position*/
|
||||
lv_obj_set_pos(new_scr, 0, 0);
|
||||
lv_obj_set_pos(lv_scr_act(), 0, 0);
|
||||
lv_style_remove_prop(lv_obj_get_local_style(new_scr, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE);
|
||||
lv_style_remove_prop(lv_obj_get_local_style(lv_scr_act(), LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE);
|
||||
|
||||
lv_anim_t a_new;
|
||||
lv_anim_init(&a_new);
|
||||
lv_anim_set_var(&a_new, new_scr);
|
||||
lv_anim_set_start_cb(&a_new, scr_load_anim_start);
|
||||
lv_anim_set_ready_cb(&a_new, scr_anim_ready);
|
||||
lv_anim_set_time(&a_new, time);
|
||||
lv_anim_set_delay(&a_new, delay);
|
||||
|
||||
lv_anim_t a_old;
|
||||
lv_anim_init(&a_old);
|
||||
lv_anim_set_var(&a_old, d->act_scr);
|
||||
lv_anim_set_time(&a_old, time);
|
||||
lv_anim_set_delay(&a_old, delay);
|
||||
|
||||
switch(anim_type) {
|
||||
case LV_SCR_LOAD_ANIM_NONE:
|
||||
/* Create a dummy animation to apply the delay*/
|
||||
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x);
|
||||
lv_anim_set_values(&a_new, 0, 0);
|
||||
break;
|
||||
case LV_SCR_LOAD_ANIM_OVER_LEFT:
|
||||
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x);
|
||||
lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0);
|
||||
break;
|
||||
case LV_SCR_LOAD_ANIM_OVER_RIGHT:
|
||||
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x);
|
||||
lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0);
|
||||
break;
|
||||
case LV_SCR_LOAD_ANIM_OVER_TOP:
|
||||
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y);
|
||||
lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0);
|
||||
break;
|
||||
case LV_SCR_LOAD_ANIM_OVER_BOTTOM:
|
||||
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y);
|
||||
lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0);
|
||||
break;
|
||||
case LV_SCR_LOAD_ANIM_MOVE_LEFT:
|
||||
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x);
|
||||
lv_anim_set_values(&a_new, lv_disp_get_hor_res(d), 0);
|
||||
|
||||
lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x);
|
||||
lv_anim_set_values(&a_old, 0, -lv_disp_get_hor_res(d));
|
||||
break;
|
||||
case LV_SCR_LOAD_ANIM_MOVE_RIGHT:
|
||||
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_x);
|
||||
lv_anim_set_values(&a_new, -lv_disp_get_hor_res(d), 0);
|
||||
|
||||
lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_x);
|
||||
lv_anim_set_values(&a_old, 0, lv_disp_get_hor_res(d));
|
||||
break;
|
||||
case LV_SCR_LOAD_ANIM_MOVE_TOP:
|
||||
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y);
|
||||
lv_anim_set_values(&a_new, lv_disp_get_ver_res(d), 0);
|
||||
|
||||
lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y);
|
||||
lv_anim_set_values(&a_old, 0, -lv_disp_get_ver_res(d));
|
||||
break;
|
||||
case LV_SCR_LOAD_ANIM_MOVE_BOTTOM:
|
||||
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) lv_obj_set_y);
|
||||
lv_anim_set_values(&a_new, -lv_disp_get_ver_res(d), 0);
|
||||
|
||||
lv_anim_set_exec_cb(&a_old, (lv_anim_exec_xcb_t) lv_obj_set_y);
|
||||
lv_anim_set_values(&a_old, 0, lv_disp_get_ver_res(d));
|
||||
break;
|
||||
|
||||
case LV_SCR_LOAD_ANIM_FADE_ON:
|
||||
lv_anim_set_exec_cb(&a_new, (lv_anim_exec_xcb_t) opa_scale_anim);
|
||||
lv_anim_set_values(&a_new, LV_OPA_TRANSP, LV_OPA_COVER);
|
||||
break;
|
||||
}
|
||||
|
||||
lv_anim_start(&a_new);
|
||||
lv_anim_start(&a_old);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get elapsed time since last user activity on a display (e.g. click)
|
||||
* @param disp pointer to an display (NULL to get the overall smallest inactivity)
|
||||
@@ -178,3 +373,28 @@ lv_task_t * _lv_disp_get_refr_task(lv_disp_t * disp)
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
static void scr_load_anim_start(lv_anim_t * a)
|
||||
{
|
||||
lv_disp_t * d = lv_obj_get_disp(a->var);
|
||||
d->prev_scr = lv_scr_act();
|
||||
|
||||
lv_disp_load_scr(a->var);
|
||||
}
|
||||
|
||||
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v)
|
||||
{
|
||||
lv_obj_set_style_local_opa_scale(obj, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, v);
|
||||
}
|
||||
|
||||
|
||||
static void scr_anim_ready(lv_anim_t * a)
|
||||
{
|
||||
lv_disp_t * d = lv_obj_get_disp(a->var);
|
||||
|
||||
if(d->prev_scr && d->del_prev) lv_obj_del(d->prev_scr);
|
||||
d->prev_scr = NULL;
|
||||
lv_style_remove_prop(lv_obj_get_local_style(a->var, LV_OBJ_PART_MAIN), LV_STYLE_OPA_SCALE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -24,6 +24,19 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_SCR_LOAD_ANIM_NONE,
|
||||
LV_SCR_LOAD_ANIM_OVER_LEFT,
|
||||
LV_SCR_LOAD_ANIM_OVER_RIGHT,
|
||||
LV_SCR_LOAD_ANIM_OVER_TOP,
|
||||
LV_SCR_LOAD_ANIM_OVER_BOTTOM,
|
||||
LV_SCR_LOAD_ANIM_MOVE_LEFT,
|
||||
LV_SCR_LOAD_ANIM_MOVE_RIGHT,
|
||||
LV_SCR_LOAD_ANIM_MOVE_TOP,
|
||||
LV_SCR_LOAD_ANIM_MOVE_BOTTOM,
|
||||
LV_SCR_LOAD_ANIM_FADE_ON,
|
||||
} lv_scr_load_anim_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@@ -36,6 +49,14 @@ extern "C" {
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Return with a pointer to the previous screen. Only used during screen transitions.
|
||||
* @param disp pointer to display which previous screen should be get. (NULL to use the default
|
||||
* screen)
|
||||
* @return pointer to the previous screen object or NULL if not used now
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_scr_prev(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Make a screen active
|
||||
* @param scr pointer to a screen
|
||||
@@ -64,6 +85,41 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp);
|
||||
*/
|
||||
void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr);
|
||||
|
||||
|
||||
/**
|
||||
* Set the background color of a display
|
||||
* @param disp pointer to a display
|
||||
* @param color color of the background
|
||||
*/
|
||||
void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color);
|
||||
|
||||
/**
|
||||
* Set the background image of a display
|
||||
* @param disp pointer to a display
|
||||
* @param img_src path to file or pointer to an `lv_img_dsc_t` variable
|
||||
*/
|
||||
void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src);
|
||||
|
||||
/**
|
||||
* Opacity of the background
|
||||
* @param disp pointer to a display
|
||||
* @param opa opacity (0..255)
|
||||
*/
|
||||
void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa);
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
|
||||
/**
|
||||
* Switch screen with animation
|
||||
* @param scr pointer to the new screen to load
|
||||
* @param anim_type type of the animation from `lv_scr_load_anim_t`. E.g. `LV_SCR_LOAD_ANIM_MOVE_LEFT`
|
||||
* @param time time of the animation
|
||||
* @param delay delay before the transition
|
||||
* @param auto_del true: automatically delete the old screen
|
||||
*/
|
||||
void lv_scr_load_anim(lv_obj_t * scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del);
|
||||
|
||||
#endif
|
||||
/**
|
||||
* Get elapsed time since last user activity on a display (e.g. click)
|
||||
* @param disp pointer to an display (NULL to get the overall smallest inactivity)
|
||||
@@ -122,6 +178,7 @@ static inline void lv_scr_load(lv_obj_t * scr)
|
||||
lv_disp_load_scr(scr);
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@@ -154,6 +211,11 @@ static inline void lv_scr_load(lv_obj_t * scr)
|
||||
*/
|
||||
#define LV_DPX(n) LV_MATH_MAX((( lv_disp_get_dpi(NULL) * (n) + 80) / 160), 1) /*+80 for rounding*/
|
||||
|
||||
static inline lv_coord_t lv_dpx(lv_coord_t n)
|
||||
{
|
||||
return LV_DPX(n);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -213,6 +213,7 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj)
|
||||
indev->cursor = cur_obj;
|
||||
lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp));
|
||||
lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y);
|
||||
lv_obj_set_click(indev->cursor, false);
|
||||
}
|
||||
|
||||
#if LV_USE_GROUP
|
||||
|
||||
@@ -85,6 +85,10 @@ static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coor
|
||||
static void report_style_mod_core(void * style_p, lv_obj_t * obj);
|
||||
static void refresh_children_style(lv_obj_t * obj);
|
||||
static void base_dir_refr_children(lv_obj_t * obj);
|
||||
static void obj_align_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set,
|
||||
lv_coord_t x_ofs, lv_coord_t y_ofs);
|
||||
static void obj_align_origo_core(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, bool x_set, bool y_set,
|
||||
lv_coord_t x_ofs, lv_coord_t y_ofs);
|
||||
#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);
|
||||
@@ -501,10 +505,12 @@ void lv_obj_invalidate_area(const lv_obj_t * obj, const lv_area_t * area)
|
||||
|
||||
if(lv_obj_get_hidden(obj)) return;
|
||||
|
||||
/*Invalidate the object only if it belongs to the 'LV_GC_ROOT(_lv_act_scr)'*/
|
||||
/*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_layer_top(disp) ||
|
||||
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*/
|
||||
@@ -684,13 +690,11 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
||||
/*Convert x and y to absolute coordinates*/
|
||||
lv_obj_t * par = obj->parent;
|
||||
|
||||
if(par == NULL) {
|
||||
LV_LOG_WARN("lv_obj_set_pos: not changing position of screen object");
|
||||
return;
|
||||
if(par) {
|
||||
x = x + par->coords.x1;
|
||||
y = y + par->coords.y1;
|
||||
}
|
||||
|
||||
x = x + par->coords.x1;
|
||||
y = y + par->coords.y1;
|
||||
|
||||
/*Calculate and set the movement*/
|
||||
lv_point_t diff;
|
||||
@@ -720,7 +724,7 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
||||
obj->signal_cb(obj, LV_SIGNAL_COORD_CHG, &ori);
|
||||
|
||||
/*Send a signal to the parent too*/
|
||||
par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
if(par) par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
|
||||
/*Invalidate the new area*/
|
||||
lv_obj_invalidate(obj);
|
||||
@@ -883,7 +887,6 @@ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h)
|
||||
lv_obj_set_height(obj, h - mtop - mbottom);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Align an object to an other object.
|
||||
* @param obj pointer to an object to align
|
||||
@@ -900,19 +903,7 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
|
||||
|
||||
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||
|
||||
lv_point_t new_pos;
|
||||
_lv_area_align(&base->coords, &obj->coords, align, &new_pos);
|
||||
|
||||
/*Bring together the coordination system of base and obj*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
lv_coord_t par_abs_x = par->coords.x1;
|
||||
lv_coord_t par_abs_y = par->coords.y1;
|
||||
new_pos.x += x_ofs;
|
||||
new_pos.y += y_ofs;
|
||||
new_pos.x -= par_abs_x;
|
||||
new_pos.y -= par_abs_y;
|
||||
|
||||
lv_obj_set_pos(obj, new_pos.x, new_pos.y);
|
||||
obj_align_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`*/
|
||||
@@ -924,6 +915,42 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Align an object to an other object horizontally.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param x_ofs x coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
if(base == NULL) base = lv_obj_get_parent(obj);
|
||||
|
||||
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||
|
||||
obj_align_core(obj, base, align, true, false, x_ofs, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Align an object to an other object vertically.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param y_ofs y coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
if(base == NULL) base = lv_obj_get_parent(obj);
|
||||
|
||||
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||
|
||||
obj_align_core(obj, base, align, true, false, 0, y_ofs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Align an object's middle point to an other object.
|
||||
* @param obj pointer to an object to align
|
||||
@@ -936,12 +963,6 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
lv_coord_t new_x = lv_obj_get_x(obj);
|
||||
lv_coord_t new_y = lv_obj_get_y(obj);
|
||||
|
||||
lv_coord_t obj_w_half = lv_obj_get_width(obj) / 2;
|
||||
lv_coord_t obj_h_half = lv_obj_get_height(obj) / 2;
|
||||
|
||||
if(base == NULL) {
|
||||
base = lv_obj_get_parent(obj);
|
||||
}
|
||||
@@ -949,123 +970,7 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
|
||||
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||
|
||||
|
||||
switch(align) {
|
||||
case LV_ALIGN_CENTER:
|
||||
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_TOP_LEFT:
|
||||
new_x = -obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
case LV_ALIGN_IN_TOP_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_TOP_RIGHT:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_BOTTOM_LEFT:
|
||||
new_x = -obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
case LV_ALIGN_IN_BOTTOM_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_BOTTOM_RIGHT:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_LEFT_MID:
|
||||
new_x = -obj_w_half;
|
||||
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_RIGHT_MID:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_LEFT:
|
||||
new_x = -obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_RIGHT:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_LEFT:
|
||||
new_x = -obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_RIGHT:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_TOP:
|
||||
new_x = -obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_MID:
|
||||
new_x = -obj_w_half;
|
||||
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_BOTTOM:
|
||||
new_x = -obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_TOP:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_MID:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_BOTTOM:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
}
|
||||
|
||||
/*Bring together the coordination system of base and obj*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
lv_coord_t base_abs_x = base->coords.x1;
|
||||
lv_coord_t base_abs_y = base->coords.y1;
|
||||
lv_coord_t par_abs_x = par->coords.x1;
|
||||
lv_coord_t par_abs_y = par->coords.y1;
|
||||
new_x += x_ofs + base_abs_x;
|
||||
new_y += y_ofs + base_abs_y;
|
||||
new_x -= par_abs_x;
|
||||
new_y -= par_abs_y;
|
||||
|
||||
lv_obj_set_pos(obj, new_x, new_y);
|
||||
obj_align_origo_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`*/
|
||||
@@ -1077,6 +982,49 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Align an object's middle point to an other object horizontally.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param x_ofs x coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_origo_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);
|
||||
|
||||
if(base == NULL) {
|
||||
base = lv_obj_get_parent(obj);
|
||||
}
|
||||
|
||||
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||
|
||||
|
||||
obj_align_origo_core(obj, base, align, true, false, x_ofs, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Align an object's middle point to an other object vertically.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param y_ofs y coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_origo_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);
|
||||
|
||||
if(base == NULL) {
|
||||
base = lv_obj_get_parent(obj);
|
||||
}
|
||||
|
||||
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
|
||||
|
||||
|
||||
obj_align_origo_core(obj, base, align, true, false, 0, y_ofs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Realign the object based on the last `lv_obj_align` parameters.
|
||||
* @param obj pointer to an object
|
||||
@@ -1805,6 +1753,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.
|
||||
@@ -3164,7 +3158,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if LV_USE_OUTLINE
|
||||
if(draw_dsc->outline_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->outline_width = lv_obj_get_style_outline_width(obj, part);
|
||||
if(draw_dsc->outline_width) {
|
||||
@@ -3178,7 +3172,9 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_PATTERN
|
||||
if(draw_dsc->pattern_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->pattern_image = lv_obj_get_style_pattern_image(obj, part);
|
||||
if(draw_dsc->pattern_image) {
|
||||
@@ -3199,6 +3195,8 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_SHADOW
|
||||
if(draw_dsc->shadow_opa > LV_OPA_MIN) {
|
||||
draw_dsc->shadow_width = lv_obj_get_style_shadow_width(obj, part);
|
||||
@@ -3217,6 +3215,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_VALUE_STR
|
||||
if(draw_dsc->value_opa > LV_OPA_MIN) {
|
||||
draw_dsc->value_str = lv_obj_get_style_value_str(obj, part);
|
||||
if(draw_dsc->value_str) {
|
||||
@@ -3235,6 +3234,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_OPA_SCALE
|
||||
if(opa_scale < LV_OPA_MAX) {
|
||||
@@ -3872,6 +3872,159 @@ 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)
|
||||
{
|
||||
lv_point_t new_pos;
|
||||
_lv_area_align(&base->coords, &obj->coords, align, &new_pos);
|
||||
|
||||
/*Bring together the coordination system of base and obj*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
lv_coord_t par_abs_x = par->coords.x1;
|
||||
lv_coord_t par_abs_y = par->coords.y1;
|
||||
new_pos.x += x_ofs;
|
||||
new_pos.y += y_ofs;
|
||||
new_pos.x -= par_abs_x;
|
||||
new_pos.y -= par_abs_y;
|
||||
|
||||
if(x_set && y_set) lv_obj_set_pos(obj, new_pos.x, new_pos.y);
|
||||
else if(x_set) lv_obj_set_x(obj, new_pos.x);
|
||||
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)
|
||||
{
|
||||
lv_coord_t new_x = lv_obj_get_x(obj);
|
||||
lv_coord_t new_y = lv_obj_get_y(obj);
|
||||
|
||||
lv_coord_t obj_w_half = lv_obj_get_width(obj) / 2;
|
||||
lv_coord_t obj_h_half = lv_obj_get_height(obj) / 2;
|
||||
|
||||
|
||||
switch(align) {
|
||||
case LV_ALIGN_CENTER:
|
||||
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_TOP_LEFT:
|
||||
new_x = -obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
case LV_ALIGN_IN_TOP_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_TOP_RIGHT:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_BOTTOM_LEFT:
|
||||
new_x = -obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
case LV_ALIGN_IN_BOTTOM_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_BOTTOM_RIGHT:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_LEFT_MID:
|
||||
new_x = -obj_w_half;
|
||||
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_RIGHT_MID:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_LEFT:
|
||||
new_x = -obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_RIGHT:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_LEFT:
|
||||
new_x = -obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_MID:
|
||||
new_x = lv_obj_get_width(base) / 2 - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_RIGHT:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_TOP:
|
||||
new_x = -obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_MID:
|
||||
new_x = -obj_w_half;
|
||||
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_BOTTOM:
|
||||
new_x = -obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_TOP:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = -obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_MID:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) / 2 - obj_h_half;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_BOTTOM:
|
||||
new_x = lv_obj_get_width(base) - obj_w_half;
|
||||
new_y = lv_obj_get_height(base) - obj_h_half;
|
||||
break;
|
||||
}
|
||||
|
||||
/*Bring together the coordination system of base and obj*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
lv_coord_t base_abs_x = base->coords.x1;
|
||||
lv_coord_t base_abs_y = base->coords.y1;
|
||||
lv_coord_t par_abs_x = par->coords.x1;
|
||||
lv_coord_t par_abs_y = par->coords.y1;
|
||||
new_x += x_ofs + base_abs_x;
|
||||
new_y += y_ofs + base_abs_y;
|
||||
new_x -= par_abs_x;
|
||||
new_y -= par_abs_y;
|
||||
if(x_set && y_set) lv_obj_set_pos(obj, new_x, new_y);
|
||||
else if(x_set) lv_obj_set_x(obj, new_x);
|
||||
else if(y_set) lv_obj_set_y(obj, new_y);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,6 +47,9 @@ extern "C" {
|
||||
#define LV_EXT_CLICK_AREA_TINY 1
|
||||
#define LV_EXT_CLICK_AREA_FULL 2
|
||||
|
||||
#define _LV_OBJ_PART_VIRTUAL_FIRST 0x01
|
||||
#define _LV_OBJ_PART_REAL_FIRST 0x40
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@@ -247,8 +250,8 @@ typedef struct _lv_obj_t {
|
||||
|
||||
enum {
|
||||
LV_OBJ_PART_MAIN,
|
||||
_LV_OBJ_PART_VIRTUAL_LAST = 0x01,
|
||||
_LV_OBJ_PART_REAL_LAST = 0x40,
|
||||
_LV_OBJ_PART_VIRTUAL_LAST = _LV_OBJ_PART_VIRTUAL_FIRST,
|
||||
_LV_OBJ_PART_REAL_LAST = _LV_OBJ_PART_REAL_FIRST,
|
||||
LV_OBJ_PART_ALL = 0xFF,
|
||||
};
|
||||
|
||||
@@ -465,6 +468,24 @@ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h);
|
||||
*/
|
||||
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs);
|
||||
|
||||
/**
|
||||
* Align an object to an other object horizontally.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param x_ofs x coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs);
|
||||
|
||||
/**
|
||||
* Align an object to an other object vertically.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param y_ofs y coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_y(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t y_ofs);
|
||||
|
||||
/**
|
||||
* Align an object to an other object.
|
||||
* @param obj pointer to an object to align
|
||||
@@ -475,6 +496,25 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* Align an object's middle point to an other object horizontally.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param x_ofs x coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_origo_x(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs);
|
||||
|
||||
/**
|
||||
* Align an object's middle point to an other object vertically.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param y_ofs y coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align_origo_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.
|
||||
* @param obj pointer to an object
|
||||
@@ -783,6 +823,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.
|
||||
|
||||
@@ -490,7 +490,8 @@ static void lv_refr_area_part(const lv_area_t * area_p)
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_t * top_p;
|
||||
lv_obj_t * top_act_scr = NULL;
|
||||
lv_obj_t * top_prev_scr = NULL;
|
||||
|
||||
/*Get the new mask from the original area and the act. VDB
|
||||
It will be a part of 'area_p'*/
|
||||
@@ -498,10 +499,55 @@ static void lv_refr_area_part(const lv_area_t * area_p)
|
||||
_lv_area_intersect(&start_mask, area_p, &vdb->area);
|
||||
|
||||
/*Get the most top object which is not covered by others*/
|
||||
top_p = lv_refr_get_top_obj(&start_mask, lv_disp_get_scr_act(disp_refr));
|
||||
top_act_scr = lv_refr_get_top_obj(&start_mask, lv_disp_get_scr_act(disp_refr));
|
||||
if(disp_refr->prev_scr) {
|
||||
top_prev_scr = lv_refr_get_top_obj(&start_mask, disp_refr->prev_scr);
|
||||
}
|
||||
|
||||
/*Draw a display background if there is no top object*/
|
||||
if(top_act_scr == NULL && top_prev_scr == NULL) {
|
||||
if(disp_refr->bg_img) {
|
||||
lv_draw_img_dsc_t dsc;
|
||||
lv_draw_img_dsc_init(&dsc);
|
||||
dsc.opa = disp_refr->bg_opa;
|
||||
lv_img_header_t header;
|
||||
lv_res_t res;
|
||||
res = lv_img_decoder_get_info(disp_refr->bg_img, &header);
|
||||
if(res == LV_RES_OK) {
|
||||
lv_area_t a;
|
||||
lv_area_set(&a, 0, 0, header.w - 1, header.h - 1);
|
||||
lv_draw_img(&a, &start_mask, disp_refr->bg_img, &dsc);
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Can't draw the background image")
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_draw_rect_dsc_t dsc;
|
||||
lv_draw_rect_dsc_init(&dsc);
|
||||
dsc.bg_color = disp_refr->bg_color;
|
||||
dsc.bg_opa = disp_refr->bg_opa;
|
||||
lv_draw_rect(&start_mask, &start_mask, &dsc);
|
||||
|
||||
}
|
||||
}
|
||||
/*Refresh the previous screen if any*/
|
||||
if(disp_refr->prev_scr) {
|
||||
/*Get the most top object which is not covered by others*/
|
||||
if(top_prev_scr == NULL) {
|
||||
top_prev_scr = disp_refr->prev_scr;
|
||||
}
|
||||
/*Do the refreshing from the top object*/
|
||||
lv_refr_obj_and_children(top_prev_scr, &start_mask);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(top_act_scr == NULL) {
|
||||
top_act_scr = disp_refr->act_scr;
|
||||
}
|
||||
/*Do the refreshing from the top object*/
|
||||
lv_refr_obj_and_children(top_p, &start_mask);
|
||||
lv_refr_obj_and_children(top_act_scr, &start_mask);
|
||||
|
||||
/*Also refresh top and sys layer unconditionally*/
|
||||
lv_refr_obj_and_children(lv_disp_get_layer_top(disp_refr), &start_mask);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -570,7 +570,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);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,9 +36,11 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
|
||||
#if LV_USE_BLEND_MODES
|
||||
static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
|
||||
#endif
|
||||
|
||||
static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
@@ -49,12 +51,14 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
|
||||
#if LV_USE_BLEND_MODES
|
||||
static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode);
|
||||
|
||||
static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
|
||||
static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -167,9 +171,11 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_fill(const lv_area_t * clip_area, const lv_
|
||||
else if(mode == LV_BLEND_MODE_NORMAL) {
|
||||
fill_normal(disp_area, disp_buf, &draw_area, color, opa, mask, mask_res);
|
||||
}
|
||||
#if LV_USE_BLEND_MODES
|
||||
else {
|
||||
fill_blended(disp_area, disp_buf, &draw_area, color, opa, mask, mask_res, mode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,9 +236,11 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_map(const lv_area_t * clip_area, const lv_a
|
||||
else if(mode == LV_BLEND_MODE_NORMAL) {
|
||||
map_normal(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res);
|
||||
}
|
||||
#if LV_USE_BLEND_MODES
|
||||
else {
|
||||
map_blended(disp_area, disp_buf, &draw_area, map_area, map_buf, opa, mask, mask_res, mode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -515,7 +523,7 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if LV_USE_BLEND_MODES
|
||||
/**
|
||||
* Fill an area with a color but apply blending algorithms
|
||||
* @param disp_area the current display area (destination area)
|
||||
@@ -606,6 +614,7 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
@@ -845,7 +854,7 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if LV_USE_BLEND_MODES
|
||||
static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_blend_mode_t mode)
|
||||
@@ -996,3 +1005,4 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co
|
||||
|
||||
return lv_color_mix(fg, bg, opa);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -407,7 +407,6 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
/*Build the image and a mask line-by-line*/
|
||||
uint32_t mask_buf_size = lv_area_get_size(&draw_area) > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : lv_area_get_size(&draw_area);
|
||||
lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t));
|
||||
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size);
|
||||
@@ -420,7 +419,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
||||
lv_opa_t px_opa = map_px[LV_IMG_PX_SIZE_ALPHA_BYTE - 1];
|
||||
mask_buf[px_i] = px_opa;
|
||||
if(px_opa) {
|
||||
#if LV_COLOR_DEPTH == 8
|
||||
#if LV_COLOR_DEPTH == 8 || LV_COLOR_DEPTH == 1
|
||||
map2[px_i].full = map_px[0];
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
map2[px_i].full = map_px[0] + (map_px[1] << 8);
|
||||
|
||||
@@ -213,12 +213,12 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
sel_start = sel_end;
|
||||
sel_end = tmp;
|
||||
}
|
||||
|
||||
lv_draw_line_dsc_t line_dsc;
|
||||
dsc->decor = LV_TEXT_DECOR_UNDERLINE;
|
||||
if((dsc->decor & LV_TEXT_DECOR_UNDERLINE) || (dsc->decor & LV_TEXT_DECOR_STRIKETHROUGH)) {
|
||||
lv_draw_line_dsc_init(&line_dsc);
|
||||
line_dsc.color = dsc->color;
|
||||
line_dsc.width = (dsc->font->line_height + 5) / 10; /*+5 for rounding*/
|
||||
line_dsc.width = font->underline_thickness;
|
||||
line_dsc.opa = dsc->opa;
|
||||
line_dsc.blend_mode = dsc->blend_mode;
|
||||
}
|
||||
@@ -342,7 +342,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
p1.x = pos_x_start;
|
||||
p1.y = pos.y + dsc->font->line_height - dsc->font->base_line + line_dsc.width / 2 + 1;
|
||||
p1.y = pos.y + dsc->font->line_height - dsc->font->base_line - font->underline_position;
|
||||
p2.x = pos.x;
|
||||
p2.y = p1.y;
|
||||
lv_draw_line(&p1, &p2, mask, &line_dsc);
|
||||
@@ -420,7 +420,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_letter(const lv_point_t * pos_p, const
|
||||
}
|
||||
|
||||
/* Don't draw anything if the character is empty. E.g. space */
|
||||
if((g.box_h == 0) && (g.box_w == 0)) return;
|
||||
if((g.box_h == 0) || (g.box_w == 0)) return;
|
||||
|
||||
int32_t pos_x = pos_p->x + g.ofs_x;
|
||||
int32_t pos_y = pos_p->y + (font_p->line_height - font_p->base_line) - g.box_h - g.ofs_y;
|
||||
@@ -607,6 +607,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_
|
||||
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
|
||||
const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
|
||||
{
|
||||
#if LV_USE_FONT_SUBPX
|
||||
const uint8_t * bpp_opa_table;
|
||||
uint32_t bitmask_init;
|
||||
uint32_t bitmask;
|
||||
@@ -806,6 +807,9 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
||||
|
||||
_lv_mem_buf_release(mask_buf);
|
||||
_lv_mem_buf_release(color_buf);
|
||||
#else
|
||||
LV_LOG_WARN("Can't draw sub-pixel rendered letter because LV_USE_FONT_SUBPX == 0 in lv_conf.h");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,8 +30,10 @@
|
||||
LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip,
|
||||
lv_draw_rect_dsc_t * dsc);
|
||||
static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i);
|
||||
|
||||
#if LV_USE_OUTLINE
|
||||
static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
#endif
|
||||
#if LV_USE_SHADOW
|
||||
LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip,
|
||||
lv_draw_rect_dsc_t * dsc);
|
||||
@@ -39,8 +41,17 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord
|
||||
lv_coord_t r);
|
||||
LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups_buf);
|
||||
#endif
|
||||
static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
|
||||
#if LV_USE_PATTERN
|
||||
static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
#endif
|
||||
|
||||
#if LV_USE_VALUE_STR
|
||||
static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc);
|
||||
#endif
|
||||
static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip,
|
||||
lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
|
||||
LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -95,10 +106,19 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect
|
||||
#endif
|
||||
|
||||
draw_bg(coords, clip, dsc);
|
||||
|
||||
#if LV_USE_PATTERN
|
||||
draw_pattern(coords, clip, dsc);
|
||||
#endif
|
||||
draw_border(coords, clip, dsc);
|
||||
draw_value(coords, clip, dsc);
|
||||
|
||||
#if LV_USE_VALUE_STR
|
||||
draw_value_str(coords, clip, dsc);
|
||||
#endif
|
||||
|
||||
#if LV_USE_OUTLINE
|
||||
draw_outline(coords, clip, dsc);
|
||||
#endif
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
}
|
||||
@@ -370,41 +390,6 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
|
||||
if(dsc->border_width == 0) return;
|
||||
if(dsc->border_side == LV_BORDER_SIDE_NONE) return;
|
||||
|
||||
lv_opa_t opa = dsc->border_opa;
|
||||
|
||||
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
|
||||
|
||||
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
|
||||
|
||||
/* Get clipped fill area which is the real draw area.
|
||||
* It is always the same or inside `fill_area` */
|
||||
lv_area_t draw_area;
|
||||
bool is_common;
|
||||
is_common = _lv_area_intersect(&draw_area, coords, clip);
|
||||
if(is_common == false) return;
|
||||
|
||||
const lv_area_t * disp_area = &vdb->area;
|
||||
|
||||
/* Now `draw_area` has absolute coordinates.
|
||||
* Make it relative to `disp_area` to simplify draw to `disp_buf`*/
|
||||
draw_area.x1 -= disp_area->x1;
|
||||
draw_area.y1 -= disp_area->y1;
|
||||
draw_area.x2 -= disp_area->x1;
|
||||
draw_area.y2 -= disp_area->y1;
|
||||
|
||||
int32_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
|
||||
/*Create a mask if there is a radius*/
|
||||
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w);
|
||||
|
||||
uint8_t other_mask_cnt = lv_draw_mask_get_cnt();
|
||||
bool simple_mode = true;
|
||||
if(other_mask_cnt) simple_mode = false;
|
||||
else if(dsc->border_side != LV_BORDER_SIDE_FULL) simple_mode = false;
|
||||
|
||||
int16_t mask_rout_id = LV_MASK_ID_INV;
|
||||
|
||||
int32_t coords_w = lv_area_get_width(coords);
|
||||
int32_t coords_h = lv_area_get_height(coords);
|
||||
|
||||
@@ -413,140 +398,80 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
|
||||
int32_t short_side = LV_MATH_MIN(coords_w, coords_h);
|
||||
if(rout > short_side >> 1) rout = short_side >> 1;
|
||||
|
||||
/*Get the outer area*/
|
||||
lv_draw_mask_radius_param_t mask_rout_param;
|
||||
if(rout > 0) {
|
||||
lv_draw_mask_radius_init(&mask_rout_param, coords, rout, false);
|
||||
mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL);
|
||||
}
|
||||
|
||||
/*Get the inner radius*/
|
||||
int32_t rin = rout - dsc->border_width;
|
||||
if(rin < 0) rin = 0;
|
||||
|
||||
/*Get the inner area*/
|
||||
lv_area_t area_small;
|
||||
lv_area_copy(&area_small, coords);
|
||||
area_small.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
area_small.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
area_small.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
area_small.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
lv_area_t area_inner;
|
||||
lv_area_copy(&area_inner, coords);
|
||||
area_inner.x1 += ((dsc->border_side & LV_BORDER_SIDE_LEFT) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
area_inner.x2 -= ((dsc->border_side & LV_BORDER_SIDE_RIGHT) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
area_inner.y1 += ((dsc->border_side & LV_BORDER_SIDE_TOP) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
area_inner.y2 -= ((dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? dsc->border_width : - (dsc->border_width + rout));
|
||||
|
||||
/*Create inner the mask*/
|
||||
lv_draw_mask_radius_param_t mask_rin_param;
|
||||
lv_draw_mask_radius_init(&mask_rin_param, &area_small, rout - dsc->border_width, true);
|
||||
int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL);
|
||||
|
||||
int32_t corner_size = LV_MATH_MAX(rout, dsc->border_width - 1);
|
||||
|
||||
int32_t h;
|
||||
lv_draw_mask_res_t mask_res;
|
||||
lv_area_t fill_area;
|
||||
|
||||
lv_color_t color = dsc->border_color;
|
||||
lv_blend_mode_t blend_mode = dsc->border_blend_mode;
|
||||
|
||||
/*Apply some optimization if there is no other mask*/
|
||||
if(simple_mode) {
|
||||
/*Draw the upper corner area*/
|
||||
int32_t upper_corner_end = coords->y1 - disp_area->y1 + corner_size;
|
||||
upper_corner_end = LV_MATH_MIN(upper_corner_end, draw_area.y2);
|
||||
fill_area.x1 = coords->x1;
|
||||
fill_area.x2 = coords->x2;
|
||||
fill_area.y1 = disp_area->y1 + draw_area.y1;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
for(h = draw_area.y1; h <= upper_corner_end; h++) {
|
||||
_lv_memset_ff(mask_buf, draw_area_w);
|
||||
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
lv_area_t fill_area2;
|
||||
fill_area2.y1 = fill_area.y1;
|
||||
fill_area2.y2 = fill_area.y2;
|
||||
|
||||
fill_area2.x1 = coords->x1;
|
||||
fill_area2.x2 = coords->x1 + rout - 1;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
|
||||
|
||||
/*Draw the top horizontal line*/
|
||||
if(fill_area2.y2 < coords->y1 + dsc->border_width) {
|
||||
fill_area2.x1 = coords->x1 + rout;
|
||||
fill_area2.x2 = coords->x2 - rout;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
}
|
||||
|
||||
fill_area2.x1 = coords->x2 - rout + 1;
|
||||
fill_area2.x2 = coords->x2;
|
||||
|
||||
int32_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
if(mask_ofs < 0) mask_ofs = 0;
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
|
||||
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
}
|
||||
|
||||
/*Draw the lower corner area */
|
||||
int32_t lower_corner_end = coords->y2 - disp_area->y1 - corner_size;
|
||||
lower_corner_end = LV_MATH_MAX(lower_corner_end, draw_area.y1);
|
||||
if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1;
|
||||
fill_area.y1 = disp_area->y1 + lower_corner_end;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
for(h = lower_corner_end; h <= draw_area.y2; h++) {
|
||||
_lv_memset_ff(mask_buf, draw_area_w);
|
||||
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
lv_area_t fill_area2;
|
||||
fill_area2.x1 = coords->x1;
|
||||
fill_area2.x2 = coords->x1 + rout - 1;
|
||||
fill_area2.y1 = fill_area.y1;
|
||||
fill_area2.y2 = fill_area.y2;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
|
||||
|
||||
/*Draw the bottom horizontal line*/
|
||||
if(fill_area2.y2 > coords->y2 - dsc->border_width) {
|
||||
fill_area2.x1 = coords->x1 + rout;
|
||||
fill_area2.x2 = coords->x2 - rout;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
}
|
||||
fill_area2.x1 = coords->x2 - rout + 1;
|
||||
fill_area2.x2 = coords->x2;
|
||||
|
||||
int32_t mask_ofs = (coords->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
if(mask_ofs < 0) mask_ofs = 0;
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
|
||||
|
||||
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
}
|
||||
|
||||
/*Draw the left vertical border part*/
|
||||
fill_area.y1 = coords->y1 + corner_size + 1;
|
||||
fill_area.y2 = coords->y2 - corner_size - 1;
|
||||
|
||||
fill_area.x1 = coords->x1;
|
||||
fill_area.x2 = coords->x1 + dsc->border_width - 1;
|
||||
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
|
||||
/*Draw the right vertical border*/
|
||||
fill_area.x1 = coords->x2 - dsc->border_width + 1;
|
||||
fill_area.x2 = coords->x2;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
if(dsc->border_side == LV_BORDER_SIDE_FULL) {
|
||||
draw_full_border(&area_inner, coords, clip, dsc->radius, dsc->border_color, dsc->border_opa, dsc->border_blend_mode);
|
||||
}
|
||||
/*Process line by line if there is other mask too*/
|
||||
else {
|
||||
lv_opa_t opa = dsc->border_opa;
|
||||
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
|
||||
|
||||
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
|
||||
|
||||
/* Get clipped fill area which is the real draw area.
|
||||
* It is always the same or inside `fill_area` */
|
||||
lv_area_t draw_area;
|
||||
bool is_common;
|
||||
is_common = _lv_area_intersect(&draw_area, coords, clip);
|
||||
if(is_common == false) return;
|
||||
|
||||
const lv_area_t * disp_area = &vdb->area;
|
||||
|
||||
/* Now `draw_area` has absolute coordinates.
|
||||
* Make it relative to `disp_area` to simplify draw to `disp_buf`*/
|
||||
draw_area.x1 -= disp_area->x1;
|
||||
draw_area.y1 -= disp_area->y1;
|
||||
draw_area.x2 -= disp_area->x1;
|
||||
draw_area.y2 -= disp_area->y1;
|
||||
|
||||
int32_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
|
||||
/*Create a mask if there is a radius*/
|
||||
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w);
|
||||
|
||||
/*Create mask for the outer area*/
|
||||
int16_t mask_rout_id = LV_MASK_ID_INV;
|
||||
lv_draw_mask_radius_param_t mask_rout_param;
|
||||
if(rout > 0) {
|
||||
lv_draw_mask_radius_init(&mask_rout_param, coords, rout, false);
|
||||
mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL);
|
||||
}
|
||||
|
||||
/*Create mask for the inner mask*/
|
||||
int32_t rin = rout - dsc->border_width;
|
||||
if(rin < 0) rin = 0;
|
||||
lv_draw_mask_radius_param_t mask_rin_param;
|
||||
lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rout - dsc->border_width, true);
|
||||
int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL);
|
||||
|
||||
int32_t corner_size = LV_MATH_MAX(rout, dsc->border_width - 1);
|
||||
|
||||
int32_t h;
|
||||
lv_draw_mask_res_t mask_res;
|
||||
lv_area_t fill_area;
|
||||
|
||||
lv_color_t color = dsc->border_color;
|
||||
lv_blend_mode_t blend_mode = dsc->border_blend_mode;
|
||||
|
||||
fill_area.x1 = coords->x1;
|
||||
fill_area.x2 = coords->x2;
|
||||
fill_area.y1 = disp_area->y1 + draw_area.y1;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
|
||||
uint32_t buf_ofs = 0;
|
||||
if(dsc->border_side == LV_BORDER_SIDE_LEFT) fill_area.x2 = coords->x1 + corner_size;
|
||||
else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) fill_area.x1 = coords->x2 - corner_size;
|
||||
else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) {
|
||||
fill_area.x1 = coords->x2 - corner_size;
|
||||
buf_ofs = fill_area.x1 - coords->x1;
|
||||
}
|
||||
|
||||
volatile bool top_only = false;
|
||||
volatile bool bottom_only = false;
|
||||
@@ -565,16 +490,16 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
|
||||
(bottom_only && fill_area.y1 >= coords->y2 - corner_size)) {
|
||||
_lv_memset_ff(mask_buf, draw_area_w);
|
||||
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
_lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
|
||||
_lv_blend_fill(clip, &fill_area, color, mask_buf + buf_ofs, mask_res, opa, blend_mode);
|
||||
}
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
|
||||
}
|
||||
lv_draw_mask_remove_id(mask_rin_id);
|
||||
lv_draw_mask_remove_id(mask_rout_id);
|
||||
_lv_mem_buf_release(mask_buf);
|
||||
}
|
||||
lv_draw_mask_remove_id(mask_rin_id);
|
||||
lv_draw_mask_remove_id(mask_rout_id);
|
||||
_lv_mem_buf_release(mask_buf);
|
||||
}
|
||||
|
||||
LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(lv_draw_rect_dsc_t * dsc, lv_coord_t s, lv_coord_t i)
|
||||
@@ -1222,6 +1147,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t
|
||||
|
||||
#endif
|
||||
|
||||
#if LV_USE_OUTLINE
|
||||
static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->outline_opa <= LV_OPA_MIN) return;
|
||||
@@ -1231,10 +1157,6 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr
|
||||
|
||||
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
|
||||
|
||||
uint8_t other_mask_cnt = lv_draw_mask_get_cnt();
|
||||
bool simple_mode = true;
|
||||
if(other_mask_cnt) simple_mode = false;
|
||||
|
||||
/*Get the inner radius*/
|
||||
lv_area_t area_inner;
|
||||
lv_area_copy(&area_inner, coords);
|
||||
@@ -1243,16 +1165,6 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr
|
||||
area_inner.x2 += dsc->outline_pad;
|
||||
area_inner.y2 += dsc->outline_pad;
|
||||
|
||||
int32_t inner_w = lv_area_get_width(&area_inner);
|
||||
int32_t inner_h = lv_area_get_height(&area_inner);
|
||||
|
||||
int32_t rin = dsc->radius;
|
||||
int32_t short_side = LV_MATH_MIN(inner_w, inner_h);
|
||||
if(rin > short_side >> 1) rin = short_side >> 1;
|
||||
|
||||
/*Get the outer area*/
|
||||
int32_t rout = rin + dsc->outline_width;
|
||||
|
||||
lv_area_t area_outer;
|
||||
lv_area_copy(&area_outer, &area_inner);
|
||||
|
||||
@@ -1261,165 +1173,13 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr
|
||||
area_outer.y1 -= dsc->outline_width;
|
||||
area_outer.y2 += dsc->outline_width;
|
||||
|
||||
int32_t coords_out_w = lv_area_get_width(&area_outer);
|
||||
int32_t coords_out_h = lv_area_get_height(&area_outer);
|
||||
short_side = LV_MATH_MIN(coords_out_w, coords_out_h);
|
||||
if(rout > short_side >> 1) rout = short_side >> 1;
|
||||
|
||||
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
|
||||
|
||||
/* Get clipped fill area which is the real draw area.
|
||||
* It is always the same or inside `fill_area` */
|
||||
lv_area_t draw_area;
|
||||
bool is_common;
|
||||
is_common = _lv_area_intersect(&draw_area, &area_outer, clip);
|
||||
if(is_common == false) return;
|
||||
|
||||
const lv_area_t * disp_area = &vdb->area;
|
||||
|
||||
/* Now `draw_area` has absolute coordinates.
|
||||
* Make it relative to `disp_area` to simplify draw to `disp_buf`*/
|
||||
draw_area.x1 -= disp_area->x1;
|
||||
draw_area.y1 -= disp_area->y1;
|
||||
draw_area.x2 -= disp_area->x1;
|
||||
draw_area.y2 -= disp_area->y1;
|
||||
|
||||
int32_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
|
||||
/*Create inner the mask*/
|
||||
lv_draw_mask_radius_param_t mask_rin_param;
|
||||
lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rin, true);
|
||||
int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL);
|
||||
|
||||
lv_draw_mask_radius_param_t mask_rout_param;
|
||||
lv_draw_mask_radius_init(&mask_rout_param, &area_outer, rout, false);
|
||||
int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL);
|
||||
|
||||
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w);
|
||||
|
||||
int32_t corner_size = LV_MATH_MAX(rout, dsc->outline_width - 1);
|
||||
|
||||
int32_t h;
|
||||
lv_draw_mask_res_t mask_res;
|
||||
lv_area_t fill_area;
|
||||
|
||||
lv_color_t color = dsc->outline_color;
|
||||
lv_blend_mode_t blend_mode = dsc->outline_blend_mode;
|
||||
|
||||
/*Apply some optimization if there is no other mask*/
|
||||
if(simple_mode) {
|
||||
/*Draw the upper corner area*/
|
||||
int32_t upper_corner_end = area_outer.y1 - disp_area->y1 + corner_size;
|
||||
|
||||
fill_area.x1 = area_outer.x1;
|
||||
fill_area.x2 = area_outer.x2;
|
||||
fill_area.y1 = disp_area->y1 + draw_area.y1;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
for(h = draw_area.y1; h <= upper_corner_end; h++) {
|
||||
_lv_memset_ff(mask_buf, draw_area_w);
|
||||
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
lv_area_t fill_area2;
|
||||
fill_area2.y1 = fill_area.y1;
|
||||
fill_area2.y2 = fill_area.y2;
|
||||
|
||||
fill_area2.x1 = area_outer.x1;
|
||||
fill_area2.x2 = area_outer.x1 + rout - 1;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
|
||||
|
||||
/*Draw the top horizontal line*/
|
||||
if(fill_area2.y2 < area_outer.y1 + dsc->outline_width) {
|
||||
fill_area2.x1 = area_outer.x1 + rout;
|
||||
fill_area2.x2 = area_outer.x2 - rout;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
}
|
||||
|
||||
fill_area2.x1 = area_outer.x2 - rout + 1;
|
||||
fill_area2.x2 = area_outer.x2;
|
||||
|
||||
int32_t mask_ofs = (area_outer.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
if(mask_ofs < 0) mask_ofs = 0;
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
|
||||
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
}
|
||||
|
||||
/*Draw the lower corner area */
|
||||
int32_t lower_corner_end = area_outer.y2 - disp_area->y1 - corner_size;
|
||||
if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1;
|
||||
fill_area.y1 = disp_area->y1 + lower_corner_end;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
for(h = lower_corner_end; h <= draw_area.y2; h++) {
|
||||
_lv_memset_ff(mask_buf, draw_area_w);
|
||||
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
lv_area_t fill_area2;
|
||||
fill_area2.x1 = area_outer.x1;
|
||||
fill_area2.x2 = area_outer.x1 + rout - 1;
|
||||
fill_area2.y1 = fill_area.y1;
|
||||
fill_area2.y2 = fill_area.y2;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
|
||||
|
||||
/*Draw the bottom horizontal line*/
|
||||
if(fill_area2.y2 > area_outer.y2 - dsc->outline_width) {
|
||||
fill_area2.x1 = area_outer.x1 + rout;
|
||||
fill_area2.x2 = area_outer.x2 - rout;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
}
|
||||
fill_area2.x1 = area_outer.x2 - rout + 1;
|
||||
fill_area2.x2 = area_outer.x2;
|
||||
|
||||
int32_t mask_ofs = (area_outer.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
if(mask_ofs < 0) mask_ofs = 0;
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
|
||||
|
||||
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
}
|
||||
|
||||
/*Draw the left vertical part*/
|
||||
fill_area.y1 = area_outer.y1 + corner_size + 1;
|
||||
fill_area.y2 = area_outer.y2 - corner_size - 1;
|
||||
|
||||
fill_area.x1 = area_outer.x1;
|
||||
fill_area.x2 = area_outer.x1 + dsc->outline_width - 1;
|
||||
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
|
||||
/*Draw the right vertical border*/
|
||||
fill_area.x1 = area_outer.x2 - dsc->outline_width + 1;
|
||||
fill_area.x2 = area_outer.x2;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
}
|
||||
/*Process line by line if there is other mask too*/
|
||||
else {
|
||||
fill_area.x1 = area_outer.x1;
|
||||
fill_area.x2 = area_outer.x2;
|
||||
fill_area.y1 = disp_area->y1 + draw_area.y1;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
|
||||
for(h = draw_area.y1; h <= draw_area.y2; h++) {
|
||||
_lv_memset_ff(mask_buf, draw_area_w);
|
||||
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
_lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
|
||||
}
|
||||
}
|
||||
lv_draw_mask_remove_id(mask_rin_id);
|
||||
lv_draw_mask_remove_id(mask_rout_id);
|
||||
_lv_mem_buf_release(mask_buf);
|
||||
draw_full_border(&area_inner, &area_outer, clip, dsc->radius, dsc->outline_color, dsc->outline_opa,
|
||||
dsc->outline_blend_mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_USE_PATTERN
|
||||
static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->pattern_image == NULL) return;
|
||||
@@ -1520,9 +1280,11 @@ static void draw_pattern(const lv_area_t * coords, const lv_area_t * clip, lv_dr
|
||||
lv_draw_mask_remove_id(radius_mask_id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
|
||||
#if LV_USE_VALUE_STR
|
||||
static void draw_value_str(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->value_str == NULL) return;
|
||||
if(dsc->value_opa <= LV_OPA_MIN) return;
|
||||
@@ -1555,4 +1317,179 @@ static void draw_value(const lv_area_t * coords, const lv_area_t * clip, lv_draw
|
||||
|
||||
lv_draw_label(&value_area, clip, &label_dsc, dsc->value_str, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * area_outer, const lv_area_t * clip,
|
||||
lv_coord_t radius, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
|
||||
{
|
||||
uint8_t other_mask_cnt = lv_draw_mask_get_cnt();
|
||||
bool simple_mode = true;
|
||||
if(other_mask_cnt) simple_mode = false;
|
||||
|
||||
int32_t inner_w = lv_area_get_width(area_inner);
|
||||
int32_t inner_h = lv_area_get_height(area_inner);
|
||||
lv_coord_t border_width = area_outer->x2 - area_inner->x2;
|
||||
int32_t rin = radius;
|
||||
|
||||
int32_t short_side = LV_MATH_MIN(inner_w, inner_h);
|
||||
if(rin > short_side >> 1) rin = short_side >> 1;
|
||||
|
||||
/*Get the outer area*/
|
||||
int32_t rout = rin + border_width;
|
||||
|
||||
int32_t coords_out_w = lv_area_get_width(area_outer);
|
||||
int32_t coords_out_h = lv_area_get_height(area_outer);
|
||||
short_side = LV_MATH_MIN(coords_out_w, coords_out_h);
|
||||
if(rout > short_side >> 1) rout = short_side >> 1;
|
||||
|
||||
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
|
||||
|
||||
/* Get clipped fill area which is the real draw area.
|
||||
* It is always the same or inside `fill_area` */
|
||||
lv_area_t draw_area;
|
||||
bool is_common;
|
||||
is_common = _lv_area_intersect(&draw_area, area_outer, clip);
|
||||
if(is_common == false) return;
|
||||
|
||||
const lv_area_t * disp_area = &vdb->area;
|
||||
|
||||
/* Now `draw_area` has absolute coordinates.
|
||||
* Make it relative to `disp_area` to simplify draw to `disp_buf`*/
|
||||
draw_area.x1 -= disp_area->x1;
|
||||
draw_area.y1 -= disp_area->y1;
|
||||
draw_area.x2 -= disp_area->x1;
|
||||
draw_area.y2 -= disp_area->y1;
|
||||
|
||||
int32_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
|
||||
/*Create inner the mask*/
|
||||
lv_draw_mask_radius_param_t mask_rin_param;
|
||||
lv_draw_mask_radius_init(&mask_rin_param, area_inner, rin, true);
|
||||
int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL);
|
||||
|
||||
lv_draw_mask_radius_param_t mask_rout_param;
|
||||
lv_draw_mask_radius_init(&mask_rout_param, area_outer, rout, false);
|
||||
int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL);
|
||||
|
||||
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w);
|
||||
|
||||
int32_t corner_size = LV_MATH_MAX(rout, border_width - 1);
|
||||
|
||||
int32_t h;
|
||||
lv_draw_mask_res_t mask_res;
|
||||
lv_area_t fill_area;
|
||||
|
||||
/*Apply some optimization if there is no other mask*/
|
||||
if(simple_mode) {
|
||||
/*Draw the upper corner area*/
|
||||
int32_t upper_corner_end = area_outer->y1 - disp_area->y1 + corner_size;
|
||||
|
||||
fill_area.x1 = area_outer->x1;
|
||||
fill_area.x2 = area_outer->x2;
|
||||
fill_area.y1 = disp_area->y1 + draw_area.y1;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
for(h = draw_area.y1; h <= upper_corner_end; h++) {
|
||||
_lv_memset_ff(mask_buf, draw_area_w);
|
||||
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
lv_area_t fill_area2;
|
||||
fill_area2.y1 = fill_area.y1;
|
||||
fill_area2.y2 = fill_area.y2;
|
||||
|
||||
fill_area2.x1 = area_outer->x1;
|
||||
fill_area2.x2 = area_outer->x1 + rout - 1;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
|
||||
|
||||
/*Draw the top horizontal line*/
|
||||
if(fill_area2.y2 < area_outer->y1 + border_width) {
|
||||
fill_area2.x1 = area_outer->x1 + rout;
|
||||
fill_area2.x2 = area_outer->x2 - rout;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
}
|
||||
|
||||
fill_area2.x1 = area_outer->x2 - rout + 1;
|
||||
fill_area2.x2 = area_outer->x2;
|
||||
|
||||
int32_t mask_ofs = (area_outer->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
if(mask_ofs < 0) mask_ofs = 0;
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
|
||||
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
}
|
||||
|
||||
/*Draw the lower corner area */
|
||||
int32_t lower_corner_end = area_outer->y2 - disp_area->y1 - corner_size;
|
||||
if(lower_corner_end <= upper_corner_end) lower_corner_end = upper_corner_end + 1;
|
||||
fill_area.y1 = disp_area->y1 + lower_corner_end;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
for(h = lower_corner_end; h <= draw_area.y2; h++) {
|
||||
_lv_memset_ff(mask_buf, draw_area_w);
|
||||
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
lv_area_t fill_area2;
|
||||
fill_area2.x1 = area_outer->x1;
|
||||
fill_area2.x2 = area_outer->x1 + rout - 1;
|
||||
fill_area2.y1 = fill_area.y1;
|
||||
fill_area2.y2 = fill_area.y2;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf, mask_res, opa, blend_mode);
|
||||
|
||||
/*Draw the bottom horizontal line*/
|
||||
if(fill_area2.y2 > area_outer->y2 - border_width) {
|
||||
fill_area2.x1 = area_outer->x1 + rout;
|
||||
fill_area2.x2 = area_outer->x2 - rout;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area2, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
}
|
||||
fill_area2.x1 = area_outer->x2 - rout + 1;
|
||||
fill_area2.x2 = area_outer->x2;
|
||||
|
||||
int32_t mask_ofs = (area_outer->x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
|
||||
if(mask_ofs < 0) mask_ofs = 0;
|
||||
_lv_blend_fill(clip, &fill_area2, color, mask_buf + mask_ofs, mask_res, opa, blend_mode);
|
||||
|
||||
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
}
|
||||
|
||||
/*Draw the left vertical part*/
|
||||
fill_area.y1 = area_outer->y1 + corner_size + 1;
|
||||
fill_area.y2 = area_outer->y2 - corner_size - 1;
|
||||
|
||||
fill_area.x1 = area_outer->x1;
|
||||
fill_area.x2 = area_outer->x1 + border_width - 1;
|
||||
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
|
||||
/*Draw the right vertical border*/
|
||||
fill_area.x1 = area_outer->x2 - border_width + 1;
|
||||
fill_area.x2 = area_outer->x2;
|
||||
|
||||
_lv_blend_fill(clip, &fill_area, color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, blend_mode);
|
||||
}
|
||||
/*Process line by line if there is other mask too*/
|
||||
else {
|
||||
fill_area.x1 = area_outer->x1;
|
||||
fill_area.x2 = area_outer->x2;
|
||||
fill_area.y1 = disp_area->y1 + draw_area.y1;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
|
||||
for(h = draw_area.y1; h <= draw_area.y2; h++) {
|
||||
_lv_memset_ff(mask_buf, draw_area_w);
|
||||
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
|
||||
|
||||
_lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
|
||||
fill_area.y1++;
|
||||
fill_area.y2++;
|
||||
|
||||
}
|
||||
}
|
||||
lv_draw_mask_remove_id(mask_rin_id);
|
||||
lv_draw_mask_remove_id(mask_rout_id);
|
||||
_lv_mem_buf_release(mask_buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,9 @@ void _lv_img_decoder_init(void)
|
||||
lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header)
|
||||
{
|
||||
header->always_zero = 0;
|
||||
header->h = 0;
|
||||
header->w = 0;
|
||||
header->cf = LV_IMG_CF_UNKNOWN;
|
||||
|
||||
lv_res_t res = LV_RES_INV;
|
||||
lv_img_decoder_t * d;
|
||||
@@ -150,10 +153,6 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co
|
||||
if(res == LV_RES_OK) break;
|
||||
}
|
||||
|
||||
if(res == LV_RES_INV) {
|
||||
_lv_memset_00(dsc, sizeof(lv_img_decoder_dsc_t));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -37,14 +37,13 @@ static int32_t unicode_list_compare(const void * ref, const void * element);
|
||||
static int32_t kern_pair_8_compare(const void * ref, const void * element);
|
||||
static int32_t kern_pair_16_compare(const void * ref, const void * element);
|
||||
|
||||
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp);
|
||||
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp, bool prefilter);
|
||||
static inline void decompress_line(uint8_t * out, lv_coord_t w);
|
||||
static inline uint8_t get_bits(const uint8_t * in, uint32_t bit_pos, uint8_t len);
|
||||
static inline void bits_write(uint8_t * out, uint32_t bit_pos, uint8_t val, uint8_t len);
|
||||
static inline void rle_init(const uint8_t * in, uint8_t bpp);
|
||||
static inline uint8_t rle_next(void);
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
@@ -89,6 +88,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
|
||||
}
|
||||
/*Handle compressed bitmap*/
|
||||
else {
|
||||
#if LV_USE_FONT_COMPRESSED
|
||||
uint32_t gsize = gdsc->box_w * gdsc->box_h;
|
||||
if(gsize == 0) return NULL;
|
||||
|
||||
@@ -115,8 +115,13 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
|
||||
if(decompr_buf == NULL) return NULL;
|
||||
}
|
||||
|
||||
decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp);
|
||||
bool prefilter = fdsc->bitmap_format == LV_FONT_FMT_TXT_COMPRESSED ? true : false;
|
||||
decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp,
|
||||
prefilter);
|
||||
return decompr_buf;
|
||||
#else /* !LV_USE_FONT_COMPRESSED */
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*If not returned earlier then the letter is not found in this font*/
|
||||
@@ -334,8 +339,9 @@ static int32_t kern_pair_16_compare(const void * ref, const void * element)
|
||||
* @param out buffer to store the result
|
||||
* @param px_num number of pixels in the glyph (width * height)
|
||||
* @param bpp bit per pixel (bpp = 3 will be converted to bpp = 4)
|
||||
* @param prefilter true: the lines are XORed
|
||||
*/
|
||||
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp)
|
||||
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp, bool prefilter)
|
||||
{
|
||||
uint32_t wrp = 0;
|
||||
uint8_t wr_size = bpp;
|
||||
@@ -344,7 +350,12 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
|
||||
rle_init(in, bpp);
|
||||
|
||||
uint8_t * line_buf1 = _lv_mem_buf_get(w);
|
||||
uint8_t * line_buf2 = _lv_mem_buf_get(w);
|
||||
|
||||
uint8_t * line_buf2 = NULL;
|
||||
|
||||
if(prefilter) {
|
||||
line_buf2 = _lv_mem_buf_get(w);
|
||||
}
|
||||
|
||||
decompress_line(line_buf1, w);
|
||||
|
||||
@@ -357,12 +368,22 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
|
||||
}
|
||||
|
||||
for(y = 1; y < h; y++) {
|
||||
decompress_line(line_buf2, w);
|
||||
if(prefilter) {
|
||||
decompress_line(line_buf2, w);
|
||||
|
||||
for(x = 0; x < w; x++) {
|
||||
line_buf1[x] = line_buf2[x] ^ line_buf1[x];
|
||||
bits_write(out, wrp, line_buf1[x], bpp);
|
||||
wrp += wr_size;
|
||||
for(x = 0; x < w; x++) {
|
||||
line_buf1[x] = line_buf2[x] ^ line_buf1[x];
|
||||
bits_write(out, wrp, line_buf1[x], bpp);
|
||||
wrp += wr_size;
|
||||
}
|
||||
}
|
||||
else {
|
||||
decompress_line(line_buf1, w);
|
||||
|
||||
for(x = 0; x < w; x++) {
|
||||
bits_write(out, wrp, line_buf1[x], bpp);
|
||||
wrp += wr_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ typedef struct {
|
||||
typedef enum {
|
||||
LV_FONT_FMT_TXT_PLAIN = 0,
|
||||
LV_FONT_FMT_TXT_COMPRESSED = 1,
|
||||
LV_FONT_FMT_TXT_COMPRESSED_NO_PREFILTER = 1,
|
||||
} lv_font_fmt_txt_bitmap_format_t;
|
||||
|
||||
|
||||
|
||||
@@ -144,6 +144,15 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
|
||||
disp->inv_p = 0;
|
||||
disp->last_activity_time = 0;
|
||||
|
||||
disp->bg_color = LV_COLOR_WHITE;
|
||||
disp->bg_img = NULL;
|
||||
#if LV_COLOR_SCREEN_TRANSP
|
||||
disp->bg_opa = LV_OPA_TRANSP;
|
||||
#else
|
||||
disp->bg_opa = LV_OPA_COVER;
|
||||
#endif
|
||||
|
||||
disp->prev_scr = NULL;
|
||||
disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/
|
||||
disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
|
||||
disp->sys_layer = lv_obj_create(NULL, NULL); /*Create sys layer on the display*/
|
||||
|
||||
@@ -52,10 +52,10 @@ typedef struct {
|
||||
void * buf_act;
|
||||
uint32_t size; /*In pixel count*/
|
||||
lv_area_t area;
|
||||
volatile int
|
||||
flushing; /*1: flushing is in progress. (It can't be a bitfield because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
|
||||
volatile int
|
||||
flushing_last; /*1: It was the last chunk to flush. (It can't be a bitfield because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
|
||||
/*1: flushing is in progress. (It can't be a bit field because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
|
||||
volatile int flushing;
|
||||
/*1: It was the last chunk to flush. (It can't be a bi tfield because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
|
||||
volatile int flushing_last;
|
||||
volatile uint32_t last_area : 1; /*1: the last area is being rendered*/
|
||||
volatile uint32_t last_part : 1; /*1: the last part of the current area is being rendered*/
|
||||
} lv_disp_buf_t;
|
||||
@@ -146,10 +146,18 @@ typedef struct _disp_t {
|
||||
|
||||
/** Screens of the display*/
|
||||
lv_ll_t scr_ll;
|
||||
struct _lv_obj_t * act_scr; /**< Currently active screen on this display */
|
||||
struct _lv_obj_t * act_scr; /**< Currently active screen on this display */
|
||||
struct _lv_obj_t * prev_scr; /**< Previous screen. Used during screen animations */
|
||||
struct _lv_obj_t * top_layer; /**< @see lv_disp_get_layer_top */
|
||||
struct _lv_obj_t * sys_layer; /**< @see lv_disp_get_layer_sys */
|
||||
|
||||
uint8_t del_prev :
|
||||
1; /**< 1: Automatically delete the previous screen when the screen load animation is ready */
|
||||
|
||||
lv_color_t bg_color; /**< Default display color when screens are transparent*/
|
||||
const void * bg_img; /**< An image source to display as wallpaper*/
|
||||
lv_opa_t bg_opa; /**<Opacity of the background color or wallpaper */
|
||||
|
||||
/** Invalidated (marked to redraw) areas*/
|
||||
lv_area_t inv_areas[LV_INV_BUF_SIZE];
|
||||
uint8_t inv_area_joined[LV_INV_BUF_SIZE];
|
||||
|
||||
@@ -390,7 +390,7 @@ static inline uint32_t lv_color_to32(lv_color_t color)
|
||||
{
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
if(color.full == 0)
|
||||
return 0;
|
||||
return 0xFF000000;
|
||||
else
|
||||
return 0xFFFFFFFF;
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
|
||||
@@ -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
|
||||
**********************/
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_theme.h"
|
||||
#include "../lv_core/lv_obj.h"
|
||||
#include "../../lvgl.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -20,6 +19,8 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
|
||||
static void clear_styles(lv_obj_t * obj, lv_theme_style_t name);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -53,6 +54,69 @@ lv_theme_t * lv_theme_get_act(void)
|
||||
return act_theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the active theme on an object
|
||||
* @param obj pointer to an object
|
||||
* @param name the name of the theme element to apply. E.g. `LV_THEME_BTN`
|
||||
*/
|
||||
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
{
|
||||
/* Remove the existing styles from all part of the object. */
|
||||
clear_styles(obj, name);
|
||||
|
||||
/*Apply the theme including the base theme(s)*/
|
||||
|
||||
apply_theme(act_theme, obj, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a theme to an other or initialize a theme
|
||||
* @param theme pointer to a theme to initialize
|
||||
* @param copy pointer to a theme to copy
|
||||
* or `NULL` to initialize `theme` to empty
|
||||
*/
|
||||
void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy)
|
||||
{
|
||||
_lv_memset_00(theme, sizeof(lv_theme_t));
|
||||
|
||||
if(copy) {
|
||||
theme->font_small = copy->font_small;
|
||||
theme->font_normal = copy->font_normal;
|
||||
theme->font_subtitle = copy->font_subtitle;
|
||||
theme->font_title = copy->font_title;
|
||||
theme->color_primary = copy->color_primary;
|
||||
theme->color_secondary = copy->color_secondary;
|
||||
theme->flags = copy->flags;
|
||||
theme->base = copy->base;
|
||||
theme->apply_cb = copy->apply_cb;
|
||||
theme->apply_xcb = copy->apply_xcb;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a base theme for a theme.
|
||||
* The styles from the base them will be added before the styles of the current theme.
|
||||
* Arbitrary long chain of themes can be created by setting base themes.
|
||||
* @param new_theme pointer to theme which base should be set
|
||||
* @param base pointer to the base theme
|
||||
*/
|
||||
void lv_theme_set_base(lv_theme_t * new_theme, lv_theme_t * base)
|
||||
{
|
||||
new_theme->base = base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback for a theme.
|
||||
* The callback is used to add styles to different objects
|
||||
* @param theme pointer to theme which callback should be set
|
||||
* @param cb pointer to the callback
|
||||
*/
|
||||
void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb)
|
||||
{
|
||||
theme->apply_cb = apply_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the small font of the theme
|
||||
* @return pointer to the font
|
||||
@@ -116,12 +180,299 @@ uint32_t lv_theme_get_flags(void)
|
||||
return act_theme->flags;
|
||||
}
|
||||
|
||||
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
{
|
||||
act_theme->apply_xcb(obj, name);
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
|
||||
{
|
||||
if(th->base) {
|
||||
apply_theme(th->base, obj, name);
|
||||
}
|
||||
|
||||
/*apply_xcb is deprecated, use apply_cb instead*/
|
||||
if(th->apply_xcb) {
|
||||
th->apply_xcb(obj, name);
|
||||
}
|
||||
else if(th->apply_cb) {
|
||||
th->apply_cb(act_theme, obj, name);
|
||||
}
|
||||
}
|
||||
|
||||
static void clear_styles(lv_obj_t * obj, lv_theme_style_t name)
|
||||
{
|
||||
switch(name) {
|
||||
case LV_THEME_NONE:
|
||||
break;
|
||||
|
||||
case LV_THEME_SCR:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
break;
|
||||
case LV_THEME_OBJ:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
break;
|
||||
#if LV_USE_CONT
|
||||
case LV_THEME_CONT:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_BTN
|
||||
case LV_THEME_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_BTNMATRIX
|
||||
case LV_THEME_BTNMATRIX:
|
||||
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_KEYBOARD
|
||||
case LV_THEME_KEYBOARD:
|
||||
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_BAR
|
||||
case LV_THEME_BAR:
|
||||
lv_obj_clean_style_list(obj, LV_BAR_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_SWITCH
|
||||
case LV_THEME_SWITCH:
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC);
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_CANVAS
|
||||
case LV_THEME_CANVAS:
|
||||
lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_IMG
|
||||
case LV_THEME_IMAGE:
|
||||
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_IMGBTN
|
||||
case LV_THEME_IMGBTN:
|
||||
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LABEL
|
||||
case LV_THEME_LABEL:
|
||||
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LINE
|
||||
case LV_THEME_LINE:
|
||||
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_ARC
|
||||
case LV_THEME_ARC:
|
||||
lv_obj_clean_style_list(obj, LV_ARC_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_SPINNER
|
||||
case LV_THEME_SPINNER:
|
||||
lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_SLIDER
|
||||
case LV_THEME_SLIDER:
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC);
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_CHECKBOX
|
||||
case LV_THEME_CHECKBOX:
|
||||
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_MSGBOX
|
||||
case LV_THEME_MSGBOX:
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG);
|
||||
break;
|
||||
|
||||
case LV_THEME_MSGBOX_BTNS:
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG);
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN);
|
||||
break;
|
||||
|
||||
#endif
|
||||
#if LV_USE_LED
|
||||
case LV_THEME_LED:
|
||||
lv_obj_clean_style_list(obj, LV_LED_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_PAGE
|
||||
case LV_THEME_PAGE:
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_TABVIEW
|
||||
case LV_THEME_TABVIEW:
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE);
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG);
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC);
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
|
||||
break;
|
||||
|
||||
case LV_THEME_TABVIEW_PAGE:
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_TILEVIEW
|
||||
case LV_THEME_TILEVIEW:
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_USE_ROLLER
|
||||
case LV_THEME_ROLLER:
|
||||
lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_USE_OBJMASK
|
||||
case LV_THEME_OBJMASK:
|
||||
lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LIST
|
||||
case LV_THEME_LIST:
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE);
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR);
|
||||
break;
|
||||
|
||||
case LV_THEME_LIST_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_DROPDOWN
|
||||
case LV_THEME_DROPDOWN:
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN);
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST);
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_CHART
|
||||
case LV_THEME_CHART:
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG);
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_TABLE
|
||||
case LV_THEME_TABLE:
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1);
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2);
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3);
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_WIN
|
||||
case LV_THEME_WIN:
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR);
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER);
|
||||
break;
|
||||
|
||||
case LV_THEME_WIN_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_TEXTAREA
|
||||
case LV_THEME_TEXTAREA:
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR);
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_USE_SPINBOX
|
||||
case LV_THEME_SPINBOX:
|
||||
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR);
|
||||
break;
|
||||
|
||||
case LV_THEME_SPINBOX_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_CALENDAR
|
||||
case LV_THEME_CALENDAR:
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG);
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE);
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER);
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_CPICKER
|
||||
case LV_THEME_CPICKER:
|
||||
lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN);
|
||||
lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LINEMETER
|
||||
case LV_THEME_LINEMETER:
|
||||
lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_GAUGE
|
||||
case LV_THEME_GAUGE:
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN);
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR);
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ typedef enum {
|
||||
#endif
|
||||
#if LV_USE_SPINBOX
|
||||
LV_THEME_SPINBOX,
|
||||
LV_THEME_SPINBOX_BTN, /*Button extra for spinbox*/
|
||||
LV_THEME_SPINBOX_BTN, /*Control button for the spinbox*/
|
||||
#endif
|
||||
#if LV_USE_SPINNER
|
||||
LV_THEME_SPINNER,
|
||||
@@ -141,13 +141,20 @@ typedef enum {
|
||||
#endif
|
||||
|
||||
_LV_THEME_BUILTIN_LAST,
|
||||
_LV_THEME_CUSTOM_START = _LV_THEME_BUILTIN_LAST,
|
||||
LV_THEME_CUSTOM_START = _LV_THEME_BUILTIN_LAST,
|
||||
_LV_THEME_CUSTOM_LAST = 0xFFFF,
|
||||
|
||||
} lv_theme_style_t;
|
||||
|
||||
typedef struct {
|
||||
void (*apply_xcb)(lv_obj_t *, lv_theme_style_t);
|
||||
struct _lv_theme_t;
|
||||
|
||||
typedef void (*lv_theme_apply_cb_t)(struct _lv_theme_t *, lv_obj_t *, lv_theme_style_t);
|
||||
typedef void (*lv_theme_apply_xcb_t)(lv_obj_t *, lv_theme_style_t); /*Deprecated: use `apply_cb` instead*/
|
||||
|
||||
typedef struct _lv_theme_t {
|
||||
lv_theme_apply_cb_t apply_cb;
|
||||
lv_theme_apply_xcb_t apply_xcb; /*Deprecated: use `apply_cb` instead*/
|
||||
struct _lv_theme_t * base; /**< Apply the current theme's style on top of this theme.*/
|
||||
lv_color_t color_primary;
|
||||
lv_color_t color_secondary;
|
||||
const lv_font_t * font_small;
|
||||
@@ -175,9 +182,37 @@ void lv_theme_set_act(lv_theme_t * th);
|
||||
*/
|
||||
lv_theme_t * lv_theme_get_act(void);
|
||||
|
||||
|
||||
/**
|
||||
* Apply the active theme on an object
|
||||
* @param obj pointer to an object
|
||||
* @param name the name of the theme element to apply. E.g. `LV_THEME_BTN`
|
||||
*/
|
||||
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name);
|
||||
|
||||
/**
|
||||
* Copy a theme to an other or initialize a theme
|
||||
* @param theme pointer to a theme to initialize
|
||||
* @param copy pointer to a theme to copy
|
||||
* or `NULL` to initialize `theme` to empty
|
||||
*/
|
||||
void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy);
|
||||
|
||||
/**
|
||||
* Set a base theme for a theme.
|
||||
* The styles from the base them will be added before the styles of the current theme.
|
||||
* Arbitrary long chain of themes can be created by setting base themes.
|
||||
* @param new_theme pointer to theme which base should be set
|
||||
* @param base pointer to the base theme
|
||||
*/
|
||||
void lv_theme_set_base(lv_theme_t * new_theme, lv_theme_t * base);
|
||||
|
||||
/**
|
||||
* Set an apply callback for a theme.
|
||||
* The apply callback is used to add styles to different objects
|
||||
* @param theme pointer to theme which callback should be set
|
||||
* @param apply_cb pointer to the callback
|
||||
*/
|
||||
void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb);
|
||||
|
||||
/**
|
||||
* Get the small font of the theme
|
||||
@@ -221,7 +256,6 @@ lv_color_t lv_theme_get_color_secondary(void);
|
||||
*/
|
||||
uint32_t lv_theme_get_flags(void);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef struct {
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name);
|
||||
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
|
||||
static void style_init_reset(lv_style_t * style);
|
||||
|
||||
/**********************
|
||||
@@ -89,13 +89,15 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco
|
||||
style_init_reset(&styles->opa_cover);
|
||||
lv_style_set_bg_opa(&styles->opa_cover, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
|
||||
theme.apply_xcb = theme_apply;
|
||||
theme.apply_xcb = NULL;
|
||||
theme.apply_cb = theme_apply;
|
||||
return &theme;
|
||||
}
|
||||
|
||||
|
||||
void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
|
||||
{
|
||||
LV_UNUSED(th);
|
||||
if(name == LV_THEME_SCR) {
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &styles->opa_cover);
|
||||
|
||||
@@ -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)))
|
||||
@@ -176,7 +177,7 @@ typedef struct {
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name);
|
||||
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
|
||||
static void style_init_reset(lv_style_t * style);
|
||||
|
||||
/**********************
|
||||
@@ -210,7 +211,8 @@ static void basic_init(void)
|
||||
lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG);
|
||||
lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, COLOR_BG_BORDER);
|
||||
lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED, theme.color_primary);
|
||||
if((theme.flags & LV_THEME_MATERIAL_FLAG_NO_FOCUS) == 0)lv_style_set_border_color(&styles->bg, LV_STATE_FOCUSED,
|
||||
theme.color_primary);
|
||||
lv_style_set_border_color(&styles->bg, LV_STATE_EDITED, theme.color_secondary);
|
||||
lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH);
|
||||
lv_style_set_border_post(&styles->bg, LV_STATE_DEFAULT, true);
|
||||
@@ -298,7 +300,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 +359,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);
|
||||
|
||||
@@ -608,7 +610,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);
|
||||
@@ -738,7 +740,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);
|
||||
@@ -934,7 +936,8 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s
|
||||
win_init();
|
||||
tabview_win_shared_init();
|
||||
|
||||
theme.apply_xcb = theme_apply;
|
||||
theme.apply_xcb = NULL;
|
||||
theme.apply_cb = theme_apply;
|
||||
|
||||
inited = true;
|
||||
|
||||
@@ -944,8 +947,10 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s
|
||||
}
|
||||
|
||||
|
||||
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
|
||||
{
|
||||
LV_UNUSED(th);
|
||||
|
||||
lv_style_list_t * list;
|
||||
|
||||
switch(name) {
|
||||
@@ -953,18 +958,15 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
break;
|
||||
|
||||
case LV_THEME_SCR:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->scr);
|
||||
break;
|
||||
case LV_THEME_OBJ:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
#if LV_USE_CONT
|
||||
case LV_THEME_CONT:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
@@ -972,7 +974,6 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_BTN
|
||||
case LV_THEME_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
break;
|
||||
@@ -980,12 +981,10 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_BTNMATRIX
|
||||
case LV_THEME_BTNMATRIX:
|
||||
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->bg_click);
|
||||
@@ -994,12 +993,10 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_KEYBOARD
|
||||
case LV_THEME_KEYBOARD:
|
||||
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->scr);
|
||||
_lv_style_list_add_style(list, &styles->kb_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->bg_click);
|
||||
@@ -1008,11 +1005,9 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_BAR
|
||||
case LV_THEME_BAR:
|
||||
lv_obj_clean_style_list(obj, LV_BAR_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_BAR_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bar_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bar_indic);
|
||||
break;
|
||||
@@ -1020,15 +1015,12 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SWITCH
|
||||
case LV_THEME_SWITCH:
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bar_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bar_indic);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB);
|
||||
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &styles->sw_knob);
|
||||
break;
|
||||
@@ -1036,42 +1028,35 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_CANVAS
|
||||
case LV_THEME_CANVAS:
|
||||
lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_IMG
|
||||
case LV_THEME_IMAGE:
|
||||
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_IMGBTN
|
||||
case LV_THEME_IMGBTN:
|
||||
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LABEL
|
||||
case LV_THEME_LABEL:
|
||||
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LINE
|
||||
case LV_THEME_LINE:
|
||||
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_ARC
|
||||
case LV_THEME_ARC:
|
||||
lv_obj_clean_style_list(obj, LV_ARC_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_ARC_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->arc_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->arc_indic);
|
||||
break;
|
||||
@@ -1079,11 +1064,9 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SPINNER
|
||||
case LV_THEME_SPINNER:
|
||||
lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->arc_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->arc_indic);
|
||||
break;
|
||||
@@ -1091,16 +1074,13 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SLIDER
|
||||
case LV_THEME_SLIDER:
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bar_bg);
|
||||
_lv_style_list_add_style(list, &styles->slider_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bar_indic);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB);
|
||||
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &styles->slider_knob);
|
||||
break;
|
||||
@@ -1108,11 +1088,9 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_CHECKBOX
|
||||
case LV_THEME_CHECKBOX:
|
||||
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->cb_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET);
|
||||
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
_lv_style_list_add_style(list, &styles->cb_bullet);
|
||||
@@ -1121,18 +1099,15 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_MSGBOX
|
||||
case LV_THEME_MSGBOX:
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->mbox_bg);
|
||||
break;
|
||||
|
||||
case LV_THEME_MSGBOX_BTNS:
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
break;
|
||||
@@ -1140,27 +1115,22 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
#endif
|
||||
#if LV_USE_LED
|
||||
case LV_THEME_LED:
|
||||
lv_obj_clean_style_list(obj, LV_LED_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->led);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_PAGE
|
||||
case LV_THEME_PAGE:
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
_lv_style_list_add_style(list, &styles->pad_inner);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_EDGE_FLASH);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_EDGE_FLASH);
|
||||
_lv_style_list_add_style(list, &styles->edge_flash);
|
||||
#endif
|
||||
@@ -1168,29 +1138,20 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
#endif
|
||||
#if LV_USE_TABVIEW
|
||||
case LV_THEME_TABVIEW:
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->scr);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG);
|
||||
_lv_style_list_add_style(list, &styles->tabview_btns_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->tabview_indic);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
|
||||
_lv_style_list_add_style(list, &styles->tabview_btns);
|
||||
break;
|
||||
|
||||
case LV_THEME_TABVIEW_PAGE:
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
_lv_style_list_add_style(list, &styles->tabview_page_scrl);
|
||||
|
||||
@@ -1199,16 +1160,13 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_TILEVIEW
|
||||
case LV_THEME_TILEVIEW:
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->scr);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
|
||||
#if LV_USE_ANIMATION
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
|
||||
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
|
||||
_lv_style_list_add_style(list, &styles->edge_flash);
|
||||
#endif
|
||||
@@ -1218,12 +1176,10 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_ROLLER
|
||||
case LV_THEME_ROLLER:
|
||||
lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->roller_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED);
|
||||
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED);
|
||||
_lv_style_list_add_style(list, &styles->roller_sel);
|
||||
break;
|
||||
@@ -1232,27 +1188,22 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_OBJMASK
|
||||
case LV_THEME_OBJMASK:
|
||||
lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LIST
|
||||
case LV_THEME_LIST:
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_LIST_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->list_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
break;
|
||||
|
||||
case LV_THEME_LIST_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->list_btn);
|
||||
break;
|
||||
@@ -1260,22 +1211,18 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_DROPDOWN
|
||||
case LV_THEME_DROPDOWN:
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->bg_click);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->ddlist_page);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED);
|
||||
_lv_style_list_add_style(list, &styles->ddlist_sel);
|
||||
break;
|
||||
@@ -1283,41 +1230,33 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_CHART
|
||||
case LV_THEME_CHART:
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CHART_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->chart_bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
_lv_style_list_add_style(list, &styles->chart_series_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES);
|
||||
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
|
||||
_lv_style_list_add_style(list, &styles->chart_series);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_TABLE
|
||||
case LV_THEME_TABLE:
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1);
|
||||
_lv_style_list_add_style(list, &styles->table_cell);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2);
|
||||
_lv_style_list_add_style(list, &styles->table_cell);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3);
|
||||
_lv_style_list_add_style(list, &styles->table_cell);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4);
|
||||
_lv_style_list_add_style(list, &styles->table_cell);
|
||||
break;
|
||||
@@ -1325,25 +1264,20 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_WIN
|
||||
case LV_THEME_WIN:
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->scr);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
|
||||
_lv_style_list_add_style(list, &styles->tabview_page_scrl);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER);
|
||||
_lv_style_list_add_style(list, &styles->tabview_btns_bg);
|
||||
break;
|
||||
|
||||
case LV_THEME_WIN_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->tabview_btns);
|
||||
break;
|
||||
@@ -1351,20 +1285,16 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_TEXTAREA
|
||||
case LV_THEME_TEXTAREA:
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
|
||||
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
|
||||
_lv_style_list_add_style(list, &styles->ta_placeholder);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR);
|
||||
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR);
|
||||
_lv_style_list_add_style(list, &styles->ta_cursor);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
break;
|
||||
@@ -1374,18 +1304,15 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SPINBOX
|
||||
case LV_THEME_SPINBOX:
|
||||
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR);
|
||||
_lv_style_list_add_style(list, &styles->spinbox_cursor);
|
||||
break;
|
||||
|
||||
case LV_THEME_SPINBOX_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->bg_click);
|
||||
@@ -1394,30 +1321,24 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_CALENDAR
|
||||
case LV_THEME_CALENDAR:
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE);
|
||||
_lv_style_list_add_style(list, &styles->calendar_date_nums);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER);
|
||||
_lv_style_list_add_style(list, &styles->calendar_header);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
|
||||
_lv_style_list_add_style(list, &styles->calendar_daynames);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_CPICKER
|
||||
case LV_THEME_CPICKER:
|
||||
lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->cpicker_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB);
|
||||
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &styles->cpicker_indic);
|
||||
break;
|
||||
@@ -1425,7 +1346,6 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_LINEMETER
|
||||
case LV_THEME_LINEMETER:
|
||||
lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->lmeter);
|
||||
@@ -1433,16 +1353,13 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
#endif
|
||||
#if LV_USE_GAUGE
|
||||
case LV_THEME_GAUGE:
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->gauge_main);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR);
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR);
|
||||
_lv_style_list_add_style(list, &styles->gauge_strong);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE);
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE);
|
||||
_lv_style_list_add_style(list, &styles->gauge_needle);
|
||||
break;
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -38,6 +38,7 @@ typedef struct {
|
||||
lv_style_t pad_normal;
|
||||
lv_style_t pad_small;
|
||||
lv_style_t pad_inner;
|
||||
lv_style_t txt_underline;
|
||||
|
||||
#if LV_USE_ARC
|
||||
lv_style_t arc_bg, arc_indic;
|
||||
@@ -83,7 +84,7 @@ typedef struct {
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name);
|
||||
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
|
||||
static void style_init_reset(lv_style_t * style);
|
||||
|
||||
/**********************
|
||||
@@ -122,6 +123,8 @@ static void basic_init(void)
|
||||
lv_style_set_bg_opa(&styles->bg, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&styles->bg, LV_STATE_DEFAULT, BG_COLOR);
|
||||
lv_style_set_border_width(&styles->bg, LV_STATE_DEFAULT, BORDER_WIDTH);
|
||||
lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED, BORDER_WIDTH * 2);
|
||||
lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED | LV_STATE_EDITED, BORDER_WIDTH * 3);
|
||||
lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR);
|
||||
lv_style_set_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1));
|
||||
lv_style_set_scale_end_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1));
|
||||
@@ -139,10 +142,11 @@ static void basic_init(void)
|
||||
style_init_reset(&styles->clip_corner);
|
||||
lv_style_set_clip_corner(&styles->clip_corner, LV_STATE_DEFAULT, true);
|
||||
|
||||
|
||||
style_init_reset(&styles->btn);
|
||||
lv_style_set_radius(&styles->btn, LV_STATE_DEFAULT, RADIUS);
|
||||
lv_style_set_border_width(&styles->btn, LV_STATE_DEFAULT, BORDER_WIDTH);
|
||||
lv_style_set_border_width(&styles->btn, LV_STATE_FOCUSED, BORDER_WIDTH + 1);
|
||||
lv_style_set_border_width(&styles->btn, LV_STATE_FOCUSED | LV_STATE_EDITED, BORDER_WIDTH + 2);
|
||||
lv_style_set_border_color(&styles->btn, LV_STATE_DEFAULT, FG_COLOR);
|
||||
lv_style_set_bg_color(&styles->btn, LV_STATE_DEFAULT, BG_COLOR);
|
||||
lv_style_set_bg_color(&styles->btn, LV_STATE_PRESSED, FG_COLOR);
|
||||
@@ -204,6 +208,9 @@ static void basic_init(void)
|
||||
|
||||
style_init_reset(&styles->pad_inner);
|
||||
lv_style_set_pad_inner(&styles->pad_inner, LV_STATE_DEFAULT, LV_DPI / 15);
|
||||
|
||||
style_init_reset(&styles->txt_underline);
|
||||
lv_style_set_text_decor(&styles->txt_underline, LV_STATE_FOCUSED, LV_TEXT_DECOR_UNDERLINE);
|
||||
}
|
||||
|
||||
static void arc_init(void)
|
||||
@@ -552,14 +559,17 @@ lv_theme_t * lv_theme_mono_init(lv_color_t color_primary, lv_color_t color_secon
|
||||
table_init();
|
||||
win_init();
|
||||
|
||||
theme.apply_xcb = theme_apply;
|
||||
theme.apply_xcb = NULL;
|
||||
theme.apply_cb = theme_apply;
|
||||
|
||||
return &theme;
|
||||
}
|
||||
|
||||
|
||||
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
|
||||
{
|
||||
LV_UNUSED(th);
|
||||
|
||||
lv_style_list_t * list;
|
||||
|
||||
switch(name) {
|
||||
@@ -567,18 +577,15 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
break;
|
||||
|
||||
case LV_THEME_SCR:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->scr);
|
||||
break;
|
||||
case LV_THEME_OBJ:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
#if LV_USE_CONT
|
||||
case LV_THEME_CONT:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
@@ -586,34 +593,31 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_BTN
|
||||
case LV_THEME_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
_lv_style_list_add_style(list, &styles->txt_underline);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_BTNMATRIX
|
||||
case LV_THEME_BTNMATRIX:
|
||||
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
_lv_style_list_add_style(list, &styles->txt_underline);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_KEYBOARD
|
||||
case LV_THEME_KEYBOARD:
|
||||
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
@@ -622,13 +626,11 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_BAR
|
||||
case LV_THEME_BAR:
|
||||
lv_obj_clean_style_list(obj, LV_BAR_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_BAR_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_none);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->fg_color);
|
||||
@@ -638,18 +640,15 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SWITCH
|
||||
case LV_THEME_SWITCH:
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_none);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->fg_color);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB);
|
||||
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_none);
|
||||
@@ -659,46 +658,39 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_CANVAS
|
||||
case LV_THEME_CANVAS:
|
||||
lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_IMG
|
||||
case LV_THEME_IMAGE:
|
||||
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_IMGBTN
|
||||
case LV_THEME_IMGBTN:
|
||||
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LABEL
|
||||
case LV_THEME_LABEL:
|
||||
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LINE
|
||||
case LV_THEME_LINE:
|
||||
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_ARC
|
||||
case LV_THEME_ARC:
|
||||
lv_obj_clean_style_list(obj, LV_ARC_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_ARC_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->arc_bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->arc_indic);
|
||||
break;
|
||||
@@ -706,12 +698,10 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SPINNER
|
||||
case LV_THEME_SPINNER:
|
||||
lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->tick_line);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->fg_color);
|
||||
@@ -721,59 +711,53 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SLIDER
|
||||
case LV_THEME_SLIDER:
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_none);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->fg_color);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB);
|
||||
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
_lv_style_list_add_style(list, &styles->fg_color);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_CHECKBOX
|
||||
case LV_THEME_CHECKBOX:
|
||||
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET);
|
||||
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_MSGBOX
|
||||
case LV_THEME_MSGBOX:
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
|
||||
case LV_THEME_MSGBOX_BTNS:
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG);
|
||||
_lv_style_list_add_style(list, &styles->pad_inner);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
_lv_style_list_add_style(list, &styles->txt_underline);
|
||||
break;
|
||||
|
||||
#endif
|
||||
#if LV_USE_LED
|
||||
case LV_THEME_LED:
|
||||
lv_obj_clean_style_list(obj, LV_LED_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
@@ -781,45 +765,32 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
#endif
|
||||
#if LV_USE_PAGE
|
||||
case LV_THEME_PAGE:
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
_lv_style_list_add_style(list, &styles->pad_inner);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_TABVIEW
|
||||
case LV_THEME_TABVIEW:
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->scr);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG);
|
||||
_lv_style_list_add_style(list, &styles->tab_bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
_lv_style_list_add_style(list, &styles->txt_underline);
|
||||
break;
|
||||
|
||||
case LV_THEME_TABVIEW_PAGE:
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
_lv_style_list_add_style(list, &styles->pad_normal);
|
||||
|
||||
@@ -828,15 +799,12 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_TILEVIEW
|
||||
case LV_THEME_TILEVIEW:
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
|
||||
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
@@ -845,12 +813,10 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_ROLLER
|
||||
case LV_THEME_ROLLER:
|
||||
lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->big_line_space);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED);
|
||||
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->fg_color);
|
||||
@@ -861,53 +827,44 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_OBJMASK
|
||||
case LV_THEME_OBJMASK:
|
||||
lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LIST
|
||||
case LV_THEME_LIST:
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_LIST_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_none);
|
||||
_lv_style_list_add_style(list, &styles->clip_corner);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
break;
|
||||
|
||||
case LV_THEME_LIST_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
_lv_style_list_add_style(list, &styles->list_btn);
|
||||
_lv_style_list_add_style(list, &styles->txt_underline);
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_DROPDOWN
|
||||
case LV_THEME_DROPDOWN:
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->big_line_space);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->fg_color);
|
||||
@@ -917,42 +874,34 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_CHART
|
||||
case LV_THEME_CHART:
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CHART_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->border_none);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES);
|
||||
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
|
||||
_lv_style_list_add_style(list, &styles->chart_series);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_TABLE
|
||||
case LV_THEME_TABLE:
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->no_radius);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->no_radius);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->no_radius);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->no_radius);
|
||||
@@ -961,25 +910,20 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_WIN
|
||||
case LV_THEME_WIN:
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
|
||||
case LV_THEME_WIN_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
@@ -988,17 +932,12 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_TEXTAREA
|
||||
case LV_THEME_TEXTAREA:
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR);
|
||||
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR);
|
||||
_lv_style_list_add_style(list, &styles->ta_cursor);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->sb);
|
||||
break;
|
||||
@@ -1007,33 +946,30 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SPINBOX
|
||||
case LV_THEME_SPINBOX:
|
||||
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->fg_color);
|
||||
_lv_style_list_add_style(list, &styles->pad_none);
|
||||
_lv_style_list_add_style(list, &styles->no_radius);
|
||||
_lv_style_list_add_style(list, &styles->txt_underline);
|
||||
break;
|
||||
|
||||
case LV_THEME_SPINBOX_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
_lv_style_list_add_style(list, &styles->txt_underline);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_CALENDAR
|
||||
case LV_THEME_CALENDAR:
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
@@ -1041,12 +977,10 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
_lv_style_list_add_style(list, &styles->border_none);
|
||||
_lv_style_list_add_style(list, &styles->calendar_date);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER);
|
||||
_lv_style_list_add_style(list, &styles->pad_normal);
|
||||
_lv_style_list_add_style(list, &styles->border_none);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->pad_small);
|
||||
@@ -1054,11 +988,9 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
#endif
|
||||
#if LV_USE_CPICKER
|
||||
case LV_THEME_CPICKER:
|
||||
lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB);
|
||||
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
@@ -1067,7 +999,6 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_LINEMETER
|
||||
case LV_THEME_LINEMETER:
|
||||
lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
@@ -1076,16 +1007,13 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
#endif
|
||||
#if LV_USE_GAUGE
|
||||
case LV_THEME_GAUGE:
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR);
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR);
|
||||
_lv_style_list_add_style(list, &styles->gauge_major);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE);
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE);
|
||||
_lv_style_list_add_style(list, &styles->gauge_needle);
|
||||
break;
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef struct {
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void theme_apply(lv_obj_t * obj, lv_theme_style_t name);
|
||||
static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -402,14 +402,17 @@ lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_s
|
||||
table_init();
|
||||
win_init();
|
||||
|
||||
theme.apply_xcb = theme_apply;
|
||||
theme.apply_xcb = NULL;
|
||||
theme.apply_cb = theme_apply;
|
||||
|
||||
return &theme;
|
||||
}
|
||||
|
||||
|
||||
void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
|
||||
{
|
||||
LV_UNUSED(th);
|
||||
|
||||
lv_style_list_t * list;
|
||||
|
||||
switch(name) {
|
||||
@@ -417,19 +420,16 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
break;
|
||||
|
||||
case LV_THEME_SCR:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->tight);
|
||||
break;
|
||||
case LV_THEME_OBJ:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
#if LV_USE_CONT
|
||||
case LV_THEME_CONT:
|
||||
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
@@ -437,7 +437,6 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_BTN
|
||||
case LV_THEME_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
@@ -446,11 +445,9 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_BTNMATRIX
|
||||
case LV_THEME_BTNMATRIX:
|
||||
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_BTNMATRIX_PART_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
@@ -459,11 +456,9 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_KEYBOARD
|
||||
case LV_THEME_KEYBOARD:
|
||||
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_KEYBOARD_PART_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_KEYBOARD_PART_BTN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
@@ -472,12 +467,10 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_BAR
|
||||
case LV_THEME_BAR:
|
||||
lv_obj_clean_style_list(obj, LV_BAR_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_BAR_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->tight);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->color);
|
||||
@@ -486,18 +479,15 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SWITCH
|
||||
case LV_THEME_SWITCH:
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->tight);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->color);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB);
|
||||
list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->tight);
|
||||
@@ -507,48 +497,41 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_CANVAS
|
||||
case LV_THEME_CANVAS:
|
||||
lv_obj_clean_style_list(obj, LV_CANVAS_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_IMG
|
||||
case LV_THEME_IMAGE:
|
||||
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_IMGBTN
|
||||
case LV_THEME_IMGBTN:
|
||||
lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LABEL
|
||||
case LV_THEME_LABEL:
|
||||
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LINE
|
||||
case LV_THEME_LINE:
|
||||
lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_ARC
|
||||
case LV_THEME_ARC:
|
||||
lv_obj_clean_style_list(obj, LV_ARC_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_ARC_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->tick_line);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->color);
|
||||
@@ -558,12 +541,10 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SPINNER
|
||||
case LV_THEME_SPINNER:
|
||||
lv_obj_clean_style_list(obj, LV_SPINNER_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->tick_line);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SPINNER_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINNER_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->color);
|
||||
@@ -573,16 +554,13 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SLIDER
|
||||
case LV_THEME_SLIDER:
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->color);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB);
|
||||
list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
@@ -591,10 +569,8 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_CHECKBOX
|
||||
case LV_THEME_CHECKBOX:
|
||||
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CHECKBOX_PART_BULLET);
|
||||
list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
@@ -603,17 +579,14 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_MSGBOX
|
||||
case LV_THEME_MSGBOX:
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
|
||||
case LV_THEME_MSGBOX_BTNS:
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_MSGBOX_PART_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_MSGBOX_PART_BTN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
@@ -622,7 +595,6 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
#endif
|
||||
#if LV_USE_LED
|
||||
case LV_THEME_LED:
|
||||
lv_obj_clean_style_list(obj, LV_LED_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_LED_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->color);
|
||||
@@ -631,53 +603,43 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
#endif
|
||||
#if LV_USE_PAGE
|
||||
case LV_THEME_PAGE:
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->gray);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
#endif
|
||||
#if LV_USE_TABVIEW
|
||||
case LV_THEME_TABVIEW:
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_BG_SCRLLABLE);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->color);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_INDIC);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_INDIC);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->color);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
|
||||
list = lv_obj_get_style_list(obj, LV_TABVIEW_PART_TAB_BTN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
break;
|
||||
|
||||
case LV_THEME_TABVIEW_PAGE:
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->gray);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
@@ -686,15 +648,12 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_TILEVIEW
|
||||
case LV_THEME_TILEVIEW:
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
|
||||
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
@@ -703,11 +662,9 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_ROLLER
|
||||
case LV_THEME_ROLLER:
|
||||
lv_obj_clean_style_list(obj, LV_ROLLER_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_ROLLER_PART_SELECTED);
|
||||
list = lv_obj_get_style_list(obj, LV_ROLLER_PART_SELECTED);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->color);
|
||||
@@ -717,27 +674,22 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_OBJMASK
|
||||
case LV_THEME_OBJMASK:
|
||||
lv_obj_clean_style_list(obj, LV_OBJMASK_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_OBJMASK_PART_MAIN);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LIST
|
||||
case LV_THEME_LIST:
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_LIST_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE);
|
||||
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLABLE);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
|
||||
case LV_THEME_LIST_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
@@ -746,20 +698,16 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_DROPDOWN
|
||||
case LV_THEME_DROPDOWN:
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED);
|
||||
list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->color);
|
||||
@@ -768,15 +716,12 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_CHART
|
||||
case LV_THEME_CHART:
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CHART_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES);
|
||||
list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->tight);
|
||||
@@ -784,23 +729,18 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
#endif
|
||||
#if LV_USE_TABLE
|
||||
case LV_THEME_TABLE:
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL1);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL1);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL2);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL2);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL3);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL3);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TABLE_PART_CELL4);
|
||||
list = lv_obj_get_style_list(obj, LV_TABLE_PART_CELL4);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
@@ -808,25 +748,20 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_WIN
|
||||
case LV_THEME_WIN:
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER);
|
||||
list = lv_obj_get_style_list(obj, LV_WIN_PART_HEADER);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
|
||||
case LV_THEME_WIN_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
@@ -835,20 +770,16 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_TEXTAREA
|
||||
case LV_THEME_TEXTAREA:
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
|
||||
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_PLACEHOLDER);
|
||||
_lv_style_list_add_style(list, &styles->gray);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_CURSOR);
|
||||
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_CURSOR);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->tight);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
|
||||
list = lv_obj_get_style_list(obj, LV_TEXTAREA_PART_SCROLLBAR);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
@@ -857,17 +788,14 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_SPINBOX
|
||||
case LV_THEME_SPINBOX:
|
||||
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_SPINBOX_PART_CURSOR);
|
||||
list = lv_obj_get_style_list(obj, LV_SPINBOX_PART_CURSOR);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
|
||||
case LV_THEME_SPINBOX_BTN:
|
||||
lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
@@ -876,21 +804,17 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_CALENDAR
|
||||
case LV_THEME_CALENDAR:
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_BG);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_BG);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DATE);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DATE);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->btn);
|
||||
_lv_style_list_add_style(list, &styles->tight);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_HEADER);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_HEADER);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
|
||||
list = lv_obj_get_style_list(obj, LV_CALENDAR_PART_DAY_NAMES);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->tight);
|
||||
@@ -898,11 +822,9 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
#endif
|
||||
#if LV_USE_CPICKER
|
||||
case LV_THEME_CPICKER:
|
||||
lv_obj_clean_style_list(obj, LV_CPICKER_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB);
|
||||
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
@@ -911,7 +833,6 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
|
||||
#if LV_USE_LINEMETER
|
||||
case LV_THEME_LINEMETER:
|
||||
lv_obj_clean_style_list(obj, LV_LINEMETER_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
@@ -919,16 +840,13 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
#endif
|
||||
#if LV_USE_GAUGE
|
||||
case LV_THEME_GAUGE:
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAIN);
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAIN);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
_lv_style_list_add_style(list, &styles->round);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_MAJOR);
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_MAJOR);
|
||||
_lv_style_list_add_style(list, &styles->tick_line);
|
||||
|
||||
lv_obj_clean_style_list(obj, LV_GAUGE_PART_NEEDLE);
|
||||
list = lv_obj_get_style_list(obj, LV_GAUGE_PART_NEEDLE);
|
||||
_lv_style_list_add_style(list, &styles->bg);
|
||||
break;
|
||||
@@ -937,10 +855,7 @@ void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -658,7 +658,6 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
|
||||
lv_draw_rect_dsc_t draw_rect_tmp_dsc;
|
||||
lv_draw_label_dsc_t draw_label_tmp_dsc;
|
||||
|
||||
/*The state changes without re-caching the styles, disable the use of cache*/
|
||||
lv_state_t state_ori = btnm->state;
|
||||
btnm->state = LV_STATE_DEFAULT;
|
||||
lv_draw_rect_dsc_init(&draw_rect_rel_dsc);
|
||||
@@ -695,9 +694,20 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
|
||||
/*Choose the style*/
|
||||
lv_draw_rect_dsc_t * draw_rect_dsc_act;
|
||||
lv_draw_label_dsc_t * draw_label_dsc_act;
|
||||
bool tgl_state = button_get_tgl_state(ext->ctrl_bits[btn_i]);
|
||||
lv_state_t btn_state = LV_STATE_DEFAULT;
|
||||
if(button_get_tgl_state(ext->ctrl_bits[btn_i])) btn_state |= LV_STATE_CHECKED;
|
||||
if(button_is_inactive(ext->ctrl_bits[btn_i])) btn_state |= LV_STATE_DISABLED;
|
||||
if(btn_i == ext->btn_id_pr) btn_state |= LV_STATE_PRESSED;
|
||||
if(btn_i == ext->btn_id_focused) {
|
||||
btn_state |= LV_STATE_FOCUSED;
|
||||
if(state_ori & LV_STATE_EDITED) btn_state |= LV_STATE_EDITED;
|
||||
}
|
||||
|
||||
if(tgl_state) {
|
||||
if(btn_state == LV_STATE_DEFAULT) {
|
||||
draw_rect_dsc_act = &draw_rect_rel_dsc;
|
||||
draw_label_dsc_act = &draw_label_rel_dsc;
|
||||
}
|
||||
else if(btn_state == LV_STATE_CHECKED) {
|
||||
if(!chk_inited) {
|
||||
btnm->state = LV_STATE_CHECKED;
|
||||
lv_draw_rect_dsc_init(&draw_rect_chk_dsc);
|
||||
@@ -708,9 +718,10 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
|
||||
btnm->state = state_ori;
|
||||
chk_inited = true;
|
||||
}
|
||||
draw_rect_dsc_act = &draw_rect_chk_dsc;
|
||||
draw_label_dsc_act = &draw_label_chk_dsc;
|
||||
}
|
||||
|
||||
if(button_is_inactive(ext->ctrl_bits[btn_i])) {
|
||||
else if(btn_state == LV_STATE_CHECKED) {
|
||||
if(!disabled_inited) {
|
||||
btnm->state = LV_STATE_DISABLED;
|
||||
lv_draw_rect_dsc_init(&draw_rect_ina_dsc);
|
||||
@@ -724,21 +735,9 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
|
||||
draw_rect_dsc_act = &draw_rect_ina_dsc;
|
||||
draw_label_dsc_act = &draw_label_ina_dsc;
|
||||
}
|
||||
/*Simple released or checked buttons button*/
|
||||
else if(btn_i != ext->btn_id_pr && btn_i != ext->btn_id_focused) {
|
||||
draw_rect_dsc_act = tgl_state ? &draw_rect_chk_dsc : &draw_rect_rel_dsc;
|
||||
draw_label_dsc_act = tgl_state ? &draw_label_chk_dsc : &draw_label_rel_dsc;
|
||||
}
|
||||
/*Focused and/or pressed + checked or released button*/
|
||||
/*In other cases get the styles directly without caching them*/
|
||||
else {
|
||||
btnm->state = LV_STATE_DEFAULT;
|
||||
if(tgl_state) btnm->state = LV_STATE_CHECKED;
|
||||
if(ext->btn_id_pr == btn_i) btnm->state |= LV_STATE_PRESSED;
|
||||
if(ext->btn_id_focused == btn_i) {
|
||||
btnm->state |= LV_STATE_FOCUSED;
|
||||
if(state_ori & LV_STATE_EDITED) btnm->state |= LV_STATE_EDITED;
|
||||
}
|
||||
|
||||
btnm->state = btn_state;
|
||||
lv_draw_rect_dsc_init(&draw_rect_tmp_dsc);
|
||||
lv_draw_label_dsc_init(&draw_label_tmp_dsc);
|
||||
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_tmp_dsc);
|
||||
|
||||
@@ -57,7 +57,11 @@ static uint8_t is_leap_year(uint32_t year);
|
||||
**********************/
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_design;
|
||||
#if LV_CALENDAR_WEEK_STARTS_MONDAY != 0
|
||||
static const char * day_name[7] = {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"};
|
||||
#else
|
||||
static const char * day_name[7] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};
|
||||
#endif
|
||||
static const char * month_name[12] = {"January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"
|
||||
};
|
||||
@@ -1059,14 +1063,18 @@ static uint8_t is_leap_year(uint32_t year)
|
||||
* @param year a year
|
||||
* @param month a month
|
||||
* @param day a day
|
||||
* @return [0..6] which means [Sun..Sat]
|
||||
* @return [0..6] which means [Sun..Sat] or [Mon..Sun] depending on LV_CALENDAR_WEEK_STARTS_MONDAY
|
||||
*/
|
||||
static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day)
|
||||
{
|
||||
uint32_t a = month < 3 ? 1 : 0;
|
||||
uint32_t b = year - a;
|
||||
|
||||
#if LV_CALENDAR_WEEK_STARTS_MONDAY
|
||||
uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400) - 1) % 7;
|
||||
#else
|
||||
uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7;
|
||||
#endif
|
||||
|
||||
return day_of_week;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
/**
|
||||
* Set a buffer for the canvas.
|
||||
* @param buf a buffer where the content of the canvas will be.
|
||||
* The required size is (lv_img_color_format_get_px_size(cf) * w * h) / 8)
|
||||
* The required size is (lv_img_color_format_get_px_size(cf) * w) / 8 * h)
|
||||
* It can be allocated with `lv_mem_alloc()` or
|
||||
* it can be statically allocated array (e.g. static lv_color_t buf[100*50]) or
|
||||
* it can be an address in RAM or external SRAM
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#define LV_CHART_PNUM_DEF 10
|
||||
#define LV_CHART_AXIS_MAJOR_TICK_LEN_COE 1 / 15
|
||||
#define LV_CHART_AXIS_MINOR_TICK_LEN_COE 2 / 3
|
||||
#define LV_CHART_AXIS_PRIMARY_Y 1
|
||||
#define LV_CHART_AXIS_SECONDARY_Y 0
|
||||
#define LV_CHART_LABEL_ITERATOR_FORWARD 1
|
||||
#define LV_CHART_LABEL_ITERATOR_REVERSE 0
|
||||
|
||||
@@ -101,8 +99,12 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
_lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t));
|
||||
|
||||
ext->ymin = LV_CHART_YMIN_DEF;
|
||||
ext->ymax = LV_CHART_YMAX_DEF;
|
||||
uint8_t i;
|
||||
for(i = 0; i < _LV_CHART_AXIS_LAST; i++) {
|
||||
ext->ymin[i] = LV_CHART_YMIN_DEF;
|
||||
ext->ymax[i] = LV_CHART_YMAX_DEF;
|
||||
}
|
||||
|
||||
ext->hdiv_cnt = LV_CHART_HDIV_DEF;
|
||||
ext->vdiv_cnt = LV_CHART_VDIV_DEF;
|
||||
ext->point_cnt = LV_CHART_PNUM_DEF;
|
||||
@@ -118,7 +120,6 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->secondary_y_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
||||
ext->secondary_y_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO;
|
||||
|
||||
|
||||
lv_style_list_init(&ext->style_series_bg);
|
||||
lv_style_list_init(&ext->style_series);
|
||||
|
||||
@@ -133,7 +134,6 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_set_size(chart, LV_DPI * 3, LV_DPI * 2);
|
||||
|
||||
lv_theme_apply(chart, LV_THEME_CHART);
|
||||
|
||||
}
|
||||
else {
|
||||
lv_chart_ext_t * ext_copy = lv_obj_get_ext_attr(copy);
|
||||
@@ -142,11 +142,11 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_style_list_copy(&ext->style_series_bg, &ext_copy->style_series_bg);
|
||||
|
||||
ext->type = ext_copy->type;
|
||||
ext->ymin = ext_copy->ymin;
|
||||
ext->ymax = ext_copy->ymax;
|
||||
ext->hdiv_cnt = ext_copy->hdiv_cnt;
|
||||
ext->vdiv_cnt = ext_copy->vdiv_cnt;
|
||||
ext->point_cnt = ext_copy->point_cnt;
|
||||
_lv_memcpy_small(ext->ymin, ext_copy->ymin, sizeof(ext->ymin));
|
||||
_lv_memcpy_small(ext->ymax, ext_copy->ymax, sizeof(ext->ymax));
|
||||
_lv_memcpy(&ext->x_axis, &ext_copy->x_axis, sizeof(lv_chart_axis_cfg_t));
|
||||
_lv_memcpy(&ext->y_axis, &ext_copy->y_axis, sizeof(lv_chart_axis_cfg_t));
|
||||
_lv_memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t));
|
||||
@@ -191,6 +191,8 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
|
||||
}
|
||||
|
||||
ser->start_point = 0;
|
||||
ser->ext_buf_assigned = false;
|
||||
ser->y_axis = LV_CHART_AXIS_PRIMARY_Y;
|
||||
|
||||
uint16_t i;
|
||||
lv_coord_t * p_tmp = ser->points;
|
||||
@@ -248,20 +250,26 @@ void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the minimal and maximal y values
|
||||
* Set the minimal and maximal y values on an axis
|
||||
* @param chart pointer to a graph background object
|
||||
* @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
|
||||
* @param ymin y minimum value
|
||||
* @param ymax y maximum value
|
||||
*/
|
||||
void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax)
|
||||
void lv_chart_set_y_range(lv_obj_t * chart, lv_chart_axis_t axis, lv_coord_t ymin, lv_coord_t ymax)
|
||||
{
|
||||
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext->ymin == ymin && ext->ymax == ymax) return;
|
||||
if(axis >= _LV_CHART_AXIS_LAST) {
|
||||
LV_LOG_WARN("Invalid axis: %d", axis);
|
||||
return;
|
||||
}
|
||||
|
||||
ext->ymin = ymin;
|
||||
ext->ymax = ymax;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext->ymin[axis] == ymin && ext->ymax[axis] == ymax) return;
|
||||
|
||||
ext->ymin[axis] = ymin;
|
||||
ext->ymax[axis] = ymax;
|
||||
|
||||
lv_chart_refresh(chart);
|
||||
}
|
||||
@@ -303,43 +311,44 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
|
||||
if(point_cnt < 1) point_cnt = 1;
|
||||
|
||||
_LV_LL_READ_BACK(ext->series_ll, ser) {
|
||||
if(ser->start_point != 0) {
|
||||
lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt);
|
||||
LV_ASSERT_MEM(new_points);
|
||||
if(new_points == NULL) return;
|
||||
if(!ser->ext_buf_assigned) {
|
||||
if(ser->start_point != 0) {
|
||||
lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * point_cnt);
|
||||
LV_ASSERT_MEM(new_points);
|
||||
if(new_points == NULL) return;
|
||||
|
||||
if(point_cnt >= point_cnt_old) {
|
||||
for(i = 0; i < point_cnt_old; i++) {
|
||||
new_points[i] =
|
||||
ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
|
||||
if(point_cnt >= point_cnt_old) {
|
||||
for(i = 0; i < point_cnt_old; i++) {
|
||||
new_points[i] =
|
||||
ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
|
||||
}
|
||||
for(i = point_cnt_old; i < point_cnt; i++) {
|
||||
new_points[i] = def; /*Fill up the rest with default value*/
|
||||
}
|
||||
}
|
||||
for(i = point_cnt_old; i < point_cnt; i++) {
|
||||
new_points[i] = def; /*Fill up the rest with default value*/
|
||||
else {
|
||||
for(i = 0; i < point_cnt; i++) {
|
||||
new_points[i] =
|
||||
ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
|
||||
}
|
||||
}
|
||||
|
||||
/*Switch over pointer from old to new*/
|
||||
lv_mem_free(ser->points);
|
||||
ser->points = new_points;
|
||||
}
|
||||
else {
|
||||
for(i = 0; i < point_cnt; i++) {
|
||||
new_points[i] =
|
||||
ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
|
||||
}
|
||||
}
|
||||
|
||||
/*Switch over pointer from old to new*/
|
||||
lv_mem_free(ser->points);
|
||||
ser->points = new_points;
|
||||
}
|
||||
else {
|
||||
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
|
||||
LV_ASSERT_MEM(ser->points);
|
||||
if(ser->points == NULL) return;
|
||||
/*Initialize the new points*/
|
||||
if(point_cnt > point_cnt_old) {
|
||||
for(i = point_cnt_old - 1; i < point_cnt; i++) {
|
||||
ser->points[i] = def;
|
||||
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
|
||||
LV_ASSERT_MEM(ser->points);
|
||||
if(ser->points == NULL) return;
|
||||
/*Initialize the new points*/
|
||||
if(point_cnt > point_cnt_old) {
|
||||
for(i = point_cnt_old - 1; i < point_cnt; i++) {
|
||||
ser->points[i] = def;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ser->start_point = 0;
|
||||
}
|
||||
|
||||
@@ -540,6 +549,86 @@ void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_
|
||||
ext->secondary_y_axis.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the index of the x-axis start point in the data array
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to a data series on 'chart'
|
||||
* @param id the index of the x point in the data array
|
||||
*/
|
||||
void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id)
|
||||
{
|
||||
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(ser);
|
||||
|
||||
if(chart == NULL || ser == NULL) return;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext == NULL) return;
|
||||
if(id >= ext->point_cnt) return;
|
||||
ser->start_point = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an external array of data points to use for the chart
|
||||
* NOTE: It is the users responsibility to make sure the point_cnt matches the external array size.
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to a data series on 'chart'
|
||||
* @param array external array of points for chart
|
||||
* @param point_cnt number of external points in the array
|
||||
*/
|
||||
void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt)
|
||||
{
|
||||
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(ser);
|
||||
|
||||
if(chart == NULL || ser == NULL) return;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(!ser->ext_buf_assigned && ser->points) lv_mem_free(ser->points);
|
||||
ser->ext_buf_assigned = true;
|
||||
ser->points = array;
|
||||
ext->point_cnt = point_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an individual point y value in the chart series directly based on index
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to a data series on 'chart'
|
||||
* @param value value to assign to array point
|
||||
* @param id the index of the x point in the array
|
||||
*/
|
||||
void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id)
|
||||
{
|
||||
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(ser);
|
||||
|
||||
if(chart == NULL || ser == NULL) return;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext == NULL) return;
|
||||
if(id >= ext->point_cnt) return;
|
||||
ser->points[id] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Y axis of a series
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to series
|
||||
* @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
|
||||
*/
|
||||
void lv_chart_set_series_axis(lv_obj_t * chart, lv_chart_series_t * ser, lv_chart_axis_t axis)
|
||||
{
|
||||
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(ser);
|
||||
|
||||
if(axis >= _LV_CHART_AXIS_LAST) {
|
||||
LV_LOG_WARN("Invalid axis: %d", axis);
|
||||
return;
|
||||
}
|
||||
|
||||
if(ser->y_axis == axis) return;
|
||||
|
||||
ser->y_axis = axis;
|
||||
lv_chart_refresh(chart);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@@ -570,6 +659,49 @@ uint16_t lv_chart_get_point_count(const lv_obj_t * chart)
|
||||
return ext->point_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current index of the x-axis start point in the data array
|
||||
* @param ser pointer to a data series on 'chart'
|
||||
* @return the index of the current x start point in the data array
|
||||
*/
|
||||
uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser)
|
||||
{
|
||||
LV_ASSERT_NULL(ser);
|
||||
|
||||
return(ser->start_point);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an individual point y value in the chart series directly based on index
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to a data series on 'chart'
|
||||
* @param id the index of the x point in the array
|
||||
* @return value of array point at index id
|
||||
*/
|
||||
lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id)
|
||||
{
|
||||
LV_ASSERT_OBJ(chart, LV_OBJX_NAME);
|
||||
LV_ASSERT_NULL(ser);
|
||||
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(id >= ext->point_cnt) id = 0;
|
||||
return(ser->points[id]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Y axis of a series
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to series
|
||||
* @return `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
|
||||
*/
|
||||
lv_chart_axis_t lv_chart_get_series_axis(lv_obj_t * chart, lv_chart_series_t * ser)
|
||||
{
|
||||
LV_ASSERT_NULL(ser);
|
||||
LV_UNUSED(chart);
|
||||
|
||||
return ser->y_axis;
|
||||
}
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
@@ -651,8 +783,12 @@ static lv_res_t lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
lv_chart_series_t * ser;
|
||||
_LV_LL_READ(ext->series_ll, ser) {
|
||||
lv_mem_free(ser->points);
|
||||
while(ext->series_ll.head != NULL) {
|
||||
ser = _lv_ll_get_head(&ext->series_ll);
|
||||
|
||||
if(!ser->ext_buf_assigned) lv_mem_free(ser->points);
|
||||
|
||||
_lv_ll_remove(&ext->series_ll, ser);
|
||||
lv_mem_free(ser);
|
||||
}
|
||||
_lv_ll_clear(&ext->series_ll);
|
||||
@@ -837,8 +973,8 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co
|
||||
|
||||
lv_coord_t p_act = start_point;
|
||||
lv_coord_t p_prev = start_point;
|
||||
int32_t y_tmp = (int32_t)((int32_t)ser->points[p_prev] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
int32_t y_tmp = (int32_t)((int32_t)ser->points[p_prev] - ext->ymin[ser->y_axis]) * h;
|
||||
y_tmp = y_tmp / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
for(i = 0; i < ext->point_cnt; i++) {
|
||||
@@ -849,8 +985,8 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co
|
||||
|
||||
p_act = (start_point + i) % ext->point_cnt;
|
||||
|
||||
y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin[ser->y_axis]) * h;
|
||||
y_tmp = y_tmp / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
/*Don't draw the first point. A second point is also required to draw the line*/
|
||||
@@ -973,8 +1109,8 @@ static void draw_series_column(lv_obj_t * chart, const lv_area_t * series_area,
|
||||
col_dsc.bg_color = ser->color;
|
||||
|
||||
lv_coord_t p_act = (start_point + i) % ext->point_cnt;
|
||||
y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin[ser->y_axis]) * h;
|
||||
y_tmp = y_tmp / (ext->ymax[ser->y_axis] - ext->ymin[ser->y_axis]);
|
||||
col_a.y1 = h - y_tmp + series_area->y1;
|
||||
|
||||
if(ser->points[p_act] != LV_CHART_POINT_DEF) {
|
||||
@@ -1371,6 +1507,9 @@ static void invalidate_lines(lv_obj_t * chart, uint16_t i)
|
||||
|
||||
lv_area_t coords;
|
||||
lv_area_copy(&coords, &series_area);
|
||||
coords.y1 -= line_width + point_radius;
|
||||
coords.y2 += line_width + point_radius;
|
||||
|
||||
if(i < ext->point_cnt - 1) {
|
||||
coords.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs - line_width - point_radius;
|
||||
coords.x2 = ((w * (i + 1)) / (ext->point_cnt - 1)) + x_ofs + line_width + point_radius;
|
||||
|
||||
@@ -42,6 +42,7 @@ enum {
|
||||
LV_CHART_TYPE_NONE = 0x00, /**< Don't draw the series*/
|
||||
LV_CHART_TYPE_LINE = 0x01, /**< Connect the points with lines*/
|
||||
LV_CHART_TYPE_COLUMN = 0x02, /**< Draw columns*/
|
||||
LV_CHART_TYPE_SCATTER = 0x03, /**< X/Y chart, points and/or lines*/
|
||||
};
|
||||
typedef uint8_t lv_chart_type_t;
|
||||
|
||||
@@ -52,17 +53,27 @@ enum {
|
||||
};
|
||||
typedef uint8_t lv_chart_update_mode_t;
|
||||
|
||||
|
||||
enum {
|
||||
LV_CHART_AXIS_PRIMARY_Y,
|
||||
LV_CHART_AXIS_SECONDARY_Y,
|
||||
_LV_CHART_AXIS_LAST,
|
||||
};
|
||||
typedef uint8_t lv_chart_axis_t;
|
||||
|
||||
typedef struct {
|
||||
lv_coord_t * points;
|
||||
lv_color_t color;
|
||||
uint16_t start_point;
|
||||
uint8_t ext_buf_assigned : 1;
|
||||
lv_chart_axis_t y_axis : 1;
|
||||
} lv_chart_series_t;
|
||||
|
||||
/** Data of axis */
|
||||
enum {
|
||||
LV_CHART_AXIS_SKIP_LAST_TICK = 0x00, /**< don't draw the last tick */
|
||||
LV_CHART_AXIS_DRAW_LAST_TICK = 0x01, /**< draw the last tick */
|
||||
LV_CHART_AXIS_INVERSE_LABELS_ORDER = 0x02 /**< draw tick labels in an inversed order*/
|
||||
LV_CHART_AXIS_INVERSE_LABELS_ORDER = 0x02 /**< draw tick labels in an inverted order*/
|
||||
};
|
||||
typedef uint8_t lv_chart_axis_options_t;
|
||||
|
||||
@@ -79,8 +90,8 @@ typedef struct {
|
||||
/*No inherited ext*/ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
lv_ll_t series_ll; /*Linked list for the data line pointers (stores lv_chart_series_t)*/
|
||||
lv_coord_t ymin; /*y min value (used to scale the data)*/
|
||||
lv_coord_t ymax; /*y max value (used to scale the data)*/
|
||||
lv_coord_t ymin[_LV_CHART_AXIS_LAST]; /*y min values for both axis (used to scale the data)*/
|
||||
lv_coord_t ymax[_LV_CHART_AXIS_LAST]; /*y max values for both axis (used to scale the data)*/
|
||||
uint8_t hdiv_cnt; /*Number of horizontal division lines*/
|
||||
uint8_t vdiv_cnt; /*Number of vertical division lines*/
|
||||
uint16_t point_cnt; /*Point number in a data line*/
|
||||
@@ -136,6 +147,7 @@ void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie);
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
|
||||
/**
|
||||
* Set the number of horizontal and vertical division lines
|
||||
* @param chart pointer to a graph background object
|
||||
@@ -145,12 +157,13 @@ void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie);
|
||||
void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv);
|
||||
|
||||
/**
|
||||
* Set the minimal and maximal y values
|
||||
* Set the minimal and maximal y values on an axis
|
||||
* @param chart pointer to a graph background object
|
||||
* @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
|
||||
* @param ymin y minimum value
|
||||
* @param ymax y maximum value
|
||||
*/
|
||||
void lv_chart_set_range(lv_obj_t * chart, lv_coord_t ymin, lv_coord_t ymax);
|
||||
void lv_chart_set_y_range(lv_obj_t * chart, lv_chart_axis_t axis, lv_coord_t ymin, lv_coord_t ymax);
|
||||
|
||||
/**
|
||||
* Set a new type for a chart
|
||||
@@ -260,6 +273,40 @@ void lv_chart_set_secondary_y_tick_texts(lv_obj_t * chart, const char * list_of_
|
||||
void lv_chart_set_y_tick_texts(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks,
|
||||
lv_chart_axis_options_t options);
|
||||
|
||||
/**
|
||||
* Set the index of the x-axis start point in the data array
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to a data series on 'chart'
|
||||
* @param id the index of the x point in the data array
|
||||
*/
|
||||
void lv_chart_set_x_start_point(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id);
|
||||
|
||||
/**
|
||||
* Set an external array of data points to use for the chart
|
||||
* NOTE: It is the users responsibility to make sure the point_cnt matches the external array size.
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to a data series on 'chart'
|
||||
* @param array external array of points for chart
|
||||
*/
|
||||
void lv_chart_set_ext_array(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t array[], uint16_t point_cnt);
|
||||
|
||||
/**
|
||||
* Set an individual point value in the chart series directly based on index
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to a data series on 'chart'
|
||||
* @param value value to assign to array point
|
||||
* @param id the index of the x point in the array
|
||||
*/
|
||||
void lv_chart_set_point_id(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t value, uint16_t id);
|
||||
|
||||
/**
|
||||
* Set the Y axis of a series
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to series
|
||||
* @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
|
||||
*/
|
||||
void lv_chart_set_series_axis(lv_obj_t * chart, lv_chart_series_t * ser, lv_chart_axis_t axis);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@@ -278,6 +325,30 @@ lv_chart_type_t lv_chart_get_type(const lv_obj_t * chart);
|
||||
*/
|
||||
uint16_t lv_chart_get_point_count(const lv_obj_t * chart);
|
||||
|
||||
/**
|
||||
* get the current index of the x-axis start point in the data array
|
||||
* @param ser pointer to a data series on 'chart'
|
||||
* @return the index of the current x start point in the data array
|
||||
*/
|
||||
uint16_t lv_chart_get_x_start_point(lv_chart_series_t * ser);
|
||||
|
||||
/**
|
||||
* Get an individual point value in the chart series directly based on index
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to a data series on 'chart'
|
||||
* @param id the index of the x point in the array
|
||||
* @return value of array point at index id
|
||||
*/
|
||||
lv_coord_t lv_chart_get_point_id(lv_obj_t * chart, lv_chart_series_t * ser, uint16_t id);
|
||||
|
||||
/**
|
||||
* Get the Y axis of a series
|
||||
* @param chart pointer to a chart object
|
||||
* @param ser pointer to series
|
||||
* @return `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
|
||||
*/
|
||||
lv_chart_axis_t lv_chart_get_series_axis(lv_obj_t * chart, lv_chart_series_t * ser);
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
@@ -106,6 +106,15 @@ static inline void lv_checkbox_set_disabled(lv_obj_t * cb)
|
||||
lv_btn_set_state(cb, LV_BTN_STATE_DISABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the state of a check box
|
||||
* @param cb pointer to a check box object
|
||||
* @param state the new state of the check box (from lv_btn_state_t enum)
|
||||
*/
|
||||
static inline void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state)
|
||||
{
|
||||
lv_btn_set_state(cb, state);
|
||||
}
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@@ -137,6 +146,15 @@ static inline bool lv_checkbox_is_inactive(const lv_obj_t * cb)
|
||||
return lv_btn_get_state(cb) == LV_BTN_STATE_DISABLED ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current state of a check box
|
||||
* @param cb pointer to a check box object
|
||||
* @return the state of the check box (from lv_btn_state_t enum)
|
||||
*/
|
||||
static inline lv_btn_state_t lv_checkbox_get_state(const lv_obj_t * cb)
|
||||
{
|
||||
return lv_btn_get_state(cb);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -628,7 +628,7 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
|
||||
_LV_LL_READ_BACK(cont->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
|
||||
lv_coord_t obj_w = lv_obj_get_width(child);
|
||||
if(act_x + inner + obj_w > w_fit) {
|
||||
if(act_x + obj_w > w_fit + left) {
|
||||
act_x = left;
|
||||
act_y += y_ofs;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,13 @@
|
||||
|
||||
#define TRI_OFFSET 2
|
||||
|
||||
/* The OUTER_MASK_WIDTH define is required to assist with the placing of a mask over the outer ring of the widget as when the
|
||||
* multicoloured radial lines are calculated for the outer ring of the widget their lengths are jittering because of the
|
||||
* integer based arithmetic. From tests the maximum delta was found to be 2 so the current value is set to 3 to achieve
|
||||
* appropriate masking.
|
||||
*/
|
||||
#define OUTER_MASK_WIDTH 3
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@@ -483,6 +490,17 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask)
|
||||
uint16_t i;
|
||||
lv_coord_t cir_w = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN);
|
||||
|
||||
/* Mask outer ring of widget to tidy up ragged edges of lines while drawing outer ring */
|
||||
lv_area_t mask_area_out;
|
||||
lv_area_copy(&mask_area_out, &cpicker->coords);
|
||||
mask_area_out.x1 += OUTER_MASK_WIDTH;
|
||||
mask_area_out.x2 -= OUTER_MASK_WIDTH;
|
||||
mask_area_out.y1 += OUTER_MASK_WIDTH;
|
||||
mask_area_out.y2 -= OUTER_MASK_WIDTH;
|
||||
lv_draw_mask_radius_param_t mask_out_param;
|
||||
lv_draw_mask_radius_init(&mask_out_param, &mask_area_out, LV_RADIUS_CIRCLE, false);
|
||||
int16_t mask_out_id = lv_draw_mask_add(&mask_out_param, 0);
|
||||
|
||||
/* The inner line ends will be masked out.
|
||||
* So make lines a little bit longer because the masking makes a more even result */
|
||||
lv_coord_t cir_w_extra = cir_w + line_dsc.width;
|
||||
@@ -498,7 +516,8 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask)
|
||||
|
||||
lv_draw_line(&p[0], &p[1], mask, &line_dsc);
|
||||
}
|
||||
|
||||
/* Now remove mask to continue with inner part */
|
||||
lv_draw_mask_remove_id(mask_out_id);
|
||||
|
||||
/*Mask out the inner area*/
|
||||
lv_draw_rect_dsc_t bg_dsc;
|
||||
|
||||
@@ -589,15 +589,6 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area)
|
||||
lv_draw_line_dsc_init(&line_dsc);
|
||||
lv_obj_init_draw_line_dsc(gauge, LV_GAUGE_PART_NEEDLE, &line_dsc);
|
||||
|
||||
lv_draw_img_dsc_t img_dsc;
|
||||
if(ext->needle_img == NULL) {
|
||||
lv_draw_img_dsc_init(&img_dsc);
|
||||
lv_obj_init_draw_img_dsc(gauge, LV_GAUGE_PART_MAIN, &img_dsc);
|
||||
img_dsc.recolor_opa = LV_OPA_COVER;
|
||||
img_dsc.pivot.x = ext->needle_img_pivot.x;
|
||||
img_dsc.pivot.y = ext->needle_img_pivot.y;
|
||||
}
|
||||
|
||||
p_mid.x = x_ofs;
|
||||
p_mid.y = y_ofs;
|
||||
for(i = 0; i < ext->needle_count; i++) {
|
||||
@@ -625,10 +616,18 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * clip_area)
|
||||
a.y1 = gauge->coords.y1 + lv_area_get_height(&gauge->coords) / 2 - ext->needle_img_pivot.y;
|
||||
a.x2 = a.x1 + info.w - 1;
|
||||
a.y2 = a.y1 + info.h - 1;
|
||||
lv_draw_img_dsc_t img_dsc;
|
||||
lv_draw_img_dsc_init(&img_dsc);
|
||||
lv_obj_init_draw_img_dsc(gauge, LV_GAUGE_PART_MAIN, &img_dsc);
|
||||
img_dsc.recolor_opa = LV_OPA_COVER;
|
||||
img_dsc.pivot.x = ext->needle_img_pivot.x;
|
||||
img_dsc.pivot.y = ext->needle_img_pivot.y;
|
||||
|
||||
if(ext->needle_colors != NULL)
|
||||
img_dsc.recolor = ext->needle_colors[i];
|
||||
|
||||
needle_angle = (needle_angle * 10);
|
||||
if(needle_angle > 3600) needle_angle -= 3600;
|
||||
img_dsc.angle = needle_angle;
|
||||
lv_draw_img(&a, clip_area, ext->needle_img, &img_dsc);
|
||||
}
|
||||
|
||||
@@ -126,9 +126,9 @@ void lv_linemeter_set_value(lv_obj_t * lmeter, int32_t value)
|
||||
ext->cur_value = ext->cur_value < ext->min_value ? ext->min_value : ext->cur_value;
|
||||
|
||||
int16_t level_old =
|
||||
(int32_t)((int32_t)(old_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
|
||||
(int32_t)((int32_t)(old_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value);
|
||||
int16_t level_new =
|
||||
(int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
|
||||
(int32_t)((int32_t)(ext->cur_value - ext->min_value) * (ext->line_cnt - 1)) / (ext->max_value - ext->min_value);
|
||||
|
||||
if(level_new == level_old) {
|
||||
return;
|
||||
@@ -393,7 +393,7 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
|
||||
lv_coord_t y_ofs = lmeter->coords.y1 + r_out + top;
|
||||
int16_t angle_ofs = ext->angle_ofs + 90 + (360 - ext->scale_angle) / 2;
|
||||
int16_t level =
|
||||
(int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
|
||||
(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);
|
||||
@@ -519,7 +519,8 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
|
||||
p1.x = x_out_extra;
|
||||
p1.y = y_out_extra;
|
||||
|
||||
if(i >= level) {
|
||||
/* Set the color of the lines */
|
||||
if(i > level) {
|
||||
line_dsc.color = end_color;
|
||||
line_dsc.width = end_line_width;
|
||||
}
|
||||
@@ -538,12 +539,12 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
|
||||
lv_draw_mask_remove_id(mask_out_id);
|
||||
#endif
|
||||
|
||||
if(part == LV_LINEMETER_PART_MAIN) {
|
||||
if(part == LV_LINEMETER_PART_MAIN && level + 1 < ext->line_cnt - 1) {
|
||||
lv_style_int_t border_width = lv_obj_get_style_scale_border_width(lmeter, part);
|
||||
lv_style_int_t end_border_width = lv_obj_get_style_scale_end_border_width(lmeter, part);
|
||||
|
||||
if(border_width || end_border_width) {
|
||||
int16_t end_angle = (level * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs - 1;
|
||||
int16_t end_angle = ((level + 1) * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs;
|
||||
lv_draw_line_dsc_t arc_dsc;
|
||||
lv_draw_line_dsc_init(&arc_dsc);
|
||||
lv_obj_init_draw_line_dsc(lmeter, part, &arc_dsc);
|
||||
@@ -559,8 +560,6 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
|
||||
arc_dsc.color = end_color;
|
||||
lv_draw_arc(x_ofs, y_ofs, r_out, end_angle, (angle_ofs + ext->scale_angle) % 360, clip_area, &arc_dsc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,7 +569,6 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the line meters
|
||||
|
||||
@@ -495,7 +495,7 @@ uint16_t lv_list_get_size(const lv_obj_t * list)
|
||||
lv_obj_t * btn = lv_list_get_next_btn(list, NULL);
|
||||
while(btn) {
|
||||
size++;
|
||||
btn = lv_list_get_next_btn(list, NULL);
|
||||
btn = lv_list_get_next_btn(list, btn);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
@@ -767,6 +767,11 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
if(btn) lv_list_focus_btn(list, btn);
|
||||
}
|
||||
}
|
||||
else if(c == LV_KEY_ESC) {
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
/* Handle ESC/Cancel event */
|
||||
res = lv_event_send(ext->act_sel_btn, LV_EVENT_CANCEL, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -402,7 +402,7 @@ lv_coord_t lv_page_get_width_grid(lv_obj_t * page, uint8_t div, uint8_t span)
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide the height of the object and get the width of a given number of columns.
|
||||
* Divide the height of the object and get the height of a given number of rows.
|
||||
* Take into account the paddings of the background and scrollable too.
|
||||
* @param obj pointer to an object
|
||||
* @param div indicates how many rows are assumed.
|
||||
@@ -495,14 +495,14 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_
|
||||
lv_coord_t scrlable_y = lv_obj_get_y(ext->scrl);
|
||||
lv_coord_t page_h = lv_obj_get_height(page);
|
||||
|
||||
lv_coord_t top_err = -(scrlable_y + obj_y);
|
||||
lv_coord_t bot_err = scrlable_y + obj_y + obj_h - page_h;
|
||||
|
||||
lv_style_int_t bg_top = lv_obj_get_style_pad_top(page, LV_PAGE_PART_BG);
|
||||
lv_style_int_t bg_bottom = lv_obj_get_style_pad_bottom(page, LV_PAGE_PART_BG);
|
||||
lv_style_int_t scrl_top = lv_obj_get_style_pad_top(ext->scrl, LV_CONT_PART_MAIN);
|
||||
lv_style_int_t scrl_bottom = lv_obj_get_style_pad_bottom(ext->scrl, LV_CONT_PART_MAIN);
|
||||
|
||||
lv_coord_t top_err = -((scrlable_y + obj_y) - bg_top);
|
||||
lv_coord_t bot_err = scrlable_y + obj_y + obj_h - (page_h - bg_bottom);
|
||||
|
||||
/*Out of the page on the top*/
|
||||
if((obj_h <= page_h && top_err > 0) || (obj_h > page_h && top_err < bot_err)) {
|
||||
/*Calculate a new position and let some space above*/
|
||||
@@ -524,14 +524,14 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_
|
||||
lv_coord_t scrlable_x = lv_obj_get_x(ext->scrl);
|
||||
lv_coord_t page_w = lv_obj_get_width(page);
|
||||
|
||||
lv_coord_t left_err = -(scrlable_x + obj_x);
|
||||
lv_coord_t right_err = scrlable_x + obj_x + obj_w - page_w;
|
||||
|
||||
lv_style_int_t bg_left = lv_obj_get_style_pad_left(page, LV_PAGE_PART_BG);
|
||||
lv_style_int_t bg_right = lv_obj_get_style_pad_right(page, LV_PAGE_PART_BG);
|
||||
lv_style_int_t scrl_left = lv_obj_get_style_pad_top(ext->scrl, LV_CONT_PART_MAIN);
|
||||
lv_style_int_t scrl_right = lv_obj_get_style_pad_bottom(ext->scrl, LV_CONT_PART_MAIN);
|
||||
|
||||
lv_coord_t left_err = -((scrlable_x + obj_x) - bg_left);
|
||||
lv_coord_t right_err = scrlable_x + obj_x + obj_w - (page_w - bg_right);
|
||||
|
||||
/*Out of the page on the left*/
|
||||
if((obj_w <= page_w && left_err > 0) || (obj_w > page_w && left_err < right_err)) {
|
||||
/*Calculate a new position and let some space on the side*/
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * clip_area, lv_design_mode_t mode);
|
||||
static lv_design_res_t lv_roller_label_design(lv_obj_t * label, const lv_area_t * clip_area, lv_design_mode_t mode);
|
||||
static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * param);
|
||||
static lv_style_list_t * lv_roller_get_style(lv_obj_t * roller, uint8_t part);
|
||||
static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * param);
|
||||
@@ -51,6 +52,7 @@ static void draw_bg(lv_obj_t * roller, const lv_area_t * clip_area);
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_design_cb_t ancestor_label_design;
|
||||
static lv_signal_cb_t ancestor_scrl_signal;
|
||||
|
||||
/**********************
|
||||
@@ -103,7 +105,8 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
lv_obj_t * label = lv_label_create(roller, NULL);
|
||||
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
|
||||
|
||||
if(ancestor_label_design == NULL) ancestor_label_design = lv_obj_get_design_cb(label);
|
||||
lv_obj_set_design_cb(label, lv_roller_label_design);
|
||||
lv_obj_t * scrl = lv_page_get_scrollable(roller);
|
||||
lv_obj_set_drag(scrl, true);
|
||||
lv_page_set_scrollable_fit2(roller, LV_FIT_PARENT, LV_FIT_NONE); /*Height is specified directly*/
|
||||
@@ -195,10 +198,8 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo
|
||||
|
||||
ext->sel_opt_id_ori = ext->sel_opt_id;
|
||||
|
||||
|
||||
refr_height(roller);
|
||||
refr_width(roller);
|
||||
// refr_position(roller, LV_ANIM_OFF);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -416,7 +417,6 @@ const char * lv_roller_get_options(const lv_obj_t * roller)
|
||||
*/
|
||||
static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * clip_area, lv_design_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return LV_DESIGN_RES_NOT_COVER;
|
||||
}
|
||||
@@ -449,13 +449,13 @@ static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * cli
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
lv_obj_init_draw_label_dsc(roller, LV_ROLLER_PART_SELECTED, &label_dsc);
|
||||
|
||||
lv_coord_t font_h = lv_font_get_line_height(label_dsc.font);
|
||||
lv_coord_t bg_font_h = lv_font_get_line_height(lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG));
|
||||
|
||||
/*Redraw the text on the selected area with a different color*/
|
||||
/*Redraw the text on the selected area*/
|
||||
lv_area_t rect_area;
|
||||
rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - label_dsc.line_space / 2;
|
||||
if((font_h & 0x1) && (label_dsc.line_space & 0x1)) rect_area.y1--; /*Compensate the two rounding error*/
|
||||
rect_area.y2 = rect_area.y1 + font_h + label_dsc.line_space - 1;
|
||||
rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - bg_font_h / 2 - label_dsc.line_space / 2;
|
||||
if((bg_font_h & 0x1) && (label_dsc.line_space & 0x1)) rect_area.y1--; /*Compensate the two rounding error*/
|
||||
rect_area.y2 = rect_area.y1 + bg_font_h + label_dsc.line_space - 1;
|
||||
rect_area.x1 = roller->coords.x1;
|
||||
rect_area.x2 = roller->coords.x2;
|
||||
lv_area_t mask_sel;
|
||||
@@ -472,7 +472,94 @@ static lv_design_res_t lv_roller_design(lv_obj_t * roller, const lv_area_t * cli
|
||||
label_dsc.flag |= LV_TXT_FLAG_RIGHT;
|
||||
}
|
||||
|
||||
lv_draw_label(&label->coords, &mask_sel, &label_dsc, lv_label_get_text(label), NULL);
|
||||
/*Get the size of the "selected text"*/
|
||||
lv_point_t res_p;
|
||||
_lv_txt_get_size(&res_p, lv_label_get_text(label), label_dsc.font, label_dsc.letter_space, label_dsc.line_space,
|
||||
lv_obj_get_width(roller), LV_TXT_FLAG_EXPAND);
|
||||
|
||||
/*Move the selected label proportionally with the background label*/
|
||||
lv_coord_t roller_h = lv_obj_get_height(roller);
|
||||
int32_t label_y_prop = label->coords.y1 - (roller_h / 2 +
|
||||
roller->coords.y1); /*label offset from the middle line of the roller*/
|
||||
label_y_prop = (label_y_prop << 14) / lv_obj_get_height(
|
||||
label); /*Proportional position from the middle line (upscaled)*/
|
||||
|
||||
/*Apply a correction with different line heights*/
|
||||
const lv_font_t * normal_label_font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG);
|
||||
lv_coord_t corr = (label_dsc.font->line_height - normal_label_font->line_height) / 2;
|
||||
|
||||
/*Apply the proportional position to the selected text*/
|
||||
res_p.y -= corr;
|
||||
int32_t label_sel_y = roller_h / 2 + roller->coords.y1;
|
||||
label_sel_y += (label_y_prop * res_p.y) >> 14;
|
||||
label_sel_y -= corr;
|
||||
|
||||
/*Draw the selected text*/
|
||||
lv_area_t label_sel_area;
|
||||
label_sel_area.x1 = label->coords.x1;
|
||||
label_sel_area.y1 = label_sel_y;
|
||||
label_sel_area.x2 = label->coords.x2;
|
||||
label_sel_area.y2 = label_sel_area.y1 + res_p.y;
|
||||
|
||||
label_dsc.flag |= LV_TXT_FLAG_EXPAND;
|
||||
lv_draw_label(&label_sel_area, &mask_sel, &label_dsc, lv_label_get_text(label), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return LV_DESIGN_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the roller's label
|
||||
* @param roller pointer to an object
|
||||
* @param clip_area the object will be drawn only in this area
|
||||
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
||||
* LV_DESIGN_DRAW_POST: drawing after all children are drawn
|
||||
* @param return an element of `lv_design_res_t`
|
||||
*/
|
||||
static lv_design_res_t lv_roller_label_design(lv_obj_t * label, const lv_area_t * clip_area, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
return ancestor_label_design(label, clip_area, mode);
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DESIGN_DRAW_MAIN) {
|
||||
/* Split the drawing of the label into an upper (above the selected area)
|
||||
* and a lower (below the selected area)*/
|
||||
lv_obj_t * roller = lv_obj_get_parent(lv_obj_get_parent(label));
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG);
|
||||
lv_style_int_t line_space = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_BG);
|
||||
lv_coord_t font_h = lv_font_get_line_height(font);
|
||||
|
||||
lv_area_t rect_area;
|
||||
rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - line_space / 2;
|
||||
if((font_h & 0x1) && (line_space & 0x1)) rect_area.y1--; /*Compensate the two rounding error*/
|
||||
rect_area.y2 = rect_area.y1 + font_h + line_space - 1;
|
||||
lv_area_t roller_coords;
|
||||
lv_obj_get_coords(roller, &roller_coords);
|
||||
lv_obj_get_inner_coords(roller, &roller_coords);
|
||||
|
||||
rect_area.x1 = roller_coords.x1;
|
||||
rect_area.x2 = roller_coords.x2;
|
||||
|
||||
lv_area_t clip2;
|
||||
clip2.x1 = label->coords.x1;
|
||||
clip2.y1 = label->coords.y1;
|
||||
clip2.x2 = label->coords.x2;
|
||||
clip2.y2 = rect_area.y1;
|
||||
if(_lv_area_intersect(&clip2, clip_area, &clip2)) {
|
||||
ancestor_label_design(label, &clip2, mode);
|
||||
}
|
||||
|
||||
clip2.x1 = label->coords.x1;
|
||||
clip2.y1 = rect_area.y2;
|
||||
clip2.x2 = label->coords.x2;
|
||||
clip2.y2 = label->coords.y2;
|
||||
if(_lv_area_intersect(&clip2, clip_area, &clip2)) {
|
||||
ancestor_label_design(label, &clip2, mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -764,7 +851,7 @@ static void refr_position(lv_obj_t * roller, lv_anim_enable_t anim_en)
|
||||
lv_coord_t h = lv_obj_get_height(roller);
|
||||
uint16_t anim_time = lv_roller_get_anim_time(roller);
|
||||
|
||||
/* Normally the animation's `end_cb` sets correct position of the roller is infinite.
|
||||
/* Normally the animation's `end_cb` sets correct position of the roller if infinite.
|
||||
* But without animations do it manually*/
|
||||
if(anim_en == LV_ANIM_OFF || anim_time == 0) {
|
||||
inf_normalize(roller_scrl);
|
||||
|
||||
@@ -230,20 +230,6 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
||||
|
||||
ext->tab_cnt++;
|
||||
|
||||
switch(ext->btns_pos) {
|
||||
case LV_TABVIEW_TAB_POS_TOP:
|
||||
case LV_TABVIEW_TAB_POS_BOTTOM:
|
||||
ext->tab_name_ptr = lv_mem_realloc((void *)ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt + 1));
|
||||
break;
|
||||
case LV_TABVIEW_TAB_POS_LEFT:
|
||||
case LV_TABVIEW_TAB_POS_RIGHT:
|
||||
ext->tab_name_ptr = lv_mem_realloc((void *)ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt * 2));
|
||||
break;
|
||||
}
|
||||
|
||||
LV_ASSERT_MEM(ext->tab_name_ptr);
|
||||
if(ext->tab_name_ptr == NULL) return NULL;
|
||||
|
||||
/* FIXME: It is not possible yet to switch tab button position from/to top/bottom from/to left/right at runtime.
|
||||
* Method: clean extra \n when switch from LV_TABVIEW_BTNS_POS_LEFT or LV_TABVIEW_BTNS_POS_RIGHT
|
||||
* to LV_TABVIEW_BTNS_POS_TOP or LV_TABVIEW_BTNS_POS_BOTTOM.
|
||||
@@ -448,6 +434,35 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
|
||||
lv_btnmatrix_set_btn_ctrl(ext->btns, ext->tab_cur, LV_BTNMATRIX_CTRL_CHECK_STATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of a tab.
|
||||
* @param tabview pointer to Tab view object
|
||||
* @param id index of the tab the name should be set
|
||||
* @param name new tab name
|
||||
*/
|
||||
void lv_tabview_set_tab_name(lv_obj_t * tabview, uint16_t id, char * name)
|
||||
{
|
||||
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
|
||||
|
||||
/* get tabview's ext pointer which contains the tab name pointer list */
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
|
||||
/* check for valid tab index */
|
||||
if(ext->tab_cnt > id) {
|
||||
/* reallocate memory for new tab name (use reallocate due to mostly the size didn't change much) */
|
||||
char * str = lv_mem_realloc((void *)ext->tab_name_ptr[id], strlen(name) + 1);
|
||||
LV_ASSERT_MEM(str);
|
||||
|
||||
/* store new tab name at allocated memory */
|
||||
strcpy(str, name);
|
||||
/* update pointer */
|
||||
ext->tab_name_ptr[id] = str;
|
||||
|
||||
/* force redrawing of the tab headers */
|
||||
lv_obj_invalidate(ext->btns);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the animation time of tab view when a new tab is loaded
|
||||
* @param tabview pointer to Tab view object
|
||||
|
||||
@@ -119,6 +119,14 @@ void lv_tabview_clean_tab(lv_obj_t * tab);
|
||||
*/
|
||||
void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t anim);
|
||||
|
||||
/**
|
||||
* Set the name of a tab.
|
||||
* @param tabview pointer to Tab view object
|
||||
* @param id index of the tab the name should be set
|
||||
* @param name new tab name
|
||||
*/
|
||||
void lv_tabview_set_tab_name(lv_obj_t * tabview, uint16_t id, char * name);
|
||||
|
||||
/**
|
||||
* Set the animation time of tab view when a new tab is loaded
|
||||
* @param tabview pointer to Tab view object
|
||||
|
||||
@@ -60,6 +60,7 @@ static void pwd_char_hider(lv_obj_t * ta);
|
||||
static bool char_is_accepted(lv_obj_t * ta, uint32_t c);
|
||||
static void refr_cursor_area(lv_obj_t * ta);
|
||||
static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, lv_indev_t * click_source);
|
||||
static lv_res_t insert_handler(lv_obj_t * ta, const char * txt);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -148,7 +149,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_label_set_text(ext->label, "Text area");
|
||||
lv_obj_set_click(ext->label, false);
|
||||
lv_obj_set_size(ta, LV_TEXTAREA_DEF_WIDTH, LV_TEXTAREA_DEF_HEIGHT);
|
||||
lv_textarea_set_sscrollbar_mode(ta, LV_SCROLLBAR_MODE_DRAG);
|
||||
lv_textarea_set_scrollbar_mode(ta, LV_SCROLLBAR_MODE_DRAG);
|
||||
|
||||
lv_obj_reset_style_list(ta, LV_PAGE_PART_SCROLLABLE);
|
||||
lv_theme_apply(ta, LV_THEME_TEXTAREA);
|
||||
@@ -243,17 +244,8 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c)
|
||||
if(c != 0) while(*letter_buf == 0) ++letter_buf;
|
||||
#endif
|
||||
|
||||
ta_insert_replace = NULL;
|
||||
lv_event_send(ta, LV_EVENT_INSERT, letter_buf);
|
||||
if(ta_insert_replace) {
|
||||
if(ta_insert_replace[0] == '\0') return; /*Drop this text*/
|
||||
|
||||
/*Add the replaced text directly it's different from the original*/
|
||||
if(strcmp(ta_insert_replace, letter_buf)) {
|
||||
lv_textarea_add_text(ta, ta_insert_replace);
|
||||
return;
|
||||
}
|
||||
}
|
||||
lv_res_t res = insert_handler(ta, letter_buf);
|
||||
if(res != LV_RES_OK) return;
|
||||
|
||||
if(ext->one_line && (c == '\n' || c == '\r')) {
|
||||
LV_LOG_INFO("Text area: line break ignored in one-line mode");
|
||||
@@ -268,6 +260,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*If a new line was added it shouldn't show edge flash effect*/
|
||||
bool edge_flash_en = lv_textarea_get_edge_flash(ta);
|
||||
lv_textarea_set_edge_flash(ta, false);
|
||||
@@ -333,18 +326,6 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt)
|
||||
|
||||
lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta);
|
||||
|
||||
ta_insert_replace = NULL;
|
||||
lv_event_send(ta, LV_EVENT_INSERT, txt);
|
||||
if(ta_insert_replace) {
|
||||
if(ta_insert_replace[0] == '\0') return; /*Drop this text*/
|
||||
|
||||
/*Add the replaced text directly it's different from the original*/
|
||||
if(strcmp(ta_insert_replace, txt)) {
|
||||
lv_textarea_add_text(ta, ta_insert_replace);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/
|
||||
|
||||
/*Add the character one-by-one if not all characters are accepted or there is character limit.*/
|
||||
@@ -357,6 +338,9 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt)
|
||||
return;
|
||||
}
|
||||
|
||||
lv_res_t res = insert_handler(ta, txt);
|
||||
if(res != LV_RES_OK) return;
|
||||
|
||||
/*If a new line was added it shouldn't show edge flash effect*/
|
||||
bool edge_flash_en = lv_textarea_get_edge_flash(ta);
|
||||
lv_textarea_set_edge_flash(ta, false);
|
||||
@@ -419,18 +403,10 @@ void lv_textarea_del_char(lv_obj_t * ta)
|
||||
|
||||
if(cur_pos == 0) return;
|
||||
|
||||
ta_insert_replace = NULL;
|
||||
char del_buf[2] = {LV_KEY_DEL, '\0'};
|
||||
lv_event_send(ta, LV_EVENT_INSERT, del_buf);
|
||||
if(ta_insert_replace) {
|
||||
if(ta_insert_replace[0] == '\0') return; /*Drop this text*/
|
||||
|
||||
/*Add the replaced text directly it's different from the original*/
|
||||
if(strcmp(ta_insert_replace, del_buf)) {
|
||||
lv_textarea_add_text(ta, ta_insert_replace);
|
||||
return;
|
||||
}
|
||||
}
|
||||
lv_res_t res = insert_handler(ta, del_buf);
|
||||
if(res != LV_RES_OK) return;
|
||||
|
||||
char * label_txt = lv_label_get_text(ext->label);
|
||||
|
||||
@@ -1915,4 +1891,21 @@ static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, lv_
|
||||
#endif
|
||||
}
|
||||
|
||||
static lv_res_t insert_handler(lv_obj_t * ta, const char * txt)
|
||||
{
|
||||
ta_insert_replace = NULL;
|
||||
lv_event_send(ta, LV_EVENT_INSERT, txt);
|
||||
if(ta_insert_replace) {
|
||||
if(ta_insert_replace[0] == '\0') return LV_RES_INV; /*Drop this text*/
|
||||
|
||||
/*Add the replaced text directly it's different from the original*/
|
||||
if(strcmp(ta_insert_replace, txt)) {
|
||||
lv_textarea_add_text(ta, ta_insert_replace);
|
||||
return LV_RES_INV;
|
||||
}
|
||||
}
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -224,7 +224,7 @@ void lv_textarea_set_insert_replace(lv_obj_t * ta, const char * txt);
|
||||
* @param ta pointer to a text area object
|
||||
* @param sb_mode the new mode from 'lv_scrollbar_mode_t' enum
|
||||
*/
|
||||
static inline void lv_textarea_set_sscrollbar_mode(lv_obj_t * ta, lv_scrollbar_mode_t mode)
|
||||
static inline void lv_textarea_set_scrollbar_mode(lv_obj_t * ta, lv_scrollbar_mode_t mode)
|
||||
{
|
||||
lv_page_set_scrollbar_mode(ta, mode);
|
||||
}
|
||||
|
||||
@@ -403,8 +403,8 @@ static void drag_end_handler(lv_obj_t * tileview)
|
||||
lv_obj_t * scrl = lv_page_get_scrollable(tileview);
|
||||
lv_point_t p;
|
||||
|
||||
p.x = -(scrl->coords.x1 - lv_obj_get_width(tileview) / 2);
|
||||
p.y = -(scrl->coords.y1 - lv_obj_get_height(tileview) / 2);
|
||||
p.x = -(lv_obj_get_x(scrl) - lv_obj_get_width(tileview) / 2);
|
||||
p.y = -(lv_obj_get_y(scrl) - lv_obj_get_height(tileview) / 2);
|
||||
|
||||
lv_drag_dir_t drag_dir = indev->proc.types.pointer.drag_dir;
|
||||
/*From the drag vector (drag throw) predict the end position*/
|
||||
|
||||
Reference in New Issue
Block a user