working lcd small quer
This commit is contained in:
27
libraries/lvgl/.typos.toml
Normal file
27
libraries/lvgl/.typos.toml
Normal file
@ -0,0 +1,27 @@
|
||||
[files]
|
||||
extend-exclude = [
|
||||
".git/",
|
||||
"docs/_static/css/fontawesome.min.css",
|
||||
"docs/README_*",
|
||||
"src/libs/",
|
||||
]
|
||||
ignore-hidden = false
|
||||
|
||||
[default]
|
||||
extend-ignore-re = [
|
||||
"\\bser[^a-z]",
|
||||
"\\bfle[^a-z]",
|
||||
'"Lorem ipsum .*"',
|
||||
"Nam consectetur",
|
||||
"U\\+[0-9A-F]{4}",
|
||||
'\{ "[a-z]+", "[^ -~]+" \},',
|
||||
"`[0-9a-f]{7} <https://\\S+>`__",
|
||||
"Rename lv_chart_clear_serie",
|
||||
"rename LV_ROLLER_MODE_INIFINITE",
|
||||
"CARD_INFO_SET\\(&img_multilang_avatar_.*\\)",
|
||||
"ACI\\)",
|
||||
]
|
||||
|
||||
[default.extend-words]
|
||||
# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6loca.html
|
||||
"loca" = "loca"
|
||||
36
libraries/lvgl/CMakeLists.txt
Normal file
36
libraries/lvgl/CMakeLists.txt
Normal file
@ -0,0 +1,36 @@
|
||||
cmake_minimum_required(VERSION 3.12.4)
|
||||
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
|
||||
if(NOT ESP_PLATFORM)
|
||||
project(lvgl LANGUAGES C CXX ASM HOMEPAGE_URL https://github.com/lvgl/lvgl)
|
||||
endif()
|
||||
|
||||
set(LVGL_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
if(ESP_PLATFORM)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/env_support/cmake/esp.cmake)
|
||||
elseif(ZEPHYR_BASE)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/env_support/cmake/zephyr.cmake)
|
||||
elseif(MICROPY_DIR)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/env_support/cmake/micropython.cmake)
|
||||
else()
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/env_support/cmake/custom.cmake)
|
||||
endif()
|
||||
|
||||
#[[
|
||||
unfortunately CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS does not work for global data.
|
||||
for global data we still need decl specs.
|
||||
Check out the docs to learn more about the limitations of CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
|
||||
https://cmake.org/cmake/help/latest/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html#prop_tgt:WINDOWS_EXPORT_ALL_SYMBOLS
|
||||
|
||||
For all compiled sources within the library (i.e. basically all lvgl files) we need to use dllexport.
|
||||
For all compiled sources from outside the library (i.e. files which include lvgl headers) we need to use dllimport.
|
||||
We can do this by using CMakes INTERFACE and PRIVATE keyword.
|
||||
]]
|
||||
if (MSVC)
|
||||
target_compile_definitions(lvgl
|
||||
INTERFACE LV_ATTRIBUTE_EXTERN_DATA=__declspec\(dllimport\)
|
||||
PRIVATE LV_ATTRIBUTE_EXTERN_DATA=__declspec\(dllexport\)
|
||||
)
|
||||
endif()
|
||||
116
libraries/lvgl/CMakePresets.json
Normal file
116
libraries/lvgl/CMakePresets.json
Normal file
@ -0,0 +1,116 @@
|
||||
{
|
||||
"version": 3,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "_base",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"LV_CONF_SKIP": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-base",
|
||||
"inherits": "_base",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||
"installDir": "${sourceDir}/build/install/${presetName}",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "cl.exe",
|
||||
"CMAKE_CXX_COMPILER": "cl.exe",
|
||||
"BUILD_SHARED_LIBS": "ON"
|
||||
},
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
},
|
||||
"architecture": {
|
||||
"value": "x64",
|
||||
"strategy": "external"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-base",
|
||||
"inherits": "_base",
|
||||
"displayName": "Linux",
|
||||
"description": "Setup WSL or native linux",
|
||||
"generator": "Ninja Multi-Config",
|
||||
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||
"installDir": "${sourceDir}/build/${presetName}",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Linux"
|
||||
},
|
||||
"vendor": {
|
||||
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
|
||||
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
|
||||
}
|
||||
},
|
||||
"cacheVariables": {
|
||||
"BUILD_SHARED_LIBS": "ON"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "_base",
|
||||
"hidden": true,
|
||||
"jobs": 12
|
||||
},
|
||||
{
|
||||
"name": "windows-base_dbg",
|
||||
"inherits": "_base",
|
||||
"displayName": "Debug",
|
||||
"configurePreset": "windows-base",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "windows-base_rel",
|
||||
"inherits": "_base",
|
||||
"displayName": "Release",
|
||||
"configurePreset": "windows-base",
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "linux-base_dbg",
|
||||
"inherits": "_base",
|
||||
"displayName": "Debug",
|
||||
"configurePreset": "linux-base",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "linux-base_rel",
|
||||
"inherits": "_base",
|
||||
"displayName": "Release",
|
||||
"configurePreset": "linux-base",
|
||||
"configuration": "Release"
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "windows-base_dbg",
|
||||
"displayName": "Debug",
|
||||
"configurePreset": "windows-base",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "windows-base_rel",
|
||||
"displayName": "Release",
|
||||
"configurePreset": "windows-base",
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "linux-base_dbg",
|
||||
"displayName": "Debug",
|
||||
"configurePreset": "linux-base",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "linux-base_rel",
|
||||
"displayName": "Release",
|
||||
"configurePreset": "linux-base",
|
||||
"configuration": "Release"
|
||||
}
|
||||
]
|
||||
}
|
||||
1628
libraries/lvgl/Kconfig
Normal file
1628
libraries/lvgl/Kconfig
Normal file
File diff suppressed because it is too large
Load Diff
8
libraries/lvgl/LICENCE.txt
Normal file
8
libraries/lvgl/LICENCE.txt
Normal file
@ -0,0 +1,8 @@
|
||||
MIT licence
|
||||
Copyright (c) 2021 LVGL Kft
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
474
libraries/lvgl/README.md
Normal file
474
libraries/lvgl/README.md
Normal file
@ -0,0 +1,474 @@
|
||||
This LVGL-9.1.0 is modified by SquareLine Team here and there to provide the best experience even with this experimental 9.1 LVGL version, added fixes:
|
||||
- Bar/Slider widget drawing caused a crash when value was maximum and top_padding was nonzero and right_padding was 0 (`lv_bar.c`, also adding +1 to right_padding in SquareLine Studio export if there's top-padding set.)
|
||||
- The swipe gesture was improved to not get double value aka 0 velocity from timer based callback when 'EVENT'-mode is set for the indev (as in built-in SDL2 driver). (`lv_indev.c`)
|
||||
Also a modification can be enabled with `LV_SQUARELINE_MOD__SWIPE` defined and set to 1 in `lv_conf.h`, that brings back old 8.3 swipe-gesture behaviour, i.e. not abandonings wipe process when a new object comes across swipe-path.
|
||||
- For the Visual Studio board-template with resizable window, some extra window-size setting code was added into `lv_windows_display.c`, so the window is set to guarantee the wished client-size for the exported UI.
|
||||
|
||||
|
||||
<a href="https://github.com/sponsors/lvgl" target="_blank"><img align="left" src="https://lvgl.io/assets/images/sponsor.png" height="32px"></a>
|
||||
|
||||
<p align="right">
|
||||
<b>English</b> | <a href="./docs/README_zh.rst">中文</a> | <a href="./docs/README_pt_BR.rst">Português do Brasil</a> | <a href="./docs/README_jp.rst">日本語</a>
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://lvgl.io/assets/images/logo_lvgl.png">
|
||||
</p>
|
||||
|
||||
<h1 align="center">Light and Versatile Graphics Library</h1>
|
||||
<br>
|
||||
<div align="center">
|
||||
<img src="https://github.com/kisvegabor/test/raw/master/smartwatch_demo.gif">
|
||||
|
||||
<img border="1px" src="https://lvgl.io/assets/images/lvgl_widgets_demo.gif">
|
||||
</div>
|
||||
<br>
|
||||
<p align="center">
|
||||
<a href="https://lvgl.io" title="Homepage of LVGL">Website </a> |
|
||||
<a href="https://docs.lvgl.io/" title="Detailed documentation with 100+ examples">Docs</a> |
|
||||
<a href="https://forum.lvgl.io" title="Get help and help others">Forum</a> |
|
||||
<a href="https://lvgl.io/demos" title="Demos running in your browser">Demos</a> |
|
||||
<a href="https://lvgl.io/services" title="Graphics design, UI implementation and consulting">Services</a>
|
||||
</p>
|
||||
<br>
|
||||
|
||||
## :ledger: Overview
|
||||
|
||||
**Mature and Well-known**<br>
|
||||
LVGL is the most popular free and open source embedded graphics library to create beautiful UIs for any MCU, MPU and display type. It's supported by industry leading vendors and projects like Arm, STM32, NXP, Espressif, Nuvoton, Arduino, RT-Thread, Zephyr, NuttX, Adafruit and many more.
|
||||
|
||||
**Feature Rich**<br>
|
||||
It has all the features to create modern and beautiful GUIs: 30+ built-in widgets, a powerful style system, web inspired layout managers, and a typography system supporting many languages. To integrate LVGL into your platform, all you need is at least 32kB RAM and 128 kB Flash, a C compiler, a frame buffer, and at least an 1/10 screen sized buffer for rendering.
|
||||
|
||||
**Services**<br>
|
||||
Our team is ready to help you with graphics design, UI implementation and consulting services. Contact us if you need some support during the development of your next GUI project.
|
||||
|
||||
## :rocket: Features
|
||||
|
||||
**Free and Portable**
|
||||
- A fully portable C (C++ compatible) library with no external dependencies.
|
||||
- Can be compiled to any MCU or MPU, with any (RT)OS.
|
||||
- Supports monochrome, ePaper, OLED or TFT displays, or even monitors. [Porting Guide](https://docs.lvgl.io/master/porting/project.html)
|
||||
- Distributed under the MIT license, so you can easily use it in commercial projects too.
|
||||
- Needs only 32kB RAM and 128 kB Flash, a frame buffer, and at least an 1/10 screen sized buffer for rendering.
|
||||
- OS, External memory and GPU are supported but not required.
|
||||
|
||||
**Widgets, Styles, Layouts and more**
|
||||
- 30+ built-in [Widgets](https://docs.lvgl.io/master/widgets/index.html): Button, Label, Slider, Chart, Keyboard, Meter, Arc, Table and many more.
|
||||
- Flexible [Style system](https://docs.lvgl.io/master/overview/style.html) with ~100 style properties to customize any part of the widgets in any state.
|
||||
- [Flexbox](https://docs.lvgl.io/master/layouts/flex.html) and [Grid](https://docs.lvgl.io/master/layouts/grid.html)-like layouts engines to automatically size and position the widgets in a responsive way.
|
||||
- Texts are rendered with UTF-8 encoding supporting CJK, Thai, Hindi, Arabic, Persian writing systems.
|
||||
- Word wrapping, kerning, text scrolling, sub-pixel rendering, Pinyin-IME Chinese input, Emojis in texts.
|
||||
- Rendering engine supporting animations, anti-aliasing, opacity, smooth scrolling, shadows, image transformation, etc
|
||||
- Supports Mouse, Touchpad, Keypad, Keyboard, External buttons, Encoder [Input devices](https://docs.lvgl.io/master/porting/indev.html).
|
||||
- [Multiple display](https://docs.lvgl.io/master/overview/disp.html#multiple-display-support) support.
|
||||
|
||||
**Binding and Build Support**
|
||||
- [Micropython Binding](https://blog.lvgl.io/2019-02-20/micropython-bindings) exposes LVGL API
|
||||
- [PikaScript Binding](https://blog.lvgl.io/2022-08-24/pikascript-and-lvgl) python on MCU lighter and easier.
|
||||
- No custom build system is used. You can build LVGL as you build the other files of your project.
|
||||
- Support for Make and [CMake](https://docs.lvgl.io/master/get-started/platforms/cmake.html) is included out of the box.
|
||||
- [Develop on PC](https://docs.lvgl.io/master/get-started/platforms/pc-simulator.html) and use the same UI code on embedded hardware.
|
||||
- Convert the C UI code to HTML file with our [Emscripten port](https://github.com/lvgl/lv_web_emscripten).
|
||||
|
||||
**Docs, Tools, and Services**
|
||||
- Detailed [Documentation](https://docs.lvgl.io/) with [100+ simple examples](https://docs.lvgl.io/master/index.html)
|
||||
- [Services](https://lvgl.io/services) such as User interface design, Implementation and Consulting to make UI development simpler and faster.
|
||||
|
||||
## :heart: Sponsor
|
||||
|
||||
If LVGL saved you a lot of time and money or you just had fun using it, consider [Supporting its Development](https://github.com/sponsors/lvgl).
|
||||
|
||||
**How do we spend the donations?**<br>
|
||||
Our goal is to provide financial compensation for people who do the most for LVGL. It means not only the maintainers but anyone who implements a great feature should get a payment from the accumulated money. We use the donations to cover our operational costs like servers and related services.
|
||||
|
||||
**How to donate?**<br>
|
||||
We use [GitHub Sponsors](https://github.com/sponsors/lvgl) where you can easily send one time or recurring donations. You can also see all of our expenses in a transparent way.
|
||||
|
||||
**How to get paid for your contribution?**<br>
|
||||
If someone implements or fixes an issue labeled as [Sponsored](https://github.com/lvgl/lvgl/labels/Sponsored) he or she will get a payment for that work. We estimate the required time, complexity and importance of the issue and set a price accordingly. To jump in just comment on a [Sponsored](https://github.com/lvgl/lvgl/labels/Sponsored) issue saying "Hi, I'd like to deal with it. This is how I'm planning to fix/implement it...". A work is considered ready when it's approved and merged by a maintainer. After that you can submit and expense at [opencollective.com](https://opencollective.com/lvgl) and you will receive the payment in a few days.
|
||||
|
||||
**Organizations supporting LVGL**<br>
|
||||
[](https://opencollective.com/lvgl)
|
||||
|
||||
**Individuals supporting LVGL**<br>
|
||||
[](https://opencollective.com/lvgl)
|
||||
|
||||
## :package: Packages
|
||||
LVGL is available as:
|
||||
- [Arduino library](https://docs.lvgl.io/master/integration/framework/arduino.html)
|
||||
- [PlatformIO package](https://registry.platformio.org/libraries/lvgl/lvgl)
|
||||
- [Zephyr library](https://docs.lvgl.io/master/integration/os/zephyr.html)
|
||||
- [ESP-IDF(ESP32) component](https://components.espressif.com/components/lvgl/lvgl)
|
||||
- [NXP MCUXpresso component](https://www.nxp.com/design/software/embedded-software/lvgl-open-source-graphics-library:LITTLEVGL-OPEN-SOURCE-GRAPHICS-LIBRARY)
|
||||
- [NuttX library](https://docs.lvgl.io/master/integration/os/nuttx.html)
|
||||
- [RT-Thread RTOS](https://docs.lvgl.io/master/integration/os/rt-thread.html)
|
||||
- CMSIS-Pack
|
||||
- [RIOT OS package](https://doc.riot-os.org/group__pkg__lvgl.html#details)
|
||||
|
||||
|
||||
## :robot: Examples
|
||||
|
||||
See some examples of creating widgets, using layouts and applying styles. You will find C and MicroPython code, and links to try out or edit the examples in an online MicroPython editor.
|
||||
|
||||
For more examples check out the [Examples](https://github.com/lvgl/lvgl/tree/master/examples) folder.
|
||||
|
||||
|
||||
### Hello world label
|
||||
|
||||

|
||||
|
||||
<details>
|
||||
<summary>C code</summary>
|
||||
|
||||
```c
|
||||
/*Change the active screen's background color*/
|
||||
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x003a57), LV_PART_MAIN);
|
||||
|
||||
/*Create a white label, set its text and align it to the center*/
|
||||
lv_obj_t * label = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(label, "Hello world");
|
||||
lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0xffffff), LV_PART_MAIN);
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>MicroPython code | <a href="https://sim.lvgl.io/v8.3/micropython/ports/javascript/index.html?script_direct=4ab7c40c35b0dc349aa2f0c3b00938d7d8e8ac9f" target="_blank">Online Simulator</a></summary>
|
||||
|
||||
```python
|
||||
# Change the active screen's background color
|
||||
scr = lv.screen_active()
|
||||
scr.set_style_bg_color(lv.color_hex(0x003a57), lv.PART.MAIN)
|
||||
|
||||
# Create a white label, set its text and align it to the center
|
||||
label = lv.label(lv.screen_active())
|
||||
label.set_text("Hello world")
|
||||
label.set_style_text_color(lv.color_hex(0xffffff), lv.PART.MAIN)
|
||||
label.align(lv.ALIGN.CENTER, 0, 0)
|
||||
```
|
||||
</details>
|
||||
<br>
|
||||
|
||||
### Button with Click Event
|
||||
|
||||

|
||||
|
||||
<details>
|
||||
<summary>C code</summary>
|
||||
|
||||
```c
|
||||
lv_obj_t * button = lv_button_create(lv_screen_active()); /*Add a button to the current screen*/
|
||||
lv_obj_center(button); /*Set its position*/
|
||||
lv_obj_set_size(button, 100, 50); /*Set its size*/
|
||||
lv_obj_add_event_cb(button, button_event_cb, LV_EVENT_CLICKED, NULL); /*Assign a callback to the button*/
|
||||
|
||||
lv_obj_t * label = lv_label_create(button); /*Add a label to the button*/
|
||||
lv_label_set_text(label, "Button"); /*Set the labels text*/
|
||||
lv_obj_center(label); /*Align the label to the center*/
|
||||
...
|
||||
|
||||
void button_event_cb(lv_event_t * e)
|
||||
{
|
||||
printf("Clicked\n");
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>MicroPython code | <a href="https://sim.lvgl.io/v8.3/micropython/ports/javascript/index.html?script_startup=https://raw.githubusercontent.com/lvgl/lvgl/0d9ab4ee0e591aad1970e3c9164fd7c544ecce70/examples/header.py&script=https://raw.githubusercontent.com/lvgl/lvgl/0d9ab4ee0e591aad1970e3c9164fd7c544ecce70/examples/widgets/slider/lv_example_slider_2.py&script_direct=926bde43ec7af0146c486de470c53f11f167491e" target="_blank">Online Simulator</a></summary>
|
||||
|
||||
```python
|
||||
def button_event_cb(e):
|
||||
print("Clicked")
|
||||
|
||||
# Create a Button and a Label
|
||||
button = lv.button(lv.screen_active())
|
||||
button.center()
|
||||
button.set_size(100, 50)
|
||||
button.add_event_cb(button_event_cb, lv.EVENT.CLICKED, None)
|
||||
|
||||
label = lv.label(button)
|
||||
label.set_text("Button")
|
||||
label.center()
|
||||
```
|
||||
</details>
|
||||
<br>
|
||||
|
||||
### Checkboxes with Layout
|
||||

|
||||
|
||||
<details>
|
||||
<summary>C code</summary>
|
||||
|
||||
```c
|
||||
|
||||
lv_obj_set_flex_flow(lv_screen_active(), LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_t * cb;
|
||||
cb = lv_checkbox_create(lv_screen_active());
|
||||
lv_checkbox_set_text(cb, "Apple");
|
||||
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);
|
||||
|
||||
cb = lv_checkbox_create(lv_screen_active());
|
||||
lv_checkbox_set_text(cb, "Banana");
|
||||
lv_obj_add_state(cb, LV_STATE_CHECKED);
|
||||
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);
|
||||
|
||||
cb = lv_checkbox_create(lv_screen_active());
|
||||
lv_checkbox_set_text(cb, "Lemon");
|
||||
lv_obj_add_state(cb, LV_STATE_DISABLED);
|
||||
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);
|
||||
|
||||
cb = lv_checkbox_create(lv_screen_active());
|
||||
lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED);
|
||||
lv_checkbox_set_text(cb, "Melon\nand a new line");
|
||||
lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL);
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>MicroPython code | <a href="https://sim.lvgl.io/v8.3/micropython/ports/javascript/index.html?script_startup=https://raw.githubusercontent.com/lvgl/lvgl/0d9ab4ee0e591aad1970e3c9164fd7c544ecce70/examples/header.py&script=https://raw.githubusercontent.com/lvgl/lvgl/0d9ab4ee0e591aad1970e3c9164fd7c544ecce70/examples/widgets/slider/lv_example_slider_2.py&script_direct=311d37e5f70daf1cb0d2cad24c7f72751b5f1792" target="_blank">Online Simulator</a></summary>
|
||||
|
||||
```python
|
||||
def event_handler(e):
|
||||
code = e.get_code()
|
||||
obj = e.get_target_obj()
|
||||
if code == lv.EVENT.VALUE_CHANGED:
|
||||
txt = obj.get_text()
|
||||
if obj.get_state() & lv.STATE.CHECKED:
|
||||
state = "Checked"
|
||||
else:
|
||||
state = "Unchecked"
|
||||
print(txt + ":" + state)
|
||||
|
||||
|
||||
lv.screen_active().set_flex_flow(lv.FLEX_FLOW.COLUMN)
|
||||
lv.screen_active().set_flex_align(lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.START, lv.FLEX_ALIGN.CENTER)
|
||||
|
||||
cb = lv.checkbox(lv.screen_active())
|
||||
cb.set_text("Apple")
|
||||
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
|
||||
|
||||
cb = lv.checkbox(lv.screen_active())
|
||||
cb.set_text("Banana")
|
||||
cb.add_state(lv.STATE.CHECKED)
|
||||
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
|
||||
|
||||
cb = lv.checkbox(lv.screen_active())
|
||||
cb.set_text("Lemon")
|
||||
cb.add_state(lv.STATE.DISABLED)
|
||||
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
|
||||
|
||||
cb = lv.checkbox(lv.screen_active())
|
||||
cb.add_state(lv.STATE.CHECKED | lv.STATE.DISABLED)
|
||||
cb.set_text("Melon")
|
||||
cb.add_event_cb(event_handler, lv.EVENT.ALL, None)
|
||||
```
|
||||
|
||||
</details>
|
||||
<br>
|
||||
|
||||
### Styling a Slider
|
||||

|
||||
|
||||
|
||||
<details>
|
||||
<summary>C code</summary>
|
||||
|
||||
```c
|
||||
lv_obj_t * slider = lv_slider_create(lv_screen_active());
|
||||
lv_slider_set_value(slider, 70, LV_ANIM_OFF);
|
||||
lv_obj_set_size(slider, 300, 20);
|
||||
lv_obj_center(slider);
|
||||
|
||||
/*Add local styles to MAIN part (background rectangle)*/
|
||||
lv_obj_set_style_bg_color(slider, lv_color_hex(0x0F1215), LV_PART_MAIN);
|
||||
lv_obj_set_style_bg_opa(slider, 255, LV_PART_MAIN);
|
||||
lv_obj_set_style_border_color(slider, lv_color_hex(0x333943), LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(slider, 5, LV_PART_MAIN);
|
||||
lv_obj_set_style_pad_all(slider, 5, LV_PART_MAIN);
|
||||
|
||||
/*Create a reusable style sheet for the INDICATOR part*/
|
||||
static lv_style_t style_indicator;
|
||||
lv_style_init(&style_indicator);
|
||||
lv_style_set_bg_color(&style_indicator, lv_color_hex(0x37B9F5));
|
||||
lv_style_set_bg_grad_color(&style_indicator, lv_color_hex(0x1464F0));
|
||||
lv_style_set_bg_grad_dir(&style_indicator, LV_GRAD_DIR_HOR);
|
||||
lv_style_set_shadow_color(&style_indicator, lv_color_hex(0x37B9F5));
|
||||
lv_style_set_shadow_width(&style_indicator, 15);
|
||||
lv_style_set_shadow_spread(&style_indicator, 5);
|
||||
4
|
||||
/*Add the style sheet to the slider's INDICATOR part*/
|
||||
lv_obj_add_style(slider, &style_indicator, LV_PART_INDICATOR);
|
||||
|
||||
/*Add the same style to the KNOB part too and locally overwrite some properties*/
|
||||
lv_obj_add_style(slider, &style_indicator, LV_PART_KNOB);
|
||||
|
||||
lv_obj_set_style_outline_color(slider, lv_color_hex(0x0096FF), LV_PART_KNOB);
|
||||
lv_obj_set_style_outline_width(slider, 3, LV_PART_KNOB);
|
||||
lv_obj_set_style_outline_pad(slider, -5, LV_PART_KNOB);
|
||||
lv_obj_set_style_shadow_spread(slider, 2, LV_PART_KNOB);
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>MicroPython code |
|
||||
<a href="https://sim.lvgl.io/v8.3/micropython/ports/javascript/index.html?script_startup=https://raw.githubusercontent.com/lvgl/lvgl/0d9ab4ee0e591aad1970e3c9164fd7c544ecce70/examples/header.py&script=https://raw.githubusercontent.com/lvgl/lvgl/0d9ab4ee0e591aad1970e3c9164fd7c544ecce70/examples/widgets/slider/lv_example_slider_2.py&script_direct=c431c7b4dfd2cc0dd9c392b74365d5af6ea986f0" target="_blank">Online Simulator</a>
|
||||
</summary>
|
||||
|
||||
|
||||
```python
|
||||
# Create a slider and add the style
|
||||
slider = lv.slider(lv.screen_active())
|
||||
slider.set_value(70, lv.ANIM.OFF)
|
||||
slider.set_size(300, 20)
|
||||
slider.center()
|
||||
|
||||
# Add local styles to MAIN part (background rectangle)
|
||||
slider.set_style_bg_color(lv.color_hex(0x0F1215), lv.PART.MAIN)
|
||||
slider.set_style_bg_opa(255, lv.PART.MAIN)
|
||||
slider.set_style_border_color(lv.color_hex(0x333943), lv.PART.MAIN)
|
||||
slider.set_style_border_width(5, lv.PART.MAIN)
|
||||
slider.set_style_pad_all(5, lv.PART.MAIN)
|
||||
|
||||
# Create a reusable style sheet for the INDICATOR part
|
||||
style_indicator = lv.style_t()
|
||||
style_indicator.init()
|
||||
style_indicator.set_bg_color(lv.color_hex(0x37B9F5))
|
||||
style_indicator.set_bg_grad_color(lv.color_hex(0x1464F0))
|
||||
style_indicator.set_bg_grad_dir(lv.GRAD_DIR.HOR)
|
||||
style_indicator.set_shadow_color(lv.color_hex(0x37B9F5))
|
||||
style_indicator.set_shadow_width(15)
|
||||
style_indicator.set_shadow_spread(5)
|
||||
|
||||
# Add the style sheet to the slider's INDICATOR part
|
||||
slider.add_style(style_indicator, lv.PART.INDICATOR)
|
||||
slider.add_style(style_indicator, lv.PART.KNOB)
|
||||
|
||||
# Add the same style to the KNOB part too and locally overwrite some properties
|
||||
slider.set_style_outline_color(lv.color_hex(0x0096FF), lv.PART.KNOB)
|
||||
slider.set_style_outline_width(3, lv.PART.KNOB)
|
||||
slider.set_style_outline_pad(-5, lv.PART.KNOB)
|
||||
slider.set_style_shadow_spread(2, lv.PART.KNOB)
|
||||
```
|
||||
</details>
|
||||
<br>
|
||||
|
||||
### English, Hebrew (mixed LTR-RTL) and Chinese texts
|
||||
|
||||

|
||||
|
||||
<details>
|
||||
<summary>C code</summary>
|
||||
|
||||
```c
|
||||
lv_obj_t * ltr_label = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(ltr_label, "In modern terminology, a microcontroller is similar to a system on a chip (SoC).");
|
||||
lv_obj_set_style_text_font(ltr_label, &lv_font_montserrat_16, 0);
|
||||
lv_obj_set_width(ltr_label, 310);
|
||||
lv_obj_align(ltr_label, LV_ALIGN_TOP_LEFT, 5, 5);
|
||||
|
||||
lv_obj_t * rtl_label = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(rtl_label,"מעבד, או בשמו המלא יחידת עיבוד מרכזית (באנגלית: CPU - Central Processing Unit).");
|
||||
lv_obj_set_style_base_dir(rtl_label, LV_BASE_DIR_RTL, 0);
|
||||
lv_obj_set_style_text_font(rtl_label, &lv_font_dejavu_16_persian_hebrew, 0);
|
||||
lv_obj_set_width(rtl_label, 310);
|
||||
lv_obj_align(rtl_label, LV_ALIGN_LEFT_MID, 5, 0);
|
||||
|
||||
lv_obj_t * cz_label = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(cz_label,
|
||||
"嵌入式系统(Embedded System),\n是一种嵌入机械或电气系统内部、具有专一功能和实时计算性能的计算机系统。");
|
||||
lv_obj_set_style_text_font(cz_label, &lv_font_simsun_16_cjk, 0);
|
||||
lv_obj_set_width(cz_label, 310);
|
||||
lv_obj_align(cz_label, LV_ALIGN_BOTTOM_LEFT, 5, -5);
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>MicroPython code | <a href="https://sim.lvgl.io/v8.3/micropython/ports/javascript/index.html?script_startup=https://raw.githubusercontent.com/lvgl/lvgl/0d9ab4ee0e591aad1970e3c9164fd7c544ecce70/examples/header.py&script=https://raw.githubusercontent.com/lvgl/lvgl/0d9ab4ee0e591aad1970e3c9164fd7c544ecce70/examples/widgets/slider/lv_example_slider_2.py&script_direct=18bb38200a64e10ead1aa17a65c977fc18131842" target="_blank">Online Simulator</a></summary>
|
||||
|
||||
```python
|
||||
ltr_label = lv.label(lv.screen_active())
|
||||
ltr_label.set_text("In modern terminology, a microcontroller is similar to a system on a chip (SoC).")
|
||||
ltr_label.set_style_text_font(lv.font_montserrat_16, 0);
|
||||
|
||||
ltr_label.set_width(310)
|
||||
ltr_label.align(lv.ALIGN.TOP_LEFT, 5, 5)
|
||||
|
||||
rtl_label = lv.label(lv.screen_active())
|
||||
rtl_label.set_text("מעבד, או בשמו המלא יחידת עיבוד מרכזית (באנגלית: CPU - Central Processing Unit).")
|
||||
rtl_label.set_style_base_dir(lv.BASE_DIR.RTL, 0)
|
||||
rtl_label.set_style_text_font(lv.font_dejavu_16_persian_hebrew, 0)
|
||||
rtl_label.set_width(310)
|
||||
rtl_label.align(lv.ALIGN.LEFT_MID, 5, 0)
|
||||
|
||||
font_simsun_16_cjk = lv.font_load("S:../../assets/font/lv_font_simsun_16_cjk.fnt")
|
||||
|
||||
cz_label = lv.label(lv.screen_active())
|
||||
cz_label.set_style_text_font(font_simsun_16_cjk, 0)
|
||||
cz_label.set_text("嵌入式系统(Embedded System),\n是一种嵌入机械或电气系统内部、具有专一功能和实时计算性能的计算机系统。")
|
||||
cz_label.set_width(310)
|
||||
cz_label.align(lv.ALIGN.BOTTOM_LEFT, 5, -5)
|
||||
|
||||
```
|
||||
</details>
|
||||
|
||||
## :arrow_forward: Get started
|
||||
This list will guide you to get started with LVGL step-by-step.
|
||||
|
||||
**Get Familiar with LVGL**
|
||||
|
||||
1. Check the [Online demos](https://lvgl.io/demos) to see LVGL in action (3 minutes)
|
||||
2. Read the [Introduction](https://docs.lvgl.io/master/intro/index.html) page of the documentation (5 minutes)
|
||||
3. Get familiar with the basics on the [Quick overview](https://docs.lvgl.io/master/get-started/quick-overview.html) page (15 minutes)
|
||||
|
||||
**Start to Use LVGL**
|
||||
|
||||
4. Set up a [Simulator](https://docs.lvgl.io/master/integration/ide/pc-simulator.html#simulator) (10 minutes)
|
||||
5. Try out some [Examples](https://github.com/lvgl/lvgl/tree/master/examples)
|
||||
6. Port LVGL to a board. See the [Porting](https://docs.lvgl.io/master/porting/index.html) guide or check the ready to use [Projects](https://github.com/lvgl?q=lv_port_)
|
||||
|
||||
**Become a Pro**
|
||||
|
||||
7. Read the [Overview](https://docs.lvgl.io/master/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/master/widgets/index.html) to see their features and usage
|
||||
|
||||
**Get Help and Help Others**
|
||||
|
||||
9. If you have questions go to the [Forum](http://forum.lvgl.io/)
|
||||
10. Read the [Contributing](https://docs.lvgl.io/master/CONTRIBUTING.html) guide to see how you can help to improve LVGL (15 minutes)
|
||||
|
||||
|
||||
## :handshake: Services
|
||||
LVGL LLC was established to provide a solid background for LVGL library and to offer several type of services to help you in UI development. With 15+ years of experience in the user interface and graphics industry we can help you the bring your UI to the next level.
|
||||
|
||||
- **Graphics design** Our in-house graphics designers are experts in creating beautiful modern designs which fit to your product and the resources of your hardware.
|
||||
- **UI implementation** We can also implement your UI based on the design you or we have created. You can be sure that we will make the most out of your hardware and LVGL. If a feature or widget is missing from LVGL, don't worry, we will implement it for you.
|
||||
- **Consulting and Support** We can support you with consulting as well to avoid pricey and time consuming mistakes during the UI development.
|
||||
- **Board certification** For companies who are offering development boards, or production ready kits we do board certification which shows how board can run LVGL.
|
||||
|
||||
|
||||
Check out our [Demos](https://lvgl.io/demos) as reference. For more information take look at the [Services page](https://lvgl.io/services).
|
||||
|
||||
[Contact us](https://lvgl.io/#contact) and tell how we can help.
|
||||
|
||||
|
||||
## :star2: 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 or even hosting your own project under the LVGL organization.
|
||||
|
||||
For a detailed description of contribution opportunities visit the [Contributing](https://docs.lvgl.io/master/CONTRIBUTING.html) section of the documentation.
|
||||
|
||||
More than 300 people already left their fingerprint in LVGL. Be one them! See you here! :slightly_smiling_face:
|
||||
|
||||
<a href="https://github.com/lvgl/lvgl/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=lvgl/lvgl&max=48" />
|
||||
</a>
|
||||
|
||||
... and many other.
|
||||
11
libraries/lvgl/SConscript
Normal file
11
libraries/lvgl/SConscript
Normal file
@ -0,0 +1,11 @@
|
||||
# RT-Thread building script for bridge
|
||||
|
||||
import os
|
||||
from building import *
|
||||
|
||||
objs = []
|
||||
cwd = GetCurrentDir()
|
||||
|
||||
objs = objs + SConscript(cwd + '/env_support/rt-thread/SConscript')
|
||||
|
||||
Return('objs')
|
||||
66
libraries/lvgl/component.mk
Normal file
66
libraries/lvgl/component.mk
Normal file
@ -0,0 +1,66 @@
|
||||
# ESP-IDF component file for make based commands
|
||||
|
||||
COMPONENT_SRCDIRS := . \
|
||||
src \
|
||||
src/core \
|
||||
src/draw \
|
||||
src/extra \
|
||||
src/font \
|
||||
src/hal \
|
||||
src/misc \
|
||||
src/widgets \
|
||||
src/draw/arm2d \
|
||||
src/draw/nxp \
|
||||
src/draw/sdl \
|
||||
src/draw/stm32_dma2d \
|
||||
src/draw/sw \
|
||||
src/draw/swm342_dma2d \
|
||||
src/extra/layouts \
|
||||
src/extra/libs \
|
||||
src/extra/others \
|
||||
src/extra/themes \
|
||||
src/extra/widgets \
|
||||
src/extra/layouts/flex \
|
||||
src/extra/layouts/grid \
|
||||
src/extra/libs/bmp \
|
||||
src/extra/libs/ffmpeg \
|
||||
src/extra/libs/freetype \
|
||||
src/extra/libs/fsdrv \
|
||||
src/extra/libs/gif \
|
||||
src/extra/libs/png \
|
||||
src/extra/libs/qrcode \
|
||||
src/extra/libs/rlottie \
|
||||
src/extra/libs/sjgp \
|
||||
src/extra/others/fragment \
|
||||
src/extra/others/gridnav \
|
||||
src/extra/others/ime \
|
||||
src/extra/others/imgfont \
|
||||
src/extra/others/monkey \
|
||||
src/extra/others/msg \
|
||||
src/extra/others/snapshot \
|
||||
src/extra/themes/basic \
|
||||
src/extra/themes/default \
|
||||
src/extra/themes/mono \
|
||||
src/extra/widgets/animimg \
|
||||
src/extra/widgets/calendar \
|
||||
src/extra/widgets/chart \
|
||||
src/extra/widgets/colorwheel \
|
||||
src/extra/widgets/imgbtn \
|
||||
src/extra/widgets/keyboard \
|
||||
src/extra/widgets/led \
|
||||
src/extra/widgets/list \
|
||||
src/extra/widgets/menu \
|
||||
src/extra/widgets/meter \
|
||||
src/extra/widgets/msgbox \
|
||||
src/extra/widgets/span \
|
||||
src/extra/widgets/spinbox \
|
||||
src/extra/widgets/spinner \
|
||||
src/extra/widgets/tabview \
|
||||
src/extra/widgets/tileview \
|
||||
src/extra/widgets/win
|
||||
|
||||
ifeq ($(CONFIG_LV_USE_THORVG_INTERNAL),y)
|
||||
COMPONENT_SRCDIRS += src/extra/libs/thorvg
|
||||
endif
|
||||
|
||||
COMPONENT_ADD_INCLUDEDIRS := $(COMPONENT_SRCDIRS) .
|
||||
0
libraries/lvgl/demos/.gitkeep
Normal file
0
libraries/lvgl/demos/.gitkeep
Normal file
187
libraries/lvgl/env_support/cmake/custom.cmake
Normal file
187
libraries/lvgl/env_support/cmake/custom.cmake
Normal file
@ -0,0 +1,187 @@
|
||||
# Option to define LV_LVGL_H_INCLUDE_SIMPLE, default: ON
|
||||
option(LV_LVGL_H_INCLUDE_SIMPLE
|
||||
"Use #include \"lvgl.h\" instead of #include \"../../lvgl.h\"" ON)
|
||||
|
||||
# Option to define LV_CONF_INCLUDE_SIMPLE, default: ON
|
||||
option(LV_CONF_INCLUDE_SIMPLE
|
||||
"Use #include \"lv_conf.h\" instead of #include \"../../lv_conf.h\"" ON)
|
||||
|
||||
# Option LV_CONF_PATH, which should be the path for lv_conf.h
|
||||
# If set parent path LV_CONF_DIR is added to includes
|
||||
if( LV_CONF_PATH )
|
||||
get_filename_component(LV_CONF_DIR ${LV_CONF_PATH} DIRECTORY)
|
||||
endif( LV_CONF_PATH )
|
||||
|
||||
# Option to build shared libraries (as opposed to static), default: OFF
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||
|
||||
# Set sources used for LVGL components
|
||||
file(GLOB_RECURSE SOURCES ${LVGL_ROOT_DIR}/src/*.c ${LVGL_ROOT_DIR}/src/*.S)
|
||||
file(GLOB_RECURSE EXAMPLE_SOURCES ${LVGL_ROOT_DIR}/examples/*.c)
|
||||
file(GLOB_RECURSE DEMO_SOURCES ${LVGL_ROOT_DIR}/demos/*.c)
|
||||
file(GLOB_RECURSE THORVG_SOURCES ${LVGL_ROOT_DIR}/src/libs/thorvg/*.cpp ${LVGL_ROOT_DIR}/src/others/vg_lite_tvg/*.cpp)
|
||||
|
||||
# Build LVGL library
|
||||
add_library(lvgl ${SOURCES})
|
||||
add_library(lvgl::lvgl ALIAS lvgl)
|
||||
|
||||
target_compile_definitions(
|
||||
lvgl PUBLIC $<$<BOOL:${LV_LVGL_H_INCLUDE_SIMPLE}>:LV_LVGL_H_INCLUDE_SIMPLE>
|
||||
$<$<BOOL:${LV_CONF_INCLUDE_SIMPLE}>:LV_CONF_INCLUDE_SIMPLE>
|
||||
$<$<COMPILE_LANGUAGE:ASM>:__ASSEMBLY__>)
|
||||
|
||||
# Add definition of LV_CONF_PATH only if needed
|
||||
if(LV_CONF_PATH)
|
||||
target_compile_definitions(lvgl PUBLIC LV_CONF_PATH=${LV_CONF_PATH})
|
||||
endif()
|
||||
|
||||
# Add definition of LV_CONF_SKIP only if needed
|
||||
if(LV_CONF_SKIP)
|
||||
target_compile_definitions(lvgl PUBLIC LV_CONF_SKIP=1)
|
||||
endif()
|
||||
|
||||
# Include root and optional parent path of LV_CONF_PATH
|
||||
target_include_directories(lvgl SYSTEM PUBLIC ${LVGL_ROOT_DIR} ${LV_CONF_DIR})
|
||||
|
||||
|
||||
if(NOT LV_CONF_BUILD_DISABLE_THORVG_INTERNAL)
|
||||
add_library(lvgl_thorvg ${THORVG_SOURCES})
|
||||
add_library(lvgl::thorvg ALIAS lvgl_thorvg)
|
||||
target_include_directories(lvgl_thorvg SYSTEM PUBLIC ${LVGL_ROOT_DIR}/src/libs/thorvg)
|
||||
target_link_libraries(lvgl_thorvg PUBLIC lvgl)
|
||||
endif()
|
||||
|
||||
# Build LVGL example library
|
||||
if(NOT LV_CONF_BUILD_DISABLE_EXAMPLES)
|
||||
add_library(lvgl_examples ${EXAMPLE_SOURCES})
|
||||
add_library(lvgl::examples ALIAS lvgl_examples)
|
||||
|
||||
target_include_directories(lvgl_examples SYSTEM PUBLIC ${LVGL_ROOT_DIR}/examples)
|
||||
target_link_libraries(lvgl_examples PUBLIC lvgl)
|
||||
endif()
|
||||
|
||||
# Build LVGL demos library
|
||||
if(NOT LV_CONF_BUILD_DISABLE_DEMOS)
|
||||
add_library(lvgl_demos ${DEMO_SOURCES})
|
||||
add_library(lvgl::demos ALIAS lvgl_demos)
|
||||
|
||||
target_include_directories(lvgl_demos SYSTEM PUBLIC ${LVGL_ROOT_DIR}/demos)
|
||||
target_link_libraries(lvgl_demos PUBLIC lvgl)
|
||||
endif()
|
||||
|
||||
# Lbrary and headers can be installed to system using make install
|
||||
file(GLOB LVGL_PUBLIC_HEADERS "${CMAKE_SOURCE_DIR}/lv_conf.h"
|
||||
"${CMAKE_SOURCE_DIR}/lvgl.h")
|
||||
|
||||
if("${LIB_INSTALL_DIR}" STREQUAL "")
|
||||
set(LIB_INSTALL_DIR "lib")
|
||||
endif()
|
||||
if("${RUNTIME_INSTALL_DIR}" STREQUAL "")
|
||||
set(RUNTIME_INSTALL_DIR "bin")
|
||||
endif()
|
||||
if("${INC_INSTALL_DIR}" STREQUAL "")
|
||||
set(INC_INSTALL_DIR "include/lvgl")
|
||||
endif()
|
||||
|
||||
#Install headers
|
||||
install(
|
||||
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/"
|
||||
FILES_MATCHING
|
||||
PATTERN "*.h")
|
||||
|
||||
# install example headers
|
||||
if(NOT LV_CONF_BUILD_DISABLE_EXAMPLES)
|
||||
install(
|
||||
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/examples"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/"
|
||||
FILES_MATCHING
|
||||
PATTERN "*.h")
|
||||
endif()
|
||||
|
||||
# install demo headers
|
||||
if(NOT LV_CONF_BUILD_DISABLE_DEMOS)
|
||||
install(
|
||||
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/demos"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/"
|
||||
FILES_MATCHING
|
||||
PATTERN "*.h")
|
||||
endif()
|
||||
|
||||
|
||||
configure_file("${LVGL_ROOT_DIR}/lvgl.pc.in" lvgl.pc @ONLY)
|
||||
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/lvgl.pc"
|
||||
DESTINATION "${LIB_INSTALL_DIR}/pkgconfig/")
|
||||
|
||||
# Install library
|
||||
set_target_properties(
|
||||
lvgl
|
||||
PROPERTIES OUTPUT_NAME lvgl
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||
PUBLIC_HEADER "${LVGL_PUBLIC_HEADERS}")
|
||||
|
||||
install(
|
||||
TARGETS lvgl
|
||||
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
|
||||
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
|
||||
RUNTIME DESTINATION "${RUNTIME_INSTALL_DIR}"
|
||||
PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}")
|
||||
|
||||
|
||||
# Install library thorvg
|
||||
if(NOT LV_CONF_BUILD_DISABLE_THORVG_INTERNAL)
|
||||
set_target_properties(
|
||||
lvgl_thorvg
|
||||
PROPERTIES OUTPUT_NAME lvgl_thorvg
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||
PUBLIC_HEADER "${LVGL_PUBLIC_HEADERS}")
|
||||
|
||||
install(
|
||||
TARGETS lvgl_thorvg
|
||||
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
|
||||
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
|
||||
RUNTIME DESTINATION "${RUNTIME_INSTALL_DIR}"
|
||||
PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}")
|
||||
endif()
|
||||
|
||||
# Install library demos
|
||||
if(NOT LV_CONF_BUILD_DISABLE_DEMOS)
|
||||
set_target_properties(
|
||||
lvgl_demos
|
||||
PROPERTIES OUTPUT_NAME lvgl_demos
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||
PUBLIC_HEADER "${LVGL_PUBLIC_HEADERS}")
|
||||
|
||||
install(
|
||||
TARGETS lvgl_demos
|
||||
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
|
||||
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
|
||||
RUNTIME DESTINATION "${RUNTIME_INSTALL_DIR}"
|
||||
PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}")
|
||||
endif()
|
||||
|
||||
#install library examples
|
||||
if(NOT LV_CONF_BUILD_DISABLE_EXAMPLES)
|
||||
set_target_properties(
|
||||
lvgl_examples
|
||||
PROPERTIES OUTPUT_NAME lvgl_examples
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||
PUBLIC_HEADER "${LVGL_PUBLIC_HEADERS}")
|
||||
|
||||
install(
|
||||
TARGETS lvgl_examples
|
||||
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
|
||||
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
|
||||
RUNTIME DESTINATION "${RUNTIME_INSTALL_DIR}"
|
||||
PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}")
|
||||
endif()
|
||||
54
libraries/lvgl/env_support/cmake/esp.cmake
Normal file
54
libraries/lvgl/env_support/cmake/esp.cmake
Normal file
@ -0,0 +1,54 @@
|
||||
file(GLOB_RECURSE SOURCES ${LVGL_ROOT_DIR}/src/*.c ${LVGL_ROOT_DIR}/src/*.cpp)
|
||||
|
||||
idf_build_get_property(LV_MICROPYTHON LV_MICROPYTHON)
|
||||
|
||||
if(LV_MICROPYTHON)
|
||||
idf_component_register(
|
||||
SRCS
|
||||
${SOURCES}
|
||||
INCLUDE_DIRS
|
||||
${LVGL_ROOT_DIR}
|
||||
${LVGL_ROOT_DIR}/src
|
||||
${LVGL_ROOT_DIR}/../
|
||||
REQUIRES
|
||||
main)
|
||||
else()
|
||||
if(CONFIG_LV_BUILD_EXAMPLES)
|
||||
file(GLOB_RECURSE EXAMPLE_SOURCES ${LVGL_ROOT_DIR}/examples/*.c)
|
||||
set_source_files_properties(${EXAMPLE_SOURCES} COMPILE_FLAGS "-Wno-unused-variable -Wno-format")
|
||||
endif()
|
||||
|
||||
if(CONFIG_LV_USE_DEMO_WIDGETS)
|
||||
file(GLOB_RECURSE DEMO_WIDGETS_SOURCES ${LVGL_ROOT_DIR}/demos/widgets/*.c)
|
||||
list(APPEND DEMO_SOURCES ${DEMO_WIDGETS_SOURCES})
|
||||
endif()
|
||||
if(CONFIG_LV_USE_DEMO_KEYPAD_AND_ENCODER)
|
||||
file(GLOB_RECURSE DEMO_KEYPAD_AND_ENCODER_SOURCES ${LVGL_ROOT_DIR}/demos/keypad_encoder/*.c)
|
||||
list(APPEND DEMO_SOURCES ${DEMO_KEYPAD_AND_ENCODER_SOURCES})
|
||||
endif()
|
||||
if(CONFIG_LV_USE_DEMO_BENCHMARK)
|
||||
file(GLOB_RECURSE DEMO_BENCHMARK_SOURCES ${LVGL_ROOT_DIR}/demos/benchmark/*.c)
|
||||
list(APPEND DEMO_SOURCES ${DEMO_BENCHMARK_SOURCES})
|
||||
endif()
|
||||
if(CONFIG_LV_USE_DEMO_STRESS)
|
||||
file(GLOB_RECURSE DEMO_STRESS_SOURCES ${LVGL_ROOT_DIR}/demos/stress/*.c)
|
||||
list(APPEND DEMO_SOURCES ${DEMO_STRESS_SOURCES})
|
||||
endif()
|
||||
if(CONFIG_LV_USE_DEMO_MUSIC)
|
||||
file(GLOB_RECURSE DEMO_MUSIC_SOURCES ${LVGL_ROOT_DIR}/demos/music/*.c)
|
||||
list(APPEND DEMO_SOURCES ${DEMO_MUSIC_SOURCES})
|
||||
set_source_files_properties(${DEMO_MUSIC_SOURCES} COMPILE_FLAGS "-Wno-format")
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${SOURCES} ${EXAMPLE_SOURCES} ${DEMO_SOURCES}
|
||||
INCLUDE_DIRS ${LVGL_ROOT_DIR} ${LVGL_ROOT_DIR}/src ${LVGL_ROOT_DIR}/../
|
||||
${LVGL_ROOT_DIR}/examples ${LVGL_ROOT_DIR}/demos
|
||||
REQUIRES esp_timer)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_CONF_INCLUDE_SIMPLE")
|
||||
|
||||
if(CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM)
|
||||
target_compile_definitions(${COMPONENT_LIB}
|
||||
PUBLIC "-DLV_ATTRIBUTE_FAST_MEM=IRAM_ATTR")
|
||||
endif()
|
||||
18
libraries/lvgl/env_support/cmake/micropython.cmake
Normal file
18
libraries/lvgl/env_support/cmake/micropython.cmake
Normal file
@ -0,0 +1,18 @@
|
||||
file(GLOB_RECURSE SOURCES ${LVGL_ROOT_DIR}/src/*.c)
|
||||
file(GLOB_RECURSE EXAMPLE_SOURCES ${LVGL_ROOT_DIR}/examples/*.c)
|
||||
|
||||
# With micropython, build lvgl as interface library, link chain is:
|
||||
# lvgl_interface [lvgl] → usermod_lvgl_bindings [lv_bindings] → usermod
|
||||
# [micropython] → firmware [micropython]
|
||||
add_library(lvgl_interface INTERFACE)
|
||||
# ${SOURCES} must NOT be given to add_library directly for some reason (won't be
|
||||
# built)
|
||||
target_sources(lvgl_interface INTERFACE ${SOURCES})
|
||||
# Micropython builds with -Werror; we need to suppress some warnings, such as:
|
||||
#
|
||||
# /home/test/build/lv_micropython/ports/rp2/build-PICO/lv_mp.c:29316:16: error:
|
||||
# 'lv_style_transition_dsc_t_path_xcb_callback' defined but not used
|
||||
# [-Werror=unused-function] 29316 | STATIC int32_t
|
||||
# lv_style_transition_dsc_t_path_xcb_callback(const lv_anim_t * arg0) |
|
||||
# ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
target_compile_options(lvgl_interface INTERFACE -Wno-unused-function)
|
||||
14
libraries/lvgl/env_support/cmake/zephyr.cmake
Normal file
14
libraries/lvgl/env_support/cmake/zephyr.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
if(CONFIG_LVGL)
|
||||
|
||||
zephyr_include_directories(${ZEPHYR_BASE}/lib/gui/lvgl)
|
||||
|
||||
target_include_directories(lvgl INTERFACE ${LVGL_ROOT_DIR})
|
||||
|
||||
zephyr_compile_definitions(LV_CONF_KCONFIG_EXTERNAL_INCLUDE=<autoconf.h>)
|
||||
|
||||
zephyr_library()
|
||||
|
||||
file(GLOB_RECURSE SOURCES ${LVGL_ROOT_DIR}/src/*.c)
|
||||
zephyr_library_sources(${SOURCES})
|
||||
|
||||
endif(CONFIG_LVGL)
|
||||
BIN
libraries/lvgl/env_support/cmsis-pack/LVGL.lvgl.9.1.0.pack
Normal file
BIN
libraries/lvgl/env_support/cmsis-pack/LVGL.lvgl.9.1.0.pack
Normal file
Binary file not shown.
1937
libraries/lvgl/env_support/cmsis-pack/LVGL.lvgl.pdsc
Normal file
1937
libraries/lvgl/env_support/cmsis-pack/LVGL.lvgl.pdsc
Normal file
File diff suppressed because it is too large
Load Diff
9
libraries/lvgl/env_support/cmsis-pack/LVGL.pidx
Normal file
9
libraries/lvgl/env_support/cmsis-pack/LVGL.pidx
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<index schemaVersion="1.0.0" xs:noNamespaceSchemaLocation="PackIndex.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<vendor>LVGL</vendor>
|
||||
<url>https://raw.githubusercontent.com/lvgl/lvgl/master/env_support/cmsis-pack/</url>
|
||||
<timestamp>2024-03-19</timestamp>
|
||||
<pindex>
|
||||
<pdsc url="https://raw.githubusercontent.com/lvgl/lvgl/master/env_support/cmsis-pack/" vendor="LVGL" name="lvgl" version="9.1.0"/>
|
||||
</pindex>
|
||||
</index>
|
||||
269
libraries/lvgl/env_support/cmsis-pack/README.md
Normal file
269
libraries/lvgl/env_support/cmsis-pack/README.md
Normal file
@ -0,0 +1,269 @@
|
||||
# How to Create CMSIS-Pack
|
||||
|
||||
|
||||
|
||||
## STEP 1 Update 'lv_conf_cmsis.h'
|
||||
|
||||
1. Copy the **lv_conf_template.h** to '**cmsis-pack**' directory
|
||||
|
||||
2. Set the macro protector to '1'
|
||||
|
||||
```c
|
||||
...
|
||||
/* clang-format off */
|
||||
#if 1 /*Set it to "1" to enable content*/
|
||||
...
|
||||
```
|
||||
|
||||
remove the misleading guide above this code segment.
|
||||
|
||||
```c
|
||||
/*
|
||||
* Copy this file as `lv_conf.h`
|
||||
* 1. simply next to the `lvgl` folder
|
||||
* 2. or any other places and
|
||||
* - define `LV_CONF_INCLUDE_SIMPLE`
|
||||
* - add the path as include path
|
||||
*/
|
||||
```
|
||||
|
||||
|
||||
3. Add including for '**RTE_Components.h**'
|
||||
|
||||
```c
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
|
||||
#include "RTE_Components.h"
|
||||
...
|
||||
```
|
||||
4. Remove macro definitions for
|
||||
|
||||
- LV_USE_DEMO_WIDGETS
|
||||
|
||||
- LV_USE_DEMO_BENCHMARK
|
||||
|
||||
- LV_USE_IME_PINYIN
|
||||
|
||||
- LV_USE_OS
|
||||
|
||||
- LV_USE_FILE_EXPLORER
|
||||
|
||||
- LV_USE_DEMO_WIDGETS
|
||||
|
||||
- LV_USE_DEMO_KEYPAD_AND_ENCODER
|
||||
|
||||
- LV_USE_DEMO_BENCHMARK
|
||||
|
||||
- LV_USE_DEMO_RENDER
|
||||
|
||||
- LV_USE_DEMO_STRESS
|
||||
|
||||
- LV_USE_DEMO_MUSIC
|
||||
|
||||
- LV_USE_DEMO_FLEX_LAYOUT
|
||||
|
||||
- LV_USE_DEMO_MULTILANG
|
||||
|
||||
- LV_USE_DEMO_TRANSFORM
|
||||
|
||||
- LV_USE_DEMO_SCROLL
|
||||
|
||||
- LV_USE_DEMO_VECTOR_GRAPHIC
|
||||
|
||||
- LV_USE_DRAW_VGLITE
|
||||
|
||||
- LV_USE_DRAW_VG_LITE
|
||||
|
||||
- LV_USE_DRAW_PXP
|
||||
|
||||
- LV_USE_DRAW_SDL
|
||||
|
||||
- LV_USE_DRAW_ARM2D
|
||||
|
||||
- LV_USE_SNAPSHOT
|
||||
|
||||
- LV_USE_MONKEY
|
||||
|
||||
- LV_USE_GRIDNAV
|
||||
|
||||
- LV_USE_FRAGMENT
|
||||
|
||||
- LV_USE_IMGFONT
|
||||
|
||||
- LV_USE_LINUX_DRM
|
||||
|
||||
- LV_USE_TFT_ESPI
|
||||
|
||||
- LV_USE_ST7735
|
||||
|
||||
- LV_USE_ST7789
|
||||
|
||||
- LV_USE_ST7796
|
||||
|
||||
- LV_USE_ILI9341
|
||||
|
||||
|
||||
|
||||
5. Update `LV_LOG_PRINTF` to `1` and `LV_LOG_LEVEL` to `LV_LOG_LEVEL_USER`
|
||||
|
||||
|
||||
6. Set `LV_FONT_MONTSERRAT_12`, `LV_FONT_MONTSERRAT_24` and `LV_FONT_MONTSERRAT_16` to `1` (So Widgets and Benchmark can be compiled correctly, this is for improving the out of box experience.)
|
||||
|
||||
|
||||
7. Update macro `LV_ATTRIBUTE_MEM_ALIGN` and `LV_ATTRIBUTE_MEM_ALIGN_SIZE` to force a WORD alignment.
|
||||
```c
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1
|
||||
#define LV_DRAW_BUF_STRIDE_ALIGN 4
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN __attribute__((aligned(4)))
|
||||
```
|
||||
Make sure `LV_MEM_SIZE` is no less than `(128*1024U)`.
|
||||
|
||||
8. Remove following macro definitions in the `3rd party libraries` section:
|
||||
|
||||
- \#define LV_USE_FS_STDIO 0
|
||||
- \#define LV_USE_FS_POSIX 0
|
||||
- \#define LV_USE_FS_WIN32 0
|
||||
- \#define LV_USE_FS_FATFS 0
|
||||
- #define LV_USE_FS_LITTLEFS 0
|
||||
- #define LV_USE_FS_MEMFS 0
|
||||
- \#define LV_USE_LODEPNG 0
|
||||
- #define LV_USE_LIBPNG 0
|
||||
- \#define LV_USE_BMP 0
|
||||
- \#define LV_USE_RLE 0
|
||||
- #define LV_USE_TJPGD 0
|
||||
- #define LV_USE_LIBJPEG_TURBO 0
|
||||
- \#define LV_USE_GIF 0
|
||||
- \#define LV_USE_BARCODE 0
|
||||
- \#define LV_USE_QRCODE 0
|
||||
- \#define LV_USE_FREETYPE 0
|
||||
- \#define LV_USE_TINY_TTF 0
|
||||
- \#define LV_USE_RLOTTIE 0
|
||||
- \#define LV_USE_FFMPEG 0
|
||||
|
||||
9. update the definition of following macros: `LV_USE_VECTOR_GRAPHIC`, `LV_USE_THORVE_INTERNAL` and `LV_USE_THORVE_EXTERNAL` as
|
||||
|
||||
```c
|
||||
/*Enable Vector Graphic APIs*/
|
||||
#ifndef LV_USE_VECTOR_GRAPHIC
|
||||
# define LV_USE_VECTOR_GRAPHIC 0
|
||||
|
||||
/* Enable ThorVG (vector graphics library) from the src/libs folder */
|
||||
# define LV_USE_THORVG_INTERNAL 0
|
||||
|
||||
/* Enable ThorVG by assuming that its installed and linked to the project */
|
||||
# define LV_USE_THORVG_EXTERNAL 0
|
||||
#endif
|
||||
```
|
||||
|
||||
10. update the definition of following macros: `LV_USE_LZ4`, `LV_USE_LZ4_INTERNAL` and `LV_USE_LZ4_EXTERNAL` as
|
||||
|
||||
```c
|
||||
/*Enable LZ4 compress/decompress lib*/
|
||||
#ifndef LV_USE_LZ4
|
||||
# define LV_USE_LZ4 0
|
||||
|
||||
/*Use lvgl built-in LZ4 lib*/
|
||||
# define LV_USE_LZ4_INTERNAL 0
|
||||
|
||||
/*Use external LZ4 library*/
|
||||
# define LV_USE_LZ4_EXTERNAL 0
|
||||
#endif
|
||||
```
|
||||
|
||||
|
||||
11. Add the following code to `HAL SETTINGS`:
|
||||
|
||||
```c
|
||||
/*customize tick-get */
|
||||
#if defined(__PERF_COUNTER__) && __PERF_COUNTER__
|
||||
#define LV_GLOBAL_INIT(__GLOBAL_PTR) \
|
||||
do { \
|
||||
lv_global_init((lv_global_t *)(__GLOBAL_PTR)); \
|
||||
extern uint32_t perfc_tick_get(void); \
|
||||
(__GLOBAL_PTR)->tick_state.tick_get_cb = perfc_tick_get; \
|
||||
} while(0)
|
||||
#endif
|
||||
```
|
||||
|
||||
|
||||
|
||||
12. Replace the macro definition:
|
||||
|
||||
```c
|
||||
#define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_NONE
|
||||
```
|
||||
|
||||
with:
|
||||
|
||||
```c
|
||||
#if !defined(LV_USE_DRAW_SW_ASM) && defined(RTE_Acceleration_Arm_2D)
|
||||
/*turn-on helium acceleration when Arm-2D and the Helium-powered device are detected */
|
||||
#if defined(__ARM_FEATURE_MVE) && __ARM_FEATURE_MVE
|
||||
#define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_HELIUM
|
||||
#define LV_USE_DRAW_ARM2D 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_USE_DRAW_SW_ASM
|
||||
#define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_NONE
|
||||
#endif
|
||||
```
|
||||
|
||||
13. Update macro `LV_PROFILER_INCLUDE`:
|
||||
|
||||
```c
|
||||
#define LV_PROFILER_INCLUDE "src/misc/lv_profiler_builtin.h"
|
||||
```
|
||||
|
||||
|
||||
|
||||
14. rename '**lv_conf_template.h**' to '**lv_conf_cmsis.h**'.
|
||||
|
||||
|
||||
|
||||
## STEP 2 Check, Update and Run the 'gen_pack.sh'
|
||||
|
||||
```sh
|
||||
if [ `uname -s` = "Linux" ]
|
||||
then
|
||||
CMSIS_PACK_PATH="/home/$USER/.arm/Packs/ARM/CMSIS/5.7.0/"
|
||||
PATH_TO_ADD="$CMSIS_PACK_PATH/CMSIS/Utilities/Linux64/"
|
||||
else
|
||||
CMSIS_PACK_PATH="/C/Users/$USER/AppData/Local/Arm/Packs/ARM/CMSIS/5.7.0"
|
||||
PATH_TO_ADD="/C/Program Files (x86)/7-Zip/:$CMSIS_PACK_PATH/CMSIS/Utilities/Win32/:/C/xmllint/"
|
||||
fi
|
||||
[[ ":$PATH:" != *":$PATH_TO_ADD}:"* ]] && PATH="${PATH}:${PATH_TO_ADD}"
|
||||
echo $PATH_TO_ADD appended to PATH
|
||||
echo " "
|
||||
```
|
||||
|
||||
|
||||
|
||||
### A. For Windows users
|
||||
|
||||
Update the '**CMSIS_PACK_PATH**' accordingly (Usually just replace the name gabriel with your own windows account name is sufficient.).
|
||||
|
||||
Update the '**PATH_TO_ADD**' to point to the installation folders of **7Zip** and **xmllint**.
|
||||
|
||||
Launch the git-bash and go to the cmsis-pack folder.
|
||||
|
||||
enter the following command:
|
||||
|
||||
```sh
|
||||
./gen_pack.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
### B. For Linux Users
|
||||
|
||||
Update '**PATH_TO_ADD**' if necessary.
|
||||
|
||||
go to the **cmsis-pack** folder.
|
||||
|
||||
enter the following command:
|
||||
|
||||
```sh
|
||||
./gen_pack.sh
|
||||
```
|
||||
236
libraries/lvgl/env_support/cmsis-pack/gen_pack.sh
Normal file
236
libraries/lvgl/env_support/cmsis-pack/gen_pack.sh
Normal file
@ -0,0 +1,236 @@
|
||||
#!/bin/bash
|
||||
# Version: 1.1
|
||||
# Date: 2022-01-11
|
||||
# This bash script generates a CMSIS Software Pack:
|
||||
#
|
||||
# Pre-requisites:
|
||||
# - bash shell (for Windows: install git for Windows)
|
||||
# - 7z in path (zip archiving utility)
|
||||
# e.g. Ubuntu: sudo apt-get install p7zip-full p7zip-rar)
|
||||
# - PackChk in path with execute permission
|
||||
# (see CMSIS-Pack: CMSIS/Utilities/<os>/PackChk)
|
||||
# - xmllint in path (XML schema validation)
|
||||
# e.g. Ubuntu: sudo apt-get install libxml2-utils
|
||||
# Windows: download from https://www.zlatkovic.com/pub/libxml/
|
||||
|
||||
############### EDIT BELOW ###############
|
||||
# Extend Path environment variable locally
|
||||
#
|
||||
if [ `uname -s` = "Linux" ]
|
||||
then
|
||||
CMSIS_PACK_PATH="/home/$USER/.arm/Packs/ARM/CMSIS/5.7.0/"
|
||||
PATH_TO_ADD="$CMSIS_PACK_PATH/CMSIS/Utilities/Linux64/"
|
||||
else
|
||||
CMSIS_PACK_PATH="/C/Users/$USER/AppData/Local/Arm/Packs/ARM/CMSIS/5.7.0"
|
||||
PATH_TO_ADD="/C/Program Files (x86)/7-Zip/:/C/Program Files/7-Zip/:$CMSIS_PACK_PATH/CMSIS/Utilities/Win32/:/C/xmllint/"
|
||||
fi
|
||||
[[ ":$PATH:" != *":$PATH_TO_ADD}:"* ]] && PATH="${PATH}:${PATH_TO_ADD}"
|
||||
echo $PATH_TO_ADD appended to PATH
|
||||
echo " "
|
||||
|
||||
# Pack warehouse directory - destination
|
||||
PACK_WAREHOUSE=./
|
||||
|
||||
# Temporary pack build directory
|
||||
PACK_BUILD=build/
|
||||
|
||||
# Specify directories included in pack relative to base directory
|
||||
# All directories:
|
||||
# PACK_DIRS=`ls -d */`
|
||||
# Do not include the build directory if it is local
|
||||
# PACK_DIRS=${PACK_DIRS//$PACK_BUILD/}
|
||||
# PACK_DIRS=${PACK_DIRS//$PACK_WAREHOUSE/}
|
||||
|
||||
# alternative: specify directory names to be added to pack base directory
|
||||
PACK_DIRS="
|
||||
../../src
|
||||
../../demos
|
||||
../../env_support/pikascript
|
||||
"
|
||||
|
||||
|
||||
# Specify file names to be added to pack base directory
|
||||
PACK_BASE_FILES="
|
||||
../../LICENCE.txt
|
||||
../../README.md
|
||||
../../lvgl.h
|
||||
lv_conf_cmsis.h
|
||||
lv_cmsis_pack.txt
|
||||
"
|
||||
|
||||
############ DO NOT EDIT BELOW ###########
|
||||
echo Starting CMSIS-Pack Generation: `date`
|
||||
# Zip utility check
|
||||
ZIP=7z
|
||||
type -a $ZIP
|
||||
errorlevel=$?
|
||||
if [ $errorlevel -gt 0 ]
|
||||
then
|
||||
echo "Error: No 7zip Utility found"
|
||||
echo "Action: Add 7zip to your path"
|
||||
echo " "
|
||||
exit
|
||||
fi
|
||||
|
||||
# Pack checking utility check
|
||||
PACKCHK=PackChk
|
||||
type -a $PACKCHK
|
||||
errorlevel=$?
|
||||
if [ $errorlevel != 0 ]
|
||||
then
|
||||
echo "Error: No PackChk Utility found"
|
||||
echo "Action: Add PackChk to your path"
|
||||
echo "Hint: Included in CMSIS Pack:"
|
||||
echo "<pack_root_dir>/ARM/CMSIS/<version>/CMSIS/Utilities/<os>/"
|
||||
echo " "
|
||||
exit
|
||||
fi
|
||||
echo " "
|
||||
|
||||
# XML syntax checking utility check
|
||||
XMLLINT=xmllint
|
||||
type -a $XMLLINT
|
||||
errorlevel=$?
|
||||
if [ $errorlevel != 0 ]
|
||||
then
|
||||
echo "Error: No xmllint found"
|
||||
echo "Action: Add xmllint to your path"
|
||||
echo " "
|
||||
exit
|
||||
fi
|
||||
echo " "
|
||||
|
||||
# Locate Package Description file
|
||||
# check whether there is more than one pdsc file
|
||||
NUM_PDSCS=`ls -1 *.pdsc | wc -l`
|
||||
PACK_DESCRIPTION_FILE=`ls *.pdsc`
|
||||
if [ $NUM_PDSCS -lt 1 ]
|
||||
then
|
||||
echo "Error: No *.pdsc file found in current directory"
|
||||
echo " "
|
||||
elif [ $NUM_PDSCS -gt 1 ]
|
||||
then
|
||||
echo "Error: Only one PDSC file allowed in directory structure:"
|
||||
echo "Found:"
|
||||
echo "$PACK_DESCRIPTION_FILE"
|
||||
echo "Action: Delete unused pdsc files"
|
||||
echo " "
|
||||
exit
|
||||
fi
|
||||
|
||||
SAVEIFS=$IFS
|
||||
IFS=.
|
||||
set $PACK_DESCRIPTION_FILE
|
||||
# Pack Vendor
|
||||
PACK_VENDOR=$1
|
||||
# Pack Name
|
||||
PACK_NAME=$2
|
||||
echo Generating Pack Version: for $PACK_VENDOR.$PACK_NAME
|
||||
echo " "
|
||||
IFS=$SAVEIFS
|
||||
|
||||
#if $PACK_BUILD directory does not exist, create it.
|
||||
if [ ! -d $PACK_BUILD ]; then
|
||||
mkdir -p $PACK_BUILD
|
||||
fi
|
||||
|
||||
mkdir -p ${PACK_BUILD}/examples
|
||||
mkdir -p ${PACK_BUILD}/examples/porting
|
||||
|
||||
|
||||
|
||||
# directories
|
||||
echo Adding directories to pack:
|
||||
echo $PACK_DIRS
|
||||
echo " "
|
||||
for d in ${PACK_DIRS}
|
||||
do
|
||||
cp -r "$d" ${PACK_BUILD}
|
||||
done
|
||||
|
||||
# files for base directory
|
||||
echo Adding files to pack:
|
||||
echo $PACK_BASE_FILES
|
||||
echo " "
|
||||
for f in $PACK_BASE_FILES
|
||||
do
|
||||
cp -f "$f" $PACK_BUILD/
|
||||
done
|
||||
|
||||
# Copy files into build base directory: $PACK_BUILD
|
||||
# pdsc file is mandatory in base directory:
|
||||
cp -f ./$PACK_VENDOR.$PACK_NAME.pdsc ${PACK_BUILD}
|
||||
cp -f ../../examples/porting/* ${PACK_BUILD}/examples/porting
|
||||
cp -f ./lv_os_custom_c.txt ${PACK_BUILD}/src/osal/lv_os_custom.c
|
||||
cp -f ./lv_os_custom_h.txt ${PACK_BUILD}/src/osal/lv_os_custom.h
|
||||
|
||||
mv "${PACK_BUILD}/lv_cmsis_pack.txt" "${PACK_BUILD}/lv_cmsis_pack.c"
|
||||
|
||||
# Run Schema Check (for Linux only):
|
||||
# sudo apt-get install libxml2-utils
|
||||
|
||||
echo Running schema check for $PACK_VENDOR.$PACK_NAME.pdsc
|
||||
$XMLLINT --noout --schema ${CMSIS_PACK_PATH}/CMSIS/Utilities/PACK.xsd $PACK_BUILD/$PACK_VENDOR.$PACK_NAME.pdsc
|
||||
errorlevel=$?
|
||||
if [ $errorlevel -ne 0 ]; then
|
||||
echo "build aborted: Schema check of $PACK_VENDOR.$PACK_NAME.pdsc against PACK.xsd failed"
|
||||
echo " "
|
||||
exit
|
||||
fi
|
||||
|
||||
# Run Pack Check and generate PackName file with version
|
||||
$PACKCHK $PACK_BUILD/$PACK_VENDOR.$PACK_NAME.pdsc -n PackName.txt -x M362
|
||||
errorlevel=$?
|
||||
if [ $errorlevel -ne 0 ]; then
|
||||
echo "build aborted: pack check failed"
|
||||
echo " "
|
||||
exit
|
||||
fi
|
||||
|
||||
PACKNAME=`cat PackName.txt`
|
||||
rm -rf PackName.txt
|
||||
|
||||
# echo apply patches...
|
||||
# rm -rf $PACK_BUILD/demos/lv_demos.h
|
||||
# cp -f ./lv_demos.h $PACK_BUILD/demos/
|
||||
|
||||
echo delete files...
|
||||
find $PACK_BUILD/demos/ -type f -name "*.png" -delete
|
||||
find $PACK_BUILD/demos/ -type f -name "*.gif" -delete
|
||||
find $PACK_BUILD/demos/ -type f -name "*.gif" -delete
|
||||
find $PACK_BUILD/demos/ -type f -name "*.ttf" -delete
|
||||
find $PACK_BUILD/demos/ -type f -name "*.otf" -delete
|
||||
find $PACK_BUILD/demos/ -type f -name "*.jpg" -delete
|
||||
find $PACK_BUILD/demos/ -type f -name "*.fnt" -delete
|
||||
|
||||
# Archiving
|
||||
# $ZIP a $PACKNAME
|
||||
echo creating pack file $PACKNAME
|
||||
#if $PACK_WAREHOUSE directory does not exist create it
|
||||
if [ ! -d $PACK_WAREHOUSE ]; then
|
||||
mkdir -p $PACK_WAREHOUSE
|
||||
fi
|
||||
pushd $PACK_WAREHOUSE
|
||||
PACK_WAREHOUSE=`pwd`
|
||||
popd
|
||||
pushd $PACK_BUILD
|
||||
"$ZIP" a $PACK_WAREHOUSE/$PACKNAME -tzip
|
||||
popd
|
||||
errorlevel=$?
|
||||
if [ $errorlevel -ne 0 ]; then
|
||||
echo "build aborted: archiving failed"
|
||||
exit
|
||||
fi
|
||||
|
||||
# cp -f ./$PACK_VENDOR.$PACK_NAME.pdsc ${PACK_WAREHOUSE}
|
||||
|
||||
|
||||
echo "build of pack succeeded"
|
||||
# Clean up
|
||||
echo "cleaning up ..."
|
||||
|
||||
rm -rf $PACK_BUILD
|
||||
|
||||
echo " "
|
||||
|
||||
echo Completed CMSIS-Pack Generation: `date`
|
||||
139
libraries/lvgl/env_support/cmsis-pack/lv_cmsis_pack.txt
Normal file
139
libraries/lvgl/env_support/cmsis-pack/lv_cmsis_pack.txt
Normal file
@ -0,0 +1,139 @@
|
||||
/****************************************************************************
|
||||
* Copyright 2022 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) *
|
||||
* *
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); *
|
||||
* you may not use this file except in compliance with the License. *
|
||||
* You may obtain a copy of the License at *
|
||||
* *
|
||||
* http://www.apache.org/licenses/LICENSE-2.0 *
|
||||
* *
|
||||
* Unless required by applicable law or agreed to in writing, software *
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, *
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
|
||||
* See the License for the specific language governing permissions and *
|
||||
* limitations under the License. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file lv_cmsis_pack.c
|
||||
*
|
||||
* @brief This file will only be used by cmsis-pack.
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "RTE_Components.h"
|
||||
#include <time.h>
|
||||
|
||||
#if defined(__PERF_COUNTER__) && __PERF_COUNTER__
|
||||
# include "perf_counter.h"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "lv_global.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define state LV_GLOBAL_DEFAULT()->tick_state
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/*! \name The macros to identify the compiler */
|
||||
/*! @{ */
|
||||
|
||||
/*! \note for IAR */
|
||||
#undef __IS_COMPILER_IAR__
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
# define __IS_COMPILER_IAR__ 1
|
||||
#endif
|
||||
|
||||
/*! \note for arm compiler 5 */
|
||||
#undef __IS_COMPILER_ARM_COMPILER_5__
|
||||
#if ((__ARMCC_VERSION >= 5000000) && (__ARMCC_VERSION < 6000000))
|
||||
# define __IS_COMPILER_ARM_COMPILER_5__ 1
|
||||
#endif
|
||||
/*! @} */
|
||||
|
||||
/*! \note for arm compiler 6 */
|
||||
|
||||
#undef __IS_COMPILER_ARM_COMPILER_6__
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
# define __IS_COMPILER_ARM_COMPILER_6__ 1
|
||||
#endif
|
||||
|
||||
#undef __IS_COMPILER_ARM_COMPILER__
|
||||
#if defined(__IS_COMPILER_ARM_COMPILER_5__) && __IS_COMPILER_ARM_COMPILER_5__ \
|
||||
|| defined(__IS_COMPILER_ARM_COMPILER_6__) && __IS_COMPILER_ARM_COMPILER_6__
|
||||
|
||||
# define __IS_COMPILER_ARM_COMPILER__ 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#undef __IS_COMPILER_LLVM__
|
||||
#if defined(__clang__) && !__IS_COMPILER_ARM_COMPILER_6__
|
||||
# define __IS_COMPILER_LLVM__ 1
|
||||
#else
|
||||
/*! \note for gcc */
|
||||
# undef __IS_COMPILER_GCC__
|
||||
# if defined(__GNUC__) && !( defined(__IS_COMPILER_ARM_COMPILER__) \
|
||||
|| defined(__IS_COMPILER_LLVM__))
|
||||
# define __IS_COMPILER_GCC__ 1
|
||||
# endif
|
||||
/*! @} */
|
||||
#endif
|
||||
/*! @} */
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/* When Arm Compilers using the MicroLib, provide an empty implementation for
|
||||
* time() which is not included in the MicroLib
|
||||
*/
|
||||
#if defined(__IS_COMPILER_ARM_COMPILER__) && __IS_COMPILER_ARM_COMPILER__
|
||||
# if defined(__MICROLIB)
|
||||
__attribute__((weak))
|
||||
_ARMABI time_t time(time_t * time)
|
||||
{
|
||||
return (time_t)(-1);
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
|
||||
# if defined(__PERF_COUNTER__) && __PERF_COUNTER__
|
||||
/**
|
||||
* Get the elapsed milliseconds since start up from perf_counter
|
||||
* @return the elapsed milliseconds
|
||||
*/
|
||||
uint32_t perfc_tick_get(void)
|
||||
{
|
||||
return (uint32_t)get_system_ms();
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
885
libraries/lvgl/env_support/cmsis-pack/lv_conf_cmsis.h
Normal file
885
libraries/lvgl/env_support/cmsis-pack/lv_conf_cmsis.h
Normal file
@ -0,0 +1,885 @@
|
||||
/**
|
||||
* @file lv_conf.h
|
||||
* Configuration file for v9.1.0
|
||||
*/
|
||||
|
||||
/* clang-format off */
|
||||
#if 1 /*Set it to "1" to enable content*/
|
||||
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
|
||||
#if defined(_RTE_)
|
||||
#include "RTE_Components.h"
|
||||
#endif
|
||||
|
||||
/*If you need to include anything here, do it inside the `__ASSEMBLY__` guard */
|
||||
#if 0 && defined(__ASSEMBLY__)
|
||||
#include "my_include.h"
|
||||
#endif
|
||||
|
||||
/*====================
|
||||
COLOR SETTINGS
|
||||
*====================*/
|
||||
|
||||
/*Color depth: 8 (A8), 16 (RGB565), 24 (RGB888), 32 (XRGB8888)*/
|
||||
#define LV_COLOR_DEPTH 16
|
||||
|
||||
/*=========================
|
||||
STDLIB WRAPPER SETTINGS
|
||||
*=========================*/
|
||||
|
||||
/* Possible values
|
||||
* - LV_STDLIB_BUILTIN: LVGL's built in implementation
|
||||
* - LV_STDLIB_CLIB: Standard C functions, like malloc, strlen, etc
|
||||
* - LV_STDLIB_MICROPYTHON: MicroPython implementation
|
||||
* - LV_STDLIB_RTTHREAD: RT-Thread implementation
|
||||
* - LV_STDLIB_CUSTOM: Implement the functions externally
|
||||
*/
|
||||
#define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN
|
||||
#define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN
|
||||
#define LV_USE_STDLIB_SPRINTF LV_STDLIB_BUILTIN
|
||||
|
||||
|
||||
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
|
||||
/*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/
|
||||
#define LV_MEM_SIZE (128 * 1024U) /*[bytes]*/
|
||||
|
||||
/*Size of the memory expand for `lv_malloc()` in bytes*/
|
||||
#define LV_MEM_POOL_EXPAND_SIZE 0
|
||||
|
||||
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
|
||||
#define LV_MEM_ADR 0 /*0: unused*/
|
||||
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
|
||||
#if LV_MEM_ADR == 0
|
||||
#undef LV_MEM_POOL_INCLUDE
|
||||
#undef LV_MEM_POOL_ALLOC
|
||||
#endif
|
||||
#endif /*LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN*/
|
||||
|
||||
/*====================
|
||||
HAL SETTINGS
|
||||
*====================*/
|
||||
|
||||
/*Default display refresh, input device read and animation step period.*/
|
||||
#define LV_DEF_REFR_PERIOD 33 /*[ms]*/
|
||||
|
||||
/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
|
||||
*(Not so important, you can adjust it to modify default sizes and spaces)*/
|
||||
#define LV_DPI_DEF 130 /*[px/inch]*/
|
||||
|
||||
/*customize tick-get */
|
||||
#if defined(__PERF_COUNTER__) && __PERF_COUNTER__
|
||||
#define LV_GLOBAL_INIT(__GLOBAL_PTR) \
|
||||
do { \
|
||||
lv_global_init((lv_global_t *)(__GLOBAL_PTR)); \
|
||||
extern uint32_t perfc_tick_get(void); \
|
||||
(__GLOBAL_PTR)->tick_state.tick_get_cb = perfc_tick_get; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/*=================
|
||||
* OPERATING SYSTEM
|
||||
*=================*/
|
||||
|
||||
#if LV_USE_OS == LV_OS_CUSTOM
|
||||
#define LV_OS_CUSTOM_INCLUDE <stdint.h>
|
||||
#endif
|
||||
|
||||
/*========================
|
||||
* RENDERING CONFIGURATION
|
||||
*========================*/
|
||||
|
||||
/*Align the stride of all layers and images to this bytes*/
|
||||
#define LV_DRAW_BUF_STRIDE_ALIGN 1
|
||||
|
||||
/*Align the start address of draw_buf addresses to this bytes*/
|
||||
#define LV_DRAW_BUF_ALIGN 4
|
||||
|
||||
/* If a widget has `style_opa < 255` (not `bg_opa`, `text_opa` etc) or not NORMAL blend mode
|
||||
* it is buffered into a "simple" layer before rendering. The widget can be buffered in smaller chunks.
|
||||
* "Transformed layers" (if `transform_angle/zoom` are set) use larger buffers
|
||||
* and can't be drawn in chunks. */
|
||||
|
||||
/*The target buffer size for simple layer chunks.*/
|
||||
#define LV_DRAW_LAYER_SIMPLE_BUF_SIZE (24 * 1024) /*[bytes]*/
|
||||
|
||||
#define LV_USE_DRAW_SW 1
|
||||
#if LV_USE_DRAW_SW == 1
|
||||
/* Set the number of draw unit.
|
||||
* > 1 requires an operating system enabled in `LV_USE_OS`
|
||||
* > 1 means multiply threads will render the screen in parallel */
|
||||
#define LV_DRAW_SW_DRAW_UNIT_CNT 1
|
||||
|
||||
/* Enable native helium assembly to be compiled */
|
||||
#define LV_USE_NATIVE_HELIUM_ASM 0
|
||||
|
||||
/* 0: use a simple renderer capable of drawing only simple rectangles with gradient, images, texts, and straight lines only
|
||||
* 1: use a complex renderer capable of drawing rounded corners, shadow, skew lines, and arcs too */
|
||||
#define LV_DRAW_SW_COMPLEX 1
|
||||
|
||||
#if LV_DRAW_SW_COMPLEX == 1
|
||||
/*Allow buffering some shadow calculation.
|
||||
*LV_DRAW_SW_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius`
|
||||
*Caching has LV_DRAW_SW_SHADOW_CACHE_SIZE^2 RAM cost*/
|
||||
#define LV_DRAW_SW_SHADOW_CACHE_SIZE 0
|
||||
|
||||
/* Set number of maximally cached circle data.
|
||||
* The circumference of 1/4 circle are saved for anti-aliasing
|
||||
* radius * 4 bytes are used per circle (the most often used radiuses are saved)
|
||||
* 0: to disable caching */
|
||||
#define LV_DRAW_SW_CIRCLE_CACHE_SIZE 4
|
||||
#endif
|
||||
|
||||
#if !defined(LV_USE_DRAW_SW_ASM) && defined(RTE_Acceleration_Arm_2D)
|
||||
/*turn-on helium acceleration when Arm-2D and the Helium-powered device are detected */
|
||||
#if defined(__ARM_FEATURE_MVE) && __ARM_FEATURE_MVE
|
||||
#define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_HELIUM
|
||||
#define LV_USE_DRAW_ARM2D_SYNC 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_USE_DRAW_SW_ASM
|
||||
#define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_NONE
|
||||
#endif
|
||||
|
||||
#if LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_CUSTOM
|
||||
#define LV_DRAW_SW_ASM_CUSTOM_INCLUDE ""
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LV_USE_DRAW_VGLITE
|
||||
/* Enable blit quality degradation workaround recommended for screen's dimension > 352 pixels. */
|
||||
#define LV_USE_VGLITE_BLIT_SPLIT 0
|
||||
|
||||
#if LV_USE_OS
|
||||
/* Enable VGLite draw async. Queue multiple tasks and flash them once to the GPU. */
|
||||
#define LV_USE_VGLITE_DRAW_ASYNC 1
|
||||
#endif
|
||||
|
||||
/* Enable VGLite asserts. */
|
||||
#define LV_USE_VGLITE_ASSERT 0
|
||||
#endif
|
||||
|
||||
#if LV_USE_DRAW_PXP
|
||||
/* Enable PXP asserts. */
|
||||
#define LV_USE_PXP_ASSERT 0
|
||||
#endif
|
||||
|
||||
/* Use VG-Lite GPU. */
|
||||
#define LV_USE_DRAW_VG_LITE 0
|
||||
|
||||
#if LV_USE_DRAW_VG_LITE
|
||||
/* Enable VG-Lite custom external 'gpu_init()' function */
|
||||
#define LV_VG_LITE_USE_GPU_INIT 0
|
||||
|
||||
/* Enable VG-Lite assert. */
|
||||
#define LV_VG_LITE_USE_ASSERT 0
|
||||
|
||||
/* VG-Lite flush commit trigger threshold. GPU will try to batch these many draw tasks. */
|
||||
#define LV_VG_LITE_FLUSH_MAX_COUNT 8
|
||||
|
||||
/* Enable border to simulate shadow
|
||||
* NOTE: which usually improves performance,
|
||||
* but does not guarantee the same rendering quality as the software. */
|
||||
#define LV_VG_LITE_USE_BOX_SHADOW 0
|
||||
|
||||
/* VG-Lite gradient image maximum cache number.
|
||||
* NOTE: The memory usage of a single gradient image is 4K bytes.
|
||||
*/
|
||||
#define LV_VG_LITE_GRAD_CACHE_SIZE 32
|
||||
|
||||
#endif
|
||||
|
||||
/*=======================
|
||||
* FEATURE CONFIGURATION
|
||||
*=======================*/
|
||||
|
||||
/*-------------
|
||||
* Logging
|
||||
*-----------*/
|
||||
|
||||
/*Enable the log module*/
|
||||
#define LV_USE_LOG 0
|
||||
#if LV_USE_LOG
|
||||
|
||||
/*How important log should be added:
|
||||
*LV_LOG_LEVEL_TRACE A lot of logs to give detailed information
|
||||
*LV_LOG_LEVEL_INFO Log important events
|
||||
*LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem
|
||||
*LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
|
||||
*LV_LOG_LEVEL_USER Only logs added by the user
|
||||
*LV_LOG_LEVEL_NONE Do not log anything*/
|
||||
#define LV_LOG_LEVEL LV_LOG_LEVEL_USER
|
||||
|
||||
/*1: Print the log with 'printf';
|
||||
*0: User need to register a callback with `lv_log_register_print_cb()`*/
|
||||
#define LV_LOG_PRINTF 1
|
||||
|
||||
/*1: Enable print timestamp;
|
||||
*0: Disable print timestamp*/
|
||||
#define LV_LOG_USE_TIMESTAMP 1
|
||||
|
||||
/*1: Print file and line number of the log;
|
||||
*0: Do not print file and line number of the log*/
|
||||
#define LV_LOG_USE_FILE_LINE 1
|
||||
|
||||
/*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/
|
||||
#define LV_LOG_TRACE_MEM 1
|
||||
#define LV_LOG_TRACE_TIMER 1
|
||||
#define LV_LOG_TRACE_INDEV 1
|
||||
#define LV_LOG_TRACE_DISP_REFR 1
|
||||
#define LV_LOG_TRACE_EVENT 1
|
||||
#define LV_LOG_TRACE_OBJ_CREATE 1
|
||||
#define LV_LOG_TRACE_LAYOUT 1
|
||||
#define LV_LOG_TRACE_ANIM 1
|
||||
#define LV_LOG_TRACE_CACHE 1
|
||||
|
||||
#endif /*LV_USE_LOG*/
|
||||
|
||||
/*-------------
|
||||
* Asserts
|
||||
*-----------*/
|
||||
|
||||
/*Enable asserts if an operation is failed or an invalid data is found.
|
||||
*If LV_USE_LOG is enabled an error message will be printed on failure*/
|
||||
#define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/
|
||||
#define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/
|
||||
#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/
|
||||
#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/
|
||||
#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/
|
||||
|
||||
/*Add a custom handler when assert happens e.g. to restart the MCU*/
|
||||
#define LV_ASSERT_HANDLER_INCLUDE <stdint.h>
|
||||
#define LV_ASSERT_HANDLER while(1); /*Halt by default*/
|
||||
|
||||
/*-------------
|
||||
* Debug
|
||||
*-----------*/
|
||||
|
||||
/*1: Draw random colored rectangles over the redrawn areas*/
|
||||
#define LV_USE_REFR_DEBUG 0
|
||||
|
||||
/*1: Draw a red overlay for ARGB layers and a green overlay for RGB layers*/
|
||||
#define LV_USE_LAYER_DEBUG 0
|
||||
|
||||
/*1: Draw overlays with different colors for each draw_unit's tasks.
|
||||
*Also add the index number of the draw unit on white background.
|
||||
*For layers add the index number of the draw unit on black background.*/
|
||||
#define LV_USE_PARALLEL_DRAW_DEBUG 0
|
||||
|
||||
/*-------------
|
||||
* Others
|
||||
*-----------*/
|
||||
|
||||
#define LV_ENABLE_GLOBAL_CUSTOM 0
|
||||
#if LV_ENABLE_GLOBAL_CUSTOM
|
||||
/*Header to include for the custom 'lv_global' function"*/
|
||||
#define LV_GLOBAL_CUSTOM_INCLUDE <stdint.h>
|
||||
#endif
|
||||
|
||||
/*Default cache size in bytes.
|
||||
*Used by image decoders such as `lv_lodepng` to keep the decoded image in the memory.
|
||||
*Data larger than the size of the cache also can be allocated but
|
||||
*will be dropped immediately after usage.*/
|
||||
#define LV_CACHE_DEF_SIZE 0
|
||||
|
||||
/*Default number of image header cache entries. The cache is used to store the headers of images
|
||||
*The main logic is like `LV_CACHE_DEF_SIZE` but for image headers.*/
|
||||
#define LV_IMAGE_HEADER_CACHE_DEF_CNT 0
|
||||
|
||||
/*Number of stops allowed per gradient. Increase this to allow more stops.
|
||||
*This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/
|
||||
#define LV_GRADIENT_MAX_STOPS 2
|
||||
|
||||
/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.
|
||||
* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
|
||||
#define LV_COLOR_MIX_ROUND_OFS 0
|
||||
|
||||
/* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */
|
||||
#define LV_OBJ_STYLE_CACHE 0
|
||||
|
||||
/* Add `id` field to `lv_obj_t` */
|
||||
#define LV_USE_OBJ_ID 0
|
||||
|
||||
/* Use lvgl builtin method for obj ID */
|
||||
#define LV_USE_OBJ_ID_BUILTIN 0
|
||||
|
||||
/*Use obj property set/get API*/
|
||||
#define LV_USE_OBJ_PROPERTY 0
|
||||
|
||||
/* VG-Lite Simulator */
|
||||
/*Requires: LV_USE_THORVG_INTERNAL or LV_USE_THORVG_EXTERNAL */
|
||||
#define LV_USE_VG_LITE_THORVG 0
|
||||
|
||||
#if LV_USE_VG_LITE_THORVG
|
||||
|
||||
/*Enable LVGL's blend mode support*/
|
||||
#define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT 0
|
||||
|
||||
/*Enable YUV color format support*/
|
||||
#define LV_VG_LITE_THORVG_YUV_SUPPORT 0
|
||||
|
||||
/*Enable 16 pixels alignment*/
|
||||
#define LV_VG_LITE_THORVG_16PIXELS_ALIGN 1
|
||||
|
||||
/*Buffer address alignment*/
|
||||
#define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN 64
|
||||
|
||||
/*Enable multi-thread render*/
|
||||
#define LV_VG_LITE_THORVG_THREAD_RENDER 0
|
||||
|
||||
#endif
|
||||
|
||||
/*=====================
|
||||
* COMPILER SETTINGS
|
||||
*====================*/
|
||||
|
||||
/*For big endian systems set to 1*/
|
||||
#define LV_BIG_ENDIAN_SYSTEM 0
|
||||
|
||||
/*Define a custom attribute to `lv_tick_inc` function*/
|
||||
#define LV_ATTRIBUTE_TICK_INC
|
||||
|
||||
/*Define a custom attribute to `lv_timer_handler` function*/
|
||||
#define LV_ATTRIBUTE_TIMER_HANDLER
|
||||
|
||||
/*Define a custom attribute to `lv_display_flush_ready` function*/
|
||||
#define LV_ATTRIBUTE_FLUSH_READY
|
||||
|
||||
/*Required alignment size for buffers*/
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 4
|
||||
|
||||
/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default).
|
||||
* E.g. __attribute__((aligned(4)))*/
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN __attribute__((aligned(4)))
|
||||
|
||||
/*Attribute to mark large constant arrays for example font's bitmaps*/
|
||||
#define LV_ATTRIBUTE_LARGE_CONST
|
||||
|
||||
/*Compiler prefix for a big array declaration in RAM*/
|
||||
#define LV_ATTRIBUTE_LARGE_RAM_ARRAY
|
||||
|
||||
/*Place performance critical functions into a faster memory (e.g RAM)*/
|
||||
#define LV_ATTRIBUTE_FAST_MEM
|
||||
|
||||
/*Export integer constant to binding. This macro is used with constants in the form of LV_<CONST> that
|
||||
*should also appear on LVGL binding API such as Micropython.*/
|
||||
#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/
|
||||
|
||||
/*Prefix all global extern data with this*/
|
||||
#define LV_ATTRIBUTE_EXTERN_DATA
|
||||
|
||||
/* Use `float` as `lv_value_precise_t` */
|
||||
#define LV_USE_FLOAT 0
|
||||
|
||||
/*==================
|
||||
* FONT USAGE
|
||||
*===================*/
|
||||
|
||||
/*Montserrat fonts with ASCII range and some symbols using bpp = 4
|
||||
*https://fonts.google.com/specimen/Montserrat*/
|
||||
#define LV_FONT_MONTSERRAT_8 0
|
||||
#define LV_FONT_MONTSERRAT_10 0
|
||||
#define LV_FONT_MONTSERRAT_12 1
|
||||
#define LV_FONT_MONTSERRAT_14 1
|
||||
#define LV_FONT_MONTSERRAT_16 1
|
||||
#define LV_FONT_MONTSERRAT_18 0
|
||||
#define LV_FONT_MONTSERRAT_20 0
|
||||
#define LV_FONT_MONTSERRAT_22 0
|
||||
#define LV_FONT_MONTSERRAT_24 1
|
||||
#define LV_FONT_MONTSERRAT_26 0
|
||||
#define LV_FONT_MONTSERRAT_28 0
|
||||
#define LV_FONT_MONTSERRAT_30 0
|
||||
#define LV_FONT_MONTSERRAT_32 0
|
||||
#define LV_FONT_MONTSERRAT_34 0
|
||||
#define LV_FONT_MONTSERRAT_36 0
|
||||
#define LV_FONT_MONTSERRAT_38 0
|
||||
#define LV_FONT_MONTSERRAT_40 0
|
||||
#define LV_FONT_MONTSERRAT_42 0
|
||||
#define LV_FONT_MONTSERRAT_44 0
|
||||
#define LV_FONT_MONTSERRAT_46 0
|
||||
#define LV_FONT_MONTSERRAT_48 0
|
||||
|
||||
/*Demonstrate special features*/
|
||||
#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/
|
||||
#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/
|
||||
#define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/
|
||||
|
||||
/*Pixel perfect monospace fonts*/
|
||||
#define LV_FONT_UNSCII_8 0
|
||||
#define LV_FONT_UNSCII_16 0
|
||||
|
||||
/*Optionally declare custom fonts here.
|
||||
*You can use these fonts as default font too and they will be available globally.
|
||||
*E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/
|
||||
#define LV_FONT_CUSTOM_DECLARE
|
||||
|
||||
/*Always set a default font*/
|
||||
#define LV_FONT_DEFAULT &lv_font_montserrat_14
|
||||
|
||||
/*Enable handling large font and/or fonts with a lot of characters.
|
||||
*The limit depends on the font size, font face and bpp.
|
||||
*Compiler error will be triggered if a font needs it.*/
|
||||
#define LV_FONT_FMT_TXT_LARGE 0
|
||||
|
||||
/*Enables/disables support for compressed fonts.*/
|
||||
#define LV_USE_FONT_COMPRESSED 0
|
||||
|
||||
/*Enable drawing placeholders when glyph dsc is not found*/
|
||||
#define LV_USE_FONT_PLACEHOLDER 1
|
||||
|
||||
/*=================
|
||||
* TEXT SETTINGS
|
||||
*=================*/
|
||||
|
||||
/**
|
||||
* Select a character encoding for strings.
|
||||
* Your IDE or editor should have the same character encoding
|
||||
* - LV_TXT_ENC_UTF8
|
||||
* - LV_TXT_ENC_ASCII
|
||||
*/
|
||||
#define LV_TXT_ENC LV_TXT_ENC_UTF8
|
||||
|
||||
/*Can break (wrap) texts on these chars*/
|
||||
#define LV_TXT_BREAK_CHARS " ,.;:-_)]}"
|
||||
|
||||
/*If a word is at least this long, will break wherever "prettiest"
|
||||
*To disable, set to a value <= 0*/
|
||||
#define LV_TXT_LINE_BREAK_LONG_LEN 0
|
||||
|
||||
/*Minimum number of characters in a long word to put on a line before a break.
|
||||
*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
|
||||
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3
|
||||
|
||||
/*Minimum number of characters in a long word to put on a line after a break.
|
||||
*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
|
||||
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3
|
||||
|
||||
/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts.
|
||||
*The direction will be processed according to the Unicode Bidirectional Algorithm:
|
||||
*https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/
|
||||
#define LV_USE_BIDI 0
|
||||
#if LV_USE_BIDI
|
||||
/*Set the default direction. Supported values:
|
||||
*`LV_BASE_DIR_LTR` Left-to-Right
|
||||
*`LV_BASE_DIR_RTL` Right-to-Left
|
||||
*`LV_BASE_DIR_AUTO` detect texts base direction*/
|
||||
#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO
|
||||
#endif
|
||||
|
||||
/*Enable Arabic/Persian processing
|
||||
*In these languages characters should be replaced with an other form based on their position in the text*/
|
||||
#define LV_USE_ARABIC_PERSIAN_CHARS 0
|
||||
|
||||
/*==================
|
||||
* WIDGETS
|
||||
*================*/
|
||||
|
||||
/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/
|
||||
|
||||
#define LV_WIDGETS_HAS_DEFAULT_VALUE 1
|
||||
|
||||
#define LV_USE_ANIMIMG 1
|
||||
|
||||
#define LV_USE_ARC 1
|
||||
|
||||
#define LV_USE_BAR 1
|
||||
|
||||
#define LV_USE_BUTTON 1
|
||||
|
||||
#define LV_USE_BUTTONMATRIX 1
|
||||
|
||||
#define LV_USE_CALENDAR 1
|
||||
#if LV_USE_CALENDAR
|
||||
#define LV_CALENDAR_WEEK_STARTS_MONDAY 0
|
||||
#if LV_CALENDAR_WEEK_STARTS_MONDAY
|
||||
#define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"}
|
||||
#else
|
||||
#define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}
|
||||
#endif
|
||||
|
||||
#define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
|
||||
#define LV_USE_CALENDAR_HEADER_ARROW 1
|
||||
#define LV_USE_CALENDAR_HEADER_DROPDOWN 1
|
||||
#endif /*LV_USE_CALENDAR*/
|
||||
|
||||
#define LV_USE_CANVAS 1
|
||||
|
||||
#define LV_USE_CHART 1
|
||||
|
||||
#define LV_USE_CHECKBOX 1
|
||||
|
||||
#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_IMAGE 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_IMAGEBUTTON 1
|
||||
|
||||
#define LV_USE_KEYBOARD 1
|
||||
|
||||
#define LV_USE_LABEL 1
|
||||
#if LV_USE_LABEL
|
||||
#define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/
|
||||
#define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/
|
||||
#define LV_LABEL_WAIT_CHAR_COUNT 3 /*The count of wait chart*/
|
||||
#endif
|
||||
|
||||
#define LV_USE_LED 1
|
||||
|
||||
#define LV_USE_LINE 1
|
||||
|
||||
#define LV_USE_LIST 1
|
||||
|
||||
#define LV_USE_MENU 1
|
||||
|
||||
#define LV_USE_MSGBOX 1
|
||||
|
||||
#define LV_USE_ROLLER 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_SCALE 1
|
||||
|
||||
#define LV_USE_SLIDER 1 /*Requires: lv_bar*/
|
||||
|
||||
#define LV_USE_SPAN 1
|
||||
#if LV_USE_SPAN
|
||||
/*A line text can contain maximum num of span descriptor */
|
||||
#define LV_SPAN_SNIPPET_STACK_SIZE 64
|
||||
#endif
|
||||
|
||||
#define LV_USE_SPINBOX 1
|
||||
|
||||
#define LV_USE_SPINNER 1
|
||||
|
||||
#define LV_USE_SWITCH 1
|
||||
|
||||
#define LV_USE_TEXTAREA 1 /*Requires: lv_label*/
|
||||
#if LV_USE_TEXTAREA != 0
|
||||
#define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/
|
||||
#endif
|
||||
|
||||
#define LV_USE_TABLE 1
|
||||
|
||||
#define LV_USE_TABVIEW 1
|
||||
|
||||
#define LV_USE_TILEVIEW 1
|
||||
|
||||
#define LV_USE_WIN 1
|
||||
|
||||
/*==================
|
||||
* THEMES
|
||||
*==================*/
|
||||
|
||||
/*A simple, impressive and very complete theme*/
|
||||
#define LV_USE_THEME_DEFAULT 1
|
||||
#if LV_USE_THEME_DEFAULT
|
||||
|
||||
/*0: Light mode; 1: Dark mode*/
|
||||
#define LV_THEME_DEFAULT_DARK 0
|
||||
|
||||
/*1: Enable grow on press*/
|
||||
#define LV_THEME_DEFAULT_GROW 1
|
||||
|
||||
/*Default transition time in [ms]*/
|
||||
#define LV_THEME_DEFAULT_TRANSITION_TIME 80
|
||||
#endif /*LV_USE_THEME_DEFAULT*/
|
||||
|
||||
/*A very simple theme that is a good starting point for a custom theme*/
|
||||
#define LV_USE_THEME_SIMPLE 1
|
||||
|
||||
/*A theme designed for monochrome displays*/
|
||||
#define LV_USE_THEME_MONO 1
|
||||
|
||||
/*==================
|
||||
* LAYOUTS
|
||||
*==================*/
|
||||
|
||||
/*A layout similar to Flexbox in CSS.*/
|
||||
#define LV_USE_FLEX 1
|
||||
|
||||
/*A layout similar to Grid in CSS.*/
|
||||
#define LV_USE_GRID 1
|
||||
|
||||
/*====================
|
||||
* 3RD PARTS LIBRARIES
|
||||
*====================*/
|
||||
|
||||
/*File system interfaces for common APIs */
|
||||
|
||||
/*API for fopen, fread, etc*/
|
||||
#if LV_USE_FS_STDIO
|
||||
#define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||
#define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*API for open, read, etc*/
|
||||
#if LV_USE_FS_POSIX
|
||||
#define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||
#define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*API for CreateFile, ReadFile, etc*/
|
||||
#if LV_USE_FS_WIN32
|
||||
#define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||
#define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/
|
||||
#if LV_USE_FS_FATFS
|
||||
#define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*API for memory-mapped file access. */
|
||||
#if LV_USE_FS_MEMFS
|
||||
#define LV_FS_MEMFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#endif
|
||||
|
||||
/*API for LittleFs. */
|
||||
#if LV_USE_FS_LITTLEFS
|
||||
#define LV_FS_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#endif
|
||||
|
||||
/*GIF decoder library*/
|
||||
#if LV_USE_GIF
|
||||
/*GIF decoder accelerate*/
|
||||
#define LV_GIF_CACHE_DECODE_DATA 0
|
||||
#endif
|
||||
|
||||
|
||||
/*Decode bin images to RAM*/
|
||||
#define LV_BIN_DECODER_RAM_LOAD 0
|
||||
|
||||
|
||||
/*FreeType library*/
|
||||
#if LV_USE_FREETYPE
|
||||
/*Let FreeType to use LVGL memory and file porting*/
|
||||
#define LV_FREETYPE_USE_LVGL_PORT 0
|
||||
|
||||
/*Cache count of the glyphs in FreeType. It means the number of glyphs that can be cached.
|
||||
*The higher the value, the more memory will be used.*/
|
||||
#define LV_FREETYPE_CACHE_FT_GLYPH_CNT 256
|
||||
#endif
|
||||
|
||||
/* Built-in TTF decoder */
|
||||
#if LV_USE_TINY_TTF
|
||||
/* Enable loading TTF data from files */
|
||||
#define LV_TINY_TTF_FILE_SUPPORT 0
|
||||
#endif
|
||||
|
||||
|
||||
/*Enable Vector Graphic APIs*/
|
||||
#ifndef LV_USE_VECTOR_GRAPHIC
|
||||
# define LV_USE_VECTOR_GRAPHIC 0
|
||||
|
||||
/* Enable ThorVG (vector graphics library) from the src/libs folder */
|
||||
# define LV_USE_THORVG_INTERNAL 0
|
||||
|
||||
/* Enable ThorVG by assuming that its installed and linked to the project */
|
||||
# define LV_USE_THORVG_EXTERNAL 0
|
||||
#endif
|
||||
|
||||
/*Enable LZ4 compress/decompress lib*/
|
||||
#ifndef LV_USE_LZ4
|
||||
/*Use lvgl built-in LZ4 lib*/
|
||||
# define LV_USE_LZ4_INTERNAL 0
|
||||
|
||||
/*Use external LZ4 library*/
|
||||
# define LV_USE_LZ4_EXTERNAL 0
|
||||
#endif
|
||||
|
||||
/*FFmpeg library for image decoding and playing videos
|
||||
*Supports all major image formats so do not enable other image decoder with it*/
|
||||
#if LV_USE_FFMPEG
|
||||
/*Dump input information to stderr*/
|
||||
#define LV_FFMPEG_DUMP_FORMAT 0
|
||||
#endif
|
||||
|
||||
/*==================
|
||||
* OTHERS
|
||||
*==================*/
|
||||
|
||||
/*1: Enable system monitor component*/
|
||||
#define LV_USE_SYSMON 0
|
||||
|
||||
#if LV_USE_SYSMON
|
||||
|
||||
/*1: Show CPU usage and FPS count
|
||||
* Requires `LV_USE_SYSMON = 1`*/
|
||||
#define LV_USE_PERF_MONITOR 0
|
||||
#if LV_USE_PERF_MONITOR
|
||||
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
|
||||
|
||||
/*0: Displays performance data on the screen, 1: Prints performance data using log.*/
|
||||
#define LV_USE_PERF_MONITOR_LOG_MODE 0
|
||||
#endif
|
||||
|
||||
/*1: Show the used memory and the memory fragmentation
|
||||
* Requires `LV_USE_STDLIB_MALLOC = LV_STDLIB_BUILTIN`
|
||||
* Requires `LV_USE_SYSMON = 1`*/
|
||||
#define LV_USE_MEM_MONITOR 0
|
||||
#if LV_USE_MEM_MONITOR
|
||||
#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
|
||||
#endif
|
||||
|
||||
#endif /*LV_USE_SYSMON*/
|
||||
|
||||
/*1: Enable the runtime performance profiler*/
|
||||
#define LV_USE_PROFILER 0
|
||||
#if LV_USE_PROFILER
|
||||
/*1: Enable the built-in profiler*/
|
||||
#define LV_USE_PROFILER_BUILTIN 1
|
||||
#if LV_USE_PROFILER_BUILTIN
|
||||
/*Default profiler trace buffer size*/
|
||||
#define LV_PROFILER_BUILTIN_BUF_SIZE (16 * 1024) /*[bytes]*/
|
||||
#endif
|
||||
|
||||
/*Header to include for the profiler*/
|
||||
#define LV_PROFILER_INCLUDE "src/misc/lv_profiler_builtin.h"
|
||||
|
||||
/*Profiler start point function*/
|
||||
#define LV_PROFILER_BEGIN LV_PROFILER_BUILTIN_BEGIN
|
||||
|
||||
/*Profiler end point function*/
|
||||
#define LV_PROFILER_END LV_PROFILER_BUILTIN_END
|
||||
|
||||
/*Profiler start point function with custom tag*/
|
||||
#define LV_PROFILER_BEGIN_TAG LV_PROFILER_BUILTIN_BEGIN_TAG
|
||||
|
||||
/*Profiler end point function with custom tag*/
|
||||
#define LV_PROFILER_END_TAG LV_PROFILER_BUILTIN_END_TAG
|
||||
#endif
|
||||
|
||||
/*1: Enable an observer pattern implementation*/
|
||||
#define LV_USE_OBSERVER 1
|
||||
|
||||
/*1: Enable Pinyin input method*/
|
||||
/*Requires: lv_keyboard*/
|
||||
#if LV_USE_IME_PINYIN
|
||||
/*1: Use default thesaurus*/
|
||||
/*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/
|
||||
#define LV_IME_PINYIN_USE_DEFAULT_DICT 1
|
||||
/*Set the maximum number of candidate panels that can be displayed*/
|
||||
/*This needs to be adjusted according to the size of the screen*/
|
||||
#define LV_IME_PINYIN_CAND_TEXT_NUM 6
|
||||
|
||||
/*Use 9 key input(k9)*/
|
||||
#define LV_IME_PINYIN_USE_K9_MODE 1
|
||||
#if LV_IME_PINYIN_USE_K9_MODE == 1
|
||||
#define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3
|
||||
#endif /*LV_IME_PINYIN_USE_K9_MODE*/
|
||||
#endif
|
||||
|
||||
/*1: Enable file explorer*/
|
||||
/*Requires: lv_table*/
|
||||
#if LV_USE_FILE_EXPLORER
|
||||
/*Maximum length of path*/
|
||||
#define LV_FILE_EXPLORER_PATH_MAX_LEN (128)
|
||||
/*Quick access bar, 1:use, 0:not use*/
|
||||
/*Requires: lv_list*/
|
||||
#define LV_FILE_EXPLORER_QUICK_ACCESS 1
|
||||
#endif
|
||||
|
||||
/*==================
|
||||
* DEVICES
|
||||
*==================*/
|
||||
|
||||
/*Use SDL to open window on PC and handle mouse and keyboard*/
|
||||
#define LV_USE_SDL 0
|
||||
#if LV_USE_SDL
|
||||
#define LV_SDL_INCLUDE_PATH <SDL2/SDL.h>
|
||||
#define LV_SDL_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT /*LV_DISPLAY_RENDER_MODE_DIRECT is recommended for best performance*/
|
||||
#define LV_SDL_BUF_COUNT 1 /*1 or 2*/
|
||||
#define LV_SDL_FULLSCREEN 0 /*1: Make the window full screen by default*/
|
||||
#define LV_SDL_DIRECT_EXIT 1 /*1: Exit the application when all SDL windows are closed*/
|
||||
#define LV_SDL_MOUSEWHEEL_MODE LV_SDL_MOUSEWHEEL_MODE_ENCODER /*LV_SDL_MOUSEWHEEL_MODE_ENCODER/CROWN*/
|
||||
#endif
|
||||
|
||||
/*Use X11 to open window on Linux desktop and handle mouse and keyboard*/
|
||||
#define LV_USE_X11 0
|
||||
#if LV_USE_X11
|
||||
#define LV_X11_DIRECT_EXIT 1 /*Exit the application when all X11 windows have been closed*/
|
||||
#define LV_X11_DOUBLE_BUFFER 1 /*Use double buffers for endering*/
|
||||
/*select only 1 of the following render modes (LV_X11_RENDER_MODE_PARTIAL preferred!)*/
|
||||
#define LV_X11_RENDER_MODE_PARTIAL 1 /*Partial render mode (preferred)*/
|
||||
#define LV_X11_RENDER_MODE_DIRECT 0 /*direct render mode*/
|
||||
#define LV_X11_RENDER_MODE_FULL 0 /*Full render mode*/
|
||||
#endif
|
||||
|
||||
/*Driver for /dev/fb*/
|
||||
#define LV_USE_LINUX_FBDEV 0
|
||||
#if LV_USE_LINUX_FBDEV
|
||||
#define LV_LINUX_FBDEV_BSD 0
|
||||
#define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL
|
||||
#define LV_LINUX_FBDEV_BUFFER_COUNT 0
|
||||
#define LV_LINUX_FBDEV_BUFFER_SIZE 60
|
||||
#endif
|
||||
|
||||
/*Use Nuttx to open window and handle touchscreen*/
|
||||
#define LV_USE_NUTTX 0
|
||||
|
||||
#if LV_USE_NUTTX
|
||||
#define LV_USE_NUTTX_LIBUV 0
|
||||
|
||||
/*Use Nuttx custom init API to open window and handle touchscreen*/
|
||||
#define LV_USE_NUTTX_CUSTOM_INIT 0
|
||||
|
||||
/*Driver for /dev/lcd*/
|
||||
#define LV_USE_NUTTX_LCD 0
|
||||
#if LV_USE_NUTTX_LCD
|
||||
#define LV_NUTTX_LCD_BUFFER_COUNT 0
|
||||
#define LV_NUTTX_LCD_BUFFER_SIZE 60
|
||||
#endif
|
||||
|
||||
/*Driver for /dev/input*/
|
||||
#define LV_USE_NUTTX_TOUCHSCREEN 0
|
||||
|
||||
#endif
|
||||
|
||||
/*Driver for evdev input devices*/
|
||||
#define LV_USE_EVDEV 0
|
||||
|
||||
/*Driver for libinput input devices*/
|
||||
#define LV_USE_LIBINPUT 0
|
||||
|
||||
#if LV_USE_LIBINPUT
|
||||
#define LV_LIBINPUT_BSD 0
|
||||
|
||||
/*Full keyboard support*/
|
||||
#define LV_LIBINPUT_XKB 0
|
||||
#if LV_LIBINPUT_XKB
|
||||
/*"setxkbmap -query" can help find the right values for your keyboard*/
|
||||
#define LV_LIBINPUT_XKB_KEY_MAP { .rules = NULL, .model = "pc101", .layout = "us", .variant = NULL, .options = NULL }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define LV_USE_GENERIC_MIPI (LV_USE_ST7735 | LV_USE_ST7789 | LV_USE_ST7796 | LV_USE_ILI9341)
|
||||
|
||||
/*==================
|
||||
* EXAMPLES
|
||||
*==================*/
|
||||
|
||||
/*Enable the examples to be built with the library*/
|
||||
#define LV_BUILD_EXAMPLES 1
|
||||
|
||||
/*===================
|
||||
* DEMO USAGE
|
||||
====================*/
|
||||
|
||||
/*Music player demo*/
|
||||
#if LV_USE_DEMO_MUSIC
|
||||
#define LV_DEMO_MUSIC_SQUARE 0
|
||||
#define LV_DEMO_MUSIC_LANDSCAPE 0
|
||||
#define LV_DEMO_MUSIC_ROUND 0
|
||||
#define LV_DEMO_MUSIC_LARGE 0
|
||||
#define LV_DEMO_MUSIC_AUTO_PLAY 0
|
||||
#endif
|
||||
|
||||
/*--END OF LV_CONF_H--*/
|
||||
|
||||
#endif /*LV_CONF_H*/
|
||||
|
||||
#endif /*End of "Content enable"*/
|
||||
120
libraries/lvgl/env_support/cmsis-pack/lv_os_custom_c.txt
Normal file
120
libraries/lvgl/env_support/cmsis-pack/lv_os_custom_c.txt
Normal file
@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @file lv_os_custom.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_os.h"
|
||||
|
||||
#if LV_USE_OS == LV_OS_CUSTOM
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../misc/lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size,
|
||||
void * user_data)
|
||||
{
|
||||
LV_UNUSED(thread);
|
||||
LV_UNUSED(callback);
|
||||
LV_UNUSED(prio);
|
||||
LV_UNUSED(stack_size);
|
||||
LV_UNUSED(user_data);
|
||||
LV_ASSERT(0);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
lv_result_t lv_thread_delete(lv_thread_t * thread)
|
||||
{
|
||||
LV_UNUSED(thread);
|
||||
LV_ASSERT(0);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
lv_result_t lv_mutex_init(lv_mutex_t * mutex)
|
||||
{
|
||||
LV_UNUSED(mutex);
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
lv_result_t lv_mutex_lock(lv_mutex_t * mutex)
|
||||
{
|
||||
LV_UNUSED(mutex);
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
lv_result_t lv_mutex_lock_isr(lv_mutex_t * mutex)
|
||||
{
|
||||
LV_UNUSED(mutex);
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
lv_result_t lv_mutex_unlock(lv_mutex_t * mutex)
|
||||
{
|
||||
LV_UNUSED(mutex);
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
lv_result_t lv_mutex_delete(lv_mutex_t * mutex)
|
||||
{
|
||||
LV_UNUSED(mutex);
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
lv_result_t lv_thread_sync_init(lv_thread_sync_t * sync)
|
||||
{
|
||||
LV_UNUSED(sync);
|
||||
LV_ASSERT(0);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
lv_result_t lv_thread_sync_wait(lv_thread_sync_t * sync)
|
||||
{
|
||||
LV_UNUSED(sync);
|
||||
LV_ASSERT(0);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
lv_result_t lv_thread_sync_signal(lv_thread_sync_t * sync)
|
||||
{
|
||||
LV_UNUSED(sync);
|
||||
LV_ASSERT(0);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
lv_result_t lv_thread_sync_delete(lv_thread_sync_t * sync)
|
||||
{
|
||||
LV_UNUSED(sync);
|
||||
LV_ASSERT(0);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OS == LV_OS_CUSTOM*/
|
||||
43
libraries/lvgl/env_support/cmsis-pack/lv_os_custom_h.txt
Normal file
43
libraries/lvgl/env_support/cmsis-pack/lv_os_custom_h.txt
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @file lv_os_custom.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OS_CUSTOM_H
|
||||
#define LV_OS_CUSTOM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#if LV_USE_OS == LV_OS_CUSTOM
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef int lv_mutex_t;
|
||||
typedef int lv_thread_t;
|
||||
typedef int lv_thread_sync_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OS == LV_OS_CUSTOM*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OS_CUSTOM_H*/
|
||||
@ -0,0 +1,90 @@
|
||||
From 18083a559734d297838e4cf34a856a4770062319 Mon Sep 17 00:00:00 2001
|
||||
From: tvanfossen <vanfosst@gmail.com>
|
||||
Date: Tue, 23 Aug 2022 10:06:53 -0400
|
||||
Subject: [PATCH] changes to compile with esp-idf
|
||||
|
||||
---
|
||||
CMakeLists.txt | 11 ++++++-----
|
||||
src/vector/vimageloader.cpp | 23 +++++++++++++----------
|
||||
2 files changed, 19 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 38a9862..ee6d2cd 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -95,10 +95,11 @@ if (NOT APPLE AND NOT WIN32)
|
||||
)
|
||||
endif()
|
||||
|
||||
-if (LOTTIE_MODULE)
|
||||
- # for dlopen, dlsym and dlclose dependency
|
||||
- target_link_libraries(rlottie PRIVATE ${CMAKE_DL_LIBS})
|
||||
-endif()
|
||||
+# No Sym links in ESP-IDF
|
||||
+# if (LOTTIE_MODULE)
|
||||
+# # for dlopen, dlsym and dlclose dependency
|
||||
+# target_link_libraries(rlottie PRIVATE ${CMAKE_DL_LIBS})
|
||||
+# endif()
|
||||
|
||||
if (NOT LOTTIE_ASAN)
|
||||
if(APPLE)
|
||||
@@ -137,7 +138,7 @@ endif (NOT LIB_INSTALL_DIR)
|
||||
#declare source and include files
|
||||
add_subdirectory(inc)
|
||||
add_subdirectory(src)
|
||||
-add_subdirectory(example)
|
||||
+# add_subdirectory(example) // We dont need example dir in ESP-IDF
|
||||
|
||||
if (LOTTIE_TEST)
|
||||
enable_testing()
|
||||
diff --git a/src/vector/vimageloader.cpp b/src/vector/vimageloader.cpp
|
||||
index c2446be..3df4c6a 100644
|
||||
--- a/src/vector/vimageloader.cpp
|
||||
+++ b/src/vector/vimageloader.cpp
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
#else
|
||||
-# include <dlfcn.h>
|
||||
+// # include <dlfcn.h> //Does not work on ESP-IDF
|
||||
#endif // _WIN32
|
||||
|
||||
using lottie_image_load_f = unsigned char *(*)(const char *filename, int *x,
|
||||
@@ -61,22 +61,25 @@ struct VImageLoader::Impl {
|
||||
void *dl_handle{nullptr};
|
||||
void init()
|
||||
{
|
||||
- imageLoad = reinterpret_cast<lottie_image_load_f>(
|
||||
- dlsym(dl_handle, "lottie_image_load"));
|
||||
- imageFree = reinterpret_cast<lottie_image_free_f>(
|
||||
- dlsym(dl_handle, "lottie_image_free"));
|
||||
- imageFromData = reinterpret_cast<lottie_image_load_data_f>(
|
||||
- dlsym(dl_handle, "lottie_image_load_from_data"));
|
||||
+ // No sym links in ESP-iDF
|
||||
+ // imageLoad = reinterpret_cast<lottie_image_load_f>(
|
||||
+ // dlsym(dl_handle, "lottie_image_load"));
|
||||
+ // imageFree = reinterpret_cast<lottie_image_free_f>(
|
||||
+ // dlsym(dl_handle, "lottie_image_free"));
|
||||
+ // imageFromData = reinterpret_cast<lottie_image_load_data_f>(
|
||||
+ // dlsym(dl_handle, "lottie_image_load_from_data"));
|
||||
}
|
||||
|
||||
void moduleFree()
|
||||
{
|
||||
- if (dl_handle) dlclose(dl_handle);
|
||||
+ // if (dl_handle) dlclose(dl_handle); // No sym links in ESP-iDF
|
||||
}
|
||||
bool moduleLoad()
|
||||
{
|
||||
- dl_handle = dlopen(LOTTIE_IMAGE_MODULE_PLUGIN, RTLD_LAZY);
|
||||
- return (dl_handle == nullptr);
|
||||
+ // No sym links in ESP idf
|
||||
+ // dl_handle = dlopen(LOTTIE_IMAGE_MODULE_PLUGIN, RTLD_LAZY);
|
||||
+ // return (dl_handle == nullptr);
|
||||
+ return true
|
||||
}
|
||||
# endif // _WIN32
|
||||
#else // LOTTIE_IMAGE_MODULE_SUPPORT
|
||||
--
|
||||
2.34.1
|
||||
|
||||
24
libraries/lvgl/env_support/esp/rlottie/CMakeLists.txt
Normal file
24
libraries/lvgl/env_support/esp/rlottie/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
if (0)
|
||||
if (LV_USE_RLOTTIE)
|
||||
|
||||
idf_component_register(SRCS ${SOURCES}
|
||||
INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/rlottie/inc"
|
||||
)
|
||||
|
||||
set(LOTTIE_MODULE OFF)
|
||||
set(LOTTIE_THREAD OFF)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
option(BUILD_TESTING OFF)
|
||||
|
||||
function(install)
|
||||
endfunction()
|
||||
|
||||
function(export)
|
||||
endfunction()
|
||||
|
||||
add_subdirectory(rlottie)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE rlottie)
|
||||
endif()
|
||||
endif()
|
||||
11
libraries/lvgl/env_support/pikascript/README.md
Normal file
11
libraries/lvgl/env_support/pikascript/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# PikaScript Binding for LVGL
|
||||
|
||||
[PikaScript](https://github.com/pikasTech/pikascript) is an ultralightweight python engine that can run with 4KB of RAM and 32KB of Flash (such as STM32G030C8 and STM32F103C8), and is very easy to deploy and expand.
|
||||
|
||||
More details to see: [PikaScript and lvgl: Make Python Lighter, Easier and Smarter](https://blog.lvgl.io/2022-08-24/pikascript-and-lvgl)
|
||||
|
||||
The available Python APIs are in the `pika_lvgl.pyi`, and you need copy the `pika_lvgl.pyi` to the root path of pikascript, then `import pika_lvgl` in `main.py`.
|
||||
|
||||
The available simulation project on windows: https://github.com/pikasTech/lv_pikascript
|
||||
|
||||
More document about PikaScript: https://pikadoc.readthedocs.io/en/latest/index.html
|
||||
16
libraries/lvgl/env_support/pikascript/pika_lv_point_t.c
Normal file
16
libraries/lvgl/env_support/pikascript/pika_lv_point_t.c
Normal file
@ -0,0 +1,16 @@
|
||||
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
#include "../../lvgl.h"
|
||||
#endif
|
||||
|
||||
#ifdef PIKASCRIPT
|
||||
|
||||
#include "pika_lvgl_point_t.h"
|
||||
|
||||
void pika_lvgl_point_t___init__(PikaObj* self) {
|
||||
lv_point_t lv_point = {0};
|
||||
args_setStruct(self->list, "lv_point_struct", lv_point);
|
||||
obj_setPtr(self, "lv_point", args_getStruct(self->list, "lv_point_struct"));
|
||||
}
|
||||
#endif
|
||||
44
libraries/lvgl/env_support/pikascript/pika_lv_timer_t.c
Normal file
44
libraries/lvgl/env_support/pikascript/pika_lv_timer_t.c
Normal file
@ -0,0 +1,44 @@
|
||||
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
#include "../../lvgl.h"
|
||||
#endif
|
||||
|
||||
#ifdef PIKASCRIPT
|
||||
|
||||
#include "pika_lvgl_lv_timer_t.h"
|
||||
|
||||
PikaEventListener* g_pika_lv_timer_event_listener;
|
||||
|
||||
void __pika_timer_cb(lv_timer_t* timer) {
|
||||
PikaObj* eventHandleObj = pks_eventLisener_getEventHandleObj(
|
||||
g_pika_lv_timer_event_listener, (uint32_t)timer);
|
||||
obj_newDirectObj(eventHandleObj, "timer", New_pika_lvgl_lv_timer_t);
|
||||
obj_setPtr(obj_getPtr(eventHandleObj, "timer"), "lv_timer", timer);
|
||||
obj_run(eventHandleObj, "eventCallBack(timer)");
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_timer_t_set_period(PikaObj* self, int period) {
|
||||
lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer");
|
||||
lv_timer_set_period(lv_timer, period);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_timer_t_set_cb(PikaObj* self, Arg* cb) {
|
||||
lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer");
|
||||
lv_timer_set_cb(lv_timer, __pika_timer_cb);
|
||||
|
||||
obj_setArg(self, "eventCallBack", cb);
|
||||
/* init event_listener for the first time */
|
||||
if (NULL == g_pika_lv_timer_event_listener) {
|
||||
pks_eventLisener_init(&g_pika_lv_timer_event_listener);
|
||||
}
|
||||
pks_eventLicener_registerEvent(g_pika_lv_timer_event_listener,
|
||||
(uint32_t)lv_timer, self);
|
||||
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_timer_t__delete(PikaObj* self) {
|
||||
lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer");
|
||||
lv_timer_delete(lv_timer);
|
||||
}
|
||||
#endif
|
||||
364
libraries/lvgl/env_support/pikascript/pika_lv_wegit.c
Normal file
364
libraries/lvgl/env_support/pikascript/pika_lv_wegit.c
Normal file
@ -0,0 +1,364 @@
|
||||
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
#include "../../lvgl.h"
|
||||
#endif
|
||||
|
||||
#ifdef PIKASCRIPT
|
||||
#include "BaseObj.h"
|
||||
#include "pika_lvgl.h"
|
||||
#include "pika_lvgl_arc.h"
|
||||
#include "pika_lvgl_bar.h"
|
||||
#include "pika_lvgl_btn.h"
|
||||
#include "pika_lvgl_checkbox.h"
|
||||
#include "pika_lvgl_dropdown.h"
|
||||
#include "pika_lvgl_label.h"
|
||||
#include "pika_lvgl_lv_obj.h"
|
||||
#include "pika_lvgl_roller.h"
|
||||
#include "pika_lvgl_slider.h"
|
||||
#include "pika_lvgl_switch.h"
|
||||
#include "pika_lvgl_table.h"
|
||||
#include "pika_lvgl_textarea.h"
|
||||
|
||||
void pika_lvgl_arc___init__(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_arc_create(lv_parent);
|
||||
obj_setPtr(self, "lv_obj", lv_obj);
|
||||
obj_setInt(self, "MODE_NORMAL", LV_ARC_MODE_NORMAL);
|
||||
obj_setInt(self, "MODE_SYMMETRICAL", LV_ARC_MODE_SYMMETRICAL);
|
||||
obj_setInt(self, "MODE_REVERSE", LV_ARC_MODE_REVERSE);
|
||||
}
|
||||
|
||||
void pika_lvgl_arc_set_end_angle(PikaObj* self, int angle) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_arc_set_end_angle(lv_obj, angle);
|
||||
}
|
||||
|
||||
void pika_lvgl_arc_set_bg_angles(PikaObj* self, int start, int end) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_arc_set_bg_angles(lv_obj, start, end);
|
||||
}
|
||||
|
||||
void pika_lvgl_arc_set_angles(PikaObj* self, int start, int end) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_arc_set_angles(lv_obj, start, end);
|
||||
}
|
||||
|
||||
int pika_lvgl_arc_get_angle_end(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_arc_get_angle_end(lv_obj);
|
||||
}
|
||||
int pika_lvgl_arc_get_angle_start(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_arc_get_angle_start(lv_obj);
|
||||
}
|
||||
int pika_lvgl_arc_get_bg_angle_end(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_arc_get_bg_angle_end(lv_obj);
|
||||
}
|
||||
int pika_lvgl_arc_get_bg_angle_start(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_arc_get_bg_angle_start(lv_obj);
|
||||
}
|
||||
int pika_lvgl_arc_get_max_value(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_arc_get_max_value(lv_obj);
|
||||
}
|
||||
int pika_lvgl_arc_get_min_value(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_arc_get_min_value(lv_obj);
|
||||
}
|
||||
int pika_lvgl_arc_get_mode(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_arc_get_mode(lv_obj);
|
||||
}
|
||||
// int pika_lvgl_arc_get_rotation(PikaObj *self){
|
||||
// lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
// return lv_arc_get_rotation(lv_obj);
|
||||
// }
|
||||
int pika_lvgl_arc_get_value(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_arc_get_value(lv_obj);
|
||||
}
|
||||
void pika_lvgl_arc_set_mode(PikaObj *self, int mode){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_arc_set_mode(lv_obj, mode);
|
||||
}
|
||||
void pika_lvgl_arc_set_range(PikaObj *self, int min, int max){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_arc_set_range(lv_obj, min, max);
|
||||
}
|
||||
void pika_lvgl_arc_set_rotation(PikaObj *self, int rotation){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_arc_set_rotation(lv_obj, rotation);
|
||||
}
|
||||
void pika_lvgl_arc_set_start_angle(PikaObj *self, int start){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_arc_set_start_angle(lv_obj, start);
|
||||
}
|
||||
void pika_lvgl_arc_set_value(PikaObj *self, int value){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_arc_set_value(lv_obj, value);
|
||||
}
|
||||
void pika_lvgl_arc_set_bg_end_angle(PikaObj *self, int angle){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_arc_set_bg_end_angle(lv_obj, angle);
|
||||
}
|
||||
void pika_lvgl_arc_set_bg_start_angle(PikaObj *self, int start){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_arc_set_bg_start_angle(lv_obj, start);
|
||||
}
|
||||
|
||||
void pika_lvgl_arc_set_change_rate(PikaObj *self, int rate){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_arc_set_change_rate(lv_obj, rate);
|
||||
}
|
||||
|
||||
void pika_lvgl_bar___init__(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_bar_create(lv_parent);
|
||||
obj_setPtr(self, "lv_obj", lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_bar_set_value(PikaObj* self, int value, int anim) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_bar_set_value(lv_obj, value, value);
|
||||
}
|
||||
|
||||
int pika_lvgl_bar_get_max_value(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_bar_get_max_value(lv_obj);
|
||||
}
|
||||
int pika_lvgl_bar_get_min_value(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_bar_get_min_value(lv_obj);
|
||||
}
|
||||
int pika_lvgl_bar_get_mode(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_bar_get_mode(lv_obj);
|
||||
}
|
||||
int pika_lvgl_bar_get_start_value(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_bar_get_start_value(lv_obj);
|
||||
}
|
||||
int pika_lvgl_bar_get_value(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_bar_get_value(lv_obj);
|
||||
}
|
||||
void pika_lvgl_bar_set_mode(PikaObj *self, int mode){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_bar_set_mode(lv_obj, mode);
|
||||
}
|
||||
void pika_lvgl_bar_set_range(PikaObj *self, int min, int max){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_bar_set_range(lv_obj, min, max);
|
||||
}
|
||||
void pika_lvgl_bar_set_start_value(PikaObj *self, int start_value, int anim){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_bar_set_start_value(lv_obj, start_value, anim);
|
||||
}
|
||||
|
||||
void pika_lvgl_btn___init__(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_button_create(lv_parent);
|
||||
obj_setPtr(self, "lv_obj", lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_checkbox___init__(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_checkbox_create(lv_parent);
|
||||
obj_setPtr(self, "lv_obj", lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_checkbox_set_text(PikaObj* self, char* txt) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_checkbox_set_text(lv_obj, txt);
|
||||
}
|
||||
|
||||
void pika_lvgl_checkbox_set_text_static(PikaObj *self, char* txt){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_checkbox_set_text_static(lv_obj, txt);
|
||||
}
|
||||
|
||||
char* pika_lvgl_checkbox_get_text(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return (char*) lv_checkbox_get_text(lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_dropdown___init__(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_dropdown_create(lv_parent);
|
||||
obj_setPtr(self, "lv_obj", lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_dropdown_set_options(PikaObj* self, char* options) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_dropdown_set_options(lv_obj, options);
|
||||
}
|
||||
|
||||
void pika_lvgl_dropdown_add_option(PikaObj *self, char* options, int pos){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_dropdown_add_option(lv_obj, options, pos);
|
||||
}
|
||||
void pika_lvgl_dropdown_clear_options(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_dropdown_clear_options(lv_obj);
|
||||
}
|
||||
void pika_lvgl_dropdown_close(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_dropdown_close(lv_obj);
|
||||
}
|
||||
int pika_lvgl_dropdown_get_dir(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_dropdown_get_dir(lv_obj);
|
||||
}
|
||||
// PikaObj* pika_lvgl_dropdown_get_list(PikaObj *self){
|
||||
// lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
// return obj_getObj(lv_dropdown_get_list(lv_obj));
|
||||
// }
|
||||
int pika_lvgl_dropdown_get_option_count(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_dropdown_get_option_count(lv_obj);
|
||||
}
|
||||
int pika_lvgl_dropdown_get_option_index(PikaObj *self, char* txt){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_dropdown_get_option_index(lv_obj, txt);
|
||||
}
|
||||
char* pika_lvgl_dropdown_get_options(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return (char*) lv_dropdown_get_options(lv_obj);
|
||||
}
|
||||
int pika_lvgl_dropdown_get_selected(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_dropdown_get_selected(lv_obj);
|
||||
}
|
||||
int pika_lvgl_dropdown_get_selected_highlight(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_dropdown_get_selected_highlight(lv_obj);
|
||||
}
|
||||
|
||||
char* pika_lvgl_dropdown_get_selected_str(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
obj_setBytes(self, "_buff",NULL, 128);
|
||||
char* _buff = (char*)obj_getBytes(self, "_buff");
|
||||
lv_dropdown_get_selected_str(lv_obj, _buff, 128);
|
||||
return _buff;
|
||||
}
|
||||
char* pika_lvgl_dropdown_get_symbol(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return (char*)lv_dropdown_get_symbol(lv_obj);
|
||||
}
|
||||
char* pika_lvgl_dropdown_get_text(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return (char*)lv_dropdown_get_text(lv_obj);
|
||||
}
|
||||
int pika_lvgl_dropdown_is_open(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_dropdown_is_open(lv_obj);
|
||||
}
|
||||
void pika_lvgl_dropdown_open(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_dropdown_open(lv_obj);
|
||||
}
|
||||
void pika_lvgl_dropdown_set_dir(PikaObj *self, int dir){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_dropdown_set_dir(lv_obj, dir);
|
||||
}
|
||||
void pika_lvgl_dropdown_set_selected(PikaObj *self, int sel_opt){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_dropdown_set_selected(lv_obj, sel_opt);
|
||||
}
|
||||
void pika_lvgl_dropdown_set_selected_highlight(PikaObj *self, int en){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_dropdown_set_selected_highlight(lv_obj, en);
|
||||
}
|
||||
void pika_lvgl_dropdown_set_symbol(PikaObj *self, char* symbol){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_dropdown_set_symbol(lv_obj, symbol);
|
||||
}
|
||||
void pika_lvgl_dropdown_set_text(PikaObj *self, char* txt){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_dropdown_set_text(lv_obj, txt);
|
||||
}
|
||||
|
||||
void pika_lvgl_label___init__(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_label_create(lv_parent);
|
||||
obj_setPtr(self, "lv_obj", lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_label_set_long_mode(PikaObj* self, int mode) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_label_set_long_mode(lv_obj, mode);
|
||||
}
|
||||
|
||||
void pika_lvgl_label_set_recolor(PikaObj* self, int en) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_label_set_recolor(lv_obj, en);
|
||||
}
|
||||
|
||||
void pika_lvgl_label_set_text(PikaObj* self, char* txt) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_label_set_text(lv_obj, txt);
|
||||
}
|
||||
|
||||
void pika_lvgl_label_set_style_text_align(PikaObj* self,
|
||||
int value,
|
||||
int selector) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_obj_set_style_text_align(lv_obj, value, selector);
|
||||
}
|
||||
|
||||
void pika_lvgl_roller___init__(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_roller_create(lv_parent);
|
||||
obj_setPtr(self, "lv_obj", lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_roller_set_options(PikaObj* self, char* options, int mode) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_roller_set_options(lv_obj, options, mode);
|
||||
}
|
||||
|
||||
void pika_lvgl_roller_set_visible_row_count(PikaObj* self, int row_cnt) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_roller_set_visible_row_count(lv_obj, row_cnt);
|
||||
}
|
||||
|
||||
void pika_lvgl_slider___init__(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_slider_create(lv_parent);
|
||||
obj_setPtr(self, "lv_obj", lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_switch___init__(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_switch_create(lv_parent);
|
||||
obj_setPtr(self, "lv_obj", lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_table___init__(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_table_create(lv_parent);
|
||||
obj_setPtr(self, "lv_obj", lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_table_set_cell_value(PikaObj* self,
|
||||
int row,
|
||||
int col,
|
||||
char* txt) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_table_set_cell_value(lv_obj, row, col, txt);
|
||||
}
|
||||
|
||||
void pika_lvgl_textarea___init__(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_textarea_create(lv_parent);
|
||||
obj_setPtr(self, "lv_obj", lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_textarea_set_one_line(PikaObj* self, int en) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_textarea_set_one_line(lv_obj, en);
|
||||
}
|
||||
#endif
|
||||
199
libraries/lvgl/env_support/pikascript/pika_lvgl.c
Normal file
199
libraries/lvgl/env_support/pikascript/pika_lvgl.c
Normal file
@ -0,0 +1,199 @@
|
||||
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
#include "../../lvgl.h"
|
||||
#endif
|
||||
|
||||
#ifdef PIKASCRIPT
|
||||
#include "pika_lvgl.h"
|
||||
#include "BaseObj.h"
|
||||
#include "pika_lvgl_ALIGN.h"
|
||||
#include "pika_lvgl_ANIM.h"
|
||||
#include "pika_lvgl_EVENT.h"
|
||||
#include "pika_lvgl_OPA.h"
|
||||
#include "pika_lvgl_PALETTE.h"
|
||||
#include "pika_lvgl_STATE.h"
|
||||
#include "pika_lvgl_arc.h"
|
||||
#include "pika_lvgl_lv_color_t.h"
|
||||
#include "pika_lvgl_lv_obj.h"
|
||||
#include "pika_lvgl_indev_t.h"
|
||||
#include "pika_lvgl_lv_timer_t.h"
|
||||
|
||||
PikaObj* pika_lv_event_listener_g;
|
||||
|
||||
void pika_lvgl_STATE___init__(PikaObj* self) {
|
||||
obj_setInt(self, "DEFAULT", LV_STATE_DEFAULT);
|
||||
obj_setInt(self, "CHECKED", LV_STATE_CHECKED);
|
||||
obj_setInt(self, "FOCUSED", LV_STATE_FOCUSED);
|
||||
obj_setInt(self, "FOCUS_KEY", LV_STATE_FOCUS_KEY);
|
||||
obj_setInt(self, "EDITED", LV_STATE_EDITED);
|
||||
obj_setInt(self, "HOVERED", LV_STATE_HOVERED);
|
||||
obj_setInt(self, "PRESSED", LV_STATE_PRESSED);
|
||||
obj_setInt(self, "SCROLLED", LV_STATE_SCROLLED);
|
||||
obj_setInt(self, "DISABLED", LV_STATE_DISABLED);
|
||||
obj_setInt(self, "USER_1", LV_STATE_USER_1);
|
||||
obj_setInt(self, "USER_2", LV_STATE_USER_2);
|
||||
obj_setInt(self, "USER_3", LV_STATE_USER_3);
|
||||
obj_setInt(self, "USER_4", LV_STATE_USER_4);
|
||||
obj_setInt(self, "ANY", LV_STATE_ANY);
|
||||
}
|
||||
|
||||
void pika_lvgl_ANIM___init__(PikaObj* self) {
|
||||
obj_setInt(self, "ON", LV_ANIM_OFF);
|
||||
obj_setInt(self, "OFF", LV_ANIM_ON);
|
||||
}
|
||||
|
||||
void pika_lvgl_ALIGN___init__(PikaObj* self) {
|
||||
obj_setInt(self, "CENTER", LV_ALIGN_CENTER);
|
||||
obj_setInt(self, "DEFAULT", LV_ALIGN_DEFAULT);
|
||||
obj_setInt(self, "TOP_LEFT", LV_ALIGN_TOP_LEFT);
|
||||
obj_setInt(self, "TOP_MID", LV_ALIGN_TOP_MID);
|
||||
obj_setInt(self, "TOP_RIGHT", LV_ALIGN_TOP_RIGHT);
|
||||
obj_setInt(self, "BOTTOM_LEFT", LV_ALIGN_BOTTOM_LEFT);
|
||||
obj_setInt(self, "BOTTOM_MID", LV_ALIGN_BOTTOM_MID);
|
||||
obj_setInt(self, "BOTTOM_RIGHT", LV_ALIGN_BOTTOM_RIGHT);
|
||||
obj_setInt(self, "LEFT_MID", LV_ALIGN_LEFT_MID);
|
||||
obj_setInt(self, "RIGHT_MID", LV_ALIGN_RIGHT_MID);
|
||||
obj_setInt(self, "OUT_TOP_LEFT", LV_ALIGN_OUT_TOP_LEFT);
|
||||
obj_setInt(self, "OUT_TOP_MID", LV_ALIGN_OUT_TOP_MID);
|
||||
obj_setInt(self, "OUT_TOP_RIGHT", LV_ALIGN_OUT_TOP_RIGHT);
|
||||
obj_setInt(self, "OUT_BOTTOM_LEFT", LV_ALIGN_OUT_BOTTOM_LEFT);
|
||||
obj_setInt(self, "OUT_BOTTOM_MID", LV_ALIGN_OUT_BOTTOM_MID);
|
||||
obj_setInt(self, "OUT_BOTTOM_RIGHT", LV_ALIGN_OUT_BOTTOM_RIGHT);
|
||||
obj_setInt(self, "OUT_LEFT_TOP", LV_ALIGN_OUT_LEFT_TOP);
|
||||
obj_setInt(self, "OUT_LEFT_MID", LV_ALIGN_OUT_LEFT_MID);
|
||||
obj_setInt(self, "OUT_LEFT_BOTTOM", LV_ALIGN_OUT_LEFT_BOTTOM);
|
||||
obj_setInt(self, "OUT_RIGHT_TOP", LV_ALIGN_OUT_RIGHT_TOP);
|
||||
obj_setInt(self, "OUT_RIGHT_MID", LV_ALIGN_OUT_RIGHT_MID);
|
||||
obj_setInt(self, "OUT_RIGHT_BOTTOM", LV_ALIGN_OUT_RIGHT_BOTTOM);
|
||||
}
|
||||
|
||||
void pika_lvgl_EVENT___init__(PikaObj* self) {
|
||||
obj_setInt(self, "ALL", LV_EVENT_ALL);
|
||||
obj_setInt(self, "PRESSED", LV_EVENT_PRESSED);
|
||||
obj_setInt(self, "PRESSING", LV_EVENT_PRESSING);
|
||||
obj_setInt(self, "PRESS_LOST", LV_EVENT_PRESS_LOST);
|
||||
obj_setInt(self, "SHORT_CLICKED", LV_EVENT_SHORT_CLICKED);
|
||||
obj_setInt(self, "LONG_PRESSED", LV_EVENT_LONG_PRESSED);
|
||||
obj_setInt(self, "LONG_PRESSED_REPEAT", LV_EVENT_LONG_PRESSED_REPEAT);
|
||||
obj_setInt(self, "CLICKED", LV_EVENT_CLICKED);
|
||||
obj_setInt(self, "RELEASED", LV_EVENT_RELEASED);
|
||||
obj_setInt(self, "SCROLL_BEGIN", LV_EVENT_SCROLL_BEGIN);
|
||||
obj_setInt(self, "SCROLL_END", LV_EVENT_SCROLL_END);
|
||||
obj_setInt(self, "SCROLL", LV_EVENT_SCROLL);
|
||||
obj_setInt(self, "GESTURE", LV_EVENT_GESTURE);
|
||||
obj_setInt(self, "KEY", LV_EVENT_KEY);
|
||||
obj_setInt(self, "FOCUSED", LV_EVENT_FOCUSED);
|
||||
obj_setInt(self, "DEFOCUSED", LV_EVENT_DEFOCUSED);
|
||||
obj_setInt(self, "LEAVE", LV_EVENT_LEAVE);
|
||||
obj_setInt(self, "HIT_TEST", LV_EVENT_HIT_TEST);
|
||||
obj_setInt(self, "COVER_CHECK", LV_EVENT_COVER_CHECK);
|
||||
obj_setInt(self, "REFR_EXT_DRAW_SIZE", LV_EVENT_REFR_EXT_DRAW_SIZE);
|
||||
obj_setInt(self, "DRAW_MAIN_BEGIN", LV_EVENT_DRAW_MAIN_BEGIN);
|
||||
obj_setInt(self, "DRAW_MAIN", LV_EVENT_DRAW_MAIN);
|
||||
obj_setInt(self, "DRAW_MAIN_END", LV_EVENT_DRAW_MAIN_END);
|
||||
obj_setInt(self, "DRAW_POST_BEGIN", LV_EVENT_DRAW_POST_BEGIN);
|
||||
obj_setInt(self, "DRAW_POST", LV_EVENT_DRAW_POST);
|
||||
obj_setInt(self, "DRAW_POST_END", LV_EVENT_DRAW_POST_END);
|
||||
obj_setInt(self, "DRAW_PART_BEGIN", LV_EVENT_DRAW_PART_BEGIN);
|
||||
obj_setInt(self, "DRAW_PART_END", LV_EVENT_DRAW_PART_END);
|
||||
obj_setInt(self, "VALUE_CHANGED", LV_EVENT_VALUE_CHANGED);
|
||||
obj_setInt(self, "INSERT", LV_EVENT_INSERT);
|
||||
obj_setInt(self, "REFRESH", LV_EVENT_REFRESH);
|
||||
obj_setInt(self, "READY", LV_EVENT_READY);
|
||||
obj_setInt(self, "CANCEL", LV_EVENT_CANCEL);
|
||||
obj_setInt(self, "DELETE", LV_EVENT_DELETE);
|
||||
obj_setInt(self, "CHILD_CHANGED", LV_EVENT_CHILD_CHANGED);
|
||||
obj_setInt(self, "CHILD_CREATED", LV_EVENT_CHILD_CREATED);
|
||||
obj_setInt(self, "CHILD_DELETED", LV_EVENT_CHILD_DELETED);
|
||||
obj_setInt(self, "SCREEN_UNLOAD_START", LV_EVENT_SCREEN_UNLOAD_START);
|
||||
obj_setInt(self, "SCREEN_LOAD_START", LV_EVENT_SCREEN_LOAD_START);
|
||||
obj_setInt(self, "SCREEN_LOADED", LV_EVENT_SCREEN_LOADED);
|
||||
obj_setInt(self, "SCREEN_UNLOADED", LV_EVENT_SCREEN_UNLOADED);
|
||||
obj_setInt(self, "SIZE_CHANGED", LV_EVENT_SIZE_CHANGED);
|
||||
obj_setInt(self, "STYLE_CHANGED", LV_EVENT_STYLE_CHANGED);
|
||||
obj_setInt(self, "LAYOUT_CHANGED", LV_EVENT_LAYOUT_CHANGED);
|
||||
obj_setInt(self, "GET_SELF_SIZE", LV_EVENT_GET_SELF_SIZE);
|
||||
obj_setInt(self, "PREPROCESS", LV_EVENT_PREPROCESS);
|
||||
}
|
||||
|
||||
void pika_lvgl_OPA___init__(PikaObj* self) {
|
||||
obj_setInt(self, "TRANSP", LV_OPA_TRANSP);
|
||||
obj_setInt(self, "COVER", LV_OPA_COVER);
|
||||
}
|
||||
|
||||
void pika_lvgl_PALETTE___init__(PikaObj* self) {
|
||||
obj_setInt(self, "RED", LV_PALETTE_RED);
|
||||
obj_setInt(self, "PINK", LV_PALETTE_PINK);
|
||||
obj_setInt(self, "PURPLE", LV_PALETTE_PURPLE);
|
||||
obj_setInt(self, "DEEP_PURPLE", LV_PALETTE_DEEP_PURPLE);
|
||||
obj_setInt(self, "INDIGO", LV_PALETTE_INDIGO);
|
||||
obj_setInt(self, "BLUE", LV_PALETTE_BLUE);
|
||||
obj_setInt(self, "LIGHT_BLUE", LV_PALETTE_LIGHT_BLUE);
|
||||
obj_setInt(self, "CYAN", LV_PALETTE_CYAN);
|
||||
obj_setInt(self, "TEAL", LV_PALETTE_TEAL);
|
||||
obj_setInt(self, "GREEN", LV_PALETTE_GREEN);
|
||||
obj_setInt(self, "LIGHT_GREEN", LV_PALETTE_LIGHT_GREEN);
|
||||
obj_setInt(self, "LIME", LV_PALETTE_LIME);
|
||||
obj_setInt(self, "YELLOW", LV_PALETTE_YELLOW);
|
||||
obj_setInt(self, "AMBER", LV_PALETTE_AMBER);
|
||||
obj_setInt(self, "ORANGE", LV_PALETTE_ORANGE);
|
||||
obj_setInt(self, "DEEP_ORANGE", LV_PALETTE_DEEP_ORANGE);
|
||||
obj_setInt(self, "BROWN", LV_PALETTE_BROWN);
|
||||
obj_setInt(self, "BLUE_GREY", LV_PALETTE_BLUE_GREY);
|
||||
obj_setInt(self, "GREY", LV_PALETTE_GREY);
|
||||
obj_setInt(self, "NONE", LV_PALETTE_NONE);
|
||||
}
|
||||
|
||||
PikaObj* pika_lvgl_screen_active(PikaObj* self) {
|
||||
PikaObj* new_obj = newNormalObj(New_TinyObj);
|
||||
lv_obj_t* lv_obj = lv_screen_active();
|
||||
obj_setPtr(new_obj, "lv_obj", lv_obj);
|
||||
return new_obj;
|
||||
}
|
||||
|
||||
void pika_lvgl___init__(PikaObj* self) {
|
||||
obj_newDirectObj(self, "lv_event_listener", New_TinyObj);
|
||||
pika_lv_event_listener_g = obj_getObj(self, "lv_event_listener");
|
||||
}
|
||||
|
||||
PikaObj* pika_lvgl_obj(PikaObj* self, PikaObj* parent) {
|
||||
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
|
||||
lv_obj_t* lv_obj = lv_obj_create(lv_parent);
|
||||
PikaObj* new_obj = newNormalObj(New_pika_lvgl_lv_obj);
|
||||
obj_setPtr(new_obj, "lv_obj", lv_obj);
|
||||
return new_obj;
|
||||
}
|
||||
|
||||
PikaObj* pika_lvgl_palette_lighten(PikaObj *self, int p, int lvl){
|
||||
PikaObj* new_obj = newNormalObj(New_pika_lvgl_lv_color_t);
|
||||
lv_color_t lv_color = lv_palette_lighten(p, lvl);
|
||||
args_setStruct(new_obj->list, "lv_color_struct", lv_color);
|
||||
lv_color_t* plv_color = args_getStruct(new_obj->list, "lv_color_struct");
|
||||
obj_setPtr(new_obj, "lv_color", plv_color);
|
||||
return new_obj;
|
||||
}
|
||||
|
||||
PikaObj* pika_lvgl_palette_main(PikaObj* self, int p) {
|
||||
PikaObj* new_obj = newNormalObj(New_pika_lvgl_lv_color_t);
|
||||
lv_color_t lv_color = lv_palette_main(p);
|
||||
args_setStruct(new_obj->list, "lv_color_struct", lv_color);
|
||||
obj_setPtr(new_obj, "lv_color",
|
||||
args_getStruct(new_obj->list, "lv_color_struct"));
|
||||
return new_obj;
|
||||
}
|
||||
|
||||
PikaObj* pika_lvgl_indev_get_active(PikaObj *self){
|
||||
PikaObj* new_obj = newNormalObj(New_pika_lvgl_indev_t);
|
||||
lv_indev_t *lv_indev = lv_indev_active();
|
||||
obj_setPtr(new_obj,"lv_indev", lv_indev);
|
||||
return new_obj;
|
||||
}
|
||||
|
||||
PikaObj* pika_lvgl_timer_create_basic(PikaObj *self){
|
||||
PikaObj* new_obj = newNormalObj(New_pika_lvgl_lv_timer_t);
|
||||
lv_timer_t *lv_timer = lv_timer_create_basic();
|
||||
obj_setPtr(new_obj,"lv_timer", lv_timer);
|
||||
return new_obj;
|
||||
}
|
||||
#endif
|
||||
263
libraries/lvgl/env_support/pikascript/pika_lvgl.pyi
Normal file
263
libraries/lvgl/env_support/pikascript/pika_lvgl.pyi
Normal file
@ -0,0 +1,263 @@
|
||||
from PikaObj import *
|
||||
|
||||
def __init__(): ...
|
||||
|
||||
class EVENT:
|
||||
ALL: int
|
||||
PRESSED: int
|
||||
PRESSING: int
|
||||
PRESS_LOST: int
|
||||
SHORT_CLICKED: int
|
||||
LONG_PRESSED: int
|
||||
LONG_PRESSED_REPEAT: int
|
||||
CLICKED: int
|
||||
RELEASED: int
|
||||
SCROLL_BEGIN: int
|
||||
SCROLL_END: int
|
||||
SCROLL: int
|
||||
GESTURE: int
|
||||
KEY: int
|
||||
FOCUSED: int
|
||||
DEFOCUSED: int
|
||||
LEAVE: int
|
||||
HIT_TEST: int
|
||||
COVER_CHECK: int
|
||||
REFR_EXT_DRAW_SIZE: int
|
||||
DRAW_MAIN_BEGIN: int
|
||||
DRAW_MAIN: int
|
||||
DRAW_MAIN_END: int
|
||||
DRAW_POST_BEGIN: int
|
||||
DRAW_POST: int
|
||||
DRAW_POST_END: int
|
||||
DRAW_PART_BEGIN: int
|
||||
DRAW_PART_END: int
|
||||
VALUE_CHANGED: int
|
||||
INSERT: int
|
||||
REFRESH: int
|
||||
READY: int
|
||||
CANCEL: int
|
||||
DELETE: int
|
||||
CHILD_CHANGED: int
|
||||
CHILD_CREATED: int
|
||||
CHILD_DELETED: int
|
||||
SCREEN_UNLOAD_START: int
|
||||
SCREEN_LOAD_START: int
|
||||
SCREEN_LOADED: int
|
||||
SCREEN_UNLOADED: int
|
||||
SIZE_CHANGED: int
|
||||
STYLE_CHANGED: int
|
||||
LAYOUT_CHANGED: int
|
||||
GET_SELF_SIZE: int
|
||||
PREPROCESS: int
|
||||
def __init__(self): ...
|
||||
|
||||
class ALIGN:
|
||||
DEFAULT: int
|
||||
TOP_LEFT: int
|
||||
TOP_MID: int
|
||||
TOP_RIGHT: int
|
||||
BOTTOM_LEFT: int
|
||||
BOTTOM_MID: int
|
||||
BOTTOM_RIGHT: int
|
||||
LEFT_MID: int
|
||||
RIGHT_MID: int
|
||||
CENTER: int
|
||||
OUT_TOP_LEFT: int
|
||||
OUT_TOP_MID: int
|
||||
OUT_TOP_RIGHT: int
|
||||
OUT_BOTTOM_LEFT: int
|
||||
OUT_BOTTOM_MID: int
|
||||
OUT_BOTTOM_RIGHT: int
|
||||
OUT_LEFT_TOP: int
|
||||
OUT_LEFT_MID: int
|
||||
OUT_LEFT_BOTTOM: int
|
||||
OUT_RIGHT_TOP: int
|
||||
OUT_RIGHT_MID: int
|
||||
OUT_RIGHT_BOTTOM: int
|
||||
def __init__(self): ...
|
||||
|
||||
class PALETTE:
|
||||
RED: int
|
||||
PINK: int
|
||||
PURPLE: int
|
||||
DEEP_PURPLE: int
|
||||
INDIGO: int
|
||||
BLUE: int
|
||||
LIGHT_BLUE: int
|
||||
CYAN: int
|
||||
TEAL: int
|
||||
GREEN: int
|
||||
LIGHT_GREEN: int
|
||||
LIME: int
|
||||
YELLOW: int
|
||||
AMBER: int
|
||||
ORANGE: int
|
||||
DEEP_ORANGE: int
|
||||
BROWN: int
|
||||
BLUE_GREY: int
|
||||
GREY: int
|
||||
NONE: int
|
||||
def __init__(self): ...
|
||||
|
||||
class OPA:
|
||||
TRANSP: int
|
||||
COVER: int
|
||||
def __init__(self): ...
|
||||
|
||||
class ANIM:
|
||||
OFF: int
|
||||
ON: int
|
||||
def __init__(self): ...
|
||||
|
||||
class STATE:
|
||||
def __init__(self): ...
|
||||
|
||||
class lv_event:
|
||||
def get_code(self) -> int: ...
|
||||
def get_target(self) -> lv_obj: ...
|
||||
|
||||
class lv_color_t: ...
|
||||
|
||||
class lv_timer_t:
|
||||
def set_period(period: int): ...
|
||||
def set_cb(cb: any): ...
|
||||
def _del(self): ...
|
||||
|
||||
def palette_lighten(p: int, lvl: int) -> lv_color_t: ...
|
||||
def palette_main(p: int) -> lv_color_t: ...
|
||||
|
||||
class style_t:
|
||||
def __init__(self): ...
|
||||
def init(self): ...
|
||||
def set_radius(self, radius: int): ...
|
||||
def set_bg_opa(self, opa: int): ...
|
||||
def set_bg_color(self, color: lv_color_t): ...
|
||||
def set_outline_width(self, w: int): ...
|
||||
def set_outline_color(self, color: lv_color_t): ...
|
||||
def set_outline_pad(self, pad: int): ...
|
||||
def set_shadow_width(self, w: int): ...
|
||||
def set_shadow_spread(self, s: int): ...
|
||||
def set_shadow_color(self, color: lv_color_t): ...
|
||||
|
||||
class lv_obj:
|
||||
def center(self): ...
|
||||
def set_size(self, size_x: int, size_y: int): ...
|
||||
def align(self, align: int, x_ofs: int, y_ofs: int): ...
|
||||
def set_height(self, h: int): ...
|
||||
def update_layout(self): ...
|
||||
def set_width(self, w: int): ...
|
||||
def add_state(self, state: int): ...
|
||||
def add_event(self, event_cb: any, filter: int, user_data: pointer): ...
|
||||
def add_style(self, style: style_t, selector: int): ...
|
||||
def get_x(self) -> int: ...
|
||||
def get_y(self) -> int: ...
|
||||
def set_pos(self, x: int, y: int): ...
|
||||
|
||||
class indev_t:
|
||||
def get_vect(self, point: point_t): ...
|
||||
|
||||
def obj(parent: lv_obj) -> lv_obj: ...
|
||||
def indev_get_act() -> indev_t: ...
|
||||
|
||||
class point_t:
|
||||
def __init__(self): ...
|
||||
|
||||
class arc(lv_obj):
|
||||
MODE_NORMAL: int
|
||||
MODE_SYMMETRICAL: int
|
||||
MODE_REVERSE: int
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_start_angle(self, start: int): ...
|
||||
def set_end_angle(self, angle: int): ...
|
||||
def set_angles(self, start: int, end: int): ...
|
||||
def set_bg_start_angle(self, start: int): ...
|
||||
def set_bg_end_angle(self, angle: int): ...
|
||||
def set_bg_angles(self, start: int, end: int): ...
|
||||
def set_rotation(self, rotation: int): ...
|
||||
def set_mode(self, mode: int): ...
|
||||
def set_value(self, value: int): ...
|
||||
def set_range(self, min: int, max: int): ...
|
||||
def set_change_rate(self, rate: int): ...
|
||||
def get_angle_start(self) -> int: ...
|
||||
def get_angle_end(self) -> int: ...
|
||||
def get_bg_angle_start(self) -> int: ...
|
||||
def get_bg_angle_end(self) -> int: ...
|
||||
def get_value(self) -> int: ...
|
||||
def get_min_value(self) -> int: ...
|
||||
def get_max_value(self) -> int: ...
|
||||
def get_mode(self) -> int: ...
|
||||
# def get_rotation(self) -> int: ...
|
||||
|
||||
class bar(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_value(self, value: int, anim: int): ...
|
||||
def set_start_value(self, start_value: int, anim: int): ...
|
||||
def set_range(self, min: int, max: int): ...
|
||||
def set_mode(self, mode: int): ...
|
||||
def get_value(self) -> int: ...
|
||||
def get_start_value(self) -> int: ...
|
||||
def get_min_value(self) -> int: ...
|
||||
def get_max_value(self) -> int: ...
|
||||
def get_mode(self) -> int: ...
|
||||
|
||||
class btn(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
|
||||
class checkbox(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_text(self, txt: str): ...
|
||||
def set_text_static(self, txt: str): ...
|
||||
def get_text(self) -> str: ...
|
||||
|
||||
class dropdown(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_text(self, txt: str): ...
|
||||
def set_options(self, options: str): ...
|
||||
def add_option(self, option: str, pos:int): ...
|
||||
def clear_options(self): ...
|
||||
def set_selected(self, sel_opt: int): ...
|
||||
def set_dir(self, dir: int): ...
|
||||
def set_symbol(self, symbol: str): ...
|
||||
def set_selected_highlight(self, en: int): ...
|
||||
# def get_list(self) -> lv_obj: ...
|
||||
def get_text(self) -> str: ...
|
||||
def get_options(self) -> str: ...
|
||||
def get_selected(self) -> int: ...
|
||||
def get_option_cnt(self) -> int: ...
|
||||
def get_selected_str(self) -> str: ...
|
||||
def get_option_index(self, option: str) -> int: ...
|
||||
def get_symbol(self) -> str: ...
|
||||
def get_selected_highlight(self) -> int: ...
|
||||
def get_dir(self) -> int: ...
|
||||
def open(self): ...
|
||||
def close(self): ...
|
||||
def is_open(self) -> int: ...
|
||||
|
||||
class label(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_text(self, txt: str): ...
|
||||
def set_long_mode(self, mode: int): ...
|
||||
def set_recolor(self, en: int): ...
|
||||
def set_style_text_align(self, value: int, selector: int): ...
|
||||
|
||||
class roller(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_options(self, options: str, mode: int): ...
|
||||
def set_visible_row_count(self, row_cnt: int): ...
|
||||
|
||||
class slider(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
|
||||
class switch(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
|
||||
class table(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_cell_value(self, row: int, col: int, txt: str): ...
|
||||
|
||||
class textarea(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_one_line(en: int): ...
|
||||
|
||||
def scr_act() -> lv_obj: ...
|
||||
def timer_create_basic() -> lv_timer_t: ...
|
||||
18
libraries/lvgl/env_support/pikascript/pika_lvgl_indev_t.c
Normal file
18
libraries/lvgl/env_support/pikascript/pika_lvgl_indev_t.c
Normal file
@ -0,0 +1,18 @@
|
||||
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
#include "../../lvgl.h"
|
||||
#endif
|
||||
|
||||
#ifdef PIKASCRIPT
|
||||
|
||||
#include "pika_lvgl_indev_t.h"
|
||||
|
||||
void pika_lvgl_indev_t_get_vect(PikaObj* self, PikaObj* point) {
|
||||
lv_indev_t* lv_indev = obj_getPtr(self, "lv_indev");
|
||||
lv_point_t* lv_point = obj_getPtr(point, "lv_point");
|
||||
lv_indev_get_vect(lv_indev, lv_point);
|
||||
obj_setInt(point, "x", lv_point->x);
|
||||
obj_setInt(point, "y", lv_point->y);
|
||||
}
|
||||
#endif
|
||||
24
libraries/lvgl/env_support/pikascript/pika_lvgl_lv_event.c
Normal file
24
libraries/lvgl/env_support/pikascript/pika_lvgl_lv_event.c
Normal file
@ -0,0 +1,24 @@
|
||||
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
#include "../../lvgl.h"
|
||||
#endif
|
||||
|
||||
#ifdef PIKASCRIPT
|
||||
|
||||
#include "pika_lvgl_lv_event.h"
|
||||
|
||||
int pika_lvgl_lv_event_get_code(PikaObj *self){
|
||||
lv_event_t *lv_event = obj_getPtr(self, "lv_event");
|
||||
return lv_event_get_code(lv_event);
|
||||
}
|
||||
|
||||
PikaObj *New_pika_lvgl_lv_obj(Args *args);
|
||||
PikaObj* pika_lvgl_lv_event_get_target(PikaObj *self){
|
||||
lv_event_t *lv_event = obj_getPtr(self, "lv_event");
|
||||
lv_obj_t* lv_obj = lv_event_get_target(lv_event);
|
||||
PikaObj* new_obj = newNormalObj(New_pika_lvgl_lv_obj);
|
||||
obj_setPtr(new_obj, "lv_obj", lv_obj);
|
||||
return new_obj;
|
||||
}
|
||||
#endif
|
||||
116
libraries/lvgl/env_support/pikascript/pika_lvgl_lv_obj.c
Normal file
116
libraries/lvgl/env_support/pikascript/pika_lvgl_lv_obj.c
Normal file
@ -0,0 +1,116 @@
|
||||
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
#include "../../lvgl.h"
|
||||
#endif
|
||||
|
||||
#ifdef PIKASCRIPT
|
||||
|
||||
#include "pika_lvgl_lv_obj.h"
|
||||
#include "BaseObj.h"
|
||||
#include "dataStrs.h"
|
||||
#include "pika_lvgl.h"
|
||||
#include "pika_lvgl_arc.h"
|
||||
#include "pika_lvgl_lv_event.h"
|
||||
|
||||
extern PikaObj* pika_lv_event_listener_g;
|
||||
|
||||
void pika_lvgl_lv_obj_center(PikaObj* self) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_obj_center(lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_obj_set_size(PikaObj* self, int size_x, int size_y) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_obj_set_size(lv_obj, size_x, size_y);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_obj_align(PikaObj* self, int align, int x_ofs, int y_ofs) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_obj_align(lv_obj, align, x_ofs, y_ofs);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_obj_set_height(PikaObj* self, int h) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_obj_set_height(lv_obj, h);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_obj_update_layout(PikaObj* self) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_obj_update_layout(lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_obj_set_width(PikaObj* self, int w) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_obj_set_width(lv_obj, w);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_obj_add_state(PikaObj* self, int state) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_obj_add_state(lv_obj, state);
|
||||
}
|
||||
|
||||
PikaObj* eventLisener_getHandler(PikaObj* self, uintptr_t event_id) {
|
||||
Args buffs = {0};
|
||||
char* event_name =
|
||||
strsFormat(&buffs, PIKA_SPRINTF_BUFF_SIZE, "%d", event_id);
|
||||
PikaObj* event_item = obj_getObj(self, event_name);
|
||||
PikaObj* event_handler = obj_getPtr(event_item, "handler");
|
||||
strsDeinit(&buffs);
|
||||
return event_handler;
|
||||
}
|
||||
|
||||
static void __pika_event_cb(lv_event_t* e) {
|
||||
lv_obj_t* target = lv_event_get_target(e);
|
||||
PikaObj* event_handler =
|
||||
eventLisener_getHandler(pika_lv_event_listener_g, (uintptr_t)target);
|
||||
PikaObj* evt = obj_getObj(event_handler, "_event_evt");
|
||||
obj_setPtr(evt, "lv_event", e);
|
||||
obj_run(event_handler, "_event_cb(_event_evt)");
|
||||
}
|
||||
|
||||
void eventLicener_registerEvent(PikaObj* self,
|
||||
uintptr_t event_id,
|
||||
PikaObj* event_handler) {
|
||||
Args buffs = {0};
|
||||
char* event_name =
|
||||
strsFormat(&buffs, PIKA_SPRINTF_BUFF_SIZE, "%d", event_id);
|
||||
obj_newDirectObj(self, event_name, New_TinyObj);
|
||||
PikaObj* event_item = obj_getObj(self, event_name);
|
||||
obj_setRef(event_item, "handler", event_handler);
|
||||
strsDeinit(&buffs);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_obj_add_event_cb(PikaObj* self,
|
||||
Arg* event_cb,
|
||||
int filter,
|
||||
void* user_data) {
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_obj_add_event_cb(lv_obj, __pika_event_cb, filter, NULL);
|
||||
obj_setArg(self, "_event_cb", event_cb);
|
||||
obj_setPtr(self, "_event_user_data", user_data);
|
||||
obj_newDirectObj(self, "_event_evt", New_pika_lvgl_lv_event);
|
||||
eventLicener_registerEvent(pika_lv_event_listener_g, (uintptr_t)lv_obj, self);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_obj_add_style(PikaObj *self, PikaObj* style, int selector){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_style_t* lv_style = obj_getPtr(style, "lv_style");
|
||||
lv_obj_add_style(lv_obj, lv_style, selector);
|
||||
}
|
||||
|
||||
int pika_lvgl_lv_obj_get_x(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_obj_get_x(lv_obj);
|
||||
}
|
||||
|
||||
int pika_lvgl_lv_obj_get_y(PikaObj *self){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
return lv_obj_get_y(lv_obj);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_obj_set_pos(PikaObj *self, int x, int y){
|
||||
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
|
||||
lv_obj_set_pos(lv_obj, x, y);
|
||||
}
|
||||
#endif
|
||||
70
libraries/lvgl/env_support/pikascript/pika_lvgl_lv_style_t.c
Normal file
70
libraries/lvgl/env_support/pikascript/pika_lvgl_lv_style_t.c
Normal file
@ -0,0 +1,70 @@
|
||||
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||
#include "lvgl.h"
|
||||
#else
|
||||
#include "../../lvgl.h"
|
||||
#endif
|
||||
|
||||
#ifdef PIKASCRIPT
|
||||
|
||||
#include "pika_lvgl_style_t.h"
|
||||
|
||||
void pika_lvgl_style_t_init(PikaObj* self) {
|
||||
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
|
||||
lv_style_init(lv_style);
|
||||
}
|
||||
|
||||
void pika_lvgl_style_t_set_bg_color(PikaObj* self, PikaObj* color) {
|
||||
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
|
||||
lv_color_t* lv_color = obj_getPtr(color, "lv_color");
|
||||
lv_style_set_bg_color(lv_style, *lv_color);
|
||||
}
|
||||
|
||||
void pika_lvgl_style_t_set_bg_opa(PikaObj* self, int opa) {
|
||||
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
|
||||
lv_style_set_bg_opa(lv_style, opa);
|
||||
}
|
||||
|
||||
void pika_lvgl_style_t_set_outline_color(PikaObj* self, PikaObj* color) {
|
||||
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
|
||||
lv_color_t* lv_color = obj_getPtr(color, "lv_color");
|
||||
lv_style_set_outline_color(lv_style, *lv_color);
|
||||
}
|
||||
|
||||
void pika_lvgl_style_t_set_outline_pad(PikaObj* self, int pad) {
|
||||
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
|
||||
lv_style_set_outline_pad(lv_style, pad);
|
||||
}
|
||||
|
||||
void pika_lvgl_style_t_set_outline_width(PikaObj* self, int w) {
|
||||
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
|
||||
lv_style_set_outline_width(lv_style, w);
|
||||
}
|
||||
|
||||
void pika_lvgl_style_t_set_radius(PikaObj* self, int radius) {
|
||||
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
|
||||
lv_style_set_radius(lv_style, radius);
|
||||
}
|
||||
|
||||
void pika_lvgl_style_t___init__(PikaObj* self) {
|
||||
lv_style_t lv_style_stack = {0};
|
||||
args_setStruct(self->list, "lv_style_struct", lv_style_stack);
|
||||
lv_style_t* lv_style = args_getStruct(self->list, "lv_style_struct");
|
||||
obj_setPtr(self, "lv_style", lv_style);
|
||||
}
|
||||
|
||||
void pika_lvgl_style_t_set_shadow_color(PikaObj *self, PikaObj* color){
|
||||
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
|
||||
lv_color_t* lv_color = obj_getPtr(color, "lv_color");
|
||||
lv_style_set_shadow_color(lv_style, *lv_color);
|
||||
}
|
||||
|
||||
void pika_lvgl_style_t_set_shadow_spread(PikaObj *self, int s){
|
||||
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
|
||||
lv_style_set_shadow_spread(lv_style, s);
|
||||
}
|
||||
|
||||
void pika_lvgl_style_t_set_shadow_width(PikaObj *self, int w){
|
||||
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
|
||||
lv_style_set_shadow_width(lv_style, w);
|
||||
}
|
||||
#endif
|
||||
70
libraries/lvgl/env_support/rt-thread/SConscript
Normal file
70
libraries/lvgl/env_support/rt-thread/SConscript
Normal file
@ -0,0 +1,70 @@
|
||||
from building import *
|
||||
import rtconfig
|
||||
import os
|
||||
|
||||
src = []
|
||||
inc = []
|
||||
group = []
|
||||
|
||||
cwd = GetCurrentDir() # get current dir path
|
||||
|
||||
port_src = Glob('*.c')
|
||||
port_inc = [cwd]
|
||||
group = group + DefineGroup('LVGL-port', port_src, depend = ['PKG_USING_LVGL'], CPPPATH = port_inc)
|
||||
|
||||
# check if .h or .hpp files exists
|
||||
def check_h_hpp_exists(path):
|
||||
file_dirs = os.listdir(path)
|
||||
for file_dir in file_dirs:
|
||||
if os.path.splitext(file_dir)[1] in ['.h', '.hpp']:
|
||||
return True
|
||||
return False
|
||||
|
||||
lvgl_cwd = cwd + '/../../'
|
||||
|
||||
lvgl_src_cwd = lvgl_cwd + 'src/'
|
||||
inc = inc + [lvgl_src_cwd]
|
||||
src = src + Glob(os.path.join(lvgl_src_cwd,'*.c'))
|
||||
for root, dirs, files in os.walk(lvgl_src_cwd):
|
||||
for dir in dirs:
|
||||
current_path = os.path.join(root, dir)
|
||||
src = src + Glob(os.path.join(current_path,'*.c')) # add all .c files
|
||||
if check_h_hpp_exists(current_path): # add .h and .hpp path
|
||||
inc = inc + [current_path]
|
||||
|
||||
|
||||
if GetDepend('PKG_LVGL_USING_EXAMPLES'):
|
||||
lvgl_src_cwd = lvgl_cwd + 'examples/'
|
||||
inc = inc + [lvgl_src_cwd]
|
||||
for root, dirs, files in os.walk(lvgl_src_cwd):
|
||||
for dir in dirs:
|
||||
current_path = os.path.join(root, dir)
|
||||
src = src + Glob(os.path.join(current_path,'*.c'))
|
||||
if check_h_hpp_exists(current_path):
|
||||
inc = inc + [current_path]
|
||||
|
||||
if GetDepend('PKG_LVGL_USING_DEMOS'):
|
||||
lvgl_src_cwd = lvgl_cwd + 'demos/'
|
||||
inc = inc + [lvgl_src_cwd]
|
||||
for root, dirs, files in os.walk(lvgl_src_cwd):
|
||||
for dir in dirs:
|
||||
current_path = os.path.join(root, dir)
|
||||
src = src + Glob(os.path.join(current_path,'*.c'))
|
||||
if check_h_hpp_exists(current_path):
|
||||
inc = inc + [current_path]
|
||||
|
||||
LOCAL_CFLAGS = ''
|
||||
if rtconfig.PLATFORM == 'gcc' or rtconfig.PLATFORM == 'armclang': # GCC or Keil AC6
|
||||
LOCAL_CFLAGS += ' -std=c99'
|
||||
elif rtconfig.PLATFORM == 'armcc': # Keil AC5
|
||||
LOCAL_CFLAGS += ' --c99 --gnu'
|
||||
|
||||
group = group + DefineGroup('LVGL', src, depend = ['PKG_USING_LVGL'], CPPPATH = inc, LOCAL_CFLAGS = LOCAL_CFLAGS)
|
||||
|
||||
list = os.listdir(cwd)
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
group = group + SConscript(os.path.join(d, 'SConscript'))
|
||||
|
||||
Return('group')
|
||||
74
libraries/lvgl/env_support/rt-thread/lv_rt_thread_conf.h
Normal file
74
libraries/lvgl/env_support/rt-thread/lv_rt_thread_conf.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-15 Meco Man The first version
|
||||
*/
|
||||
|
||||
#ifndef LV_RT_THREAD_CONF_H
|
||||
#define LV_RT_THREAD_CONF_H
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
|
||||
#define LV_RTTHREAD_INCLUDE <rtthread.h>
|
||||
#include LV_RTTHREAD_INCLUDE
|
||||
|
||||
/*=========================
|
||||
STDLIB WRAPPER SETTINGS
|
||||
*=========================*/
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
#define LV_USE_STDLIB_MALLOC LV_STDLIB_RTTHREAD
|
||||
#endif
|
||||
|
||||
#define LV_USE_STDLIB_STRING LV_STDLIB_RTTHREAD
|
||||
|
||||
#if LV_USE_FLOAT == 0
|
||||
#define LV_USE_STDLIB_SPRINTF LV_STDLIB_RTTHREAD
|
||||
#endif
|
||||
|
||||
/*=================
|
||||
* OPERATING SYSTEM
|
||||
*=================*/
|
||||
|
||||
#define LV_USE_OS LV_OS_RTTHREAD
|
||||
|
||||
/*-------------
|
||||
* Asserts
|
||||
*-----------*/
|
||||
|
||||
#define LV_ASSERT_HANDLER_INCLUDE LV_RTTHREAD_INCLUDE
|
||||
#define LV_ASSERT_HANDLER RT_ASSERT(0);
|
||||
|
||||
/*=====================
|
||||
* COMPILER SETTINGS
|
||||
*====================*/
|
||||
|
||||
#ifdef ARCH_CPU_BIG_ENDIAN
|
||||
#define LV_BIG_ENDIAN_SYSTEM 1
|
||||
#else
|
||||
#define LV_BIG_ENDIAN_SYSTEM 0
|
||||
#endif
|
||||
|
||||
#ifdef rt_align /* >= RT-Thread v5.0.0 */
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN rt_align(RT_ALIGN_SIZE)
|
||||
#else
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN ALIGN(RT_ALIGN_SIZE)
|
||||
#endif
|
||||
|
||||
/*==================
|
||||
* EXAMPLES
|
||||
*==================*/
|
||||
|
||||
#ifdef PKG_LVGL_USING_EXAMPLES
|
||||
#define LV_BUILD_EXAMPLES 1
|
||||
#endif
|
||||
|
||||
/*--END OF LV_RT_THREAD_CONF_H--*/
|
||||
|
||||
#endif /*__RTTHREAD__*/
|
||||
|
||||
#endif /*LV_CONF_H*/
|
||||
90
libraries/lvgl/env_support/rt-thread/lv_rt_thread_port.c
Normal file
90
libraries/lvgl/env_support/rt-thread/lv_rt_thread_port.c
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-18 Meco Man the first version
|
||||
* 2022-05-10 Meco Man improve rt-thread initialization process
|
||||
*/
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#define DBG_TAG "LVGL"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifndef PKG_LVGL_THREAD_STACK_SIZE
|
||||
#define PKG_LVGL_THREAD_STACK_SIZE 4096
|
||||
#endif /* PKG_LVGL_THREAD_STACK_SIZE */
|
||||
|
||||
#ifndef PKG_LVGL_THREAD_PRIO
|
||||
#define PKG_LVGL_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
|
||||
#endif /* PKG_LVGL_THREAD_PRIO */
|
||||
|
||||
#ifndef PKG_LVGL_DISP_REFR_PERIOD
|
||||
#define PKG_LVGL_DISP_REFR_PERIOD 33
|
||||
#endif /* PKG_LVGL_DISP_REFR_PERIOD */
|
||||
|
||||
extern void lv_port_disp_init(void);
|
||||
extern void lv_port_indev_init(void);
|
||||
extern void lv_user_gui_init(void);
|
||||
|
||||
static struct rt_thread lvgl_thread;
|
||||
|
||||
#ifdef rt_align
|
||||
rt_align(RT_ALIGN_SIZE)
|
||||
#else
|
||||
ALIGN(RT_ALIGN_SIZE)
|
||||
#endif
|
||||
static rt_uint8_t lvgl_thread_stack[PKG_LVGL_THREAD_STACK_SIZE];
|
||||
|
||||
#if LV_USE_LOG
|
||||
static void lv_rt_log(const char *buf)
|
||||
{
|
||||
LOG_I(buf);
|
||||
}
|
||||
#endif /* LV_USE_LOG */
|
||||
|
||||
static void lvgl_thread_entry(void *parameter)
|
||||
{
|
||||
#if LV_USE_LOG
|
||||
lv_log_register_print_cb(lv_rt_log);
|
||||
#endif /* LV_USE_LOG */
|
||||
lv_init();
|
||||
lv_port_disp_init();
|
||||
lv_port_indev_init();
|
||||
lv_user_gui_init();
|
||||
|
||||
lv_tick_set_cb(&rt_tick_get_millisecond);
|
||||
|
||||
/* handle the tasks of LVGL */
|
||||
while(1)
|
||||
{
|
||||
lv_task_handler();
|
||||
rt_thread_mdelay(PKG_LVGL_DISP_REFR_PERIOD);
|
||||
}
|
||||
}
|
||||
|
||||
static int lvgl_thread_init(void)
|
||||
{
|
||||
rt_err_t err;
|
||||
|
||||
err = rt_thread_init(&lvgl_thread, "LVGL", lvgl_thread_entry, RT_NULL,
|
||||
&lvgl_thread_stack[0], sizeof(lvgl_thread_stack), PKG_LVGL_THREAD_PRIO, 10);
|
||||
if(err != RT_EOK)
|
||||
{
|
||||
LOG_E("Failed to create LVGL thread");
|
||||
return -1;
|
||||
}
|
||||
rt_thread_startup(&lvgl_thread);
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_ENV_EXPORT(lvgl_thread_init);
|
||||
|
||||
#endif /*__RTTHREAD__*/
|
||||
@ -0,0 +1,4 @@
|
||||
This folder is for LVGL SquareLine Studio
|
||||
|
||||
SquareLine Studio can automatically put the generated C files into `ui` folder, so that rt-thread will automatically detect them; or, as a user, you can move the generated C files into `ui` folder manually.
|
||||
|
||||
25
libraries/lvgl/env_support/rt-thread/squareline/SConscript
Normal file
25
libraries/lvgl/env_support/rt-thread/squareline/SConscript
Normal file
@ -0,0 +1,25 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
inc = [cwd]
|
||||
|
||||
# check if .h or .hpp files exists
|
||||
def check_h_hpp_exists(path):
|
||||
file_dirs = os.listdir(path)
|
||||
for file_dir in file_dirs:
|
||||
if os.path.splitext(file_dir)[1] in ['.h', '.hpp']:
|
||||
return True
|
||||
return False
|
||||
|
||||
sls_src_cwd = cwd
|
||||
for root, dirs, files in os.walk(sls_src_cwd):
|
||||
for dir in dirs:
|
||||
current_path = os.path.join(root, dir)
|
||||
src = src + Glob(os.path.join(current_path,'*.c')) # add all .c files
|
||||
if check_h_hpp_exists(current_path): # add .h and .hpp path
|
||||
inc = inc + [current_path]
|
||||
|
||||
group = DefineGroup('LVGL-SquareLine', src, depend = ['PKG_USING_LVGL_SQUARELINE'], CPPPATH = inc)
|
||||
|
||||
Return('group')
|
||||
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-05-13 Meco Man First version
|
||||
*/
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
|
||||
void lv_user_gui_init(void)
|
||||
{
|
||||
extern void ui_init(void);
|
||||
ui_init();
|
||||
}
|
||||
|
||||
#endif /* __RTTHREAD__ */
|
||||
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-11-20 Meco Man The first version
|
||||
*/
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
|
||||
#include "../../../../../lvgl.h" /* back to the root folder's lvgl.h */
|
||||
|
||||
#endif /* __RTTHREAD__ */
|
||||
2
libraries/lvgl/env_support/zephyr/module.yml
Normal file
2
libraries/lvgl/env_support/zephyr/module.yml
Normal file
@ -0,0 +1,2 @@
|
||||
build:
|
||||
cmake: .
|
||||
0
libraries/lvgl/examples/.gitkeep
Normal file
0
libraries/lvgl/examples/.gitkeep
Normal file
5
libraries/lvgl/idf_component.yml
Normal file
5
libraries/lvgl/idf_component.yml
Normal file
@ -0,0 +1,5 @@
|
||||
description: LVGL - Light and Versatile Graphics Library
|
||||
url: https://lvgl.io/
|
||||
repository: https://github.com/lvgl/lvgl.git
|
||||
documentation: https://docs.lvgl.io/
|
||||
issues: https://github.com/lvgl/lvgl/issues
|
||||
17
libraries/lvgl/library.json
Normal file
17
libraries/lvgl/library.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "lvgl",
|
||||
"version": "9.1.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
libraries/lvgl/library.properties
Normal file
10
libraries/lvgl/library.properties
Normal file
@ -0,0 +1,10 @@
|
||||
name=lvgl
|
||||
version=9.1.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
|
||||
988
libraries/lvgl/lv_conf_template.h
Normal file
988
libraries/lvgl/lv_conf_template.h
Normal file
@ -0,0 +1,988 @@
|
||||
/**
|
||||
* @file lv_conf.h
|
||||
* Configuration file for v9.1.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copy this file as `lv_conf.h`
|
||||
* 1. simply next to the `lvgl` folder
|
||||
* 2. or any other places and
|
||||
* - define `LV_CONF_INCLUDE_SIMPLE`
|
||||
* - add the path as include path
|
||||
*/
|
||||
|
||||
/* clang-format off */
|
||||
#if 0 /*Set it to "1" to enable content*/
|
||||
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
|
||||
/*If you need to include anything here, do it inside the `__ASSEMBLY__` guard */
|
||||
#if 0 && defined(__ASSEMBLY__)
|
||||
#include "my_include.h"
|
||||
#endif
|
||||
|
||||
/*====================
|
||||
COLOR SETTINGS
|
||||
*====================*/
|
||||
|
||||
/*Color depth: 8 (A8), 16 (RGB565), 24 (RGB888), 32 (XRGB8888)*/
|
||||
#define LV_COLOR_DEPTH 16
|
||||
|
||||
/*=========================
|
||||
STDLIB WRAPPER SETTINGS
|
||||
*=========================*/
|
||||
|
||||
/* Possible values
|
||||
* - LV_STDLIB_BUILTIN: LVGL's built in implementation
|
||||
* - LV_STDLIB_CLIB: Standard C functions, like malloc, strlen, etc
|
||||
* - LV_STDLIB_MICROPYTHON: MicroPython implementation
|
||||
* - LV_STDLIB_RTTHREAD: RT-Thread implementation
|
||||
* - LV_STDLIB_CUSTOM: Implement the functions externally
|
||||
*/
|
||||
#define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN
|
||||
#define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN
|
||||
#define LV_USE_STDLIB_SPRINTF LV_STDLIB_BUILTIN
|
||||
|
||||
|
||||
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
|
||||
/*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/
|
||||
#define LV_MEM_SIZE (64 * 1024U) /*[bytes]*/
|
||||
|
||||
/*Size of the memory expand for `lv_malloc()` in bytes*/
|
||||
#define LV_MEM_POOL_EXPAND_SIZE 0
|
||||
|
||||
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
|
||||
#define LV_MEM_ADR 0 /*0: unused*/
|
||||
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
|
||||
#if LV_MEM_ADR == 0
|
||||
#undef LV_MEM_POOL_INCLUDE
|
||||
#undef LV_MEM_POOL_ALLOC
|
||||
#endif
|
||||
#endif /*LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN*/
|
||||
|
||||
/*====================
|
||||
HAL SETTINGS
|
||||
*====================*/
|
||||
|
||||
/*Default display refresh, input device read and animation step period.*/
|
||||
#define LV_DEF_REFR_PERIOD 33 /*[ms]*/
|
||||
|
||||
/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
|
||||
*(Not so important, you can adjust it to modify default sizes and spaces)*/
|
||||
#define LV_DPI_DEF 130 /*[px/inch]*/
|
||||
|
||||
/*=================
|
||||
* OPERATING SYSTEM
|
||||
*=================*/
|
||||
/*Select an operating system to use. Possible options:
|
||||
* - LV_OS_NONE
|
||||
* - LV_OS_PTHREAD
|
||||
* - LV_OS_FREERTOS
|
||||
* - LV_OS_CMSIS_RTOS2
|
||||
* - LV_OS_RTTHREAD
|
||||
* - LV_OS_WINDOWS
|
||||
* - LV_OS_CUSTOM */
|
||||
#define LV_USE_OS LV_OS_NONE
|
||||
|
||||
#if LV_USE_OS == LV_OS_CUSTOM
|
||||
#define LV_OS_CUSTOM_INCLUDE <stdint.h>
|
||||
#endif
|
||||
|
||||
/*========================
|
||||
* RENDERING CONFIGURATION
|
||||
*========================*/
|
||||
|
||||
/*Align the stride of all layers and images to this bytes*/
|
||||
#define LV_DRAW_BUF_STRIDE_ALIGN 1
|
||||
|
||||
/*Align the start address of draw_buf addresses to this bytes*/
|
||||
#define LV_DRAW_BUF_ALIGN 4
|
||||
|
||||
/* If a widget has `style_opa < 255` (not `bg_opa`, `text_opa` etc) or not NORMAL blend mode
|
||||
* it is buffered into a "simple" layer before rendering. The widget can be buffered in smaller chunks.
|
||||
* "Transformed layers" (if `transform_angle/zoom` are set) use larger buffers
|
||||
* and can't be drawn in chunks. */
|
||||
|
||||
/*The target buffer size for simple layer chunks.*/
|
||||
#define LV_DRAW_LAYER_SIMPLE_BUF_SIZE (24 * 1024) /*[bytes]*/
|
||||
|
||||
#define LV_USE_DRAW_SW 1
|
||||
#if LV_USE_DRAW_SW == 1
|
||||
/* Set the number of draw unit.
|
||||
* > 1 requires an operating system enabled in `LV_USE_OS`
|
||||
* > 1 means multiply threads will render the screen in parallel */
|
||||
#define LV_DRAW_SW_DRAW_UNIT_CNT 1
|
||||
|
||||
/* Use Arm-2D to accelerate the sw render */
|
||||
#define LV_USE_DRAW_ARM2D_SYNC 0
|
||||
|
||||
/* Enable native helium assembly to be compiled */
|
||||
#define LV_USE_NATIVE_HELIUM_ASM 0
|
||||
|
||||
/* 0: use a simple renderer capable of drawing only simple rectangles with gradient, images, texts, and straight lines only
|
||||
* 1: use a complex renderer capable of drawing rounded corners, shadow, skew lines, and arcs too */
|
||||
#define LV_DRAW_SW_COMPLEX 1
|
||||
|
||||
#if LV_DRAW_SW_COMPLEX == 1
|
||||
/*Allow buffering some shadow calculation.
|
||||
*LV_DRAW_SW_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius`
|
||||
*Caching has LV_DRAW_SW_SHADOW_CACHE_SIZE^2 RAM cost*/
|
||||
#define LV_DRAW_SW_SHADOW_CACHE_SIZE 0
|
||||
|
||||
/* Set number of maximally cached circle data.
|
||||
* The circumference of 1/4 circle are saved for anti-aliasing
|
||||
* radius * 4 bytes are used per circle (the most often used radiuses are saved)
|
||||
* 0: to disable caching */
|
||||
#define LV_DRAW_SW_CIRCLE_CACHE_SIZE 4
|
||||
#endif
|
||||
|
||||
#define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_NONE
|
||||
|
||||
#if LV_USE_DRAW_SW_ASM == LV_DRAW_SW_ASM_CUSTOM
|
||||
#define LV_DRAW_SW_ASM_CUSTOM_INCLUDE ""
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Use NXP's VG-Lite GPU on iMX RTxxx platforms. */
|
||||
#define LV_USE_DRAW_VGLITE 0
|
||||
|
||||
#if LV_USE_DRAW_VGLITE
|
||||
/* Enable blit quality degradation workaround recommended for screen's dimension > 352 pixels. */
|
||||
#define LV_USE_VGLITE_BLIT_SPLIT 0
|
||||
|
||||
#if LV_USE_OS
|
||||
/* Enable VGLite draw async. Queue multiple tasks and flash them once to the GPU. */
|
||||
#define LV_USE_VGLITE_DRAW_ASYNC 1
|
||||
#endif
|
||||
|
||||
/* Enable VGLite asserts. */
|
||||
#define LV_USE_VGLITE_ASSERT 0
|
||||
#endif
|
||||
|
||||
/* Use NXP's PXP on iMX RTxxx platforms. */
|
||||
#define LV_USE_DRAW_PXP 0
|
||||
|
||||
#if LV_USE_DRAW_PXP
|
||||
/* Enable PXP asserts. */
|
||||
#define LV_USE_PXP_ASSERT 0
|
||||
#endif
|
||||
|
||||
/* Use Renesas Dave2D on RA platforms. */
|
||||
#define LV_USE_DRAW_DAVE2D 0
|
||||
|
||||
/* Draw using cached SDL textures*/
|
||||
#define LV_USE_DRAW_SDL 0
|
||||
|
||||
/* Use VG-Lite GPU. */
|
||||
#define LV_USE_DRAW_VG_LITE 0
|
||||
|
||||
#if LV_USE_DRAW_VG_LITE
|
||||
/* Enable VG-Lite custom external 'gpu_init()' function */
|
||||
#define LV_VG_LITE_USE_GPU_INIT 0
|
||||
|
||||
/* Enable VG-Lite assert. */
|
||||
#define LV_VG_LITE_USE_ASSERT 0
|
||||
|
||||
/* VG-Lite flush commit trigger threshold. GPU will try to batch these many draw tasks. */
|
||||
#define LV_VG_LITE_FLUSH_MAX_COUNT 8
|
||||
|
||||
/* Enable border to simulate shadow
|
||||
* NOTE: which usually improves performance,
|
||||
* but does not guarantee the same rendering quality as the software. */
|
||||
#define LV_VG_LITE_USE_BOX_SHADOW 0
|
||||
|
||||
/* VG-Lite gradient image maximum cache number.
|
||||
* NOTE: The memory usage of a single gradient image is 4K bytes.
|
||||
*/
|
||||
#define LV_VG_LITE_GRAD_CACHE_SIZE 32
|
||||
|
||||
#endif
|
||||
|
||||
/*=======================
|
||||
* FEATURE CONFIGURATION
|
||||
*=======================*/
|
||||
|
||||
/*-------------
|
||||
* Logging
|
||||
*-----------*/
|
||||
|
||||
/*Enable the log module*/
|
||||
#define LV_USE_LOG 0
|
||||
#if LV_USE_LOG
|
||||
|
||||
/*How important log should be added:
|
||||
*LV_LOG_LEVEL_TRACE A lot of logs to give detailed information
|
||||
*LV_LOG_LEVEL_INFO Log important events
|
||||
*LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem
|
||||
*LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
|
||||
*LV_LOG_LEVEL_USER Only logs added by the user
|
||||
*LV_LOG_LEVEL_NONE Do not log anything*/
|
||||
#define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
||||
|
||||
/*1: Print the log with 'printf';
|
||||
*0: User need to register a callback with `lv_log_register_print_cb()`*/
|
||||
#define LV_LOG_PRINTF 0
|
||||
|
||||
/*1: Enable print timestamp;
|
||||
*0: Disable print timestamp*/
|
||||
#define LV_LOG_USE_TIMESTAMP 1
|
||||
|
||||
/*1: Print file and line number of the log;
|
||||
*0: Do not print file and line number of the log*/
|
||||
#define LV_LOG_USE_FILE_LINE 1
|
||||
|
||||
/*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/
|
||||
#define LV_LOG_TRACE_MEM 1
|
||||
#define LV_LOG_TRACE_TIMER 1
|
||||
#define LV_LOG_TRACE_INDEV 1
|
||||
#define LV_LOG_TRACE_DISP_REFR 1
|
||||
#define LV_LOG_TRACE_EVENT 1
|
||||
#define LV_LOG_TRACE_OBJ_CREATE 1
|
||||
#define LV_LOG_TRACE_LAYOUT 1
|
||||
#define LV_LOG_TRACE_ANIM 1
|
||||
#define LV_LOG_TRACE_CACHE 1
|
||||
|
||||
#endif /*LV_USE_LOG*/
|
||||
|
||||
/*-------------
|
||||
* Asserts
|
||||
*-----------*/
|
||||
|
||||
/*Enable asserts if an operation is failed or an invalid data is found.
|
||||
*If LV_USE_LOG is enabled an error message will be printed on failure*/
|
||||
#define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/
|
||||
#define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/
|
||||
#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/
|
||||
#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/
|
||||
#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/
|
||||
|
||||
/*Add a custom handler when assert happens e.g. to restart the MCU*/
|
||||
#define LV_ASSERT_HANDLER_INCLUDE <stdint.h>
|
||||
#define LV_ASSERT_HANDLER while(1); /*Halt by default*/
|
||||
|
||||
/*-------------
|
||||
* Debug
|
||||
*-----------*/
|
||||
|
||||
/*1: Draw random colored rectangles over the redrawn areas*/
|
||||
#define LV_USE_REFR_DEBUG 0
|
||||
|
||||
/*1: Draw a red overlay for ARGB layers and a green overlay for RGB layers*/
|
||||
#define LV_USE_LAYER_DEBUG 0
|
||||
|
||||
/*1: Draw overlays with different colors for each draw_unit's tasks.
|
||||
*Also add the index number of the draw unit on white background.
|
||||
*For layers add the index number of the draw unit on black background.*/
|
||||
#define LV_USE_PARALLEL_DRAW_DEBUG 0
|
||||
|
||||
/*-------------
|
||||
* Others
|
||||
*-----------*/
|
||||
|
||||
#define LV_ENABLE_GLOBAL_CUSTOM 0
|
||||
#if LV_ENABLE_GLOBAL_CUSTOM
|
||||
/*Header to include for the custom 'lv_global' function"*/
|
||||
#define LV_GLOBAL_CUSTOM_INCLUDE <stdint.h>
|
||||
#endif
|
||||
|
||||
/*Default cache size in bytes.
|
||||
*Used by image decoders such as `lv_lodepng` to keep the decoded image in the memory.
|
||||
*If size is not set to 0, the decoder will fail to decode when the cache is full.
|
||||
*If size is 0, the cache function is not enabled and the decoded mem will be released immediately after use.*/
|
||||
#define LV_CACHE_DEF_SIZE 0
|
||||
|
||||
/*Default number of image header cache entries. The cache is used to store the headers of images
|
||||
*The main logic is like `LV_CACHE_DEF_SIZE` but for image headers.*/
|
||||
#define LV_IMAGE_HEADER_CACHE_DEF_CNT 0
|
||||
|
||||
/*Number of stops allowed per gradient. Increase this to allow more stops.
|
||||
*This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/
|
||||
#define LV_GRADIENT_MAX_STOPS 2
|
||||
|
||||
/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.
|
||||
* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
|
||||
#define LV_COLOR_MIX_ROUND_OFS 0
|
||||
|
||||
/* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */
|
||||
#define LV_OBJ_STYLE_CACHE 0
|
||||
|
||||
/* Add `id` field to `lv_obj_t` */
|
||||
#define LV_USE_OBJ_ID 0
|
||||
|
||||
/* Use lvgl builtin method for obj ID */
|
||||
#define LV_USE_OBJ_ID_BUILTIN 0
|
||||
|
||||
/*Use obj property set/get API*/
|
||||
#define LV_USE_OBJ_PROPERTY 0
|
||||
|
||||
/* VG-Lite Simulator */
|
||||
/*Requires: LV_USE_THORVG_INTERNAL or LV_USE_THORVG_EXTERNAL */
|
||||
#define LV_USE_VG_LITE_THORVG 0
|
||||
|
||||
#if LV_USE_VG_LITE_THORVG
|
||||
|
||||
/*Enable LVGL's blend mode support*/
|
||||
#define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT 0
|
||||
|
||||
/*Enable YUV color format support*/
|
||||
#define LV_VG_LITE_THORVG_YUV_SUPPORT 0
|
||||
|
||||
/*Enable 16 pixels alignment*/
|
||||
#define LV_VG_LITE_THORVG_16PIXELS_ALIGN 1
|
||||
|
||||
/*Buffer address alignment*/
|
||||
#define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN 64
|
||||
|
||||
/*Enable multi-thread render*/
|
||||
#define LV_VG_LITE_THORVG_THREAD_RENDER 0
|
||||
|
||||
#endif
|
||||
|
||||
/*=====================
|
||||
* COMPILER SETTINGS
|
||||
*====================*/
|
||||
|
||||
/*For big endian systems set to 1*/
|
||||
#define LV_BIG_ENDIAN_SYSTEM 0
|
||||
|
||||
/*Define a custom attribute to `lv_tick_inc` function*/
|
||||
#define LV_ATTRIBUTE_TICK_INC
|
||||
|
||||
/*Define a custom attribute to `lv_timer_handler` function*/
|
||||
#define LV_ATTRIBUTE_TIMER_HANDLER
|
||||
|
||||
/*Define a custom attribute to `lv_display_flush_ready` function*/
|
||||
#define LV_ATTRIBUTE_FLUSH_READY
|
||||
|
||||
/*Required alignment size for buffers*/
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1
|
||||
|
||||
/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default).
|
||||
* E.g. __attribute__((aligned(4)))*/
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||
|
||||
/*Attribute to mark large constant arrays for example font's bitmaps*/
|
||||
#define LV_ATTRIBUTE_LARGE_CONST
|
||||
|
||||
/*Compiler prefix for a big array declaration in RAM*/
|
||||
#define LV_ATTRIBUTE_LARGE_RAM_ARRAY
|
||||
|
||||
/*Place performance critical functions into a faster memory (e.g RAM)*/
|
||||
#define LV_ATTRIBUTE_FAST_MEM
|
||||
|
||||
/*Export integer constant to binding. This macro is used with constants in the form of LV_<CONST> that
|
||||
*should also appear on LVGL binding API such as Micropython.*/
|
||||
#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/
|
||||
|
||||
/*Prefix all global extern data with this*/
|
||||
#define LV_ATTRIBUTE_EXTERN_DATA
|
||||
|
||||
/* Use `float` as `lv_value_precise_t` */
|
||||
#define LV_USE_FLOAT 0
|
||||
|
||||
/*==================
|
||||
* FONT USAGE
|
||||
*===================*/
|
||||
|
||||
/*Montserrat fonts with ASCII range and some symbols using bpp = 4
|
||||
*https://fonts.google.com/specimen/Montserrat*/
|
||||
#define LV_FONT_MONTSERRAT_8 0
|
||||
#define LV_FONT_MONTSERRAT_10 0
|
||||
#define LV_FONT_MONTSERRAT_12 0
|
||||
#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
|
||||
#define LV_FONT_MONTSERRAT_24 0
|
||||
#define LV_FONT_MONTSERRAT_26 0
|
||||
#define LV_FONT_MONTSERRAT_28 0
|
||||
#define LV_FONT_MONTSERRAT_30 0
|
||||
#define LV_FONT_MONTSERRAT_32 0
|
||||
#define LV_FONT_MONTSERRAT_34 0
|
||||
#define LV_FONT_MONTSERRAT_36 0
|
||||
#define LV_FONT_MONTSERRAT_38 0
|
||||
#define LV_FONT_MONTSERRAT_40 0
|
||||
#define LV_FONT_MONTSERRAT_42 0
|
||||
#define LV_FONT_MONTSERRAT_44 0
|
||||
#define LV_FONT_MONTSERRAT_46 0
|
||||
#define LV_FONT_MONTSERRAT_48 0
|
||||
|
||||
/*Demonstrate special features*/
|
||||
#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/
|
||||
#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/
|
||||
#define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/
|
||||
|
||||
/*Pixel perfect monospace fonts*/
|
||||
#define LV_FONT_UNSCII_8 0
|
||||
#define LV_FONT_UNSCII_16 0
|
||||
|
||||
/*Optionally declare custom fonts here.
|
||||
*You can use these fonts as default font too and they will be available globally.
|
||||
*E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/
|
||||
#define LV_FONT_CUSTOM_DECLARE
|
||||
|
||||
/*Always set a default font*/
|
||||
#define LV_FONT_DEFAULT &lv_font_montserrat_14
|
||||
|
||||
/*Enable handling large font and/or fonts with a lot of characters.
|
||||
*The limit depends on the font size, font face and bpp.
|
||||
*Compiler error will be triggered if a font needs it.*/
|
||||
#define LV_FONT_FMT_TXT_LARGE 0
|
||||
|
||||
/*Enables/disables support for compressed fonts.*/
|
||||
#define LV_USE_FONT_COMPRESSED 0
|
||||
|
||||
/*Enable drawing placeholders when glyph dsc is not found*/
|
||||
#define LV_USE_FONT_PLACEHOLDER 1
|
||||
|
||||
/*=================
|
||||
* TEXT SETTINGS
|
||||
*=================*/
|
||||
|
||||
/**
|
||||
* Select a character encoding for strings.
|
||||
* Your IDE or editor should have the same character encoding
|
||||
* - LV_TXT_ENC_UTF8
|
||||
* - LV_TXT_ENC_ASCII
|
||||
*/
|
||||
#define LV_TXT_ENC LV_TXT_ENC_UTF8
|
||||
|
||||
/*Can break (wrap) texts on these chars*/
|
||||
#define LV_TXT_BREAK_CHARS " ,.;:-_)]}"
|
||||
|
||||
/*If a word is at least this long, will break wherever "prettiest"
|
||||
*To disable, set to a value <= 0*/
|
||||
#define LV_TXT_LINE_BREAK_LONG_LEN 0
|
||||
|
||||
/*Minimum number of characters in a long word to put on a line before a break.
|
||||
*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
|
||||
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3
|
||||
|
||||
/*Minimum number of characters in a long word to put on a line after a break.
|
||||
*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
|
||||
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3
|
||||
|
||||
/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts.
|
||||
*The direction will be processed according to the Unicode Bidirectional Algorithm:
|
||||
*https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/
|
||||
#define LV_USE_BIDI 0
|
||||
#if LV_USE_BIDI
|
||||
/*Set the default direction. Supported values:
|
||||
*`LV_BASE_DIR_LTR` Left-to-Right
|
||||
*`LV_BASE_DIR_RTL` Right-to-Left
|
||||
*`LV_BASE_DIR_AUTO` detect texts base direction*/
|
||||
#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO
|
||||
#endif
|
||||
|
||||
/*Enable Arabic/Persian processing
|
||||
*In these languages characters should be replaced with an other form based on their position in the text*/
|
||||
#define LV_USE_ARABIC_PERSIAN_CHARS 0
|
||||
|
||||
/*==================
|
||||
* WIDGETS
|
||||
*================*/
|
||||
|
||||
/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/
|
||||
|
||||
#define LV_WIDGETS_HAS_DEFAULT_VALUE 1
|
||||
|
||||
#define LV_USE_ANIMIMG 1
|
||||
|
||||
#define LV_USE_ARC 1
|
||||
|
||||
#define LV_USE_BAR 1
|
||||
|
||||
#define LV_USE_BUTTON 1
|
||||
|
||||
#define LV_USE_BUTTONMATRIX 1
|
||||
|
||||
#define LV_USE_CALENDAR 1
|
||||
#if LV_USE_CALENDAR
|
||||
#define LV_CALENDAR_WEEK_STARTS_MONDAY 0
|
||||
#if LV_CALENDAR_WEEK_STARTS_MONDAY
|
||||
#define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"}
|
||||
#else
|
||||
#define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}
|
||||
#endif
|
||||
|
||||
#define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
|
||||
#define LV_USE_CALENDAR_HEADER_ARROW 1
|
||||
#define LV_USE_CALENDAR_HEADER_DROPDOWN 1
|
||||
#endif /*LV_USE_CALENDAR*/
|
||||
|
||||
#define LV_USE_CANVAS 1
|
||||
|
||||
#define LV_USE_CHART 1
|
||||
|
||||
#define LV_USE_CHECKBOX 1
|
||||
|
||||
#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_IMAGE 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_IMAGEBUTTON 1
|
||||
|
||||
#define LV_USE_KEYBOARD 1
|
||||
|
||||
#define LV_USE_LABEL 1
|
||||
#if LV_USE_LABEL
|
||||
#define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/
|
||||
#define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/
|
||||
#define LV_LABEL_WAIT_CHAR_COUNT 3 /*The count of wait chart*/
|
||||
#endif
|
||||
|
||||
#define LV_USE_LED 1
|
||||
|
||||
#define LV_USE_LINE 1
|
||||
|
||||
#define LV_USE_LIST 1
|
||||
|
||||
#define LV_USE_MENU 1
|
||||
|
||||
#define LV_USE_MSGBOX 1
|
||||
|
||||
#define LV_USE_ROLLER 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_SCALE 1
|
||||
|
||||
#define LV_USE_SLIDER 1 /*Requires: lv_bar*/
|
||||
|
||||
#define LV_USE_SPAN 1
|
||||
#if LV_USE_SPAN
|
||||
/*A line text can contain maximum num of span descriptor */
|
||||
#define LV_SPAN_SNIPPET_STACK_SIZE 64
|
||||
#endif
|
||||
|
||||
#define LV_USE_SPINBOX 1
|
||||
|
||||
#define LV_USE_SPINNER 1
|
||||
|
||||
#define LV_USE_SWITCH 1
|
||||
|
||||
#define LV_USE_TEXTAREA 1 /*Requires: lv_label*/
|
||||
#if LV_USE_TEXTAREA != 0
|
||||
#define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/
|
||||
#endif
|
||||
|
||||
#define LV_USE_TABLE 1
|
||||
|
||||
#define LV_USE_TABVIEW 1
|
||||
|
||||
#define LV_USE_TILEVIEW 1
|
||||
|
||||
#define LV_USE_WIN 1
|
||||
|
||||
/*==================
|
||||
* THEMES
|
||||
*==================*/
|
||||
|
||||
/*A simple, impressive and very complete theme*/
|
||||
#define LV_USE_THEME_DEFAULT 1
|
||||
#if LV_USE_THEME_DEFAULT
|
||||
|
||||
/*0: Light mode; 1: Dark mode*/
|
||||
#define LV_THEME_DEFAULT_DARK 0
|
||||
|
||||
/*1: Enable grow on press*/
|
||||
#define LV_THEME_DEFAULT_GROW 1
|
||||
|
||||
/*Default transition time in [ms]*/
|
||||
#define LV_THEME_DEFAULT_TRANSITION_TIME 80
|
||||
#endif /*LV_USE_THEME_DEFAULT*/
|
||||
|
||||
/*A very simple theme that is a good starting point for a custom theme*/
|
||||
#define LV_USE_THEME_SIMPLE 1
|
||||
|
||||
/*A theme designed for monochrome displays*/
|
||||
#define LV_USE_THEME_MONO 1
|
||||
|
||||
/*==================
|
||||
* LAYOUTS
|
||||
*==================*/
|
||||
|
||||
/*A layout similar to Flexbox in CSS.*/
|
||||
#define LV_USE_FLEX 1
|
||||
|
||||
/*A layout similar to Grid in CSS.*/
|
||||
#define LV_USE_GRID 1
|
||||
|
||||
/*====================
|
||||
* 3RD PARTS LIBRARIES
|
||||
*====================*/
|
||||
|
||||
/*File system interfaces for common APIs */
|
||||
|
||||
/*API for fopen, fread, etc*/
|
||||
#define LV_USE_FS_STDIO 0
|
||||
#if LV_USE_FS_STDIO
|
||||
#define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||
#define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*API for open, read, etc*/
|
||||
#define LV_USE_FS_POSIX 0
|
||||
#if LV_USE_FS_POSIX
|
||||
#define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||
#define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*API for CreateFile, ReadFile, etc*/
|
||||
#define LV_USE_FS_WIN32 0
|
||||
#if LV_USE_FS_WIN32
|
||||
#define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||
#define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/
|
||||
#define LV_USE_FS_FATFS 0
|
||||
#if LV_USE_FS_FATFS
|
||||
#define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*API for memory-mapped file access. */
|
||||
#define LV_USE_FS_MEMFS 0
|
||||
#if LV_USE_FS_MEMFS
|
||||
#define LV_FS_MEMFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#endif
|
||||
|
||||
/*API for LittleFs. */
|
||||
#define LV_USE_FS_LITTLEFS 0
|
||||
#if LV_USE_FS_LITTLEFS
|
||||
#define LV_FS_LITTLEFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#endif
|
||||
|
||||
/*LODEPNG decoder library*/
|
||||
#define LV_USE_LODEPNG 0
|
||||
|
||||
/*PNG decoder(libpng) library*/
|
||||
#define LV_USE_LIBPNG 0
|
||||
|
||||
/*BMP decoder library*/
|
||||
#define LV_USE_BMP 0
|
||||
|
||||
/* JPG + split JPG decoder library.
|
||||
* Split JPG is a custom format optimized for embedded systems. */
|
||||
#define LV_USE_TJPGD 0
|
||||
|
||||
/* libjpeg-turbo decoder library.
|
||||
* Supports complete JPEG specifications and high-performance JPEG decoding. */
|
||||
#define LV_USE_LIBJPEG_TURBO 0
|
||||
|
||||
/*GIF decoder library*/
|
||||
#define LV_USE_GIF 0
|
||||
#if LV_USE_GIF
|
||||
/*GIF decoder accelerate*/
|
||||
#define LV_GIF_CACHE_DECODE_DATA 0
|
||||
#endif
|
||||
|
||||
|
||||
/*Decode bin images to RAM*/
|
||||
#define LV_BIN_DECODER_RAM_LOAD 0
|
||||
|
||||
/*RLE decompress library*/
|
||||
#define LV_USE_RLE 0
|
||||
|
||||
/*QR code library*/
|
||||
#define LV_USE_QRCODE 0
|
||||
|
||||
/*Barcode code library*/
|
||||
#define LV_USE_BARCODE 0
|
||||
|
||||
/*FreeType library*/
|
||||
#define LV_USE_FREETYPE 0
|
||||
#if LV_USE_FREETYPE
|
||||
/*Let FreeType to use LVGL memory and file porting*/
|
||||
#define LV_FREETYPE_USE_LVGL_PORT 0
|
||||
|
||||
/*Cache count of the glyphs in FreeType. It means the number of glyphs that can be cached.
|
||||
*The higher the value, the more memory will be used.*/
|
||||
#define LV_FREETYPE_CACHE_FT_GLYPH_CNT 256
|
||||
#endif
|
||||
|
||||
/* Built-in TTF decoder */
|
||||
#define LV_USE_TINY_TTF 0
|
||||
#if LV_USE_TINY_TTF
|
||||
/* Enable loading TTF data from files */
|
||||
#define LV_TINY_TTF_FILE_SUPPORT 0
|
||||
#endif
|
||||
|
||||
/*Rlottie library*/
|
||||
#define LV_USE_RLOTTIE 0
|
||||
|
||||
/*Enable Vector Graphic APIs*/
|
||||
#define LV_USE_VECTOR_GRAPHIC 0
|
||||
|
||||
/* Enable ThorVG (vector graphics library) from the src/libs folder */
|
||||
#define LV_USE_THORVG_INTERNAL 0
|
||||
|
||||
/* Enable ThorVG by assuming that its installed and linked to the project */
|
||||
#define LV_USE_THORVG_EXTERNAL 0
|
||||
|
||||
/*Use lvgl built-in LZ4 lib*/
|
||||
#define LV_USE_LZ4_INTERNAL 0
|
||||
|
||||
/*Use external LZ4 library*/
|
||||
#define LV_USE_LZ4_EXTERNAL 0
|
||||
|
||||
/*FFmpeg library for image decoding and playing videos
|
||||
*Supports all major image formats so do not enable other image decoder with it*/
|
||||
#define LV_USE_FFMPEG 0
|
||||
#if LV_USE_FFMPEG
|
||||
/*Dump input information to stderr*/
|
||||
#define LV_FFMPEG_DUMP_FORMAT 0
|
||||
#endif
|
||||
|
||||
/*==================
|
||||
* OTHERS
|
||||
*==================*/
|
||||
|
||||
/*1: Enable API to take snapshot for object*/
|
||||
#define LV_USE_SNAPSHOT 0
|
||||
|
||||
/*1: Enable system monitor component*/
|
||||
#define LV_USE_SYSMON 0
|
||||
#if LV_USE_SYSMON
|
||||
/*Get the idle percentage. E.g. uint32_t my_get_idle(void);*/
|
||||
#define LV_SYSMON_GET_IDLE lv_timer_get_idle
|
||||
|
||||
/*1: Show CPU usage and FPS count
|
||||
* Requires `LV_USE_SYSMON = 1`*/
|
||||
#define LV_USE_PERF_MONITOR 0
|
||||
#if LV_USE_PERF_MONITOR
|
||||
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
|
||||
|
||||
/*0: Displays performance data on the screen, 1: Prints performance data using log.*/
|
||||
#define LV_USE_PERF_MONITOR_LOG_MODE 0
|
||||
#endif
|
||||
|
||||
/*1: Show the used memory and the memory fragmentation
|
||||
* Requires `LV_USE_STDLIB_MALLOC = LV_STDLIB_BUILTIN`
|
||||
* Requires `LV_USE_SYSMON = 1`*/
|
||||
#define LV_USE_MEM_MONITOR 0
|
||||
#if LV_USE_MEM_MONITOR
|
||||
#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
|
||||
#endif
|
||||
|
||||
#endif /*LV_USE_SYSMON*/
|
||||
|
||||
/*1: Enable the runtime performance profiler*/
|
||||
#define LV_USE_PROFILER 0
|
||||
#if LV_USE_PROFILER
|
||||
/*1: Enable the built-in profiler*/
|
||||
#define LV_USE_PROFILER_BUILTIN 1
|
||||
#if LV_USE_PROFILER_BUILTIN
|
||||
/*Default profiler trace buffer size*/
|
||||
#define LV_PROFILER_BUILTIN_BUF_SIZE (16 * 1024) /*[bytes]*/
|
||||
#endif
|
||||
|
||||
/*Header to include for the profiler*/
|
||||
#define LV_PROFILER_INCLUDE "lvgl/src/misc/lv_profiler_builtin.h"
|
||||
|
||||
/*Profiler start point function*/
|
||||
#define LV_PROFILER_BEGIN LV_PROFILER_BUILTIN_BEGIN
|
||||
|
||||
/*Profiler end point function*/
|
||||
#define LV_PROFILER_END LV_PROFILER_BUILTIN_END
|
||||
|
||||
/*Profiler start point function with custom tag*/
|
||||
#define LV_PROFILER_BEGIN_TAG LV_PROFILER_BUILTIN_BEGIN_TAG
|
||||
|
||||
/*Profiler end point function with custom tag*/
|
||||
#define LV_PROFILER_END_TAG LV_PROFILER_BUILTIN_END_TAG
|
||||
#endif
|
||||
|
||||
/*1: Enable Monkey test*/
|
||||
#define LV_USE_MONKEY 0
|
||||
|
||||
/*1: Enable grid navigation*/
|
||||
#define LV_USE_GRIDNAV 0
|
||||
|
||||
/*1: Enable lv_obj fragment*/
|
||||
#define LV_USE_FRAGMENT 0
|
||||
|
||||
/*1: Support using images as font in label or span widgets */
|
||||
#define LV_USE_IMGFONT 0
|
||||
|
||||
/*1: Enable an observer pattern implementation*/
|
||||
#define LV_USE_OBSERVER 1
|
||||
|
||||
/*1: Enable Pinyin input method*/
|
||||
/*Requires: lv_keyboard*/
|
||||
#define LV_USE_IME_PINYIN 0
|
||||
#if LV_USE_IME_PINYIN
|
||||
/*1: Use default thesaurus*/
|
||||
/*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/
|
||||
#define LV_IME_PINYIN_USE_DEFAULT_DICT 1
|
||||
/*Set the maximum number of candidate panels that can be displayed*/
|
||||
/*This needs to be adjusted according to the size of the screen*/
|
||||
#define LV_IME_PINYIN_CAND_TEXT_NUM 6
|
||||
|
||||
/*Use 9 key input(k9)*/
|
||||
#define LV_IME_PINYIN_USE_K9_MODE 1
|
||||
#if LV_IME_PINYIN_USE_K9_MODE == 1
|
||||
#define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3
|
||||
#endif /*LV_IME_PINYIN_USE_K9_MODE*/
|
||||
#endif
|
||||
|
||||
/*1: Enable file explorer*/
|
||||
/*Requires: lv_table*/
|
||||
#define LV_USE_FILE_EXPLORER 0
|
||||
#if LV_USE_FILE_EXPLORER
|
||||
/*Maximum length of path*/
|
||||
#define LV_FILE_EXPLORER_PATH_MAX_LEN (128)
|
||||
/*Quick access bar, 1:use, 0:not use*/
|
||||
/*Requires: lv_list*/
|
||||
#define LV_FILE_EXPLORER_QUICK_ACCESS 1
|
||||
#endif
|
||||
|
||||
/*==================
|
||||
* DEVICES
|
||||
*==================*/
|
||||
|
||||
/*Use SDL to open window on PC and handle mouse and keyboard*/
|
||||
#define LV_USE_SDL 0
|
||||
#if LV_USE_SDL
|
||||
#define LV_SDL_INCLUDE_PATH <SDL2/SDL.h>
|
||||
#define LV_SDL_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT /*LV_DISPLAY_RENDER_MODE_DIRECT is recommended for best performance*/
|
||||
#define LV_SDL_BUF_COUNT 1 /*1 or 2*/
|
||||
#define LV_SDL_FULLSCREEN 0 /*1: Make the window full screen by default*/
|
||||
#define LV_SDL_DIRECT_EXIT 1 /*1: Exit the application when all SDL windows are closed*/
|
||||
#define LV_SDL_MOUSEWHEEL_MODE LV_SDL_MOUSEWHEEL_MODE_ENCODER /*LV_SDL_MOUSEWHEEL_MODE_ENCODER/CROWN*/
|
||||
#endif
|
||||
|
||||
/*Use X11 to open window on Linux desktop and handle mouse and keyboard*/
|
||||
#define LV_USE_X11 0
|
||||
#if LV_USE_X11
|
||||
#define LV_X11_DIRECT_EXIT 1 /*Exit the application when all X11 windows have been closed*/
|
||||
#define LV_X11_DOUBLE_BUFFER 1 /*Use double buffers for endering*/
|
||||
/*select only 1 of the following render modes (LV_X11_RENDER_MODE_PARTIAL preferred!)*/
|
||||
#define LV_X11_RENDER_MODE_PARTIAL 1 /*Partial render mode (preferred)*/
|
||||
#define LV_X11_RENDER_MODE_DIRECT 0 /*direct render mode*/
|
||||
#define LV_X11_RENDER_MODE_FULL 0 /*Full render mode*/
|
||||
#endif
|
||||
|
||||
/*Driver for /dev/fb*/
|
||||
#define LV_USE_LINUX_FBDEV 0
|
||||
#if LV_USE_LINUX_FBDEV
|
||||
#define LV_LINUX_FBDEV_BSD 0
|
||||
#define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL
|
||||
#define LV_LINUX_FBDEV_BUFFER_COUNT 0
|
||||
#define LV_LINUX_FBDEV_BUFFER_SIZE 60
|
||||
#endif
|
||||
|
||||
/*Use Nuttx to open window and handle touchscreen*/
|
||||
#define LV_USE_NUTTX 0
|
||||
|
||||
#if LV_USE_NUTTX
|
||||
#define LV_USE_NUTTX_LIBUV 0
|
||||
|
||||
/*Use Nuttx custom init API to open window and handle touchscreen*/
|
||||
#define LV_USE_NUTTX_CUSTOM_INIT 0
|
||||
|
||||
/*Driver for /dev/lcd*/
|
||||
#define LV_USE_NUTTX_LCD 0
|
||||
#if LV_USE_NUTTX_LCD
|
||||
#define LV_NUTTX_LCD_BUFFER_COUNT 0
|
||||
#define LV_NUTTX_LCD_BUFFER_SIZE 60
|
||||
#endif
|
||||
|
||||
/*Driver for /dev/input*/
|
||||
#define LV_USE_NUTTX_TOUCHSCREEN 0
|
||||
|
||||
#endif
|
||||
|
||||
/*Driver for /dev/dri/card*/
|
||||
#define LV_USE_LINUX_DRM 0
|
||||
|
||||
/*Interface for TFT_eSPI*/
|
||||
#define LV_USE_TFT_ESPI 0
|
||||
|
||||
/*Driver for evdev input devices*/
|
||||
#define LV_USE_EVDEV 0
|
||||
|
||||
/*Driver for libinput input devices*/
|
||||
#define LV_USE_LIBINPUT 0
|
||||
|
||||
#if LV_USE_LIBINPUT
|
||||
#define LV_LIBINPUT_BSD 0
|
||||
|
||||
/*Full keyboard support*/
|
||||
#define LV_LIBINPUT_XKB 0
|
||||
#if LV_LIBINPUT_XKB
|
||||
/*"setxkbmap -query" can help find the right values for your keyboard*/
|
||||
#define LV_LIBINPUT_XKB_KEY_MAP { .rules = NULL, .model = "pc101", .layout = "us", .variant = NULL, .options = NULL }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*Drivers for LCD devices connected via SPI/parallel port*/
|
||||
#define LV_USE_ST7735 0
|
||||
#define LV_USE_ST7789 0
|
||||
#define LV_USE_ST7796 0
|
||||
#define LV_USE_ILI9341 0
|
||||
|
||||
#define LV_USE_GENERIC_MIPI (LV_USE_ST7735 | LV_USE_ST7789 | LV_USE_ST7796 | LV_USE_ILI9341)
|
||||
|
||||
/* LVGL Windows backend */
|
||||
#define LV_USE_WINDOWS 0
|
||||
|
||||
/*==================
|
||||
* EXAMPLES
|
||||
*==================*/
|
||||
|
||||
/*Enable the examples to be built with the library*/
|
||||
#define LV_BUILD_EXAMPLES 1
|
||||
|
||||
/*===================
|
||||
* DEMO USAGE
|
||||
====================*/
|
||||
|
||||
/*Show some widget. It might be required to increase `LV_MEM_SIZE` */
|
||||
#define LV_USE_DEMO_WIDGETS 0
|
||||
|
||||
/*Demonstrate the usage of encoder and keyboard*/
|
||||
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0
|
||||
|
||||
/*Benchmark your system*/
|
||||
#define LV_USE_DEMO_BENCHMARK 0
|
||||
|
||||
/*Render test for each primitives. Requires at least 480x272 display*/
|
||||
#define LV_USE_DEMO_RENDER 0
|
||||
|
||||
/*Stress test for LVGL*/
|
||||
#define LV_USE_DEMO_STRESS 0
|
||||
|
||||
/*Music player demo*/
|
||||
#define LV_USE_DEMO_MUSIC 0
|
||||
#if LV_USE_DEMO_MUSIC
|
||||
#define LV_DEMO_MUSIC_SQUARE 0
|
||||
#define LV_DEMO_MUSIC_LANDSCAPE 0
|
||||
#define LV_DEMO_MUSIC_ROUND 0
|
||||
#define LV_DEMO_MUSIC_LARGE 0
|
||||
#define LV_DEMO_MUSIC_AUTO_PLAY 0
|
||||
#endif
|
||||
|
||||
/*Flex layout demo*/
|
||||
#define LV_USE_DEMO_FLEX_LAYOUT 0
|
||||
|
||||
/*Smart-phone like multi-language demo*/
|
||||
#define LV_USE_DEMO_MULTILANG 0
|
||||
|
||||
/*Widget transformation demo*/
|
||||
#define LV_USE_DEMO_TRANSFORM 0
|
||||
|
||||
/*Demonstrate scroll settings*/
|
||||
#define LV_USE_DEMO_SCROLL 0
|
||||
|
||||
/*Vector graphic demo*/
|
||||
#define LV_USE_DEMO_VECTOR_GRAPHIC 0
|
||||
/*--END OF LV_CONF_H--*/
|
||||
|
||||
#endif /*LV_CONF_H*/
|
||||
|
||||
#endif /*End of "Content enable"*/
|
||||
190
libraries/lvgl/lvgl.h
Normal file
190
libraries/lvgl/lvgl.h
Normal file
@ -0,0 +1,190 @@
|
||||
/**
|
||||
* @file lvgl.h
|
||||
* Include all LVGL related headers
|
||||
*/
|
||||
|
||||
#ifndef LVGL_H
|
||||
#define LVGL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************
|
||||
* CURRENT VERSION OF LVGL
|
||||
***************************/
|
||||
#define LVGL_VERSION_MAJOR 9
|
||||
#define LVGL_VERSION_MINOR 1
|
||||
#define LVGL_VERSION_PATCH 0
|
||||
#define LVGL_VERSION_INFO ""
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "src/lv_init.h"
|
||||
|
||||
#include "src/stdlib/lv_mem.h"
|
||||
#include "src/stdlib/lv_string.h"
|
||||
#include "src/stdlib/lv_sprintf.h"
|
||||
|
||||
#include "src/misc/lv_log.h"
|
||||
#include "src/misc/lv_timer.h"
|
||||
#include "src/misc/lv_math.h"
|
||||
#include "src/misc/lv_array.h"
|
||||
#include "src/misc/lv_async.h"
|
||||
#include "src/misc/lv_anim_timeline.h"
|
||||
#include "src/misc/lv_profiler_builtin.h"
|
||||
#include "src/misc/lv_rb.h"
|
||||
|
||||
#include "src/tick/lv_tick.h"
|
||||
|
||||
#include "src/core/lv_obj.h"
|
||||
#include "src/core/lv_group.h"
|
||||
#include "src/indev/lv_indev.h"
|
||||
#include "src/core/lv_refr.h"
|
||||
#include "src/display/lv_display.h"
|
||||
|
||||
#include "src/font/lv_font.h"
|
||||
#include "src/font/lv_binfont_loader.h"
|
||||
#include "src/font/lv_font_fmt_txt.h"
|
||||
|
||||
#include "src/widgets/animimage/lv_animimage.h"
|
||||
#include "src/widgets/arc/lv_arc.h"
|
||||
#include "src/widgets/bar/lv_bar.h"
|
||||
#include "src/widgets/button/lv_button.h"
|
||||
#include "src/widgets/buttonmatrix/lv_buttonmatrix.h"
|
||||
#include "src/widgets/calendar/lv_calendar.h"
|
||||
#include "src/widgets/canvas/lv_canvas.h"
|
||||
#include "src/widgets/chart/lv_chart.h"
|
||||
#include "src/widgets/checkbox/lv_checkbox.h"
|
||||
#include "src/widgets/dropdown/lv_dropdown.h"
|
||||
#include "src/widgets/image/lv_image.h"
|
||||
#include "src/widgets/imagebutton/lv_imagebutton.h"
|
||||
#include "src/widgets/keyboard/lv_keyboard.h"
|
||||
#include "src/widgets/label/lv_label.h"
|
||||
#include "src/widgets/led/lv_led.h"
|
||||
#include "src/widgets/line/lv_line.h"
|
||||
#include "src/widgets/list/lv_list.h"
|
||||
#include "src/widgets/menu/lv_menu.h"
|
||||
#include "src/widgets/msgbox/lv_msgbox.h"
|
||||
#include "src/widgets/roller/lv_roller.h"
|
||||
#include "src/widgets/scale/lv_scale.h"
|
||||
#include "src/widgets/slider/lv_slider.h"
|
||||
#include "src/widgets/span/lv_span.h"
|
||||
#include "src/widgets/spinbox/lv_spinbox.h"
|
||||
#include "src/widgets/spinner/lv_spinner.h"
|
||||
#include "src/widgets/switch/lv_switch.h"
|
||||
#include "src/widgets/table/lv_table.h"
|
||||
#include "src/widgets/tabview/lv_tabview.h"
|
||||
#include "src/widgets/textarea/lv_textarea.h"
|
||||
#include "src/widgets/tileview/lv_tileview.h"
|
||||
#include "src/widgets/win/lv_win.h"
|
||||
|
||||
#include "src/others/snapshot/lv_snapshot.h"
|
||||
#include "src/others/sysmon/lv_sysmon.h"
|
||||
#include "src/others/monkey/lv_monkey.h"
|
||||
#include "src/others/gridnav/lv_gridnav.h"
|
||||
#include "src/others/fragment/lv_fragment.h"
|
||||
#include "src/others/imgfont/lv_imgfont.h"
|
||||
#include "src/others/observer/lv_observer.h"
|
||||
#include "src/others/ime/lv_ime_pinyin.h"
|
||||
#include "src/others/file_explorer/lv_file_explorer.h"
|
||||
|
||||
#include "src/libs/barcode/lv_barcode.h"
|
||||
#include "src/libs/bin_decoder/lv_bin_decoder.h"
|
||||
#include "src/libs/bmp/lv_bmp.h"
|
||||
#include "src/libs/rle/lv_rle.h"
|
||||
#include "src/libs/fsdrv/lv_fsdrv.h"
|
||||
#include "src/libs/lodepng/lv_lodepng.h"
|
||||
#include "src/libs/libpng/lv_libpng.h"
|
||||
#include "src/libs/gif/lv_gif.h"
|
||||
#include "src/libs/qrcode/lv_qrcode.h"
|
||||
#include "src/libs/tjpgd/lv_tjpgd.h"
|
||||
#include "src/libs/libjpeg_turbo/lv_libjpeg_turbo.h"
|
||||
#include "src/libs/freetype/lv_freetype.h"
|
||||
#include "src/libs/rlottie/lv_rlottie.h"
|
||||
#include "src/libs/ffmpeg/lv_ffmpeg.h"
|
||||
#include "src/libs/tiny_ttf/lv_tiny_ttf.h"
|
||||
|
||||
#include "src/layouts/lv_layout.h"
|
||||
|
||||
#include "src/draw/lv_draw.h"
|
||||
#include "src/draw/lv_draw_buf.h"
|
||||
#include "src/draw/lv_draw_vector.h"
|
||||
|
||||
#include "src/themes/lv_theme.h"
|
||||
|
||||
#include "src/drivers/lv_drivers.h"
|
||||
|
||||
#include "src/lv_api_map_v8.h"
|
||||
#include "src/lv_api_map_v9_0.h"
|
||||
|
||||
#include "src/core/lv_global.h"
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/** Gives 1 if the x.y.z version is supported in the current version
|
||||
* Usage:
|
||||
*
|
||||
* - Require v6
|
||||
* #if LV_VERSION_CHECK(6,0,0)
|
||||
* new_func_in_v6();
|
||||
* #endif
|
||||
*
|
||||
*
|
||||
* - Require at least v5.3
|
||||
* #if LV_VERSION_CHECK(5,3,0)
|
||||
* new_feature_from_v5_3();
|
||||
* #endif
|
||||
*
|
||||
*
|
||||
* - Require v5.3.2 bugfixes
|
||||
* #if LV_VERSION_CHECK(5,3,2)
|
||||
* bugfix_in_v5_3_2();
|
||||
* #endif
|
||||
*
|
||||
*/
|
||||
#define LV_VERSION_CHECK(x,y,z) (x == LVGL_VERSION_MAJOR && (y < LVGL_VERSION_MINOR || (y == LVGL_VERSION_MINOR && z <= LVGL_VERSION_PATCH)))
|
||||
|
||||
/**
|
||||
* Wrapper functions for VERSION macros
|
||||
*/
|
||||
|
||||
static inline int lv_version_major(void)
|
||||
{
|
||||
return LVGL_VERSION_MAJOR;
|
||||
}
|
||||
|
||||
static inline int lv_version_minor(void)
|
||||
{
|
||||
return LVGL_VERSION_MINOR;
|
||||
}
|
||||
|
||||
static inline int lv_version_patch(void)
|
||||
{
|
||||
return LVGL_VERSION_PATCH;
|
||||
}
|
||||
|
||||
static inline const char * lv_version_info(void)
|
||||
{
|
||||
return LVGL_VERSION_INFO;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LVGL_H*/
|
||||
12
libraries/lvgl/lvgl.mk
Normal file
12
libraries/lvgl/lvgl.mk
Normal file
@ -0,0 +1,12 @@
|
||||
LVGL_PATH ?= ${shell pwd}/lvgl
|
||||
|
||||
ASRCS += $(shell find $(LVGL_PATH)/src -type f -name '*.S')
|
||||
CSRCS += $(shell find $(LVGL_PATH)/src -type f -name '*.c')
|
||||
CSRCS += $(shell find $(LVGL_PATH)/demos -type f -name '*.c')
|
||||
CSRCS += $(shell find $(LVGL_PATH)/examples -type f -name '*.c')
|
||||
CXXEXT := .cpp
|
||||
CXXSRCS += $(shell find $(LVGL_PATH)/src -type f -name '*${CXXEXT}')
|
||||
|
||||
AFLAGS += "-I$(LVGL_PATH)"
|
||||
CFLAGS += "-I$(LVGL_PATH)"
|
||||
CXXFLAGS += "-I$(LVGL_PATH)"
|
||||
10
libraries/lvgl/lvgl.pc.in
Normal file
10
libraries/lvgl/lvgl.pc.in
Normal file
@ -0,0 +1,10 @@
|
||||
prefix="@CMAKE_INSTALL_PREFIX@"
|
||||
includedir="${prefix}/@INC_INSTALL_DIR@"
|
||||
libdir=${prefix}/lib
|
||||
|
||||
Name: lvgl
|
||||
Description: Light and Versatile Graphics Library
|
||||
URL: https://lvgl.io/
|
||||
Version: 9.1.0
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -llvgl
|
||||
244
libraries/lvgl/src/core/lv_global.h
Normal file
244
libraries/lvgl/src/core/lv_global.h
Normal file
@ -0,0 +1,244 @@
|
||||
/**
|
||||
* @file lv_global.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_GLOBAL_H
|
||||
#define LV_GLOBAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../draw/lv_draw.h"
|
||||
#if LV_USE_DRAW_SW
|
||||
#include "../draw/sw/lv_draw_sw.h"
|
||||
#endif
|
||||
#include "../misc/lv_anim.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_color_op.h"
|
||||
#include "../misc/lv_ll.h"
|
||||
#include "../misc/lv_log.h"
|
||||
#include "../misc/lv_style.h"
|
||||
#include "../misc/lv_timer.h"
|
||||
#include "../others/sysmon/lv_sysmon.h"
|
||||
#include "../stdlib/builtin/lv_tlsf.h"
|
||||
|
||||
#if LV_USE_FONT_COMPRESSED
|
||||
#include "../font/lv_font_fmt_txt.h"
|
||||
#endif
|
||||
|
||||
#include "../tick/lv_tick.h"
|
||||
#include "../layouts/lv_layout.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define ZERO_MEM_SENTINEL 0xa1b2c3d4
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
#if LV_USE_SPAN != 0
|
||||
struct _snippet_stack;
|
||||
#endif
|
||||
|
||||
#if LV_USE_FREETYPE
|
||||
struct _lv_freetype_context_t;
|
||||
#endif
|
||||
|
||||
#if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN
|
||||
struct _lv_profiler_builtin_ctx_t;
|
||||
#endif
|
||||
|
||||
#if LV_USE_NUTTX
|
||||
struct _lv_nuttx_ctx_t;
|
||||
#endif
|
||||
|
||||
typedef struct _lv_global_t {
|
||||
bool inited;
|
||||
bool deinit_in_progress; /**< Can be used e.g. in the LV_EVENT_DELETE to deinit the drivers too */
|
||||
|
||||
lv_ll_t disp_ll;
|
||||
lv_display_t * disp_refresh;
|
||||
lv_display_t * disp_default;
|
||||
|
||||
lv_ll_t style_trans_ll;
|
||||
bool style_refresh;
|
||||
uint32_t style_custom_table_size;
|
||||
uint32_t style_last_custom_prop_id;
|
||||
uint8_t * style_custom_prop_flag_lookup_table;
|
||||
|
||||
lv_ll_t group_ll;
|
||||
lv_group_t * group_default;
|
||||
|
||||
lv_ll_t indev_ll;
|
||||
lv_indev_t * indev_active;
|
||||
lv_obj_t * indev_obj_active;
|
||||
|
||||
uint32_t layout_count;
|
||||
lv_layout_dsc_t * layout_list;
|
||||
bool layout_update_mutex;
|
||||
|
||||
uint32_t memory_zero;
|
||||
uint32_t math_rand_seed;
|
||||
|
||||
lv_event_t * event_header;
|
||||
uint32_t event_last_register_id;
|
||||
|
||||
lv_timer_state_t timer_state;
|
||||
lv_anim_state_t anim_state;
|
||||
lv_tick_state_t tick_state;
|
||||
|
||||
lv_draw_buf_handlers_t draw_buf_handlers;
|
||||
|
||||
lv_ll_t img_decoder_ll;
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
lv_cache_t * img_cache;
|
||||
#endif
|
||||
|
||||
#if LV_IMAGE_HEADER_CACHE_DEF_CNT > 0
|
||||
lv_cache_t * img_header_cache;
|
||||
#endif
|
||||
|
||||
lv_draw_global_info_t draw_info;
|
||||
#if defined(LV_DRAW_SW_SHADOW_CACHE_SIZE) && LV_DRAW_SW_SHADOW_CACHE_SIZE > 0
|
||||
lv_draw_sw_shadow_cache_t sw_shadow_cache;
|
||||
#endif
|
||||
#if LV_DRAW_SW_COMPLEX
|
||||
_lv_draw_sw_mask_radius_circle_dsc_arr_t sw_circle_cache;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LOG
|
||||
lv_log_print_g_cb_t custom_log_print_cb;
|
||||
#endif
|
||||
|
||||
#if LV_USE_LOG && LV_LOG_USE_TIMESTAMP
|
||||
uint32_t log_last_log_time;
|
||||
#endif
|
||||
|
||||
#if LV_USE_THEME_SIMPLE
|
||||
void * theme_simple;
|
||||
#endif
|
||||
|
||||
#if LV_USE_THEME_DEFAULT
|
||||
void * theme_default;
|
||||
#endif
|
||||
|
||||
#if LV_USE_THEME_MONO
|
||||
void * theme_mono;
|
||||
#endif
|
||||
|
||||
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
|
||||
lv_tlsf_state_t tlsf_state;
|
||||
#endif
|
||||
|
||||
lv_ll_t fsdrv_ll;
|
||||
#if LV_USE_FS_STDIO != '\0'
|
||||
lv_fs_drv_t stdio_fs_drv;
|
||||
#endif
|
||||
#if LV_USE_FS_POSIX
|
||||
lv_fs_drv_t posix_fs_drv;
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_FATFS
|
||||
lv_fs_drv_t fatfs_fs_drv;
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_WIN32 != '\0'
|
||||
lv_fs_drv_t win32_fs_drv;
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_LITTLEFS
|
||||
lv_fs_drv_t littlefs_fs_drv;
|
||||
#endif
|
||||
|
||||
#if LV_USE_FREETYPE
|
||||
struct _lv_freetype_context_t * ft_context;
|
||||
#endif
|
||||
|
||||
#if LV_USE_TINY_TTF
|
||||
lv_cache_t * tiny_ttf_cache;
|
||||
#endif
|
||||
|
||||
#if LV_USE_FONT_COMPRESSED
|
||||
lv_font_fmt_rle_t font_fmt_rle;
|
||||
#endif
|
||||
|
||||
#if LV_USE_SPAN != 0
|
||||
struct _snippet_stack * span_snippet_stack;
|
||||
#endif
|
||||
|
||||
#if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN
|
||||
struct _lv_profiler_builtin_ctx_t * profiler_context;
|
||||
#endif
|
||||
|
||||
#if LV_USE_FILE_EXPLORER != 0
|
||||
lv_style_t fe_list_button_style;
|
||||
#endif
|
||||
|
||||
#if LV_USE_SYSMON && LV_USE_PERF_MONITOR
|
||||
lv_sysmon_backend_data_t sysmon_perf;
|
||||
#endif
|
||||
|
||||
#if LV_USE_SYSMON && LV_USE_MEM_MONITOR
|
||||
lv_sysmon_backend_data_t sysmon_mem;
|
||||
#endif
|
||||
|
||||
#if LV_USE_IME_PINYIN != 0
|
||||
size_t ime_cand_len;
|
||||
#endif
|
||||
|
||||
#if LV_USE_OBJ_ID_BUILTIN
|
||||
void * objid_array;
|
||||
uint32_t objid_count;
|
||||
#endif
|
||||
|
||||
#if LV_USE_NUTTX
|
||||
struct _lv_nuttx_ctx_t * nuttx_ctx;
|
||||
#endif
|
||||
|
||||
void * user_data;
|
||||
} lv_global_t;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#if LV_ENABLE_GLOBAL_CUSTOM
|
||||
#include LV_GLOBAL_CUSTOM_INCLUDE
|
||||
|
||||
#ifndef LV_GLOBAL_CUSTOM
|
||||
#define LV_GLOBAL_CUSTOM() lv_global_default()
|
||||
#endif
|
||||
#define LV_GLOBAL_DEFAULT() LV_GLOBAL_CUSTOM()
|
||||
#else
|
||||
LV_ATTRIBUTE_EXTERN_DATA extern lv_global_t lv_global;
|
||||
#define LV_GLOBAL_DEFAULT() (&lv_global)
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
#if LV_ENABLE_GLOBAL_CUSTOM
|
||||
/**
|
||||
* Get the default global object for current thread
|
||||
* @return pointer to the default global object
|
||||
*/
|
||||
lv_global_t * lv_global_default(void);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_GLOBAL_H*/
|
||||
536
libraries/lvgl/src/core/lv_group.c
Normal file
536
libraries/lvgl/src/core/lv_group.c
Normal file
@ -0,0 +1,536 @@
|
||||
/**
|
||||
* @file lv_group.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stddef.h>
|
||||
|
||||
#include "lv_group.h"
|
||||
#include "../core/lv_obj.h"
|
||||
#include "../core/lv_global.h"
|
||||
#include "../indev/lv_indev.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define default_group LV_GLOBAL_DEFAULT()->group_default
|
||||
#define group_ll_p &(LV_GLOBAL_DEFAULT()->group_ll)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *),
|
||||
void * (*move)(const lv_ll_t *, const void *));
|
||||
static void lv_group_refocus(lv_group_t * g);
|
||||
static lv_indev_t * get_indev(const lv_group_t * g);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void _lv_group_init(void)
|
||||
{
|
||||
_lv_ll_init(group_ll_p, sizeof(lv_group_t));
|
||||
}
|
||||
|
||||
void _lv_group_deinit(void)
|
||||
{
|
||||
_lv_ll_clear(group_ll_p);
|
||||
}
|
||||
|
||||
lv_group_t * lv_group_create(void)
|
||||
{
|
||||
lv_group_t * group = _lv_ll_ins_head(group_ll_p);
|
||||
LV_ASSERT_MALLOC(group);
|
||||
if(group == NULL) return NULL;
|
||||
_lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *));
|
||||
|
||||
group->obj_focus = NULL;
|
||||
group->frozen = 0;
|
||||
group->focus_cb = NULL;
|
||||
group->edge_cb = NULL;
|
||||
group->editing = 0;
|
||||
group->refocus_policy = LV_GROUP_REFOCUS_POLICY_PREV;
|
||||
group->wrap = 1;
|
||||
group->user_data = NULL;
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
void lv_group_delete(lv_group_t * group)
|
||||
{
|
||||
/*Defocus the currently focused object*/
|
||||
LV_ASSERT_NULL(group);
|
||||
if(group->obj_focus != NULL) {
|
||||
lv_obj_send_event(*group->obj_focus, LV_EVENT_DEFOCUSED, get_indev(group));
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
/*Remove the objects from the group*/
|
||||
lv_obj_t ** obj;
|
||||
_LV_LL_READ(&group->obj_ll, obj) {
|
||||
if((*obj)->spec_attr)(*obj)->spec_attr->group_p = NULL;
|
||||
}
|
||||
|
||||
/*Remove the group from any indev devices */
|
||||
lv_indev_t * indev = lv_indev_get_next(NULL);
|
||||
while(indev) {
|
||||
if(lv_indev_get_group(indev) == group) {
|
||||
lv_indev_set_group(indev, NULL);
|
||||
}
|
||||
indev = lv_indev_get_next(indev);
|
||||
}
|
||||
|
||||
/*If the group is the default group, set the default group as NULL*/
|
||||
if(group == lv_group_get_default()) lv_group_set_default(NULL);
|
||||
|
||||
_lv_ll_clear(&(group->obj_ll));
|
||||
_lv_ll_remove(group_ll_p, group);
|
||||
lv_free(group);
|
||||
}
|
||||
|
||||
void lv_group_set_default(lv_group_t * group)
|
||||
{
|
||||
default_group = group;
|
||||
}
|
||||
|
||||
lv_group_t * lv_group_get_default(void)
|
||||
{
|
||||
return default_group;
|
||||
}
|
||||
|
||||
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
||||
{
|
||||
if(group == NULL) return;
|
||||
|
||||
LV_LOG_TRACE("begin");
|
||||
|
||||
/*Be sure the object is removed from its current group*/
|
||||
lv_group_remove_obj(obj);
|
||||
|
||||
/*Do not add the object twice*/
|
||||
lv_obj_t ** obj_i;
|
||||
_LV_LL_READ(&group->obj_ll, obj_i) {
|
||||
if((*obj_i) == obj) {
|
||||
LV_LOG_INFO("the object is already added to this group");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*If the object is already in a group and focused then refocus it*/
|
||||
lv_group_t * group_cur = lv_obj_get_group(obj);
|
||||
if(group_cur) {
|
||||
if(obj->spec_attr->group_p && *(obj->spec_attr->group_p->obj_focus) == obj) {
|
||||
lv_group_refocus(group_cur);
|
||||
|
||||
LV_LOG_INFO("changing object's group");
|
||||
}
|
||||
}
|
||||
|
||||
if(obj->spec_attr == NULL) lv_obj_allocate_spec_attr(obj);
|
||||
obj->spec_attr->group_p = group;
|
||||
|
||||
lv_obj_t ** next = _lv_ll_ins_tail(&group->obj_ll);
|
||||
LV_ASSERT_MALLOC(next);
|
||||
if(next == NULL) return;
|
||||
*next = obj;
|
||||
|
||||
/*If the head and the tail is equal then there is only one object in the linked list.
|
||||
*In this case automatically activate it*/
|
||||
if(_lv_ll_get_head(&group->obj_ll) == next) {
|
||||
lv_group_refocus(group);
|
||||
}
|
||||
|
||||
LV_LOG_TRACE("finished");
|
||||
}
|
||||
|
||||
void lv_group_swap_obj(lv_obj_t * obj1, lv_obj_t * obj2)
|
||||
{
|
||||
lv_group_t * g1 = lv_obj_get_group(obj1);
|
||||
lv_group_t * g2 = lv_obj_get_group(obj2);
|
||||
if(g1 != g2) return;
|
||||
if(g1 == NULL) return;
|
||||
|
||||
/*Do not add the object twice*/
|
||||
lv_obj_t ** obj_i;
|
||||
_LV_LL_READ(&g1->obj_ll, obj_i) {
|
||||
if((*obj_i) == obj1)(*obj_i) = obj2;
|
||||
else if((*obj_i) == obj2)(*obj_i) = obj1;
|
||||
}
|
||||
|
||||
lv_obj_t * focused = lv_group_get_focused(g1);
|
||||
if(focused == obj1) lv_group_focus_obj(obj2);
|
||||
else if(focused == obj2) lv_group_focus_obj(obj1);
|
||||
|
||||
}
|
||||
|
||||
void lv_group_remove_obj(lv_obj_t * obj)
|
||||
{
|
||||
lv_group_t * g = lv_obj_get_group(obj);
|
||||
if(g == NULL) return;
|
||||
|
||||
LV_LOG_TRACE("begin");
|
||||
|
||||
/*Focus on the next object*/
|
||||
if(g->obj_focus && *g->obj_focus == obj) {
|
||||
if(g->frozen) g->frozen = 0;
|
||||
|
||||
/*If this is the only object in the group then focus to nothing.*/
|
||||
if(_lv_ll_get_head(&g->obj_ll) == g->obj_focus && _lv_ll_get_tail(&g->obj_ll) == g->obj_focus) {
|
||||
lv_obj_send_event(*g->obj_focus, LV_EVENT_DEFOCUSED, get_indev(g));
|
||||
}
|
||||
/*If there more objects in the group then focus to the next/prev object*/
|
||||
else {
|
||||
lv_group_refocus(g);
|
||||
}
|
||||
}
|
||||
|
||||
/*If the focuses object is still the same then it was the only object in the group but it will
|
||||
*be deleted. Set the `obj_focus` to NULL to get back to the initial state of the group with
|
||||
*zero objects*/
|
||||
if(g->obj_focus && *g->obj_focus == obj) {
|
||||
g->obj_focus = NULL;
|
||||
}
|
||||
|
||||
/*Search the object and remove it from its group*/
|
||||
lv_obj_t ** i;
|
||||
_LV_LL_READ(&g->obj_ll, i) {
|
||||
if(*i == obj) {
|
||||
_lv_ll_remove(&g->obj_ll, i);
|
||||
lv_free(i);
|
||||
if(obj->spec_attr) obj->spec_attr->group_p = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
LV_LOG_TRACE("finished");
|
||||
}
|
||||
|
||||
void lv_group_remove_all_objs(lv_group_t * group)
|
||||
{
|
||||
LV_ASSERT_NULL(group);
|
||||
|
||||
/*Defocus the currently focused object*/
|
||||
if(group->obj_focus != NULL) {
|
||||
lv_obj_send_event(*group->obj_focus, LV_EVENT_DEFOCUSED, get_indev(group));
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
group->obj_focus = NULL;
|
||||
}
|
||||
|
||||
/*Remove the objects from the group*/
|
||||
lv_obj_t ** obj;
|
||||
_LV_LL_READ(&group->obj_ll, obj) {
|
||||
if((*obj)->spec_attr)(*obj)->spec_attr->group_p = NULL;
|
||||
}
|
||||
|
||||
_lv_ll_clear(&(group->obj_ll));
|
||||
}
|
||||
|
||||
void lv_group_focus_obj(lv_obj_t * obj)
|
||||
{
|
||||
if(obj == NULL) return;
|
||||
lv_group_t * g = lv_obj_get_group(obj);
|
||||
if(g == NULL) return;
|
||||
|
||||
if(g->frozen != 0) return;
|
||||
|
||||
/*On defocus edit mode must be leaved*/
|
||||
lv_group_set_editing(g, false);
|
||||
|
||||
lv_obj_t ** i;
|
||||
_LV_LL_READ(&g->obj_ll, i) {
|
||||
if(*i == obj) {
|
||||
if(g->obj_focus != NULL && obj != *g->obj_focus) { /*Do not defocus if the same object needs to be focused again*/
|
||||
lv_result_t res = lv_obj_send_event(*g->obj_focus, LV_EVENT_DEFOCUSED, get_indev(g));
|
||||
if(res != LV_RESULT_OK) return;
|
||||
lv_obj_invalidate(*g->obj_focus);
|
||||
}
|
||||
|
||||
g->obj_focus = i;
|
||||
|
||||
if(g->obj_focus != NULL) {
|
||||
if(g->focus_cb) g->focus_cb(g);
|
||||
lv_result_t res = lv_obj_send_event(*g->obj_focus, LV_EVENT_FOCUSED, get_indev(g));
|
||||
if(res != LV_RESULT_OK) return;
|
||||
lv_obj_invalidate(*g->obj_focus);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_group_focus_next(lv_group_t * group)
|
||||
{
|
||||
LV_ASSERT_NULL(group);
|
||||
|
||||
bool focus_changed = focus_next_core(group, _lv_ll_get_head, _lv_ll_get_next);
|
||||
if(group->edge_cb) {
|
||||
if(!focus_changed)
|
||||
group->edge_cb(group, true);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_group_focus_prev(lv_group_t * group)
|
||||
{
|
||||
LV_ASSERT_NULL(group);
|
||||
|
||||
bool focus_changed = focus_next_core(group, _lv_ll_get_tail, _lv_ll_get_prev);
|
||||
if(group->edge_cb) {
|
||||
if(!focus_changed)
|
||||
group->edge_cb(group, false);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_group_focus_freeze(lv_group_t * group, bool en)
|
||||
{
|
||||
LV_ASSERT_NULL(group);
|
||||
|
||||
if(en == false) group->frozen = 0;
|
||||
else group->frozen = 1;
|
||||
}
|
||||
|
||||
lv_result_t lv_group_send_data(lv_group_t * group, uint32_t c)
|
||||
{
|
||||
LV_ASSERT_NULL(group);
|
||||
|
||||
lv_obj_t * act = lv_group_get_focused(group);
|
||||
if(act == NULL) return LV_RESULT_OK;
|
||||
|
||||
if(lv_obj_has_state(act, LV_STATE_DISABLED)) return LV_RESULT_OK;
|
||||
|
||||
return lv_obj_send_event(act, LV_EVENT_KEY, &c);
|
||||
}
|
||||
|
||||
void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb)
|
||||
{
|
||||
if(group == NULL) return;
|
||||
|
||||
group->focus_cb = focus_cb;
|
||||
}
|
||||
|
||||
void lv_group_set_edge_cb(lv_group_t * group, lv_group_edge_cb_t edge_cb)
|
||||
{
|
||||
LV_ASSERT_NULL(group);
|
||||
|
||||
group->edge_cb = edge_cb;
|
||||
}
|
||||
|
||||
void lv_group_set_editing(lv_group_t * group, bool edit)
|
||||
{
|
||||
LV_ASSERT_NULL(group);
|
||||
uint8_t en_val = edit ? 1 : 0;
|
||||
|
||||
if(en_val == group->editing) return; /*Do not set the same mode again*/
|
||||
|
||||
group->editing = en_val;
|
||||
lv_obj_t * focused = lv_group_get_focused(group);
|
||||
|
||||
if(focused) {
|
||||
lv_result_t res = lv_obj_send_event(*group->obj_focus, LV_EVENT_FOCUSED, get_indev(group));
|
||||
if(res != LV_RESULT_OK) return;
|
||||
|
||||
lv_obj_invalidate(focused);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_group_set_refocus_policy(lv_group_t * group, lv_group_refocus_policy_t policy)
|
||||
{
|
||||
LV_ASSERT_NULL(group);
|
||||
group->refocus_policy = policy & 0x01;
|
||||
}
|
||||
|
||||
void lv_group_set_wrap(lv_group_t * group, bool en)
|
||||
{
|
||||
LV_ASSERT_NULL(group);
|
||||
group->wrap = en ? 1 : 0;
|
||||
}
|
||||
|
||||
lv_obj_t * lv_group_get_focused(const lv_group_t * group)
|
||||
{
|
||||
if(!group) return NULL;
|
||||
if(group->obj_focus == NULL) return NULL;
|
||||
|
||||
return *group->obj_focus;
|
||||
}
|
||||
|
||||
lv_group_focus_cb_t lv_group_get_focus_cb(const lv_group_t * group)
|
||||
{
|
||||
if(!group) return NULL;
|
||||
return group->focus_cb;
|
||||
}
|
||||
|
||||
lv_group_edge_cb_t lv_group_get_edge_cb(const lv_group_t * group)
|
||||
{
|
||||
if(!group) return NULL;
|
||||
return group->edge_cb;
|
||||
}
|
||||
|
||||
bool lv_group_get_editing(const lv_group_t * group)
|
||||
{
|
||||
if(!group) return false;
|
||||
return group->editing;
|
||||
}
|
||||
|
||||
bool lv_group_get_wrap(lv_group_t * group)
|
||||
{
|
||||
if(!group) return false;
|
||||
return group->wrap;
|
||||
}
|
||||
|
||||
uint32_t lv_group_get_obj_count(lv_group_t * group)
|
||||
{
|
||||
LV_ASSERT_NULL(group);
|
||||
return _lv_ll_get_len(&group->obj_ll);
|
||||
}
|
||||
|
||||
uint32_t lv_group_get_count(void)
|
||||
{
|
||||
return _lv_ll_get_len(group_ll_p);
|
||||
}
|
||||
|
||||
lv_group_t * lv_group_by_index(uint32_t index)
|
||||
{
|
||||
uint32_t len = 0;
|
||||
void * node;
|
||||
|
||||
for(node = _lv_ll_get_tail(group_ll_p); node != NULL; node = _lv_ll_get_prev(group_ll_p, node)) {
|
||||
if(len == index) {
|
||||
return (lv_group_t *) node;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void lv_group_refocus(lv_group_t * g)
|
||||
{
|
||||
/*Refocus must temporarily allow wrapping to work correctly*/
|
||||
uint8_t temp_wrap = g->wrap;
|
||||
g->wrap = 1;
|
||||
|
||||
if(g->refocus_policy == LV_GROUP_REFOCUS_POLICY_NEXT)
|
||||
lv_group_focus_next(g);
|
||||
else if(g->refocus_policy == LV_GROUP_REFOCUS_POLICY_PREV)
|
||||
lv_group_focus_prev(g);
|
||||
/*Restore wrap property*/
|
||||
g->wrap = temp_wrap;
|
||||
}
|
||||
|
||||
static bool focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *),
|
||||
void * (*move)(const lv_ll_t *, const void *))
|
||||
{
|
||||
bool focus_changed = false;
|
||||
if(group->frozen) return focus_changed;
|
||||
|
||||
lv_obj_t ** obj_next = group->obj_focus;
|
||||
lv_obj_t ** obj_sentinel = NULL;
|
||||
bool can_move = true;
|
||||
bool can_begin = true;
|
||||
|
||||
for(;;) {
|
||||
if(obj_next == NULL) {
|
||||
if(group->wrap || obj_sentinel == NULL) {
|
||||
if(!can_begin) return focus_changed;
|
||||
obj_next = begin(&group->obj_ll);
|
||||
can_move = false;
|
||||
can_begin = false;
|
||||
}
|
||||
else {
|
||||
/*Currently focused object is the last/first in the group, keep it that way*/
|
||||
return focus_changed;
|
||||
}
|
||||
}
|
||||
|
||||
if(obj_sentinel == NULL) {
|
||||
obj_sentinel = obj_next;
|
||||
if(obj_sentinel == NULL) return focus_changed; /*Group is empty*/
|
||||
}
|
||||
|
||||
if(can_move) {
|
||||
obj_next = move(&group->obj_ll, obj_next);
|
||||
|
||||
/*Give up if we walked the entire list and haven't found another visible object*/
|
||||
if(obj_next == obj_sentinel) return focus_changed;
|
||||
}
|
||||
|
||||
can_move = true;
|
||||
|
||||
if(obj_next == NULL) continue;
|
||||
if(lv_obj_get_state(*obj_next) & LV_STATE_DISABLED) continue;
|
||||
|
||||
/*Hidden objects don't receive focus.
|
||||
*If any parent is hidden, the object is also hidden)*/
|
||||
lv_obj_t * parent = *obj_next;
|
||||
while(parent) {
|
||||
if(lv_obj_has_flag(parent, LV_OBJ_FLAG_HIDDEN)) break;
|
||||
parent = lv_obj_get_parent(parent);
|
||||
}
|
||||
|
||||
if(parent && lv_obj_has_flag(parent, LV_OBJ_FLAG_HIDDEN)) continue;
|
||||
|
||||
/*If we got her a good candidate is found*/
|
||||
break;
|
||||
}
|
||||
|
||||
if(obj_next == group->obj_focus) return focus_changed; /*There's only one visible object and it's already focused*/
|
||||
|
||||
if(group->obj_focus) {
|
||||
lv_result_t res = lv_obj_send_event(*group->obj_focus, LV_EVENT_DEFOCUSED, get_indev(group));
|
||||
if(res != LV_RESULT_OK) return focus_changed;
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
lv_result_t res = lv_obj_send_event(*group->obj_focus, LV_EVENT_FOCUSED, get_indev(group));
|
||||
if(res != LV_RESULT_OK) return focus_changed;
|
||||
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
|
||||
if(group->focus_cb) group->focus_cb(group);
|
||||
focus_changed = true;
|
||||
return focus_changed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an indev preferably with POINTER type (because it's the most generic) that uses the given group.
|
||||
* In other words, find an indev, that is related to the given group.
|
||||
* In the worst case simply return the latest indev
|
||||
* @param g a group the find in the indevs
|
||||
* @return the suggested indev
|
||||
*/
|
||||
static lv_indev_t * get_indev(const lv_group_t * g)
|
||||
{
|
||||
lv_indev_t * indev_guess = NULL;
|
||||
lv_indev_t * indev = lv_indev_get_next(NULL);
|
||||
|
||||
while(indev) {
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
/*Prefer POINTER*/
|
||||
if(indev_type == LV_INDEV_TYPE_POINTER) return indev;
|
||||
if(lv_indev_get_group(indev) == g) {
|
||||
indev_guess = indev;
|
||||
}
|
||||
indev = lv_indev_get_next(indev);
|
||||
}
|
||||
|
||||
return indev_guess;
|
||||
}
|
||||
275
libraries/lvgl/src/core/lv_group.h
Normal file
275
libraries/lvgl/src/core/lv_group.h
Normal file
@ -0,0 +1,275 @@
|
||||
/**
|
||||
* @file lv_group.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_GROUP_H
|
||||
#define LV_GROUP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../misc/lv_ll.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Predefined keys to control the focused object via lv_group_send(group, c)*/
|
||||
enum _lv_key_t {
|
||||
LV_KEY_UP = 17, /*0x11*/
|
||||
LV_KEY_DOWN = 18, /*0x12*/
|
||||
LV_KEY_RIGHT = 19, /*0x13*/
|
||||
LV_KEY_LEFT = 20, /*0x14*/
|
||||
LV_KEY_ESC = 27, /*0x1B*/
|
||||
LV_KEY_DEL = 127, /*0x7F*/
|
||||
LV_KEY_BACKSPACE = 8, /*0x08*/
|
||||
LV_KEY_ENTER = 10, /*0x0A, '\n'*/
|
||||
LV_KEY_NEXT = 9, /*0x09, '\t'*/
|
||||
LV_KEY_PREV = 11, /*0x0B, '*/
|
||||
LV_KEY_HOME = 2, /*0x02, STX*/
|
||||
LV_KEY_END = 3, /*0x03, ETX*/
|
||||
};
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef void (*lv_group_focus_cb_t)(lv_group_t *);
|
||||
typedef void (*lv_group_edge_cb_t)(lv_group_t *, bool);
|
||||
|
||||
/**
|
||||
* Groups can be used to logically hold objects so that they can be individually focused.
|
||||
* They are NOT for laying out objects on a screen (try layouts for that).
|
||||
*/
|
||||
struct _lv_group_t {
|
||||
lv_ll_t obj_ll; /**< Linked list to store the objects in the group*/
|
||||
lv_obj_t ** obj_focus; /**< The object in focus*/
|
||||
|
||||
lv_group_focus_cb_t focus_cb; /**< A function to call when a new object is focused (optional)*/
|
||||
lv_group_edge_cb_t edge_cb; /**< A function to call when an edge is reached, no more focus
|
||||
targets are available in this direction (to allow edge feedback
|
||||
like a sound or a scroll bounce) */
|
||||
|
||||
void * user_data;
|
||||
|
||||
uint8_t frozen : 1; /**< 1: can't focus to new object*/
|
||||
uint8_t editing : 1; /**< 1: Edit mode, 0: Navigate mode*/
|
||||
uint8_t refocus_policy : 1; /**< 1: Focus prev if focused on deletion. 0: Focus next if focused on
|
||||
deletion.*/
|
||||
uint8_t wrap : 1; /**< 1: Focus next/prev can wrap at end of list. 0: Focus next/prev stops at end
|
||||
of list.*/
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
LV_GROUP_REFOCUS_POLICY_NEXT = 0,
|
||||
LV_GROUP_REFOCUS_POLICY_PREV = 1
|
||||
} lv_group_refocus_policy_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init the group module
|
||||
* @remarks Internal function, do not call directly.
|
||||
*/
|
||||
void _lv_group_init(void);
|
||||
|
||||
/**
|
||||
* Deinit the group module
|
||||
* @remarks Internal function, do not call directly.
|
||||
*/
|
||||
void _lv_group_deinit(void);
|
||||
|
||||
/**
|
||||
* Create a new object group
|
||||
* @return pointer to the new object group
|
||||
*/
|
||||
lv_group_t * lv_group_create(void);
|
||||
|
||||
/**
|
||||
* Delete a group object
|
||||
* @param group pointer to a group
|
||||
*/
|
||||
void lv_group_delete(lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Set a default group. New object are added to this group if it's enabled in their class with `add_to_def_group = true`
|
||||
* @param group pointer to a group (can be `NULL`)
|
||||
*/
|
||||
void lv_group_set_default(lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Get the default group
|
||||
* @return pointer to the default group
|
||||
*/
|
||||
lv_group_t * lv_group_get_default(void);
|
||||
|
||||
/**
|
||||
* Add an object to a group
|
||||
* @param group pointer to a group
|
||||
* @param obj pointer to an object to add
|
||||
*/
|
||||
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Swap 2 object in a group. The object must be in the same group
|
||||
* @param obj1 pointer to an object
|
||||
* @param obj2 pointer to an other object
|
||||
*/
|
||||
void lv_group_swap_obj(lv_obj_t * obj1, lv_obj_t * obj2);
|
||||
|
||||
/**
|
||||
* Remove an object from its group
|
||||
* @param obj pointer to an object to remove
|
||||
*/
|
||||
void lv_group_remove_obj(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Remove all objects from a group
|
||||
* @param group pointer to a group
|
||||
*/
|
||||
void lv_group_remove_all_objs(lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Focus on an object (defocus the current)
|
||||
* @param obj pointer to an object to focus on
|
||||
*/
|
||||
void lv_group_focus_obj(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Focus the next object in a group (defocus the current)
|
||||
* @param group pointer to a group
|
||||
*/
|
||||
void lv_group_focus_next(lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Focus the previous object in a group (defocus the current)
|
||||
* @param group pointer to a group
|
||||
*/
|
||||
void lv_group_focus_prev(lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Do not let to change the focus from the current object
|
||||
* @param group pointer to a group
|
||||
* @param en true: freeze, false: release freezing (normal mode)
|
||||
*/
|
||||
void lv_group_focus_freeze(lv_group_t * group, bool en);
|
||||
|
||||
/**
|
||||
* Send a control character to the focuses object of a group
|
||||
* @param group pointer to a group
|
||||
* @param c a character (use LV_KEY_.. to navigate)
|
||||
* @return result of focused object in group.
|
||||
*/
|
||||
lv_result_t lv_group_send_data(lv_group_t * group, uint32_t c);
|
||||
|
||||
/**
|
||||
* Set a function for a group which will be called when a new object is focused
|
||||
* @param group pointer to a group
|
||||
* @param focus_cb the call back function or NULL if unused
|
||||
*/
|
||||
void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb);
|
||||
|
||||
/**
|
||||
* Set a function for a group which will be called when a focus edge is reached
|
||||
* @param group pointer to a group
|
||||
* @param edge_cb the call back function or NULL if unused
|
||||
*/
|
||||
void lv_group_set_edge_cb(lv_group_t * group, lv_group_edge_cb_t edge_cb);
|
||||
|
||||
/**
|
||||
* Set whether the next or previous item in a group is focused if the currently focused obj is
|
||||
* deleted.
|
||||
* @param group pointer to a group
|
||||
* @param policy new refocus policy enum
|
||||
*/
|
||||
void lv_group_set_refocus_policy(lv_group_t * group, lv_group_refocus_policy_t policy);
|
||||
|
||||
/**
|
||||
* Manually set the current mode (edit or navigate).
|
||||
* @param group pointer to group
|
||||
* @param edit true: edit mode; false: navigate mode
|
||||
*/
|
||||
void lv_group_set_editing(lv_group_t * group, bool edit);
|
||||
|
||||
/**
|
||||
* Set whether focus next/prev will allow wrapping from first->last or last->first object.
|
||||
* @param group pointer to group
|
||||
* @param en true: wrapping enabled; false: wrapping disabled
|
||||
*/
|
||||
void lv_group_set_wrap(lv_group_t * group, bool en);
|
||||
|
||||
/**
|
||||
* Get the focused object or NULL if there isn't one
|
||||
* @param group pointer to a group
|
||||
* @return pointer to the focused object
|
||||
*/
|
||||
lv_obj_t * lv_group_get_focused(const lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Get the focus callback function of a group
|
||||
* @param group pointer to a group
|
||||
* @return the call back function or NULL if not set
|
||||
*/
|
||||
lv_group_focus_cb_t lv_group_get_focus_cb(const lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Get the edge callback function of a group
|
||||
* @param group pointer to a group
|
||||
* @return the call back function or NULL if not set
|
||||
*/
|
||||
lv_group_edge_cb_t lv_group_get_edge_cb(const lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Get the current mode (edit or navigate).
|
||||
* @param group pointer to group
|
||||
* @return true: edit mode; false: navigate mode
|
||||
*/
|
||||
bool lv_group_get_editing(const lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Get whether focus next/prev will allow wrapping from first->last or last->first object.
|
||||
* @param group pointer to group
|
||||
* @param en true: wrapping enabled; false: wrapping disabled
|
||||
*/
|
||||
bool lv_group_get_wrap(lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Get the number of object in the group
|
||||
* @param group pointer to a group
|
||||
* @return number of objects in the group
|
||||
*/
|
||||
uint32_t lv_group_get_obj_count(lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Get the number of groups
|
||||
* @return number of groups
|
||||
*/
|
||||
uint32_t lv_group_get_count(void);
|
||||
|
||||
/**
|
||||
* Get a group by its index
|
||||
* @return pointer to the group
|
||||
*/
|
||||
lv_group_t * lv_group_by_index(uint32_t index);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_GROUP_H*/
|
||||
873
libraries/lvgl/src/core/lv_obj.c
Normal file
873
libraries/lvgl/src/core/lv_obj.c
Normal file
@ -0,0 +1,873 @@
|
||||
/**
|
||||
* @file lv_obj.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_obj.h"
|
||||
#include "../indev/lv_indev.h"
|
||||
#include "../indev/lv_indev_private.h"
|
||||
#include "lv_refr.h"
|
||||
#include "lv_group.h"
|
||||
#include "../display/lv_display.h"
|
||||
#include "../display/lv_display_private.h"
|
||||
#include "../themes/lv_theme.h"
|
||||
#include "../misc/lv_assert.h"
|
||||
#include "../misc/lv_math.h"
|
||||
#include "../misc/lv_log.h"
|
||||
#include "../tick/lv_tick.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS (&lv_obj_class)
|
||||
#define LV_OBJ_DEF_WIDTH (LV_DPX(100))
|
||||
#define LV_OBJ_DEF_HEIGHT (LV_DPX(50))
|
||||
#define STYLE_TRANSITION_MAX 32
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_obj_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static void lv_obj_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static void lv_obj_draw(lv_event_t * e);
|
||||
static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e);
|
||||
static void draw_scrollbar(lv_obj_t * obj, lv_layer_t * layer);
|
||||
static lv_result_t scrollbar_init_draw_dsc(lv_obj_t * obj, lv_draw_rect_dsc_t * dsc);
|
||||
static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find);
|
||||
static void update_obj_state(lv_obj_t * obj, lv_state_t new_state);
|
||||
#if LV_USE_OBJ_PROPERTY
|
||||
static lv_result_t lv_obj_set_any(lv_obj_t *, lv_prop_id_t, const lv_property_t *);
|
||||
static lv_result_t lv_obj_get_any(const lv_obj_t *, lv_prop_id_t, lv_property_t *);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
#if LV_USE_OBJ_PROPERTY
|
||||
static const lv_property_ops_t properties[] = {
|
||||
{
|
||||
.id = LV_PROPERTY_OBJ_PARENT,
|
||||
.setter = lv_obj_set_parent,
|
||||
.getter = lv_obj_get_parent,
|
||||
},
|
||||
{
|
||||
.id = LV_PROPERTY_ID_ANY,
|
||||
.setter = lv_obj_set_any,
|
||||
.getter = lv_obj_get_any,
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
const lv_obj_class_t lv_obj_class = {
|
||||
.constructor_cb = lv_obj_constructor,
|
||||
.destructor_cb = lv_obj_destructor,
|
||||
.event_cb = lv_obj_event,
|
||||
.width_def = LV_DPI_DEF,
|
||||
.height_def = LV_DPI_DEF,
|
||||
.editable = LV_OBJ_CLASS_EDITABLE_FALSE,
|
||||
.group_def = LV_OBJ_CLASS_GROUP_DEF_FALSE,
|
||||
.instance_size = (sizeof(lv_obj_t)),
|
||||
.base_class = NULL,
|
||||
.name = "obj",
|
||||
#if LV_USE_OBJ_PROPERTY
|
||||
.prop_index_start = LV_PROPERTY_OBJ_START,
|
||||
.prop_index_end = LV_PROPERTY_OBJ_END,
|
||||
.properties = properties,
|
||||
.properties_count = sizeof(properties) / sizeof(properties[0]),
|
||||
#endif
|
||||
};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_obj_t * lv_obj_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/*-----------------
|
||||
* Attribute set
|
||||
*----------------*/
|
||||
|
||||
void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
bool was_on_layout = lv_obj_is_layout_positioned(obj);
|
||||
|
||||
/* We must invalidate the area occupied by the object before we hide it as calls to invalidate hidden objects are ignored */
|
||||
if(f & LV_OBJ_FLAG_HIDDEN) lv_obj_invalidate(obj);
|
||||
|
||||
obj->flags |= f;
|
||||
|
||||
if(f & LV_OBJ_FLAG_HIDDEN) {
|
||||
if(lv_obj_has_state(obj, LV_STATE_FOCUSED)) {
|
||||
lv_group_t * group = lv_obj_get_group(obj);
|
||||
if(group != NULL) {
|
||||
lv_group_focus_next(group);
|
||||
lv_obj_t * next_obj = lv_group_get_focused(group);
|
||||
if(next_obj != NULL) {
|
||||
lv_obj_invalidate(next_obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((was_on_layout != lv_obj_is_layout_positioned(obj)) || (f & (LV_OBJ_FLAG_LAYOUT_1 | LV_OBJ_FLAG_LAYOUT_2))) {
|
||||
lv_obj_mark_layout_as_dirty(lv_obj_get_parent(obj));
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
}
|
||||
|
||||
if(f & LV_OBJ_FLAG_SCROLLABLE) {
|
||||
lv_area_t hor_area, ver_area;
|
||||
lv_obj_get_scrollbar_area(obj, &hor_area, &ver_area);
|
||||
lv_obj_invalidate_area(obj, &hor_area);
|
||||
lv_obj_invalidate_area(obj, &ver_area);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_obj_remove_flag(lv_obj_t * obj, lv_obj_flag_t f)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
bool was_on_layout = lv_obj_is_layout_positioned(obj);
|
||||
if(f & LV_OBJ_FLAG_SCROLLABLE) {
|
||||
lv_area_t hor_area, ver_area;
|
||||
lv_obj_get_scrollbar_area(obj, &hor_area, &ver_area);
|
||||
lv_obj_invalidate_area(obj, &hor_area);
|
||||
lv_obj_invalidate_area(obj, &ver_area);
|
||||
}
|
||||
|
||||
obj->flags &= (~f);
|
||||
|
||||
if(f & LV_OBJ_FLAG_HIDDEN) {
|
||||
lv_obj_invalidate(obj);
|
||||
if(lv_obj_is_layout_positioned(obj)) {
|
||||
lv_obj_mark_layout_as_dirty(lv_obj_get_parent(obj));
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
}
|
||||
}
|
||||
|
||||
if((was_on_layout != lv_obj_is_layout_positioned(obj)) || (f & (LV_OBJ_FLAG_LAYOUT_1 | LV_OBJ_FLAG_LAYOUT_2))) {
|
||||
lv_obj_mark_layout_as_dirty(lv_obj_get_parent(obj));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void lv_obj_update_flag(lv_obj_t * obj, lv_obj_flag_t f, bool v)
|
||||
{
|
||||
if(v) lv_obj_add_flag(obj, f);
|
||||
else lv_obj_remove_flag(obj, f);
|
||||
}
|
||||
|
||||
void lv_obj_add_state(lv_obj_t * obj, lv_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_state_t new_state = obj->state | state;
|
||||
if(obj->state != new_state) {
|
||||
|
||||
if(new_state & LV_STATE_DISABLED) {
|
||||
lv_indev_reset(NULL, obj);
|
||||
}
|
||||
|
||||
update_obj_state(obj, new_state);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_obj_remove_state(lv_obj_t * obj, lv_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_state_t new_state = obj->state & (~state);
|
||||
if(obj->state != new_state) {
|
||||
update_obj_state(obj, new_state);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_obj_set_state(lv_obj_t * obj, lv_state_t state, bool v)
|
||||
{
|
||||
if(v) lv_obj_add_state(obj, state);
|
||||
else lv_obj_remove_state(obj, state);
|
||||
}
|
||||
|
||||
/*=======================
|
||||
* Getter functions
|
||||
*======================*/
|
||||
|
||||
bool lv_obj_has_flag(const lv_obj_t * obj, lv_obj_flag_t f)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
return (obj->flags & f) == f;
|
||||
}
|
||||
|
||||
bool lv_obj_has_flag_any(const lv_obj_t * obj, lv_obj_flag_t f)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
return !!(obj->flags & f);
|
||||
}
|
||||
|
||||
lv_state_t lv_obj_get_state(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
return obj->state;
|
||||
}
|
||||
|
||||
bool lv_obj_has_state(const lv_obj_t * obj, lv_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
return !!(obj->state & state);
|
||||
}
|
||||
|
||||
lv_group_t * lv_obj_get_group(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
if(obj->spec_attr) return obj->spec_attr->group_p;
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
/*-------------------
|
||||
* OTHER FUNCTIONS
|
||||
*------------------*/
|
||||
|
||||
void lv_obj_allocate_spec_attr(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
if(obj->spec_attr == NULL) {
|
||||
obj->spec_attr = lv_malloc_zeroed(sizeof(_lv_obj_spec_attr_t));
|
||||
LV_ASSERT_MALLOC(obj->spec_attr);
|
||||
if(obj->spec_attr == NULL) return;
|
||||
|
||||
obj->spec_attr->scroll_dir = LV_DIR_ALL;
|
||||
obj->spec_attr->scrollbar_mode = LV_SCROLLBAR_MODE_AUTO;
|
||||
}
|
||||
}
|
||||
|
||||
bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p)
|
||||
{
|
||||
if(obj == NULL) return false;
|
||||
return obj->class_p == class_p;
|
||||
}
|
||||
|
||||
bool lv_obj_has_class(const lv_obj_t * obj, const lv_obj_class_t * class_p)
|
||||
{
|
||||
const lv_obj_class_t * obj_class = obj->class_p;
|
||||
while(obj_class) {
|
||||
if(obj_class == class_p) return true;
|
||||
obj_class = obj_class->base_class;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const lv_obj_class_t * lv_obj_get_class(const lv_obj_t * obj)
|
||||
{
|
||||
return obj->class_p;
|
||||
}
|
||||
|
||||
bool lv_obj_is_valid(const lv_obj_t * obj)
|
||||
{
|
||||
lv_display_t * disp = lv_display_get_next(NULL);
|
||||
while(disp) {
|
||||
uint32_t i;
|
||||
for(i = 0; i < disp->screen_cnt; i++) {
|
||||
if(disp->screens[i] == obj) return true;
|
||||
bool found = obj_valid_child(disp->screens[i], obj);
|
||||
if(found) return true;
|
||||
}
|
||||
|
||||
disp = lv_display_get_next(disp);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void lv_obj_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
LV_TRACE_OBJ_CREATE("begin");
|
||||
|
||||
lv_obj_t * parent = obj->parent;
|
||||
if(parent) {
|
||||
int32_t sl = lv_obj_get_scroll_left(parent);
|
||||
int32_t st = lv_obj_get_scroll_top(parent);
|
||||
|
||||
obj->coords.y1 = parent->coords.y1 + lv_obj_get_style_pad_top(parent, LV_PART_MAIN) - st;
|
||||
obj->coords.y2 = obj->coords.y1 - 1;
|
||||
obj->coords.x1 = parent->coords.x1 + lv_obj_get_style_pad_left(parent, LV_PART_MAIN) - sl;
|
||||
obj->coords.x2 = obj->coords.x1 - 1;
|
||||
}
|
||||
|
||||
/*Set attributes*/
|
||||
obj->flags = LV_OBJ_FLAG_CLICKABLE;
|
||||
obj->flags |= LV_OBJ_FLAG_SNAPPABLE;
|
||||
if(parent) obj->flags |= LV_OBJ_FLAG_PRESS_LOCK;
|
||||
if(parent) obj->flags |= LV_OBJ_FLAG_SCROLL_CHAIN;
|
||||
obj->flags |= LV_OBJ_FLAG_CLICK_FOCUSABLE;
|
||||
obj->flags |= LV_OBJ_FLAG_SCROLLABLE;
|
||||
obj->flags |= LV_OBJ_FLAG_SCROLL_ELASTIC;
|
||||
obj->flags |= LV_OBJ_FLAG_SCROLL_MOMENTUM;
|
||||
obj->flags |= LV_OBJ_FLAG_SCROLL_WITH_ARROW;
|
||||
if(parent) obj->flags |= LV_OBJ_FLAG_GESTURE_BUBBLE;
|
||||
|
||||
#if LV_USE_OBJ_ID
|
||||
lv_obj_assign_id(class_p, obj);
|
||||
#endif
|
||||
|
||||
LV_TRACE_OBJ_CREATE("finished");
|
||||
}
|
||||
|
||||
static void lv_obj_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
|
||||
_lv_event_mark_deleted(obj);
|
||||
|
||||
/*Remove all style*/
|
||||
lv_obj_enable_style_refresh(false); /*No need to refresh the style because the object will be deleted*/
|
||||
lv_obj_remove_style_all(obj);
|
||||
lv_obj_enable_style_refresh(true);
|
||||
|
||||
/*Remove the animations from this object*/
|
||||
lv_anim_delete(obj, NULL);
|
||||
|
||||
/*Delete from the group*/
|
||||
lv_group_t * group = lv_obj_get_group(obj);
|
||||
if(group) lv_group_remove_obj(obj);
|
||||
|
||||
if(obj->spec_attr) {
|
||||
if(obj->spec_attr->children) {
|
||||
lv_free(obj->spec_attr->children);
|
||||
obj->spec_attr->children = NULL;
|
||||
}
|
||||
|
||||
lv_event_remove_all(&obj->spec_attr->event_list);
|
||||
|
||||
lv_free(obj->spec_attr);
|
||||
obj->spec_attr = NULL;
|
||||
}
|
||||
|
||||
#if LV_USE_OBJ_ID
|
||||
lv_obj_free_id(obj);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void lv_obj_draw(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_current_target(e);
|
||||
if(code == LV_EVENT_COVER_CHECK) {
|
||||
lv_cover_check_info_t * info = lv_event_get_param(e);
|
||||
if(info->res == LV_COVER_RES_MASKED) return;
|
||||
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) {
|
||||
info->res = LV_COVER_RES_MASKED;
|
||||
return;
|
||||
}
|
||||
|
||||
/*Most trivial test. Is the mask fully IN the object? If no it surely doesn't cover it*/
|
||||
int32_t r = lv_obj_get_style_radius(obj, LV_PART_MAIN);
|
||||
int32_t w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
|
||||
int32_t h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
|
||||
lv_area_t coords;
|
||||
lv_area_copy(&coords, &obj->coords);
|
||||
lv_area_increase(&coords, w, h);
|
||||
|
||||
if(_lv_area_is_in(info->area, &coords, r) == false) {
|
||||
info->res = LV_COVER_RES_NOT_COVER;
|
||||
return;
|
||||
}
|
||||
|
||||
if(lv_obj_get_style_bg_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) {
|
||||
info->res = LV_COVER_RES_NOT_COVER;
|
||||
return;
|
||||
}
|
||||
|
||||
if(lv_obj_get_style_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) {
|
||||
info->res = LV_COVER_RES_NOT_COVER;
|
||||
return;
|
||||
}
|
||||
|
||||
if(lv_obj_get_style_bg_grad_dir(obj, 0) != LV_GRAD_DIR_NONE) {
|
||||
if(lv_obj_get_style_bg_grad_opa(obj, 0) < LV_OPA_MAX) {
|
||||
info->res = LV_COVER_RES_NOT_COVER;
|
||||
return;
|
||||
}
|
||||
}
|
||||
const lv_grad_dsc_t * grad_dsc = lv_obj_get_style_bg_grad(obj, 0);
|
||||
if(grad_dsc) {
|
||||
uint32_t i;
|
||||
for(i = 0; i < grad_dsc->stops_count; i++) {
|
||||
if(grad_dsc->stops[i].opa < LV_OPA_MAX) {
|
||||
info->res = LV_COVER_RES_NOT_COVER;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
info->res = LV_COVER_RES_COVER;
|
||||
}
|
||||
else if(code == LV_EVENT_DRAW_MAIN) {
|
||||
lv_layer_t * layer = lv_event_get_layer(e);
|
||||
lv_draw_rect_dsc_t draw_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_dsc);
|
||||
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &draw_dsc);
|
||||
/*If the border is drawn later disable loading its properties*/
|
||||
if(lv_obj_get_style_border_post(obj, LV_PART_MAIN)) {
|
||||
draw_dsc.border_post = 1;
|
||||
}
|
||||
|
||||
int32_t w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
|
||||
int32_t h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
|
||||
lv_area_t coords;
|
||||
lv_area_copy(&coords, &obj->coords);
|
||||
lv_area_increase(&coords, w, h);
|
||||
|
||||
lv_draw_rect(layer, &draw_dsc, &coords);
|
||||
}
|
||||
else if(code == LV_EVENT_DRAW_POST) {
|
||||
lv_layer_t * layer = lv_event_get_layer(e);
|
||||
draw_scrollbar(obj, layer);
|
||||
|
||||
/*If the border is drawn later disable loading other properties*/
|
||||
if(lv_obj_get_style_border_post(obj, LV_PART_MAIN)) {
|
||||
lv_draw_rect_dsc_t draw_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_dsc);
|
||||
draw_dsc.bg_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.bg_image_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.outline_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.shadow_opa = LV_OPA_TRANSP;
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &draw_dsc);
|
||||
|
||||
int32_t w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
|
||||
int32_t h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
|
||||
lv_area_t coords;
|
||||
lv_area_copy(&coords, &obj->coords);
|
||||
lv_area_increase(&coords, w, h);
|
||||
|
||||
lv_draw_rect(layer, &draw_dsc, &coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_scrollbar(lv_obj_t * obj, lv_layer_t * layer)
|
||||
{
|
||||
|
||||
lv_area_t hor_area;
|
||||
lv_area_t ver_area;
|
||||
lv_obj_get_scrollbar_area(obj, &hor_area, &ver_area);
|
||||
|
||||
if(lv_area_get_size(&hor_area) <= 0 && lv_area_get_size(&ver_area) <= 0) return;
|
||||
|
||||
lv_draw_rect_dsc_t draw_dsc;
|
||||
lv_result_t sb_res = scrollbar_init_draw_dsc(obj, &draw_dsc);
|
||||
if(sb_res != LV_RESULT_OK) return;
|
||||
|
||||
if(lv_area_get_size(&hor_area) > 0) {
|
||||
draw_dsc.base.id1 = 0;
|
||||
lv_draw_rect(layer, &draw_dsc, &hor_area);
|
||||
}
|
||||
if(lv_area_get_size(&ver_area) > 0) {
|
||||
draw_dsc.base.id1 = 1;
|
||||
lv_draw_rect(layer, &draw_dsc, &ver_area);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the draw descriptor for the scrollbar
|
||||
* @param obj pointer to an object
|
||||
* @param dsc the draw descriptor to initialize
|
||||
* @return LV_RESULT_OK: the scrollbar is visible; LV_RESULT_INVALID: the scrollbar is not visible
|
||||
*/
|
||||
static lv_result_t scrollbar_init_draw_dsc(lv_obj_t * obj, lv_draw_rect_dsc_t * dsc)
|
||||
{
|
||||
lv_draw_rect_dsc_init(dsc);
|
||||
dsc->bg_opa = lv_obj_get_style_bg_opa(obj, LV_PART_SCROLLBAR);
|
||||
if(dsc->bg_opa > LV_OPA_MIN) {
|
||||
dsc->bg_color = lv_obj_get_style_bg_color(obj, LV_PART_SCROLLBAR);
|
||||
}
|
||||
|
||||
dsc->border_opa = lv_obj_get_style_border_opa(obj, LV_PART_SCROLLBAR);
|
||||
if(dsc->border_opa > LV_OPA_MIN) {
|
||||
dsc->border_width = lv_obj_get_style_border_width(obj, LV_PART_SCROLLBAR);
|
||||
if(dsc->border_width > 0) {
|
||||
dsc->border_color = lv_obj_get_style_border_color(obj, LV_PART_SCROLLBAR);
|
||||
}
|
||||
else {
|
||||
dsc->border_opa = LV_OPA_TRANSP;
|
||||
}
|
||||
}
|
||||
|
||||
dsc->shadow_opa = lv_obj_get_style_shadow_opa(obj, LV_PART_SCROLLBAR);
|
||||
if(dsc->shadow_opa > LV_OPA_MIN) {
|
||||
dsc->shadow_width = lv_obj_get_style_shadow_width(obj, LV_PART_SCROLLBAR);
|
||||
if(dsc->shadow_width > 0) {
|
||||
dsc->shadow_spread = lv_obj_get_style_shadow_spread(obj, LV_PART_SCROLLBAR);
|
||||
dsc->shadow_color = lv_obj_get_style_shadow_color(obj, LV_PART_SCROLLBAR);
|
||||
}
|
||||
else {
|
||||
dsc->shadow_opa = LV_OPA_TRANSP;
|
||||
}
|
||||
}
|
||||
|
||||
lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, LV_PART_SCROLLBAR);
|
||||
if(opa < LV_OPA_MAX) {
|
||||
lv_opa_t v = LV_OPA_MIX2(dsc->bg_opa, opa);
|
||||
dsc->bg_opa = v;
|
||||
dsc->border_opa = v;
|
||||
dsc->shadow_opa = v;
|
||||
}
|
||||
|
||||
if(dsc->bg_opa != LV_OPA_TRANSP || dsc->border_opa != LV_OPA_TRANSP || dsc->shadow_opa != LV_OPA_TRANSP) {
|
||||
dsc->radius = lv_obj_get_style_radius(obj, LV_PART_SCROLLBAR);
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
else {
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_current_target(e);
|
||||
if(code == LV_EVENT_PRESSED) {
|
||||
lv_obj_add_state(obj, LV_STATE_PRESSED);
|
||||
}
|
||||
else if(code == LV_EVENT_RELEASED) {
|
||||
lv_obj_remove_state(obj, LV_STATE_PRESSED);
|
||||
void * param = lv_event_get_param(e);
|
||||
/*Go the checked state if enabled*/
|
||||
if(lv_indev_get_scroll_obj(param) == NULL && lv_obj_has_flag(obj, LV_OBJ_FLAG_CHECKABLE)) {
|
||||
if(!(lv_obj_get_state(obj) & LV_STATE_CHECKED)) lv_obj_add_state(obj, LV_STATE_CHECKED);
|
||||
else lv_obj_remove_state(obj, LV_STATE_CHECKED);
|
||||
|
||||
lv_result_t res = lv_obj_send_event(obj, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RESULT_OK) return;
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_PRESS_LOST) {
|
||||
lv_obj_remove_state(obj, LV_STATE_PRESSED);
|
||||
}
|
||||
else if(code == LV_EVENT_STYLE_CHANGED) {
|
||||
uint32_t child_cnt = lv_obj_get_child_count(obj);
|
||||
for(uint32_t i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
lv_obj_mark_layout_as_dirty(child);
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_KEY) {
|
||||
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_CHECKABLE)) {
|
||||
uint32_t c = lv_event_get_key(e);
|
||||
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
|
||||
lv_obj_add_state(obj, LV_STATE_CHECKED);
|
||||
}
|
||||
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
|
||||
lv_obj_remove_state(obj, LV_STATE_CHECKED);
|
||||
}
|
||||
|
||||
/*With Enter LV_EVENT_RELEASED will send VALUE_CHANGE event*/
|
||||
if(c != LV_KEY_ENTER) {
|
||||
lv_result_t res = lv_obj_send_event(obj, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RESULT_OK) return;
|
||||
}
|
||||
}
|
||||
else if(lv_obj_has_flag(obj, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_WITH_ARROW) && !lv_obj_is_editable(obj)) {
|
||||
/*scroll by keypad or encoder*/
|
||||
lv_anim_enable_t anim_enable = LV_ANIM_OFF;
|
||||
int32_t sl = lv_obj_get_scroll_left(obj);
|
||||
int32_t sr = lv_obj_get_scroll_right(obj);
|
||||
uint32_t c = lv_event_get_key(e);
|
||||
if(c == LV_KEY_DOWN) {
|
||||
/*use scroll_to_x/y functions to enforce scroll limits*/
|
||||
lv_obj_scroll_to_y(obj, lv_obj_get_scroll_y(obj) + lv_obj_get_height(obj) / 4, anim_enable);
|
||||
}
|
||||
else if(c == LV_KEY_UP) {
|
||||
lv_obj_scroll_to_y(obj, lv_obj_get_scroll_y(obj) - lv_obj_get_height(obj) / 4, anim_enable);
|
||||
}
|
||||
else if(c == LV_KEY_RIGHT) {
|
||||
/*If the object can't be scrolled horizontally then scroll it vertically*/
|
||||
if(!((lv_obj_get_scroll_dir(obj) & LV_DIR_HOR) && (sl > 0 || sr > 0)))
|
||||
lv_obj_scroll_to_y(obj, lv_obj_get_scroll_y(obj) + lv_obj_get_height(obj) / 4, anim_enable);
|
||||
else
|
||||
lv_obj_scroll_to_x(obj, lv_obj_get_scroll_x(obj) + lv_obj_get_width(obj) / 4, anim_enable);
|
||||
}
|
||||
else if(c == LV_KEY_LEFT) {
|
||||
/*If the object can't be scrolled horizontally then scroll it vertically*/
|
||||
if(!((lv_obj_get_scroll_dir(obj) & LV_DIR_HOR) && (sl > 0 || sr > 0)))
|
||||
lv_obj_scroll_to_y(obj, lv_obj_get_scroll_y(obj) - lv_obj_get_height(obj) / 4, anim_enable);
|
||||
else
|
||||
lv_obj_scroll_to_x(obj, lv_obj_get_scroll_x(obj) - lv_obj_get_width(obj) / 4, anim_enable);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_FOCUSED) {
|
||||
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS)) {
|
||||
lv_obj_scroll_to_view_recursive(obj, LV_ANIM_ON);
|
||||
}
|
||||
|
||||
bool editing = false;
|
||||
editing = lv_group_get_editing(lv_obj_get_group(obj));
|
||||
lv_state_t state = LV_STATE_FOCUSED;
|
||||
|
||||
/* Use the indev for then indev handler.
|
||||
* But if the obj was focused manually it returns NULL so try to
|
||||
* use the indev from the event*/
|
||||
lv_indev_t * indev = lv_indev_active();
|
||||
if(indev == NULL) indev = lv_event_get_indev(e);
|
||||
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
if(indev_type == LV_INDEV_TYPE_KEYPAD || indev_type == LV_INDEV_TYPE_ENCODER) state |= LV_STATE_FOCUS_KEY;
|
||||
if(editing) {
|
||||
state |= LV_STATE_EDITED;
|
||||
lv_obj_add_state(obj, state);
|
||||
}
|
||||
else {
|
||||
lv_obj_add_state(obj, state);
|
||||
lv_obj_remove_state(obj, LV_STATE_EDITED);
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_SCROLL_BEGIN) {
|
||||
lv_obj_add_state(obj, LV_STATE_SCROLLED);
|
||||
}
|
||||
else if(code == LV_EVENT_SCROLL_END) {
|
||||
lv_obj_remove_state(obj, LV_STATE_SCROLLED);
|
||||
if(lv_obj_get_scrollbar_mode(obj) == LV_SCROLLBAR_MODE_ACTIVE) {
|
||||
lv_area_t hor_area, ver_area;
|
||||
lv_obj_get_scrollbar_area(obj, &hor_area, &ver_area);
|
||||
lv_obj_invalidate_area(obj, &hor_area);
|
||||
lv_obj_invalidate_area(obj, &ver_area);
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_DEFOCUSED) {
|
||||
lv_obj_remove_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED | LV_STATE_FOCUS_KEY);
|
||||
}
|
||||
else if(code == LV_EVENT_SIZE_CHANGED) {
|
||||
int32_t align = lv_obj_get_style_align(obj, LV_PART_MAIN);
|
||||
uint16_t layout = lv_obj_get_style_layout(obj, LV_PART_MAIN);
|
||||
if(layout || align) {
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
}
|
||||
|
||||
uint32_t i;
|
||||
uint32_t child_cnt = lv_obj_get_child_count(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
lv_obj_mark_layout_as_dirty(child);
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_CHILD_CHANGED) {
|
||||
int32_t w = lv_obj_get_style_width(obj, LV_PART_MAIN);
|
||||
int32_t h = lv_obj_get_style_height(obj, LV_PART_MAIN);
|
||||
int32_t align = lv_obj_get_style_align(obj, LV_PART_MAIN);
|
||||
uint16_t layout = lv_obj_get_style_layout(obj, LV_PART_MAIN);
|
||||
if(layout || align || w == LV_SIZE_CONTENT || h == LV_SIZE_CONTENT) {
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_CHILD_DELETED) {
|
||||
obj->readjust_scroll_after_layout = 1;
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
}
|
||||
else if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
|
||||
int32_t d = lv_obj_calculate_ext_draw_size(obj, LV_PART_MAIN);
|
||||
lv_event_set_ext_draw_size(e, d);
|
||||
}
|
||||
else if(code == LV_EVENT_DRAW_MAIN || code == LV_EVENT_DRAW_POST || code == LV_EVENT_COVER_CHECK) {
|
||||
lv_obj_draw(e);
|
||||
}
|
||||
else if(code == LV_EVENT_INDEV_RESET) {
|
||||
lv_obj_remove_state(obj, LV_STATE_PRESSED);
|
||||
lv_obj_remove_state(obj, LV_STATE_SCROLLED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the state (fully overwrite) of an object.
|
||||
* If specified in the styles, transition animations will be started from the previous state to the current.
|
||||
* @param obj pointer to an object
|
||||
* @param state the new state
|
||||
*/
|
||||
static void update_obj_state(lv_obj_t * obj, lv_state_t new_state)
|
||||
{
|
||||
if(obj->state == new_state) return;
|
||||
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_state_t prev_state = obj->state;
|
||||
|
||||
_lv_style_state_cmp_t cmp_res = _lv_obj_style_state_compare(obj, prev_state, new_state);
|
||||
/*If there is no difference in styles there is nothing else to do*/
|
||||
if(cmp_res == _LV_STYLE_STATE_CMP_SAME) {
|
||||
obj->state = new_state;
|
||||
return;
|
||||
}
|
||||
|
||||
/*Invalidate the object in their current state*/
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
obj->state = new_state;
|
||||
_lv_obj_update_layer_type(obj);
|
||||
_lv_obj_style_transition_dsc_t * ts = lv_malloc_zeroed(sizeof(_lv_obj_style_transition_dsc_t) * STYLE_TRANSITION_MAX);
|
||||
uint32_t tsi = 0;
|
||||
uint32_t i;
|
||||
for(i = 0; i < obj->style_cnt && tsi < STYLE_TRANSITION_MAX; i++) {
|
||||
_lv_obj_style_t * obj_style = &obj->styles[i];
|
||||
lv_state_t state_act = lv_obj_style_get_selector_state(obj->styles[i].selector);
|
||||
lv_part_t part_act = lv_obj_style_get_selector_part(obj->styles[i].selector);
|
||||
if(state_act & (~new_state)) continue; /*Skip unrelated styles*/
|
||||
if(obj_style->is_trans) continue;
|
||||
|
||||
lv_style_value_t v;
|
||||
if(lv_style_get_prop_inlined(obj_style->style, LV_STYLE_TRANSITION, &v) != LV_STYLE_RES_FOUND) continue;
|
||||
const lv_style_transition_dsc_t * tr = v.ptr;
|
||||
|
||||
/*Add the props to the set if not added yet or added but with smaller weight*/
|
||||
uint32_t j;
|
||||
for(j = 0; tr->props[j] != 0 && tsi < STYLE_TRANSITION_MAX; j++) {
|
||||
uint32_t t;
|
||||
for(t = 0; t < tsi; t++) {
|
||||
lv_style_selector_t selector = ts[t].selector;
|
||||
lv_state_t state_ts = lv_obj_style_get_selector_state(selector);
|
||||
lv_part_t part_ts = lv_obj_style_get_selector_part(selector);
|
||||
if(ts[t].prop == tr->props[j] && part_ts == part_act && state_ts >= state_act) break;
|
||||
}
|
||||
|
||||
/*If not found add it*/
|
||||
if(t == tsi) {
|
||||
ts[tsi].time = tr->time;
|
||||
ts[tsi].delay = tr->delay;
|
||||
ts[tsi].path_cb = tr->path_xcb;
|
||||
ts[tsi].prop = tr->props[j];
|
||||
ts[tsi].user_data = tr->user_data;
|
||||
ts[tsi].selector = obj_style->selector;
|
||||
tsi++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < tsi; i++) {
|
||||
lv_part_t part_act = lv_obj_style_get_selector_part(ts[i].selector);
|
||||
_lv_obj_style_create_transition(obj, part_act, prev_state, new_state, &ts[i]);
|
||||
}
|
||||
|
||||
lv_free(ts);
|
||||
|
||||
if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_REDRAW) {
|
||||
/*Invalidation is not enough, e.g. layer type needs to be updated too*/
|
||||
lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ANY);
|
||||
}
|
||||
else if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_LAYOUT) {
|
||||
lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ANY);
|
||||
}
|
||||
else if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) {
|
||||
lv_obj_invalidate(obj);
|
||||
lv_obj_refresh_ext_draw_size(obj);
|
||||
}
|
||||
}
|
||||
|
||||
static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find)
|
||||
{
|
||||
/*Check all children of `parent`*/
|
||||
uint32_t child_cnt = 0;
|
||||
if(parent->spec_attr) child_cnt = parent->spec_attr->child_cnt;
|
||||
uint32_t i;
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = parent->spec_attr->children[i];
|
||||
if(child == obj_to_find) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*Check the children*/
|
||||
bool found = obj_valid_child(child, obj_to_find);
|
||||
if(found) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#if LV_USE_OBJ_PROPERTY
|
||||
static lv_result_t lv_obj_set_any(lv_obj_t * obj, lv_prop_id_t id, const lv_property_t * prop)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
if(id >= LV_PROPERTY_OBJ_FLAG_START && id <= LV_PROPERTY_OBJ_FLAG_END) {
|
||||
lv_obj_flag_t flag = 1L << (id - LV_PROPERTY_OBJ_FLAG_START);
|
||||
if(prop->num) lv_obj_add_flag(obj, flag);
|
||||
else lv_obj_remove_flag(obj, flag);
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
else if(id >= LV_PROPERTY_OBJ_STATE_START && id <= LV_PROPERTY_OBJ_STATE_END) {
|
||||
lv_state_t state = 1L << (id - LV_PROPERTY_OBJ_STATE_START);
|
||||
if(id == LV_PROPERTY_OBJ_STATE_ANY) {
|
||||
state = LV_STATE_ANY;
|
||||
}
|
||||
|
||||
if(prop->num) lv_obj_add_state(obj, state);
|
||||
else lv_obj_remove_state(obj, state);
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
else {
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
static lv_result_t lv_obj_get_any(const lv_obj_t * obj, lv_prop_id_t id, lv_property_t * prop)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
if(id >= LV_PROPERTY_OBJ_FLAG_START && id <= LV_PROPERTY_OBJ_FLAG_END) {
|
||||
lv_obj_flag_t flag = 1L << (id - LV_PROPERTY_OBJ_FLAG_START);
|
||||
prop->id = id;
|
||||
prop->num = obj->flags & flag;
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
else if(id >= LV_PROPERTY_OBJ_STATE_START && id <= LV_PROPERTY_OBJ_STATE_END) {
|
||||
prop->id = id;
|
||||
if(id == LV_PROPERTY_OBJ_STATE_ANY) {
|
||||
prop->num = obj->state;
|
||||
}
|
||||
else {
|
||||
lv_obj_flag_t flag = 1L << (id - LV_PROPERTY_OBJ_STATE_START);
|
||||
prop->num = obj->state & flag;
|
||||
}
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
else {
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
470
libraries/lvgl/src/core/lv_obj.h
Normal file
470
libraries/lvgl/src/core/lv_obj.h
Normal file
@ -0,0 +1,470 @@
|
||||
/**
|
||||
* @file lv_obj.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBJ_H
|
||||
#define LV_OBJ_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../misc/lv_style.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../misc/lv_assert.h"
|
||||
|
||||
#include "lv_obj_tree.h"
|
||||
#include "lv_obj_pos.h"
|
||||
#include "lv_obj_scroll.h"
|
||||
#include "lv_obj_style.h"
|
||||
#include "lv_obj_draw.h"
|
||||
#include "lv_obj_class.h"
|
||||
#include "lv_obj_event.h"
|
||||
#include "lv_obj_property.h"
|
||||
#include "lv_group.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Possible states of a widget.
|
||||
* OR-ed values are possible
|
||||
*/
|
||||
enum _lv_state_t {
|
||||
LV_STATE_DEFAULT = 0x0000,
|
||||
LV_STATE_CHECKED = 0x0001,
|
||||
LV_STATE_FOCUSED = 0x0002,
|
||||
LV_STATE_FOCUS_KEY = 0x0004,
|
||||
LV_STATE_EDITED = 0x0008,
|
||||
LV_STATE_HOVERED = 0x0010,
|
||||
LV_STATE_PRESSED = 0x0020,
|
||||
LV_STATE_SCROLLED = 0x0040,
|
||||
LV_STATE_DISABLED = 0x0080,
|
||||
LV_STATE_USER_1 = 0x1000,
|
||||
LV_STATE_USER_2 = 0x2000,
|
||||
LV_STATE_USER_3 = 0x4000,
|
||||
LV_STATE_USER_4 = 0x8000,
|
||||
|
||||
LV_STATE_ANY = 0xFFFF, /**< Special value can be used in some functions to target all states*/
|
||||
};
|
||||
|
||||
/**
|
||||
* The possible parts of widgets.
|
||||
* The parts can be considered as the internal building block of the widgets.
|
||||
* E.g. slider = background + indicator + knob
|
||||
* Not all parts are used by every widget
|
||||
*/
|
||||
|
||||
enum _lv_part_t {
|
||||
LV_PART_MAIN = 0x000000, /**< A background like rectangle*/
|
||||
LV_PART_SCROLLBAR = 0x010000, /**< The scrollbar(s)*/
|
||||
LV_PART_INDICATOR = 0x020000, /**< Indicator, e.g. for slider, bar, switch, or the tick box of the checkbox*/
|
||||
LV_PART_KNOB = 0x030000, /**< Like handle to grab to adjust the value*/
|
||||
LV_PART_SELECTED = 0x040000, /**< Indicate the currently selected option or section*/
|
||||
LV_PART_ITEMS = 0x050000, /**< Used if the widget has multiple similar elements (e.g. table cells)*/
|
||||
LV_PART_CURSOR = 0x060000, /**< Mark a specific place e.g. for text area's cursor or on a chart*/
|
||||
|
||||
LV_PART_CUSTOM_FIRST = 0x080000, /**< Extension point for custom widgets*/
|
||||
|
||||
LV_PART_ANY = 0x0F0000, /**< Special value can be used in some functions to target all parts*/
|
||||
};
|
||||
|
||||
/**
|
||||
* On/Off features controlling the object's behavior.
|
||||
* OR-ed values are possible
|
||||
*
|
||||
* Note: update obj flags corresponding properties below
|
||||
* whenever add/remove flags or change bit definition of flags.
|
||||
*/
|
||||
typedef enum {
|
||||
LV_OBJ_FLAG_HIDDEN = (1L << 0), /**< Make the object hidden. (Like it wasn't there at all)*/
|
||||
LV_OBJ_FLAG_CLICKABLE = (1L << 1), /**< Make the object clickable by the input devices*/
|
||||
LV_OBJ_FLAG_CLICK_FOCUSABLE = (1L << 2), /**< Add focused state to the object when clicked*/
|
||||
LV_OBJ_FLAG_CHECKABLE = (1L << 3), /**< Toggle checked state when the object is clicked*/
|
||||
LV_OBJ_FLAG_SCROLLABLE = (1L << 4), /**< Make the object scrollable*/
|
||||
LV_OBJ_FLAG_SCROLL_ELASTIC = (1L << 5), /**< Allow scrolling inside but with slower speed*/
|
||||
LV_OBJ_FLAG_SCROLL_MOMENTUM = (1L << 6), /**< Make the object scroll further when "thrown"*/
|
||||
LV_OBJ_FLAG_SCROLL_ONE = (1L << 7), /**< Allow scrolling only one snappable children*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN_HOR = (1L << 8), /**< Allow propagating the horizontal scroll to a parent*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN_VER = (1L << 9), /**< Allow propagating the vertical scroll to a parent*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN = (LV_OBJ_FLAG_SCROLL_CHAIN_HOR | LV_OBJ_FLAG_SCROLL_CHAIN_VER),
|
||||
LV_OBJ_FLAG_SCROLL_ON_FOCUS = (1L << 10), /**< Automatically scroll object to make it visible when focused*/
|
||||
LV_OBJ_FLAG_SCROLL_WITH_ARROW = (1L << 11), /**< Allow scrolling the focused object with arrow keys*/
|
||||
LV_OBJ_FLAG_SNAPPABLE = (1L << 12), /**< If scroll snap is enabled on the parent it can snap to this object*/
|
||||
LV_OBJ_FLAG_PRESS_LOCK = (1L << 13), /**< Keep the object pressed even if the press slid from the object*/
|
||||
LV_OBJ_FLAG_EVENT_BUBBLE = (1L << 14), /**< Propagate the events to the parent too*/
|
||||
LV_OBJ_FLAG_GESTURE_BUBBLE = (1L << 15), /**< Propagate the gestures to the parent*/
|
||||
LV_OBJ_FLAG_ADV_HITTEST = (1L << 16), /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners.*/
|
||||
LV_OBJ_FLAG_IGNORE_LAYOUT = (1L << 17), /**< Make the object position-able by the layouts*/
|
||||
LV_OBJ_FLAG_FLOATING = (1L << 18), /**< Do not scroll the object when the parent scrolls and ignore layout*/
|
||||
LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS = (1L << 19), /**< Send `LV_EVENT_DRAW_TASK_ADDED` events*/
|
||||
LV_OBJ_FLAG_OVERFLOW_VISIBLE = (1L << 20),/**< Do not clip the children to the parent's ext draw size*/
|
||||
#if LV_USE_FLEX
|
||||
LV_OBJ_FLAG_FLEX_IN_NEW_TRACK = (1L << 21), /**< Start a new flex track on this item*/
|
||||
#endif
|
||||
|
||||
LV_OBJ_FLAG_LAYOUT_1 = (1L << 23), /**< Custom flag, free to use by layouts*/
|
||||
LV_OBJ_FLAG_LAYOUT_2 = (1L << 24), /**< Custom flag, free to use by layouts*/
|
||||
|
||||
LV_OBJ_FLAG_WIDGET_1 = (1L << 25), /**< Custom flag, free to use by widget*/
|
||||
LV_OBJ_FLAG_WIDGET_2 = (1L << 26), /**< Custom flag, free to use by widget*/
|
||||
LV_OBJ_FLAG_USER_1 = (1L << 27), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_2 = (1L << 28), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_3 = (1L << 29), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_4 = (1L << 30), /**< Custom flag, free to use by user*/
|
||||
} _lv_obj_flag_t;
|
||||
|
||||
#if LV_USE_OBJ_PROPERTY
|
||||
enum {
|
||||
/*OBJ flag properties */
|
||||
LV_PROPERTY_ID(OBJ, FLAG_START, LV_PROPERTY_TYPE_INT, 0),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_HIDDEN, LV_PROPERTY_TYPE_INT, 0),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_CLICKABLE, LV_PROPERTY_TYPE_INT, 1),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_CLICK_FOCUSABLE, LV_PROPERTY_TYPE_INT, 2),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_CHECKABLE, LV_PROPERTY_TYPE_INT, 3),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_SCROLLABLE, LV_PROPERTY_TYPE_INT, 4),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_SCROLL_ELASTIC, LV_PROPERTY_TYPE_INT, 5),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_SCROLL_MOMENTUM, LV_PROPERTY_TYPE_INT, 6),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_SCROLL_ONE, LV_PROPERTY_TYPE_INT, 7),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_SCROLL_CHAIN_HOR, LV_PROPERTY_TYPE_INT, 8),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_SCROLL_CHAIN_VER, LV_PROPERTY_TYPE_INT, 9),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_SCROLL_ON_FOCUS, LV_PROPERTY_TYPE_INT, 10),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_SCROLL_WITH_ARROW, LV_PROPERTY_TYPE_INT, 11),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_SNAPPABLE, LV_PROPERTY_TYPE_INT, 12),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_PRESS_LOCK, LV_PROPERTY_TYPE_INT, 13),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_EVENT_BUBBLE, LV_PROPERTY_TYPE_INT, 14),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_GESTURE_BUBBLE, LV_PROPERTY_TYPE_INT, 15),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_ADV_HITTEST, LV_PROPERTY_TYPE_INT, 16),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_IGNORE_LAYOUT, LV_PROPERTY_TYPE_INT, 17),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_FLOATING, LV_PROPERTY_TYPE_INT, 18),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_SEND_DRAW_TASK_EVENTS, LV_PROPERTY_TYPE_INT, 19),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_OVERFLOW_VISIBLE, LV_PROPERTY_TYPE_INT, 20),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_FLEX_IN_NEW_TRACK, LV_PROPERTY_TYPE_INT, 21),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_LAYOUT_1, LV_PROPERTY_TYPE_INT, 23),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_LAYOUT_2, LV_PROPERTY_TYPE_INT, 24),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_WIDGET_1, LV_PROPERTY_TYPE_INT, 25),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_WIDGET_2, LV_PROPERTY_TYPE_INT, 26),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_USER_1, LV_PROPERTY_TYPE_INT, 27),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_USER_2, LV_PROPERTY_TYPE_INT, 28),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_USER_3, LV_PROPERTY_TYPE_INT, 29),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_USER_4, LV_PROPERTY_TYPE_INT, 30),
|
||||
LV_PROPERTY_ID(OBJ, FLAG_END, LV_PROPERTY_TYPE_INT, 30),
|
||||
|
||||
LV_PROPERTY_ID(OBJ, STATE_START, LV_PROPERTY_TYPE_INT, 31),
|
||||
LV_PROPERTY_ID(OBJ, STATE_CHECKED, LV_PROPERTY_TYPE_INT, 31),
|
||||
LV_PROPERTY_ID(OBJ, STATE_FOCUSED, LV_PROPERTY_TYPE_INT, 32),
|
||||
LV_PROPERTY_ID(OBJ, STATE_FOCUS_KEY, LV_PROPERTY_TYPE_INT, 33),
|
||||
LV_PROPERTY_ID(OBJ, STATE_EDITED, LV_PROPERTY_TYPE_INT, 34),
|
||||
LV_PROPERTY_ID(OBJ, STATE_HOVERED, LV_PROPERTY_TYPE_INT, 35),
|
||||
LV_PROPERTY_ID(OBJ, STATE_PRESSED, LV_PROPERTY_TYPE_INT, 36),
|
||||
LV_PROPERTY_ID(OBJ, STATE_SCROLLED, LV_PROPERTY_TYPE_INT, 37),
|
||||
LV_PROPERTY_ID(OBJ, STATE_DISABLED, LV_PROPERTY_TYPE_INT, 38),
|
||||
/*not used bit8-bit11*/
|
||||
LV_PROPERTY_ID(OBJ, STATE_USER_1, LV_PROPERTY_TYPE_INT, 43),
|
||||
LV_PROPERTY_ID(OBJ, STATE_USER_2, LV_PROPERTY_TYPE_INT, 44),
|
||||
LV_PROPERTY_ID(OBJ, STATE_USER_3, LV_PROPERTY_TYPE_INT, 45),
|
||||
LV_PROPERTY_ID(OBJ, STATE_USER_4, LV_PROPERTY_TYPE_INT, 46),
|
||||
LV_PROPERTY_ID(OBJ, STATE_ANY, LV_PROPERTY_TYPE_INT, 47),
|
||||
LV_PROPERTY_ID(OBJ, STATE_END, LV_PROPERTY_TYPE_INT, 47),
|
||||
|
||||
/*OBJ normal properties*/
|
||||
LV_PROPERTY_ID(OBJ, PARENT, LV_PROPERTY_TYPE_POINTER, 31),
|
||||
|
||||
LV_PROPERTY_OBJ_END,
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Make the base object's class publicly available.
|
||||
*/
|
||||
LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_obj_class;
|
||||
|
||||
/**
|
||||
* Special, rarely used attributes.
|
||||
* They are allocated automatically if any elements is set.
|
||||
*/
|
||||
typedef struct {
|
||||
lv_obj_t ** children; /**< Store the pointer of the children in an array.*/
|
||||
lv_group_t * group_p;
|
||||
lv_event_list_t event_list;
|
||||
|
||||
lv_point_t scroll; /**< The current X/Y scroll offset*/
|
||||
|
||||
int32_t ext_click_pad; /**< Extra click padding in all direction*/
|
||||
int32_t ext_draw_size; /**< EXTend the size in every direction for drawing.*/
|
||||
|
||||
uint16_t child_cnt; /**< Number of children*/
|
||||
uint16_t scrollbar_mode : 2; /**< How to display scrollbars, see `lv_scrollbar_mode_t`*/
|
||||
uint16_t scroll_snap_x : 2; /**< Where to align the snappable children horizontally, see `lv_scroll_snap_t`*/
|
||||
uint16_t scroll_snap_y : 2; /**< Where to align the snappable children vertically*/
|
||||
uint16_t scroll_dir : 4; /**< The allowed scroll direction(s), see `lv_dir_t`*/
|
||||
uint16_t layer_type : 2; /**< Cache the layer type here. Element of @lv_intermediate_layer_type_t */
|
||||
} _lv_obj_spec_attr_t;
|
||||
|
||||
struct _lv_obj_t {
|
||||
const lv_obj_class_t * class_p;
|
||||
lv_obj_t * parent;
|
||||
_lv_obj_spec_attr_t * spec_attr;
|
||||
_lv_obj_style_t * styles;
|
||||
#if LV_OBJ_STYLE_CACHE
|
||||
uint32_t style_main_prop_is_set;
|
||||
uint32_t style_other_prop_is_set;
|
||||
#endif
|
||||
void * user_data;
|
||||
#if LV_USE_OBJ_ID
|
||||
void * id;
|
||||
#endif
|
||||
lv_area_t coords;
|
||||
lv_obj_flag_t flags;
|
||||
lv_state_t state;
|
||||
uint16_t layout_inv : 1;
|
||||
uint16_t readjust_scroll_after_layout : 1;
|
||||
uint16_t scr_layout_inv : 1;
|
||||
uint16_t skip_trans : 1;
|
||||
uint16_t style_cnt : 6;
|
||||
uint16_t h_layout : 1;
|
||||
uint16_t w_layout : 1;
|
||||
uint16_t is_deleting : 1;
|
||||
};
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a base object (a rectangle)
|
||||
* @param parent pointer to a parent object. If NULL then a screen will be created.
|
||||
* @return pointer to the new object
|
||||
*/
|
||||
lv_obj_t * lv_obj_create(lv_obj_t * parent);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set one or more flags
|
||||
* @param obj pointer to an object
|
||||
* @param f R-ed values from `lv_obj_flag_t` to set.
|
||||
*/
|
||||
void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f);
|
||||
|
||||
/**
|
||||
* Remove one or more flags
|
||||
* @param obj pointer to an object
|
||||
* @param f OR-ed values from `lv_obj_flag_t` to set.
|
||||
*/
|
||||
void lv_obj_remove_flag(lv_obj_t * obj, lv_obj_flag_t f);
|
||||
|
||||
/**
|
||||
* Set add or remove one or more flags.
|
||||
* @param obj pointer to an object
|
||||
* @param f OR-ed values from `lv_obj_flag_t` to update.
|
||||
* @param v true: add the flags; false: remove the flags
|
||||
*/
|
||||
void lv_obj_update_flag(lv_obj_t * obj, lv_obj_flag_t f, bool v);
|
||||
|
||||
/**
|
||||
* Add one or more states to the object. The other state bits will remain unchanged.
|
||||
* If specified in the styles, transition animation will be started from the previous state to the current.
|
||||
* @param obj pointer to an object
|
||||
* @param state the states to add. E.g `LV_STATE_PRESSED | LV_STATE_FOCUSED`
|
||||
*/
|
||||
void lv_obj_add_state(lv_obj_t * obj, lv_state_t state);
|
||||
|
||||
/**
|
||||
* Remove one or more states to the object. The other state bits will remain unchanged.
|
||||
* If specified in the styles, transition animation will be started from the previous state to the current.
|
||||
* @param obj pointer to an object
|
||||
* @param state the states to add. E.g `LV_STATE_PRESSED | LV_STATE_FOCUSED`
|
||||
*/
|
||||
void lv_obj_remove_state(lv_obj_t * obj, lv_state_t state);
|
||||
|
||||
/**
|
||||
* Add or remove one or more states to the object. The other state bits will remain unchanged.
|
||||
* @param obj pointer to an object
|
||||
* @param state the states to add. E.g `LV_STATE_PRESSED | LV_STATE_FOCUSED`
|
||||
* @param v true: add the states; false: remove the states
|
||||
*/
|
||||
void lv_obj_set_state(lv_obj_t * obj, lv_state_t state, bool v);
|
||||
|
||||
/**
|
||||
* Set the user_data field of the object
|
||||
* @param obj pointer to an object
|
||||
* @param user_data pointer to the new user_data.
|
||||
*/
|
||||
static inline void lv_obj_set_user_data(lv_obj_t * obj, void * user_data)
|
||||
{
|
||||
obj->user_data = user_data;
|
||||
}
|
||||
|
||||
/*=======================
|
||||
* Getter functions
|
||||
*======================*/
|
||||
|
||||
/**
|
||||
* Check if a given flag or all the given flags are set on an object.
|
||||
* @param obj pointer to an object
|
||||
* @param f the flag(s) to check (OR-ed values can be used)
|
||||
* @return true: all flags are set; false: not all flags are set
|
||||
*/
|
||||
bool lv_obj_has_flag(const lv_obj_t * obj, lv_obj_flag_t f);
|
||||
|
||||
/**
|
||||
* Check if a given flag or any of the flags are set on an object.
|
||||
* @param obj pointer to an object
|
||||
* @param f the flag(s) to check (OR-ed values can be used)
|
||||
* @return true: at lest one flag flag is set; false: none of the flags are set
|
||||
*/
|
||||
bool lv_obj_has_flag_any(const lv_obj_t * obj, lv_obj_flag_t f);
|
||||
|
||||
/**
|
||||
* Get the state of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the state (OR-ed values from `lv_state_t`)
|
||||
*/
|
||||
lv_state_t lv_obj_get_state(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Check if the object is in a given state or not.
|
||||
* @param obj pointer to an object
|
||||
* @param state a state or combination of states to check
|
||||
* @return true: `obj` is in `state`; false: `obj` is not in `state`
|
||||
*/
|
||||
bool lv_obj_has_state(const lv_obj_t * obj, lv_state_t state);
|
||||
|
||||
/**
|
||||
* Get the group of the object
|
||||
* @param obj pointer to an object
|
||||
* @return the pointer to group of the object
|
||||
*/
|
||||
lv_group_t * lv_obj_get_group(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the user_data field of the object
|
||||
* @param obj pointer to an object
|
||||
* @return the pointer to the user_data of the object
|
||||
*/
|
||||
static inline void * lv_obj_get_user_data(lv_obj_t * obj)
|
||||
{
|
||||
return obj->user_data;
|
||||
}
|
||||
|
||||
/*=======================
|
||||
* Other functions
|
||||
*======================*/
|
||||
|
||||
/**
|
||||
* Allocate special data for an object if not allocated yet.
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_allocate_spec_attr(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Check the type of obj.
|
||||
* @param obj pointer to an object
|
||||
* @param class_p a class to check (e.g. `lv_slider_class`)
|
||||
* @return true: `class_p` is the `obj` class.
|
||||
*/
|
||||
bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p);
|
||||
|
||||
/**
|
||||
* Check if any object has a given class (type).
|
||||
* It checks the ancestor classes too.
|
||||
* @param obj pointer to an object
|
||||
* @param class_p a class to check (e.g. `lv_slider_class`)
|
||||
* @return true: `obj` has the given class
|
||||
*/
|
||||
bool lv_obj_has_class(const lv_obj_t * obj, const lv_obj_class_t * class_p);
|
||||
|
||||
/**
|
||||
* Get the class (type) of the object
|
||||
* @param obj pointer to an object
|
||||
* @return the class (type) of the object
|
||||
*/
|
||||
const lv_obj_class_t * lv_obj_get_class(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Check if any object is still "alive".
|
||||
* @param obj pointer to an object
|
||||
* @return true: valid
|
||||
*/
|
||||
bool lv_obj_is_valid(const lv_obj_t * obj);
|
||||
|
||||
#if LV_USE_OBJ_ID
|
||||
|
||||
/**
|
||||
* Assign an id to an object if not previously assigned
|
||||
* Set `LV_USE_OBJ_ID_BUILTIN` to 1 to use builtin method to generate object ID.
|
||||
* Otherwise, these functions including `lv_obj_[assign|free|stringify]_id` should be implemented externally.
|
||||
*
|
||||
* @param class_p the class this obj belongs to. Note obj->class_p is the class currently being constructed.
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_assign_id(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Free resources allocated by `lv_obj_assign_id`
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_free_id(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Format an object's id into a string.
|
||||
* @param obj pointer to an object
|
||||
* @param buf buffer to write the string into
|
||||
* @param len length of the buffer
|
||||
*/
|
||||
const char * lv_obj_stringify_id(lv_obj_t * obj, char * buf, uint32_t len);
|
||||
|
||||
#if LV_USE_OBJ_ID_BUILTIN
|
||||
/**
|
||||
* Free resources used by builtin ID generator.
|
||||
*/
|
||||
void lv_objid_builtin_destroy(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /*LV_USE_OBJ_ID*/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#if LV_USE_ASSERT_OBJ
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_class) \
|
||||
do { \
|
||||
LV_ASSERT_MSG(obj_p != NULL, "The object is NULL"); \
|
||||
LV_ASSERT_MSG(lv_obj_has_class(obj_p, obj_class) == true, "Incompatible object type."); \
|
||||
LV_ASSERT_MSG(lv_obj_is_valid(obj_p) == true, "The object is invalid, deleted or corrupted?"); \
|
||||
} while(0)
|
||||
# else
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_class) do{}while(0)
|
||||
#endif
|
||||
|
||||
#if LV_USE_LOG && LV_LOG_TRACE_OBJ_CREATE
|
||||
# define LV_TRACE_OBJ_CREATE(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||
#else
|
||||
# define LV_TRACE_OBJ_CREATE(...)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBJ_H*/
|
||||
194
libraries/lvgl/src/core/lv_obj_class.c
Normal file
194
libraries/lvgl/src/core/lv_obj_class.c
Normal file
@ -0,0 +1,194 @@
|
||||
/**
|
||||
* @file lv_obj_class.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_obj.h"
|
||||
#include "../themes/lv_theme.h"
|
||||
#include "../display/lv_display.h"
|
||||
#include "../display/lv_display_private.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS (&lv_obj_class)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_obj_construct(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static uint32_t get_instance_size(const lv_obj_class_t * class_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_obj_t * lv_obj_class_create_obj(const lv_obj_class_t * class_p, lv_obj_t * parent)
|
||||
{
|
||||
LV_TRACE_OBJ_CREATE("Creating object with %p class on %p parent", (void *)class_p, (void *)parent);
|
||||
uint32_t s = get_instance_size(class_p);
|
||||
lv_obj_t * obj = lv_malloc_zeroed(s);
|
||||
if(obj == NULL) return NULL;
|
||||
obj->class_p = class_p;
|
||||
obj->parent = parent;
|
||||
|
||||
/*Create a screen*/
|
||||
if(parent == NULL) {
|
||||
LV_TRACE_OBJ_CREATE("creating a screen");
|
||||
lv_display_t * disp = lv_display_get_default();
|
||||
if(!disp) {
|
||||
LV_LOG_WARN("No display created yet. No place to assign the new screen");
|
||||
lv_free(obj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(disp->screens == NULL) {
|
||||
disp->screen_cnt = 0;
|
||||
}
|
||||
|
||||
disp->screen_cnt++;
|
||||
disp->screens = lv_realloc(disp->screens, sizeof(lv_obj_t *) * disp->screen_cnt);
|
||||
disp->screens[disp->screen_cnt - 1] = obj;
|
||||
|
||||
/*Set coordinates to full screen size*/
|
||||
obj->coords.x1 = 0;
|
||||
obj->coords.y1 = 0;
|
||||
obj->coords.x2 = lv_display_get_horizontal_resolution(NULL) - 1;
|
||||
obj->coords.y2 = lv_display_get_vertical_resolution(NULL) - 1;
|
||||
}
|
||||
/*Create a normal object*/
|
||||
else {
|
||||
LV_TRACE_OBJ_CREATE("creating normal object");
|
||||
LV_ASSERT_OBJ(parent, MY_CLASS);
|
||||
if(parent->spec_attr == NULL) {
|
||||
lv_obj_allocate_spec_attr(parent);
|
||||
}
|
||||
|
||||
parent->spec_attr->child_cnt++;
|
||||
parent->spec_attr->children = lv_realloc(parent->spec_attr->children,
|
||||
sizeof(lv_obj_t *) * parent->spec_attr->child_cnt);
|
||||
parent->spec_attr->children[parent->spec_attr->child_cnt - 1] = obj;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
void lv_obj_class_init_obj(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
lv_obj_enable_style_refresh(false);
|
||||
|
||||
lv_theme_apply(obj);
|
||||
lv_obj_construct(obj->class_p, obj);
|
||||
|
||||
lv_obj_enable_style_refresh(true);
|
||||
lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ANY);
|
||||
|
||||
lv_obj_refresh_self_size(obj);
|
||||
|
||||
lv_group_t * def_group = lv_group_get_default();
|
||||
if(def_group && lv_obj_is_group_def(obj)) {
|
||||
lv_group_add_obj(def_group, obj);
|
||||
}
|
||||
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
if(parent) {
|
||||
/*Call the ancestor's event handler to the parent to notify it about the new child.
|
||||
*Also triggers layout update*/
|
||||
lv_obj_send_event(parent, LV_EVENT_CHILD_CHANGED, obj);
|
||||
lv_obj_send_event(parent, LV_EVENT_CHILD_CREATED, obj);
|
||||
|
||||
/*Invalidate the area if not screen created*/
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
}
|
||||
|
||||
void _lv_obj_destruct(lv_obj_t * obj)
|
||||
{
|
||||
if(obj->class_p->destructor_cb) obj->class_p->destructor_cb(obj->class_p, obj);
|
||||
|
||||
if(obj->class_p->base_class) {
|
||||
/*Don't let the descendant methods run during destructing the ancestor type*/
|
||||
obj->class_p = obj->class_p->base_class;
|
||||
|
||||
/*Call the base class's destructor too*/
|
||||
_lv_obj_destruct(obj);
|
||||
}
|
||||
}
|
||||
|
||||
bool lv_obj_is_editable(lv_obj_t * obj)
|
||||
{
|
||||
const lv_obj_class_t * class_p = obj->class_p;
|
||||
|
||||
/*Find a base in which editable is set*/
|
||||
while(class_p && class_p->editable == LV_OBJ_CLASS_EDITABLE_INHERIT) class_p = class_p->base_class;
|
||||
|
||||
if(class_p == NULL) return false;
|
||||
|
||||
return class_p->editable == LV_OBJ_CLASS_EDITABLE_TRUE;
|
||||
}
|
||||
|
||||
bool lv_obj_is_group_def(lv_obj_t * obj)
|
||||
{
|
||||
const lv_obj_class_t * class_p = obj->class_p;
|
||||
|
||||
/*Find a base in which group_def is set*/
|
||||
while(class_p && class_p->group_def == LV_OBJ_CLASS_GROUP_DEF_INHERIT) class_p = class_p->base_class;
|
||||
|
||||
if(class_p == NULL) return false;
|
||||
|
||||
return class_p->group_def == LV_OBJ_CLASS_GROUP_DEF_TRUE;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void lv_obj_construct(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
if(obj->class_p->base_class) {
|
||||
const lv_obj_class_t * original_class_p = obj->class_p;
|
||||
|
||||
/*Don't let the descendant methods run during constructing the ancestor type*/
|
||||
obj->class_p = obj->class_p->base_class;
|
||||
|
||||
/*Construct the base first*/
|
||||
lv_obj_construct(class_p, obj);
|
||||
|
||||
/*Restore the original class*/
|
||||
obj->class_p = original_class_p;
|
||||
}
|
||||
|
||||
if(obj->class_p->constructor_cb) obj->class_p->constructor_cb(class_p, obj);
|
||||
}
|
||||
|
||||
static uint32_t get_instance_size(const lv_obj_class_t * class_p)
|
||||
{
|
||||
/*Find a base in which instance size is set*/
|
||||
const lv_obj_class_t * base = class_p;
|
||||
while(base && base->instance_size == 0) base = base->base_class;
|
||||
|
||||
if(base == NULL) return 0; /*Never happens: set at least in `lv_obj` class*/
|
||||
|
||||
return base->instance_size;
|
||||
}
|
||||
106
libraries/lvgl/src/core/lv_obj_class.h
Normal file
106
libraries/lvgl/src/core/lv_obj_class.h
Normal file
@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @file lv_obj_class.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBJ_CLASS_H
|
||||
#define LV_OBJ_CLASS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "lv_obj_property.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_OBJ_CLASS_EDITABLE_INHERIT, /**< Check the base class. Must have 0 value to let zero initialized class inherit*/
|
||||
LV_OBJ_CLASS_EDITABLE_TRUE,
|
||||
LV_OBJ_CLASS_EDITABLE_FALSE,
|
||||
} lv_obj_class_editable_t;
|
||||
|
||||
typedef enum {
|
||||
LV_OBJ_CLASS_GROUP_DEF_INHERIT, /**< Check the base class. Must have 0 value to let zero initialized class inherit*/
|
||||
LV_OBJ_CLASS_GROUP_DEF_TRUE,
|
||||
LV_OBJ_CLASS_GROUP_DEF_FALSE,
|
||||
} lv_obj_class_group_def_t;
|
||||
|
||||
typedef enum {
|
||||
LV_OBJ_CLASS_THEME_INHERITABLE_FALSE, /**< Do not inherit theme from base class. */
|
||||
LV_OBJ_CLASS_THEME_INHERITABLE_TRUE,
|
||||
} lv_obj_class_theme_inheritable_t;
|
||||
|
||||
typedef void (*lv_obj_class_event_cb_t)(lv_obj_class_t * class_p, lv_event_t * e);
|
||||
/**
|
||||
* Describe the common methods of every object.
|
||||
* Similar to a C++ class.
|
||||
*/
|
||||
struct _lv_obj_class_t {
|
||||
const lv_obj_class_t * base_class;
|
||||
/*class_p is the final class while obj->class_p is the class currently being [de]constructed.*/
|
||||
void (*constructor_cb)(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
void (*destructor_cb)(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
|
||||
/*class_p is the class in which event is being processed.*/
|
||||
void (*event_cb)(const lv_obj_class_t * class_p, lv_event_t * e); /**< Widget type specific event function*/
|
||||
|
||||
#if LV_USE_OBJ_PROPERTY
|
||||
uint32_t prop_index_start;
|
||||
uint32_t prop_index_end;
|
||||
const lv_property_ops_t * properties;
|
||||
uint32_t properties_count;
|
||||
#endif
|
||||
|
||||
void * user_data;
|
||||
const char * name;
|
||||
int32_t width_def;
|
||||
int32_t height_def;
|
||||
uint32_t editable : 2; /**< Value from ::lv_obj_class_editable_t*/
|
||||
uint32_t group_def : 2; /**< Value from ::lv_obj_class_group_def_t*/
|
||||
uint32_t instance_size : 16;
|
||||
uint32_t theme_inheritable : 1; /**< Value from ::lv_obj_class_theme_inheritable_t*/
|
||||
};
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create an object form a class descriptor
|
||||
* @param class_p pointer to a class
|
||||
* @param parent pointer to an object where the new object should be created
|
||||
* @return pointer to the created object
|
||||
*/
|
||||
lv_obj_t * lv_obj_class_create_obj(const lv_obj_class_t * class_p, lv_obj_t * parent);
|
||||
|
||||
void lv_obj_class_init_obj(lv_obj_t * obj);
|
||||
|
||||
void _lv_obj_destruct(lv_obj_t * obj);
|
||||
|
||||
bool lv_obj_is_editable(lv_obj_t * obj);
|
||||
|
||||
bool lv_obj_is_group_def(lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBJ_CLASS_H*/
|
||||
324
libraries/lvgl/src/core/lv_obj_draw.c
Normal file
324
libraries/lvgl/src/core/lv_obj_draw.c
Normal file
@ -0,0 +1,324 @@
|
||||
/**
|
||||
* @file lv_obj_draw.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_obj_draw.h"
|
||||
#include "lv_obj.h"
|
||||
#include "../display/lv_display.h"
|
||||
#include "../indev/lv_indev.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS (&lv_obj_class)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t * draw_dsc)
|
||||
{
|
||||
draw_dsc->base.obj = obj;
|
||||
draw_dsc->base.part = part;
|
||||
|
||||
lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, part);
|
||||
if(part != LV_PART_MAIN) {
|
||||
if(opa <= LV_OPA_MIN) {
|
||||
draw_dsc->bg_opa = LV_OPA_TRANSP;
|
||||
draw_dsc->bg_image_opa = LV_OPA_TRANSP;
|
||||
draw_dsc->border_opa = LV_OPA_TRANSP;
|
||||
draw_dsc->outline_opa = LV_OPA_TRANSP;
|
||||
draw_dsc->shadow_opa = LV_OPA_TRANSP;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
draw_dsc->radius = lv_obj_get_style_radius(obj, part);
|
||||
|
||||
if(draw_dsc->bg_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->bg_opa = lv_obj_get_style_bg_opa(obj, part);
|
||||
if(draw_dsc->bg_opa > LV_OPA_MIN) {
|
||||
draw_dsc->bg_color = lv_obj_get_style_bg_color_filtered(obj, part);
|
||||
const lv_grad_dsc_t * grad = lv_obj_get_style_bg_grad(obj, part);
|
||||
if(grad && grad->dir != LV_GRAD_DIR_NONE) {
|
||||
lv_memcpy(&draw_dsc->bg_grad, grad, sizeof(*grad));
|
||||
}
|
||||
else {
|
||||
draw_dsc->bg_grad.dir = lv_obj_get_style_bg_grad_dir(obj, part);
|
||||
if(draw_dsc->bg_grad.dir != LV_GRAD_DIR_NONE) {
|
||||
draw_dsc->bg_grad.stops[0].color = lv_obj_get_style_bg_color_filtered(obj, part);
|
||||
draw_dsc->bg_grad.stops[1].color = lv_obj_get_style_bg_grad_color_filtered(obj, part);
|
||||
draw_dsc->bg_grad.stops[0].frac = lv_obj_get_style_bg_main_stop(obj, part);
|
||||
draw_dsc->bg_grad.stops[1].frac = lv_obj_get_style_bg_grad_stop(obj, part);
|
||||
draw_dsc->bg_grad.stops[0].opa = lv_obj_get_style_bg_main_opa(obj, part);
|
||||
draw_dsc->bg_grad.stops[1].opa = lv_obj_get_style_bg_grad_opa(obj, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(draw_dsc->border_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->border_width = lv_obj_get_style_border_width(obj, part);
|
||||
if(draw_dsc->border_width) {
|
||||
draw_dsc->border_opa = lv_obj_get_style_border_opa(obj, part);
|
||||
if(draw_dsc->border_opa > LV_OPA_MIN) {
|
||||
draw_dsc->border_side = lv_obj_get_style_border_side(obj, part);
|
||||
draw_dsc->border_color = lv_obj_get_style_border_color_filtered(obj, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
draw_dsc->outline_opa = lv_obj_get_style_outline_opa(obj, part);
|
||||
if(draw_dsc->outline_opa > LV_OPA_MIN) {
|
||||
draw_dsc->outline_pad = lv_obj_get_style_outline_pad(obj, part);
|
||||
draw_dsc->outline_color = lv_obj_get_style_outline_color_filtered(obj, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(draw_dsc->bg_image_opa != LV_OPA_TRANSP) {
|
||||
draw_dsc->bg_image_src = lv_obj_get_style_bg_image_src(obj, part);
|
||||
if(draw_dsc->bg_image_src) {
|
||||
draw_dsc->bg_image_opa = lv_obj_get_style_bg_image_opa(obj, part);
|
||||
if(draw_dsc->bg_image_opa > LV_OPA_MIN) {
|
||||
if(lv_image_src_get_type(draw_dsc->bg_image_src) == LV_IMAGE_SRC_SYMBOL) {
|
||||
draw_dsc->bg_image_symbol_font = lv_obj_get_style_text_font(obj, part);
|
||||
draw_dsc->bg_image_recolor = lv_obj_get_style_text_color_filtered(obj, part);
|
||||
}
|
||||
else {
|
||||
draw_dsc->bg_image_recolor = lv_obj_get_style_bg_image_recolor_filtered(obj, part);
|
||||
draw_dsc->bg_image_recolor_opa = lv_obj_get_style_bg_image_recolor_opa(obj, part);
|
||||
draw_dsc->bg_image_tiled = lv_obj_get_style_bg_image_tiled(obj, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(draw_dsc->shadow_opa) {
|
||||
draw_dsc->shadow_width = lv_obj_get_style_shadow_width(obj, part);
|
||||
if(draw_dsc->shadow_width) {
|
||||
if(draw_dsc->shadow_opa > LV_OPA_MIN) {
|
||||
draw_dsc->shadow_opa = lv_obj_get_style_shadow_opa(obj, part);
|
||||
if(draw_dsc->shadow_opa > LV_OPA_MIN) {
|
||||
draw_dsc->shadow_offset_x = lv_obj_get_style_shadow_offset_x(obj, part);
|
||||
draw_dsc->shadow_offset_y = lv_obj_get_style_shadow_offset_y(obj, part);
|
||||
draw_dsc->shadow_spread = lv_obj_get_style_shadow_spread(obj, part);
|
||||
draw_dsc->shadow_color = lv_obj_get_style_shadow_color_filtered(obj, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(opa < LV_OPA_MAX) {
|
||||
draw_dsc->bg_opa = LV_OPA_MIX2(draw_dsc->bg_opa, opa);
|
||||
draw_dsc->bg_image_opa = LV_OPA_MIX2(draw_dsc->bg_image_opa, opa);
|
||||
draw_dsc->border_opa = LV_OPA_MIX2(draw_dsc->border_opa, opa);
|
||||
draw_dsc->shadow_opa = LV_OPA_MIX2(draw_dsc->shadow_opa, opa);
|
||||
draw_dsc->outline_opa = LV_OPA_MIX2(draw_dsc->outline_opa, opa);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint32_t part, lv_draw_label_dsc_t * draw_dsc)
|
||||
{
|
||||
draw_dsc->base.obj = obj;
|
||||
draw_dsc->base.part = part;
|
||||
|
||||
draw_dsc->opa = lv_obj_get_style_text_opa(obj, part);
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, part);
|
||||
if(opa < LV_OPA_MAX) {
|
||||
draw_dsc->opa = LV_OPA_MIX2(draw_dsc->opa, opa);
|
||||
}
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
draw_dsc->color = lv_obj_get_style_text_color_filtered(obj, part);
|
||||
draw_dsc->letter_space = lv_obj_get_style_text_letter_space(obj, part);
|
||||
draw_dsc->line_space = lv_obj_get_style_text_line_space(obj, part);
|
||||
draw_dsc->decor = lv_obj_get_style_text_decor(obj, part);
|
||||
if(part != LV_PART_MAIN) draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part);
|
||||
|
||||
draw_dsc->font = lv_obj_get_style_text_font(obj, part);
|
||||
|
||||
#if LV_USE_BIDI
|
||||
draw_dsc->bidi_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN);
|
||||
#endif
|
||||
|
||||
draw_dsc->align = lv_obj_get_style_text_align(obj, part);
|
||||
}
|
||||
|
||||
void lv_obj_init_draw_image_dsc(lv_obj_t * obj, uint32_t part, lv_draw_image_dsc_t * draw_dsc)
|
||||
{
|
||||
draw_dsc->base.obj = obj;
|
||||
draw_dsc->base.part = part;
|
||||
|
||||
draw_dsc->opa = lv_obj_get_style_image_opa(obj, part);
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, part);
|
||||
if(opa < LV_OPA_MAX) {
|
||||
draw_dsc->opa = LV_OPA_MIX2(draw_dsc->opa, opa);
|
||||
}
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
draw_dsc->rotation = 0;
|
||||
draw_dsc->scale_x = LV_SCALE_NONE;
|
||||
draw_dsc->scale_y = LV_SCALE_NONE;
|
||||
draw_dsc->pivot.x = lv_area_get_width(&obj->coords) / 2;
|
||||
draw_dsc->pivot.y = lv_area_get_height(&obj->coords) / 2;
|
||||
|
||||
draw_dsc->recolor_opa = lv_obj_get_style_image_recolor_opa(obj, part);
|
||||
draw_dsc->recolor = lv_obj_get_style_image_recolor_filtered(obj, part);
|
||||
|
||||
if(part != LV_PART_MAIN) draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part);
|
||||
}
|
||||
|
||||
void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint32_t part, lv_draw_line_dsc_t * draw_dsc)
|
||||
{
|
||||
draw_dsc->base.obj = obj;
|
||||
draw_dsc->base.part = part;
|
||||
|
||||
draw_dsc->opa = lv_obj_get_style_line_opa(obj, part);
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, part);
|
||||
if(opa < LV_OPA_MAX) {
|
||||
draw_dsc->opa = LV_OPA_MIX2(draw_dsc->opa, opa);
|
||||
}
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
draw_dsc->width = lv_obj_get_style_line_width(obj, part);
|
||||
if(draw_dsc->width == 0) return;
|
||||
|
||||
draw_dsc->color = lv_obj_get_style_line_color_filtered(obj, part);
|
||||
|
||||
draw_dsc->dash_width = lv_obj_get_style_line_dash_width(obj, part);
|
||||
if(draw_dsc->dash_width) {
|
||||
draw_dsc->dash_gap = lv_obj_get_style_line_dash_gap(obj, part);
|
||||
}
|
||||
|
||||
draw_dsc->round_start = lv_obj_get_style_line_rounded(obj, part);
|
||||
draw_dsc->round_end = draw_dsc->round_start;
|
||||
|
||||
if(part != LV_PART_MAIN) draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part);
|
||||
}
|
||||
|
||||
void lv_obj_init_draw_arc_dsc(lv_obj_t * obj, uint32_t part, lv_draw_arc_dsc_t * draw_dsc)
|
||||
{
|
||||
draw_dsc->base.obj = obj;
|
||||
draw_dsc->base.part = part;
|
||||
|
||||
draw_dsc->width = lv_obj_get_style_arc_width(obj, part);
|
||||
if(draw_dsc->width == 0) return;
|
||||
|
||||
draw_dsc->opa = lv_obj_get_style_arc_opa(obj, part);
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, part);
|
||||
if(opa < LV_OPA_MAX) {
|
||||
draw_dsc->opa = LV_OPA_MIX2(draw_dsc->opa, opa);
|
||||
}
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
draw_dsc->color = lv_obj_get_style_arc_color_filtered(obj, part);
|
||||
draw_dsc->img_src = lv_obj_get_style_arc_image_src(obj, part);
|
||||
|
||||
draw_dsc->rounded = lv_obj_get_style_arc_rounded(obj, part);
|
||||
}
|
||||
|
||||
int32_t lv_obj_calculate_ext_draw_size(lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
int32_t s = 0;
|
||||
|
||||
int32_t sh_width = lv_obj_get_style_shadow_width(obj, part);
|
||||
if(sh_width) {
|
||||
lv_opa_t sh_opa = lv_obj_get_style_shadow_opa(obj, part);
|
||||
if(sh_opa > LV_OPA_MIN) {
|
||||
sh_width = sh_width / 2 + 1; /*The blur adds only half width*/
|
||||
sh_width += lv_obj_get_style_shadow_spread(obj, part);
|
||||
int32_t sh_ofs_x = lv_obj_get_style_shadow_offset_x(obj, part);
|
||||
int32_t sh_ofs_y = lv_obj_get_style_shadow_offset_y(obj, part);
|
||||
sh_width += LV_MAX(LV_ABS(sh_ofs_x), LV_ABS(sh_ofs_y));
|
||||
s = LV_MAX(s, sh_width);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t outline_width = lv_obj_get_style_outline_width(obj, part);
|
||||
if(outline_width) {
|
||||
lv_opa_t outline_opa = lv_obj_get_style_outline_opa(obj, part);
|
||||
if(outline_opa > LV_OPA_MIN) {
|
||||
int32_t outline_pad = lv_obj_get_style_outline_pad(obj, part);
|
||||
s = LV_MAX(s, outline_pad + outline_width);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t w = lv_obj_get_style_transform_width(obj, part);
|
||||
int32_t h = lv_obj_get_style_transform_height(obj, part);
|
||||
int32_t wh = LV_MAX(w, h);
|
||||
if(wh > 0) s += wh;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void lv_obj_refresh_ext_draw_size(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
int32_t s_old = _lv_obj_get_ext_draw_size(obj);
|
||||
int32_t s_new = 0;
|
||||
lv_obj_send_event(obj, LV_EVENT_REFR_EXT_DRAW_SIZE, &s_new);
|
||||
|
||||
/*Store the result if the special attrs already allocated*/
|
||||
if(obj->spec_attr) {
|
||||
obj->spec_attr->ext_draw_size = s_new;
|
||||
}
|
||||
/*Allocate spec. attrs. only if the result is not zero.
|
||||
*Zero is the default value if the spec. attr. are not defined.*/
|
||||
else if(s_new != 0) {
|
||||
lv_obj_allocate_spec_attr(obj);
|
||||
obj->spec_attr->ext_draw_size = s_new;
|
||||
}
|
||||
|
||||
if(s_new != s_old) lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
int32_t _lv_obj_get_ext_draw_size(const lv_obj_t * obj)
|
||||
{
|
||||
if(obj->spec_attr) return obj->spec_attr->ext_draw_size;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
lv_layer_type_t _lv_obj_get_layer_type(const lv_obj_t * obj)
|
||||
{
|
||||
|
||||
if(obj->spec_attr) return (lv_layer_type_t)obj->spec_attr->layer_type;
|
||||
else return LV_LAYER_TYPE_NONE;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
118
libraries/lvgl/src/core/lv_obj_draw.h
Normal file
118
libraries/lvgl/src/core/lv_obj_draw.h
Normal file
@ -0,0 +1,118 @@
|
||||
/**
|
||||
* @file lv_obj_draw.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBJ_DRAW_H
|
||||
#define LV_OBJ_DRAW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../draw/lv_draw.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_LAYER_TYPE_NONE,
|
||||
LV_LAYER_TYPE_SIMPLE,
|
||||
LV_LAYER_TYPE_TRANSFORM,
|
||||
} lv_layer_type_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a rectangle draw descriptor from an object's styles in its current state
|
||||
* @param obj pointer to an object
|
||||
* @param part part of the object, e.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc
|
||||
* @param draw_dsc the descriptor to initialize.
|
||||
* If an `..._opa` field is set to `LV_OPA_TRANSP` the related properties won't be initialized.
|
||||
* Should be initialized with `lv_draw_rect_dsc_init(draw_dsc)`.
|
||||
* @note Only the relevant fields will be set.
|
||||
* E.g. if `border width == 0` the other border properties won't be evaluated.
|
||||
*/
|
||||
void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t * draw_dsc);
|
||||
|
||||
/**
|
||||
* Initialize a label draw descriptor from an object's styles in its current state
|
||||
* @param obj pointer to an object
|
||||
* @param part part of the object, e.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc
|
||||
* @param draw_dsc the descriptor to initialize.
|
||||
* If the `opa` field is set to or the property is equal to `LV_OPA_TRANSP` the rest won't be initialized.
|
||||
* Should be initialized with `lv_draw_label_dsc_init(draw_dsc)`.
|
||||
*/
|
||||
void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint32_t part, lv_draw_label_dsc_t * draw_dsc);
|
||||
|
||||
/**
|
||||
* Initialize an image draw descriptor from an object's styles in its current state
|
||||
* @param obj pointer to an object
|
||||
* @param part part of the object, e.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc
|
||||
* @param draw_dsc the descriptor to initialize.
|
||||
* Should be initialized with `lv_draw_image_dsc_init(draw_dsc)`.
|
||||
*/
|
||||
void lv_obj_init_draw_image_dsc(lv_obj_t * obj, uint32_t part, lv_draw_image_dsc_t * draw_dsc);
|
||||
|
||||
/**
|
||||
* Initialize a line draw descriptor from an object's styles in its current state
|
||||
* @param obj pointer to an object
|
||||
* @param part part of the object, e.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc
|
||||
* @param draw_dsc the descriptor to initialize.
|
||||
* Should be initialized with `lv_draw_line_dsc_init(draw_dsc)`.
|
||||
*/
|
||||
void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint32_t part, lv_draw_line_dsc_t * draw_dsc);
|
||||
|
||||
/**
|
||||
* Initialize an arc draw descriptor from an object's styles in its current state
|
||||
* @param obj pointer to an object
|
||||
* @param part part of the object, e.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc
|
||||
* @param draw_dsc the descriptor to initialize.
|
||||
* Should be initialized with `lv_draw_arc_dsc_init(draw_dsc)`.
|
||||
*/
|
||||
void lv_obj_init_draw_arc_dsc(lv_obj_t * obj, uint32_t part, lv_draw_arc_dsc_t * draw_dsc);
|
||||
|
||||
/**
|
||||
* Get the required extra size (around the object's part) to draw shadow, outline, value etc.
|
||||
* @param obj pointer to an object
|
||||
* @param part part of the object
|
||||
* @return the extra size required around the object
|
||||
*/
|
||||
int32_t lv_obj_calculate_ext_draw_size(lv_obj_t * obj, uint32_t part);
|
||||
|
||||
/**
|
||||
* Send a 'LV_EVENT_REFR_EXT_DRAW_SIZE' Call the ancestor's event handler to the object to refresh the value of the extended draw size.
|
||||
* The result will be saved in `obj`.
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refresh_ext_draw_size(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the extended draw area of an object.
|
||||
* @param obj pointer to an object
|
||||
* @return the size extended draw area around the real coordinates
|
||||
*/
|
||||
int32_t _lv_obj_get_ext_draw_size(const lv_obj_t * obj);
|
||||
|
||||
lv_layer_type_t _lv_obj_get_layer_type(const lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBJ_DRAW_H*/
|
||||
414
libraries/lvgl/src/core/lv_obj_event.c
Normal file
414
libraries/lvgl/src/core/lv_obj_event.c
Normal file
@ -0,0 +1,414 @@
|
||||
/**
|
||||
* @file lv_obj_event.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_obj.h"
|
||||
#include "../indev/lv_indev.h"
|
||||
#include "../indev/lv_indev_private.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS (&lv_obj_class)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_result_t event_send_core(lv_event_t * e);
|
||||
static bool event_is_bubbled(lv_event_t * e);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#if LV_USE_LOG && LV_LOG_TRACE_EVENT
|
||||
#define LV_TRACE_EVENT(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||
#else
|
||||
#define LV_TRACE_EVENT(...)
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_result_t lv_obj_send_event(lv_obj_t * obj, lv_event_code_t event_code, void * param)
|
||||
{
|
||||
if(obj == NULL) return LV_RESULT_OK;
|
||||
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_event_t e;
|
||||
e.current_target = obj;
|
||||
e.original_target = obj;
|
||||
e.code = event_code;
|
||||
e.user_data = NULL;
|
||||
e.param = param;
|
||||
e.deleted = 0;
|
||||
e.stop_bubbling = 0;
|
||||
e.stop_processing = 0;
|
||||
|
||||
_lv_event_push(&e);
|
||||
|
||||
/*Send the event*/
|
||||
lv_result_t res = event_send_core(&e);
|
||||
|
||||
/*Remove this element from the list*/
|
||||
_lv_event_pop(&e);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
lv_result_t lv_obj_event_base(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
{
|
||||
const lv_obj_class_t * base;
|
||||
if(class_p == NULL) base = ((lv_obj_t *)e->current_target)->class_p;
|
||||
else base = class_p->base_class;
|
||||
|
||||
/*Find a base in which call the ancestor's event handler_cb if set*/
|
||||
while(base && base->event_cb == NULL) base = base->base_class;
|
||||
|
||||
if(base == NULL) return LV_RESULT_OK;
|
||||
if(base->event_cb == NULL) return LV_RESULT_OK;
|
||||
|
||||
/*Call the actual event callback*/
|
||||
e->user_data = NULL;
|
||||
base->event_cb(base, e);
|
||||
|
||||
lv_result_t res = LV_RESULT_OK;
|
||||
/*Stop if the object is deleted*/
|
||||
if(e->deleted) res = LV_RESULT_INVALID;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
lv_event_dsc_t * lv_obj_add_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb, lv_event_code_t filter, void * user_data)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_obj_allocate_spec_attr(obj);
|
||||
|
||||
return lv_event_add(&obj->spec_attr->event_list, event_cb, filter, user_data);
|
||||
}
|
||||
|
||||
uint32_t lv_obj_get_event_count(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_NULL(obj);
|
||||
if(obj->spec_attr == NULL) return 0;
|
||||
return lv_event_get_count(&obj->spec_attr->event_list);
|
||||
}
|
||||
|
||||
lv_event_dsc_t * lv_obj_get_event_dsc(lv_obj_t * obj, uint32_t index)
|
||||
{
|
||||
LV_ASSERT_NULL(obj);
|
||||
if(obj->spec_attr == NULL) return NULL;
|
||||
return lv_event_get_dsc(&obj->spec_attr->event_list, index);
|
||||
}
|
||||
|
||||
bool lv_obj_remove_event(lv_obj_t * obj, uint32_t index)
|
||||
{
|
||||
LV_ASSERT_NULL(obj);
|
||||
if(obj->spec_attr == NULL) return false;
|
||||
return lv_event_remove(&obj->spec_attr->event_list, index);
|
||||
}
|
||||
|
||||
bool lv_obj_remove_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb)
|
||||
{
|
||||
LV_ASSERT_NULL(obj);
|
||||
|
||||
uint32_t event_cnt = lv_obj_get_event_count(obj);
|
||||
uint32_t i;
|
||||
for(i = 0; i < event_cnt; i++) {
|
||||
lv_event_dsc_t * dsc = lv_obj_get_event_dsc(obj, i);
|
||||
if(dsc->cb == event_cb) {
|
||||
lv_obj_remove_event(obj, i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool lv_obj_remove_event_dsc(lv_obj_t * obj, lv_event_dsc_t * dsc)
|
||||
{
|
||||
LV_ASSERT_NULL(obj);
|
||||
LV_ASSERT_NULL(dsc);
|
||||
if(obj->spec_attr == NULL) return false;
|
||||
return lv_event_remove_dsc(&obj->spec_attr->event_list, dsc);
|
||||
}
|
||||
|
||||
uint32_t lv_obj_remove_event_cb_with_user_data(lv_obj_t * obj, lv_event_cb_t event_cb, void * user_data)
|
||||
{
|
||||
LV_ASSERT_NULL(obj);
|
||||
|
||||
uint32_t event_cnt = lv_obj_get_event_count(obj);
|
||||
uint32_t removed_count = 0;
|
||||
int32_t i;
|
||||
|
||||
for(i = event_cnt - 1; i >= 0; i--) {
|
||||
lv_event_dsc_t * dsc = lv_obj_get_event_dsc(obj, i);
|
||||
if(dsc && dsc->cb == event_cb && dsc->user_data == user_data) {
|
||||
lv_obj_remove_event(obj, i);
|
||||
removed_count ++;
|
||||
}
|
||||
}
|
||||
|
||||
return removed_count;
|
||||
}
|
||||
|
||||
lv_obj_t * lv_event_get_current_target_obj(lv_event_t * e)
|
||||
{
|
||||
return lv_event_get_current_target(e);
|
||||
}
|
||||
|
||||
lv_obj_t * lv_event_get_target_obj(lv_event_t * e)
|
||||
{
|
||||
return lv_event_get_target(e);
|
||||
}
|
||||
|
||||
lv_indev_t * lv_event_get_indev(lv_event_t * e)
|
||||
{
|
||||
|
||||
if(e->code == LV_EVENT_PRESSED ||
|
||||
e->code == LV_EVENT_PRESSING ||
|
||||
e->code == LV_EVENT_PRESS_LOST ||
|
||||
e->code == LV_EVENT_SHORT_CLICKED ||
|
||||
e->code == LV_EVENT_LONG_PRESSED ||
|
||||
e->code == LV_EVENT_LONG_PRESSED_REPEAT ||
|
||||
e->code == LV_EVENT_CLICKED ||
|
||||
e->code == LV_EVENT_RELEASED ||
|
||||
e->code == LV_EVENT_SCROLL_BEGIN ||
|
||||
e->code == LV_EVENT_SCROLL_END ||
|
||||
e->code == LV_EVENT_SCROLL ||
|
||||
e->code == LV_EVENT_GESTURE ||
|
||||
e->code == LV_EVENT_KEY ||
|
||||
e->code == LV_EVENT_FOCUSED ||
|
||||
e->code == LV_EVENT_DEFOCUSED ||
|
||||
e->code == LV_EVENT_LEAVE) {
|
||||
return lv_event_get_param(e);
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
lv_layer_t * lv_event_get_layer(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_DRAW_MAIN ||
|
||||
e->code == LV_EVENT_DRAW_MAIN_BEGIN ||
|
||||
e->code == LV_EVENT_DRAW_MAIN_END ||
|
||||
e->code == LV_EVENT_DRAW_POST ||
|
||||
e->code == LV_EVENT_DRAW_POST_BEGIN ||
|
||||
e->code == LV_EVENT_DRAW_POST_END) {
|
||||
return lv_event_get_param(e);
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const lv_area_t * lv_event_get_old_size(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_SIZE_CHANGED) {
|
||||
return lv_event_get_param(e);
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t lv_event_get_key(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_KEY) {
|
||||
uint32_t * k = lv_event_get_param(e);
|
||||
if(k) return *k;
|
||||
else return 0;
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t lv_event_get_rotary_diff(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_ROTARY) {
|
||||
int32_t * r = lv_event_get_param(e);
|
||||
if(r) return *r;
|
||||
else return 0;
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
lv_anim_t * lv_event_get_scroll_anim(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_SCROLL_BEGIN) {
|
||||
return lv_event_get_param(e);
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_event_set_ext_draw_size(lv_event_t * e, int32_t size)
|
||||
{
|
||||
if(e->code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
|
||||
int32_t * cur_size = lv_event_get_param(e);
|
||||
*cur_size = LV_MAX(*cur_size, size);
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
}
|
||||
}
|
||||
|
||||
lv_point_t * lv_event_get_self_size_info(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_GET_SELF_SIZE) {
|
||||
return lv_event_get_param(e);
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
lv_hit_test_info_t * lv_event_get_hit_test_info(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_HIT_TEST) {
|
||||
return lv_event_get_param(e);
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const lv_area_t * lv_event_get_cover_area(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_COVER_CHECK) {
|
||||
lv_cover_check_info_t * p = lv_event_get_param(e);
|
||||
return p->area;
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_event_set_cover_res(lv_event_t * e, lv_cover_res_t res)
|
||||
{
|
||||
if(e->code == LV_EVENT_COVER_CHECK) {
|
||||
lv_cover_check_info_t * p = lv_event_get_param(e);
|
||||
if(res > p->res) p->res = res; /*Save only "stronger" results*/
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
}
|
||||
}
|
||||
|
||||
lv_draw_task_t * lv_event_get_draw_task(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_DRAW_TASK_ADDED) {
|
||||
return lv_event_get_param(e);
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static lv_result_t event_send_core(lv_event_t * e)
|
||||
{
|
||||
LV_TRACE_EVENT("Sending event %d to %p with %p param", e->code, (void *)e->original_target, e->param);
|
||||
|
||||
/*Call the input device's feedback callback if set*/
|
||||
lv_indev_t * indev_act = lv_indev_active();
|
||||
if(indev_act) {
|
||||
if(e->stop_processing) return LV_RESULT_OK;
|
||||
if(e->deleted) return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
lv_obj_t * target = e->current_target;
|
||||
lv_result_t res = LV_RESULT_OK;
|
||||
lv_event_list_t * list = target->spec_attr ? &target->spec_attr->event_list : NULL;
|
||||
|
||||
res = lv_event_send(list, e, true);
|
||||
if(res != LV_RESULT_OK) return res;
|
||||
|
||||
res = lv_obj_event_base(NULL, e);
|
||||
if(res != LV_RESULT_OK) return res;
|
||||
|
||||
res = lv_event_send(list, e, false);
|
||||
if(res != LV_RESULT_OK) return res;
|
||||
|
||||
lv_obj_t * parent = lv_obj_get_parent(e->current_target);
|
||||
if(parent && event_is_bubbled(e)) {
|
||||
e->current_target = parent;
|
||||
res = event_send_core(e);
|
||||
if(res != LV_RESULT_OK) return res;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static bool event_is_bubbled(lv_event_t * e)
|
||||
{
|
||||
if(e->stop_bubbling) return false;
|
||||
|
||||
/*Event codes that always bubble*/
|
||||
switch(e->code) {
|
||||
case LV_EVENT_CHILD_CREATED:
|
||||
case LV_EVENT_CHILD_DELETED:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*Check other codes only if bubbling is enabled*/
|
||||
if(lv_obj_has_flag(e->current_target, LV_OBJ_FLAG_EVENT_BUBBLE) == false) return false;
|
||||
|
||||
switch(e->code) {
|
||||
case LV_EVENT_HIT_TEST:
|
||||
case LV_EVENT_COVER_CHECK:
|
||||
case LV_EVENT_REFR_EXT_DRAW_SIZE:
|
||||
case LV_EVENT_DRAW_MAIN_BEGIN:
|
||||
case LV_EVENT_DRAW_MAIN:
|
||||
case LV_EVENT_DRAW_MAIN_END:
|
||||
case LV_EVENT_DRAW_POST_BEGIN:
|
||||
case LV_EVENT_DRAW_POST:
|
||||
case LV_EVENT_DRAW_POST_END:
|
||||
case LV_EVENT_DRAW_TASK_ADDED:
|
||||
case LV_EVENT_REFRESH:
|
||||
case LV_EVENT_DELETE:
|
||||
case LV_EVENT_CHILD_CREATED:
|
||||
case LV_EVENT_CHILD_DELETED:
|
||||
case LV_EVENT_CHILD_CHANGED:
|
||||
case LV_EVENT_SIZE_CHANGED:
|
||||
case LV_EVENT_STYLE_CHANGED:
|
||||
case LV_EVENT_GET_SELF_SIZE:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
221
libraries/lvgl/src/core/lv_obj_event.h
Normal file
221
libraries/lvgl/src/core/lv_obj_event.h
Normal file
@ -0,0 +1,221 @@
|
||||
/**
|
||||
* @file lv_obj_event.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBJ_EVENT_H
|
||||
#define LV_OBJ_EVENT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../misc/lv_event.h"
|
||||
#include "../indev/lv_indev.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Used as the event parameter of ::LV_EVENT_HIT_TEST to check if an `point` can click the object or not.
|
||||
* `res` should be set like this:
|
||||
* - If already set to `false` an other event wants that point non clickable. If you want to respect it leave it as `false` or set `true` to overwrite it.
|
||||
* - If already set `true` and `point` shouldn't be clickable set to `false`
|
||||
* - If already set to `true` you agree that `point` can click the object leave it as `true`
|
||||
*/
|
||||
typedef struct {
|
||||
const lv_point_t * point; /**< A point relative to screen to check if it can click the object or not*/
|
||||
bool res; /**< true: `point` can click the object; false: it cannot*/
|
||||
} lv_hit_test_info_t;
|
||||
|
||||
/** Cover check results.*/
|
||||
typedef enum {
|
||||
LV_COVER_RES_COVER = 0,
|
||||
LV_COVER_RES_NOT_COVER = 1,
|
||||
LV_COVER_RES_MASKED = 2,
|
||||
} lv_cover_res_t;
|
||||
|
||||
/**
|
||||
* Used as the event parameter of ::LV_EVENT_COVER_CHECK to check if an area is covered by the object or not.
|
||||
* In the event use `const lv_area_t * area = lv_event_get_cover_area(e)` to get the area to check
|
||||
* and `lv_event_set_cover_res(e, res)` to set the result.
|
||||
*/
|
||||
typedef struct {
|
||||
lv_cover_res_t res;
|
||||
const lv_area_t * area;
|
||||
} lv_cover_check_info_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Send an event to the object
|
||||
* @param obj pointer to an object
|
||||
* @param event_code the type of the event from `lv_event_t`
|
||||
* @param param arbitrary data depending on the widget type and the event. (Usually `NULL`)
|
||||
* @return LV_RESULT_OK: `obj` was not deleted in the event; LV_RESULT_INVALID: `obj` was deleted in the event_code
|
||||
*/
|
||||
lv_result_t lv_obj_send_event(lv_obj_t * obj, lv_event_code_t event_code, void * param);
|
||||
|
||||
/**
|
||||
* Used by the widgets internally to call the ancestor widget types's event handler
|
||||
* @param class_p pointer to the class of the widget (NOT the ancestor class)
|
||||
* @param e pointer to the event descriptor
|
||||
* @return LV_RESULT_OK: the target object was not deleted in the event; LV_RESULT_INVALID: it was deleted in the event_code
|
||||
*/
|
||||
lv_result_t lv_obj_event_base(const lv_obj_class_t * class_p, lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the current target of the event. It's the object which event handler being called.
|
||||
* If the event is not bubbled it's the same as "original" target.
|
||||
* @param e pointer to the event descriptor
|
||||
* @return the target of the event_code
|
||||
*/
|
||||
lv_obj_t * lv_event_get_current_target_obj(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the object originally targeted by the event. It's the same even if the event is bubbled.
|
||||
* @param e pointer to the event descriptor
|
||||
* @return pointer to the original target of the event_code
|
||||
*/
|
||||
lv_obj_t * lv_event_get_target_obj(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Add an event handler function for an object.
|
||||
* Used by the user to react on event which happens with the object.
|
||||
* An object can have multiple event handler. They will be called in the same order as they were added.
|
||||
* @param obj pointer to an object
|
||||
* @param filter an event code (e.g. `LV_EVENT_CLICKED`) on which the event should be called. `LV_EVENT_ALL` can be used to receive all the events.
|
||||
* @param event_cb the new event function
|
||||
* @param user_data custom data data will be available in `event_cb`
|
||||
* @return handler to the event. It can be used in `lv_obj_remove_event_dsc`.
|
||||
*/
|
||||
lv_event_dsc_t * lv_obj_add_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb, lv_event_code_t filter, void * user_data);
|
||||
|
||||
uint32_t lv_obj_get_event_count(lv_obj_t * obj);
|
||||
|
||||
lv_event_dsc_t * lv_obj_get_event_dsc(lv_obj_t * obj, uint32_t index);
|
||||
|
||||
bool lv_obj_remove_event(lv_obj_t * obj, uint32_t index);
|
||||
|
||||
bool lv_obj_remove_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb);
|
||||
|
||||
bool lv_obj_remove_event_dsc(lv_obj_t * obj, lv_event_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Remove an event_cb with user_data
|
||||
* @param obj pointer to a obj
|
||||
* @param event_cb the event_cb of the event to remove
|
||||
* @param user_data user_data
|
||||
* @return the count of the event removed
|
||||
*/
|
||||
uint32_t lv_obj_remove_event_cb_with_user_data(lv_obj_t * obj, lv_event_cb_t event_cb, void * user_data);
|
||||
|
||||
/**
|
||||
* Get the input device passed as parameter to indev related events.
|
||||
* @param e pointer to an event
|
||||
* @return the indev that triggered the event or NULL if called on a not indev related event
|
||||
*/
|
||||
lv_indev_t * lv_event_get_indev(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the draw context which should be the first parameter of the draw functions.
|
||||
* Namely: `LV_EVENT_DRAW_MAIN/POST`, `LV_EVENT_DRAW_MAIN/POST_BEGIN`, `LV_EVENT_DRAW_MAIN/POST_END`
|
||||
* @param e pointer to an event
|
||||
* @return pointer to a draw context or NULL if called on an unrelated event
|
||||
*/
|
||||
lv_layer_t * lv_event_get_layer(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the old area of the object before its size was changed. Can be used in `LV_EVENT_SIZE_CHANGED`
|
||||
* @param e pointer to an event
|
||||
* @return the old absolute area of the object or NULL if called on an unrelated event
|
||||
*/
|
||||
const lv_area_t * lv_event_get_old_size(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the key passed as parameter to an event. Can be used in `LV_EVENT_KEY`
|
||||
* @param e pointer to an event
|
||||
* @return the triggering key or NULL if called on an unrelated event
|
||||
*/
|
||||
uint32_t lv_event_get_key(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the signed rotary encoder diff. passed as parameter to an event. Can be used in `LV_EVENT_ROTARY`
|
||||
* @param e pointer to an event
|
||||
* @return the triggering key or NULL if called on an unrelated event
|
||||
*/
|
||||
int32_t lv_event_get_rotary_diff(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get the animation descriptor of a scrolling. Can be used in `LV_EVENT_SCROLL_BEGIN`
|
||||
* @param e pointer to an event
|
||||
* @return the animation that will scroll the object. (can be modified as required)
|
||||
*/
|
||||
lv_anim_t * lv_event_get_scroll_anim(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Set the new extra draw size. Can be used in `LV_EVENT_REFR_EXT_DRAW_SIZE`
|
||||
* @param e pointer to an event
|
||||
* @param size The new extra draw size
|
||||
*/
|
||||
void lv_event_set_ext_draw_size(lv_event_t * e, int32_t size);
|
||||
|
||||
/**
|
||||
* Get a pointer to an `lv_point_t` variable in which the self size should be saved (width in `point->x` and height `point->y`).
|
||||
* Can be used in `LV_EVENT_GET_SELF_SIZE`
|
||||
* @param e pointer to an event
|
||||
* @return pointer to `lv_point_t` or NULL if called on an unrelated event
|
||||
*/
|
||||
lv_point_t * lv_event_get_self_size_info(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get a pointer to an `lv_hit_test_info_t` variable in which the hit test result should be saved. Can be used in `LV_EVENT_HIT_TEST`
|
||||
* @param e pointer to an event
|
||||
* @return pointer to `lv_hit_test_info_t` or NULL if called on an unrelated event
|
||||
*/
|
||||
lv_hit_test_info_t * lv_event_get_hit_test_info(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Get a pointer to an area which should be examined whether the object fully covers it or not.
|
||||
* Can be used in `LV_EVENT_HIT_TEST`
|
||||
* @param e pointer to an event
|
||||
* @return an area with absolute coordinates to check
|
||||
*/
|
||||
const lv_area_t * lv_event_get_cover_area(lv_event_t * e);
|
||||
|
||||
/**
|
||||
* Set the result of cover checking. Can be used in `LV_EVENT_COVER_CHECK`
|
||||
* @param e pointer to an event
|
||||
* @param res an element of ::lv_cover_check_info_t
|
||||
*/
|
||||
void lv_event_set_cover_res(lv_event_t * e, lv_cover_res_t res);
|
||||
|
||||
/**
|
||||
* Get the draw task which was just added.
|
||||
* Can be used in `LV_EVENT_DRAW_TASK_ADDED event`
|
||||
* @param e pointer to an event
|
||||
* @return the added draw task
|
||||
*/
|
||||
lv_draw_task_t * lv_event_get_draw_task(lv_event_t * e);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBJ_EVENT_H*/
|
||||
108
libraries/lvgl/src/core/lv_obj_id_builtin.c
Normal file
108
libraries/lvgl/src/core/lv_obj_id_builtin.c
Normal file
@ -0,0 +1,108 @@
|
||||
/**
|
||||
* @file lv_obj_id.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_obj.h"
|
||||
#include "lv_global.h"
|
||||
#include "../osal/lv_os.h"
|
||||
#include "../stdlib/lv_sprintf.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
typedef struct _class_info_t {
|
||||
const lv_obj_class_t * class_p;
|
||||
uint32_t obj_count;
|
||||
} class_info_t;
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#if LV_USE_OBJ_ID_BUILTIN
|
||||
|
||||
void lv_obj_assign_id(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT(obj && class_p);
|
||||
|
||||
uint32_t i;
|
||||
uint32_t id = 0;
|
||||
lv_global_t * global = LV_GLOBAL_DEFAULT();
|
||||
class_info_t * info = NULL;
|
||||
|
||||
if(obj == NULL || class_p == NULL) return;
|
||||
if(global == NULL) return;
|
||||
|
||||
obj->id = NULL;
|
||||
|
||||
for(i = 0; i < global->objid_count; i ++) {
|
||||
info = ((class_info_t *)global->objid_array) + i;
|
||||
if(class_p == info->class_p) break;
|
||||
}
|
||||
|
||||
/*Resize array*/
|
||||
if(i == global->objid_count) {
|
||||
void * array = lv_realloc(global->objid_array, sizeof(class_info_t) * (global->objid_count + 1));
|
||||
LV_ASSERT_MALLOC(array);
|
||||
if(array == NULL) return;
|
||||
global->objid_array = array;
|
||||
global->objid_count ++;
|
||||
info = ((class_info_t *)global->objid_array) + i;
|
||||
info->obj_count = 0;
|
||||
info->class_p = class_p;
|
||||
}
|
||||
|
||||
id = ++info->obj_count;
|
||||
|
||||
obj->id = (void *)(lv_uintptr_t)id;
|
||||
}
|
||||
|
||||
void lv_obj_free_id(lv_obj_t * obj)
|
||||
{
|
||||
LV_UNUSED(obj);
|
||||
}
|
||||
|
||||
const char * lv_obj_stringify_id(lv_obj_t * obj, char * buf, uint32_t len)
|
||||
{
|
||||
const char * name;
|
||||
if(obj == NULL || obj->class_p == NULL) return NULL;
|
||||
if(buf == NULL) return NULL;
|
||||
|
||||
name = obj->class_p->name;
|
||||
if(name == NULL) name = "nameless";
|
||||
|
||||
lv_snprintf(buf, len, "%s%" LV_PRId32 "", name, (uint32_t)(lv_uintptr_t)obj->id);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void lv_objid_builtin_destroy(void)
|
||||
{
|
||||
lv_global_t * global = LV_GLOBAL_DEFAULT();
|
||||
if(global == NULL) return;
|
||||
|
||||
lv_free(global->objid_array);
|
||||
global->objid_count = 0;
|
||||
}
|
||||
|
||||
#endif /*LV_USE_OBJ_ID_BUILTIN*/
|
||||
1163
libraries/lvgl/src/core/lv_obj_pos.c
Normal file
1163
libraries/lvgl/src/core/lv_obj_pos.c
Normal file
File diff suppressed because it is too large
Load Diff
454
libraries/lvgl/src/core/lv_obj_pos.h
Normal file
454
libraries/lvgl/src/core/lv_obj_pos.h
Normal file
@ -0,0 +1,454 @@
|
||||
/**
|
||||
* @file lv_obj_pos.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBJ_POS_H
|
||||
#define LV_OBJ_POS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../misc/lv_area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
/** No flags */
|
||||
LV_OBJ_POINT_TRANSFORM_FLAG_NONE = 0x00,
|
||||
|
||||
/** Consider the transformation properties of the parents too */
|
||||
LV_OBJ_POINT_TRANSFORM_FLAG_RECURSIVE = 0x01,
|
||||
|
||||
/** Execute the inverse of the transformation (-angle and 1/zoom) */
|
||||
LV_OBJ_POINT_TRANSFORM_FLAG_INVERSE = 0x02,
|
||||
|
||||
/** Both inverse and recursive*/
|
||||
LV_OBJ_POINT_TRANSFORM_FLAG_INVERSE_RECURSIVE = 0x03,
|
||||
} lv_obj_point_transform_flag_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Set the position of an object relative to the set alignment.
|
||||
* @param obj pointer to an object
|
||||
* @param x new x coordinate
|
||||
* @param y new y coordinate
|
||||
* @note With default alignment it's the distance from the top left corner
|
||||
* @note E.g. LV_ALIGN_CENTER alignment it's the offset from the center of the parent
|
||||
* @note The position is interpreted on the content area of the parent
|
||||
* @note The values can be set in pixel or in percentage of parent size with `lv_pct(v)`
|
||||
*/
|
||||
void lv_obj_set_pos(lv_obj_t * obj, int32_t x, int32_t y);
|
||||
|
||||
/**
|
||||
* Set the x coordinate of an object
|
||||
* @param obj pointer to an object
|
||||
* @param x new x coordinate
|
||||
* @note With default alignment it's the distance from the top left corner
|
||||
* @note E.g. LV_ALIGN_CENTER alignment it's the offset from the center of the parent
|
||||
* @note The position is interpreted on the content area of the parent
|
||||
* @note The values can be set in pixel or in percentage of parent size with `lv_pct(v)`
|
||||
*/
|
||||
void lv_obj_set_x(lv_obj_t * obj, int32_t x);
|
||||
|
||||
/**
|
||||
* Set the y coordinate of an object
|
||||
* @param obj pointer to an object
|
||||
* @param y new y coordinate
|
||||
* @note With default alignment it's the distance from the top left corner
|
||||
* @note E.g. LV_ALIGN_CENTER alignment it's the offset from the center of the parent
|
||||
* @note The position is interpreted on the content area of the parent
|
||||
* @note The values can be set in pixel or in percentage of parent size with `lv_pct(v)`
|
||||
*/
|
||||
void lv_obj_set_y(lv_obj_t * obj, int32_t y);
|
||||
|
||||
/**
|
||||
* Set the size of an object.
|
||||
* @param obj pointer to an object
|
||||
* @param w the new width
|
||||
* @param h the new height
|
||||
* @note possible values are:
|
||||
* pixel simple set the size accordingly
|
||||
* LV_SIZE_CONTENT set the size to involve all children in the given direction
|
||||
* lv_pct(x) to set size in percentage of the parent's content area size (the size without paddings).
|
||||
* x should be in [0..1000]% range
|
||||
*/
|
||||
void lv_obj_set_size(lv_obj_t * obj, int32_t w, int32_t h);
|
||||
|
||||
/**
|
||||
* Recalculate the size of the object
|
||||
* @param obj pointer to an object
|
||||
* @return true: the size has been changed
|
||||
*/
|
||||
bool lv_obj_refr_size(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Set the width of an object
|
||||
* @param obj pointer to an object
|
||||
* @param w the new width
|
||||
* @note possible values are:
|
||||
* pixel simple set the size accordingly
|
||||
* LV_SIZE_CONTENT set the size to involve all children in the given direction
|
||||
* lv_pct(x) to set size in percentage of the parent's content area size (the size without paddings).
|
||||
* x should be in [0..1000]% range
|
||||
*/
|
||||
void lv_obj_set_width(lv_obj_t * obj, int32_t w);
|
||||
|
||||
/**
|
||||
* Set the height of an object
|
||||
* @param obj pointer to an object
|
||||
* @param h the new height
|
||||
* @note possible values are:
|
||||
* pixel simple set the size accordingly
|
||||
* LV_SIZE_CONTENT set the size to involve all children in the given direction
|
||||
* lv_pct(x) to set size in percentage of the parent's content area size (the size without paddings).
|
||||
* x should be in [0..1000]% range
|
||||
*/
|
||||
void lv_obj_set_height(lv_obj_t * obj, int32_t h);
|
||||
|
||||
/**
|
||||
* Set the width reduced by the left and right padding and the border width.
|
||||
* @param obj pointer to an object
|
||||
* @param w the width without paddings in pixels
|
||||
*/
|
||||
void lv_obj_set_content_width(lv_obj_t * obj, int32_t w);
|
||||
|
||||
/**
|
||||
* Set the height reduced by the top and bottom padding and the border width.
|
||||
* @param obj pointer to an object
|
||||
* @param h the height without paddings in pixels
|
||||
*/
|
||||
void lv_obj_set_content_height(lv_obj_t * obj, int32_t h);
|
||||
|
||||
/**
|
||||
* Set a layout for an object
|
||||
* @param obj pointer to an object
|
||||
* @param layout pointer to a layout descriptor to set
|
||||
*/
|
||||
void lv_obj_set_layout(lv_obj_t * obj, uint32_t layout);
|
||||
|
||||
/**
|
||||
* Test whether the and object is positioned by a layout or not
|
||||
* @param obj pointer to an object to test
|
||||
* @return true: positioned by a layout; false: not positioned by a layout
|
||||
*/
|
||||
bool lv_obj_is_layout_positioned(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Mark the object for layout update.
|
||||
* @param obj pointer to an object whose children needs to be updated
|
||||
*/
|
||||
void lv_obj_mark_layout_as_dirty(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Update the layout of an object.
|
||||
* @param obj pointer to an object whose children needs to be updated
|
||||
*/
|
||||
void lv_obj_update_layout(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Change the alignment of an object.
|
||||
* @param obj pointer to an object to align
|
||||
* @param align type of alignment (see 'lv_align_t' enum) `LV_ALIGN_OUT_...` can't be used.
|
||||
*/
|
||||
void lv_obj_set_align(lv_obj_t * obj, lv_align_t align);
|
||||
|
||||
/**
|
||||
* Change the alignment of an object and set new coordinates.
|
||||
* Equivalent to:
|
||||
* lv_obj_set_align(obj, align);
|
||||
* lv_obj_set_pos(obj, x_ofs, y_ofs);
|
||||
* @param obj pointer to an object to align
|
||||
* @param align type of alignment (see 'lv_align_t' enum) `LV_ALIGN_OUT_...` can't be used.
|
||||
* @param x_ofs x coordinate offset after alignment
|
||||
* @param y_ofs y coordinate offset after alignment
|
||||
*/
|
||||
void lv_obj_align(lv_obj_t * obj, lv_align_t align, int32_t x_ofs, int32_t y_ofs);
|
||||
|
||||
/**
|
||||
* Align an object to an other object.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an other object (if NULL `obj`s 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
|
||||
* @param y_ofs y coordinate offset after alignment
|
||||
* @note if the position or size of `base` changes `obj` needs to be aligned manually again
|
||||
*/
|
||||
void lv_obj_align_to(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, int32_t x_ofs,
|
||||
int32_t y_ofs);
|
||||
|
||||
/**
|
||||
* Align an object to the center on its parent.
|
||||
* @param obj pointer to an object to align
|
||||
* @note if the parent size changes `obj` needs to be aligned manually again
|
||||
*/
|
||||
static inline void lv_obj_center(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_align(obj, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the coordinates of an object to an area
|
||||
* @param obj pointer to an object
|
||||
* @param coords pointer to an area to store the coordinates
|
||||
*/
|
||||
void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * coords);
|
||||
|
||||
/**
|
||||
* Get the x coordinate of object.
|
||||
* @param obj pointer to an object
|
||||
* @return distance of `obj` from the left side of its parent plus the parent's left padding
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @note Zero return value means the object is on the left padding of the parent, and not on the left edge.
|
||||
* @note Scrolling of the parent doesn't change the returned value.
|
||||
* @note The returned value is always the distance from the parent even if `obj` is positioned by a layout.
|
||||
*/
|
||||
int32_t lv_obj_get_x(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the x2 coordinate of object.
|
||||
* @param obj pointer to an object
|
||||
* @return distance of `obj` from the right side of its parent plus the parent's right padding
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @note Zero return value means the object is on the right padding of the parent, and not on the right edge.
|
||||
* @note Scrolling of the parent doesn't change the returned value.
|
||||
* @note The returned value is always the distance from the parent even if `obj` is positioned by a layout.
|
||||
*/
|
||||
int32_t lv_obj_get_x2(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the y coordinate of object.
|
||||
* @param obj pointer to an object
|
||||
* @return distance of `obj` from the top side of its parent plus the parent's top padding
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @note Zero return value means the object is on the top padding of the parent, and not on the top edge.
|
||||
* @note Scrolling of the parent doesn't change the returned value.
|
||||
* @note The returned value is always the distance from the parent even if `obj` is positioned by a layout.
|
||||
*/
|
||||
int32_t lv_obj_get_y(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the y2 coordinate of object.
|
||||
* @param obj pointer to an object
|
||||
* @return distance of `obj` from the bottom side of its parent plus the parent's bottom padding
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @note Zero return value means the object is on the bottom padding of the parent, and not on the bottom edge.
|
||||
* @note Scrolling of the parent doesn't change the returned value.
|
||||
* @note The returned value is always the distance from the parent even if `obj` is positioned by a layout.
|
||||
*/
|
||||
int32_t lv_obj_get_y2(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the actually set x coordinate of object, i.e. the offset form the set alignment
|
||||
* @param obj pointer to an object
|
||||
* @return the set x coordinate
|
||||
*/
|
||||
int32_t lv_obj_get_x_aligned(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the actually set y coordinate of object, i.e. the offset form the set alignment
|
||||
* @param obj pointer to an object
|
||||
* @return the set y coordinate
|
||||
*/
|
||||
int32_t lv_obj_get_y_aligned(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the width of an object
|
||||
* @param obj pointer to an object
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @return the width in pixels
|
||||
*/
|
||||
int32_t lv_obj_get_width(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the height of an object
|
||||
* @param obj pointer to an object
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @return the height in pixels
|
||||
*/
|
||||
int32_t lv_obj_get_height(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the width reduced by the left and right padding and the border width.
|
||||
* @param obj pointer to an object
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @return the width which still fits into its parent without causing overflow (making the parent scrollable)
|
||||
*/
|
||||
int32_t lv_obj_get_content_width(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the height reduced by the top and bottom padding and the border width.
|
||||
* @param obj pointer to an object
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @return the height which still fits into the parent without causing overflow (making the parent scrollable)
|
||||
*/
|
||||
int32_t lv_obj_get_content_height(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the area reduced by the paddings and the border width.
|
||||
* @param obj pointer to an object
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @param area the area which still fits into the parent without causing overflow (making the parent scrollable)
|
||||
*/
|
||||
void lv_obj_get_content_coords(const lv_obj_t * obj, lv_area_t * area);
|
||||
|
||||
/**
|
||||
* Get the width occupied by the "parts" of the widget. E.g. the width of all columns of a table.
|
||||
* @param obj pointer to an objects
|
||||
* @return the width of the virtually drawn content
|
||||
* @note This size independent from the real size of the widget.
|
||||
* It just tells how large the internal ("virtual") content is.
|
||||
*/
|
||||
int32_t lv_obj_get_self_width(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the height occupied by the "parts" of the widget. E.g. the height of all rows of a table.
|
||||
* @param obj pointer to an objects
|
||||
* @return the width of the virtually drawn content
|
||||
* @note This size independent from the real size of the widget.
|
||||
* It just tells how large the internal ("virtual") content is.
|
||||
*/
|
||||
int32_t lv_obj_get_self_height(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Handle if the size of the internal ("virtual") content of an object has changed.
|
||||
* @param obj pointer to an object
|
||||
* @return false: nothing happened; true: refresh happened
|
||||
*/
|
||||
bool lv_obj_refresh_self_size(lv_obj_t * obj);
|
||||
|
||||
void lv_obj_refr_pos(lv_obj_t * obj);
|
||||
|
||||
void lv_obj_move_to(lv_obj_t * obj, int32_t x, int32_t y);
|
||||
|
||||
void lv_obj_move_children_by(lv_obj_t * obj, int32_t x_diff, int32_t y_diff, bool ignore_floating);
|
||||
|
||||
/**
|
||||
* Transform a point using the angle and zoom style properties of an object
|
||||
* @param obj pointer to an object whose style properties should be used
|
||||
* @param p a point to transform, the result will be written back here too
|
||||
* @param flags OR-ed valued of :cpp:enum:`lv_obj_point_transform_flag_t`
|
||||
*/
|
||||
void lv_obj_transform_point(const lv_obj_t * obj, lv_point_t * p, lv_obj_point_transform_flag_t flags);
|
||||
|
||||
/**
|
||||
* Transform an array of points using the angle and zoom style properties of an object
|
||||
* @param obj pointer to an object whose style properties should be used
|
||||
* @param points the array of points to transform, the result will be written back here too
|
||||
* @param count number of points in the array
|
||||
* @param flags OR-ed valued of :cpp:enum:`lv_obj_point_transform_flag_t`
|
||||
*/
|
||||
void lv_obj_transform_point_array(const lv_obj_t * obj, lv_point_t points[], size_t count,
|
||||
lv_obj_point_transform_flag_t flags);
|
||||
|
||||
/**
|
||||
* Transform an area using the angle and zoom style properties of an object
|
||||
* @param obj pointer to an object whose style properties should be used
|
||||
* @param area an area to transform, the result will be written back here too
|
||||
* @param flags OR-ed valued of :cpp:enum:`lv_obj_point_transform_flag_t`
|
||||
*/
|
||||
void lv_obj_get_transformed_area(const lv_obj_t * obj, lv_area_t * area, lv_obj_point_transform_flag_t flags);
|
||||
|
||||
/**
|
||||
* Mark an area of an object as invalid.
|
||||
* The area will be truncated to the object's area and marked for redraw.
|
||||
* @param obj pointer to an object
|
||||
* @param area the area to redraw
|
||||
*/
|
||||
void lv_obj_invalidate_area(const lv_obj_t * obj, const lv_area_t * area);
|
||||
|
||||
/**
|
||||
* Mark the object as invalid to redrawn its area
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_invalidate(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Tell whether an area of an object is visible (even partially) now or not
|
||||
* @param obj pointer to an object
|
||||
* @param area the are to check. The visible part of the area will be written back here.
|
||||
* @return true visible; false not visible (hidden, out of parent, on other screen, etc)
|
||||
*/
|
||||
bool lv_obj_area_is_visible(const lv_obj_t * obj, lv_area_t * area);
|
||||
|
||||
/**
|
||||
* Tell whether an object is visible (even partially) now or not
|
||||
* @param obj pointer to an object
|
||||
* @return true: visible; false not visible (hidden, out of parent, on other screen, etc)
|
||||
*/
|
||||
bool lv_obj_is_visible(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Set the size of an extended clickable area
|
||||
* @param obj pointer to an object
|
||||
* @param size extended clickable area in all 4 directions [px]
|
||||
*/
|
||||
void lv_obj_set_ext_click_area(lv_obj_t * obj, int32_t size);
|
||||
|
||||
/**
|
||||
* Get the an area where to object can be clicked.
|
||||
* It's the object's normal area plus the extended click area.
|
||||
* @param obj pointer to an object
|
||||
* @param area store the result area here
|
||||
*/
|
||||
void lv_obj_get_click_area(const lv_obj_t * obj, lv_area_t * area);
|
||||
|
||||
/**
|
||||
* Hit-test an object given a particular point in screen space.
|
||||
* @param obj object to hit-test
|
||||
* @param point screen-space point (absolute coordinate)
|
||||
* @return true: if the object is considered under the point
|
||||
*/
|
||||
bool lv_obj_hit_test(lv_obj_t * obj, const lv_point_t * point);
|
||||
|
||||
/**
|
||||
* Clamp a width between min and max width. If the min/max width is in percentage value use the ref_width
|
||||
* @param width width to clamp
|
||||
* @param min_width the minimal width
|
||||
* @param max_width the maximal width
|
||||
* @param ref_width the reference width used when min/max width is in percentage
|
||||
* @return the clamped width
|
||||
*/
|
||||
int32_t lv_clamp_width(int32_t width, int32_t min_width, int32_t max_width, int32_t ref_width);
|
||||
|
||||
/**
|
||||
* Clamp a height between min and max height. If the min/max height is in percentage value use the ref_height
|
||||
* @param height height to clamp
|
||||
* @param min_height the minimal height
|
||||
* @param max_height the maximal height
|
||||
* @param ref_height the reference height used when min/max height is in percentage
|
||||
* @return the clamped height
|
||||
*/
|
||||
int32_t lv_clamp_height(int32_t height, int32_t min_height, int32_t max_height, int32_t ref_height);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBJ_POS_H*/
|
||||
179
libraries/lvgl/src/core/lv_obj_property.c
Normal file
179
libraries/lvgl/src/core/lv_obj_property.c
Normal file
@ -0,0 +1,179 @@
|
||||
/**
|
||||
* @file lv_obj_id.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../core/lv_obj.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
#include "lv_obj_property.h"
|
||||
|
||||
#if LV_USE_OBJ_PROPERTY
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef void (*lv_property_set_int_t)(lv_obj_t *, int32_t);
|
||||
typedef void (*lv_property_set_pointer_t)(lv_obj_t *, const void *);
|
||||
typedef void (*lv_property_set_color_t)(lv_obj_t *, lv_color_t);
|
||||
typedef lv_result_t (*lv_property_setter_t)(lv_obj_t *, lv_prop_id_t, const lv_property_t *);
|
||||
|
||||
typedef int32_t (*lv_property_get_int_t)(const lv_obj_t *);
|
||||
typedef void * (*lv_property_get_pointer_t)(const lv_obj_t *);
|
||||
typedef lv_color_t (*lv_property_get_color_t)(const lv_obj_t *);
|
||||
typedef lv_result_t (*lv_property_getter_t)(const lv_obj_t *, lv_prop_id_t, lv_property_t *);
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
static lv_result_t obj_property(lv_obj_t * obj, lv_prop_id_t id, lv_property_t * value, bool set);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_result_t lv_obj_set_property(lv_obj_t * obj, const lv_property_t * value)
|
||||
{
|
||||
LV_ASSERT(obj && value);
|
||||
|
||||
if(value->id == LV_PROPERTY_ID_INVALID) {
|
||||
LV_LOG_WARN("invalid property id set to %p\n", obj);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
if(value->id < LV_PROPERTY_ID_START) {
|
||||
lv_obj_set_local_style_prop(obj, value->id, value->_style, 0);
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
return obj_property(obj, value->id, (lv_property_t *)value, true);
|
||||
}
|
||||
|
||||
lv_result_t lv_obj_set_properties(lv_obj_t * obj, const lv_property_t * value, uint32_t count)
|
||||
{
|
||||
for(uint32_t i = 0; i < count; i++) {
|
||||
lv_result_t result = lv_obj_set_property(obj, &value[i]);
|
||||
if(result != LV_RESULT_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
lv_property_t lv_obj_get_property(lv_obj_t * obj, lv_prop_id_t id)
|
||||
{
|
||||
lv_result_t result;
|
||||
lv_property_t value;
|
||||
|
||||
if(id == LV_PROPERTY_ID_INVALID) {
|
||||
LV_LOG_WARN("invalid property id to get from %p\n", obj);
|
||||
value.id = 0;
|
||||
value.num = 0;
|
||||
return value;
|
||||
}
|
||||
|
||||
if(id < LV_PROPERTY_ID_START) {
|
||||
lv_obj_get_local_style_prop(obj, id, &value._style, 0);
|
||||
value.id = id;
|
||||
return value;
|
||||
}
|
||||
|
||||
result = obj_property(obj, id, &value, false);
|
||||
if(result != LV_RESULT_OK)
|
||||
value.id = 0;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static lv_result_t obj_property(lv_obj_t * obj, lv_prop_id_t id, lv_property_t * value, bool set)
|
||||
{
|
||||
const lv_property_ops_t * properties;
|
||||
const lv_property_ops_t * prop;
|
||||
|
||||
const lv_obj_class_t * clz;
|
||||
uint32_t index = LV_PROPERTY_ID_INDEX(id);
|
||||
|
||||
for(clz = obj->class_p ; clz; clz = clz->base_class) {
|
||||
properties = clz->properties;
|
||||
if(properties == NULL) {
|
||||
/* try base class*/
|
||||
continue;
|
||||
}
|
||||
|
||||
if(id != LV_PROPERTY_ID_ANY && (index < clz->prop_index_start || index > clz->prop_index_end)) {
|
||||
/* try base class*/
|
||||
continue;
|
||||
}
|
||||
|
||||
/*Check if there's setter available for this class*/
|
||||
for(uint32_t i = 0; i < clz->properties_count; i++) {
|
||||
prop = &properties[i];
|
||||
|
||||
/*pass id and value directly to widget's property method*/
|
||||
if(prop->id == LV_PROPERTY_ID_ANY) {
|
||||
value->id = prop->id;
|
||||
if(set) return ((lv_property_setter_t)prop->setter)(obj, id, value);
|
||||
else return ((lv_property_getter_t)prop->getter)(obj, id, value);
|
||||
}
|
||||
|
||||
/*Not this id, check next*/
|
||||
if(prop->id != id)
|
||||
continue;
|
||||
|
||||
/*id matched but we got null pointer to functions*/
|
||||
if(set ? prop->setter == NULL : prop->getter == NULL) {
|
||||
LV_LOG_WARN("null %s provided, id: %d\n", set ? "setter" : "getter", id);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
/*Update value id if it's a read*/
|
||||
if(!set) value->id = prop->id;
|
||||
|
||||
switch(LV_PROPERTY_ID_TYPE(prop->id)) {
|
||||
case LV_PROPERTY_TYPE_INT:
|
||||
if(set)((lv_property_set_int_t)(prop->setter))(obj, value->num);
|
||||
else value->num = ((lv_property_get_int_t)(prop->getter))(obj);
|
||||
break;
|
||||
case LV_PROPERTY_TYPE_POINTER:
|
||||
case LV_PROPERTY_TYPE_IMGSRC:
|
||||
if(set)((lv_property_set_pointer_t)(prop->setter))(obj, value->ptr);
|
||||
else value->ptr = ((lv_property_get_pointer_t)(prop->getter))(obj);
|
||||
break;
|
||||
case LV_PROPERTY_TYPE_COLOR:
|
||||
if(set)((lv_property_set_color_t)prop->setter)(obj, value->color);
|
||||
else value->color = ((lv_property_get_color_t)(prop->getter))(obj);
|
||||
break;
|
||||
default:
|
||||
LV_LOG_WARN("unknown property id: 0x%08x\n", prop->id);
|
||||
return LV_RESULT_INVALID;
|
||||
break;
|
||||
}
|
||||
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
/*If no setter found, try base class then*/
|
||||
}
|
||||
|
||||
LV_LOG_WARN("unknown property id: 0x%08x\n", id);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
#endif /*LV_USE_OBJ_PROPERTY*/
|
||||
128
libraries/lvgl/src/core/lv_obj_property.h
Normal file
128
libraries/lvgl/src/core/lv_obj_property.h
Normal file
@ -0,0 +1,128 @@
|
||||
/**
|
||||
* @file lv_obj_property.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBJ_PROPERTY_H
|
||||
#define LV_OBJ_PROPERTY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../misc/lv_style.h"
|
||||
|
||||
#if LV_USE_OBJ_PROPERTY
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/*All possible property value types*/
|
||||
#define LV_PROPERTY_TYPE_INVALID 0 /*Use default 0 as invalid to detect program outliers*/
|
||||
#define LV_PROPERTY_TYPE_INT 1 /*int32_t type*/
|
||||
#define LV_PROPERTY_TYPE_PRECISE 2 /*lv_value_precise_t, int32_t or float depending on LV_USE_FLOAT*/
|
||||
#define LV_PROPERTY_TYPE_COLOR 3 /*ARGB8888 type*/
|
||||
#define LV_PROPERTY_TYPE_POINTER 4 /*void * pointer*/
|
||||
#define LV_PROPERTY_TYPE_IMGSRC 5 /*Special pointer for image*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
#define LV_PROPERTY_ID(clz, name, type, index) LV_PROPERTY_## clz ##_##name = (LV_PROPERTY_## clz ##_START + (index)) | ((type) << 28)
|
||||
|
||||
#define LV_PROPERTY_ID_TYPE(id) ((id) >> 28)
|
||||
#define LV_PROPERTY_ID_INDEX(id) ((id) & 0xfffffff)
|
||||
|
||||
/*Set properties from an array of lv_property_t*/
|
||||
#define LV_OBJ_SET_PROPERTY_ARRAY(obj, array) lv_obj_set_properties(obj, array, sizeof(array)/sizeof(array[0]))
|
||||
|
||||
/**
|
||||
* Group of predefined widget ID start value.
|
||||
*/
|
||||
enum {
|
||||
LV_PROPERTY_ID_INVALID = 0,
|
||||
|
||||
/*ID 0 to 0xff are style ID, check lv_style_prop_t*/
|
||||
LV_PROPERTY_ID_START = 0x100, /*ID little than 0xff is style ID*/
|
||||
|
||||
/* lv_obj.c */
|
||||
LV_PROPERTY_OBJ_START = 1000,
|
||||
|
||||
/* lv_image.c */
|
||||
LV_PROPERTY_IMAGE_START = 1100,
|
||||
|
||||
/*Special ID*/
|
||||
LV_PROPERTY_ID_BUILTIN_LAST, /*Use it to extend ID and make sure it's unique and compile time determinant*/
|
||||
|
||||
LV_PROPERTY_ID_ANY = 0x7ffffffe, /*Special ID used by lvgl to intercept all setter/getter call.*/
|
||||
};
|
||||
|
||||
typedef uint32_t lv_prop_id_t;
|
||||
|
||||
typedef struct {
|
||||
lv_prop_id_t id;
|
||||
union {
|
||||
int32_t num; /**< Number integer number (opacity, enums, booleans or "normal" numbers)*/
|
||||
const void * ptr; /**< Constant pointers (font, cone text, etc)*/
|
||||
lv_color_t color; /**< Colors*/
|
||||
lv_value_precise_t precise; /**< float or int for precise value*/
|
||||
lv_style_value_t _style; /**< A place holder for style value which is same as property value.*/
|
||||
};
|
||||
} lv_property_t;
|
||||
|
||||
typedef struct {
|
||||
lv_prop_id_t id;
|
||||
|
||||
void * setter;
|
||||
void * getter;
|
||||
} lv_property_ops_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set widget property value.
|
||||
* @param obj pointer to an object
|
||||
* @param id ID of which property
|
||||
* @param value The property value to set
|
||||
* @return return LV_RESULT_OK if success
|
||||
*/
|
||||
lv_result_t lv_obj_set_property(lv_obj_t * obj, const lv_property_t * value);
|
||||
|
||||
lv_result_t lv_obj_set_properties(lv_obj_t * obj, const lv_property_t * value, uint32_t count);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Read property value from object
|
||||
* @param obj pointer to an object
|
||||
* @param id ID of which property
|
||||
* @param value pointer to a buffer to store the value
|
||||
* @return ? to be discussed, LV_RESULT_OK or LV_RESULT_INVALID
|
||||
*/
|
||||
lv_property_t lv_obj_get_property(lv_obj_t * obj, lv_prop_id_t id);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OBJ_PROPERTY*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBJ_PROPERTY_H*/
|
||||
795
libraries/lvgl/src/core/lv_obj_scroll.c
Normal file
795
libraries/lvgl/src/core/lv_obj_scroll.c
Normal file
@ -0,0 +1,795 @@
|
||||
/**
|
||||
* @file lv_obj_scroll.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_obj_scroll.h"
|
||||
#include "lv_obj.h"
|
||||
#include "../indev/lv_indev.h"
|
||||
#include "../indev/lv_indev_scroll.h"
|
||||
#include "../display/lv_display.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS (&lv_obj_class)
|
||||
#define SCROLL_ANIM_TIME_MIN 200 /*ms*/
|
||||
#define SCROLL_ANIM_TIME_MAX 400 /*ms*/
|
||||
#define SCROLLBAR_MIN_SIZE (LV_DPX(10))
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void scroll_x_anim(void * obj, int32_t v);
|
||||
static void scroll_y_anim(void * obj, int32_t v);
|
||||
static void scroll_completed_completed_cb(lv_anim_t * a);
|
||||
static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_point_t * scroll_value,
|
||||
lv_anim_enable_t anim_en);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
void lv_obj_set_scrollbar_mode(lv_obj_t * obj, lv_scrollbar_mode_t mode)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_obj_allocate_spec_attr(obj);
|
||||
|
||||
if(obj->spec_attr->scrollbar_mode == mode) return;
|
||||
obj->spec_attr->scrollbar_mode = mode;
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
void lv_obj_set_scroll_dir(lv_obj_t * obj, lv_dir_t dir)
|
||||
{
|
||||
lv_obj_allocate_spec_attr(obj);
|
||||
|
||||
if(dir != obj->spec_attr->scroll_dir) {
|
||||
obj->spec_attr->scroll_dir = dir;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_obj_set_scroll_snap_x(lv_obj_t * obj, lv_scroll_snap_t align)
|
||||
{
|
||||
lv_obj_allocate_spec_attr(obj);
|
||||
obj->spec_attr->scroll_snap_x = align;
|
||||
}
|
||||
|
||||
void lv_obj_set_scroll_snap_y(lv_obj_t * obj, lv_scroll_snap_t align)
|
||||
{
|
||||
lv_obj_allocate_spec_attr(obj);
|
||||
obj->spec_attr->scroll_snap_y = align;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
lv_scrollbar_mode_t lv_obj_get_scrollbar_mode(const lv_obj_t * obj)
|
||||
{
|
||||
if(obj->spec_attr) return (lv_scrollbar_mode_t) obj->spec_attr->scrollbar_mode;
|
||||
else return LV_SCROLLBAR_MODE_AUTO;
|
||||
}
|
||||
|
||||
lv_dir_t lv_obj_get_scroll_dir(const lv_obj_t * obj)
|
||||
{
|
||||
if(obj->spec_attr) return (lv_dir_t) obj->spec_attr->scroll_dir;
|
||||
else return LV_DIR_ALL;
|
||||
}
|
||||
|
||||
lv_scroll_snap_t lv_obj_get_scroll_snap_x(const lv_obj_t * obj)
|
||||
{
|
||||
if(obj->spec_attr) return (lv_scroll_snap_t) obj->spec_attr->scroll_snap_x;
|
||||
else return LV_SCROLL_SNAP_NONE;
|
||||
}
|
||||
|
||||
lv_scroll_snap_t lv_obj_get_scroll_snap_y(const lv_obj_t * obj)
|
||||
{
|
||||
if(obj->spec_attr) return (lv_scroll_snap_t) obj->spec_attr->scroll_snap_y;
|
||||
else return LV_SCROLL_SNAP_NONE;
|
||||
}
|
||||
|
||||
int32_t lv_obj_get_scroll_x(const lv_obj_t * obj)
|
||||
{
|
||||
if(obj->spec_attr == NULL) return 0;
|
||||
return -obj->spec_attr->scroll.x;
|
||||
}
|
||||
|
||||
int32_t lv_obj_get_scroll_y(const lv_obj_t * obj)
|
||||
{
|
||||
if(obj->spec_attr == NULL) return 0;
|
||||
return -obj->spec_attr->scroll.y;
|
||||
}
|
||||
|
||||
int32_t lv_obj_get_scroll_top(lv_obj_t * obj)
|
||||
{
|
||||
if(obj->spec_attr == NULL) return 0;
|
||||
return -obj->spec_attr->scroll.y;
|
||||
}
|
||||
|
||||
int32_t lv_obj_get_scroll_bottom(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
int32_t child_res = LV_COORD_MIN;
|
||||
uint32_t i;
|
||||
uint32_t child_cnt = lv_obj_get_child_count(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
|
||||
int32_t tmp_y = child->coords.y2 + lv_obj_get_style_margin_bottom(child, LV_PART_MAIN);
|
||||
child_res = LV_MAX(child_res, tmp_y);
|
||||
}
|
||||
|
||||
int32_t space_top = lv_obj_get_style_space_top(obj, LV_PART_MAIN);
|
||||
int32_t space_bottom = lv_obj_get_style_space_bottom(obj, LV_PART_MAIN);
|
||||
|
||||
if(child_res != LV_COORD_MIN) {
|
||||
child_res -= (obj->coords.y2 - space_bottom);
|
||||
}
|
||||
|
||||
int32_t self_h = lv_obj_get_self_height(obj);
|
||||
self_h = self_h - (lv_obj_get_height(obj) - space_top - space_bottom);
|
||||
self_h -= lv_obj_get_scroll_y(obj);
|
||||
return LV_MAX(child_res, self_h);
|
||||
}
|
||||
|
||||
int32_t lv_obj_get_scroll_left(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
/*Normally can't scroll the object out on the left.
|
||||
*So simply use the current scroll position as "left size"*/
|
||||
if(lv_obj_get_style_base_dir(obj, LV_PART_MAIN) != LV_BASE_DIR_RTL) {
|
||||
if(obj->spec_attr == NULL) return 0;
|
||||
return -obj->spec_attr->scroll.x;
|
||||
}
|
||||
|
||||
/*With RTL base direction scrolling the left is normal so find the left most coordinate*/
|
||||
int32_t space_right = lv_obj_get_style_space_right(obj, LV_PART_MAIN);
|
||||
int32_t space_left = lv_obj_get_style_space_left(obj, LV_PART_MAIN);
|
||||
|
||||
int32_t child_res = 0;
|
||||
|
||||
uint32_t i;
|
||||
int32_t x1 = LV_COORD_MAX;
|
||||
uint32_t child_cnt = lv_obj_get_child_count(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
|
||||
int32_t tmp_x = child->coords.x1 - lv_obj_get_style_margin_left(child, LV_PART_MAIN);
|
||||
x1 = LV_MIN(x1, tmp_x);
|
||||
}
|
||||
|
||||
if(x1 != LV_COORD_MAX) {
|
||||
child_res = x1;
|
||||
child_res = (obj->coords.x1 + space_left) - child_res;
|
||||
}
|
||||
else {
|
||||
child_res = LV_COORD_MIN;
|
||||
}
|
||||
|
||||
int32_t self_w = lv_obj_get_self_width(obj);
|
||||
self_w = self_w - (lv_obj_get_width(obj) - space_right - space_left);
|
||||
self_w += lv_obj_get_scroll_x(obj);
|
||||
|
||||
return LV_MAX(child_res, self_w);
|
||||
}
|
||||
|
||||
int32_t lv_obj_get_scroll_right(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
/*With RTL base dir can't scroll to the object out on the right.
|
||||
*So simply use the current scroll position as "right size"*/
|
||||
if(lv_obj_get_style_base_dir(obj, LV_PART_MAIN) == LV_BASE_DIR_RTL) {
|
||||
if(obj->spec_attr == NULL) return 0;
|
||||
return obj->spec_attr->scroll.x;
|
||||
}
|
||||
|
||||
/*With other base direction (LTR) scrolling to the right is normal so find the right most coordinate*/
|
||||
int32_t child_res = LV_COORD_MIN;
|
||||
uint32_t i;
|
||||
uint32_t child_cnt = lv_obj_get_child_count(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
|
||||
int32_t tmp_x = child->coords.x2 + lv_obj_get_style_margin_right(child, LV_PART_MAIN);
|
||||
child_res = LV_MAX(child_res, tmp_x);
|
||||
}
|
||||
|
||||
int32_t space_right = lv_obj_get_style_space_right(obj, LV_PART_MAIN);
|
||||
int32_t space_left = lv_obj_get_style_space_left(obj, LV_PART_MAIN);
|
||||
|
||||
if(child_res != LV_COORD_MIN) {
|
||||
child_res -= (obj->coords.x2 - space_right);
|
||||
}
|
||||
|
||||
int32_t self_w;
|
||||
self_w = lv_obj_get_self_width(obj);
|
||||
self_w = self_w - (lv_obj_get_width(obj) - space_right - space_left);
|
||||
self_w -= lv_obj_get_scroll_x(obj);
|
||||
return LV_MAX(child_res, self_w);
|
||||
}
|
||||
|
||||
void lv_obj_get_scroll_end(lv_obj_t * obj, lv_point_t * end)
|
||||
{
|
||||
lv_anim_t * a;
|
||||
a = lv_anim_get(obj, scroll_x_anim);
|
||||
end->x = a ? -a->end_value : lv_obj_get_scroll_x(obj);
|
||||
|
||||
a = lv_anim_get(obj, scroll_y_anim);
|
||||
end->y = a ? -a->end_value : lv_obj_get_scroll_y(obj);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
void lv_obj_scroll_by_bounded(lv_obj_t * obj, int32_t dx, int32_t dy, lv_anim_enable_t anim_en)
|
||||
{
|
||||
if(dx == 0 && dy == 0) return;
|
||||
|
||||
/*We need to know the final sizes for bound check*/
|
||||
lv_obj_update_layout(obj);
|
||||
|
||||
/*Don't let scroll more than naturally possible by the size of the content*/
|
||||
int32_t x_current = -lv_obj_get_scroll_x(obj);
|
||||
int32_t x_bounded = x_current + dx;
|
||||
|
||||
if(lv_obj_get_style_base_dir(obj, LV_PART_MAIN) != LV_BASE_DIR_RTL) {
|
||||
if(x_bounded > 0) x_bounded = 0;
|
||||
if(x_bounded < 0) {
|
||||
int32_t scroll_max = lv_obj_get_scroll_left(obj) + lv_obj_get_scroll_right(obj);
|
||||
if(scroll_max < 0) scroll_max = 0;
|
||||
|
||||
if(x_bounded < -scroll_max) x_bounded = -scroll_max;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(x_bounded < 0) x_bounded = 0;
|
||||
if(x_bounded > 0) {
|
||||
int32_t scroll_max = lv_obj_get_scroll_left(obj) + lv_obj_get_scroll_right(obj);
|
||||
if(scroll_max < 0) scroll_max = 0;
|
||||
|
||||
if(x_bounded > scroll_max) x_bounded = scroll_max;
|
||||
}
|
||||
}
|
||||
|
||||
/*Don't let scroll more than naturally possible by the size of the content*/
|
||||
int32_t y_current = -lv_obj_get_scroll_y(obj);
|
||||
int32_t y_bounded = y_current + dy;
|
||||
|
||||
if(y_bounded > 0) y_bounded = 0;
|
||||
if(y_bounded < 0) {
|
||||
int32_t scroll_max = lv_obj_get_scroll_top(obj) + lv_obj_get_scroll_bottom(obj);
|
||||
if(scroll_max < 0) scroll_max = 0;
|
||||
if(y_bounded < -scroll_max) y_bounded = -scroll_max;
|
||||
}
|
||||
|
||||
dx = x_bounded - x_current;
|
||||
dy = y_bounded - y_current;
|
||||
if(dx || dy) {
|
||||
lv_obj_scroll_by(obj, dx, dy, anim_en);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_obj_scroll_by(lv_obj_t * obj, int32_t dx, int32_t dy, lv_anim_enable_t anim_en)
|
||||
{
|
||||
if(dx == 0 && dy == 0) return;
|
||||
if(anim_en == LV_ANIM_ON) {
|
||||
lv_display_t * d = lv_obj_get_display(obj);
|
||||
lv_anim_t a;
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, obj);
|
||||
lv_anim_set_completed_cb(&a, scroll_completed_completed_cb);
|
||||
|
||||
if(dx) {
|
||||
uint32_t t = lv_anim_speed_clamped((lv_display_get_horizontal_resolution(d)) >> 1, SCROLL_ANIM_TIME_MIN,
|
||||
SCROLL_ANIM_TIME_MAX);
|
||||
lv_anim_set_duration(&a, t);
|
||||
int32_t sx = lv_obj_get_scroll_x(obj);
|
||||
lv_anim_set_values(&a, -sx, -sx + dx);
|
||||
lv_anim_set_exec_cb(&a, scroll_x_anim);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_ease_out);
|
||||
|
||||
lv_result_t res;
|
||||
res = lv_obj_send_event(obj, LV_EVENT_SCROLL_BEGIN, &a);
|
||||
if(res != LV_RESULT_OK) return;
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
|
||||
if(dy) {
|
||||
uint32_t t = lv_anim_speed_clamped((lv_display_get_vertical_resolution(d)) >> 1, SCROLL_ANIM_TIME_MIN,
|
||||
SCROLL_ANIM_TIME_MAX);
|
||||
lv_anim_set_duration(&a, t);
|
||||
int32_t sy = lv_obj_get_scroll_y(obj);
|
||||
lv_anim_set_values(&a, -sy, -sy + dy);
|
||||
lv_anim_set_exec_cb(&a, scroll_y_anim);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_ease_out);
|
||||
|
||||
lv_result_t res;
|
||||
res = lv_obj_send_event(obj, LV_EVENT_SCROLL_BEGIN, &a);
|
||||
if(res != LV_RESULT_OK) return;
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*Remove pending animations*/
|
||||
lv_anim_delete(obj, scroll_y_anim);
|
||||
lv_anim_delete(obj, scroll_x_anim);
|
||||
|
||||
lv_result_t res;
|
||||
res = lv_obj_send_event(obj, LV_EVENT_SCROLL_BEGIN, NULL);
|
||||
if(res != LV_RESULT_OK) return;
|
||||
|
||||
res = _lv_obj_scroll_by_raw(obj, dx, dy);
|
||||
if(res != LV_RESULT_OK) return;
|
||||
|
||||
res = lv_obj_send_event(obj, LV_EVENT_SCROLL_END, NULL);
|
||||
if(res != LV_RESULT_OK) return;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_obj_scroll_to(lv_obj_t * obj, int32_t x, int32_t y, lv_anim_enable_t anim_en)
|
||||
{
|
||||
lv_obj_scroll_to_x(obj, x, anim_en);
|
||||
lv_obj_scroll_to_y(obj, y, anim_en);
|
||||
}
|
||||
|
||||
void lv_obj_scroll_to_x(lv_obj_t * obj, int32_t x, lv_anim_enable_t anim_en)
|
||||
{
|
||||
lv_anim_delete(obj, scroll_x_anim);
|
||||
|
||||
int32_t scroll_x = lv_obj_get_scroll_x(obj);
|
||||
int32_t diff = -x + scroll_x;
|
||||
|
||||
lv_obj_scroll_by_bounded(obj, diff, 0, anim_en);
|
||||
}
|
||||
|
||||
void lv_obj_scroll_to_y(lv_obj_t * obj, int32_t y, lv_anim_enable_t anim_en)
|
||||
{
|
||||
lv_anim_delete(obj, scroll_y_anim);
|
||||
|
||||
int32_t scroll_y = lv_obj_get_scroll_y(obj);
|
||||
int32_t diff = -y + scroll_y;
|
||||
|
||||
lv_obj_scroll_by_bounded(obj, 0, diff, anim_en);
|
||||
}
|
||||
|
||||
void lv_obj_scroll_to_view(lv_obj_t * obj, lv_anim_enable_t anim_en)
|
||||
{
|
||||
/*Be sure the screens layout is correct*/
|
||||
lv_obj_update_layout(obj);
|
||||
|
||||
lv_point_t p = {0, 0};
|
||||
scroll_area_into_view(&obj->coords, obj, &p, anim_en);
|
||||
}
|
||||
|
||||
void lv_obj_scroll_to_view_recursive(lv_obj_t * obj, lv_anim_enable_t anim_en)
|
||||
{
|
||||
/*Be sure the screens layout is correct*/
|
||||
lv_obj_update_layout(obj);
|
||||
|
||||
lv_point_t p = {0, 0};
|
||||
lv_obj_t * child = obj;
|
||||
lv_obj_t * parent = lv_obj_get_parent(child);
|
||||
while(parent) {
|
||||
scroll_area_into_view(&obj->coords, child, &p, anim_en);
|
||||
child = parent;
|
||||
parent = lv_obj_get_parent(parent);
|
||||
}
|
||||
}
|
||||
|
||||
lv_result_t _lv_obj_scroll_by_raw(lv_obj_t * obj, int32_t x, int32_t y)
|
||||
{
|
||||
if(x == 0 && y == 0) return LV_RESULT_OK;
|
||||
|
||||
lv_obj_allocate_spec_attr(obj);
|
||||
|
||||
obj->spec_attr->scroll.x += x;
|
||||
obj->spec_attr->scroll.y += y;
|
||||
|
||||
lv_obj_move_children_by(obj, x, y, true);
|
||||
lv_result_t res = lv_obj_send_event(obj, LV_EVENT_SCROLL, NULL);
|
||||
if(res != LV_RESULT_OK) return res;
|
||||
lv_obj_invalidate(obj);
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
bool lv_obj_is_scrolling(const lv_obj_t * obj)
|
||||
{
|
||||
lv_indev_t * indev = lv_indev_get_next(NULL);
|
||||
while(indev) {
|
||||
if(lv_indev_get_scroll_obj(indev) == obj) return true;
|
||||
indev = lv_indev_get_next(indev);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void lv_obj_update_snap(lv_obj_t * obj, lv_anim_enable_t anim_en)
|
||||
{
|
||||
lv_obj_update_layout(obj);
|
||||
lv_point_t p;
|
||||
lv_indev_scroll_get_snap_dist(obj, &p);
|
||||
lv_obj_scroll_by(obj, p.x, p.y, anim_en);
|
||||
}
|
||||
|
||||
void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t * ver_area)
|
||||
{
|
||||
lv_area_set(hor_area, 0, 0, -1, -1);
|
||||
lv_area_set(ver_area, 0, 0, -1, -1);
|
||||
|
||||
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_SCROLLABLE) == false) return;
|
||||
|
||||
lv_dir_t sm = lv_obj_get_scrollbar_mode(obj);
|
||||
if(sm == LV_SCROLLBAR_MODE_OFF) return;
|
||||
|
||||
/*If there is no indev scrolling this object but `mode==active` return*/
|
||||
lv_indev_t * indev = lv_indev_get_next(NULL);
|
||||
if(sm == LV_SCROLLBAR_MODE_ACTIVE) {
|
||||
while(indev) {
|
||||
if(lv_indev_get_scroll_obj(indev) == obj) break;
|
||||
indev = lv_indev_get_next(indev);
|
||||
}
|
||||
if(indev == NULL) return;
|
||||
}
|
||||
|
||||
int32_t st = lv_obj_get_scroll_top(obj);
|
||||
int32_t sb = lv_obj_get_scroll_bottom(obj);
|
||||
int32_t sl = lv_obj_get_scroll_left(obj);
|
||||
int32_t sr = lv_obj_get_scroll_right(obj);
|
||||
|
||||
lv_dir_t dir = lv_obj_get_scroll_dir(obj);
|
||||
|
||||
bool ver_draw = false;
|
||||
if((dir & LV_DIR_VER) &&
|
||||
((sm == LV_SCROLLBAR_MODE_ON) ||
|
||||
(sm == LV_SCROLLBAR_MODE_AUTO && (st > 0 || sb > 0)) ||
|
||||
(sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_DIR_VER))) {
|
||||
ver_draw = true;
|
||||
}
|
||||
|
||||
bool hor_draw = false;
|
||||
if((dir & LV_DIR_HOR) &&
|
||||
((sm == LV_SCROLLBAR_MODE_ON) ||
|
||||
(sm == LV_SCROLLBAR_MODE_AUTO && (sl > 0 || sr > 0)) ||
|
||||
(sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_DIR_HOR))) {
|
||||
hor_draw = true;
|
||||
}
|
||||
|
||||
if(!hor_draw && !ver_draw) return;
|
||||
|
||||
bool rtl = lv_obj_get_style_base_dir(obj, LV_PART_SCROLLBAR) == LV_BASE_DIR_RTL;
|
||||
|
||||
int32_t top_space = lv_obj_get_style_pad_top(obj, LV_PART_SCROLLBAR);
|
||||
int32_t bottom_space = lv_obj_get_style_pad_bottom(obj, LV_PART_SCROLLBAR);
|
||||
int32_t left_space = lv_obj_get_style_pad_left(obj, LV_PART_SCROLLBAR);
|
||||
int32_t right_space = lv_obj_get_style_pad_right(obj, LV_PART_SCROLLBAR);
|
||||
int32_t thickness = lv_obj_get_style_width(obj, LV_PART_SCROLLBAR);
|
||||
|
||||
int32_t obj_h = lv_obj_get_height(obj);
|
||||
int32_t obj_w = lv_obj_get_width(obj);
|
||||
|
||||
/*Space required for the vertical and horizontal scrollbars*/
|
||||
int32_t ver_reg_space = ver_draw ? thickness : 0;
|
||||
int32_t hor_req_space = hor_draw ? thickness : 0;
|
||||
int32_t rem;
|
||||
|
||||
if(lv_obj_get_style_bg_opa(obj, LV_PART_SCROLLBAR) < LV_OPA_MIN &&
|
||||
lv_obj_get_style_border_opa(obj, LV_PART_SCROLLBAR) < LV_OPA_MIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*Draw vertical scrollbar if the mode is ON or can be scrolled in this direction*/
|
||||
int32_t content_h = obj_h + st + sb;
|
||||
if(ver_draw && content_h) {
|
||||
ver_area->y1 = obj->coords.y1;
|
||||
ver_area->y2 = obj->coords.y2;
|
||||
if(rtl) {
|
||||
ver_area->x1 = obj->coords.x1 + left_space;
|
||||
ver_area->x2 = ver_area->x1 + thickness - 1;
|
||||
}
|
||||
else {
|
||||
ver_area->x2 = obj->coords.x2 - right_space;
|
||||
ver_area->x1 = ver_area->x2 - thickness + 1;
|
||||
}
|
||||
|
||||
int32_t sb_h = ((obj_h - top_space - bottom_space - hor_req_space) * obj_h) / content_h;
|
||||
sb_h = LV_MAX(sb_h, SCROLLBAR_MIN_SIZE);
|
||||
rem = (obj_h - top_space - bottom_space - hor_req_space) -
|
||||
sb_h; /*Remaining size from the scrollbar track that is not the scrollbar itself*/
|
||||
int32_t scroll_h = content_h - obj_h; /*The size of the content which can be really scrolled*/
|
||||
if(scroll_h <= 0) {
|
||||
ver_area->y1 = obj->coords.y1 + top_space;
|
||||
ver_area->y2 = obj->coords.y2 - bottom_space - hor_req_space - 1;
|
||||
}
|
||||
else {
|
||||
int32_t sb_y = (rem * sb) / scroll_h;
|
||||
sb_y = rem - sb_y;
|
||||
|
||||
ver_area->y1 = obj->coords.y1 + sb_y + top_space;
|
||||
ver_area->y2 = ver_area->y1 + sb_h - 1;
|
||||
if(ver_area->y1 < obj->coords.y1 + top_space) {
|
||||
ver_area->y1 = obj->coords.y1 + top_space;
|
||||
if(ver_area->y1 + SCROLLBAR_MIN_SIZE > ver_area->y2) {
|
||||
ver_area->y2 = ver_area->y1 + SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
}
|
||||
if(ver_area->y2 > obj->coords.y2 - hor_req_space - bottom_space) {
|
||||
ver_area->y2 = obj->coords.y2 - hor_req_space - bottom_space;
|
||||
if(ver_area->y2 - SCROLLBAR_MIN_SIZE < ver_area->y1) {
|
||||
ver_area->y1 = ver_area->y2 - SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Draw horizontal scrollbar if the mode is ON or can be scrolled in this direction*/
|
||||
int32_t content_w = obj_w + sl + sr;
|
||||
if(hor_draw && content_w) {
|
||||
hor_area->y2 = obj->coords.y2 - bottom_space;
|
||||
hor_area->y1 = hor_area->y2 - thickness + 1;
|
||||
hor_area->x1 = obj->coords.x1;
|
||||
hor_area->x2 = obj->coords.x2;
|
||||
|
||||
int32_t sb_w = ((obj_w - left_space - right_space - ver_reg_space) * obj_w) / content_w;
|
||||
sb_w = LV_MAX(sb_w, SCROLLBAR_MIN_SIZE);
|
||||
rem = (obj_w - left_space - right_space - ver_reg_space) -
|
||||
sb_w; /*Remaining size from the scrollbar track that is not the scrollbar itself*/
|
||||
int32_t scroll_w = content_w - obj_w; /*The size of the content which can be really scrolled*/
|
||||
if(scroll_w <= 0) {
|
||||
if(rtl) {
|
||||
hor_area->x1 = obj->coords.x1 + left_space + ver_reg_space - 1;
|
||||
hor_area->x2 = obj->coords.x2 - right_space;
|
||||
}
|
||||
else {
|
||||
hor_area->x1 = obj->coords.x1 + left_space;
|
||||
hor_area->x2 = obj->coords.x2 - right_space - ver_reg_space - 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int32_t sb_x = (rem * sr) / scroll_w;
|
||||
sb_x = rem - sb_x;
|
||||
|
||||
if(rtl) {
|
||||
hor_area->x1 = obj->coords.x1 + sb_x + left_space + ver_reg_space;
|
||||
hor_area->x2 = hor_area->x1 + sb_w - 1;
|
||||
if(hor_area->x1 < obj->coords.x1 + left_space + ver_reg_space) {
|
||||
hor_area->x1 = obj->coords.x1 + left_space + ver_reg_space;
|
||||
if(hor_area->x1 + SCROLLBAR_MIN_SIZE > hor_area->x2) {
|
||||
hor_area->x2 = hor_area->x1 + SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
}
|
||||
if(hor_area->x2 > obj->coords.x2 - right_space) {
|
||||
hor_area->x2 = obj->coords.x2 - right_space;
|
||||
if(hor_area->x2 - SCROLLBAR_MIN_SIZE < hor_area->x1) {
|
||||
hor_area->x1 = hor_area->x2 - SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
hor_area->x1 = obj->coords.x1 + sb_x + left_space;
|
||||
hor_area->x2 = hor_area->x1 + sb_w - 1;
|
||||
if(hor_area->x1 < obj->coords.x1 + left_space) {
|
||||
hor_area->x1 = obj->coords.x1 + left_space;
|
||||
if(hor_area->x1 + SCROLLBAR_MIN_SIZE > hor_area->x2) {
|
||||
hor_area->x2 = hor_area->x1 + SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
}
|
||||
if(hor_area->x2 > obj->coords.x2 - ver_reg_space - right_space) {
|
||||
hor_area->x2 = obj->coords.x2 - ver_reg_space - right_space;
|
||||
if(hor_area->x2 - SCROLLBAR_MIN_SIZE < hor_area->x1) {
|
||||
hor_area->x1 = hor_area->x2 - SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_obj_scrollbar_invalidate(lv_obj_t * obj)
|
||||
{
|
||||
lv_area_t hor_area;
|
||||
lv_area_t ver_area;
|
||||
lv_obj_get_scrollbar_area(obj, &hor_area, &ver_area);
|
||||
|
||||
if(lv_area_get_size(&hor_area) <= 0 && lv_area_get_size(&ver_area) <= 0) return;
|
||||
|
||||
if(lv_area_get_size(&hor_area) > 0) lv_obj_invalidate_area(obj, &hor_area);
|
||||
if(lv_area_get_size(&ver_area) > 0) lv_obj_invalidate_area(obj, &ver_area);
|
||||
}
|
||||
|
||||
void lv_obj_readjust_scroll(lv_obj_t * obj, lv_anim_enable_t anim_en)
|
||||
{
|
||||
/*Be sure the bottom side is not remains scrolled in*/
|
||||
/*With snapping the content can't be scrolled in*/
|
||||
if(lv_obj_get_scroll_snap_y(obj) == LV_SCROLL_SNAP_NONE) {
|
||||
int32_t st = lv_obj_get_scroll_top(obj);
|
||||
int32_t sb = lv_obj_get_scroll_bottom(obj);
|
||||
if(sb < 0 && st > 0) {
|
||||
sb = LV_MIN(st, -sb);
|
||||
lv_obj_scroll_by(obj, 0, sb, anim_en);
|
||||
}
|
||||
}
|
||||
|
||||
if(lv_obj_get_scroll_snap_x(obj) == LV_SCROLL_SNAP_NONE) {
|
||||
int32_t sl = lv_obj_get_scroll_left(obj);
|
||||
int32_t sr = lv_obj_get_scroll_right(obj);
|
||||
if(lv_obj_get_style_base_dir(obj, LV_PART_MAIN) != LV_BASE_DIR_RTL) {
|
||||
/*Be sure the left side is not remains scrolled in*/
|
||||
if(sr < 0 && sl > 0) {
|
||||
sr = LV_MIN(sl, -sr);
|
||||
lv_obj_scroll_by(obj, sr, 0, anim_en);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*Be sure the right side is not remains scrolled in*/
|
||||
if(sl < 0 && sr > 0) {
|
||||
sr = LV_MIN(sr, -sl);
|
||||
lv_obj_scroll_by(obj, sl, 0, anim_en);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void scroll_x_anim(void * obj, int32_t v)
|
||||
{
|
||||
_lv_obj_scroll_by_raw(obj, v + lv_obj_get_scroll_x(obj), 0);
|
||||
}
|
||||
|
||||
static void scroll_y_anim(void * obj, int32_t v)
|
||||
{
|
||||
_lv_obj_scroll_by_raw(obj, 0, v + lv_obj_get_scroll_y(obj));
|
||||
}
|
||||
|
||||
static void scroll_completed_completed_cb(lv_anim_t * a)
|
||||
{
|
||||
lv_obj_send_event(a->var, LV_EVENT_SCROLL_END, NULL);
|
||||
}
|
||||
|
||||
static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_point_t * scroll_value,
|
||||
lv_anim_enable_t anim_en)
|
||||
{
|
||||
lv_obj_t * parent = lv_obj_get_parent(child);
|
||||
if(!lv_obj_has_flag(parent, LV_OBJ_FLAG_SCROLLABLE)) return;
|
||||
|
||||
lv_dir_t scroll_dir = lv_obj_get_scroll_dir(parent);
|
||||
int32_t snap_goal = 0;
|
||||
int32_t act = 0;
|
||||
const lv_area_t * area_tmp;
|
||||
|
||||
int32_t y_scroll = 0;
|
||||
lv_scroll_snap_t snap_y = lv_obj_get_scroll_snap_y(parent);
|
||||
if(snap_y != LV_SCROLL_SNAP_NONE) area_tmp = &child->coords;
|
||||
else area_tmp = area;
|
||||
|
||||
int32_t stop = lv_obj_get_style_space_top(parent, LV_PART_MAIN);
|
||||
int32_t sbottom = lv_obj_get_style_space_bottom(parent, LV_PART_MAIN);
|
||||
int32_t top_diff = parent->coords.y1 + stop - area_tmp->y1 - scroll_value->y;
|
||||
int32_t bottom_diff = -(parent->coords.y2 - sbottom - area_tmp->y2 - scroll_value->y);
|
||||
int32_t parent_h = lv_obj_get_height(parent) - stop - sbottom;
|
||||
if((top_diff >= 0 && bottom_diff >= 0)) y_scroll = 0;
|
||||
else if(top_diff > 0) {
|
||||
y_scroll = top_diff;
|
||||
/*Do not let scrolling in*/
|
||||
int32_t st = lv_obj_get_scroll_top(parent);
|
||||
if(st - y_scroll < 0) y_scroll = 0;
|
||||
}
|
||||
else if(bottom_diff > 0) {
|
||||
y_scroll = -bottom_diff;
|
||||
/*Do not let scrolling in*/
|
||||
int32_t sb = lv_obj_get_scroll_bottom(parent);
|
||||
if(sb + y_scroll < 0) y_scroll = 0;
|
||||
}
|
||||
|
||||
switch(snap_y) {
|
||||
case LV_SCROLL_SNAP_START:
|
||||
snap_goal = parent->coords.y1 + stop;
|
||||
act = area_tmp->y1 + y_scroll;
|
||||
y_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
snap_goal = parent->coords.y2 - sbottom;
|
||||
act = area_tmp->y2 + y_scroll;
|
||||
y_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
snap_goal = parent->coords.y1 + stop + parent_h / 2;
|
||||
act = lv_area_get_height(area_tmp) / 2 + area_tmp->y1 + y_scroll;
|
||||
y_scroll += snap_goal - act;
|
||||
break;
|
||||
}
|
||||
|
||||
int32_t x_scroll = 0;
|
||||
lv_scroll_snap_t snap_x = lv_obj_get_scroll_snap_x(parent);
|
||||
if(snap_x != LV_SCROLL_SNAP_NONE) area_tmp = &child->coords;
|
||||
else area_tmp = area;
|
||||
|
||||
int32_t sleft = lv_obj_get_style_space_left(parent, LV_PART_MAIN);
|
||||
int32_t sright = lv_obj_get_style_space_right(parent, LV_PART_MAIN);
|
||||
int32_t left_diff = parent->coords.x1 + sleft - area_tmp->x1 - scroll_value->x;
|
||||
int32_t right_diff = -(parent->coords.x2 - sright - area_tmp->x2 - scroll_value->x);
|
||||
if((left_diff >= 0 && right_diff >= 0)) x_scroll = 0;
|
||||
else if(left_diff > 0) {
|
||||
x_scroll = left_diff;
|
||||
/*Do not let scrolling in*/
|
||||
int32_t sl = lv_obj_get_scroll_left(parent);
|
||||
if(sl - x_scroll < 0) x_scroll = 0;
|
||||
}
|
||||
else if(right_diff > 0) {
|
||||
x_scroll = -right_diff;
|
||||
/*Do not let scrolling in*/
|
||||
int32_t sr = lv_obj_get_scroll_right(parent);
|
||||
if(sr + x_scroll < 0) x_scroll = 0;
|
||||
}
|
||||
|
||||
int32_t parent_w = lv_obj_get_width(parent) - sleft - sright;
|
||||
switch(snap_x) {
|
||||
case LV_SCROLL_SNAP_START:
|
||||
snap_goal = parent->coords.x1 + sleft;
|
||||
act = area_tmp->x1 + x_scroll;
|
||||
x_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
snap_goal = parent->coords.x2 - sright;
|
||||
act = area_tmp->x2 + x_scroll;
|
||||
x_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
snap_goal = parent->coords.x1 + sleft + parent_w / 2;
|
||||
act = lv_area_get_width(area_tmp) / 2 + area_tmp->x1 + x_scroll;
|
||||
x_scroll += snap_goal - act;
|
||||
break;
|
||||
}
|
||||
|
||||
/*Remove any pending scroll animations.*/
|
||||
bool y_del = lv_anim_delete(parent, scroll_y_anim);
|
||||
bool x_del = lv_anim_delete(parent, scroll_x_anim);
|
||||
if(y_del || x_del) {
|
||||
lv_result_t res;
|
||||
res = lv_obj_send_event(parent, LV_EVENT_SCROLL_END, NULL);
|
||||
if(res != LV_RESULT_OK) return;
|
||||
}
|
||||
|
||||
if((scroll_dir & LV_DIR_LEFT) == 0 && x_scroll < 0) x_scroll = 0;
|
||||
if((scroll_dir & LV_DIR_RIGHT) == 0 && x_scroll > 0) x_scroll = 0;
|
||||
if((scroll_dir & LV_DIR_TOP) == 0 && y_scroll < 0) y_scroll = 0;
|
||||
if((scroll_dir & LV_DIR_BOTTOM) == 0 && y_scroll > 0) y_scroll = 0;
|
||||
|
||||
scroll_value->x += anim_en == LV_ANIM_OFF ? 0 : x_scroll;
|
||||
scroll_value->y += anim_en == LV_ANIM_OFF ? 0 : y_scroll;
|
||||
lv_obj_scroll_by(parent, x_scroll, y_scroll, anim_en);
|
||||
}
|
||||
314
libraries/lvgl/src/core/lv_obj_scroll.h
Normal file
314
libraries/lvgl/src/core/lv_obj_scroll.h
Normal file
@ -0,0 +1,314 @@
|
||||
/**
|
||||
* @file lv_obj_scroll.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBJ_SCROLL_H
|
||||
#define LV_OBJ_SCROLL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_anim.h"
|
||||
#include "../misc/lv_types.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Can't include lv_obj.h because it includes this header file*/
|
||||
|
||||
/** Scrollbar modes: shows when should the scrollbars be visible*/
|
||||
enum _lv_scrollbar_mode_t {
|
||||
LV_SCROLLBAR_MODE_OFF, /**< Never show scrollbars*/
|
||||
LV_SCROLLBAR_MODE_ON, /**< Always show scrollbars*/
|
||||
LV_SCROLLBAR_MODE_ACTIVE, /**< Show scroll bars when object is being scrolled*/
|
||||
LV_SCROLLBAR_MODE_AUTO, /**< Show scroll bars when the content is large enough to be scrolled*/
|
||||
};
|
||||
|
||||
#ifdef DOXYGEN
|
||||
typedef _lv_scrollbar_mode_t lv_scrollbar_mode_t;
|
||||
#else
|
||||
typedef uint8_t lv_scrollbar_mode_t;
|
||||
#endif /*DOXYGEN*/
|
||||
|
||||
/** Scroll span align options. Tells where to align the snappable children when scroll stops.*/
|
||||
enum _lv_scroll_snap_t {
|
||||
LV_SCROLL_SNAP_NONE, /**< Do not align, leave where it is*/
|
||||
LV_SCROLL_SNAP_START, /**< Align to the left/top*/
|
||||
LV_SCROLL_SNAP_END, /**< Align to the right/bottom*/
|
||||
LV_SCROLL_SNAP_CENTER /**< Align to the center*/
|
||||
};
|
||||
|
||||
#ifdef DOXYGEN
|
||||
typedef _lv_scroll_snap_t lv_scroll_snap_t;
|
||||
#else
|
||||
typedef uint8_t lv_scroll_snap_t;
|
||||
#endif /*DOXYGEN*/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set how the scrollbars should behave.
|
||||
* @param obj pointer to an object
|
||||
* @param mode LV_SCROLL_MODE_ON/OFF/AUTO/ACTIVE
|
||||
*/
|
||||
void lv_obj_set_scrollbar_mode(lv_obj_t * obj, lv_scrollbar_mode_t mode);
|
||||
|
||||
/**
|
||||
* Set the object in which directions can be scrolled
|
||||
* @param obj pointer to an object
|
||||
* @param dir the allow scroll directions. An element or OR-ed values of `lv_dir_t`
|
||||
*/
|
||||
void lv_obj_set_scroll_dir(lv_obj_t * obj, lv_dir_t dir);
|
||||
|
||||
/**
|
||||
* Set where to snap the children when scrolling ends horizontally
|
||||
* @param obj pointer to an object
|
||||
* @param align the snap align to set from `lv_scroll_snap_t`
|
||||
*/
|
||||
void lv_obj_set_scroll_snap_x(lv_obj_t * obj, lv_scroll_snap_t align);
|
||||
|
||||
/**
|
||||
* Set where to snap the children when scrolling ends vertically
|
||||
* @param obj pointer to an object
|
||||
* @param align the snap align to set from `lv_scroll_snap_t`
|
||||
*/
|
||||
void lv_obj_set_scroll_snap_y(lv_obj_t * obj, lv_scroll_snap_t align);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the current scroll mode (when to hide the scrollbars)
|
||||
* @param obj pointer to an object
|
||||
* @return the current scroll mode from `lv_scrollbar_mode_t`
|
||||
*/
|
||||
lv_scrollbar_mode_t lv_obj_get_scrollbar_mode(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the object in which directions can be scrolled
|
||||
* @param obj pointer to an object
|
||||
* @param dir the allow scroll directions. An element or OR-ed values of `lv_dir_t`
|
||||
*/
|
||||
lv_dir_t lv_obj_get_scroll_dir(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get where to snap the children when scrolling ends horizontally
|
||||
* @param obj pointer to an object
|
||||
* @return the current snap align from `lv_scroll_snap_t`
|
||||
*/
|
||||
lv_scroll_snap_t lv_obj_get_scroll_snap_x(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get where to snap the children when scrolling ends vertically
|
||||
* @param obj pointer to an object
|
||||
* @return the current snap align from `lv_scroll_snap_t`
|
||||
*/
|
||||
lv_scroll_snap_t lv_obj_get_scroll_snap_y(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get current X scroll position.
|
||||
* @param obj pointer to an object
|
||||
* @return the current scroll position from the left edge.
|
||||
* If the object is not scrolled return 0
|
||||
* If scrolled return > 0
|
||||
* If scrolled in (elastic scroll) return < 0
|
||||
*/
|
||||
int32_t lv_obj_get_scroll_x(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get current Y scroll position.
|
||||
* @param obj pointer to an object
|
||||
* @return the current scroll position from the top edge.
|
||||
* If the object is not scrolled return 0
|
||||
* If scrolled return > 0
|
||||
* If scrolled inside return < 0
|
||||
*/
|
||||
int32_t lv_obj_get_scroll_y(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Return the height of the area above the object.
|
||||
* That is the number of pixels the object can be scrolled down.
|
||||
* Normally positive but can be negative when scrolled inside.
|
||||
* @param obj pointer to an object
|
||||
* @return the scrollable area above the object in pixels
|
||||
*/
|
||||
int32_t lv_obj_get_scroll_top(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Return the height of the area below the object.
|
||||
* That is the number of pixels the object can be scrolled down.
|
||||
* Normally positive but can be negative when scrolled inside.
|
||||
* @param obj pointer to an object
|
||||
* @return the scrollable area below the object in pixels
|
||||
*/
|
||||
int32_t lv_obj_get_scroll_bottom(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Return the width of the area on the left the object.
|
||||
* That is the number of pixels the object can be scrolled down.
|
||||
* Normally positive but can be negative when scrolled inside.
|
||||
* @param obj pointer to an object
|
||||
* @return the scrollable area on the left the object in pixels
|
||||
*/
|
||||
int32_t lv_obj_get_scroll_left(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Return the width of the area on the right the object.
|
||||
* That is the number of pixels the object can be scrolled down.
|
||||
* Normally positive but can be negative when scrolled inside.
|
||||
* @param obj pointer to an object
|
||||
* @return the scrollable area on the right the object in pixels
|
||||
*/
|
||||
int32_t lv_obj_get_scroll_right(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the X and Y coordinates where the scrolling will end for this object if a scrolling animation is in progress.
|
||||
* If no scrolling animation, give the current `x` or `y` scroll position.
|
||||
* @param obj pointer to an object
|
||||
* @param end pointer to store the result
|
||||
*/
|
||||
void lv_obj_get_scroll_end(lv_obj_t * obj, lv_point_t * end);
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Scroll by a given amount of pixels
|
||||
* @param obj pointer to an object to scroll
|
||||
* @param x pixels to scroll horizontally
|
||||
* @param y pixels to scroll vertically
|
||||
* @param anim_en LV_ANIM_ON: scroll with animation; LV_ANIM_OFF: scroll immediately
|
||||
* @note > 0 value means scroll right/bottom (show the more content on the right/bottom)
|
||||
* @note e.g. dy = -20 means scroll down 20 px
|
||||
*/
|
||||
void lv_obj_scroll_by(lv_obj_t * obj, int32_t x, int32_t y, lv_anim_enable_t anim_en);
|
||||
|
||||
/**
|
||||
* Scroll by a given amount of pixels.
|
||||
* `dx` and `dy` will be limited internally to allow scrolling only on the content area.
|
||||
* @param obj pointer to an object to scroll
|
||||
* @param dx pixels to scroll horizontally
|
||||
* @param dy pixels to scroll vertically
|
||||
* @param anim_en LV_ANIM_ON: scroll with animation; LV_ANIM_OFF: scroll immediately
|
||||
* @note e.g. dy = -20 means scroll down 20 px
|
||||
*/
|
||||
void lv_obj_scroll_by_bounded(lv_obj_t * obj, int32_t dx, int32_t dy, lv_anim_enable_t anim_en);
|
||||
|
||||
/**
|
||||
* Scroll to a given coordinate on an object.
|
||||
* `x` and `y` will be limited internally to allow scrolling only on the content area.
|
||||
* @param obj pointer to an object to scroll
|
||||
* @param x pixels to scroll horizontally
|
||||
* @param y pixels to scroll vertically
|
||||
* @param anim_en LV_ANIM_ON: scroll with animation; LV_ANIM_OFF: scroll immediately
|
||||
*/
|
||||
void lv_obj_scroll_to(lv_obj_t * obj, int32_t x, int32_t y, lv_anim_enable_t anim_en);
|
||||
|
||||
/**
|
||||
* Scroll to a given X coordinate on an object.
|
||||
* `x` will be limited internally to allow scrolling only on the content area.
|
||||
* @param obj pointer to an object to scroll
|
||||
* @param x pixels to scroll horizontally
|
||||
* @param anim_en LV_ANIM_ON: scroll with animation; LV_ANIM_OFF: scroll immediately
|
||||
*/
|
||||
void lv_obj_scroll_to_x(lv_obj_t * obj, int32_t x, lv_anim_enable_t anim_en);
|
||||
|
||||
/**
|
||||
* Scroll to a given Y coordinate on an object
|
||||
* `y` will be limited internally to allow scrolling only on the content area.
|
||||
* @param obj pointer to an object to scroll
|
||||
* @param y pixels to scroll vertically
|
||||
* @param anim_en LV_ANIM_ON: scroll with animation; LV_ANIM_OFF: scroll immediately
|
||||
*/
|
||||
void lv_obj_scroll_to_y(lv_obj_t * obj, int32_t y, lv_anim_enable_t anim_en);
|
||||
|
||||
/**
|
||||
* Scroll to an object until it becomes visible on its parent
|
||||
* @param obj pointer to an object to scroll into view
|
||||
* @param anim_en LV_ANIM_ON: scroll with animation; LV_ANIM_OFF: scroll immediately
|
||||
*/
|
||||
void lv_obj_scroll_to_view(lv_obj_t * obj, lv_anim_enable_t anim_en);
|
||||
|
||||
/**
|
||||
* Scroll to an object until it becomes visible on its parent.
|
||||
* Do the same on the parent's parent, and so on.
|
||||
* Therefore the object will be scrolled into view even it has nested scrollable parents
|
||||
* @param obj pointer to an object to scroll into view
|
||||
* @param anim_en LV_ANIM_ON: scroll with animation; LV_ANIM_OFF: scroll immediately
|
||||
*/
|
||||
void lv_obj_scroll_to_view_recursive(lv_obj_t * obj, lv_anim_enable_t anim_en);
|
||||
|
||||
/**
|
||||
* Low level function to scroll by given x and y coordinates.
|
||||
* `LV_EVENT_SCROLL` is sent.
|
||||
* @param obj pointer to an object to scroll
|
||||
* @param x pixels to scroll horizontally
|
||||
* @param y pixels to scroll vertically
|
||||
* @return `LV_RESULT_INVALID`: to object was deleted in `LV_EVENT_SCROLL`;
|
||||
* `LV_RESULT_OK`: if the object is still valid
|
||||
*/
|
||||
lv_result_t _lv_obj_scroll_by_raw(lv_obj_t * obj, int32_t x, int32_t y);
|
||||
|
||||
/**
|
||||
* Tell whether an object is being scrolled or not at this moment
|
||||
* @param obj pointer to an object
|
||||
* @return true: `obj` is being scrolled
|
||||
*/
|
||||
bool lv_obj_is_scrolling(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Check the children of `obj` and scroll `obj` to fulfill the scroll_snap settings
|
||||
* @param obj an object whose children needs to checked and snapped
|
||||
* @param anim_en LV_ANIM_ON/OFF
|
||||
*/
|
||||
void lv_obj_update_snap(lv_obj_t * obj, lv_anim_enable_t anim_en);
|
||||
|
||||
/**
|
||||
* Get the area of the scrollbars
|
||||
* @param obj pointer to an object
|
||||
* @param hor pointer to store the area of the horizontal scrollbar
|
||||
* @param ver pointer to store the area of the vertical scrollbar
|
||||
*/
|
||||
void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor, lv_area_t * ver);
|
||||
|
||||
/**
|
||||
* Invalidate the area of the scrollbars
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_scrollbar_invalidate(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Checks if the content is scrolled "in" and adjusts it to a normal position.
|
||||
* @param obj pointer to an object
|
||||
* @param anim_en LV_ANIM_ON/OFF
|
||||
*/
|
||||
void lv_obj_readjust_scroll(lv_obj_t * obj, lv_anim_enable_t anim_en);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBJ_SCROLL_H*/
|
||||
1118
libraries/lvgl/src/core/lv_obj_style.c
Normal file
1118
libraries/lvgl/src/core/lv_obj_style.c
Normal file
File diff suppressed because it is too large
Load Diff
370
libraries/lvgl/src/core/lv_obj_style.h
Normal file
370
libraries/lvgl/src/core/lv_obj_style.h
Normal file
@ -0,0 +1,370 @@
|
||||
/**
|
||||
* @file lv_obj_style.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBJ_STYLE_H
|
||||
#define LV_OBJ_STYLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "../misc/lv_bidi.h"
|
||||
#include "../misc/lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Can't include lv_obj.h because it includes this header file*/
|
||||
|
||||
#ifndef LV_OBJ_H
|
||||
/// @cond
|
||||
/**
|
||||
* Tells Doxygen to ignore a duplicate declaration
|
||||
*/
|
||||
typedef uint32_t lv_part_t;
|
||||
typedef uint16_t lv_state_t;
|
||||
/// @endcond
|
||||
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
_LV_STYLE_STATE_CMP_SAME, /*The style properties in the 2 states are identical*/
|
||||
_LV_STYLE_STATE_CMP_DIFF_REDRAW, /*The differences can be shown with a simple redraw*/
|
||||
_LV_STYLE_STATE_CMP_DIFF_DRAW_PAD, /*The differences can be shown with a simple redraw*/
|
||||
_LV_STYLE_STATE_CMP_DIFF_LAYOUT, /*The differences can be shown with a simple redraw*/
|
||||
} _lv_style_state_cmp_t;
|
||||
|
||||
typedef uint32_t lv_style_selector_t;
|
||||
|
||||
typedef struct {
|
||||
const lv_style_t * style;
|
||||
uint32_t selector : 24;
|
||||
uint32_t is_local : 1;
|
||||
uint32_t is_trans : 1;
|
||||
} _lv_obj_style_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t time;
|
||||
uint16_t delay;
|
||||
lv_style_selector_t selector;
|
||||
lv_style_prop_t prop;
|
||||
lv_anim_path_cb_t path_cb;
|
||||
void * user_data;
|
||||
} _lv_obj_style_transition_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the object related style manager module.
|
||||
* Called by LVGL in `lv_init()`
|
||||
*/
|
||||
void _lv_obj_style_init(void);
|
||||
|
||||
/**
|
||||
* Deinitialize the object related style manager module.
|
||||
* Called by LVGL in `lv_deinit()`
|
||||
*/
|
||||
void _lv_obj_style_deinit(void);
|
||||
|
||||
/**
|
||||
* Add a style to an object.
|
||||
* @param obj pointer to an object
|
||||
* @param style pointer to a style to add
|
||||
* @param selector OR-ed value of parts and state to which the style should be added
|
||||
* @example lv_obj_add_style(btn, &style_btn, 0); //Default button style
|
||||
* @example lv_obj_add_style(btn, &btn_red, LV_STATE_PRESSED); //Overwrite only some colors to red when pressed
|
||||
*/
|
||||
void lv_obj_add_style(lv_obj_t * obj, const lv_style_t * style, lv_style_selector_t selector);
|
||||
|
||||
/**
|
||||
* Replaces a style of an object, preserving the order of the style stack (local styles and transitions are ignored).
|
||||
* @param obj pointer to an object
|
||||
* @param old_style pointer to a style to replace.
|
||||
* @param new_style pointer to a style to replace the old style with.
|
||||
* @param selector OR-ed values of states and a part to replace only styles with matching selectors. LV_STATE_ANY and LV_PART_ANY can be used
|
||||
* @example lv_obj_replace_style(obj, &yellow_style, &blue_style, LV_PART_ANY | LV_STATE_ANY); //Replace a specific style
|
||||
* @example lv_obj_replace_style(obj, &yellow_style, &blue_style, LV_PART_MAIN | LV_STATE_PRESSED); //Replace a specific style assigned to the main part when it is pressed
|
||||
*/
|
||||
bool lv_obj_replace_style(lv_obj_t * obj, const lv_style_t * old_style, const lv_style_t * new_style,
|
||||
lv_style_selector_t selector);
|
||||
|
||||
/**
|
||||
* Remove a style from an object.
|
||||
* @param obj pointer to an object
|
||||
* @param style pointer to a style to remove. Can be NULL to check only the selector
|
||||
* @param selector OR-ed values of states and a part to remove only styles with matching selectors. LV_STATE_ANY and LV_PART_ANY can be used
|
||||
* @example lv_obj_remove_style(obj, &style, LV_PART_ANY | LV_STATE_ANY); //Remove a specific style
|
||||
* @example lv_obj_remove_style(obj, NULL, LV_PART_MAIN | LV_STATE_ANY); //Remove all styles from the main part
|
||||
* @example lv_obj_remove_style(obj, NULL, LV_PART_ANY | LV_STATE_ANY); //Remove all styles
|
||||
*/
|
||||
void lv_obj_remove_style(lv_obj_t * obj, const lv_style_t * style, lv_style_selector_t selector);
|
||||
|
||||
/**
|
||||
* Remove all styles from an object
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_remove_style_all(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
* @param style pointer to a style. Only the objects with this style will be notified
|
||||
* (NULL to notify all objects)
|
||||
*/
|
||||
void lv_obj_report_style_change(lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Notify an object and its children about its style is modified.
|
||||
* @param obj pointer to an object
|
||||
* @param part the part whose style was changed. E.g. `LV_PART_ANY`, `LV_PART_MAIN`
|
||||
* @param prop `LV_STYLE_PROP_ANY` or an `LV_STYLE_...` property.
|
||||
* It is used to optimize what needs to be refreshed.
|
||||
* `LV_STYLE_PROP_INV` to perform only a style cache update
|
||||
*/
|
||||
void lv_obj_refresh_style(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop);
|
||||
|
||||
/**
|
||||
* Enable or disable automatic style refreshing when a new style is added/removed to/from an object
|
||||
* or any other style change happens.
|
||||
* @param en true: enable refreshing; false: disable refreshing
|
||||
*/
|
||||
void lv_obj_enable_style_refresh(bool en);
|
||||
|
||||
/**
|
||||
* Get the value of a style property. The current state of the object will be considered.
|
||||
* Inherited properties will be inherited.
|
||||
* If a property is not set a default value will be returned.
|
||||
* @param obj pointer to an object
|
||||
* @param part a part from which the property should be get
|
||||
* @param prop the property to get
|
||||
* @return the value of the property.
|
||||
* Should be read from the correct field of the `lv_style_value_t` according to the type of the property.
|
||||
*/
|
||||
lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop);
|
||||
|
||||
/**
|
||||
* Check if an object has a specified style property for a given style selector.
|
||||
* @param obj pointer to an object
|
||||
* @param selector the style selector to be checked, defining the scope of the style to be examined.
|
||||
* @param prop the property to be checked.
|
||||
* @return true if the object has the specified selector and property, false otherwise.
|
||||
*/
|
||||
bool lv_obj_has_style_prop(const lv_obj_t * obj, lv_style_selector_t selector, lv_style_prop_t prop);
|
||||
|
||||
/**
|
||||
* Set local style property on an object's part and state.
|
||||
* @param obj pointer to an object
|
||||
* @param prop the property
|
||||
* @param value value of the property. The correct element should be set according to the type of the property
|
||||
* @param selector OR-ed value of parts and state for which the style should be set
|
||||
*/
|
||||
void lv_obj_set_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t value,
|
||||
lv_style_selector_t selector);
|
||||
|
||||
lv_style_res_t lv_obj_get_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t * value,
|
||||
lv_style_selector_t selector);
|
||||
|
||||
/**
|
||||
* Remove a local style property from a part of an object with a given state.
|
||||
* @param obj pointer to an object
|
||||
* @param prop a style property to remove.
|
||||
* @param selector OR-ed value of parts and state for which the style should be removed
|
||||
* @return true the property was found and removed; false: the property was not found
|
||||
*/
|
||||
bool lv_obj_remove_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_selector_t selector);
|
||||
|
||||
/**
|
||||
* Used internally for color filtering
|
||||
*/
|
||||
lv_style_value_t _lv_obj_style_apply_color_filter(const lv_obj_t * obj, uint32_t part, lv_style_value_t v);
|
||||
|
||||
/**
|
||||
* Used internally to create a style transition
|
||||
* @param obj
|
||||
* @param part
|
||||
* @param prev_state
|
||||
* @param new_state
|
||||
* @param tr
|
||||
*/
|
||||
void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t prev_state,
|
||||
lv_state_t new_state, const _lv_obj_style_transition_dsc_t * tr);
|
||||
|
||||
/**
|
||||
* Used internally to compare the appearance of an object in 2 states
|
||||
* @param obj
|
||||
* @param state1
|
||||
* @param state2
|
||||
* @return
|
||||
*/
|
||||
_lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t state1, lv_state_t state2);
|
||||
|
||||
/**
|
||||
* Fade in an an object and all its children.
|
||||
* @param obj the object to fade in
|
||||
* @param time time of fade
|
||||
* @param delay delay to start the animation
|
||||
*/
|
||||
void lv_obj_fade_in(lv_obj_t * obj, uint32_t time, uint32_t delay);
|
||||
|
||||
/**
|
||||
* Fade out an an object and all its children.
|
||||
* @param obj the object to fade out
|
||||
* @param time time of fade
|
||||
* @param delay delay to start the animation
|
||||
*/
|
||||
void lv_obj_fade_out(lv_obj_t * obj, uint32_t time, uint32_t delay);
|
||||
|
||||
static inline lv_state_t lv_obj_style_get_selector_state(lv_style_selector_t selector)
|
||||
{
|
||||
return selector & 0xFFFF;
|
||||
}
|
||||
|
||||
static inline lv_part_t lv_obj_style_get_selector_part(lv_style_selector_t selector)
|
||||
{
|
||||
return selector & 0xFF0000;
|
||||
}
|
||||
|
||||
#include "lv_obj_style_gen.h"
|
||||
|
||||
static inline void lv_obj_set_style_pad_all(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_pad_left(obj, value, selector);
|
||||
lv_obj_set_style_pad_right(obj, value, selector);
|
||||
lv_obj_set_style_pad_top(obj, value, selector);
|
||||
lv_obj_set_style_pad_bottom(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_pad_hor(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_pad_left(obj, value, selector);
|
||||
lv_obj_set_style_pad_right(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_pad_ver(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_pad_top(obj, value, selector);
|
||||
lv_obj_set_style_pad_bottom(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_margin_all(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_margin_left(obj, value, selector);
|
||||
lv_obj_set_style_margin_right(obj, value, selector);
|
||||
lv_obj_set_style_margin_top(obj, value, selector);
|
||||
lv_obj_set_style_margin_bottom(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_margin_hor(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_margin_left(obj, value, selector);
|
||||
lv_obj_set_style_margin_right(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_margin_ver(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_margin_top(obj, value, selector);
|
||||
lv_obj_set_style_margin_bottom(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_pad_gap(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_pad_row(obj, value, selector);
|
||||
lv_obj_set_style_pad_column(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_size(lv_obj_t * obj, int32_t width, int32_t height,
|
||||
lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_width(obj, width, selector);
|
||||
lv_obj_set_style_height(obj, height, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_transform_scale(lv_obj_t * obj, int32_t value,
|
||||
lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_transform_scale_x(obj, value, selector);
|
||||
lv_obj_set_style_transform_scale_y(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_space_left(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
int32_t padding = lv_obj_get_style_pad_left(obj, part);
|
||||
int32_t border_width = lv_obj_get_style_border_width(obj, part);
|
||||
lv_border_side_t border_side = lv_obj_get_style_border_side(obj, part);
|
||||
return (border_side & LV_BORDER_SIDE_LEFT) ? padding + border_width : padding;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_space_right(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
int32_t padding = lv_obj_get_style_pad_right(obj, part);
|
||||
int32_t border_width = lv_obj_get_style_border_width(obj, part);
|
||||
lv_border_side_t border_side = lv_obj_get_style_border_side(obj, part);
|
||||
return (border_side & LV_BORDER_SIDE_RIGHT) ? padding + border_width : padding;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_space_top(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
int32_t padding = lv_obj_get_style_pad_top(obj, part);
|
||||
int32_t border_width = lv_obj_get_style_border_width(obj, part);
|
||||
lv_border_side_t border_side = lv_obj_get_style_border_side(obj, part);
|
||||
return (border_side & LV_BORDER_SIDE_TOP) ? padding + border_width : padding;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_space_bottom(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
int32_t padding = lv_obj_get_style_pad_bottom(obj, part);
|
||||
int32_t border_width = lv_obj_get_style_border_width(obj, part);
|
||||
lv_border_side_t border_side = lv_obj_get_style_border_side(obj, part);
|
||||
return (border_side & LV_BORDER_SIDE_BOTTOM) ? padding + border_width : padding;
|
||||
}
|
||||
|
||||
lv_text_align_t lv_obj_calculate_style_text_align(const lv_obj_t * obj, lv_part_t part, const char * txt);
|
||||
|
||||
static inline int32_t lv_obj_get_style_transform_scale_x_safe(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
int16_t zoom = lv_obj_get_style_transform_scale_x(obj, part);
|
||||
return zoom != 0 ? zoom : 1;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_transform_scale_y_safe(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
int16_t zoom = lv_obj_get_style_transform_scale_y(obj, part);
|
||||
return zoom != 0 ? zoom : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the `opa` style property from all parents and multiply and `>> 8` them.
|
||||
* @param obj the object whose opacity should be get
|
||||
* @param part the part whose opacity should be get. Non-MAIN parts will consider the `opa` of the MAIN part too
|
||||
* @return the final opacity considering the parents' opacity too
|
||||
*/
|
||||
lv_opa_t lv_obj_get_style_opa_recursive(const lv_obj_t * obj, lv_part_t part);
|
||||
|
||||
/**
|
||||
* Update the layer type of a widget bayed on its current styles.
|
||||
* The result will be stored in `obj->spec_attr->layer_type`
|
||||
* @param obj the object whose layer should be updated
|
||||
*/
|
||||
void _lv_obj_update_layer_type(lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBJ_STYLE_H*/
|
||||
897
libraries/lvgl/src/core/lv_obj_style_gen.c
Normal file
897
libraries/lvgl/src/core/lv_obj_style_gen.c
Normal file
@ -0,0 +1,897 @@
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
* DO NOT EDIT
|
||||
* This file is automatically generated by "style_api_gen.py"
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include "lv_obj.h"
|
||||
|
||||
|
||||
void lv_obj_set_style_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_WIDTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_min_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_MIN_WIDTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_max_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_MAX_WIDTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_height(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_HEIGHT, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_min_height(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_MIN_HEIGHT, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_max_height(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_MAX_HEIGHT, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_length(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_LENGTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_X, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_Y, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_align(lv_obj_t * obj, lv_align_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_ALIGN, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_transform_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_WIDTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_transform_height(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_HEIGHT, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_translate_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSLATE_X, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_translate_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSLATE_Y, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_transform_scale_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_SCALE_X, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_transform_scale_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_SCALE_Y, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_transform_rotation(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_ROTATION, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_transform_pivot_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_PIVOT_X, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_transform_pivot_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_PIVOT_Y, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_transform_skew_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_SKEW_X, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_transform_skew_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSFORM_SKEW_Y, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_pad_top(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_TOP, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_pad_bottom(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_BOTTOM, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_pad_left(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_LEFT, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_pad_right(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_RIGHT, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_pad_row(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_ROW, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_pad_column(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_PAD_COLUMN, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_margin_top(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_MARGIN_TOP, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_margin_bottom(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_MARGIN_BOTTOM, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_margin_left(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_MARGIN_LEFT, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_margin_right(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_MARGIN_RIGHT, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.color = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_COLOR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_grad_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.color = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_GRAD_COLOR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_grad_dir(lv_obj_t * obj, lv_grad_dir_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_GRAD_DIR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_main_stop(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_MAIN_STOP, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_grad_stop(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_GRAD_STOP, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_main_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_MAIN_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_grad_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_GRAD_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_grad(lv_obj_t * obj, const lv_grad_dsc_t * value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.ptr = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_GRAD, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_image_src(lv_obj_t * obj, const void * value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.ptr = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_IMAGE_SRC, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_image_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_IMAGE_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_image_recolor(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.color = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_IMAGE_RECOLOR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_image_recolor_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_IMAGE_RECOLOR_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bg_image_tiled(lv_obj_t * obj, bool value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BG_IMAGE_TILED, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_border_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.color = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BORDER_COLOR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_border_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BORDER_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_border_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BORDER_WIDTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_border_side(lv_obj_t * obj, lv_border_side_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BORDER_SIDE, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_border_post(lv_obj_t * obj, bool value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BORDER_POST, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_outline_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_OUTLINE_WIDTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_outline_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.color = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_OUTLINE_COLOR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_outline_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_OUTLINE_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_outline_pad(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_OUTLINE_PAD, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_shadow_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_SHADOW_WIDTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_shadow_offset_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_SHADOW_OFFSET_X, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_shadow_offset_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_SHADOW_OFFSET_Y, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_shadow_spread(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_SHADOW_SPREAD, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_shadow_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.color = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_SHADOW_COLOR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_shadow_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_SHADOW_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_image_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_IMAGE_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_image_recolor(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.color = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_IMAGE_RECOLOR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_image_recolor_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_IMAGE_RECOLOR_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_line_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_LINE_WIDTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_line_dash_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_LINE_DASH_WIDTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_line_dash_gap(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_LINE_DASH_GAP, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_line_rounded(lv_obj_t * obj, bool value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_LINE_ROUNDED, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_line_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.color = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_LINE_COLOR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_line_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_LINE_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_arc_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_ARC_WIDTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_arc_rounded(lv_obj_t * obj, bool value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_ARC_ROUNDED, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_arc_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.color = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_ARC_COLOR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_arc_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_ARC_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_arc_image_src(lv_obj_t * obj, const void * value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.ptr = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_ARC_IMAGE_SRC, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_text_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.color = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TEXT_COLOR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_text_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TEXT_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_text_font(lv_obj_t * obj, const lv_font_t * value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.ptr = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TEXT_FONT, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_text_letter_space(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TEXT_LETTER_SPACE, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_text_line_space(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TEXT_LINE_SPACE, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_text_decor(lv_obj_t * obj, lv_text_decor_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TEXT_DECOR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_text_align(lv_obj_t * obj, lv_text_align_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TEXT_ALIGN, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_radius(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_RADIUS, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_clip_corner(lv_obj_t * obj, bool value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_CLIP_CORNER, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_opa_layered(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_OPA_LAYERED, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_color_filter_dsc(lv_obj_t * obj, const lv_color_filter_dsc_t * value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.ptr = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_COLOR_FILTER_DSC, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_color_filter_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_COLOR_FILTER_OPA, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_anim(lv_obj_t * obj, const lv_anim_t * value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.ptr = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_ANIM, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_anim_duration(lv_obj_t * obj, uint32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_ANIM_DURATION, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_transition(lv_obj_t * obj, const lv_style_transition_dsc_t * value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.ptr = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_TRANSITION, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_blend_mode(lv_obj_t * obj, lv_blend_mode_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BLEND_MODE, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_layout(lv_obj_t * obj, uint16_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_LAYOUT, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_base_dir(lv_obj_t * obj, lv_base_dir_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BASE_DIR, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_bitmap_mask_src(lv_obj_t * obj, const lv_image_dsc_t * value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.ptr = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_BITMAP_MASK_SRC, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_rotary_sensitivity(lv_obj_t * obj, uint32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_ROTARY_SENSITIVITY, v, selector);
|
||||
}
|
||||
#if LV_USE_FLEX
|
||||
|
||||
void lv_obj_set_style_flex_flow(lv_obj_t * obj, lv_flex_flow_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_FLOW, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_flex_main_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_MAIN_PLACE, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_flex_cross_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_CROSS_PLACE, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_flex_track_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_TRACK_PLACE, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_flex_grow(lv_obj_t * obj, uint8_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_GROW, v, selector);
|
||||
}
|
||||
#endif /*LV_USE_FLEX*/
|
||||
|
||||
#if LV_USE_GRID
|
||||
|
||||
void lv_obj_set_style_grid_column_dsc_array(lv_obj_t * obj, const int32_t * value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.ptr = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_COLUMN_DSC_ARRAY, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_column_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_COLUMN_ALIGN, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_row_dsc_array(lv_obj_t * obj, const int32_t * value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.ptr = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_ROW_DSC_ARRAY, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_row_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_ROW_ALIGN, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_cell_column_pos(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_COLUMN_POS, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_cell_x_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_X_ALIGN, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_cell_column_span(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_COLUMN_SPAN, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_cell_row_pos(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_ROW_POS, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_cell_y_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_Y_ALIGN, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_cell_row_span(lv_obj_t * obj, int32_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_ROW_SPAN, v, selector);
|
||||
}
|
||||
#endif /*LV_USE_GRID*/
|
||||
|
||||
868
libraries/lvgl/src/core/lv_obj_style_gen.h
Normal file
868
libraries/lvgl/src/core/lv_obj_style_gen.h
Normal file
@ -0,0 +1,868 @@
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
* DO NOT EDIT
|
||||
* This file is automatically generated by "style_api_gen.py"
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LV_OBJ_STYLE_GEN_H
|
||||
#define LV_OBJ_STYLE_GEN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_style.h"
|
||||
#include "../core/lv_obj_style.h"
|
||||
|
||||
static inline int32_t lv_obj_get_style_width(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_WIDTH);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_min_width(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MIN_WIDTH);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_max_width(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MAX_WIDTH);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_height(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_HEIGHT);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_min_height(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MIN_HEIGHT);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_max_height(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MAX_HEIGHT);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_length(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LENGTH);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_x(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_X);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_y(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_Y);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_align_t lv_obj_get_style_align(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ALIGN);
|
||||
return (lv_align_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_transform_width(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_WIDTH);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_transform_height(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_HEIGHT);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_translate_x(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSLATE_X);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_translate_y(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSLATE_Y);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_transform_scale_x(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_SCALE_X);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_transform_scale_y(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_SCALE_Y);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_transform_rotation(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ROTATION);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_transform_pivot_x(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_PIVOT_X);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_transform_pivot_y(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_PIVOT_Y);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_transform_skew_x(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_SKEW_X);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_transform_skew_y(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_SKEW_Y);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_pad_top(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_TOP);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_pad_bottom(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_BOTTOM);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_pad_left(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_LEFT);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_pad_right(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_RIGHT);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_pad_row(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_ROW);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_pad_column(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_COLUMN);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_margin_top(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MARGIN_TOP);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_margin_bottom(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MARGIN_BOTTOM);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_margin_left(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MARGIN_LEFT);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_margin_right(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_MARGIN_RIGHT);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_bg_color(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR);
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_bg_color_filtered(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR));
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_bg_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_bg_grad_color(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR);
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_bg_grad_color_filtered(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR));
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_grad_dir_t lv_obj_get_style_bg_grad_dir(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_DIR);
|
||||
return (lv_grad_dir_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_bg_main_stop(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_MAIN_STOP);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_bg_grad_stop(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_STOP);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_bg_main_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_MAIN_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_bg_grad_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline const lv_grad_dsc_t * lv_obj_get_style_bg_grad(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD);
|
||||
return (const lv_grad_dsc_t *)v.ptr;
|
||||
}
|
||||
|
||||
static inline const void * lv_obj_get_style_bg_image_src(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMAGE_SRC);
|
||||
return (const void *)v.ptr;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_bg_image_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMAGE_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_bg_image_recolor(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMAGE_RECOLOR);
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_bg_image_recolor_filtered(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMAGE_RECOLOR));
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_bg_image_recolor_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMAGE_RECOLOR_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline bool lv_obj_get_style_bg_image_tiled(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMAGE_TILED);
|
||||
return (bool)v.num;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_border_color(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR);
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_border_color_filtered(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR));
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_border_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_border_width(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_WIDTH);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_border_side_t lv_obj_get_style_border_side(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_SIDE);
|
||||
return (lv_border_side_t)v.num;
|
||||
}
|
||||
|
||||
static inline bool lv_obj_get_style_border_post(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_POST);
|
||||
return (bool)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_outline_width(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_WIDTH);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_outline_color(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR);
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_outline_color_filtered(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR));
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_outline_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_outline_pad(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_PAD);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_shadow_width(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_WIDTH);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_shadow_offset_x(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFFSET_X);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_shadow_offset_y(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFFSET_Y);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_shadow_spread(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_SPREAD);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_shadow_color(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR);
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_shadow_color_filtered(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR));
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_shadow_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_image_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMAGE_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_image_recolor(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMAGE_RECOLOR);
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_image_recolor_filtered(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_IMAGE_RECOLOR));
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_image_recolor_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMAGE_RECOLOR_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_line_width(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_WIDTH);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_line_dash_width(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_WIDTH);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_line_dash_gap(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_GAP);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline bool lv_obj_get_style_line_rounded(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_ROUNDED);
|
||||
return (bool)v.num;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_line_color(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR);
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_line_color_filtered(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR));
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_line_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_arc_width(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ARC_WIDTH);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline bool lv_obj_get_style_arc_rounded(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ARC_ROUNDED);
|
||||
return (bool)v.num;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_arc_color(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ARC_COLOR);
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_arc_color_filtered(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_ARC_COLOR));
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_arc_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ARC_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline const void * lv_obj_get_style_arc_image_src(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ARC_IMAGE_SRC);
|
||||
return (const void *)v.ptr;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_text_color(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR);
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_text_color_filtered(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = _lv_obj_style_apply_color_filter(obj, part, lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR));
|
||||
return v.color;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_text_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline const lv_font_t * lv_obj_get_style_text_font(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_FONT);
|
||||
return (const lv_font_t *)v.ptr;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_text_letter_space(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LETTER_SPACE);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_text_line_space(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LINE_SPACE);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_text_decor_t lv_obj_get_style_text_decor(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_DECOR);
|
||||
return (lv_text_decor_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_text_align_t lv_obj_get_style_text_align(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_ALIGN);
|
||||
return (lv_text_align_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_radius(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_RADIUS);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline bool lv_obj_get_style_clip_corner(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CLIP_CORNER);
|
||||
return (bool)v.num;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_opa_layered(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OPA_LAYERED);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline const lv_color_filter_dsc_t * lv_obj_get_style_color_filter_dsc(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_DSC);
|
||||
return (const lv_color_filter_dsc_t *)v.ptr;
|
||||
}
|
||||
|
||||
static inline lv_opa_t lv_obj_get_style_color_filter_opa(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_OPA);
|
||||
return (lv_opa_t)v.num;
|
||||
}
|
||||
|
||||
static inline const lv_anim_t * lv_obj_get_style_anim(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ANIM);
|
||||
return (const lv_anim_t *)v.ptr;
|
||||
}
|
||||
|
||||
static inline uint32_t lv_obj_get_style_anim_duration(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ANIM_DURATION);
|
||||
return (uint32_t)v.num;
|
||||
}
|
||||
|
||||
static inline const lv_style_transition_dsc_t * lv_obj_get_style_transition(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION);
|
||||
return (const lv_style_transition_dsc_t *)v.ptr;
|
||||
}
|
||||
|
||||
static inline lv_blend_mode_t lv_obj_get_style_blend_mode(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BLEND_MODE);
|
||||
return (lv_blend_mode_t)v.num;
|
||||
}
|
||||
|
||||
static inline uint16_t lv_obj_get_style_layout(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LAYOUT);
|
||||
return (uint16_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_base_dir_t lv_obj_get_style_base_dir(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BASE_DIR);
|
||||
return (lv_base_dir_t)v.num;
|
||||
}
|
||||
|
||||
static inline const lv_image_dsc_t * lv_obj_get_style_bitmap_mask_src(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BITMAP_MASK_SRC);
|
||||
return (const lv_image_dsc_t *)v.ptr;
|
||||
}
|
||||
|
||||
static inline uint32_t lv_obj_get_style_rotary_sensitivity(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ROTARY_SENSITIVITY);
|
||||
return (uint32_t)v.num;
|
||||
}
|
||||
|
||||
#if LV_USE_FLEX
|
||||
static inline lv_flex_flow_t lv_obj_get_style_flex_flow(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_FLOW);
|
||||
return (lv_flex_flow_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_flex_align_t lv_obj_get_style_flex_main_place(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_MAIN_PLACE);
|
||||
return (lv_flex_align_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_flex_align_t lv_obj_get_style_flex_cross_place(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_CROSS_PLACE);
|
||||
return (lv_flex_align_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_flex_align_t lv_obj_get_style_flex_track_place(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_TRACK_PLACE);
|
||||
return (lv_flex_align_t)v.num;
|
||||
}
|
||||
|
||||
static inline uint8_t lv_obj_get_style_flex_grow(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_GROW);
|
||||
return (uint8_t)v.num;
|
||||
}
|
||||
|
||||
#endif /*LV_USE_FLEX*/
|
||||
|
||||
#if LV_USE_GRID
|
||||
static inline const int32_t * lv_obj_get_style_grid_column_dsc_array(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_COLUMN_DSC_ARRAY);
|
||||
return (const int32_t *)v.ptr;
|
||||
}
|
||||
|
||||
static inline lv_grid_align_t lv_obj_get_style_grid_column_align(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_COLUMN_ALIGN);
|
||||
return (lv_grid_align_t)v.num;
|
||||
}
|
||||
|
||||
static inline const int32_t * lv_obj_get_style_grid_row_dsc_array(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_ROW_DSC_ARRAY);
|
||||
return (const int32_t *)v.ptr;
|
||||
}
|
||||
|
||||
static inline lv_grid_align_t lv_obj_get_style_grid_row_align(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_ROW_ALIGN);
|
||||
return (lv_grid_align_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_grid_cell_column_pos(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_COLUMN_POS);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_grid_align_t lv_obj_get_style_grid_cell_x_align(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_X_ALIGN);
|
||||
return (lv_grid_align_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_grid_cell_column_span(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_COLUMN_SPAN);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_grid_cell_row_pos(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_ROW_POS);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_grid_align_t lv_obj_get_style_grid_cell_y_align(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_Y_ALIGN);
|
||||
return (lv_grid_align_t)v.num;
|
||||
}
|
||||
|
||||
static inline int32_t lv_obj_get_style_grid_cell_row_span(const lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_ROW_SPAN);
|
||||
return (int32_t)v.num;
|
||||
}
|
||||
|
||||
#endif /*LV_USE_GRID*/
|
||||
|
||||
void lv_obj_set_style_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_min_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_max_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_height(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_min_height(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_max_height(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_length(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_align(lv_obj_t * obj, lv_align_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_transform_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_transform_height(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_translate_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_translate_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_transform_scale_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_transform_scale_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_transform_rotation(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_transform_pivot_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_transform_pivot_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_transform_skew_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_transform_skew_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_pad_top(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_pad_bottom(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_pad_left(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_pad_right(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_pad_row(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_pad_column(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_margin_top(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_margin_bottom(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_margin_left(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_margin_right(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_grad_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_grad_dir(lv_obj_t * obj, lv_grad_dir_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_main_stop(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_grad_stop(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_main_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_grad_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_grad(lv_obj_t * obj, const lv_grad_dsc_t * value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_image_src(lv_obj_t * obj, const void * value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_image_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_image_recolor(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_image_recolor_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bg_image_tiled(lv_obj_t * obj, bool value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_border_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_border_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_border_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_border_side(lv_obj_t * obj, lv_border_side_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_border_post(lv_obj_t * obj, bool value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_outline_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_outline_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_outline_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_outline_pad(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_shadow_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_shadow_offset_x(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_shadow_offset_y(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_shadow_spread(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_shadow_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_shadow_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_image_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_image_recolor(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_image_recolor_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_dash_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_dash_gap(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_rounded(lv_obj_t * obj, bool value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_arc_width(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_arc_rounded(lv_obj_t * obj, bool value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_arc_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_arc_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_arc_image_src(lv_obj_t * obj, const void * value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_text_color(lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_text_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_text_font(lv_obj_t * obj, const lv_font_t * value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_text_letter_space(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_text_line_space(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_text_decor(lv_obj_t * obj, lv_text_decor_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_text_align(lv_obj_t * obj, lv_text_align_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_radius(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_clip_corner(lv_obj_t * obj, bool value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_opa_layered(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_color_filter_dsc(lv_obj_t * obj, const lv_color_filter_dsc_t * value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_color_filter_opa(lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_anim(lv_obj_t * obj, const lv_anim_t * value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_anim_duration(lv_obj_t * obj, uint32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_transition(lv_obj_t * obj, const lv_style_transition_dsc_t * value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_blend_mode(lv_obj_t * obj, lv_blend_mode_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_layout(lv_obj_t * obj, uint16_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_base_dir(lv_obj_t * obj, lv_base_dir_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_bitmap_mask_src(lv_obj_t * obj, const lv_image_dsc_t * value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_rotary_sensitivity(lv_obj_t * obj, uint32_t value, lv_style_selector_t selector);
|
||||
#if LV_USE_FLEX
|
||||
void lv_obj_set_style_flex_flow(lv_obj_t * obj, lv_flex_flow_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_flex_main_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_flex_cross_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_flex_track_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_flex_grow(lv_obj_t * obj, uint8_t value, lv_style_selector_t selector);
|
||||
#endif /*LV_USE_FLEX*/
|
||||
|
||||
#if LV_USE_GRID
|
||||
void lv_obj_set_style_grid_column_dsc_array(lv_obj_t * obj, const int32_t * value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_grid_column_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_grid_row_dsc_array(lv_obj_t * obj, const int32_t * value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_grid_row_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_grid_cell_column_pos(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_grid_cell_x_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_grid_cell_column_span(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_grid_cell_row_pos(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_grid_cell_y_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_grid_cell_row_span(lv_obj_t * obj, int32_t value, lv_style_selector_t selector);
|
||||
#endif /*LV_USE_GRID*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_OBJ_STYLE_GEN_H */
|
||||
659
libraries/lvgl/src/core/lv_obj_tree.c
Normal file
659
libraries/lvgl/src/core/lv_obj_tree.c
Normal file
@ -0,0 +1,659 @@
|
||||
/**
|
||||
* @file lv_obj_tree.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lv_obj.h"
|
||||
#include "../indev/lv_indev.h"
|
||||
#include "../indev/lv_indev_private.h"
|
||||
#include "../display/lv_display.h"
|
||||
#include "../display/lv_display_private.h"
|
||||
#include "../misc/lv_anim.h"
|
||||
#include "../misc/lv_async.h"
|
||||
#include "../core/lv_global.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS (&lv_obj_class)
|
||||
#define disp_ll_p &(LV_GLOBAL_DEFAULT()->disp_ll)
|
||||
|
||||
#define OBJ_DUMP_STRING_LEN 128
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_obj_delete_async_cb(void * obj);
|
||||
static void obj_delete_core(lv_obj_t * obj);
|
||||
static lv_obj_tree_walk_res_t walk_core(lv_obj_t * obj, lv_obj_tree_walk_cb_t cb, void * user_data);
|
||||
static lv_obj_tree_walk_res_t dump_tree_core(lv_obj_t * obj, int32_t depth);
|
||||
static lv_obj_t * lv_obj_get_first_not_deleting_child(lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_obj_delete(lv_obj_t * obj)
|
||||
{
|
||||
if(obj->is_deleting)
|
||||
return;
|
||||
|
||||
LV_LOG_TRACE("begin (delete %p)", (void *)obj);
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
|
||||
lv_display_t * disp = NULL;
|
||||
bool act_screen_del = false;
|
||||
if(par == NULL) {
|
||||
disp = lv_obj_get_display(obj);
|
||||
if(!disp) return; /*Shouldn't happen*/
|
||||
if(disp->act_scr == obj) act_screen_del = true;
|
||||
}
|
||||
|
||||
obj_delete_core(obj);
|
||||
|
||||
/*Call the ancestor's event handler to the parent to notify it about the child delete*/
|
||||
if(par && !par->is_deleting) {
|
||||
lv_obj_scrollbar_invalidate(par);
|
||||
lv_obj_send_event(par, LV_EVENT_CHILD_CHANGED, NULL);
|
||||
lv_obj_send_event(par, LV_EVENT_CHILD_DELETED, NULL);
|
||||
}
|
||||
|
||||
/*Handle if the active screen was deleted*/
|
||||
if(act_screen_del) {
|
||||
LV_LOG_WARN("the active screen was deleted");
|
||||
disp->act_scr = NULL;
|
||||
}
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
LV_LOG_TRACE("finished (delete %p)", (void *)obj);
|
||||
}
|
||||
|
||||
void lv_obj_clean(lv_obj_t * obj)
|
||||
{
|
||||
LV_LOG_TRACE("begin (clean %p)", (void *)obj);
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
uint32_t cnt = lv_obj_get_child_count(obj);
|
||||
lv_obj_t * child = lv_obj_get_first_not_deleting_child(obj);
|
||||
while(child) {
|
||||
obj_delete_core(child);
|
||||
child = lv_obj_get_first_not_deleting_child(obj);
|
||||
}
|
||||
/*Just to remove scroll animations if any*/
|
||||
lv_obj_scroll_to(obj, 0, 0, LV_ANIM_OFF);
|
||||
if(obj->spec_attr) {
|
||||
obj->spec_attr->scroll.x = 0;
|
||||
obj->spec_attr->scroll.y = 0;
|
||||
}
|
||||
|
||||
if(lv_obj_get_child_count(obj) < cnt) {
|
||||
lv_obj_send_event(obj, LV_EVENT_CHILD_CHANGED, NULL);
|
||||
lv_obj_send_event(obj, LV_EVENT_CHILD_DELETED, NULL);
|
||||
}
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
|
||||
LV_LOG_TRACE("finished (clean %p)", (void *)obj);
|
||||
}
|
||||
|
||||
void lv_obj_delete_delayed(lv_obj_t * obj, uint32_t delay_ms)
|
||||
{
|
||||
lv_anim_t a;
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, obj);
|
||||
lv_anim_set_exec_cb(&a, NULL);
|
||||
lv_anim_set_duration(&a, 1);
|
||||
lv_anim_set_delay(&a, delay_ms);
|
||||
lv_anim_set_completed_cb(&a, lv_obj_delete_anim_completed_cb);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
|
||||
void lv_obj_delete_anim_completed_cb(lv_anim_t * a)
|
||||
{
|
||||
lv_obj_delete(a->var);
|
||||
}
|
||||
|
||||
void lv_obj_delete_async(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_async_call(lv_obj_delete_async_cb, obj);
|
||||
}
|
||||
|
||||
void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
LV_ASSERT_OBJ(parent, MY_CLASS);
|
||||
|
||||
if(obj->parent == NULL) {
|
||||
LV_LOG_WARN("Can't set the parent of a screen");
|
||||
return;
|
||||
}
|
||||
|
||||
if(parent == NULL) {
|
||||
LV_LOG_WARN("Can't set parent == NULL to an object");
|
||||
return;
|
||||
}
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
lv_obj_allocate_spec_attr(parent);
|
||||
|
||||
lv_obj_t * old_parent = obj->parent;
|
||||
/*Remove the object from the old parent's child list*/
|
||||
int32_t i;
|
||||
for(i = lv_obj_get_index(obj); i <= (int32_t)lv_obj_get_child_count(old_parent) - 2; i++) {
|
||||
old_parent->spec_attr->children[i] = old_parent->spec_attr->children[i + 1];
|
||||
}
|
||||
old_parent->spec_attr->child_cnt--;
|
||||
if(old_parent->spec_attr->child_cnt) {
|
||||
old_parent->spec_attr->children = lv_realloc(old_parent->spec_attr->children,
|
||||
old_parent->spec_attr->child_cnt * (sizeof(lv_obj_t *)));
|
||||
}
|
||||
else {
|
||||
lv_free(old_parent->spec_attr->children);
|
||||
old_parent->spec_attr->children = NULL;
|
||||
}
|
||||
|
||||
/*Add the child to the new parent as the last (newest child)*/
|
||||
parent->spec_attr->child_cnt++;
|
||||
parent->spec_attr->children = lv_realloc(parent->spec_attr->children,
|
||||
parent->spec_attr->child_cnt * (sizeof(lv_obj_t *)));
|
||||
parent->spec_attr->children[lv_obj_get_child_count(parent) - 1] = obj;
|
||||
|
||||
obj->parent = parent;
|
||||
|
||||
/*Notify the original parent because one of its children is lost*/
|
||||
lv_obj_scrollbar_invalidate(old_parent);
|
||||
lv_obj_send_event(old_parent, LV_EVENT_CHILD_CHANGED, obj);
|
||||
lv_obj_send_event(old_parent, LV_EVENT_CHILD_DELETED, NULL);
|
||||
|
||||
/*Notify the new parent about the child*/
|
||||
lv_obj_send_event(parent, LV_EVENT_CHILD_CHANGED, obj);
|
||||
lv_obj_send_event(parent, LV_EVENT_CHILD_CREATED, NULL);
|
||||
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
void lv_obj_move_to_index(lv_obj_t * obj, int32_t index)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
/* Check parent validity */
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
if(!parent) {
|
||||
LV_LOG_WARN("parent is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t parent_child_count = lv_obj_get_child_count(parent);
|
||||
/* old_index only can be 0 or greater, this point can not be reached if the parent is not null */
|
||||
const int32_t old_index = lv_obj_get_index(obj);
|
||||
LV_ASSERT(0 <= old_index);
|
||||
|
||||
if(index < 0) {
|
||||
index += parent_child_count;
|
||||
}
|
||||
|
||||
/* Index was negative and the absolute value is greater than parent child count */
|
||||
if((index < 0)
|
||||
/* Index is same or bigger than parent child count */
|
||||
|| (index >= (int32_t) parent_child_count)
|
||||
/* If both previous and new index are the same */
|
||||
|| (index == old_index)) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t i = old_index;
|
||||
if(index < old_index) {
|
||||
while(i > index) {
|
||||
parent->spec_attr->children[i] = parent->spec_attr->children[i - 1];
|
||||
i--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while(i < index) {
|
||||
parent->spec_attr->children[i] = parent->spec_attr->children[i + 1];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
parent->spec_attr->children[index] = obj;
|
||||
lv_obj_send_event(parent, LV_EVENT_CHILD_CHANGED, NULL);
|
||||
lv_obj_invalidate(parent);
|
||||
}
|
||||
|
||||
void lv_obj_swap(lv_obj_t * obj1, lv_obj_t * obj2)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj1, MY_CLASS);
|
||||
LV_ASSERT_OBJ(obj2, MY_CLASS);
|
||||
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj1);
|
||||
lv_obj_t * parent2 = lv_obj_get_parent(obj2);
|
||||
|
||||
uint_fast32_t index1 = lv_obj_get_index(obj1);
|
||||
uint_fast32_t index2 = lv_obj_get_index(obj2);
|
||||
|
||||
lv_obj_send_event(parent2, LV_EVENT_CHILD_DELETED, obj2);
|
||||
lv_obj_send_event(parent, LV_EVENT_CHILD_DELETED, obj1);
|
||||
|
||||
parent->spec_attr->children[index1] = obj2;
|
||||
obj2->parent = parent;
|
||||
|
||||
parent2->spec_attr->children[index2] = obj1;
|
||||
obj1->parent = parent2;
|
||||
|
||||
lv_obj_send_event(parent, LV_EVENT_CHILD_CHANGED, obj2);
|
||||
lv_obj_send_event(parent, LV_EVENT_CHILD_CREATED, obj2);
|
||||
lv_obj_send_event(parent2, LV_EVENT_CHILD_CHANGED, obj1);
|
||||
lv_obj_send_event(parent2, LV_EVENT_CHILD_CREATED, obj1);
|
||||
|
||||
lv_obj_invalidate(parent);
|
||||
|
||||
if(parent != parent2) {
|
||||
lv_obj_invalidate(parent2);
|
||||
}
|
||||
lv_group_swap_obj(obj1, obj2);
|
||||
}
|
||||
|
||||
lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
const lv_obj_t * par = obj;
|
||||
const lv_obj_t * act_par;
|
||||
|
||||
do {
|
||||
act_par = par;
|
||||
par = lv_obj_get_parent(act_par);
|
||||
} while(par != NULL);
|
||||
|
||||
return (lv_obj_t *)act_par;
|
||||
}
|
||||
|
||||
lv_display_t * lv_obj_get_display(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
const lv_obj_t * scr;
|
||||
|
||||
if(obj->parent == NULL) scr = obj; /*`obj` is a screen*/
|
||||
else scr = lv_obj_get_screen(obj); /*get the screen of `obj`*/
|
||||
|
||||
lv_display_t * d;
|
||||
lv_ll_t * disp_head = disp_ll_p;
|
||||
_LV_LL_READ(disp_head, d) {
|
||||
uint32_t i;
|
||||
for(i = 0; i < d->screen_cnt; i++) {
|
||||
if(d->screens[i] == scr) return d;
|
||||
}
|
||||
}
|
||||
|
||||
LV_LOG_WARN("No screen found");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_obj_t * lv_obj_get_parent(const lv_obj_t * obj)
|
||||
{
|
||||
if(obj == NULL) return NULL;
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
return obj->parent;
|
||||
}
|
||||
|
||||
lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, int32_t idx)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
if(obj->spec_attr == NULL) return NULL;
|
||||
|
||||
uint32_t idu;
|
||||
if(idx < 0) {
|
||||
idx = obj->spec_attr->child_cnt + idx;
|
||||
if(idx < 0) return NULL;
|
||||
idu = (uint32_t) idx;
|
||||
}
|
||||
else {
|
||||
idu = idx;
|
||||
}
|
||||
|
||||
if(idu >= obj->spec_attr->child_cnt) return NULL;
|
||||
else return obj->spec_attr->children[idx];
|
||||
}
|
||||
|
||||
lv_obj_t * lv_obj_get_child_by_type(const lv_obj_t * obj, int32_t idx, const lv_obj_class_t * class_p)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
if(obj->spec_attr == NULL) return NULL;
|
||||
|
||||
int32_t i;
|
||||
int32_t cnt = (int32_t)obj->spec_attr->child_cnt;
|
||||
if(idx >= 0) {
|
||||
for(i = 0; i < cnt; i++) {
|
||||
if(obj->spec_attr->children[i]->class_p == class_p) {
|
||||
if(idx == 0) return obj->spec_attr->children[i];
|
||||
else idx--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
idx++; /*-1 means the first child*/
|
||||
for(i = cnt - 1; i >= 0; i--) {
|
||||
if(obj->spec_attr->children[i]->class_p == class_p) {
|
||||
if(idx == 0) return obj->spec_attr->children[i];
|
||||
else idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_obj_t * lv_obj_get_sibling(const lv_obj_t * obj, int32_t idx)
|
||||
{
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
int32_t sibling_idx = (int32_t)lv_obj_get_index(obj) + idx;
|
||||
if(sibling_idx < 0) return NULL;
|
||||
|
||||
return lv_obj_get_child(parent, sibling_idx);
|
||||
}
|
||||
|
||||
lv_obj_t * lv_obj_get_sibling_by_type(const lv_obj_t * obj, int32_t idx, const lv_obj_class_t * class_p)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
int32_t sibling_idx = (int32_t)lv_obj_get_index_by_type(obj, class_p) + idx;
|
||||
if(sibling_idx < 0) return NULL;
|
||||
|
||||
return lv_obj_get_child(parent, sibling_idx);
|
||||
}
|
||||
|
||||
uint32_t lv_obj_get_child_count(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
if(obj->spec_attr == NULL) return 0;
|
||||
return obj->spec_attr->child_cnt;
|
||||
}
|
||||
|
||||
uint32_t lv_obj_get_child_count_by_type(const lv_obj_t * obj, const lv_obj_class_t * class_p)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
if(obj->spec_attr == NULL) return 0;
|
||||
|
||||
uint32_t i;
|
||||
uint32_t cnt = 0;
|
||||
for(i = 0; i < obj->spec_attr->child_cnt; i++) {
|
||||
if(obj->spec_attr->children[i]->class_p == class_p) cnt++;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
int32_t lv_obj_get_index(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
if(parent == NULL) return -1;
|
||||
|
||||
int32_t i = 0;
|
||||
for(i = 0; i < parent->spec_attr->child_cnt; i++) {
|
||||
if(parent->spec_attr->children[i] == obj) return i;
|
||||
}
|
||||
|
||||
/*Shouldn't reach this point*/
|
||||
LV_ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t lv_obj_get_index_by_type(const lv_obj_t * obj, const lv_obj_class_t * class_p)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
if(parent == NULL) return 0xFFFFFFFF;
|
||||
|
||||
uint32_t i = 0;
|
||||
uint32_t idx = 0;
|
||||
for(i = 0; i < parent->spec_attr->child_cnt; i++) {
|
||||
lv_obj_t * child = parent->spec_attr->children[i];
|
||||
if(child->class_p == class_p) {
|
||||
if(child == obj) return idx;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
/*Can happen if there was no children with the given type*/
|
||||
return -1;
|
||||
}
|
||||
|
||||
void lv_obj_tree_walk(lv_obj_t * start_obj, lv_obj_tree_walk_cb_t cb, void * user_data)
|
||||
{
|
||||
walk_core(start_obj, cb, user_data);
|
||||
}
|
||||
|
||||
void lv_obj_dump_tree(lv_obj_t * start_obj)
|
||||
{
|
||||
if(start_obj == NULL) {
|
||||
lv_display_t * disp = lv_display_get_next(NULL);
|
||||
while(disp) {
|
||||
uint32_t i;
|
||||
for(i = 0; i < disp->screen_cnt; i++) {
|
||||
dump_tree_core(disp->screens[i], 0);
|
||||
}
|
||||
disp = lv_display_get_next(disp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dump_tree_core(start_obj, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void lv_obj_delete_async_cb(void * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_obj_delete(obj);
|
||||
}
|
||||
|
||||
static void obj_indev_reset(lv_indev_t * indev, lv_obj_t * obj)
|
||||
{
|
||||
/*Wait for release to avoid accidentally triggering other obj to be clicked*/
|
||||
lv_indev_wait_release(indev);
|
||||
|
||||
/*Reset the input device*/
|
||||
lv_indev_reset(indev, obj);
|
||||
}
|
||||
|
||||
static void obj_delete_core(lv_obj_t * obj)
|
||||
{
|
||||
if(obj->is_deleting)
|
||||
return;
|
||||
|
||||
obj->is_deleting = true;
|
||||
|
||||
/*Let the user free the resources used in `LV_EVENT_DELETE`*/
|
||||
lv_result_t res = lv_obj_send_event(obj, LV_EVENT_DELETE, NULL);
|
||||
if(res == LV_RESULT_INVALID) {
|
||||
obj->is_deleting = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/*Clean registered event_cb*/
|
||||
if(obj->spec_attr) lv_event_remove_all(&(obj->spec_attr->event_list));
|
||||
|
||||
/*Recursively delete the children*/
|
||||
lv_obj_t * child = lv_obj_get_child(obj, 0);
|
||||
while(child) {
|
||||
obj_delete_core(child);
|
||||
child = lv_obj_get_child(obj, 0);
|
||||
}
|
||||
|
||||
lv_group_t * group = lv_obj_get_group(obj);
|
||||
|
||||
/*Reset all input devices if the object to delete is used*/
|
||||
lv_indev_t * indev = lv_indev_get_next(NULL);
|
||||
while(indev) {
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
if(indev_type == LV_INDEV_TYPE_POINTER || indev_type == LV_INDEV_TYPE_BUTTON) {
|
||||
if(indev->pointer.act_obj == obj || indev->pointer.last_obj == obj || indev->pointer.scroll_obj == obj) {
|
||||
obj_indev_reset(indev, obj);
|
||||
}
|
||||
if(indev->pointer.last_pressed == obj) {
|
||||
indev->pointer.last_pressed = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(indev->group == group && obj == lv_indev_get_active_obj()) {
|
||||
obj_indev_reset(indev, obj);
|
||||
}
|
||||
indev = lv_indev_get_next(indev);
|
||||
}
|
||||
|
||||
/*Delete all pending async del-s*/
|
||||
lv_result_t async_cancel_res = LV_RESULT_OK;
|
||||
while(async_cancel_res == LV_RESULT_OK) {
|
||||
async_cancel_res = lv_async_call_cancel(lv_obj_delete_async_cb, obj);
|
||||
}
|
||||
|
||||
/*All children deleted. Now clean up the object specific data*/
|
||||
_lv_obj_destruct(obj);
|
||||
|
||||
/*Remove the screen for the screen list*/
|
||||
if(obj->parent == NULL) {
|
||||
lv_display_t * disp = lv_obj_get_display(obj);
|
||||
uint32_t i;
|
||||
/*Find the screen in the list*/
|
||||
for(i = 0; i < disp->screen_cnt; i++) {
|
||||
if(disp->screens[i] == obj) break;
|
||||
}
|
||||
|
||||
uint32_t id = i;
|
||||
for(i = id; i < disp->screen_cnt - 1; i++) {
|
||||
disp->screens[i] = disp->screens[i + 1];
|
||||
}
|
||||
disp->screen_cnt--;
|
||||
disp->screens = lv_realloc(disp->screens, disp->screen_cnt * sizeof(lv_obj_t *));
|
||||
}
|
||||
/*Remove the object from the child list of its parent*/
|
||||
else {
|
||||
int32_t id = lv_obj_get_index(obj);
|
||||
uint16_t i;
|
||||
for(i = id; i < obj->parent->spec_attr->child_cnt - 1; i++) {
|
||||
obj->parent->spec_attr->children[i] = obj->parent->spec_attr->children[i + 1];
|
||||
}
|
||||
obj->parent->spec_attr->child_cnt--;
|
||||
obj->parent->spec_attr->children = lv_realloc(obj->parent->spec_attr->children,
|
||||
obj->parent->spec_attr->child_cnt * sizeof(lv_obj_t *));
|
||||
}
|
||||
|
||||
/*Free the object itself*/
|
||||
lv_free(obj);
|
||||
}
|
||||
|
||||
static lv_obj_tree_walk_res_t walk_core(lv_obj_t * obj, lv_obj_tree_walk_cb_t cb, void * user_data)
|
||||
{
|
||||
lv_obj_tree_walk_res_t res = LV_OBJ_TREE_WALK_NEXT;
|
||||
|
||||
if(obj == NULL) {
|
||||
lv_display_t * disp = lv_display_get_next(NULL);
|
||||
while(disp) {
|
||||
uint32_t i;
|
||||
for(i = 0; i < disp->screen_cnt; i++) {
|
||||
walk_core(disp->screens[i], cb, user_data);
|
||||
}
|
||||
disp = lv_display_get_next(disp);
|
||||
}
|
||||
return LV_OBJ_TREE_WALK_END; /*The value doesn't matter as it wasn't called recursively*/
|
||||
}
|
||||
|
||||
res = cb(obj, user_data);
|
||||
|
||||
if(res == LV_OBJ_TREE_WALK_END) return LV_OBJ_TREE_WALK_END;
|
||||
|
||||
if(res != LV_OBJ_TREE_WALK_SKIP_CHILDREN) {
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_count(obj); i++) {
|
||||
res = walk_core(lv_obj_get_child(obj, i), cb, user_data);
|
||||
if(res == LV_OBJ_TREE_WALK_END) return LV_OBJ_TREE_WALK_END;
|
||||
}
|
||||
}
|
||||
return LV_OBJ_TREE_WALK_NEXT;
|
||||
}
|
||||
|
||||
static lv_obj_tree_walk_res_t dump_tree_core(lv_obj_t * obj, int32_t depth)
|
||||
{
|
||||
lv_obj_tree_walk_res_t res;
|
||||
|
||||
#if LV_USE_LOG
|
||||
const char * id;
|
||||
|
||||
#if LV_USE_OBJ_ID
|
||||
char buf[OBJ_DUMP_STRING_LEN];
|
||||
id = lv_obj_stringify_id(obj, buf, sizeof(buf));
|
||||
if(id == NULL) id = "obj0";
|
||||
#else
|
||||
id = "obj0";
|
||||
#endif
|
||||
|
||||
/*id of `obj0` is an invalid id for builtin id*/
|
||||
LV_LOG_USER("parent:%p, obj:%p, id:%s;", (void *)(obj ? obj->parent : NULL), (void *)obj, id);
|
||||
#endif /*LV_USE_LOG*/
|
||||
|
||||
if(obj && obj->spec_attr && obj->spec_attr->child_cnt) {
|
||||
for(uint32_t i = 0; i < obj->spec_attr->child_cnt; i++) {
|
||||
res = dump_tree_core(lv_obj_get_child(obj, i), depth + 1);
|
||||
if(res == LV_OBJ_TREE_WALK_END)
|
||||
break;
|
||||
}
|
||||
return LV_OBJ_TREE_WALK_NEXT;
|
||||
}
|
||||
else {
|
||||
return LV_OBJ_TREE_WALK_END;
|
||||
}
|
||||
}
|
||||
|
||||
static lv_obj_t * lv_obj_get_first_not_deleting_child(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
if(obj->spec_attr == NULL) return NULL;
|
||||
|
||||
int32_t i;
|
||||
int32_t cnt = (int32_t)obj->spec_attr->child_cnt;
|
||||
for(i = 0; i < cnt; i++) {
|
||||
if(!obj->spec_attr->children[i]->is_deleting) {
|
||||
return obj->spec_attr->children[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
239
libraries/lvgl/src/core/lv_obj_tree.h
Normal file
239
libraries/lvgl/src/core/lv_obj_tree.h
Normal file
@ -0,0 +1,239 @@
|
||||
/**
|
||||
* @file struct _lv_obj_tree.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OBJ_TREE_H
|
||||
#define LV_OBJ_TREE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../misc/lv_anim.h"
|
||||
#include "../display/lv_display.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_OBJ_TREE_WALK_NEXT,
|
||||
LV_OBJ_TREE_WALK_SKIP_CHILDREN,
|
||||
LV_OBJ_TREE_WALK_END,
|
||||
} lv_obj_tree_walk_res_t;
|
||||
|
||||
typedef lv_obj_tree_walk_res_t (*lv_obj_tree_walk_cb_t)(lv_obj_t *, void *);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Delete an object and all of its children.
|
||||
* Also remove the objects from their group and remove all animations (if any).
|
||||
* Send `LV_EVENT_DELETED` to deleted objects.
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_delete(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Delete all children of an object.
|
||||
* Also remove the objects from their group and remove all animations (if any).
|
||||
* Send `LV_EVENT_DELETED` to deleted objects.
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_clean(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Delete an object after some delay
|
||||
* @param obj pointer to an object
|
||||
* @param delay_ms time to wait before delete in milliseconds
|
||||
*/
|
||||
void lv_obj_delete_delayed(lv_obj_t * obj, uint32_t delay_ms);
|
||||
|
||||
/**
|
||||
* A function to be easily used in animation ready callback to delete an object when the animation is ready
|
||||
* @param a pointer to the animation
|
||||
*/
|
||||
void lv_obj_delete_anim_completed_cb(lv_anim_t * a);
|
||||
|
||||
/**
|
||||
* Helper function for asynchronously deleting objects.
|
||||
* Useful for cases where you can't delete an object directly in an `LV_EVENT_DELETE` handler (i.e. parent).
|
||||
* @param obj object to delete
|
||||
* @see lv_async_call
|
||||
*/
|
||||
void lv_obj_delete_async(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Move the parent of an object. The relative coordinates will be kept.
|
||||
*
|
||||
* @param obj pointer to an object whose parent needs to be changed
|
||||
* @param parent pointer to the new parent
|
||||
*/
|
||||
void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent);
|
||||
|
||||
/**
|
||||
* Swap the positions of two objects.
|
||||
* When used in listboxes, it can be used to sort the listbox items.
|
||||
* @param obj1 pointer to the first object
|
||||
* @param obj2 pointer to the second object
|
||||
*/
|
||||
void lv_obj_swap(lv_obj_t * obj1, lv_obj_t * obj2);
|
||||
|
||||
/**
|
||||
* moves the object to the given index in its parent.
|
||||
* When used in listboxes, it can be used to sort the listbox items.
|
||||
* @param obj pointer to the object to be moved.
|
||||
* @param index new index in parent. -1 to count from the back
|
||||
* @note to move to the background: lv_obj_move_to_index(obj, 0)
|
||||
* @note to move forward (up): lv_obj_move_to_index(obj, lv_obj_get_index(obj) - 1)
|
||||
*/
|
||||
void lv_obj_move_to_index(lv_obj_t * obj, int32_t index);
|
||||
|
||||
/**
|
||||
* Get the screen of an object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to the object's screen
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the display of the object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to the object's display
|
||||
*/
|
||||
lv_display_t * lv_obj_get_display(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the parent of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the parent of the object. (NULL if `obj` was a screen)
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_parent(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the child of an object by the child's index.
|
||||
* @param obj pointer to an object whose child should be get
|
||||
* @param idx the index of the child.
|
||||
* 0: the oldest (firstly created) child
|
||||
* 1: the second oldest
|
||||
* child count-1: the youngest
|
||||
* -1: the youngest
|
||||
* -2: the second youngest
|
||||
* @return pointer to the child or NULL if the index was invalid
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, int32_t idx);
|
||||
|
||||
/**
|
||||
* Get the child of an object by the child's index. Consider the children only with a given type.
|
||||
* @param obj pointer to an object whose child should be get
|
||||
* @param idx the index of the child.
|
||||
* 0: the oldest (firstly created) child
|
||||
* 1: the second oldest
|
||||
* child count-1: the youngest
|
||||
* -1: the youngest
|
||||
* -2: the second youngest
|
||||
* @param class_p the type of the children to check
|
||||
* @return pointer to the child or NULL if the index was invalid
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_child_by_type(const lv_obj_t * obj, int32_t idx,
|
||||
const lv_obj_class_t * class_p);
|
||||
|
||||
/**
|
||||
* Return a sibling of an object
|
||||
* @param obj pointer to an object whose sibling should be get
|
||||
* @param idx 0: `obj` itself
|
||||
* -1: the first older sibling
|
||||
* -2: the next older sibling
|
||||
* 1: the first younger sibling
|
||||
* 2: the next younger sibling
|
||||
* etc
|
||||
* @return pointer to the requested sibling or NULL if there is no such sibling
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_sibling(const lv_obj_t * obj, int32_t idx);
|
||||
|
||||
/**
|
||||
* Return a sibling of an object. Consider the siblings only with a given type.
|
||||
* @param obj pointer to an object whose sibling should be get
|
||||
* @param idx 0: `obj` itself
|
||||
* -1: the first older sibling
|
||||
* -2: the next older sibling
|
||||
* 1: the first younger sibling
|
||||
* 2: the next younger sibling
|
||||
* etc
|
||||
* @param class_p the type of the children to check
|
||||
* @return pointer to the requested sibling or NULL if there is no such sibling
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_sibling_by_type(const lv_obj_t * obj, int32_t idx,
|
||||
const lv_obj_class_t * class_p);
|
||||
|
||||
/**
|
||||
* Get the number of children
|
||||
* @param obj pointer to an object
|
||||
* @return the number of children
|
||||
*/
|
||||
uint32_t lv_obj_get_child_count(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the number of children having a given type.
|
||||
* @param obj pointer to an object
|
||||
* @param class_p the type of the children to check
|
||||
* @return the number of children
|
||||
*/
|
||||
|
||||
uint32_t lv_obj_get_child_count_by_type(const lv_obj_t * obj, const lv_obj_class_t * class_p);
|
||||
|
||||
/**
|
||||
* Get the index of a child.
|
||||
* @param obj pointer to an object
|
||||
* @return the child index of the object.
|
||||
* E.g. 0: the oldest (firstly created child).
|
||||
* (-1 if child could not be found or no parent exists)
|
||||
*/
|
||||
int32_t lv_obj_get_index(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the index of a child. Consider the children only with a given type.
|
||||
* @param obj pointer to an object
|
||||
* @param class_p the type of the children to check
|
||||
* @return the child index of the object.
|
||||
* E.g. 0: the oldest (firstly created child with the given class).
|
||||
* (-1 if child could not be found or no parent exists)
|
||||
*/
|
||||
int32_t lv_obj_get_index_by_type(const lv_obj_t * obj, const lv_obj_class_t * class_p);
|
||||
|
||||
/**
|
||||
* Iterate through all children of any object.
|
||||
* @param start_obj start integrating from this object
|
||||
* @param cb call this callback on the objects
|
||||
* @param user_data pointer to any user related data (will be passed to `cb`)
|
||||
*/
|
||||
void lv_obj_tree_walk(lv_obj_t * start_obj, lv_obj_tree_walk_cb_t cb, void * user_data);
|
||||
|
||||
/**
|
||||
* Iterate through all children of any object and print their ID.
|
||||
* @param start_obj start integrating from this object
|
||||
*/
|
||||
void lv_obj_dump_tree(lv_obj_t * start_ob);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OBJ_TREE_H*/
|
||||
1092
libraries/lvgl/src/core/lv_refr.c
Normal file
1092
libraries/lvgl/src/core/lv_refr.c
Normal file
File diff suppressed because it is too large
Load Diff
104
libraries/lvgl/src/core/lv_refr.h
Normal file
104
libraries/lvgl/src/core/lv_refr.h
Normal file
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @file lv_refr.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_REFR_H
|
||||
#define LV_REFR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_obj.h"
|
||||
#include "../display/lv_display.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the screen refresh subsystem
|
||||
*/
|
||||
void _lv_refr_init(void);
|
||||
|
||||
/**
|
||||
* Deinitialize the screen refresh subsystem
|
||||
*/
|
||||
void _lv_refr_deinit(void);
|
||||
|
||||
/**
|
||||
* Redraw the invalidated areas now.
|
||||
* Normally the redrawing is periodically executed in `lv_timer_handler` but a long blocking process
|
||||
* can prevent the call of `lv_timer_handler`. In this case if the GUI is updated in the process
|
||||
* (e.g. progress bar) this function can be called when the screen should be updated.
|
||||
* @param disp pointer to display to refresh. NULL to refresh all displays.
|
||||
*/
|
||||
void lv_refr_now(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Redrawn on object and all its children using the passed draw context
|
||||
* @param layer pointer to a layer where to draw.
|
||||
* @param obj the start object from the redraw should start
|
||||
*/
|
||||
void lv_obj_redraw(lv_layer_t * layer, lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Invalidate an area on display to redraw it
|
||||
* @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas)
|
||||
* @param disp pointer to display where the area should be invalidated (NULL can be used if there is
|
||||
* only one display)
|
||||
*/
|
||||
void _lv_inv_area(lv_display_t * disp, const lv_area_t * area_p);
|
||||
|
||||
/**
|
||||
* Get the display which is being refreshed
|
||||
* @return the display being refreshed
|
||||
*/
|
||||
lv_display_t * _lv_refr_get_disp_refreshing(void);
|
||||
|
||||
/**
|
||||
* Set the display which is being refreshed
|
||||
* @param disp the display being refreshed
|
||||
*/
|
||||
void _lv_refr_set_disp_refreshing(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Called periodically to handle the refreshing
|
||||
* @param timer pointer to the timer itself
|
||||
*/
|
||||
void _lv_display_refr_timer(lv_timer_t * timer);
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_REFR_H*/
|
||||
1058
libraries/lvgl/src/display/lv_display.c
Normal file
1058
libraries/lvgl/src/display/lv_display.c
Normal file
File diff suppressed because it is too large
Load Diff
602
libraries/lvgl/src/display/lv_display.h
Normal file
602
libraries/lvgl/src/display/lv_display.h
Normal file
@ -0,0 +1,602 @@
|
||||
/**
|
||||
* @file lv_disp.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DISPLAY_H
|
||||
#define LV_DISPLAY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../misc/lv_timer.h"
|
||||
#include "../misc/lv_event.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../draw/lv_draw.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#ifndef LV_ATTRIBUTE_FLUSH_READY
|
||||
#define LV_ATTRIBUTE_FLUSH_READY
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_DISPLAY_ROTATION_0 = 0,
|
||||
LV_DISPLAY_ROTATION_90,
|
||||
LV_DISPLAY_ROTATION_180,
|
||||
LV_DISPLAY_ROTATION_270
|
||||
} lv_display_rotation_t;
|
||||
|
||||
typedef enum {
|
||||
/**
|
||||
* Use the buffer(s) to render the screen is smaller parts.
|
||||
* This way the buffers can be smaller then the display to save RAM. At least 1/10 screen size buffer(s) are recommended.
|
||||
*/
|
||||
LV_DISPLAY_RENDER_MODE_PARTIAL,
|
||||
|
||||
/**
|
||||
* The buffer(s) has to be screen sized and LVGL will render into the correct location of the buffer.
|
||||
* This way the buffer always contain the whole image. Only the changed ares will be updated.
|
||||
* With 2 buffers the buffers' content are kept in sync automatically and in flush_cb only address change is required.
|
||||
*/
|
||||
LV_DISPLAY_RENDER_MODE_DIRECT,
|
||||
|
||||
/**
|
||||
* Always redraw the whole screen even if only one pixel has been changed.
|
||||
* With 2 buffers in flush_cb only and address change is required.
|
||||
*/
|
||||
LV_DISPLAY_RENDER_MODE_FULL,
|
||||
} lv_display_render_mode_t;
|
||||
|
||||
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_IN,
|
||||
LV_SCR_LOAD_ANIM_FADE_ON = LV_SCR_LOAD_ANIM_FADE_IN, /*For backward compatibility*/
|
||||
LV_SCR_LOAD_ANIM_FADE_OUT,
|
||||
LV_SCR_LOAD_ANIM_OUT_LEFT,
|
||||
LV_SCR_LOAD_ANIM_OUT_RIGHT,
|
||||
LV_SCR_LOAD_ANIM_OUT_TOP,
|
||||
LV_SCR_LOAD_ANIM_OUT_BOTTOM,
|
||||
} lv_screen_load_anim_t;
|
||||
|
||||
typedef void (*lv_display_flush_cb_t)(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map);
|
||||
typedef void (*lv_display_flush_wait_cb_t)(lv_display_t * disp);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a new display with the given resolution
|
||||
* @param hor_res horizontal resolution in pixels
|
||||
* @param ver_res vertical resolution in pixels
|
||||
* @return pointer to a display object or `NULL` on error
|
||||
*/
|
||||
lv_display_t * lv_display_create(int32_t hor_res, int32_t ver_res);
|
||||
|
||||
/**
|
||||
* Remove a display
|
||||
* @param disp pointer to display
|
||||
*/
|
||||
void lv_display_delete(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Set a default display. The new screens will be created on it by default.
|
||||
* @param disp pointer to a display
|
||||
*/
|
||||
void lv_display_set_default(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Get the default display
|
||||
* @return pointer to the default display
|
||||
*/
|
||||
lv_display_t * lv_display_get_default(void);
|
||||
|
||||
/**
|
||||
* Get the next display.
|
||||
* @param disp pointer to the current display. NULL to initialize.
|
||||
* @return the next display or NULL if no more. Gives the first display when the parameter is NULL.
|
||||
*/
|
||||
lv_display_t * lv_display_get_next(lv_display_t * disp);
|
||||
|
||||
/*---------------------
|
||||
* RESOLUTION
|
||||
*--------------------*/
|
||||
|
||||
/**
|
||||
* Sets the resolution of a display. `LV_EVENT_RESOLUTION_CHANGED` event will be sent.
|
||||
* Here the native resolution of the device should be set. If the display will be rotated later with
|
||||
* `lv_display_set_rotation` LVGL will swap the hor. and ver. resolution automatically.
|
||||
* @param disp pointer to a display
|
||||
* @param hor_res the new horizontal resolution
|
||||
* @param ver_res the new vertical resolution
|
||||
*/
|
||||
void lv_display_set_resolution(lv_display_t * disp, int32_t hor_res, int32_t ver_res);
|
||||
|
||||
/**
|
||||
* It's not mandatory to use the whole display for LVGL, however in some cases physical resolution is important.
|
||||
* For example the touchpad still sees whole resolution and the values needs to be converted
|
||||
* to the active LVGL display area.
|
||||
* @param disp pointer to a display
|
||||
* @param hor_res the new physical horizontal resolution, or -1 to assume it's the same as the normal hor. res.
|
||||
* @param ver_res the new physical vertical resolution, or -1 to assume it's the same as the normal hor. res.
|
||||
*/
|
||||
void lv_display_set_physical_resolution(lv_display_t * disp, int32_t hor_res, int32_t ver_res);
|
||||
|
||||
/**
|
||||
* If physical resolution is not the same as the normal resolution
|
||||
* the offset of the active display area can be set here.
|
||||
* @param disp pointer to a display
|
||||
* @param x X offset
|
||||
* @param y Y offset
|
||||
*/
|
||||
void lv_display_set_offset(lv_display_t * disp, int32_t x, int32_t y);
|
||||
|
||||
/**
|
||||
* Set the rotation of this display. LVGL will swap the horizontal and vertical resolutions internally.
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @param rotation `LV_DISPLAY_ROTATION_0/90/180/270`
|
||||
*/
|
||||
void lv_display_set_rotation(lv_display_t * disp, lv_display_rotation_t rotation);
|
||||
|
||||
/**
|
||||
* Set the DPI (dot per inch) of the display.
|
||||
* dpi = sqrt(hor_res^2 + ver_res^2) / diagonal"
|
||||
* @param disp pointer to a display
|
||||
* @param dpi the new DPI
|
||||
*/
|
||||
void lv_display_set_dpi(lv_display_t * disp, int32_t dpi);
|
||||
|
||||
/**
|
||||
* Get the horizontal resolution of a display.
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return the horizontal resolution of the display.
|
||||
*/
|
||||
int32_t lv_display_get_horizontal_resolution(const lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Get the vertical resolution of a display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return the vertical resolution of the display
|
||||
*/
|
||||
int32_t lv_display_get_vertical_resolution(const lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Get the physical horizontal resolution of a display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return the physical horizontal resolution of the display
|
||||
*/
|
||||
int32_t lv_display_get_physical_horizontal_resolution(const lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Get the physical vertical resolution of a display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return the physical vertical resolution of the display
|
||||
*/
|
||||
int32_t lv_display_get_physical_vertical_resolution(const lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Get the horizontal offset from the full / physical display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return the horizontal offset from the physical display
|
||||
*/
|
||||
int32_t lv_display_get_offset_x(const lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Get the vertical offset from the full / physical display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return the horizontal offset from the physical display
|
||||
*/
|
||||
int32_t lv_display_get_offset_y(const lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Get the current rotation of this display.
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return the current rotation
|
||||
*/
|
||||
lv_display_rotation_t lv_display_get_rotation(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Get the DPI of the display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return dpi of the display
|
||||
*/
|
||||
int32_t lv_display_get_dpi(const lv_display_t * disp);
|
||||
|
||||
/*---------------------
|
||||
* BUFFERING
|
||||
*--------------------*/
|
||||
|
||||
/**
|
||||
* Set the buffers for a display, similarly to `lv_display_set_draw_buffers`, but accept the raw buffer pointers.
|
||||
* @param disp pointer to a display
|
||||
* @param buf1 first buffer
|
||||
* @param buf2 second buffer (can be `NULL`)
|
||||
* @param buf_size buffer size in byte
|
||||
* @param render_mode LV_DISPLAY_RENDER_MODE_PARTIAL/DIRECT/FULL
|
||||
*/
|
||||
void lv_display_set_buffers(lv_display_t * disp, void * buf1, void * buf2, uint32_t buf_size,
|
||||
lv_display_render_mode_t render_mode);
|
||||
|
||||
/**
|
||||
* Set the buffers for a display, accept a draw buffer pointer.
|
||||
* Normally use `lv_display_set_buffers` is enough for most cases.
|
||||
* Use this function when an existing lv_draw_buf_t is available.
|
||||
* @param disp pointer to a display
|
||||
* @param buf1 first buffer
|
||||
* @param buf2 second buffer (can be `NULL`)
|
||||
*/
|
||||
void lv_display_set_draw_buffers(lv_display_t * disp, lv_draw_buf_t * buf1, lv_draw_buf_t * buf2);
|
||||
|
||||
/**
|
||||
* Set display render mode
|
||||
* @param disp pointer to a display
|
||||
* @param render_mode LV_DISPLAY_RENDER_MODE_PARTIAL/DIRECT/FULL
|
||||
*/
|
||||
void lv_display_set_render_mode(lv_display_t * disp, lv_display_render_mode_t render_mode);
|
||||
|
||||
/**
|
||||
* Set the flush callback which will be called to copy the rendered image to the display.
|
||||
* @param disp pointer to a display
|
||||
* @param flush_cb the flush callback (`px_map` contains the rendered image as raw pixel map and it should be copied to `area` on the display)
|
||||
*/
|
||||
void lv_display_set_flush_cb(lv_display_t * disp, lv_display_flush_cb_t flush_cb);
|
||||
|
||||
/**
|
||||
* Set a callback to be used while LVGL is waiting flushing to be finished.
|
||||
* It can do any complex logic to wait, including semaphores, mutexes, polling flags, etc.
|
||||
* If not set the `disp->flushing` flag is used which can be cleared with `lv_display_flush_ready()`
|
||||
* @param disp pointer to a display
|
||||
* @param wait_cb a callback to call while LVGL is waiting for flush ready.
|
||||
* If NULL `lv_display_flush_ready()` can be used to signal that flushing is ready.
|
||||
*/
|
||||
void lv_display_set_flush_wait_cb(lv_display_t * disp, lv_display_flush_wait_cb_t wait_cb);
|
||||
|
||||
/**
|
||||
* Set the color format of the display.
|
||||
* @param disp pointer to a display
|
||||
* @param color_format Possible values are
|
||||
* - LV_COLOR_FORMAT_RGB565
|
||||
* - LV_COLOR_FORMAT_RGB888
|
||||
* - LV_COLOR_FORMAT_XRGB888
|
||||
* - LV_COLOR_FORMAT_ARGB888
|
||||
*@note To change the endianness of the rendered image in case of RGB565 format
|
||||
* (i.e. swap the 2 bytes) call `lv_draw_sw_rgb565_swap` in the flush_cb
|
||||
*/
|
||||
void lv_display_set_color_format(lv_display_t * disp, lv_color_format_t color_format);
|
||||
|
||||
/**
|
||||
* Get the color format of the display
|
||||
* @param disp pointer to a display
|
||||
* @return the color format
|
||||
*/
|
||||
lv_color_format_t lv_display_get_color_format(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Enable anti-aliasing for the render engine
|
||||
* @param disp pointer to a display
|
||||
* @param en true/false
|
||||
*/
|
||||
void lv_display_set_antialiasing(lv_display_t * disp, bool en);
|
||||
|
||||
/**
|
||||
* Get if anti-aliasing is enabled for a display or not
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return true/false
|
||||
*/
|
||||
bool lv_display_get_antialiasing(lv_display_t * disp);
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
|
||||
/**
|
||||
* Call from the display driver when the flushing is finished
|
||||
* @param disp pointer to display whose `flush_cb` was called
|
||||
*/
|
||||
LV_ATTRIBUTE_FLUSH_READY void lv_display_flush_ready(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Tell if it's the last area of the refreshing process.
|
||||
* Can be called from `flush_cb` to execute some special display refreshing if needed when all areas area flushed.
|
||||
* @param disp pointer to display
|
||||
* @return true: it's the last area to flush;
|
||||
* false: there are other areas too which will be refreshed soon
|
||||
*/
|
||||
LV_ATTRIBUTE_FLUSH_READY bool lv_display_flush_is_last(lv_display_t * disp);
|
||||
|
||||
//! @endcond
|
||||
|
||||
bool lv_display_is_double_buffered(lv_display_t * disp);
|
||||
|
||||
/*---------------------
|
||||
* SCREENS
|
||||
*--------------------*/
|
||||
|
||||
/**
|
||||
* Return a pointer to the active screen on a display
|
||||
* @param disp pointer to display which active screen should be get.
|
||||
* (NULL to use the default screen)
|
||||
* @return pointer to the active screen object (loaded by 'lv_screen_load()')
|
||||
*/
|
||||
lv_obj_t * lv_display_get_screen_active(lv_display_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_display_get_screen_prev(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Return the top layer. The top layer is the same on all screens and it is above the normal screen layer.
|
||||
* @param disp pointer to display which top layer should be get. (NULL to use the default screen)
|
||||
* @return pointer to the top layer object
|
||||
*/
|
||||
lv_obj_t * lv_display_get_layer_top(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Return the sys. layer. The system layer is the same on all screen and it is above the normal screen and the top layer.
|
||||
* @param disp pointer to display which sys. layer should be retrieved. (NULL to use the default screen)
|
||||
* @return pointer to the sys layer object
|
||||
*/
|
||||
lv_obj_t * lv_display_get_layer_sys(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Return the bottom layer. The bottom layer is the same on all screen and it is under the normal screen layer.
|
||||
* It's visible only if the the screen is transparent.
|
||||
* @param disp pointer to display (NULL to use the default screen)
|
||||
* @return pointer to the bottom layer object
|
||||
*/
|
||||
lv_obj_t * lv_display_get_layer_bottom(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Load a screen on the default display
|
||||
* @param scr pointer to a screen
|
||||
*/
|
||||
void lv_screen_load(struct _lv_obj_t * scr);
|
||||
|
||||
/**
|
||||
* Switch screen with animation
|
||||
* @param scr pointer to the new screen to load
|
||||
* @param anim_type type of the animation from `lv_screen_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_screen_load_anim(lv_obj_t * scr, lv_screen_load_anim_t anim_type, uint32_t time, uint32_t delay,
|
||||
bool auto_del);
|
||||
|
||||
/**
|
||||
* Get the active screen of the default display
|
||||
* @return pointer to the active screen
|
||||
*/
|
||||
static inline lv_obj_t * lv_screen_active(void)
|
||||
{
|
||||
return lv_display_get_screen_active(lv_display_get_default());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top layer of the default display
|
||||
* @return pointer to the top layer
|
||||
*/
|
||||
static inline lv_obj_t * lv_layer_top(void)
|
||||
{
|
||||
return lv_display_get_layer_top(lv_display_get_default());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the system layer of the default display
|
||||
* @return pointer to the sys layer
|
||||
*/
|
||||
static inline lv_obj_t * lv_layer_sys(void)
|
||||
{
|
||||
return lv_display_get_layer_sys(lv_display_get_default());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bottom layer of the default display
|
||||
* @return pointer to the bottom layer
|
||||
*/
|
||||
static inline lv_obj_t * lv_layer_bottom(void)
|
||||
{
|
||||
return lv_display_get_layer_bottom(lv_display_get_default());
|
||||
}
|
||||
|
||||
/*---------------------
|
||||
* OTHERS
|
||||
*--------------------*/
|
||||
|
||||
/**
|
||||
* Add an event handler to the display
|
||||
* @param disp pointer to a display
|
||||
* @param event_cb an event callback
|
||||
* @param filter event code to react or `LV_EVENT_ALL`
|
||||
* @param user_data optional user_data
|
||||
*/
|
||||
void lv_display_add_event_cb(lv_display_t * disp, lv_event_cb_t event_cb, lv_event_code_t filter, void * user_data);
|
||||
|
||||
/**
|
||||
* Get the number of event attached to a display
|
||||
* @param disp pointer to a display
|
||||
* @return number of events
|
||||
*/
|
||||
uint32_t lv_display_get_event_count(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Get an event descriptor for an event
|
||||
* @param disp pointer to a display
|
||||
* @param index the index of the event
|
||||
* @return the event descriptor
|
||||
*/
|
||||
lv_event_dsc_t * lv_display_get_event_dsc(lv_display_t * disp, uint32_t index);
|
||||
|
||||
/**
|
||||
* Remove an event
|
||||
* @param disp pointer to a display
|
||||
* @param index the index of the event to remove
|
||||
* @return true: and event was removed; false: no event was removed
|
||||
*/
|
||||
bool lv_display_delete_event(lv_display_t * disp, uint32_t index);
|
||||
|
||||
/**
|
||||
* Remove an event_cb with user_data
|
||||
* @param disp pointer to a display
|
||||
* @param event_cb the event_cb of the event to remove
|
||||
* @param user_data user_data
|
||||
* @return the count of the event removed
|
||||
*/
|
||||
uint32_t lv_display_remove_event_cb_with_user_data(lv_display_t * disp, lv_event_cb_t event_cb, void * user_data);
|
||||
|
||||
/**
|
||||
* Send an event to a display
|
||||
* @param disp pointer to a display
|
||||
* @param code an event code. LV_EVENT_...
|
||||
* @param param optional param
|
||||
* @return LV_RESULT_OK: disp wasn't deleted in the event.
|
||||
*/
|
||||
lv_result_t lv_display_send_event(lv_display_t * disp, lv_event_code_t code, void * param);
|
||||
|
||||
/**
|
||||
* Set the theme of a display. If there are no user created widgets yet the screens' theme will be updated
|
||||
* @param disp pointer to a display
|
||||
* @param th pointer to a theme
|
||||
*/
|
||||
void lv_display_set_theme(lv_display_t * disp, lv_theme_t * th);
|
||||
|
||||
/**
|
||||
* Get the theme of a display
|
||||
* @param disp pointer to a display
|
||||
* @return the display's theme (can be NULL)
|
||||
*/
|
||||
lv_theme_t * lv_display_get_theme(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Get elapsed time since last user activity on a display (e.g. click)
|
||||
* @param disp pointer to a display (NULL to get the overall smallest inactivity)
|
||||
* @return elapsed ticks (milliseconds) since the last activity
|
||||
*/
|
||||
uint32_t lv_display_get_inactive_time(const lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Manually trigger an activity on a display
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
*/
|
||||
void lv_display_trigger_activity(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Temporarily enable and disable the invalidation of the display.
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @param en true: enable invalidation; false: invalidation
|
||||
*/
|
||||
void lv_display_enable_invalidation(lv_display_t * disp, bool en);
|
||||
|
||||
/**
|
||||
* Get display invalidation is enabled.
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
* @return return true if invalidation is enabled
|
||||
*/
|
||||
bool lv_display_is_invalidation_enabled(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Get a pointer to the screen refresher timer to
|
||||
* modify its parameters with `lv_timer_...` functions.
|
||||
* @param disp pointer to a display
|
||||
* @return pointer to the display refresher timer. (NULL on error)
|
||||
*/
|
||||
lv_timer_t * lv_display_get_refr_timer(lv_display_t * disp);
|
||||
|
||||
/**
|
||||
* Delete screen refresher timer
|
||||
* @param disp pointer to a display
|
||||
*/
|
||||
void lv_display_delete_refr_timer(lv_display_t * disp);
|
||||
|
||||
void lv_display_set_user_data(lv_display_t * disp, void * user_data);
|
||||
void lv_display_set_driver_data(lv_display_t * disp, void * driver_data);
|
||||
void * lv_display_get_user_data(lv_display_t * disp);
|
||||
void * lv_display_get_driver_data(lv_display_t * disp);
|
||||
lv_draw_buf_t * lv_display_get_buf_active(lv_display_t * disp);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/*------------------------------------------------
|
||||
* To improve backward compatibility
|
||||
* Recommended only if you have one display
|
||||
*------------------------------------------------*/
|
||||
|
||||
#ifndef LV_HOR_RES
|
||||
/**
|
||||
* The horizontal resolution of the currently active display.
|
||||
*/
|
||||
#define LV_HOR_RES lv_display_get_horizontal_resolution(lv_display_get_default())
|
||||
#endif
|
||||
|
||||
#ifndef LV_VER_RES
|
||||
/**
|
||||
* The vertical resolution of the currently active display.
|
||||
*/
|
||||
#define LV_VER_RES lv_display_get_vertical_resolution(lv_display_get_default())
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Same as Android's DIP. (Different name is chosen to avoid mistype between LV_DPI and LV_DIP)
|
||||
* 1 dip is 1 px on a 160 DPI screen
|
||||
* 1 dip is 2 px on a 320 DPI screen
|
||||
* https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dip-dp-and-sp
|
||||
*/
|
||||
#define _LV_DPX_CALC(dpi, n) ((n) == 0 ? 0 :LV_MAX((( (dpi) * (n) + 80) / 160), 1)) /*+80 for rounding*/
|
||||
#define LV_DPX(n) _LV_DPX_CALC(lv_display_get_dpi(NULL), n)
|
||||
|
||||
/**
|
||||
* Scale the given number of pixels (a distance or size) relative to a 160 DPI display
|
||||
* considering the DPI of the default display.
|
||||
* It ensures that e.g. `lv_dpx(100)` will have the same physical size regardless to the
|
||||
* DPI of the display.
|
||||
* @param n the number of pixels to scale
|
||||
* @return `n x current_dpi/160`
|
||||
*/
|
||||
static inline int32_t lv_dpx(int32_t n)
|
||||
{
|
||||
return LV_DPX(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale the given number of pixels (a distance or size) relative to a 160 DPI display
|
||||
* considering the DPI of the given display.
|
||||
* It ensures that e.g. `lv_dpx(100)` will have the same physical size regardless to the
|
||||
* DPI of the display.
|
||||
* @param disp a display whose dpi should be considered
|
||||
* @param n the number of pixels to scale
|
||||
* @return `n x current_dpi/160`
|
||||
*/
|
||||
static inline int32_t lv_display_dpx(const lv_display_t * disp, int32_t n)
|
||||
{
|
||||
return _LV_DPX_CALC(lv_display_get_dpi(disp), n);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DISPLAY_H*/
|
||||
165
libraries/lvgl/src/display/lv_display_private.h
Normal file
165
libraries/lvgl/src/display/lv_display_private.h
Normal file
@ -0,0 +1,165 @@
|
||||
/**
|
||||
* @file lv_display_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DISPLAY_PRIVATE_H
|
||||
#define LV_DISPLAY_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../core/lv_obj.h"
|
||||
#include "../draw/lv_draw.h"
|
||||
#include "lv_display.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_INV_BUF_SIZE
|
||||
#define LV_INV_BUF_SIZE 32 /*Buffer size for invalid areas*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_display_t {
|
||||
|
||||
/*---------------------
|
||||
* Resolution
|
||||
*--------------------*/
|
||||
|
||||
/** Horizontal resolution.*/
|
||||
int32_t hor_res;
|
||||
|
||||
/** Vertical resolution.*/
|
||||
int32_t ver_res;
|
||||
|
||||
/** Horizontal resolution of the full / physical display. Set to -1 for fullscreen mode.*/
|
||||
int32_t physical_hor_res;
|
||||
|
||||
/** Vertical resolution of the full / physical display. Set to -1 for fullscreen mode.*/
|
||||
int32_t physical_ver_res;
|
||||
|
||||
/** Horizontal offset from the full / physical display. Set to 0 for fullscreen mode.*/
|
||||
int32_t offset_x;
|
||||
|
||||
/** Vertical offset from the full / physical display. Set to 0 for fullscreen mode.*/
|
||||
int32_t offset_y;
|
||||
|
||||
uint32_t dpi; /** DPI (dot per inch) of the display. Default value is `LV_DPI_DEF`.*/
|
||||
|
||||
/*---------------------
|
||||
* Buffering
|
||||
*--------------------*/
|
||||
lv_draw_buf_t * buf_1;
|
||||
lv_draw_buf_t * buf_2;
|
||||
|
||||
/** Internal, used by the library*/
|
||||
lv_draw_buf_t * buf_act;
|
||||
|
||||
/** MANDATORY: Write the internal buffer (draw_buf) to the display. 'lv_display_flush_ready()' has to be
|
||||
* called when finished*/
|
||||
lv_display_flush_cb_t flush_cb;
|
||||
|
||||
/**
|
||||
* Used to wait while flushing is ready.
|
||||
* It can do any complex logic to wait, including semaphores, mutexes, polling flags, etc.
|
||||
* If not set `flushing` flag is used which can be cleared with `lv_display_flush_ready()`*/
|
||||
lv_display_flush_wait_cb_t flush_wait_cb;
|
||||
|
||||
/*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 bit field 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_display_render_mode_t render_mode;
|
||||
uint32_t antialiasing : 1; /**< 1: anti-aliasing is enabled on this display.*/
|
||||
|
||||
/** 1: The current screen rendering is in progress*/
|
||||
uint32_t rendering_in_progress : 1;
|
||||
|
||||
lv_color_format_t color_format;
|
||||
|
||||
/** Invalidated (marked to redraw) areas*/
|
||||
lv_area_t inv_areas[LV_INV_BUF_SIZE];
|
||||
uint8_t inv_area_joined[LV_INV_BUF_SIZE];
|
||||
uint32_t inv_p;
|
||||
int32_t inv_en_cnt;
|
||||
|
||||
/** Double buffer sync areas (redrawn during last refresh) */
|
||||
lv_ll_t sync_areas;
|
||||
|
||||
lv_draw_buf_t _static_buf1; /*Used when user pass in a raw buffer as display draw buffer*/
|
||||
lv_draw_buf_t _static_buf2;
|
||||
/*---------------------
|
||||
* Layer
|
||||
*--------------------*/
|
||||
lv_layer_t * layer_head;
|
||||
void (*layer_init)(lv_display_t * disp, lv_layer_t * layer);
|
||||
void (*layer_deinit)(lv_display_t * disp, lv_layer_t * layer);
|
||||
|
||||
/*---------------------
|
||||
* Screens
|
||||
*--------------------*/
|
||||
|
||||
/** Screens of the display*/
|
||||
lv_obj_t ** screens; /**< Array of screen objects.*/
|
||||
lv_obj_t * act_scr; /**< Currently active screen on this display*/
|
||||
lv_obj_t * prev_scr; /**< Previous screen. Used during screen animations*/
|
||||
lv_obj_t * scr_to_load; /**< The screen prepared to load in lv_screen_load_anim*/
|
||||
lv_obj_t * bottom_layer; /**< @see lv_display_get_layer_bottom*/
|
||||
lv_obj_t * top_layer; /**< @see lv_display_get_layer_top*/
|
||||
lv_obj_t * sys_layer; /**< @see lv_display_get_layer_sys*/
|
||||
uint32_t screen_cnt;
|
||||
uint8_t draw_prev_over_act : 1;/** 1: Draw previous screen over active screen*/
|
||||
uint8_t del_prev : 1; /** 1: Automatically delete the previous screen when the screen load animation is ready*/
|
||||
|
||||
/*---------------------
|
||||
* Others
|
||||
*--------------------*/
|
||||
|
||||
void * driver_data; /**< Custom user data*/
|
||||
|
||||
void * user_data; /**< Custom user data*/
|
||||
|
||||
lv_event_list_t event_list;
|
||||
|
||||
uint32_t sw_rotate : 1; /**< 1: use software rotation (slower)*/
|
||||
uint32_t rotation : 2; /**< Element of @lv_display_rotation_t*/
|
||||
|
||||
/**< The theme assigned to the screen*/
|
||||
lv_theme_t * theme;
|
||||
|
||||
/** A timer which periodically checks the dirty areas and refreshes them*/
|
||||
lv_timer_t * refr_timer;
|
||||
|
||||
/*Miscellaneous data*/
|
||||
uint32_t last_activity_time; /**< Last time when there was activity on this display*/
|
||||
|
||||
/** The area being refreshed*/
|
||||
lv_area_t refreshed_area;
|
||||
};
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DISPLAY_PRIVATE_H*/
|
||||
424
libraries/lvgl/src/draw/lv_draw.c
Normal file
424
libraries/lvgl/src/draw/lv_draw.c
Normal file
@ -0,0 +1,424 @@
|
||||
/**
|
||||
* @file lv_draw.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw.h"
|
||||
#include "sw/lv_draw_sw.h"
|
||||
#include "../display/lv_display_private.h"
|
||||
#include "../core/lv_global.h"
|
||||
#include "../core/lv_refr.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define _draw_info LV_GLOBAL_DEFAULT()->draw_info
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool is_independent(lv_layer_t * layer, lv_draw_task_t * t_check);
|
||||
|
||||
static inline uint32_t get_layer_size_kb(uint32_t size_byte)
|
||||
{
|
||||
return size_byte < 1024 ? 1 : size_byte >> 10;
|
||||
}
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_draw_init(void)
|
||||
{
|
||||
#if LV_USE_OS
|
||||
lv_thread_sync_init(&_draw_info.sync);
|
||||
#endif
|
||||
}
|
||||
|
||||
void lv_draw_deinit(void)
|
||||
{
|
||||
#if LV_USE_OS
|
||||
lv_thread_sync_delete(&_draw_info.sync);
|
||||
#endif
|
||||
|
||||
lv_draw_unit_t * u = _draw_info.unit_head;
|
||||
while(u) {
|
||||
lv_draw_unit_t * cur_unit = u;
|
||||
u = u->next;
|
||||
|
||||
if(cur_unit->delete_cb) cur_unit->delete_cb(cur_unit);
|
||||
lv_free(cur_unit);
|
||||
}
|
||||
_draw_info.unit_head = NULL;
|
||||
}
|
||||
|
||||
void * lv_draw_create_unit(size_t size)
|
||||
{
|
||||
lv_draw_unit_t * new_unit = lv_malloc_zeroed(size);
|
||||
|
||||
new_unit->next = _draw_info.unit_head;
|
||||
_draw_info.unit_head = new_unit;
|
||||
|
||||
return new_unit;
|
||||
}
|
||||
|
||||
lv_draw_task_t * lv_draw_add_task(lv_layer_t * layer, const lv_area_t * coords)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
lv_draw_task_t * new_task = lv_malloc_zeroed(sizeof(lv_draw_task_t));
|
||||
|
||||
new_task->area = *coords;
|
||||
new_task->_real_area = *coords;
|
||||
new_task->clip_area = layer->_clip_area;
|
||||
new_task->state = LV_DRAW_TASK_STATE_QUEUED;
|
||||
|
||||
/*Find the tail*/
|
||||
if(layer->draw_task_head == NULL) {
|
||||
layer->draw_task_head = new_task;
|
||||
}
|
||||
else {
|
||||
lv_draw_task_t * tail = layer->draw_task_head;
|
||||
while(tail->next) tail = tail->next;
|
||||
|
||||
tail->next = new_task;
|
||||
}
|
||||
|
||||
LV_PROFILER_END;
|
||||
return new_task;
|
||||
}
|
||||
|
||||
void lv_draw_finalize_task_creation(lv_layer_t * layer, lv_draw_task_t * t)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
lv_draw_dsc_base_t * base_dsc = t->draw_dsc;
|
||||
base_dsc->layer = layer;
|
||||
|
||||
lv_draw_global_info_t * info = &_draw_info;
|
||||
|
||||
/*Send LV_EVENT_DRAW_TASK_ADDED and dispatch only on the "main" draw_task
|
||||
*and not on the draw tasks added in the event.
|
||||
*Sending LV_EVENT_DRAW_TASK_ADDED events might cause recursive event sends and besides
|
||||
*dispatching might remove the "main" draw task while it's still being used in the event*/
|
||||
|
||||
if(info->task_running == false) {
|
||||
if(base_dsc->obj && lv_obj_has_flag(base_dsc->obj, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS)) {
|
||||
info->task_running = true;
|
||||
lv_obj_send_event(base_dsc->obj, LV_EVENT_DRAW_TASK_ADDED, t);
|
||||
info->task_running = false;
|
||||
}
|
||||
|
||||
/*Let the draw units set their preference score*/
|
||||
t->preference_score = 100;
|
||||
t->preferred_draw_unit_id = 0;
|
||||
lv_draw_unit_t * u = info->unit_head;
|
||||
while(u) {
|
||||
if(u->evaluate_cb) u->evaluate_cb(u, t);
|
||||
u = u->next;
|
||||
}
|
||||
|
||||
lv_draw_dispatch();
|
||||
}
|
||||
else {
|
||||
/*Let the draw units set their preference score*/
|
||||
t->preference_score = 100;
|
||||
t->preferred_draw_unit_id = 0;
|
||||
lv_draw_unit_t * u = info->unit_head;
|
||||
while(u) {
|
||||
if(u->evaluate_cb) u->evaluate_cb(u, t);
|
||||
u = u->next;
|
||||
}
|
||||
}
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
void lv_draw_dispatch(void)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
bool render_running = false;
|
||||
lv_display_t * disp = lv_display_get_next(NULL);
|
||||
while(disp) {
|
||||
lv_layer_t * layer = disp->layer_head;
|
||||
while(layer) {
|
||||
if(lv_draw_dispatch_layer(disp, layer))
|
||||
render_running = true;
|
||||
layer = layer->next;
|
||||
}
|
||||
if(!render_running) {
|
||||
lv_draw_dispatch_request();
|
||||
}
|
||||
disp = lv_display_get_next(disp);
|
||||
}
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
bool lv_draw_dispatch_layer(lv_display_t * disp, lv_layer_t * layer)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
/*Remove the finished tasks first*/
|
||||
lv_draw_task_t * t_prev = NULL;
|
||||
lv_draw_task_t * t = layer->draw_task_head;
|
||||
while(t) {
|
||||
lv_draw_task_t * t_next = t->next;
|
||||
if(t->state == LV_DRAW_TASK_STATE_READY) {
|
||||
if(t_prev) t_prev->next = t->next; /*Remove by it by assigning the next task to the previous*/
|
||||
else layer->draw_task_head = t_next; /*If it was the head, set the next as head*/
|
||||
|
||||
/*If it was layer drawing free the layer too*/
|
||||
if(t->type == LV_DRAW_TASK_TYPE_LAYER) {
|
||||
lv_draw_image_dsc_t * draw_image_dsc = t->draw_dsc;
|
||||
lv_layer_t * layer_drawn = (lv_layer_t *)draw_image_dsc->src;
|
||||
|
||||
if(layer_drawn->draw_buf) {
|
||||
int32_t h = lv_area_get_height(&layer_drawn->buf_area);
|
||||
int32_t w = lv_area_get_width(&layer_drawn->buf_area);
|
||||
uint32_t layer_size_byte = h * lv_draw_buf_width_to_stride(w, layer_drawn->color_format);
|
||||
|
||||
_draw_info.used_memory_for_layers_kb -= get_layer_size_kb(layer_size_byte);
|
||||
LV_LOG_INFO("Layer memory used: %" LV_PRIu32 " kB\n", _draw_info.used_memory_for_layers_kb);
|
||||
lv_draw_buf_destroy(layer_drawn->draw_buf);
|
||||
layer_drawn->draw_buf = NULL;
|
||||
}
|
||||
|
||||
/*Remove the layer from the display's*/
|
||||
if(disp) {
|
||||
lv_layer_t * l2 = disp->layer_head;
|
||||
while(l2) {
|
||||
if(l2->next == layer_drawn) {
|
||||
l2->next = layer_drawn->next;
|
||||
break;
|
||||
}
|
||||
l2 = l2->next;
|
||||
}
|
||||
|
||||
if(disp->layer_deinit) disp->layer_deinit(disp, layer_drawn);
|
||||
lv_free(layer_drawn);
|
||||
}
|
||||
}
|
||||
lv_draw_label_dsc_t * draw_label_dsc = lv_draw_task_get_label_dsc(t);
|
||||
if(draw_label_dsc && draw_label_dsc->text_local) {
|
||||
lv_free((void *)draw_label_dsc->text);
|
||||
draw_label_dsc->text = NULL;
|
||||
}
|
||||
|
||||
lv_free(t->draw_dsc);
|
||||
lv_free(t);
|
||||
}
|
||||
else {
|
||||
t_prev = t;
|
||||
}
|
||||
t = t_next;
|
||||
}
|
||||
|
||||
bool render_running = false;
|
||||
|
||||
/*This layer is ready, enable blending its buffer*/
|
||||
if(layer->parent && layer->all_tasks_added && layer->draw_task_head == NULL) {
|
||||
/*Find a draw task with TYPE_LAYER in the layer where the src is this layer*/
|
||||
lv_draw_task_t * t_src = layer->parent->draw_task_head;
|
||||
while(t_src) {
|
||||
if(t_src->type == LV_DRAW_TASK_TYPE_LAYER && t_src->state == LV_DRAW_TASK_STATE_WAITING) {
|
||||
lv_draw_image_dsc_t * draw_dsc = t_src->draw_dsc;
|
||||
if(draw_dsc->src == layer) {
|
||||
t_src->state = LV_DRAW_TASK_STATE_QUEUED;
|
||||
lv_draw_dispatch_request();
|
||||
break;
|
||||
}
|
||||
}
|
||||
t_src = t_src->next;
|
||||
}
|
||||
}
|
||||
/*Assign draw tasks to the draw_units*/
|
||||
else {
|
||||
/*Find a draw unit which is not busy and can take at least one task*/
|
||||
/*Let all draw units to pick draw tasks*/
|
||||
lv_draw_unit_t * u = _draw_info.unit_head;
|
||||
while(u) {
|
||||
int32_t taken_cnt = u->dispatch_cb(u, layer);
|
||||
if(taken_cnt >= 0) render_running = true;
|
||||
u = u->next;
|
||||
}
|
||||
}
|
||||
|
||||
LV_PROFILER_END;
|
||||
return render_running;
|
||||
}
|
||||
|
||||
void lv_draw_dispatch_wait_for_request(void)
|
||||
{
|
||||
#if LV_USE_OS
|
||||
lv_thread_sync_wait(&_draw_info.sync);
|
||||
#else
|
||||
while(!_draw_info.dispatch_req);
|
||||
_draw_info.dispatch_req = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void lv_draw_dispatch_request(void)
|
||||
{
|
||||
#if LV_USE_OS
|
||||
lv_thread_sync_signal(&_draw_info.sync);
|
||||
#else
|
||||
_draw_info.dispatch_req = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
lv_draw_task_t * lv_draw_get_next_available_task(lv_layer_t * layer, lv_draw_task_t * t_prev, uint8_t draw_unit_id)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
/*If the first task is screen sized, there cannot be independent areas*/
|
||||
if(layer->draw_task_head) {
|
||||
int32_t hor_res = lv_display_get_horizontal_resolution(_lv_refr_get_disp_refreshing());
|
||||
int32_t ver_res = lv_display_get_vertical_resolution(_lv_refr_get_disp_refreshing());
|
||||
lv_draw_task_t * t = layer->draw_task_head;
|
||||
if(t->state != LV_DRAW_TASK_STATE_QUEUED &&
|
||||
t->area.x1 <= 0 && t->area.x2 >= hor_res - 1 &&
|
||||
t->area.y1 <= 0 && t->area.y2 >= ver_res - 1) {
|
||||
LV_PROFILER_END;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
lv_draw_task_t * t = t_prev ? t_prev->next : layer->draw_task_head;
|
||||
while(t) {
|
||||
/*Find a queued and independent task*/
|
||||
if(t->state == LV_DRAW_TASK_STATE_QUEUED &&
|
||||
(t->preferred_draw_unit_id == LV_DRAW_UNIT_ID_ANY || t->preferred_draw_unit_id == draw_unit_id) &&
|
||||
is_independent(layer, t)) {
|
||||
LV_PROFILER_END;
|
||||
return t;
|
||||
}
|
||||
t = t->next;
|
||||
}
|
||||
|
||||
LV_PROFILER_END;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint32_t lv_draw_get_dependent_count(lv_draw_task_t * t_check)
|
||||
{
|
||||
if(t_check == NULL) return 0;
|
||||
if(t_check->next == NULL) return 0;
|
||||
|
||||
LV_PROFILER_BEGIN;
|
||||
uint32_t cnt = 0;
|
||||
|
||||
lv_draw_task_t * t = t_check->next;
|
||||
while(t) {
|
||||
if((t->state == LV_DRAW_TASK_STATE_QUEUED || t->state == LV_DRAW_TASK_STATE_WAITING) &&
|
||||
_lv_area_is_on(&t_check->area, &t->area)) {
|
||||
cnt++;
|
||||
}
|
||||
|
||||
t = t->next;
|
||||
}
|
||||
LV_PROFILER_END;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
lv_layer_t * lv_draw_layer_create(lv_layer_t * parent_layer, lv_color_format_t color_format, const lv_area_t * area)
|
||||
{
|
||||
lv_display_t * disp = _lv_refr_get_disp_refreshing();
|
||||
lv_layer_t * new_layer = lv_malloc_zeroed(sizeof(lv_layer_t));
|
||||
LV_ASSERT_MALLOC(new_layer);
|
||||
if(new_layer == NULL) return NULL;
|
||||
|
||||
new_layer->parent = parent_layer;
|
||||
new_layer->_clip_area = *area;
|
||||
new_layer->buf_area = *area;
|
||||
new_layer->color_format = color_format;
|
||||
|
||||
if(disp->layer_head) {
|
||||
lv_layer_t * tail = disp->layer_head;
|
||||
while(tail->next) tail = tail->next;
|
||||
tail->next = new_layer;
|
||||
}
|
||||
else {
|
||||
disp->layer_head = new_layer;
|
||||
}
|
||||
|
||||
return new_layer;
|
||||
}
|
||||
|
||||
void * lv_draw_layer_alloc_buf(lv_layer_t * layer)
|
||||
{
|
||||
/*If the buffer of the layer is already allocated return it*/
|
||||
if(layer->draw_buf != NULL) {
|
||||
return layer->draw_buf->data;
|
||||
}
|
||||
|
||||
/*If the buffer of the layer is not allocated yet, allocate it now*/
|
||||
int32_t w = lv_area_get_width(&layer->buf_area);
|
||||
int32_t h = lv_area_get_height(&layer->buf_area);
|
||||
uint32_t layer_size_byte = h * lv_draw_buf_width_to_stride(w, layer->color_format);
|
||||
|
||||
layer->draw_buf = lv_draw_buf_create(w, h, layer->color_format, 0);
|
||||
|
||||
if(layer->draw_buf == NULL) {
|
||||
LV_LOG_WARN("Allocating layer buffer failed. Try later");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_draw_info.used_memory_for_layers_kb += get_layer_size_kb(layer_size_byte);
|
||||
LV_LOG_INFO("Layer memory used: %" LV_PRIu32 " kB\n", _draw_info.used_memory_for_layers_kb);
|
||||
|
||||
if(lv_color_format_has_alpha(layer->color_format)) {
|
||||
lv_draw_buf_clear(layer->draw_buf, NULL);
|
||||
}
|
||||
|
||||
return layer->draw_buf->data;
|
||||
}
|
||||
|
||||
void * lv_draw_layer_go_to_xy(lv_layer_t * layer, int32_t x, int32_t y)
|
||||
{
|
||||
return lv_draw_buf_goto_xy(layer->draw_buf, x, y);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Check if there are older draw task overlapping the area of `t_check`
|
||||
* @param layer the draw ctx to search in
|
||||
* @param t_check check this task if it overlaps with the older ones
|
||||
* @return true: `t_check` is not overlapping with older tasks so it's independent
|
||||
*/
|
||||
static bool is_independent(lv_layer_t * layer, lv_draw_task_t * t_check)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
lv_draw_task_t * t = layer->draw_task_head;
|
||||
|
||||
/*If t_check is outside of the older tasks then it's independent*/
|
||||
while(t && t != t_check) {
|
||||
if(t->state != LV_DRAW_TASK_STATE_READY) {
|
||||
lv_area_t a;
|
||||
if(_lv_area_intersect(&a, &t->_real_area, &t_check->_real_area)) {
|
||||
LV_PROFILER_END;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
t = t->next;
|
||||
}
|
||||
LV_PROFILER_END;
|
||||
|
||||
return true;
|
||||
}
|
||||
330
libraries/lvgl/src/draw/lv_draw.h
Normal file
330
libraries/lvgl/src/draw/lv_draw.h
Normal file
@ -0,0 +1,330 @@
|
||||
/**
|
||||
* @file lv_draw.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_H
|
||||
#define LV_DRAW_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#include "../misc/lv_types.h"
|
||||
#include "../misc/lv_style.h"
|
||||
#include "../misc/lv_text.h"
|
||||
#include "../misc/lv_profiler.h"
|
||||
#include "lv_image_decoder.h"
|
||||
#include "../osal/lv_os.h"
|
||||
#include "lv_draw_buf.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_DRAW_UNIT_ID_ANY 0
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_DRAW_TASK_TYPE_FILL,
|
||||
LV_DRAW_TASK_TYPE_BORDER,
|
||||
LV_DRAW_TASK_TYPE_BOX_SHADOW,
|
||||
LV_DRAW_TASK_TYPE_LABEL,
|
||||
LV_DRAW_TASK_TYPE_IMAGE,
|
||||
LV_DRAW_TASK_TYPE_LAYER,
|
||||
LV_DRAW_TASK_TYPE_LINE,
|
||||
LV_DRAW_TASK_TYPE_ARC,
|
||||
LV_DRAW_TASK_TYPE_TRIANGLE,
|
||||
LV_DRAW_TASK_TYPE_MASK_RECTANGLE,
|
||||
LV_DRAW_TASK_TYPE_MASK_BITMAP,
|
||||
LV_DRAW_TASK_TYPE_VECTOR,
|
||||
} lv_draw_task_type_t;
|
||||
|
||||
typedef enum {
|
||||
LV_DRAW_TASK_STATE_WAITING, /*Waiting for something to be finished. E.g. rendering a layer*/
|
||||
LV_DRAW_TASK_STATE_QUEUED,
|
||||
LV_DRAW_TASK_STATE_IN_PROGRESS,
|
||||
LV_DRAW_TASK_STATE_READY,
|
||||
} lv_draw_task_state_t;
|
||||
|
||||
struct _lv_draw_task_t {
|
||||
lv_draw_task_t * next;
|
||||
|
||||
lv_draw_task_type_t type;
|
||||
|
||||
/**
|
||||
* The area where to draw
|
||||
*/
|
||||
lv_area_t area;
|
||||
|
||||
/**
|
||||
* The real draw area. E.g. for shadow, outline, or transformed images it's different from `area`
|
||||
*/
|
||||
lv_area_t _real_area;
|
||||
|
||||
/** The original area which is updated*/
|
||||
lv_area_t clip_area_original;
|
||||
|
||||
/**
|
||||
* The clip area of the layer is saved here when the draw task is created.
|
||||
* As the clip area of the layer can be changed as new draw tasks are added its current value needs to be saved.
|
||||
* Therefore during drawing the layer's clip area shouldn't be used as it might be already changed for other draw tasks.
|
||||
*/
|
||||
lv_area_t clip_area;
|
||||
|
||||
volatile int state; /*int instead of lv_draw_task_state_t to be sure its atomic*/
|
||||
|
||||
void * draw_dsc;
|
||||
|
||||
/**
|
||||
* The ID of the draw_unit which should take this task
|
||||
*/
|
||||
uint8_t preferred_draw_unit_id;
|
||||
|
||||
/**
|
||||
* Set to which extent `preferred_draw_unit_id` is good at this task.
|
||||
* 80: means 20% better (faster) than software rendering
|
||||
* 100: the default value
|
||||
* 110: means 10% worse (slower) than software rendering
|
||||
*/
|
||||
uint8_t preference_score;
|
||||
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
void * user_data;
|
||||
} lv_draw_mask_t;
|
||||
|
||||
struct _lv_draw_unit_t {
|
||||
lv_draw_unit_t * next;
|
||||
|
||||
/**
|
||||
* The target_layer on which drawing should happen
|
||||
*/
|
||||
lv_layer_t * target_layer;
|
||||
|
||||
const lv_area_t * clip_area;
|
||||
|
||||
/**
|
||||
* Called to try to assign a draw task to itself.
|
||||
* `lv_draw_get_next_available_task` can be used to get an independent draw task.
|
||||
* A draw task should be assign only if the draw unit can draw it too
|
||||
* @param draw_unit pointer to the draw unit
|
||||
* @param layer pointer to a layer on which the draw task should be drawn
|
||||
* @return >=0: The number of taken draw task:
|
||||
* 0 means the task has not yet been completed.
|
||||
* 1 means a new task has been accepted.
|
||||
* -1: The draw unit wanted to work on a task but couldn't do that
|
||||
* due to some errors (e.g. out of memory).
|
||||
* It signals that LVGL should call the dispatcher later again
|
||||
* to let draw unit try to start the rendering again.
|
||||
*/
|
||||
int32_t (*dispatch_cb)(lv_draw_unit_t * draw_unit, lv_layer_t * layer);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param draw_unit
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
int32_t (*evaluate_cb)(lv_draw_unit_t * draw_unit, lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Called to delete draw unit.
|
||||
* @param draw_unit
|
||||
* @return
|
||||
*/
|
||||
int32_t (*delete_cb)(lv_draw_unit_t * draw_unit);
|
||||
};
|
||||
|
||||
struct _lv_layer_t {
|
||||
|
||||
/** Target draw buffer of the layer*/
|
||||
lv_draw_buf_t * draw_buf;
|
||||
|
||||
/** The absolute coordinates of the buffer */
|
||||
lv_area_t buf_area;
|
||||
|
||||
/** The color format of the layer. LV_COLOR_FORMAT_... */
|
||||
lv_color_format_t color_format;
|
||||
|
||||
/**
|
||||
* NEVER USE IT DRAW UNITS. USED INTERNALLY DURING DRAW TASK CREATION.
|
||||
* The current clip area with absolute coordinates, always the same or smaller than `buf_area`
|
||||
* Can be set before new draw tasks are added to indicate the clip area of the draw tasks.
|
||||
* Therefore `lv_draw_add_task()` always saves it in the new draw task to know the clip area when the draw task was added.
|
||||
* During drawing the draw units also sees the saved clip_area and should use it during drawing.
|
||||
* During drawing the layer's clip area shouldn't be used as it might be already changed for other draw tasks.
|
||||
*/
|
||||
lv_area_t _clip_area;
|
||||
|
||||
/** Linked list of draw tasks */
|
||||
lv_draw_task_t * draw_task_head;
|
||||
|
||||
lv_layer_t * parent;
|
||||
lv_layer_t * next;
|
||||
bool all_tasks_added;
|
||||
void * user_data;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
lv_obj_t * obj;
|
||||
uint32_t part;
|
||||
uint32_t id1;
|
||||
uint32_t id2;
|
||||
lv_layer_t * layer;
|
||||
size_t dsc_size;
|
||||
void * user_data;
|
||||
} lv_draw_dsc_base_t;
|
||||
|
||||
typedef struct {
|
||||
lv_draw_unit_t * unit_head;
|
||||
uint32_t used_memory_for_layers_kb;
|
||||
#if LV_USE_OS
|
||||
lv_thread_sync_t sync;
|
||||
#else
|
||||
int dispatch_req;
|
||||
#endif
|
||||
lv_mutex_t circle_cache_mutex;
|
||||
bool task_running;
|
||||
} lv_draw_global_info_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Used internally to initialize the drawing module
|
||||
*/
|
||||
void lv_draw_init(void);
|
||||
|
||||
/**
|
||||
* Deinitialize the drawing module
|
||||
*/
|
||||
void lv_draw_deinit(void);
|
||||
|
||||
/**
|
||||
* Allocate a new draw unit with the given size and appends it to the list of draw units
|
||||
* @param size the size to allocate. E.g. `sizeof(my_draw_unit_t)`,
|
||||
* where the first element of `my_draw_unit_t` is `lv_draw_unit_t`.
|
||||
*/
|
||||
void * lv_draw_create_unit(size_t size);
|
||||
|
||||
/**
|
||||
* Add an empty draw task to the draw task list of a layer.
|
||||
* @param layer pointer to a layer
|
||||
* @param coords the coordinates of the draw task
|
||||
* @return the created draw task which needs to be
|
||||
* further configured e.g. by added a draw descriptor
|
||||
*/
|
||||
lv_draw_task_t * lv_draw_add_task(lv_layer_t * layer, const lv_area_t * coords);
|
||||
|
||||
/**
|
||||
* Needs to be called when a draw task is created and configured.
|
||||
* It will send an event about the new draw task to the widget
|
||||
* and assign it to a draw unit.
|
||||
* @param layer pointer to a layer
|
||||
* @param t poinr to a draw task
|
||||
*/
|
||||
void lv_draw_finalize_task_creation(lv_layer_t * layer, lv_draw_task_t * t);
|
||||
|
||||
/**
|
||||
* Try dispatching draw tasks to draw units
|
||||
*/
|
||||
void lv_draw_dispatch(void);
|
||||
|
||||
/**
|
||||
* Used internally to try dispatching draw tasks of a specific layer
|
||||
* @param disp pointer to a display on which the dispatching was requested
|
||||
* @param layer pointer to a layer
|
||||
* @return at least one draw task is being rendered (maybe it was taken earlier)
|
||||
*/
|
||||
bool lv_draw_dispatch_layer(lv_display_t * disp, lv_layer_t * layer);
|
||||
|
||||
/**
|
||||
* Wait for a new dispatch request.
|
||||
* It's blocking if `LV_USE_OS == 0` else it yields
|
||||
*/
|
||||
void lv_draw_dispatch_wait_for_request(void);
|
||||
|
||||
/**
|
||||
* When a draw unit finished a draw task it needs to request dispatching
|
||||
* to let LVGL assign a new draw task to it
|
||||
*/
|
||||
void lv_draw_dispatch_request(void);
|
||||
|
||||
/**
|
||||
* Find and available draw task
|
||||
* @param layer the draw ctx to search in
|
||||
* @param t_prev continue searching from this task
|
||||
* @param draw_unit_id check the task where `preferred_draw_unit_id` equals this value or `LV_DRAW_UNIT_ID_ANY`
|
||||
* @return tan available draw task or NULL if there is no any
|
||||
*/
|
||||
lv_draw_task_t * lv_draw_get_next_available_task(lv_layer_t * layer, lv_draw_task_t * t_prev, uint8_t draw_unit_id);
|
||||
|
||||
/**
|
||||
* Tell how many draw task are waiting to be drawn on the area of `t_check`.
|
||||
* It can be used to determine if a GPU shall combine many draw tasks in to one or not.
|
||||
* If a lot of tasks are waiting for the current ones it makes sense to draw them one-by-one
|
||||
* to not block the dependent tasks' rendering
|
||||
* @param t_check the task whose dependent tasks shall be counted
|
||||
* @return number of tasks depending on `t_check`
|
||||
*/
|
||||
uint32_t lv_draw_get_dependent_count(lv_draw_task_t * t_check);
|
||||
|
||||
/**
|
||||
* Create a new layer on a parent layer
|
||||
* @param parent_layer the parent layer to which the layer will be merged when it's rendered
|
||||
* @param color_format the color format of the layer
|
||||
* @param area the areas of the layer (absolute coordinates)
|
||||
* @return the new target_layer or NULL on error
|
||||
*/
|
||||
lv_layer_t * lv_draw_layer_create(lv_layer_t * parent_layer, lv_color_format_t color_format, const lv_area_t * area);
|
||||
|
||||
/**
|
||||
* Try to allocate a buffer for the layer.
|
||||
* @param layer pointer to a layer
|
||||
* @return pointer to the allocated aligned buffer or NULL on failure
|
||||
*/
|
||||
void * lv_draw_layer_alloc_buf(lv_layer_t * layer);
|
||||
|
||||
/**
|
||||
* Got to a pixel at X and Y coordinate on a layer
|
||||
* @param layer pointer to a layer
|
||||
* @param x the target X coordinate
|
||||
* @param y the target X coordinate
|
||||
* @return `buf` offset to point to the given X and Y coordinate
|
||||
*/
|
||||
void * lv_draw_layer_go_to_xy(lv_layer_t * layer, int32_t x, int32_t y);
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* POST INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_rect.h"
|
||||
#include "lv_draw_label.h"
|
||||
#include "lv_draw_image.h"
|
||||
#include "lv_draw_arc.h"
|
||||
#include "lv_draw_line.h"
|
||||
#include "lv_draw_triangle.h"
|
||||
#include "lv_draw_mask.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_H*/
|
||||
172
libraries/lvgl/src/draw/lv_draw_arc.c
Normal file
172
libraries/lvgl/src/draw/lv_draw_arc.c
Normal file
@ -0,0 +1,172 @@
|
||||
/**
|
||||
* @file lv_draw_arc.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../core/lv_obj.h"
|
||||
#include "lv_draw_arc.h"
|
||||
#include "../core/lv_obj_event.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(lv_draw_arc_dsc_t));
|
||||
dsc->width = 1;
|
||||
dsc->opa = LV_OPA_COVER;
|
||||
dsc->color = lv_color_black();
|
||||
}
|
||||
|
||||
lv_draw_arc_dsc_t * lv_draw_task_get_arc_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_ARC ? (lv_draw_arc_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_arc(lv_layer_t * layer, const lv_draw_arc_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
if(dsc->width == 0) return;
|
||||
if(dsc->start_angle == dsc->end_angle) return;
|
||||
|
||||
LV_PROFILER_BEGIN;
|
||||
lv_area_t a;
|
||||
a.x1 = dsc->center.x - dsc->radius;
|
||||
a.y1 = dsc->center.y - dsc->radius;
|
||||
a.x2 = dsc->center.x + dsc->radius - 1;
|
||||
a.y2 = dsc->center.y + dsc->radius - 1;
|
||||
lv_draw_task_t * t = lv_draw_add_task(layer, &a);
|
||||
|
||||
t->draw_dsc = lv_malloc(sizeof(*dsc));
|
||||
lv_memcpy(t->draw_dsc, dsc, sizeof(*dsc));
|
||||
t->type = LV_DRAW_TASK_TYPE_ARC;
|
||||
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
void lv_draw_arc_get_area(int32_t x, int32_t y, uint16_t radius, lv_value_precise_t start_angle,
|
||||
lv_value_precise_t end_angle,
|
||||
int32_t w, bool rounded, lv_area_t * area)
|
||||
{
|
||||
int32_t rout = radius;
|
||||
int32_t start_angle_int = (int32_t) start_angle;
|
||||
int32_t end_angle_int = (int32_t) end_angle;
|
||||
|
||||
/*Special case: full arc invalidation */
|
||||
if(end_angle_int == start_angle_int + 360) {
|
||||
area->x1 = x - rout;
|
||||
area->y1 = y - rout;
|
||||
area->x2 = x + rout;
|
||||
area->y2 = y + rout;
|
||||
return;
|
||||
}
|
||||
|
||||
if(start_angle_int > 360) start_angle_int -= 360;
|
||||
if(end_angle_int > 360) end_angle_int -= 360;
|
||||
|
||||
int32_t rin = radius - w;
|
||||
int32_t extra_area = rounded ? w / 2 + 1 : 0;
|
||||
uint8_t start_quarter = start_angle_int / 90;
|
||||
uint8_t end_quarter = end_angle_int / 90;
|
||||
|
||||
/*360 deg still counts as quarter 3 (360 / 90 would be 4)*/
|
||||
if(start_quarter == 4) start_quarter = 3;
|
||||
if(end_quarter == 4) end_quarter = 3;
|
||||
|
||||
if(start_quarter == end_quarter && start_angle_int <= end_angle_int) {
|
||||
if(start_quarter == 0) {
|
||||
area->y1 = y + ((lv_trigo_sin(start_angle_int) * rin) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->x2 = x + ((lv_trigo_sin(start_angle_int + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
|
||||
area->y2 = y + ((lv_trigo_sin(end_angle_int) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
area->x1 = x + ((lv_trigo_sin(end_angle_int + 90) * rin) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
}
|
||||
else if(start_quarter == 1) {
|
||||
area->y2 = y + ((lv_trigo_sin(start_angle_int) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
area->x2 = x + ((lv_trigo_sin(start_angle_int + 90) * rin) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
|
||||
area->y1 = y + ((lv_trigo_sin(end_angle_int) * rin) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->x1 = x + ((lv_trigo_sin(end_angle_int + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
}
|
||||
else if(start_quarter == 2) {
|
||||
area->x1 = x + ((lv_trigo_sin(start_angle_int + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->y2 = y + ((lv_trigo_sin(start_angle_int) * rin) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
|
||||
area->y1 = y + ((lv_trigo_sin(end_angle_int) * rout) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->x2 = x + ((lv_trigo_sin(end_angle_int + 90) * rin) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
}
|
||||
else if(start_quarter == 3) {
|
||||
area->x1 = x + ((lv_trigo_sin(start_angle_int + 90) * rin) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->y1 = y + ((lv_trigo_sin(start_angle_int) * rout) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
|
||||
area->x2 = x + ((lv_trigo_sin(end_angle_int + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
area->y2 = y + ((lv_trigo_sin(end_angle_int) * rin) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
}
|
||||
}
|
||||
else if(start_quarter == 0 && end_quarter == 1) {
|
||||
area->x1 = x + ((lv_trigo_sin(end_angle_int + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->y1 = y + ((LV_MIN(lv_trigo_sin(end_angle_int),
|
||||
lv_trigo_sin(start_angle_int)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->x2 = x + ((lv_trigo_sin(start_angle_int + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
area->y2 = y + rout + extra_area;
|
||||
}
|
||||
else if(start_quarter == 1 && end_quarter == 2) {
|
||||
area->x1 = x - rout - extra_area;
|
||||
area->y1 = y + ((lv_trigo_sin(end_angle_int) * rout) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->x2 = x + ((LV_MAX(lv_trigo_sin(start_angle_int + 90),
|
||||
lv_trigo_sin(end_angle_int + 90)) * rin) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
area->y2 = y + ((lv_trigo_sin(start_angle_int) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
}
|
||||
else if(start_quarter == 2 && end_quarter == 3) {
|
||||
area->x1 = x + ((lv_trigo_sin(start_angle_int + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->y1 = y - rout - extra_area;
|
||||
area->x2 = x + ((lv_trigo_sin(end_angle_int + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
area->y2 = y + (LV_MAX(lv_trigo_sin(end_angle_int) * rin,
|
||||
lv_trigo_sin(start_angle_int) * rin) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
}
|
||||
else if(start_quarter == 3 && end_quarter == 0) {
|
||||
area->x1 = x + ((LV_MIN(lv_trigo_sin(end_angle_int + 90),
|
||||
lv_trigo_sin(start_angle_int + 90)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->y1 = y + ((lv_trigo_sin(start_angle_int) * rout) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->x2 = x + rout + extra_area;
|
||||
area->y2 = y + ((lv_trigo_sin(end_angle_int) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
|
||||
}
|
||||
else {
|
||||
area->x1 = x - rout;
|
||||
area->y1 = y - rout;
|
||||
area->x2 = x + rout;
|
||||
area->y2 = y + rout;
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
90
libraries/lvgl/src/draw/lv_draw_arc.h
Normal file
90
libraries/lvgl/src/draw/lv_draw_arc.h
Normal file
@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @file lv_draw_arc.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_ARC_H
|
||||
#define LV_DRAW_ARC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
lv_draw_dsc_base_t base;
|
||||
|
||||
lv_color_t color;
|
||||
int32_t width;
|
||||
lv_value_precise_t start_angle;
|
||||
lv_value_precise_t end_angle;
|
||||
lv_point_t center;
|
||||
uint16_t radius;
|
||||
const void * img_src;
|
||||
lv_opa_t opa;
|
||||
uint8_t rounded : 1;
|
||||
} lv_draw_arc_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an arc draw descriptor.
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get an arc draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_ARC
|
||||
*/
|
||||
lv_draw_arc_dsc_t * lv_draw_task_get_arc_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Create an arc draw task.
|
||||
* @param layer pointer to a layer
|
||||
* @param dsc pointer to an initialized draw descriptor variable
|
||||
*/
|
||||
void lv_draw_arc(lv_layer_t * layer, const lv_draw_arc_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Get an area the should be invalidated when the arcs angle changed between start_angle and end_ange
|
||||
* @param x the x coordinate of the center of the arc
|
||||
* @param y the y coordinate of the center of the arc
|
||||
* @param radius the radius of the arc
|
||||
* @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right)
|
||||
* @param end_angle the end angle of the arc
|
||||
* @param w width of the arc
|
||||
* @param rounded true: the arc is rounded
|
||||
* @param area store the area to invalidate here
|
||||
*/
|
||||
void lv_draw_arc_get_area(int32_t x, int32_t y, uint16_t radius, lv_value_precise_t start_angle,
|
||||
lv_value_precise_t end_angle,
|
||||
int32_t w, bool rounded, lv_area_t * area);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_ARC_H*/
|
||||
523
libraries/lvgl/src/draw/lv_draw_buf.c
Normal file
523
libraries/lvgl/src/draw/lv_draw_buf.c
Normal file
@ -0,0 +1,523 @@
|
||||
/**
|
||||
* @file lv_draw_buf.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../misc/lv_types.h"
|
||||
#include "lv_draw_buf.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
#include "../core/lv_global.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define handlers LV_GLOBAL_DEFAULT()->draw_buf_handlers
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void * buf_malloc(size_t size, lv_color_format_t color_format);
|
||||
static void buf_free(void * buf);
|
||||
static void * buf_align(void * buf, lv_color_format_t color_format);
|
||||
static void * draw_buf_malloc(size_t size_bytes, lv_color_format_t color_format);
|
||||
static void draw_buf_free(void * buf);
|
||||
static uint32_t width_to_stride(uint32_t w, lv_color_format_t color_format);
|
||||
static uint32_t _calculate_draw_buf_size(uint32_t w, uint32_t h, lv_color_format_t cf, uint32_t stride);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void _lv_draw_buf_init_handlers(void)
|
||||
{
|
||||
lv_memzero(&handlers, sizeof(lv_draw_buf_handlers_t));
|
||||
handlers.buf_malloc_cb = buf_malloc;
|
||||
handlers.buf_free_cb = buf_free;
|
||||
handlers.align_pointer_cb = buf_align;
|
||||
handlers.invalidate_cache_cb = NULL;
|
||||
handlers.width_to_stride_cb = width_to_stride;
|
||||
}
|
||||
|
||||
lv_draw_buf_handlers_t * lv_draw_buf_get_handlers(void)
|
||||
{
|
||||
return &handlers;
|
||||
}
|
||||
|
||||
uint32_t lv_draw_buf_width_to_stride(uint32_t w, lv_color_format_t color_format)
|
||||
{
|
||||
if(handlers.width_to_stride_cb) return handlers.width_to_stride_cb(w, color_format);
|
||||
else return 0;
|
||||
}
|
||||
|
||||
void * lv_draw_buf_align(void * data, lv_color_format_t color_format)
|
||||
{
|
||||
if(handlers.align_pointer_cb) return handlers.align_pointer_cb(data, color_format);
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
void lv_draw_buf_invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * area)
|
||||
{
|
||||
if(handlers.invalidate_cache_cb) {
|
||||
LV_ASSERT_NULL(draw_buf);
|
||||
const lv_image_header_t * header = &draw_buf->header;
|
||||
lv_area_t full;
|
||||
if(area == NULL) {
|
||||
full = (lv_area_t) {
|
||||
0, 0, header->w - 1, header->h - 1
|
||||
};
|
||||
area = &full;
|
||||
}
|
||||
handlers.invalidate_cache_cb(draw_buf, area);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_buf_clear(lv_draw_buf_t * draw_buf, const lv_area_t * a)
|
||||
{
|
||||
LV_ASSERT_NULL(draw_buf);
|
||||
if(a && lv_area_get_width(a) < 0) return;
|
||||
if(a && lv_area_get_height(a) < 0) return;
|
||||
|
||||
const lv_image_header_t * header = &draw_buf->header;
|
||||
uint32_t stride = header->stride;
|
||||
|
||||
if(a == NULL) {
|
||||
lv_memzero(draw_buf->data, header->h * stride);
|
||||
}
|
||||
else {
|
||||
uint8_t * bufc;
|
||||
uint32_t line_length;
|
||||
int32_t start_y, end_y;
|
||||
uint8_t px_size = lv_color_format_get_size(header->cf);
|
||||
bufc = lv_draw_buf_goto_xy(draw_buf, a->x1, a->y1);
|
||||
line_length = lv_area_get_width(a) * px_size;
|
||||
start_y = a->y1;
|
||||
end_y = a->y2;
|
||||
for(; start_y <= end_y; start_y++) {
|
||||
lv_memzero(bufc, line_length);
|
||||
bufc += stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_draw_buf_copy(lv_draw_buf_t * dest, const lv_area_t * dest_area,
|
||||
const lv_draw_buf_t * src, const lv_area_t * src_area)
|
||||
{
|
||||
uint8_t * dest_bufc;
|
||||
uint8_t * src_bufc;
|
||||
int32_t line_width;
|
||||
|
||||
/*Source and dest color format must be same. Color conversion is not supported yet.*/
|
||||
LV_ASSERT_FORMAT_MSG(dest->header.cf == src->header.cf, "Color format mismatch: %d != %d",
|
||||
dest->header.cf, src->header.cf);
|
||||
|
||||
if(dest_area == NULL) line_width = dest->header.w;
|
||||
else line_width = lv_area_get_width(dest_area);
|
||||
|
||||
/* For indexed image, copy the palette if we are copying full image area*/
|
||||
if(dest_area == NULL || src_area == NULL) {
|
||||
if(LV_COLOR_FORMAT_IS_INDEXED(dest->header.cf)) {
|
||||
lv_memcpy(dest->data, src->data, LV_COLOR_INDEXED_PALETTE_SIZE(dest->header.cf) * sizeof(lv_color32_t));
|
||||
}
|
||||
}
|
||||
|
||||
/*Check source and dest area have same width*/
|
||||
if((src_area == NULL && line_width != src->header.w) || \
|
||||
(src_area != NULL && line_width != lv_area_get_width(src_area))) {
|
||||
LV_ASSERT_MSG(0, "Source and destination areas have different width");
|
||||
return;
|
||||
}
|
||||
|
||||
if(src_area) src_bufc = lv_draw_buf_goto_xy(src, src_area->x1, src_area->y1);
|
||||
else src_bufc = lv_draw_buf_goto_xy(src, 0, 0);
|
||||
|
||||
if(dest_area) dest_bufc = lv_draw_buf_goto_xy(dest, dest_area->x1, dest_area->y1);
|
||||
else dest_bufc = lv_draw_buf_goto_xy(dest, 0, 0);
|
||||
|
||||
int32_t start_y, end_y;
|
||||
if(dest_area) {
|
||||
start_y = dest_area->y1;
|
||||
end_y = dest_area->y2;
|
||||
}
|
||||
else {
|
||||
start_y = 0;
|
||||
end_y = dest->header.h - 1;
|
||||
}
|
||||
|
||||
uint32_t dest_stride = dest->header.stride;
|
||||
uint32_t src_stride = src->header.stride;
|
||||
uint32_t line_bytes = (line_width * lv_color_format_get_bpp(dest->header.cf) + 7) >> 3;
|
||||
|
||||
for(; start_y <= end_y; start_y++) {
|
||||
lv_memcpy(dest_bufc, src_bufc, line_bytes);
|
||||
dest_bufc += dest_stride;
|
||||
src_bufc += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
lv_result_t lv_draw_buf_init(lv_draw_buf_t * draw_buf, uint32_t w, uint32_t h, lv_color_format_t cf, uint32_t stride,
|
||||
void * data, uint32_t data_size)
|
||||
{
|
||||
LV_ASSERT_NULL(draw_buf);
|
||||
if(draw_buf == NULL) return LV_RESULT_INVALID;
|
||||
|
||||
lv_memzero(draw_buf, sizeof(lv_draw_buf_t));
|
||||
if(stride == 0) stride = lv_draw_buf_width_to_stride(w, cf);
|
||||
if(stride * h > data_size) {
|
||||
LV_LOG_WARN("Data size too small, required: %" LV_PRId32 ", provided: %" LV_PRId32, stride * h,
|
||||
data_size);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
lv_image_header_t * header = &draw_buf->header;
|
||||
header->w = w;
|
||||
header->h = h;
|
||||
header->cf = cf;
|
||||
header->stride = stride;
|
||||
header->flags = 0;
|
||||
header->magic = LV_IMAGE_HEADER_MAGIC;
|
||||
|
||||
draw_buf->data = lv_draw_buf_align(data, cf);
|
||||
draw_buf->unaligned_data = data;
|
||||
draw_buf->data_size = data_size;
|
||||
if(draw_buf->data != draw_buf->unaligned_data) {
|
||||
LV_LOG_WARN("Data is not aligned, ignored");
|
||||
}
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
lv_draw_buf_t * lv_draw_buf_create(uint32_t w, uint32_t h, lv_color_format_t cf, uint32_t stride)
|
||||
{
|
||||
lv_draw_buf_t * draw_buf = lv_malloc_zeroed(sizeof(lv_draw_buf_t));
|
||||
LV_ASSERT_MALLOC(draw_buf);
|
||||
if(draw_buf == NULL) return NULL;
|
||||
if(stride == 0) stride = lv_draw_buf_width_to_stride(w, cf);
|
||||
|
||||
uint32_t size = _calculate_draw_buf_size(w, h, cf, stride);
|
||||
|
||||
void * buf = draw_buf_malloc(size, cf);
|
||||
/*Do not assert here as LVGL or the app might just want to try creating a draw_buf*/
|
||||
if(buf == NULL) {
|
||||
LV_LOG_WARN("No memory: %"LV_PRIu32"x%"LV_PRIu32", cf: %d, stride: %"LV_PRIu32", %"LV_PRIu32"Byte, ",
|
||||
w, h, cf, stride, size);
|
||||
lv_free(draw_buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
draw_buf->header.w = w;
|
||||
draw_buf->header.h = h;
|
||||
draw_buf->header.cf = cf;
|
||||
draw_buf->header.flags = LV_IMAGE_FLAGS_MODIFIABLE | LV_IMAGE_FLAGS_ALLOCATED;
|
||||
draw_buf->header.stride = stride;
|
||||
draw_buf->header.magic = LV_IMAGE_HEADER_MAGIC;
|
||||
draw_buf->data = lv_draw_buf_align(buf, cf);
|
||||
draw_buf->unaligned_data = buf;
|
||||
draw_buf->data_size = size;
|
||||
return draw_buf;
|
||||
}
|
||||
|
||||
lv_draw_buf_t * lv_draw_buf_dup(const lv_draw_buf_t * draw_buf)
|
||||
{
|
||||
const lv_image_header_t * header = &draw_buf->header;
|
||||
lv_draw_buf_t * new_buf = lv_draw_buf_create(header->w, header->h, header->cf, header->stride);
|
||||
if(new_buf == NULL) return NULL;
|
||||
|
||||
new_buf->header.flags = draw_buf->header.flags;
|
||||
new_buf->header.flags |= LV_IMAGE_FLAGS_MODIFIABLE | LV_IMAGE_FLAGS_ALLOCATED;
|
||||
|
||||
/*Choose the smaller size to copy*/
|
||||
uint32_t size = LV_MIN(draw_buf->data_size, new_buf->data_size);
|
||||
|
||||
/*Copy image data*/
|
||||
lv_memcpy(new_buf->data, draw_buf->data, size);
|
||||
return new_buf;
|
||||
}
|
||||
|
||||
lv_draw_buf_t * lv_draw_buf_reshape(lv_draw_buf_t * draw_buf, lv_color_format_t cf, uint32_t w, uint32_t h,
|
||||
uint32_t stride)
|
||||
{
|
||||
if(draw_buf == NULL) return NULL;
|
||||
|
||||
/*If color format is unknown, keep using the original color format.*/
|
||||
if(cf == LV_COLOR_FORMAT_UNKNOWN) cf = draw_buf->header.cf;
|
||||
if(stride == 0) stride = lv_draw_buf_width_to_stride(w, cf);
|
||||
|
||||
uint32_t size = _calculate_draw_buf_size(w, h, cf, stride);
|
||||
|
||||
if(size > draw_buf->data_size) {
|
||||
LV_LOG_TRACE("Draw buf too small for new shape");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
draw_buf->header.cf = cf;
|
||||
draw_buf->header.w = w;
|
||||
draw_buf->header.h = h;
|
||||
draw_buf->header.stride = stride;
|
||||
|
||||
return draw_buf;
|
||||
}
|
||||
|
||||
void lv_draw_buf_destroy(lv_draw_buf_t * buf)
|
||||
{
|
||||
LV_ASSERT_NULL(buf);
|
||||
if(buf == NULL) return;
|
||||
|
||||
if(buf->header.flags & LV_IMAGE_FLAGS_ALLOCATED) {
|
||||
draw_buf_free(buf->unaligned_data);
|
||||
lv_free(buf);
|
||||
}
|
||||
else {
|
||||
LV_LOG_ERROR("draw buffer is not allocated, ignored");
|
||||
}
|
||||
}
|
||||
|
||||
void * lv_draw_buf_goto_xy(const lv_draw_buf_t * buf, uint32_t x, uint32_t y)
|
||||
{
|
||||
LV_ASSERT_NULL(buf);
|
||||
if(buf == NULL) return NULL;
|
||||
|
||||
uint8_t * data = buf->data;
|
||||
|
||||
/*Skip palette*/
|
||||
data += LV_COLOR_INDEXED_PALETTE_SIZE(buf->header.cf) * sizeof(lv_color32_t);
|
||||
data += buf->header.stride * y;
|
||||
|
||||
if(x == 0) return data;
|
||||
|
||||
return data + x * lv_color_format_get_size(buf->header.cf);
|
||||
}
|
||||
|
||||
lv_result_t lv_draw_buf_adjust_stride(lv_draw_buf_t * src, uint32_t stride)
|
||||
{
|
||||
LV_ASSERT_NULL(src);
|
||||
LV_ASSERT_NULL(src->data);
|
||||
if(src == NULL) return LV_RESULT_INVALID;
|
||||
if(src->data == NULL) return LV_RESULT_INVALID;
|
||||
|
||||
const lv_image_header_t * header = &src->header;
|
||||
uint32_t w = header->w;
|
||||
uint32_t h = header->h;
|
||||
|
||||
/*Use global stride*/
|
||||
if(stride == 0) stride = lv_draw_buf_width_to_stride(w, header->cf);
|
||||
|
||||
/*Check if stride already match*/
|
||||
if(header->stride == stride) return LV_RESULT_OK;
|
||||
|
||||
/*Calculate the minimal stride allowed from bpp*/
|
||||
uint32_t bpp = lv_color_format_get_bpp(header->cf);
|
||||
uint32_t min_stride = (w * bpp + 7) >> 3;
|
||||
if(stride < min_stride) {
|
||||
LV_LOG_WARN("New stride is too small. min: %" LV_PRId32, min_stride);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
/*Check if buffer has enough space. */
|
||||
uint32_t new_size = _calculate_draw_buf_size(w, h, header->cf, stride);
|
||||
if(new_size > src->data_size) {
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
uint32_t offset = LV_COLOR_INDEXED_PALETTE_SIZE(header->cf) * 4;
|
||||
|
||||
if(stride > header->stride) {
|
||||
/*Copy from the last line to the first*/
|
||||
uint8_t * src_data = src->data + offset + header->stride * (h - 1);
|
||||
uint8_t * dst_data = src->data + offset + stride * (h - 1);
|
||||
for(uint32_t y = 0; y < h; y++) {
|
||||
lv_memmove(dst_data, src_data, min_stride);
|
||||
src_data -= header->stride;
|
||||
dst_data -= stride;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*Copy from the first line to the last*/
|
||||
uint8_t * src_data = src->data + offset;
|
||||
uint8_t * dst_data = src->data + offset;
|
||||
for(uint32_t y = 0; y < h; y++) {
|
||||
lv_memmove(dst_data, src_data, min_stride);
|
||||
src_data += header->stride;
|
||||
dst_data += stride;
|
||||
}
|
||||
}
|
||||
|
||||
src->header.stride = stride;
|
||||
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
lv_result_t lv_draw_buf_premultiply(lv_draw_buf_t * draw_buf)
|
||||
{
|
||||
LV_ASSERT_NULL(draw_buf);
|
||||
if(draw_buf == NULL) return LV_RESULT_INVALID;
|
||||
|
||||
if(draw_buf->header.flags & LV_IMAGE_FLAGS_PREMULTIPLIED) return LV_RESULT_INVALID;
|
||||
if((draw_buf->header.flags & LV_IMAGE_FLAGS_MODIFIABLE) == 0) {
|
||||
LV_LOG_WARN("draw buf is not modifiable: 0x%04x", draw_buf->header.flags);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
/*Premultiply color with alpha, do case by case by judging color format*/
|
||||
lv_color_format_t cf = draw_buf->header.cf;
|
||||
if(LV_COLOR_FORMAT_IS_INDEXED(cf)) {
|
||||
int size = LV_COLOR_INDEXED_PALETTE_SIZE(cf);
|
||||
lv_color32_t * palette = (lv_color32_t *)draw_buf->data;
|
||||
for(int i = 0; i < size; i++) {
|
||||
lv_color_premultiply(&palette[i]);
|
||||
}
|
||||
}
|
||||
else if(cf == LV_COLOR_FORMAT_ARGB8888) {
|
||||
uint32_t h = draw_buf->header.h;
|
||||
uint32_t w = draw_buf->header.w;
|
||||
uint32_t stride = draw_buf->header.stride;
|
||||
uint8_t * line = (uint8_t *)draw_buf->data;
|
||||
for(uint32_t y = 0; y < h; y++) {
|
||||
lv_color32_t * pixel = (lv_color32_t *)line;
|
||||
for(uint32_t x = 0; x < w; x++) {
|
||||
lv_color_premultiply(pixel);
|
||||
pixel++;
|
||||
}
|
||||
line += stride;
|
||||
}
|
||||
}
|
||||
else if(cf == LV_COLOR_FORMAT_RGB565A8) {
|
||||
uint32_t h = draw_buf->header.h;
|
||||
uint32_t w = draw_buf->header.w;
|
||||
uint32_t stride = draw_buf->header.stride;
|
||||
uint32_t alpha_stride = stride / 2;
|
||||
uint8_t * line = (uint8_t *)draw_buf->data;
|
||||
lv_opa_t * alpha = (lv_opa_t *)(line + stride * h);
|
||||
for(uint32_t y = 0; y < h; y++) {
|
||||
lv_color16_t * pixel = (lv_color16_t *)line;
|
||||
for(uint32_t x = 0; x < w; x++) {
|
||||
lv_color16_premultiply(pixel, alpha[x]);
|
||||
pixel++;
|
||||
}
|
||||
line += stride;
|
||||
alpha += alpha_stride;
|
||||
}
|
||||
}
|
||||
else if(cf == LV_COLOR_FORMAT_ARGB8565) {
|
||||
uint32_t h = draw_buf->header.h;
|
||||
uint32_t w = draw_buf->header.w;
|
||||
uint32_t stride = draw_buf->header.stride;
|
||||
uint8_t * line = (uint8_t *)draw_buf->data;
|
||||
for(uint32_t y = 0; y < h; y++) {
|
||||
uint8_t * pixel = line;
|
||||
for(uint32_t x = 0; x < w; x++) {
|
||||
uint8_t alpha = pixel[2];
|
||||
lv_color16_premultiply((lv_color16_t *)pixel, alpha);
|
||||
pixel += 3;
|
||||
}
|
||||
line += stride;
|
||||
}
|
||||
}
|
||||
else if(LV_COLOR_FORMAT_IS_ALPHA_ONLY(cf)) {
|
||||
/*Pass*/
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("draw buf has no alpha, cf: %d", cf);
|
||||
}
|
||||
|
||||
draw_buf->header.flags |= LV_IMAGE_FLAGS_PREMULTIPLIED;
|
||||
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
void lv_draw_buf_set_palette(lv_draw_buf_t * draw_buf, uint8_t index, lv_color32_t color)
|
||||
{
|
||||
LV_ASSERT_NULL(draw_buf);
|
||||
if(draw_buf == NULL) return;
|
||||
|
||||
if(!LV_COLOR_FORMAT_IS_INDEXED(draw_buf->header.cf)) {
|
||||
LV_LOG_WARN("Not indexed color format");
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t * buf = (uint8_t *)draw_buf->data;
|
||||
lv_memcpy(&buf[index * sizeof(color)], &color, sizeof(color));
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void * buf_malloc(size_t size_bytes, lv_color_format_t color_format)
|
||||
{
|
||||
LV_UNUSED(color_format);
|
||||
|
||||
/*Allocate larger memory to be sure it can be aligned as needed*/
|
||||
size_bytes += LV_DRAW_BUF_ALIGN - 1;
|
||||
return lv_malloc(size_bytes);
|
||||
}
|
||||
|
||||
static void buf_free(void * buf)
|
||||
{
|
||||
lv_free(buf);
|
||||
}
|
||||
|
||||
static void * buf_align(void * buf, lv_color_format_t color_format)
|
||||
{
|
||||
LV_UNUSED(color_format);
|
||||
|
||||
uint8_t * buf_u8 = buf;
|
||||
if(buf_u8) {
|
||||
buf_u8 += LV_DRAW_BUF_ALIGN - 1;
|
||||
buf_u8 = (uint8_t *)((lv_uintptr_t) buf_u8 & ~(LV_DRAW_BUF_ALIGN - 1));
|
||||
}
|
||||
return buf_u8;
|
||||
}
|
||||
|
||||
static uint32_t width_to_stride(uint32_t w, lv_color_format_t color_format)
|
||||
{
|
||||
uint32_t width_byte;
|
||||
width_byte = w * lv_color_format_get_bpp(color_format);
|
||||
width_byte = (width_byte + 7) >> 3; /*Round up*/
|
||||
return (width_byte + LV_DRAW_BUF_STRIDE_ALIGN - 1) & ~(LV_DRAW_BUF_STRIDE_ALIGN - 1);
|
||||
}
|
||||
|
||||
static void * draw_buf_malloc(size_t size_bytes, lv_color_format_t color_format)
|
||||
{
|
||||
if(handlers.buf_malloc_cb) return handlers.buf_malloc_cb(size_bytes, color_format);
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
static void draw_buf_free(void * buf)
|
||||
{
|
||||
if(handlers.buf_free_cb) handlers.buf_free_cb(buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* For given width, height, color format, and stride, calculate the size needed for a new draw buffer.
|
||||
*/
|
||||
static uint32_t _calculate_draw_buf_size(uint32_t w, uint32_t h, lv_color_format_t cf, uint32_t stride)
|
||||
{
|
||||
uint32_t size;
|
||||
|
||||
if(stride == 0) stride = lv_draw_buf_width_to_stride(w, cf);
|
||||
|
||||
size = stride * h;
|
||||
if(cf == LV_COLOR_FORMAT_RGB565A8) {
|
||||
size += (stride / 2) * h; /*A8 mask*/
|
||||
}
|
||||
else if(LV_COLOR_FORMAT_IS_INDEXED(cf)) {
|
||||
/*@todo we have to include palette right before image data*/
|
||||
size += LV_COLOR_INDEXED_PALETTE_SIZE(cf) * 4;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
301
libraries/lvgl/src/draw/lv_draw_buf.h
Normal file
301
libraries/lvgl/src/draw/lv_draw_buf.h
Normal file
@ -0,0 +1,301 @@
|
||||
/**
|
||||
* @file lv_draw_buf.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_BUF_H
|
||||
#define LV_DRAW_BUF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
#include "lv_image_dsc.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/*Use this value to let LVGL calculate stride automatically*/
|
||||
#define LV_STRIDE_AUTO 0
|
||||
LV_EXPORT_CONST_INT(LV_STRIDE_AUTO);
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
lv_image_header_t header;
|
||||
uint32_t data_size; /*Total buf size in bytes*/
|
||||
uint8_t * data;
|
||||
void * unaligned_data; /*Unaligned address of `data`, used internally by lvgl*/
|
||||
} lv_draw_buf_t;
|
||||
|
||||
/**
|
||||
* Stride alignment for draw buffers.
|
||||
* It may vary between different color formats and hardware.
|
||||
* Refine it to suit your needs.
|
||||
*/
|
||||
|
||||
#define _LV_DRAW_BUF_STRIDE(w, cf) \
|
||||
((((w) * LV_COLOR_FORMAT_GET_BPP(cf) + 7) / 8 + (LV_DRAW_BUF_STRIDE_ALIGN) - 1) & ~((LV_DRAW_BUF_STRIDE_ALIGN) - 1))
|
||||
|
||||
#define _LV_DRAW_BUF_SIZE(w, h, cf) \
|
||||
(_LV_DRAW_BUF_STRIDE(w, cf) * (h))
|
||||
|
||||
/**
|
||||
* Define a static draw buffer with the given width, height, and color format.
|
||||
* Stride alignment is set to LV_DRAW_BUF_STRIDE_ALIGN.
|
||||
*/
|
||||
#define LV_DRAW_BUF_DEFINE(name, _w, _h, _cf) \
|
||||
static uint8_t buf_##name[_LV_DRAW_BUF_SIZE(_w, _h, _cf)]; \
|
||||
static lv_draw_buf_t name = { \
|
||||
.header = { \
|
||||
.magic = LV_IMAGE_HEADER_MAGIC, \
|
||||
.cf = (_cf), \
|
||||
.flags = LV_IMAGE_FLAGS_MODIFIABLE, \
|
||||
.w = (_w), \
|
||||
.h = (_h), \
|
||||
.stride = _LV_DRAW_BUF_STRIDE(_w, _cf), \
|
||||
.reserved_2 = 0, \
|
||||
}, \
|
||||
.data_size = sizeof(buf_##name), \
|
||||
.data = buf_##name, \
|
||||
.unaligned_data = buf_##name, \
|
||||
}
|
||||
|
||||
typedef void * (*lv_draw_buf_malloc_cb)(size_t size, lv_color_format_t color_format);
|
||||
|
||||
typedef void (*lv_draw_buf_free_cb)(void * draw_buf);
|
||||
|
||||
typedef void * (*lv_draw_buf_align_cb)(void * buf, lv_color_format_t color_format);
|
||||
|
||||
typedef void (*lv_draw_buf_invalidate_cache_cb)(const lv_draw_buf_t * draw_buf, const lv_area_t * area);
|
||||
|
||||
typedef uint32_t (*lv_draw_buf_width_to_stride_cb)(uint32_t w, lv_color_format_t color_format);
|
||||
|
||||
typedef struct {
|
||||
lv_draw_buf_malloc_cb buf_malloc_cb;
|
||||
lv_draw_buf_free_cb buf_free_cb;
|
||||
lv_draw_buf_align_cb align_pointer_cb;
|
||||
lv_draw_buf_invalidate_cache_cb invalidate_cache_cb;
|
||||
lv_draw_buf_width_to_stride_cb width_to_stride_cb;
|
||||
} lv_draw_buf_handlers_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Called internally to initialize the draw_buf_handlers in lv_global
|
||||
*/
|
||||
void _lv_draw_buf_init_handlers(void);
|
||||
|
||||
/**
|
||||
* Get the struct which holds the callbacks for draw buf management.
|
||||
* Custom callback can be set on the returned value
|
||||
* @return pointer to the struct of handlers
|
||||
*/
|
||||
lv_draw_buf_handlers_t * lv_draw_buf_get_handlers(void);
|
||||
|
||||
/**
|
||||
* Align the address of a buffer. The buffer needs to be large enough for the real data after alignment
|
||||
* @param buf the data to align
|
||||
* @param color_format the color format of the buffer
|
||||
* @return the aligned buffer
|
||||
*/
|
||||
void * lv_draw_buf_align(void * buf, lv_color_format_t color_format);
|
||||
|
||||
/**
|
||||
* Invalidate the cache of the buffer
|
||||
* @param draw_buf the draw buffer needs to be invalidated
|
||||
* @param area the area to invalidate in the buffer,
|
||||
* use NULL to invalidate the whole draw buffer address range
|
||||
*/
|
||||
void lv_draw_buf_invalidate_cache(const lv_draw_buf_t * draw_buf, const lv_area_t * area);
|
||||
|
||||
/**
|
||||
* Calculate the stride in bytes based on a width and color format
|
||||
* @param w the width in pixels
|
||||
* @param color_format the color format
|
||||
* @return the stride in bytes
|
||||
*/
|
||||
uint32_t lv_draw_buf_width_to_stride(uint32_t w, lv_color_format_t color_format);
|
||||
|
||||
/**
|
||||
* Clear an area on the buffer
|
||||
* @param draw_buf pointer to draw buffer
|
||||
* @param a the area to clear, or NULL to clear the whole buffer
|
||||
*/
|
||||
void lv_draw_buf_clear(lv_draw_buf_t * draw_buf, const lv_area_t * a);
|
||||
|
||||
/**
|
||||
* Copy an area from a buffer to an other
|
||||
* @param dest pointer to the destination draw buffer
|
||||
* @param dest_area the area to copy from the destination buffer, if NULL, use the whole buffer
|
||||
* @param src pointer to the source draw buffer
|
||||
* @param src_area the area to copy from the destination buffer, if NULL, use the whole buffer
|
||||
* @note `dest_area` and `src_area` should have the same width and height
|
||||
* @note `dest` and `src` should have same color format. Color converting is not supported fow now.
|
||||
*/
|
||||
void lv_draw_buf_copy(lv_draw_buf_t * dest, const lv_area_t * dest_area,
|
||||
const lv_draw_buf_t * src, const lv_area_t * src_area);
|
||||
|
||||
/**
|
||||
* Note: Eventually, lv_draw_buf_malloc/free will be kept as private.
|
||||
* For now, we use `create` to distinguish with malloc.
|
||||
*
|
||||
* Create an draw buf by allocating struct for `lv_draw_buf_t` and allocating a buffer for it
|
||||
* that meets specified requirements.
|
||||
*
|
||||
* @param w the buffer width in pixels
|
||||
* @param h the buffer height in pixels
|
||||
* @param cf the color format for image
|
||||
* @param stride the stride in bytes for image. Use 0 for automatic calculation based on
|
||||
* w, cf, and global stride alignment configuration.
|
||||
*/
|
||||
lv_draw_buf_t * lv_draw_buf_create(uint32_t w, uint32_t h, lv_color_format_t cf, uint32_t stride);
|
||||
|
||||
/**
|
||||
* Initialize a draw buf with the given buffer and parameters.
|
||||
* @param draw_buf the draw buf to initialize
|
||||
* @param w the buffer width in pixels
|
||||
* @param h the buffer height in pixels
|
||||
* @param cf the color format
|
||||
* @param stride the stride in bytes. Use 0 for automatic calculation
|
||||
* @param data the buffer used for drawing. Unaligned `data` will be aligned internally
|
||||
* @param data_size the size of the buffer in bytes
|
||||
* @return return LV_RESULT_OK on success, LV_RESULT_INVALID otherwise
|
||||
*/
|
||||
lv_result_t lv_draw_buf_init(lv_draw_buf_t * draw_buf, uint32_t w, uint32_t h, lv_color_format_t cf, uint32_t stride,
|
||||
void * data, uint32_t data_size);
|
||||
|
||||
/**
|
||||
* Duplicate a draw buf with same image size, stride and color format. Copy the image data too.
|
||||
* @param draw_buf the draw buf to duplicate
|
||||
* @return the duplicated draw buf on success, NULL if failed
|
||||
*/
|
||||
lv_draw_buf_t * lv_draw_buf_dup(const lv_draw_buf_t * draw_buf);
|
||||
|
||||
/**
|
||||
* Keep using the existing memory, reshape the draw buffer to the given width and height.
|
||||
* Return NULL if data_size is smaller than the required size.
|
||||
* @param draw_buf pointer to a draw buffer
|
||||
* @param cf the new color format, use 0 or LV_COLOR_FORMAT_UNKNOWN to keep using the original color format.
|
||||
* @param w the new width in pixels
|
||||
* @param h the new height in pixels
|
||||
* @param stride the stride in bytes for image. Use 0 for automatic calculation.
|
||||
*/
|
||||
lv_draw_buf_t * lv_draw_buf_reshape(lv_draw_buf_t * draw_buf, lv_color_format_t cf, uint32_t w, uint32_t h,
|
||||
uint32_t stride);
|
||||
|
||||
/**
|
||||
* Destroy a draw buf by free the actual buffer if it's marked as LV_IMAGE_FLAGS_ALLOCATED in header.
|
||||
* Then free the lv_draw_buf_t struct.
|
||||
*/
|
||||
void lv_draw_buf_destroy(lv_draw_buf_t * buf);
|
||||
|
||||
/**
|
||||
* Return pointer to the buffer at the given coordinates
|
||||
*/
|
||||
void * lv_draw_buf_goto_xy(const lv_draw_buf_t * buf, uint32_t x, uint32_t y);
|
||||
|
||||
/**
|
||||
* Adjust the stride of a draw buf in place.
|
||||
* @param src pointer to a draw buffer
|
||||
* @param stride the new stride in bytes for image. Use LV_STRIDE_AUTO for automatic calculation.
|
||||
* @return LV_RESULT_OK: success or LV_RESULT_INVALID: failed
|
||||
*/
|
||||
lv_result_t lv_draw_buf_adjust_stride(lv_draw_buf_t * src, uint32_t stride);
|
||||
|
||||
/**
|
||||
* Premultiply draw buffer color with alpha channel.
|
||||
* If it's already premultiplied, return directly.
|
||||
* Only color formats with alpha channel will be processed.
|
||||
*
|
||||
* @return LV_RESULT_OK: premultiply success
|
||||
*/
|
||||
lv_result_t lv_draw_buf_premultiply(lv_draw_buf_t * draw_buf);
|
||||
|
||||
static inline bool lv_draw_buf_has_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag)
|
||||
{
|
||||
return draw_buf->header.flags & flag;
|
||||
}
|
||||
|
||||
static inline void lv_draw_buf_set_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag)
|
||||
{
|
||||
draw_buf->header.flags |= flag;
|
||||
}
|
||||
|
||||
static inline void lv_draw_buf_clear_flag(lv_draw_buf_t * draw_buf, lv_image_flags_t flag)
|
||||
{
|
||||
draw_buf->header.flags &= ~flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* As of now, draw buf share same definition as `lv_image_dsc_t`.
|
||||
* And is interchangeable with `lv_image_dsc_t`.
|
||||
*/
|
||||
|
||||
static inline void lv_draw_buf_from_image(lv_draw_buf_t * buf, const lv_image_dsc_t * img)
|
||||
{
|
||||
lv_memcpy(buf, img, sizeof(lv_image_dsc_t));
|
||||
buf->unaligned_data = buf->data;
|
||||
}
|
||||
|
||||
static inline void lv_draw_buf_to_image(const lv_draw_buf_t * buf, lv_image_dsc_t * img)
|
||||
{
|
||||
lv_memcpy((void *)img, buf, sizeof(lv_image_dsc_t));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the palette color of an indexed image. Valid only for `LV_COLOR_FORMAT_I1/2/4/8`
|
||||
* @param draw_buf pointer to an image descriptor
|
||||
* @param index the palette color to set:
|
||||
* - for `LV_COLOR_FORMAT_I1`: 0..1
|
||||
* - for `LV_COLOR_FORMAT_I2`: 0..3
|
||||
* - for `LV_COLOR_FORMAT_I4`: 0..15
|
||||
* - for `LV_COLOR_FORMAT_I8`: 0..255
|
||||
* @param color the color to set in lv_color32_t format
|
||||
*/
|
||||
void lv_draw_buf_set_palette(lv_draw_buf_t * draw_buf, uint8_t index, lv_color32_t color);
|
||||
|
||||
/**
|
||||
* @deprecated Use lv_draw_buf_set_palette instead.
|
||||
*/
|
||||
static inline void lv_image_buf_set_palette(lv_image_dsc_t * dsc, uint8_t id, lv_color32_t c)
|
||||
{
|
||||
LV_LOG_WARN("Deprecated API, use lv_draw_buf_set_palette instead.");
|
||||
lv_draw_buf_set_palette((lv_draw_buf_t *)dsc, id, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use lv_draw_buffer_create/destroy instead.
|
||||
* Free the data pointer and dsc struct of an image.
|
||||
*/
|
||||
static inline void lv_image_buf_free(lv_image_dsc_t * dsc)
|
||||
{
|
||||
LV_LOG_WARN("Deprecated API, use lv_draw_buf_destroy instead.");
|
||||
if(dsc != NULL) {
|
||||
if(dsc->data != NULL)
|
||||
lv_free((void *)dsc->data);
|
||||
|
||||
lv_free((void *)dsc);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_BUF_H*/
|
||||
295
libraries/lvgl/src/draw/lv_draw_image.c
Normal file
295
libraries/lvgl/src/draw/lv_draw_image.c
Normal file
@ -0,0 +1,295 @@
|
||||
/**
|
||||
* @file lv_draw_img.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_image.h"
|
||||
#include "../display/lv_display.h"
|
||||
#include "../misc/lv_log.h"
|
||||
#include "../misc/lv_math.h"
|
||||
#include "../core/lv_refr.h"
|
||||
#include "../stdlib/lv_mem.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
static void img_decode_and_draw(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
|
||||
lv_image_decoder_dsc_t * decoder_dsc, lv_area_t * relative_decoded_area,
|
||||
const lv_area_t * img_area, const lv_area_t * clipped_img_area,
|
||||
lv_draw_image_core_cb draw_core_cb);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_draw_image_dsc_init(lv_draw_image_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(lv_draw_image_dsc_t));
|
||||
dsc->recolor = lv_color_black();
|
||||
dsc->opa = LV_OPA_COVER;
|
||||
dsc->scale_x = LV_SCALE_NONE;
|
||||
dsc->scale_y = LV_SCALE_NONE;
|
||||
dsc->antialias = LV_COLOR_DEPTH > 8 ? 1 : 0;
|
||||
dsc->original_area.x2 = LV_COORD_MIN; /*Indicate invalid area by default by setting a negative size*/
|
||||
dsc->base.dsc_size = sizeof(lv_draw_image_dsc_t);
|
||||
}
|
||||
|
||||
lv_draw_image_dsc_t * lv_draw_task_get_image_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_IMAGE ? (lv_draw_image_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_layer(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv_area_t * coords)
|
||||
{
|
||||
lv_draw_task_t * t = lv_draw_add_task(layer, coords);
|
||||
|
||||
t->draw_dsc = lv_malloc(sizeof(*dsc));
|
||||
lv_memcpy(t->draw_dsc, dsc, sizeof(*dsc));
|
||||
t->type = LV_DRAW_TASK_TYPE_LAYER;
|
||||
t->state = LV_DRAW_TASK_STATE_WAITING;
|
||||
|
||||
_lv_image_buf_get_transformed_area(&t->_real_area, lv_area_get_width(coords), lv_area_get_height(coords),
|
||||
dsc->rotation, dsc->scale_x, dsc->scale_y, &dsc->pivot);
|
||||
lv_area_move(&t->_real_area, coords->x1, coords->y1);
|
||||
|
||||
lv_layer_t * layer_to_draw = (lv_layer_t *)dsc->src;
|
||||
layer_to_draw->all_tasks_added = true;
|
||||
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
}
|
||||
|
||||
void lv_draw_image(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv_area_t * coords)
|
||||
{
|
||||
if(dsc->src == NULL) {
|
||||
LV_LOG_WARN("Image draw: src is NULL");
|
||||
return;
|
||||
}
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
LV_PROFILER_BEGIN;
|
||||
|
||||
lv_draw_image_dsc_t * new_image_dsc = lv_malloc(sizeof(*dsc));
|
||||
lv_memcpy(new_image_dsc, dsc, sizeof(*dsc));
|
||||
lv_result_t res = lv_image_decoder_get_info(new_image_dsc->src, &new_image_dsc->header);
|
||||
if(res != LV_RESULT_OK) {
|
||||
LV_LOG_WARN("Couldn't get info about the image");
|
||||
lv_free(new_image_dsc);
|
||||
return;
|
||||
}
|
||||
|
||||
lv_draw_task_t * t = lv_draw_add_task(layer, coords);
|
||||
t->draw_dsc = new_image_dsc;
|
||||
t->type = LV_DRAW_TASK_TYPE_IMAGE;
|
||||
|
||||
_lv_image_buf_get_transformed_area(&t->_real_area, lv_area_get_width(coords), lv_area_get_height(coords),
|
||||
dsc->rotation, dsc->scale_x, dsc->scale_y, &dsc->pivot);
|
||||
lv_area_move(&t->_real_area, coords->x1, coords->y1);
|
||||
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
lv_image_src_t lv_image_src_get_type(const void * src)
|
||||
{
|
||||
if(src == NULL) return LV_IMAGE_SRC_UNKNOWN;
|
||||
const uint8_t * u8_p = src;
|
||||
|
||||
/*The first byte shows the type of the image source*/
|
||||
if(u8_p[0] >= 0x20 && u8_p[0] <= 0x7F) {
|
||||
return LV_IMAGE_SRC_FILE; /*If it's an ASCII character then it's file name*/
|
||||
}
|
||||
else if(u8_p[0] >= 0x80) {
|
||||
return LV_IMAGE_SRC_SYMBOL; /*Symbols begins after 0x7F*/
|
||||
}
|
||||
else {
|
||||
return LV_IMAGE_SRC_VARIABLE; /*`lv_image_dsc_t` is draw to the first byte < 0x20*/
|
||||
}
|
||||
}
|
||||
|
||||
void _lv_draw_image_normal_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
|
||||
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb)
|
||||
{
|
||||
if(draw_core_cb == NULL) {
|
||||
LV_LOG_WARN("draw_core_cb is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
lv_area_t draw_area;
|
||||
lv_area_copy(&draw_area, coords);
|
||||
if(draw_dsc->rotation || draw_dsc->scale_x != LV_SCALE_NONE || draw_dsc->scale_y != LV_SCALE_NONE) {
|
||||
int32_t w = lv_area_get_width(coords);
|
||||
int32_t h = lv_area_get_height(coords);
|
||||
|
||||
_lv_image_buf_get_transformed_area(&draw_area, w, h, draw_dsc->rotation, draw_dsc->scale_x, draw_dsc->scale_y,
|
||||
&draw_dsc->pivot);
|
||||
|
||||
draw_area.x1 += coords->x1;
|
||||
draw_area.y1 += coords->y1;
|
||||
draw_area.x2 += coords->x1;
|
||||
draw_area.y2 += coords->y1;
|
||||
}
|
||||
|
||||
lv_area_t clipped_img_area;
|
||||
if(!_lv_area_intersect(&clipped_img_area, &draw_area, draw_unit->clip_area)) {
|
||||
return;
|
||||
}
|
||||
|
||||
lv_image_decoder_dsc_t decoder_dsc;
|
||||
lv_result_t res = lv_image_decoder_open(&decoder_dsc, draw_dsc->src, NULL);
|
||||
if(res != LV_RESULT_OK) {
|
||||
LV_LOG_ERROR("Failed to open image");
|
||||
return;
|
||||
}
|
||||
|
||||
img_decode_and_draw(draw_unit, draw_dsc, &decoder_dsc, NULL, coords, &clipped_img_area, draw_core_cb);
|
||||
|
||||
lv_image_decoder_close(&decoder_dsc);
|
||||
}
|
||||
|
||||
void _lv_draw_image_tiled_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
|
||||
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb)
|
||||
{
|
||||
if(draw_core_cb == NULL) {
|
||||
LV_LOG_WARN("draw_core_cb is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
lv_image_decoder_dsc_t decoder_dsc;
|
||||
lv_result_t res = lv_image_decoder_open(&decoder_dsc, draw_dsc->src, NULL);
|
||||
if(res != LV_RESULT_OK) {
|
||||
LV_LOG_ERROR("Failed to open image");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t img_w = draw_dsc->header.w;
|
||||
int32_t img_h = draw_dsc->header.h;
|
||||
|
||||
lv_area_t tile_area = *coords;
|
||||
lv_area_set_width(&tile_area, img_w);
|
||||
lv_area_set_height(&tile_area, img_h);
|
||||
|
||||
int32_t tile_x_start = tile_area.x1;
|
||||
|
||||
lv_area_t relative_decoded_area = {
|
||||
.x1 = LV_COORD_MIN,
|
||||
.y1 = LV_COORD_MIN,
|
||||
.x2 = LV_COORD_MIN,
|
||||
.y2 = LV_COORD_MIN,
|
||||
};
|
||||
|
||||
while(tile_area.y1 <= draw_unit->clip_area->y2) {
|
||||
while(tile_area.x1 <= draw_unit->clip_area->x2) {
|
||||
|
||||
lv_area_t clipped_img_area;
|
||||
if(_lv_area_intersect(&clipped_img_area, &tile_area, draw_unit->clip_area)) {
|
||||
img_decode_and_draw(draw_unit, draw_dsc, &decoder_dsc, &relative_decoded_area, &tile_area, &clipped_img_area,
|
||||
draw_core_cb);
|
||||
}
|
||||
|
||||
tile_area.x1 += img_w;
|
||||
tile_area.x2 += img_w;
|
||||
}
|
||||
|
||||
tile_area.y1 += img_h;
|
||||
tile_area.y2 += img_h;
|
||||
tile_area.x1 = tile_x_start;
|
||||
tile_area.x2 = tile_x_start + img_w - 1;
|
||||
}
|
||||
|
||||
lv_image_decoder_close(&decoder_dsc);
|
||||
}
|
||||
|
||||
void _lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, int32_t angle,
|
||||
uint16_t scale_x, uint16_t scale_y, const lv_point_t * pivot)
|
||||
{
|
||||
if(angle == 0 && scale_x == LV_SCALE_NONE && scale_y == LV_SCALE_NONE) {
|
||||
res->x1 = 0;
|
||||
res->y1 = 0;
|
||||
res->x2 = w - 1;
|
||||
res->y2 = h - 1;
|
||||
return;
|
||||
}
|
||||
|
||||
lv_point_t p[4] = {
|
||||
{0, 0},
|
||||
{w, 0},
|
||||
{0, h},
|
||||
{w, h},
|
||||
};
|
||||
lv_point_transform(&p[0], angle, scale_x, scale_y, pivot, true);
|
||||
lv_point_transform(&p[1], angle, scale_x, scale_y, pivot, true);
|
||||
lv_point_transform(&p[2], angle, scale_x, scale_y, pivot, true);
|
||||
lv_point_transform(&p[3], angle, scale_x, scale_y, pivot, true);
|
||||
res->x1 = LV_MIN4(p[0].x, p[1].x, p[2].x, p[3].x);
|
||||
res->x2 = LV_MAX4(p[0].x, p[1].x, p[2].x, p[3].x) - 1;
|
||||
res->y1 = LV_MIN4(p[0].y, p[1].y, p[2].y, p[3].y);
|
||||
res->y2 = LV_MAX4(p[0].y, p[1].y, p[2].y, p[3].y) - 1;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void img_decode_and_draw(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
|
||||
lv_image_decoder_dsc_t * decoder_dsc, lv_area_t * relative_decoded_area,
|
||||
const lv_area_t * img_area, const lv_area_t * clipped_img_area,
|
||||
lv_draw_image_core_cb draw_core_cb)
|
||||
{
|
||||
lv_draw_image_sup_t sup;
|
||||
sup.alpha_color = draw_dsc->recolor;
|
||||
sup.palette = decoder_dsc->palette;
|
||||
sup.palette_size = decoder_dsc->palette_size;
|
||||
|
||||
/*The whole image is available, just draw it*/
|
||||
if(decoder_dsc->decoded && (relative_decoded_area == NULL || relative_decoded_area->x1 == LV_COORD_MIN)) {
|
||||
draw_core_cb(draw_unit, draw_dsc, decoder_dsc, &sup, img_area, clipped_img_area);
|
||||
}
|
||||
/*Draw in smaller pieces*/
|
||||
else {
|
||||
lv_area_t relative_full_area_to_decode = *clipped_img_area;
|
||||
lv_area_move(&relative_full_area_to_decode, -img_area->x1, -img_area->y1);
|
||||
lv_area_t tmp;
|
||||
if(relative_decoded_area == NULL) relative_decoded_area = &tmp;
|
||||
relative_decoded_area->x1 = LV_COORD_MIN;
|
||||
relative_decoded_area->y1 = LV_COORD_MIN;
|
||||
relative_decoded_area->x2 = LV_COORD_MIN;
|
||||
relative_decoded_area->y2 = LV_COORD_MIN;
|
||||
lv_result_t res = LV_RESULT_OK;
|
||||
|
||||
while(res == LV_RESULT_OK) {
|
||||
res = lv_image_decoder_get_area(decoder_dsc, &relative_full_area_to_decode, relative_decoded_area);
|
||||
|
||||
lv_area_t absolute_decoded_area = *relative_decoded_area;
|
||||
lv_area_move(&absolute_decoded_area, img_area->x1, img_area->y1);
|
||||
if(res == LV_RESULT_OK) {
|
||||
/*Limit draw area to the current decoded area and draw the image*/
|
||||
lv_area_t clipped_img_area_sub;
|
||||
if(_lv_area_intersect(&clipped_img_area_sub, clipped_img_area, &absolute_decoded_area)) {
|
||||
draw_core_cb(draw_unit, draw_dsc, decoder_dsc, &sup,
|
||||
&absolute_decoded_area, &clipped_img_area_sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
163
libraries/lvgl/src/draw/lv_draw_image.h
Normal file
163
libraries/lvgl/src/draw/lv_draw_image.h
Normal file
@ -0,0 +1,163 @@
|
||||
/**
|
||||
* @file lv_draw_img.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_IMAGE_H
|
||||
#define LV_DRAW_IMAGE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw.h"
|
||||
#include "lv_image_decoder.h"
|
||||
#include "lv_draw_buf.h"
|
||||
#include "../misc/lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
lv_color_t alpha_color;
|
||||
const lv_color32_t * palette;
|
||||
uint32_t palette_size : 9;
|
||||
} lv_draw_image_sup_t;
|
||||
|
||||
typedef struct _lv_draw_image_dsc_t {
|
||||
lv_draw_dsc_base_t base;
|
||||
|
||||
const void * src;
|
||||
lv_image_header_t header;
|
||||
|
||||
int32_t rotation;
|
||||
int32_t scale_x;
|
||||
int32_t scale_y;
|
||||
int32_t skew_x;
|
||||
int32_t skew_y;
|
||||
lv_point_t pivot;
|
||||
|
||||
lv_color_t recolor;
|
||||
lv_opa_t recolor_opa;
|
||||
|
||||
lv_opa_t opa;
|
||||
lv_blend_mode_t blend_mode : 4;
|
||||
|
||||
uint16_t antialias : 1;
|
||||
uint16_t tile : 1;
|
||||
lv_draw_image_sup_t * sup;
|
||||
|
||||
/** Might be used to indicate the original size of the image if only a small portion is rendered now.
|
||||
* Used when a part of a layer is rendered to show the total layer size*/
|
||||
lv_area_t original_area;
|
||||
const lv_image_dsc_t * bitmap_mask_src;
|
||||
} lv_draw_image_dsc_t;
|
||||
|
||||
/**
|
||||
* PErform the actual rendering of a decoded image
|
||||
* @param draw_unit pointer to a draw unit
|
||||
* @param draw_dsc the draw descriptor of the image
|
||||
* @param decoder_dsc pointer to the decoded image's descriptor
|
||||
* @param sup supplementary data
|
||||
* @param img_coords the absolute coordinates of the image
|
||||
* @param clipped_img_area the absolute clip coordinates
|
||||
*/
|
||||
typedef void (*lv_draw_image_core_cb)(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
|
||||
const lv_image_decoder_dsc_t * decoder_dsc, lv_draw_image_sup_t * sup,
|
||||
const lv_area_t * img_coords, const lv_area_t * clipped_img_area);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an image draw descriptor.
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void lv_draw_image_dsc_init(lv_draw_image_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get an image draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_IMAGE
|
||||
*/
|
||||
lv_draw_image_dsc_t * lv_draw_task_get_image_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Create an image draw task
|
||||
* @param layer pointer to a layer
|
||||
* @param dsc pointer to an initialized draw descriptor
|
||||
* @param coords the coordinates of the image
|
||||
*/
|
||||
void lv_draw_image(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv_area_t * coords);
|
||||
|
||||
/**
|
||||
* Create a draw task to blend a layer to an other layer
|
||||
* @param layer pointer to a layer
|
||||
* @param dsc pointer to an initialized draw descriptor
|
||||
* @param coords the coordinates of the layer
|
||||
*/
|
||||
void lv_draw_layer(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv_area_t * coords);
|
||||
|
||||
/**
|
||||
* Get the type of an image source
|
||||
* @param src pointer to an image source:
|
||||
* - pointer to an 'lv_image_t' variable (image stored internally and compiled into the code)
|
||||
* - a path to a file (e.g. "S:/folder/image.bin")
|
||||
* - or a symbol (e.g. LV_SYMBOL_CLOSE)
|
||||
* @return type of the image source LV_IMAGE_SRC_VARIABLE/FILE/SYMBOL/UNKNOWN
|
||||
*/
|
||||
lv_image_src_t lv_image_src_get_type(const void * src);
|
||||
|
||||
/**
|
||||
* Can be used by draw units to handle the decoding and
|
||||
* prepare everything for the actual image rendering
|
||||
* @param draw_unit pointer to a draw unit
|
||||
* @param draw_dsc the draw descriptor of the image
|
||||
* @param coords the absolute coordinates of the image
|
||||
* @param draw_core_cb a callback to perform the actual rendering
|
||||
*/
|
||||
void _lv_draw_image_normal_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
|
||||
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb);
|
||||
|
||||
/**
|
||||
* Can be used by draw units for TILED images to handle the decoding and
|
||||
* prepare everything for the actual image rendering
|
||||
* @param draw_unit pointer to a draw unit
|
||||
* @param draw_dsc the draw descriptor of the image
|
||||
* @param coords the absolute coordinates of the image
|
||||
* @param draw_core_cb a callback to perform the actual rendering
|
||||
*/
|
||||
void _lv_draw_image_tiled_helper(lv_draw_unit_t * draw_unit, const lv_draw_image_dsc_t * draw_dsc,
|
||||
const lv_area_t * coords, lv_draw_image_core_cb draw_core_cb);
|
||||
|
||||
/**
|
||||
* Get the area of a rectangle if its rotated and scaled
|
||||
* @param res store the coordinates here
|
||||
* @param w width of the rectangle to transform
|
||||
* @param h height of the rectangle to transform
|
||||
* @param angle angle of rotation
|
||||
* @param scale_x zoom in x direction, (256 no zoom)
|
||||
* @param scale_y zoom in y direction, (256 no zoom)
|
||||
* @param pivot x,y pivot coordinates of rotation
|
||||
*/
|
||||
void _lv_image_buf_get_transformed_area(lv_area_t * res, int32_t w, int32_t h, int32_t angle,
|
||||
uint16_t scale_x, uint16_t scale_y, const lv_point_t * pivot);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_IMAGE_H*/
|
||||
439
libraries/lvgl/src/draw/lv_draw_label.c
Normal file
439
libraries/lvgl/src/draw/lv_draw_label.c
Normal file
@ -0,0 +1,439 @@
|
||||
/**
|
||||
* @file lv_draw_label.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../core/lv_obj.h"
|
||||
#include "lv_draw_label.h"
|
||||
#include "../misc/lv_math.h"
|
||||
#include "../core/lv_obj_event.h"
|
||||
#include "../misc/lv_bidi.h"
|
||||
#include "../misc/lv_assert.h"
|
||||
#include "../stdlib/lv_mem.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LABEL_RECOLOR_PAR_LENGTH 6
|
||||
#define LV_LABEL_HINT_UPDATE_TH 1024 /*Update the "hint" if the label's y coordinates have changed more then this*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void draw_letter(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t * dsc, const lv_point_t * pos,
|
||||
const lv_font_t * font, uint32_t letter, lv_draw_glyph_cb_t cb);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(lv_draw_label_dsc_t));
|
||||
dsc->opa = LV_OPA_COVER;
|
||||
dsc->color = lv_color_black();
|
||||
dsc->font = LV_FONT_DEFAULT;
|
||||
dsc->sel_start = LV_DRAW_LABEL_NO_TXT_SEL;
|
||||
dsc->sel_end = LV_DRAW_LABEL_NO_TXT_SEL;
|
||||
dsc->sel_color = lv_color_black();
|
||||
dsc->sel_bg_color = lv_palette_main(LV_PALETTE_BLUE);
|
||||
dsc->bidi_dir = LV_BASE_DIR_LTR;
|
||||
dsc->base.dsc_size = sizeof(lv_draw_label_dsc_t);
|
||||
}
|
||||
|
||||
lv_draw_label_dsc_t * lv_draw_task_get_label_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_LABEL ? (lv_draw_label_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_glyph_dsc_init(lv_draw_glyph_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(lv_draw_glyph_dsc_t));
|
||||
}
|
||||
|
||||
void LV_ATTRIBUTE_FAST_MEM lv_draw_label(lv_layer_t * layer, const lv_draw_label_dsc_t * dsc,
|
||||
const lv_area_t * coords)
|
||||
{
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
if(dsc->text == NULL || dsc->text[0] == '\0') return;
|
||||
if(dsc->font == NULL) {
|
||||
LV_LOG_WARN("dsc->font == NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
LV_PROFILER_BEGIN;
|
||||
lv_draw_task_t * t = lv_draw_add_task(layer, coords);
|
||||
|
||||
t->draw_dsc = lv_malloc(sizeof(*dsc));
|
||||
lv_memcpy(t->draw_dsc, dsc, sizeof(*dsc));
|
||||
t->type = LV_DRAW_TASK_TYPE_LABEL;
|
||||
|
||||
/*The text is stored in a local variable so malloc memory for it*/
|
||||
if(dsc->text_local) {
|
||||
lv_draw_label_dsc_t * new_dsc = t->draw_dsc;
|
||||
new_dsc->text = lv_strdup(dsc->text);
|
||||
}
|
||||
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
void LV_ATTRIBUTE_FAST_MEM lv_draw_character(lv_layer_t * layer, lv_draw_label_dsc_t * dsc,
|
||||
const lv_point_t * point, uint32_t unicode_letter)
|
||||
{
|
||||
if(dsc->opa <= LV_OPA_MIN) return;
|
||||
if(dsc->font == NULL) {
|
||||
LV_LOG_WARN("dsc->font == NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
if(_lv_text_is_marker(unicode_letter)) return;
|
||||
|
||||
LV_PROFILER_BEGIN;
|
||||
|
||||
lv_font_glyph_dsc_t g;
|
||||
lv_font_get_glyph_dsc(dsc->font, &g, unicode_letter, 0);
|
||||
|
||||
lv_area_t a;
|
||||
a.x1 = point->x;
|
||||
a.y1 = point->y;
|
||||
a.x2 = a.x1 + g.adv_w;
|
||||
a.y2 = a.y1 + lv_font_get_line_height(g.resolved_font ? g.resolved_font : dsc->font);
|
||||
|
||||
/*lv_draw_label needs UTF8 text so convert the Unicode character to an UTF8 string */
|
||||
uint32_t letter_buf[2];
|
||||
letter_buf[0] = _lv_text_unicode_to_encoded(unicode_letter);
|
||||
letter_buf[1] = '\0';
|
||||
|
||||
const char * letter_buf_char = (const char *)letter_buf;
|
||||
|
||||
#if LV_BIG_ENDIAN_SYSTEM
|
||||
while(*letter_buf_char == 0) ++letter_buf_char;
|
||||
#endif
|
||||
|
||||
dsc->text = letter_buf_char;
|
||||
dsc->text_local = 1;
|
||||
|
||||
lv_draw_label(layer, dsc, &a);
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
void lv_draw_label_iterate_characters(lv_draw_unit_t * draw_unit, const lv_draw_label_dsc_t * dsc,
|
||||
const lv_area_t * coords,
|
||||
lv_draw_glyph_cb_t cb)
|
||||
{
|
||||
const lv_font_t * font = dsc->font;
|
||||
int32_t w;
|
||||
|
||||
lv_area_t clipped_area;
|
||||
bool clip_ok = _lv_area_intersect(&clipped_area, coords, draw_unit->clip_area);
|
||||
if(!clip_ok) return;
|
||||
|
||||
lv_text_align_t align = dsc->align;
|
||||
lv_base_dir_t base_dir = dsc->bidi_dir;
|
||||
|
||||
lv_bidi_calculate_align(&align, &base_dir, dsc->text);
|
||||
|
||||
if((dsc->flag & LV_TEXT_FLAG_EXPAND) == 0) {
|
||||
/*Normally use the label's width as width*/
|
||||
w = lv_area_get_width(coords);
|
||||
}
|
||||
else {
|
||||
/*If EXPAND is enabled then not limit the text's width to the object's width*/
|
||||
lv_point_t p;
|
||||
lv_text_get_size(&p, dsc->text, dsc->font, dsc->letter_space, dsc->line_space, LV_COORD_MAX,
|
||||
dsc->flag);
|
||||
w = p.x;
|
||||
}
|
||||
|
||||
int32_t line_height_font = lv_font_get_line_height(font);
|
||||
int32_t line_height = line_height_font + dsc->line_space;
|
||||
|
||||
/*Init variables for the first line*/
|
||||
int32_t line_width = 0;
|
||||
lv_point_t pos;
|
||||
lv_point_set(&pos, coords->x1, coords->y1);
|
||||
|
||||
int32_t x_ofs = 0;
|
||||
int32_t y_ofs = 0;
|
||||
x_ofs = dsc->ofs_x;
|
||||
y_ofs = dsc->ofs_y;
|
||||
pos.y += y_ofs;
|
||||
|
||||
uint32_t line_start = 0;
|
||||
int32_t last_line_start = -1;
|
||||
|
||||
/*Check the hint to use the cached info*/
|
||||
if(dsc->hint && y_ofs == 0 && coords->y1 < 0) {
|
||||
/*If the label changed too much recalculate the hint.*/
|
||||
if(LV_ABS(dsc->hint->coord_y - coords->y1) > LV_LABEL_HINT_UPDATE_TH - 2 * line_height) {
|
||||
dsc->hint->line_start = -1;
|
||||
}
|
||||
last_line_start = dsc->hint->line_start;
|
||||
}
|
||||
|
||||
/*Use the hint if it's valid*/
|
||||
if(dsc->hint && last_line_start >= 0) {
|
||||
line_start = last_line_start;
|
||||
pos.y += dsc->hint->y;
|
||||
}
|
||||
|
||||
uint32_t line_end = line_start + _lv_text_get_next_line(&dsc->text[line_start], font, dsc->letter_space, w, NULL,
|
||||
dsc->flag);
|
||||
|
||||
/*Go the first visible line*/
|
||||
while(pos.y + line_height_font < draw_unit->clip_area->y1) {
|
||||
/*Go to next line*/
|
||||
line_start = line_end;
|
||||
line_end += _lv_text_get_next_line(&dsc->text[line_start], font, dsc->letter_space, w, NULL, dsc->flag);
|
||||
pos.y += line_height;
|
||||
|
||||
/*Save at the threshold coordinate*/
|
||||
if(dsc->hint && pos.y >= -LV_LABEL_HINT_UPDATE_TH && dsc->hint->line_start < 0) {
|
||||
dsc->hint->line_start = line_start;
|
||||
dsc->hint->y = pos.y - coords->y1;
|
||||
dsc->hint->coord_y = coords->y1;
|
||||
}
|
||||
|
||||
if(dsc->text[line_start] == '\0') return;
|
||||
}
|
||||
|
||||
/*Align to middle*/
|
||||
if(align == LV_TEXT_ALIGN_CENTER) {
|
||||
line_width = lv_text_get_width(&dsc->text[line_start], line_end - line_start, font, dsc->letter_space);
|
||||
|
||||
pos.x += (lv_area_get_width(coords) - line_width) / 2;
|
||||
|
||||
}
|
||||
/*Align to the right*/
|
||||
else if(align == LV_TEXT_ALIGN_RIGHT) {
|
||||
line_width = lv_text_get_width(&dsc->text[line_start], line_end - line_start, font, dsc->letter_space);
|
||||
pos.x += lv_area_get_width(coords) - line_width;
|
||||
}
|
||||
|
||||
uint32_t sel_start = dsc->sel_start;
|
||||
uint32_t sel_end = dsc->sel_end;
|
||||
if(sel_start > sel_end) {
|
||||
uint32_t tmp = sel_start;
|
||||
sel_start = sel_end;
|
||||
sel_end = tmp;
|
||||
}
|
||||
|
||||
lv_area_t bg_coords;
|
||||
lv_draw_glyph_dsc_t draw_letter_dsc;
|
||||
lv_draw_glyph_dsc_init(&draw_letter_dsc);
|
||||
draw_letter_dsc.opa = dsc->opa;
|
||||
draw_letter_dsc.bg_coords = &bg_coords;
|
||||
draw_letter_dsc.color = dsc->color;
|
||||
|
||||
lv_draw_fill_dsc_t fill_dsc;
|
||||
lv_draw_fill_dsc_init(&fill_dsc);
|
||||
fill_dsc.opa = dsc->opa;
|
||||
int32_t underline_width = font->underline_thickness ? font->underline_thickness : 1;
|
||||
int32_t line_start_x;
|
||||
uint32_t i;
|
||||
int32_t letter_w;
|
||||
|
||||
/*Write out all lines*/
|
||||
while(dsc->text[line_start] != '\0') {
|
||||
pos.x += x_ofs;
|
||||
line_start_x = pos.x;
|
||||
|
||||
/*Write all letter of a line*/
|
||||
i = 0;
|
||||
#if LV_USE_BIDI
|
||||
char * bidi_txt = lv_malloc(line_end - line_start + 1);
|
||||
LV_ASSERT_MALLOC(bidi_txt);
|
||||
_lv_bidi_process_paragraph(dsc->text + line_start, bidi_txt, line_end - line_start, base_dir, NULL, 0);
|
||||
#else
|
||||
const char * bidi_txt = dsc->text + line_start;
|
||||
#endif
|
||||
|
||||
while(i < line_end - line_start) {
|
||||
uint32_t logical_char_pos = 0;
|
||||
if(sel_start != 0xFFFF && sel_end != 0xFFFF) {
|
||||
#if LV_USE_BIDI
|
||||
logical_char_pos = _lv_text_encoded_get_char_id(dsc->text, line_start);
|
||||
uint32_t t = _lv_text_encoded_get_char_id(bidi_txt, i);
|
||||
logical_char_pos += _lv_bidi_get_logical_pos(bidi_txt, NULL, line_end - line_start, base_dir, t, NULL);
|
||||
#else
|
||||
logical_char_pos = _lv_text_encoded_get_char_id(dsc->text, line_start + i);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t letter;
|
||||
uint32_t letter_next;
|
||||
_lv_text_encoded_letter_next_2(bidi_txt, &letter, &letter_next, &i);
|
||||
|
||||
letter_w = lv_font_get_glyph_width(font, letter, letter_next);
|
||||
|
||||
/*Always set the bg_coordinates for placeholder drawing*/
|
||||
bg_coords.x1 = pos.x;
|
||||
bg_coords.y1 = pos.y;
|
||||
bg_coords.x2 = pos.x + letter_w - 1;
|
||||
bg_coords.y2 = pos.y + line_height - 1;
|
||||
|
||||
if(i >= line_end - line_start) {
|
||||
if(dsc->decor & LV_TEXT_DECOR_UNDERLINE) {
|
||||
lv_area_t fill_area;
|
||||
fill_area.x1 = line_start_x;
|
||||
fill_area.x2 = pos.x + letter_w - 1;
|
||||
fill_area.y1 = pos.y + font->line_height - font->base_line - font->underline_position;
|
||||
fill_area.y2 = fill_area.y1 + underline_width - 1;
|
||||
|
||||
fill_dsc.color = dsc->color;
|
||||
cb(draw_unit, NULL, &fill_dsc, &fill_area);
|
||||
}
|
||||
if(dsc->decor & LV_TEXT_DECOR_STRIKETHROUGH) {
|
||||
lv_area_t fill_area;
|
||||
fill_area.x1 = line_start_x;
|
||||
fill_area.x2 = pos.x + letter_w - 1;
|
||||
fill_area.y1 = pos.y + (font->line_height - font->base_line) * 2 / 3 + font->underline_thickness / 2;
|
||||
fill_area.y2 = fill_area.y1 + underline_width - 1;
|
||||
|
||||
fill_dsc.color = dsc->color;
|
||||
cb(draw_unit, NULL, &fill_dsc, &fill_area);
|
||||
}
|
||||
}
|
||||
|
||||
if(sel_start != 0xFFFF && sel_end != 0xFFFF && logical_char_pos >= sel_start && logical_char_pos < sel_end) {
|
||||
draw_letter_dsc.color = dsc->sel_color;
|
||||
fill_dsc.color = dsc->sel_bg_color;
|
||||
cb(draw_unit, NULL, &fill_dsc, &bg_coords);
|
||||
}
|
||||
else {
|
||||
draw_letter_dsc.color = dsc->color;
|
||||
}
|
||||
|
||||
draw_letter(draw_unit, &draw_letter_dsc, &pos, font, letter, cb);
|
||||
|
||||
if(letter_w > 0) {
|
||||
pos.x += letter_w + dsc->letter_space;
|
||||
}
|
||||
}
|
||||
|
||||
#if LV_USE_BIDI
|
||||
lv_free(bidi_txt);
|
||||
bidi_txt = NULL;
|
||||
#endif
|
||||
/*Go to next line*/
|
||||
line_start = line_end;
|
||||
line_end += _lv_text_get_next_line(&dsc->text[line_start], font, dsc->letter_space, w, NULL, dsc->flag);
|
||||
|
||||
pos.x = coords->x1;
|
||||
/*Align to middle*/
|
||||
if(align == LV_TEXT_ALIGN_CENTER) {
|
||||
line_width =
|
||||
lv_text_get_width(&dsc->text[line_start], line_end - line_start, font, dsc->letter_space);
|
||||
|
||||
pos.x += (lv_area_get_width(coords) - line_width) / 2;
|
||||
}
|
||||
/*Align to the right*/
|
||||
else if(align == LV_TEXT_ALIGN_RIGHT) {
|
||||
line_width =
|
||||
lv_text_get_width(&dsc->text[line_start], line_end - line_start, font, dsc->letter_space);
|
||||
pos.x += lv_area_get_width(coords) - line_width;
|
||||
}
|
||||
|
||||
/*Go the next line position*/
|
||||
pos.y += line_height;
|
||||
|
||||
if(pos.y > draw_unit->clip_area->y2) break;
|
||||
}
|
||||
|
||||
if(draw_letter_dsc._draw_buf) lv_draw_buf_destroy(draw_letter_dsc._draw_buf);
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void draw_letter(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t * dsc, const lv_point_t * pos,
|
||||
const lv_font_t * font, uint32_t letter, lv_draw_glyph_cb_t cb)
|
||||
{
|
||||
lv_font_glyph_dsc_t g;
|
||||
|
||||
if(_lv_text_is_marker(letter)) /*Markers are valid letters but should not be rendered.*/
|
||||
return;
|
||||
|
||||
LV_PROFILER_BEGIN;
|
||||
bool g_ret = lv_font_get_glyph_dsc(font, &g, letter, '\0');
|
||||
if(g_ret == false) {
|
||||
/*Add warning if the dsc is not found*/
|
||||
LV_LOG_WARN("lv_draw_letter: glyph dsc. not found for U+%" LV_PRIX32, letter);
|
||||
}
|
||||
|
||||
/*Don't draw anything if the character is empty. E.g. space*/
|
||||
if((g.box_h == 0) || (g.box_w == 0)) {
|
||||
LV_PROFILER_END;
|
||||
return;
|
||||
}
|
||||
|
||||
lv_area_t letter_coords;
|
||||
letter_coords.x1 = pos->x + g.ofs_x;
|
||||
letter_coords.x2 = letter_coords.x1 + g.box_w - 1;
|
||||
letter_coords.y1 = pos->y + (font->line_height - font->base_line) - g.box_h - g.ofs_y;
|
||||
letter_coords.y2 = letter_coords.y1 + g.box_h - 1;
|
||||
|
||||
/*If the letter is completely out of mask don't draw it*/
|
||||
if(_lv_area_is_out(&letter_coords, draw_unit->clip_area, 0) &&
|
||||
_lv_area_is_out(dsc->bg_coords, draw_unit->clip_area, 0)) {
|
||||
LV_PROFILER_END;
|
||||
return;
|
||||
}
|
||||
|
||||
if(g.resolved_font) {
|
||||
lv_draw_buf_t * draw_buf = NULL;
|
||||
if(LV_FONT_GLYPH_FORMAT_NONE < g.format && g.format < LV_FONT_GLYPH_FORMAT_IMAGE) {
|
||||
/*Only check draw buf for bitmap glyph*/
|
||||
draw_buf = lv_draw_buf_reshape(dsc->_draw_buf, 0, g.box_w, g.box_h, LV_STRIDE_AUTO);
|
||||
if(draw_buf == NULL) {
|
||||
if(dsc->_draw_buf) lv_draw_buf_destroy(dsc->_draw_buf);
|
||||
|
||||
uint32_t h = g.box_h;
|
||||
if(h * g.box_w < 64) h *= 2; /*Alloc a slightly larger buffer*/
|
||||
draw_buf = lv_draw_buf_create(g.box_w, h, LV_COLOR_FORMAT_A8, LV_STRIDE_AUTO);
|
||||
LV_ASSERT_MALLOC(draw_buf);
|
||||
draw_buf->header.h = g.box_h;
|
||||
dsc->_draw_buf = draw_buf;
|
||||
}
|
||||
}
|
||||
|
||||
dsc->glyph_data = (void *)lv_font_get_glyph_bitmap(&g, letter, draw_buf);
|
||||
dsc->format = dsc->glyph_data ? g.format : LV_FONT_GLYPH_FORMAT_NONE;
|
||||
}
|
||||
else {
|
||||
dsc->format = LV_FONT_GLYPH_FORMAT_NONE;
|
||||
}
|
||||
|
||||
dsc->letter_coords = &letter_coords;
|
||||
dsc->g = &g;
|
||||
cb(draw_unit, dsc, NULL, NULL);
|
||||
|
||||
if(g.resolved_font && font->release_glyph) {
|
||||
font->release_glyph(font, &g);
|
||||
}
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
167
libraries/lvgl/src/draw/lv_draw_label.h
Normal file
167
libraries/lvgl/src/draw/lv_draw_label.h
Normal file
@ -0,0 +1,167 @@
|
||||
/**
|
||||
* @file lv_draw_label.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_LABEL_H
|
||||
#define LV_DRAW_LABEL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw.h"
|
||||
#include "../misc/lv_bidi.h"
|
||||
#include "../misc/lv_text.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../misc/lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_DRAW_LABEL_NO_TXT_SEL (0xFFFF)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/** Store some info to speed up drawing of very large texts
|
||||
* It takes a lot of time to get the first visible character because
|
||||
* all the previous characters needs to be checked to calculate the positions.
|
||||
* This structure stores an earlier (e.g. at -1000 px) coordinate and the index of that line.
|
||||
* Therefore the calculations can start from here.*/
|
||||
typedef struct _lv_draw_label_hint_t {
|
||||
/** Index of the line at `y` coordinate*/
|
||||
int32_t line_start;
|
||||
|
||||
/** Give the `y` coordinate of the first letter at `line start` index. Relative to the label's coordinates*/
|
||||
int32_t y;
|
||||
|
||||
/** The 'y1' coordinate of the label when the hint was saved.
|
||||
* Used to invalidate the hint if the label has moved too much.*/
|
||||
int32_t coord_y;
|
||||
} lv_draw_label_hint_t;
|
||||
|
||||
typedef struct {
|
||||
lv_draw_dsc_base_t base;
|
||||
|
||||
const char * text;
|
||||
const lv_font_t * font;
|
||||
uint32_t sel_start;
|
||||
uint32_t sel_end;
|
||||
lv_color_t color;
|
||||
lv_color_t sel_color;
|
||||
lv_color_t sel_bg_color;
|
||||
int32_t line_space;
|
||||
int32_t letter_space;
|
||||
int32_t ofs_x;
|
||||
int32_t ofs_y;
|
||||
lv_opa_t opa;
|
||||
lv_base_dir_t bidi_dir;
|
||||
lv_text_align_t align;
|
||||
lv_text_flag_t flag;
|
||||
lv_text_decor_t decor : 3;
|
||||
lv_blend_mode_t blend_mode : 3;
|
||||
/**
|
||||
* < 1: malloc buffer and copy `text` there.
|
||||
* 0: `text` is const and it's pointer will be valid during rendering.*/
|
||||
uint8_t text_local : 1;
|
||||
lv_draw_label_hint_t * hint;
|
||||
} lv_draw_label_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
void * glyph_data; /*Depends on `format` field, it could be image source or draw buf of bitmap or vector data.*/
|
||||
lv_font_glyph_format_t format;
|
||||
const lv_area_t * letter_coords;
|
||||
const lv_area_t * bg_coords;
|
||||
const lv_font_glyph_dsc_t * g;
|
||||
lv_color_t color;
|
||||
lv_opa_t opa;
|
||||
lv_draw_buf_t * _draw_buf; /*a shared draw buf for get_bitmap, do not use it directly, use glyph_data instead*/
|
||||
} lv_draw_glyph_dsc_t;
|
||||
|
||||
/**
|
||||
* Passed as a parameter to `lv_draw_label_iterate_characters` to
|
||||
* draw the characters one by one
|
||||
* @param draw_unit pointer to a draw unit
|
||||
* @param dsc pointer to `lv_draw_glyph_dsc_t` to describe the character to draw
|
||||
* if NULL don't draw character
|
||||
* @param fill_dsc pointer to a fill descriptor to draw a background for the character or
|
||||
* underline or strike through
|
||||
* if NULL do not fill anything
|
||||
* @param fill_area the area to fill
|
||||
* if NULL do not fill anything
|
||||
*/
|
||||
typedef void(*lv_draw_glyph_cb_t)(lv_draw_unit_t * draw_unit, lv_draw_glyph_dsc_t * dsc, lv_draw_fill_dsc_t * fill_dsc,
|
||||
const lv_area_t * fill_area);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a label draw descriptor
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a label draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_LABEL
|
||||
*/
|
||||
lv_draw_label_dsc_t * lv_draw_task_get_label_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Initialize a glyph draw descriptor.
|
||||
* Used internally.
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void lv_draw_glyph_dsc_init(lv_draw_glyph_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Crate a draw task to render a text
|
||||
* @param layer pointer to a layer
|
||||
* @param dsc pointer to draw descriptor
|
||||
* @param coords coordinates of the character
|
||||
*/
|
||||
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_label(lv_layer_t * layer, const lv_draw_label_dsc_t * dsc,
|
||||
const lv_area_t * coords);
|
||||
|
||||
/**
|
||||
* Crate a draw task to render a single character
|
||||
* @param layer pointer to a layer
|
||||
* @param dsc pointer to draw descriptor
|
||||
* @param point position of the label
|
||||
* @param unicode_letter the letter to draw
|
||||
*/
|
||||
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_character(lv_layer_t * layer, lv_draw_label_dsc_t * dsc,
|
||||
const lv_point_t * point, uint32_t unicode_letter);
|
||||
|
||||
/**
|
||||
* Should be used during rendering the characters to get the position and other
|
||||
* parameters of the characters
|
||||
* @param draw_unit pointer to a draw unit
|
||||
* @param dsc pointer to draw descriptor
|
||||
* @param coords coordinates of the label
|
||||
* @param cb a callback to call to draw each glyphs one by one
|
||||
*/
|
||||
void lv_draw_label_iterate_characters(lv_draw_unit_t * draw_unit, const lv_draw_label_dsc_t * dsc,
|
||||
const lv_area_t * coords, lv_draw_glyph_cb_t cb);
|
||||
|
||||
/***********************
|
||||
* GLOBAL VARIABLES
|
||||
***********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_LABEL_H*/
|
||||
72
libraries/lvgl/src/draw/lv_draw_line.c
Normal file
72
libraries/lvgl/src/draw/lv_draw_line.c
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @file lv_draw_line.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
#include "../core/lv_refr.h"
|
||||
#include "../misc/lv_math.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void LV_ATTRIBUTE_FAST_MEM lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(lv_draw_line_dsc_t));
|
||||
dsc->width = 1;
|
||||
dsc->opa = LV_OPA_COVER;
|
||||
dsc->color = lv_color_black();
|
||||
}
|
||||
|
||||
lv_draw_line_dsc_t * lv_draw_task_get_line_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_LINE ? (lv_draw_line_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void LV_ATTRIBUTE_FAST_MEM lv_draw_line(lv_layer_t * layer, const lv_draw_line_dsc_t * dsc)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
lv_area_t a;
|
||||
a.x1 = (int32_t)LV_MIN(dsc->p1.x, dsc->p2.x) - dsc->width;
|
||||
a.x2 = (int32_t)LV_MAX(dsc->p1.x, dsc->p2.x) + dsc->width;
|
||||
a.y1 = (int32_t)LV_MIN(dsc->p1.y, dsc->p2.y) - dsc->width;
|
||||
a.y2 = (int32_t)LV_MAX(dsc->p1.y, dsc->p2.y) + dsc->width;
|
||||
|
||||
lv_draw_task_t * t = lv_draw_add_task(layer, &a);
|
||||
|
||||
t->draw_dsc = lv_malloc(sizeof(*dsc));
|
||||
lv_memcpy(t->draw_dsc, dsc, sizeof(*dsc));
|
||||
t->type = LV_DRAW_TASK_TYPE_LINE;
|
||||
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
76
libraries/lvgl/src/draw/lv_draw_line.h
Normal file
76
libraries/lvgl/src/draw/lv_draw_line.h
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @file lv_draw_line.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_LINE_H
|
||||
#define LV_DRAW_LINE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct {
|
||||
lv_draw_dsc_base_t base;
|
||||
|
||||
lv_point_precise_t p1;
|
||||
lv_point_precise_t p2;
|
||||
lv_color_t color;
|
||||
int32_t width;
|
||||
int32_t dash_width;
|
||||
int32_t dash_gap;
|
||||
lv_opa_t opa;
|
||||
lv_blend_mode_t blend_mode : 2;
|
||||
uint8_t round_start : 1;
|
||||
uint8_t round_end : 1;
|
||||
uint8_t raw_end : 1; /*Do not bother with perpendicular line ending if it's not visible for any reason*/
|
||||
} lv_draw_line_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a line draw descriptor
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a line draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_LINE
|
||||
*/
|
||||
lv_draw_line_dsc_t * lv_draw_task_get_line_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Create a line draw task
|
||||
* @param layer pointer to a layer
|
||||
* @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
|
||||
*/
|
||||
void lv_draw_line(lv_layer_t * layer, const lv_draw_line_dsc_t * dsc);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_LINE_H*/
|
||||
80
libraries/lvgl/src/draw/lv_draw_mask.c
Normal file
80
libraries/lvgl/src/draw/lv_draw_mask.c
Normal file
@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @file lv_draw_mask.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
#include "lv_draw_mask.h"
|
||||
#include "../core/lv_refr.h"
|
||||
#include "../misc/lv_math.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void LV_ATTRIBUTE_FAST_MEM lv_draw_mask_rect_dsc_init(lv_draw_mask_rect_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(lv_draw_mask_rect_dsc_t));
|
||||
}
|
||||
|
||||
lv_draw_mask_rect_dsc_t * lv_draw_task_get_mask_rect_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_MASK_RECTANGLE ? (lv_draw_mask_rect_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void LV_ATTRIBUTE_FAST_MEM lv_draw_mask_rect(lv_layer_t * layer, const lv_draw_mask_rect_dsc_t * dsc)
|
||||
{
|
||||
if(!lv_color_format_has_alpha(layer->color_format)) {
|
||||
LV_LOG_WARN("Only layers with alpha channel can be masked");
|
||||
return;
|
||||
}
|
||||
LV_PROFILER_BEGIN;
|
||||
|
||||
lv_draw_task_t * t = lv_draw_add_task(layer, &layer->buf_area);
|
||||
|
||||
t->draw_dsc = lv_malloc(sizeof(*dsc));
|
||||
lv_memcpy(t->draw_dsc, dsc, sizeof(*dsc));
|
||||
t->type = LV_DRAW_TASK_TYPE_MASK_RECTANGLE;
|
||||
|
||||
lv_draw_dsc_base_t * base_dsc = t->draw_dsc;
|
||||
base_dsc->layer = layer;
|
||||
|
||||
if(base_dsc->obj && lv_obj_has_flag(base_dsc->obj, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS)) {
|
||||
/*Disable sending LV_EVENT_DRAW_TASK_ADDED first to avoid triggering recursive
|
||||
*event calls due draw task adds in the event*/
|
||||
lv_obj_remove_flag(base_dsc->obj, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
|
||||
lv_obj_send_event(dsc->base.obj, LV_EVENT_DRAW_TASK_ADDED, t);
|
||||
lv_obj_add_flag(base_dsc->obj, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS);
|
||||
}
|
||||
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
67
libraries/lvgl/src/draw/lv_draw_mask.h
Normal file
67
libraries/lvgl/src/draw/lv_draw_mask.h
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @file lv_draw_mask_rect.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_MASK_RECT_H
|
||||
#define LV_DRAW_MASK_RECT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_style.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct {
|
||||
lv_draw_dsc_base_t base;
|
||||
|
||||
lv_area_t area;
|
||||
int32_t radius;
|
||||
} lv_draw_mask_rect_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a rectangle mask draw descriptor.
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_mask_rect_dsc_init(lv_draw_mask_rect_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a rectangle mask draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_MASK_RECTANGLE
|
||||
*/
|
||||
lv_draw_mask_rect_dsc_t * lv_draw_task_get_mask_rect_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Create a draw task to mask a rectangle from the buffer
|
||||
* @param layer pointer to a layer
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void lv_draw_mask_rect(lv_layer_t * layer, const lv_draw_mask_rect_dsc_t * dsc);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_MASK_RECT_H*/
|
||||
297
libraries/lvgl/src/draw/lv_draw_rect.c
Normal file
297
libraries/lvgl/src/draw/lv_draw_rect.c
Normal file
@ -0,0 +1,297 @@
|
||||
/**
|
||||
* @file lv_draw_rect.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../core/lv_obj.h"
|
||||
#include "lv_draw_rect.h"
|
||||
#include "../misc/lv_assert.h"
|
||||
#include "../core/lv_obj_event.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void LV_ATTRIBUTE_FAST_MEM lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(lv_draw_rect_dsc_t));
|
||||
dsc->bg_color = lv_color_white();
|
||||
dsc->bg_grad.stops[0].color = lv_color_white();
|
||||
dsc->bg_grad.stops[1].color = lv_color_black();
|
||||
dsc->bg_grad.stops[1].frac = 0xFF;
|
||||
dsc->bg_grad.stops_count = 2;
|
||||
dsc->border_color = lv_color_black();
|
||||
dsc->shadow_color = lv_color_black();
|
||||
dsc->bg_image_symbol_font = LV_FONT_DEFAULT;
|
||||
dsc->bg_opa = LV_OPA_COVER;
|
||||
dsc->bg_image_opa = LV_OPA_COVER;
|
||||
dsc->outline_opa = LV_OPA_COVER;
|
||||
dsc->border_opa = LV_OPA_COVER;
|
||||
dsc->shadow_opa = LV_OPA_COVER;
|
||||
dsc->border_side = LV_BORDER_SIDE_FULL;
|
||||
}
|
||||
|
||||
void lv_draw_fill_dsc_init(lv_draw_fill_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(*dsc));
|
||||
dsc->opa = LV_OPA_COVER;
|
||||
dsc->base.dsc_size = sizeof(lv_draw_fill_dsc_t);
|
||||
}
|
||||
|
||||
lv_draw_fill_dsc_t * lv_draw_task_get_fill_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_FILL ? (lv_draw_fill_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_border_dsc_init(lv_draw_border_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(*dsc));
|
||||
dsc->opa = LV_OPA_COVER;
|
||||
dsc->side = LV_BORDER_SIDE_FULL;
|
||||
dsc->base.dsc_size = sizeof(lv_draw_border_dsc_t);
|
||||
}
|
||||
|
||||
lv_draw_border_dsc_t * lv_draw_task_get_border_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_BORDER ? (lv_draw_border_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_box_shadow_dsc_init(lv_draw_box_shadow_dsc_t * dsc)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(*dsc));
|
||||
dsc->opa = LV_OPA_COVER;
|
||||
dsc->base.dsc_size = sizeof(lv_draw_box_shadow_dsc_t);
|
||||
}
|
||||
|
||||
lv_draw_box_shadow_dsc_t * lv_draw_task_get_box_shadow_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_BOX_SHADOW ? (lv_draw_box_shadow_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_rect(lv_layer_t * layer, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords)
|
||||
{
|
||||
|
||||
LV_PROFILER_BEGIN;
|
||||
bool has_shadow;
|
||||
bool has_fill;
|
||||
bool has_border;
|
||||
bool has_outline;
|
||||
bool has_bg_img;
|
||||
|
||||
if(dsc->shadow_width == 0 ||
|
||||
dsc->shadow_opa <= LV_OPA_MIN ||
|
||||
(dsc->shadow_width == 1 && dsc->shadow_spread <= 0 &&
|
||||
dsc->shadow_offset_x == 0 && dsc->shadow_offset_y == 0)) {
|
||||
has_shadow = false;
|
||||
}
|
||||
else {
|
||||
has_shadow = true;
|
||||
}
|
||||
|
||||
if(dsc->bg_opa <= LV_OPA_MIN) has_fill = false;
|
||||
else has_fill = true;
|
||||
|
||||
if(dsc->bg_image_opa <= LV_OPA_MIN || dsc->bg_image_src == NULL) has_bg_img = false;
|
||||
else has_bg_img = true;
|
||||
|
||||
if(dsc->border_opa <= LV_OPA_MIN || dsc->border_width == 0 || dsc->border_post == true) has_border = false;
|
||||
else has_border = true;
|
||||
|
||||
if(dsc->outline_opa <= LV_OPA_MIN || dsc->outline_width == 0) has_outline = false;
|
||||
else has_outline = true;
|
||||
|
||||
bool bg_cover = true;
|
||||
if(dsc->bg_opa < LV_OPA_COVER) bg_cover = false;
|
||||
else if(dsc->bg_grad.dir != LV_GRAD_DIR_NONE) {
|
||||
uint32_t s;
|
||||
for(s = 0; s < dsc->bg_grad.stops_count; s++) {
|
||||
if(dsc->bg_grad.stops[s].opa != LV_OPA_COVER) {
|
||||
bg_cover = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lv_draw_task_t * t;
|
||||
|
||||
/*Shadow*/
|
||||
if(has_shadow) {
|
||||
/*Check whether the shadow is visible*/
|
||||
t = lv_draw_add_task(layer, coords);
|
||||
lv_draw_box_shadow_dsc_t * shadow_dsc = lv_malloc(sizeof(lv_draw_box_shadow_dsc_t));
|
||||
t->draw_dsc = shadow_dsc;
|
||||
lv_area_increase(&t->_real_area, dsc->shadow_spread, dsc->shadow_spread);
|
||||
lv_area_increase(&t->_real_area, dsc->shadow_width, dsc->shadow_width);
|
||||
lv_area_move(&t->_real_area, dsc->shadow_offset_x, dsc->shadow_offset_y);
|
||||
shadow_dsc->base = dsc->base;
|
||||
shadow_dsc->base.dsc_size = sizeof(lv_draw_box_shadow_dsc_t);
|
||||
shadow_dsc->radius = dsc->radius;
|
||||
shadow_dsc->color = dsc->shadow_color;
|
||||
shadow_dsc->width = dsc->shadow_width;
|
||||
shadow_dsc->spread = dsc->shadow_spread;
|
||||
shadow_dsc->opa = dsc->shadow_opa;
|
||||
shadow_dsc->ofs_x = dsc->shadow_offset_x;
|
||||
shadow_dsc->ofs_y = dsc->shadow_offset_y;
|
||||
shadow_dsc->bg_cover = bg_cover;
|
||||
t->type = LV_DRAW_TASK_TYPE_BOX_SHADOW;
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
}
|
||||
|
||||
/*Background*/
|
||||
if(has_fill) {
|
||||
lv_area_t bg_coords = *coords;
|
||||
/*If the border fully covers make the bg area 1px smaller to avoid artifacts on the corners*/
|
||||
if(dsc->border_width > 1 && dsc->border_opa >= LV_OPA_MAX && dsc->radius != 0) {
|
||||
bg_coords.x1 += (dsc->border_side & LV_BORDER_SIDE_LEFT) ? 1 : 0;
|
||||
bg_coords.y1 += (dsc->border_side & LV_BORDER_SIDE_TOP) ? 1 : 0;
|
||||
bg_coords.x2 -= (dsc->border_side & LV_BORDER_SIDE_RIGHT) ? 1 : 0;
|
||||
bg_coords.y2 -= (dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? 1 : 0;
|
||||
}
|
||||
|
||||
t = lv_draw_add_task(layer, &bg_coords);
|
||||
lv_draw_fill_dsc_t * bg_dsc = lv_malloc(sizeof(lv_draw_fill_dsc_t));
|
||||
lv_draw_fill_dsc_init(bg_dsc);
|
||||
t->draw_dsc = bg_dsc;
|
||||
bg_dsc->base = dsc->base;
|
||||
bg_dsc->base.dsc_size = sizeof(lv_draw_fill_dsc_t);
|
||||
bg_dsc->radius = dsc->radius;
|
||||
bg_dsc->color = dsc->bg_color;
|
||||
bg_dsc->grad = dsc->bg_grad;
|
||||
bg_dsc->opa = dsc->bg_opa;
|
||||
t->type = LV_DRAW_TASK_TYPE_FILL;
|
||||
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
}
|
||||
|
||||
/*Background image*/
|
||||
if(has_bg_img) {
|
||||
lv_image_src_t src_type = lv_image_src_get_type(dsc->bg_image_src);
|
||||
lv_result_t res = LV_RESULT_OK;
|
||||
lv_image_header_t header;
|
||||
if(src_type == LV_IMAGE_SRC_VARIABLE || src_type == LV_IMAGE_SRC_FILE) {
|
||||
res = lv_image_decoder_get_info(dsc->bg_image_src, &header);
|
||||
}
|
||||
else if(src_type == LV_IMAGE_SRC_UNKNOWN) {
|
||||
res = LV_RESULT_INVALID;
|
||||
}
|
||||
else {
|
||||
lv_memzero(&header, sizeof(header));
|
||||
}
|
||||
|
||||
if(res == LV_RESULT_OK) {
|
||||
if(src_type == LV_IMAGE_SRC_VARIABLE || src_type == LV_IMAGE_SRC_FILE) {
|
||||
|
||||
if(dsc->bg_image_tiled) {
|
||||
t = lv_draw_add_task(layer, coords);
|
||||
}
|
||||
else {
|
||||
lv_area_t a = {0, 0, header.w - 1, header.h - 1};
|
||||
lv_area_align(coords, &a, LV_ALIGN_CENTER, 0, 0);
|
||||
t = lv_draw_add_task(layer, &a);
|
||||
}
|
||||
|
||||
lv_draw_image_dsc_t * bg_image_dsc = lv_malloc(sizeof(lv_draw_image_dsc_t));
|
||||
lv_draw_image_dsc_init(bg_image_dsc);
|
||||
t->draw_dsc = bg_image_dsc;
|
||||
bg_image_dsc->base = dsc->base;
|
||||
bg_image_dsc->base.dsc_size = sizeof(lv_draw_image_dsc_t);
|
||||
bg_image_dsc->src = dsc->bg_image_src;
|
||||
bg_image_dsc->opa = dsc->bg_image_opa;
|
||||
bg_image_dsc->recolor = dsc->bg_image_recolor;
|
||||
bg_image_dsc->recolor_opa = dsc->bg_image_recolor_opa;
|
||||
bg_image_dsc->tile = dsc->bg_image_tiled;
|
||||
bg_image_dsc->header = header;
|
||||
t->type = LV_DRAW_TASK_TYPE_IMAGE;
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
}
|
||||
else {
|
||||
lv_point_t s;
|
||||
lv_text_get_size(&s, dsc->bg_image_src, dsc->bg_image_symbol_font, 0, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
|
||||
lv_area_t a = {0, 0, s.x - 1, s.y - 1};
|
||||
lv_area_align(coords, &a, LV_ALIGN_CENTER, 0, 0);
|
||||
t = lv_draw_add_task(layer, &a);
|
||||
|
||||
lv_draw_label_dsc_t * bg_label_dsc = lv_malloc(sizeof(lv_draw_label_dsc_t));
|
||||
lv_draw_label_dsc_init(bg_label_dsc);
|
||||
t->draw_dsc = bg_label_dsc;
|
||||
bg_label_dsc->base = dsc->base;
|
||||
bg_label_dsc->base.dsc_size = sizeof(lv_draw_label_dsc_t);
|
||||
bg_label_dsc->color = dsc->bg_image_recolor;
|
||||
bg_label_dsc->font = dsc->bg_image_symbol_font;
|
||||
bg_label_dsc->text = dsc->bg_image_src;
|
||||
t->type = LV_DRAW_TASK_TYPE_LABEL;
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Border*/
|
||||
if(has_border) {
|
||||
t = lv_draw_add_task(layer, coords);
|
||||
lv_draw_border_dsc_t * border_dsc = lv_malloc(sizeof(lv_draw_border_dsc_t));
|
||||
t->draw_dsc = border_dsc;
|
||||
border_dsc->base = dsc->base;
|
||||
border_dsc->base.dsc_size = sizeof(lv_draw_border_dsc_t);
|
||||
border_dsc->radius = dsc->radius;
|
||||
border_dsc->color = dsc->border_color;
|
||||
border_dsc->opa = dsc->border_opa;
|
||||
border_dsc->width = dsc->border_width;
|
||||
border_dsc->side = dsc->border_side;
|
||||
t->type = LV_DRAW_TASK_TYPE_BORDER;
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
}
|
||||
|
||||
/*Outline*/
|
||||
if(has_outline) {
|
||||
lv_area_t outline_coords = *coords;
|
||||
lv_area_increase(&outline_coords, dsc->outline_width + dsc->outline_pad, dsc->outline_width + dsc->outline_pad);
|
||||
t = lv_draw_add_task(layer, &outline_coords);
|
||||
lv_draw_border_dsc_t * outline_dsc = lv_malloc(sizeof(lv_draw_border_dsc_t));
|
||||
t->draw_dsc = outline_dsc;
|
||||
lv_area_increase(&t->_real_area, dsc->outline_width, dsc->outline_width);
|
||||
lv_area_increase(&t->_real_area, dsc->outline_pad, dsc->outline_pad);
|
||||
outline_dsc->base = dsc->base;
|
||||
outline_dsc->base.dsc_size = sizeof(lv_draw_border_dsc_t);
|
||||
outline_dsc->radius = dsc->radius == LV_RADIUS_CIRCLE ? LV_RADIUS_CIRCLE : dsc->radius + dsc->outline_width +
|
||||
dsc->outline_pad;
|
||||
outline_dsc->color = dsc->outline_color;
|
||||
outline_dsc->opa = dsc->outline_opa;
|
||||
outline_dsc->width = dsc->outline_width;
|
||||
outline_dsc->side = LV_BORDER_SIDE_FULL;
|
||||
t->type = LV_DRAW_TASK_TYPE_BORDER;
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
}
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
174
libraries/lvgl/src/draw/lv_draw_rect.h
Normal file
174
libraries/lvgl/src/draw/lv_draw_rect.h
Normal file
@ -0,0 +1,174 @@
|
||||
/**
|
||||
* @file lv_draw_rect.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_RECT_H
|
||||
#define LV_DRAW_RECT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw.h"
|
||||
#include "../misc/lv_color.h"
|
||||
#include "../misc/lv_area.h"
|
||||
#include "../misc/lv_style.h"
|
||||
#include "sw/lv_draw_sw_gradient.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_RADIUS_CIRCLE 0x7FFF /**< A very big radius to always draw as circle*/
|
||||
LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
lv_draw_dsc_base_t base;
|
||||
|
||||
int32_t radius;
|
||||
|
||||
/*Background*/
|
||||
lv_opa_t bg_opa;
|
||||
lv_color_t bg_color; /**< First element of a gradient is a color, so it maps well here*/
|
||||
lv_grad_dsc_t bg_grad;
|
||||
|
||||
/*Background img*/
|
||||
const void * bg_image_src;
|
||||
const void * bg_image_symbol_font;
|
||||
lv_color_t bg_image_recolor;
|
||||
lv_opa_t bg_image_opa;
|
||||
lv_opa_t bg_image_recolor_opa;
|
||||
uint8_t bg_image_tiled;
|
||||
|
||||
/*Border*/
|
||||
lv_color_t border_color;
|
||||
int32_t border_width;
|
||||
lv_opa_t border_opa;
|
||||
lv_border_side_t border_side : 5;
|
||||
uint8_t border_post : 1; /*The border will be drawn later*/
|
||||
|
||||
/*Outline*/
|
||||
lv_color_t outline_color;
|
||||
int32_t outline_width;
|
||||
int32_t outline_pad;
|
||||
lv_opa_t outline_opa;
|
||||
|
||||
/*Shadow*/
|
||||
lv_color_t shadow_color;
|
||||
int32_t shadow_width;
|
||||
int32_t shadow_offset_x;
|
||||
int32_t shadow_offset_y;
|
||||
int32_t shadow_spread;
|
||||
lv_opa_t shadow_opa;
|
||||
} lv_draw_rect_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
lv_draw_dsc_base_t base;
|
||||
|
||||
int32_t radius;
|
||||
|
||||
lv_opa_t opa;
|
||||
lv_color_t color;
|
||||
lv_grad_dsc_t grad;
|
||||
} lv_draw_fill_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
lv_draw_dsc_base_t base;
|
||||
|
||||
int32_t radius;
|
||||
|
||||
lv_color_t color;
|
||||
int32_t width;
|
||||
lv_opa_t opa;
|
||||
lv_border_side_t side : 5;
|
||||
|
||||
} lv_draw_border_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
lv_draw_dsc_base_t base;
|
||||
|
||||
int32_t radius;
|
||||
|
||||
lv_color_t color;
|
||||
int32_t width;
|
||||
int32_t spread;
|
||||
int32_t ofs_x;
|
||||
int32_t ofs_y;
|
||||
lv_opa_t opa;
|
||||
uint8_t bg_cover : 1;
|
||||
} lv_draw_box_shadow_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a rectangle draw descriptor.
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void /* LV_ATTRIBUTE_FAST_MEM */ lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Initialize a fill draw descriptor.
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void lv_draw_fill_dsc_init(lv_draw_fill_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a fill draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_FILL
|
||||
*/
|
||||
lv_draw_fill_dsc_t * lv_draw_task_get_fill_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Initialize a border draw descriptor.
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void lv_draw_border_dsc_init(lv_draw_border_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a border draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_BORDER
|
||||
*/
|
||||
lv_draw_border_dsc_t * lv_draw_task_get_border_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Initialize a box shadow draw descriptor.
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void lv_draw_box_shadow_dsc_init(lv_draw_box_shadow_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Try to get a box shadow draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_BOX_SHADOW
|
||||
*/
|
||||
lv_draw_box_shadow_dsc_t * lv_draw_task_get_box_shadow_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* The rectangle is a wrapper for fill, border, bg. image and box shadow.
|
||||
* Internally fill, border, image and box shadow draw tasks will be created.
|
||||
* @param layer pointer to a layer
|
||||
* @param dsc pointer to an initialized draw descriptor variable
|
||||
* @param coords the coordinates of the rectangle
|
||||
*/
|
||||
void lv_draw_rect(lv_layer_t * layer, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_RECT_H*/
|
||||
78
libraries/lvgl/src/draw/lv_draw_triangle.c
Normal file
78
libraries/lvgl/src/draw/lv_draw_triangle.c
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @file lv_draw_triangle.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../core/lv_obj.h"
|
||||
#include "lv_draw_triangle.h"
|
||||
#include "../misc/lv_math.h"
|
||||
#include "../stdlib/lv_mem.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_draw_triangle_dsc_init(lv_draw_triangle_dsc_t * dsc)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
lv_memzero(dsc, sizeof(lv_draw_triangle_dsc_t));
|
||||
dsc->bg_color = lv_color_white();
|
||||
dsc->bg_grad.stops[0].color = lv_color_white();
|
||||
dsc->bg_grad.stops[1].color = lv_color_black();
|
||||
dsc->bg_grad.stops[1].frac = 0xFF;
|
||||
dsc->bg_grad.stops_count = 2;
|
||||
dsc->bg_opa = LV_OPA_COVER;
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
lv_draw_triangle_dsc_t * lv_draw_task_get_triangle_dsc(lv_draw_task_t * task)
|
||||
{
|
||||
return task->type == LV_DRAW_TASK_TYPE_TRIANGLE ? (lv_draw_triangle_dsc_t *)task->draw_dsc : NULL;
|
||||
}
|
||||
|
||||
void lv_draw_triangle(lv_layer_t * layer, const lv_draw_triangle_dsc_t * dsc)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
lv_area_t a;
|
||||
a.x1 = (int32_t)LV_MIN3(dsc->p[0].x, dsc->p[1].x, dsc->p[2].x);
|
||||
a.y1 = (int32_t)LV_MIN3(dsc->p[0].y, dsc->p[1].y, dsc->p[2].y);
|
||||
a.x2 = (int32_t)LV_MAX3(dsc->p[0].x, dsc->p[1].x, dsc->p[2].x);
|
||||
a.y2 = (int32_t)LV_MAX3(dsc->p[0].y, dsc->p[1].y, dsc->p[2].y);
|
||||
|
||||
lv_draw_task_t * t = lv_draw_add_task(layer, &a);
|
||||
|
||||
t->draw_dsc = lv_malloc(sizeof(*dsc));
|
||||
lv_memcpy(t->draw_dsc, dsc, sizeof(*dsc));
|
||||
t->type = LV_DRAW_TASK_TYPE_TRIANGLE;
|
||||
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
67
libraries/lvgl/src/draw/lv_draw_triangle.h
Normal file
67
libraries/lvgl/src/draw/lv_draw_triangle.h
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @file lv_draw_triangle.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_TRIANGLE_H
|
||||
#define LV_DRAW_TRIANGLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_rect.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct {
|
||||
lv_draw_dsc_base_t base;
|
||||
|
||||
lv_opa_t bg_opa;
|
||||
lv_color_t bg_color;
|
||||
lv_grad_dsc_t bg_grad;
|
||||
|
||||
lv_point_precise_t p[3];
|
||||
} lv_draw_triangle_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a triangle draw descriptor
|
||||
* @param dsc pointer to a draw descriptor
|
||||
*/
|
||||
void lv_draw_triangle_dsc_init(lv_draw_triangle_dsc_t * draw_dsc);
|
||||
|
||||
/**
|
||||
* Try to get a triangle draw descriptor from a draw task.
|
||||
* @param task draw task
|
||||
* @return the task's draw descriptor or NULL if the task is not of type LV_DRAW_TASK_TYPE_TRIANGLE
|
||||
*/
|
||||
lv_draw_triangle_dsc_t * lv_draw_task_get_triangle_dsc(lv_draw_task_t * task);
|
||||
|
||||
/**
|
||||
* Create a triangle draw task
|
||||
* @param layer pointer to a layer
|
||||
* @param dsc pointer to an initialized `lv_draw_triangle_dsc_t` variable
|
||||
*/
|
||||
void lv_draw_triangle(lv_layer_t * layer, const lv_draw_triangle_dsc_t * draw_dsc);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_TRIANGLE_H*/
|
||||
893
libraries/lvgl/src/draw/lv_draw_vector.c
Normal file
893
libraries/lvgl/src/draw/lv_draw_vector.c
Normal file
@ -0,0 +1,893 @@
|
||||
/**
|
||||
* @file lv_draw_vector.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_vector.h"
|
||||
|
||||
#if LV_USE_VECTOR_GRAPHIC
|
||||
|
||||
#include "../misc/lv_ll.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#define MATH_PI 3.14159265358979323846f
|
||||
#define MATH_HALF_PI 1.57079632679489661923f
|
||||
|
||||
#define DEG_TO_RAD 0.017453292519943295769236907684886f
|
||||
#define RAD_TO_DEG 57.295779513082320876798154814105f
|
||||
|
||||
#define MATH_RADIANS(deg) ((deg) * DEG_TO_RAD)
|
||||
#define MATH_DEGRESS(rad) ((rad) * RAD_TO_DEG)
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926f
|
||||
#endif
|
||||
|
||||
#define CHECK_AND_RESIZE_PATH_CONTAINER(P, N) \
|
||||
do { \
|
||||
if ((lv_array_size(&(P)->ops) + (N)) > lv_array_capacity(&(P)->ops)) { \
|
||||
lv_array_resize(&(P)->ops, ((P)->ops.capacity << 1)); \
|
||||
} \
|
||||
if ((lv_array_size(&(P)->points) + (N)) > lv_array_capacity(&(P)->points)) { \
|
||||
lv_array_resize(&(P)->points, ((P)->points.capacity << 1)); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
lv_vector_path_t * path;
|
||||
lv_vector_draw_dsc_t dsc;
|
||||
} _lv_vector_draw_task;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
static bool _is_identity_or_translation(const lv_matrix_t * matrix)
|
||||
{
|
||||
return (matrix->m[0][0] == 1.0f &&
|
||||
matrix->m[0][1] == 0.0f &&
|
||||
matrix->m[1][0] == 0.0f &&
|
||||
matrix->m[1][1] == 1.0f &&
|
||||
matrix->m[2][0] == 0.0f &&
|
||||
matrix->m[2][1] == 0.0f &&
|
||||
matrix->m[2][2] == 1.0f);
|
||||
}
|
||||
|
||||
static void _multiply_matrix(lv_matrix_t * matrix, const lv_matrix_t * mul)
|
||||
{
|
||||
/*TODO: use NEON to optimize this function on ARM architecture.*/
|
||||
lv_matrix_t tmp;
|
||||
|
||||
for(int y = 0; y < 3; y++) {
|
||||
for(int x = 0; x < 3; x++) {
|
||||
tmp.m[y][x] = (matrix->m[y][0] * mul->m[0][x])
|
||||
+ (matrix->m[y][1] * mul->m[1][x])
|
||||
+ (matrix->m[y][2] * mul->m[2][x]);
|
||||
}
|
||||
}
|
||||
|
||||
lv_memcpy(matrix, &tmp, sizeof(lv_matrix_t));
|
||||
}
|
||||
|
||||
static void _copy_draw_dsc(lv_vector_draw_dsc_t * dst, const lv_vector_draw_dsc_t * src)
|
||||
{
|
||||
dst->fill_dsc.style = src->fill_dsc.style;
|
||||
dst->fill_dsc.color = src->fill_dsc.color;
|
||||
dst->fill_dsc.opa = src->fill_dsc.opa;
|
||||
dst->fill_dsc.fill_rule = src->fill_dsc.fill_rule;
|
||||
dst->fill_dsc.gradient.style = src->fill_dsc.gradient.style;
|
||||
dst->fill_dsc.gradient.cx = src->fill_dsc.gradient.cx;
|
||||
dst->fill_dsc.gradient.cy = src->fill_dsc.gradient.cy;
|
||||
dst->fill_dsc.gradient.cr = src->fill_dsc.gradient.cr;
|
||||
dst->fill_dsc.gradient.spread = src->fill_dsc.gradient.spread;
|
||||
lv_memcpy(&(dst->fill_dsc.gradient.grad), &(src->fill_dsc.gradient.grad), sizeof(lv_grad_dsc_t));
|
||||
lv_memcpy(&(dst->fill_dsc.img_dsc), &(src->fill_dsc.img_dsc), sizeof(lv_draw_image_dsc_t));
|
||||
lv_memcpy(&(dst->fill_dsc.matrix), &(src->fill_dsc.matrix), sizeof(lv_matrix_t));
|
||||
|
||||
dst->stroke_dsc.style = src->stroke_dsc.style;
|
||||
dst->stroke_dsc.color = src->stroke_dsc.color;
|
||||
dst->stroke_dsc.opa = src->stroke_dsc.opa;
|
||||
dst->stroke_dsc.width = src->stroke_dsc.width;
|
||||
dst->stroke_dsc.cap = src->stroke_dsc.cap;
|
||||
dst->stroke_dsc.join = src->stroke_dsc.join;
|
||||
dst->stroke_dsc.miter_limit = src->stroke_dsc.miter_limit;
|
||||
lv_array_copy(&(dst->stroke_dsc.dash_pattern), &(src->stroke_dsc.dash_pattern));
|
||||
dst->stroke_dsc.gradient.style = src->stroke_dsc.gradient.style;
|
||||
dst->stroke_dsc.gradient.cx = src->stroke_dsc.gradient.cx;
|
||||
dst->stroke_dsc.gradient.cy = src->stroke_dsc.gradient.cy;
|
||||
dst->stroke_dsc.gradient.cr = src->stroke_dsc.gradient.cr;
|
||||
dst->stroke_dsc.gradient.spread = src->fill_dsc.gradient.spread;
|
||||
lv_memcpy(&(dst->stroke_dsc.gradient.grad), &(src->stroke_dsc.gradient.grad), sizeof(lv_grad_dsc_t));
|
||||
lv_memcpy(&(dst->stroke_dsc.matrix), &(src->stroke_dsc.matrix), sizeof(lv_matrix_t));
|
||||
|
||||
dst->blend_mode = src->blend_mode;
|
||||
lv_memcpy(&(dst->matrix), &(src->matrix), sizeof(lv_matrix_t));
|
||||
lv_area_copy(&(dst->scissor_area), &(src->scissor_area));
|
||||
}
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/* matrix functions */
|
||||
void lv_matrix_identity(lv_matrix_t * matrix)
|
||||
{
|
||||
matrix->m[0][0] = 1.0f;
|
||||
matrix->m[0][1] = 0.0f;
|
||||
matrix->m[0][2] = 0.0f;
|
||||
matrix->m[1][0] = 0.0f;
|
||||
matrix->m[1][1] = 1.0f;
|
||||
matrix->m[1][2] = 0.0f;
|
||||
matrix->m[2][0] = 0.0f;
|
||||
matrix->m[2][1] = 0.0f;
|
||||
matrix->m[2][2] = 1.0f;
|
||||
}
|
||||
|
||||
void lv_matrix_translate(lv_matrix_t * matrix, float dx, float dy)
|
||||
{
|
||||
if(_is_identity_or_translation(matrix)) {
|
||||
/*optimization for matrix translation.*/
|
||||
matrix->m[0][2] += dx;
|
||||
matrix->m[1][2] += dy;
|
||||
return;
|
||||
}
|
||||
|
||||
lv_matrix_t tlm = {{
|
||||
{1.0f, 0.0f, dx},
|
||||
{0.0f, 1.0f, dy},
|
||||
{0.0f, 0.0f, 1.0f},
|
||||
}
|
||||
};
|
||||
|
||||
_multiply_matrix(matrix, &tlm);
|
||||
}
|
||||
|
||||
void lv_matrix_scale(lv_matrix_t * matrix, float scale_x, float scale_y)
|
||||
{
|
||||
lv_matrix_t scm = {{
|
||||
{scale_x, 0.0f, 0.0f},
|
||||
{0.0f, scale_y, 0.0f},
|
||||
{0.0f, 0.0f, 1.0f},
|
||||
}
|
||||
};
|
||||
|
||||
_multiply_matrix(matrix, &scm);
|
||||
}
|
||||
|
||||
void lv_matrix_rotate(lv_matrix_t * matrix, float degree)
|
||||
{
|
||||
float radian = degree / 180.0f * (float)M_PI;
|
||||
float cos_r = cosf(radian);
|
||||
float sin_r = sinf(radian);
|
||||
|
||||
lv_matrix_t rtm = {{
|
||||
{cos_r, -sin_r, 0.0f},
|
||||
{sin_r, cos_r, 0.0f},
|
||||
{0.0f, 0.0f, 1.0f},
|
||||
}
|
||||
};
|
||||
|
||||
_multiply_matrix(matrix, &rtm);
|
||||
}
|
||||
|
||||
void lv_matrix_skew(lv_matrix_t * matrix, float skew_x, float skew_y)
|
||||
{
|
||||
float rskew_x = skew_x / 180.0f * (float)M_PI;
|
||||
float rskew_y = skew_y / 180.0f * (float)M_PI;
|
||||
float tan_x = tanf(rskew_x);
|
||||
float tan_y = tanf(rskew_y);
|
||||
|
||||
lv_matrix_t skm = {{
|
||||
{1.0f, tan_x, 0.0f},
|
||||
{tan_y, 1.0f, 0.0f},
|
||||
{0.0f, 0.0f, 1.0f},
|
||||
}
|
||||
};
|
||||
|
||||
_multiply_matrix(matrix, &skm);
|
||||
}
|
||||
|
||||
void lv_matrix_multiply(lv_matrix_t * matrix, const lv_matrix_t * m)
|
||||
{
|
||||
_multiply_matrix(matrix, m);
|
||||
}
|
||||
|
||||
void lv_matrix_transform_point(const lv_matrix_t * matrix, lv_fpoint_t * point)
|
||||
{
|
||||
float x = point->x;
|
||||
float y = point->y;
|
||||
|
||||
point->x = x * matrix->m[0][0] + y * matrix->m[1][0] + matrix->m[0][2];
|
||||
point->y = x * matrix->m[0][1] + y * matrix->m[1][1] + matrix->m[1][2];
|
||||
}
|
||||
|
||||
void lv_matrix_transform_path(const lv_matrix_t * matrix, lv_vector_path_t * path)
|
||||
{
|
||||
lv_fpoint_t * pt = lv_array_front(&path->points);
|
||||
uint32_t size = lv_array_size(&path->points);
|
||||
for(uint32_t i = 0; i < size; i++) {
|
||||
lv_matrix_transform_point(matrix, &pt[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* path functions */
|
||||
lv_vector_path_t * lv_vector_path_create(lv_vector_path_quality_t quality)
|
||||
{
|
||||
lv_vector_path_t * path = lv_malloc(sizeof(lv_vector_path_t));
|
||||
LV_ASSERT_MALLOC(path);
|
||||
lv_memzero(path, sizeof(lv_vector_path_t));
|
||||
path->quality = quality;
|
||||
lv_array_init(&path->ops, 8, sizeof(uint8_t));
|
||||
lv_array_init(&path->points, 8, sizeof(lv_fpoint_t));
|
||||
return path;
|
||||
}
|
||||
|
||||
void lv_vector_path_copy(lv_vector_path_t * target_path, const lv_vector_path_t * path)
|
||||
{
|
||||
target_path->quality = path->quality;
|
||||
lv_array_copy(&target_path->ops, &path->ops);
|
||||
lv_array_copy(&target_path->points, &path->points);
|
||||
}
|
||||
|
||||
void lv_vector_path_clear(lv_vector_path_t * path)
|
||||
{
|
||||
lv_array_clear(&path->ops);
|
||||
lv_array_clear(&path->points);
|
||||
}
|
||||
|
||||
void lv_vector_path_delete(lv_vector_path_t * path)
|
||||
{
|
||||
lv_array_deinit(&path->ops);
|
||||
lv_array_deinit(&path->points);
|
||||
lv_free(path);
|
||||
}
|
||||
|
||||
void lv_vector_path_move_to(lv_vector_path_t * path, const lv_fpoint_t * p)
|
||||
{
|
||||
CHECK_AND_RESIZE_PATH_CONTAINER(path, 1);
|
||||
|
||||
uint8_t op = LV_VECTOR_PATH_OP_MOVE_TO;
|
||||
lv_array_push_back(&path->ops, &op);
|
||||
lv_array_push_back(&path->points, p);
|
||||
}
|
||||
|
||||
void lv_vector_path_line_to(lv_vector_path_t * path, const lv_fpoint_t * p)
|
||||
{
|
||||
if(lv_array_is_empty(&path->ops)) {
|
||||
/*first op must be move_to*/
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_AND_RESIZE_PATH_CONTAINER(path, 1);
|
||||
|
||||
uint8_t op = LV_VECTOR_PATH_OP_LINE_TO;
|
||||
lv_array_push_back(&path->ops, &op);
|
||||
lv_array_push_back(&path->points, p);
|
||||
}
|
||||
|
||||
void lv_vector_path_quad_to(lv_vector_path_t * path, const lv_fpoint_t * p1, const lv_fpoint_t * p2)
|
||||
{
|
||||
if(lv_array_is_empty(&path->ops)) {
|
||||
/*first op must be move_to*/
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_AND_RESIZE_PATH_CONTAINER(path, 2);
|
||||
|
||||
uint8_t op = LV_VECTOR_PATH_OP_QUAD_TO;
|
||||
lv_array_push_back(&path->ops, &op);
|
||||
lv_array_push_back(&path->points, p1);
|
||||
lv_array_push_back(&path->points, p2);
|
||||
}
|
||||
|
||||
void lv_vector_path_cubic_to(lv_vector_path_t * path, const lv_fpoint_t * p1, const lv_fpoint_t * p2,
|
||||
const lv_fpoint_t * p3)
|
||||
{
|
||||
if(lv_array_is_empty(&path->ops)) {
|
||||
/*first op must be move_to*/
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_AND_RESIZE_PATH_CONTAINER(path, 3);
|
||||
|
||||
uint8_t op = LV_VECTOR_PATH_OP_CUBIC_TO;
|
||||
lv_array_push_back(&path->ops, &op);
|
||||
lv_array_push_back(&path->points, p1);
|
||||
lv_array_push_back(&path->points, p2);
|
||||
lv_array_push_back(&path->points, p3);
|
||||
}
|
||||
|
||||
void lv_vector_path_close(lv_vector_path_t * path)
|
||||
{
|
||||
if(lv_array_is_empty(&path->ops)) {
|
||||
/*first op must be move_to*/
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_AND_RESIZE_PATH_CONTAINER(path, 1);
|
||||
|
||||
uint8_t op = LV_VECTOR_PATH_OP_CLOSE;
|
||||
lv_array_push_back(&path->ops, &op);
|
||||
}
|
||||
|
||||
void lv_vector_path_get_bounding(const lv_vector_path_t * path, lv_area_t * area)
|
||||
{
|
||||
LV_ASSERT_NULL(path);
|
||||
LV_ASSERT_NULL(area);
|
||||
|
||||
uint32_t len = lv_array_size(&path->points);
|
||||
if(len == 0) {
|
||||
lv_memzero(area, sizeof(lv_area_t));
|
||||
return;
|
||||
}
|
||||
|
||||
lv_fpoint_t * p = lv_array_front(&path->points);
|
||||
float x1 = p[0].x;
|
||||
float x2 = p[0].x;
|
||||
float y1 = p[0].y;
|
||||
float y2 = p[0].y;
|
||||
|
||||
for(uint32_t i = 1; i < len; i++) {
|
||||
if(p[i].x < x1) x1 = p[i].x;
|
||||
if(p[i].y < y1) y1 = p[i].y;
|
||||
if(p[i].x > x2) x2 = p[i].x;
|
||||
if(p[i].y > y2) y2 = p[i].y;
|
||||
}
|
||||
|
||||
area->x1 = (int32_t)x1;
|
||||
area->y1 = (int32_t)y1;
|
||||
area->x2 = (int32_t)x2;
|
||||
area->y2 = (int32_t)y2;
|
||||
}
|
||||
|
||||
void lv_vector_path_append_rect(lv_vector_path_t * path, const lv_area_t * rect, float rx, float ry)
|
||||
{
|
||||
float x = rect->x1;
|
||||
float y = rect->y1;
|
||||
float w = (float)lv_area_get_width(rect);
|
||||
float h = (float)lv_area_get_height(rect);
|
||||
|
||||
float hw = w * 0.5f;
|
||||
float hh = h * 0.5f;
|
||||
|
||||
if(rx > hw) rx = hw;
|
||||
if(ry > hh) ry = hh;
|
||||
|
||||
if(rx == 0 && ry == 0) {
|
||||
lv_fpoint_t pt = {x, y};
|
||||
lv_vector_path_move_to(path, &pt);
|
||||
pt.x += w;
|
||||
lv_vector_path_line_to(path, &pt);
|
||||
pt.y += h;
|
||||
lv_vector_path_line_to(path, &pt);
|
||||
pt.x -= w;
|
||||
lv_vector_path_line_to(path, &pt);
|
||||
lv_vector_path_close(path);
|
||||
}
|
||||
else if(rx == hw && ry == hh) {
|
||||
lv_fpoint_t pt = {x + w * 0.5f, y + h * 0.5f};
|
||||
lv_vector_path_append_circle(path, &pt, rx, ry);
|
||||
}
|
||||
else {
|
||||
float hrx = rx * 0.5f;
|
||||
float hry = ry * 0.5f;
|
||||
lv_fpoint_t pt, pt2, pt3;
|
||||
|
||||
pt.x = x + rx;
|
||||
pt.y = y;
|
||||
lv_vector_path_move_to(path, &pt);
|
||||
|
||||
pt.x = x + w - rx;
|
||||
pt.y = y;
|
||||
lv_vector_path_line_to(path, &pt);
|
||||
|
||||
pt.x = x + w - rx + hrx;
|
||||
pt.y = y;
|
||||
pt2.x = x + w;
|
||||
pt2.y = y + ry - hry;
|
||||
pt3.x = x + w;
|
||||
pt3.y = y + ry;
|
||||
lv_vector_path_cubic_to(path, &pt, &pt2, &pt3);
|
||||
|
||||
pt.x = x + w;
|
||||
pt.y = y + h - ry;
|
||||
lv_vector_path_line_to(path, &pt);
|
||||
|
||||
pt.x = x + w;
|
||||
pt.y = y + h - ry + hry;
|
||||
pt2.x = x + w - rx + hrx;
|
||||
pt2.y = y + h;
|
||||
pt3.x = x + w - rx;
|
||||
pt3.y = y + h;
|
||||
lv_vector_path_cubic_to(path, &pt, &pt2, &pt3);
|
||||
|
||||
pt.x = x + rx;
|
||||
pt.y = y + h;
|
||||
lv_vector_path_line_to(path, &pt);
|
||||
|
||||
pt.x = x + rx - hrx;
|
||||
pt.y = y + h;
|
||||
pt2.x = x;
|
||||
pt2.y = y + h - ry + hry;
|
||||
pt3.x = x;
|
||||
pt3.y = y + h - ry;
|
||||
lv_vector_path_cubic_to(path, &pt, &pt2, &pt3);
|
||||
|
||||
pt.x = x;
|
||||
pt.y = y + ry;
|
||||
lv_vector_path_line_to(path, &pt);
|
||||
|
||||
pt.x = x;
|
||||
pt.y = y + ry - hry;
|
||||
pt2.x = x + rx - hrx;
|
||||
pt2.y = y;
|
||||
pt3.x = x + rx;
|
||||
pt3.y = y;
|
||||
lv_vector_path_cubic_to(path, &pt, &pt2, &pt3);
|
||||
lv_vector_path_close(path);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_vector_path_append_circle(lv_vector_path_t * path, const lv_fpoint_t * c, float rx, float ry)
|
||||
{
|
||||
float krx = rx * 0.552284f;
|
||||
float kry = ry * 0.552284f;
|
||||
float cx = c->x;
|
||||
float cy = c->y;
|
||||
|
||||
lv_fpoint_t pt, pt2, pt3;
|
||||
pt.x = cx;
|
||||
pt.y = cy - ry;
|
||||
lv_vector_path_move_to(path, &pt);
|
||||
|
||||
pt.x = cx + krx;
|
||||
pt.y = cy - ry;
|
||||
pt2.x = cx + rx;
|
||||
pt2.y = cy - kry;
|
||||
pt3.x = cx + rx;
|
||||
pt3.y = cy;
|
||||
lv_vector_path_cubic_to(path, &pt, &pt2, &pt3);
|
||||
|
||||
pt.x = cx + rx;
|
||||
pt.y = cy + kry;
|
||||
pt2.x = cx + krx;
|
||||
pt2.y = cy + ry;
|
||||
pt3.x = cx;
|
||||
pt3.y = cy + ry;
|
||||
lv_vector_path_cubic_to(path, &pt, &pt2, &pt3);
|
||||
|
||||
pt.x = cx - krx;
|
||||
pt.y = cy + ry;
|
||||
pt2.x = cx - rx;
|
||||
pt2.y = cy + kry;
|
||||
pt3.x = cx - rx;
|
||||
pt3.y = cy;
|
||||
lv_vector_path_cubic_to(path, &pt, &pt2, &pt3);
|
||||
|
||||
pt.x = cx - rx;
|
||||
pt.y = cy - kry;
|
||||
pt2.x = cx - krx;
|
||||
pt2.y = cy - ry;
|
||||
pt3.x = cx;
|
||||
pt3.y = cy - ry;
|
||||
lv_vector_path_cubic_to(path, &pt, &pt2, &pt3);
|
||||
|
||||
lv_vector_path_close(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a arc to the path
|
||||
* @param path pointer to a path
|
||||
* @param c pointer to a `lv_fpoint_t` variable for center of the circle
|
||||
* @param radius the radius for arc
|
||||
* @param start_angle the start angle for arc
|
||||
* @param sweep the sweep angle for arc, could be negative
|
||||
* @param pie true: draw a pie, false: draw a arc
|
||||
*/
|
||||
void lv_vector_path_append_arc(lv_vector_path_t * path, const lv_fpoint_t * c, float radius, float start_angle,
|
||||
float sweep, bool pie)
|
||||
{
|
||||
float cx = c->x;
|
||||
float cy = c->y;
|
||||
|
||||
/* just circle */
|
||||
if(sweep >= 360.0f || sweep <= -360.0f) {
|
||||
lv_vector_path_append_circle(path, c, radius, radius);
|
||||
return;
|
||||
}
|
||||
|
||||
start_angle = MATH_RADIANS(start_angle);
|
||||
sweep = MATH_RADIANS(sweep);
|
||||
|
||||
int n_curves = (int)ceil(fabsf(sweep / MATH_HALF_PI));
|
||||
float sweep_sign = sweep < 0 ? -1.f : 1.f;
|
||||
float fract = fmodf(sweep, MATH_HALF_PI);
|
||||
fract = (fabsf(fract) < FLT_EPSILON) ? MATH_HALF_PI * sweep_sign : fract;
|
||||
|
||||
/* Start from here */
|
||||
lv_fpoint_t start = {
|
||||
.x = radius * cosf(start_angle),
|
||||
.y = radius * sinf(start_angle),
|
||||
};
|
||||
|
||||
if(pie) {
|
||||
lv_vector_path_move_to(path, &(lv_fpoint_t) {
|
||||
cx, cy
|
||||
});
|
||||
lv_vector_path_line_to(path, &(lv_fpoint_t) {
|
||||
start.x + cx, start.y + cy
|
||||
});
|
||||
}
|
||||
|
||||
for(int i = 0; i < n_curves; ++i) {
|
||||
float end_angle = start_angle + ((i != n_curves - 1) ? MATH_HALF_PI * sweep_sign : fract);
|
||||
float end_x = radius * cosf(end_angle);
|
||||
float end_y = radius * sinf(end_angle);
|
||||
|
||||
/* variables needed to calculate bezier control points */
|
||||
|
||||
/** get bezier control points using article:
|
||||
* (http://itc.ktu.lt/index.php/ITC/article/view/11812/6479)
|
||||
*/
|
||||
float ax = start.x;
|
||||
float ay = start.y;
|
||||
float bx = end_x;
|
||||
float by = end_y;
|
||||
float q1 = ax * ax + ay * ay;
|
||||
float q2 = ax * bx + ay * by + q1;
|
||||
float k2 = (4.0f / 3.0f) * ((sqrtf(2 * q1 * q2) - q2) / (ax * by - ay * bx));
|
||||
|
||||
/* Next start point is the current end point */
|
||||
start.x = end_x;
|
||||
start.y = end_y;
|
||||
|
||||
end_x += cx;
|
||||
end_y += cy;
|
||||
|
||||
lv_fpoint_t ctrl1 = {ax - k2 * ay + cx, ay + k2 * ax + cy};
|
||||
lv_fpoint_t ctrl2 = {bx + k2 * by + cx, by - k2 * bx + cy};
|
||||
lv_fpoint_t end = {end_x, end_y};
|
||||
lv_vector_path_cubic_to(path, &ctrl1, &ctrl2, &end);
|
||||
start_angle = end_angle;
|
||||
}
|
||||
|
||||
if(pie) {
|
||||
lv_vector_path_close(path);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_vector_path_append_path(lv_vector_path_t * path, const lv_vector_path_t * subpath)
|
||||
{
|
||||
uint32_t ops_size = lv_array_size(&path->ops);
|
||||
uint32_t nops_size = lv_array_size(&subpath->ops);
|
||||
uint32_t point_size = lv_array_size(&path->points);
|
||||
uint32_t npoint_size = lv_array_size(&subpath->points);
|
||||
|
||||
lv_array_concat(&path->ops, &subpath->ops);
|
||||
path->ops.size = ops_size + nops_size;
|
||||
|
||||
lv_array_concat(&path->points, &subpath->points);
|
||||
path->points.size = point_size + npoint_size;
|
||||
}
|
||||
|
||||
/* draw dsc functions */
|
||||
|
||||
lv_vector_dsc_t * lv_vector_dsc_create(lv_layer_t * layer)
|
||||
{
|
||||
lv_vector_dsc_t * dsc = lv_malloc(sizeof(lv_vector_dsc_t));
|
||||
LV_ASSERT_MALLOC(dsc);
|
||||
lv_memzero(dsc, sizeof(lv_vector_dsc_t));
|
||||
|
||||
dsc->layer = layer;
|
||||
|
||||
lv_vector_fill_dsc_t * fill_dsc = &(dsc->current_dsc.fill_dsc);
|
||||
fill_dsc->style = LV_VECTOR_DRAW_STYLE_SOLID;
|
||||
fill_dsc->color = lv_color_to_32(lv_color_black(), 0xFF);
|
||||
fill_dsc->opa = LV_OPA_COVER;
|
||||
fill_dsc->fill_rule = LV_VECTOR_FILL_NONZERO;
|
||||
lv_matrix_identity(&(fill_dsc->matrix)); /*identity matrix*/
|
||||
|
||||
lv_vector_stroke_dsc_t * stroke_dsc = &(dsc->current_dsc.stroke_dsc);
|
||||
stroke_dsc->style = LV_VECTOR_DRAW_STYLE_SOLID;
|
||||
stroke_dsc->color = lv_color_to_32(lv_color_black(), 0xFF);
|
||||
stroke_dsc->opa = LV_OPA_0; /*default no stroke*/
|
||||
stroke_dsc->width = 1.0f;
|
||||
stroke_dsc->cap = LV_VECTOR_STROKE_CAP_BUTT;
|
||||
stroke_dsc->join = LV_VECTOR_STROKE_JOIN_MITER;
|
||||
stroke_dsc->miter_limit = 4.0f;
|
||||
lv_matrix_identity(&(stroke_dsc->matrix)); /*identity matrix*/
|
||||
|
||||
dsc->current_dsc.blend_mode = LV_VECTOR_BLEND_SRC_OVER;
|
||||
dsc->current_dsc.scissor_area = layer->_clip_area;
|
||||
lv_matrix_identity(&(dsc->current_dsc.matrix)); /*identity matrix*/
|
||||
dsc->tasks.task_list = NULL;
|
||||
return dsc;
|
||||
}
|
||||
|
||||
void lv_vector_dsc_delete(lv_vector_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->tasks.task_list) {
|
||||
lv_ll_t * task_list = dsc->tasks.task_list;
|
||||
_lv_vector_for_each_destroy_tasks(task_list, NULL, NULL);
|
||||
dsc->tasks.task_list = NULL;
|
||||
}
|
||||
lv_array_deinit(&(dsc->current_dsc.stroke_dsc.dash_pattern));
|
||||
lv_free(dsc);
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_blend_mode(lv_vector_dsc_t * dsc, lv_vector_blend_t blend)
|
||||
{
|
||||
dsc->current_dsc.blend_mode = blend;
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_transform(lv_vector_dsc_t * dsc, const lv_matrix_t * matrix)
|
||||
{
|
||||
lv_memcpy(&(dsc->current_dsc.matrix), matrix, sizeof(lv_matrix_t));
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_fill_color(lv_vector_dsc_t * dsc, lv_color_t color)
|
||||
{
|
||||
dsc->current_dsc.fill_dsc.style = LV_VECTOR_DRAW_STYLE_SOLID;
|
||||
dsc->current_dsc.fill_dsc.color = lv_color_to_32(color, 0xFF);
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_fill_color32(lv_vector_dsc_t * dsc, lv_color32_t color)
|
||||
{
|
||||
dsc->current_dsc.fill_dsc.style = LV_VECTOR_DRAW_STYLE_SOLID;
|
||||
dsc->current_dsc.fill_dsc.color = color;
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_fill_opa(lv_vector_dsc_t * dsc, lv_opa_t opa)
|
||||
{
|
||||
dsc->current_dsc.fill_dsc.opa = opa;
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_fill_rule(lv_vector_dsc_t * dsc, lv_vector_fill_t rule)
|
||||
{
|
||||
dsc->current_dsc.fill_dsc.fill_rule = rule;
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_fill_image(lv_vector_dsc_t * dsc, const lv_draw_image_dsc_t * img_dsc)
|
||||
{
|
||||
dsc->current_dsc.fill_dsc.style = LV_VECTOR_DRAW_STYLE_PATTERN;
|
||||
lv_memcpy(&(dsc->current_dsc.fill_dsc.img_dsc), img_dsc, sizeof(lv_draw_image_dsc_t));
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_fill_linear_gradient(lv_vector_dsc_t * dsc, const lv_grad_dsc_t * grad,
|
||||
lv_vector_gradient_spread_t spread)
|
||||
{
|
||||
dsc->current_dsc.fill_dsc.style = LV_VECTOR_DRAW_STYLE_GRADIENT;
|
||||
dsc->current_dsc.fill_dsc.gradient.style = LV_VECTOR_GRADIENT_STYLE_LINEAR;
|
||||
dsc->current_dsc.fill_dsc.gradient.spread = spread;
|
||||
lv_memcpy(&(dsc->current_dsc.fill_dsc.gradient.grad), grad, sizeof(lv_grad_dsc_t));
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_fill_radial_gradient(lv_vector_dsc_t * dsc, const lv_grad_dsc_t * grad, float cx, float cy,
|
||||
float radius, lv_vector_gradient_spread_t spread)
|
||||
{
|
||||
dsc->current_dsc.fill_dsc.style = LV_VECTOR_DRAW_STYLE_GRADIENT;
|
||||
dsc->current_dsc.fill_dsc.gradient.style = LV_VECTOR_GRADIENT_STYLE_RADIAL;
|
||||
dsc->current_dsc.fill_dsc.gradient.cx = cx;
|
||||
dsc->current_dsc.fill_dsc.gradient.cy = cy;
|
||||
dsc->current_dsc.fill_dsc.gradient.cr = radius;
|
||||
dsc->current_dsc.fill_dsc.gradient.spread = spread;
|
||||
lv_memcpy(&(dsc->current_dsc.fill_dsc.gradient.grad), grad, sizeof(lv_grad_dsc_t));
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_fill_transform(lv_vector_dsc_t * dsc, const lv_matrix_t * matrix)
|
||||
{
|
||||
lv_memcpy(&(dsc->current_dsc.fill_dsc.matrix), matrix, sizeof(lv_matrix_t));
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_stroke_transform(lv_vector_dsc_t * dsc, const lv_matrix_t * matrix)
|
||||
{
|
||||
lv_memcpy(&(dsc->current_dsc.stroke_dsc.matrix), matrix, sizeof(lv_matrix_t));
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_stroke_color32(lv_vector_dsc_t * dsc, lv_color32_t color)
|
||||
{
|
||||
dsc->current_dsc.stroke_dsc.style = LV_VECTOR_DRAW_STYLE_SOLID;
|
||||
dsc->current_dsc.stroke_dsc.color = color;
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_stroke_color(lv_vector_dsc_t * dsc, lv_color_t color)
|
||||
{
|
||||
dsc->current_dsc.stroke_dsc.style = LV_VECTOR_DRAW_STYLE_SOLID;
|
||||
dsc->current_dsc.stroke_dsc.color = lv_color_to_32(color, 0xFF);
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_stroke_opa(lv_vector_dsc_t * dsc, lv_opa_t opa)
|
||||
{
|
||||
dsc->current_dsc.stroke_dsc.opa = opa;
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_stroke_width(lv_vector_dsc_t * dsc, float width)
|
||||
{
|
||||
dsc->current_dsc.stroke_dsc.width = width;
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_stroke_dash(lv_vector_dsc_t * dsc, float * dash_pattern, uint16_t dash_count)
|
||||
{
|
||||
lv_array_t * dash_array = &(dsc->current_dsc.stroke_dsc.dash_pattern);
|
||||
if(dash_pattern) {
|
||||
lv_array_clear(dash_array);
|
||||
if(lv_array_capacity(dash_array) == 0) {
|
||||
lv_array_init(dash_array, dash_count, sizeof(float));
|
||||
}
|
||||
else {
|
||||
lv_array_resize(dash_array, dash_count);
|
||||
}
|
||||
for(uint16_t i = 0; i < dash_count; i++) {
|
||||
lv_array_push_back(dash_array, &dash_pattern[i]);
|
||||
}
|
||||
}
|
||||
else { /*clear dash*/
|
||||
lv_array_clear(dash_array);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_stroke_cap(lv_vector_dsc_t * dsc, lv_vector_stroke_cap_t cap)
|
||||
{
|
||||
dsc->current_dsc.stroke_dsc.cap = cap;
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_stroke_join(lv_vector_dsc_t * dsc, lv_vector_stroke_join_t join)
|
||||
{
|
||||
dsc->current_dsc.stroke_dsc.join = join;
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_stroke_miter_limit(lv_vector_dsc_t * dsc, uint16_t miter_limit)
|
||||
{
|
||||
dsc->current_dsc.stroke_dsc.miter_limit = miter_limit;
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_stroke_linear_gradient(lv_vector_dsc_t * dsc, const lv_grad_dsc_t * grad,
|
||||
lv_vector_gradient_spread_t spread)
|
||||
{
|
||||
dsc->current_dsc.stroke_dsc.style = LV_VECTOR_DRAW_STYLE_GRADIENT;
|
||||
dsc->current_dsc.stroke_dsc.gradient.style = LV_VECTOR_GRADIENT_STYLE_LINEAR;
|
||||
dsc->current_dsc.stroke_dsc.gradient.spread = spread;
|
||||
lv_memcpy(&(dsc->current_dsc.stroke_dsc.gradient.grad), grad, sizeof(lv_grad_dsc_t));
|
||||
}
|
||||
|
||||
void lv_vector_dsc_set_stroke_radial_gradient(lv_vector_dsc_t * dsc, const lv_grad_dsc_t * grad, float cx, float cy,
|
||||
float radius, lv_vector_gradient_spread_t spread)
|
||||
{
|
||||
dsc->current_dsc.stroke_dsc.style = LV_VECTOR_DRAW_STYLE_GRADIENT;
|
||||
dsc->current_dsc.stroke_dsc.gradient.style = LV_VECTOR_GRADIENT_STYLE_RADIAL;
|
||||
dsc->current_dsc.stroke_dsc.gradient.cx = cx;
|
||||
dsc->current_dsc.stroke_dsc.gradient.cy = cy;
|
||||
dsc->current_dsc.stroke_dsc.gradient.cr = radius;
|
||||
dsc->current_dsc.stroke_dsc.gradient.spread = spread;
|
||||
lv_memcpy(&(dsc->current_dsc.stroke_dsc.gradient.grad), grad, sizeof(lv_grad_dsc_t));
|
||||
}
|
||||
|
||||
/* draw functions */
|
||||
void lv_vector_dsc_add_path(lv_vector_dsc_t * dsc, const lv_vector_path_t * path)
|
||||
{
|
||||
lv_area_t rect;
|
||||
if(!_lv_area_intersect(&rect, &(dsc->layer->_clip_area), &(dsc->current_dsc.scissor_area))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(dsc->current_dsc.fill_dsc.opa == 0
|
||||
&& dsc->current_dsc.stroke_dsc.opa == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!dsc->tasks.task_list) {
|
||||
dsc->tasks.task_list = lv_malloc(sizeof(lv_ll_t));
|
||||
LV_ASSERT_MALLOC(dsc->tasks.task_list);
|
||||
_lv_ll_init(dsc->tasks.task_list, sizeof(_lv_vector_draw_task));
|
||||
}
|
||||
|
||||
_lv_vector_draw_task * new_task = (_lv_vector_draw_task *)_lv_ll_ins_tail(dsc->tasks.task_list);
|
||||
lv_memset(new_task, 0, sizeof(_lv_vector_draw_task));
|
||||
|
||||
new_task->path = lv_vector_path_create(0);
|
||||
|
||||
_copy_draw_dsc(&(new_task->dsc), &(dsc->current_dsc));
|
||||
lv_vector_path_copy(new_task->path, path);
|
||||
new_task->dsc.scissor_area = rect;
|
||||
}
|
||||
|
||||
void lv_vector_clear_area(lv_vector_dsc_t * dsc, const lv_area_t * rect)
|
||||
{
|
||||
lv_area_t r;
|
||||
if(!_lv_area_intersect(&r, &(dsc->layer->_clip_area), &(dsc->current_dsc.scissor_area))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!dsc->tasks.task_list) {
|
||||
dsc->tasks.task_list = lv_malloc(sizeof(lv_ll_t));
|
||||
LV_ASSERT_MALLOC(dsc->tasks.task_list);
|
||||
_lv_ll_init(dsc->tasks.task_list, sizeof(_lv_vector_draw_task));
|
||||
}
|
||||
|
||||
_lv_vector_draw_task * new_task = (_lv_vector_draw_task *)_lv_ll_ins_tail(dsc->tasks.task_list);
|
||||
lv_memset(new_task, 0, sizeof(_lv_vector_draw_task));
|
||||
|
||||
new_task->dsc.fill_dsc.color = dsc->current_dsc.fill_dsc.color;
|
||||
new_task->dsc.fill_dsc.opa = dsc->current_dsc.fill_dsc.opa;
|
||||
lv_area_copy(&(new_task->dsc.scissor_area), rect);
|
||||
}
|
||||
|
||||
void lv_draw_vector(lv_vector_dsc_t * dsc)
|
||||
{
|
||||
if(!dsc->tasks.task_list) {
|
||||
return;
|
||||
}
|
||||
|
||||
lv_layer_t * layer = dsc->layer;
|
||||
|
||||
lv_draw_task_t * t = lv_draw_add_task(layer, &(layer->_clip_area));
|
||||
t->type = LV_DRAW_TASK_TYPE_VECTOR;
|
||||
t->draw_dsc = lv_malloc(sizeof(lv_draw_vector_task_dsc_t));
|
||||
lv_memcpy(t->draw_dsc, &(dsc->tasks), sizeof(lv_draw_vector_task_dsc_t));
|
||||
lv_draw_finalize_task_creation(layer, t);
|
||||
dsc->tasks.task_list = NULL;
|
||||
}
|
||||
|
||||
/* draw dsc transform */
|
||||
void lv_vector_dsc_identity(lv_vector_dsc_t * dsc)
|
||||
{
|
||||
lv_matrix_identity(&(dsc->current_dsc.matrix)); /*identity matrix*/
|
||||
}
|
||||
|
||||
void lv_vector_dsc_scale(lv_vector_dsc_t * dsc, float scale_x, float scale_y)
|
||||
{
|
||||
lv_matrix_scale(&(dsc->current_dsc.matrix), scale_x, scale_y);
|
||||
}
|
||||
|
||||
void lv_vector_dsc_rotate(lv_vector_dsc_t * dsc, float degree)
|
||||
{
|
||||
lv_matrix_rotate(&(dsc->current_dsc.matrix), degree);
|
||||
}
|
||||
|
||||
void lv_vector_dsc_translate(lv_vector_dsc_t * dsc, float tx, float ty)
|
||||
{
|
||||
lv_matrix_translate(&(dsc->current_dsc.matrix), tx, ty);
|
||||
}
|
||||
|
||||
void lv_vector_dsc_skew(lv_vector_dsc_t * dsc, float skew_x, float skew_y)
|
||||
{
|
||||
lv_matrix_skew(&(dsc->current_dsc.matrix), skew_x, skew_y);
|
||||
}
|
||||
|
||||
void _lv_vector_for_each_destroy_tasks(lv_ll_t * task_list, vector_draw_task_cb cb, void * data)
|
||||
{
|
||||
_lv_vector_draw_task * task = _lv_ll_get_head(task_list);
|
||||
_lv_vector_draw_task * next_task = NULL;
|
||||
|
||||
while(task != NULL) {
|
||||
next_task = _lv_ll_get_next(task_list, task);
|
||||
_lv_ll_remove(task_list, task);
|
||||
|
||||
if(cb) {
|
||||
cb(data, task->path, &(task->dsc));
|
||||
}
|
||||
|
||||
if(task->path) {
|
||||
lv_vector_path_delete(task->path);
|
||||
}
|
||||
lv_array_deinit(&(task->dsc.stroke_dsc.dash_pattern));
|
||||
|
||||
lv_free(task);
|
||||
task = next_task;
|
||||
}
|
||||
lv_free(task_list);
|
||||
}
|
||||
#endif /* LV_USE_VECTOR_GRAPHIC */
|
||||
571
libraries/lvgl/src/draw/lv_draw_vector.h
Normal file
571
libraries/lvgl/src/draw/lv_draw_vector.h
Normal file
@ -0,0 +1,571 @@
|
||||
/**
|
||||
* @file lv_draw_vector.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_VECTOR_H
|
||||
#define LV_DRAW_VECTOR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw.h"
|
||||
#include "../misc/lv_array.h"
|
||||
|
||||
#if LV_USE_VECTOR_GRAPHIC
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
enum {
|
||||
LV_VECTOR_FILL_NONZERO = 0,
|
||||
LV_VECTOR_FILL_EVENODD,
|
||||
};
|
||||
typedef uint8_t lv_vector_fill_t;
|
||||
|
||||
enum {
|
||||
LV_VECTOR_STROKE_CAP_BUTT = 0,
|
||||
LV_VECTOR_STROKE_CAP_SQUARE,
|
||||
LV_VECTOR_STROKE_CAP_ROUND,
|
||||
};
|
||||
typedef uint8_t lv_vector_stroke_cap_t;
|
||||
|
||||
enum {
|
||||
LV_VECTOR_STROKE_JOIN_MITER = 0,
|
||||
LV_VECTOR_STROKE_JOIN_BEVEL,
|
||||
LV_VECTOR_STROKE_JOIN_ROUND,
|
||||
};
|
||||
typedef uint8_t lv_vector_stroke_join_t;
|
||||
|
||||
enum {
|
||||
LV_VECTOR_PATH_QUALITY_MEDIUM = 0, /* default*/
|
||||
LV_VECTOR_PATH_QUALITY_HIGH,
|
||||
LV_VECTOR_PATH_QUALITY_LOW,
|
||||
};
|
||||
typedef uint8_t lv_vector_path_quality_t;
|
||||
|
||||
enum {
|
||||
LV_VECTOR_BLEND_SRC_OVER = 0,
|
||||
LV_VECTOR_BLEND_SRC_IN,
|
||||
LV_VECTOR_BLEND_DST_OVER,
|
||||
LV_VECTOR_BLEND_DST_IN,
|
||||
LV_VECTOR_BLEND_SCREEN,
|
||||
LV_VECTOR_BLEND_MULTIPLY,
|
||||
LV_VECTOR_BLEND_NONE,
|
||||
LV_VECTOR_BLEND_ADDITIVE,
|
||||
LV_VECTOR_BLEND_SUBTRACTIVE,
|
||||
};
|
||||
typedef uint8_t lv_vector_blend_t;
|
||||
|
||||
enum {
|
||||
LV_VECTOR_PATH_OP_MOVE_TO = 0,
|
||||
LV_VECTOR_PATH_OP_LINE_TO,
|
||||
LV_VECTOR_PATH_OP_QUAD_TO,
|
||||
LV_VECTOR_PATH_OP_CUBIC_TO,
|
||||
LV_VECTOR_PATH_OP_CLOSE,
|
||||
};
|
||||
typedef uint8_t lv_vector_path_op_t;
|
||||
|
||||
enum {
|
||||
LV_VECTOR_DRAW_STYLE_SOLID = 0,
|
||||
LV_VECTOR_DRAW_STYLE_PATTERN,
|
||||
LV_VECTOR_DRAW_STYLE_GRADIENT,
|
||||
};
|
||||
typedef uint8_t lv_vector_draw_style_t;
|
||||
|
||||
enum {
|
||||
LV_VECTOR_GRADIENT_SPREAD_PAD = 0,
|
||||
LV_VECTOR_GRADIENT_SPREAD_REPEAT,
|
||||
LV_VECTOR_GRADIENT_SPREAD_REFLECT,
|
||||
};
|
||||
typedef uint8_t lv_vector_gradient_spread_t;
|
||||
|
||||
enum {
|
||||
LV_VECTOR_GRADIENT_STYLE_LINEAR = 0,
|
||||
LV_VECTOR_GRADIENT_STYLE_RADIAL,
|
||||
};
|
||||
typedef uint8_t lv_vector_gradient_style_t;
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
} lv_fpoint_t;
|
||||
|
||||
typedef struct {
|
||||
float m[3][3];
|
||||
} lv_matrix_t;
|
||||
|
||||
typedef struct {
|
||||
lv_vector_path_quality_t quality;
|
||||
lv_array_t ops;
|
||||
lv_array_t points;
|
||||
} lv_vector_path_t;
|
||||
|
||||
typedef struct {
|
||||
lv_vector_gradient_style_t style;
|
||||
lv_grad_dsc_t grad;
|
||||
float cx;
|
||||
float cy;
|
||||
float cr;
|
||||
lv_vector_gradient_spread_t spread;
|
||||
} lv_vector_gradient_t;
|
||||
|
||||
typedef struct {
|
||||
lv_vector_draw_style_t style;
|
||||
lv_color32_t color;
|
||||
lv_opa_t opa;
|
||||
lv_vector_fill_t fill_rule;
|
||||
lv_draw_image_dsc_t img_dsc;
|
||||
lv_vector_gradient_t gradient;
|
||||
lv_matrix_t matrix;
|
||||
} lv_vector_fill_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
lv_vector_draw_style_t style;
|
||||
lv_color32_t color;
|
||||
lv_opa_t opa;
|
||||
float width;
|
||||
lv_array_t dash_pattern;
|
||||
lv_vector_stroke_cap_t cap;
|
||||
lv_vector_stroke_join_t join;
|
||||
uint16_t miter_limit;
|
||||
lv_vector_gradient_t gradient;
|
||||
lv_matrix_t matrix;
|
||||
} lv_vector_stroke_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
lv_vector_fill_dsc_t fill_dsc;
|
||||
lv_vector_stroke_dsc_t stroke_dsc;
|
||||
lv_matrix_t matrix;
|
||||
lv_vector_blend_t blend_mode;
|
||||
lv_area_t scissor_area;
|
||||
} lv_vector_draw_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
lv_draw_dsc_base_t base;
|
||||
lv_ll_t * task_list; /*draw task list.*/
|
||||
} lv_draw_vector_task_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
lv_layer_t * layer;
|
||||
lv_vector_draw_dsc_t current_dsc;
|
||||
/* private data */
|
||||
lv_draw_vector_task_dsc_t tasks;
|
||||
} lv_vector_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Set matrix to identity matrix
|
||||
* @param matrix pointer to a matrix
|
||||
*/
|
||||
void lv_matrix_identity(lv_matrix_t * matrix);
|
||||
|
||||
/**
|
||||
* Translate the matrix to new position
|
||||
* @param matrix pointer to a matrix
|
||||
* @param tx the amount of translate in x direction
|
||||
* @param tx the amount of translate in y direction
|
||||
*/
|
||||
void lv_matrix_translate(lv_matrix_t * matrix, float tx, float ty);
|
||||
|
||||
/**
|
||||
* Change the scale factor of the matrix
|
||||
* @param matrix pointer to a matrix
|
||||
* @param scale_x the scale factor for the X direction
|
||||
* @param scale_y the scale factor for the Y direction
|
||||
*/
|
||||
void lv_matrix_scale(lv_matrix_t * matrix, float scale_x, float scale_y);
|
||||
|
||||
/**
|
||||
* Rotate the matrix with origin
|
||||
* @param matrix pointer to a matrix
|
||||
* @param degree angle to rotate
|
||||
*/
|
||||
void lv_matrix_rotate(lv_matrix_t * matrix, float degree);
|
||||
|
||||
/**
|
||||
* Change the skew factor of the matrix
|
||||
* @param matrix pointer to a matrix
|
||||
* @param skew_x the skew factor for x direction
|
||||
* @param skew_y the skew factor for y direction
|
||||
*/
|
||||
void lv_matrix_skew(lv_matrix_t * matrix, float skew_x, float skew_y);
|
||||
|
||||
/**
|
||||
* Multiply two matrix and store the result to the first one
|
||||
* @param matrix pointer to a matrix
|
||||
* @param matrix2 pointer to another matrix
|
||||
*/
|
||||
void lv_matrix_multiply(lv_matrix_t * matrix, const lv_matrix_t * matrix2);
|
||||
|
||||
/**
|
||||
* Transform the coordinates of a point using given matrix
|
||||
* @param matrix pointer to a matrix
|
||||
* @param point pointer to a point
|
||||
*/
|
||||
void lv_matrix_transform_point(const lv_matrix_t * matrix, lv_fpoint_t * point);
|
||||
|
||||
/**
|
||||
* Transform all the coordinates of a path using given matrix
|
||||
* @param matrix pointer to a matrix
|
||||
* @param path pointer to a path
|
||||
*/
|
||||
void lv_matrix_transform_path(const lv_matrix_t * matrix, lv_vector_path_t * path);
|
||||
|
||||
/**
|
||||
* Create a vector graphic path object
|
||||
* @param quality the quality hint of path
|
||||
* @return pointer to the created path object
|
||||
*/
|
||||
lv_vector_path_t * lv_vector_path_create(lv_vector_path_quality_t quality);
|
||||
|
||||
/**
|
||||
* Copy a path data to another
|
||||
* @param target_path pointer to a path
|
||||
* @param path pointer to source path
|
||||
*/
|
||||
void lv_vector_path_copy(lv_vector_path_t * target_path, const lv_vector_path_t * path);
|
||||
|
||||
/**
|
||||
* Clear path data
|
||||
* @param path pointer to a path
|
||||
*/
|
||||
void lv_vector_path_clear(lv_vector_path_t * path);
|
||||
|
||||
/**
|
||||
* Delete the graphic path object
|
||||
* @param path pointer to a path
|
||||
*/
|
||||
void lv_vector_path_delete(lv_vector_path_t * path);
|
||||
|
||||
/**
|
||||
* Begin a new sub path and set a point to path
|
||||
* @param path pointer to a path
|
||||
* @param p pointer to a `lv_fpoint_t` variable
|
||||
*/
|
||||
void lv_vector_path_move_to(lv_vector_path_t * path, const lv_fpoint_t * p);
|
||||
|
||||
/**
|
||||
* Add a line to the path from last point to the point
|
||||
* @param path pointer to a path
|
||||
* @param p pointer to a `lv_fpoint_t` variable
|
||||
*/
|
||||
void lv_vector_path_line_to(lv_vector_path_t * path, const lv_fpoint_t * p);
|
||||
|
||||
/**
|
||||
* Add a quadratic bezier line to the path from last point to the point
|
||||
* @param path pointer to a path
|
||||
* @param p1 pointer to a `lv_fpoint_t` variable for control point
|
||||
* @param p2 pointer to a `lv_fpoint_t` variable for end point
|
||||
*/
|
||||
void lv_vector_path_quad_to(lv_vector_path_t * path, const lv_fpoint_t * p1, const lv_fpoint_t * p2);
|
||||
|
||||
/**
|
||||
* Add a cubic bezier line to the path from last point to the point
|
||||
* @param path pointer to a path
|
||||
* @param p1 pointer to a `lv_fpoint_t` variable for first control point
|
||||
* @param p2 pointer to a `lv_fpoint_t` variable for second control point
|
||||
* @param p3 pointer to a `lv_fpoint_t` variable for end point
|
||||
*/
|
||||
void lv_vector_path_cubic_to(lv_vector_path_t * path, const lv_fpoint_t * p1, const lv_fpoint_t * p2,
|
||||
const lv_fpoint_t * p3);
|
||||
|
||||
/**
|
||||
* Close the sub path
|
||||
* @param path pointer to a path
|
||||
*/
|
||||
void lv_vector_path_close(lv_vector_path_t * path);
|
||||
|
||||
/**
|
||||
* Get the bounding box of a path
|
||||
* @param path pointer to a path
|
||||
* @param area pointer to a `lv_area_t` variable for bounding box
|
||||
*/
|
||||
void lv_vector_path_get_bounding(const lv_vector_path_t * path, lv_area_t * area);
|
||||
|
||||
/**
|
||||
* Add a rectangle to the path
|
||||
* @param path pointer to a path
|
||||
* @param rect pointer to a `lv_area_t` variable
|
||||
* @param rx the horizontal radius for rounded rectangle
|
||||
* @param ry the vertical radius for rounded rectangle
|
||||
*/
|
||||
void lv_vector_path_append_rect(lv_vector_path_t * path, const lv_area_t * rect, float rx, float ry);
|
||||
|
||||
/**
|
||||
* Add a circle to the path
|
||||
* @param path pointer to a path
|
||||
* @param c pointer to a `lv_fpoint_t` variable for center of the circle
|
||||
* @param rx the horizontal radius for circle
|
||||
* @param ry the vertical radius for circle
|
||||
*/
|
||||
void lv_vector_path_append_circle(lv_vector_path_t * path, const lv_fpoint_t * c, float rx, float ry);
|
||||
|
||||
/**
|
||||
* Add a arc to the path
|
||||
* @param path pointer to a path
|
||||
* @param c pointer to a `lv_fpoint_t` variable for center of the circle
|
||||
* @param radius the radius for arc
|
||||
* @param start_angle the start angle for arc
|
||||
* @param sweep the sweep angle for arc, could be negative
|
||||
* @param pie true: draw a pie, false: draw a arc
|
||||
*/
|
||||
void lv_vector_path_append_arc(lv_vector_path_t * path, const lv_fpoint_t * c, float radius, float start_angle,
|
||||
float sweep, bool pie);
|
||||
|
||||
/**
|
||||
* Add an sub path to the path
|
||||
* @param path pointer to a path
|
||||
* @param subpath pointer to another path which will be added
|
||||
*/
|
||||
void lv_vector_path_append_path(lv_vector_path_t * path, const lv_vector_path_t * subpath);
|
||||
|
||||
/**
|
||||
* Create a vector graphic descriptor
|
||||
* @param layer pointer to a layer
|
||||
* @return pointer to the created descriptor
|
||||
*/
|
||||
lv_vector_dsc_t * lv_vector_dsc_create(lv_layer_t * layer);
|
||||
|
||||
/**
|
||||
* Delete the vector graphic descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
*/
|
||||
void lv_vector_dsc_delete(lv_vector_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Set a matrix to current transformation matrix
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param matrix pointer to a matrix
|
||||
*/
|
||||
void lv_vector_dsc_set_transform(lv_vector_dsc_t * dsc, const lv_matrix_t * matrix);
|
||||
|
||||
/**
|
||||
* Set blend mode for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param blend the blend mode to be set in `lv_vector_blend_t`
|
||||
*/
|
||||
void lv_vector_dsc_set_blend_mode(lv_vector_dsc_t * dsc, lv_vector_blend_t blend);
|
||||
|
||||
/**
|
||||
* Set fill color for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param color the color to be set in lv_color32_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_fill_color32(lv_vector_dsc_t * dsc, lv_color32_t color);
|
||||
|
||||
/**
|
||||
* Set fill color for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param color the color to be set in lv_color_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_fill_color(lv_vector_dsc_t * dsc, lv_color_t color);
|
||||
|
||||
/**
|
||||
* Set fill opacity for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param opa the opacity to be set in lv_opa_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_fill_opa(lv_vector_dsc_t * dsc, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Set fill rule for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param rule the fill rule to be set in lv_vector_fill_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_fill_rule(lv_vector_dsc_t * dsc, lv_vector_fill_t rule);
|
||||
|
||||
/**
|
||||
* Set fill image for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param img_dsc pointer to a `lv_draw_image_dsc_t` variable
|
||||
*/
|
||||
void lv_vector_dsc_set_fill_image(lv_vector_dsc_t * dsc, const lv_draw_image_dsc_t * img_dsc);
|
||||
|
||||
/**
|
||||
* Set fill linear gradient for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param grad pointer to a `lv_grad_dsc_t` variable
|
||||
* @param spread the gradient spread to be set in lv_vector_gradient_spread_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_fill_linear_gradient(lv_vector_dsc_t * dsc, const lv_grad_dsc_t * grad,
|
||||
lv_vector_gradient_spread_t spread);
|
||||
|
||||
/**
|
||||
* Set fill radial gradient for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param grad pointer to a `lv_grad_dsc_t` variable
|
||||
* @param cx the x for center of the circle
|
||||
* @param cy the y for center of the circle
|
||||
* @param radius the radius for circle
|
||||
* @param spread the gradient spread to be set in lv_vector_gradient_spread_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_fill_radial_gradient(lv_vector_dsc_t * dsc, const lv_grad_dsc_t * grad, float cx, float cy,
|
||||
float radius, lv_vector_gradient_spread_t spread);
|
||||
|
||||
/**
|
||||
* Set a matrix to current fill transformation matrix
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param matrix pointer to a matrix
|
||||
*/
|
||||
void lv_vector_dsc_set_fill_transform(lv_vector_dsc_t * dsc, const lv_matrix_t * matrix);
|
||||
|
||||
/**
|
||||
* Set stroke color for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param color the color to be set in lv_color32_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_stroke_color32(lv_vector_dsc_t * dsc, lv_color32_t color);
|
||||
|
||||
/**
|
||||
* Set stroke color for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param color the color to be set in lv_color_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_stroke_color(lv_vector_dsc_t * dsc, lv_color_t color);
|
||||
|
||||
/**
|
||||
* Set stroke opacity for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param opa the opacity to be set in lv_opa_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_stroke_opa(lv_vector_dsc_t * dsc, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Set stroke line width for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param width the stroke line width
|
||||
*/
|
||||
void lv_vector_dsc_set_stroke_width(lv_vector_dsc_t * dsc, float width);
|
||||
|
||||
/**
|
||||
* Set stroke line dash pattern for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param dash_pattern an array of values that specify the segments of dash line
|
||||
* @param dash_count the length of dash pattern array
|
||||
*/
|
||||
void lv_vector_dsc_set_stroke_dash(lv_vector_dsc_t * dsc, float * dash_pattern, uint16_t dash_count);
|
||||
|
||||
/**
|
||||
* Set stroke line cap style for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param cap the line cap to be set in lv_vector_stroke_cap_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_stroke_cap(lv_vector_dsc_t * dsc, lv_vector_stroke_cap_t cap);
|
||||
|
||||
/**
|
||||
* Set stroke line join style for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param join the line join to be set in lv_vector_stroke_join_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_stroke_join(lv_vector_dsc_t * dsc, lv_vector_stroke_join_t join);
|
||||
|
||||
/**
|
||||
* Set stroke miter limit for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param miter_limit the stroke miter_limit
|
||||
*/
|
||||
void lv_vector_dsc_set_stroke_miter_limit(lv_vector_dsc_t * dsc, uint16_t miter_limit);
|
||||
|
||||
/**
|
||||
* Set stroke linear gradient for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param grad pointer to a `lv_grad_dsc_t` variable
|
||||
* @param spread the gradient spread to be set in lv_vector_gradient_spread_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_stroke_linear_gradient(lv_vector_dsc_t * dsc, const lv_grad_dsc_t * grad,
|
||||
lv_vector_gradient_spread_t spread);
|
||||
/**
|
||||
* Set stroke radial gradient for descriptor
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param grad pointer to a `lv_grad_dsc_t` variable
|
||||
* @param cx the x for center of the circle
|
||||
* @param cy the y for center of the circle
|
||||
* @param radius the radius for circle
|
||||
* @param spread the gradient spread to be set in lv_vector_gradient_spread_t format
|
||||
*/
|
||||
void lv_vector_dsc_set_stroke_radial_gradient(lv_vector_dsc_t * dsc, const lv_grad_dsc_t * grad, float cx, float cy,
|
||||
float radius, lv_vector_gradient_spread_t spread);
|
||||
/**
|
||||
* Set a matrix to current stroke transformation matrix
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param matrix pointer to a matrix
|
||||
*/
|
||||
void lv_vector_dsc_set_stroke_transform(lv_vector_dsc_t * dsc, const lv_matrix_t * matrix);
|
||||
|
||||
/**
|
||||
* Set current transformation matrix to identity matrix
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
*/
|
||||
void lv_vector_dsc_identity(lv_vector_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Change the scale factor of current transformation matrix
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param scale_x the scale factor for the X direction
|
||||
* @param scale_y the scale factor for the Y direction
|
||||
*/
|
||||
void lv_vector_dsc_scale(lv_vector_dsc_t * dsc, float scale_x, float scale_y);
|
||||
|
||||
/**
|
||||
* Rotate current transformation matrix with origin
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param degree angle to rotate
|
||||
*/
|
||||
void lv_vector_dsc_rotate(lv_vector_dsc_t * dsc, float degree);
|
||||
|
||||
/**
|
||||
* Translate current transformation matrix to new position
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param tx the amount of translate in x direction
|
||||
* @param tx the amount of translate in y direction
|
||||
*/
|
||||
void lv_vector_dsc_translate(lv_vector_dsc_t * dsc, float tx, float ty);
|
||||
|
||||
/**
|
||||
* Change the skew factor of current transformation matrix
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param skew_x the skew factor for x direction
|
||||
* @param skew_y the skew factor for y direction
|
||||
*/
|
||||
void lv_vector_dsc_skew(lv_vector_dsc_t * dsc, float skew_x, float skew_y);
|
||||
|
||||
/**
|
||||
* Add a graphic path to the draw list
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param path pointer to a path
|
||||
*/
|
||||
void lv_vector_dsc_add_path(lv_vector_dsc_t * dsc, const lv_vector_path_t * path);
|
||||
|
||||
/**
|
||||
* Clear a rectangle area use current fill color
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
* @param rect the area to clear in the buffer
|
||||
*/
|
||||
void lv_vector_clear_area(lv_vector_dsc_t * dsc, const lv_area_t * rect);
|
||||
|
||||
/**
|
||||
* Draw all the vector graphic paths
|
||||
* @param dsc pointer to a vector graphic descriptor
|
||||
*/
|
||||
void lv_draw_vector(lv_vector_dsc_t * dsc);
|
||||
|
||||
/* Traverser for task list */
|
||||
typedef void (*vector_draw_task_cb)(void * ctx, const lv_vector_path_t * path, const lv_vector_draw_dsc_t * dsc);
|
||||
|
||||
void _lv_vector_for_each_destroy_tasks(lv_ll_t * task_list, vector_draw_task_cb cb, void * data);
|
||||
|
||||
#endif /* LV_USE_VECTOR_GRAPHIC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_DRAW_VECTOR_H */
|
||||
470
libraries/lvgl/src/draw/lv_image_decoder.c
Normal file
470
libraries/lvgl/src/draw/lv_image_decoder.c
Normal file
@ -0,0 +1,470 @@
|
||||
/**
|
||||
* @file lv_image_decoder.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_image_decoder.h"
|
||||
#include "../misc/lv_assert.h"
|
||||
#include "../draw/lv_draw_image.h"
|
||||
#include "../misc/lv_ll.h"
|
||||
#include "../stdlib/lv_string.h"
|
||||
#include "../core/lv_global.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define img_decoder_ll_p &(LV_GLOBAL_DEFAULT()->img_decoder_ll)
|
||||
#define img_cache_p (LV_GLOBAL_DEFAULT()->img_cache)
|
||||
#define img_header_cache_p (LV_GLOBAL_DEFAULT()->img_header_cache)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
static uint32_t img_width_to_stride(lv_image_header_t * header);
|
||||
|
||||
/**
|
||||
* Get the header info of an image source, and return the a pointer to the decoder that can open it.
|
||||
* @param src The image source (e.g. a filename or a pointer to a C array)
|
||||
* @param header The header of the image
|
||||
* @return The decoder that can open the image source or NULL if not found (or can't open it).
|
||||
*/
|
||||
static lv_image_decoder_t * image_decoder_get_info(const void * src, lv_image_header_t * header);
|
||||
|
||||
#if LV_IMAGE_HEADER_CACHE_DEF_CNT > 0
|
||||
static lv_cache_compare_res_t image_decoder_header_cache_compare_cb(const lv_image_header_cache_data_t * lhs,
|
||||
const lv_image_header_cache_data_t * rhs);
|
||||
static void image_decoder_header_cache_free_cb(lv_image_header_cache_data_t * entry, void * user_data);
|
||||
#endif
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
static lv_cache_compare_res_t image_decoder_cache_compare_cb(const lv_image_cache_data_t * lhs,
|
||||
const lv_image_cache_data_t * rhs);
|
||||
static void image_decoder_cache_free_cb(lv_image_cache_data_t * entry, void * user_data);
|
||||
|
||||
static lv_result_t try_cache(lv_image_decoder_dsc_t * dsc);
|
||||
#endif
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the image decoder module
|
||||
*/
|
||||
void _lv_image_decoder_init(void)
|
||||
{
|
||||
_lv_ll_init(img_decoder_ll_p, sizeof(lv_image_decoder_t));
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
img_cache_p = lv_cache_create(&lv_cache_class_lru_rb_size,
|
||||
sizeof(lv_image_cache_data_t), LV_CACHE_DEF_SIZE, (lv_cache_ops_t) {
|
||||
.compare_cb = (lv_cache_compare_cb_t)image_decoder_cache_compare_cb,
|
||||
.create_cb = NULL,
|
||||
.free_cb = (lv_cache_free_cb_t)image_decoder_cache_free_cb,
|
||||
});
|
||||
|
||||
#endif
|
||||
|
||||
#if LV_IMAGE_HEADER_CACHE_DEF_CNT > 0
|
||||
img_header_cache_p = lv_cache_create(&lv_cache_class_lru_rb_count,
|
||||
sizeof(lv_image_header_cache_data_t), LV_IMAGE_HEADER_CACHE_DEF_CNT, (lv_cache_ops_t) {
|
||||
.compare_cb = (lv_cache_compare_cb_t)image_decoder_header_cache_compare_cb,
|
||||
.create_cb = NULL,
|
||||
.free_cb = (lv_cache_free_cb_t)image_decoder_header_cache_free_cb
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Deinitialize the image decoder module
|
||||
*/
|
||||
void _lv_image_decoder_deinit(void)
|
||||
{
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
lv_cache_destroy(img_cache_p, NULL);
|
||||
#endif
|
||||
|
||||
#if LV_IMAGE_HEADER_CACHE_DEF_CNT > 0
|
||||
lv_cache_destroy(img_header_cache_p, NULL);
|
||||
#endif
|
||||
_lv_ll_clear(img_decoder_ll_p);
|
||||
}
|
||||
|
||||
lv_result_t lv_image_decoder_get_info(const void * src, lv_image_header_t * header)
|
||||
{
|
||||
lv_image_decoder_t * decoder = image_decoder_get_info(src, header);
|
||||
if(decoder == NULL) return LV_RESULT_INVALID;
|
||||
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
lv_result_t lv_image_decoder_open(lv_image_decoder_dsc_t * dsc, const void * src, const lv_image_decoder_args_t * args)
|
||||
{
|
||||
lv_memzero(dsc, sizeof(lv_image_decoder_dsc_t));
|
||||
|
||||
if(src == NULL) return LV_RESULT_INVALID;
|
||||
dsc->src = src;
|
||||
dsc->src_type = lv_image_src_get_type(src);
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
dsc->cache = img_cache_p;
|
||||
/*Try cache first, unless we are told to ignore cache.*/
|
||||
if(!(args && args->no_cache)) {
|
||||
/*
|
||||
* Check the cache first
|
||||
* If the image is found in the cache, just return it.*/
|
||||
if(try_cache(dsc) == LV_RESULT_OK) return LV_RESULT_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*Find the decoder that can open the image source, and get the header info in the same time.*/
|
||||
dsc->decoder = image_decoder_get_info(src, &dsc->header);
|
||||
if(dsc->decoder == NULL) return LV_RESULT_INVALID;
|
||||
|
||||
/*Make a copy of args*/
|
||||
dsc->args = args ? *args : (lv_image_decoder_args_t) {
|
||||
.stride_align = LV_DRAW_BUF_STRIDE_ALIGN != 1,
|
||||
.premultiply = false,
|
||||
.no_cache = false,
|
||||
.use_indexed = false,
|
||||
};
|
||||
|
||||
/*
|
||||
* We assume that if a decoder can get the info, it can open the image.
|
||||
* If decoder open failed, free the source and return error.
|
||||
* If decoder open succeed, add the image to cache if enabled.
|
||||
* */
|
||||
lv_result_t res = dsc->decoder->open_cb(dsc->decoder, dsc);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
lv_result_t lv_image_decoder_get_area(lv_image_decoder_dsc_t * dsc, const lv_area_t * full_area,
|
||||
lv_area_t * decoded_area)
|
||||
{
|
||||
lv_result_t res = LV_RESULT_INVALID;
|
||||
if(dsc->decoder->get_area_cb) res = dsc->decoder->get_area_cb(dsc->decoder, dsc, full_area, decoded_area);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void lv_image_decoder_close(lv_image_decoder_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->decoder) {
|
||||
if(dsc->decoder->close_cb) dsc->decoder->close_cb(dsc->decoder, dsc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new image decoder
|
||||
* @return pointer to the new image decoder
|
||||
*/
|
||||
lv_image_decoder_t * lv_image_decoder_create(void)
|
||||
{
|
||||
lv_image_decoder_t * decoder;
|
||||
decoder = _lv_ll_ins_head(img_decoder_ll_p);
|
||||
LV_ASSERT_MALLOC(decoder);
|
||||
if(decoder == NULL) return NULL;
|
||||
|
||||
lv_memzero(decoder, sizeof(lv_image_decoder_t));
|
||||
|
||||
return decoder;
|
||||
}
|
||||
|
||||
void lv_image_decoder_delete(lv_image_decoder_t * decoder)
|
||||
{
|
||||
_lv_ll_remove(img_decoder_ll_p, decoder);
|
||||
lv_free(decoder);
|
||||
}
|
||||
|
||||
lv_image_decoder_t * lv_image_decoder_get_next(lv_image_decoder_t * decoder)
|
||||
{
|
||||
if(decoder == NULL)
|
||||
return _lv_ll_get_head(img_decoder_ll_p);
|
||||
else
|
||||
return _lv_ll_get_next(img_decoder_ll_p, decoder);
|
||||
}
|
||||
|
||||
void lv_image_decoder_set_info_cb(lv_image_decoder_t * decoder, lv_image_decoder_info_f_t info_cb)
|
||||
{
|
||||
decoder->info_cb = info_cb;
|
||||
}
|
||||
|
||||
void lv_image_decoder_set_open_cb(lv_image_decoder_t * decoder, lv_image_decoder_open_f_t open_cb)
|
||||
{
|
||||
decoder->open_cb = open_cb;
|
||||
}
|
||||
|
||||
void lv_image_decoder_set_get_area_cb(lv_image_decoder_t * decoder, lv_image_decoder_get_area_cb_t get_area_cb)
|
||||
{
|
||||
decoder->get_area_cb = get_area_cb;
|
||||
}
|
||||
|
||||
void lv_image_decoder_set_close_cb(lv_image_decoder_t * decoder, lv_image_decoder_close_f_t close_cb)
|
||||
{
|
||||
decoder->close_cb = close_cb;
|
||||
}
|
||||
|
||||
void lv_image_decoder_set_cache_free_cb(lv_image_decoder_t * decoder, lv_cache_free_cb_t cache_free_cb)
|
||||
{
|
||||
decoder->cache_free_cb = cache_free_cb;
|
||||
}
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
lv_cache_entry_t * lv_image_decoder_add_to_cache(lv_image_decoder_t * decoder,
|
||||
lv_image_cache_data_t * search_key,
|
||||
const lv_draw_buf_t * decoded, void * user_data)
|
||||
{
|
||||
lv_cache_entry_t * cache_entry = lv_cache_add(img_cache_p, search_key, NULL);
|
||||
if(cache_entry == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_image_cache_data_t * cached_data;
|
||||
cached_data = lv_cache_entry_get_data(cache_entry);
|
||||
|
||||
/*Set the cache entry to decoder data*/
|
||||
cached_data->decoded = decoded;
|
||||
if(cached_data->src_type == LV_IMAGE_SRC_FILE) {
|
||||
cached_data->src = lv_strdup(cached_data->src);
|
||||
}
|
||||
cached_data->user_data = user_data; /*Need to free data on cache invalidate instead of decoder_close*/
|
||||
cached_data->decoder = decoder;
|
||||
|
||||
return cache_entry;
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_draw_buf_t * lv_image_decoder_post_process(lv_image_decoder_dsc_t * dsc, lv_draw_buf_t * decoded)
|
||||
{
|
||||
if(decoded == NULL) return NULL; /*No need to adjust*/
|
||||
|
||||
lv_image_decoder_args_t * args = &dsc->args;
|
||||
if(args->stride_align && decoded->header.cf != LV_COLOR_FORMAT_RGB565A8) {
|
||||
uint32_t stride_expect = lv_draw_buf_width_to_stride(decoded->header.w, decoded->header.cf);
|
||||
if(decoded->header.stride != stride_expect) {
|
||||
LV_LOG_TRACE("Stride mismatch");
|
||||
lv_result_t res = lv_draw_buf_adjust_stride(decoded, stride_expect);
|
||||
if(res != LV_RESULT_OK) {
|
||||
lv_draw_buf_t * aligned = lv_draw_buf_create(decoded->header.w, decoded->header.h, decoded->header.cf, stride_expect);
|
||||
if(aligned == NULL) {
|
||||
LV_LOG_ERROR("No memory for Stride adjust.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_draw_buf_copy(aligned, NULL, decoded, NULL);
|
||||
decoded = aligned;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Premultiply alpha channel*/
|
||||
if(args->premultiply
|
||||
&& !LV_COLOR_FORMAT_IS_ALPHA_ONLY(decoded->header.cf)
|
||||
&& lv_color_format_has_alpha(decoded->header.cf)
|
||||
&& !lv_draw_buf_has_flag(decoded, LV_IMAGE_FLAGS_PREMULTIPLIED) /*Hasn't done yet*/
|
||||
) {
|
||||
LV_LOG_TRACE("Alpha premultiply.");
|
||||
if(lv_draw_buf_has_flag(decoded, LV_IMAGE_FLAGS_MODIFIABLE)) {
|
||||
/*Do it directly*/
|
||||
lv_draw_buf_premultiply(decoded);
|
||||
}
|
||||
else {
|
||||
decoded = lv_draw_buf_dup(decoded);
|
||||
if(decoded == NULL) {
|
||||
LV_LOG_ERROR("No memory for premulitplying.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_draw_buf_premultiply(decoded);
|
||||
}
|
||||
}
|
||||
|
||||
return decoded;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static lv_image_decoder_t * image_decoder_get_info(const void * src, lv_image_header_t * header)
|
||||
{
|
||||
lv_memzero(header, sizeof(lv_image_header_t));
|
||||
|
||||
if(src == NULL) return NULL;
|
||||
|
||||
lv_image_src_t src_type = lv_image_src_get_type(src);
|
||||
if(src_type == LV_IMAGE_SRC_VARIABLE) {
|
||||
const lv_image_dsc_t * img_dsc = src;
|
||||
if(img_dsc->data == NULL) return NULL;
|
||||
}
|
||||
|
||||
lv_image_decoder_t * decoder;
|
||||
|
||||
#if LV_IMAGE_HEADER_CACHE_DEF_CNT > 0
|
||||
if(src_type == LV_IMAGE_SRC_FILE) {
|
||||
lv_image_header_cache_data_t search_key;
|
||||
search_key.src_type = src_type;
|
||||
search_key.src = src;
|
||||
|
||||
lv_cache_entry_t * entry = lv_cache_acquire(img_header_cache_p, &search_key, NULL);
|
||||
|
||||
if(entry) {
|
||||
lv_image_header_cache_data_t * cached_data = lv_cache_entry_get_data(entry);
|
||||
*header = cached_data->header;
|
||||
decoder = cached_data->decoder;
|
||||
lv_cache_release(img_header_cache_p, entry, NULL);
|
||||
return decoder;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_LV_LL_READ(img_decoder_ll_p, decoder) {
|
||||
/*Info and Open callbacks are required*/
|
||||
if(decoder->info_cb && decoder->open_cb) {
|
||||
lv_result_t res = decoder->info_cb(decoder, src, header);
|
||||
if(res == LV_RESULT_OK) {
|
||||
if(header->stride == 0) {
|
||||
LV_LOG_INFO("Image decoder didn't set stride. Calculate it from width.");
|
||||
header->stride = img_width_to_stride(header);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if LV_IMAGE_HEADER_CACHE_DEF_CNT > 0
|
||||
if(src_type == LV_IMAGE_SRC_FILE && decoder) {
|
||||
lv_cache_entry_t * entry;
|
||||
lv_image_header_cache_data_t search_key;
|
||||
search_key.src_type = src_type;
|
||||
search_key.src = lv_strdup(src);
|
||||
search_key.decoder = decoder;
|
||||
search_key.header = *header;
|
||||
entry = lv_cache_add(img_header_cache_p, &search_key, NULL);
|
||||
|
||||
if(entry == NULL) {
|
||||
if(src_type == LV_IMAGE_SRC_FILE) lv_free((void *)search_key.src);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_cache_release(img_header_cache_p, entry, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
return decoder;
|
||||
}
|
||||
|
||||
static uint32_t img_width_to_stride(lv_image_header_t * header)
|
||||
{
|
||||
if(header->cf == LV_COLOR_FORMAT_RGB565A8) {
|
||||
return header->w * 2;
|
||||
}
|
||||
else {
|
||||
return ((uint32_t)header->w * lv_color_format_get_bpp(header->cf) + 7) >> 3;
|
||||
}
|
||||
}
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0 || LV_IMAGE_HEADER_CACHE_DEF_CNT > 0
|
||||
inline static lv_cache_compare_res_t image_decoder_common_compare(const void * lhs_src, lv_image_src_t lhs_src_type,
|
||||
const void * rhs_src, lv_image_src_t rhs_src_type)
|
||||
{
|
||||
if(lhs_src_type == rhs_src_type) {
|
||||
if(lhs_src_type == LV_IMAGE_SRC_FILE) {
|
||||
int32_t cmp_res = lv_strcmp(lhs_src, rhs_src);
|
||||
if(cmp_res != 0) {
|
||||
return cmp_res > 0 ? 1 : -1;
|
||||
}
|
||||
}
|
||||
else if(lhs_src_type == LV_IMAGE_SRC_VARIABLE) {
|
||||
if(lhs_src != rhs_src) {
|
||||
return lhs_src > rhs_src ? 1 : -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return lhs_src_type > rhs_src_type ? 1 : -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_IMAGE_HEADER_CACHE_DEF_CNT > 0
|
||||
static lv_cache_compare_res_t image_decoder_header_cache_compare_cb(
|
||||
const lv_image_header_cache_data_t * lhs,
|
||||
const lv_image_header_cache_data_t * rhs)
|
||||
{
|
||||
return image_decoder_common_compare(lhs->src, lhs->src_type, rhs->src, rhs->src_type);
|
||||
}
|
||||
|
||||
static void image_decoder_header_cache_free_cb(lv_image_header_cache_data_t * entry, void * user_data)
|
||||
{
|
||||
LV_UNUSED(user_data); /*Unused*/
|
||||
|
||||
if(entry->src_type == LV_IMAGE_SRC_FILE) lv_free((void *)entry->src);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_CACHE_DEF_SIZE > 0
|
||||
static lv_cache_compare_res_t image_decoder_cache_compare_cb(
|
||||
const lv_image_cache_data_t * lhs,
|
||||
const lv_image_cache_data_t * rhs)
|
||||
{
|
||||
return image_decoder_common_compare(lhs->src, lhs->src_type, rhs->src, rhs->src_type);
|
||||
}
|
||||
|
||||
static void image_decoder_cache_free_cb(lv_image_cache_data_t * entry, void * user_data)
|
||||
{
|
||||
const lv_image_decoder_t * decoder = entry->decoder;
|
||||
if(decoder == NULL) return; /* Why ? */
|
||||
|
||||
if(decoder->cache_free_cb) {
|
||||
/* Decoder wants to free the cache by itself. */
|
||||
decoder->cache_free_cb(entry, user_data);
|
||||
}
|
||||
else {
|
||||
/* Destroy the decoded draw buffer if necessary. */
|
||||
lv_draw_buf_t * decoded = (lv_draw_buf_t *)entry->decoded;
|
||||
if(lv_draw_buf_has_flag(decoded, LV_IMAGE_FLAGS_ALLOCATED)) {
|
||||
lv_draw_buf_destroy(decoded);
|
||||
}
|
||||
|
||||
/*Free the duplicated file name*/
|
||||
if(entry->src_type == LV_IMAGE_SRC_FILE) lv_free((void *)entry->src);
|
||||
}
|
||||
}
|
||||
|
||||
static lv_result_t try_cache(lv_image_decoder_dsc_t * dsc)
|
||||
{
|
||||
lv_cache_t * cache = dsc->cache;
|
||||
|
||||
lv_image_cache_data_t search_key;
|
||||
search_key.src_type = dsc->src_type;
|
||||
search_key.src = dsc->src;
|
||||
|
||||
lv_cache_entry_t * entry = lv_cache_acquire(cache, &search_key, NULL);
|
||||
|
||||
if(entry) {
|
||||
lv_image_cache_data_t * cached_data = lv_cache_entry_get_data(entry);
|
||||
dsc->decoded = cached_data->decoded;
|
||||
dsc->decoder = (lv_image_decoder_t *)cached_data->decoder;
|
||||
dsc->cache_entry = entry; /*Save the cache to release it in decoder_close*/
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user