mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-21 06:53:01 +08:00
Merge branch 'dev-6.0' into dev-6.0
This commit is contained in:
commit
591e02c71b
2
.github/stale.yml
vendored
2
.github/stale.yml
vendored
@ -7,7 +7,7 @@ exemptLabels:
|
||||
- architecture
|
||||
- pinned
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue or pull request has been automatically marked as stale because it has not had
|
||||
|
37
README.md
37
README.md
@ -62,34 +62,43 @@ The easiest way to get started with LittlevGL is to run it in a simulator on you
|
||||
|
||||
Choose a project with your favourite IDE:
|
||||
|
||||
| Eclipse | CodeBlock | Visual Studio | PlatformIO | Qt Creator |
|
||||
|-------------|----------- |---------------|-----------|------------|
|
||||
| Eclipse | CodeBlocks | Visual Studio | PlatformIO | Qt Creator |
|
||||
|-------------|-------------|---------------|-----------|------------|
|
||||
| [![Eclipse](https://littlevgl.com/logo/ide/eclipse.jpg)](https://github.com/littlevgl/pc_simulator_sdl_eclipse) | [![CodeBlocks](https://littlevgl.com/logo/ide/codeblocks.jpg)](https://github.com/littlevgl/pc_simulator_win_codeblocks) | [![VisualStudio](https://littlevgl.com/logo/ide/visualstudio.jpg)](https://github.com/littlevgl/visual_studio_2017_sdl_x64) | [![PlatformIO](https://littlevgl.com/logo/ide/platformio.jpg)](https://github.com/littlevgl/pc_simulator_sdl_platformio) | [![QtCreator](https://littlevgl.com/logo/ide/qtcreator.jpg)](https://blog.littlevgl.com/2019-01-03/qt-creator) |
|
||||
| Cross-platform<br>with SDL | Native Windows | Cross-platform<br>with SDL | Cross-platform<br>with SDL | Cross-platform<br>with SDL |
|
||||
|
||||
### Porting to an embedded hardware
|
||||
In the most simple case you need to do these steps:
|
||||
1. Copy `lv_conf_templ.h` as `lv_conf.h` next to `lvgl` and set at least `LV_HOR_RES`, `LV_VER_RES` and `LV_COLOR_DEPTH`.
|
||||
2. Call `lv_tick_inc(x)` every `x` milliseconds in a Timer or Task (`x` should be between 1 and 10)
|
||||
2. Call `lv_tick_inc(x)` every `x` milliseconds **in a Timer or Task** (`x` should be between 1 and 10)
|
||||
3. Call `lv_init()`
|
||||
4. Register a function which can **copy a pixel array** to an area of the screen:
|
||||
4. Create a buffer for LittlevGL
|
||||
```c
|
||||
static lv_disp_buf_t disp_buf;
|
||||
static lv_color_t buf[LV_HOR_RES_MAX * 10]; /*Declare a buffer for 10 lines*/
|
||||
v_disp_buf_init(&disp_buf1, buf, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
|
||||
```
|
||||
4. Implement and register a function which can **copy a pixel array** to an area of your diplay:
|
||||
```c
|
||||
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
disp_drv.disp_flush = disp_flush; /*Set your driver function*/
|
||||
disp_drv.hor_res = 480; /*Set the horizontal resolution*/
|
||||
disp_drv.ver_res = 320; /*Set the vertical resolution*/
|
||||
disp_drv.flush_cb = my_disp_flush; /*Set your driver function*/
|
||||
disp_drv.buffer = &disp_buf; /*Assign the buffer to teh display*/
|
||||
lv_disp_drv_register(&disp_drv); /*Finally register the driver*/
|
||||
|
||||
void disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p)
|
||||
void my_disp_flush(lv_disp_t * disp, const lv_area_t * area, lv_color_t * color_p)
|
||||
{
|
||||
int32_t x, y;
|
||||
for(y = y1; y <= y2; y++) {
|
||||
for(x = x1; x <= x2; x++) {
|
||||
sep_pixel(x, y, *color_p); /* Put a pixel to the display.*/
|
||||
for(y = area->y1; y <= area->y2; y++) {
|
||||
for(x = area->x1; x <= area->x2; x++) {
|
||||
set_pixel(x, y, *color_p); /* Put a pixel to the display.*/
|
||||
color_p++;
|
||||
}
|
||||
}
|
||||
|
||||
lv_flush_ready(); /* Tell you are ready with the flushing*/
|
||||
lv_disp_flush_ready(disp); /* Tell you are ready with the flushing*/
|
||||
}
|
||||
|
||||
```
|
||||
@ -97,10 +106,10 @@ void disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t
|
||||
```c
|
||||
lv_indev_drv_init(&indev_drv); /*Descriptor of a input device driver*/
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER; /*Touch pad is a pointer-like device*/
|
||||
indev_drv.read = touchpad_read; /*Set your driver function*/
|
||||
indev_drv.read_cb = my_touchpad_read; /*Set your driver function*/
|
||||
lv_indev_drv_register(&indev_drv); /*Finally register the driver*/
|
||||
|
||||
bool touchpad_read(lv_indev_data_t * data)
|
||||
bool my_touchpad_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
{
|
||||
static lv_coord_t last_x = 0;
|
||||
static lv_coord_t last_y = 0;
|
||||
@ -116,9 +125,9 @@ bool touchpad_read(lv_indev_data_t * data)
|
||||
return false; /*Return `false` because we are not buffering and no more data to read*/
|
||||
}
|
||||
```
|
||||
6. Call `lv_task_handler()` periodically every few milliseconds in the main `while(1)` loop, in Timer interrupt or in an Operation system task.
|
||||
6. Call `lv_task_handler()` periodically every few milliseconds in the main `while(1)` loop, in a Timer interrupt or in an Operation system task.
|
||||
|
||||
For a detailed description check the [Documentation](https://docs.littlevgl.com/#Porting) or the [Porting tutorial](https://github.com/littlevgl/lv_examples/blob/master/lv_tutorial/0_porting/lv_tutorial_porting.c)
|
||||
For a detailed description check the [Documentation](https://docs.littlevgl.com/#Porting) or the [Porting examples](https://github.com/littlevgl/lvgl/tree/multi-disp/lv_porting).
|
||||
|
||||
|
||||
### Code examples
|
||||
|
@ -6,6 +6,50 @@
|
||||
|
||||
#ifndef LV_CONF_CHECKER_H
|
||||
#define LV_CONF_CHECKER_H
|
||||
|
||||
/*===================
|
||||
Graphical settings
|
||||
*===================*/
|
||||
|
||||
/* Horizontal and vertical resolution of the library.*/
|
||||
#ifndef LV_HOR_RES_MAX
|
||||
#define LV_HOR_RES_MAX (480)
|
||||
#endif
|
||||
#ifndef LV_VER_RES_MAX
|
||||
#define LV_VER_RES_MAX (320)
|
||||
#endif
|
||||
|
||||
/*Color settings*/
|
||||
#ifndef LV_COLOR_DEPTH
|
||||
#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/32*/
|
||||
#endif
|
||||
#ifndef LV_COLOR_16_SWAP
|
||||
#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/
|
||||
#endif
|
||||
#ifndef LV_COLOR_SCREEN_TRANSP
|
||||
#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/
|
||||
#endif
|
||||
#ifndef LV_COLOR_TRANSP
|
||||
#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/
|
||||
#endif
|
||||
|
||||
/* Enable anti-aliasing (lines, and radiuses will be smoothed) */
|
||||
#ifndef LV_ANTIALIAS
|
||||
#define LV_ANTIALIAS 1 /*1: Enable anti-aliasing*/
|
||||
#endif
|
||||
|
||||
|
||||
/*Screen refresh period in milliseconds. LittlevGL will redraw the screen with this period*/
|
||||
#ifndef LV_REFR_PERIOD
|
||||
#define LV_REFR_PERIOD 30 /*[ms]*/
|
||||
#endif
|
||||
|
||||
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
|
||||
* (Not so important, you can adjust it to modify default sizes and spaces)*/
|
||||
#ifndef LV_DPI
|
||||
#define LV_DPI 100 /*[px]*/
|
||||
#endif
|
||||
|
||||
/*===================
|
||||
Dynamic memory
|
||||
*===================*/
|
||||
@ -17,7 +61,7 @@
|
||||
#endif
|
||||
#if LV_MEM_CUSTOM == 0
|
||||
#ifndef LV_MEM_SIZE
|
||||
# define LV_MEM_SIZE (64U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
|
||||
# define LV_MEM_SIZE (16U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
|
||||
#endif
|
||||
#ifndef LV_MEM_ATTR
|
||||
# define LV_MEM_ATTR /*Complier prefix for big array declaration*/
|
||||
@ -40,7 +84,8 @@
|
||||
#endif
|
||||
#endif /*LV_MEM_CUSTOM*/
|
||||
|
||||
/* Garbage Collector settings. */
|
||||
/* Garbage Collector settings
|
||||
* Used if lvgl is binded to higher language and the memory is managed by that language */
|
||||
#ifndef LV_ENABLE_GC
|
||||
#define LV_ENABLE_GC 0
|
||||
#endif
|
||||
@ -56,96 +101,13 @@
|
||||
#endif
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
/*===================
|
||||
Graphical settings
|
||||
*===================*/
|
||||
|
||||
/* Horizontal and vertical resolution of the library.*/
|
||||
#ifndef LV_HOR_RES
|
||||
#define LV_HOR_RES (480)
|
||||
#endif
|
||||
#ifndef LV_VER_RES
|
||||
#define LV_VER_RES (320)
|
||||
#endif
|
||||
|
||||
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
|
||||
* (Not so important, you can adjust it to modify default sizes and spaces)*/
|
||||
#ifndef LV_DPI
|
||||
#define LV_DPI 100
|
||||
#endif
|
||||
|
||||
/* Enable anti-aliasing (lines, and radiuses will be smoothed) */
|
||||
#ifndef LV_ANTIALIAS
|
||||
#define LV_ANTIALIAS 1 /*1: Enable anti-aliasing*/
|
||||
#endif
|
||||
|
||||
/*Screen refresh period in milliseconds*/
|
||||
#ifndef LV_REFR_PERIOD
|
||||
#define LV_REFR_PERIOD 30
|
||||
#endif
|
||||
|
||||
/*-----------------
|
||||
* VDB settings
|
||||
*----------------*/
|
||||
|
||||
/* VDB (Virtual Display Buffer) is an internal graphics buffer.
|
||||
* To images will be drawn into this buffer first and then
|
||||
* the buffer will be passed to your `disp_drv.disp_flush` function to
|
||||
* copy it to your frame buffer.
|
||||
* VDB is required for: buffered drawing, opacity, anti-aliasing and shadows
|
||||
* Learn more: https://docs.littlevgl.com/#Drawing*/
|
||||
|
||||
/* Size of the VDB in pixels. Typical size: ~1/10 screen. Must be >= LV_HOR_RES
|
||||
* Setting it to 0 will disable VDB and `disp_drv.disp_fill` and `disp_drv.disp_map` functions
|
||||
* will be called to draw to the frame buffer directly*/
|
||||
#ifndef LV_VDB_SIZE
|
||||
#define LV_VDB_SIZE ((LV_VER_RES * LV_HOR_RES) / 10)
|
||||
#endif
|
||||
|
||||
/* Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays.
|
||||
* Special formats are handled with `disp_drv.vdb_wr`)*/
|
||||
#ifndef LV_VDB_PX_BPP
|
||||
#define LV_VDB_PX_BPP LV_COLOR_SIZE /*LV_COLOR_SIZE comes from LV_COLOR_DEPTH below to set 8, 16 or 32 bit pixel size automatically */
|
||||
#endif
|
||||
|
||||
/* Place VDB to a specific address (e.g. in external RAM)
|
||||
* 0: allocate automatically into RAM
|
||||
* LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/
|
||||
#ifndef LV_VDB_ADR
|
||||
#define LV_VDB_ADR 0
|
||||
#endif
|
||||
|
||||
/* Use two Virtual Display buffers (VDB) parallelize rendering and flushing (optional)
|
||||
* The flushing should use DMA to write the frame buffer in the background */
|
||||
#ifndef LV_VDB_DOUBLE
|
||||
#define LV_VDB_DOUBLE 0
|
||||
#endif
|
||||
|
||||
/* Place VDB2 to a specific address (e.g. in external RAM)
|
||||
* 0: allocate automatically into RAM
|
||||
* LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/
|
||||
#ifndef LV_VDB2_ADR
|
||||
#define LV_VDB2_ADR 0
|
||||
#endif
|
||||
|
||||
/* Using true double buffering in `disp_drv.disp_flush` you will always get the image of the whole screen.
|
||||
* Your only task is to set the rendered image (`color_p` parameter) as frame buffer address or send it to your display.
|
||||
* The best if you do in the blank period of you display to avoid tearing effect.
|
||||
* Requires:
|
||||
* - LV_VDB_SIZE = LV_HOR_RES * LV_VER_RES
|
||||
* - LV_VDB_DOUBLE = 1
|
||||
*/
|
||||
#ifndef LV_VDB_TRUE_DOUBLE_BUFFERED
|
||||
#define LV_VDB_TRUE_DOUBLE_BUFFERED 0
|
||||
#endif
|
||||
|
||||
/*=================
|
||||
Misc. setting
|
||||
*=================*/
|
||||
|
||||
/*Input device settings*/
|
||||
#ifndef LV_INDEV_READ_PERIOD
|
||||
#define LV_INDEV_READ_PERIOD 50 /*Input device read period in milliseconds*/
|
||||
#define LV_INDEV_READ_PERIOD 30 /*Input device read period in milliseconds*/
|
||||
#endif
|
||||
#ifndef LV_INDEV_POINT_MARKER
|
||||
#define LV_INDEV_POINT_MARKER 0 /*Mark the pressed points (required: USE_LV_REAL_DRAW = 1)*/
|
||||
@ -163,20 +125,6 @@
|
||||
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
|
||||
#endif
|
||||
|
||||
/*Color settings*/
|
||||
#ifndef LV_COLOR_DEPTH
|
||||
#define LV_COLOR_DEPTH 32 /*Color depth: 1/8/16/32*/
|
||||
#endif
|
||||
#ifndef LV_COLOR_16_SWAP
|
||||
#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/
|
||||
#endif
|
||||
#ifndef LV_COLOR_SCREEN_TRANSP
|
||||
#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/
|
||||
#endif
|
||||
#ifndef LV_COLOR_TRANSP
|
||||
#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/
|
||||
#endif
|
||||
|
||||
/*Text settings*/
|
||||
#ifndef LV_TXT_UTF8
|
||||
#define LV_TXT_UTF8 1 /*Enable UTF-8 coded Unicode character usage */
|
||||
@ -207,14 +155,17 @@
|
||||
#ifndef USE_LV_GPU
|
||||
#define USE_LV_GPU 1 /*1: Enable GPU interface*/
|
||||
#endif
|
||||
#ifndef USE_LV_REAL_DRAW
|
||||
#define USE_LV_REAL_DRAW 1 /*1: Enable function which draw directly to the frame buffer instead of VDB (required if LV_VDB_SIZE = 0)*/
|
||||
#endif
|
||||
#ifndef USE_LV_FILESYSTEM
|
||||
#define USE_LV_FILESYSTEM 1 /*1: Enable file system (might be required for images*/
|
||||
#endif
|
||||
#ifndef USE_LV_MULTI_LANG
|
||||
#define USE_LV_MULTI_LANG 0 /* Number of languages for labels to store (0: to disable this feature)*/
|
||||
#ifndef USE_LV_I18N
|
||||
#define USE_LV_I18N 1 /*1: Enable InternationalizatioN (multi-language) support*/
|
||||
#endif
|
||||
#ifndef USE_LV_USER_DATA_SINGLE
|
||||
#define USE_LV_USER_DATA_SINGLE 1 /*1: Add a `user_data` to drivers and objects*/
|
||||
#endif
|
||||
#ifndef USE_LV_USER_DATA_MULTI
|
||||
#define USE_LV_USER_DATA_MULTI 0 /*1: Add separate `user_data` for every callback*/
|
||||
#endif
|
||||
|
||||
/*Compiler settings*/
|
||||
@ -237,13 +188,15 @@
|
||||
#endif
|
||||
#if LV_TICK_CUSTOM == 1
|
||||
#ifndef LV_TICK_CUSTOM_INCLUDE
|
||||
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the sys time function*/
|
||||
#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/
|
||||
#endif
|
||||
#ifndef LV_TICK_CUSTOM_SYS_TIME_EXPR
|
||||
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
|
||||
#endif
|
||||
#endif /*LV_TICK_CUSTOM*/
|
||||
|
||||
typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/
|
||||
typedef void * lv_indev_drv_user_data_t; /*Type of user data in the display driver*/
|
||||
|
||||
/*Log settings*/
|
||||
#ifndef USE_LV_LOG
|
||||
@ -253,16 +206,16 @@
|
||||
/* 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 caused problem
|
||||
* 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
|
||||
*/
|
||||
#ifndef LV_LOG_LEVEL
|
||||
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
||||
#endif
|
||||
/* 1: Print the log with 'printf'; 0: user need to register a callback*/
|
||||
|
||||
/* 1: Print the log with 'printf'; 0: user need to register a callback*/
|
||||
#ifndef LV_LOG_PRINTF
|
||||
# define LV_LOG_PRINTF 1
|
||||
# define LV_LOG_PRINTF 0
|
||||
#endif
|
||||
#endif /*USE_LV_LOG*/
|
||||
|
||||
@ -270,7 +223,7 @@
|
||||
* THEME USAGE
|
||||
*================*/
|
||||
#ifndef LV_THEME_LIVE_UPDATE
|
||||
#define LV_THEME_LIVE_UPDATE 1 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/
|
||||
#define LV_THEME_LIVE_UPDATE 0 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/
|
||||
#endif
|
||||
|
||||
#ifndef USE_LV_THEME_TEMPL
|
||||
@ -306,16 +259,16 @@
|
||||
* To enable a built-in font use 1,2,4 or 8 values
|
||||
* which will determine the bit-per-pixel. Higher value means smoother fonts */
|
||||
#ifndef USE_LV_FONT_DEJAVU_10
|
||||
#define USE_LV_FONT_DEJAVU_10 4
|
||||
#define USE_LV_FONT_DEJAVU_10 0
|
||||
#endif
|
||||
#ifndef USE_LV_FONT_DEJAVU_10_LATIN_SUP
|
||||
#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 4
|
||||
#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 0
|
||||
#endif
|
||||
#ifndef USE_LV_FONT_DEJAVU_10_CYRILLIC
|
||||
#define USE_LV_FONT_DEJAVU_10_CYRILLIC 4
|
||||
#define USE_LV_FONT_DEJAVU_10_CYRILLIC 0
|
||||
#endif
|
||||
#ifndef USE_LV_FONT_SYMBOL_10
|
||||
#define USE_LV_FONT_SYMBOL_10 4
|
||||
#define USE_LV_FONT_SYMBOL_10 0
|
||||
#endif
|
||||
|
||||
#ifndef USE_LV_FONT_DEJAVU_20
|
||||
@ -332,29 +285,29 @@
|
||||
#endif
|
||||
|
||||
#ifndef USE_LV_FONT_DEJAVU_30
|
||||
#define USE_LV_FONT_DEJAVU_30 4
|
||||
#define USE_LV_FONT_DEJAVU_30 0
|
||||
#endif
|
||||
#ifndef USE_LV_FONT_DEJAVU_30_LATIN_SUP
|
||||
#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 4
|
||||
#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 0
|
||||
#endif
|
||||
#ifndef USE_LV_FONT_DEJAVU_30_CYRILLIC
|
||||
#define USE_LV_FONT_DEJAVU_30_CYRILLIC 4
|
||||
#define USE_LV_FONT_DEJAVU_30_CYRILLIC 0
|
||||
#endif
|
||||
#ifndef USE_LV_FONT_SYMBOL_30
|
||||
#define USE_LV_FONT_SYMBOL_30 4
|
||||
#define USE_LV_FONT_SYMBOL_30 0
|
||||
#endif
|
||||
|
||||
#ifndef USE_LV_FONT_DEJAVU_40
|
||||
#define USE_LV_FONT_DEJAVU_40 4
|
||||
#define USE_LV_FONT_DEJAVU_40 0
|
||||
#endif
|
||||
#ifndef USE_LV_FONT_DEJAVU_40_LATIN_SUP
|
||||
#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 4
|
||||
#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 0
|
||||
#endif
|
||||
#ifndef USE_LV_FONT_DEJAVU_40_CYRILLIC
|
||||
#define USE_LV_FONT_DEJAVU_40_CYRILLIC 4
|
||||
#define USE_LV_FONT_DEJAVU_40_CYRILLIC 0
|
||||
#endif
|
||||
#ifndef USE_LV_FONT_SYMBOL_40
|
||||
#define USE_LV_FONT_SYMBOL_40 4
|
||||
#define USE_LV_FONT_SYMBOL_40 0
|
||||
#endif
|
||||
|
||||
#ifndef USE_LV_FONT_MONOSPACE_8
|
||||
@ -386,7 +339,7 @@
|
||||
#define LV_OBJ_FREE_PTR 1 /*Enable the free pointer attribute*/
|
||||
#endif
|
||||
#ifndef LV_OBJ_REALIGN
|
||||
#define LV_OBJ_REALIGN 0 /*Enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/
|
||||
#define LV_OBJ_REALIGN 1 /*Enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/
|
||||
#endif
|
||||
|
||||
/*==================
|
||||
|
138
lv_conf_templ.h
138
lv_conf_templ.h
@ -9,8 +9,35 @@
|
||||
|
||||
#if 0 /*Set it to "1" to enable content*/
|
||||
|
||||
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
|
||||
/*===================
|
||||
Graphical settings
|
||||
*===================*/
|
||||
|
||||
/* Horizontal and vertical resolution of the library.*/
|
||||
#define LV_HOR_RES_MAX (480)
|
||||
#define LV_VER_RES_MAX (320)
|
||||
|
||||
/*Color settings*/
|
||||
#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/32*/
|
||||
#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/
|
||||
#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/
|
||||
#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/
|
||||
|
||||
/* Enable anti-aliasing (lines, and radiuses will be smoothed) */
|
||||
#define LV_ANTIALIAS 1 /*1: Enable anti-aliasing*/
|
||||
|
||||
|
||||
/*Screen refresh period in milliseconds. LittlevGL will redraw the screen with this period*/
|
||||
#define LV_REFR_PERIOD 30 /*[ms]*/
|
||||
|
||||
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
|
||||
* (Not so important, you can adjust it to modify default sizes and spaces)*/
|
||||
#define LV_DPI 100 /*[px]*/
|
||||
|
||||
/*===================
|
||||
Dynamic memory
|
||||
*===================*/
|
||||
@ -19,7 +46,7 @@
|
||||
* to store the graphical objects and other data */
|
||||
#define LV_MEM_CUSTOM 0 /*1: use custom malloc/free, 0: use the built-in lv_mem_alloc/lv_mem_free*/
|
||||
#if LV_MEM_CUSTOM == 0
|
||||
# define LV_MEM_SIZE (64U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
|
||||
# define LV_MEM_SIZE (16U * 1024U) /*Size memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
|
||||
# define LV_MEM_ATTR /*Complier prefix for big array declaration*/
|
||||
# define LV_MEM_ADR 0 /*Set an address for memory pool instead of allocation it as an array. Can be in external SRAM too.*/
|
||||
# define LV_MEM_AUTO_DEFRAG 1 /*Automatically defrag on free*/
|
||||
@ -38,85 +65,18 @@
|
||||
# define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/
|
||||
#endif /* LV_ENABLE_GC */
|
||||
|
||||
/*===================
|
||||
Graphical settings
|
||||
*===================*/
|
||||
|
||||
/* Horizontal and vertical resolution of the library.*/
|
||||
#define LV_HOR_RES (480)
|
||||
#define LV_VER_RES (320)
|
||||
|
||||
/* Dot Per Inch: used to initialize default sizes. E.g. a button with width = LV_DPI / 2 -> half inch wide
|
||||
* (Not so important, you can adjust it to modify default sizes and spaces)*/
|
||||
#define LV_DPI 100
|
||||
|
||||
/* Enable anti-aliasing (lines, and radiuses will be smoothed) */
|
||||
#define LV_ANTIALIAS 1 /*1: Enable anti-aliasing*/
|
||||
|
||||
/*Screen refresh period in milliseconds*/
|
||||
#define LV_REFR_PERIOD 30
|
||||
|
||||
/*-----------------
|
||||
* VDB settings
|
||||
*----------------*/
|
||||
|
||||
/* VDB (Virtual Display Buffer) is an internal graphics buffer.
|
||||
* The GUI will be drawn into this buffer first and then
|
||||
* the buffer will be passed to your `disp_drv.disp_flush` function to
|
||||
* copy it to your frame buffer.
|
||||
* VDB is required for: buffered drawing, opacity, anti-aliasing and shadows
|
||||
* Learn more: https://docs.littlevgl.com/#Drawing*/
|
||||
|
||||
/* Size of the VDB in pixels. Typical size: ~1/10 screen. Must be >= LV_HOR_RES
|
||||
* Setting it to 0 will disable VDB and `disp_drv.disp_fill` and `disp_drv.disp_map` functions
|
||||
* will be called to draw to the frame buffer directly*/
|
||||
#define LV_VDB_SIZE ((LV_VER_RES * LV_HOR_RES) / 10)
|
||||
|
||||
/* Bit-per-pixel of VDB. Useful for monochrome or non-standard color format displays.
|
||||
* Special formats are handled with `disp_drv.vdb_wr`)*/
|
||||
#define LV_VDB_PX_BPP LV_COLOR_SIZE /*LV_COLOR_SIZE comes from LV_COLOR_DEPTH below to set 8, 16 or 32 bit pixel size automatically */
|
||||
|
||||
/* Place VDB to a specific address (e.g. in external RAM)
|
||||
* 0: allocate automatically into RAM
|
||||
* LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/
|
||||
#define LV_VDB_ADR 0
|
||||
|
||||
/* Use two Virtual Display buffers (VDB) to parallelize rendering and flushing
|
||||
* The flushing should use DMA to write the frame buffer in the background */
|
||||
#define LV_VDB_DOUBLE 0
|
||||
|
||||
/* Place VDB2 to a specific address (e.g. in external RAM)
|
||||
* 0: allocate automatically into RAM
|
||||
* LV_VDB_ADR_INV: to replace it later with `lv_vdb_set_adr()`*/
|
||||
#define LV_VDB2_ADR 0
|
||||
|
||||
/* Using true double buffering in `disp_drv.disp_flush` you will always get the image of the whole screen.
|
||||
* Your only task is to set the rendered image (`color_p` parameter) as frame buffer address or send it to your display.
|
||||
* The best if you do in the blank period of you display to avoid tearing effect.
|
||||
* Requires:
|
||||
* - LV_VDB_SIZE = LV_HOR_RES * LV_VER_RES
|
||||
* - LV_VDB_DOUBLE = 1
|
||||
*/
|
||||
#define LV_VDB_TRUE_DOUBLE_BUFFERED 0
|
||||
|
||||
/*=================
|
||||
Misc. setting
|
||||
*=================*/
|
||||
|
||||
/*Input device settings*/
|
||||
#define LV_INDEV_READ_PERIOD 50 /*Input device read period in milliseconds*/
|
||||
#define LV_INDEV_READ_PERIOD 30 /*Input device read period in milliseconds*/
|
||||
#define LV_INDEV_POINT_MARKER 0 /*Mark the pressed points (required: USE_LV_REAL_DRAW = 1)*/
|
||||
#define LV_INDEV_DRAG_LIMIT 10 /*Drag threshold in pixels */
|
||||
#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */
|
||||
#define LV_INDEV_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/
|
||||
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
|
||||
|
||||
/*Color settings*/
|
||||
#define LV_COLOR_DEPTH 16 /*Color depth: 1/8/16/32*/
|
||||
#define LV_COLOR_16_SWAP 0 /*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/
|
||||
#define LV_COLOR_SCREEN_TRANSP 0 /*1: Enable screen transparency. Useful for OSD or other overlapping GUIs. Requires ARGB8888 colors*/
|
||||
#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (with chroma keying)*/
|
||||
|
||||
/*Text settings*/
|
||||
#define LV_TXT_UTF8 1 /*Enable UTF-8 coded Unicode character usage */
|
||||
#define LV_TXT_BREAK_CHARS " ,.;:-_" /*Can break texts on these chars*/
|
||||
@ -129,9 +89,10 @@
|
||||
#define USE_LV_SHADOW 1 /*1: Enable shadows*/
|
||||
#define USE_LV_GROUP 1 /*1: Enable object groups (for keyboards)*/
|
||||
#define USE_LV_GPU 1 /*1: Enable GPU interface*/
|
||||
#define USE_LV_REAL_DRAW 1 /*1: Enable function which draw directly to the frame buffer instead of VDB (required if LV_VDB_SIZE = 0)*/
|
||||
#define USE_LV_FILESYSTEM 1 /*1: Enable file system (might be required for images*/
|
||||
#define USE_LV_MULTI_LANG 0 /* Number of languages for labels to store (0: to disable this feature)*/
|
||||
#define USE_LV_I18N 1 /*1: Enable InternationalizatioN (multi-language) support*/
|
||||
#define USE_LV_USER_DATA_SINGLE 1 /*1: Add a `user_data` to drivers and objects*/
|
||||
#define USE_LV_USER_DATA_MULTI 0 /*1: Add separate `user_data` for every callback*/
|
||||
|
||||
/*Compiler settings*/
|
||||
#define LV_ATTRIBUTE_TICK_INC /* Define a custom attribute to `lv_tick_inc` function */
|
||||
@ -142,10 +103,12 @@
|
||||
/*HAL settings*/
|
||||
#define LV_TICK_CUSTOM 0 /*1: use a custom tick source (removing the need to manually update the tick with `lv_tick_inc`) */
|
||||
#if LV_TICK_CUSTOM == 1
|
||||
#define LV_TICK_CUSTOM_INCLUDE "sonething.h" /*Header for the sys time function*/
|
||||
#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/
|
||||
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
|
||||
#endif /*LV_TICK_CUSTOM*/
|
||||
|
||||
typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/
|
||||
typedef void * lv_indev_drv_user_data_t; /*Type of user data in the display driver*/
|
||||
|
||||
/*Log settings*/
|
||||
#define USE_LV_LOG 1 /*Enable/disable the log module*/
|
||||
@ -153,19 +116,19 @@
|
||||
/* 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 caused problem
|
||||
* 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
|
||||
*/
|
||||
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
||||
/* 1: Print the log with 'printf'; 0: user need to register a callback*/
|
||||
|
||||
/* 1: Print the log with 'printf'; 0: user need to register a callback*/
|
||||
# define LV_LOG_PRINTF 0
|
||||
#endif /*USE_LV_LOG*/
|
||||
|
||||
/*================
|
||||
* THEME USAGE
|
||||
*================*/
|
||||
#define LV_THEME_LIVE_UPDATE 1 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/
|
||||
#define LV_THEME_LIVE_UPDATE 0 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/
|
||||
|
||||
#define USE_LV_THEME_TEMPL 0 /*Just for test*/
|
||||
#define USE_LV_THEME_DEFAULT 1 /*Built mainly from the built-in styles. Consumes very few RAM*/
|
||||
@ -183,25 +146,25 @@
|
||||
/* More info about fonts: https://docs.littlevgl.com/#Fonts
|
||||
* To enable a built-in font use 1,2,4 or 8 values
|
||||
* which will determine the bit-per-pixel. Higher value means smoother fonts */
|
||||
#define USE_LV_FONT_DEJAVU_10 4
|
||||
#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 4
|
||||
#define USE_LV_FONT_DEJAVU_10_CYRILLIC 4
|
||||
#define USE_LV_FONT_SYMBOL_10 4
|
||||
#define USE_LV_FONT_DEJAVU_10 0
|
||||
#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_10_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_10 0
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_20 4
|
||||
#define USE_LV_FONT_DEJAVU_20_LATIN_SUP 4
|
||||
#define USE_LV_FONT_DEJAVU_20_CYRILLIC 4
|
||||
#define USE_LV_FONT_SYMBOL_20 4
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_30 4
|
||||
#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 4
|
||||
#define USE_LV_FONT_DEJAVU_30_CYRILLIC 4
|
||||
#define USE_LV_FONT_SYMBOL_30 4
|
||||
#define USE_LV_FONT_DEJAVU_30 0
|
||||
#define USE_LV_FONT_DEJAVU_30_LATIN_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_30_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_30 0
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_40 4
|
||||
#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 4
|
||||
#define USE_LV_FONT_DEJAVU_40_CYRILLIC 4
|
||||
#define USE_LV_FONT_SYMBOL_40 4
|
||||
#define USE_LV_FONT_DEJAVU_40 0
|
||||
#define USE_LV_FONT_DEJAVU_40_LATIN_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_40_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_40 0
|
||||
|
||||
#define USE_LV_FONT_MONOSPACE_8 1
|
||||
|
||||
@ -392,4 +355,5 @@
|
||||
|
||||
#endif /*LV_CONF_H*/
|
||||
|
||||
|
||||
#endif /*End of "Content enable"*/
|
||||
|
@ -1,9 +1,9 @@
|
||||
CSRCS += lv_group.c
|
||||
CSRCS += lv_indev.c
|
||||
CSRCS += lv_disp.c
|
||||
CSRCS += lv_obj.c
|
||||
CSRCS += lv_refr.c
|
||||
CSRCS += lv_style.c
|
||||
CSRCS += lv_vdb.c
|
||||
CSRCS += lv_lang.c
|
||||
|
||||
DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_core
|
||||
|
117
lv_core/lv_disp.c
Normal file
117
lv_core/lv_disp.c
Normal file
@ -0,0 +1,117 @@
|
||||
/**
|
||||
* @file lv_disp.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_disp.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Return with a pointer to the active screen
|
||||
* @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_scr_load()')
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp)
|
||||
{
|
||||
if(!disp) disp = lv_disp_get_default();
|
||||
if(!disp) {
|
||||
LV_LOG_WARN("lv_scr_act: no display registered to get its top layer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return disp->act_scr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a screen active
|
||||
* @param scr pointer to a screen
|
||||
*/
|
||||
void lv_disp_set_scr_act(lv_obj_t * scr)
|
||||
{
|
||||
lv_disp_t * d = lv_obj_get_disp(scr);
|
||||
|
||||
d->act_scr = scr;
|
||||
|
||||
lv_obj_invalidate(scr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the top layer. (Same on every screen 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 (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp)
|
||||
{
|
||||
if(!disp) disp = lv_disp_get_default();
|
||||
if(!disp) {
|
||||
LV_LOG_WARN("lv_layer_top: no display registered to get its top layer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return disp->top_layer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the sys. layer. (Same on every screen and it is above the normal screen and the top layer)
|
||||
* @param disp pointer to display which sys. layer should be get. (NULL to use the default screen)
|
||||
* @return pointer to the sys layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp)
|
||||
{
|
||||
if(!disp) disp = lv_disp_get_default();
|
||||
if(!disp) {
|
||||
LV_LOG_WARN("lv_layer_sys: no display registered to get its top layer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return disp->sys_layer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign a screen to a display.
|
||||
* @param disp pointer to a display where to assign the screen
|
||||
* @param scr pointer to a screen object to assign
|
||||
*/
|
||||
void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr)
|
||||
{
|
||||
if(lv_obj_get_parent(scr) != NULL) {
|
||||
LV_LOG_WARN("lv_disp_assign_screen: try to assign a non-screen object");
|
||||
return;
|
||||
}
|
||||
|
||||
lv_disp_t * old_disp = lv_obj_get_disp(scr);
|
||||
|
||||
if(old_disp == disp) return;
|
||||
|
||||
lv_ll_chg_list(&old_disp->scr_ll, &disp->scr_ll, scr);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
114
lv_core/lv_disp.h
Normal file
114
lv_core/lv_disp.h
Normal file
@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @file lv_disp.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DISP_H
|
||||
#define LV_DISP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_hal/lv_hal.h"
|
||||
#include "lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Return with a pointer to the active screen
|
||||
* @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_scr_load()')
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Make a screen active
|
||||
* @param scr pointer to a screen
|
||||
*/
|
||||
void lv_disp_set_scr_act(lv_obj_t * scr);
|
||||
|
||||
/**
|
||||
* Return with the top layer. (Same on every screen 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 (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Return with the sys. layer. (Same on every screen and it is above the normal screen and the top layer)
|
||||
* @param disp pointer to display which sys. layer should be get. (NULL to use the default screen)
|
||||
* @return pointer to the sys layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Assign a screen to a display.
|
||||
* @param disp pointer to a display where to assign the screen
|
||||
* @param scr pointer to a screen object to assign
|
||||
*/
|
||||
void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr);
|
||||
|
||||
/*------------------------------------------------
|
||||
* To improve backward compatibility
|
||||
* Recommended only if you have one display
|
||||
*------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Get the active screen of the default display
|
||||
* @return pointer to the active screen
|
||||
*/
|
||||
static inline lv_obj_t * lv_scr_act(void)
|
||||
{
|
||||
return lv_disp_get_scr_act(lv_disp_get_default());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top layer of the default display
|
||||
* @return pointer to the top layer
|
||||
*/
|
||||
static inline lv_obj_t * lv_top_layer(void)
|
||||
{
|
||||
return lv_disp_get_layer_top(lv_disp_get_default());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active screen of the deafult display
|
||||
* @return pointer to the sys layer
|
||||
*/
|
||||
static inline lv_obj_t * lv_sys_layer(void)
|
||||
{
|
||||
return lv_disp_get_layer_sys(lv_disp_get_default());
|
||||
}
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/*------------------------------------------------
|
||||
* To improve backward compatibility
|
||||
* Recommended only if you have one display
|
||||
*------------------------------------------------*/
|
||||
|
||||
#define LV_HOR_RES (lv_disp_get_hor_res(lv_disp_get_default());)
|
||||
#define LV_VER_RES (lv_disp_get_ver_res(lv_disp_get_default());)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_TEMPL_H*/
|
@ -8,7 +8,9 @@
|
||||
*********************/
|
||||
#include "lv_group.h"
|
||||
#if USE_LV_GROUP != 0
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include <stddef.h>
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -23,7 +25,9 @@
|
||||
**********************/
|
||||
static void style_mod_def(lv_style_t * style);
|
||||
static void style_mod_edit_def(lv_style_t * style);
|
||||
static void lv_group_refocus(lv_group_t *g);
|
||||
static void refresh_theme(lv_group_t * g, lv_theme_t * th);
|
||||
static void 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 VARIABLES
|
||||
@ -37,24 +41,35 @@ static void lv_group_refocus(lv_group_t *g);
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init. the group module
|
||||
*/
|
||||
void lv_group_init(void)
|
||||
{
|
||||
lv_ll_init(&LV_GC_ROOT(_lv_group_ll), sizeof(lv_group_t));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new object group
|
||||
* @return pointer to the new object group
|
||||
*/
|
||||
lv_group_t * lv_group_create(void)
|
||||
{
|
||||
lv_group_t * group = lv_mem_alloc(sizeof(lv_group_t));
|
||||
lv_group_t * group = lv_ll_ins_head(&LV_GC_ROOT(_lv_group_ll));
|
||||
lv_mem_assert(group);
|
||||
if(group == NULL) return NULL;
|
||||
lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *));
|
||||
|
||||
group->style_mod = style_mod_def;
|
||||
group->style_mod_edit = style_mod_edit_def;
|
||||
group->obj_focus = NULL;
|
||||
group->frozen = 0;
|
||||
group->focus_cb = NULL;
|
||||
group->click_focus = 1;
|
||||
group->editing = 0;
|
||||
group->refocus_policy = LV_GROUP_REFOCUS_POLICY_PREV;
|
||||
group->wrap = 1;
|
||||
|
||||
/*Initialize style modification callbacks from current theme*/
|
||||
refresh_theme(group, lv_theme_get_current());
|
||||
|
||||
return group;
|
||||
}
|
||||
@ -193,29 +208,7 @@ void lv_group_focus_obj(lv_obj_t * obj)
|
||||
*/
|
||||
void lv_group_focus_next(lv_group_t * group)
|
||||
{
|
||||
if(group->frozen) return;
|
||||
|
||||
if(group->obj_focus) {
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
lv_obj_t ** obj_next;
|
||||
if(group->obj_focus == NULL) obj_next = lv_ll_get_head(&group->obj_ll);
|
||||
else obj_next = lv_ll_get_next(&group->obj_ll, group->obj_focus);
|
||||
|
||||
if(obj_next == NULL) {
|
||||
if(group->wrap) obj_next = lv_ll_get_head(&group->obj_ll);
|
||||
else obj_next = lv_ll_get_tail(&group->obj_ll);
|
||||
}
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
if(group->obj_focus) {
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
|
||||
if(group->focus_cb) group->focus_cb(group);
|
||||
}
|
||||
focus_next_core(group, lv_ll_get_head, lv_ll_get_next);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,30 +217,7 @@ void lv_group_focus_next(lv_group_t * group)
|
||||
*/
|
||||
void lv_group_focus_prev(lv_group_t * group)
|
||||
{
|
||||
if(group->frozen) return;
|
||||
|
||||
if(group->obj_focus) {
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
lv_obj_t ** obj_next;
|
||||
if(group->obj_focus == NULL) obj_next = lv_ll_get_tail(&group->obj_ll);
|
||||
else obj_next = lv_ll_get_prev(&group->obj_ll, group->obj_focus);
|
||||
|
||||
if(obj_next == NULL) {
|
||||
if(group->wrap) obj_next = lv_ll_get_tail(&group->obj_ll);
|
||||
else obj_next = lv_ll_get_head(&group->obj_ll);
|
||||
}
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
if(group->obj_focus != NULL) {
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
|
||||
if(group->focus_cb) group->focus_cb(group);
|
||||
}
|
||||
|
||||
focus_next_core(group, lv_ll_get_tail, lv_ll_get_prev);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -460,6 +430,25 @@ bool lv_group_get_wrap(lv_group_t * group)
|
||||
return group->wrap ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the group that current theme changed and style modification callbacks need to be refreshed.
|
||||
* @param group pointer to group. If NULL then all groups are notified.
|
||||
*/
|
||||
void lv_group_report_style_mod(lv_group_t * group)
|
||||
{
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
|
||||
if(group != NULL) {
|
||||
refresh_theme(group, th);
|
||||
return;
|
||||
}
|
||||
|
||||
lv_group_t * i;
|
||||
LL_READ(LV_GC_ROOT(_lv_group_ll), i) {
|
||||
refresh_theme(i, th);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@ -522,4 +511,73 @@ static void style_mod_edit_def(lv_style_t * style)
|
||||
|
||||
}
|
||||
|
||||
static void refresh_theme(lv_group_t * g, lv_theme_t * th)
|
||||
{
|
||||
g->style_mod = style_mod_def;
|
||||
g->style_mod_edit = style_mod_edit_def;
|
||||
if(th) {
|
||||
if(th->group.style_mod)
|
||||
g->style_mod = th->group.style_mod;
|
||||
if(th->group.style_mod_edit)
|
||||
g->style_mod_edit = th->group.style_mod_edit;
|
||||
}
|
||||
}
|
||||
|
||||
static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *), void * (*move)(const lv_ll_t *, const void *))
|
||||
{
|
||||
if (group->frozen) return;
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if(obj_sentinel == NULL) {
|
||||
obj_sentinel = obj_next;
|
||||
if(obj_sentinel == NULL) return; /*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;
|
||||
}
|
||||
|
||||
can_move = true;
|
||||
|
||||
if(obj_next == NULL) continue;
|
||||
|
||||
/*Hidden objects don't receive focus*/
|
||||
if(!lv_obj_get_hidden(*obj_next)) break;
|
||||
}
|
||||
|
||||
if(obj_next == group->obj_focus) return; /*There's only one visible object and it's already focused*/
|
||||
|
||||
if(group->obj_focus) {
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
|
||||
if(group->focus_cb) group->focus_cb(group);
|
||||
}
|
||||
|
||||
#endif /*USE_LV_GROUP != 0*/
|
||||
|
@ -72,6 +72,12 @@ typedef enum _lv_group_refocus_policy_t {
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init. the group module
|
||||
* @remarks Internal function, do not call directly.
|
||||
*/
|
||||
void lv_group_init(void);
|
||||
|
||||
/**
|
||||
* Create a new object group
|
||||
* @return pointer to the new object group
|
||||
@ -236,6 +242,12 @@ bool lv_group_get_click_focus(const lv_group_t * group);
|
||||
*/
|
||||
bool lv_group_get_wrap(lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Notify the group that current theme changed and style modification callbacks need to be refreshed.
|
||||
* @param group pointer to group. If NULL then all groups are notified.
|
||||
*/
|
||||
void lv_group_report_style_mod(lv_group_t * group);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
256
lv_core/lv_i18n.c
Normal file
256
lv_core/lv_i18n.c
Normal file
@ -0,0 +1,256 @@
|
||||
/**
|
||||
* @file lv_i18n.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_i18n.h"
|
||||
#if USE_LV_I18N
|
||||
|
||||
#include "lv_obj.h"
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static const void * lv_i18n_get_text_core(const lv_i18n_trans_t * trans, const char * msg_id);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static const lv_i18n_lang_pack_t * languages;
|
||||
static const lv_i18n_lang_t * local_lang;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Set the languages for internationalization
|
||||
* @param langs pointer to the array of languages. (Last element has to be `NULL`)
|
||||
* @return 0: no error; < 0: error
|
||||
*/
|
||||
int lv_i18n_init(const lv_i18n_lang_pack_t * langs)
|
||||
{
|
||||
if(langs == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_init: `langs` can't be NULL");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(langs[0] == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_init: `langs` need to contain at least one translation");
|
||||
return -1;
|
||||
}
|
||||
|
||||
languages = langs;
|
||||
local_lang = langs[0]; /*Automatically select the first language*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the localization (language)
|
||||
* @param lang_code name of the translation to use. E.g. "en_GB"
|
||||
* @return 0: no error; < 0: error
|
||||
*/
|
||||
int lv_i18n_set_local(const char * lang_code)
|
||||
{
|
||||
if(languages == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_set_local: The languages are not set with lv_i18n_init() yet");
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint16_t i;
|
||||
for(i = 0; languages[i] != NULL; i++) {
|
||||
if(strcmp(languages[i]->name, lang_code) == 0) break; /*A language has found*/
|
||||
}
|
||||
|
||||
/*The language wasn't found*/
|
||||
if(languages[i] == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_set_local: The selected language doesn't found");
|
||||
return -1;
|
||||
}
|
||||
|
||||
local_lang = languages[i];
|
||||
|
||||
LV_LOG_INFO("lv_i18n_set_local: new local selected")
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the translation from a message ID
|
||||
* @param msg_id message ID
|
||||
* @return the translation of `msg_id` on the set local
|
||||
*/
|
||||
const char * lv_i18n_get_text(const char * msg_id)
|
||||
{
|
||||
if(local_lang == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_get_text: No language selected");
|
||||
return msg_id;
|
||||
}
|
||||
|
||||
const lv_i18n_lang_t * lang = local_lang;
|
||||
|
||||
if(lang->simple == NULL) {
|
||||
if(lang == languages[0]) {
|
||||
LV_LOG_WARN("lv_i18n_get_text: No translations are specified even on the default language.");
|
||||
return msg_id;
|
||||
} else {
|
||||
LV_LOG_WARN("lv_i18n_get_text: No translations are specified on the current local. Fallback to the default language");
|
||||
lang = languages[0];
|
||||
}
|
||||
|
||||
if(lang->simple == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_get_text: No translations are specified even on the default language.");
|
||||
return msg_id;
|
||||
}
|
||||
}
|
||||
|
||||
/*Find the translation*/
|
||||
const void * txt = lv_i18n_get_text_core(lang->simple, msg_id);
|
||||
if(txt == NULL) {
|
||||
if(lang == languages[0]) {
|
||||
LV_LOG_WARN("lv_i18n_get_text: No translation found even on the default language");
|
||||
return msg_id;
|
||||
} else {
|
||||
LV_LOG_WARN("lv_i18n_get_text: No translation found on this language. Fallback to the default language");
|
||||
lang = languages[0];
|
||||
}
|
||||
}
|
||||
|
||||
/*Try again with the default language*/
|
||||
if(lang->simple == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_get_text: No translations are specified even on the default language.");
|
||||
return msg_id;
|
||||
}
|
||||
|
||||
txt = lv_i18n_get_text_core(lang->simple, msg_id);
|
||||
if(txt == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_get_text: No translation found even on the default language");
|
||||
return msg_id;
|
||||
}
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the translation from a message ID and apply the language's plural rule to get correct form
|
||||
* @param msg_id message ID
|
||||
* @param num an integer to select the correct plural form
|
||||
* @return the translation of `msg_id` on the set local
|
||||
*/
|
||||
const char * lv_i18n_get_text_plural(const char * msg_id, int32_t num)
|
||||
{
|
||||
if(local_lang == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_get_text_plural: No language selected");
|
||||
return msg_id;
|
||||
}
|
||||
|
||||
const lv_i18n_lang_t * lang = local_lang;
|
||||
|
||||
if(lang->plurals == NULL || lang->plural_rule == NULL) {
|
||||
if(lang == languages[0]) {
|
||||
LV_LOG_WARN("lv_i18n_get_text_plural: No plurals or plural rule has defined even on the default language");
|
||||
return msg_id;
|
||||
} else {
|
||||
LV_LOG_WARN("lv_i18n_get_text_plural: o plurals or plural rule has defined for the language. Fallback to the default language");
|
||||
lang = languages[0];
|
||||
}
|
||||
|
||||
if(lang->plurals == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_get_text_plural: o plurals or plural rule has defined even on the default language");
|
||||
return msg_id;
|
||||
}
|
||||
}
|
||||
|
||||
lv_i18n_plural_type_t ptype = lang->plural_rule(num);
|
||||
|
||||
if(lang->plurals[ptype] == NULL) {
|
||||
if(lang == languages[0]) {
|
||||
LV_LOG_WARN("lv_i18n_get_text_plural: No translations of the required plural form even on the default language.");
|
||||
return msg_id;
|
||||
} else {
|
||||
LV_LOG_WARN("lv_i18n_get_text_plural:No translations of the required plural form for the language. Fallback to the default language");
|
||||
lang = languages[0];
|
||||
}
|
||||
}
|
||||
|
||||
/*Find the translation*/
|
||||
const void * txt = lv_i18n_get_text_core(lang->plurals[ptype], msg_id);
|
||||
if(txt == NULL) {
|
||||
if(lang == languages[0]) {
|
||||
LV_LOG_WARN("lv_i18n_get_text_plural: No translation found even on the default language");
|
||||
return msg_id;
|
||||
} else {
|
||||
LV_LOG_WARN("lv_i18n_get_text_plural: No translation found on this language. Fallback to the default language");
|
||||
lang = languages[0];
|
||||
}
|
||||
}
|
||||
|
||||
/*Try again with the default language*/
|
||||
if(lang->plurals == NULL || lang->plural_rule == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_get_text_plural: No plurals or plural rule has defined even on the default language");
|
||||
return msg_id;
|
||||
}
|
||||
|
||||
ptype = lang->plural_rule(num);
|
||||
if(lang->plurals[ptype] == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_get_text_plural: No translations of the required plural form even on the default language.");
|
||||
return msg_id;
|
||||
}
|
||||
|
||||
txt = lv_i18n_get_text_core(lang->plurals[ptype], msg_id);
|
||||
|
||||
if(txt == NULL) {
|
||||
LV_LOG_WARN("lv_i18n_get_text_plural: No translation found even on the default language");
|
||||
return msg_id;
|
||||
}
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the currently used localization.
|
||||
* @return name of the currently used localization. E.g. "en_GB"
|
||||
*/
|
||||
const char * lv_i18n_get_current_local(void)
|
||||
{
|
||||
if(local_lang) return local_lang->name;
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static const void * lv_i18n_get_text_core(const lv_i18n_trans_t * trans, const char * msg_id)
|
||||
{
|
||||
uint16_t i;
|
||||
for(i = 0; trans[i].msg_id != NULL; i++) {
|
||||
if(strcmp(trans[i].msg_id, msg_id) == 0) {
|
||||
/*The msg_id has found. Check the translation*/
|
||||
if(trans[i].txt_trans) return trans[i].txt_trans;
|
||||
}
|
||||
}
|
||||
|
||||
LV_LOG_TRACE("lv_i18n_get_text_core: `msg_id` wasn't found");
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
#endif /*USE_LV_I18N*/
|
108
lv_core/lv_i18n.h
Normal file
108
lv_core/lv_i18n.h
Normal file
@ -0,0 +1,108 @@
|
||||
/**
|
||||
* @file lv_lang.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_I18N_H
|
||||
#define LV_I18N_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#ifdef LV_CONF_INCLUDE_SIMPLE
|
||||
#include "lv_conf.h"
|
||||
#else
|
||||
#include "../../lv_conf.h"
|
||||
#endif
|
||||
|
||||
#if USE_LV_I18N
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum {
|
||||
LV_I18N_PLURAL_TYPE_ZERO,
|
||||
LV_I18N_PLURAL_TYPE_ONE,
|
||||
LV_I18N_PLURAL_TYPE_TWO,
|
||||
LV_I18N_PLURAL_TYPE_FEW,
|
||||
LV_I18N_PLURAL_TYPE_MANY,
|
||||
LV_I18N_PLURAL_TYPE_OTHER,
|
||||
_LV_I18N_PLURAL_TYPE_NUM,
|
||||
}lv_i18n_plural_type_t;
|
||||
|
||||
typedef struct {
|
||||
const char * msg_id;
|
||||
const char * txt_trans;
|
||||
}lv_i18n_trans_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char * name; /*E.g. "en_GB"*/
|
||||
const lv_i18n_trans_t * simple; /*Translations of simple texts where no plurals are used*/
|
||||
const lv_i18n_trans_t * plurals[_LV_I18N_PLURAL_TYPE_NUM]; /*Translations of the plural forms*/
|
||||
uint8_t (*plural_rule)(int32_t num); /*Function pointer to get the correct plural form for a number*/
|
||||
}lv_i18n_lang_t;
|
||||
|
||||
typedef const lv_i18n_lang_t * lv_i18n_lang_pack_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Set the languages for internationalization
|
||||
* @param langs pointer to the array of languages. (Last element has to be `NULL`)
|
||||
* @return 0: no error; < 0: error
|
||||
*/
|
||||
int lv_i18n_init(const lv_i18n_lang_pack_t * langs);
|
||||
|
||||
/**
|
||||
* Change the localization (language)
|
||||
* @param lang_code name of the translation to use. E.g. "en_GB"
|
||||
* @return 0: no error; < 0: error
|
||||
*/
|
||||
int lv_i18n_set_local(const char * lang_code);
|
||||
|
||||
/**
|
||||
* Get the translation from a message ID
|
||||
* @param msg_id message ID
|
||||
* @return the translation of `msg_id` on the set local
|
||||
*/
|
||||
const char * lv_i18n_get_text(const char * msg_id);
|
||||
|
||||
/**
|
||||
* Get the translation from a message ID and apply the language's plural rule to get correct form
|
||||
* @param msg_id message ID
|
||||
* @param num an integer to select the correct plural form
|
||||
* @return the translation of `msg_id` on the set local
|
||||
*/
|
||||
const char * lv_i18n_get_text_plural(const char * msg_id, int32_t num);
|
||||
|
||||
/**
|
||||
* Get the name of the currently used localization.
|
||||
* @return name of the currently used localization. E.g. "en_GB"
|
||||
*/
|
||||
const char * lv_i18n_get_current_local(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_I18N*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_LANG_H*/
|
@ -7,19 +7,23 @@
|
||||
* INCLUDES
|
||||
********************/
|
||||
#include "lv_indev.h"
|
||||
#include "lv_disp.h"
|
||||
#include "lv_obj.h"
|
||||
|
||||
#include "../lv_hal/lv_hal_tick.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_core/lv_refr.h"
|
||||
#include "../lv_misc/lv_task.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_draw/lv_draw_rbasic.h"
|
||||
#include "lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#if LV_INDEV_DRAG_THROW <= 0
|
||||
#warning "LV_INDEV_DRAG_THROW must be greater than 0"
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@ -121,6 +125,7 @@ void lv_indev_reset_lpr(lv_indev_t * indev)
|
||||
*/
|
||||
void lv_indev_enable(lv_hal_indev_type_t type, bool enable)
|
||||
{
|
||||
|
||||
lv_indev_t * i = lv_indev_next(NULL);
|
||||
|
||||
while(i) {
|
||||
@ -139,8 +144,8 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj)
|
||||
if(indev->driver.type != LV_INDEV_TYPE_POINTER) return;
|
||||
|
||||
indev->cursor = cur_obj;
|
||||
lv_obj_set_parent(indev->cursor, lv_layer_sys());
|
||||
lv_obj_set_pos(indev->cursor, indev->proc.act_point.x, indev->proc.act_point.y);
|
||||
lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp));
|
||||
lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y);
|
||||
}
|
||||
|
||||
#if USE_LV_GROUP
|
||||
@ -187,8 +192,8 @@ void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point)
|
||||
point->x = -1;
|
||||
point->y = -1;
|
||||
} else {
|
||||
point->x = indev->proc.act_point.x;
|
||||
point->y = indev->proc.act_point.y;
|
||||
point->x = indev->proc.types.pointer.act_point.x;
|
||||
point->y = indev->proc.types.pointer.act_point.y;
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,7 +205,7 @@ void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point)
|
||||
uint32_t lv_indev_get_key(const lv_indev_t * indev)
|
||||
{
|
||||
if(indev->driver.type != LV_INDEV_TYPE_KEYPAD) return 0;
|
||||
else return indev->proc.last_key;
|
||||
else return indev->proc.types.keypad.last_key;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -212,13 +217,13 @@ bool lv_indev_is_dragging(const lv_indev_t * indev)
|
||||
{
|
||||
if(indev == NULL) return false;
|
||||
if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) return false;
|
||||
return indev->proc.drag_in_prog == 0 ? false : true;
|
||||
return indev->proc.types.pointer.drag_in_prog == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
|
||||
* Get the types.pointer.vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
|
||||
* @param indev pointer to an input device
|
||||
* @param point pointer to a point to store the vector
|
||||
* @param point pointer to a point to store the types.pointer.vector
|
||||
*/
|
||||
void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point)
|
||||
{
|
||||
@ -232,8 +237,8 @@ void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point)
|
||||
point->x = 0;
|
||||
point->y = 0;
|
||||
} else {
|
||||
point->x = indev->proc.vect.x;
|
||||
point->y = indev->proc.vect.y;
|
||||
point->x = indev->proc.types.pointer.vect.x;
|
||||
point->y = indev->proc.types.pointer.vect.y;
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,6 +249,7 @@ void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point)
|
||||
*/
|
||||
uint32_t lv_indev_get_inactive_time(const lv_indev_t * indev)
|
||||
{
|
||||
|
||||
uint32_t t;
|
||||
|
||||
if(indev) return t = lv_tick_elaps(indev->last_activity_time);
|
||||
@ -275,7 +281,7 @@ lv_indev_feedback_t lv_indev_get_feedback(const lv_indev_t *indev)
|
||||
*/
|
||||
void lv_indev_wait_release(lv_indev_t * indev)
|
||||
{
|
||||
indev->proc.wait_unil_release = 1;
|
||||
indev->proc.types.pointer.wait_unil_release = 1;
|
||||
}
|
||||
|
||||
/**********************
|
||||
@ -348,30 +354,22 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
{
|
||||
/*Move the cursor if set and moved*/
|
||||
if(i->cursor != NULL &&
|
||||
(i->proc.last_point.x != data->point.x ||
|
||||
i->proc.last_point.y != data->point.y)) {
|
||||
(i->proc.types.pointer.last_point.x != data->point.x ||
|
||||
i->proc.types.pointer.last_point.y != data->point.y)) {
|
||||
lv_obj_set_pos(i->cursor, data->point.x, data->point.y);
|
||||
}
|
||||
|
||||
i->proc.act_point.x = data->point.x;
|
||||
i->proc.act_point.y = data->point.y;
|
||||
i->proc.types.pointer.act_point.x = data->point.x;
|
||||
i->proc.types.pointer.act_point.y = data->point.y;
|
||||
|
||||
if(i->proc.state == LV_INDEV_STATE_PR) {
|
||||
#if LV_INDEV_POINT_MARKER != 0
|
||||
lv_area_t area;
|
||||
area.x1 = i->proc.act_point.x - (LV_INDEV_POINT_MARKER >> 1);
|
||||
area.y1 = i->proc.act_point.y - (LV_INDEV_POINT_MARKER >> 1);
|
||||
area.x2 = i->proc.act_point.x + ((LV_INDEV_POINT_MARKER >> 1) | 0x1);
|
||||
area.y2 = i->proc.act_point.y + ((LV_INDEV_POINT_MARKER >> 1) | 0x1);
|
||||
lv_rfill(&area, NULL, LV_COLOR_MAKE(0xFF, 0, 0), LV_OPA_COVER);
|
||||
#endif
|
||||
indev_proc_press(&i->proc);
|
||||
} else {
|
||||
indev_proc_release(&i->proc);
|
||||
}
|
||||
|
||||
i->proc.last_point.x = i->proc.act_point.x;
|
||||
i->proc.last_point.y = i->proc.act_point.y;
|
||||
i->proc.types.pointer.last_point.x = i->proc.types.pointer.act_point.x;
|
||||
i->proc.types.pointer.last_point.y = i->proc.types.pointer.act_point.y;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -386,7 +384,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
|
||||
/*Key press happened*/
|
||||
if(data->state == LV_INDEV_STATE_PR &&
|
||||
i->proc.last_state == LV_INDEV_STATE_REL) {
|
||||
i->proc.types.keypad.last_state == LV_INDEV_STATE_REL) {
|
||||
i->proc.pr_timestamp = lv_tick_get();
|
||||
lv_obj_t * focused = lv_group_get_focused(i->group);
|
||||
if(focused && data->key == LV_GROUP_KEY_ENTER) {
|
||||
@ -394,7 +392,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
}
|
||||
/*Pressing*/
|
||||
else if(data->state == LV_INDEV_STATE_PR && i->proc.last_state == LV_INDEV_STATE_PR) {
|
||||
else if(data->state == LV_INDEV_STATE_PR && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) {
|
||||
if(data->key == LV_GROUP_KEY_ENTER &&
|
||||
i->proc.long_pr_sent == 0 &&
|
||||
lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
|
||||
@ -407,9 +405,9 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
}
|
||||
/*Release happened*/
|
||||
else if(data->state == LV_INDEV_STATE_REL && i->proc.last_state == LV_INDEV_STATE_PR) {
|
||||
else if(data->state == LV_INDEV_STATE_REL && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) {
|
||||
/*The user might clear the key when it was released. Always release the pressed key*/
|
||||
data->key = i->proc.last_key;
|
||||
data->key = i->proc.types.keypad.last_key;
|
||||
|
||||
/* Edit mode is not used by KEYPAD devices.
|
||||
* So leave edit mode if we are in it before focusing on the next/prev object*/
|
||||
@ -435,8 +433,8 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
i->proc.long_pr_sent = 0;
|
||||
}
|
||||
|
||||
i->proc.last_state = data->state;
|
||||
i->proc.last_key = data->key;
|
||||
i->proc.types.keypad.last_state = data->state;
|
||||
i->proc.types.keypad.last_key = data->key;
|
||||
#else
|
||||
(void)data; /*Unused*/
|
||||
(void)i; /*Unused*/
|
||||
@ -477,11 +475,11 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
|
||||
/*Key press happened*/
|
||||
if(data->state == LV_INDEV_STATE_PR &&
|
||||
i->proc.last_state == LV_INDEV_STATE_REL) {
|
||||
i->proc.types.keypad.last_state == LV_INDEV_STATE_REL) {
|
||||
i->proc.pr_timestamp = lv_tick_get();
|
||||
}
|
||||
/*Pressing*/
|
||||
else if(data->state == LV_INDEV_STATE_PR && i->proc.last_state == LV_INDEV_STATE_PR) {
|
||||
else if(data->state == LV_INDEV_STATE_PR && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) {
|
||||
if(i->proc.long_pr_sent == 0 &&
|
||||
lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
|
||||
/*On enter long press leave edit mode.*/
|
||||
@ -505,7 +503,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
}
|
||||
}
|
||||
/*Release happened*/
|
||||
else if(data->state == LV_INDEV_STATE_REL && i->proc.last_state == LV_INDEV_STATE_PR) {
|
||||
else if(data->state == LV_INDEV_STATE_REL && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) {
|
||||
lv_obj_t * focused = lv_group_get_focused(i->group);
|
||||
bool editable = false;
|
||||
if(focused) focused->signal_func(focused, LV_SIGNAL_GET_EDITABLE, &editable);
|
||||
@ -530,8 +528,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
i->proc.long_pr_sent = 0;
|
||||
}
|
||||
|
||||
i->proc.last_state = data->state;
|
||||
i->proc.last_key = data->key;
|
||||
i->proc.types.keypad.last_state = data->state;
|
||||
i->proc.types.keypad.last_key = data->key;
|
||||
#else
|
||||
(void)data; /*Unused*/
|
||||
(void)i; /*Unused*/
|
||||
@ -546,29 +544,22 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
*/
|
||||
static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
{
|
||||
i->proc.act_point.x = i->btn_points[data->btn].x;
|
||||
i->proc.act_point.y = i->btn_points[data->btn].y;
|
||||
i->proc.types.pointer.act_point.x = i->btn_points[data->btn_id].x;
|
||||
i->proc.types.pointer.act_point.y = i->btn_points[data->btn_id].y;
|
||||
|
||||
/*Still the same point is pressed*/
|
||||
if(i->proc.last_point.x == i->proc.act_point.x &&
|
||||
i->proc.last_point.y == i->proc.act_point.y &&
|
||||
data->state == LV_INDEV_STATE_PR) {
|
||||
#if LV_INDEV_POINT_MARKER != 0
|
||||
lv_area_t area;
|
||||
area.x1 = i->proc.act_point.x - (LV_INDEV_POINT_MARKER >> 1);
|
||||
area.y1 = i->proc.act_point.y - (LV_INDEV_POINT_MARKER >> 1);
|
||||
area.x2 = i->proc.act_point.x + ((LV_INDEV_POINT_MARKER >> 1) | 0x1);
|
||||
area.y2 = i->proc.act_point.y + ((LV_INDEV_POINT_MARKER >> 1) | 0x1);
|
||||
lv_rfill(&area, NULL, LV_COLOR_MAKE(0xFF, 0, 0), LV_OPA_COVER);
|
||||
#endif
|
||||
if(i->proc.types.pointer.last_point.x == i->proc.types.pointer.act_point.x &&
|
||||
i->proc.types.pointer.last_point.y == i->proc.types.pointer.act_point.y &&
|
||||
data->state == LV_INDEV_STATE_PR)
|
||||
{
|
||||
indev_proc_press(&i->proc);
|
||||
} else {
|
||||
/*If a new point comes always make a release*/
|
||||
indev_proc_release(&i->proc);
|
||||
}
|
||||
|
||||
i->proc.last_point.x = i->proc.act_point.x;
|
||||
i->proc.last_point.y = i->proc.act_point.y;
|
||||
i->proc.types.pointer.last_point.x = i->proc.types.pointer.act_point.x;
|
||||
i->proc.types.pointer.last_point.y = i->proc.types.pointer.act_point.y;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -577,20 +568,24 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
*/
|
||||
static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
{
|
||||
lv_obj_t * pr_obj = proc->act_obj;
|
||||
lv_obj_t * pr_obj = proc->types.pointer.act_obj;
|
||||
|
||||
if(proc->wait_unil_release != 0) return;
|
||||
if(proc->types.pointer.wait_unil_release != 0) return;
|
||||
|
||||
lv_disp_t * disp = indev_act->driver.disp;
|
||||
|
||||
/*If there is no last object then search*/
|
||||
if(proc->act_obj == NULL) {
|
||||
pr_obj = indev_search_obj(proc, lv_layer_top());
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_scr_act());
|
||||
if(proc->types.pointer.act_obj == NULL) {
|
||||
pr_obj = indev_search_obj(proc, lv_disp_get_layer_sys(disp));
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_layer_top(disp));
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_scr_act(disp));
|
||||
}
|
||||
/*If there is last object but it is not dragged and not protected also search*/
|
||||
else if(proc->drag_in_prog == 0 &&
|
||||
lv_obj_is_protected(proc->act_obj, LV_PROTECT_PRESS_LOST) == false) {/*Now act_obj != NULL*/
|
||||
pr_obj = indev_search_obj(proc, lv_layer_top());
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_scr_act());
|
||||
else if(proc->types.pointer.drag_in_prog == 0 &&
|
||||
lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_PRESS_LOST) == false) {/*Now types.pointer.act_obj != NULL*/
|
||||
pr_obj = indev_search_obj(proc, lv_disp_get_layer_sys(disp));
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_layer_top(disp));
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(proc, lv_disp_get_scr_act(disp));
|
||||
}
|
||||
/*If a dragable or a protected object was the last then keep it*/
|
||||
else {
|
||||
@ -598,34 +593,34 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
}
|
||||
|
||||
/*If a new object was found reset some variables and send a pressed signal*/
|
||||
if(pr_obj != proc->act_obj) {
|
||||
if(pr_obj != proc->types.pointer.act_obj) {
|
||||
|
||||
proc->last_point.x = proc->act_point.x;
|
||||
proc->last_point.y = proc->act_point.y;
|
||||
proc->types.pointer.last_point.x = proc->types.pointer.act_point.x;
|
||||
proc->types.pointer.last_point.y = proc->types.pointer.act_point.y;
|
||||
|
||||
/*If a new object found the previous was lost, so send a signal*/
|
||||
if(proc->act_obj != NULL) {
|
||||
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
|
||||
if(proc->types.pointer.act_obj != NULL) {
|
||||
proc->types.pointer.act_obj->signal_func(proc->types.pointer.act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
|
||||
if(proc->reset_query != 0) return;
|
||||
}
|
||||
|
||||
proc->act_obj = pr_obj; /*Save the pressed object*/
|
||||
proc->last_obj = proc->act_obj; /*Refresh the last_obj*/
|
||||
proc->types.pointer.act_obj = pr_obj; /*Save the pressed object*/
|
||||
proc->types.pointer.last_obj = proc->types.pointer.act_obj; /*Refresh the types.pointer.last_obj*/
|
||||
|
||||
if(proc->act_obj != NULL) {
|
||||
if(proc->types.pointer.act_obj != NULL) {
|
||||
/* Save the time when the obj pressed.
|
||||
* It is necessary to count the long press time.*/
|
||||
proc->pr_timestamp = lv_tick_get();
|
||||
proc->long_pr_sent = 0;
|
||||
proc->drag_range_out = 0;
|
||||
proc->drag_in_prog = 0;
|
||||
proc->drag_sum.x = 0;
|
||||
proc->drag_sum.y = 0;
|
||||
proc->vect.x = 0;
|
||||
proc->vect.y = 0;
|
||||
proc->types.pointer.drag_range_out = 0;
|
||||
proc->types.pointer.drag_in_prog = 0;
|
||||
proc->types.pointer.drag_sum.x = 0;
|
||||
proc->types.pointer.drag_sum.y = 0;
|
||||
proc->types.pointer.vect.x = 0;
|
||||
proc->types.pointer.vect.y = 0;
|
||||
|
||||
/*Search for 'top' attribute*/
|
||||
lv_obj_t * i = proc->act_obj;
|
||||
lv_obj_t * i = proc->types.pointer.act_obj;
|
||||
lv_obj_t * last_top = NULL;
|
||||
while(i != NULL) {
|
||||
if(i->top != 0) last_top = i;
|
||||
@ -641,25 +636,25 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
}
|
||||
|
||||
/*Send a signal about the press*/
|
||||
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_PRESSED, indev_act);
|
||||
proc->types.pointer.act_obj->signal_func(proc->types.pointer.act_obj, LV_SIGNAL_PRESSED, indev_act);
|
||||
if(proc->reset_query != 0) return;
|
||||
}
|
||||
}
|
||||
|
||||
/*Calculate the vector*/
|
||||
proc->vect.x = proc->act_point.x - proc->last_point.x;
|
||||
proc->vect.y = proc->act_point.y - proc->last_point.y;
|
||||
/*Calculate the types.pointer.vector*/
|
||||
proc->types.pointer.vect.x = proc->types.pointer.act_point.x - proc->types.pointer.last_point.x;
|
||||
proc->types.pointer.vect.y = proc->types.pointer.act_point.y - proc->types.pointer.last_point.y;
|
||||
|
||||
/*If there is active object and it can be dragged run the drag*/
|
||||
if(proc->act_obj != NULL) {
|
||||
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_PRESSING, indev_act);
|
||||
if(proc->types.pointer.act_obj != NULL) {
|
||||
proc->types.pointer.act_obj->signal_func(proc->types.pointer.act_obj, LV_SIGNAL_PRESSING, indev_act);
|
||||
if(proc->reset_query != 0) return;
|
||||
|
||||
indev_drag(proc);
|
||||
if(proc->reset_query != 0) return;
|
||||
|
||||
/*If there is no drag then check for long press time*/
|
||||
if(proc->drag_in_prog == 0 && proc->long_pr_sent == 0) {
|
||||
if(proc->types.pointer.drag_in_prog == 0 && proc->long_pr_sent == 0) {
|
||||
/*Send a signal about the long press if enough time elapsed*/
|
||||
if(lv_tick_elaps(proc->pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
|
||||
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act);
|
||||
@ -673,7 +668,7 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
}
|
||||
}
|
||||
/*Send long press repeated signal*/
|
||||
if(proc->drag_in_prog == 0 && proc->long_pr_sent == 1) {
|
||||
if(proc->types.pointer.drag_in_prog == 0 && proc->long_pr_sent == 1) {
|
||||
/*Send a signal about the long press repeate if enough time elapsed*/
|
||||
if(lv_tick_elaps(proc->longpr_rep_timestamp) > LV_INDEV_LONG_PRESS_REP_TIME) {
|
||||
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act);
|
||||
@ -691,31 +686,31 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
*/
|
||||
static void indev_proc_release(lv_indev_proc_t * proc)
|
||||
{
|
||||
if(proc->wait_unil_release != 0) {
|
||||
proc->act_obj = NULL;
|
||||
proc->last_obj = NULL;
|
||||
if(proc->types.pointer.wait_unil_release != 0) {
|
||||
proc->types.pointer.act_obj = NULL;
|
||||
proc->types.pointer.last_obj = NULL;
|
||||
proc->pr_timestamp = 0;
|
||||
proc->longpr_rep_timestamp = 0;
|
||||
proc->wait_unil_release = 0;
|
||||
proc->types.pointer.wait_unil_release = 0;
|
||||
}
|
||||
|
||||
/*Forgot the act obj and send a released signal */
|
||||
if(proc->act_obj != NULL) {
|
||||
if(proc->types.pointer.act_obj != NULL) {
|
||||
/* If the object was protected against press lost then it possible that
|
||||
* the object is already not pressed but still it is the `act_obj`.
|
||||
* In this case send the `LV_SIGNAL_RELEASED` if the indev is ON the `act_obj` */
|
||||
if(lv_obj_is_protected(proc->act_obj, LV_PROTECT_PRESS_LOST)) {
|
||||
* the object is already not pressed but still it is the `types.pointer.act_obj`.
|
||||
* In this case send the `LV_SIGNAL_RELEASED` if the indev is ON the `types.pointer.act_obj` */
|
||||
if(lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_PRESS_LOST)) {
|
||||
/* Search the object on the current current coordinates.
|
||||
* The start object is the object itself. If not ON it the the result will be NULL*/
|
||||
lv_obj_t * obj_on = indev_search_obj(proc, proc->act_obj);
|
||||
if(obj_on == proc->act_obj) proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_RELEASED, indev_act);
|
||||
else proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
|
||||
lv_obj_t * obj_on = indev_search_obj(proc, proc->types.pointer.act_obj);
|
||||
if(obj_on == proc->types.pointer.act_obj) proc->types.pointer.act_obj->signal_func(proc->types.pointer.act_obj, LV_SIGNAL_RELEASED, indev_act);
|
||||
else proc->types.pointer.act_obj->signal_func(proc->types.pointer.act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
|
||||
|
||||
}
|
||||
/* The simple case: `act_obj` was not protected against press lost.
|
||||
/* The simple case: `types.pointer.act_obj` was not protected against press lost.
|
||||
* If it is already not pressed then was handled in `indev_proc_press`*/
|
||||
else {
|
||||
proc->act_obj->signal_func(proc->act_obj, LV_SIGNAL_RELEASED, indev_act);
|
||||
proc->types.pointer.act_obj->signal_func(proc->types.pointer.act_obj, LV_SIGNAL_RELEASED, indev_act);
|
||||
}
|
||||
|
||||
if(proc->reset_query != 0) return;
|
||||
@ -723,15 +718,15 @@ static void indev_proc_release(lv_indev_proc_t * proc)
|
||||
/*Handle click focus*/
|
||||
#if USE_LV_GROUP
|
||||
/*Edit mode is not used by POINTER devices. So leave edit mode if we are in it*/
|
||||
lv_group_t * act_g = lv_obj_get_group(proc->act_obj);
|
||||
lv_group_t * act_g = lv_obj_get_group(proc->types.pointer.act_obj);
|
||||
if(lv_group_get_editing(act_g)) {
|
||||
lv_group_set_editing(act_g, false);
|
||||
}
|
||||
|
||||
/*Check, if the parent is in a group focus on it.*/
|
||||
if(lv_obj_is_protected(proc->act_obj, LV_PROTECT_CLICK_FOCUS) == false) { /*Respect the click protection*/
|
||||
lv_group_t * g = lv_obj_get_group(proc->act_obj);
|
||||
lv_obj_t * parent = proc->act_obj;
|
||||
if(lv_obj_is_protected(proc->types.pointer.act_obj, LV_PROTECT_CLICK_FOCUS) == false) { /*Respect the click protection*/
|
||||
lv_group_t * g = lv_obj_get_group(proc->types.pointer.act_obj);
|
||||
lv_obj_t * parent = proc->types.pointer.act_obj;
|
||||
|
||||
while(g == NULL) {
|
||||
parent = lv_obj_get_parent(parent);
|
||||
@ -751,14 +746,14 @@ static void indev_proc_release(lv_indev_proc_t * proc)
|
||||
#endif
|
||||
|
||||
if(proc->reset_query != 0) return;
|
||||
proc->act_obj = NULL;
|
||||
proc->types.pointer.act_obj = NULL;
|
||||
proc->pr_timestamp = 0;
|
||||
proc->longpr_rep_timestamp = 0;
|
||||
}
|
||||
|
||||
/*The reset can be set in the signal function.
|
||||
* In case of reset query ignore the remaining parts.*/
|
||||
if(proc->last_obj != NULL && proc->reset_query == 0) {
|
||||
if(proc->types.pointer.last_obj != NULL && proc->reset_query == 0) {
|
||||
indev_drag_throw(proc);
|
||||
if(proc->reset_query != 0) return;
|
||||
}
|
||||
@ -774,15 +769,15 @@ static void indev_proc_release(lv_indev_proc_t * proc)
|
||||
static void indev_proc_reset_query_handler(lv_indev_t * indev)
|
||||
{
|
||||
if(indev->proc.reset_query) {
|
||||
indev->proc.act_obj = NULL;
|
||||
indev->proc.last_obj = NULL;
|
||||
indev->proc.drag_range_out = 0;
|
||||
indev->proc.drag_in_prog = 0;
|
||||
indev->proc.types.pointer.act_obj = NULL;
|
||||
indev->proc.types.pointer.last_obj = NULL;
|
||||
indev->proc.types.pointer.drag_range_out = 0;
|
||||
indev->proc.types.pointer.drag_in_prog = 0;
|
||||
indev->proc.long_pr_sent = 0;
|
||||
indev->proc.pr_timestamp = 0;
|
||||
indev->proc.longpr_rep_timestamp = 0;
|
||||
indev->proc.drag_sum.x = 0;
|
||||
indev->proc.drag_sum.y = 0;
|
||||
indev->proc.types.pointer.drag_sum.x = 0;
|
||||
indev->proc.types.pointer.drag_sum.y = 0;
|
||||
indev->proc.reset_query = 0;
|
||||
}
|
||||
}
|
||||
@ -798,7 +793,7 @@ static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj)
|
||||
|
||||
/*If the point is on this object*/
|
||||
/*Check its children too*/
|
||||
if(lv_area_is_point_on(&obj->coords, &proc->act_point)) {
|
||||
if(lv_area_is_point_on(&obj->coords, &proc->types.pointer.act_point)) {
|
||||
lv_obj_t * i;
|
||||
|
||||
LL_READ(obj->child_ll, i) {
|
||||
@ -828,12 +823,12 @@ static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj)
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the dragging of indev_proc_p->act_obj
|
||||
* Handle the dragging of indev_proc_p->types.pointer.act_obj
|
||||
* @param indev pointer to a input device state
|
||||
*/
|
||||
static void indev_drag(lv_indev_proc_t * state)
|
||||
{
|
||||
lv_obj_t * drag_obj = state->act_obj;
|
||||
lv_obj_t * drag_obj = state->types.pointer.act_obj;
|
||||
|
||||
/*If drag parent is active check recursively the drag_parent attribute*/
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
||||
@ -846,43 +841,43 @@ static void indev_drag(lv_indev_proc_t * state)
|
||||
if(lv_obj_get_drag(drag_obj) == false) return;
|
||||
|
||||
/*Count the movement by drag*/
|
||||
state->drag_sum.x += state->vect.x;
|
||||
state->drag_sum.y += state->vect.y;
|
||||
state->types.pointer.drag_sum.x += state->types.pointer.vect.x;
|
||||
state->types.pointer.drag_sum.y += state->types.pointer.vect.y;
|
||||
|
||||
/*Enough move?*/
|
||||
if(state->drag_range_out == 0) {
|
||||
if(state->types.pointer.drag_range_out == 0) {
|
||||
/*If a move is greater then LV_DRAG_LIMIT then begin the drag*/
|
||||
if(LV_MATH_ABS(state->drag_sum.x) >= LV_INDEV_DRAG_LIMIT ||
|
||||
LV_MATH_ABS(state->drag_sum.y) >= LV_INDEV_DRAG_LIMIT) {
|
||||
state->drag_range_out = 1;
|
||||
if(LV_MATH_ABS(state->types.pointer.drag_sum.x) >= LV_INDEV_DRAG_LIMIT ||
|
||||
LV_MATH_ABS(state->types.pointer.drag_sum.y) >= LV_INDEV_DRAG_LIMIT) {
|
||||
state->types.pointer.drag_range_out = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*If the drag limit is stepped over then handle the dragging*/
|
||||
if(state->drag_range_out != 0) {
|
||||
/*Set new position if the vector is not zero*/
|
||||
if(state->vect.x != 0 ||
|
||||
state->vect.y != 0) {
|
||||
if(state->types.pointer.drag_range_out != 0) {
|
||||
/*Set new position if the types.pointer.vector is not zero*/
|
||||
if(state->types.pointer.vect.x != 0 ||
|
||||
state->types.pointer.vect.y != 0) {
|
||||
/*Get the coordinates of the object and modify them*/
|
||||
lv_coord_t act_x = lv_obj_get_x(drag_obj);
|
||||
lv_coord_t act_y = lv_obj_get_y(drag_obj);
|
||||
uint16_t inv_buf_size = lv_refr_get_buf_size(); /*Get the number of currently invalidated areas*/
|
||||
uint16_t inv_buf_size = lv_disp_get_inv_buf_size(indev_act->driver.disp); /*Get the number of currently invalidated areas*/
|
||||
|
||||
lv_coord_t prev_x = drag_obj->coords.x1;
|
||||
lv_coord_t prev_y = drag_obj->coords.y1;
|
||||
lv_coord_t prev_par_w = lv_obj_get_width(lv_obj_get_parent(drag_obj));
|
||||
lv_coord_t prev_par_h = lv_obj_get_height(lv_obj_get_parent(drag_obj));
|
||||
|
||||
lv_obj_set_pos(drag_obj, act_x + state->vect.x, act_y + state->vect.y);
|
||||
lv_obj_set_pos(drag_obj, act_x + state->types.pointer.vect.x, act_y + state->types.pointer.vect.y);
|
||||
|
||||
/*Set the drag in progress flag if the object is really moved*/
|
||||
|
||||
if(drag_obj->coords.x1 != prev_x || drag_obj->coords.y1 != prev_y) {
|
||||
if(state->drag_range_out != 0) { /*Send the drag begin signal on first move*/
|
||||
if(state->types.pointer.drag_range_out != 0) { /*Send the drag begin signal on first move*/
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_BEGIN, indev_act);
|
||||
if(state->reset_query != 0) return;
|
||||
}
|
||||
state->drag_in_prog = 1;
|
||||
state->types.pointer.drag_in_prog = 1;
|
||||
}
|
||||
/*If the object didn't moved then clear the invalidated areas*/
|
||||
else {
|
||||
@ -892,8 +887,8 @@ static void indev_drag(lv_indev_proc_t * state)
|
||||
lv_coord_t act_par_w = lv_obj_get_width(lv_obj_get_parent(drag_obj));
|
||||
lv_coord_t act_par_h = lv_obj_get_height(lv_obj_get_parent(drag_obj));
|
||||
if(act_par_w == prev_par_w && act_par_h == prev_par_h) {
|
||||
uint16_t new_inv_buf_size = lv_refr_get_buf_size();
|
||||
lv_refr_pop_from_buf(new_inv_buf_size - inv_buf_size);
|
||||
uint16_t new_inv_buf_size = lv_disp_get_inv_buf_size(indev_act->driver.disp);
|
||||
lv_disp_pop_from_inv_buf(indev_act->driver.disp, new_inv_buf_size - inv_buf_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -906,10 +901,10 @@ static void indev_drag(lv_indev_proc_t * state)
|
||||
*/
|
||||
static void indev_drag_throw(lv_indev_proc_t * state)
|
||||
{
|
||||
if(state->drag_in_prog == 0) return;
|
||||
if(state->types.pointer.drag_in_prog == 0) return;
|
||||
|
||||
/*Set new position if the vector is not zero*/
|
||||
lv_obj_t * drag_obj = state->last_obj;
|
||||
/*Set new position if the types.pointer.vector is not zero*/
|
||||
lv_obj_t * drag_obj = state->types.pointer.last_obj;
|
||||
|
||||
/*If drag parent is active check recursively the drag_parent attribute*/
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
||||
@ -921,40 +916,40 @@ static void indev_drag_throw(lv_indev_proc_t * state)
|
||||
|
||||
/*Return if the drag throw is not enabled*/
|
||||
if(lv_obj_get_drag_throw(drag_obj) == false) {
|
||||
state->drag_in_prog = 0;
|
||||
state->types.pointer.drag_in_prog = 0;
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
return;
|
||||
}
|
||||
|
||||
/*Reduce the vectors*/
|
||||
state->vect.x = state->vect.x * (100 - LV_INDEV_DRAG_THROW) / 100;
|
||||
state->vect.y = state->vect.y * (100 - LV_INDEV_DRAG_THROW) / 100;
|
||||
/*Reduce the types.pointer.vectors*/
|
||||
state->types.pointer.vect.x = state->types.pointer.vect.x * (100 - LV_INDEV_DRAG_THROW) / 100;
|
||||
state->types.pointer.vect.y = state->types.pointer.vect.y * (100 - LV_INDEV_DRAG_THROW) / 100;
|
||||
|
||||
if(state->vect.x != 0 ||
|
||||
state->vect.y != 0) {
|
||||
if(state->types.pointer.vect.x != 0 ||
|
||||
state->types.pointer.vect.y != 0) {
|
||||
/*Get the coordinates and modify them*/
|
||||
lv_area_t coords_ori;
|
||||
lv_obj_get_coords(drag_obj, &coords_ori);
|
||||
lv_coord_t act_x = lv_obj_get_x(drag_obj) + state->vect.x;
|
||||
lv_coord_t act_y = lv_obj_get_y(drag_obj) + state->vect.y;
|
||||
lv_coord_t act_x = lv_obj_get_x(drag_obj) + state->types.pointer.vect.x;
|
||||
lv_coord_t act_y = lv_obj_get_y(drag_obj) + state->types.pointer.vect.y;
|
||||
lv_obj_set_pos(drag_obj, act_x, act_y);
|
||||
|
||||
lv_area_t coord_new;
|
||||
lv_obj_get_coords(drag_obj, &coord_new);
|
||||
|
||||
/*If non of the coordinates are changed then do not continue throwing*/
|
||||
if((coords_ori.x1 == coord_new.x1 || state->vect.x == 0) &&
|
||||
(coords_ori.y1 == coord_new.y1 || state->vect.y == 0)) {
|
||||
state->drag_in_prog = 0;
|
||||
state->vect.x = 0;
|
||||
state->vect.y = 0;
|
||||
if((coords_ori.x1 == coord_new.x1 || state->types.pointer.vect.x == 0) &&
|
||||
(coords_ori.y1 == coord_new.y1 || state->types.pointer.vect.y == 0)) {
|
||||
state->types.pointer.drag_in_prog = 0;
|
||||
state->types.pointer.vect.x = 0;
|
||||
state->types.pointer.vect.y = 0;
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
|
||||
}
|
||||
}
|
||||
/*If the vectors become 0 -> drag_in_prog = 0 and send a drag end signal*/
|
||||
/*If the types.pointer.vectors become 0 -> types.pointer.drag_in_prog = 0 and send a drag end signal*/
|
||||
else {
|
||||
state->drag_in_prog = 0;
|
||||
state->types.pointer.drag_in_prog = 0;
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
}
|
||||
}
|
||||
|
@ -1,117 +0,0 @@
|
||||
/**
|
||||
* @file lv_lang.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_lang.h"
|
||||
#if USE_LV_MULTI_LANG
|
||||
|
||||
#include "lv_obj.h"
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lang_set_core(lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static uint8_t lang_act = 0;
|
||||
static const void * (*get_txt)(uint16_t);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Change the language
|
||||
* @param lang_id the id of the
|
||||
*/
|
||||
void lv_lang_set(uint8_t lang_id)
|
||||
{
|
||||
lang_act = lang_id;
|
||||
|
||||
lv_obj_t * i;
|
||||
LL_READ(LV_GC_ROOT(_lv_scr_ll), i) {
|
||||
i->signal_func(i, LV_SIGNAL_LANG_CHG, NULL);
|
||||
|
||||
lang_set_core(i);
|
||||
}
|
||||
|
||||
lang_set_core(lv_scr_act());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to get the texts of the set languages from a `txt_id`
|
||||
* @param fp a function pointer to get the texts
|
||||
*/
|
||||
void lv_lang_set_text_func(const void * (*fp)(uint16_t))
|
||||
{
|
||||
get_txt = fp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the function set by `lv_lang_set_text_func` to get the `txt_id` text in the set language
|
||||
* @param txt_id an ID of the text to get
|
||||
* @return the `txt_id` txt on the set language
|
||||
*/
|
||||
const void * lv_lang_get_text(uint16_t txt_id)
|
||||
{
|
||||
if(get_txt == NULL) {
|
||||
LV_LOG_WARN("lv_lang_get_text: text_func is not specified");
|
||||
return NULL; /*No text_get function specified */
|
||||
}
|
||||
if(txt_id == LV_LANG_TXT_ID_NONE) {
|
||||
LV_LOG_WARN("lv_lang_get_text: attempts to get invalid text ID");
|
||||
return NULL; /*Invalid txt_id*/
|
||||
}
|
||||
|
||||
return get_txt(txt_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return with ID of the currently selected language
|
||||
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
|
||||
*/
|
||||
uint8_t lv_lang_act(void)
|
||||
{
|
||||
return lang_act;
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Change the language of the children. (Called recursively)
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
static void lang_set_core(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
LL_READ(obj->child_ll, i) {
|
||||
i->signal_func(i, LV_SIGNAL_LANG_CHG, NULL);
|
||||
|
||||
lang_set_core(i);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*USE_LV_MULTI_LANG*/
|
@ -1,74 +0,0 @@
|
||||
/**
|
||||
* @file lv_lang.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LANG_H
|
||||
#define LV_LANG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#ifdef LV_CONF_INCLUDE_SIMPLE
|
||||
#include "lv_conf.h"
|
||||
#else
|
||||
#include "../../lv_conf.h"
|
||||
#endif
|
||||
|
||||
#if USE_LV_MULTI_LANG
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_LANG_TXT_ID_NONE 0xFFFF /*Used to not assign any text IDs for a multi-language object.*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Change the language
|
||||
* @param lang_id the id of the
|
||||
*/
|
||||
void lv_lang_set(uint8_t lang_id);
|
||||
|
||||
/**
|
||||
* Set a function to get the texts of the set languages from a `txt_id`
|
||||
* @param fp a function pointer to get the texts
|
||||
*/
|
||||
void lv_lang_set_text_func(const void * (*fp)(uint16_t));
|
||||
|
||||
/**
|
||||
* Use the function set by `lv_lang_set_text_func` to get the `txt_id` text in the set language
|
||||
* @param txt_id an ID of the text to get
|
||||
* @return the `txt_id` txt on the set language
|
||||
*/
|
||||
const void * lv_lang_get_text(uint16_t txt_id);
|
||||
|
||||
/**
|
||||
* Return with ID of the currently selected language
|
||||
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
|
||||
*/
|
||||
uint8_t lv_lang_act(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_MULTI_LANG*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_LANG_H*/
|
172
lv_core/lv_obj.c
172
lv_core/lv_obj.c
@ -10,13 +10,14 @@
|
||||
#include "lv_indev.h"
|
||||
#include "lv_refr.h"
|
||||
#include "lv_group.h"
|
||||
#include "lv_disp.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_draw/lv_draw_rbasic.h"
|
||||
#include "../lv_misc/lv_anim.h"
|
||||
#include "../lv_misc/lv_task.h"
|
||||
#include "../lv_misc/lv_fs.h"
|
||||
#include "../lv_misc/lv_ufs.h"
|
||||
#include "../lv_hal/lv_hal.h"
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
@ -38,9 +39,9 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void refresh_childen_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff);
|
||||
static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff);
|
||||
static void report_style_mod_core(void * style_p, lv_obj_t * obj);
|
||||
static void refresh_childen_style(lv_obj_t * obj);
|
||||
static void refresh_children_style(lv_obj_t * obj);
|
||||
static void delete_children(lv_obj_t * obj);
|
||||
static bool lv_obj_design(lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode);
|
||||
static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
@ -49,6 +50,8 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
static bool _lv_initialized = false;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -62,12 +65,11 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
*/
|
||||
void lv_init(void)
|
||||
{
|
||||
LV_GC_ROOT(_lv_def_scr) = NULL;
|
||||
LV_GC_ROOT(_lv_act_scr) = NULL;
|
||||
LV_GC_ROOT(_lv_top_layer) = NULL;
|
||||
LV_GC_ROOT(_lv_sys_layer) = NULL;
|
||||
LV_GC_ROOT(_lv_disp_list) = NULL;
|
||||
LV_GC_ROOT(_lv_indev_list) = NULL;
|
||||
/* Do nothing if already initialized */
|
||||
if (_lv_initialized) {
|
||||
LV_LOG_WARN("lv_init: already inited");
|
||||
return;
|
||||
}
|
||||
|
||||
LV_LOG_TRACE("lv_init started");
|
||||
|
||||
@ -85,33 +87,26 @@ void lv_init(void)
|
||||
lv_anim_init();
|
||||
#endif
|
||||
|
||||
#if USE_LV_GROUP
|
||||
lv_group_init();
|
||||
#endif
|
||||
|
||||
/*Init. the sstyles*/
|
||||
lv_style_init();
|
||||
|
||||
/*Initialize the screen refresh system*/
|
||||
lv_refr_init();
|
||||
|
||||
/*Create the default screen*/
|
||||
lv_ll_init(&LV_GC_ROOT(_lv_scr_ll), sizeof(lv_obj_t));
|
||||
LV_GC_ROOT(_lv_def_scr) = lv_obj_create(NULL, NULL);
|
||||
lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t));
|
||||
lv_ll_init(&LV_GC_ROOT(_lv_indev_ll), sizeof(lv_indev_t));
|
||||
|
||||
LV_GC_ROOT(_lv_act_scr) = LV_GC_ROOT(_lv_def_scr);
|
||||
|
||||
LV_GC_ROOT(_lv_top_layer) = lv_obj_create(NULL, NULL);
|
||||
lv_obj_set_style(LV_GC_ROOT(_lv_top_layer), &lv_style_transp_fit);
|
||||
|
||||
LV_GC_ROOT(_lv_sys_layer) = lv_obj_create(NULL, NULL);
|
||||
lv_obj_set_style(LV_GC_ROOT(_lv_sys_layer), &lv_style_transp_fit);
|
||||
|
||||
/*Refresh the screen*/
|
||||
lv_obj_invalidate(LV_GC_ROOT(_lv_act_scr));
|
||||
|
||||
#if LV_INDEV_READ_PERIOD != 0
|
||||
/*Init the input device handling*/
|
||||
lv_indev_init();
|
||||
#endif
|
||||
|
||||
|
||||
_lv_initialized = true;
|
||||
LV_LOG_INFO("lv_init ready");
|
||||
}
|
||||
|
||||
@ -133,8 +128,13 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
/*Create a screen if the parent is NULL*/
|
||||
if(parent == NULL) {
|
||||
LV_LOG_TRACE("Screen create started");
|
||||
lv_disp_t * disp = lv_disp_get_default();
|
||||
if(!disp) {
|
||||
LV_LOG_WARN("lv_obj_create: not display created to so far. No place to assign the new screen");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_obj = lv_ll_ins_head(&LV_GC_ROOT(_lv_scr_ll));
|
||||
new_obj = lv_ll_ins_head(&disp->scr_ll);
|
||||
lv_mem_assert(new_obj);
|
||||
if(new_obj == NULL) return NULL;
|
||||
|
||||
@ -144,8 +144,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
/*Set coordinates to full screen size*/
|
||||
new_obj->coords.x1 = 0;
|
||||
new_obj->coords.y1 = 0;
|
||||
new_obj->coords.x2 = LV_HOR_RES - 1;
|
||||
new_obj->coords.y2 = LV_VER_RES - 1;
|
||||
new_obj->coords.x2 = lv_disp_get_hor_res(NULL) - 1;
|
||||
new_obj->coords.y2 = lv_disp_get_ver_res(NULL) - 1;
|
||||
new_obj->ext_size = 0;
|
||||
|
||||
/*Init realign*/
|
||||
@ -160,7 +160,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
new_obj->style_p = th->bg;
|
||||
new_obj->style_p = th->style.bg;
|
||||
} else {
|
||||
new_obj->style_p = &lv_style_scr;
|
||||
}
|
||||
@ -227,7 +227,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
/*Set appearance*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
new_obj->style_p = th->panel;
|
||||
new_obj->style_p = th->style.panel;
|
||||
} else {
|
||||
new_obj->style_p = &lv_style_plain_color;
|
||||
}
|
||||
@ -357,7 +357,8 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
||||
/*Remove the object from parent's children list*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
if(par == NULL) { /*It is a screen*/
|
||||
lv_ll_rem(&LV_GC_ROOT(_lv_scr_ll), obj);
|
||||
lv_disp_t * d = lv_obj_get_disp(obj);
|
||||
lv_ll_rem(&d->scr_ll, obj);
|
||||
} else {
|
||||
lv_ll_rem(&(par->child_ll), obj);
|
||||
}
|
||||
@ -366,7 +367,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj)
|
||||
* the currently pressed object is deleted*/
|
||||
lv_indev_t * indev = lv_indev_next(NULL);
|
||||
while(indev) {
|
||||
if(indev->proc.act_obj == obj || indev->proc.last_obj == obj) {
|
||||
if(indev->proc.types.pointer.act_obj == obj || indev->proc.types.pointer.last_obj == obj) {
|
||||
lv_indev_reset(indev);
|
||||
}
|
||||
indev = lv_indev_next(indev);
|
||||
@ -415,9 +416,10 @@ void lv_obj_invalidate(const lv_obj_t * obj)
|
||||
|
||||
/*Invalidate the object only if it belongs to the 'LV_GC_ROOT(_lv_act_scr)'*/
|
||||
lv_obj_t * obj_scr = lv_obj_get_screen(obj);
|
||||
if(obj_scr == lv_scr_act() ||
|
||||
obj_scr == lv_layer_top() ||
|
||||
obj_scr == lv_layer_sys()) {
|
||||
lv_disp_t * disp = lv_obj_get_disp(obj_scr);
|
||||
if(obj_scr == lv_disp_get_scr_act(disp) ||
|
||||
obj_scr == lv_disp_get_layer_top(disp)||
|
||||
obj_scr == lv_disp_get_layer_sys(disp)) {
|
||||
/*Truncate recursively to the parents*/
|
||||
lv_area_t area_trunc;
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
@ -439,7 +441,7 @@ void lv_obj_invalidate(const lv_obj_t * obj)
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
|
||||
if(union_ok != false) lv_inv_area(&area_trunc);
|
||||
if(union_ok) lv_inv_area(disp, &area_trunc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -448,21 +450,6 @@ void lv_obj_invalidate(const lv_obj_t * obj)
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/*--------------
|
||||
* Screen set
|
||||
*--------------*/
|
||||
|
||||
/**
|
||||
* Load a new screen
|
||||
* @param scr pointer to a screen
|
||||
*/
|
||||
void lv_scr_load(lv_obj_t * scr)
|
||||
{
|
||||
LV_GC_ROOT(_lv_act_scr) = scr;
|
||||
|
||||
lv_obj_invalidate(LV_GC_ROOT(_lv_act_scr));
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* Parent/children set
|
||||
*--------------------*/
|
||||
@ -545,7 +532,7 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
||||
obj->coords.x2 += diff.x;
|
||||
obj->coords.y2 += diff.y;
|
||||
|
||||
refresh_childen_position(obj, diff.x, diff.y);
|
||||
refresh_children_position(obj, diff.x, diff.y);
|
||||
|
||||
/*Inform the object about its new coordinates*/
|
||||
obj->signal_func(obj, LV_SIGNAL_CORD_CHG, &ori);
|
||||
@ -614,6 +601,12 @@ void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
if(par != NULL) par->signal_func(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
|
||||
/*Tell the children the parent's size has changed*/
|
||||
lv_obj_t * i;
|
||||
LL_READ(obj->child_ll, i) {
|
||||
i->signal_func(i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
|
||||
}
|
||||
|
||||
/*Invalidate the new area*/
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
@ -981,7 +974,7 @@ void lv_obj_set_style(lv_obj_t * obj, lv_style_t * style)
|
||||
obj->style_p = style;
|
||||
|
||||
/*Send a signal about style change to every children with NULL style*/
|
||||
refresh_childen_style(obj);
|
||||
refresh_children_style(obj);
|
||||
|
||||
/*Notify the object about the style change too*/
|
||||
lv_obj_refresh_style(obj);
|
||||
@ -1006,14 +999,19 @@ void lv_obj_refresh_style(lv_obj_t * obj)
|
||||
*/
|
||||
void lv_obj_report_style_mod(lv_style_t * style)
|
||||
{
|
||||
lv_disp_t * d = lv_disp_get_next(NULL);
|
||||
|
||||
while(d) {
|
||||
lv_obj_t * i;
|
||||
LL_READ(LV_GC_ROOT(_lv_scr_ll), i) {
|
||||
LL_READ(d->scr_ll, i) {
|
||||
if(i->style_p == style || style == NULL) {
|
||||
lv_obj_refresh_style(i);
|
||||
}
|
||||
|
||||
report_style_mod_core(style, i);
|
||||
}
|
||||
d = lv_disp_get_next(d);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------
|
||||
@ -1294,38 +1292,6 @@ void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint1
|
||||
* Getter functions
|
||||
*======================*/
|
||||
|
||||
/*------------------
|
||||
* Screen get
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Return with a pointer to the active screen
|
||||
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
|
||||
*/
|
||||
lv_obj_t * lv_scr_act(void)
|
||||
{
|
||||
return LV_GC_ROOT(_lv_act_scr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the top layer. (Same on every screen and it is above the normal screen layer)
|
||||
* @return pointer to the top layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_layer_top(void)
|
||||
{
|
||||
return LV_GC_ROOT(_lv_top_layer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the system layer. (Same on every screen and it is above the all other layers)
|
||||
* It is used for example by the cursor
|
||||
* @return pointer to the system layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_layer_sys(void)
|
||||
{
|
||||
return LV_GC_ROOT(_lv_sys_layer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the screen of an object
|
||||
* @param obj pointer to an object
|
||||
@ -1344,6 +1310,30 @@ lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj)
|
||||
return (lv_obj_t *)act_p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display of an object
|
||||
* @param scr pointer to an object
|
||||
* @return pointer the object's display
|
||||
*/
|
||||
lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj)
|
||||
{
|
||||
const lv_obj_t * scr;
|
||||
|
||||
if(obj->par == NULL) scr = obj; /*`obj` is a screen*/
|
||||
else scr = lv_obj_get_screen(obj); /*get the screen of `obj`*/
|
||||
|
||||
lv_disp_t * d;
|
||||
LL_READ(LV_GC_ROOT(_lv_disp_ll), d) {
|
||||
lv_obj_t * s;
|
||||
LL_READ(d->scr_ll, s) {
|
||||
if(s == scr) return d;
|
||||
}
|
||||
}
|
||||
|
||||
LV_LOG_WARN("lv_scr_get_disp: screen not found")
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*---------------------
|
||||
* Parent/children get
|
||||
*--------------------*/
|
||||
@ -1866,7 +1856,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
* @param x_diff x coordinate shift
|
||||
* @param y_diff y coordinate shift
|
||||
*/
|
||||
static void refresh_childen_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff)
|
||||
static void refresh_children_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
LL_READ(obj->child_ll, i) {
|
||||
@ -1875,7 +1865,7 @@ static void refresh_childen_position(lv_obj_t * obj, lv_coord_t x_diff, lv_coord
|
||||
i->coords.x2 += x_diff;
|
||||
i->coords.y2 += y_diff;
|
||||
|
||||
refresh_childen_position(i, x_diff, y_diff);
|
||||
refresh_children_position(i, x_diff, y_diff);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1889,7 +1879,7 @@ static void report_style_mod_core(void * style_p, lv_obj_t * obj)
|
||||
lv_obj_t * i;
|
||||
LL_READ(obj->child_ll, i) {
|
||||
if(i->style_p == style_p || style_p == NULL) {
|
||||
refresh_childen_style(i);
|
||||
refresh_children_style(i);
|
||||
lv_obj_refresh_style(i);
|
||||
}
|
||||
|
||||
@ -1902,16 +1892,16 @@ static void report_style_mod_core(void * style_p, lv_obj_t * obj)
|
||||
* because the NULL styles are inherited from the parent
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
static void refresh_childen_style(lv_obj_t * obj)
|
||||
static void refresh_children_style(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||
while(child != NULL) {
|
||||
if(child->style_p == NULL) {
|
||||
refresh_childen_style(child); /*Check children too*/
|
||||
refresh_children_style(child); /*Check children too*/
|
||||
lv_obj_refresh_style(child); /*Notify the child about the style change*/
|
||||
} else if(child->style_p->glass) {
|
||||
/*Children with 'glass' parent might be effected if their style == NULL*/
|
||||
refresh_childen_style(child);
|
||||
refresh_children_style(child);
|
||||
}
|
||||
child = lv_obj_get_child(obj, child);
|
||||
}
|
||||
@ -1955,7 +1945,7 @@ static void delete_children(lv_obj_t * obj)
|
||||
* the currently pressed object is deleted*/
|
||||
lv_indev_t * indev = lv_indev_next(NULL);
|
||||
while(indev) {
|
||||
if(indev->proc.act_obj == obj || indev->proc.last_obj == obj) {
|
||||
if(indev->proc.types.pointer.act_obj == obj || indev->proc.types.pointer.last_obj == obj) {
|
||||
lv_indev_reset(indev);
|
||||
}
|
||||
indev = lv_indev_next(indev);
|
||||
|
@ -27,13 +27,14 @@ extern "C" {
|
||||
#include "../lv_misc/lv_ll.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_log.h"
|
||||
#include "../lv_hal/lv_hal.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/*Error check of lv_conf.h*/
|
||||
#if LV_HOR_RES == 0 || LV_VER_RES == 0
|
||||
#if LV_HOR_RES_MAX == 0 || LV_VER_RES_MAX == 0
|
||||
#error "LittlevGL: LV_HOR_RES and LV_VER_RES must be greater than 0"
|
||||
#endif
|
||||
|
||||
@ -41,19 +42,6 @@ extern "C" {
|
||||
#error "LittlevGL: LV_ANTIALIAS can be only 0 or 1"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE == 0 && LV_ANTIALIAS != 0
|
||||
#error "LittlevGL: If LV_VDB_SIZE == 0 the anti-aliasing must be disabled"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE > 0 && LV_VDB_SIZE < LV_HOR_RES
|
||||
#error "LittlevGL: Small Virtual Display Buffer (lv_conf.h: LV_VDB_SIZE >= LV_HOR_RES)"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE == 0 && USE_LV_REAL_DRAW == 0
|
||||
#error "LittlevGL: If LV_VDB_SIZE = 0 Real drawing function are required (lv_conf.h: USE_LV_REAL_DRAW 1)"
|
||||
#endif
|
||||
|
||||
|
||||
#define LV_ANIM_IN 0x00 /*Animation to show an object. 'OR' it with lv_anim_builtin_t*/
|
||||
#define LV_ANIM_OUT 0x80 /*Animation to hide an object. 'OR' it with lv_anim_builtin_t*/
|
||||
#define LV_ANIM_DIR_MASK 0x80 /*ANIM_IN/ANIM_OUT mask*/
|
||||
@ -89,9 +77,9 @@ enum
|
||||
LV_SIGNAL_CLEANUP,
|
||||
LV_SIGNAL_CHILD_CHG,
|
||||
LV_SIGNAL_CORD_CHG,
|
||||
LV_SIGNAL_PARENT_SIZE_CHG,
|
||||
LV_SIGNAL_STYLE_CHG,
|
||||
LV_SIGNAL_REFR_EXT_SIZE,
|
||||
LV_SIGNAL_LANG_CHG,
|
||||
LV_SIGNAL_GET_TYPE,
|
||||
|
||||
_LV_SIGNAL_FEEDBACK_SECTION_START,
|
||||
@ -273,16 +261,6 @@ void lv_obj_invalidate(const lv_obj_t * obj);
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/*--------------
|
||||
* Screen set
|
||||
*--------------*/
|
||||
|
||||
/**
|
||||
* Load a new screen
|
||||
* @param scr pointer to a screen
|
||||
*/
|
||||
void lv_scr_load(lv_obj_t * scr);
|
||||
|
||||
/*--------------------
|
||||
* Parent/children set
|
||||
*--------------------*/
|
||||
@ -552,29 +530,6 @@ void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint1
|
||||
* Getter functions
|
||||
*======================*/
|
||||
|
||||
/*------------------
|
||||
* Screen get
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Return with a pointer to the active screen
|
||||
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
|
||||
*/
|
||||
lv_obj_t * lv_scr_act(void);
|
||||
|
||||
/**
|
||||
* Return with the top layer. (Same on every screen and it is above the normal screen layer)
|
||||
* @return pointer to the top layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_layer_top(void);
|
||||
|
||||
/**
|
||||
* Return with the system layer. (Same on every screen and it is above the all other layers)
|
||||
* It is used for example by the cursor
|
||||
* @return pointer to the system layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_layer_sys(void);
|
||||
|
||||
/**
|
||||
* Return with the screen of an object
|
||||
* @param obj pointer to an object
|
||||
@ -582,6 +537,13 @@ lv_obj_t * lv_layer_sys(void);
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the display of an object
|
||||
* @param scr pointer to an object
|
||||
* @return pointer the object's display
|
||||
*/
|
||||
lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj);
|
||||
|
||||
/*---------------------
|
||||
* Parent/children get
|
||||
*--------------------*/
|
||||
|
@ -8,26 +8,20 @@
|
||||
*********************/
|
||||
#include <stddef.h>
|
||||
#include "lv_refr.h"
|
||||
#include "lv_vdb.h"
|
||||
#include "lv_disp.h"
|
||||
#include "../lv_hal/lv_hal_tick.h"
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "../lv_misc/lv_task.h"
|
||||
#include "../lv_misc/lv_mem.h"
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_INV_FIFO_SIZE
|
||||
#define LV_INV_FIFO_SIZE 32 /*The average count of objects on a screen */
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct {
|
||||
lv_area_t area;
|
||||
uint8_t joined;
|
||||
} lv_join_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
@ -35,24 +29,18 @@ typedef struct {
|
||||
static void lv_refr_task(void * param);
|
||||
static void lv_refr_join_area(void);
|
||||
static void lv_refr_areas(void);
|
||||
#if LV_VDB_SIZE == 0
|
||||
static void lv_refr_area_no_vdb(const lv_area_t * area_p);
|
||||
#else
|
||||
static void lv_refr_area_with_vdb(const lv_area_t * area_p);
|
||||
static void lv_refr_area_part_vdb(const lv_area_t * area_p);
|
||||
#endif
|
||||
static void lv_refr_area(const lv_area_t * area_p);
|
||||
static void lv_refr_area_part(const lv_area_t * area_p);
|
||||
static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj);
|
||||
static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p);
|
||||
static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p);
|
||||
static void lv_refr_vdb_flush(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_join_t inv_buf[LV_INV_FIFO_SIZE];
|
||||
static uint16_t inv_buf_p;
|
||||
static void (*monitor_cb)(uint32_t, uint32_t); /*Monitor the rendering time*/
|
||||
static void (*round_cb)(lv_area_t *); /*If set then called to modify invalidated areas for special display controllers*/
|
||||
static uint32_t px_num;
|
||||
static lv_disp_t * disp_refr; /*Display being refreshed*/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -67,9 +55,6 @@ static uint32_t px_num;
|
||||
*/
|
||||
void lv_refr_init(void)
|
||||
{
|
||||
inv_buf_p = 0;
|
||||
memset(inv_buf, 0, sizeof(inv_buf));
|
||||
|
||||
lv_task_t * task;
|
||||
task = lv_task_create(lv_refr_task, LV_REFR_PERIOD, LV_TASK_PRIO_MID, NULL);
|
||||
lv_task_ready(task); /*Be sure the screen will be refreshed immediately on start up*/
|
||||
@ -88,22 +73,26 @@ void lv_refr_now(void)
|
||||
|
||||
|
||||
/**
|
||||
* Invalidate an area
|
||||
* @param area_p pointer to area which should be invalidated
|
||||
* 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(const lv_area_t * area_p)
|
||||
void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p)
|
||||
{
|
||||
if(!disp) disp = lv_disp_get_default();
|
||||
if(!disp) return;
|
||||
|
||||
/*Clear the invalidate buffer if the parameter is NULL*/
|
||||
if(area_p == NULL) {
|
||||
inv_buf_p = 0;
|
||||
disp->inv_p = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
lv_area_t scr_area;
|
||||
scr_area.x1 = 0;
|
||||
scr_area.y1 = 0;
|
||||
scr_area.x2 = LV_HOR_RES - 1;
|
||||
scr_area.y2 = LV_VER_RES - 1;
|
||||
scr_area.x2 = disp->driver.hor_res - 1;
|
||||
scr_area.y2 = disp->driver.ver_res - 1;
|
||||
|
||||
lv_area_t com_area;
|
||||
bool suc;
|
||||
@ -112,64 +101,32 @@ void lv_inv_area(const lv_area_t * area_p)
|
||||
|
||||
/*The area is truncated to the screen*/
|
||||
if(suc != false) {
|
||||
if(round_cb) round_cb(&com_area);
|
||||
if(disp->driver.rounder_cb) disp->driver.rounder_cb(&disp_refr->driver, &com_area);
|
||||
|
||||
/*Save only if this area is not in one of the saved areas*/
|
||||
uint16_t i;
|
||||
for(i = 0; i < inv_buf_p; i++) {
|
||||
if(lv_area_is_in(&com_area, &inv_buf[i].area) != false) return;
|
||||
for(i = 0; i < disp->inv_p; i++) {
|
||||
if(lv_area_is_in(&com_area, &disp->inv_areas[i]) != false) return;
|
||||
}
|
||||
|
||||
/*Save the area*/
|
||||
if(inv_buf_p < LV_INV_FIFO_SIZE) {
|
||||
lv_area_copy(&inv_buf[inv_buf_p].area, &com_area);
|
||||
if(disp->inv_p < LV_INV_BUF_SIZE) {
|
||||
lv_area_copy(&disp->inv_areas[disp->inv_p], &com_area);
|
||||
} else {/*If no place for the area add the screen*/
|
||||
inv_buf_p = 0;
|
||||
lv_area_copy(&inv_buf[inv_buf_p].area, &scr_area);
|
||||
disp->inv_p = 0;
|
||||
lv_area_copy(&disp->inv_areas[disp->inv_p], &scr_area);
|
||||
}
|
||||
inv_buf_p ++;
|
||||
disp->inv_p ++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to call after every refresh to announce the refresh time and the number of refreshed pixels
|
||||
* @param cb pointer to a callback function (void my_refr_cb(uint32_t time_ms, uint32_t px_num))
|
||||
* time_ms: refresh time in [ms]
|
||||
* px_num: not the drawn pixels but the number of affected pixels of the screen
|
||||
* (more pixels are drawn because of overlapping objects)
|
||||
* Get the display which is being refreshed
|
||||
* @return the display being refreshed
|
||||
*/
|
||||
void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t))
|
||||
lv_disp_t * lv_refr_get_disp_refreshing(void)
|
||||
{
|
||||
monitor_cb = cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an area is invalidated to modify the coordinates of the area.
|
||||
* Special display controllers may require special coordinate rounding
|
||||
* @param cb pointer to the a function which will modify the area
|
||||
*/
|
||||
void lv_refr_set_round_cb(void(*cb)(lv_area_t *))
|
||||
{
|
||||
round_cb = cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of areas in the buffer
|
||||
* @return number of invalid areas
|
||||
*/
|
||||
uint16_t lv_refr_get_buf_size(void)
|
||||
{
|
||||
return inv_buf_p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop (delete) the last 'num' invalidated areas from the buffer
|
||||
* @param num number of areas to delete
|
||||
*/
|
||||
void lv_refr_pop_from_buf(uint16_t num)
|
||||
{
|
||||
if(inv_buf_p < num) inv_buf_p = 0;
|
||||
else inv_buf_p -= num;
|
||||
return disp_refr;
|
||||
}
|
||||
|
||||
/**********************
|
||||
@ -184,69 +141,63 @@ static void lv_refr_task(void * param)
|
||||
{
|
||||
(void)param;
|
||||
|
||||
LV_LOG_TRACE("display refresh task started");
|
||||
LV_LOG_TRACE("lv_refr_task: started");
|
||||
|
||||
uint32_t start = lv_tick_get();
|
||||
|
||||
if(lv_disp_get_active() == NULL) {
|
||||
LV_LOG_TRACE("No display is registered");
|
||||
return;
|
||||
}
|
||||
LL_READ(LV_GC_ROOT(_lv_disp_ll), disp_refr) {
|
||||
LV_LOG_TRACE("lv_refr_task: refreshing a display");
|
||||
|
||||
lv_refr_join_area();
|
||||
|
||||
lv_refr_areas();
|
||||
|
||||
/*If refresh happened ...*/
|
||||
if(inv_buf_p != 0) {
|
||||
|
||||
if(disp_refr->inv_p != 0) {
|
||||
/*In true double buffered mode copy the refreshed areas to the new VDB to keep it up to date*/
|
||||
#if LV_VDB_TRUE_DOUBLE_BUFFERED
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
vdb_p->area.x1 = 0;
|
||||
vdb_p->area.x2 = LV_HOR_RES-1;
|
||||
vdb_p->area.y1 = 0;
|
||||
vdb_p->area.y2 = LV_VER_RES - 1;
|
||||
if(lv_disp_is_true_double_buf(disp_refr)) {
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
|
||||
|
||||
/*Flush the content of the VDB*/
|
||||
lv_vdb_flush();
|
||||
lv_refr_vdb_flush();
|
||||
|
||||
/* With true double buffering the flushing should be only the address change of the current frame buffer
|
||||
* Wait until the address change is ready and copy the active content to the other frame buffer (new active VDB)
|
||||
* The changes will be written to the new VDB.*/
|
||||
lv_vdb_t * vdb_act = lv_vdb_get_active();
|
||||
lv_vdb_t * vdb_ina = lv_vdb_get_inactive();
|
||||
/* With true double buffering the flushing should be only the address change of the current frame buffer.
|
||||
* Wait until the address change is ready and copy the changed content to the other frame buffer (new active VDB)
|
||||
* to keep the buffers synchronized*/
|
||||
while(vdb->flushing);
|
||||
|
||||
uint8_t * buf_act = (uint8_t *) vdb_act->buf;
|
||||
uint8_t * buf_ina = (uint8_t *) vdb_ina->buf;
|
||||
uint8_t * buf_act = (uint8_t *) vdb->buf_act;
|
||||
uint8_t * buf_ina = (uint8_t *) vdb->buf_act == vdb->buf1 ? vdb->buf2 : vdb->buf1;
|
||||
|
||||
lv_coord_t hres = lv_disp_get_hor_res(disp_refr);
|
||||
uint16_t a;
|
||||
for(a = 0; a < inv_buf_p; a++) {
|
||||
if(inv_buf[a].joined == 0) {
|
||||
for(a = 0; a < disp_refr->inv_p; a++) {
|
||||
if(disp_refr->inv_area_joined[a] == 0) {
|
||||
lv_coord_t y;
|
||||
uint32_t start_offs = ((LV_HOR_RES * inv_buf[a].area.y1 + inv_buf[a].area.x1) * LV_VDB_PX_BPP) >> 3;
|
||||
uint32_t line_length = (lv_area_get_width(&inv_buf[a].area) * LV_VDB_PX_BPP) >> 3;
|
||||
uint32_t start_offs = (hres * disp_refr->inv_areas[a].y1 + disp_refr->inv_areas[a].x1) * sizeof(lv_color_t);
|
||||
uint32_t line_length = lv_area_get_width(&disp_refr->inv_areas[a]) * sizeof(lv_color_t);
|
||||
|
||||
for(y = inv_buf[a].area.y1; y <= inv_buf[a].area.y2; y++) {
|
||||
for(y = disp_refr->inv_areas[a].y1; y <= disp_refr->inv_areas[a].y2; y++) {
|
||||
memcpy(buf_act + start_offs, buf_ina + start_offs, line_length);
|
||||
start_offs += (LV_HOR_RES * LV_VDB_PX_BPP) >> 3;
|
||||
start_offs += hres * sizeof(lv_color_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
} /*End of true double buffer handling*/
|
||||
|
||||
/*Clean up*/
|
||||
memset(inv_buf, 0, sizeof(inv_buf));
|
||||
inv_buf_p = 0;
|
||||
memset(disp_refr->inv_areas, 0, sizeof(disp_refr->inv_areas));
|
||||
memset(disp_refr->inv_area_joined, 0, sizeof(disp_refr->inv_area_joined));
|
||||
disp_refr->inv_p = 0;
|
||||
|
||||
/*Call monitor cb if present*/
|
||||
if(monitor_cb != NULL) {
|
||||
monitor_cb(lv_tick_elaps(start), px_num);
|
||||
if(disp_refr->driver.monitor_cb) {
|
||||
disp_refr->driver.monitor_cb(&disp_refr->driver, lv_tick_elaps(start), px_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LV_LOG_TRACE("display refresh task finished");
|
||||
LV_LOG_TRACE("lv_refr_task: ready");
|
||||
}
|
||||
|
||||
|
||||
@ -258,32 +209,32 @@ static void lv_refr_join_area(void)
|
||||
uint32_t join_from;
|
||||
uint32_t join_in;
|
||||
lv_area_t joined_area;
|
||||
for(join_in = 0; join_in < inv_buf_p; join_in++) {
|
||||
if(inv_buf[join_in].joined != 0) continue;
|
||||
for(join_in = 0; join_in < disp_refr->inv_p; join_in++) {
|
||||
if(disp_refr->inv_area_joined[join_in] != 0) continue;
|
||||
|
||||
/*Check all areas to join them in 'join_in'*/
|
||||
for(join_from = 0; join_from < inv_buf_p; join_from++) {
|
||||
for(join_from = 0; join_from < disp_refr->inv_p; join_from++) {
|
||||
/*Handle only unjoined areas and ignore itself*/
|
||||
if(inv_buf[join_from].joined != 0 || join_in == join_from) {
|
||||
if(disp_refr->inv_area_joined[join_from] != 0 || join_in == join_from) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*Check if the areas are on each other*/
|
||||
if(lv_area_is_on(&inv_buf[join_in].area,
|
||||
&inv_buf[join_from].area) == false) {
|
||||
if(lv_area_is_on(&disp_refr->inv_areas[join_in],
|
||||
&disp_refr->inv_areas[join_from]) == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lv_area_join(&joined_area, &inv_buf[join_in].area,
|
||||
&inv_buf[join_from].area);
|
||||
lv_area_join(&joined_area, &disp_refr->inv_areas[join_in],
|
||||
&disp_refr->inv_areas[join_from]);
|
||||
|
||||
/*Join two area only if the joined area size is smaller*/
|
||||
if(lv_area_get_size(&joined_area) <
|
||||
(lv_area_get_size(&inv_buf[join_in].area) + lv_area_get_size(&inv_buf[join_from].area))) {
|
||||
lv_area_copy(&inv_buf[join_in].area, &joined_area);
|
||||
(lv_area_get_size(&disp_refr->inv_areas[join_in]) + lv_area_get_size(&disp_refr->inv_areas[join_from]))) {
|
||||
lv_area_copy(&disp_refr->inv_areas[join_in], &joined_area);
|
||||
|
||||
/*Mark 'join_form' is joined into 'join_in'*/
|
||||
inv_buf[join_from].joined = 1;
|
||||
disp_refr->inv_area_joined[join_from] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -297,64 +248,46 @@ static void lv_refr_areas(void)
|
||||
px_num = 0;
|
||||
uint32_t i;
|
||||
|
||||
for(i = 0; i < inv_buf_p; i++) {
|
||||
for(i = 0; i < disp_refr->inv_p; i++) {
|
||||
/*Refresh the unjoined areas*/
|
||||
if(inv_buf[i].joined == 0) {
|
||||
/*If there is no VDB do simple drawing*/
|
||||
#if LV_VDB_SIZE == 0
|
||||
lv_refr_area_no_vdb(&inv_buf[i].area);
|
||||
#else
|
||||
/*If VDB is used...*/
|
||||
lv_refr_area_with_vdb(&inv_buf[i].area);
|
||||
#endif
|
||||
if(monitor_cb != NULL) px_num += lv_area_get_size(&inv_buf[i].area);
|
||||
if(disp_refr->inv_area_joined[i] == 0) {
|
||||
|
||||
lv_refr_area(&disp_refr->inv_areas[i]);
|
||||
|
||||
if(disp_refr->driver.monitor_cb) px_num += lv_area_get_size(&disp_refr->inv_areas[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if LV_VDB_SIZE == 0
|
||||
/**
|
||||
* Refresh an area if there is no Virtual Display Buffer
|
||||
* @param area_p pointer to an area to refresh
|
||||
*/
|
||||
static void lv_refr_area_no_vdb(const lv_area_t * area_p)
|
||||
{
|
||||
lv_obj_t * top_p;
|
||||
|
||||
/*Get top object which is not covered by others*/
|
||||
top_p = lv_refr_get_top_obj(area_p, lv_scr_act());
|
||||
|
||||
/*Do the refreshing*/
|
||||
lv_refr_obj_and_children(top_p, area_p);
|
||||
|
||||
/*Also refresh top and sys layer unconditionally*/
|
||||
lv_refr_obj_and_children(lv_layer_top(), area_p);
|
||||
lv_refr_obj_and_children(lv_layer_sys(), area_p);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Refresh an area if there is Virtual Display Buffer
|
||||
* @param area_p pointer to an area to refresh
|
||||
*/
|
||||
static void lv_refr_area_with_vdb(const lv_area_t * area_p)
|
||||
static void lv_refr_area(const lv_area_t * area_p)
|
||||
{
|
||||
|
||||
#if LV_VDB_TRUE_DOUBLE_BUFFERED == 0
|
||||
/*True double buffering: there are two screen sized buffers. Just redraw directly into a buffer*/
|
||||
if(lv_disp_is_true_double_buf(disp_refr)) {
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
|
||||
vdb->area.x1 = 0;
|
||||
vdb->area.x2 = lv_disp_get_hor_res(disp_refr) - 1;
|
||||
vdb->area.y1 = 0;
|
||||
vdb->area.y2 = lv_disp_get_ver_res(disp_refr) - 1;
|
||||
lv_refr_area_part(area_p);
|
||||
}
|
||||
/*The buffer is smaller: refresh the area in parts*/
|
||||
else {
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
|
||||
/*Calculate the max row num*/
|
||||
lv_coord_t w = lv_area_get_width(area_p);
|
||||
lv_coord_t h = lv_area_get_height(area_p);
|
||||
lv_coord_t y2 = area_p->y2 >= LV_VER_RES ? y2 = LV_VER_RES - 1 : area_p->y2;
|
||||
lv_coord_t y2 = area_p->y2 >= lv_disp_get_ver_res(NULL) ? y2 = lv_disp_get_ver_res(NULL) - 1 : area_p->y2;
|
||||
|
||||
int32_t max_row = (uint32_t) LV_VDB_SIZE / w;
|
||||
int32_t max_row = (uint32_t) vdb->size / w;
|
||||
|
||||
if(max_row > h) max_row = h;
|
||||
|
||||
|
||||
/*Round down the lines of VDB if rounding is added*/
|
||||
if(round_cb) {
|
||||
if(disp_refr->driver.rounder_cb) {
|
||||
lv_area_t tmp;
|
||||
tmp.x1 = 0;
|
||||
tmp.x2 = 0;
|
||||
@ -364,7 +297,7 @@ static void lv_refr_area_with_vdb(const lv_area_t * area_p)
|
||||
lv_coord_t y_tmp = max_row;
|
||||
do {
|
||||
tmp.y2 = y_tmp;
|
||||
round_cb(&tmp);
|
||||
disp_refr->driver.rounder_cb(&disp_refr->driver, &tmp);
|
||||
y_tmp --; /*Decrement the number of line until it is rounded to a smaller (or equal) value then the original. */
|
||||
} while(lv_area_get_height(&tmp) > max_row && y_tmp != 0);
|
||||
|
||||
@ -380,87 +313,68 @@ static void lv_refr_area_with_vdb(const lv_area_t * area_p)
|
||||
lv_coord_t row;
|
||||
lv_coord_t row_last = 0;
|
||||
for(row = area_p->y1; row + max_row - 1 <= y2; row += max_row) {
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
if(!vdb_p) {
|
||||
LV_LOG_WARN("Invalid VDB pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
/*Calc. the next y coordinates of VDB*/
|
||||
vdb_p->area.x1 = area_p->x1;
|
||||
vdb_p->area.x2 = area_p->x2;
|
||||
vdb_p->area.y1 = row;
|
||||
vdb_p->area.y2 = row + max_row - 1;
|
||||
if(vdb_p->area.y2 > y2) vdb_p->area.y2 = y2;
|
||||
row_last = vdb_p->area.y2;
|
||||
lv_refr_area_part_vdb(area_p);
|
||||
vdb->area.x1 = area_p->x1;
|
||||
vdb->area.x2 = area_p->x2;
|
||||
vdb->area.y1 = row;
|
||||
vdb->area.y2 = row + max_row - 1;
|
||||
if(vdb->area.y2 > y2) vdb->area.y2 = y2;
|
||||
row_last = vdb->area.y2;
|
||||
lv_refr_area_part(area_p);
|
||||
}
|
||||
|
||||
/*If the last y coordinates are not handled yet ...*/
|
||||
if(y2 != row_last) {
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
if(!vdb_p) {
|
||||
LV_LOG_WARN("Invalid VDB pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
/*Calc. the next y coordinates of VDB*/
|
||||
vdb_p->area.x1 = area_p->x1;
|
||||
vdb_p->area.x2 = area_p->x2;
|
||||
vdb_p->area.y1 = row;
|
||||
vdb_p->area.y2 = y2;
|
||||
vdb->area.x1 = area_p->x1;
|
||||
vdb->area.x2 = area_p->x2;
|
||||
vdb->area.y1 = row;
|
||||
vdb->area.y2 = y2;
|
||||
|
||||
/*Refresh this part too*/
|
||||
lv_refr_area_part_vdb(area_p);
|
||||
lv_refr_area_part(area_p);
|
||||
}
|
||||
}
|
||||
#else
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
vdb_p->area.x1 = 0;
|
||||
vdb_p->area.x2 = LV_HOR_RES-1;
|
||||
vdb_p->area.y1 = 0;
|
||||
vdb_p->area.y2 = LV_VER_RES - 1;
|
||||
lv_refr_area_part_vdb(area_p);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh a part of an area which is on the actual Virtual Display Buffer
|
||||
* @param area_p pointer to an area to refresh
|
||||
*/
|
||||
static void lv_refr_area_part_vdb(const lv_area_t * area_p)
|
||||
static void lv_refr_area_part(const lv_area_t * area_p)
|
||||
{
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
if(!vdb_p) {
|
||||
LV_LOG_WARN("Invalid VDB pointer");
|
||||
return;
|
||||
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
|
||||
|
||||
/*In non double buffered mode, before rendering the next part wait until the previous image is flushed*/
|
||||
if(lv_disp_is_double_buf(disp_refr) == false) {
|
||||
while(vdb->flushing);
|
||||
}
|
||||
|
||||
lv_obj_t * top_p;
|
||||
|
||||
/*Get the new mask from the original area and the act. VDB
|
||||
It will be a part of 'area_p'*/
|
||||
lv_area_t start_mask;
|
||||
lv_area_intersect(&start_mask, area_p, &vdb_p->area);
|
||||
lv_area_intersect(&start_mask, area_p, &vdb->area);
|
||||
|
||||
/*Get the most top object which is not covered by others*/
|
||||
top_p = lv_refr_get_top_obj(&start_mask, lv_scr_act());
|
||||
top_p = lv_refr_get_top_obj(&start_mask, lv_disp_get_scr_act(disp_refr));
|
||||
|
||||
/*Do the refreshing from the top object*/
|
||||
lv_refr_obj_and_children(top_p, &start_mask);
|
||||
|
||||
/*Also refresh top and sys layer unconditionally*/
|
||||
lv_refr_obj_and_children(lv_layer_top(), &start_mask);
|
||||
lv_refr_obj_and_children(lv_layer_sys(), &start_mask);
|
||||
lv_refr_obj_and_children(lv_disp_get_layer_top(disp_refr), &start_mask);
|
||||
lv_refr_obj_and_children(lv_disp_get_layer_sys(disp_refr), &start_mask);
|
||||
|
||||
/* In true double buffered mode flush only once when all areas were rendered.
|
||||
* In normal mode flush after every area */
|
||||
#if LV_VDB_TRUE_DOUBLE_BUFFERED == 0
|
||||
/*Flush the content of the VDB*/
|
||||
lv_vdb_flush();
|
||||
#endif
|
||||
if(lv_disp_is_true_double_buf(disp_refr) == false) {
|
||||
lv_refr_vdb_flush();
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*LV_VDB_SIZE == 0*/
|
||||
|
||||
/**
|
||||
* Search the most top object which fully covers an area
|
||||
* @param area_p pointer to an area
|
||||
@ -507,7 +421,7 @@ static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p)
|
||||
/* Normally always will be a top_obj (at least the screen)
|
||||
* but in special cases (e.g. if the screen has alpha) it won't.
|
||||
* In this case use the screen directly */
|
||||
if(top_p == NULL) top_p = lv_scr_act();
|
||||
if(top_p == NULL) top_p = lv_disp_get_scr_act(disp_refr);
|
||||
|
||||
/*Refresh the top object and its children*/
|
||||
lv_refr_obj(top_p, mask_p);
|
||||
@ -608,3 +522,33 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the content of the VDB
|
||||
*/
|
||||
static void lv_refr_vdb_flush(void)
|
||||
{
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(lv_refr_get_disp_refreshing());
|
||||
|
||||
/*In double buffered mode wait until the other buffer is flushed before flushing the current one*/
|
||||
if(vdb->buf1 && vdb->buf2) {
|
||||
while(vdb->flushing);
|
||||
}
|
||||
|
||||
vdb->flushing = 1;
|
||||
|
||||
/*Flush the rendered content to the display*/
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
if(disp->driver.flush_cb) disp->driver.flush_cb(&disp->driver, &vdb->area, vdb->buf_act);
|
||||
|
||||
|
||||
if(vdb->buf1 && vdb->buf2) {
|
||||
if(vdb->buf_act == vdb->buf1) vdb->buf_act = vdb->buf2;
|
||||
else vdb->buf_act = vdb->buf1;
|
||||
|
||||
/*If the screen is transparent initialize it when the new VDB is selected*/
|
||||
# if LV_COLOR_SCREEN_TRANSP
|
||||
memset(vdb[vdb_active].buf, 0x00, LV_VDB_SIZE_IN_BYTES);
|
||||
# endif /*LV_COLOR_SCREEN_TRANSP*/
|
||||
}
|
||||
}
|
||||
|
@ -54,23 +54,11 @@ void lv_refr_init(void);
|
||||
void lv_refr_now(void);
|
||||
|
||||
/**
|
||||
* Invalidate an area
|
||||
* @param area_p pointer to area which should be invalidated
|
||||
* 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(const lv_area_t * area_p);
|
||||
|
||||
/**
|
||||
* Set a function to call after every refresh to announce the refresh time and the number of refreshed pixels
|
||||
* @param cb pointer to a callback function (void my_refr_cb(uint32_t time_ms, uint32_t px_num))
|
||||
*/
|
||||
void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t));
|
||||
|
||||
/**
|
||||
* Called when an area is invalidated to modify the coordinates of the area.
|
||||
* Special display controllers may require special coordinate rounding
|
||||
* @param cb pointer to the a function which will modify the area
|
||||
*/
|
||||
void lv_refr_set_round_cb(void(*cb)(lv_area_t*));
|
||||
void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p);
|
||||
|
||||
/**
|
||||
* Get the number of areas in the buffer
|
||||
@ -83,6 +71,13 @@ uint16_t lv_refr_get_buf_size(void);
|
||||
* @param num number of areas to delete
|
||||
*/
|
||||
void lv_refr_pop_from_buf(uint16_t num);
|
||||
|
||||
/**
|
||||
* Get the display which is being refreshed
|
||||
* @return the display being refreshed
|
||||
*/
|
||||
lv_disp_t * lv_refr_get_disp_refreshing(void);
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -184,7 +184,7 @@ extern lv_style_t lv_style_pretty_color;
|
||||
extern lv_style_t lv_style_btn_rel;
|
||||
extern lv_style_t lv_style_btn_pr;
|
||||
extern lv_style_t lv_style_btn_tgl_rel;
|
||||
extern lv_style_t lv_style_btn_tgl_pr;;
|
||||
extern lv_style_t lv_style_btn_tgl_pr;
|
||||
extern lv_style_t lv_style_btn_ina;
|
||||
|
||||
/**********************
|
||||
|
203
lv_core/lv_vdb.c
203
lv_core/lv_vdb.c
@ -1,203 +0,0 @@
|
||||
/**
|
||||
* @file lv_vdb.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_vdb.h"
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "../lv_misc/lv_log.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_ATTRIBUTE_FLUSH_READY
|
||||
#define LV_ATTRIBUTE_FLUSH_READY
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/*Simple VDB*/
|
||||
#if LV_VDB_DOUBLE == 0
|
||||
# if LV_VDB_ADR == 0
|
||||
/*If the buffer address is not specified simply allocate it*/
|
||||
static uint8_t vdb_buf[LV_VDB_SIZE_IN_BYTES];
|
||||
static lv_vdb_t vdb = {.buf = (lv_color_t *)vdb_buf};
|
||||
# else /*LV_VDB_ADR != 0*/
|
||||
/*If the buffer address is specified use that address*/
|
||||
static lv_vdb_t vdb = {.buf = (lv_color_t *)LV_VDB_ADR};
|
||||
# endif
|
||||
|
||||
/*LV_VDB_DOUBLE != 0*/
|
||||
#else
|
||||
/*Double VDB*/
|
||||
static uint8_t vdb_active = 0;
|
||||
# if LV_VDB_ADR == 0
|
||||
/*If the buffer address is not specified simply allocate it*/
|
||||
static uint8_t vdb_buf1[LV_VDB_SIZE_IN_BYTES];
|
||||
static uint8_t vdb_buf2[LV_VDB_SIZE_IN_BYTES];
|
||||
static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *) vdb_buf1}, {.buf = (lv_color_t *) vdb_buf2}};
|
||||
# else /*LV_VDB_ADR != 0*/
|
||||
/*If the buffer address is specified use that address*/
|
||||
static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *)LV_VDB_ADR}, {.buf = (lv_color_t *)LV_VDB2_ADR}};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static volatile bool vdb_flushing = false;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get the 'vdb' variable or allocate one in LV_VDB_DOUBLE mode
|
||||
* @return pointer to a 'vdb' variable
|
||||
*/
|
||||
lv_vdb_t * lv_vdb_get(void)
|
||||
{
|
||||
#if LV_VDB_DOUBLE == 0
|
||||
/* Wait until VDB is flushing.
|
||||
* (Until this user calls of 'lv_flush_ready()' in the display drivers's flush function*/
|
||||
while(vdb_flushing);
|
||||
|
||||
return &vdb;
|
||||
#else
|
||||
/*If already there is an active do nothing*/
|
||||
return &vdb[vdb_active];
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the content of the VDB
|
||||
*/
|
||||
void lv_vdb_flush(void)
|
||||
{
|
||||
lv_vdb_t * vdb_act = lv_vdb_get();
|
||||
if(!vdb_act) {
|
||||
LV_LOG_WARN("Invalid VDB pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
/*Don't start a new flush while the previous is not finished*/
|
||||
#if LV_VDB_DOUBLE
|
||||
while(vdb_flushing);
|
||||
#endif /*LV_VDB_DOUBLE*/
|
||||
|
||||
vdb_flushing = true;
|
||||
|
||||
/*Flush the rendered content to the display*/
|
||||
lv_disp_flush(vdb_act->area.x1, vdb_act->area.y1, vdb_act->area.x2, vdb_act->area.y2, vdb_act->buf);
|
||||
|
||||
|
||||
#if LV_VDB_DOUBLE
|
||||
/*Make the other VDB active. The content of the current will be kept until the next flush*/
|
||||
vdb_active++;
|
||||
vdb_active &= 0x1;
|
||||
|
||||
/*If the screen is transparent initialize it when the new VDB is selected*/
|
||||
# if LV_COLOR_SCREEN_TRANSP
|
||||
memset(vdb[vdb_active].buf, 0x00, LV_VDB_SIZE_IN_BYTES);
|
||||
# endif /*LV_COLOR_SCREEN_TRANSP*/
|
||||
|
||||
#endif /*#if LV_VDB_DOUBLE*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the address of VDB buffer(s) manually. To use this set `LV_VDB_ADR` (and `LV_VDB2_ADR`) to `LV_VDB_ADR_INV` in `lv_conf.h`.
|
||||
* It should be called before `lv_init()`. The size of the buffer should be: `LV_VDB_SIZE_IN_BYTES`
|
||||
* @param buf1 address of the VDB.
|
||||
* @param buf2 address of the second buffer. `NULL` if `LV_VDB_DOUBLE 0`
|
||||
*/
|
||||
void lv_vdb_set_adr(void * buf1, void * buf2)
|
||||
{
|
||||
#if LV_VDB_DOUBLE == 0
|
||||
(void) buf2; /*unused*/
|
||||
vdb.buf = buf1;
|
||||
#else
|
||||
vdb[0].buf = buf1;
|
||||
vdb[1].buf = buf2;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Call in the display driver's 'disp_flush' function when the flushing is finished
|
||||
*/
|
||||
LV_ATTRIBUTE_FLUSH_READY void lv_flush_ready(void)
|
||||
{
|
||||
vdb_flushing = false;
|
||||
|
||||
/*If the screen is transparent initialize it when the flushing is ready*/
|
||||
#if LV_VDB_DOUBLE == 0 && LV_COLOR_SCREEN_TRANSP
|
||||
memset(vdb_buf, 0x00, LV_VDB_SIZE_IN_BYTES);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Get currently active VDB, where the drawing happens. Used with `LV_VDB_DOUBLE 1`
|
||||
* @return pointer to the active VDB. If `LV_VDB_DOUBLE 0` give the single VDB
|
||||
*/
|
||||
lv_vdb_t * lv_vdb_get_active(void)
|
||||
{
|
||||
#if LV_VDB_DOUBLE == 0
|
||||
return &vdb;
|
||||
#else
|
||||
return &vdb[vdb_active];
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Get currently inactive VDB, which is being displayed or being flushed. Used with `LV_VDB_DOUBLE 1`
|
||||
* @return pointer to the inactive VDB. If `LV_VDB_DOUBLE 0` give the single VDB
|
||||
*/
|
||||
lv_vdb_t * lv_vdb_get_inactive(void)
|
||||
{
|
||||
#if LV_VDB_DOUBLE == 0
|
||||
return &vdb;
|
||||
#else
|
||||
return &vdb[(vdb_active + 1) & 0x1];
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the flushing is in progress or not
|
||||
* @return true: flushing is in progress; false: flushing ready
|
||||
*/
|
||||
bool lv_vdb_is_flushing(void)
|
||||
{
|
||||
return vdb_flushing;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Just for compatibility
|
||||
*/
|
||||
void lv_flush_ready(void)
|
||||
{
|
||||
/*Do nothing. It is used only for VDB*/
|
||||
}
|
||||
#endif
|
119
lv_core/lv_vdb.h
119
lv_core/lv_vdb.h
@ -1,119 +0,0 @@
|
||||
/**
|
||||
* @file lv_vdb.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_VDB_H
|
||||
#define LV_VDB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#ifdef LV_CONF_INCLUDE_SIMPLE
|
||||
#include "lv_conf.h"
|
||||
#else
|
||||
#include "../../lv_conf.h"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Can be used in `lv_conf.h` the set an invalid address for the VDB. It should be replaced later by a valid address using `lv_vdb_set_adr()`*/
|
||||
#define LV_VDB_ADR_INV 8 /*8 is still too small to be valid but it's aligned on 64 bit machines as well*/
|
||||
|
||||
#ifndef LV_VDB_PX_BPP
|
||||
#define LV_VDB_PX_BPP LV_COLOR_SIZE /* Default is LV_COLOR_SIZE */
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_VDB_TRUE_DOUBLE_BUFFERED && (LV_VDB_SIZE != LV_HOR_RES * LV_VER_RES || LV_VDB_DOUBLE == 0)
|
||||
#error "With LV_VDB_TRUE_DOUBLE_BUFFERED: (LV_VDB_SIZE = LV_HOR_RES * LV_VER_RES and LV_VDB_DOUBLE = 1 is required"
|
||||
#endif
|
||||
|
||||
|
||||
/* The size of VDB in bytes.
|
||||
* (LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3): just divide by 8 to convert bits to bytes
|
||||
* (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0): add an extra byte to round up.
|
||||
* E.g. if LV_VDB_SIZE = 10 and LV_VDB_PX_BPP = 1 -> 10 bits -> 2 bytes*/
|
||||
#define LV_VDB_SIZE_IN_BYTES ((LV_VDB_SIZE * LV_VDB_PX_BPP) >> 3) + (((LV_VDB_SIZE * LV_VDB_PX_BPP) & 0x7) ? 1 : 0)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
lv_area_t area;
|
||||
lv_color_t *buf;
|
||||
} lv_vdb_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get the 'vdb' variable or allocate one in LV_VDB_DOUBLE mode
|
||||
* @return pointer to a 'vdb' variable
|
||||
*/
|
||||
lv_vdb_t * lv_vdb_get(void);
|
||||
|
||||
/**
|
||||
* Flush the content of the vdb
|
||||
*/
|
||||
void lv_vdb_flush(void);
|
||||
|
||||
/**
|
||||
* Set the address of VDB buffer(s) manually. To use this set `LV_VDB_ADR` (and `LV_VDB2_ADR`) to `LV_VDB_ADR_INV` in `lv_conf.h`.
|
||||
* It should be called before `lv_init()`. The size of the buffer should be: `LV_VDB_SIZE_IN_BYTES`
|
||||
* @param buf1 address of the VDB.
|
||||
* @param buf2 address of the second buffer. `NULL` if `LV_VDB_DOUBLE 0`
|
||||
*/
|
||||
void lv_vdb_set_adr(void * buf1, void * buf2);
|
||||
|
||||
/**
|
||||
* Call in the display driver's 'disp_flush' function when the flushing is finished
|
||||
*/
|
||||
void lv_flush_ready(void);
|
||||
|
||||
/**
|
||||
* Get currently active VDB, where the drawing happens. Used with `LV_VDB_DOUBLE 1`
|
||||
* @return pointer to the active VDB. If `LV_VDB_DOUBLE 0` give the single VDB
|
||||
*/
|
||||
lv_vdb_t * lv_vdb_get_active(void);
|
||||
|
||||
/**
|
||||
* Get currently inactive VDB, which is being displayed or being flushed. Used with `LV_VDB_DOUBLE 1`
|
||||
* @return pointer to the inactive VDB. If `LV_VDB_DOUBLE 0` give the single VDB
|
||||
*/
|
||||
lv_vdb_t * lv_vdb_get_inactive(void);
|
||||
|
||||
/**
|
||||
* Whether the flushing is in progress or not
|
||||
* @return true: flushing is in progress; false: flushing ready
|
||||
*/
|
||||
bool lv_vdb_is_flushing(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#else /*LV_VDB_SIZE != 0*/
|
||||
|
||||
/*Just for compatibility*/
|
||||
void lv_flush_ready(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_VDB_H*/
|
@ -10,12 +10,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include "lv_draw.h"
|
||||
#include "lv_draw_rbasic.h"
|
||||
#include "lv_draw_vbasic.h"
|
||||
#include "../lv_misc/lv_fs.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_misc/lv_ufs.h"
|
||||
#include "../lv_objx/lv_img.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -33,22 +28,6 @@
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
void (*const px_fp)(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_color_t color, lv_opa_t opa) = lv_vpx;
|
||||
void (*const fill_fp)(const lv_area_t * coords, const lv_area_t * mask, lv_color_t color, lv_opa_t opa) = lv_vfill;
|
||||
void (*const letter_fp)(const lv_point_t * pos_p, const lv_area_t * mask, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa) = lv_vletter;
|
||||
void (*const map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa) = lv_vmap;
|
||||
#else
|
||||
void (*const px_fp)(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_color_t color, lv_opa_t opa) = lv_rpx;
|
||||
void (*const fill_fp)(const lv_area_t * coords, const lv_area_t * mask, lv_color_t color, lv_opa_t opa) = lv_rfill;
|
||||
void (*const letter_fp)(const lv_point_t * pos_p, const lv_area_t * mask, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa) = lv_rletter;
|
||||
void (*const map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa) = lv_rmap;
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -132,7 +111,7 @@ void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_
|
||||
for(i = 0; i < length; i++) {
|
||||
lv_opa_t px_opa = lv_draw_aa_get_opa(length, i, opa);
|
||||
if(aa_inv) px_opa = opa - px_opa;
|
||||
px_fp(x, y + i, mask, color, px_opa);
|
||||
lv_draw_px(x, y + i, mask, color, px_opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +136,7 @@ void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_
|
||||
for(i = 0; i < length; i++) {
|
||||
lv_opa_t px_opa = lv_draw_aa_get_opa(length, i, opa);
|
||||
if(aa_inv) px_opa = opa - px_opa;
|
||||
px_fp(x + i, y, mask, color, px_opa);
|
||||
lv_draw_px(x + i, y, mask, color, px_opa);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,12 +88,6 @@ void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
extern void (*const px_fp)(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_color_t color, lv_opa_t opa);
|
||||
extern void (*const fill_fp)(const lv_area_t * coords, const lv_area_t * mask, lv_color_t color, lv_opa_t opa);
|
||||
extern void (*const letter_fp)(const lv_point_t * pos_p, const lv_area_t * mask, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa);
|
||||
extern void (*const map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -102,6 +96,7 @@ extern void (*const map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
/**********************
|
||||
* POST INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_basic.h"
|
||||
#include "lv_draw_rect.h"
|
||||
#include "lv_draw_label.h"
|
||||
#include "lv_draw_img.h"
|
||||
|
@ -1,5 +1,4 @@
|
||||
CSRCS += lv_draw_vbasic.c
|
||||
CSRCS += lv_draw_rbasic.c
|
||||
CSRCS += lv_draw_basic.c
|
||||
CSRCS += lv_draw.c
|
||||
CSRCS += lv_draw_rect.c
|
||||
CSRCS += lv_draw_label.c
|
||||
|
@ -239,7 +239,7 @@ static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coor
|
||||
lv_area_t area;
|
||||
lv_area_set(&area, x, y, x, y + len);
|
||||
|
||||
fill_fp(&area, mask, color, opa);
|
||||
lv_draw_fill(&area, mask, color, opa);
|
||||
}
|
||||
|
||||
static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, lv_color_t color, lv_opa_t opa)
|
||||
@ -247,7 +247,7 @@ static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coor
|
||||
lv_area_t area;
|
||||
lv_area_set(&area, x, y, x + len, y);
|
||||
|
||||
fill_fp(&area, mask, color, opa);
|
||||
lv_draw_fill(&area, mask, color, opa);
|
||||
}
|
||||
|
||||
static bool deg_test_norm(uint16_t deg, uint16_t start, uint16_t end)
|
||||
|
@ -1,24 +1,22 @@
|
||||
/**
|
||||
* @file lv_vdraw.c
|
||||
* @file lv_draw_basic.c
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lv_draw_vbasic.h"
|
||||
#include "lv_draw_basic.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "../lv_core/lv_refr.h"
|
||||
#include "../lv_hal/lv_hal.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_misc/lv_font.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_log.h"
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include <stddef.h>
|
||||
#include "../lv_core/lv_vdb.h"
|
||||
#include "lv_draw.h"
|
||||
|
||||
/*********************
|
||||
@ -30,6 +28,10 @@
|
||||
*********************/
|
||||
#define VFILL_HW_ACC_SIZE_LIMIT 50 /*Always fill < 50 px with 'sw_color_fill' because of the hw. init overhead*/
|
||||
|
||||
#ifndef LV_ATTRIBUTE_MEM_ALIGN
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@ -64,16 +66,11 @@ static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa,
|
||||
* @param color pixel color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa)
|
||||
void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
if(opa < LV_OPA_MIN) return;
|
||||
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
|
||||
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
if(!vdb_p) {
|
||||
LV_LOG_WARN("Invalid VDB pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
/*Pixel out of the mask*/
|
||||
if(x < mask_p->x1 || x > mask_p->x2 ||
|
||||
@ -81,17 +78,19 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t vdb_width = lv_area_get_width(&vdb_p->area);
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
|
||||
uint32_t vdb_width = lv_area_get_width(&vdb->area);
|
||||
|
||||
/*Make the coordinates relative to VDB*/
|
||||
x -= vdb_p->area.x1;
|
||||
y -= vdb_p->area.y1;
|
||||
x -= vdb->area.x1;
|
||||
y -= vdb->area.y1;
|
||||
|
||||
lv_disp_t * disp = lv_disp_get_active();
|
||||
if(disp->driver.vdb_wr) {
|
||||
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, x, y, color, opa);
|
||||
if(disp->driver.set_px_cb) {
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, x, y, color, opa);
|
||||
} else {
|
||||
lv_color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x;
|
||||
lv_color_t * vdb_px_p = vdb->buf_act;
|
||||
vdb_px_p += y * vdb_width + x;
|
||||
#if LV_COLOR_SCREEN_TRANSP == 0
|
||||
if(opa == LV_OPA_COVER) {
|
||||
*vdb_px_p = color;
|
||||
@ -112,7 +111,7 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
|
||||
* @param color fill color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
if(opa < LV_OPA_MIN) return;
|
||||
@ -120,11 +119,6 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
|
||||
lv_area_t res_a;
|
||||
bool union_ok;
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
if(!vdb_p) {
|
||||
LV_LOG_WARN("Invalid VDB pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
/*Get the union of cord and mask*/
|
||||
/* The mask is already truncated to the vdb size
|
||||
@ -134,40 +128,43 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
/*If there are common part of the three area then draw to the vdb*/
|
||||
if(union_ok == false) return;
|
||||
|
||||
lv_area_t vdb_rel_a; /*Stores relative coordinates on vdb*/
|
||||
vdb_rel_a.x1 = res_a.x1 - vdb_p->area.x1;
|
||||
vdb_rel_a.y1 = res_a.y1 - vdb_p->area.y1;
|
||||
vdb_rel_a.x2 = res_a.x2 - vdb_p->area.x1;
|
||||
vdb_rel_a.y2 = res_a.y2 - vdb_p->area.y1;
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
|
||||
|
||||
lv_color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
uint32_t vdb_width = lv_area_get_width(&vdb_p->area);
|
||||
lv_area_t vdb_rel_a; /*Stores relative coordinates on vdb*/
|
||||
vdb_rel_a.x1 = res_a.x1 - vdb->area.x1;
|
||||
vdb_rel_a.y1 = res_a.y1 - vdb->area.y1;
|
||||
vdb_rel_a.x2 = res_a.x2 - vdb->area.x1;
|
||||
vdb_rel_a.y2 = res_a.y2 - vdb->area.y1;
|
||||
|
||||
lv_color_t * vdb_buf_tmp = vdb->buf_act;
|
||||
uint32_t vdb_width = lv_area_get_width(&vdb->area);
|
||||
/*Move the vdb_tmp to the first row*/
|
||||
vdb_buf_tmp += vdb_width * vdb_rel_a.y1;
|
||||
|
||||
|
||||
#if USE_LV_GPU
|
||||
static lv_color_t color_array_tmp[LV_HOR_RES]; /*Used by 'lv_disp_mem_blend'*/
|
||||
static LV_ATTRIBUTE_MEM_ALIGN lv_color_t color_array_tmp[LV_HOR_RES_MAX]; /*Used by 'lv_disp_mem_blend'*/
|
||||
static lv_coord_t last_width = -1;
|
||||
|
||||
lv_coord_t w = lv_area_get_width(&vdb_rel_a);
|
||||
/*Don't use hw. acc. for every small fill (because of the init overhead)*/
|
||||
if(w < VFILL_HW_ACC_SIZE_LIMIT) {
|
||||
sw_color_fill(&vdb_p->area, vdb_p->buf, &vdb_rel_a, color, opa);
|
||||
sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa);
|
||||
}
|
||||
/*Not opaque fill*/
|
||||
else if(opa == LV_OPA_COVER) {
|
||||
/*Use hw fill if present*/
|
||||
if(lv_disp_is_mem_fill_supported()) {
|
||||
if(disp->driver.mem_fill) {
|
||||
lv_coord_t row;
|
||||
for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) {
|
||||
lv_disp_mem_fill(&vdb_buf_tmp[vdb_rel_a.x1], w, color);
|
||||
disp->driver.mem_fill(&vdb_buf_tmp[vdb_rel_a.x1], w, color);
|
||||
vdb_buf_tmp += vdb_width;
|
||||
}
|
||||
}
|
||||
/*Use hw blend if present and the area is not too small*/
|
||||
else if(lv_area_get_height(&vdb_rel_a) > VFILL_HW_ACC_SIZE_LIMIT &&
|
||||
lv_disp_is_mem_blend_supported()) {
|
||||
disp->driver.mem_blend) {
|
||||
/*Fill a one line sized buffer with a color and blend this later*/
|
||||
if(color_array_tmp[0].full != color.full || last_width != w) {
|
||||
uint16_t i;
|
||||
@ -180,21 +177,21 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
/*Blend the filled line to every line VDB line-by-line*/
|
||||
lv_coord_t row;
|
||||
for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) {
|
||||
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
|
||||
disp->driver.mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
|
||||
vdb_buf_tmp += vdb_width;
|
||||
}
|
||||
|
||||
}
|
||||
/*Else use sw fill if no better option*/
|
||||
else {
|
||||
sw_color_fill(&vdb_p->area, vdb_p->buf, &vdb_rel_a, color, opa);
|
||||
sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa);
|
||||
}
|
||||
|
||||
}
|
||||
/*Fill with opacity*/
|
||||
else {
|
||||
/*Use hw blend if present*/
|
||||
if(lv_disp_is_mem_blend_supported()) {
|
||||
if(disp->driver.mem_blend) {
|
||||
if(color_array_tmp[0].full != color.full || last_width != w) {
|
||||
uint16_t i;
|
||||
for(i = 0; i < w; i++) {
|
||||
@ -205,19 +202,19 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
}
|
||||
lv_coord_t row;
|
||||
for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) {
|
||||
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
|
||||
disp->driver.mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
|
||||
vdb_buf_tmp += vdb_width;
|
||||
}
|
||||
|
||||
}
|
||||
/*Use sw fill with opa if no better option*/
|
||||
else {
|
||||
sw_color_fill(&vdb_p->area, vdb_p->buf, &vdb_rel_a, color, opa);
|
||||
sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa);
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
sw_color_fill(&vdb_p->area, vdb_p->buf, &vdb_rel_a, color, opa);
|
||||
sw_color_fill(&vdb->area, vdb->buf_act, &vdb_rel_a, color, opa);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -230,7 +227,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (0..255)
|
||||
*/
|
||||
void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
@ -292,14 +289,11 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
if(pos_x + letter_w < mask_p->x1 || pos_x > mask_p->x2 ||
|
||||
pos_y + letter_h < mask_p->y1 || pos_y > mask_p->y2) return;
|
||||
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
if(!vdb_p) {
|
||||
LV_LOG_WARN("Invalid VDB pointer");
|
||||
return;
|
||||
}
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
|
||||
|
||||
lv_coord_t vdb_width = lv_area_get_width(&vdb_p->area);
|
||||
lv_color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
lv_coord_t vdb_width = lv_area_get_width(&vdb->area);
|
||||
lv_color_t * vdb_buf_tmp = vdb->buf_act;
|
||||
lv_coord_t col, row;
|
||||
uint8_t col_bit;
|
||||
uint8_t col_byte_cnt;
|
||||
@ -315,8 +309,8 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
lv_coord_t row_end = pos_y + letter_h <= mask_p->y2 ? letter_h : mask_p->y2 - pos_y + 1;
|
||||
|
||||
/*Set a pointer on VDB to the first pixel of the letter*/
|
||||
vdb_buf_tmp += ((pos_y - vdb_p->area.y1) * vdb_width)
|
||||
+ pos_x - vdb_p->area.x1;
|
||||
vdb_buf_tmp += ((pos_y - vdb->area.y1) * vdb_width)
|
||||
+ pos_x - vdb->area.x1;
|
||||
|
||||
/*If the letter is partially out of mask the move there on VDB*/
|
||||
vdb_buf_tmp += (row_start * vdb_width) + col_start;
|
||||
@ -324,8 +318,6 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
/*Move on the map too*/
|
||||
map_p += (row_start * width_byte_bpp) + ((col_start * bpp) >> 3);
|
||||
|
||||
lv_disp_t * disp = lv_disp_get_active();
|
||||
|
||||
uint8_t letter_px;
|
||||
lv_opa_t px_opa;
|
||||
for(row = row_start; row < row_end; row ++) {
|
||||
@ -343,9 +335,9 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
(uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8;
|
||||
}
|
||||
|
||||
if(disp->driver.vdb_wr) {
|
||||
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width,
|
||||
(col + pos_x) - vdb_p->area.x1, (row + pos_y) - vdb_p->area.y1,
|
||||
if(disp->driver.set_px_cb) {
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width,
|
||||
(col + pos_x) - vdb->area.x1, (row + pos_y) - vdb->area.y1,
|
||||
color, px_opa);
|
||||
} else {
|
||||
#if LV_COLOR_SCREEN_TRANSP == 0
|
||||
@ -385,7 +377,7 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa)
|
||||
{
|
||||
@ -395,11 +387,6 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
|
||||
lv_area_t masked_a;
|
||||
bool union_ok;
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
if(!vdb_p) {
|
||||
LV_LOG_WARN("Invalid VDB pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
/*Get the union of map size and mask*/
|
||||
/* The mask is already truncated to the vdb size
|
||||
@ -421,32 +408,33 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
map_p += (masked_a.x1 - cords_p->x1) * px_size_byte;
|
||||
}
|
||||
|
||||
/*Stores coordinates relative to the current VDB*/
|
||||
masked_a.x1 = masked_a.x1 - vdb_p->area.x1;
|
||||
masked_a.y1 = masked_a.y1 - vdb_p->area.y1;
|
||||
masked_a.x2 = masked_a.x2 - vdb_p->area.x1;
|
||||
masked_a.y2 = masked_a.y2 - vdb_p->area.y1;
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
|
||||
|
||||
lv_coord_t vdb_width = lv_area_get_width(&vdb_p->area);
|
||||
lv_color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
/*Stores coordinates relative to the current VDB*/
|
||||
masked_a.x1 = masked_a.x1 - vdb->area.x1;
|
||||
masked_a.y1 = masked_a.y1 - vdb->area.y1;
|
||||
masked_a.x2 = masked_a.x2 - vdb->area.x1;
|
||||
masked_a.y2 = masked_a.y2 - vdb->area.y1;
|
||||
|
||||
lv_coord_t vdb_width = lv_area_get_width(&vdb->area);
|
||||
lv_color_t * vdb_buf_tmp = vdb->buf_act;
|
||||
vdb_buf_tmp += (uint32_t) vdb_width * masked_a.y1; /*Move to the first row*/
|
||||
vdb_buf_tmp += (uint32_t) masked_a.x1; /*Move to the first col*/
|
||||
|
||||
lv_coord_t row;
|
||||
lv_coord_t map_useful_w = lv_area_get_width(&masked_a);
|
||||
|
||||
lv_disp_t * disp = lv_disp_get_active();
|
||||
|
||||
/*The simplest case just copy the pixels into the VDB*/
|
||||
if(chroma_key == false && alpha_byte == false && opa == LV_OPA_COVER && recolor_opa == LV_OPA_TRANSP) {
|
||||
|
||||
/*Use the custom VDB write function is exists*/
|
||||
if(disp->driver.vdb_wr) {
|
||||
if(disp->driver.set_px_cb) {
|
||||
lv_coord_t col;
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = 0; col < map_useful_w; col++) {
|
||||
lv_color_t px_color = *((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]);
|
||||
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa);
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa);
|
||||
}
|
||||
map_p += map_width * px_size_byte; /*Next row on the map*/
|
||||
}
|
||||
@ -455,10 +443,10 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
else {
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
#if USE_LV_GPU
|
||||
if(lv_disp_is_mem_blend_supported() == false) {
|
||||
if(disp->driver.mem_blend == false) {
|
||||
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
|
||||
} else {
|
||||
lv_disp_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
|
||||
disp->driver.mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
|
||||
}
|
||||
#else
|
||||
sw_mem_blend(vdb_buf_tmp, (lv_color_t *)map_p, map_useful_w, opa);
|
||||
@ -508,8 +496,8 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
recolored_px = lv_color_mix(recolor, last_img_px, recolor_opa);
|
||||
}
|
||||
/*Handle custom VDB write is present*/
|
||||
if(disp->driver.vdb_wr) {
|
||||
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, recolored_px, opa_result);
|
||||
if(disp->driver.set_px_cb) {
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, recolored_px, opa_result);
|
||||
}
|
||||
/*Normal native VDB write*/
|
||||
else {
|
||||
@ -518,8 +506,8 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
}
|
||||
} else {
|
||||
/*Handle custom VDB write is present*/
|
||||
if(disp->driver.vdb_wr) {
|
||||
disp->driver.vdb_wr((uint8_t *)vdb_p->buf, vdb_width, col + masked_a.x1, row, px_color, opa_result);
|
||||
if(disp->driver.set_px_cb) {
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, px_color, opa_result);
|
||||
}
|
||||
/*Normal native VDB write*/
|
||||
else {
|
||||
@ -529,21 +517,6 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
|
||||
#else
|
||||
vdb_buf_tmp[col] = color_mix_2_alpha(vdb_buf_tmp[col], vdb_buf_tmp[col].alpha, px_color, opa_result);
|
||||
// if(vdb_buf_tmp[col].alpha == LV_OPA_TRANSP) {
|
||||
// /* When it is the first visible pixel on the transparent screen
|
||||
// * simlply use this color and set the pixel opa as backrounds alpha*/
|
||||
// vdb_buf_tmp[col] = px_color;
|
||||
// vdb_buf_tmp[col].alpha = opa_result;
|
||||
// } else {
|
||||
// /* If already this pixel is already written then for performance reasons
|
||||
// * don't care with alpha channel
|
||||
// */
|
||||
// lv_opa_t bg_opa = vdb_buf_tmp[col].alpha;
|
||||
// vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result);
|
||||
//
|
||||
// uint16_t opa_tmp = (uint16_t)opa_result + ((bg_opa * (255 - opa_result)) >> 8);
|
||||
// vdb_buf_tmp[col].alpha = opa_tmp > 0xFF ? 0xFF : opa_tmp ;
|
||||
// }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -594,11 +567,11 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_
|
||||
lv_coord_t col;
|
||||
lv_coord_t mem_width = lv_area_get_width(mem_area);
|
||||
|
||||
lv_disp_t * disp = lv_disp_get_active();
|
||||
if(disp->driver.vdb_wr) {
|
||||
lv_disp_t * disp = lv_refr_get_disp_refreshing();
|
||||
if(disp->driver.set_px_cb) {
|
||||
for(col = fill_area->x1; col <= fill_area->x2; col++) {
|
||||
for(row = fill_area->y1; row <= fill_area->y2; row++) {
|
||||
disp->driver.vdb_wr((uint8_t *)mem, mem_width, col, row, color, opa);
|
||||
disp->driver.set_px_cb(&disp->driver, (uint8_t *)mem, mem_width, col, row, color, opa);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -700,4 +673,3 @@ static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa,
|
||||
}
|
||||
#endif /*LV_COLOR_SCREEN_TRANSP*/
|
||||
|
||||
#endif
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file lv_draw_vbasic.h
|
||||
* @file lv_draw_basic.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_VBASIC_H
|
||||
#define LV_DRAW_VBASIC_H
|
||||
#ifndef LV_DRAW_BASIC_H
|
||||
#define LV_DRAW_BASIC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -19,8 +19,6 @@ extern "C" {
|
||||
#include "../../lv_conf.h"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_misc/lv_font.h"
|
||||
@ -37,7 +35,7 @@ extern "C" {
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa);
|
||||
void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa);
|
||||
/**
|
||||
* Fill an area in the Virtual Display Buffer
|
||||
* @param cords_p coordinates of the area to fill
|
||||
@ -45,7 +43,7 @@ void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t col
|
||||
* @param color fill color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
@ -57,7 +55,7 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (0..255)
|
||||
*/
|
||||
void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
@ -72,7 +70,7 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa);
|
||||
|
||||
@ -80,10 +78,8 @@ void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_VDB_SIZE != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_RBASIC_H*/
|
||||
#endif /*LV_DRAW_BASIC_H*/
|
@ -316,7 +316,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
|
||||
/* The decoder open could open the image and gave the entire uncompressed image.
|
||||
* Just draw it!*/
|
||||
if(img_data) {
|
||||
map_fp(coords, mask, img_data, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense);
|
||||
lv_draw_map(coords, mask, img_data, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense);
|
||||
}
|
||||
/* The whole uncompressed image is not available. Try to read it line-by-line*/
|
||||
else {
|
||||
@ -325,7 +325,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
|
||||
#if LV_COMPILER_VLA_SUPPORTED
|
||||
uint8_t buf[(lv_area_get_width(&mask_com) * ((LV_COLOR_DEPTH >> 3) + 1))];
|
||||
#else
|
||||
uint8_t buf[LV_HOR_RES * ((LV_COLOR_DEPTH >> 3) + 1)]; /*+1 because of the possible alpha byte*/
|
||||
uint8_t buf[LV_HOR_RES_MAX * ((LV_COLOR_DEPTH >> 3) + 1)]; /*+1 because of the possible alpha byte*/
|
||||
#endif
|
||||
lv_area_t line;
|
||||
lv_area_copy(&line, &mask_com);
|
||||
@ -341,7 +341,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas
|
||||
LV_LOG_WARN("Image draw can't read the line");
|
||||
return LV_RES_INV;
|
||||
}
|
||||
map_fp(&line, mask, buf, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense);
|
||||
lv_draw_map(&line, mask, buf, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense);
|
||||
line.y1++;
|
||||
line.y2++;
|
||||
y++;
|
||||
|
@ -7,7 +7,6 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_label.h"
|
||||
#include "lv_draw_rbasic.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
|
||||
/*********************
|
||||
@ -78,6 +77,14 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
||||
pos.x = coords->x1;
|
||||
pos.y = coords->y1;
|
||||
|
||||
lv_coord_t x_ofs = 0;
|
||||
lv_coord_t y_ofs = 0;
|
||||
if(offset != NULL) {
|
||||
x_ofs = offset->x;
|
||||
y_ofs = offset->y;
|
||||
pos.y += y_ofs;
|
||||
}
|
||||
|
||||
uint32_t line_start = 0;
|
||||
uint32_t line_end = lv_txt_get_next_line(txt, font, style->text.letter_space, w, flag);
|
||||
|
||||
@ -115,20 +122,6 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
||||
lv_color_t recolor;
|
||||
lv_coord_t letter_w;
|
||||
|
||||
lv_coord_t x_ofs = 0;
|
||||
lv_coord_t y_ofs = 0;
|
||||
if(offset != NULL) {
|
||||
x_ofs = offset->x;
|
||||
y_ofs = offset->y;
|
||||
pos.y += y_ofs;
|
||||
}
|
||||
|
||||
/*Real draw need a background color for higher bpp letter*/
|
||||
#if LV_VDB_SIZE == 0
|
||||
lv_rletter_set_background(style->body.main_color);
|
||||
#endif
|
||||
|
||||
|
||||
/*Write out all lines*/
|
||||
while(txt[line_start] != '\0') {
|
||||
if(offset != NULL) {
|
||||
@ -182,7 +175,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
||||
|
||||
if(cmd_state == CMD_STATE_IN) color = recolor;
|
||||
|
||||
letter_fp(&pos, mask, font, letter, color, opa);
|
||||
lv_draw_letter(&pos, mask, font, letter, color, opa);
|
||||
letter_w = lv_font_get_width(font, letter);
|
||||
|
||||
if(letter_w > 0){
|
||||
|
@ -192,7 +192,7 @@ static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const
|
||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask, style->line.color, opa);
|
||||
lv_draw_fill(&draw_area, mask, style->line.color, opa);
|
||||
}
|
||||
|
||||
static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
@ -214,7 +214,7 @@ static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const
|
||||
draw_area.x2 = LV_MATH_MAX(act_area.x1, act_area.x2);
|
||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
||||
fill_fp(&draw_area, mask, style->line.color, opa);
|
||||
lv_draw_fill(&draw_area, mask, style->line.color, opa);
|
||||
}
|
||||
|
||||
static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale)
|
||||
@ -436,12 +436,12 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
draw_area.y1 = prev_p.y + pattern[i].y;
|
||||
draw_area.x2 = draw_area.x1 + main_line->p_act.x - prev_p.x - 1;
|
||||
draw_area.y2 = draw_area.y1;
|
||||
fill_fp(&draw_area, mask, style->line.color, opa);
|
||||
lv_draw_fill(&draw_area, mask, style->line.color, opa);
|
||||
|
||||
/* Fill the gaps
|
||||
* When stepping in y one pixel remains empty on every corner (don't do this on the first segment ) */
|
||||
if(i != 0 && pattern[i].x != pattern[i - 1].x && !first_run) {
|
||||
px_fp(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa);
|
||||
lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -463,12 +463,12 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
draw_area.y1 = prev_p.y + pattern[i].y;
|
||||
draw_area.x2 = draw_area.x1 + main_line->p_act.x - prev_p.x;
|
||||
draw_area.y2 = draw_area.y1;
|
||||
fill_fp(&draw_area, mask, style->line.color, opa);
|
||||
lv_draw_fill(&draw_area, mask, style->line.color, opa);
|
||||
|
||||
/* Fill the gaps
|
||||
* When stepping in y one pixel remains empty on every corner */
|
||||
if(i != 0 && pattern[i].x != pattern[i - 1].x && !first_run) {
|
||||
px_fp(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa);
|
||||
lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -489,12 +489,12 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
draw_area.x2 = draw_area.x1;
|
||||
draw_area.y2 = draw_area.y1 + main_line->p_act.y - prev_p.y - 1;
|
||||
|
||||
fill_fp(&draw_area, mask, style->line.color, opa);
|
||||
lv_draw_fill(&draw_area, mask, style->line.color, opa);
|
||||
|
||||
/* Fill the gaps
|
||||
* When stepping in x one pixel remains empty on every corner (don't do this on the first segment ) */
|
||||
if(i != 0 && pattern[i].y != pattern[i - 1].y && !first_run) {
|
||||
px_fp(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa);
|
||||
lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa);
|
||||
}
|
||||
|
||||
}
|
||||
@ -519,12 +519,12 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
draw_area.x2 = draw_area.x1;
|
||||
draw_area.y2 = draw_area.y1 + main_line->p_act.y - prev_p.y;
|
||||
|
||||
fill_fp(&draw_area, mask, style->line.color, opa);
|
||||
lv_draw_fill(&draw_area, mask, style->line.color, opa);
|
||||
|
||||
/* Fill the gaps
|
||||
* When stepping in x one pixel remains empty on every corner */
|
||||
if(i != 0 && pattern[i].y != pattern[i - 1].y && !first_run) {
|
||||
px_fp(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa);
|
||||
lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,269 +0,0 @@
|
||||
/**
|
||||
* @file lv_draw_rbasic.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_draw_rbasic.h"
|
||||
#if USE_LV_REAL_DRAW != 0
|
||||
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "../lv_misc/lv_font.h"
|
||||
#include "lv_draw.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_color_t letter_bg_color;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Put a pixel to the display
|
||||
* @param x x coordinate of the pixel
|
||||
* @param y y coordinate of the pixel
|
||||
* @param mask_p the pixel will be drawn on this area
|
||||
* @param color color of the pixel
|
||||
* @param opa opacity (ignored, only for compatibility with lv_vpx)
|
||||
*/
|
||||
void lv_rpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
(void)opa; /*Opa is used only for compatibility with lv_vpx*/
|
||||
|
||||
lv_area_t area;
|
||||
area.x1 = x;
|
||||
area.y1 = y;
|
||||
area.x2 = x;
|
||||
area.y2 = y;
|
||||
|
||||
lv_rfill(&area, mask_p, color, LV_OPA_COVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill an area on the display
|
||||
* @param cords_p coordinates of the area to fill
|
||||
* @param mask_p fill only o this mask
|
||||
* @param color fill color
|
||||
* @param opa opacity (ignored, only for compatibility with lv_vfill)
|
||||
*/
|
||||
void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
|
||||
(void)opa; /*Opa is used only for compatibility with lv_vfill*/
|
||||
|
||||
lv_area_t masked_area;
|
||||
bool union_ok = true;
|
||||
|
||||
if(mask_p != NULL) {
|
||||
union_ok = lv_area_intersect(&masked_area, cords_p, mask_p);
|
||||
} else {
|
||||
lv_area_t scr_area;
|
||||
lv_area_set(&scr_area, 0, 0, LV_HOR_RES - 1, LV_VER_RES - 1);
|
||||
union_ok = lv_area_intersect(&masked_area, cords_p, &scr_area);
|
||||
}
|
||||
|
||||
if(union_ok != false) {
|
||||
lv_disp_fill(masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2, color);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a letter to the display
|
||||
* @param pos_p left-top coordinate of the latter
|
||||
* @param mask_p the letter will be drawn only on this area
|
||||
* @param font_p pointer to font
|
||||
* @param letter a letter to draw
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (ignored, only for compatibility with lv_vletter)
|
||||
*/
|
||||
void lv_rletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
(void)opa; /*Opa is used only for compatibility with lv_vletter*/
|
||||
|
||||
static uint8_t bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
|
||||
static uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
|
||||
static uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
|
||||
68, 85, 102, 119,
|
||||
136, 153, 170, 187,
|
||||
204, 221, 238, 255
|
||||
};
|
||||
|
||||
if(font_p == NULL) return;
|
||||
|
||||
uint8_t letter_w = lv_font_get_width(font_p, letter);
|
||||
uint8_t letter_h = lv_font_get_height(font_p);
|
||||
uint8_t bpp = lv_font_get_bpp(font_p, letter); /*Bit per pixel (1,2, 4 or 8)*/
|
||||
uint8_t * bpp_opa_table;
|
||||
uint8_t mask_init;
|
||||
uint8_t mask;
|
||||
|
||||
switch(bpp) {
|
||||
case 1:
|
||||
bpp_opa_table = bpp1_opa_table;
|
||||
mask_init = 0x80;
|
||||
break;
|
||||
case 2:
|
||||
bpp_opa_table = bpp2_opa_table;
|
||||
mask_init = 0xC0;
|
||||
break;
|
||||
case 4:
|
||||
bpp_opa_table = bpp4_opa_table;
|
||||
mask_init = 0xF0;
|
||||
break;
|
||||
case 8:
|
||||
bpp_opa_table = NULL;
|
||||
mask_init = 0xFF;
|
||||
break; /*No opa table, pixel value will be used directly*/
|
||||
default:
|
||||
return; /*Invalid bpp. Can't render the letter*/
|
||||
}
|
||||
|
||||
const uint8_t * map_p = lv_font_get_bitmap(font_p, letter);
|
||||
|
||||
if(map_p == NULL) return;
|
||||
|
||||
/*If the letter is completely out of mask don't draw it */
|
||||
if(pos_p->x + letter_w < mask_p->x1 || pos_p->x > mask_p->x2 ||
|
||||
pos_p->y + letter_h < mask_p->y1 || pos_p->y > mask_p->y2) return;
|
||||
|
||||
lv_coord_t col, row;
|
||||
uint8_t col_bit;
|
||||
uint8_t col_byte_cnt;
|
||||
uint8_t width_byte_scr = letter_w >> 3; /*Width in bytes (on the screen finally) (e.g. w = 11 -> 2 bytes wide)*/
|
||||
if(letter_w & 0x7) width_byte_scr++;
|
||||
uint8_t width_byte_bpp = (letter_w * bpp) >> 3; /*Letter width in byte. Real width in the font*/
|
||||
if((letter_w * bpp) & 0x7) width_byte_bpp++;
|
||||
|
||||
/* Calculate the col/row start/end on the map*/
|
||||
lv_coord_t col_start = pos_p->x >= mask_p->x1 ? 0 : mask_p->x1 - pos_p->x;
|
||||
lv_coord_t col_end = pos_p->x + letter_w <= mask_p->x2 ? letter_w : mask_p->x2 - pos_p->x + 1;
|
||||
lv_coord_t row_start = pos_p->y >= mask_p->y1 ? 0 : mask_p->y1 - pos_p->y;
|
||||
lv_coord_t row_end = pos_p->y + letter_h <= mask_p->y2 ? letter_h : mask_p->y2 - pos_p->y + 1;
|
||||
|
||||
/*Move on the map too*/
|
||||
map_p += (row_start * width_byte_bpp) + ((col_start * bpp) >> 3);
|
||||
|
||||
uint8_t letter_px;
|
||||
for(row = row_start; row < row_end; row ++) {
|
||||
col_byte_cnt = 0;
|
||||
col_bit = (col_start * bpp) % 8;
|
||||
mask = mask_init >> col_bit;
|
||||
for(col = col_start; col < col_end; col ++) {
|
||||
letter_px = (*map_p & mask) >> (8 - col_bit - bpp);
|
||||
if(letter_px != 0) {
|
||||
lv_rpx(pos_p->x + col, pos_p->y + row, mask_p, lv_color_mix(color, letter_bg_color, bpp == 8 ? letter_px : bpp_opa_table[letter_px]), LV_OPA_COVER);
|
||||
}
|
||||
|
||||
if(col_bit < 8 - bpp) {
|
||||
col_bit += bpp;
|
||||
mask = mask >> bpp;
|
||||
} else {
|
||||
col_bit = 0;
|
||||
col_byte_cnt ++;
|
||||
mask = mask_init;
|
||||
map_p ++;
|
||||
}
|
||||
}
|
||||
|
||||
map_p += (width_byte_bpp) - col_byte_cnt;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When the letter is ant-aliased it needs to know the background color
|
||||
* @param bg_color the background color of the currently drawn letter
|
||||
*/
|
||||
void lv_rletter_set_background(lv_color_t color)
|
||||
{
|
||||
letter_bg_color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a color map to the display (image)
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area
|
||||
* @param map_p pointer to a lv_color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with 'lv_vmap')
|
||||
* @param chroma_keyed true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels
|
||||
* @param alpha_byte true: extra alpha byte is inserted for every pixel (not supported, only l'v_vmap' can draw it)
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_rmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa)
|
||||
{
|
||||
if(alpha_byte) return; /*Pixel level opacity i not supported in real map drawing*/
|
||||
|
||||
(void)opa; /*opa is used only for compatibility with lv_vmap*/
|
||||
lv_area_t masked_a;
|
||||
bool union_ok;
|
||||
|
||||
union_ok = lv_area_intersect(&masked_a, cords_p, mask_p);
|
||||
|
||||
/*If there are common part of the mask and map then draw the map*/
|
||||
if(union_ok == false) return;
|
||||
|
||||
/*Go to the first pixel*/
|
||||
lv_coord_t map_width = lv_area_get_width(cords_p);
|
||||
map_p += (masked_a.y1 - cords_p->y1) * map_width * sizeof(lv_color_t);
|
||||
map_p += (masked_a.x1 - cords_p->x1) * sizeof(lv_color_t);
|
||||
|
||||
lv_coord_t row;
|
||||
if(recolor_opa == LV_OPA_TRANSP && chroma_key == false) {
|
||||
lv_coord_t mask_w = lv_area_get_width(&masked_a) - 1;
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
lv_disp_map(masked_a.x1, row, masked_a.x1 + mask_w, row, (lv_color_t *)map_p);
|
||||
map_p += map_width * sizeof(lv_color_t); /*Next row on the map*/
|
||||
}
|
||||
} else {
|
||||
lv_color_t chroma_key_color = LV_COLOR_TRANSP;
|
||||
lv_coord_t col;
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col++) {
|
||||
lv_color_t * px_color = (lv_color_t *) &map_p[(uint32_t)(col - masked_a.x1) * sizeof(lv_color_t)];
|
||||
|
||||
if(chroma_key && chroma_key_color.full == px_color->full) continue;
|
||||
|
||||
if(recolor_opa != LV_OPA_TRANSP) {
|
||||
lv_color_t recolored_px = lv_color_mix(recolor, *px_color, recolor_opa);
|
||||
|
||||
lv_rpx(col, row, mask_p, recolored_px, LV_OPA_COVER);
|
||||
} else {
|
||||
lv_rpx(col, row, mask_p, *px_color, LV_OPA_COVER);
|
||||
}
|
||||
|
||||
}
|
||||
map_p += map_width * sizeof(lv_color_t); /*Next row on the map*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_REAL_DRAW*/
|
@ -1,96 +0,0 @@
|
||||
/**
|
||||
* @file lv_draw_rbasic..h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DRAW_RBASIC_H
|
||||
#define LV_DRAW_RBASIC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#ifdef LV_CONF_INCLUDE_SIMPLE
|
||||
#include "lv_conf.h"
|
||||
#else
|
||||
#include "../../lv_conf.h"
|
||||
#endif
|
||||
|
||||
#if USE_LV_REAL_DRAW != 0
|
||||
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_misc/lv_font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
void lv_rpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Fill an area on the display
|
||||
* @param cords_p coordinates of the area to fill
|
||||
* @param mask_p fill only o this mask
|
||||
* @param color fill color
|
||||
* @param opa opacity (ignored, only for compatibility with lv_vfill)
|
||||
*/
|
||||
void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a letter to the display
|
||||
* @param pos_p left-top coordinate of the latter
|
||||
* @param mask_p the letter will be drawn only on this area
|
||||
* @param font_p pointer to font
|
||||
* @param letter a letter to draw
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (ignored, only for compatibility with lv_vletter)
|
||||
*/
|
||||
void lv_rletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* When the letter is ant-aliased it needs to know the background color
|
||||
* @param bg_color the background color of the currently drawn letter
|
||||
*/
|
||||
void lv_rletter_set_background(lv_color_t color);
|
||||
|
||||
|
||||
/**
|
||||
* Draw a color map to the display (image)
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area
|
||||
* @param map_p pointer to a lv_color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with 'lv_vmap')
|
||||
* @param chroma_keyed true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels
|
||||
* @param alpha_byte true: extra alpha byte is inserted for every pixel (not supported, only l'v_vmap' can draw it)
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_rmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_REAL_DRAW*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_DRAW_RBASIC_H*/
|
@ -30,7 +30,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
|
||||
#if USE_LV_SHADOW && LV_VDB_SIZE
|
||||
#if USE_LV_SHADOW
|
||||
static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale);
|
||||
@ -66,7 +66,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_sty
|
||||
{
|
||||
if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return;
|
||||
|
||||
#if USE_LV_SHADOW && LV_VDB_SIZE
|
||||
#if USE_LV_SHADOW
|
||||
if(style->body.shadow.width != 0) {
|
||||
lv_draw_shadow(coords, mask, style, opa_scale);
|
||||
}
|
||||
@ -133,7 +133,7 @@ static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * ma
|
||||
#endif
|
||||
}
|
||||
|
||||
fill_fp(&work_area, mask, mcolor, opa);
|
||||
lv_draw_fill(&work_area, mask, mcolor, opa);
|
||||
} else {
|
||||
lv_coord_t row;
|
||||
lv_coord_t row_start = coords->y1 + radius;
|
||||
@ -157,7 +157,7 @@ static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * ma
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - work_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
|
||||
fill_fp(&work_area, mask, act_color, opa);
|
||||
lv_draw_fill(&work_area, mask, act_color, opa);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -263,19 +263,19 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
}
|
||||
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_top, aa_opa);
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_top, aa_opa);
|
||||
|
||||
mix = (uint32_t)((uint32_t)(radius - out_y_seg_start + i) * 255) / height;
|
||||
aa_color_ver = lv_color_mix(mcolor, gcolor, mix);
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
|
||||
aa_color_ver = lv_color_mix(gcolor, mcolor, mix);
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
}
|
||||
|
||||
out_x_last = cir.x;
|
||||
@ -304,7 +304,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - edge_top_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&edge_top_area, mask, act_color, opa);
|
||||
lv_draw_fill(&edge_top_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
if(mid_top_refr != 0) {
|
||||
@ -313,7 +313,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - mid_top_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&mid_top_area, mask, act_color, opa);
|
||||
lv_draw_fill(&mid_top_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
if(mid_bot_refr != 0) {
|
||||
@ -322,7 +322,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - mid_bot_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&mid_bot_area, mask, act_color, opa);
|
||||
lv_draw_fill(&mid_bot_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
if(edge_bot_refr != 0) {
|
||||
@ -332,7 +332,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - edge_bot_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&edge_bot_area, mask, act_color, opa);
|
||||
lv_draw_fill(&edge_bot_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
/*Save the current coordinates*/
|
||||
@ -364,7 +364,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - edge_top_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&edge_top_area, mask, act_color, opa);
|
||||
lv_draw_fill(&edge_top_area, mask, act_color, opa);
|
||||
|
||||
if(edge_top_area.y1 != mid_top_area.y1) {
|
||||
|
||||
@ -373,7 +373,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - mid_top_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&mid_top_area, mask, act_color, opa);
|
||||
lv_draw_fill(&mid_top_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
if(mcolor.full == gcolor.full) act_color = mcolor;
|
||||
@ -381,7 +381,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - mid_bot_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&mid_bot_area, mask, act_color, opa);
|
||||
lv_draw_fill(&mid_bot_area, mask, act_color, opa);
|
||||
|
||||
if(edge_bot_area.y1 != mid_bot_area.y1) {
|
||||
|
||||
@ -390,7 +390,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
mix = (uint32_t)((uint32_t)(coords->y2 - edge_bot_area.y1) * 255) / height;
|
||||
act_color = lv_color_mix(mcolor, gcolor, mix);
|
||||
}
|
||||
fill_fp(&edge_bot_area, mask, act_color, opa);
|
||||
lv_draw_fill(&edge_bot_area, mask, act_color, opa);
|
||||
}
|
||||
|
||||
|
||||
@ -400,11 +400,11 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
edge_top_area.x2 = coords->x2 - radius - 2;
|
||||
edge_top_area.y1 = coords->y1;
|
||||
edge_top_area.y2 = coords->y1;
|
||||
fill_fp(&edge_top_area, mask, style->body.main_color, opa);
|
||||
lv_draw_fill(&edge_top_area, mask, style->body.main_color, opa);
|
||||
|
||||
edge_top_area.y1 = coords->y2;
|
||||
edge_top_area.y2 = coords->y2;
|
||||
fill_fp(&edge_top_area, mask, style->body.grad_color, opa);
|
||||
lv_draw_fill(&edge_top_area, mask, style->body.grad_color, opa);
|
||||
|
||||
/*Last parts of the anti-alias*/
|
||||
out_y_seg_end = cir.y;
|
||||
@ -421,19 +421,19 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
lv_coord_t i;
|
||||
for(i = 0; i < seg_size; i++) {
|
||||
lv_opa_t aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_top, aa_opa);
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_top, aa_opa);
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_bottom, aa_opa);
|
||||
|
||||
mix = (uint32_t)((uint32_t)(radius - out_y_seg_start + i) * 255) / height;
|
||||
aa_color_ver = lv_color_mix(mcolor, gcolor, mix);
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa);
|
||||
|
||||
aa_color_ver = lv_color_mix(gcolor, mcolor, mix);
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa);
|
||||
}
|
||||
|
||||
/*In some cases the last pixel is not drawn*/
|
||||
@ -446,10 +446,10 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t *
|
||||
aa_color_hor_bottom = lv_color_mix(mcolor, gcolor, mix);
|
||||
|
||||
lv_opa_t aa_opa = opa >> 1;
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, aa_color_hor_bottom, aa_opa);
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, aa_color_hor_bottom, aa_opa);
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, aa_color_hor_top, aa_opa);
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, aa_color_hor_bottom, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, aa_color_hor_top, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, aa_color_hor_top, aa_opa);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -498,7 +498,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x2;
|
||||
work_area.y1 = coords->y1;
|
||||
work_area.y2 = coords->y1 + bwidth;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Right top corner*/
|
||||
@ -507,7 +507,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x2;
|
||||
work_area.y1 = coords->y1 + (part & LV_BORDER_TOP ? bwidth + 1 : 0);
|
||||
work_area.y2 = coords->y2 - (part & LV_BORDER_BOTTOM ? bwidth + 1 : 0);
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Left bottom corner*/
|
||||
@ -516,7 +516,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x1 + bwidth;
|
||||
work_area.y1 = coords->y1 + (part & LV_BORDER_TOP ? bwidth + 1 : 0);
|
||||
work_area.y2 = coords->y2 - (part & LV_BORDER_BOTTOM ? bwidth + 1 : 0);
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Right bottom corner*/
|
||||
@ -525,7 +525,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x2;
|
||||
work_area.y1 = coords->y2 - bwidth;
|
||||
work_area.y2 = coords->y2;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -544,14 +544,14 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
if(part & LV_BORDER_LEFT) {
|
||||
work_area.x1 = coords->x1;
|
||||
work_area.x2 = work_area.x1 + bwidth;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Right border*/
|
||||
if(part & LV_BORDER_RIGHT) {
|
||||
work_area.x2 = coords->x2;
|
||||
work_area.x1 = work_area.x2 - bwidth;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
work_area.x1 = coords->x1 + corner_size - length_corr;
|
||||
@ -561,14 +561,14 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
if(part & LV_BORDER_TOP) {
|
||||
work_area.y1 = coords->y1;
|
||||
work_area.y2 = coords->y1 + bwidth;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Lower border*/
|
||||
if(part & LV_BORDER_BOTTOM) {
|
||||
work_area.y2 = coords->y2;
|
||||
work_area.y1 = work_area.y2 - bwidth;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Draw the a remaining rectangles if the radius is smaller then bwidth */
|
||||
@ -579,7 +579,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x1 + radius + LV_ANTIALIAS;
|
||||
work_area.y1 = coords->y1 + radius + 1 + LV_ANTIALIAS;
|
||||
work_area.y2 = coords->y1 + bwidth;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Right top correction*/
|
||||
@ -588,7 +588,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x2;
|
||||
work_area.y1 = coords->y1 + radius + 1 + LV_ANTIALIAS;
|
||||
work_area.y2 = coords->y1 + bwidth;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Left bottom correction*/
|
||||
@ -597,7 +597,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x1 + radius + LV_ANTIALIAS;
|
||||
work_area.y1 = coords->y2 - bwidth;
|
||||
work_area.y2 = coords->y2 - radius - 1 - LV_ANTIALIAS;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Right bottom correction*/
|
||||
@ -606,7 +606,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x2;
|
||||
work_area.y1 = coords->y2 - bwidth;
|
||||
work_area.y2 = coords->y2 - radius - 1 - LV_ANTIALIAS;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -618,7 +618,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x1 + LV_ANTIALIAS;
|
||||
work_area.y1 = coords->y1;
|
||||
work_area.y2 = coords->y1 + LV_ANTIALIAS;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Right top corner*/
|
||||
@ -627,7 +627,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x2;
|
||||
work_area.y1 = coords->y1;
|
||||
work_area.y2 = coords->y1 + LV_ANTIALIAS;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Left bottom corner*/
|
||||
@ -636,7 +636,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x1 + LV_ANTIALIAS;
|
||||
work_area.y1 = coords->y2 - LV_ANTIALIAS;
|
||||
work_area.y2 = coords->y2;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Right bottom corner*/
|
||||
@ -645,7 +645,7 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area
|
||||
work_area.x2 = coords->x2;
|
||||
work_area.y1 = coords->y2 - LV_ANTIALIAS;
|
||||
work_area.y2 = coords->y2;
|
||||
fill_fp(&work_area, mask, color, opa);
|
||||
lv_draw_fill(&work_area, mask, color, opa);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -756,24 +756,24 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -801,37 +801,37 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
/*Be sure the pixels on the middle are not drawn twice*/
|
||||
if(LV_CIRC_OCT1_X(aa_p) - 1 != LV_CIRC_OCT2_X(aa_p) + i) {
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -851,13 +851,13 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
circ_area.x2 = rb_origo.x + LV_CIRC_OCT1_X(cir_out);
|
||||
circ_area.y1 = rb_origo.y + LV_CIRC_OCT1_Y(cir_out);
|
||||
circ_area.y2 = rb_origo.y + LV_CIRC_OCT1_Y(cir_out);
|
||||
fill_fp(&circ_area, mask, color, opa);
|
||||
lv_draw_fill(&circ_area, mask, color, opa);
|
||||
|
||||
circ_area.x1 = rb_origo.x + LV_CIRC_OCT2_X(cir_out);
|
||||
circ_area.x2 = rb_origo.x + LV_CIRC_OCT2_X(cir_out);
|
||||
circ_area.y1 = rb_origo.y + LV_CIRC_OCT2_Y(cir_out) - act_w1;
|
||||
circ_area.y2 = rb_origo.y + LV_CIRC_OCT2_Y(cir_out);
|
||||
fill_fp(&circ_area, mask, color, opa);
|
||||
lv_draw_fill(&circ_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Draw the octets to the left bottom corner*/
|
||||
@ -866,13 +866,13 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
circ_area.x2 = lb_origo.x + LV_CIRC_OCT3_X(cir_out);
|
||||
circ_area.y1 = lb_origo.y + LV_CIRC_OCT3_Y(cir_out) - act_w2;
|
||||
circ_area.y2 = lb_origo.y + LV_CIRC_OCT3_Y(cir_out);
|
||||
fill_fp(&circ_area, mask, color, opa);
|
||||
lv_draw_fill(&circ_area, mask, color, opa);
|
||||
|
||||
circ_area.x1 = lb_origo.x + LV_CIRC_OCT4_X(cir_out);
|
||||
circ_area.x2 = lb_origo.x + LV_CIRC_OCT4_X(cir_out) + act_w1;
|
||||
circ_area.y1 = lb_origo.y + LV_CIRC_OCT4_Y(cir_out);
|
||||
circ_area.y2 = lb_origo.y + LV_CIRC_OCT4_Y(cir_out);
|
||||
fill_fp(&circ_area, mask, color, opa);
|
||||
lv_draw_fill(&circ_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Draw the octets to the left top corner*/
|
||||
@ -883,14 +883,14 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
circ_area.x2 = lt_origo.x + LV_CIRC_OCT5_X(cir_out) + act_w2;
|
||||
circ_area.y1 = lt_origo.y + LV_CIRC_OCT5_Y(cir_out);
|
||||
circ_area.y2 = lt_origo.y + LV_CIRC_OCT5_Y(cir_out);
|
||||
fill_fp(&circ_area, mask, color, opa);
|
||||
lv_draw_fill(&circ_area, mask, color, opa);
|
||||
}
|
||||
|
||||
circ_area.x1 = lt_origo.x + LV_CIRC_OCT6_X(cir_out);
|
||||
circ_area.x2 = lt_origo.x + LV_CIRC_OCT6_X(cir_out);
|
||||
circ_area.y1 = lt_origo.y + LV_CIRC_OCT6_Y(cir_out);
|
||||
circ_area.y2 = lt_origo.y + LV_CIRC_OCT6_Y(cir_out) + act_w1;
|
||||
fill_fp(&circ_area, mask, color, opa);
|
||||
lv_draw_fill(&circ_area, mask, color, opa);
|
||||
}
|
||||
|
||||
/*Draw the octets to the right top corner*/
|
||||
@ -899,7 +899,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
circ_area.x2 = rt_origo.x + LV_CIRC_OCT7_X(cir_out);
|
||||
circ_area.y1 = rt_origo.y + LV_CIRC_OCT7_Y(cir_out);
|
||||
circ_area.y2 = rt_origo.y + LV_CIRC_OCT7_Y(cir_out) + act_w2;
|
||||
fill_fp(&circ_area, mask, color, opa);
|
||||
lv_draw_fill(&circ_area, mask, color, opa);
|
||||
|
||||
/*Don't draw if the lines are common in the middle*/
|
||||
if(rb_origo.y + LV_CIRC_OCT1_Y(cir_out) > rt_origo.y + LV_CIRC_OCT8_Y(cir_out)) {
|
||||
@ -907,7 +907,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
circ_area.x2 = rt_origo.x + LV_CIRC_OCT8_X(cir_out);
|
||||
circ_area.y1 = rt_origo.y + LV_CIRC_OCT8_Y(cir_out);
|
||||
circ_area.y2 = rt_origo.y + LV_CIRC_OCT8_Y(cir_out);
|
||||
fill_fp(&circ_area, mask, color, opa);
|
||||
lv_draw_fill(&circ_area, mask, color, opa);
|
||||
}
|
||||
}
|
||||
lv_circ_next(&cir_out, &tmp_out);
|
||||
@ -934,23 +934,23 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
for(i = 0; i < seg_size; i++) {
|
||||
lv_opa_t aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -962,19 +962,19 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
lv_opa_t aa_opa = opa >> 1;
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
}
|
||||
|
||||
@ -987,36 +987,36 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
for(i = 0; i < seg_size; i++) {
|
||||
lv_opa_t aa_opa = lv_draw_aa_get_opa(seg_size, i, opa);
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if(LV_CIRC_OCT1_X(aa_p) - 1 != LV_CIRC_OCT2_X(aa_p) + i) {
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) {
|
||||
px_fp(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
|
||||
if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) {
|
||||
px_fp(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1025,7 +1025,7 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t
|
||||
|
||||
}
|
||||
|
||||
#if USE_LV_SHADOW && LV_VDB_SIZE
|
||||
#if USE_LV_SHADOW
|
||||
|
||||
/**
|
||||
* Draw a shadow
|
||||
@ -1089,9 +1089,9 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
lv_coord_t curve_x[radius + swidth + 1]; /*Stores the 'x' coordinates of a quarter circle.*/
|
||||
#else
|
||||
# if LV_HOR_RES > LV_VER_RES
|
||||
lv_coord_t curve_x[LV_HOR_RES];
|
||||
lv_coord_t curve_x[LV_HOR_RES_MAX];
|
||||
# else
|
||||
lv_coord_t curve_x[LV_VER_RES];
|
||||
lv_coord_t curve_x[LV_VER_RES_MAX];
|
||||
# endif
|
||||
#endif
|
||||
memset(curve_x, 0, sizeof(curve_x));
|
||||
@ -1110,9 +1110,9 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
uint32_t line_1d_blur[filter_width];
|
||||
#else
|
||||
# if LV_HOR_RES > LV_VER_RES
|
||||
uint32_t line_1d_blur[LV_HOR_RES];
|
||||
uint32_t line_1d_blur[LV_HOR_RES_MAX];
|
||||
# else
|
||||
uint32_t line_1d_blur[LV_VER_RES];
|
||||
uint32_t line_1d_blur[LV_VER_RES_MAX];
|
||||
# endif
|
||||
#endif
|
||||
/*1D Blur horizontally*/
|
||||
@ -1126,9 +1126,9 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
lv_opa_t line_2d_blur[radius + swidth + 1];
|
||||
#else
|
||||
# if LV_HOR_RES > LV_VER_RES
|
||||
lv_opa_t line_2d_blur[LV_HOR_RES];
|
||||
lv_opa_t line_2d_blur[LV_HOR_RES_MAX];
|
||||
# else
|
||||
lv_opa_t line_2d_blur[LV_VER_RES];
|
||||
lv_opa_t line_2d_blur[LV_VER_RES_MAX];
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -1203,19 +1203,19 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask
|
||||
for(d = 1; d < col; d++) {
|
||||
|
||||
if(point_lt.x < ofs_lt.x && point_lt.y < ofs_lt.y) {
|
||||
px_fp(point_lt.x, point_lt.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
lv_draw_px(point_lt.x, point_lt.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
}
|
||||
|
||||
if(point_lb.x < ofs_lb.x && point_lb.y > ofs_lb.y) {
|
||||
px_fp(point_lb.x, point_lb.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
lv_draw_px(point_lb.x, point_lb.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
}
|
||||
|
||||
if(point_rt.x > ofs_rt.x && point_rt.y < ofs_rt.y) {
|
||||
px_fp(point_rt.x, point_rt.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
lv_draw_px(point_rt.x, point_rt.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
}
|
||||
|
||||
if(point_rb.x > ofs_rb.x && point_rb.y > ofs_rb.y) {
|
||||
px_fp(point_rb.x, point_rb.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
lv_draw_px(point_rb.x, point_rb.y, mask, style->body.shadow.color, line_2d_blur[d]);
|
||||
}
|
||||
|
||||
point_rb.x++;
|
||||
@ -1247,9 +1247,9 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma
|
||||
lv_coord_t curve_x[radius + 1]; /*Stores the 'x' coordinates of a quarter circle.*/
|
||||
#else
|
||||
# if LV_HOR_RES > LV_VER_RES
|
||||
lv_coord_t curve_x[LV_HOR_RES];
|
||||
lv_coord_t curve_x[LV_HOR_RES_MAX];
|
||||
# else
|
||||
lv_coord_t curve_x[LV_VER_RES];
|
||||
lv_coord_t curve_x[LV_VER_RES_MAX];
|
||||
# endif
|
||||
#endif
|
||||
lv_point_t circ;
|
||||
@ -1266,9 +1266,9 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma
|
||||
lv_opa_t line_1d_blur[swidth];
|
||||
#else
|
||||
# if LV_HOR_RES > LV_VER_RES
|
||||
lv_opa_t line_1d_blur[LV_HOR_RES];
|
||||
lv_opa_t line_1d_blur[LV_HOR_RES_MAX];
|
||||
# else
|
||||
lv_opa_t line_1d_blur[LV_VER_RES];
|
||||
lv_opa_t line_1d_blur[LV_VER_RES_MAX];
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -1306,12 +1306,12 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma
|
||||
} else {
|
||||
px_opa = (uint16_t)((uint16_t)line_1d_blur[d] + line_1d_blur[d - diff]) >> 1;
|
||||
}
|
||||
px_fp(point_l.x, point_l.y, mask, style->body.shadow.color, px_opa);
|
||||
lv_draw_px(point_l.x, point_l.y, mask, style->body.shadow.color, px_opa);
|
||||
point_l.y ++;
|
||||
|
||||
/*Don't overdraw the pixel on the middle*/
|
||||
if(point_r.x > ofs_l.x) {
|
||||
px_fp(point_r.x, point_r.y, mask, style->body.shadow.color, px_opa);
|
||||
lv_draw_px(point_r.x, point_r.y, mask, style->body.shadow.color, px_opa);
|
||||
}
|
||||
point_r.y ++;
|
||||
}
|
||||
@ -1325,7 +1325,7 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma
|
||||
|
||||
uint16_t d;
|
||||
for(d = 0; d < swidth; d++) {
|
||||
fill_fp(&area_mid, mask, style->body.shadow.color, line_1d_blur[d]);
|
||||
lv_draw_fill(&area_mid, mask, style->body.shadow.color, line_1d_blur[d]);
|
||||
area_mid.y1 ++;
|
||||
area_mid.y2 ++;
|
||||
}
|
||||
@ -1370,19 +1370,19 @@ static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area
|
||||
for(d = 1 /*+ LV_ANTIALIAS*/; d <= swidth/* - LV_ANTIALIAS*/; d++) {
|
||||
opa_act = map[d];
|
||||
|
||||
fill_fp(&right_area, mask, style->body.shadow.color, opa_act);
|
||||
lv_draw_fill(&right_area, mask, style->body.shadow.color, opa_act);
|
||||
right_area.x1++;
|
||||
right_area.x2++;
|
||||
|
||||
fill_fp(&left_area, mask, style->body.shadow.color, opa_act);
|
||||
lv_draw_fill(&left_area, mask, style->body.shadow.color, opa_act);
|
||||
left_area.x1--;
|
||||
left_area.x2--;
|
||||
|
||||
fill_fp(&top_area, mask, style->body.shadow.color, opa_act);
|
||||
lv_draw_fill(&top_area, mask, style->body.shadow.color, opa_act);
|
||||
top_area.y1--;
|
||||
top_area.y2--;
|
||||
|
||||
fill_fp(&bottom_area, mask, style->body.shadow.color, opa_act);
|
||||
lv_draw_fill(&bottom_area, mask, style->body.shadow.color, opa_act);
|
||||
bottom_area.y1++;
|
||||
bottom_area.y2++;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, lv_colo
|
||||
draw_area.y1 = LV_MATH_MIN(act_area.y1, act_area.y2);
|
||||
draw_area.y2 = LV_MATH_MAX(act_area.y1, act_area.y2);
|
||||
draw_area.x2--; /*Do not draw most right pixel because it will be drawn by the adjacent triangle*/
|
||||
fill_fp(&draw_area, mask, color, LV_OPA_50);
|
||||
lv_draw_fill(&draw_area, mask, color, LV_OPA_COVER);
|
||||
|
||||
/*Calc. the next point of edge1*/
|
||||
y1_tmp = edge1.y;
|
||||
|
@ -48,74 +48,74 @@ void lv_font_builtin_init(void);
|
||||
|
||||
/*10 px */
|
||||
#if USE_LV_FONT_DEJAVU_10
|
||||
LV_FONT_DECLARE(lv_font_dejavu_10);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_10)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_10_LATIN_SUP
|
||||
LV_FONT_DECLARE(lv_font_dejavu_10_latin_sup);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_10_latin_sup)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_10_CYRILLIC
|
||||
LV_FONT_DECLARE(lv_font_dejavu_10_cyrillic);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_10_cyrillic)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_10
|
||||
LV_FONT_DECLARE(lv_font_symbol_10);
|
||||
LV_FONT_DECLARE(lv_font_symbol_10)
|
||||
#endif
|
||||
|
||||
/*20 px */
|
||||
#if USE_LV_FONT_DEJAVU_20
|
||||
LV_FONT_DECLARE(lv_font_dejavu_20);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_20)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_20_LATIN_SUP
|
||||
LV_FONT_DECLARE(lv_font_dejavu_20_latin_sup);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_20_latin_sup)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_20_CYRILLIC
|
||||
LV_FONT_DECLARE(lv_font_dejavu_20_cyrillic);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_20_cyrillic)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_20
|
||||
LV_FONT_DECLARE(lv_font_symbol_20);
|
||||
LV_FONT_DECLARE(lv_font_symbol_20)
|
||||
#endif
|
||||
|
||||
/*30 px */
|
||||
#if USE_LV_FONT_DEJAVU_30
|
||||
LV_FONT_DECLARE(lv_font_dejavu_30);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_30)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_30_LATIN_SUP
|
||||
LV_FONT_DECLARE(lv_font_dejavu_30_latin_sup);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_30_latin_sup)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_30_CYRILLIC
|
||||
LV_FONT_DECLARE(lv_font_dejavu_30_cyrillic);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_30_cyrillic)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_30
|
||||
LV_FONT_DECLARE(lv_font_symbol_30);
|
||||
LV_FONT_DECLARE(lv_font_symbol_30)
|
||||
#endif
|
||||
|
||||
/*40 px */
|
||||
#if USE_LV_FONT_DEJAVU_40
|
||||
LV_FONT_DECLARE(lv_font_dejavu_40);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_40)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_40_LATIN_SUP
|
||||
LV_FONT_DECLARE(lv_font_dejavu_40_latin_sup);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_40_latin_sup)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_40_CYRILLIC
|
||||
LV_FONT_DECLARE(lv_font_dejavu_40_cyrillic);
|
||||
LV_FONT_DECLARE(lv_font_dejavu_40_cyrillic)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_40
|
||||
LV_FONT_DECLARE(lv_font_symbol_40);
|
||||
LV_FONT_DECLARE(lv_font_symbol_40)
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_MONOSPACE_8
|
||||
LV_FONT_DECLARE(lv_font_monospace_8);
|
||||
LV_FONT_DECLARE(lv_font_monospace_8)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file hal.h
|
||||
* @file lv_hal.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAL_H
|
||||
#define HAL_H
|
||||
#ifndef LV_HAL_H
|
||||
#define LV_HAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -11,7 +11,7 @@
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "lv_hal.h"
|
||||
#include "../lv_misc/lv_mem.h"
|
||||
#include "../lv_core/lv_obj.h"
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
@ -36,7 +36,7 @@
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_disp_t * active;
|
||||
static lv_disp_t * disp_def;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -54,20 +54,48 @@ static lv_disp_t * active;
|
||||
*/
|
||||
void lv_disp_drv_init(lv_disp_drv_t * driver)
|
||||
{
|
||||
driver->disp_fill = NULL;
|
||||
driver->disp_map = NULL;
|
||||
driver->disp_flush = NULL;
|
||||
memset(driver, 0, sizeof(lv_disp_drv_t));
|
||||
|
||||
driver->flush_cb = NULL;
|
||||
driver->hor_res = LV_HOR_RES_MAX;
|
||||
driver->ver_res = LV_VER_RES_MAX;
|
||||
driver->buffer = NULL;
|
||||
|
||||
#if USE_LV_GPU
|
||||
driver->mem_blend = NULL;
|
||||
driver->mem_fill = NULL;
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE
|
||||
driver->vdb_wr = NULL;
|
||||
#endif
|
||||
driver->set_px_cb = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a display buffer
|
||||
* @param disp_buf pointer `lv_disp_buf_t` variable to initialize
|
||||
* @param buf1 A buffer to be used by LittlevGL to draw the image.
|
||||
* Always has to specified and can't be NULL.
|
||||
* Can be an array allocated by the user. E.g. `static lv_color_t disp_buf1[1024 * 10]`
|
||||
* Or a memory address e.g. in external SRAM
|
||||
* @param buf2 Optionally specify a second buffer to make image rendering and image flushing
|
||||
* (sending to the display) parallel.
|
||||
* In the `disp_drv->flush` you should use DMA or similar hardware to send
|
||||
* the image to the display in the background.
|
||||
* It lets LittlevGL to render next frame into the other buffer while previous is being sent.
|
||||
* Set to `NULL` if unused.
|
||||
* @param size size of the `buf1` and `buf2` in pixel count.
|
||||
*/
|
||||
void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size)
|
||||
{
|
||||
memset(disp_buf, 0, sizeof(lv_disp_buf_t));
|
||||
|
||||
disp_buf->buf1 = buf1;
|
||||
disp_buf->buf2 = buf2;
|
||||
disp_buf->buf_act = disp_buf->buf1;
|
||||
disp_buf->size = size;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register an initialized display driver.
|
||||
* Automatically set the first display as active.
|
||||
@ -76,167 +104,167 @@ void lv_disp_drv_init(lv_disp_drv_t * driver)
|
||||
*/
|
||||
lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
|
||||
{
|
||||
lv_disp_t * node;
|
||||
|
||||
node = lv_mem_alloc(sizeof(lv_disp_t));
|
||||
lv_mem_assert(node);
|
||||
if(node == NULL) return NULL;
|
||||
|
||||
memcpy(&node->driver, driver, sizeof(lv_disp_drv_t));
|
||||
node->next = NULL;
|
||||
|
||||
/* Set first display as active by default */
|
||||
if(LV_GC_ROOT(_lv_disp_list) == NULL) {
|
||||
LV_GC_ROOT(_lv_disp_list) = node;
|
||||
active = node;
|
||||
lv_obj_invalidate(lv_scr_act());
|
||||
} else {
|
||||
((lv_disp_t*)LV_GC_ROOT(_lv_disp_list))->next = node;
|
||||
lv_disp_t * disp = lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll));
|
||||
if(!disp) {
|
||||
lv_mem_assert(disp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t));
|
||||
|
||||
lv_ll_init(&disp->scr_ll, sizeof(lv_obj_t));
|
||||
|
||||
if(disp_def == NULL) disp_def = disp;
|
||||
|
||||
lv_disp_t * disp_def_tmp = disp_def;
|
||||
disp_def = disp; /*Temporarily change the default screen to create the default screens on the new display*/
|
||||
|
||||
disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/
|
||||
disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
|
||||
disp->sys_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
|
||||
lv_obj_set_style(disp->top_layer, &lv_style_transp);
|
||||
lv_obj_set_style(disp->sys_layer, &lv_style_transp);
|
||||
|
||||
disp->inv_p = 0;
|
||||
|
||||
lv_obj_invalidate(disp->act_scr);
|
||||
|
||||
disp_def = disp_def_tmp; /*Revert the default display*/
|
||||
|
||||
|
||||
/**
|
||||
* Set the active display
|
||||
* @param disp pointer to a display (return value of 'lv_disp_register')
|
||||
*/
|
||||
void lv_disp_set_active(lv_disp_t * disp)
|
||||
{
|
||||
active = disp;
|
||||
lv_obj_invalidate(lv_scr_act());
|
||||
return disp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pointer to the active display
|
||||
* @return pointer to the active display
|
||||
* Set a default screen. The new screens will be created on it by default.
|
||||
* @param disp pointer to a display
|
||||
*/
|
||||
lv_disp_t * lv_disp_get_active(void)
|
||||
void lv_disp_set_default(lv_disp_t * disp)
|
||||
{
|
||||
return active;
|
||||
disp_def = disp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default display
|
||||
* @return pointer to the default display
|
||||
*/
|
||||
lv_disp_t * lv_disp_get_default(void)
|
||||
{
|
||||
return disp_def;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
lv_coord_t lv_disp_get_hor_res(lv_disp_t * disp)
|
||||
{
|
||||
if(disp == NULL) disp = lv_disp_get_default();
|
||||
|
||||
if(disp == NULL) return LV_HOR_RES_MAX;
|
||||
else return disp->driver.hor_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp)
|
||||
{
|
||||
if(disp == NULL) disp = lv_disp_get_default();
|
||||
|
||||
if(disp == NULL) return LV_VER_RES_MAX;
|
||||
else return disp->driver.ver_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call in the display driver's `flush_cb` function when the flushing is finished
|
||||
* @param disp_drv pointer to display driver in `flush_cb` where this function is called
|
||||
*/
|
||||
LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv)
|
||||
{
|
||||
disp_drv->buffer->flushing = 0;
|
||||
|
||||
/*If the screen is transparent initialize it when the flushing is ready*/
|
||||
#if LV_COLOR_SCREEN_TRANSP
|
||||
memset(vdb_buf, 0x00, LV_VDB_SIZE_IN_BYTES);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the next display.
|
||||
* @param disp pointer to the current display. NULL to initialize.
|
||||
* @return the next display or NULL if no more. Give the first display when the parameter is NULL
|
||||
*/
|
||||
lv_disp_t * lv_disp_next(lv_disp_t * disp)
|
||||
lv_disp_t * lv_disp_get_next(lv_disp_t * disp)
|
||||
{
|
||||
if(disp == NULL) {
|
||||
return LV_GC_ROOT(_lv_disp_list);
|
||||
} else {
|
||||
if(((lv_disp_t*)LV_GC_ROOT(_lv_disp_list))->next == NULL) return NULL;
|
||||
else return ((lv_disp_t*)LV_GC_ROOT(_lv_disp_list))->next;
|
||||
}
|
||||
if(disp == NULL) return lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll));
|
||||
else return lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the content of the internal buffer (VDB) to the display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_p fill color
|
||||
* Get the internal buffer of a display
|
||||
* @param disp pointer to a display
|
||||
* @return pointer to the internal buffers
|
||||
*/
|
||||
void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color)
|
||||
lv_disp_buf_t * lv_disp_get_buf(lv_disp_t * disp)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->driver.disp_fill != NULL) active->driver.disp_fill(x1, y1, x2, y2, color);
|
||||
return disp->driver.buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill a rectangular area with a color on the active display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_p pointer to an array of colors
|
||||
* Get the number of areas in the buffer
|
||||
* @return number of invalid areas
|
||||
*/
|
||||
void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t * color_p)
|
||||
uint16_t lv_disp_get_inv_buf_size(lv_disp_t * disp)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->driver.disp_flush != NULL) {
|
||||
|
||||
LV_LOG_TRACE("disp flush started");
|
||||
active->driver.disp_flush(x1, y1, x2, y2, color_p);
|
||||
LV_LOG_TRACE("disp flush ready");
|
||||
|
||||
} else {
|
||||
LV_LOG_WARN("disp flush function registered");
|
||||
}
|
||||
return disp->inv_p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a color map to a rectangular area on the active display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_map pointer to an array of colors
|
||||
* Pop (delete) the last 'num' invalidated areas from the buffer
|
||||
* @param num number of areas to delete
|
||||
*/
|
||||
void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_map)
|
||||
void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->driver.disp_map != NULL) active->driver.disp_map(x1, y1, x2, y2, color_map);
|
||||
}
|
||||
|
||||
#if USE_LV_GPU
|
||||
|
||||
/**
|
||||
* Blend pixels to a destination memory from a source memory
|
||||
* In 'lv_disp_drv_t' 'mem_blend' is optional. (NULL if not available)
|
||||
* @param dest a memory address. Blend 'src' here.
|
||||
* @param src pointer to pixel map. Blend it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
|
||||
*/
|
||||
void lv_disp_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->driver.mem_blend != NULL) active->driver.mem_blend(dest, src, length, opa);
|
||||
if(disp->inv_p < num) disp->inv_p = 0;
|
||||
else disp->inv_p -= num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill a memory with a color (GPUs may support it)
|
||||
* In 'lv_disp_drv_t' 'mem_fill' is optional. (NULL if not available)
|
||||
* @param dest a memory address. Copy 'src' here.
|
||||
* @param src pointer to pixel map. Copy it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
|
||||
* Check the driver configuration if it's double buffered (both `buf1` and `buf2` are set)
|
||||
* @param disp pointer to to display to check
|
||||
* @return true: double buffered; false: not double buffered
|
||||
*/
|
||||
void lv_disp_mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color)
|
||||
bool lv_disp_is_double_buf(lv_disp_t * disp)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->driver.mem_fill != NULL) active->driver.mem_fill(dest, length, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows if memory blending (by GPU) is supported or not
|
||||
* @return false: 'mem_blend' is not supported in the driver; true: 'mem_blend' is supported in the driver
|
||||
*/
|
||||
bool lv_disp_is_mem_blend_supported(void)
|
||||
{
|
||||
if(active == NULL) return false;
|
||||
if(active->driver.mem_blend) return true;
|
||||
if(disp->driver.buffer->buf1 && disp->driver.buffer->buf2) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows if memory fill (by GPU) is supported or not
|
||||
* @return false: 'mem_fill' is not supported in the drover; true: 'mem_fill' is supported in the driver
|
||||
* Check the driver configuration if it's TRUE double buffered (both `buf1` and `buf2` are set and `size` is screen sized)
|
||||
* @param disp pointer to to display to check
|
||||
* @return true: double buffered; false: not double buffered
|
||||
*/
|
||||
bool lv_disp_is_mem_fill_supported(void)
|
||||
bool lv_disp_is_true_double_buf(lv_disp_t * disp)
|
||||
{
|
||||
if(active == NULL) return false;
|
||||
if(active->driver.mem_fill) return true;
|
||||
else return false;
|
||||
uint32_t scr_size = disp->driver.hor_res * disp->driver.ver_res;
|
||||
|
||||
if(lv_disp_is_double_buf(disp) &&
|
||||
disp->driver.buffer->size == scr_size) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/**
|
||||
* @file hal_disp.h
|
||||
* @file lv_hal_disp.h
|
||||
*
|
||||
* @description Display Driver HAL interface header file
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAL_DISP_H
|
||||
#define HAL_DISP_H
|
||||
#ifndef LV_HAL_DISP_H
|
||||
#define LV_HAL_DISP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -20,46 +20,106 @@ extern "C" {
|
||||
#include "lv_hal.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_misc/lv_ll.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_INV_BUF_SIZE
|
||||
#define LV_INV_BUF_SIZE 32 /*Buffer size for invalid areas */
|
||||
#endif
|
||||
|
||||
#ifndef LV_ATTRIBUTE_FLUSH_READY
|
||||
# define LV_ATTRIBUTE_FLUSH_READY
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _disp_t;
|
||||
struct _disp_drv_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void * buf1;
|
||||
void * buf2;
|
||||
|
||||
/*Used by the library*/
|
||||
void * buf_act;
|
||||
uint32_t size; /*In pixel count*/
|
||||
lv_area_t area;
|
||||
uint32_t flushing :1;
|
||||
}lv_disp_buf_t;
|
||||
|
||||
|
||||
/**
|
||||
* Display Driver structure to be registered by HAL
|
||||
*/
|
||||
typedef struct _disp_drv_t {
|
||||
/*Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished*/
|
||||
void (*disp_flush)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
|
||||
|
||||
/*Fill an area with a color on the display*/
|
||||
void (*disp_fill)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
|
||||
/*Horizontal and vertical resolution*/
|
||||
lv_coord_t hor_res;
|
||||
lv_coord_t ver_res;
|
||||
|
||||
/*Write pixel map (e.g. image) to the display*/
|
||||
void (*disp_map)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
|
||||
/* Pointer to a buffer initialized with `lv_disp_buf_init()`.
|
||||
* LittlevGL will use this buffer(s) to draw the screens contents */
|
||||
lv_disp_buf_t * buffer;
|
||||
|
||||
/* MANDATORY: Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished */
|
||||
void (*flush_cb)(struct _disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
|
||||
|
||||
/* OPTIONAL: Extend the invalidated areas to match with the display drivers requirements
|
||||
* E.g. round `y` to, 8, 16 ..) on a monochrome display*/
|
||||
void (*rounder_cb)(struct _disp_drv_t * disp_drv, lv_area_t * area);
|
||||
|
||||
/* OPTIONAL: Set a pixel in a buffer according to the special requirements of the display
|
||||
* Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales
|
||||
* Note: Much slower then drawing with supported color formats. */
|
||||
void (*set_px_cb)(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/* OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */
|
||||
void (*monitor_cb)(struct _disp_drv_t * disp_drv, uint32_t time, uint32_t px);
|
||||
|
||||
|
||||
#if USE_LV_USER_DATA_SINGLE
|
||||
lv_disp_drv_user_data_t user_data;
|
||||
#endif
|
||||
|
||||
#if USE_LV_USER_DATA_MULTI
|
||||
lv_disp_drv_user_data_t flush_user_data;
|
||||
lv_disp_drv_user_data_t rounder_user_data;
|
||||
lv_disp_drv_user_data_t set_px_user_data;
|
||||
lv_disp_drv_user_data_t monitor_user_data;
|
||||
#endif
|
||||
|
||||
/*Optional interface functions to use GPU*/
|
||||
#if USE_LV_GPU
|
||||
/*Blend two memories using opacity (GPU only)*/
|
||||
/*OPTIONAL: Blend two memories using opacity (GPU only)*/
|
||||
void (*mem_blend)(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
|
||||
|
||||
/*Fill a memory with a color (GPU only)*/
|
||||
/*OPTIONAL: Fill a memory with a color (GPU only)*/
|
||||
void (*mem_fill)(lv_color_t * dest, uint32_t length, lv_color_t color);
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE
|
||||
/*Optional: Set a pixel in a buffer according to the requirements of the display*/
|
||||
void (*vdb_wr)(uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa);
|
||||
#endif
|
||||
} lv_disp_drv_t;
|
||||
|
||||
struct _lv_obj_t;
|
||||
|
||||
typedef struct _disp_t {
|
||||
/*Driver to the display*/
|
||||
lv_disp_drv_t driver;
|
||||
struct _disp_t *next;
|
||||
|
||||
/*Screens of the display*/
|
||||
lv_ll_t scr_ll;
|
||||
struct _lv_obj_t * act_scr;
|
||||
struct _lv_obj_t * top_layer;
|
||||
struct _lv_obj_t * sys_layer;
|
||||
|
||||
/*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 :10;
|
||||
} lv_disp_t;
|
||||
|
||||
/**********************
|
||||
@ -72,7 +132,25 @@ typedef struct _disp_t {
|
||||
* After it you can set the fields.
|
||||
* @param driver pointer to driver variable to initialize
|
||||
*/
|
||||
void lv_disp_drv_init(lv_disp_drv_t *driver);
|
||||
void lv_disp_drv_init(lv_disp_drv_t * driver);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a display buffer
|
||||
* @param disp_buf pointer `lv_disp_buf_t` variable to initialize
|
||||
* @param buf1 A buffer to be used by LittlevGL to draw the image.
|
||||
* Always has to specified and can't be NULL.
|
||||
* Can be an array allocated by the user. E.g. `static lv_color_t disp_buf1[1024 * 10]`
|
||||
* Or a memory address e.g. in external SRAM
|
||||
* @param buf2 Optionally specify a second buffer to make image rendering and image flushing
|
||||
* (sending to the display) parallel.
|
||||
* In the `disp_drv->flush` you should use DMA or similar hardware to send
|
||||
* the image to the display in the background.
|
||||
* It lets LittlevGL to render next frame into the other buffer while previous is being sent.
|
||||
* Set to `NULL` if unused.
|
||||
* @param size size of the `buf1` and `buf2` in pixel count.
|
||||
*/
|
||||
void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size);
|
||||
|
||||
/**
|
||||
* Register an initialized display driver.
|
||||
@ -80,89 +158,81 @@ void lv_disp_drv_init(lv_disp_drv_t *driver);
|
||||
* @param driver pointer to an initialized 'lv_disp_drv_t' variable (can be local variable)
|
||||
* @return pointer to the new display or NULL on error
|
||||
*/
|
||||
lv_disp_t * lv_disp_drv_register(lv_disp_drv_t *driver);
|
||||
lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver);
|
||||
|
||||
/**
|
||||
* Set the active display
|
||||
* @param disp pointer to a display (return value of 'lv_disp_register')
|
||||
* Set a default screen. The new screens will be created on it by default.
|
||||
* @param disp pointer to a display
|
||||
*/
|
||||
void lv_disp_set_active(lv_disp_t * disp);
|
||||
void lv_disp_set_default(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Get a pointer to the active display
|
||||
* @return pointer to the active display
|
||||
* Get the default display
|
||||
* @return pointer to the default display
|
||||
*/
|
||||
lv_disp_t * lv_disp_get_active(void);
|
||||
lv_disp_t * lv_disp_get_default(void);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
lv_coord_t lv_disp_get_hor_res(lv_disp_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
|
||||
*/
|
||||
lv_coord_t lv_disp_get_ver_res(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Call in the display driver's `flush_cb` function when the flushing is finished
|
||||
* @param disp_drv pointer to display driver in `flush_cb` where this function is called
|
||||
*/
|
||||
LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv);
|
||||
|
||||
|
||||
/**
|
||||
* Get the next display.
|
||||
* @param disp pointer to the current display. NULL to initialize.
|
||||
* @return the next display or NULL if no more. Give the first display when the parameter is NULL
|
||||
*/
|
||||
lv_disp_t * lv_disp_next(lv_disp_t * disp);
|
||||
lv_disp_t * lv_disp_get_next(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Fill a rectangular area with a color on the active display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_p pointer to an array of colors
|
||||
* Get the internal buffer of a display
|
||||
* @param disp pointer to a display
|
||||
* @return pointer to the internal buffers
|
||||
*/
|
||||
void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p);
|
||||
lv_disp_buf_t * lv_disp_get_buf(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Fill a rectangular area with a color on the active display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color fill color
|
||||
* Get the number of areas in the buffer
|
||||
* @return number of invalid areas
|
||||
*/
|
||||
void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
|
||||
uint16_t lv_disp_get_inv_buf_size(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Put a color map to a rectangular area on the active display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_map pointer to an array of colors
|
||||
* Pop (delete) the last 'num' invalidated areas from the buffer
|
||||
* @param num number of areas to delete
|
||||
*/
|
||||
void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_map);
|
||||
|
||||
#if USE_LV_GPU
|
||||
/**
|
||||
* Blend pixels to a destination memory from a source memory
|
||||
* In 'lv_disp_drv_t' 'mem_blend' is optional. (NULL if not available)
|
||||
* @param dest a memory address. Blend 'src' here.
|
||||
* @param src pointer to pixel map. Blend it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
|
||||
*/
|
||||
void lv_disp_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
|
||||
void lv_disp_pop_from_inv_buf(lv_disp_t * disp, uint16_t num);
|
||||
|
||||
/**
|
||||
* Fill a memory with a color (GPUs may support it)
|
||||
* In 'lv_disp_drv_t' 'mem_fill' is optional. (NULL if not available)
|
||||
* @param dest a memory address. Copy 'src' here.
|
||||
* @param src pointer to pixel map. Copy it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
|
||||
* Check the driver configuration if it's double buffered (both `buf1` and `buf2` are set)
|
||||
* @param disp pointer to to display to check
|
||||
* @return true: double buffered; false: not double buffered
|
||||
*/
|
||||
void lv_disp_mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color);
|
||||
/**
|
||||
* Shows if memory blending (by GPU) is supported or not
|
||||
* @return false: 'mem_blend' is not supported in the driver; true: 'mem_blend' is supported in the driver
|
||||
*/
|
||||
bool lv_disp_is_mem_blend_supported(void);
|
||||
bool lv_disp_is_double_buf(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Shows if memory fill (by GPU) is supported or not
|
||||
* @return false: 'mem_fill' is not supported in the drover; true: 'mem_fill' is supported in the driver
|
||||
* Check the driver configuration if it's TRUE double buffered (both `buf1` and `buf2` are set and `size` is screen sized)
|
||||
* @param disp pointer to to display to check
|
||||
* @return true: double buffered; false: not double buffered
|
||||
*/
|
||||
bool lv_disp_is_mem_fill_supported(void);
|
||||
#endif
|
||||
bool lv_disp_is_true_double_buf(lv_disp_t * disp);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "../lv_hal/lv_hal_indev.h"
|
||||
#include "../lv_misc/lv_mem.h"
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
#include "lv_hal_disp.h"
|
||||
|
||||
#if defined(LV_GC_INCLUDE)
|
||||
# include LV_GC_INCLUDE
|
||||
@ -49,9 +50,9 @@
|
||||
*/
|
||||
void lv_indev_drv_init(lv_indev_drv_t * driver)
|
||||
{
|
||||
driver->read = NULL;
|
||||
memset(driver, 0, sizeof(lv_indev_drv_t));
|
||||
|
||||
driver->type = LV_INDEV_TYPE_NONE;
|
||||
driver->user_data = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,30 +62,28 @@ void lv_indev_drv_init(lv_indev_drv_t * driver)
|
||||
*/
|
||||
lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
|
||||
{
|
||||
lv_indev_t * node;
|
||||
|
||||
node = lv_mem_alloc(sizeof(lv_indev_t));
|
||||
if(!node) return NULL;
|
||||
if(driver->disp == NULL) driver->disp = lv_disp_get_default();
|
||||
|
||||
if(driver->disp == NULL) {
|
||||
LV_LOG_WARN("lv_indev_drv_register: no display registered hence can't attache the indev to a display");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_indev_t * node = lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll));
|
||||
if(!node) {
|
||||
lv_mem_assert(node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(node, 0, sizeof(lv_indev_t));
|
||||
memcpy(&node->driver, driver, sizeof(lv_indev_drv_t));
|
||||
|
||||
node->next = NULL;
|
||||
node->proc.reset_query = 1;
|
||||
node->cursor = NULL;
|
||||
node->group = NULL;
|
||||
node->btn_points = NULL;
|
||||
|
||||
if(LV_GC_ROOT(_lv_indev_list) == NULL) {
|
||||
LV_GC_ROOT(_lv_indev_list) = node;
|
||||
} else {
|
||||
lv_indev_t * last = LV_GC_ROOT(_lv_indev_list);
|
||||
while(last->next)
|
||||
last = last->next;
|
||||
|
||||
last->next = node;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -95,13 +94,8 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
|
||||
*/
|
||||
lv_indev_t * lv_indev_next(lv_indev_t * indev)
|
||||
{
|
||||
|
||||
if(indev == NULL) {
|
||||
return LV_GC_ROOT(_lv_indev_list);
|
||||
} else {
|
||||
if(indev->next == NULL) return NULL;
|
||||
else return indev->next;
|
||||
}
|
||||
if(indev == NULL) return lv_ll_get_head(LV_GC_ROOT(&_lv_indev_ll));
|
||||
else return lv_ll_get_next(LV_GC_ROOT(&_lv_indev_ll), indev);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,13 +109,11 @@ bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
bool cont = false;
|
||||
|
||||
memset(data, 0, sizeof(lv_indev_data_t));
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
|
||||
if(indev->driver.read) {
|
||||
data->user_data = indev->driver.user_data;
|
||||
if(indev->driver.read_cb) {
|
||||
|
||||
LV_LOG_TRACE("idnev read started");
|
||||
cont = indev->driver.read(data);
|
||||
cont = indev->driver.read_cb(&indev->driver, data);
|
||||
LV_LOG_TRACE("idnev read finished");
|
||||
} else {
|
||||
LV_LOG_WARN("indev function registered");
|
||||
|
@ -1,12 +1,12 @@
|
||||
/**
|
||||
* @file hal_indev.h
|
||||
* @file lv_hal_indev.h
|
||||
*
|
||||
* @description Input Device HAL interface layer header file
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAL_INDEV_H
|
||||
#define HAL_INDEV_H
|
||||
#ifndef LV_HAL_INDEV_H
|
||||
#define LV_HAL_INDEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -15,11 +15,15 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#ifdef LV_CONF_INCLUDE_SIMPLE
|
||||
#include "lv_conf.h"
|
||||
#else
|
||||
#include "../../lv_conf.h"
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "lv_hal.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_core/lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -29,6 +33,11 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_obj_t;
|
||||
struct _disp_t;
|
||||
struct _lv_indev_t;
|
||||
struct _lv_indev_drv_t;
|
||||
|
||||
/*Possible input device types*/
|
||||
enum {
|
||||
LV_INDEV_TYPE_NONE, /*Show uninitialized state*/
|
||||
@ -51,21 +60,29 @@ typedef struct {
|
||||
union {
|
||||
lv_point_t point; /*For LV_INDEV_TYPE_POINTER the currently pressed point*/
|
||||
uint32_t key; /*For LV_INDEV_TYPE_KEYPAD the currently pressed key*/
|
||||
uint32_t btn; /*For LV_INDEV_TYPE_BUTTON the currently pressed button*/
|
||||
uint32_t btn_id; /*For LV_INDEV_TYPE_BUTTON the currently pressed button*/
|
||||
int16_t enc_diff; /*For LV_INDEV_TYPE_ENCODER number of steps since the previous read*/
|
||||
};
|
||||
void *user_data; /*'lv_indev_drv_t.priv' for this driver*/
|
||||
|
||||
lv_indev_state_t state; /*LV_INDEV_STATE_REL or LV_INDEV_STATE_PR*/
|
||||
|
||||
} lv_indev_data_t;
|
||||
|
||||
/*Initialized by the user and registered by 'lv_indev_add()'*/
|
||||
typedef struct {
|
||||
typedef struct _lv_indev_drv_t {
|
||||
lv_hal_indev_type_t type; /*Input device type*/
|
||||
bool (*read)(lv_indev_data_t *data); /*Function pointer to read data. Return 'true' if there is still data to be read (buffered)*/
|
||||
void *user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/
|
||||
bool (*read_cb)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t *data); /*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb (buffered)*/
|
||||
|
||||
#if USE_LV_USER_DATA_MULTI
|
||||
lv_indev_drv_user_data_t read_user_data; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/
|
||||
#endif
|
||||
|
||||
#if USE_LV_USER_DATA_SINGLE
|
||||
lv_indev_drv_user_data_t user_data;
|
||||
#endif
|
||||
struct _disp_t * disp; /*Pointer to the assigned display*/
|
||||
} lv_indev_drv_t;
|
||||
|
||||
struct _lv_obj_t;
|
||||
|
||||
/*Run time data of input devices*/
|
||||
typedef struct _lv_indev_proc_t {
|
||||
@ -83,12 +100,12 @@ typedef struct _lv_indev_proc_t {
|
||||
uint8_t drag_range_out :1;
|
||||
uint8_t drag_in_prog :1;
|
||||
uint8_t wait_unil_release :1;
|
||||
};
|
||||
}pointer;
|
||||
struct { /*Keypad data*/
|
||||
lv_indev_state_t last_state;
|
||||
uint32_t last_key;
|
||||
};
|
||||
};
|
||||
}keypad;
|
||||
}types;
|
||||
|
||||
uint32_t pr_timestamp; /*Pressed time stamp*/
|
||||
uint32_t longpr_rep_timestamp; /*Long press repeat time stamp*/
|
||||
@ -99,9 +116,7 @@ typedef struct _lv_indev_proc_t {
|
||||
uint8_t disabled :1;
|
||||
} lv_indev_proc_t;
|
||||
|
||||
struct _lv_indev_t;
|
||||
|
||||
typedef void (*lv_indev_feedback_t)(struct _lv_indev_t *, lv_signal_t);
|
||||
typedef void (*lv_indev_feedback_t)(struct _lv_indev_t *, uint8_t);
|
||||
|
||||
struct _lv_obj_t;
|
||||
struct _lv_group_t;
|
||||
@ -118,7 +133,6 @@ typedef struct _lv_indev_t {
|
||||
const lv_point_t * btn_points; /*Array points assigned to the button ()screen will be pressed here by the buttons*/
|
||||
|
||||
};
|
||||
struct _lv_indev_t *next;
|
||||
} lv_indev_t;
|
||||
|
||||
/**********************
|
||||
@ -143,7 +157,7 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t *driver);
|
||||
/**
|
||||
* Get the next input device.
|
||||
* @param indev pointer to the current input device. NULL to initialize.
|
||||
* @return the next input devise or NULL if no more. Gives the first input device when the parameter is NULL
|
||||
* @return the next input devise or NULL if no more. Give the first input device when the parameter is NULL
|
||||
*/
|
||||
lv_indev_t * lv_indev_next(lv_indev_t * indev);
|
||||
|
||||
|
@ -393,14 +393,14 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
|
||||
#endif
|
||||
|
||||
|
||||
#define LV_COLOR_HEX(c) LV_COLOR_MAKE(((uint32_t)((uint32_t)c >> 16) & 0xFF), \
|
||||
((uint32_t)((uint32_t)c >> 8) & 0xFF), \
|
||||
((uint32_t) c & 0xFF))
|
||||
#define LV_COLOR_HEX(c) LV_COLOR_MAKE((uint8_t) ((uint32_t)((uint32_t)c >> 16) & 0xFF), \
|
||||
(uint8_t) ((uint32_t)((uint32_t)c >> 8) & 0xFF), \
|
||||
(uint8_t) ((uint32_t) c & 0xFF))
|
||||
|
||||
/*Usage LV_COLOR_HEX3(0x16C) which means LV_COLOR_HEX(0x1166CC)*/
|
||||
#define LV_COLOR_HEX3(c) LV_COLOR_MAKE((((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), \
|
||||
((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \
|
||||
((uint32_t)(c & 0xF) | ((c & 0xF) << 4)))
|
||||
#define LV_COLOR_HEX3(c) LV_COLOR_MAKE((uint8_t) (((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), \
|
||||
(uint8_t) ((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \
|
||||
(uint8_t) ((uint32_t)(c & 0xF) | ((c & 0xF) << 4)))
|
||||
|
||||
static inline lv_color_t lv_color_hex(uint32_t c){
|
||||
return LV_COLOR_HEX(c);
|
||||
|
@ -434,7 +434,7 @@ lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t * rddir_p)
|
||||
* @param free_p pointer to store the free size [kB]
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_free(char letter, uint32_t * total_p, uint32_t * free_p)
|
||||
lv_fs_res_t lv_fs_free_space(char letter, uint32_t * total_p, uint32_t * free_p)
|
||||
{
|
||||
lv_fs_drv_t * drv = lv_fs_get_drv(letter);
|
||||
|
||||
@ -444,12 +444,12 @@ lv_fs_res_t lv_fs_free(char letter, uint32_t * total_p, uint32_t * free_p)
|
||||
|
||||
lv_fs_res_t res;
|
||||
|
||||
if(drv->free == NULL) {
|
||||
if(drv->free_space == NULL) {
|
||||
res = LV_FS_RES_NOT_IMP;
|
||||
} else {
|
||||
uint32_t total_tmp = 0;
|
||||
uint32_t free_tmp = 0;
|
||||
res = drv->free(&total_tmp, &free_tmp);
|
||||
res = drv->free_space(&total_tmp, &free_tmp);
|
||||
|
||||
if(total_p != NULL) *total_p = total_tmp;
|
||||
if(free_p != NULL) *free_p = free_tmp;
|
||||
|
@ -90,7 +90,7 @@ typedef struct __lv_fs_drv_t
|
||||
lv_fs_res_t (*trunc) (void * file_p);
|
||||
lv_fs_res_t (*size) (void * file_p, uint32_t * size_p);
|
||||
lv_fs_res_t (*rename) (const char * oldname, const char * newname);
|
||||
lv_fs_res_t (*free) (uint32_t * total_p, uint32_t * free_p);
|
||||
lv_fs_res_t (*free_space) (uint32_t * total_p, uint32_t * free_p);
|
||||
|
||||
lv_fs_res_t (*dir_open) (void * rddir_p, const char * path);
|
||||
lv_fs_res_t (*dir_read) (void * rddir_p, char * fn);
|
||||
@ -234,7 +234,7 @@ lv_fs_res_t lv_fs_dir_close (lv_fs_dir_t * rddir_p);
|
||||
* @param free_p pointer to store the free size [kB]
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
lv_fs_res_t lv_fs_free (char letter, uint32_t * total_p, uint32_t * free_p);
|
||||
lv_fs_res_t lv_fs_free_space (char letter, uint32_t * total_p, uint32_t * free_p);
|
||||
|
||||
/**
|
||||
* Fill a buffer with the letters of existing drivers
|
||||
|
@ -31,17 +31,13 @@ extern "C" {
|
||||
|
||||
#define LV_GC_ROOTS(prefix) \
|
||||
prefix lv_ll_t _lv_task_ll; /*Linked list to store the lv_tasks*/ \
|
||||
prefix lv_ll_t _lv_scr_ll; /*Linked list of screens*/ \
|
||||
prefix lv_ll_t _lv_disp_ll; /*Linked list of screens*/ \
|
||||
prefix lv_ll_t _lv_indev_ll; /*Linked list of screens*/ \
|
||||
prefix lv_ll_t _lv_drv_ll;\
|
||||
prefix lv_ll_t _lv_file_ll;\
|
||||
prefix lv_ll_t _lv_anim_ll;\
|
||||
prefix void * _lv_def_scr;\
|
||||
prefix void * _lv_act_scr;\
|
||||
prefix void * _lv_top_layer;\
|
||||
prefix void * _lv_sys_layer;\
|
||||
prefix lv_ll_t _lv_group_ll;\
|
||||
prefix void * _lv_task_act;\
|
||||
prefix void * _lv_indev_list;\
|
||||
prefix void * _lv_disp_list;\
|
||||
|
||||
|
||||
#define LV_NO_PREFIX
|
||||
|
@ -340,6 +340,21 @@ void lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after)
|
||||
if(n_after == NULL) ll_p->tail = n_act;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a linked list is empty
|
||||
* @param ll_p pointer to a linked list
|
||||
* @return true: the linked list is empty; false: not empty
|
||||
*/
|
||||
bool lv_ll_is_empty(lv_ll_t * ll_p)
|
||||
{
|
||||
if(ll_p == NULL) return true;
|
||||
|
||||
if(ll_p->head == NULL && ll_p->tail == NULL) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -17,6 +17,7 @@ extern "C" {
|
||||
#include "lv_mem.h"
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -130,6 +131,12 @@ void * lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act);
|
||||
*/
|
||||
void lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after);
|
||||
|
||||
/**
|
||||
* Check if a linked list is empty
|
||||
* @param ll_p pointer to a linked list
|
||||
* @return true: the linked list is empty; false: not empty
|
||||
*/
|
||||
bool lv_ll_is_empty(lv_ll_t * ll_p);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -8,6 +8,7 @@
|
||||
*********************/
|
||||
#include "lv_math.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -54,53 +55,33 @@ static int16_t sin0_90_table[] = {
|
||||
*/
|
||||
char * lv_math_num_to_str(int32_t num, char * buf)
|
||||
{
|
||||
char * buf_ori = buf;
|
||||
if(num == 0) {
|
||||
if (num == 0) {
|
||||
buf[0] = '0';
|
||||
buf[1] = '\0';
|
||||
return buf;
|
||||
} else if(num < 0) {
|
||||
(*buf) = '-';
|
||||
buf++;
|
||||
num = LV_MATH_ABS(num);
|
||||
}
|
||||
uint32_t output = 0;
|
||||
int8_t i;
|
||||
|
||||
for(i = 31; i >= 0; i--) {
|
||||
if((output & 0xF) >= 5)
|
||||
output += 3;
|
||||
if(((output & 0xF0) >> 4) >= 5)
|
||||
output += (3 << 4);
|
||||
if(((output & 0xF00) >> 8) >= 5)
|
||||
output += (3 << 8);
|
||||
if(((output & 0xF000) >> 12) >= 5)
|
||||
output += (3 << 12);
|
||||
if(((output & 0xF0000) >> 16) >= 5)
|
||||
output += (3 << 16);
|
||||
if(((output & 0xF00000) >> 20) >= 5)
|
||||
output += (3 << 20);
|
||||
if(((output & 0xF000000) >> 24) >= 5)
|
||||
output += (3 << 24);
|
||||
if(((output & 0xF0000000) >> 28) >= 5)
|
||||
output += (3 << 28);
|
||||
output = (output << 1) | ((num >> i) & 1);
|
||||
int8_t digitCount = 0;
|
||||
int8_t i = 0;
|
||||
if (num < 0) {
|
||||
buf[digitCount++] = '-';
|
||||
num = abs(num);
|
||||
++i;
|
||||
}
|
||||
|
||||
uint8_t digit;
|
||||
bool leading_zero_ready = false;
|
||||
for(i = 28; i >= 0; i -= 4) {
|
||||
digit = ((output >> i) & 0xF) + '0';
|
||||
if(digit == '0' && leading_zero_ready == false) continue;
|
||||
|
||||
leading_zero_ready = true;
|
||||
(*buf) = digit;
|
||||
buf++;
|
||||
while (num) {
|
||||
char digit = num % 10;
|
||||
buf[digitCount++] = digit + 48;
|
||||
num /= 10;
|
||||
}
|
||||
|
||||
(*buf) = '\0';
|
||||
|
||||
return buf_ori;
|
||||
buf[digitCount] = '\0';
|
||||
digitCount--;
|
||||
while (digitCount > i) {
|
||||
char temp = buf[i];
|
||||
buf[i] = buf[digitCount];
|
||||
buf[digitCount] = temp;
|
||||
digitCount--;
|
||||
i++;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,9 +19,9 @@ extern "C" {
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_MATH_MIN(a,b) (a<b?a:b)
|
||||
#define LV_MATH_MAX(a,b) (a>b?a:b)
|
||||
#define LV_MATH_ABS(x) ((x)>0?(x):(-(x)))
|
||||
#define LV_MATH_MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define LV_MATH_MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x)))
|
||||
|
||||
#define LV_TRIGO_SIN_MAX 32767
|
||||
#define LV_TRIGO_SHIFT 15 /* >> LV_TRIGO_SHIFT to normalize*/
|
||||
|
@ -73,7 +73,7 @@ extern "C" {
|
||||
#define SYMBOL_BATTERY_EMPTY _SYMBOL_VALUE1(F0)
|
||||
#define SYMBOL_BLUETOOTH _SYMBOL_VALUE1(F1)
|
||||
#define LV_SYMBOL_GLYPH_LAST 0xF1
|
||||
#define SYMBOL_DUMMY _SYMBOL_VALUE1(xFF) /*Invalid symbol. If written before a string then `lv_img` will show it as a label*/
|
||||
#define SYMBOL_DUMMY _SYMBOL_VALUE1(FF) /*Invalid symbol. If written before a string then `lv_img` will show it as a label*/
|
||||
|
||||
#else
|
||||
#define LV_SYMBOL_GLYPH_FIRST 0xF800
|
||||
|
@ -72,7 +72,7 @@ void lv_ufs_init(void)
|
||||
ufs_drv.tell = lv_ufs_tell;
|
||||
ufs_drv.size = lv_ufs_size;
|
||||
ufs_drv.trunc = lv_ufs_trunc;
|
||||
ufs_drv.free = lv_ufs_free;
|
||||
ufs_drv.free_space = lv_ufs_free;
|
||||
|
||||
ufs_drv.dir_open = lv_ufs_dir_open;
|
||||
ufs_drv.dir_read = lv_ufs_dir_read;
|
||||
|
@ -80,7 +80,7 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->arc);
|
||||
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, th->style.arc);
|
||||
} else {
|
||||
lv_arc_set_style(new_arc, LV_ARC_STYLE_MAIN, &lv_style_plain_color);
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_bar_set_style(new_bar, LV_BAR_STYLE_BG, th->bar.bg);
|
||||
lv_bar_set_style(new_bar, LV_BAR_STYLE_INDIC, th->bar.indic);
|
||||
lv_bar_set_style(new_bar, LV_BAR_STYLE_BG, th->style.bar.bg);
|
||||
lv_bar_set_style(new_bar, LV_BAR_STYLE_INDIC, th->style.bar.indic);
|
||||
} else {
|
||||
lv_obj_set_style(new_bar, &lv_style_pretty);
|
||||
}
|
||||
|
@ -123,11 +123,11 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->btn.rel);
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->btn.pr);
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->btn.tgl_rel);
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->btn.tgl_pr);
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->btn.ina);
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->style.btn.rel);
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->style.btn.pr);
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->style.btn.tgl_rel);
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->style.btn.tgl_pr);
|
||||
lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->style.btn.ina);
|
||||
} else {
|
||||
lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_REL]);
|
||||
}
|
||||
|
@ -142,15 +142,40 @@ static inline void lv_btn_set_layout(lv_obj_t * btn, lv_layout_t layout)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the horizontal or vertical fit.
|
||||
* The button size will be set to involve the children horizontally or vertically.
|
||||
* Set the fit policy in all 4 directions separately.
|
||||
* It tell how to change the button size automatically.
|
||||
* @param btn pointer to a button object
|
||||
* @param hor_en true: enable the horizontal fit
|
||||
* @param ver_en true: enable the vertical fit
|
||||
* @param left left fit policy from `lv_fit_t`
|
||||
* @param right right fit policy from `lv_fit_t`
|
||||
* @param top bottom fit policy from `lv_fit_t`
|
||||
* @param bottom bottom fit policy from `lv_fit_t`
|
||||
*/
|
||||
static inline void lv_btn_set_fit(lv_obj_t * btn, bool hor_en, bool ver_en)
|
||||
static inline void lv_btn_set_fit4(lv_obj_t * btn, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom)
|
||||
{
|
||||
lv_cont_set_fit(btn, hor_en, ver_en);
|
||||
lv_cont_set_fit4(btn, left, right, top, bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fit policy horizontally and vertically separately.
|
||||
* It tell how to change the button size automatically.
|
||||
* @param btn pointer to a button object
|
||||
* @param hot horizontal fit policy from `lv_fit_t`
|
||||
* @param ver vertical fit policy from `lv_fit_t`
|
||||
*/
|
||||
static inline void lv_btn_set_fit2(lv_obj_t * btn, lv_fit_t hor, lv_fit_t ver)
|
||||
{
|
||||
lv_cont_set_fit2(btn, hor, ver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fit policy in all 4 direction at once.
|
||||
* It tell how to change the button size automatically.
|
||||
* @param btn pointer to a button object
|
||||
* @param fit fit policy from `lv_fit_t`
|
||||
*/
|
||||
static inline void lv_btn_set_fit(lv_obj_t * cont, lv_fit_t fit)
|
||||
{
|
||||
lv_cont_set_fit(cont, fit);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,25 +243,46 @@ static inline lv_layout_t lv_btn_get_layout(const lv_obj_t * btn)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get horizontal fit enable attribute of a button
|
||||
* Get the left fit mode
|
||||
* @param btn pointer to a button object
|
||||
* @return true: horizontal fit is enabled; false: disabled
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
static inline bool lv_btn_get_hor_fit(const lv_obj_t * btn)
|
||||
static inline lv_fit_t lv_btn_get_fit_left(const lv_obj_t * btn)
|
||||
{
|
||||
return lv_cont_get_hor_fit(btn);
|
||||
return lv_cont_get_fit_left(btn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vertical fit enable attribute of a container
|
||||
* Get the right fit mode
|
||||
* @param btn pointer to a button object
|
||||
* @return true: vertical fit is enabled; false: disabled
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
static inline bool lv_btn_get_ver_fit(const lv_obj_t * btn)
|
||||
static inline lv_fit_t lv_btn_get_fit_right(const lv_obj_t * btn)
|
||||
{
|
||||
return lv_cont_get_ver_fit(btn);
|
||||
return lv_cont_get_fit_right(btn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top fit mode
|
||||
* @param btn pointer to a button object
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
static inline lv_fit_t lv_btn_get_fit_top(const lv_obj_t * btn)
|
||||
{
|
||||
return lv_cont_get_fit_top(btn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bottom fit mode
|
||||
* @param btn pointer to a button object
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
static inline lv_fit_t lv_btn_get_fit_bottom(const lv_obj_t * btn)
|
||||
{
|
||||
return lv_cont_get_fit_bottom(btn);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get time of the ink in effect (draw a circle on click to animate in the new state)
|
||||
* @param btn pointer to a button object
|
||||
|
@ -101,18 +101,18 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new button matrix object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_btnm, LV_HOR_RES / 2, LV_VER_RES / 4);
|
||||
lv_obj_set_size(new_btnm, LV_DPI * 3, LV_DPI * 2);
|
||||
lv_btnm_set_map(new_btnm, lv_btnm_def_map);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BG, th->btnm.bg);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_REL, th->btnm.btn.rel);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_PR, th->btnm.btn.pr);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_REL, th->btnm.btn.tgl_rel);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_PR, th->btnm.btn.tgl_pr);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_INA, th->btnm.btn.ina);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BG, th->style.btnm.bg);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_REL, th->style.btnm.btn.rel);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_PR, th->style.btnm.btn.pr);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_REL, th->style.btnm.btn.tgl_rel);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_TGL_PR, th->style.btnm.btn.tgl_pr);
|
||||
lv_btnm_set_style(new_btnm, LV_BTNM_STYLE_BTN_INA, th->style.btnm.btn.ina);
|
||||
} else {
|
||||
lv_obj_set_style(new_btnm, &lv_style_pretty);
|
||||
}
|
||||
@ -708,6 +708,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
/*Invalidate to old and the new areas*/;
|
||||
//lv_obj_get_coords(btnm, &btnm_area);
|
||||
if(btn_pr != ext->btn_id_pr) {
|
||||
lv_disp_t * disp = lv_obj_get_disp(btnm);
|
||||
lv_indev_reset_lpr(param);
|
||||
if(ext->btn_id_pr != LV_BTNM_PR_NONE) {
|
||||
invalidate_button_area(btnm, ext->btn_id_pr);
|
||||
@ -736,6 +737,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
if(button_is_inactive(ext->ctrl_bits[ext->btn_id_pr]) == false && txt_i != LV_BTNM_PR_NONE) { /*Ignore the inactive buttons and clicks between the buttons*/
|
||||
if(ext->action) res = ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
|
||||
if(res == LV_RES_OK) {
|
||||
lv_disp_t * disp = lv_obj_get_disp(btnm);
|
||||
|
||||
/*Invalidate to old pressed area*/;
|
||||
invalidate_button_area(btnm, ext->btn_id_pr);
|
||||
@ -743,6 +745,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
|
||||
if(ext->toggle != 0) {
|
||||
/*Invalidate to old toggled area*/;
|
||||
invalidate_button_area(btnm, ext->btn_id_tgl);
|
||||
|
||||
ext->btn_id_tgl = ext->btn_id_pr;
|
||||
|
||||
}
|
||||
|
@ -130,14 +130,14 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->calendar.bg);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->calendar.header);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->calendar.header_pr);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->calendar.day_names);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->calendar.week_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->calendar.today_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, th->calendar.highlighted_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->calendar.inactive_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->style.calendar.bg);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->style.calendar.header);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->style.calendar.header_pr);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->style.calendar.day_names);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->style.calendar.week_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->style.calendar.today_box);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, th->style.calendar.highlighted_days);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->style.calendar.inactive_days);
|
||||
} else {
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, &lv_style_pretty);
|
||||
lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, ext->style_header);
|
||||
|
@ -81,19 +81,19 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
lv_cb_set_text(new_cb, "Check box");
|
||||
lv_btn_set_layout(new_cb, LV_LAYOUT_ROW_M);
|
||||
lv_btn_set_fit(new_cb, true, true);
|
||||
lv_btn_set_fit(new_cb, LV_FIT_TIGHT);
|
||||
lv_btn_set_toggle(new_cb, true);
|
||||
lv_obj_set_protect(new_cb, LV_PROTECT_PRESS_LOST);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BG, th->cb.bg);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL, th->cb.box.rel);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_PR, th->cb.box.pr);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_REL, th->cb.box.tgl_rel);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_PR, th->cb.box.tgl_pr);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_INA, th->cb.box.ina);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BG, th->style.cb.bg);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL, th->style.cb.box.rel);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_PR, th->style.cb.box.pr);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_REL, th->style.cb.box.tgl_rel);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_TGL_PR, th->style.cb.box.tgl_pr);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_INA, th->style.cb.box.ina);
|
||||
} else {
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BG, &lv_style_transp);
|
||||
lv_cb_set_style(new_cb, LV_CB_STYLE_BOX_REL, &lv_style_pretty);
|
||||
|
@ -90,12 +90,12 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new chart background object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_chart, LV_HOR_RES / 3, LV_VER_RES / 3);
|
||||
lv_obj_set_size(new_chart, LV_DPI * 3, LV_DPI * 2);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_chart_set_style(new_chart, th->chart);
|
||||
lv_chart_set_style(new_chart, th->style.chart);
|
||||
} else {
|
||||
lv_chart_set_style(new_chart, &lv_style_pretty);
|
||||
}
|
||||
@ -175,9 +175,10 @@ void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie)
|
||||
if(chart == NULL || serie == NULL)
|
||||
return;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext == NULL)
|
||||
return;
|
||||
for(uint32_t i = 0; i < ext->point_cnt; i++)
|
||||
if(ext == NULL) return;
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < ext->point_cnt; i++)
|
||||
{
|
||||
serie->points[i] = LV_CHART_POINT_DEF;
|
||||
}
|
||||
@ -764,12 +765,18 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask)
|
||||
*/
|
||||
static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mask)
|
||||
{
|
||||
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
/*Vertical lines works only if the width == point count. Else use the normal line type*/
|
||||
if(ext->point_cnt != w) {
|
||||
lv_chart_draw_lines(chart, mask);
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t i;
|
||||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
lv_coord_t w = lv_obj_get_width(chart);
|
||||
lv_coord_t h = lv_obj_get_height(chart);
|
||||
lv_coord_t x_ofs = chart->coords.x1;
|
||||
lv_coord_t y_ofs = chart->coords.y1;
|
||||
@ -789,11 +796,9 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas
|
||||
p2.x = 0 + x_ofs;
|
||||
y_tmp = (int32_t)((int32_t) ser->points[0] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
p1.y = LV_COORD_MIN;
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
p1.y = p2.y;
|
||||
|
||||
if(ext->point_cnt == w)
|
||||
{
|
||||
for(i = 0; i < ext->point_cnt; i++)
|
||||
{
|
||||
|
||||
@ -806,31 +811,14 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas
|
||||
p2.x++;
|
||||
}
|
||||
|
||||
if(ser->points[i] != LV_CHART_POINT_DEF) {
|
||||
lv_draw_line(&p1, &p2, mask, &style, opa_scale);
|
||||
}
|
||||
|
||||
p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
|
||||
p1.x = p2.x;
|
||||
p1.y = p2.y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i = 1; i < ext->point_cnt; i ++) {
|
||||
p1.x = p2.x;
|
||||
p1.y = p2.y;
|
||||
|
||||
p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
|
||||
|
||||
y_tmp = (int32_t)((int32_t) ser->points[i] - ext->ymin) * h;
|
||||
y_tmp = y_tmp / (ext->ymax - ext->ymin);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
if(ser->points[i - 1] >= 0 && ser->points[i] >= 0)
|
||||
{
|
||||
lv_draw_line(&p1, &p2, mask, &style, opa_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -62,10 +62,10 @@ typedef struct
|
||||
/*Chart types*/
|
||||
enum
|
||||
{
|
||||
LV_CHART_TYPE_LINE = 0x01,
|
||||
LV_CHART_TYPE_COLUMN = 0x02,
|
||||
LV_CHART_TYPE_POINT = 0x04,
|
||||
LV_CHART_TYPE_VERTICAL_LINE = 0x08,
|
||||
LV_CHART_TYPE_LINE = 0x01, /*Connect the points with lines*/
|
||||
LV_CHART_TYPE_COLUMN = 0x02, /*Draw columns*/
|
||||
LV_CHART_TYPE_POINT = 0x04, /*Draw circles on the points*/
|
||||
LV_CHART_TYPE_VERTICAL_LINE = 0x08, /*Draw vertical lines on points (useful when chart width == point count)*/
|
||||
};
|
||||
typedef uint8_t lv_chart_type_t;
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_draw/lv_draw_vbasic.h"
|
||||
#include "../lv_draw/lv_draw_basic.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
@ -78,8 +78,10 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
if(ext == NULL) return NULL;
|
||||
|
||||
lv_mem_assert(ext);
|
||||
ext->hor_fit = 0;
|
||||
ext->ver_fit = 0;
|
||||
ext->fit_left = LV_FIT_NONE;
|
||||
ext->fit_right = LV_FIT_NONE;
|
||||
ext->fit_top = LV_FIT_NONE;
|
||||
ext->fit_bottom = LV_FIT_NONE;
|
||||
ext->layout = LV_LAYOUT_OFF;
|
||||
|
||||
lv_obj_set_signal_func(new_cont, lv_cont_signal);
|
||||
@ -89,7 +91,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_cont_set_style(new_cont, th->cont);
|
||||
lv_cont_set_style(new_cont, th->style.cont);
|
||||
} else {
|
||||
lv_cont_set_style(new_cont, &lv_style_pretty);
|
||||
}
|
||||
@ -97,8 +99,10 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
lv_cont_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
ext->hor_fit = copy_ext->hor_fit;
|
||||
ext->ver_fit = copy_ext->ver_fit;
|
||||
ext->fit_left = copy_ext->fit_left;
|
||||
ext->fit_right = copy_ext->fit_right;
|
||||
ext->fit_top = copy_ext->fit_top;
|
||||
ext->fit_bottom = copy_ext->fit_bottom;
|
||||
ext->layout = copy_ext->layout;
|
||||
|
||||
/*Refresh the style with new signal function*/
|
||||
@ -107,7 +111,6 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
LV_LOG_INFO("container created");
|
||||
|
||||
|
||||
return new_cont;
|
||||
}
|
||||
|
||||
@ -131,22 +134,31 @@ void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
|
||||
cont->signal_func(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable the horizontal or vertical fit.
|
||||
* The container size will be set to involve the children horizontally or vertically.
|
||||
* Set the fit policy in all 4 directions separately.
|
||||
* It tell how to change the container's size automatically.
|
||||
* @param cont pointer to a container object
|
||||
* @param hor_en true: enable the horizontal fit
|
||||
* @param ver_en true: enable the vertical fit
|
||||
* @param left left fit policy from `lv_fit_t`
|
||||
* @param right right fit policy from `lv_fit_t`
|
||||
* @param top bottom fit policy from `lv_fit_t`
|
||||
* @param bottom bottom fit policy from `lv_fit_t`
|
||||
*/
|
||||
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en)
|
||||
void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom)
|
||||
{
|
||||
lv_obj_invalidate(cont);
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
if(ext->hor_fit == hor_en && ext->ver_fit == ver_en) return;
|
||||
if(ext->fit_left == left &&
|
||||
ext->fit_right == right &&
|
||||
ext->fit_top == top &&
|
||||
ext->fit_bottom == bottom)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ext->hor_fit = hor_en == false ? 0 : 1;
|
||||
ext->ver_fit = ver_en == false ? 0 : 1;
|
||||
ext->fit_left = left;
|
||||
ext->fit_right = right;
|
||||
ext->fit_top = top;
|
||||
ext->fit_bottom = bottom;
|
||||
|
||||
/*Send a signal to refresh the layout*/
|
||||
cont->signal_func(cont, LV_SIGNAL_CHILD_CHG, NULL);
|
||||
@ -168,25 +180,47 @@ lv_layout_t lv_cont_get_layout(const lv_obj_t * cont)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get horizontal fit enable attribute of a container
|
||||
* Get left fit mode of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return true: horizontal fit is enabled; false: disabled
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
bool lv_cont_get_hor_fit(const lv_obj_t * cont)
|
||||
lv_fit_t lv_cont_get_fit_left(const lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->hor_fit == 0 ? false : true;
|
||||
return ext->fit_left;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vertical fit enable attribute of a container
|
||||
* Get right fit mode of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return true: vertical fit is enabled; false: disabled
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
bool lv_cont_get_ver_fit(const lv_obj_t * cont)
|
||||
lv_fit_t lv_cont_get_fit_right(const lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->ver_fit == 0 ? false : true;
|
||||
return ext->fit_right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get top fit mode of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
lv_fit_t lv_cont_get_fit_top(const lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->fit_top;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bottom fit mode of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
return ext->fit_bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -244,6 +278,10 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
|
||||
lv_cont_refr_layout(cont);
|
||||
lv_cont_refr_autofit(cont);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_PARENT_SIZE_CHG) {
|
||||
/*FLOOD and FILL fit needs to be refreshed if the parent size has changed*/
|
||||
lv_cont_refr_autofit(cont);
|
||||
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
@ -574,60 +612,96 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
{
|
||||
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
|
||||
|
||||
if(ext->hor_fit == 0 &&
|
||||
ext->ver_fit == 0) {
|
||||
if(ext->fit_left == LV_FIT_NONE &&
|
||||
ext->fit_right == LV_FIT_NONE &&
|
||||
ext->fit_top == LV_FIT_NONE &&
|
||||
ext->fit_bottom == LV_FIT_NONE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lv_area_t new_cords;
|
||||
lv_area_t tight_area;
|
||||
lv_area_t ori;
|
||||
lv_style_t * style = lv_obj_get_style(cont);
|
||||
lv_obj_t * i;
|
||||
lv_coord_t hpad = style->body.padding.hor;
|
||||
lv_coord_t vpad = style->body.padding.ver;
|
||||
|
||||
lv_obj_t * par = lv_obj_get_parent(cont);
|
||||
lv_style_t * par_style = lv_obj_get_style(par);
|
||||
lv_area_t flood_area;
|
||||
lv_area_copy(&flood_area, &par->coords);
|
||||
flood_area.x1 += par_style->body.padding.hor;
|
||||
flood_area.x2 -= par_style->body.padding.hor;
|
||||
flood_area.y1 += par_style->body.padding.ver;
|
||||
flood_area.y2 -= par_style->body.padding.ver;
|
||||
|
||||
/*Search the side coordinates of the children*/
|
||||
lv_obj_get_coords(cont, &ori);
|
||||
lv_obj_get_coords(cont, &new_cords);
|
||||
lv_obj_get_coords(cont, &tight_area);
|
||||
|
||||
new_cords.x1 = LV_COORD_MAX;
|
||||
new_cords.y1 = LV_COORD_MAX;
|
||||
new_cords.x2 = LV_COORD_MIN;
|
||||
new_cords.y2 = LV_COORD_MIN;
|
||||
bool has_children = lv_ll_is_empty(&cont->child_ll) ? false : true;
|
||||
|
||||
if(has_children) {
|
||||
tight_area.x1 = LV_COORD_MAX;
|
||||
tight_area.y1 = LV_COORD_MAX;
|
||||
tight_area.x2 = LV_COORD_MIN;
|
||||
tight_area.y2 = LV_COORD_MIN;
|
||||
|
||||
LL_READ(cont->child_ll, i) {
|
||||
if(lv_obj_get_hidden(i) != false) continue;
|
||||
new_cords.x1 = LV_MATH_MIN(new_cords.x1, i->coords.x1);
|
||||
new_cords.y1 = LV_MATH_MIN(new_cords.y1, i->coords.y1);
|
||||
new_cords.x2 = LV_MATH_MAX(new_cords.x2, i->coords.x2);
|
||||
new_cords.y2 = LV_MATH_MAX(new_cords.y2, i->coords.y2);
|
||||
tight_area.x1 = LV_MATH_MIN(tight_area.x1, i->coords.x1);
|
||||
tight_area.y1 = LV_MATH_MIN(tight_area.y1, i->coords.y1);
|
||||
tight_area.x2 = LV_MATH_MAX(tight_area.x2, i->coords.x2);
|
||||
tight_area.y2 = LV_MATH_MAX(tight_area.y2, i->coords.y2);
|
||||
}
|
||||
|
||||
/*If the value is not the init value then the page has >=1 child.*/
|
||||
if(new_cords.x1 != LV_COORD_MAX) {
|
||||
if(ext->hor_fit != 0) {
|
||||
new_cords.x1 -= hpad;
|
||||
new_cords.x2 += hpad;
|
||||
} else {
|
||||
new_cords.x1 = cont->coords.x1;
|
||||
new_cords.x2 = cont->coords.x2;
|
||||
tight_area.x1 -= hpad;
|
||||
tight_area.x2 += hpad;
|
||||
tight_area.y1 -= vpad;
|
||||
tight_area.y2 += vpad;
|
||||
}
|
||||
if(ext->ver_fit != 0) {
|
||||
new_cords.y1 -= vpad;
|
||||
new_cords.y2 += vpad;
|
||||
} else {
|
||||
new_cords.y1 = cont->coords.y1;
|
||||
new_cords.y2 = cont->coords.y2;
|
||||
|
||||
lv_area_t new_area;
|
||||
lv_area_copy(&new_area, &ori);
|
||||
|
||||
switch(ext->fit_left) {
|
||||
case LV_FIT_TIGHT: new_area.x1 = tight_area.x1; break;
|
||||
case LV_FIT_FLOOD: new_area.x1 = flood_area.x1; break;
|
||||
case LV_FIT_FILL: new_area.x1 = has_children ? LV_MATH_MIN(tight_area.x1, flood_area.x1) : flood_area.x1; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(ext->fit_right) {
|
||||
case LV_FIT_TIGHT: new_area.x2 = tight_area.x2; break;
|
||||
case LV_FIT_FLOOD: new_area.x2 = flood_area.x2; break;
|
||||
case LV_FIT_FILL: new_area.x2 = has_children ? LV_MATH_MAX(tight_area.x2, flood_area.x2) : flood_area.x2; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(ext->fit_top) {
|
||||
case LV_FIT_TIGHT: new_area.y1 = tight_area.y1; break;
|
||||
case LV_FIT_FLOOD: new_area.y1 = flood_area.y1; break;
|
||||
case LV_FIT_FILL: new_area.y1 = has_children ? LV_MATH_MIN(tight_area.y1, flood_area.y1) : flood_area.y1; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(ext->fit_bottom) {
|
||||
case LV_FIT_TIGHT: new_area.y2 = tight_area.y2; break;
|
||||
case LV_FIT_FLOOD: new_area.y2 = flood_area.y2; break;
|
||||
case LV_FIT_FILL: new_area.y2 = has_children ? LV_MATH_MAX(tight_area.y2, flood_area.y2) : flood_area.y2; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
/*Do nothing if the coordinates are not changed*/
|
||||
if(cont->coords.x1 != new_cords.x1 ||
|
||||
cont->coords.y1 != new_cords.y1 ||
|
||||
cont->coords.x2 != new_cords.x2 ||
|
||||
cont->coords.y2 != new_cords.y2) {
|
||||
if(cont->coords.x1 != new_area.x1 ||
|
||||
cont->coords.y1 != new_area.y1 ||
|
||||
cont->coords.x2 != new_area.x2 ||
|
||||
cont->coords.y2 != new_area.y2)
|
||||
{
|
||||
|
||||
lv_obj_invalidate(cont);
|
||||
lv_area_copy(&cont->coords, &new_cords);
|
||||
lv_area_copy(&cont->coords, &new_area);
|
||||
lv_obj_invalidate(cont);
|
||||
|
||||
/*Notify the object about its new coordinates*/
|
||||
@ -636,8 +710,14 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
|
||||
/*Inform the parent about the new coordinates*/
|
||||
lv_obj_t * par = lv_obj_get_parent(cont);
|
||||
par->signal_func(par, LV_SIGNAL_CHILD_CHG, cont);
|
||||
|
||||
/*Tell the children the parent's size has changed*/
|
||||
lv_obj_t * i;
|
||||
LL_READ(cont->child_ll, i) {
|
||||
i->signal_func(i, LV_SIGNAL_PARENT_SIZE_CHG, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -47,13 +47,23 @@ enum
|
||||
};
|
||||
typedef uint8_t lv_layout_t;
|
||||
|
||||
|
||||
typedef enum {
|
||||
LV_FIT_NONE, /*Do not change the size automatically*/
|
||||
LV_FIT_TIGHT, /*Involve the children*/
|
||||
LV_FIT_FLOOD, /*Align the size to the parent's edge*/
|
||||
LV_FIT_FILL, /*Align the size to the parent's edge first but if there is an object out of it then involve it*/
|
||||
}lv_fit_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/
|
||||
/*New data for this type */
|
||||
uint8_t layout :4; /*A layout from 'lv_cont_layout_t' enum*/
|
||||
uint8_t hor_fit :1; /*1: Enable horizontal fit to involve all children*/
|
||||
uint8_t ver_fit :1; /*1: Enable horizontal fit to involve all children*/
|
||||
uint8_t layout :4; /*A layout from 'lv_layout_t' enum*/
|
||||
uint8_t fit_left :2; /*A fit type from `lv_fit_t` enum */
|
||||
uint8_t fit_right :2; /*A fit type from `lv_fit_t` enum */
|
||||
uint8_t fit_top :2; /*A fit type from `lv_fit_t` enum */
|
||||
uint8_t fit_bottom :2; /*A fit type from `lv_fit_t` enum */
|
||||
} lv_cont_ext_t;
|
||||
|
||||
|
||||
@ -80,15 +90,41 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
*/
|
||||
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout);
|
||||
|
||||
/**
|
||||
* Set the fit policy in all 4 directions separately.
|
||||
* It tell how to change the container's size automatically.
|
||||
* @param cont pointer to a container object
|
||||
* @param left left fit policy from `lv_fit_t`
|
||||
* @param right right fit policy from `lv_fit_t`
|
||||
* @param top bottom fit policy from `lv_fit_t`
|
||||
* @param bottom bottom fit policy from `lv_fit_t`
|
||||
*/
|
||||
void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom);
|
||||
|
||||
/**
|
||||
* Enable the horizontal or vertical fit.
|
||||
* The container size will be set to involve the children horizontally or vertically.
|
||||
* Set the fit policy horizontally and vertically separately.
|
||||
* It tell how to change the container's size automatically.
|
||||
* @param cont pointer to a container object
|
||||
* @param hor_en true: enable the horizontal fit
|
||||
* @param ver_en true: enable the vertical fit
|
||||
* @param hot horizontal fit policy from `lv_fit_t`
|
||||
* @param ver vertical fit policy from `lv_fit_t`
|
||||
*/
|
||||
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en);
|
||||
static inline void lv_cont_set_fit2(lv_obj_t * cont, lv_fit_t hor, lv_fit_t ver)
|
||||
{
|
||||
lv_cont_set_fit4(cont, hor, hor, ver, ver);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the fit policyin all 4 direction at once.
|
||||
* It tell how to change the container's size automatically.
|
||||
* @param cont pointer to a container object
|
||||
* @param fit fit policy from `lv_fit_t`
|
||||
*/
|
||||
static inline void lv_cont_set_fit(lv_obj_t * cont, lv_fit_t fit)
|
||||
{
|
||||
lv_cont_set_fit4(cont, fit, fit, fit, fit);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the style of a container
|
||||
@ -112,18 +148,32 @@ static inline void lv_cont_set_style(lv_obj_t *cont, lv_style_t * style)
|
||||
lv_layout_t lv_cont_get_layout(const lv_obj_t * cont);
|
||||
|
||||
/**
|
||||
* Get horizontal fit enable attribute of a container
|
||||
* Get left fit mode of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return true: horizontal fit is enabled; false: disabled
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
bool lv_cont_get_hor_fit(const lv_obj_t * cont);
|
||||
lv_fit_t lv_cont_get_fit_left(const lv_obj_t * cont);
|
||||
|
||||
/**
|
||||
* Get vertical fit enable attribute of a container
|
||||
* Get right fit mode of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return true: vertical fit is enabled; false: disabled
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
bool lv_cont_get_ver_fit(const lv_obj_t * cont);
|
||||
lv_fit_t lv_cont_get_fit_right(const lv_obj_t * cont);
|
||||
|
||||
/**
|
||||
* Get top fit mode of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
lv_fit_t lv_cont_get_fit_top(const lv_obj_t * cont);
|
||||
|
||||
/**
|
||||
* Get bottom fit mode of a container
|
||||
* @param cont pointer to a container object
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -104,10 +104,10 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
if(copy == NULL) {
|
||||
lv_obj_t * scrl = lv_page_get_scrl(new_ddlist);
|
||||
lv_obj_set_drag(scrl, false);
|
||||
lv_page_set_scrl_fit(new_ddlist, true, true);
|
||||
lv_page_set_scrl_fit2(new_ddlist, LV_FIT_TIGHT, LV_FIT_TIGHT);
|
||||
|
||||
ext->label = lv_label_create(new_ddlist, NULL);
|
||||
lv_cont_set_fit(new_ddlist, true, false);
|
||||
lv_cont_set_fit2(new_ddlist, LV_FIT_TIGHT, LV_FIT_NONE);
|
||||
lv_page_set_rel_action(new_ddlist, lv_ddlist_release_action);
|
||||
lv_page_set_sb_mode(new_ddlist, LV_SB_MODE_DRAG);
|
||||
lv_page_set_sb_mode(new_ddlist, LV_SB_MODE_HIDE);
|
||||
@ -118,9 +118,9 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, th->ddlist.bg);
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, th->ddlist.sel);
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SB, th->ddlist.sb);
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, th->style.ddlist.bg);
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, th->style.ddlist.sel);
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SB, th->style.ddlist.sb);
|
||||
} else {
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, &lv_style_pretty);
|
||||
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SEL, &lv_style_plain_color);
|
||||
@ -238,12 +238,11 @@ void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h)
|
||||
/**
|
||||
* Enable or disable the horizontal fit to the content
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @param en true: enable auto fit; false: disable auto fit
|
||||
* @param fit fit mode fron `lv_fit_t` (Typically `LV_FIT_NONE` or `LV_FIT_TIGHT`)
|
||||
*/
|
||||
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, bool en)
|
||||
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, lv_fit_t fit)
|
||||
{
|
||||
lv_cont_set_fit(ddlist, en, lv_cont_get_ver_fit(ddlist));
|
||||
lv_page_set_scrl_fit(ddlist, en, lv_page_get_scrl_fit_ver(ddlist));
|
||||
lv_cont_set_fit2(ddlist, fit, lv_cont_get_fit_top(ddlist));
|
||||
|
||||
lv_ddlist_refr_size(ddlist, false);
|
||||
}
|
||||
@ -624,6 +623,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
} else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
ext->label = NULL;
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(ddlist);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
@ -651,6 +651,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
if(ext->opened) {
|
||||
ext->opened = false;
|
||||
@ -686,9 +687,11 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
ext->opened = 0;
|
||||
if(ext->action) ext->action(ddlist);
|
||||
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(ddlist);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
|
||||
#endif
|
||||
} else {
|
||||
ext->opened = 1;
|
||||
}
|
||||
|
@ -117,12 +117,13 @@ void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action);
|
||||
*/
|
||||
void lv_ddlist_set_fix_height(lv_obj_t * ddlist, lv_coord_t h);
|
||||
|
||||
|
||||
/**
|
||||
* Enable or disable the horizontal fit to the content
|
||||
* @param ddlist pointer to a drop down list
|
||||
* @param en true: enable auto fit; false: disable auto fit
|
||||
* @param fit fit mode fron `lv_fit_t` (Typically `LV_FIT_NONE` or `LV_FIT_TIGHT`)
|
||||
*/
|
||||
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, bool en);
|
||||
void lv_ddlist_set_hor_fit(lv_obj_t * ddlist, lv_fit_t fit);
|
||||
|
||||
/**
|
||||
* Set the scroll bar mode of a drop down list
|
||||
|
@ -95,7 +95,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_gauge_set_style(new_gauge, th->gauge);
|
||||
lv_gauge_set_style(new_gauge, th->style.gauge);
|
||||
} else {
|
||||
lv_gauge_set_style(new_gauge, &lv_style_pretty_color);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
#error "lv_img: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
|
||||
#endif
|
||||
|
||||
#include "../lv_core/lv_lang.h"
|
||||
#include "../lv_core/lv_i18n.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_misc/lv_fs.h"
|
||||
#include "../lv_misc/lv_ufs.h"
|
||||
@ -78,9 +78,6 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->w = lv_obj_get_width(new_img);
|
||||
ext->h = lv_obj_get_height(new_img);
|
||||
ext->auto_size = 1;
|
||||
#if USE_LV_MULTI_LANG
|
||||
ext->lang_txt_id = LV_LANG_TXT_ID_NONE;
|
||||
#endif
|
||||
|
||||
/*Init the new object*/
|
||||
lv_obj_set_signal_func(new_img, lv_img_signal);
|
||||
@ -129,7 +126,7 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
||||
lv_img_src_t src_type = lv_img_src_get_type(src_img);
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
|
||||
#if LV_LOG_LEVEL >= LV_LOG_LEVEL_INFO
|
||||
#if USE_LV_LOG && LV_LOG_LEVEL >= LV_LOG_LEVEL_INFO
|
||||
switch(src_type) {
|
||||
case LV_IMG_SRC_FILE:
|
||||
LV_LOG_TRACE("lv_img_set_src: `LV_IMG_SRC_FILE` type found");
|
||||
@ -206,22 +203,6 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img)
|
||||
lv_obj_invalidate(img);
|
||||
}
|
||||
|
||||
#if USE_LV_MULTI_LANG
|
||||
/**
|
||||
* Set an ID which means a the same source but in different languages
|
||||
* @param img pointer to an image object
|
||||
* @param src_id ID of the source
|
||||
*/
|
||||
void lv_img_set_src_id(lv_obj_t * img, uint32_t src_id)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
ext->lang_txt_id = src_id;
|
||||
|
||||
/*Apply the new language*/
|
||||
img->signal_func(img, LV_SIGNAL_LANG_CHG, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Enable the auto size feature.
|
||||
* If enabled the object size will be same as the picture size.
|
||||
@ -266,19 +247,6 @@ const char * lv_img_get_file_name(const lv_obj_t * img)
|
||||
else return "";
|
||||
}
|
||||
|
||||
#if USE_LV_MULTI_LANG
|
||||
/**
|
||||
* Get the source ID of the image. (Used by the multi-language feature)
|
||||
* @param img pointer to an image
|
||||
* @return ID of the source
|
||||
*/
|
||||
uint16_t lv_img_get_src_id(lv_obj_t * img)
|
||||
{
|
||||
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
|
||||
return ext->lang_txt_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the auto size enable attribute
|
||||
* @param img pointer to an image
|
||||
@ -382,17 +350,6 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
|
||||
lv_img_set_src(img, ext->src);
|
||||
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_LANG_CHG) {
|
||||
#if USE_LV_MULTI_LANG
|
||||
if(ext->lang_txt_id != LV_LANG_TXT_ID_NONE) {
|
||||
const char * lang_src = lv_lang_get_text(ext->lang_txt_id);
|
||||
if(lang_src) {
|
||||
lv_img_set_src(img, lang_src);
|
||||
} else {
|
||||
LV_LOG_WARN("lv_lang_get_text return NULL for an image's source");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
|
@ -43,9 +43,6 @@ typedef struct
|
||||
|
||||
lv_coord_t w; /*Width of the image (Handled by the library)*/
|
||||
lv_coord_t h; /*Height of the image (Handled by the library)*/
|
||||
#if USE_LV_MULTI_LANG
|
||||
uint16_t lang_txt_id; /*The ID of the image to display. */
|
||||
#endif
|
||||
uint8_t src_type :2; /*See: lv_img_src_t*/
|
||||
uint8_t auto_size :1; /*1: automatically set the object size to the image size*/
|
||||
uint8_t cf :5; /*Color format from `lv_img_color_format_t`*/
|
||||
@ -74,15 +71,6 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy);
|
||||
*/
|
||||
void lv_img_set_src(lv_obj_t * img, const void * src_img);
|
||||
|
||||
#if USE_LV_MULTI_LANG
|
||||
/**
|
||||
* Set an ID which means a the same source but on different languages
|
||||
* @param img pointer to an image object
|
||||
* @param src_id ID of the source
|
||||
*/
|
||||
void lv_img_set_src_id(lv_obj_t * img, uint32_t txt_id);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0.
|
||||
* Use 'lv_img_set_src()' instead.
|
||||
@ -142,15 +130,6 @@ const void * lv_img_get_src(lv_obj_t * img);
|
||||
*/
|
||||
const char * lv_img_get_file_name(const lv_obj_t * img);
|
||||
|
||||
#if USE_LV_MULTI_LANG
|
||||
/**
|
||||
* Get the source ID of the image. (Used by the multi-language feature)
|
||||
* @param img pointer to an image
|
||||
* @return ID of the source
|
||||
*/
|
||||
uint16_t lv_img_get_src_id(lv_obj_t * img);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the auto size enable attribute
|
||||
* @param img pointer to an image
|
||||
|
@ -81,11 +81,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
}
|
||||
/*Copy an existing image button*/
|
||||
else {
|
||||
#if LV_IMGBTN_TILED == 0
|
||||
memset(ext->img_src, 0, sizeof(ext->img_src));
|
||||
#else
|
||||
lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
||||
|
||||
#if LV_IMGBTN_TILED == 0
|
||||
memcpy(ext->img_src, copy_ext->img_src, sizeof(ext->img_src));
|
||||
#else
|
||||
memcpy(ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left));
|
||||
memcpy(ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid));
|
||||
memcpy(ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right));
|
||||
@ -386,7 +385,7 @@ static void refr_img(lv_obj_t * imgbtn)
|
||||
ext->act_cf = LV_IMG_CF_UNKOWN;
|
||||
}
|
||||
|
||||
|
||||
lv_obj_invalidate(imgbtn);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -102,7 +102,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new keyboard keyboard*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_kb, LV_HOR_RES, LV_VER_RES / 2);
|
||||
lv_obj_set_size(new_kb, LV_DPI * 3, LV_DPI * 2);
|
||||
lv_obj_align(new_kb, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
lv_btnm_set_action(new_kb, lv_kb_def_action);
|
||||
lv_btnm_set_map(new_kb, kb_map_lc);
|
||||
@ -110,12 +110,12 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BG, th->kb.bg);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_REL, th->kb.btn.rel);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_PR, th->kb.btn.pr);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_REL, th->kb.btn.tgl_rel);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_PR, th->kb.btn.tgl_pr);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_INA, th->kb.btn.ina);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BG, th->style.kb.bg);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_REL, th->style.kb.btn.rel);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_PR, th->style.kb.btn.pr);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_REL, th->style.kb.btn.tgl_rel);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_TGL_PR, th->style.kb.btn.tgl_pr);
|
||||
lv_kb_set_style(new_kb, LV_KB_STYLE_BTN_INA, th->style.kb.btn.ina);
|
||||
} else {
|
||||
/*Let the button matrix's styles*/
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include "../lv_core/lv_obj.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_core/lv_lang.h"
|
||||
#include "../lv_core/lv_i18n.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
@ -91,9 +91,6 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->anim_speed = LV_LABEL_SCROLL_SPEED;
|
||||
ext->offset.x = 0;
|
||||
ext->offset.y = 0;
|
||||
#if USE_LV_MULTI_LANG
|
||||
ext->lang_txt_id = LV_LANG_TXT_ID_NONE;
|
||||
#endif
|
||||
lv_obj_set_design_func(new_label, lv_label_design);
|
||||
lv_obj_set_signal_func(new_label, lv_label_signal);
|
||||
|
||||
@ -237,22 +234,6 @@ void lv_label_set_static_text(lv_obj_t * label, const char * text)
|
||||
lv_label_refr_text(label);
|
||||
}
|
||||
|
||||
#if USE_LV_MULTI_LANG
|
||||
/**
|
||||
*Set a text ID which refers a the same text but in a different languages
|
||||
* @param label pointer to a label object
|
||||
* @param txt_id ID of the text
|
||||
*/
|
||||
void lv_label_set_text_id(lv_obj_t * label, uint32_t txt_id)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
ext->lang_txt_id = txt_id;
|
||||
|
||||
/*Apply the new language*/
|
||||
label->signal_func(label, LV_SIGNAL_LANG_CHG, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set the behavior of the label with longer text then the object size
|
||||
* @param label pointer to a label object
|
||||
@ -365,19 +346,6 @@ char * lv_label_get_text(const lv_obj_t * label)
|
||||
return ext->text;
|
||||
}
|
||||
|
||||
#if USE_LV_MULTI_LANG
|
||||
/**
|
||||
* Get the text ID of the label. (Used by the multi-language feature)
|
||||
* @param label pointer to a label object
|
||||
* @return ID of the text
|
||||
*/
|
||||
uint16_t lv_label_get_text_id(lv_obj_t * label)
|
||||
{
|
||||
lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
|
||||
return ext->lang_txt_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the long mode of a label
|
||||
* @param label pointer to a label object
|
||||
@ -753,17 +721,6 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param
|
||||
label->ext_size = LV_MATH_MAX(label->ext_size, style->body.padding.hor);
|
||||
label->ext_size = LV_MATH_MAX(label->ext_size, style->body.padding.ver);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_LANG_CHG) {
|
||||
#if USE_LV_MULTI_LANG
|
||||
if(ext->lang_txt_id != LV_LANG_TXT_ID_NONE) {
|
||||
const char * lang_txt = lv_lang_get_text(ext->lang_txt_id);
|
||||
if(lang_txt) {
|
||||
lv_label_set_text(label, lang_txt);
|
||||
} else {
|
||||
LV_LOG_WARN("lv_lang_get_text return NULL for a label's text");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
|
@ -69,9 +69,6 @@ typedef struct
|
||||
char dot_tmp[LV_LABEL_DOT_NUM * 4 + 1]; /*Store the character which are replaced by dots (Handled by the library)*/
|
||||
#endif
|
||||
|
||||
#if USE_LV_MULTI_LANG
|
||||
uint16_t lang_txt_id; /*The ID of the text to display*/
|
||||
#endif
|
||||
uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/
|
||||
uint16_t anim_speed; /*Speed of scroll and roll animation in px/sec unit*/
|
||||
lv_point_t offset; /*Text draw position offset*/
|
||||
@ -123,15 +120,6 @@ void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size
|
||||
*/
|
||||
void lv_label_set_static_text(lv_obj_t * label, const char * text);
|
||||
|
||||
/**
|
||||
*Set a text ID which means a the same text but on different languages
|
||||
* @param label pointer to a label object
|
||||
* @param txt_id ID of the text
|
||||
*/
|
||||
#if USE_LV_MULTI_LANG
|
||||
void lv_label_set_text_id(lv_obj_t * label, uint32_t txt_id);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set the behavior of the label with longer text then the object size
|
||||
* @param label pointer to a label object
|
||||
@ -188,15 +176,6 @@ static inline void lv_label_set_style(lv_obj_t *label, lv_style_t *style)
|
||||
*/
|
||||
char * lv_label_get_text(const lv_obj_t * label);
|
||||
|
||||
#if USE_LV_MULTI_LANG
|
||||
/**
|
||||
* Get the text ID of the label. (Used by the multi-language feature)
|
||||
* @param label pointer to a label object
|
||||
* @return ID of the text
|
||||
*/
|
||||
uint16_t lv_label_get_text_id(lv_obj_t * label);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the long mode of a label
|
||||
* @param label pointer to a label object
|
||||
|
@ -79,7 +79,7 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_led_set_style(new_led, th->led);
|
||||
lv_led_set_style(new_led, th->style.led);
|
||||
} else {
|
||||
lv_led_set_style(new_led, &lv_style_pretty_color);
|
||||
}
|
||||
|
@ -102,6 +102,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new list object*/
|
||||
if(copy == NULL) {
|
||||
lv_page_set_scrl_fit2(new_list, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
||||
lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI);
|
||||
lv_page_set_scrl_layout(new_list, LV_LIST_LAYOUT_DEF);
|
||||
lv_list_set_sb_mode(new_list, LV_SB_MODE_DRAG);
|
||||
@ -109,14 +110,14 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BG, th->list.bg);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, th->list.scrl);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_SB, th->list.sb);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_REL, th->list.btn.rel);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_PR, th->list.btn.pr);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL, th->list.btn.tgl_rel);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR, th->list.btn.tgl_pr);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_INA, th->list.btn.ina);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BG, th->style.list.bg);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, th->style.list.scrl);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_SB, th->style.list.sb);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_REL, th->style.list.btn.rel);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_PR, th->style.list.btn.pr);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL, th->style.list.btn.tgl_rel);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR, th->style.list.btn.tgl_pr);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BTN_INA, th->style.list.btn.ina);
|
||||
} else {
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_BG, &lv_style_transp_fit);
|
||||
lv_list_set_style(new_list, LV_LIST_STYLE_SCRL, &lv_style_pretty);
|
||||
@ -198,7 +199,7 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
|
||||
lv_btn_set_action(liste, LV_BTN_ACTION_CLICK, rel_action);
|
||||
lv_page_glue_obj(liste, true);
|
||||
lv_btn_set_layout(liste, LV_LAYOUT_ROW_M);
|
||||
lv_btn_set_fit(liste, false, true);
|
||||
lv_btn_set_fit2(liste, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
||||
lv_obj_set_protect(liste, LV_PROTECT_PRESS_LOST);
|
||||
lv_obj_set_signal_func(liste, lv_list_btn_signal);
|
||||
|
||||
@ -300,6 +301,9 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
|
||||
}
|
||||
|
||||
ext->selected_btn = btn;
|
||||
if( btn != NULL ) {
|
||||
ext->last_sel = btn;
|
||||
}
|
||||
|
||||
if(ext->selected_btn) {
|
||||
lv_btn_state_t s = lv_btn_get_state(ext->selected_btn);
|
||||
@ -760,7 +764,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
lv_group_t * g = lv_obj_get_group(list);
|
||||
if(lv_group_get_editing(g)) {
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
if(NULL != ext->last_sel) {
|
||||
if(ext->last_sel) {
|
||||
/* Select the last used button */
|
||||
lv_list_set_btn_selected(list, ext->last_sel);
|
||||
}
|
||||
@ -779,7 +783,7 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
lv_list_set_btn_selected(list, last_clicked_btn);
|
||||
} else {
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
if(NULL != ext->last_sel) {
|
||||
if(ext->last_sel) {
|
||||
/* Select the last used button */
|
||||
lv_list_set_btn_selected(list, ext->last_sel);
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ typedef struct
|
||||
uint32_t size; /*the number of items(buttons) in the list*/
|
||||
bool single_mode; /* whether single selected mode is enabled */
|
||||
#if USE_LV_GROUP
|
||||
lv_obj_t * last_sel; /* Last btn selected */
|
||||
lv_obj_t * selected_btn;
|
||||
lv_obj_t * last_sel; /* The last selected button. It will be reverted when the list is focused again */
|
||||
lv_obj_t * selected_btn; /* The button is currently being selected*/
|
||||
#endif
|
||||
} lv_list_ext_t;
|
||||
|
||||
|
@ -84,7 +84,7 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_lmeter_set_style(new_lmeter, th->lmeter);
|
||||
lv_lmeter_set_style(new_lmeter, th->style.lmeter);
|
||||
} else {
|
||||
lv_lmeter_set_style(new_lmeter, &lv_style_pretty_color);
|
||||
}
|
||||
|
@ -90,14 +90,14 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_label_set_text(ext->text, "Message");
|
||||
|
||||
lv_cont_set_layout(new_mbox, LV_LAYOUT_COL_M);
|
||||
lv_cont_set_fit(new_mbox, false, true);
|
||||
lv_obj_set_width(new_mbox, LV_HOR_RES / 2);
|
||||
lv_cont_set_fit2(new_mbox, LV_FIT_NONE, LV_FIT_TIGHT);
|
||||
lv_obj_set_width(new_mbox, LV_DPI * 2);
|
||||
lv_obj_align(new_mbox, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, th->mbox.bg);
|
||||
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, th->style.mbox.bg);
|
||||
} else {
|
||||
lv_mbox_set_style(new_mbox, LV_MBOX_STYLE_BG, &lv_style_pretty);
|
||||
}
|
||||
@ -144,9 +144,9 @@ void lv_mbox_add_btns(lv_obj_t * mbox, const char ** btn_map, lv_btnm_action_t a
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_BG, th->mbox.btn.bg);
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_REL, th->mbox.btn.rel);
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_PR, th->mbox.btn.pr);
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_BG, th->style.mbox.btn.bg);
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_REL, th->style.mbox.btn.rel);
|
||||
lv_mbox_set_style(mbox, LV_MBOX_STYLE_BTN_PR, th->style.mbox.btn.pr);
|
||||
} else {
|
||||
lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BG, &lv_style_transp_fit);
|
||||
}
|
||||
@ -220,7 +220,7 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
|
||||
lv_obj_animate(mbox, LV_ANIM_GROW_V | LV_ANIM_OUT, ext->anim_time, delay, lv_mbox_close_end_cb);
|
||||
|
||||
/*Disable fit to let shrinking work*/
|
||||
lv_cont_set_fit(mbox, false, false);
|
||||
lv_cont_set_fit(mbox, LV_FIT_NONE);
|
||||
} else {
|
||||
lv_obj_animate(mbox, LV_ANIM_NONE, ext->anim_time, delay, lv_mbox_close_end_cb);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_set_drag(ext->scrl, true);
|
||||
lv_obj_set_drag_throw(ext->scrl, true);
|
||||
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
|
||||
lv_cont_set_fit(ext->scrl, false, true);
|
||||
lv_cont_set_fit4(ext->scrl, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL, LV_FIT_FILL);
|
||||
|
||||
/* Add the signal function only if 'scrolling' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
@ -116,14 +116,14 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
if(par == NULL) { /*Different styles if it is screen*/
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->bg);
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->style.bg);
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_transp);
|
||||
} else {
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->page.bg);
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, th->page.scrl);
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->style.page.bg);
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, th->style.page.scrl);
|
||||
|
||||
}
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, th->page.sb);
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, th->style.page.sb);
|
||||
} else {
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, &lv_style_pretty_color);
|
||||
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_pretty);
|
||||
@ -567,7 +567,7 @@ void lv_page_scroll_ver(lv_obj_t * page, lv_coord_t dist)
|
||||
a.repeat_pause = 0;
|
||||
lv_anim_create(&a);
|
||||
#else
|
||||
lv_obj_set_y(scrl, lv_obj_get_x(scrl) + dist);
|
||||
lv_obj_set_y(scrl, lv_obj_get_y(scrl) + dist);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -765,7 +765,6 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
lv_style_t * style = lv_obj_get_style(page);
|
||||
lv_obj_t * child;
|
||||
if(sign == LV_SIGNAL_CHILD_CHG) { /*Automatically move children to the scrollable object*/
|
||||
child = lv_obj_get_child(page, NULL);
|
||||
@ -773,18 +772,21 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {
|
||||
lv_obj_t * tmp = child;
|
||||
child = lv_obj_get_child(page, child); /*Get the next child before move this*/
|
||||
|
||||
/*Reposition the child to take padding into account*/
|
||||
lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
||||
child->coords.x1 += style->body.padding.hor;
|
||||
child->coords.x2 += style->body.padding.hor;
|
||||
child->coords.y1 += style->body.padding.ver;
|
||||
child->coords.y2 += style->body.padding.ver;
|
||||
|
||||
lv_obj_set_parent(tmp, ext->scrl);
|
||||
} else {
|
||||
child = lv_obj_get_child(page, child);
|
||||
}
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*If no hor_fit enabled set the scrollable's width to the page's width*/
|
||||
if(lv_cont_get_hor_fit(ext->scrl) == false) {
|
||||
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.padding.hor);
|
||||
} else {
|
||||
ext->scrl->signal_func(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
||||
}
|
||||
|
||||
/*The scrollbars are important only if they are visible now*/
|
||||
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
|
||||
@ -796,10 +798,6 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
if(ext->scrl != NULL && (lv_obj_get_width(page) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(page) != lv_area_get_height(param))) {
|
||||
/*If no hor_fit enabled set the scrollable's width to the page's width*/
|
||||
if(lv_cont_get_hor_fit(ext->scrl) == false) {
|
||||
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.padding.hor);
|
||||
}
|
||||
|
||||
ext->scrl->signal_func(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
||||
|
||||
/*The scrollbars are important only if they are visible now*/
|
||||
@ -1000,6 +998,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
|
||||
/*Hide scrollbars if required*/
|
||||
if(page_ext->sb.mode == LV_SB_MODE_DRAG) {
|
||||
lv_disp_t * disp = lv_obj_get_disp(page);
|
||||
lv_area_t sb_area_tmp;
|
||||
if(page_ext->sb.hor_draw) {
|
||||
lv_area_copy(&sb_area_tmp, &page_ext->sb.hor_area);
|
||||
@ -1007,7 +1006,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
page_ext->sb.hor_draw = 0;
|
||||
}
|
||||
if(page_ext->sb.ver_draw) {
|
||||
@ -1016,7 +1015,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
page_ext->sb.ver_draw = 0;
|
||||
}
|
||||
}
|
||||
@ -1068,6 +1067,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
}
|
||||
|
||||
/*Invalidate the current (old) scrollbar areas*/
|
||||
lv_disp_t * disp = lv_obj_get_disp(page);
|
||||
lv_area_t sb_area_tmp;
|
||||
if(ext->sb.hor_draw != 0) {
|
||||
lv_area_copy(&sb_area_tmp, &ext->sb.hor_area);
|
||||
@ -1075,7 +1075,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
}
|
||||
if(ext->sb.ver_draw != 0) {
|
||||
lv_area_copy(&sb_area_tmp, &ext->sb.ver_area);
|
||||
@ -1083,7 +1083,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
}
|
||||
|
||||
|
||||
@ -1137,7 +1137,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
}
|
||||
if(ext->sb.ver_draw != 0) {
|
||||
lv_area_copy(&sb_area_tmp, &ext->sb.ver_area);
|
||||
@ -1145,7 +1145,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
sb_area_tmp.y1 += page->coords.y1;
|
||||
sb_area_tmp.x2 += page->coords.x1;
|
||||
sb_area_tmp.y2 += page->coords.y1;
|
||||
lv_inv_area(&sb_area_tmp);
|
||||
lv_inv_area(disp, &sb_area_tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,17 +173,42 @@ void lv_page_set_scroll_propagation(lv_obj_t * page, bool en);
|
||||
*/
|
||||
void lv_page_set_edge_flash(lv_obj_t * page, bool en);
|
||||
|
||||
|
||||
/**
|
||||
* Set the fit attribute of the scrollable part of a page.
|
||||
* It means it can set its size automatically to involve all children.
|
||||
* (Can be set separately horizontally and vertically)
|
||||
* Set the fit policy in all 4 directions separately.
|
||||
* It tell how to change the page size automatically.
|
||||
* @param page pointer to a page object
|
||||
* @param hor_en true: enable horizontal fit
|
||||
* @param ver_en true: enable vertical fit
|
||||
* @param left left fit policy from `lv_fit_t`
|
||||
* @param right right fit policy from `lv_fit_t`
|
||||
* @param top bottom fit policy from `lv_fit_t`
|
||||
* @param bottom bottom fit policy from `lv_fit_t`
|
||||
*/
|
||||
static inline void lv_page_set_scrl_fit(lv_obj_t *page, bool hor_en, bool ver_en)
|
||||
static inline void lv_page_set_scrl_fit4(lv_obj_t * page, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom)
|
||||
{
|
||||
lv_cont_set_fit(lv_page_get_scrl(page), hor_en, ver_en);
|
||||
lv_cont_set_fit4(lv_page_get_scrl(page), left, right, top, bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fit policy horizontally and vertically separately.
|
||||
* It tell how to change the page size automatically.
|
||||
* @param page pointer to a page object
|
||||
* @param hot horizontal fit policy from `lv_fit_t`
|
||||
* @param ver vertical fit policy from `lv_fit_t`
|
||||
*/
|
||||
static inline void lv_page_set_scrl_fit2(lv_obj_t * page, lv_fit_t hor, lv_fit_t ver)
|
||||
{
|
||||
lv_cont_set_fit2(lv_page_get_scrl(page), hor, ver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fit policyin all 4 direction at once.
|
||||
* It tell how to change the page size automatically.
|
||||
* @param page pointer to a button object
|
||||
* @param fit fit policy from `lv_fit_t`
|
||||
*/
|
||||
static inline void lv_page_set_scrl_fit(lv_obj_t * page, lv_fit_t fit)
|
||||
{
|
||||
lv_cont_set_fit(lv_page_get_scrl(page), fit);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -303,23 +328,43 @@ static inline lv_layout_t lv_page_get_scrl_layout(const lv_obj_t * page)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get horizontal fit attribute of the scrollable part of a page
|
||||
* @param page pointer to a page object
|
||||
* @return true: horizontal fit is enabled; false: disabled
|
||||
*/
|
||||
static inline bool lv_page_get_scrl_hor_fit(const lv_obj_t * page)
|
||||
* Get the left fit mode
|
||||
* @param page pointer to a page object
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
static inline lv_fit_t lv_page_get_scrl_fit_left(const lv_obj_t * page)
|
||||
{
|
||||
return lv_cont_get_hor_fit(lv_page_get_scrl(page));
|
||||
return lv_cont_get_fit_left(lv_page_get_scrl(page));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vertical fit attribute of the scrollable part of a page
|
||||
* @param page pointer to a page object
|
||||
* @return true: vertical fit is enabled; false: disabled
|
||||
*/
|
||||
static inline bool lv_page_get_scrl_fit_ver(const lv_obj_t * page)
|
||||
* Get the right fit mode
|
||||
* @param page pointer to a page object
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
static inline lv_fit_t lv_page_get_scrl_fit_right(const lv_obj_t * page)
|
||||
{
|
||||
return lv_cont_get_ver_fit(lv_page_get_scrl(page));
|
||||
return lv_cont_get_fit_right(lv_page_get_scrl(page));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top fit mode
|
||||
* @param page pointer to a page object
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
static inline lv_fit_t lv_page_get_scrl_get_fit_top(const lv_obj_t * page)
|
||||
{
|
||||
return lv_cont_get_fit_top(lv_page_get_scrl(page));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bottom fit mode
|
||||
* @param page pointer to a page object
|
||||
* @return an element of `lv_fit_t`
|
||||
*/
|
||||
static inline lv_fit_t lv_page_get_scrl_fit_bottom(const lv_obj_t * page)
|
||||
{
|
||||
return lv_cont_get_fit_bottom(lv_page_get_scrl(page));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,7 +93,7 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_preload_set_style(new_preload, LV_PRELOAD_STYLE_MAIN, th->preload);
|
||||
lv_preload_set_style(new_preload, LV_PRELOAD_STYLE_MAIN, th->style.preload);
|
||||
} else {
|
||||
lv_obj_set_style(new_preload, &lv_style_pretty_color);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_t * scrl = lv_page_get_scrl(new_roller);
|
||||
lv_obj_set_drag(scrl, true); /*In ddlist is might be disabled*/
|
||||
lv_page_set_rel_action(new_roller, NULL); /*Roller don't uses it (like ddlist)*/
|
||||
lv_page_set_scrl_fit(new_roller, true, false); /*Height is specified directly*/
|
||||
lv_page_set_scrl_fit2(new_roller, LV_FIT_TIGHT, LV_FIT_NONE); /*Height is specified directly*/
|
||||
lv_ddlist_open(new_roller, false);
|
||||
lv_ddlist_set_anim_time(new_roller, LV_ROLLER_ANIM_TIME);
|
||||
lv_roller_set_visible_row_count(new_roller, 3);
|
||||
@ -96,8 +96,8 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_BG, th->roller.bg);
|
||||
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_SEL, th->roller.sel);
|
||||
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_BG, th->style.roller.bg);
|
||||
lv_roller_set_style(new_roller, LV_ROLLER_STYLE_SEL, th->style.roller.sel);
|
||||
} else {
|
||||
/*Let the ddlist's style*/
|
||||
lv_obj_refresh_style(new_roller); /*To set scrollable size automatically*/
|
||||
@ -209,7 +209,7 @@ lv_label_align_t lv_roller_get_align(const lv_obj_t * roller)
|
||||
*/
|
||||
bool lv_roller_get_hor_fit(const lv_obj_t * roller)
|
||||
{
|
||||
return lv_page_get_scrl_hor_fit(roller);
|
||||
return lv_page_get_scrl_fit_left(roller);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -361,6 +361,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
refr_position(roller, false);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(roller);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
@ -382,12 +383,15 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Save the current value. Used to revert this state if ENER wont't be pressed*/
|
||||
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
#if USE_LV_GROUP
|
||||
/*Revert the original state*/
|
||||
if(ext->ddlist.sel_opt_id != ext->ddlist.sel_opt_id_ori) {
|
||||
ext->ddlist.sel_opt_id = ext->ddlist.sel_opt_id_ori;
|
||||
refr_position(roller, true);
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
|
||||
@ -402,9 +406,11 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/
|
||||
if(ext->ddlist.action) ext->ddlist.action(roller);
|
||||
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(roller);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
|
||||
#endif
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
|
@ -86,9 +86,9 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_BG, th->slider.bg);
|
||||
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_INDIC, th->slider.indic);
|
||||
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, th->slider.knob);
|
||||
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_BG, th->style.slider.bg);
|
||||
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_INDIC, th->style.slider.indic);
|
||||
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, th->style.slider.knob);
|
||||
} else {
|
||||
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, ext->style_knob);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#if USE_LV_SPINBOX != 0
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -64,19 +65,18 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Initialize the allocated 'ext'*/
|
||||
ext->ta.one_line = 1;
|
||||
ext->ta.pwd_mode = 0;
|
||||
ext->ta.accapted_chars = "1234567890+-.";
|
||||
ext->ta.accapted_chars = "1234567890+-. ";
|
||||
|
||||
ext->value = 0;
|
||||
ext->dec_point_pos = 2;
|
||||
ext->dec_point_pos = 0;
|
||||
ext->digit_count = 5;
|
||||
ext->step = 100;
|
||||
ext->digit_padding_left = 0;
|
||||
ext->step = 1;
|
||||
ext->range_max = 99999;
|
||||
ext->range_min = -99999;
|
||||
ext->value_changed_cb = NULL;
|
||||
|
||||
lv_ta_set_cursor_type(new_spinbox, LV_CURSOR_BLOCK | LV_CURSOR_HIDDEN); /*hidden by default*/
|
||||
lv_ta_set_cursor_pos(new_spinbox, 4);
|
||||
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_func(new_spinbox, lv_spinbox_signal);
|
||||
@ -87,9 +87,9 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_BG, th->spinbox.bg);
|
||||
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_CURSOR, th->spinbox.cursor);
|
||||
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_SB, th->spinbox.sb);
|
||||
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_BG, th->style.spinbox.bg);
|
||||
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_CURSOR, th->style.spinbox.cursor);
|
||||
lv_spinbox_set_style(new_spinbox, LV_SPINBOX_STYLE_SB, th->style.spinbox.sb);
|
||||
}
|
||||
}
|
||||
/*Copy an existing spinbox*/
|
||||
@ -189,13 +189,11 @@ void lv_spinbox_set_range(lv_obj_t * spinbox, int32_t range_min, int32_t range_m
|
||||
ext->range_max = range_max;
|
||||
ext->range_min = range_min;
|
||||
|
||||
if(ext->value > ext->range_max)
|
||||
{
|
||||
if(ext->value > ext->range_max) {
|
||||
ext->value = ext->range_max;
|
||||
lv_obj_invalidate(spinbox);
|
||||
}
|
||||
if(ext->value < ext->range_min)
|
||||
{
|
||||
if(ext->value < ext->range_min) {
|
||||
ext->value = ext->range_min;
|
||||
lv_obj_invalidate(spinbox);
|
||||
}
|
||||
@ -252,11 +250,9 @@ void lv_spinbox_step_next(lv_obj_t * spinbox)
|
||||
{
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||
|
||||
|
||||
if((ext->step / 10) < ext->range_max && (ext->step / 10) > ext->range_min && (ext->step / 10) > 0)
|
||||
{
|
||||
ext->step /= 10;
|
||||
}
|
||||
int32_t new_step = ext->step / 10;
|
||||
if((new_step) > 0) ext->step = new_step;
|
||||
else ext->step = 1;
|
||||
|
||||
lv_spinbox_updatevalue(spinbox);
|
||||
}
|
||||
@ -268,12 +264,10 @@ void lv_spinbox_step_next(lv_obj_t * spinbox)
|
||||
void lv_spinbox_step_previous(lv_obj_t * spinbox)
|
||||
{
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||
|
||||
|
||||
if((ext->step * 10) <= ext->range_max && (ext->step * 10) > ext->range_min && (ext->step * 10) > 0)
|
||||
{
|
||||
ext->step *= 10;
|
||||
}
|
||||
int32_t step_limit;
|
||||
step_limit = LV_MATH_MAX(ext->range_max, (ext->range_min < 0 ? (-ext->range_min) : ext->range_min));
|
||||
int32_t new_step = ext->step * 10;
|
||||
if(new_step <= step_limit) ext->step = new_step;
|
||||
|
||||
lv_spinbox_updatevalue(spinbox);
|
||||
}
|
||||
@ -286,20 +280,16 @@ void lv_spinbox_increment(lv_obj_t * spinbox)
|
||||
{
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||
|
||||
if(ext->value + ext->step <= ext->range_max)
|
||||
{
|
||||
if(ext->value + ext->step <= ext->range_max) {
|
||||
/*Special mode when zero crossing*/
|
||||
if((ext->value + ext->step) > 0 && ext->value < 0)
|
||||
{
|
||||
ext->value = -ext->value;
|
||||
}/*end special mode*/
|
||||
if((ext->value + ext->step) > 0 && ext->value < 0) ext->value = -ext->value;
|
||||
ext->value += ext->step;
|
||||
|
||||
if(ext->value_changed_cb != NULL)
|
||||
{
|
||||
ext->value_changed_cb(spinbox, ext->value);
|
||||
}
|
||||
} else {
|
||||
ext->value = ext->range_max;
|
||||
}
|
||||
|
||||
if(ext->value_changed_cb != NULL) ext->value_changed_cb(spinbox, ext->value);
|
||||
lv_spinbox_updatevalue(spinbox);
|
||||
}
|
||||
|
||||
@ -311,20 +301,15 @@ void lv_spinbox_decrement(lv_obj_t * spinbox)
|
||||
{
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||
|
||||
if(ext->value - ext->step >= ext->range_min)
|
||||
{
|
||||
if(ext->value - ext->step >= ext->range_min) {
|
||||
/*Special mode when zero crossing*/
|
||||
if((ext->value - ext->step) < 0 && ext->value > 0)
|
||||
{
|
||||
ext->value = -ext->value;
|
||||
}/*end special mode*/
|
||||
if((ext->value - ext->step) < 0 && ext->value > 0) ext->value = -ext->value;
|
||||
ext->value -= ext->step;
|
||||
} else {
|
||||
ext->value = ext->range_min;
|
||||
}
|
||||
|
||||
if(ext->value_changed_cb != NULL)
|
||||
{
|
||||
ext->value_changed_cb(spinbox, ext->value);
|
||||
}
|
||||
}
|
||||
if(ext->value_changed_cb != NULL) ext->value_changed_cb(spinbox, ext->value);
|
||||
lv_spinbox_updatevalue(spinbox);
|
||||
}
|
||||
|
||||
@ -366,65 +351,45 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
|
||||
if(buf->type[i] == NULL) break;
|
||||
}
|
||||
buf->type[i] = "lv_spinbox";
|
||||
}else if(sign == LV_SIGNAL_CONTROLL)
|
||||
{
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
||||
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
|
||||
if(c == LV_GROUP_KEY_RIGHT)
|
||||
{
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER)
|
||||
{
|
||||
if(c == LV_GROUP_KEY_RIGHT) {
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) lv_spinbox_increment(spinbox);
|
||||
else lv_spinbox_step_next(spinbox);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_LEFT) {
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) lv_spinbox_decrement(spinbox);
|
||||
else lv_spinbox_step_previous(spinbox);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_UP) {
|
||||
lv_spinbox_increment(spinbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_spinbox_step_next(spinbox);
|
||||
}
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_LEFT)
|
||||
{
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER)
|
||||
{
|
||||
else if(c == LV_GROUP_KEY_DOWN) {
|
||||
lv_spinbox_decrement(spinbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
else if(c == LV_GROUP_KEY_ENTER) {
|
||||
|
||||
if(ext->step > 1) {
|
||||
lv_spinbox_step_next(spinbox);
|
||||
} else {
|
||||
/*Restart from the MSB*/
|
||||
ext->step = 1;
|
||||
uint32_t i;
|
||||
for(i = 0; i < ext->digit_count; i++) {
|
||||
int32_t new_step = ext->step * 10;
|
||||
if(new_step >= ext->range_max) break;
|
||||
ext->step = new_step;
|
||||
}
|
||||
lv_spinbox_step_previous(spinbox);
|
||||
}
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_UP)
|
||||
{
|
||||
lv_spinbox_increment(spinbox);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_DOWN)
|
||||
{
|
||||
lv_spinbox_decrement(spinbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(c == LV_GROUP_KEY_ENTER)
|
||||
{
|
||||
int p = lv_ta_get_cursor_pos(spinbox);
|
||||
if(p == (1 + ext->digit_padding_left + ext->digit_count))
|
||||
{
|
||||
for(int i = 0; i < ext->digit_count; i++)
|
||||
lv_spinbox_step_previous(spinbox);
|
||||
} else
|
||||
{
|
||||
lv_spinbox_step_next(spinbox);
|
||||
}
|
||||
|
||||
|
||||
lv_spinbox_updatevalue(spinbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
lv_ta_add_char(spinbox, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -432,65 +397,75 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
|
||||
static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
|
||||
{
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||
int32_t v = ext->value;
|
||||
int32_t intDigits, decDigits;
|
||||
uint8_t dc = ext->digit_count;
|
||||
|
||||
intDigits = (ext->dec_point_pos==0) ? ext->digit_count : ext->dec_point_pos;
|
||||
decDigits = ext->digit_count - intDigits;
|
||||
char buf[LV_SPINBOX_MAX_DIGIT_COUNT + 8];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
char * buf_p = buf;
|
||||
|
||||
ext->digits[0] = v>=0 ? '+' : '-';
|
||||
/*Add the sign*/
|
||||
(*buf_p) = ext->value >= 0 ? '+' : '-';
|
||||
buf_p++;
|
||||
|
||||
int pl; /*padding left*/
|
||||
for(pl = 0; pl < ext->digit_padding_left; pl++)
|
||||
{
|
||||
ext->digits[1 + pl] = ' ';
|
||||
int i;
|
||||
/*padding left*/
|
||||
for(i = 0; i < ext->digit_padding_left; i++) {
|
||||
(*buf_p) = ' ';
|
||||
buf_p++;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
uint8_t digits[16];
|
||||
char digits[64];
|
||||
/*Convert the numbers to string (the sign is already handled so always covert positive number)*/
|
||||
lv_math_num_to_str(ext->value < 0 ? -ext->value : ext->value, digits);
|
||||
|
||||
if(v < 0)
|
||||
v = -v;
|
||||
for(i = 0; i < dc; i++)
|
||||
{
|
||||
digits[i] = v%10;
|
||||
v = v/10;
|
||||
/*Add leading zeros*/
|
||||
int lz_cnt = ext->digit_count - (int)strlen(digits);
|
||||
if(lz_cnt > 0) {
|
||||
for(i = strlen(digits); i >= 0; i--) {
|
||||
digits[i + lz_cnt] = digits[i];
|
||||
}
|
||||
for(i = 0; i < lz_cnt; i++) {
|
||||
digits[i] = '0';
|
||||
}
|
||||
}
|
||||
|
||||
int k;
|
||||
for(k = 0; k < intDigits; k++)
|
||||
{
|
||||
ext->digits[1 + pl + k] = '0' + digits[--i];
|
||||
int32_t intDigits;
|
||||
intDigits = (ext->dec_point_pos == 0) ? ext->digit_count : ext->dec_point_pos;
|
||||
|
||||
/*Add the decimal part*/
|
||||
for(i = 0; i < intDigits && digits[i] != '\0'; i++) {
|
||||
(*buf_p) = digits[i];
|
||||
buf_p++;
|
||||
}
|
||||
|
||||
ext->digits[1 + pl + intDigits] = '.';
|
||||
if(ext->dec_point_pos != 0) {
|
||||
/*Insert the decimal point*/
|
||||
(*buf_p) = '.';
|
||||
buf_p++;
|
||||
|
||||
int d;
|
||||
|
||||
for(d = 0; d < decDigits; d++)
|
||||
{
|
||||
ext->digits[1 + pl + intDigits + 1 + d] = '0' + digits[--i];
|
||||
for(/*Leave i*/ ;i < ext->digit_count && digits[i] != '\0'; i++) {
|
||||
(*buf_p) = digits[i];
|
||||
buf_p++;
|
||||
}
|
||||
}
|
||||
|
||||
ext->digits[1 + pl + intDigits + 1 + decDigits] = '\0';
|
||||
/*Refresh the text*/
|
||||
lv_ta_set_text(spinbox, (char*)buf);
|
||||
|
||||
lv_label_set_text(ext->ta.label, (char*)ext->digits);
|
||||
|
||||
/*Set the cursor position*/
|
||||
int32_t step = ext->step;
|
||||
uint8_t cPos = ext->digit_count + pl;
|
||||
uint8_t cur_pos = ext->digit_count;
|
||||
while(step >= 10)
|
||||
{
|
||||
step /= 10;
|
||||
cPos--;
|
||||
cur_pos--;
|
||||
}
|
||||
|
||||
if(cPos > pl + intDigits )
|
||||
{
|
||||
cPos ++;
|
||||
}
|
||||
if(cur_pos > intDigits ) cur_pos ++; /*Skip teh decimal point*/
|
||||
|
||||
lv_ta_set_cursor_pos(spinbox, cPos);
|
||||
cur_pos += ext->digit_padding_left;
|
||||
|
||||
lv_ta_set_cursor_pos(spinbox, cur_pos);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -50,11 +50,9 @@ typedef struct {
|
||||
int32_t range_max;
|
||||
int32_t range_min;
|
||||
int32_t step;
|
||||
uint8_t digit_count:4;
|
||||
uint8_t dec_point_pos:4; /*if 0, there is no separator and the number is an integer*/
|
||||
uint8_t digit_padding_left:4;
|
||||
uint8_t digit_padding_right:4;
|
||||
uint8_t digits[1+1+LV_SPINBOX_MAX_DIGIT_COUNT]; /*1 sign, 1 point, 16 num digits*/
|
||||
uint16_t digit_count:4;
|
||||
uint16_t dec_point_pos:4; /*if 0, there is no separator and the number is an integer*/
|
||||
uint16_t digit_padding_left:4;
|
||||
lv_spinbox_value_changed_cb_t value_changed_cb;
|
||||
} lv_spinbox_ext_t;
|
||||
|
||||
|
@ -88,10 +88,10 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_sw_set_style(new_sw, LV_SW_STYLE_BG, th->sw.bg);
|
||||
lv_sw_set_style(new_sw, LV_SW_STYLE_INDIC, th->sw.indic);
|
||||
lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_OFF, th->sw.knob_off);
|
||||
lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_ON, th->sw.knob_on);
|
||||
lv_sw_set_style(new_sw, LV_SW_STYLE_BG, th->style.sw.bg);
|
||||
lv_sw_set_style(new_sw, LV_SW_STYLE_INDIC, th->style.sw.indic);
|
||||
lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_OFF, th->style.sw.knob_off);
|
||||
lv_sw_set_style(new_sw, LV_SW_STYLE_KNOB_ON, th->style.sw.knob_on);
|
||||
} else {
|
||||
/*Let the slider' style*/
|
||||
}
|
||||
|
@ -108,6 +108,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->cursor.valid_x = 0;
|
||||
ext->one_line = 0;
|
||||
ext->label = NULL;
|
||||
ext->placeholder = NULL;
|
||||
|
||||
lv_obj_set_signal_func(new_ta, lv_ta_signal);
|
||||
lv_obj_set_signal_func(lv_page_get_scrl(new_ta), lv_ta_scrollable_signal);
|
||||
@ -115,6 +116,8 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new text area object*/
|
||||
if(copy == NULL) {
|
||||
lv_page_set_scrl_fit2(new_ta, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
||||
|
||||
ext->label = lv_label_create(new_ta, NULL);
|
||||
|
||||
lv_obj_set_design_func(ext->page.scrl, lv_ta_scrollable_design);
|
||||
@ -129,8 +132,8 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_ta_set_style(new_ta, LV_TA_STYLE_BG, th->ta.area);
|
||||
lv_ta_set_style(new_ta, LV_TA_STYLE_SB, th->ta.sb);
|
||||
lv_ta_set_style(new_ta, LV_TA_STYLE_BG, th->style.ta.area);
|
||||
lv_ta_set_style(new_ta, LV_TA_STYLE_SB, th->style.ta.sb);
|
||||
} else {
|
||||
lv_ta_set_style(new_ta, LV_TA_STYLE_BG, &lv_style_pretty);
|
||||
}
|
||||
@ -607,7 +610,7 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en)
|
||||
lv_coord_t font_h = lv_font_get_height(style_label->text.font);
|
||||
|
||||
ext->one_line = 1;
|
||||
lv_page_set_scrl_fit(ta, true, true);
|
||||
lv_page_set_scrl_fit2(ta, LV_FIT_TIGHT, LV_FIT_FLOOD);
|
||||
lv_obj_set_height(ta, font_h + (style_ta->body.padding.ver + style_scrl->body.padding.ver) * 2);
|
||||
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_EXPAND);
|
||||
if(ext->placeholder) lv_label_set_long_mode(ext->placeholder, LV_LABEL_LONG_EXPAND);
|
||||
@ -616,7 +619,7 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en)
|
||||
lv_style_t * style_ta = lv_obj_get_style(ta);
|
||||
|
||||
ext->one_line = 0;
|
||||
lv_page_set_scrl_fit(ta, false, true);
|
||||
lv_page_set_scrl_fit2(ta, LV_FIT_FLOOD, LV_FIT_TIGHT);
|
||||
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK);
|
||||
if(ext->placeholder) lv_label_set_long_mode(ext->placeholder, LV_LABEL_LONG_BREAK);
|
||||
|
||||
@ -645,19 +648,17 @@ void lv_ta_set_text_align(lv_obj_t * ta, lv_label_align_t align)
|
||||
/*Normal left align. Just let the text expand*/
|
||||
if(align == LV_LABEL_ALIGN_LEFT) {
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_EXPAND);
|
||||
lv_page_set_scrl_fit(ta, true, false);
|
||||
lv_page_set_scrl_fit2(ta, LV_FIT_TIGHT, LV_FIT_FLOOD);
|
||||
lv_label_set_align(label, align);
|
||||
|
||||
}
|
||||
/*Else use fix label width equal to the Text area width*/
|
||||
else {
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_CROP);
|
||||
lv_page_set_scrl_fit(ta, false, false);
|
||||
lv_page_set_scrl_width(ta, 1); /*To refresh the scrollable's width*/
|
||||
lv_page_set_scrl_fit2(ta, LV_FIT_FLOOD, LV_FIT_FLOOD);
|
||||
lv_label_set_align(label, align);
|
||||
|
||||
lv_style_t * bg_style = lv_ta_get_style(ta, LV_TA_STYLE_BG);
|
||||
lv_obj_set_width(label, lv_obj_get_width(ta) - 2 * bg_style->body.padding.hor);
|
||||
lv_obj_set_width(label, lv_page_get_fit_width(ta));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1230,13 +1231,14 @@ static void cursor_blink_anim(lv_obj_t * ta, uint8_t show)
|
||||
if(ext->cursor.type != LV_CURSOR_NONE &&
|
||||
(ext->cursor.type & LV_CURSOR_HIDDEN) == 0)
|
||||
{
|
||||
lv_disp_t * disp = lv_obj_get_disp(ta);
|
||||
lv_area_t area_tmp;
|
||||
lv_area_copy(&area_tmp, &ext->cursor.area);
|
||||
area_tmp.x1 += ext->label->coords.x1;
|
||||
area_tmp.y1 += ext->label->coords.y1;
|
||||
area_tmp.x2 += ext->label->coords.x1;
|
||||
area_tmp.y2 += ext->label->coords.y1;
|
||||
lv_inv_area(&area_tmp);
|
||||
lv_inv_area(disp, &area_tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1421,13 +1423,14 @@ static void refr_cursor_area(lv_obj_t * ta)
|
||||
}
|
||||
|
||||
/*Save the new area*/
|
||||
lv_disp_t * disp = lv_obj_get_disp(ta);
|
||||
lv_area_t area_tmp;
|
||||
lv_area_copy(&area_tmp, &ext->cursor.area);
|
||||
area_tmp.x1 += ext->label->coords.x1;
|
||||
area_tmp.y1 += ext->label->coords.y1;
|
||||
area_tmp.x2 += ext->label->coords.x1;
|
||||
area_tmp.y2 += ext->label->coords.y1;
|
||||
lv_inv_area(&area_tmp);
|
||||
lv_inv_area(disp, &area_tmp);
|
||||
|
||||
lv_area_copy(&ext->cursor.area, &cur_area);
|
||||
|
||||
@ -1436,7 +1439,7 @@ static void refr_cursor_area(lv_obj_t * ta)
|
||||
area_tmp.y1 += ext->label->coords.y1;
|
||||
area_tmp.x2 += ext->label->coords.x1;
|
||||
area_tmp.y2 += ext->label->coords.y1;
|
||||
lv_inv_area(&area_tmp);
|
||||
lv_inv_area(disp, &area_tmp);
|
||||
}
|
||||
|
||||
static void placeholder_update(lv_obj_t * ta)
|
||||
@ -1470,9 +1473,12 @@ static void update_cursor_position_on_click(lv_obj_t * ta, lv_indev_t * click_so
|
||||
|
||||
lv_obj_get_coords(ext->label, &label_coords);
|
||||
|
||||
lv_point_t point_act;
|
||||
lv_indev_get_point(click_source, &point_act);
|
||||
if(point_act.x < 0 || point_act.y < 0) return; /*Ignore event from keypad*/
|
||||
lv_point_t relative_position;
|
||||
relative_position.x = click_source->proc.act_point.x - label_coords.x1;
|
||||
relative_position.y = click_source->proc.act_point.y - label_coords.y1;
|
||||
relative_position.x = point_act.x - label_coords.x1;
|
||||
relative_position.y = point_act.y - label_coords.y1;
|
||||
|
||||
lv_coord_t label_width = lv_obj_get_width(ext->label);
|
||||
|
||||
|
@ -89,11 +89,11 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_table_set_style(new_table, LV_TABLE_STYLE_BG, th->table.bg);
|
||||
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL1, th->table.cell);
|
||||
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL2, th->table.cell);
|
||||
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL3, th->table.cell);
|
||||
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL4, th->table.cell);
|
||||
lv_table_set_style(new_table, LV_TABLE_STYLE_BG, th->style.table.bg);
|
||||
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL1, th->style.table.cell);
|
||||
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL2, th->style.table.cell);
|
||||
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL3, th->style.table.cell);
|
||||
lv_table_set_style(new_table, LV_TABLE_STYLE_CELL4, th->style.table.cell);
|
||||
} else {
|
||||
lv_table_set_style(new_table, LV_TABLE_STYLE_BG, &lv_style_plain_color);
|
||||
}
|
||||
|
@ -106,7 +106,8 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->tab_name_ptr[0] = "";
|
||||
ext->tab_cnt = 0;
|
||||
|
||||
lv_obj_set_size(new_tabview, LV_HOR_RES, LV_VER_RES);
|
||||
lv_disp_t * disp = lv_obj_get_disp(new_tabview);
|
||||
lv_obj_set_size(new_tabview, lv_disp_get_hor_res(disp), lv_disp_get_ver_res(disp));
|
||||
|
||||
ext->btns = lv_btnm_create(new_tabview, NULL);
|
||||
lv_obj_set_height(ext->btns, 3 * LV_DPI / 4);
|
||||
@ -120,22 +121,22 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
lv_obj_set_click(ext->indic, false);
|
||||
|
||||
ext->content = lv_cont_create(new_tabview, NULL);
|
||||
lv_cont_set_fit(ext->content, true, false);
|
||||
lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE);
|
||||
lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T);
|
||||
lv_cont_set_style(ext->content, &lv_style_transp_tight);
|
||||
lv_obj_set_height(ext->content, LV_VER_RES - lv_obj_get_height(ext->btns));
|
||||
lv_obj_set_height(ext->content, lv_obj_get_height(new_tabview) - lv_obj_get_height(ext->btns));
|
||||
lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, th->tabview.bg);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, th->tabview.indic);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, th->tabview.btn.bg);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_REL, th->tabview.btn.rel);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_PR, th->tabview.btn.pr);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, th->tabview.btn.tgl_rel);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, th->tabview.btn.tgl_pr);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, th->style.tabview.bg);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_INDIC, th->style.tabview.indic);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, th->style.tabview.btn.bg);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_REL, th->style.tabview.btn.rel);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_PR, th->style.tabview.btn.pr);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, th->style.tabview.btn.tgl_rel);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, th->style.tabview.btn.tgl_pr);
|
||||
} else {
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, &lv_style_plain);
|
||||
lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, &lv_style_transp);
|
||||
@ -621,12 +622,14 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
/*With ENCODER select the first button only in edit mode*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(tabview);
|
||||
if(lv_group_get_editing(g)) {
|
||||
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
|
||||
btnm_ext->btn_id_pr = 0;
|
||||
lv_obj_invalidate(ext->btns);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
|
||||
btnm_ext->btn_id_pr = 0;
|
||||
|
@ -89,15 +89,15 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new tileview*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_tileview, LV_HOR_RES, LV_VER_RES);
|
||||
lv_obj_set_size(new_tileview, LV_DPI * 3, LV_DPI * 3);
|
||||
lv_obj_set_drag_throw(lv_page_get_scrl(new_tileview), false);
|
||||
lv_page_set_scrl_fit(new_tileview, true, true);
|
||||
lv_page_set_scrl_fit(new_tileview, LV_FIT_TIGHT);
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_page_set_style(new_tileview, LV_PAGE_STYLE_BG, th->tileview.bg);
|
||||
lv_page_set_style(new_tileview, LV_PAGE_STYLE_SCRL, th->tileview.scrl);
|
||||
lv_page_set_style(new_tileview, LV_PAGE_STYLE_SB, th->tileview.sb);
|
||||
lv_page_set_style(new_tileview, LV_PAGE_STYLE_BG, th->style.tileview.bg);
|
||||
lv_page_set_style(new_tileview, LV_PAGE_STYLE_SCRL, th->style.tileview.scrl);
|
||||
lv_page_set_style(new_tileview, LV_PAGE_STYLE_SB, th->style.tileview.sb);
|
||||
} else {
|
||||
lv_page_set_style(new_tileview, LV_PAGE_STYLE_BG, &lv_style_transp_tight);
|
||||
lv_page_set_style(new_tileview, LV_PAGE_STYLE_SCRL, &lv_style_transp_tight);
|
||||
@ -343,14 +343,14 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void
|
||||
|
||||
/*Set horizontal drag constraint if no vertical constraint an dragged to valid x direction */
|
||||
if(ext->drag_ver == 0 &&
|
||||
((ext->drag_right_en && indev->proc.drag_sum.x <= -LV_INDEV_DRAG_LIMIT) ||
|
||||
(ext->drag_left_en && indev->proc.drag_sum.x >= LV_INDEV_DRAG_LIMIT))) {
|
||||
((ext->drag_right_en && indev->proc.types.pointer.drag_sum.x <= -LV_INDEV_DRAG_LIMIT) ||
|
||||
(ext->drag_left_en && indev->proc.types.pointer.drag_sum.x >= LV_INDEV_DRAG_LIMIT))) {
|
||||
ext->drag_hor = 1;
|
||||
}
|
||||
/*Set vertical drag constraint if no horizontal constraint an dragged to valid y direction */
|
||||
if(ext->drag_hor == 0 &&
|
||||
((ext->drag_bottom_en && indev->proc.drag_sum.y <= -LV_INDEV_DRAG_LIMIT) ||
|
||||
(ext->drag_top_en && indev->proc.drag_sum.y >= LV_INDEV_DRAG_LIMIT))) {
|
||||
((ext->drag_bottom_en && indev->proc.types.pointer.drag_sum.y <= -LV_INDEV_DRAG_LIMIT) ||
|
||||
(ext->drag_top_en && indev->proc.types.pointer.drag_sum.y >= LV_INDEV_DRAG_LIMIT))) {
|
||||
ext->drag_ver = 1;
|
||||
}
|
||||
|
||||
@ -369,7 +369,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void
|
||||
lv_coord_t h = lv_obj_get_height(tileview);
|
||||
lv_coord_t w = lv_obj_get_width(tileview);
|
||||
if(ext->drag_top_en == 0) {
|
||||
if(y > -(ext->act_id.y * h) && indev->proc.vect.y > 0 && ext->drag_hor == 0) {
|
||||
if(y > -(ext->act_id.y * h) && indev->proc.types.pointer.vect.y > 0 && ext->drag_hor == 0) {
|
||||
if(ext->page.edge_flash.enabled &&
|
||||
ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 &&
|
||||
ext->page.edge_flash.top_ip == 0 && ext->page.edge_flash.bottom_ip == 0) {
|
||||
@ -380,7 +380,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void
|
||||
lv_obj_set_y(scrl, -ext->act_id.y * h);
|
||||
}
|
||||
}
|
||||
if(ext->drag_bottom_en == 0 && indev->proc.vect.y < 0 && ext->drag_hor == 0) {
|
||||
if(ext->drag_bottom_en == 0 && indev->proc.types.pointer.vect.y < 0 && ext->drag_hor == 0) {
|
||||
if(y < -(ext->act_id.y * h)) {
|
||||
if(ext->page.edge_flash.enabled &&
|
||||
ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 &&
|
||||
@ -393,7 +393,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void
|
||||
lv_obj_set_y(scrl, -ext->act_id.y * h);
|
||||
}
|
||||
if(ext->drag_left_en == 0) {
|
||||
if(x > -(ext->act_id.x * w) && indev->proc.vect.x > 0 && ext->drag_ver == 0) {
|
||||
if(x > -(ext->act_id.x * w) && indev->proc.types.pointer.vect.x > 0 && ext->drag_ver == 0) {
|
||||
if(ext->page.edge_flash.enabled &&
|
||||
ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 &&
|
||||
ext->page.edge_flash.top_ip == 0 && ext->page.edge_flash.bottom_ip == 0) {
|
||||
@ -404,7 +404,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void
|
||||
lv_obj_set_x(scrl, -ext->act_id.x * w);
|
||||
}
|
||||
}
|
||||
if(ext->drag_right_en == 0 && indev->proc.vect.x < 0 && ext->drag_ver == 0) {
|
||||
if(ext->drag_right_en == 0 && indev->proc.types.pointer.vect.x < 0 && ext->drag_ver == 0) {
|
||||
if(x < -(ext->act_id.x * w)) {
|
||||
if(ext->page.edge_flash.enabled &&
|
||||
ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 &&
|
||||
@ -475,14 +475,14 @@ static lv_res_t element_signal_func(lv_obj_t * element, lv_signal_t sign, void *
|
||||
* let the tileview to finish the move.*/
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_tileview_ext_t * ext = lv_obj_get_ext_attr(tileview);
|
||||
if(indev->proc.drag_in_prog && (ext->drag_hor || ext->drag_ver)) {
|
||||
if(lv_indev_is_dragging(indev) && (ext->drag_hor || ext->drag_ver)) {
|
||||
|
||||
lv_obj_t * drag_obj = element;
|
||||
while(lv_obj_get_drag_parent(drag_obj)) {
|
||||
drag_obj = lv_obj_get_parent(drag_obj);
|
||||
if(drag_obj == NULL) break;
|
||||
}
|
||||
indev->proc.drag_in_prog = 0;
|
||||
indev->proc.types.pointer.drag_in_prog = 0;
|
||||
if(drag_obj) drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, NULL);
|
||||
}
|
||||
|
||||
@ -506,8 +506,8 @@ static void drag_end_handler(lv_obj_t * tileview)
|
||||
lv_obj_t * scrl = lv_page_get_scrl(tileview);
|
||||
lv_point_t p;
|
||||
|
||||
p.x = - (scrl->coords.x1 - LV_HOR_RES / 2);
|
||||
p.y = - (scrl->coords.y1 - LV_VER_RES / 2);
|
||||
p.x = - (scrl->coords.x1 - lv_obj_get_width(tileview) / 2);
|
||||
p.y = - (scrl->coords.y1 - lv_obj_get_height(tileview) / 2);
|
||||
|
||||
/*From the drag vector (drag throw) predict the end position*/
|
||||
if(ext->drag_hor) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#if USE_LV_WIN != 0
|
||||
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_core/lv_disp.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -70,7 +71,10 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
|
||||
/*Init the new window object*/
|
||||
if(copy == NULL) {
|
||||
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
|
||||
lv_disp_t * disp = lv_obj_get_disp(new_win);
|
||||
lv_coord_t hres = lv_disp_get_hor_res(disp);
|
||||
lv_coord_t vres = lv_disp_get_ver_res(disp);
|
||||
lv_obj_set_size(new_win, hres, vres);
|
||||
lv_obj_set_pos(new_win, 0, 0);
|
||||
lv_obj_set_style(new_win, &lv_style_pretty);
|
||||
|
||||
@ -92,13 +96,13 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Set the default styles*/
|
||||
lv_theme_t * th = lv_theme_get_current();
|
||||
if(th) {
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_BG, th->win.bg);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_SB, th->win.sb);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, th->win.header);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_BG, th->win.content.bg);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_SCRL, th->win.content.scrl);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_BTN_REL, th->win.btn.rel);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_BTN_PR, th->win.btn.pr);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_BG, th->style.win.bg);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_SB, th->style.win.sb);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_HEADER, th->style.win.header);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_BG, th->style.win.content.bg);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_SCRL, th->style.win.content.scrl);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_BTN_REL, th->style.win.btn.rel);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_BTN_PR, th->style.win.btn.pr);
|
||||
} else {
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_BG, &lv_style_plain);
|
||||
lv_win_set_style(new_win, LV_WIN_STYLE_CONTENT_BG, &lv_style_plain);
|
||||
@ -107,7 +111,6 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
}
|
||||
|
||||
lv_obj_set_signal_func(new_win, lv_win_signal);
|
||||
lv_obj_set_size(new_win, LV_HOR_RES, LV_VER_RES);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
|
@ -24,9 +24,7 @@
|
||||
**********************/
|
||||
static void disp_init(void);
|
||||
|
||||
static void disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
|
||||
static void disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
|
||||
static void disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
|
||||
static void disp_flush(lv_disp_t * disp, const lv_area_t * area, lv_color_t * color_p);
|
||||
#if USE_LV_GPU
|
||||
static void mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
|
||||
static void mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color);
|
||||
@ -51,6 +49,41 @@ void lv_port_disp_init(void)
|
||||
* -----------------------*/
|
||||
disp_init();
|
||||
|
||||
/*-----------------------------
|
||||
* Create a buffer for drawing
|
||||
*----------------------------*/
|
||||
|
||||
/* LittlevGL requires a buffer where it draw the objects. The buffer's has to be greater than 1 display row
|
||||
*
|
||||
* There are three buffering configurations:
|
||||
* 1. Create ONE buffer some rows: LittlevGL will draw the display's content here and writes it to your display
|
||||
* 2. Create TWO buffer some rows: LittlevGL will draw the display's content to a buffer and writes it your display.
|
||||
* You should use DMA to write the buffer's content to the display.
|
||||
* It will enable LittlevGL to draw the next part of the screen to the other buffer while
|
||||
* the data is being sent form the first buffer. It makes rendering and flushing parallel.
|
||||
* 3. Create TWO screen buffer: Similar to 2) but the buffer have to be screen sized. When LittlevGL is ready it will give the
|
||||
* whole frame to display. This way you only need to change the frame buffer's address instead of
|
||||
* copying the pixels.
|
||||
* */
|
||||
|
||||
/* Example for 1) */
|
||||
static lv_disp_buf_t disp_buf_1;
|
||||
static lv_color_t buf1_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/
|
||||
lv_disp_buf_init(&disp_buf_1, buf1_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
|
||||
|
||||
/* Example for 2) */
|
||||
static lv_disp_buf_t disp_buf_2;
|
||||
static lv_color_t buf2_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/
|
||||
static lv_color_t buf2_2[LV_HOR_RES_MAX * 10]; /*An other buffer for 10 rows*/
|
||||
lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
|
||||
|
||||
/* Example for 3) */
|
||||
static lv_disp_buf_t disp_buf_3;
|
||||
static lv_color_t buf3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*A screen sized buffer*/
|
||||
static lv_color_t buf3_2[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*An other screen sized buffer*/
|
||||
lv_disp_buf_init(&disp_buf_3, buf3_1, buf3_2, LV_HOR_RES_MAX * LV_VER_RES_MAX); /*Initialize the display buffer*/
|
||||
|
||||
|
||||
/*-----------------------------------
|
||||
* Register the display in LittlevGL
|
||||
*----------------------------------*/
|
||||
@ -60,14 +93,15 @@ void lv_port_disp_init(void)
|
||||
|
||||
/*Set up the functions to access to your display*/
|
||||
|
||||
/*Used in buffered mode (LV_VDB_SIZE != 0 in lv_conf.h)*/
|
||||
disp_drv.disp_flush = disp_flush;
|
||||
/*Set the resolution of the display*/
|
||||
disp_drv.hor_res = 480;
|
||||
disp_drv.ver_res = 320;
|
||||
|
||||
/*Used in unbuffered mode (LV_VDB_SIZE == 0 in lv_conf.h)*/
|
||||
disp_drv.disp_fill = disp_fill;
|
||||
/*Used to copy the buffer's content to the display*/
|
||||
disp_drv.flush_cb = disp_flush;
|
||||
|
||||
/*Used in unbuffered mode (LV_VDB_SIZE == 0 in lv_conf.h)*/
|
||||
disp_drv.disp_map = disp_map;
|
||||
/*Set a display buffer*/
|
||||
disp_drv.buffer = &disp_buf_2;
|
||||
|
||||
#if USE_LV_GPU
|
||||
/*Optionally add functions to access the GPU. (Only in buffered mode, LV_VDB_SIZE != 0)*/
|
||||
@ -95,16 +129,15 @@ static void disp_init(void)
|
||||
|
||||
/* Flush the content of the internal buffer the specific area on the display
|
||||
* You can use DMA or any hardware acceleration to do this operation in the background but
|
||||
* 'lv_flush_ready()' has to be called when finished
|
||||
* This function is required only when LV_VDB_SIZE != 0 in lv_conf.h*/
|
||||
static void disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p)
|
||||
* 'lv_disp_flush_ready()' has to be called when finished. */
|
||||
static void disp_flush(lv_disp_t * disp, const lv_area_t * area, lv_color_t * color_p)
|
||||
{
|
||||
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
for(y = y1; y <= y2; y++) {
|
||||
for(x = x1; x <= x2; x++) {
|
||||
for(y = area->y1; y <= area->y2; y++) {
|
||||
for(x = area->x1; x <= area->x2; x++) {
|
||||
/* Put a pixel to the display. For example: */
|
||||
/* put_px(x, y, *color_p)*/
|
||||
color_p++;
|
||||
@ -113,46 +146,10 @@ static void disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_
|
||||
|
||||
/* IMPORTANT!!!
|
||||
* Inform the graphics library that you are ready with the flushing*/
|
||||
lv_flush_ready();
|
||||
lv_disp_flush_ready(disp);
|
||||
}
|
||||
|
||||
|
||||
/* Write a pixel array (called 'map') to the a specific area on the display
|
||||
* This function is required only when LV_VDB_SIZE == 0 in lv_conf.h*/
|
||||
static void disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p)
|
||||
{
|
||||
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
for(y = y1; y <= y2; y++) {
|
||||
for(x = x1; x <= x2; x++) {
|
||||
/* Put a pixel to the display. For example: */
|
||||
/* put_px(x, y, *color_p)*/
|
||||
color_p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Write a pixel array (called 'map') to the a specific area on the display
|
||||
* This function is required only when LV_VDB_SIZE == 0 in lv_conf.h*/
|
||||
static void disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color)
|
||||
{
|
||||
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
for(y = y1; y <= y2; y++) {
|
||||
for(x = x1; x <= x2; x++) {
|
||||
/* Put a pixel to the display. For example: */
|
||||
/* put_px(x, y, *color)*/
|
||||
}
|
||||
}
|
||||
|
||||
(void)color; /*Just to avid warnings*/
|
||||
}
|
||||
|
||||
/*OPTIONAL: GPU INTERFACE*/
|
||||
#if USE_LV_GPU
|
||||
|
||||
|
@ -24,25 +24,25 @@
|
||||
**********************/
|
||||
|
||||
static void touchpad_init(void);
|
||||
static bool touchpad_read(lv_indev_data_t * data);
|
||||
static bool touchpad_read(lv_indev_t * indev, lv_indev_data_t * data);
|
||||
static bool touchpad_is_pressed(void);
|
||||
static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y);
|
||||
|
||||
static void mouse_init(void);
|
||||
static bool mouse_read(lv_indev_data_t * data);
|
||||
static bool mouse_read(lv_indev_t * indev, lv_indev_data_t * data);
|
||||
static bool mouse_is_pressed(void);
|
||||
static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y);
|
||||
|
||||
static void keypad_init(void);
|
||||
static bool keypad_read(lv_indev_data_t * data);
|
||||
static bool keypad_read(lv_indev_t * indev, lv_indev_data_t * data);
|
||||
static uint32_t keypad_get_key(void);
|
||||
|
||||
static void encoder_init(void);
|
||||
static bool encoder_read(lv_indev_data_t * data);
|
||||
static bool encoder_read(lv_indev_t * indev, lv_indev_data_t * data);
|
||||
static void encoder_handler(void);
|
||||
|
||||
static void button_init(void);
|
||||
static bool button_read(lv_indev_data_t * data);
|
||||
static bool button_read(lv_indev_t * indev, lv_indev_data_t * data);
|
||||
static int8_t button_get_pressed_id(void);
|
||||
static bool button_is_pressed(uint8_t id);
|
||||
|
||||
@ -92,7 +92,7 @@ void lv_port_indev_init(void)
|
||||
/*Register a touchpad input device*/
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read = touchpad_read;
|
||||
indev_drv.read_cb = touchpad_read;
|
||||
indev_touchpad = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
/*------------------
|
||||
@ -105,11 +105,11 @@ void lv_port_indev_init(void)
|
||||
/*Register a mouse input device*/
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read = mouse_read;
|
||||
indev_drv.read_cb = mouse_read;
|
||||
indev_mouse = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
/*Set cursor. For simplicity set a HOME symbol now.*/
|
||||
lv_obj_t * mouse_cursor = lv_img_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * mouse_cursor = lv_img_create(lv_disp_get_scr_act(NULL), NULL);
|
||||
lv_img_set_src(mouse_cursor, SYMBOL_HOME);
|
||||
lv_indev_set_cursor(indev_mouse, mouse_cursor);
|
||||
|
||||
@ -123,7 +123,7 @@ void lv_port_indev_init(void)
|
||||
/*Register a keypad input device*/
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_KEYPAD;
|
||||
indev_drv.read = keypad_read;
|
||||
indev_drv.read_cb = keypad_read;
|
||||
indev_keypad = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
/* Later you should create group(s) with `lv_group_t * group = lv_group_create()`,
|
||||
@ -141,7 +141,7 @@ void lv_port_indev_init(void)
|
||||
/*Register a encoder input device*/
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_KEYPAD;
|
||||
indev_drv.read = encoder_read;
|
||||
indev_drv.read_cb = encoder_read;
|
||||
indev_encoder = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
/* Later you should create group(s) with `lv_group_t * group = lv_group_create()`,
|
||||
@ -159,7 +159,7 @@ void lv_port_indev_init(void)
|
||||
/*Register a button input device*/
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_BUTTON;
|
||||
indev_drv.read = button_read;
|
||||
indev_drv.read_cb = button_read;
|
||||
indev_button = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
/*Assign buttons to points on the screen*/
|
||||
@ -187,7 +187,7 @@ static void touchpad_init(void)
|
||||
}
|
||||
|
||||
/* Will be called by the library to read the touchpad */
|
||||
static bool touchpad_read(lv_indev_data_t * data)
|
||||
static bool touchpad_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
{
|
||||
static lv_coord_t last_x = 0;
|
||||
static lv_coord_t last_y = 0;
|
||||
@ -237,7 +237,7 @@ static void mouse_init(void)
|
||||
}
|
||||
|
||||
/* Will be called by the library to read the mouse */
|
||||
static bool mouse_read(lv_indev_data_t * data)
|
||||
static bool mouse_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
{
|
||||
/*Get the current x and y coordinates*/
|
||||
mouse_get_xy(&data->point.x, &data->point.y);
|
||||
@ -281,7 +281,7 @@ static void keypad_init(void)
|
||||
}
|
||||
|
||||
/* Will be called by the library to read the mouse */
|
||||
static bool keypad_read(lv_indev_data_t * data)
|
||||
static bool keypad_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
{
|
||||
static uint32_t last_key = 0;
|
||||
|
||||
@ -342,7 +342,7 @@ static void encoder_init(void)
|
||||
}
|
||||
|
||||
/* Will be called by the library to read the encoder */
|
||||
static bool encoder_read(lv_indev_data_t * data)
|
||||
static bool encoder_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
{
|
||||
|
||||
data->enc_diff = encoder_diff;
|
||||
@ -373,7 +373,7 @@ static void button_init(void)
|
||||
}
|
||||
|
||||
/* Will be called by the library to read the button */
|
||||
static bool button_read(lv_indev_data_t * data)
|
||||
static bool button_read(lv_indev_t * indev, lv_indev_data_t * data)
|
||||
{
|
||||
|
||||
static uint8_t last_btn = 0;
|
||||
@ -389,7 +389,7 @@ static bool button_read(lv_indev_data_t * data)
|
||||
}
|
||||
|
||||
/*Save the last pressed button's ID*/
|
||||
data->btn = last_btn;
|
||||
data->btn_id = last_btn;
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
|
@ -34,10 +34,8 @@ static lv_theme_t * current_theme;
|
||||
* This way the theme styles will always point to the same memory address even after theme is change.
|
||||
* (The pointers in the theme points to the styles declared by the theme itself) */
|
||||
|
||||
/* Store the styles in this array.
|
||||
* Can't determine the size in compile time because sizeof is not evaluated (should be `sizeof(lv_theme_t) / sizeof(lv_style_t*)`).
|
||||
* Error will be generated in run time if too small.*/
|
||||
static lv_style_t th_styles[120];
|
||||
/* Store the styles in this array. */
|
||||
static lv_style_t th_styles[LV_THEME_STYLE_COUNT];
|
||||
static bool inited = false;
|
||||
static lv_theme_t current_theme;
|
||||
#endif
|
||||
@ -60,18 +58,12 @@ void lv_theme_set_current(lv_theme_t * th)
|
||||
#if LV_THEME_LIVE_UPDATE == 0
|
||||
current_theme = th;
|
||||
#else
|
||||
uint32_t style_num = sizeof(lv_theme_t) / sizeof(lv_style_t *); /*Number of styles in a theme*/
|
||||
uint32_t style_num = sizeof(th->style) / sizeof(lv_style_t *); /*Number of styles in a theme*/
|
||||
|
||||
if(!inited) {
|
||||
/*It's not sure `th_styles` is big enough. Check it now!*/
|
||||
if(style_num > sizeof(th_styles) / sizeof(lv_style_t)) {
|
||||
LV_LOG_ERROR("Themes: th_styles array is too small. Increase it's size!");
|
||||
while(1);
|
||||
}
|
||||
|
||||
/*Initialize the style pointers `current_theme` to point to the `th_styles` style array */
|
||||
uint16_t i;
|
||||
lv_style_t ** cur_th_style_p = (lv_style_t **) ¤t_theme;
|
||||
lv_style_t ** cur_th_style_p = (lv_style_t **) ¤t_theme.style;
|
||||
for(i = 0; i < style_num; i++) {
|
||||
uintptr_t adr = (uintptr_t)&th_styles[i];
|
||||
memcpy(&cur_th_style_p[i], &adr, sizeof(lv_style_t *));
|
||||
@ -82,14 +74,24 @@ void lv_theme_set_current(lv_theme_t * th)
|
||||
|
||||
/*Copy the styles pointed by the new theme to the `th_styles` style array*/
|
||||
uint16_t i;
|
||||
lv_style_t ** th_style = (lv_style_t **) th;
|
||||
lv_style_t ** th_style = (lv_style_t **) &th->style;
|
||||
for(i = 0; i < style_num; i++) {
|
||||
uintptr_t s = (uintptr_t)th_style[i];
|
||||
if(s) memcpy(&th_styles[i], (void *)s, sizeof(lv_style_t));
|
||||
}
|
||||
|
||||
#if USE_LV_GROUP
|
||||
/*Copy group style modification callback functions*/
|
||||
memcpy(¤t_theme.group, &th->group, sizeof(th->group));
|
||||
#endif
|
||||
|
||||
/*Let the object know their style might change*/
|
||||
lv_obj_report_style_mod(NULL);
|
||||
|
||||
#if USE_LV_GROUP
|
||||
lv_group_report_style_mod(NULL);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../lv_core/lv_style.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -30,6 +31,7 @@ extern "C" {
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
struct {
|
||||
lv_style_t *bg;
|
||||
lv_style_t *panel;
|
||||
|
||||
@ -288,6 +290,15 @@ typedef struct {
|
||||
lv_style_t *pr;
|
||||
} btn;
|
||||
} win;
|
||||
#endif
|
||||
} style;
|
||||
|
||||
#if USE_LV_GROUP
|
||||
struct
|
||||
{
|
||||
lv_group_style_mod_func_t style_mod;
|
||||
lv_group_style_mod_func_t style_mod_edit;
|
||||
} group;
|
||||
#endif
|
||||
} lv_theme_t;
|
||||
|
||||
@ -312,6 +323,9 @@ lv_theme_t * lv_theme_get_current(void);
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/* Returns number of styles within the `lv_theme_t` structure. */
|
||||
#define LV_THEME_STYLE_COUNT (sizeof(((lv_theme_t *)0)->style) / sizeof(lv_style_t *))
|
||||
|
||||
/**********************
|
||||
* POST INCLUDE
|
||||
*********************/
|
||||
|
@ -114,6 +114,7 @@ static void basic_init(void)
|
||||
panel.body.border.width = 2;
|
||||
panel.body.border.opa = LV_OPA_60;
|
||||
panel.text.color = lv_color_hsv_to_rgb(_hue, 8, 96);
|
||||
panel.image.color = lv_color_hsv_to_rgb(_hue, 8, 96);
|
||||
panel.line.color = lv_color_hsv_to_rgb(_hue, 20, 70);
|
||||
|
||||
/*Scrollbar*/
|
||||
@ -129,15 +130,15 @@ static void basic_init(void)
|
||||
sb.body.padding.ver = 1;
|
||||
sb.body.padding.inner = LV_DPI / 15; /*Scrollbar width*/
|
||||
|
||||
theme.bg = &bg;
|
||||
theme.panel = &panel;
|
||||
theme.style.bg = &bg;
|
||||
theme.style.panel = &panel;
|
||||
|
||||
}
|
||||
|
||||
static void cont_init(void)
|
||||
{
|
||||
#if USE_LV_CONT != 0
|
||||
theme.cont = &panel;
|
||||
theme.style.cont = &panel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -156,6 +157,7 @@ static void btn_init(void)
|
||||
btn_rel.body.padding.inner = LV_DPI / 10;
|
||||
btn_rel.text.color = lv_color_hsv_to_rgb(_hue, 8, 96);
|
||||
btn_rel.text.font = _font;
|
||||
btn_rel.image.color = lv_color_hsv_to_rgb(_hue, 8, 96);
|
||||
|
||||
lv_style_copy(&btn_pr, &btn_rel);
|
||||
btn_pr.body.opa = LV_OPA_COVER;
|
||||
@ -165,6 +167,7 @@ static void btn_init(void)
|
||||
btn_pr.body.border.opa = LV_OPA_60;
|
||||
btn_pr.text.font = _font;
|
||||
btn_pr.text.color = lv_color_hsv_to_rgb(_hue, 10, 100);
|
||||
btn_pr.image.color = lv_color_hsv_to_rgb(_hue, 10, 100);
|
||||
|
||||
lv_style_copy(&btn_trel, &btn_pr);
|
||||
btn_trel.body.opa = LV_OPA_COVER;
|
||||
@ -175,6 +178,7 @@ static void btn_init(void)
|
||||
btn_trel.body.border.color = lv_color_hsv_to_rgb(_hue, 80, 90);
|
||||
btn_trel.text.font = _font;
|
||||
btn_trel.text.color = lv_color_hsv_to_rgb(_hue, 0, 100);
|
||||
btn_trel.image.color = lv_color_hsv_to_rgb(_hue, 0, 100);
|
||||
|
||||
lv_style_copy(&btn_tpr, &btn_trel);
|
||||
btn_tpr.body.opa = LV_OPA_COVER;
|
||||
@ -185,6 +189,7 @@ static void btn_init(void)
|
||||
btn_tpr.body.border.color = lv_color_hsv_to_rgb(_hue, 80, 70);
|
||||
btn_tpr.text.font = _font;
|
||||
btn_tpr.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
|
||||
btn_tpr.image.color = lv_color_hsv_to_rgb(_hue, 10, 90);
|
||||
|
||||
lv_style_copy(&btn_ina, &btn_rel);
|
||||
btn_ina.body.border.opa = LV_OPA_60;
|
||||
@ -192,11 +197,11 @@ static void btn_init(void)
|
||||
btn_ina.text.font = _font;
|
||||
btn_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
|
||||
|
||||
theme.btn.rel = &btn_rel;
|
||||
theme.btn.pr = &btn_pr;
|
||||
theme.btn.tgl_rel = &btn_trel;
|
||||
theme.btn.tgl_pr = &btn_tpr;
|
||||
theme.btn.ina = &btn_ina;
|
||||
theme.style.btn.rel = &btn_rel;
|
||||
theme.style.btn.pr = &btn_pr;
|
||||
theme.style.btn.tgl_rel = &btn_trel;
|
||||
theme.style.btn.tgl_pr = &btn_tpr;
|
||||
theme.style.btn.ina = &btn_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -216,9 +221,9 @@ static void label_init(void)
|
||||
lv_style_copy(&label_hint, &label_prim);
|
||||
label_hint.text.color = lv_color_hsv_to_rgb(_hue, 20, 70);
|
||||
|
||||
theme.label.prim = &label_prim;
|
||||
theme.label.sec = &label_sec;
|
||||
theme.label.hint = &label_hint;
|
||||
theme.style.label.prim = &label_prim;
|
||||
theme.style.label.sec = &label_sec;
|
||||
theme.style.label.hint = &label_hint;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -250,8 +255,8 @@ static void bar_init(void)
|
||||
bar_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 80);
|
||||
bar_indic.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 80);
|
||||
|
||||
theme.bar.bg = &bar_bg;
|
||||
theme.bar.indic = &bar_indic;
|
||||
theme.style.bar.bg = &bar_bg;
|
||||
theme.style.bar.indic = &bar_indic;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -267,8 +272,8 @@ static void img_init(void)
|
||||
img_light.image.color = lv_color_hsv_to_rgb(_hue, 85, 65);
|
||||
img_light.image.intense = LV_OPA_80;
|
||||
|
||||
theme.img.light = &img_light;
|
||||
theme.img.dark = &img_dark;
|
||||
theme.style.img.light = &img_light;
|
||||
theme.style.img.dark = &img_dark;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -280,7 +285,7 @@ static void line_init(void)
|
||||
line_decor.line.color = lv_color_hsv_to_rgb(_hue, 50, 50);
|
||||
line_decor.line.width = 1;
|
||||
|
||||
theme.line.decor = &line_decor;
|
||||
theme.style.line.decor = &line_decor;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -298,7 +303,7 @@ static void led_init(void)
|
||||
led.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 60);
|
||||
led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 100, 100);
|
||||
|
||||
theme.led = &led;
|
||||
theme.style.led = &led;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -314,9 +319,9 @@ static void slider_init(void)
|
||||
slider_knob.body.border.color = LV_COLOR_GRAY;
|
||||
slider_knob.body.border.opa = LV_OPA_50;
|
||||
|
||||
theme.slider.bg = &bar_bg;
|
||||
theme.slider.indic = &bar_indic;
|
||||
theme.slider.knob = &slider_knob;
|
||||
theme.style.slider.bg = &bar_bg;
|
||||
theme.style.slider.indic = &bar_indic;
|
||||
theme.style.slider.knob = &slider_knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -341,10 +346,10 @@ static void sw_init(void)
|
||||
lv_style_copy(&sw_knob, &slider_knob);
|
||||
sw_knob.body.opa = LV_OPA_80;
|
||||
|
||||
theme.sw.bg = &sw_bg;
|
||||
theme.sw.indic = &sw_indic;
|
||||
theme.sw.knob_off = &sw_knob;
|
||||
theme.sw.knob_on = &sw_knob;
|
||||
theme.style.sw.bg = &sw_bg;
|
||||
theme.style.sw.indic = &sw_indic;
|
||||
theme.style.sw.knob_off = &sw_knob;
|
||||
theme.style.sw.knob_on = &sw_knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -359,7 +364,7 @@ static void lmeter_init(void)
|
||||
lmeter_bg.line.color = LV_COLOR_HEX3(0x222);
|
||||
lmeter_bg.line.width = 2;
|
||||
|
||||
theme.lmeter = &lmeter_bg;
|
||||
theme.style.lmeter = &lmeter_bg;
|
||||
|
||||
#endif
|
||||
}
|
||||
@ -380,7 +385,7 @@ static void gauge_init(void)
|
||||
gauge_bg.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
|
||||
gauge_bg.text.font = _font;
|
||||
|
||||
theme.gauge = &gauge_bg;
|
||||
theme.style.gauge = &gauge_bg;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -400,7 +405,7 @@ static void arc_init(void)
|
||||
arc.body.padding.hor = 3;
|
||||
arc.body.padding.ver = 3;
|
||||
|
||||
theme.arc = &arc;
|
||||
theme.style.arc = &arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -408,14 +413,14 @@ static void preload_init(void)
|
||||
{
|
||||
#if USE_LV_PRELOAD != 0
|
||||
|
||||
theme.preload = theme.arc;
|
||||
theme.style.preload = theme.style.arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
theme.chart = &panel;
|
||||
theme.style.chart = &panel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -449,13 +454,13 @@ static void calendar_init(void)
|
||||
lv_style_copy(&gray_text, &def);
|
||||
gray_text.text.color = lv_color_hsv_to_rgb(_hue, 10, 65);
|
||||
|
||||
theme.calendar.bg = &panel;
|
||||
theme.calendar.header = &header;
|
||||
theme.calendar.week_box = &header;
|
||||
theme.calendar.today_box = &today_box;
|
||||
theme.calendar.day_names = &color_text;
|
||||
theme.calendar.highlighted_days = &color_text;
|
||||
theme.calendar.inactive_days = &gray_text;
|
||||
theme.style.calendar.bg = &panel;
|
||||
theme.style.calendar.header = &header;
|
||||
theme.style.calendar.week_box = &header;
|
||||
theme.style.calendar.today_box = &today_box;
|
||||
theme.style.calendar.day_names = &color_text;
|
||||
theme.style.calendar.highlighted_days = &color_text;
|
||||
theme.style.calendar.inactive_days = &gray_text;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -501,12 +506,12 @@ static void cb_init(void)
|
||||
cb_ina.body.main_color = LV_COLOR_SILVER;
|
||||
cb_ina.body.grad_color = LV_COLOR_SILVER;
|
||||
|
||||
theme.cb.bg = &cb_bg;
|
||||
theme.cb.box.rel = &cb_rel;
|
||||
theme.cb.box.pr = &cb_pr;
|
||||
theme.cb.box.tgl_rel = &cb_trel;
|
||||
theme.cb.box.tgl_pr = &cb_tpr;
|
||||
theme.cb.box.ina = &cb_ina;
|
||||
theme.style.cb.bg = &cb_bg;
|
||||
theme.style.cb.box.rel = &cb_rel;
|
||||
theme.style.cb.box.pr = &cb_pr;
|
||||
theme.style.cb.box.tgl_rel = &cb_trel;
|
||||
theme.style.cb.box.tgl_pr = &cb_tpr;
|
||||
theme.style.cb.box.ina = &cb_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -540,24 +545,24 @@ static void btnm_init(void)
|
||||
lv_style_copy(&btnm_ina, &btnm_rel);
|
||||
btnm_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 60);
|
||||
|
||||
theme.btnm.bg = &btnm_bg;
|
||||
theme.btnm.btn.rel = &btnm_rel;
|
||||
theme.btnm.btn.pr = &btnm_pr;
|
||||
theme.btnm.btn.tgl_rel = &btnm_trel;
|
||||
theme.btnm.btn.tgl_pr = &btnm_pr;
|
||||
theme.btnm.btn.ina = &btnm_ina;
|
||||
theme.style.btnm.bg = &btnm_bg;
|
||||
theme.style.btnm.btn.rel = &btnm_rel;
|
||||
theme.style.btnm.btn.pr = &btnm_pr;
|
||||
theme.style.btnm.btn.tgl_rel = &btnm_trel;
|
||||
theme.style.btnm.btn.tgl_pr = &btnm_pr;
|
||||
theme.style.btnm.btn.ina = &btnm_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void kb_init(void)
|
||||
{
|
||||
#if USE_LV_KB
|
||||
theme.kb.bg = &btnm_bg;
|
||||
theme.kb.btn.rel = &btnm_rel;
|
||||
theme.kb.btn.pr = &btnm_pr;
|
||||
theme.kb.btn.tgl_rel = &btnm_trel;
|
||||
theme.kb.btn.tgl_pr = &btnm_pr;
|
||||
theme.kb.btn.ina = &btnm_ina;
|
||||
theme.style.kb.bg = &btnm_bg;
|
||||
theme.style.kb.btn.rel = &btnm_rel;
|
||||
theme.style.kb.btn.pr = &btnm_pr;
|
||||
theme.style.kb.btn.tgl_rel = &btnm_trel;
|
||||
theme.style.kb.btn.tgl_pr = &btnm_pr;
|
||||
theme.style.kb.btn.ina = &btnm_ina;
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -569,38 +574,38 @@ static void mbox_init(void)
|
||||
lv_style_copy(&mbox_bg, &panel);
|
||||
mbox_bg.body.shadow.width = LV_DPI / 12;
|
||||
|
||||
theme.mbox.bg = &mbox_bg;
|
||||
theme.mbox.btn.bg = &lv_style_transp;
|
||||
theme.mbox.btn.rel = &btn_trel;
|
||||
theme.mbox.btn.pr = &btn_tpr;
|
||||
theme.style.mbox.bg = &mbox_bg;
|
||||
theme.style.mbox.btn.bg = &lv_style_transp;
|
||||
theme.style.mbox.btn.rel = &btn_trel;
|
||||
theme.style.mbox.btn.pr = &btn_tpr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void page_init(void)
|
||||
{
|
||||
#if USE_LV_PAGE
|
||||
theme.page.bg = &panel;
|
||||
theme.page.scrl = &lv_style_transp_fit;
|
||||
theme.page.sb = &sb;
|
||||
theme.style.page.bg = &panel;
|
||||
theme.style.page.scrl = &lv_style_transp_fit;
|
||||
theme.style.page.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ta_init(void)
|
||||
{
|
||||
#if USE_LV_TA
|
||||
theme.ta.area = &panel;
|
||||
theme.ta.oneline = &panel;
|
||||
theme.ta.cursor = NULL;
|
||||
theme.ta.sb = &sb;
|
||||
theme.style.ta.area = &panel;
|
||||
theme.style.ta.oneline = &panel;
|
||||
theme.style.ta.cursor = NULL;
|
||||
theme.style.ta.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void spinbox_init(void)
|
||||
{
|
||||
#if USE_LV_SPINBOX
|
||||
theme.spinbox.bg= &panel;
|
||||
theme.spinbox.cursor = theme.ta.cursor;
|
||||
theme.spinbox.sb = theme.ta.sb;
|
||||
theme.style.spinbox.bg= &panel;
|
||||
theme.style.spinbox.cursor = theme.style.ta.cursor;
|
||||
theme.style.spinbox.sb = theme.style.ta.sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -615,6 +620,7 @@ static void list_init(void)
|
||||
list_rel.body.border.opa = LV_OPA_COVER;
|
||||
list_rel.text.color = lv_color_hsv_to_rgb(_hue, 10, 94);
|
||||
list_rel.text.font = _font;
|
||||
list_rel.image.color = lv_color_hsv_to_rgb(_hue, 10, 94);
|
||||
|
||||
lv_style_copy(&list_pr, &list_rel);
|
||||
list_pr.body.empty = 0;
|
||||
@ -622,6 +628,7 @@ static void list_init(void)
|
||||
list_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 34, 41);
|
||||
list_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 34, 41);
|
||||
list_pr.text.color = lv_color_hsv_to_rgb(_hue, 7, 96);
|
||||
list_pr.image.color = lv_color_hsv_to_rgb(_hue, 7, 96);
|
||||
|
||||
lv_style_copy(&list_trel, &list_rel);
|
||||
lv_style_copy(&list_tpr, &list_pr);
|
||||
@ -631,14 +638,14 @@ static void list_init(void)
|
||||
list_bg.body.padding.hor = 0;
|
||||
list_bg.body.padding.ver = 0;
|
||||
|
||||
theme.list.sb = &sb;
|
||||
theme.list.bg = &list_bg;
|
||||
theme.list.scrl = &lv_style_transp_tight;
|
||||
theme.list.btn.rel = &list_rel;
|
||||
theme.list.btn.pr = &list_pr;
|
||||
theme.list.btn.tgl_rel = &list_trel;
|
||||
theme.list.btn.tgl_pr = &list_tpr;
|
||||
theme.list.btn.ina = &list_ina;
|
||||
theme.style.list.sb = &sb;
|
||||
theme.style.list.bg = &list_bg;
|
||||
theme.style.list.scrl = &lv_style_transp_tight;
|
||||
theme.style.list.btn.rel = &list_rel;
|
||||
theme.style.list.btn.pr = &list_pr;
|
||||
theme.style.list.btn.tgl_rel = &list_trel;
|
||||
theme.style.list.btn.tgl_pr = &list_tpr;
|
||||
theme.style.list.btn.ina = &list_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -656,9 +663,9 @@ static void ddlist_init(void)
|
||||
ddlist_sel.body.opa = LV_OPA_COVER;
|
||||
ddlist_sel.body.radius = 0;
|
||||
|
||||
theme.ddlist.bg = &ddlist_bg;
|
||||
theme.ddlist.sel = &ddlist_sel;
|
||||
theme.ddlist.sb = &sb;
|
||||
theme.style.ddlist.bg = &ddlist_bg;
|
||||
theme.style.ddlist.sel = &ddlist_sel;
|
||||
theme.style.ddlist.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -682,8 +689,8 @@ static void roller_init(void)
|
||||
roller_sel.text.opa = LV_OPA_COVER;
|
||||
roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 70, 95);
|
||||
|
||||
theme.roller.bg = &roller_bg;
|
||||
theme.roller.sel = &roller_sel;
|
||||
theme.style.roller.bg = &roller_bg;
|
||||
theme.style.roller.sel = &roller_sel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -736,22 +743,22 @@ static void tabview_init(void)
|
||||
tab_indic.body.grad_color = lv_color_hsv_to_rgb(_hue, 80, 87);
|
||||
tab_indic.body.padding.inner = LV_DPI / 10; /*Indicator height*/
|
||||
|
||||
theme.tabview.bg = &bg;
|
||||
theme.tabview.indic = &tab_indic;
|
||||
theme.tabview.btn.bg = &lv_style_transp_tight;
|
||||
theme.tabview.btn.rel = &tab_rel;
|
||||
theme.tabview.btn.pr = &tab_pr;
|
||||
theme.tabview.btn.tgl_rel = &tab_trel;
|
||||
theme.tabview.btn.tgl_pr = &tab_tpr;
|
||||
theme.style.tabview.bg = &bg;
|
||||
theme.style.tabview.indic = &tab_indic;
|
||||
theme.style.tabview.btn.bg = &lv_style_transp_tight;
|
||||
theme.style.tabview.btn.rel = &tab_rel;
|
||||
theme.style.tabview.btn.pr = &tab_pr;
|
||||
theme.style.tabview.btn.tgl_rel = &tab_trel;
|
||||
theme.style.tabview.btn.tgl_pr = &tab_tpr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tileview_init(void)
|
||||
{
|
||||
#if USE_LV_TILEVIEW != 0
|
||||
theme.tileview.bg = &lv_style_transp_tight;
|
||||
theme.tileview.scrl = &lv_style_transp_tight;
|
||||
theme.tileview.sb = theme.page.sb;
|
||||
theme.style.tileview.bg = &lv_style_transp_tight;
|
||||
theme.style.tileview.scrl = &lv_style_transp_tight;
|
||||
theme.style.tileview.sb = theme.style.page.sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -766,8 +773,8 @@ static void table_init(void)
|
||||
cell.body.padding.ver = LV_DPI / 12;
|
||||
|
||||
|
||||
theme.table.bg = &lv_style_transp_tight;
|
||||
theme.table.cell = &cell;
|
||||
theme.style.table.bg = &lv_style_transp_tight;
|
||||
theme.style.table.cell = &cell;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -787,17 +794,57 @@ static void win_init(void)
|
||||
header.body.border.color = lv_color_hsv_to_rgb(_hue, 20, 80);
|
||||
header.body.border.part = LV_BORDER_BOTTOM;
|
||||
header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100);
|
||||
header.image.color = lv_color_hsv_to_rgb(_hue, 5, 100);
|
||||
|
||||
theme.win.bg = &bg;
|
||||
theme.win.sb = &sb;
|
||||
theme.win.header = &header;
|
||||
theme.win.content.bg = &lv_style_transp;
|
||||
theme.win.content.scrl = &lv_style_transp;
|
||||
theme.win.btn.rel = &btn_rel;
|
||||
theme.win.btn.pr = &btn_pr;
|
||||
theme.style.win.bg = &bg;
|
||||
theme.style.win.sb = &sb;
|
||||
theme.style.win.header = &header;
|
||||
theme.style.win.content.bg = &lv_style_transp;
|
||||
theme.style.win.content.scrl = &lv_style_transp;
|
||||
theme.style.win.btn.rel = &btn_rel;
|
||||
theme.style.win.btn.pr = &btn_pr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_LV_GROUP
|
||||
|
||||
static void style_mod(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = lv_color_hsv_to_rgb(_hue, 70, 90);
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void style_mod_edit(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_GREEN;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
|
||||
style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60);
|
||||
|
||||
style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*USE_LV_GROUP*/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
@ -817,8 +864,8 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme.style;
|
||||
for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
@ -854,6 +901,11 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font)
|
||||
table_init();
|
||||
win_init();
|
||||
|
||||
#if USE_LV_GROUP
|
||||
theme.group.style_mod = style_mod;
|
||||
theme.group.style_mod_edit = style_mod_edit;
|
||||
#endif
|
||||
|
||||
return &theme;
|
||||
}
|
||||
|
||||
|
@ -63,19 +63,19 @@ static void basic_init(void)
|
||||
plain_bordered.body.border.width = 2;
|
||||
plain_bordered.body.border.color = LV_COLOR_HEX3(0xbbb);
|
||||
|
||||
theme.bg = &lv_style_plain;
|
||||
theme.panel = &lv_style_pretty;
|
||||
theme.style.bg = &lv_style_plain;
|
||||
theme.style.panel = &lv_style_pretty;
|
||||
|
||||
}
|
||||
|
||||
static void btn_init(void)
|
||||
{
|
||||
#if USE_LV_BTN != 0
|
||||
theme.btn.rel = &lv_style_btn_rel;
|
||||
theme.btn.pr = &lv_style_btn_pr;
|
||||
theme.btn.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.btn.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
theme.btn.ina = &lv_style_btn_ina;
|
||||
theme.style.btn.rel = &lv_style_btn_rel;
|
||||
theme.style.btn.pr = &lv_style_btn_pr;
|
||||
theme.style.btn.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.style.btn.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
theme.style.btn.ina = &lv_style_btn_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -92,9 +92,9 @@ static void label_init(void)
|
||||
label_hint.text.color = LV_COLOR_HEX3(0xaaa);
|
||||
|
||||
|
||||
theme.label.prim = &label_prim;
|
||||
theme.label.sec = &label_sec;
|
||||
theme.label.hint = &label_hint;
|
||||
theme.style.label.prim = &label_prim;
|
||||
theme.style.label.sec = &label_sec;
|
||||
theme.style.label.hint = &label_hint;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -104,8 +104,8 @@ static void img_init(void)
|
||||
#if USE_LV_IMG != 0
|
||||
|
||||
|
||||
theme.img.light = &def;
|
||||
theme.img.dark = &def;
|
||||
theme.style.img.light = &def;
|
||||
theme.style.img.dark = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ static void line_init(void)
|
||||
{
|
||||
#if USE_LV_LINE != 0
|
||||
|
||||
theme.line.decor = &def;
|
||||
theme.style.line.decor = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ static void led_init(void)
|
||||
led.body.shadow.color = led.body.main_color;
|
||||
|
||||
|
||||
theme.led = &led;
|
||||
theme.style.led = &led;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -138,8 +138,8 @@ static void bar_init(void)
|
||||
{
|
||||
#if USE_LV_BAR
|
||||
|
||||
theme.bar.bg = &lv_style_pretty;
|
||||
theme.bar.indic = &lv_style_pretty_color;
|
||||
theme.style.bar.bg = &lv_style_pretty;
|
||||
theme.style.bar.indic = &lv_style_pretty_color;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -150,9 +150,9 @@ static void slider_init(void)
|
||||
slider_bg.body.padding.hor = LV_DPI / 20;
|
||||
slider_bg.body.padding.ver = LV_DPI / 20;
|
||||
|
||||
theme.slider.bg = &slider_bg;
|
||||
theme.slider.indic = &lv_style_pretty_color;
|
||||
theme.slider.knob = &lv_style_pretty;
|
||||
theme.style.slider.bg = &slider_bg;
|
||||
theme.style.slider.indic = &lv_style_pretty_color;
|
||||
theme.style.slider.knob = &lv_style_pretty;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -163,10 +163,10 @@ static void sw_init(void)
|
||||
sw_bg.body.padding.hor = 3;
|
||||
sw_bg.body.padding.ver = 3;
|
||||
|
||||
theme.sw.bg = &sw_bg;
|
||||
theme.sw.indic = &lv_style_pretty_color;
|
||||
theme.sw.knob_off = &lv_style_pretty;
|
||||
theme.sw.knob_on = &lv_style_pretty;
|
||||
theme.style.sw.bg = &sw_bg;
|
||||
theme.style.sw.indic = &lv_style_pretty_color;
|
||||
theme.style.sw.knob_off = &lv_style_pretty;
|
||||
theme.style.sw.knob_on = &lv_style_pretty;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ static void lmeter_init(void)
|
||||
lmeter.body.main_color = lv_color_mix(lmeter.body.main_color, LV_COLOR_WHITE, LV_OPA_50);
|
||||
lmeter.body.grad_color = lv_color_mix(lmeter.body.grad_color, LV_COLOR_BLACK, LV_OPA_50);
|
||||
|
||||
theme.lmeter = &lmeter;
|
||||
theme.style.lmeter = &lmeter;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ static void gauge_init(void)
|
||||
gauge.body.grad_color = lmeter.body.main_color;
|
||||
gauge.text.color = LV_COLOR_HEX3(0x888);
|
||||
|
||||
theme.gauge = &gauge;
|
||||
theme.style.gauge = &gauge;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ static void chart_init(void)
|
||||
#if USE_LV_CHART
|
||||
|
||||
|
||||
theme.chart = &lv_style_pretty;
|
||||
theme.style.chart = &lv_style_pretty;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -214,12 +214,12 @@ static void cb_init(void)
|
||||
#if USE_LV_CB != 0
|
||||
|
||||
|
||||
theme.cb.bg = &lv_style_transp;
|
||||
theme.cb.box.rel = &lv_style_pretty;
|
||||
theme.cb.box.pr = &lv_style_btn_pr;
|
||||
theme.cb.box.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.cb.box.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
theme.cb.box.ina = &lv_style_btn_ina;
|
||||
theme.style.cb.bg = &lv_style_transp;
|
||||
theme.style.cb.box.rel = &lv_style_pretty;
|
||||
theme.style.cb.box.pr = &lv_style_btn_pr;
|
||||
theme.style.cb.box.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.style.cb.box.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
theme.style.cb.box.ina = &lv_style_btn_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -229,12 +229,12 @@ static void btnm_init(void)
|
||||
#if USE_LV_BTNM
|
||||
|
||||
|
||||
theme.btnm.bg = &lv_style_pretty;
|
||||
theme.btnm.btn.rel = &lv_style_btn_rel;
|
||||
theme.btnm.btn.pr = &lv_style_btn_pr;
|
||||
theme.btnm.btn.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.btnm.btn.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
theme.btnm.btn.ina = &lv_style_btn_ina;
|
||||
theme.style.btnm.bg = &lv_style_pretty;
|
||||
theme.style.btnm.btn.rel = &lv_style_btn_rel;
|
||||
theme.style.btnm.btn.pr = &lv_style_btn_pr;
|
||||
theme.style.btnm.btn.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.style.btnm.btn.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
theme.style.btnm.btn.ina = &lv_style_btn_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -243,12 +243,12 @@ static void kb_init(void)
|
||||
#if USE_LV_KB
|
||||
|
||||
|
||||
theme.kb.bg = &lv_style_pretty;
|
||||
theme.kb.btn.rel = &lv_style_btn_rel;
|
||||
theme.kb.btn.pr = &lv_style_btn_pr;
|
||||
theme.kb.btn.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.kb.btn.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
theme.kb.btn.ina = &lv_style_btn_ina;
|
||||
theme.style.kb.bg = &lv_style_pretty;
|
||||
theme.style.kb.btn.rel = &lv_style_btn_rel;
|
||||
theme.style.kb.btn.pr = &lv_style_btn_pr;
|
||||
theme.style.kb.btn.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.style.kb.btn.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
theme.style.kb.btn.ina = &lv_style_btn_ina;
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -258,10 +258,10 @@ static void mbox_init(void)
|
||||
#if USE_LV_MBOX
|
||||
|
||||
|
||||
theme.mbox.bg = &lv_style_pretty;
|
||||
theme.mbox.btn.bg = &lv_style_transp;
|
||||
theme.mbox.btn.rel = &lv_style_btn_rel;
|
||||
theme.mbox.btn.pr = &lv_style_btn_tgl_pr;
|
||||
theme.style.mbox.bg = &lv_style_pretty;
|
||||
theme.style.mbox.btn.bg = &lv_style_transp;
|
||||
theme.style.mbox.btn.rel = &lv_style_btn_rel;
|
||||
theme.style.mbox.btn.pr = &lv_style_btn_tgl_pr;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -270,9 +270,9 @@ static void page_init(void)
|
||||
#if USE_LV_PAGE
|
||||
|
||||
|
||||
theme.page.bg = &lv_style_pretty;
|
||||
theme.page.scrl = &lv_style_transp_tight;
|
||||
theme.page.sb = &sb;
|
||||
theme.style.page.bg = &lv_style_pretty;
|
||||
theme.style.page.scrl = &lv_style_transp_tight;
|
||||
theme.style.page.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -281,10 +281,10 @@ static void ta_init(void)
|
||||
#if USE_LV_TA
|
||||
|
||||
|
||||
theme.ta.area = &lv_style_pretty;
|
||||
theme.ta.oneline = &lv_style_pretty;
|
||||
theme.ta.cursor = NULL;
|
||||
theme.ta.sb = &sb;
|
||||
theme.style.ta.area = &lv_style_pretty;
|
||||
theme.style.ta.oneline = &lv_style_pretty;
|
||||
theme.style.ta.cursor = NULL;
|
||||
theme.style.ta.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -292,14 +292,14 @@ static void list_init(void)
|
||||
{
|
||||
#if USE_LV_LIST != 0
|
||||
|
||||
theme.list.bg = &lv_style_pretty;
|
||||
theme.list.scrl = &lv_style_transp_fit;
|
||||
theme.list.sb = &sb;
|
||||
theme.list.btn.rel = &lv_style_btn_rel;
|
||||
theme.list.btn.pr = &lv_style_btn_pr;
|
||||
theme.list.btn.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.list.btn.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
theme.list.btn.ina = &lv_style_btn_ina;
|
||||
theme.style.list.bg = &lv_style_pretty;
|
||||
theme.style.list.scrl = &lv_style_transp_fit;
|
||||
theme.style.list.sb = &sb;
|
||||
theme.style.list.btn.rel = &lv_style_btn_rel;
|
||||
theme.style.list.btn.pr = &lv_style_btn_pr;
|
||||
theme.style.list.btn.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.style.list.btn.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
theme.style.list.btn.ina = &lv_style_btn_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -308,9 +308,9 @@ static void ddlist_init(void)
|
||||
#if USE_LV_DDLIST != 0
|
||||
|
||||
|
||||
theme.ddlist.bg = &lv_style_pretty;
|
||||
theme.ddlist.sel = &lv_style_plain_color;
|
||||
theme.ddlist.sb = &sb;
|
||||
theme.style.ddlist.bg = &lv_style_pretty;
|
||||
theme.style.ddlist.sel = &lv_style_plain_color;
|
||||
theme.style.ddlist.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -319,8 +319,8 @@ static void roller_init(void)
|
||||
#if USE_LV_ROLLER != 0
|
||||
|
||||
|
||||
theme.roller.bg = &lv_style_pretty;
|
||||
theme.roller.sel = &lv_style_plain_color;
|
||||
theme.style.roller.bg = &lv_style_pretty;
|
||||
theme.style.roller.sel = &lv_style_plain_color;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -329,13 +329,13 @@ static void tabview_init(void)
|
||||
#if USE_LV_TABVIEW != 0
|
||||
|
||||
|
||||
theme.tabview.bg = &plain_bordered;
|
||||
theme.tabview.indic = &lv_style_plain_color;
|
||||
theme.tabview.btn.bg = &lv_style_transp;
|
||||
theme.tabview.btn.rel = &lv_style_btn_rel;
|
||||
theme.tabview.btn.pr = &lv_style_btn_pr;
|
||||
theme.tabview.btn.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.tabview.btn.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
theme.style.tabview.bg = &plain_bordered;
|
||||
theme.style.tabview.indic = &lv_style_plain_color;
|
||||
theme.style.tabview.btn.bg = &lv_style_transp;
|
||||
theme.style.tabview.btn.rel = &lv_style_btn_rel;
|
||||
theme.style.tabview.btn.pr = &lv_style_btn_pr;
|
||||
theme.style.tabview.btn.tgl_rel = &lv_style_btn_tgl_rel;
|
||||
theme.style.tabview.btn.tgl_pr = &lv_style_btn_tgl_pr;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -345,16 +345,64 @@ static void win_init(void)
|
||||
#if USE_LV_WIN != 0
|
||||
|
||||
|
||||
theme.win.bg = &plain_bordered;
|
||||
theme.win.sb = &sb;
|
||||
theme.win.header = &lv_style_plain_color;
|
||||
theme.win.content.bg = &lv_style_transp;
|
||||
theme.win.content.scrl = &lv_style_transp;
|
||||
theme.win.btn.rel = &lv_style_btn_rel;
|
||||
theme.win.btn.pr = &lv_style_btn_pr;
|
||||
theme.style.win.bg = &plain_bordered;
|
||||
theme.style.win.sb = &sb;
|
||||
theme.style.win.header = &lv_style_plain_color;
|
||||
theme.style.win.content.bg = &lv_style_transp;
|
||||
theme.style.win.content.scrl = &lv_style_transp;
|
||||
theme.style.win.btn.rel = &lv_style_btn_rel;
|
||||
theme.style.win.btn.pr = &lv_style_btn_pr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_LV_GROUP
|
||||
|
||||
static void style_mod(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_ORANGE;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
|
||||
style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70);
|
||||
style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70);
|
||||
style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60);
|
||||
|
||||
style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70);
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void style_mod_edit(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_GREEN;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
|
||||
style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60);
|
||||
|
||||
style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*USE_LV_GROUP*/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
@ -376,8 +424,8 @@ lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme.style;
|
||||
for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
@ -406,6 +454,11 @@ lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font)
|
||||
tabview_init();
|
||||
win_init();
|
||||
|
||||
#if USE_LV_GROUP
|
||||
theme.group.style_mod = style_mod;
|
||||
theme.group.style_mod_edit = style_mod_edit;
|
||||
#endif
|
||||
|
||||
return &theme;
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ static void basic_init(void)
|
||||
panel.body.padding.ver = LV_DPI / 8;
|
||||
panel.body.padding.inner = LV_DPI / 12;
|
||||
panel.text.color = LV_COLOR_HEX3(0x333);
|
||||
panel.image.color = LV_COLOR_HEX3(0x333);
|
||||
|
||||
lv_style_copy(&sb, &def);
|
||||
sb.body.main_color = LV_COLOR_BLACK;
|
||||
@ -79,8 +80,8 @@ static void basic_init(void)
|
||||
sb.body.opa = LV_OPA_40;
|
||||
sb.body.padding.hor = LV_DPI / 25;
|
||||
|
||||
theme.bg = &bg;
|
||||
theme.panel = &panel;
|
||||
theme.style.bg = &bg;
|
||||
theme.style.panel = &panel;
|
||||
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ static void cont_init(void)
|
||||
#if USE_LV_CONT != 0
|
||||
|
||||
|
||||
theme.cont = theme.panel;
|
||||
theme.style.cont = theme.style.panel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -109,6 +110,7 @@ static void btn_init(void)
|
||||
rel.body.shadow.type = LV_SHADOW_BOTTOM;
|
||||
rel.body.shadow.width = 6;
|
||||
rel.text.color = lv_color_hsv_to_rgb(_hue, 5, 95);
|
||||
rel.image.color = lv_color_hsv_to_rgb(_hue, 5, 95);
|
||||
|
||||
|
||||
lv_style_copy(&pr, &rel);
|
||||
@ -131,12 +133,13 @@ static void btn_init(void)
|
||||
ina.body.grad_color = ina.body.main_color;
|
||||
ina.body.shadow.width = 0;
|
||||
ina.text.color = lv_color_hsv_to_rgb(_hue, 95, 5);
|
||||
ina.image.color = lv_color_hsv_to_rgb(_hue, 95, 5);
|
||||
|
||||
theme.btn.rel = &rel;
|
||||
theme.btn.pr = ≺
|
||||
theme.btn.tgl_rel = &tgl_rel;
|
||||
theme.btn.tgl_pr = &tgl_pr;
|
||||
theme.btn.ina = &ina;
|
||||
theme.style.btn.rel = &rel;
|
||||
theme.style.btn.pr = ≺
|
||||
theme.style.btn.tgl_rel = &tgl_rel;
|
||||
theme.style.btn.tgl_pr = &tgl_pr;
|
||||
theme.style.btn.ina = &ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -156,9 +159,9 @@ static void label_init(void)
|
||||
lv_style_copy(&hint, &prim);
|
||||
hint.text.color = lv_color_hsv_to_rgb(_hue, 40, 90);
|
||||
|
||||
theme.label.prim = &prim;
|
||||
theme.label.sec = &sec;
|
||||
theme.label.hint = &hint;
|
||||
theme.style.label.prim = &prim;
|
||||
theme.style.label.sec = &sec;
|
||||
theme.style.label.hint = &hint;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -175,8 +178,8 @@ static void img_init(void)
|
||||
img_light.image.intense = LV_OPA_80;
|
||||
|
||||
|
||||
theme.img.light = &def;
|
||||
theme.img.dark = &def;
|
||||
theme.style.img.light = &def;
|
||||
theme.style.img.dark = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -185,7 +188,7 @@ static void line_init(void)
|
||||
#if USE_LV_LINE != 0
|
||||
|
||||
|
||||
theme.line.decor = &def;
|
||||
theme.style.line.decor = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -204,7 +207,7 @@ static void led_init(void)
|
||||
led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 100, 100);
|
||||
|
||||
|
||||
theme.led = &led;
|
||||
theme.style.led = &led;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -227,8 +230,8 @@ static void bar_init(void)
|
||||
bar_indic.body.padding.hor = 0;
|
||||
bar_indic.body.padding.ver = 0;
|
||||
|
||||
theme.bar.bg = &bar_bg;
|
||||
theme.bar.indic = &bar_indic;
|
||||
theme.style.bar.bg = &bar_bg;
|
||||
theme.style.bar.indic = &bar_indic;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -240,12 +243,12 @@ static void slider_init(void)
|
||||
lv_style_copy(&knob, &def);
|
||||
knob.body.radius = LV_RADIUS_CIRCLE;
|
||||
knob.body.border.width = 0;
|
||||
knob.body.main_color = theme.bar.indic->body.main_color;
|
||||
knob.body.main_color = theme.style.bar.indic->body.main_color;
|
||||
knob.body.grad_color = knob.body.main_color;
|
||||
|
||||
theme.slider.bg = theme.bar.bg;
|
||||
theme.slider.indic = theme.bar.indic;
|
||||
theme.slider.knob = &knob;
|
||||
theme.style.slider.bg = theme.style.bar.bg;
|
||||
theme.style.slider.indic = theme.style.bar.indic;
|
||||
theme.style.slider.knob = &knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -253,13 +256,13 @@ static void sw_init(void)
|
||||
{
|
||||
#if USE_LV_SW != 0
|
||||
static lv_style_t sw_bg, sw_indic, sw_knob_off, sw_knob_on;
|
||||
lv_style_copy(&sw_bg, theme.slider.bg);
|
||||
lv_style_copy(&sw_bg, theme.style.slider.bg);
|
||||
sw_bg.body.radius = LV_RADIUS_CIRCLE;
|
||||
|
||||
lv_style_copy(&sw_indic, theme.slider.bg);
|
||||
lv_style_copy(&sw_indic, theme.style.slider.bg);
|
||||
sw_indic.body.radius = LV_RADIUS_CIRCLE;
|
||||
|
||||
lv_style_copy(&sw_knob_on, theme.slider.knob);
|
||||
lv_style_copy(&sw_knob_on, theme.style.slider.knob);
|
||||
sw_knob_on.body.shadow.width = 3;
|
||||
sw_knob_on.body.shadow.type = LV_SHADOW_BOTTOM;
|
||||
sw_knob_on.body.shadow.color = DEF_SHADOW_COLOR;
|
||||
@ -272,10 +275,10 @@ static void sw_init(void)
|
||||
sw_knob_off.body.border.color = LV_COLOR_HEX3(0x999);
|
||||
sw_knob_off.body.border.opa = LV_OPA_COVER;
|
||||
|
||||
theme.sw.bg = &sw_bg;
|
||||
theme.sw.indic = &sw_indic;
|
||||
theme.sw.knob_off = &sw_knob_off;
|
||||
theme.sw.knob_on = &sw_knob_on;
|
||||
theme.style.sw.bg = &sw_bg;
|
||||
theme.style.sw.indic = &sw_indic;
|
||||
theme.style.sw.knob_off = &sw_knob_off;
|
||||
theme.style.sw.knob_on = &sw_knob_on;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -291,7 +294,7 @@ static void lmeter_init(void)
|
||||
lmeter.line.color = LV_COLOR_HEX3(0x999);
|
||||
lmeter.line.width = 2;
|
||||
|
||||
theme.lmeter = &lmeter;
|
||||
theme.style.lmeter = &lmeter;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -310,7 +313,7 @@ static void gauge_init(void)
|
||||
gauge.line.width = 3;
|
||||
gauge.line.color = lv_color_hsv_to_rgb(_hue, 95, 70);
|
||||
|
||||
theme.gauge = &gauge;
|
||||
theme.style.gauge = &gauge;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -329,7 +332,7 @@ static void arc_init(void)
|
||||
arc.body.padding.hor = 0;
|
||||
arc.body.padding.ver = 0;
|
||||
|
||||
theme.arc = &arc;
|
||||
theme.style.arc = &arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -337,14 +340,14 @@ static void preload_init(void)
|
||||
{
|
||||
#if USE_LV_PRELOAD != 0
|
||||
|
||||
theme.preload = theme.arc;
|
||||
theme.style.preload = theme.style.arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
theme.chart = theme.panel;
|
||||
theme.style.chart = theme.style.panel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -364,9 +367,9 @@ static void calendar_init(void)
|
||||
week_box.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 100);
|
||||
week_box.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 100);
|
||||
week_box.body.padding.ver = LV_DPI / 20;
|
||||
week_box.body.padding.hor = theme.panel->body.padding.hor;
|
||||
week_box.body.border.color = theme.panel->body.border.color;
|
||||
week_box.body.border.width = theme.panel->body.border.width;
|
||||
week_box.body.padding.hor = theme.style.panel->body.padding.hor;
|
||||
week_box.body.border.color = theme.style.panel->body.border.color;
|
||||
week_box.body.border.width = theme.style.panel->body.border.width;
|
||||
week_box.body.border.part = LV_BORDER_LEFT | LV_BORDER_RIGHT;
|
||||
week_box.body.radius = 0;
|
||||
|
||||
@ -377,12 +380,12 @@ static void calendar_init(void)
|
||||
today_box.body.padding.ver = LV_DPI / 20;
|
||||
today_box.body.radius = 0;
|
||||
|
||||
theme.calendar.bg = theme.panel;
|
||||
theme.calendar.header = &lv_style_transp;
|
||||
theme.calendar.inactive_days = &ina_days;
|
||||
theme.calendar.highlighted_days = &high_days;
|
||||
theme.calendar.week_box = &week_box;
|
||||
theme.calendar.today_box = &today_box;
|
||||
theme.style.calendar.bg = theme.style.panel;
|
||||
theme.style.calendar.header = &lv_style_transp;
|
||||
theme.style.calendar.inactive_days = &ina_days;
|
||||
theme.style.calendar.highlighted_days = &high_days;
|
||||
theme.style.calendar.week_box = &week_box;
|
||||
theme.style.calendar.today_box = &today_box;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -390,7 +393,7 @@ static void cb_init(void)
|
||||
{
|
||||
#if USE_LV_CB != 0
|
||||
static lv_style_t rel, pr, tgl_rel, tgl_pr, ina;
|
||||
lv_style_copy(&rel, theme.panel);
|
||||
lv_style_copy(&rel, theme.style.panel);
|
||||
rel.body.shadow.type = LV_SHADOW_BOTTOM;
|
||||
rel.body.shadow.width = 3;
|
||||
|
||||
@ -410,14 +413,14 @@ static void cb_init(void)
|
||||
tgl_pr.body.grad_color = tgl_pr.body.main_color;
|
||||
tgl_pr.body.shadow.width = 0;
|
||||
|
||||
lv_style_copy(&ina, theme.btn.ina);
|
||||
lv_style_copy(&ina, theme.style.btn.ina);
|
||||
|
||||
theme.cb.bg = &lv_style_transp;
|
||||
theme.cb.box.rel = &rel;
|
||||
theme.cb.box.pr = ≺
|
||||
theme.cb.box.tgl_rel = &tgl_rel;
|
||||
theme.cb.box.tgl_pr = &tgl_pr;
|
||||
theme.cb.box.ina = &ina;
|
||||
theme.style.cb.bg = &lv_style_transp;
|
||||
theme.style.cb.box.rel = &rel;
|
||||
theme.style.cb.box.pr = ≺
|
||||
theme.style.cb.box.tgl_rel = &tgl_rel;
|
||||
theme.style.cb.box.tgl_pr = &tgl_pr;
|
||||
theme.style.cb.box.ina = &ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -427,13 +430,13 @@ static void btnm_init(void)
|
||||
#if USE_LV_BTNM
|
||||
static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina;
|
||||
|
||||
lv_style_copy(&bg, theme.panel);
|
||||
lv_style_copy(&bg, theme.style.panel);
|
||||
bg.body.padding.hor = 0;
|
||||
bg.body.padding.ver = 0;
|
||||
bg.body.padding.inner = 0;
|
||||
bg.text.color = LV_COLOR_HEX3(0x555);
|
||||
|
||||
lv_style_copy(&rel, theme.panel);
|
||||
lv_style_copy(&rel, theme.style.panel);
|
||||
rel.body.border.part = LV_BORDER_FULL | LV_BORDER_INTERNAL;
|
||||
rel.body.border.width = 1;
|
||||
rel.body.border.color = LV_COLOR_HEX3(0xbbb);
|
||||
@ -462,12 +465,12 @@ static void btnm_init(void)
|
||||
ina.body.main_color = LV_COLOR_HEX3(0xccc);
|
||||
ina.body.grad_color = ina.body.main_color;
|
||||
|
||||
theme.btnm.bg = &bg;
|
||||
theme.btnm.btn.rel = &rel;
|
||||
theme.btnm.btn.pr = ≺
|
||||
theme.btnm.btn.tgl_rel = &tgl_rel;
|
||||
theme.btnm.btn.tgl_pr = &tgl_pr;
|
||||
theme.btnm.btn.ina = &def;
|
||||
theme.style.btnm.bg = &bg;
|
||||
theme.style.btnm.btn.rel = &rel;
|
||||
theme.style.btnm.btn.pr = ≺
|
||||
theme.style.btnm.btn.tgl_rel = &tgl_rel;
|
||||
theme.style.btnm.btn.tgl_pr = &tgl_pr;
|
||||
theme.style.btnm.btn.ina = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -479,12 +482,12 @@ static void kb_init(void)
|
||||
lv_style_copy(&rel, &lv_style_transp);
|
||||
rel.text.font = _font;
|
||||
|
||||
theme.kb.bg = theme.btnm.bg;
|
||||
theme.kb.btn.rel = &rel;
|
||||
theme.kb.btn.pr = theme.btnm.btn.pr;
|
||||
theme.kb.btn.tgl_rel = theme.btnm.btn.tgl_rel;
|
||||
theme.kb.btn.tgl_pr = theme.btnm.btn.tgl_pr;
|
||||
theme.kb.btn.ina = theme.btnm.btn.ina;
|
||||
theme.style.kb.bg = theme.style.btnm.bg;
|
||||
theme.style.kb.btn.rel = &rel;
|
||||
theme.style.kb.btn.pr = theme.style.btnm.btn.pr;
|
||||
theme.style.kb.btn.tgl_rel = theme.style.btnm.btn.tgl_rel;
|
||||
theme.style.kb.btn.tgl_pr = theme.style.btnm.btn.tgl_pr;
|
||||
theme.style.kb.btn.ina = theme.style.btnm.btn.ina;
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -499,13 +502,13 @@ static void mbox_init(void)
|
||||
rel.text.font = _font;
|
||||
rel.text.color = lv_color_hsv_to_rgb(_hue, 85, 75);
|
||||
|
||||
lv_style_copy(&pr, theme.btnm.btn.pr);
|
||||
lv_style_copy(&pr, theme.style.btnm.btn.pr);
|
||||
pr.text.color = lv_color_hsv_to_rgb(_hue, 85, 60);
|
||||
|
||||
theme.mbox.bg = theme.panel;
|
||||
theme.mbox.btn.bg = &lv_style_transp;
|
||||
theme.mbox.btn.rel = &rel;
|
||||
theme.mbox.btn.pr = ≺
|
||||
theme.style.mbox.bg = theme.style.panel;
|
||||
theme.style.mbox.btn.bg = &lv_style_transp;
|
||||
theme.style.mbox.btn.rel = &rel;
|
||||
theme.style.mbox.btn.pr = ≺
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -514,9 +517,9 @@ static void page_init(void)
|
||||
#if USE_LV_PAGE
|
||||
|
||||
|
||||
theme.page.bg = theme.panel;
|
||||
theme.page.scrl = &lv_style_transp;
|
||||
theme.page.sb = &sb;
|
||||
theme.style.page.bg = theme.style.panel;
|
||||
theme.style.page.scrl = &lv_style_transp;
|
||||
theme.style.page.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -534,19 +537,19 @@ static void ta_init(void)
|
||||
oneline.body.border.opa = LV_OPA_COVER;
|
||||
oneline.text.color = LV_COLOR_HEX3(0x333);
|
||||
|
||||
theme.ta.area = theme.panel;
|
||||
theme.ta.oneline = &oneline;
|
||||
theme.ta.cursor = NULL; /*Let library to calculate the cursor's style*/
|
||||
theme.ta.sb = &sb;
|
||||
theme.style.ta.area = theme.style.panel;
|
||||
theme.style.ta.oneline = &oneline;
|
||||
theme.style.ta.cursor = NULL; /*Let library to calculate the cursor's style*/
|
||||
theme.style.ta.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void spinbox_init(void)
|
||||
{
|
||||
#if USE_LV_SPINBOX
|
||||
theme.spinbox.bg= theme.panel;
|
||||
theme.spinbox.cursor = theme.ta.cursor;
|
||||
theme.spinbox.sb = theme.ta.sb;
|
||||
theme.style.spinbox.bg= theme.style.panel;
|
||||
theme.style.spinbox.cursor = theme.style.ta.cursor;
|
||||
theme.style.spinbox.sb = theme.style.ta.sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -556,7 +559,7 @@ static void list_init(void)
|
||||
|
||||
static lv_style_t list_bg, rel, pr, tgl_rel, tgl_pr, ina;
|
||||
|
||||
lv_style_copy(&list_bg, theme.panel);
|
||||
lv_style_copy(&list_bg, theme.style.panel);
|
||||
list_bg.body.padding.hor = 0;
|
||||
list_bg.body.padding.ver = 0;
|
||||
list_bg.body.padding.inner = 0;
|
||||
@ -594,14 +597,14 @@ static void list_init(void)
|
||||
ina.body.grad_color = ina.body.main_color;
|
||||
|
||||
|
||||
theme.list.sb = &sb;
|
||||
theme.list.bg = &list_bg;
|
||||
theme.list.scrl = &lv_style_transp_tight;
|
||||
theme.list.btn.rel = &rel;
|
||||
theme.list.btn.pr = ≺
|
||||
theme.list.btn.tgl_rel = &tgl_rel;
|
||||
theme.list.btn.tgl_pr = &tgl_pr;
|
||||
theme.list.btn.ina = &ina;
|
||||
theme.style.list.sb = &sb;
|
||||
theme.style.list.bg = &list_bg;
|
||||
theme.style.list.scrl = &lv_style_transp_tight;
|
||||
theme.style.list.btn.rel = &rel;
|
||||
theme.style.list.btn.pr = ≺
|
||||
theme.style.list.btn.tgl_rel = &tgl_rel;
|
||||
theme.style.list.btn.tgl_pr = &tgl_pr;
|
||||
theme.style.list.btn.ina = &ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -609,7 +612,7 @@ static void ddlist_init(void)
|
||||
{
|
||||
#if USE_LV_DDLIST != 0
|
||||
static lv_style_t bg, sel;
|
||||
lv_style_copy(&bg, theme.panel);
|
||||
lv_style_copy(&bg, theme.style.panel);
|
||||
bg.body.padding.hor = LV_DPI / 6;
|
||||
bg.body.padding.ver = LV_DPI / 6;
|
||||
bg.text.line_space = LV_DPI / 8;
|
||||
@ -623,9 +626,9 @@ static void ddlist_init(void)
|
||||
sel.text.color = lv_color_hsv_to_rgb(_hue, 5, 95);
|
||||
|
||||
|
||||
theme.ddlist.bg = &bg;
|
||||
theme.ddlist.sel = &sel;
|
||||
theme.ddlist.sb = &sb;
|
||||
theme.style.ddlist.bg = &bg;
|
||||
theme.style.ddlist.sel = &sel;
|
||||
theme.style.ddlist.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -645,8 +648,8 @@ static void roller_init(void)
|
||||
roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 90, 70);
|
||||
|
||||
|
||||
theme.roller.bg = &roller_bg;
|
||||
theme.roller.sel = &roller_sel;
|
||||
theme.style.roller.bg = &roller_bg;
|
||||
theme.style.roller.sel = &roller_sel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -708,22 +711,22 @@ static void tabview_init(void)
|
||||
tgl_pr.body.radius = 0;
|
||||
tgl_pr.text.color = lv_color_hsv_to_rgb(_hue, 90, 60);
|
||||
|
||||
theme.tabview.bg = theme.bg;
|
||||
theme.tabview.indic = &indic;
|
||||
theme.tabview.btn.bg = &btn_bg;
|
||||
theme.tabview.btn.rel = &rel;
|
||||
theme.tabview.btn.pr = ≺
|
||||
theme.tabview.btn.tgl_rel = &tgl_rel;
|
||||
theme.tabview.btn.tgl_pr = &tgl_pr;
|
||||
theme.style.tabview.bg = theme.style.bg;
|
||||
theme.style.tabview.indic = &indic;
|
||||
theme.style.tabview.btn.bg = &btn_bg;
|
||||
theme.style.tabview.btn.rel = &rel;
|
||||
theme.style.tabview.btn.pr = ≺
|
||||
theme.style.tabview.btn.tgl_rel = &tgl_rel;
|
||||
theme.style.tabview.btn.tgl_pr = &tgl_pr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tileview_init(void)
|
||||
{
|
||||
#if USE_LV_TILEVIEW != 0
|
||||
theme.tileview.bg = &lv_style_transp_tight;
|
||||
theme.tileview.scrl = &lv_style_transp_tight;
|
||||
theme.tileview.sb = theme.page.sb;
|
||||
theme.style.tileview.bg = &lv_style_transp_tight;
|
||||
theme.style.tileview.scrl = &lv_style_transp_tight;
|
||||
theme.style.tileview.sb = theme.style.page.sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -731,15 +734,15 @@ static void table_init(void)
|
||||
{
|
||||
#if USE_LV_TABLE != 0
|
||||
static lv_style_t cell;
|
||||
lv_style_copy(&cell, theme.panel);
|
||||
lv_style_copy(&cell, theme.style.panel);
|
||||
cell.body.radius = 0;
|
||||
cell.body.border.width = 1;
|
||||
cell.body.padding.hor = LV_DPI / 12;
|
||||
cell.body.padding.ver = LV_DPI / 12;
|
||||
|
||||
|
||||
theme.table.bg = &lv_style_transp_tight;
|
||||
theme.table.cell = &cell;
|
||||
theme.style.table.bg = &lv_style_transp_tight;
|
||||
theme.style.table.cell = &cell;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -760,6 +763,7 @@ static void win_init(void)
|
||||
header.body.padding.hor = 0;
|
||||
header.body.padding.ver = 0;
|
||||
header.text.color = LV_COLOR_HEX3(0x333);
|
||||
header.image.color = LV_COLOR_HEX3(0x333);
|
||||
|
||||
lv_style_copy(&pr, &def);
|
||||
pr.body.main_color = LV_COLOR_HEX3(0xbbb);
|
||||
@ -768,18 +772,67 @@ static void win_init(void)
|
||||
pr.body.empty = 0;
|
||||
pr.body.radius = 0;
|
||||
pr.text.color = LV_COLOR_HEX3(0x111);
|
||||
pr.image.color = LV_COLOR_HEX3(0x111);
|
||||
|
||||
|
||||
theme.win.bg = theme.panel;
|
||||
theme.win.sb = &sb;
|
||||
theme.win.header = &header;
|
||||
theme.win.content.bg = &lv_style_transp;
|
||||
theme.win.content.scrl = &lv_style_transp;
|
||||
theme.win.btn.rel = &lv_style_transp;
|
||||
theme.win.btn.pr = ≺
|
||||
theme.style.win.bg = theme.style.panel;
|
||||
theme.style.win.sb = &sb;
|
||||
theme.style.win.header = &header;
|
||||
theme.style.win.content.bg = &lv_style_transp;
|
||||
theme.style.win.content.scrl = &lv_style_transp;
|
||||
theme.style.win.btn.rel = &lv_style_transp;
|
||||
theme.style.win.btn.pr = ≺
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_LV_GROUP
|
||||
|
||||
static void style_mod(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = lv_color_hsv_to_rgb(_hue, 90, 70);
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
|
||||
style->body.main_color = lv_color_mix(style->body.main_color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70);
|
||||
style->body.grad_color = lv_color_mix(style->body.grad_color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70);
|
||||
style->body.shadow.color = lv_color_mix(style->body.shadow.color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_60);
|
||||
|
||||
style->text.color = lv_color_mix(style->text.color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70);
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void style_mod_edit(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_GREEN;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
|
||||
style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60);
|
||||
|
||||
style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*USE_LV_GROUP*/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
@ -801,8 +854,8 @@ lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t * font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme.style;
|
||||
for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
@ -838,6 +891,11 @@ lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t * font)
|
||||
table_init();
|
||||
win_init();
|
||||
|
||||
#if USE_LV_GROUP
|
||||
theme.group.style_mod = style_mod;
|
||||
theme.group.style_mod_edit = style_mod_edit;
|
||||
#endif
|
||||
|
||||
return &theme;
|
||||
}
|
||||
|
||||
|
@ -91,8 +91,8 @@ static void basic_init(void)
|
||||
lv_style_copy(&dark_frame, &dark_plain);
|
||||
dark_frame.body.radius = LV_DPI / 20;
|
||||
|
||||
theme.bg = &def;
|
||||
theme.panel = &light_frame;
|
||||
theme.style.bg = &def;
|
||||
theme.style.panel = &light_frame;
|
||||
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ static void cont_init(void)
|
||||
#if USE_LV_CONT != 0
|
||||
|
||||
|
||||
theme.cont = &def;
|
||||
theme.style.cont = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -110,11 +110,11 @@ static void btn_init(void)
|
||||
#if USE_LV_BTN != 0
|
||||
|
||||
|
||||
theme.btn.rel = &light_frame;
|
||||
theme.btn.pr = &dark_frame;
|
||||
theme.btn.tgl_rel = &dark_frame;
|
||||
theme.btn.tgl_pr = &light_frame;
|
||||
theme.btn.ina = &light_frame;
|
||||
theme.style.btn.rel = &light_frame;
|
||||
theme.style.btn.pr = &dark_frame;
|
||||
theme.style.btn.tgl_rel = &dark_frame;
|
||||
theme.style.btn.tgl_pr = &light_frame;
|
||||
theme.style.btn.ina = &light_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -124,9 +124,9 @@ static void label_init(void)
|
||||
#if USE_LV_LABEL != 0
|
||||
|
||||
|
||||
theme.label.prim = NULL;
|
||||
theme.label.sec = NULL;
|
||||
theme.label.hint = NULL;
|
||||
theme.style.label.prim = NULL;
|
||||
theme.style.label.sec = NULL;
|
||||
theme.style.label.hint = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -135,15 +135,15 @@ static void img_init(void)
|
||||
#if USE_LV_IMG != 0
|
||||
|
||||
|
||||
theme.img.light = &def;
|
||||
theme.img.dark = &def;
|
||||
theme.style.img.light = &def;
|
||||
theme.style.img.dark = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void line_init(void)
|
||||
{
|
||||
#if USE_LV_LINE != 0
|
||||
theme.line.decor = NULL;
|
||||
theme.style.line.decor = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ static void led_init(void)
|
||||
led.body.shadow.color = LV_COLOR_BLACK;
|
||||
led.body.shadow.type = LV_SHADOW_FULL;
|
||||
|
||||
theme.led = &led;
|
||||
theme.style.led = &led;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -177,8 +177,8 @@ static void bar_init(void)
|
||||
bar_indic.body.padding.ver = LV_DPI / 30;
|
||||
bar_indic.body.radius = LV_RADIUS_CIRCLE;
|
||||
|
||||
theme.bar.bg = &bar_bg;
|
||||
theme.bar.indic = &bar_indic;
|
||||
theme.style.bar.bg = &bar_bg;
|
||||
theme.style.bar.indic = &bar_indic;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -191,9 +191,9 @@ static void slider_init(void)
|
||||
slider_knob.body.padding.hor = LV_DPI / 30;
|
||||
slider_knob.body.padding.ver = LV_DPI / 30;
|
||||
|
||||
theme.slider.bg = theme.bar.bg;
|
||||
theme.slider.indic = theme.bar.indic;
|
||||
theme.slider.knob = &slider_knob;
|
||||
theme.style.slider.bg = theme.style.bar.bg;
|
||||
theme.style.slider.indic = theme.style.bar.indic;
|
||||
theme.style.slider.knob = &slider_knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -202,10 +202,10 @@ static void sw_init(void)
|
||||
#if USE_LV_SW != 0
|
||||
|
||||
|
||||
theme.sw.bg = theme.slider.bg;
|
||||
theme.sw.indic = theme.slider.indic;
|
||||
theme.sw.knob_off = theme.slider.knob;
|
||||
theme.sw.knob_on = theme.slider.knob;
|
||||
theme.style.sw.bg = theme.style.slider.bg;
|
||||
theme.style.sw.indic = theme.style.slider.indic;
|
||||
theme.style.sw.knob_off = theme.style.slider.knob;
|
||||
theme.style.sw.knob_on = theme.style.slider.knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ static void lmeter_init(void)
|
||||
lmeter_bg.line.color = LV_COLOR_WHITE;
|
||||
lmeter_bg.line.width = 1;
|
||||
|
||||
theme.lmeter = &lmeter_bg;
|
||||
theme.style.lmeter = &lmeter_bg;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -231,19 +231,19 @@ static void gauge_init(void)
|
||||
{
|
||||
#if USE_LV_GAUGE != 0
|
||||
static lv_style_t gauge_bg;
|
||||
lv_style_copy(&gauge_bg, theme.lmeter);
|
||||
lv_style_copy(&gauge_bg, theme.style.lmeter);
|
||||
gauge_bg.line.color = LV_COLOR_BLACK;
|
||||
gauge_bg.line.width = 1;
|
||||
|
||||
|
||||
theme.gauge = &gauge_bg;
|
||||
theme.style.gauge = &gauge_bg;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
theme.chart = &light_frame;
|
||||
theme.style.chart = &light_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -255,8 +255,8 @@ static void calendar_init(void)
|
||||
box.body.padding.ver = LV_DPI / 20;
|
||||
|
||||
/*Can't handle highlighted dates in this theme*/
|
||||
theme.calendar.week_box = &box;
|
||||
theme.calendar.today_box = &box;
|
||||
theme.style.calendar.week_box = &box;
|
||||
theme.style.calendar.today_box = &box;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -265,12 +265,12 @@ static void cb_init(void)
|
||||
#if USE_LV_CB != 0
|
||||
|
||||
|
||||
theme.cb.bg = &lv_style_transp;
|
||||
theme.cb.box.rel = &light_frame;
|
||||
theme.cb.box.pr = &dark_frame;
|
||||
theme.cb.box.tgl_rel = &dark_frame;
|
||||
theme.cb.box.tgl_pr = &light_frame;
|
||||
theme.cb.box.ina = &light_frame;
|
||||
theme.style.cb.bg = &lv_style_transp;
|
||||
theme.style.cb.box.rel = &light_frame;
|
||||
theme.style.cb.box.pr = &dark_frame;
|
||||
theme.style.cb.box.tgl_rel = &dark_frame;
|
||||
theme.style.cb.box.tgl_pr = &light_frame;
|
||||
theme.style.cb.box.ina = &light_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -280,24 +280,24 @@ static void btnm_init(void)
|
||||
#if USE_LV_BTNM
|
||||
|
||||
|
||||
theme.btnm.bg = &light_frame;
|
||||
theme.btnm.btn.rel = &light_frame;
|
||||
theme.btnm.btn.pr = &dark_frame;
|
||||
theme.btnm.btn.tgl_rel = &dark_frame;
|
||||
theme.btnm.btn.tgl_pr = &light_frame;
|
||||
theme.btnm.btn.ina = &light_frame;
|
||||
theme.style.btnm.bg = &light_frame;
|
||||
theme.style.btnm.btn.rel = &light_frame;
|
||||
theme.style.btnm.btn.pr = &dark_frame;
|
||||
theme.style.btnm.btn.tgl_rel = &dark_frame;
|
||||
theme.style.btnm.btn.tgl_pr = &light_frame;
|
||||
theme.style.btnm.btn.ina = &light_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void kb_init(void)
|
||||
{
|
||||
#if USE_LV_KB
|
||||
theme.kb.bg = &lv_style_transp_fit;
|
||||
theme.kb.btn.rel = &light_frame;
|
||||
theme.kb.btn.pr = &light_frame;
|
||||
theme.kb.btn.tgl_rel = &dark_frame;
|
||||
theme.kb.btn.tgl_pr = &dark_frame;
|
||||
theme.kb.btn.ina = &light_frame;
|
||||
theme.style.kb.bg = &lv_style_transp_fit;
|
||||
theme.style.kb.btn.rel = &light_frame;
|
||||
theme.style.kb.btn.pr = &light_frame;
|
||||
theme.style.kb.btn.tgl_rel = &dark_frame;
|
||||
theme.style.kb.btn.tgl_pr = &dark_frame;
|
||||
theme.style.kb.btn.ina = &light_frame;
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -307,10 +307,10 @@ static void mbox_init(void)
|
||||
#if USE_LV_MBOX
|
||||
|
||||
|
||||
theme.mbox.bg = &dark_frame;
|
||||
theme.mbox.btn.bg = &lv_style_transp_fit;
|
||||
theme.mbox.btn.rel = &light_frame;
|
||||
theme.mbox.btn.pr = &dark_frame;
|
||||
theme.style.mbox.bg = &dark_frame;
|
||||
theme.style.mbox.btn.bg = &lv_style_transp_fit;
|
||||
theme.style.mbox.btn.rel = &light_frame;
|
||||
theme.style.mbox.btn.pr = &dark_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -319,9 +319,9 @@ static void page_init(void)
|
||||
#if USE_LV_PAGE
|
||||
|
||||
|
||||
theme.page.bg = &light_frame;
|
||||
theme.page.scrl = &light_frame;
|
||||
theme.page.sb = &dark_frame;
|
||||
theme.style.page.bg = &light_frame;
|
||||
theme.style.page.scrl = &light_frame;
|
||||
theme.style.page.sb = &dark_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -330,10 +330,10 @@ static void ta_init(void)
|
||||
#if USE_LV_TA
|
||||
|
||||
|
||||
theme.ta.area = &light_frame;
|
||||
theme.ta.oneline = &light_frame;
|
||||
theme.ta.cursor = NULL; /*Let library to calculate the cursor's style*/
|
||||
theme.ta.sb = &dark_frame;
|
||||
theme.style.ta.area = &light_frame;
|
||||
theme.style.ta.oneline = &light_frame;
|
||||
theme.style.ta.cursor = NULL; /*Let library to calculate the cursor's style*/
|
||||
theme.style.ta.sb = &dark_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -342,14 +342,14 @@ static void list_init(void)
|
||||
#if USE_LV_LIST != 0
|
||||
|
||||
|
||||
theme.list.sb = &dark_frame;
|
||||
theme.list.bg = &light_frame;
|
||||
theme.list.scrl = &lv_style_transp_fit;
|
||||
theme.list.btn.rel = &light_plain;
|
||||
theme.list.btn.pr = &dark_plain;
|
||||
theme.list.btn.tgl_rel = &dark_plain;
|
||||
theme.list.btn.tgl_pr = &light_plain;
|
||||
theme.list.btn.ina = &light_plain;
|
||||
theme.style.list.sb = &dark_frame;
|
||||
theme.style.list.bg = &light_frame;
|
||||
theme.style.list.scrl = &lv_style_transp_fit;
|
||||
theme.style.list.btn.rel = &light_plain;
|
||||
theme.style.list.btn.pr = &dark_plain;
|
||||
theme.style.list.btn.tgl_rel = &dark_plain;
|
||||
theme.style.list.btn.tgl_pr = &light_plain;
|
||||
theme.style.list.btn.ina = &light_plain;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -360,9 +360,9 @@ static void ddlist_init(void)
|
||||
lv_style_copy(&bg, &light_frame);
|
||||
bg.text.line_space = LV_DPI / 12;
|
||||
|
||||
theme.ddlist.bg = &bg;
|
||||
theme.ddlist.sel = &dark_plain;
|
||||
theme.ddlist.sb = &dark_frame;
|
||||
theme.style.ddlist.bg = &bg;
|
||||
theme.style.ddlist.sel = &dark_plain;
|
||||
theme.style.ddlist.sb = &dark_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -373,8 +373,8 @@ static void roller_init(void)
|
||||
lv_style_copy(&bg, &light_frame);
|
||||
bg.text.line_space = LV_DPI / 12;
|
||||
|
||||
theme.roller.bg = &bg;
|
||||
theme.roller.sel = &dark_frame;
|
||||
theme.style.roller.bg = &bg;
|
||||
theme.style.roller.sel = &dark_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -383,13 +383,13 @@ static void tabview_init(void)
|
||||
#if USE_LV_TABVIEW != 0
|
||||
|
||||
|
||||
theme.tabview.bg = &light_frame;
|
||||
theme.tabview.indic = &light_plain;
|
||||
theme.tabview.btn.bg = &lv_style_transp_fit;
|
||||
theme.tabview.btn.rel = &light_frame;
|
||||
theme.tabview.btn.pr = &dark_frame;
|
||||
theme.tabview.btn.tgl_rel = &dark_frame;
|
||||
theme.tabview.btn.tgl_pr = &light_frame;
|
||||
theme.style.tabview.bg = &light_frame;
|
||||
theme.style.tabview.indic = &light_plain;
|
||||
theme.style.tabview.btn.bg = &lv_style_transp_fit;
|
||||
theme.style.tabview.btn.rel = &light_frame;
|
||||
theme.style.tabview.btn.pr = &dark_frame;
|
||||
theme.style.tabview.btn.tgl_rel = &dark_frame;
|
||||
theme.style.tabview.btn.tgl_pr = &light_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -402,16 +402,52 @@ static void win_init(void)
|
||||
win_header.body.padding.hor = LV_DPI / 30;
|
||||
win_header.body.padding.ver = LV_DPI / 30;
|
||||
|
||||
theme.win.bg = &light_frame;
|
||||
theme.win.sb = &dark_frame;
|
||||
theme.win.header = &win_header;
|
||||
theme.win.content.bg = &lv_style_transp;
|
||||
theme.win.content.scrl = &lv_style_transp;
|
||||
theme.win.btn.rel = &light_frame;
|
||||
theme.win.btn.pr = &dark_frame;
|
||||
theme.style.win.bg = &light_frame;
|
||||
theme.style.win.sb = &dark_frame;
|
||||
theme.style.win.header = &win_header;
|
||||
theme.style.win.content.bg = &lv_style_transp;
|
||||
theme.style.win.content.scrl = &lv_style_transp;
|
||||
theme.style.win.btn.rel = &light_frame;
|
||||
theme.style.win.btn.pr = &dark_frame;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_LV_GROUP
|
||||
|
||||
static void style_mod(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void style_mod_edit(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*USE_LV_GROUP*/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
@ -435,8 +471,8 @@ lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme.style;
|
||||
for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
@ -467,6 +503,11 @@ lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font)
|
||||
tabview_init();
|
||||
win_init();
|
||||
|
||||
#if USE_LV_GROUP
|
||||
theme.group.style_mod = style_mod;
|
||||
theme.group.style_mod_edit = style_mod_edit;
|
||||
#endif
|
||||
|
||||
return &theme;
|
||||
}
|
||||
|
||||
|
@ -132,8 +132,8 @@ static void basic_init(void)
|
||||
sb.body.padding.ver = 1;
|
||||
sb.body.padding.inner = LV_DPI / 15; /*Scrollbar width*/
|
||||
|
||||
theme.bg = &bg;
|
||||
theme.panel = &panel;
|
||||
theme.style.bg = &bg;
|
||||
theme.style.panel = &panel;
|
||||
|
||||
}
|
||||
|
||||
@ -188,11 +188,11 @@ static void btn_init(void)
|
||||
btn_ina.text.font = _font;
|
||||
btn_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
|
||||
|
||||
theme.btn.rel = &btn_rel;
|
||||
theme.btn.pr = &btn_pr;
|
||||
theme.btn.tgl_rel = &btn_trel;
|
||||
theme.btn.tgl_pr = &btn_tpr;
|
||||
theme.btn.ina = &btn_ina;
|
||||
theme.style.btn.rel = &btn_rel;
|
||||
theme.style.btn.pr = &btn_pr;
|
||||
theme.style.btn.tgl_rel = &btn_trel;
|
||||
theme.style.btn.tgl_pr = &btn_tpr;
|
||||
theme.style.btn.ina = &btn_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -214,9 +214,9 @@ static void label_init(void)
|
||||
lv_style_copy(&label_hint, &label_prim);
|
||||
label_hint.text.color = lv_color_hsv_to_rgb(_hue, 20, 70);
|
||||
|
||||
theme.label.prim = &label_prim;
|
||||
theme.label.sec = &label_sec;
|
||||
theme.label.hint = &label_hint;
|
||||
theme.style.label.prim = &label_prim;
|
||||
theme.style.label.sec = &label_sec;
|
||||
theme.style.label.hint = &label_hint;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -248,8 +248,8 @@ static void bar_init(void)
|
||||
bar_indic.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 80);
|
||||
bar_indic.body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 80);
|
||||
|
||||
theme.bar.bg = &bar_bg;
|
||||
theme.bar.indic = &bar_indic;
|
||||
theme.style.bar.bg = &bar_bg;
|
||||
theme.style.bar.indic = &bar_indic;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -265,8 +265,8 @@ static void img_init(void)
|
||||
img_light.image.color = lv_color_hsv_to_rgb(_hue, 85, 65);
|
||||
img_light.image.intense = LV_OPA_80;
|
||||
|
||||
theme.img.light = &img_light;
|
||||
theme.img.dark = &img_dark;
|
||||
theme.style.img.light = &img_light;
|
||||
theme.style.img.dark = &img_dark;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ static void line_init(void)
|
||||
line_decor.line.color = lv_color_hsv_to_rgb(_hue, 50, 50);
|
||||
line_decor.line.width = 1;
|
||||
|
||||
theme.line.decor = &line_decor;
|
||||
theme.style.line.decor = &line_decor;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ static void led_init(void)
|
||||
led.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 60);
|
||||
led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 100, 100);
|
||||
|
||||
theme.led = &led;
|
||||
theme.style.led = &led;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -312,9 +312,9 @@ static void slider_init(void)
|
||||
slider_knob.body.border.color = LV_COLOR_ORANGE;
|
||||
slider_knob.body.border.opa = LV_OPA_50;
|
||||
|
||||
theme.slider.bg = &bar_bg;
|
||||
theme.slider.indic = &bar_indic;
|
||||
theme.slider.knob = &slider_knob;
|
||||
theme.style.slider.bg = &bar_bg;
|
||||
theme.style.slider.indic = &bar_indic;
|
||||
theme.style.slider.knob = &slider_knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -339,10 +339,10 @@ static void sw_init(void)
|
||||
lv_style_copy(&sw_knob, &slider_knob);
|
||||
sw_knob.body.opa = LV_OPA_80;
|
||||
|
||||
theme.sw.bg = &sw_bg;
|
||||
theme.sw.indic = &sw_indic;
|
||||
theme.sw.knob_off = &sw_knob;
|
||||
theme.sw.knob_on = &sw_knob;
|
||||
theme.style.sw.bg = &sw_bg;
|
||||
theme.style.sw.indic = &sw_indic;
|
||||
theme.style.sw.knob_off = &sw_knob;
|
||||
theme.style.sw.knob_on = &sw_knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ static void lmeter_init(void)
|
||||
lmeter_bg.line.color = LV_COLOR_HEX3(0x500);
|
||||
lmeter_bg.line.width = 2;
|
||||
|
||||
theme.lmeter = &lmeter_bg;
|
||||
theme.style.lmeter = &lmeter_bg;
|
||||
|
||||
#endif
|
||||
}
|
||||
@ -378,7 +378,7 @@ static void gauge_init(void)
|
||||
gauge_bg.text.color = lv_color_hsv_to_rgb(_hue, 10, 90);
|
||||
gauge_bg.text.font = _font;
|
||||
|
||||
theme.gauge = &gauge_bg;
|
||||
theme.style.gauge = &gauge_bg;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ static void arc_init(void)
|
||||
/*For preloader*/
|
||||
arc.body.border.width = 0;
|
||||
|
||||
theme.arc = &arc;
|
||||
theme.style.arc = &arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -403,14 +403,14 @@ static void preload_init(void)
|
||||
{
|
||||
#if USE_LV_PRELOAD != 0
|
||||
|
||||
theme.preload = theme.arc;
|
||||
theme.style.preload = theme.style.arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
theme.chart = &panel;
|
||||
theme.style.chart = &panel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -428,7 +428,7 @@ static void calendar_init(void)
|
||||
static lv_style_t week_box;
|
||||
lv_style_copy(&week_box, &def);
|
||||
week_box.body.empty = 1;
|
||||
week_box.body.border.color = theme.panel->body.border.color;
|
||||
week_box.body.border.color = theme.style.panel->body.border.color;
|
||||
week_box.body.padding.ver = LV_DPI / 20;
|
||||
|
||||
static lv_style_t today_box;
|
||||
@ -438,13 +438,13 @@ static void calendar_init(void)
|
||||
today_box.body.padding.ver = LV_DPI / 20;
|
||||
today_box.body.radius = 0;
|
||||
|
||||
theme.calendar.bg = theme.panel;
|
||||
theme.calendar.header = theme.label.prim;
|
||||
theme.calendar.inactive_days = theme.label.hint;
|
||||
theme.calendar.highlighted_days = theme.label.sec;
|
||||
theme.calendar.week_box = &week_box;
|
||||
theme.calendar.today_box = &week_box;
|
||||
theme.calendar.header_pr = theme.label.prim;
|
||||
theme.style.calendar.bg = theme.style.panel;
|
||||
theme.style.calendar.header = theme.style.label.prim;
|
||||
theme.style.calendar.inactive_days = theme.style.label.hint;
|
||||
theme.style.calendar.highlighted_days = theme.style.label.sec;
|
||||
theme.style.calendar.week_box = &week_box;
|
||||
theme.style.calendar.today_box = &week_box;
|
||||
theme.style.calendar.header_pr = theme.style.label.prim;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -490,12 +490,12 @@ static void cb_init(void)
|
||||
cb_ina.body.main_color = LV_COLOR_PURPLE;
|
||||
cb_ina.body.grad_color = LV_COLOR_SILVER;
|
||||
|
||||
theme.cb.bg = &cb_bg;
|
||||
theme.cb.box.rel = &cb_rel;
|
||||
theme.cb.box.pr = &cb_pr;
|
||||
theme.cb.box.tgl_rel = &cb_trel;
|
||||
theme.cb.box.tgl_pr = &cb_tpr;
|
||||
theme.cb.box.ina = &cb_ina;
|
||||
theme.style.cb.bg = &cb_bg;
|
||||
theme.style.cb.box.rel = &cb_rel;
|
||||
theme.style.cb.box.pr = &cb_pr;
|
||||
theme.style.cb.box.tgl_rel = &cb_trel;
|
||||
theme.style.cb.box.tgl_pr = &cb_tpr;
|
||||
theme.style.cb.box.ina = &cb_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -529,24 +529,24 @@ static void btnm_init(void)
|
||||
lv_style_copy(&btnm_ina, &btnm_rel);
|
||||
btnm_ina.text.color = lv_color_hsv_to_rgb(_hue, 10, 60);
|
||||
|
||||
theme.btnm.bg = &btnm_bg;
|
||||
theme.btnm.btn.rel = &btnm_rel;
|
||||
theme.btnm.btn.pr = &btnm_pr;
|
||||
theme.btnm.btn.tgl_rel = &btnm_trel;
|
||||
theme.btnm.btn.tgl_pr = &btnm_pr;
|
||||
theme.btnm.btn.ina = &btnm_ina;
|
||||
theme.style.btnm.bg = &btnm_bg;
|
||||
theme.style.btnm.btn.rel = &btnm_rel;
|
||||
theme.style.btnm.btn.pr = &btnm_pr;
|
||||
theme.style.btnm.btn.tgl_rel = &btnm_trel;
|
||||
theme.style.btnm.btn.tgl_pr = &btnm_pr;
|
||||
theme.style.btnm.btn.ina = &btnm_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void kb_init(void)
|
||||
{
|
||||
#if USE_LV_KB
|
||||
theme.kb.bg = &btnm_bg;
|
||||
theme.kb.btn.rel = &btnm_rel;
|
||||
theme.kb.btn.pr = &btnm_pr;
|
||||
theme.kb.btn.tgl_rel = &btnm_trel;
|
||||
theme.kb.btn.tgl_pr = &btnm_pr;
|
||||
theme.kb.btn.ina = &btnm_ina;
|
||||
theme.style.kb.bg = &btnm_bg;
|
||||
theme.style.kb.btn.rel = &btnm_rel;
|
||||
theme.style.kb.btn.pr = &btnm_pr;
|
||||
theme.style.kb.btn.tgl_rel = &btnm_trel;
|
||||
theme.style.kb.btn.tgl_pr = &btnm_pr;
|
||||
theme.style.kb.btn.ina = &btnm_ina;
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -558,38 +558,38 @@ static void mbox_init(void)
|
||||
lv_style_copy(&mbox_bg, &panel);
|
||||
mbox_bg.body.shadow.width = LV_DPI / 12;
|
||||
|
||||
theme.mbox.bg = &mbox_bg;
|
||||
theme.mbox.btn.bg = &lv_style_transp;
|
||||
theme.mbox.btn.rel = &btn_trel;
|
||||
theme.mbox.btn.pr = &btn_tpr;
|
||||
theme.style.mbox.bg = &mbox_bg;
|
||||
theme.style.mbox.btn.bg = &lv_style_transp;
|
||||
theme.style.mbox.btn.rel = &btn_trel;
|
||||
theme.style.mbox.btn.pr = &btn_tpr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void page_init(void)
|
||||
{
|
||||
#if USE_LV_PAGE
|
||||
theme.page.bg = &panel;
|
||||
theme.page.scrl = &lv_style_transp_fit;
|
||||
theme.page.sb = &sb;
|
||||
theme.style.page.bg = &panel;
|
||||
theme.style.page.scrl = &lv_style_transp_fit;
|
||||
theme.style.page.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ta_init(void)
|
||||
{
|
||||
#if USE_LV_TA
|
||||
theme.ta.area = &panel;
|
||||
theme.ta.oneline = &panel;
|
||||
theme.ta.cursor = NULL;
|
||||
theme.ta.sb = &sb;
|
||||
theme.style.ta.area = &panel;
|
||||
theme.style.ta.oneline = &panel;
|
||||
theme.style.ta.cursor = NULL;
|
||||
theme.style.ta.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void spinbox_init(void)
|
||||
{
|
||||
#if USE_LV_SPINBOX
|
||||
theme.spinbox.bg= &panel;
|
||||
theme.spinbox.cursor = theme.ta.cursor;
|
||||
theme.spinbox.sb = theme.ta.sb;
|
||||
theme.style.spinbox.bg= &panel;
|
||||
theme.style.spinbox.cursor = theme.style.ta.cursor;
|
||||
theme.style.spinbox.sb = theme.style.ta.sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -620,14 +620,14 @@ static void list_init(void)
|
||||
list_bg.body.padding.hor = 0;
|
||||
list_bg.body.padding.ver = 0;
|
||||
|
||||
theme.list.sb = &sb;
|
||||
theme.list.bg = &list_bg;
|
||||
theme.list.scrl = &lv_style_transp_tight;
|
||||
theme.list.btn.rel = &list_rel;
|
||||
theme.list.btn.pr = &list_pr;
|
||||
theme.list.btn.tgl_rel = &list_trel;
|
||||
theme.list.btn.tgl_pr = &list_tpr;
|
||||
theme.list.btn.ina = &list_ina;
|
||||
theme.style.list.sb = &sb;
|
||||
theme.style.list.bg = &list_bg;
|
||||
theme.style.list.scrl = &lv_style_transp_tight;
|
||||
theme.style.list.btn.rel = &list_rel;
|
||||
theme.style.list.btn.pr = &list_pr;
|
||||
theme.style.list.btn.tgl_rel = &list_trel;
|
||||
theme.style.list.btn.tgl_pr = &list_tpr;
|
||||
theme.style.list.btn.ina = &list_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -645,9 +645,9 @@ static void ddlist_init(void)
|
||||
ddlist_sel.body.opa = LV_OPA_COVER;
|
||||
ddlist_sel.body.radius = 0;
|
||||
|
||||
theme.ddlist.bg = &ddlist_bg;
|
||||
theme.ddlist.sel = &ddlist_sel;
|
||||
theme.ddlist.sb = &sb;
|
||||
theme.style.ddlist.bg = &ddlist_bg;
|
||||
theme.style.ddlist.sel = &ddlist_sel;
|
||||
theme.style.ddlist.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -671,8 +671,8 @@ static void roller_init(void)
|
||||
roller_sel.text.opa = LV_OPA_COVER;
|
||||
roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 70, 95);
|
||||
|
||||
theme.roller.bg = &roller_bg;
|
||||
theme.roller.sel = &roller_sel;
|
||||
theme.style.roller.bg = &roller_bg;
|
||||
theme.style.roller.sel = &roller_sel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -725,22 +725,22 @@ static void tabview_init(void)
|
||||
tab_indic.body.grad_color = lv_color_hsv_to_rgb(_hue, 80, 87);
|
||||
tab_indic.body.padding.inner = LV_DPI / 10; /*Indicator height*/
|
||||
|
||||
theme.tabview.bg = &bg;
|
||||
theme.tabview.indic = &tab_indic;
|
||||
theme.tabview.btn.bg = &lv_style_transp_tight;
|
||||
theme.tabview.btn.rel = &tab_rel;
|
||||
theme.tabview.btn.pr = &tab_pr;
|
||||
theme.tabview.btn.tgl_rel = &tab_trel;
|
||||
theme.tabview.btn.tgl_pr = &tab_tpr;
|
||||
theme.style.tabview.bg = &bg;
|
||||
theme.style.tabview.indic = &tab_indic;
|
||||
theme.style.tabview.btn.bg = &lv_style_transp_tight;
|
||||
theme.style.tabview.btn.rel = &tab_rel;
|
||||
theme.style.tabview.btn.pr = &tab_pr;
|
||||
theme.style.tabview.btn.tgl_rel = &tab_trel;
|
||||
theme.style.tabview.btn.tgl_pr = &tab_tpr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tileview_init(void)
|
||||
{
|
||||
#if USE_LV_TILEVIEW != 0
|
||||
theme.tileview.bg = &lv_style_transp_tight;
|
||||
theme.tileview.scrl = &lv_style_transp_tight;
|
||||
theme.tileview.sb = theme.page.sb;
|
||||
theme.style.tileview.bg = &lv_style_transp_tight;
|
||||
theme.style.tileview.scrl = &lv_style_transp_tight;
|
||||
theme.style.tileview.sb = theme.style.page.sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -752,8 +752,8 @@ static void table_init(void)
|
||||
cell.body.radius = 0;
|
||||
cell.body.border.width = 1;
|
||||
|
||||
theme.table.bg = &lv_style_transp_tight;
|
||||
theme.table.cell = &cell;
|
||||
theme.style.table.bg = &lv_style_transp_tight;
|
||||
theme.style.table.cell = &cell;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -771,16 +771,39 @@ static void win_init(void)
|
||||
win_header.body.border.color = lv_color_hsv_to_rgb(_hue, 20, 80);
|
||||
win_header.text.color = lv_color_hsv_to_rgb(_hue, 5, 100);
|
||||
|
||||
theme.win.bg = &bg;
|
||||
theme.win.sb = &sb;
|
||||
theme.win.header = &win_header;
|
||||
theme.win.content.bg = &lv_style_transp;
|
||||
theme.win.content.scrl = &lv_style_transp;
|
||||
theme.win.btn.rel = &btn_rel;
|
||||
theme.win.btn.pr = &btn_pr;
|
||||
theme.style.win.bg = &bg;
|
||||
theme.style.win.sb = &sb;
|
||||
theme.style.win.header = &win_header;
|
||||
theme.style.win.content.bg = &lv_style_transp;
|
||||
theme.style.win.content.scrl = &lv_style_transp;
|
||||
theme.style.win.btn.rel = &btn_rel;
|
||||
theme.style.win.btn.pr = &btn_pr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_LV_GROUP
|
||||
|
||||
static void style_mod(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
style->body.border.width = 2;
|
||||
style->body.border.color = LV_COLOR_SILVER;
|
||||
style->body.border.opa = LV_OPA_70;
|
||||
style->body.padding.hor = 0;
|
||||
style->body.padding.ver = 0;
|
||||
style->body.shadow.width = LV_DPI / 20;
|
||||
style->body.shadow.color = lv_color_hsv_to_rgb(_hue, 20, 90);
|
||||
style->body.main_color = lv_color_hsv_to_rgb(_hue, 40, 80);
|
||||
style->body.grad_color = lv_color_hsv_to_rgb(_hue, 40, 80);
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*USE_LV_GROUP*/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
@ -800,8 +823,8 @@ lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t * font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme.style;
|
||||
for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
@ -836,6 +859,11 @@ lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t * font)
|
||||
table_init();
|
||||
win_init();
|
||||
|
||||
#if USE_LV_GROUP
|
||||
theme.group.style_mod = style_mod;
|
||||
theme.group.style_mod_edit = style_mod;
|
||||
#endif
|
||||
|
||||
return &theme;
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,7 @@ static void basic_init(void)
|
||||
bg.body.grad_color = lv_color_hsv_to_rgb(_hue, 11, 30);
|
||||
bg.text.color = lv_color_hsv_to_rgb(_hue, 5, 95);
|
||||
bg.text.font = _font;
|
||||
bg.image.color = lv_color_hsv_to_rgb(_hue, 5, 95);
|
||||
|
||||
lv_style_copy(&sb, &def);
|
||||
sb.body.main_color = lv_color_hsv_to_rgb(_hue, 30, 60);
|
||||
@ -81,8 +82,8 @@ static void basic_init(void)
|
||||
panel.body.padding.hor = LV_DPI / 10;
|
||||
panel.line.color = lv_color_hsv_to_rgb(_hue, 20, 40);
|
||||
panel.line.width = 1;
|
||||
theme.bg = &bg;
|
||||
theme.panel = &def;
|
||||
theme.style.bg = &bg;
|
||||
theme.style.panel = &def;
|
||||
}
|
||||
|
||||
static void cont_init(void)
|
||||
@ -90,7 +91,7 @@ static void cont_init(void)
|
||||
#if USE_LV_CONT != 0
|
||||
|
||||
|
||||
theme.cont = &panel;
|
||||
theme.style.cont = &panel;
|
||||
#endif
|
||||
}
|
||||
static void btn_init(void)
|
||||
@ -109,6 +110,7 @@ static void btn_init(void)
|
||||
btn_rel.body.shadow.color = LV_COLOR_HEX3(0x111);
|
||||
btn_rel.body.shadow.width = LV_DPI / 30;
|
||||
btn_rel.text.color = LV_COLOR_HEX3(0xeee);
|
||||
btn_rel.image.color = LV_COLOR_HEX3(0xeee);
|
||||
|
||||
lv_style_copy(&btn_pr, &btn_rel);
|
||||
btn_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 30);
|
||||
@ -119,24 +121,27 @@ static void btn_init(void)
|
||||
btn_tgl_rel.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 40);
|
||||
btn_tgl_rel.body.shadow.width = LV_DPI / 40;
|
||||
btn_tgl_rel.text.color = LV_COLOR_HEX3(0xddd);
|
||||
btn_tgl_rel.image.color = LV_COLOR_HEX3(0xddd);
|
||||
|
||||
lv_style_copy(&btn_tgl_pr, &btn_rel);
|
||||
btn_tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 10);
|
||||
btn_tgl_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 30);
|
||||
btn_tgl_pr.body.shadow.width = LV_DPI / 30;
|
||||
btn_tgl_pr.text.color = LV_COLOR_HEX3(0xddd);
|
||||
btn_tgl_pr.image.color = LV_COLOR_HEX3(0xddd);
|
||||
|
||||
lv_style_copy(&btn_ina, &btn_rel);
|
||||
btn_ina.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 20);
|
||||
btn_ina.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 20);
|
||||
btn_ina.text.color = LV_COLOR_HEX3(0xaaa);
|
||||
btn_ina.body.shadow.width = 0;
|
||||
btn_ina.text.color = LV_COLOR_HEX3(0xaaa);
|
||||
btn_ina.image.color = LV_COLOR_HEX3(0xaaa);
|
||||
|
||||
theme.btn.rel = &btn_rel;
|
||||
theme.btn.pr = &btn_pr;
|
||||
theme.btn.tgl_rel = &btn_tgl_rel;
|
||||
theme.btn.tgl_pr = &btn_tgl_pr;
|
||||
theme.btn.ina = &btn_ina;
|
||||
theme.style.btn.rel = &btn_rel;
|
||||
theme.style.btn.pr = &btn_pr;
|
||||
theme.style.btn.tgl_rel = &btn_tgl_rel;
|
||||
theme.style.btn.tgl_pr = &btn_tgl_pr;
|
||||
theme.style.btn.ina = &btn_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -154,9 +159,9 @@ static void label_init(void)
|
||||
lv_style_copy(&hint, &bg);
|
||||
hint.text.color = lv_color_hsv_to_rgb(_hue, 20, 55);
|
||||
|
||||
theme.label.prim = &prim;
|
||||
theme.label.sec = &sec;
|
||||
theme.label.hint = &hint;
|
||||
theme.style.label.prim = &prim;
|
||||
theme.style.label.sec = &sec;
|
||||
theme.style.label.hint = &hint;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -165,7 +170,7 @@ static void line_init(void)
|
||||
#if USE_LV_LINE != 0
|
||||
|
||||
|
||||
theme.line.decor = &def;
|
||||
theme.style.line.decor = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -183,7 +188,7 @@ static void led_init(void)
|
||||
led.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 60);
|
||||
led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 100, 100);
|
||||
|
||||
theme.led = &led;
|
||||
theme.style.led = &led;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -192,8 +197,8 @@ static void img_init(void)
|
||||
#if USE_LV_IMG != 0
|
||||
|
||||
|
||||
theme.img.light = &def;
|
||||
theme.img.dark = &def;
|
||||
theme.style.img.light = &def;
|
||||
theme.style.img.dark = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -215,8 +220,8 @@ static void bar_init(void)
|
||||
bar_indic.body.padding.hor = 0;
|
||||
bar_indic.body.padding.ver = 0;
|
||||
|
||||
theme.bar.bg = &bar_bg;
|
||||
theme.bar.indic = &bar_indic;
|
||||
theme.style.bar.bg = &bar_bg;
|
||||
theme.style.bar.indic = &bar_indic;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -227,9 +232,9 @@ static void slider_init(void)
|
||||
lv_style_copy(&slider_knob, &btn_rel);
|
||||
slider_knob.body.radius = LV_RADIUS_CIRCLE;
|
||||
|
||||
theme.slider.bg = &bar_bg;
|
||||
theme.slider.indic = &bar_indic;
|
||||
theme.slider.knob = &slider_knob;
|
||||
theme.style.slider.bg = &bar_bg;
|
||||
theme.style.slider.indic = &bar_indic;
|
||||
theme.style.slider.knob = &slider_knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -238,10 +243,10 @@ static void sw_init(void)
|
||||
#if USE_LV_SW != 0
|
||||
|
||||
|
||||
theme.sw.bg = &bar_bg;
|
||||
theme.sw.indic = &bar_indic;
|
||||
theme.sw.knob_off = &slider_knob;
|
||||
theme.sw.knob_on = &slider_knob;
|
||||
theme.style.sw.bg = &bar_bg;
|
||||
theme.style.sw.indic = &bar_indic;
|
||||
theme.style.sw.knob_off = &slider_knob;
|
||||
theme.style.sw.knob_on = &slider_knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -259,7 +264,7 @@ static void lmeter_init(void)
|
||||
lmeter_bg.line.width = 1;
|
||||
lmeter_bg.text.color = LV_COLOR_HEX3(0xddd);
|
||||
|
||||
theme.lmeter = &lmeter_bg;
|
||||
theme.style.lmeter = &lmeter_bg;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -274,7 +279,7 @@ static void gauge_init(void)
|
||||
gauge_bg.line.width = 1;
|
||||
gauge_bg.text.color = LV_COLOR_HEX3(0xddd);
|
||||
|
||||
theme.gauge = &gauge_bg;
|
||||
theme.style.gauge = &gauge_bg;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -294,7 +299,7 @@ static void arc_init(void)
|
||||
arc.body.padding.hor = 1;
|
||||
arc.body.padding.ver = 1;
|
||||
|
||||
theme.arc = &arc;
|
||||
theme.style.arc = &arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -302,14 +307,14 @@ static void preload_init(void)
|
||||
{
|
||||
#if USE_LV_PRELOAD != 0
|
||||
|
||||
theme.preload = theme.arc;
|
||||
theme.style.preload = theme.style.arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
theme.chart = &panel;
|
||||
theme.style.chart = &panel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -361,13 +366,13 @@ static void calendar_init(void)
|
||||
lv_style_copy(&ina_days, &bg);
|
||||
ina_days.text.color = lv_color_hsv_to_rgb(_hue, 0, 60);
|
||||
|
||||
theme.calendar.bg = &cal_bg;
|
||||
theme.calendar.header = &cal_header;
|
||||
theme.calendar.week_box = &week_box;
|
||||
theme.calendar.today_box = &today_box;
|
||||
theme.calendar.highlighted_days = &highlighted_days;
|
||||
theme.calendar.day_names = &cal_bg;
|
||||
theme.calendar.inactive_days = &ina_days;
|
||||
theme.style.calendar.bg = &cal_bg;
|
||||
theme.style.calendar.header = &cal_header;
|
||||
theme.style.calendar.week_box = &week_box;
|
||||
theme.style.calendar.today_box = &today_box;
|
||||
theme.style.calendar.highlighted_days = &highlighted_days;
|
||||
theme.style.calendar.day_names = &cal_bg;
|
||||
theme.style.calendar.inactive_days = &ina_days;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -407,12 +412,12 @@ static void cb_init(void)
|
||||
ina.body.grad_color = LV_COLOR_HEX3(0x777);
|
||||
ina.body.border.width = 0;
|
||||
|
||||
theme.cb.bg = &lv_style_transp;
|
||||
theme.cb.box.rel = &rel;
|
||||
theme.cb.box.pr = ≺
|
||||
theme.cb.box.tgl_rel = &tgl_rel;
|
||||
theme.cb.box.tgl_pr = &tgl_pr;
|
||||
theme.cb.box.ina = &def;
|
||||
theme.style.cb.bg = &lv_style_transp;
|
||||
theme.style.cb.box.rel = &rel;
|
||||
theme.style.cb.box.pr = ≺
|
||||
theme.style.cb.box.tgl_rel = &tgl_rel;
|
||||
theme.style.cb.box.tgl_pr = &tgl_pr;
|
||||
theme.style.cb.box.ina = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -453,24 +458,24 @@ static void btnm_init(void)
|
||||
ina.body.border.width = rel.body.border.width;
|
||||
ina.body.radius = rel.body.radius;
|
||||
|
||||
theme.btnm.bg = &btnm_bg;
|
||||
theme.btnm.btn.rel = &rel;
|
||||
theme.btnm.btn.pr = ≺
|
||||
theme.btnm.btn.tgl_rel = &tgl_rel;
|
||||
theme.btnm.btn.tgl_pr = &tgl_pr;
|
||||
theme.btnm.btn.ina = &ina;
|
||||
theme.style.btnm.bg = &btnm_bg;
|
||||
theme.style.btnm.btn.rel = &rel;
|
||||
theme.style.btnm.btn.pr = ≺
|
||||
theme.style.btnm.btn.tgl_rel = &tgl_rel;
|
||||
theme.style.btnm.btn.tgl_pr = &tgl_pr;
|
||||
theme.style.btnm.btn.ina = &ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void kb_init(void)
|
||||
{
|
||||
#if USE_LV_KB
|
||||
theme.kb.bg = &bg;
|
||||
theme.kb.btn.rel = &btn_rel;
|
||||
theme.kb.btn.pr = &btn_pr;
|
||||
theme.kb.btn.tgl_rel = &btn_tgl_rel;
|
||||
theme.kb.btn.tgl_pr = &btn_tgl_pr;
|
||||
theme.kb.btn.ina = &btn_ina;
|
||||
theme.style.kb.bg = &bg;
|
||||
theme.style.kb.btn.rel = &btn_rel;
|
||||
theme.style.kb.btn.pr = &btn_pr;
|
||||
theme.style.kb.btn.tgl_rel = &btn_tgl_rel;
|
||||
theme.style.kb.btn.tgl_pr = &btn_tgl_pr;
|
||||
theme.style.kb.btn.ina = &btn_ina;
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -487,10 +492,10 @@ static void mbox_init(void)
|
||||
mbox_bg.body.shadow.width = LV_DPI / 10;
|
||||
mbox_bg.body.shadow.color = LV_COLOR_HEX3(0x222);
|
||||
mbox_bg.body.radius = LV_DPI / 20;
|
||||
theme.mbox.bg = &mbox_bg;
|
||||
theme.mbox.btn.bg = &lv_style_transp;
|
||||
theme.mbox.btn.rel = &btn_rel;
|
||||
theme.mbox.btn.pr = &btn_pr;
|
||||
theme.style.mbox.bg = &mbox_bg;
|
||||
theme.style.mbox.btn.bg = &lv_style_transp;
|
||||
theme.style.mbox.btn.rel = &btn_rel;
|
||||
theme.style.mbox.btn.pr = &btn_pr;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -506,28 +511,28 @@ static void page_init(void)
|
||||
page_scrl.body.border.width = 1;
|
||||
page_scrl.body.radius = LV_DPI / 20;
|
||||
|
||||
theme.page.bg = &panel;
|
||||
theme.page.scrl = &page_scrl;
|
||||
theme.page.sb = &sb;
|
||||
theme.style.page.bg = &panel;
|
||||
theme.style.page.scrl = &page_scrl;
|
||||
theme.style.page.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ta_init(void)
|
||||
{
|
||||
#if USE_LV_TA
|
||||
theme.ta.area = &panel;
|
||||
theme.ta.oneline = &panel;
|
||||
theme.ta.cursor = NULL;
|
||||
theme.ta.sb = &def;
|
||||
theme.style.ta.area = &panel;
|
||||
theme.style.ta.oneline = &panel;
|
||||
theme.style.ta.cursor = NULL;
|
||||
theme.style.ta.sb = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void spinbox_init(void)
|
||||
{
|
||||
#if USE_LV_SPINBOX
|
||||
theme.spinbox.bg= &panel;
|
||||
theme.spinbox.cursor = theme.ta.cursor;
|
||||
theme.spinbox.sb = theme.ta.sb;
|
||||
theme.style.spinbox.bg= &panel;
|
||||
theme.style.spinbox.cursor = theme.style.ta.cursor;
|
||||
theme.style.spinbox.sb = theme.style.ta.sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -571,14 +576,14 @@ static void list_init(void)
|
||||
list_btn_tgl_pr.body.main_color = btn_tgl_pr.body.main_color;
|
||||
list_btn_tgl_pr.body.grad_color = btn_tgl_pr.body.grad_color;
|
||||
|
||||
theme.list.sb = &sb;
|
||||
theme.list.bg = &list_bg;
|
||||
theme.list.scrl = &lv_style_transp_tight;
|
||||
theme.list.btn.rel = &list_btn_rel;
|
||||
theme.list.btn.pr = &list_btn_pr;
|
||||
theme.list.btn.tgl_rel = &list_btn_tgl_rel;
|
||||
theme.list.btn.tgl_pr = &list_btn_tgl_pr;
|
||||
theme.list.btn.ina = &def;
|
||||
theme.style.list.sb = &sb;
|
||||
theme.style.list.bg = &list_bg;
|
||||
theme.style.list.scrl = &lv_style_transp_tight;
|
||||
theme.style.list.btn.rel = &list_btn_rel;
|
||||
theme.style.list.btn.pr = &list_btn_pr;
|
||||
theme.style.list.btn.tgl_rel = &list_btn_tgl_rel;
|
||||
theme.style.list.btn.tgl_pr = &list_btn_tgl_pr;
|
||||
theme.style.list.btn.ina = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -596,9 +601,9 @@ static void ddlist_init(void)
|
||||
ddlist_sel.body.grad_color = lv_color_hsv_to_rgb(_hue, 20, 50);
|
||||
ddlist_sel.body.radius = 0;
|
||||
|
||||
theme.ddlist.bg = &ddlist_bg;
|
||||
theme.ddlist.sel = &ddlist_sel;
|
||||
theme.ddlist.sb = &def;
|
||||
theme.style.ddlist.bg = &ddlist_bg;
|
||||
theme.style.ddlist.sel = &ddlist_sel;
|
||||
theme.style.ddlist.sb = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -613,30 +618,30 @@ static void roller_init(void)
|
||||
roller_bg.text.color = lv_color_hsv_to_rgb(_hue, 5, 70);
|
||||
roller_bg.text.opa = LV_OPA_60;
|
||||
|
||||
theme.roller.bg = &roller_bg;
|
||||
theme.roller.sel = &ddlist_sel;
|
||||
theme.style.roller.bg = &roller_bg;
|
||||
theme.style.roller.sel = &ddlist_sel;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tabview_init(void)
|
||||
{
|
||||
#if USE_LV_TABVIEW != 0
|
||||
theme.tabview.bg = &bg;
|
||||
theme.tabview.indic = &lv_style_transp;
|
||||
theme.tabview.btn.bg = &lv_style_transp;
|
||||
theme.tabview.btn.rel = &btn_rel;
|
||||
theme.tabview.btn.pr = &btn_pr;
|
||||
theme.tabview.btn.tgl_rel = &btn_tgl_rel;
|
||||
theme.tabview.btn.tgl_pr = &btn_tgl_pr;
|
||||
theme.style.tabview.bg = &bg;
|
||||
theme.style.tabview.indic = &lv_style_transp;
|
||||
theme.style.tabview.btn.bg = &lv_style_transp;
|
||||
theme.style.tabview.btn.rel = &btn_rel;
|
||||
theme.style.tabview.btn.pr = &btn_pr;
|
||||
theme.style.tabview.btn.tgl_rel = &btn_tgl_rel;
|
||||
theme.style.tabview.btn.tgl_pr = &btn_tgl_pr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tileview_init(void)
|
||||
{
|
||||
#if USE_LV_TILEVIEW != 0
|
||||
theme.tileview.bg = &lv_style_transp_tight;
|
||||
theme.tileview.scrl = &lv_style_transp_tight;
|
||||
theme.tileview.sb = theme.page.sb;
|
||||
theme.style.tileview.bg = &lv_style_transp_tight;
|
||||
theme.style.tileview.scrl = &lv_style_transp_tight;
|
||||
theme.style.tileview.sb = theme.style.page.sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -651,8 +656,8 @@ static void table_init(void)
|
||||
cell.body.padding.ver = LV_DPI / 12;
|
||||
|
||||
|
||||
theme.table.bg = &lv_style_transp_tight;
|
||||
theme.table.cell = &cell;
|
||||
theme.style.table.bg = &lv_style_transp_tight;
|
||||
theme.style.table.cell = &cell;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -678,17 +683,54 @@ static void win_init(void)
|
||||
win_btn_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 10);
|
||||
win_btn_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 10);
|
||||
win_btn_pr.text.color = LV_COLOR_HEX3(0xaaa);
|
||||
win_btn_pr.image.color = LV_COLOR_HEX3(0xaaa);
|
||||
|
||||
theme.win.bg = &win_bg;
|
||||
theme.win.sb = &sb;
|
||||
theme.win.header = &win_header;
|
||||
theme.win.content.bg = &lv_style_transp;
|
||||
theme.win.content.scrl = &lv_style_transp;
|
||||
theme.win.btn.rel = &lv_style_transp;
|
||||
theme.win.btn.pr = &win_btn_pr;
|
||||
theme.style.win.bg = &win_bg;
|
||||
theme.style.win.sb = &sb;
|
||||
theme.style.win.header = &win_header;
|
||||
theme.style.win.content.bg = &lv_style_transp;
|
||||
theme.style.win.content.scrl = &lv_style_transp;
|
||||
theme.style.win.btn.rel = &lv_style_transp;
|
||||
theme.style.win.btn.pr = &win_btn_pr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_LV_GROUP
|
||||
|
||||
static void style_mod(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = lv_color_hsv_to_rgb(_hue, 80, 70);
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void style_mod_edit(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_GREEN;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*USE_LV_GROUP*/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
@ -710,8 +752,8 @@ lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t * font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme.style;
|
||||
for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
@ -747,6 +789,11 @@ lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t * font)
|
||||
table_init();
|
||||
win_init();
|
||||
|
||||
#if USE_LV_GROUP
|
||||
theme.group.style_mod = style_mod;
|
||||
theme.group.style_mod_edit = style_mod_edit;
|
||||
#endif
|
||||
|
||||
return &theme;
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,8 @@ static void basic_init(void)
|
||||
lv_style_copy(&def, &lv_style_pretty); /*Initialize the default style*/
|
||||
def.text.font = _font;
|
||||
|
||||
theme.bg = &def;
|
||||
theme.panel = &def;
|
||||
theme.style.bg = &def;
|
||||
theme.style.panel = &def;
|
||||
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ static void cont_init(void)
|
||||
#if USE_LV_CONT != 0
|
||||
|
||||
|
||||
theme.cont = &def;
|
||||
theme.style.cont = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -66,22 +66,22 @@ static void btn_init(void)
|
||||
#if USE_LV_BTN != 0
|
||||
|
||||
|
||||
theme.btn.rel = &def;
|
||||
theme.btn.pr = &def;
|
||||
theme.btn.tgl_rel = &def;
|
||||
theme.btn.tgl_pr = &def;
|
||||
theme.btn.ina = &def;
|
||||
theme.style.btn.rel = &def;
|
||||
theme.style.btn.pr = &def;
|
||||
theme.style.btn.tgl_rel = &def;
|
||||
theme.style.btn.tgl_pr = &def;
|
||||
theme.style.btn.ina = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void imgbtn_init(void)
|
||||
{
|
||||
#if USE_LV_IMGBTN != 0
|
||||
theme.imgbtn.rel = &def;
|
||||
theme.imgbtn.pr = &def;
|
||||
theme.imgbtn.tgl_rel = &def;
|
||||
theme.imgbtn.tgl_pr = &def;
|
||||
theme.imgbtn.ina = &def;
|
||||
theme.style.imgbtn.rel = &def;
|
||||
theme.style.imgbtn.pr = &def;
|
||||
theme.style.imgbtn.tgl_rel = &def;
|
||||
theme.style.imgbtn.tgl_pr = &def;
|
||||
theme.style.imgbtn.ina = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -90,9 +90,9 @@ static void label_init(void)
|
||||
#if USE_LV_LABEL != 0
|
||||
|
||||
|
||||
theme.label.prim = &def;
|
||||
theme.label.sec = &def;
|
||||
theme.label.hint = &def;
|
||||
theme.style.label.prim = &def;
|
||||
theme.style.label.sec = &def;
|
||||
theme.style.label.hint = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -101,8 +101,8 @@ static void img_init(void)
|
||||
#if USE_LV_IMG != 0
|
||||
|
||||
|
||||
theme.img.light = &def;
|
||||
theme.img.dark = &def;
|
||||
theme.style.img.light = &def;
|
||||
theme.style.img.dark = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ static void line_init(void)
|
||||
#if USE_LV_LINE != 0
|
||||
|
||||
|
||||
theme.line.decor = &def;
|
||||
theme.style.line.decor = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ static void led_init(void)
|
||||
#if USE_LV_LED != 0
|
||||
|
||||
|
||||
theme.led = &def;
|
||||
theme.style.led = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -129,8 +129,8 @@ static void bar_init(void)
|
||||
#if USE_LV_BAR
|
||||
|
||||
|
||||
theme.bar.bg = &def;
|
||||
theme.bar.indic = &def;
|
||||
theme.style.bar.bg = &def;
|
||||
theme.style.bar.indic = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -139,9 +139,9 @@ static void slider_init(void)
|
||||
#if USE_LV_SLIDER != 0
|
||||
|
||||
|
||||
theme.slider.bg = &def;
|
||||
theme.slider.indic = &def;
|
||||
theme.slider.knob = &def;
|
||||
theme.style.slider.bg = &def;
|
||||
theme.style.slider.indic = &def;
|
||||
theme.style.slider.knob = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -150,10 +150,10 @@ static void sw_init(void)
|
||||
#if USE_LV_SW != 0
|
||||
|
||||
|
||||
theme.sw.bg = &def;
|
||||
theme.sw.indic = &def;
|
||||
theme.sw.knob_off = &def;
|
||||
theme.sw.knob_on = &def;
|
||||
theme.style.sw.bg = &def;
|
||||
theme.style.sw.indic = &def;
|
||||
theme.style.sw.knob_off = &def;
|
||||
theme.style.sw.knob_on = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ static void lmeter_init(void)
|
||||
#if USE_LV_LMETER != 0
|
||||
|
||||
|
||||
theme.lmeter = &def;
|
||||
theme.style.lmeter = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ static void gauge_init(void)
|
||||
#if USE_LV_GAUGE != 0
|
||||
|
||||
|
||||
theme.gauge = &def;
|
||||
theme.style.gauge = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ static void arc_init(void)
|
||||
#if USE_LV_ARC != 0
|
||||
|
||||
|
||||
theme.arc = &def;
|
||||
theme.style.arc = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ static void preload_init(void)
|
||||
#if USE_LV_PRELOAD != 0
|
||||
|
||||
|
||||
theme.preload = &def;
|
||||
theme.style.preload = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
|
||||
theme.chart = &def;
|
||||
theme.style.chart = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -206,14 +206,14 @@ static void calendar_init(void)
|
||||
{
|
||||
#if USE_LV_CALENDAR
|
||||
|
||||
theme.calendar.bg = theme.panel;
|
||||
theme.calendar.header = &def;
|
||||
theme.calendar.inactive_days = &def;
|
||||
theme.calendar.highlighted_days = &def;
|
||||
theme.calendar.week_box = &def;
|
||||
theme.calendar.today_box = &def;
|
||||
theme.calendar.header_pr = &def;
|
||||
theme.calendar.day_names = &def;
|
||||
theme.style.calendar.bg = theme.style.panel;
|
||||
theme.style.calendar.header = &def;
|
||||
theme.style.calendar.inactive_days = &def;
|
||||
theme.style.calendar.highlighted_days = &def;
|
||||
theme.style.calendar.week_box = &def;
|
||||
theme.style.calendar.today_box = &def;
|
||||
theme.style.calendar.header_pr = &def;
|
||||
theme.style.calendar.day_names = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -222,12 +222,12 @@ static void cb_init(void)
|
||||
#if USE_LV_CB != 0
|
||||
|
||||
|
||||
theme.cb.bg = &def;
|
||||
theme.cb.box.rel = &def;
|
||||
theme.cb.box.pr = &def;
|
||||
theme.cb.box.tgl_rel = &def;
|
||||
theme.cb.box.tgl_pr = &def;
|
||||
theme.cb.box.ina = &def;
|
||||
theme.style.cb.bg = &def;
|
||||
theme.style.cb.box.rel = &def;
|
||||
theme.style.cb.box.pr = &def;
|
||||
theme.style.cb.box.tgl_rel = &def;
|
||||
theme.style.cb.box.tgl_pr = &def;
|
||||
theme.style.cb.box.ina = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -237,12 +237,12 @@ static void btnm_init(void)
|
||||
#if USE_LV_BTNM
|
||||
|
||||
|
||||
theme.btnm.bg = &def;
|
||||
theme.btnm.btn.rel = &def;
|
||||
theme.btnm.btn.pr = &def;
|
||||
theme.btnm.btn.tgl_rel = &def;
|
||||
theme.btnm.btn.tgl_pr = &def;
|
||||
theme.btnm.btn.ina = &def;
|
||||
theme.style.btnm.bg = &def;
|
||||
theme.style.btnm.btn.rel = &def;
|
||||
theme.style.btnm.btn.pr = &def;
|
||||
theme.style.btnm.btn.tgl_rel = &def;
|
||||
theme.style.btnm.btn.tgl_pr = &def;
|
||||
theme.style.btnm.btn.ina = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -251,12 +251,12 @@ static void kb_init(void)
|
||||
#if USE_LV_KB
|
||||
|
||||
|
||||
theme.kb.bg = &def;
|
||||
theme.kb.btn.rel = &def;
|
||||
theme.kb.btn.pr = &def;
|
||||
theme.kb.btn.tgl_rel = &def;
|
||||
theme.kb.btn.tgl_pr = &def;
|
||||
theme.kb.btn.ina = &def;
|
||||
theme.style.kb.bg = &def;
|
||||
theme.style.kb.btn.rel = &def;
|
||||
theme.style.kb.btn.pr = &def;
|
||||
theme.style.kb.btn.tgl_rel = &def;
|
||||
theme.style.kb.btn.tgl_pr = &def;
|
||||
theme.style.kb.btn.ina = &def;
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -266,10 +266,10 @@ static void mbox_init(void)
|
||||
#if USE_LV_MBOX
|
||||
|
||||
|
||||
theme.mbox.bg = &def;
|
||||
theme.mbox.btn.bg = &def;
|
||||
theme.mbox.btn.rel = &def;
|
||||
theme.mbox.btn.pr = &def;
|
||||
theme.style.mbox.bg = &def;
|
||||
theme.style.mbox.btn.bg = &def;
|
||||
theme.style.mbox.btn.rel = &def;
|
||||
theme.style.mbox.btn.pr = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -278,9 +278,9 @@ static void page_init(void)
|
||||
#if USE_LV_PAGE
|
||||
|
||||
|
||||
theme.page.bg = &def;
|
||||
theme.page.scrl = &def;
|
||||
theme.page.sb = &def;
|
||||
theme.style.page.bg = &def;
|
||||
theme.style.page.scrl = &def;
|
||||
theme.style.page.sb = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -289,10 +289,10 @@ static void ta_init(void)
|
||||
#if USE_LV_TA
|
||||
|
||||
|
||||
theme.ta.area = &def;
|
||||
theme.ta.oneline = &def;
|
||||
theme.ta.cursor = NULL; /*Let library to calculate the cursor's style*/
|
||||
theme.ta.sb = &def;
|
||||
theme.style.ta.area = &def;
|
||||
theme.style.ta.oneline = &def;
|
||||
theme.style.ta.cursor = NULL; /*Let library to calculate the cursor's style*/
|
||||
theme.style.ta.sb = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -301,14 +301,14 @@ static void list_init(void)
|
||||
#if USE_LV_LIST != 0
|
||||
|
||||
|
||||
theme.list.sb = &def;
|
||||
theme.list.bg = &def;
|
||||
theme.list.scrl = &def;
|
||||
theme.list.btn.rel = &def;
|
||||
theme.list.btn.pr = &def;
|
||||
theme.list.btn.tgl_rel = &def;
|
||||
theme.list.btn.tgl_pr = &def;
|
||||
theme.list.btn.ina = &def;
|
||||
theme.style.list.sb = &def;
|
||||
theme.style.list.bg = &def;
|
||||
theme.style.list.scrl = &def;
|
||||
theme.style.list.btn.rel = &def;
|
||||
theme.style.list.btn.pr = &def;
|
||||
theme.style.list.btn.tgl_rel = &def;
|
||||
theme.style.list.btn.tgl_pr = &def;
|
||||
theme.style.list.btn.ina = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -317,9 +317,9 @@ static void ddlist_init(void)
|
||||
#if USE_LV_DDLIST != 0
|
||||
|
||||
|
||||
theme.ddlist.bg = &def;
|
||||
theme.ddlist.sel = &def;
|
||||
theme.ddlist.sb = &def;
|
||||
theme.style.ddlist.bg = &def;
|
||||
theme.style.ddlist.sel = &def;
|
||||
theme.style.ddlist.sb = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -328,8 +328,8 @@ static void roller_init(void)
|
||||
#if USE_LV_ROLLER != 0
|
||||
|
||||
|
||||
theme.roller.bg = &def;
|
||||
theme.roller.sel = &def;
|
||||
theme.style.roller.bg = &def;
|
||||
theme.style.roller.sel = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -338,13 +338,13 @@ static void tabview_init(void)
|
||||
#if USE_LV_TABVIEW != 0
|
||||
|
||||
|
||||
theme.tabview.bg = &def;
|
||||
theme.tabview.indic = &def;
|
||||
theme.tabview.btn.bg = &def;
|
||||
theme.tabview.btn.rel = &def;
|
||||
theme.tabview.btn.pr = &def;
|
||||
theme.tabview.btn.tgl_rel = &def;
|
||||
theme.tabview.btn.tgl_pr = &def;
|
||||
theme.style.tabview.bg = &def;
|
||||
theme.style.tabview.indic = &def;
|
||||
theme.style.tabview.btn.bg = &def;
|
||||
theme.style.tabview.btn.rel = &def;
|
||||
theme.style.tabview.btn.pr = &def;
|
||||
theme.style.tabview.btn.tgl_rel = &def;
|
||||
theme.style.tabview.btn.tgl_pr = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -354,16 +354,64 @@ static void win_init(void)
|
||||
#if USE_LV_WIN != 0
|
||||
|
||||
|
||||
theme.win.bg = &def;
|
||||
theme.win.sb = &def;
|
||||
theme.win.header = &def;
|
||||
theme.win.content.bg = &def;
|
||||
theme.win.content.scrl = &def;
|
||||
theme.win.btn.rel = &def;
|
||||
theme.win.btn.pr = &def;
|
||||
theme.style.win.bg = &def;
|
||||
theme.style.win.sb = &def;
|
||||
theme.style.win.header = &def;
|
||||
theme.style.win.content.bg = &def;
|
||||
theme.style.win.content.scrl = &def;
|
||||
theme.style.win.btn.rel = &def;
|
||||
theme.style.win.btn.pr = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_LV_GROUP
|
||||
|
||||
static void style_mod(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_ORANGE;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
|
||||
style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70);
|
||||
style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70);
|
||||
style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60);
|
||||
|
||||
style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70);
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void style_mod_edit(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_GREEN;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
|
||||
style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60);
|
||||
|
||||
style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*USE_LV_GROUP*/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
@ -385,8 +433,8 @@ lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t * font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme.style;
|
||||
for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
@ -419,6 +467,11 @@ lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t * font)
|
||||
tabview_init();
|
||||
win_init();
|
||||
|
||||
#if USE_LV_GROUP
|
||||
theme.group.style_mod = style_mod;
|
||||
theme.group.style_mod_edit = style_mod_edit;
|
||||
#endif
|
||||
|
||||
return &theme;
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@ static void basic_init(void)
|
||||
def.body.border.opa = LV_OPA_COVER;
|
||||
def.text.font = _font;
|
||||
def.text.color = LV_COLOR_HEX3(0x444);
|
||||
def.image.color = LV_COLOR_HEX3(0x444);
|
||||
|
||||
lv_style_copy(&bg, &def);
|
||||
bg.body.main_color = LV_COLOR_WHITE;
|
||||
@ -78,8 +79,8 @@ static void basic_init(void)
|
||||
sb.body.radius = LV_RADIUS_CIRCLE;
|
||||
sb.body.padding.inner = LV_DPI / 10;
|
||||
|
||||
theme.bg = &bg;
|
||||
theme.panel = &panel;
|
||||
theme.style.bg = &bg;
|
||||
theme.style.panel = &panel;
|
||||
}
|
||||
|
||||
static void cont_init(void)
|
||||
@ -87,7 +88,7 @@ static void cont_init(void)
|
||||
#if USE_LV_CONT != 0
|
||||
|
||||
|
||||
theme.cont = theme.panel;
|
||||
theme.style.cont = theme.style.panel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -106,25 +107,29 @@ static void btn_init(void)
|
||||
rel.body.padding.hor = LV_DPI / 4;
|
||||
rel.body.padding.ver = LV_DPI / 8;
|
||||
rel.text.color = lv_color_hsv_to_rgb(_hue, 40, 90);
|
||||
rel.image.color = lv_color_hsv_to_rgb(_hue, 40, 90);
|
||||
|
||||
lv_style_copy(&pr, &rel);
|
||||
pr.body.border.color = lv_color_hsv_to_rgb(_hue, 40, 60);
|
||||
pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 60);
|
||||
pr.body.shadow.width = 0;
|
||||
pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 60);
|
||||
pr.image.color = lv_color_hsv_to_rgb(_hue, 40, 60);
|
||||
|
||||
lv_style_copy(&tgl_pr, &pr);
|
||||
tgl_pr.body.border.color = lv_color_hsv_to_rgb(_hue, 40, 50);
|
||||
tgl_pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 50);
|
||||
tgl_pr.image.color = lv_color_hsv_to_rgb(_hue, 40, 50);
|
||||
|
||||
lv_style_copy(&ina, &tgl_pr);
|
||||
ina.body.border.color = LV_COLOR_HEX3(0xbbb);
|
||||
ina.text.color = LV_COLOR_HEX3(0xbbb);
|
||||
ina.image.color = LV_COLOR_HEX3(0xbbb);
|
||||
|
||||
theme.btn.rel = &rel;
|
||||
theme.btn.pr = ≺
|
||||
theme.btn.tgl_rel = ≺
|
||||
theme.btn.tgl_pr = &tgl_pr;
|
||||
theme.btn.ina = &ina;
|
||||
theme.style.btn.rel = &rel;
|
||||
theme.style.btn.pr = ≺
|
||||
theme.style.btn.tgl_rel = ≺
|
||||
theme.style.btn.tgl_pr = &tgl_pr;
|
||||
theme.style.btn.ina = &ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -140,9 +145,9 @@ static void label_init(void)
|
||||
sec.text.color = lv_color_hsv_to_rgb(_hue, 50, 80);
|
||||
hint.text.color = lv_color_hsv_to_rgb(_hue, 25, 85);
|
||||
|
||||
theme.label.prim = &prim;
|
||||
theme.label.sec = &sec;
|
||||
theme.label.hint = &hint;
|
||||
theme.style.label.prim = &prim;
|
||||
theme.style.label.sec = &sec;
|
||||
theme.style.label.hint = &hint;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -158,8 +163,8 @@ static void img_init(void)
|
||||
img_light.image.color = lv_color_hsv_to_rgb(_hue, 85, 55);
|
||||
img_light.image.intense = LV_OPA_80;
|
||||
|
||||
theme.img.light = &img_light;
|
||||
theme.img.dark = &img_dark;
|
||||
theme.style.img.light = &img_light;
|
||||
theme.style.img.dark = &img_dark;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -168,7 +173,7 @@ static void line_init(void)
|
||||
#if USE_LV_LINE != 0
|
||||
|
||||
|
||||
theme.line.decor = &def;
|
||||
theme.style.line.decor = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -187,7 +192,7 @@ static void led_init(void)
|
||||
led.body.border.color = lv_color_hsv_to_rgb(_hue, 60, 60);
|
||||
led.body.shadow.color = lv_color_hsv_to_rgb(_hue, 80, 100);
|
||||
|
||||
theme.led = &led;
|
||||
theme.style.led = &led;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -212,8 +217,8 @@ static void bar_init(void)
|
||||
indic.body.padding.ver = LV_DPI / 20;
|
||||
|
||||
|
||||
theme.bar.bg = &bg;
|
||||
theme.bar.indic = &indic;
|
||||
theme.style.bar.bg = &bg;
|
||||
theme.style.bar.indic = &indic;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -223,14 +228,14 @@ static void slider_init(void)
|
||||
static lv_style_t knob;
|
||||
|
||||
lv_style_copy(&knob, &def);
|
||||
knob.body.main_color = theme.bar.indic->body.main_color;
|
||||
knob.body.main_color = theme.style.bar.indic->body.main_color;
|
||||
knob.body.grad_color = knob.body.main_color;
|
||||
knob.body.radius = LV_RADIUS_CIRCLE;
|
||||
knob.body.border.width = 0;
|
||||
|
||||
theme.slider.bg = theme.bar.bg;
|
||||
theme.slider.indic = theme.bar.indic;
|
||||
theme.slider.knob = &knob;
|
||||
theme.style.slider.bg = theme.style.bar.bg;
|
||||
theme.style.slider.indic = theme.style.bar.indic;
|
||||
theme.style.slider.knob = &knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -239,22 +244,22 @@ static void sw_init(void)
|
||||
#if USE_LV_SW != 0
|
||||
static lv_style_t indic;
|
||||
|
||||
lv_style_copy(&indic, theme.slider.indic);
|
||||
lv_style_copy(&indic, theme.style.slider.indic);
|
||||
indic.body.radius = LV_RADIUS_CIRCLE;
|
||||
indic.body.main_color = lv_color_hsv_to_rgb(_hue, 15, 95);
|
||||
indic.body.grad_color = indic.body.main_color;
|
||||
indic.body.border.width = theme.slider.bg->body.border.width;
|
||||
indic.body.border.color = theme.slider.bg->body.border.color;
|
||||
indic.body.border.opa = theme.slider.bg->body.border.opa;
|
||||
indic.body.border.width = theme.style.slider.bg->body.border.width;
|
||||
indic.body.border.color = theme.style.slider.bg->body.border.color;
|
||||
indic.body.border.opa = theme.style.slider.bg->body.border.opa;
|
||||
indic.body.padding.hor = 0;
|
||||
indic.body.padding.ver = 0;
|
||||
|
||||
|
||||
|
||||
theme.sw.bg = theme.slider.bg;
|
||||
theme.sw.indic = &indic;
|
||||
theme.sw.knob_off = theme.slider.knob;
|
||||
theme.sw.knob_on = theme.slider.knob;
|
||||
theme.style.sw.bg = theme.style.slider.bg;
|
||||
theme.style.sw.indic = &indic;
|
||||
theme.style.sw.knob_off = theme.style.slider.knob;
|
||||
theme.style.sw.knob_on = theme.style.slider.knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -271,7 +276,7 @@ static void lmeter_init(void)
|
||||
lmeter.body.grad_color = lmeter.body.main_color;
|
||||
lmeter.body.padding.hor = LV_DPI / 8;
|
||||
|
||||
theme.lmeter = &lmeter;
|
||||
theme.style.lmeter = &lmeter;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -288,7 +293,7 @@ static void gauge_init(void)
|
||||
gauge.body.padding.hor = LV_DPI / 16;
|
||||
gauge.body.border.color = LV_COLOR_HEX3(0x666); /*Needle middle color*/
|
||||
|
||||
theme.gauge = &gauge;
|
||||
theme.style.gauge = &gauge;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -305,7 +310,7 @@ static void arc_init(void)
|
||||
/*For preloader*/
|
||||
arc.body.border.width = 0;
|
||||
|
||||
theme.arc = &arc;
|
||||
theme.style.arc = &arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -313,14 +318,14 @@ static void preload_init(void)
|
||||
{
|
||||
#if USE_LV_PRELOAD != 0
|
||||
|
||||
theme.preload = theme.arc;
|
||||
theme.style.preload = theme.style.arc;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
theme.chart = theme.panel;
|
||||
theme.style.chart = theme.style.panel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -338,16 +343,16 @@ static void calendar_init(void)
|
||||
static lv_style_t today_box;
|
||||
lv_style_copy(&today_box, &def);
|
||||
today_box.body.empty = 1;
|
||||
today_box.body.border.color = theme.panel->body.border.color;
|
||||
today_box.body.border.color = theme.style.panel->body.border.color;
|
||||
today_box.body.padding.ver = LV_DPI / 20;
|
||||
today_box.body.radius = LV_RADIUS_CIRCLE;
|
||||
|
||||
theme.calendar.bg = theme.panel;
|
||||
theme.calendar.header = &lv_style_transp;
|
||||
theme.calendar.inactive_days = &ina_days;
|
||||
theme.calendar.highlighted_days = &high_days;
|
||||
theme.calendar.week_box = &lv_style_transp_fit;
|
||||
theme.calendar.today_box = &today_box;
|
||||
theme.style.calendar.bg = theme.style.panel;
|
||||
theme.style.calendar.header = &lv_style_transp;
|
||||
theme.style.calendar.inactive_days = &ina_days;
|
||||
theme.style.calendar.highlighted_days = &high_days;
|
||||
theme.style.calendar.week_box = &lv_style_transp_fit;
|
||||
theme.style.calendar.today_box = &today_box;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -384,12 +389,12 @@ static void cb_init(void)
|
||||
ina.body.border.color = LV_COLOR_HEX3(0xaaa);
|
||||
|
||||
|
||||
theme.cb.bg = &lv_style_transp;
|
||||
theme.cb.box.rel = &rel;
|
||||
theme.cb.box.pr = ≺
|
||||
theme.cb.box.tgl_rel = &tgl_rel;
|
||||
theme.cb.box.tgl_pr = &tgl_pr;
|
||||
theme.cb.box.ina = &ina;
|
||||
theme.style.cb.bg = &lv_style_transp;
|
||||
theme.style.cb.box.rel = &rel;
|
||||
theme.style.cb.box.pr = ≺
|
||||
theme.style.cb.box.tgl_rel = &tgl_rel;
|
||||
theme.style.cb.box.tgl_pr = &tgl_pr;
|
||||
theme.style.cb.box.ina = &ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -434,12 +439,12 @@ static void btnm_init(void)
|
||||
ina.body.grad_color = tgl_pr.body.main_color;
|
||||
ina.text.color = LV_COLOR_HEX3(0x888);;
|
||||
|
||||
theme.btnm.bg = &bg;
|
||||
theme.btnm.btn.rel = &rel;
|
||||
theme.btnm.btn.pr = ≺
|
||||
theme.btnm.btn.tgl_rel = &tgl_rel;
|
||||
theme.btnm.btn.tgl_pr = &tgl_pr;
|
||||
theme.btnm.btn.ina = &ina;
|
||||
theme.style.btnm.bg = &bg;
|
||||
theme.style.btnm.btn.rel = &rel;
|
||||
theme.style.btnm.btn.pr = ≺
|
||||
theme.style.btnm.btn.tgl_rel = &tgl_rel;
|
||||
theme.style.btnm.btn.tgl_pr = &tgl_pr;
|
||||
theme.style.btnm.btn.ina = &ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -489,12 +494,12 @@ static void kb_init(void)
|
||||
ina.body.grad_color = ina.body.main_color;
|
||||
ina.text.color = LV_COLOR_HEX3(0xbbb);
|
||||
|
||||
theme.kb.bg = &bg;
|
||||
theme.kb.btn.rel = &rel;
|
||||
theme.kb.btn.pr = ≺
|
||||
theme.kb.btn.tgl_rel = &tgl_rel;
|
||||
theme.kb.btn.tgl_pr = &tgl_pr;
|
||||
theme.kb.btn.ina = &ina;
|
||||
theme.style.kb.bg = &bg;
|
||||
theme.style.kb.btn.rel = &rel;
|
||||
theme.style.kb.btn.pr = ≺
|
||||
theme.style.kb.btn.tgl_rel = &tgl_rel;
|
||||
theme.style.kb.btn.tgl_pr = &tgl_pr;
|
||||
theme.style.kb.btn.ina = &ina;
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -503,7 +508,7 @@ static void mbox_init(void)
|
||||
{
|
||||
#if USE_LV_MBOX
|
||||
static lv_style_t bg, rel, pr;
|
||||
lv_style_copy(&bg, theme.panel);
|
||||
lv_style_copy(&bg, theme.style.panel);
|
||||
bg.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 95);
|
||||
bg.body.grad_color = bg.body.main_color;
|
||||
bg.text.color = lv_color_hsv_to_rgb(_hue, 40, 25);
|
||||
@ -525,10 +530,10 @@ static void mbox_init(void)
|
||||
pr.body.grad_color = pr.body.main_color;
|
||||
|
||||
|
||||
theme.mbox.bg = &bg;
|
||||
theme.mbox.btn.bg = &lv_style_transp;
|
||||
theme.mbox.btn.rel = &rel;
|
||||
theme.mbox.btn.pr = ≺
|
||||
theme.style.mbox.bg = &bg;
|
||||
theme.style.mbox.btn.bg = &lv_style_transp;
|
||||
theme.style.mbox.btn.rel = &rel;
|
||||
theme.style.mbox.btn.pr = ≺
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -537,9 +542,9 @@ static void page_init(void)
|
||||
#if USE_LV_PAGE
|
||||
|
||||
|
||||
theme.page.bg = theme.panel;
|
||||
theme.page.scrl = &lv_style_transp;
|
||||
theme.page.sb = &sb;
|
||||
theme.style.page.bg = theme.style.panel;
|
||||
theme.style.page.scrl = &lv_style_transp;
|
||||
theme.style.page.sb = &sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -547,25 +552,25 @@ static void ta_init(void)
|
||||
{
|
||||
#if USE_LV_TA
|
||||
static lv_style_t oneline;
|
||||
lv_style_copy(&oneline, theme.panel);
|
||||
lv_style_copy(&oneline, theme.style.panel);
|
||||
oneline.body.radius = LV_RADIUS_CIRCLE;
|
||||
oneline.body.padding.ver = LV_DPI / 10;
|
||||
oneline.body.shadow.width = 0;
|
||||
|
||||
|
||||
theme.ta.area = theme.panel;
|
||||
theme.ta.oneline = &oneline;
|
||||
theme.ta.cursor = NULL; /*Let library to calculate the cursor's style*/
|
||||
theme.ta.sb = &def;
|
||||
theme.style.ta.area = theme.style.panel;
|
||||
theme.style.ta.oneline = &oneline;
|
||||
theme.style.ta.cursor = NULL; /*Let library to calculate the cursor's style*/
|
||||
theme.style.ta.sb = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void spinbox_init(void)
|
||||
{
|
||||
#if USE_LV_SPINBOX
|
||||
theme.spinbox.bg= theme.panel;
|
||||
theme.spinbox.cursor = theme.ta.cursor;
|
||||
theme.spinbox.sb = theme.ta.sb;
|
||||
theme.style.spinbox.bg= theme.style.panel;
|
||||
theme.style.spinbox.cursor = theme.style.ta.cursor;
|
||||
theme.style.spinbox.sb = theme.style.ta.sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -574,7 +579,7 @@ static void list_init(void)
|
||||
#if USE_LV_LIST != 0
|
||||
static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina;
|
||||
|
||||
lv_style_copy(&bg, theme.panel);
|
||||
lv_style_copy(&bg, theme.style.panel);
|
||||
bg.body.padding.hor = 0;
|
||||
bg.body.padding.ver = 0;
|
||||
|
||||
@ -584,27 +589,31 @@ static void list_init(void)
|
||||
rel.body.padding.hor = LV_DPI / 8;
|
||||
rel.body.padding.ver = LV_DPI / 8;
|
||||
rel.text.color = LV_COLOR_HEX3(0x666);
|
||||
rel.image.color = LV_COLOR_HEX3(0x666);
|
||||
|
||||
lv_style_copy(&pr, &rel);
|
||||
pr.text.color = theme.btn.pr->text.color;
|
||||
pr.text.color = theme.style.btn.pr->text.color;
|
||||
pr.image.color = theme.style.btn.pr->image.color;
|
||||
|
||||
lv_style_copy(&tgl_rel, &rel);
|
||||
tgl_rel.text.color = lv_color_hsv_to_rgb(_hue, 50, 90);
|
||||
|
||||
lv_style_copy(&tgl_pr, &rel);
|
||||
tgl_pr.text.color = theme.btn.tgl_pr->text.color;
|
||||
tgl_pr.text.color = theme.style.btn.tgl_pr->text.color;
|
||||
tgl_pr.image.color = theme.style.btn.tgl_pr->image.color;
|
||||
|
||||
lv_style_copy(&ina, &rel);
|
||||
ina.text.color = theme.btn.ina->text.color;
|
||||
ina.text.color = theme.style.btn.ina->text.color;
|
||||
ina.image.color = theme.style.btn.ina->image.color;
|
||||
|
||||
theme.list.sb = &sb;
|
||||
theme.list.bg = &bg;
|
||||
theme.list.scrl = &lv_style_transp_tight;
|
||||
theme.list.btn.rel = &rel;
|
||||
theme.list.btn.pr = ≺
|
||||
theme.list.btn.tgl_rel = &tgl_rel;
|
||||
theme.list.btn.tgl_pr = &tgl_pr;
|
||||
theme.list.btn.ina = &ina;
|
||||
theme.style.list.sb = &sb;
|
||||
theme.style.list.bg = &bg;
|
||||
theme.style.list.scrl = &lv_style_transp_tight;
|
||||
theme.style.list.btn.rel = &rel;
|
||||
theme.style.list.btn.pr = ≺
|
||||
theme.style.list.btn.tgl_rel = &tgl_rel;
|
||||
theme.style.list.btn.tgl_pr = &tgl_pr;
|
||||
theme.style.list.btn.ina = &ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -612,7 +621,7 @@ static void ddlist_init(void)
|
||||
{
|
||||
#if USE_LV_DDLIST != 0
|
||||
static lv_style_t bg, sel;
|
||||
lv_style_copy(&bg, theme.panel);
|
||||
lv_style_copy(&bg, theme.style.panel);
|
||||
bg.text.line_space = LV_DPI / 8;
|
||||
bg.body.padding.hor = LV_DPI / 6;
|
||||
bg.body.padding.ver = LV_DPI / 8;
|
||||
@ -623,9 +632,9 @@ static void ddlist_init(void)
|
||||
sel.body.border.width = 0;
|
||||
sel.text.color = lv_color_hsv_to_rgb(_hue, 50, 80);
|
||||
|
||||
theme.ddlist.bg = &bg;
|
||||
theme.ddlist.sel = &sel;
|
||||
theme.ddlist.sb = &def;
|
||||
theme.style.ddlist.bg = &bg;
|
||||
theme.style.ddlist.sel = &sel;
|
||||
theme.style.ddlist.sb = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -639,12 +648,12 @@ static void roller_init(void)
|
||||
bg.text.line_space = LV_DPI / 6;
|
||||
bg.text.color = LV_COLOR_HEX3(0x999);
|
||||
|
||||
lv_style_copy(&sel, theme.panel);
|
||||
lv_style_copy(&sel, theme.style.panel);
|
||||
sel.body.radius = LV_RADIUS_CIRCLE;
|
||||
sel.body.empty = 1;
|
||||
|
||||
theme.roller.bg = &bg;
|
||||
theme.roller.sel = &sel;
|
||||
theme.style.roller.bg = &bg;
|
||||
theme.style.roller.sel = &sel;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -681,22 +690,22 @@ static void tabview_init(void)
|
||||
lv_style_copy(&tgl_pr, &rel);
|
||||
tgl_pr.text.color = lv_color_hsv_to_rgb(_hue, 50, 70);
|
||||
|
||||
theme.tabview.bg = theme.bg;
|
||||
theme.tabview.indic = &indic;
|
||||
theme.tabview.btn.bg = &btn_bg;
|
||||
theme.tabview.btn.rel = &rel;
|
||||
theme.tabview.btn.pr = ≺
|
||||
theme.tabview.btn.tgl_rel = &tgl_rel;
|
||||
theme.tabview.btn.tgl_pr = &tgl_pr;
|
||||
theme.style.tabview.bg = theme.style.bg;
|
||||
theme.style.tabview.indic = &indic;
|
||||
theme.style.tabview.btn.bg = &btn_bg;
|
||||
theme.style.tabview.btn.rel = &rel;
|
||||
theme.style.tabview.btn.pr = ≺
|
||||
theme.style.tabview.btn.tgl_rel = &tgl_rel;
|
||||
theme.style.tabview.btn.tgl_pr = &tgl_pr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tileview_init(void)
|
||||
{
|
||||
#if USE_LV_TILEVIEW != 0
|
||||
theme.tileview.bg = &lv_style_transp_tight;
|
||||
theme.tileview.scrl = &lv_style_transp_tight;
|
||||
theme.tileview.sb = theme.page.sb;
|
||||
theme.style.tileview.bg = &lv_style_transp_tight;
|
||||
theme.style.tileview.scrl = &lv_style_transp_tight;
|
||||
theme.style.tileview.sb = theme.style.page.sb;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -704,15 +713,15 @@ static void table_init(void)
|
||||
{
|
||||
#if USE_LV_TABLE != 0
|
||||
static lv_style_t cell;
|
||||
lv_style_copy(&cell, theme.panel);
|
||||
lv_style_copy(&cell, theme.style.panel);
|
||||
cell.body.radius = 0;
|
||||
cell.body.border.width = 1;
|
||||
cell.body.shadow.width = 0;
|
||||
cell.body.padding.hor = LV_DPI / 12;
|
||||
cell.body.padding.ver = LV_DPI / 12;
|
||||
|
||||
theme.table.bg = &lv_style_transp_tight;
|
||||
theme.table.cell = &cell;
|
||||
theme.style.table.bg = &lv_style_transp_tight;
|
||||
theme.style.table.cell = &cell;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -727,25 +736,70 @@ static void win_init(void)
|
||||
header.body.border.part = LV_BORDER_BOTTOM;
|
||||
header.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 90);
|
||||
header.text.color = LV_COLOR_HEX3(0x666);
|
||||
header.image.color = LV_COLOR_HEX3(0x666);
|
||||
|
||||
lv_style_copy(&rel, &def);
|
||||
rel.body.empty = 1;
|
||||
rel.body.border.width = 0;
|
||||
rel.text.color = LV_COLOR_HEX3(0x666);
|
||||
rel.image.color = LV_COLOR_HEX3(0x666);
|
||||
|
||||
lv_style_copy(&pr, &rel);
|
||||
pr.text.color = LV_COLOR_HEX3(0x333);
|
||||
pr.image.color = LV_COLOR_HEX3(0x333);
|
||||
|
||||
theme.win.bg = theme.panel;
|
||||
theme.win.sb = &sb;
|
||||
theme.win.header = &header;
|
||||
theme.win.content.bg = &lv_style_transp;
|
||||
theme.win.content.scrl = &lv_style_transp;
|
||||
theme.win.btn.rel = &rel;
|
||||
theme.win.btn.pr = ≺
|
||||
theme.style.win.bg = theme.style.panel;
|
||||
theme.style.win.sb = &sb;
|
||||
theme.style.win.header = &header;
|
||||
theme.style.win.content.bg = &lv_style_transp;
|
||||
theme.style.win.content.scrl = &lv_style_transp;
|
||||
theme.style.win.btn.rel = &rel;
|
||||
theme.style.win.btn.pr = ≺
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_LV_GROUP
|
||||
|
||||
static void style_mod(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = lv_color_hsv_to_rgb(_hue, 40, 50);
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void style_mod_edit(lv_style_t * style)
|
||||
{
|
||||
#if LV_COLOR_DEPTH != 1
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_GREEN;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
|
||||
style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_GREEN, LV_OPA_60);
|
||||
|
||||
style->text.color = lv_color_mix(style->text.color, LV_COLOR_GREEN, LV_OPA_70);
|
||||
#else
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_BLACK;
|
||||
style->body.border.width = 3;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*USE_LV_GROUP*/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
@ -767,8 +821,8 @@ lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t * font)
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) {
|
||||
lv_style_t ** style_p = (lv_style_t **) &theme.style;
|
||||
for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
@ -804,6 +858,11 @@ lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t * font)
|
||||
table_init();
|
||||
win_init();
|
||||
|
||||
#if USE_LV_GROUP
|
||||
theme.group.style_mod = style_mod;
|
||||
theme.group.style_mod_edit = style_mod_edit;
|
||||
#endif
|
||||
|
||||
return &theme;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user