Merge branch 'dev-7.0' into speed/gpu

This commit is contained in:
Gabor Kiss-Vamosi
2020-04-27 14:53:17 +02:00
98 changed files with 76888 additions and 1126 deletions

17
.github/workflows/ccpp.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: C/C++ CI
on:
push:
branches: [ dev-7.0 ]
pull_request:
branches: [ dev-7.0 ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: cd tests; python ./build.py

View File

@@ -93,7 +93,7 @@ You can use the [Simulators](https://docs.littlevgl.com/en/html/get-started/pc-s
1. [Download](https://littlevgl.com/download) or [Clone](https://github.com/littlevgl/lvgl) the library
2. Copy the `lvgl` folder into your project
3. Copy `lvgl/lv_conf_template.h` as `lv_conf.h` next to the `lvgl` folder and set at least `LV_HOR_RES_MAX`, `LV_VER_RES_MAX` and `LV_COLOR_DEPTH`.
3. Copy `lvgl/lv_conf_template.h` as `lv_conf.h` next to the `lvgl` folder and set at least `LV_HOR_RES_MAX`, `LV_VER_RES_MAX` and `LV_COLOR_DEPTH`. Don't forget to **change the `#if 0` statement near the top of the file to `#if 1`**, otherwise you will get compilation errors.
4. Include `lvgl/lvgl.h` where you need to use LittlevGL related functions.
5. Call `lv_tick_inc(x)` every `x` milliseconds **in a Timer or Task** (`x` should be between 1 and 10). It is required for the internal timing of LittlevGL.
6. Call `lv_init()`

View File

@@ -1,16 +0,0 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- dev-7.0
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
cd tests
python build.py
displayName: 'Build'

View File

@@ -56,7 +56,7 @@
/* 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]*/
#define LV_DPI 130 /*[px]*/
/* The the real width of the display changes some default values:
* default object sizes, layout of examples, etc.
@@ -65,9 +65,9 @@
* The 4th is extra large which has no upper limit so not listed here
* The upper limit of the categories are set below in 0.1 inch unit.
*/
#define LV_DISP_SMALL_LIMIT 20
#define LV_DISP_MEDIUM_LIMIT 45
#define LV_DISP_LARGE_LIMIT 65
#define LV_DISP_SMALL_LIMIT 30
#define LV_DISP_MEDIUM_LIMIT 50
#define LV_DISP_LARGE_LIMIT 70
/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */
typedef int16_t lv_coord_t;
@@ -340,6 +340,14 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
#define LV_FONT_MONTSERRAT_28 0
#define LV_FONT_MONTSERRAT_30 0
#define LV_FONT_MONTSERRAT_32 0
#define LV_FONT_MONTSERRAT_34 0
#define LV_FONT_MONTSERRAT_36 0
#define LV_FONT_MONTSERRAT_38 0
#define LV_FONT_MONTSERRAT_40 0
#define LV_FONT_MONTSERRAT_42 0
#define LV_FONT_MONTSERRAT_44 0
#define LV_FONT_MONTSERRAT_46 0
#define LV_FONT_MONTSERRAT_48 0
/* Demonstrate special features */
#define LV_FONT_MONTSERRAT_12_SUBPX 0
@@ -501,7 +509,7 @@ typedef void * lv_obj_user_data_t;
/*Chart (dependencies: -)*/
#define LV_USE_CHART 1
#if LV_USE_CHART
# define LV_CHART_AXIS_TICK_LABEL_MAX_LEN 20
# define LV_CHART_AXIS_TICK_LABEL_MAX_LEN 256
#endif
/*Container (dependencies: -*/

View File

@@ -44,6 +44,38 @@ print("\nGenerating 32 px")
os.system("python built_in_font_gen.py --size 32 -o lv_font_montserrat_32.c --bpp 4")
os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_32.c')
print("\nGenerating 34 px")
os.system("python built_in_font_gen.py --size 34 -o lv_font_montserrat_34.c --bpp 4")
os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_34.c')
print("\nGenerating 36 px")
os.system("python built_in_font_gen.py --size 36 -o lv_font_montserrat_36.c --bpp 4")
os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_36.c')
print("\nGenerating 38 px")
os.system("python built_in_font_gen.py --size 38 -o lv_font_montserrat_38.c --bpp 4")
os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_38.c')
print("\nGenerating 40 px")
os.system("python built_in_font_gen.py --size 40 -o lv_font_montserrat_40.c --bpp 4")
os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_40.c')
print("\nGenerating 42 px")
os.system("python built_in_font_gen.py --size 42 -o lv_font_montserrat_42.c --bpp 4")
os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_42.c')
print("\nGenerating 44 px")
os.system("python built_in_font_gen.py --size 44 -o lv_font_montserrat_44.c --bpp 4")
os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_44.c')
print("\nGenerating 46 px")
os.system("python built_in_font_gen.py --size 46 -o lv_font_montserrat_46.c --bpp 4")
os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_46.c')
print("\nGenerating 48 px")
os.system("python built_in_font_gen.py --size 48 -o lv_font_montserrat_48.c --bpp 4")
os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_48.c')
print("\nGenerating 12 px subpx")
os.system("python built_in_font_gen.py --size 12 -o lv_font_montserrat_12_subpx.c --bpp 4 --subpx")
os.system('sed -i \'s|#include "lvgl/lvgl.h"|#include "../../lvgl.h"|\' lv_font_montserrat_12_subpx.c')

View File

@@ -31,6 +31,11 @@ extern "C" {
* V6.0 COMPATIBILITY
*--------------------*/
static inline void lv_task_once(lv_task_t *task)
{
lv_task_set_repeat_count(task, 1);
}
#if LV_USE_CHART
#define lv_chart_get_point_cnt lv_chart_get_point_count

View File

@@ -86,7 +86,7 @@
* 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]*/
#define LV_DPI 130 /*[px]*/
#endif
/* The the real width of the display changes some default values:
@@ -97,13 +97,13 @@
* The upper limit of the categories are set below in 0.1 inch unit.
*/
#ifndef LV_DISP_SMALL_LIMIT
#define LV_DISP_SMALL_LIMIT 20
#define LV_DISP_SMALL_LIMIT 30
#endif
#ifndef LV_DISP_MEDIUM_LIMIT
#define LV_DISP_MEDIUM_LIMIT 45
#define LV_DISP_MEDIUM_LIMIT 50
#endif
#ifndef LV_DISP_LARGE_LIMIT
#define LV_DISP_LARGE_LIMIT 65
#define LV_DISP_LARGE_LIMIT 70
#endif
/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */
@@ -496,6 +496,30 @@
#ifndef LV_FONT_MONTSERRAT_32
#define LV_FONT_MONTSERRAT_32 0
#endif
#ifndef LV_FONT_MONTSERRAT_34
#define LV_FONT_MONTSERRAT_34 0
#endif
#ifndef LV_FONT_MONTSERRAT_36
#define LV_FONT_MONTSERRAT_36 0
#endif
#ifndef LV_FONT_MONTSERRAT_38
#define LV_FONT_MONTSERRAT_38 0
#endif
#ifndef LV_FONT_MONTSERRAT_40
#define LV_FONT_MONTSERRAT_40 0
#endif
#ifndef LV_FONT_MONTSERRAT_42
#define LV_FONT_MONTSERRAT_42 0
#endif
#ifndef LV_FONT_MONTSERRAT_44
#define LV_FONT_MONTSERRAT_44 0
#endif
#ifndef LV_FONT_MONTSERRAT_46
#define LV_FONT_MONTSERRAT_46 0
#endif
#ifndef LV_FONT_MONTSERRAT_48
#define LV_FONT_MONTSERRAT_48 0
#endif
/* Demonstrate special features */
#ifndef LV_FONT_MONTSERRAT_12_SUBPX
@@ -744,7 +768,7 @@
#endif
#if LV_USE_CHART
#ifndef LV_CHART_AXIS_TICK_LABEL_MAX_LEN
# define LV_CHART_AXIS_TICK_LABEL_MAX_LEN 20
# define LV_CHART_AXIS_TICK_LABEL_MAX_LEN 256
#endif
#endif

View File

@@ -63,6 +63,7 @@ bool lv_debug_check_obj_type(const lv_obj_t * obj, const char * obj_type)
uint8_t i;
for(i = 0; i < LV_MAX_ANCESTOR_NUM; i++) {
if(types.type[i] == NULL) break;
if(strcmp(types.type[i], obj_type) == 0) return true;
}
@@ -159,7 +160,7 @@ void lv_debug_log_error(const char * msg, uint64_t value)
char * bufp = buf;
/*Add the function name*/
memcpy(bufp, msg, msg_len);
lv_memcpy(bufp, msg, msg_len);
bufp += msg_len;
/*Add value in hey*/

View File

@@ -152,7 +152,7 @@ static inline void lv_scr_load(lv_obj_t * scr)
* 1 dip is 2 px on a 320 DPI screen
* https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dip-dp-and-sp
*/
#define LV_DPX(n) LV_MATH_MAX(((LV_DPI * (n)) / 160), 1)
#define LV_DPX(n) LV_MATH_MAX(((LV_DPI * (n) + 80) / 160), 1) /*+80 for rounding*/
#ifdef __cplusplus
} /* extern "C" */

View File

@@ -73,7 +73,7 @@ lv_group_t * lv_group_create(void)
group->wrap = 1;
#if LV_USE_USER_DATA
memset(&group->user_data, 0, sizeof(lv_group_user_data_t));
lv_memset_00(&group->user_data, sizeof(lv_group_user_data_t));
#endif
return group;
@@ -303,28 +303,6 @@ lv_res_t lv_group_send_data(lv_group_t * group, uint32_t c)
return res;
}
/**
* Set a function for a group which will modify the object's style if it is in focus
* @param group pointer to a group
* @param style_mod_cb the style modifier function pointer
*/
void lv_group_set_style_mod_cb(lv_group_t * group, lv_group_style_mod_cb_t style_mod_cb)
{
group->style_mod_cb = style_mod_cb;
if(group->obj_focus != NULL) lv_obj_invalidate(*group->obj_focus);
}
/**
* Set a function for a group which will modify the object's style if it is in focus in edit mode
* @param group pointer to a group
* @param style_mod_func the style modifier function pointer
*/
void lv_group_set_style_mod_edit_cb(lv_group_t * group, lv_group_style_mod_cb_t style_mod_edit_cb)
{
group->style_mod_edit_cb = style_mod_edit_cb;
if(group->obj_focus != NULL) lv_obj_invalidate(*group->obj_focus);
}
/**
* Set a function for a group which will be called when a new object is focused
* @param group pointer to a group
@@ -342,6 +320,7 @@ void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb)
*/
void lv_group_set_editing(lv_group_t * group, bool edit)
{
if(group == NULL) return;
uint8_t en_val = edit ? 1 : 0;
if(en_val == group->editing) return; /*Do not set the same mode again*/
@@ -383,26 +362,6 @@ void lv_group_set_wrap(lv_group_t * group, bool en)
group->wrap = en ? 1 : 0;
}
/**
* Modify a style with the set 'style_mod' function. The input style remains unchanged.
* @param group pointer to group
* @param style pointer to a style to modify
* @return a copy of the input style but modified with the 'style_mod' function
*/
lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style)
{
/*Load the current style. It will be modified by the callback*/
lv_style_copy(&group->style_tmp, style);
if(group->editing) {
if(group->style_mod_edit_cb) group->style_mod_edit_cb(group, &group->style_tmp);
}
else {
if(group->style_mod_cb) group->style_mod_cb(group, &group->style_tmp);
}
return &group->style_tmp;
}
/**
* Get the focused object or NULL if there isn't one
* @param group pointer to a group
@@ -428,28 +387,6 @@ lv_group_user_data_t * lv_group_get_user_data(lv_group_t * group)
}
#endif
/**
* Get a the style modifier function of a group
* @param group pointer to a group
* @return pointer to the style modifier function
*/
lv_group_style_mod_cb_t lv_group_get_style_mod_cb(const lv_group_t * group)
{
if(!group) return NULL;
return group->style_mod_cb;
}
/**
* Get a the style modifier function of a group in edit mode
* @param group pointer to a group
* @return pointer to the style modifier function
*/
lv_group_style_mod_cb_t lv_group_get_style_mod_edit_cb(const lv_group_t * group)
{
if(!group) return NULL;
return group->style_mod_edit_cb;
}
/**
* Get the focus callback function of a group
* @param group pointer to a group

View File

@@ -55,10 +55,7 @@ typedef struct _lv_group_t {
lv_ll_t obj_ll; /**< Linked list to store the objects in the group */
lv_obj_t ** obj_focus; /**< The object in focus*/
lv_group_style_mod_cb_t style_mod_cb; /**< A function to modifies the style of the focused object*/
lv_group_style_mod_cb_t style_mod_edit_cb; /**< A function which modifies the style of the edited object*/
lv_group_focus_cb_t focus_cb; /**< A function to call when a new object is focused (optional)*/
lv_style_t style_tmp; /**< Stores the modified style of the focused object */
#if LV_USE_USER_DATA
lv_group_user_data_t user_data;
#endif

View File

@@ -235,7 +235,7 @@ void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group)
* @param indev pointer to an input device
* @param group point to a group
*/
void lv_indev_set_button_points(lv_indev_t * indev, const lv_point_t * points)
void lv_indev_set_button_points(lv_indev_t * indev, const lv_point_t points[])
{
if(indev->driver.type == LV_INDEV_TYPE_BUTTON) {
indev->btn_points = points;
@@ -797,7 +797,7 @@ static void indev_proc_press(lv_indev_proc_t * proc)
}
/*Do not use disabled objects*/
if((lv_obj_get_state(indev_obj_act, LV_OBJ_PART_MAIN) & LV_STATE_DISABLED)) {
if(indev_obj_act && (lv_obj_get_state(indev_obj_act, LV_OBJ_PART_MAIN) & LV_STATE_DISABLED)) {
indev_obj_act = proc->types.pointer.act_obj;
}

View File

@@ -96,7 +96,7 @@ void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group);
* @param indev pointer to an input device
* @param group point to a group
*/
void lv_indev_set_button_points(lv_indev_t * indev, const lv_point_t * points);
void lv_indev_set_button_points(lv_indev_t * indev, const lv_point_t points[]);
/**
* Get the last point of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)

View File

@@ -40,8 +40,8 @@
* DEFINES
*********************/
#define LV_OBJX_NAME "lv_obj"
#define LV_OBJ_DEF_WIDTH (LV_DPI / 2)
#define LV_OBJ_DEF_HEIGHT (LV_DPI / 4)
#define LV_OBJ_DEF_WIDTH (LV_DPX(100))
#define LV_OBJ_DEF_HEIGHT (LV_DPX(50))
/**********************
* TYPEDEFS
@@ -60,13 +60,13 @@ typedef struct {
lv_color_t _color;
lv_style_int_t _int;
lv_opa_t _opa;
lv_style_fptr_dptr_t _ptr;
const void * _ptr;
} start_value;
union {
lv_color_t _color;
lv_style_int_t _int;
lv_opa_t _opa;
lv_style_fptr_dptr_t _ptr;
const void * _ptr;
} end_value;
} lv_style_trans_t;
@@ -209,7 +209,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
LV_ASSERT_MEM(new_obj);
if(new_obj == NULL) return NULL;
memset(new_obj, 0x00, sizeof(lv_obj_t));
lv_memset_00(new_obj, sizeof(lv_obj_t));
#if LV_USE_BIDI
new_obj->base_dir = LV_BIDI_BASE_DIR_DEF;
@@ -232,7 +232,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
LV_ASSERT_MEM(new_obj);
if(new_obj == NULL) return NULL;
memset(new_obj, 0x00, sizeof(lv_obj_t));
lv_memset_00(new_obj, sizeof(lv_obj_t));
new_obj->parent = parent;
@@ -265,7 +265,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
new_obj->ext_draw_pad = 0;
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
memset(&new_obj->ext_click_pad, 0, sizeof(new_obj->ext_click_pad));
lv_memset_00(&new_obj->ext_click_pad, sizeof(new_obj->ext_click_pad));
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
new_obj->ext_click_pad_hor = 0;
new_obj->ext_click_pad_ver = 0;
@@ -282,7 +282,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
/*Init. user date*/
#if LV_USE_USER_DATA
memset(&new_obj->user_data, 0, sizeof(lv_obj_user_data_t));
lv_memset_00(&new_obj->user_data, sizeof(lv_obj_user_data_t));
#endif
@@ -328,7 +328,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
/*Set user data*/
#if LV_USE_USER_DATA
memcpy(&new_obj->user_data, &copy->user_data, sizeof(lv_obj_user_data_t));
lv_memcpy(&new_obj->user_data, &copy->user_data, sizeof(lv_obj_user_data_t));
#endif
/*Copy realign*/
@@ -800,9 +800,35 @@ void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h)
lv_obj_set_size(obj, lv_obj_get_width(obj), h);
}
/**
* Set the width reduced by the left and right padding.
* @param obj pointer to an object
* @param w the width without paddings
*/
void lv_obj_set_width_fit(lv_obj_t * obj, lv_coord_t w)
{
lv_style_int_t pleft = lv_obj_get_style_pad_left(obj, LV_OBJ_PART_MAIN);
lv_style_int_t pright = lv_obj_get_style_pad_right(obj, LV_OBJ_PART_MAIN);
lv_obj_set_width(obj, w - pleft - pright);
}
/**
* Set the height reduced by the top and bottom padding.
* @param obj pointer to an object
* @param h the height without paddings
*/
void lv_obj_set_height_fit(lv_obj_t * obj, lv_coord_t h)
{
lv_style_int_t ptop = lv_obj_get_style_pad_top(obj, LV_OBJ_PART_MAIN);
lv_style_int_t pbottom = lv_obj_get_style_pad_bottom(obj, LV_OBJ_PART_MAIN);
lv_obj_set_width(obj, h - ptop - pbottom);
}
/**
* Set the width of an object by taking the left and right margin into account.
* The object heigwidthht will be `obj_w = w - margon_left - margin_right`
* The object width will be `obj_w = w - margon_left - margin_right`
* @param obj pointer to an object
* @param w new height including margins
*/
@@ -834,10 +860,10 @@ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h)
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment
* @param y_mod y coordinate shift after alignment
* @param x_ofs x coordinate offset after alignment
* @param y_ofs y coordinate offset after alignment
*/
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
@@ -852,8 +878,8 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
lv_obj_t * par = lv_obj_get_parent(obj);
lv_coord_t par_abs_x = par->coords.x1;
lv_coord_t par_abs_y = par->coords.y1;
new_pos.x += x_mod;
new_pos.y += y_mod;
new_pos.x += x_ofs;
new_pos.y += y_ofs;
new_pos.x -= par_abs_x;
new_pos.y -= par_abs_y;
@@ -862,8 +888,8 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
#if LV_USE_OBJ_REALIGN
/*Save the last align parameters to use them in `lv_obj_realign`*/
obj->realign.align = align;
obj->realign.xofs = x_mod;
obj->realign.yofs = y_mod;
obj->realign.xofs = x_ofs;
obj->realign.yofs = y_ofs;
obj->realign.base = base;
obj->realign.origo_align = 0;
#endif
@@ -874,10 +900,10 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment
* @param y_mod y coordinate shift after alignment
* @param x_ofs x coordinate offset after alignment
* @param y_ofs y coordinate offset after alignment
*/
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
@@ -1005,8 +1031,8 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
lv_coord_t base_abs_y = base->coords.y1;
lv_coord_t par_abs_x = par->coords.x1;
lv_coord_t par_abs_y = par->coords.y1;
new_x += x_mod + base_abs_x;
new_y += y_mod + base_abs_y;
new_x += x_ofs + base_abs_x;
new_y += y_ofs + base_abs_y;
new_x -= par_abs_x;
new_y -= par_abs_y;
@@ -1015,8 +1041,8 @@ void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align,
#if LV_USE_OBJ_REALIGN
/*Save the last align parameters to use them in `lv_obj_realign`*/
obj->realign.align = align;
obj->realign.xofs = x_mod;
obj->realign.yofs = y_mod;
obj->realign.xofs = x_ofs;
obj->realign.yofs = y_ofs;
obj->realign.base = base;
obj->realign.origo_align = 1;
#endif
@@ -1235,7 +1261,7 @@ void _lv_obj_set_style_local_opa(lv_obj_t * obj, uint8_t part, lv_style_property
* For example: `lv_obj_style_get_border_opa()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_style_fptr_dptr_t value)
void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, const void * value)
{
lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part);
lv_style_list_set_local_ptr(style_dsc, prop, value);
@@ -1267,7 +1293,7 @@ bool _lv_obj_remove_style_local_prop(lv_obj_t * obj, uint8_t part, lv_style_prop
/**
* Notify an object (and its children) about its style is modified
* @param obj pointer to an object
* @param prop `LV_STYLE_PROP_ALL` or an `LV_STYLE_...` property. It is used the optimize what needs to be refreshed.
* @param prop `LV_STYLE_PROP_ALL` or an `LV_STYLE_...` property. It is used to optimize what needs to be refreshed.
*/
void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop)
{
@@ -1332,9 +1358,8 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop)
lv_obj_invalidate(obj);
if(prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_INHERIT_MASK))
/*Send style change signals*/
refresh_children_style(obj);
/*Send style change signals*/
if(prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_INHERIT_MASK)) refresh_children_style(obj);
}
else {
lv_obj_invalidate(obj);
@@ -1570,7 +1595,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
lv_style_int_t time = lv_obj_get_style_transition_time(obj, part);
lv_style_property_t props[LV_STYLE_TRANS_NUM_MAX];
lv_style_int_t delay = lv_obj_get_style_transition_delay(obj, part);
lv_anim_path_cb_t path = lv_obj_get_style_transition_path(obj, part);
lv_anim_path_t * path = lv_obj_get_style_transition_path(obj, part);
props[0] = lv_obj_get_style_transition_prop_1(obj, part);
props[1] = lv_obj_get_style_transition_prop_2(obj, part);
props[2] = lv_obj_get_style_transition_prop_3(obj, part);
@@ -1600,7 +1625,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
lv_anim_set_values(&a, 0x00, 0xFF);
lv_anim_set_time(&a, time);
lv_anim_set_delay(&a, delay);
lv_anim_set_path_cb(&a, path);
lv_anim_set_path(&a, path);
a.early_apply = 0;
lv_anim_start(&a);
}
@@ -2513,14 +2538,14 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop
* For example: `lv_obj_style_get_border_opa()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
lv_style_fptr_dptr_t _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
{
lv_style_property_t prop_ori = prop;
lv_style_attr_t attr;
attr.full = prop_ori >> 8;
lv_style_fptr_dptr_t value_act;
const void * value_act;
lv_res_t res = LV_RES_INV;
const lv_obj_t * parent = obj;
while(parent) {
@@ -2546,22 +2571,17 @@ lv_style_fptr_dptr_t _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, l
/*Handle unset values*/
prop = prop & (~LV_STYLE_STATE_MASK);
lv_style_fptr_dptr_t fd;
fd.dptr = NULL;
fd.fptr = NULL;
switch(prop) {
case LV_STYLE_TEXT_FONT:
case LV_STYLE_VALUE_FONT:
fd.dptr = LV_THEME_DEFAULT_FONT_NORMAL;
return fd;
return LV_THEME_DEFAULT_FONT_NORMAL;
#if LV_USE_ANIMATION
case LV_STYLE_TRANSITION_PATH:
fd.fptr = (lv_style_prop_cb_t)lv_anim_path_linear;
return fd;
return &lv_anim_path_def;
#endif
}
return fd;
return NULL;
}
/**
@@ -2826,8 +2846,8 @@ void lv_obj_get_type(const lv_obj_t * obj, lv_obj_type_t * buf)
lv_obj_type_t tmp;
memset(buf, 0, sizeof(lv_obj_type_t));
memset(&tmp, 0, sizeof(lv_obj_type_t));
lv_memset_00(buf, sizeof(lv_obj_type_t));
lv_memset_00(&tmp, sizeof(lv_obj_type_t));
obj->signal_cb((lv_obj_t *)obj, LV_SIGNAL_GET_TYPE, &tmp);
@@ -2878,7 +2898,7 @@ void lv_obj_set_user_data(lv_obj_t * obj, lv_obj_user_data_t data)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
memcpy(&obj->user_data, &data, sizeof(lv_obj_user_data_t));
lv_memcpy(&obj->user_data, &data, sizeof(lv_obj_user_data_t));
}
#endif
@@ -3770,22 +3790,22 @@ static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop,
else { /*Ptr*/
obj->state = prev_state;
style_list->skip_trans = 1;
lv_style_fptr_dptr_t fd1 = _lv_obj_get_style_ptr(obj, part, prop);
const void * p1 = _lv_obj_get_style_ptr(obj, part, prop);
obj->state = new_state;
lv_style_fptr_dptr_t fd2 = _lv_obj_get_style_ptr(obj, part, prop);
const void * p2 = _lv_obj_get_style_ptr(obj, part, prop);
style_list->skip_trans = 0;
if(memcmp(&fd1, &fd2, sizeof(lv_style_fptr_dptr_t)) == 0) return NULL;
if(memcmp(&p1, &p2, sizeof(const void *)) == 0) return NULL;
obj->state = prev_state;
fd1 = _lv_obj_get_style_ptr(obj, part, prop);
p1 = _lv_obj_get_style_ptr(obj, part, prop);
obj->state = new_state;
_lv_style_set_ptr(style_trans, prop, fd1); /*Be sure `trans_style` has a valid value */
_lv_style_set_ptr(style_trans, prop, p1); /*Be sure `trans_style` has a valid value */
tr = lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
LV_ASSERT_MEM(tr);
if(tr == NULL) return NULL;
tr->start_value._ptr = fd1;
tr->end_value._ptr = fd2;
tr->start_value._ptr = p1;
tr->end_value._ptr = p2;
}
return tr;
@@ -3853,7 +3873,7 @@ static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v)
_lv_style_set_opa(style, tr->prop, x);
}
else {
lv_style_fptr_dptr_t x;
const void * x;
if(v < 128) x = tr->start_value._ptr;
else x = tr->end_value._ptr;
_lv_style_set_ptr(style, tr->prop, x);

View File

@@ -426,9 +426,23 @@ void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w);
*/
void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h);
/**
* Set the width reduced by the left and right padding.
* @param obj pointer to an object
* @param w the width without paddings
*/
void lv_obj_set_width_fit(lv_obj_t * obj, lv_coord_t w);
/**
* Set the height reduced by the top and bottom padding.
* @param obj pointer to an object
* @param h the height without paddings
*/
void lv_obj_set_height_fit(lv_obj_t * obj, lv_coord_t h);
/**
* Set the width of an object by taking the left and right margin into account.
* The object heigwidthht will be `obj_w = w - margon_left - margin_right`
* The object width will be `obj_w = w - margon_left - margin_right`
* @param obj pointer to an object
* @param w new height including margins
*/
@@ -447,20 +461,20 @@ void lv_obj_set_height_margin(lv_obj_t * obj, lv_coord_t h);
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment
* @param y_mod y coordinate shift after alignment
* @param x_ofs x coordinate offset after alignment
* @param y_ofs y coordinate offset after alignment
*/
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod);
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs);
/**
* Align an object to an other object.
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment
* @param y_mod y coordinate shift after alignment
* @param x_ofs x coordinate offset after alignment
* @param y_ofs y coordinate offset after alignment
*/
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod);
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs);
/**
* Realign the object based on the last `lv_obj_align` parameters.
@@ -520,8 +534,9 @@ void lv_obj_clean_style_list(lv_obj_t * obj, uint8_t part);
void lv_obj_reset_style_list(lv_obj_t * obj, uint8_t part);
/**
* Notify an object about its style is modified
* Notify an object (and its children) about its style is modified
* @param obj pointer to an object
* @param prop `LV_STYLE_PROP_ALL` or an `LV_STYLE_...` property. It is used to optimize what needs to be refreshed.
*/
void lv_obj_refresh_style(lv_obj_t * obj, lv_style_property_t prop);
@@ -586,48 +601,7 @@ void _lv_obj_set_style_local_opa(lv_obj_t * obj, uint8_t type, lv_style_property
* For example: `lv_obj_style_get_border_opa()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_style_fptr_dptr_t value);
/**
* Set a local style property of a part of an object in a given state.
* @param obj pointer to an object
* @param part the part of the object which style property should be set.
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param the value to set
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_obj_style_get_trasition_path()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void _lv_obj_set_style_local_func_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop,
lv_style_prop_cb_t value)
{
lv_style_fptr_dptr_t fd;
fd.fptr = value;
fd.dptr = NULL;
_lv_obj_set_style_local_ptr(obj, type, prop, fd);
}
/**
* Set a local style property of a part of an object in a given state.
* @param obj pointer to an object
* @param part the part of the object which style property should be set.
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param the value to set
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_obj_style_get_text_font()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void _lv_obj_set_style_local_data_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop,
const void * value)
{
lv_style_fptr_dptr_t fd;
fd.fptr = NULL;
fd.dptr = value;
_lv_obj_set_style_local_ptr(obj, type, prop, fd);
}
void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, const void * value);
/**
* Remove a local style property from a part of an object with a given state.
@@ -1133,52 +1107,7 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop
* For example: `lv_obj_style_get_border_opa()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
lv_style_fptr_dptr_t _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
/**
* Get a style property of a part of an object in the object's current state.
* If there is a running transitions it is taken into account
* @param obj pointer to an object
* @param part the part of the object which style property should be get.
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
* @param prop the property to get. E.g. `LV_STYLE_TEXT_FONT`.
* The state of the object will be added internally
* @return the value of the property of the given part in the current state.
* If the property is not found a default value will be returned.
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_obj_style_get_trasition_path()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline lv_style_prop_cb_t _lv_obj_get_style_func_ptr(const lv_obj_t * obj, uint8_t part,
lv_style_property_t prop)
{
lv_style_fptr_dptr_t fd;
fd = _lv_obj_get_style_ptr(obj, part, prop);
return fd.fptr;
}
/**
* Get a style property of a part of an object in the object's current state.
* If there is a running transitions it is taken into account
* @param obj pointer to an object
* @param part the part of the object which style property should be get.
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
* @param prop the property to get. E.g. `LV_STYLE_TEXT_FONT`.
* The state of the object will be added internally
* @return the value of the property of the given part in the current state.
* If the property is not found a default value will be returned.
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_obj_style_get_text_font()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline const void * _lv_obj_get_style_data_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
{
lv_style_fptr_dptr_t fd;
fd = _lv_obj_get_style_ptr(obj, part, prop);
return fd.dptr;
}
const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
/**
* Get the local style of a part of an object.

View File

@@ -58,24 +58,12 @@ extern "C" {
* `lv_style_set_border_width(&style1, LV_STATE_PRESSED, 2);`
*/
#ifdef __cplusplus
#define FUNC_PTR_CAST(v) reinterpret_cast<lv_style_prop_cb_t>(v)
#else
#define FUNC_PTR_CAST(v) (lv_style_prop_cb_t)v
#endif
#define _OBJ_GET_STYLE_scalar(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
{ \
return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
}
#define _OBJ_GET_STYLE_func_ptr(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
{ \
return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
}
#define _OBJ_GET_STYLE_nonscalar(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
{ \
@@ -94,12 +82,6 @@ extern "C" {
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
#define _OBJ_SET_STYLE_LOCAL_func_ptr(prop_name, func_name, value_type, style_type) \
static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
{ \
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), FUNC_PTR_CAST(value)); \
}
#define _OBJ_SET_STYLE_scalar(prop_name, func_name, value_type, style_type) \
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
{ \
@@ -112,12 +94,6 @@ extern "C" {
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
#define _OBJ_SET_STYLE_func_ptr(prop_name, func_name, value_type, style_type) \
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
{ \
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), FUNC_PTR_CAST(value)); \
} \
#define _LV_OBJ_STYLE_SET_GET_DECLARE(prop_name, func_name, value_type, style_type, scalar) \
_OBJ_GET_STYLE_##scalar(prop_name, func_name, value_type, style_type) \
_OBJ_SET_STYLE_LOCAL_##scalar(prop_name, func_name, value_type, style_type) \
@@ -180,7 +156,7 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_BLEND_MODE, pattern_blend_mode, lv_blend_m
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_RECOLOR, pattern_recolor, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_OPA, pattern_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_RECOLOR_OPA, pattern_recolor_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_IMAGE, pattern_image, const void *, _data_ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_IMAGE, pattern_image, const void *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_LETTER_SPACE, value_letter_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_LINE_SPACE, value_line_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_BLEND_MODE, value_blend_mode, lv_blend_mode_t, _int, scalar)
@@ -189,8 +165,8 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OFS_Y, value_ofs_y, lv_style_int_t, _int, sc
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_ALIGN, value_align, lv_align_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_COLOR, value_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OPA, value_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t *, _data_ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char *, _data_ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LETTER_SPACE, text_letter_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LINE_SPACE, text_line_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_DECOR, text_decor, lv_text_decor_t, _int, scalar)
@@ -198,7 +174,7 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_BLEND_MODE, text_blend_mode, lv_blend_mode_t,
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_COLOR, text_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_COLOR, text_sel_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_OPA, text_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t *, _data_ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_WIDTH, line_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_BLEND_MODE, line_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_DASH_WIDTH, line_dash_width, lv_style_int_t, _int, scalar)
@@ -219,10 +195,10 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_4, transition_prop_4, lv_style_int
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_5, transition_prop_5, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_6, transition_prop_6, lv_style_int_t, _int, scalar)
#if LV_USE_ANIMATION
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_anim_path_cb_t, _func_ptr, func_ptr)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_anim_path_t *, _ptr, scalar)
#else
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_style_prop_cb_t, _func_ptr,
func_ptr) /*For compatibility*/
/*For compatibility*/
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, const void *, _ptr, scalar)
#endif
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_WIDTH, scale_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_BORDER_WIDTH, scale_border_width, lv_style_int_t, _int, scalar)

View File

@@ -225,7 +225,7 @@ void lv_disp_refr_task(lv_task_t * task)
uint32_t line_length = lv_area_get_width(&disp_refr->inv_areas[a]) * sizeof(lv_color_t);
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);
lv_memcpy(buf_act + start_offs, buf_ina + start_offs, line_length);
start_offs += hres * sizeof(lv_color_t);
}
}

View File

@@ -60,7 +60,7 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list);
*/
void lv_style_init(lv_style_t * style)
{
memset(style, 0x00, sizeof(lv_style_t));
lv_memset_00(style, sizeof(lv_style_t));
#if LV_USE_ASSERT_STYLE
style->sentinel = LV_DEBUG_STYLE_SENTINEL_VALUE;
#endif
@@ -81,9 +81,8 @@ void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src)
if(style_src->map == NULL) return;
uint16_t size = lv_style_get_mem_size(style_src);
style_dest->map = lv_mem_alloc(size);
memcpy(style_dest->map, style_src->map, size);
lv_memcpy(style_dest->map, style_src->map, size);
}
/**
@@ -113,7 +112,7 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop)
if((prop & 0xF) < LV_STYLE_ID_COLOR) prop_size += sizeof(lv_style_int_t);
else if((prop & 0xF) < LV_STYLE_ID_OPA) prop_size += sizeof(lv_color_t);
else if((prop & 0xF) < LV_STYLE_ID_PTR) prop_size += sizeof(lv_opa_t);
else prop_size += sizeof(lv_style_fptr_dptr_t);
else prop_size += sizeof(const void *);
/*Move the props to fill the space of the property to delete*/
uint32_t i;
@@ -136,7 +135,7 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop)
*/
void lv_style_list_init(lv_style_list_t * list)
{
memset(list, 0x00, sizeof(lv_style_list_t));
lv_memset_00(list, sizeof(lv_style_list_t));
#if LV_USE_ASSERT_STYLE
list->sentinel = LV_DEBUG_STYLE_LIST_SENTINEL_VALUE;
#endif
@@ -160,24 +159,24 @@ void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * lis
if(list_src->has_local == 0) {
if(list_src->has_trans) {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
lv_memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 1;
}
else {
list_dest->style_list = lv_mem_alloc(list_src->style_cnt * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *));
lv_memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt;
}
}
else {
if(list_src->has_trans) {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 2) * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list + 2, (list_src->style_cnt - 2) * sizeof(lv_style_t *));
lv_memcpy(list_dest->style_list, list_src->style_list + 2, (list_src->style_cnt - 2) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 2;
}
else {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
lv_memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 1;
}
@@ -342,7 +341,7 @@ uint16_t lv_style_get_mem_size(const lv_style_t * style)
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t);
else i += sizeof(lv_style_fptr_dptr_t);
else i += sizeof(const void *);
i += sizeof(lv_style_property_t);
}
@@ -374,7 +373,7 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in
attr_goal.full = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) {
memcpy(style->map + id + sizeof(lv_style_property_t), &value, sizeof(lv_style_int_t));
lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &value, sizeof(lv_style_int_t));
return;
}
}
@@ -391,9 +390,9 @@ void _lv_style_set_int(lv_style_t * style, lv_style_property_t prop, lv_style_in
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
memcpy(style->map + size - sizeof(lv_style_int_t) - end_mark_size, &value, sizeof(lv_style_int_t));
memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
lv_memcpy_small(style->map + size - sizeof(lv_style_int_t) - end_mark_size, &value, sizeof(lv_style_int_t));
lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
}
/**
@@ -420,7 +419,7 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_
attr_goal.full = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) {
memcpy(style->map + id + sizeof(lv_style_property_t), &color, sizeof(lv_color_t));
lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &color, sizeof(lv_color_t));
return;
}
}
@@ -438,9 +437,9 @@ void _lv_style_set_color(lv_style_t * style, lv_style_property_t prop, lv_color_
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
memcpy(style->map + size - sizeof(lv_color_t) - end_mark_size, &color, sizeof(lv_color_t));
memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
lv_memcpy_small(style->map + size - sizeof(lv_color_t) - end_mark_size, &color, sizeof(lv_color_t));
lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
}
/**
@@ -467,7 +466,7 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op
attr_goal.full = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) {
memcpy(style->map + id + sizeof(lv_style_property_t), &opa, sizeof(lv_opa_t));
lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &opa, sizeof(lv_opa_t));
return;
}
}
@@ -485,9 +484,9 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
memcpy(style->map + size - sizeof(lv_opa_t) - end_mark_size, &opa, sizeof(lv_opa_t));
memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
lv_memcpy_small(style->map + size - sizeof(lv_opa_t) - end_mark_size, &opa, sizeof(lv_opa_t));
lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
}
/**
@@ -500,7 +499,7 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op
* For example: `lv_style_set_border_width()`
* @note for performance reasons it's not checked if the property is really has pointer type
*/
void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, lv_style_fptr_dptr_t p)
void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void * p)
{
LV_ASSERT_STYLE(style);
@@ -514,27 +513,27 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, lv_style_fp
attr_goal.full = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) {
memcpy(style->map + id + sizeof(lv_style_property_t), &p, sizeof(lv_style_fptr_dptr_t));
lv_memcpy_small(style->map + id + sizeof(lv_style_property_t), &p, sizeof(const void * ));
return;
}
}
/*Add new property if not exists yet*/
uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(lv_style_fptr_dptr_t));
uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(const void * ));
lv_style_property_t end_mark = _LV_STYLE_CLOSEING_PROP;
uint8_t end_mark_size = sizeof(end_mark);
uint16_t size = lv_style_get_mem_size(style);
if(size == 0) size += end_mark_size;
size += sizeof(lv_style_property_t) + sizeof(lv_style_fptr_dptr_t);
size += sizeof(lv_style_property_t) + sizeof(const void * );
style->map = lv_mem_realloc(style->map, size);
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
memcpy(style->map + size - sizeof(lv_style_fptr_dptr_t) - end_mark_size, &p, sizeof(lv_style_fptr_dptr_t));
memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
lv_memcpy_small(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
lv_memcpy_small(style->map + size - sizeof(const void * ) - end_mark_size, &p, sizeof(const void * ));
lv_memcpy_small(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
}
/**
@@ -554,12 +553,13 @@ int16_t _lv_style_get_int(const lv_style_t * style, lv_style_property_t prop, vo
if(style == NULL) return -1;
if(style->map == NULL) return -1;
int32_t id = get_property_index(style, prop);
if(id < 0) {
return -1;
}
else {
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t));
lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_int_t));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
@@ -590,12 +590,13 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo
if(style == NULL) return -1;
if(style->map == NULL) return -1;
int32_t id = get_property_index(style, prop);
if(id < 0) {
return -1;
}
else {
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_opa_t));
lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_opa_t));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
@@ -629,7 +630,7 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop,
return -1;
}
else {
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_color_t));
lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_color_t));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
@@ -655,15 +656,16 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop,
*/
int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void * v_res)
{
lv_style_fptr_dptr_t * res = (lv_style_fptr_dptr_t *)v_res;
const void ** res = (const void **)v_res;
if(style == NULL) return -1;
if(style->map == NULL) return -1;
int32_t id = get_property_index(style, prop);
if(id < 0) {
return -1;
}
else {
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_fptr_dptr_t));
lv_memcpy_small(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(const void *));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
@@ -789,7 +791,7 @@ void lv_style_list_set_local_color(lv_style_list_t * list, lv_style_property_t p
* @param value the value to set
* @note for performance reasons it's not checked if the property really has pointer type
*/
void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t prop, lv_style_fptr_dptr_t value)
void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t prop, const void * value)
{
LV_ASSERT_STYLE_LIST(list);
@@ -962,7 +964,7 @@ lv_res_t lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop,
* LV_RES_INV: there was NO matching property in the list
* @note for performance reasons it's not checked if the property really has pointer type
*/
lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, lv_style_fptr_dptr_t * res)
lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, const void ** res)
{
LV_ASSERT_STYLE_LIST(list);
@@ -975,9 +977,7 @@ lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop,
int16_t weight = -1;
lv_style_fptr_dptr_t value_act;
value_act.dptr = NULL;
value_act.fptr = NULL;
const void * value_act;
int16_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
@@ -985,20 +985,17 @@ lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop,
int16_t weight_act = _lv_style_get_ptr(class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
res->dptr = value_act.dptr;
res->fptr = value_act.fptr;
*res = value_act;
return LV_RES_OK;
}
else if(list->has_trans && weight_act >= 0 && ci == 0 && !list->skip_trans) {
res->dptr = value_act.dptr;
res->fptr = value_act.fptr;
*res = value_act;
return LV_RES_OK;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
res->dptr = value_act.dptr;
res->fptr = value_act.fptr;
*res = value_act;
}
}
@@ -1020,7 +1017,6 @@ lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop,
*/
static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop)
{
LV_ASSERT_STYLE(style);
if(style->map == NULL) return -1;
@@ -1058,7 +1054,7 @@ static inline int32_t get_property_index(const lv_style_t * style, lv_style_prop
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t);
else i += sizeof(lv_style_fptr_dptr_t);
else i += sizeof(const void *);
i += sizeof(lv_style_property_t);
}
@@ -1091,4 +1087,3 @@ static lv_style_t * get_alloc_local_style(lv_style_list_t * list)
return local_style;
}

View File

@@ -216,14 +216,6 @@ typedef struct {
typedef int16_t lv_style_int_t;
typedef void(*lv_style_prop_cb_t)(void);
typedef union {
lv_style_prop_cb_t fptr;
const void * dptr;
} lv_style_fptr_dptr_t;
typedef struct {
lv_style_t ** style_list;
#if LV_USE_ASSERT_STYLE
@@ -371,43 +363,8 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op
* For example: `lv_style_set_border_width()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, lv_style_fptr_dptr_t p);
void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void * p);
/**
* Set a function pointer typed property in a style.
* @param style pointer to a style where the property should be set
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TRANSITION_PATH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param value the value to set
* @note shouldn't be used directly. Use the specific property set functions instead.
* For example: `lv_style_set_border_width()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void _lv_style_set_func_ptr(lv_style_t * style, lv_style_property_t prop, lv_style_prop_cb_t p)
{
lv_style_fptr_dptr_t fd;
fd.dptr = NULL;
fd.fptr = p;
_lv_style_set_ptr(style, prop, fd);
}
/**
* Set a data pointer typed property in a style.
* @param style pointer to a style where the property should be set
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TRANSITION_PATH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param value the value to set
* @note shouldn't be used directly. Use the specific property set functions instead.
* For example: `lv_style_set_border_width()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void _lv_style_set_data_ptr(lv_style_t * style, lv_style_property_t prop, const void * p)
{
lv_style_fptr_dptr_t fd;
fd.fptr = NULL;
fd.dptr = p;
_lv_style_set_ptr(style, prop, fd);
}
/**
@@ -470,57 +427,6 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo
*/
int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void * res);
/**
* Get a pointer typed property from a style.
* @param style pointer to a style from where the property should be get
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param res pointer to a buffer to store the result value
* @return -1: the property wasn't found in the style.
* The matching state bits of the desired state (in `prop`) and the best matching property's state
* Higher value means match in higher precedence state.
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_style_get_transition_path()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline int16_t _lv_style_get_func_ptr(const lv_style_t * style, lv_style_property_t prop, void * res)
{
lv_style_fptr_dptr_t fd_res;
fd_res.dptr = NULL;
fd_res.fptr = NULL;
lv_res_t r = _lv_style_get_ptr(style, prop, &fd_res);
lv_style_prop_cb_t * res2 = (lv_style_prop_cb_t *)res;
*res2 = fd_res.fptr;
return r;
}
/**
* Get a pointer typed property from a style.
* @param style pointer to a style from where the property should be get
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param res pointer to a buffer to store the result value
* @return -1: the property wasn't found in the style.
* The matching state bits of the desired state (in `prop`) and the best matching property's state
* Higher value means match in higher precedence state.
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_style_get_text_font()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline int16_t _lv_style_get_data_ptr(const lv_style_t * style, lv_style_property_t prop, void * res)
{
lv_style_fptr_dptr_t fd_res;
fd_res.dptr = NULL;
fd_res.fptr = NULL;
lv_res_t r = _lv_style_get_ptr(style, prop, &fd_res);
void ** res2 = (void **)res;
*res2 = (void *)fd_res.dptr;
return r;
}
/**
* Get the local style of a style list
* @param list pointer to a style list where the local property should be set
@@ -580,41 +486,8 @@ void lv_style_list_set_local_opa(lv_style_list_t * list, lv_style_property_t pro
* @param value the value to set
* @note for performance reasons it's not checked if the property really has pointer type
*/
void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t prop, lv_style_fptr_dptr_t value);
void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t prop, const void * value);
/**
* Set a local pointer typed property in a style list.
* @param list pointer to a style list where the local property should be set
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TRANSITION_PATH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param value the value to set
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void lv_style_list_set_local_func_ptr(lv_style_list_t * list, lv_style_property_t prop,
lv_style_prop_cb_t value)
{
lv_style_fptr_dptr_t fd;
fd.dptr = NULL;
fd.fptr = value;
lv_style_list_set_local_ptr(list, prop, fd);
}
/**
* Set a local pointer typed property in a style list.
* @param list pointer to a style list where the local property should be set
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param value the value to set
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void lv_style_list_set_local_data_ptr(lv_style_list_t * list, lv_style_property_t prop,
const void * value)
{
lv_style_fptr_dptr_t fd;
fd.fptr = NULL;
fd.dptr = value;
lv_style_list_set_local_ptr(list, prop, fd);
}
/**
* Get an integer typed property from a style list.
* It will return the property which match best with given state.
@@ -665,55 +538,10 @@ lv_res_t lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop,
* @return LV_RES_OK: there was a matching property in the list
* LV_RES_INV: there was NO matching property in the list
* @note for performance reasons it's not checked if the property really has pointer type
* @note Do not use this function directly. Use `lv_style_list_get_func_ptr` or `lv_style_list_get_data_ptr`
*/
lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, lv_style_fptr_dptr_t * res);
lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, const void ** res);
/**
* Get a function pointer typed property from a style list.
* It will return the property which match best with given state.
* @param list pointer to a style list from where the property should be get
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TRANSITION_PATH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param res pointer to a buffer to store the result
* @return LV_RES_OK: there was a matching property in the list
* LV_RES_INV: there was NO matching property in the list
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline lv_res_t lv_style_list_get_func_ptr(lv_style_list_t * list, lv_style_property_t prop, void (**res)(void))
{
lv_style_fptr_dptr_t fd_res;
fd_res.dptr = NULL;
fd_res.fptr = NULL;
lv_res_t r = lv_style_list_get_ptr(list, prop, &fd_res);
*res = fd_res.fptr;
return r;
}
/**
* Get a data pointer typed property from a style list.
* It will return the property which match best with given state.
* @param list pointer to a style list from where the property should be get
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param res pointer to a buffer to store the result
* @return LV_RES_OK: there was a matching property in the list
* LV_RES_INV: there was NO matching property in the list
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline lv_res_t lv_style_list_get_data_ptr(lv_style_list_t * list, lv_style_property_t prop, const void ** res)
{
lv_style_fptr_dptr_t fd_res;
fd_res.dptr = NULL;
fd_res.fptr = NULL;
lv_res_t r = lv_style_list_get_ptr(list, prop, &fd_res);
*res = fd_res.dptr;
return r;
}
/*************************
* GLOBAL VARIABLES
*************************/

View File

@@ -909,11 +909,11 @@ static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color
fg.ch.red = LV_MATH_MIN(tmp, 255);
#endif
tmp = bg.ch.green + fg.ch.green;
#if LV_COLOR_DEPTH == 8
fg.ch.green = LV_MATH_MIN(tmp, 7);
#elif LV_COLOR_DEPTH == 16
#if LV_COLOR_16_SWAP == 0
tmp = bg.ch.green + fg.ch.green;
fg.ch.green = LV_MATH_MIN(tmp, 63);
#else
tmp = (bg.ch.green_h << 3) + bg.ch.green_l + (fg.ch.green_h << 3) + fg.ch.green_l;

View File

@@ -50,7 +50,7 @@ static void show_error(const lv_area_t * coords, const lv_area_t * clip_area, co
void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc)
{
memset(dsc, 0x00, sizeof(lv_draw_img_dsc_t));
lv_memset_00(dsc, sizeof(lv_draw_img_dsc_t));
dsc->recolor = LV_COLOR_BLACK;
dsc->opa = LV_OPA_COVER;
dsc->zoom = LV_IMG_ZOOM_NONE;

View File

@@ -33,12 +33,11 @@ typedef uint8_t cmd_state_t;
* STATIC PROTOTYPES
**********************/
static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, const lv_font_t * font_p,
uint32_t letter,
lv_color_t color, lv_opa_t opa);
uint32_t letter, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa);
const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa);
const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
static uint8_t hex_char_to_num(char hex);
@@ -46,32 +45,39 @@ static uint8_t hex_char_to_num(char hex);
/**********************
* STATIC VARIABLES
**********************/
/*clang-format off*/
static const uint8_t bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
static const uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
static const 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
};
static const uint8_t bpp8_opa_table[256] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
};
/*clang-format on*/
/**********************
* GLOBAL VARIABLES
**********************/
const uint8_t _lv_bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
const uint8_t _lv_bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
const uint8_t _lv_bpp3_opa_table[8] = {0, 36, 73, 109, /*Opacity mapping with bpp = 3*/
146, 182, 219, 255};
const uint8_t _lv_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
};
const uint8_t _lv_bpp8_opa_table[256] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
};
/**********************
* MACROS
@@ -83,7 +89,7 @@ static const uint8_t bpp8_opa_table[256] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
{
memset(dsc, 0x00, sizeof(lv_draw_label_dsc_t));
lv_memset_00(dsc, sizeof(lv_draw_label_dsc_t));
dsc->opa = LV_OPA_COVER;
dsc->color = LV_COLOR_BLACK;
dsc->font = LV_THEME_DEFAULT_FONT_NORMAL;
@@ -276,7 +282,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
/*Get the parameter*/
if(i - par_start == LABEL_RECOLOR_PAR_LENGTH + 1) {
char buf[LABEL_RECOLOR_PAR_LENGTH + 1];
memcpy(buf, &bidi_txt[par_start], LABEL_RECOLOR_PAR_LENGTH);
lv_memcpy_small(buf, &bidi_txt[par_start], LABEL_RECOLOR_PAR_LENGTH);
buf[LABEL_RECOLOR_PAR_LENGTH] = '\0';
int r, g, b;
r = (hex_char_to_num(buf[0]) << 4) + hex_char_to_num(buf[1]);
@@ -310,7 +316,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
}
}
lv_draw_letter(&pos, mask, font, letter, color, opa);
lv_draw_letter(&pos, mask, font, letter, color, opa, dsc->blend_mode);
if(letter_w > 0) {
pos.x += letter_w + dsc->letter_space;
@@ -386,7 +392,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
*/
static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, const lv_font_t * font_p,
uint32_t letter,
lv_color_t color, lv_opa_t opa)
lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
{
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
@@ -429,16 +435,16 @@ static void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area
}
if(font_p->subpx) {
draw_letter_subpx(pos_x, pos_y, &g, clip_area, map_p, color, opa);
draw_letter_subpx(pos_x, pos_y, &g, clip_area, map_p, color, opa, blend_mode);
}
else {
draw_letter_normal(pos_x, pos_y, &g, clip_area, map_p, color, opa);
draw_letter_normal(pos_x, pos_y, &g, clip_area, map_p, color, opa, blend_mode);
}
}
static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa)
const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
{
const uint8_t * bpp_opa_table_p;
uint32_t bitmask_init;
@@ -449,22 +455,22 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
switch(bpp) {
case 1:
bpp_opa_table_p = bpp1_opa_table;
bpp_opa_table_p = _lv_bpp1_opa_table;
bitmask_init = 0x80;
shades = 2;
break;
case 2:
bpp_opa_table_p = bpp2_opa_table;
bpp_opa_table_p = _lv_bpp2_opa_table;
bitmask_init = 0xC0;
shades = 4;
break;
case 4:
bpp_opa_table_p = bpp4_opa_table;
bpp_opa_table_p = _lv_bpp4_opa_table;
bitmask_init = 0xF0;
shades = 16;
break;
case 8:
bpp_opa_table_p = bpp8_opa_table;
bpp_opa_table_p = _lv_bpp8_opa_table;
bitmask_init = 0xFF;
shades = 256;
break; /*No opa table, pixel value will be used directly*/
@@ -567,7 +573,7 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
else {
lv_blend_fill(clip_area, &fill_area,
color, mask_buf, LV_DRAW_MASK_RES_CHANGED, LV_OPA_COVER,
LV_BLEND_MODE_NORMAL);
blend_mode);
fill_area.y1 = fill_area.y2 + 1;
fill_area.y2 = fill_area.y1;
@@ -584,7 +590,7 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
fill_area.y2--;
lv_blend_fill(clip_area, &fill_area,
color, mask_buf, LV_DRAW_MASK_RES_CHANGED, LV_OPA_COVER,
LV_BLEND_MODE_NORMAL);
blend_mode);
mask_p = 0;
}
@@ -592,7 +598,7 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph
}
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa)
const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode)
{
const uint8_t * bpp_opa_table;
uint32_t bitmask_init;
@@ -602,19 +608,19 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
switch(bpp) {
case 1:
bpp_opa_table = bpp1_opa_table;
bpp_opa_table = _lv_bpp1_opa_table;
bitmask_init = 0x80;
break;
case 2:
bpp_opa_table = bpp2_opa_table;
bpp_opa_table = _lv_bpp2_opa_table;
bitmask_init = 0xC0;
break;
case 4:
bpp_opa_table = bpp4_opa_table;
bpp_opa_table = _lv_bpp4_opa_table;
bitmask_init = 0xF0;
break;
case 8:
bpp_opa_table = bpp8_opa_table;
bpp_opa_table = _lv_bpp8_opa_table;
bitmask_init = 0xFF;
break; /*No opa table, pixel value will be used directly*/
default:
@@ -765,7 +771,7 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
map_area.y2 ++;
}
else {
lv_blend_map(clip_area, &map_area, color_buf, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa, LV_BLEND_MODE_NORMAL);
lv_blend_map(clip_area, &map_area, color_buf, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa, blend_mode);
map_area.y1 = map_area.y2 + 1;
map_area.y2 = map_area.y1;
@@ -784,7 +790,7 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
/*Flush the last part*/
if(map_area.y1 != map_area.y2) {
map_area.y2--;
lv_blend_map(clip_area, &map_area, color_buf, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa, LV_BLEND_MODE_NORMAL);
lv_blend_map(clip_area, &map_area, color_buf, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa, blend_mode);
}
lv_mem_buf_release(mask_buf);

View File

@@ -76,6 +76,15 @@ void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc);
void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_label_dsc_t * dsc,
const char * txt, lv_draw_label_hint_t * hint);
/***********************
* GLOBAL VARIABLES
***********************/
extern const uint8_t _lv_bpp2_opa_table[];
extern const uint8_t _lv_bpp3_opa_table[];
extern const uint8_t _lv_bpp1_opa_table[];
extern const uint8_t _lv_bpp4_opa_table[];
extern const uint8_t _lv_bpp8_opa_table[];
/**********************
* MACROS
**********************/

View File

@@ -45,7 +45,7 @@ static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2,
void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc)
{
memset(dsc, 0x00, sizeof(lv_draw_line_dsc_t));
lv_memset_00(dsc, sizeof(lv_draw_line_dsc_t));
dsc->width = 1;
dsc->opa = LV_OPA_COVER;
dsc->color = LV_COLOR_BLACK;
@@ -145,7 +145,7 @@ static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2,
if(simple_mode) {
lv_blend_fill(clip, &draw_area,
dsc->color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
LV_BLEND_MODE_NORMAL);
dsc->blend_mode);
}
/*If there other mask apply it*/
else {

View File

@@ -210,7 +210,7 @@ void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t
param->flat = (LV_MATH_ABS(p2x - p1x) > LV_MATH_ABS(p2y - p1y)) ? 1 : 0;
param->yx_steep = 0;
param->xy_steep = 0;
param->dsc.cb = (lv_draw_mask_cb_t)lv_draw_mask_line;
param->dsc.cb = (lv_draw_mask_xcb_t)lv_draw_mask_line;
param->dsc.type = LV_DRAW_MASK_TYPE_LINE;
int32_t dx = p2x - p1x;
@@ -328,7 +328,7 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert
param->cfg.end_angle = end_angle;
param->cfg.vertex_p.x = vertex_x;
param->cfg.vertex_p.y = vertex_y;
param->dsc.cb = (lv_draw_mask_cb_t)lv_draw_mask_angle;
param->dsc.cb = (lv_draw_mask_xcb_t)lv_draw_mask_angle;
param->dsc.type = LV_DRAW_MASK_TYPE_ANGLE;
if(start_angle >= 0 && start_angle < 180) {
@@ -375,7 +375,7 @@ void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area
lv_area_copy(&param->cfg.rect, rect);
param->cfg.radius = radius;
param->cfg.outer = inv ? 1 : 0;
param->dsc.cb = (lv_draw_mask_cb_t)lv_draw_mask_radius;
param->dsc.cb = (lv_draw_mask_xcb_t)lv_draw_mask_radius;
param->dsc.type = LV_DRAW_MASK_TYPE_RADIUS;
param->y_prev = INT32_MIN;
param->y_prev_x.f = 0;
@@ -401,7 +401,7 @@ void lv_draw_mask_fade_init(lv_draw_mask_fade_param_t * param, const lv_area_t *
param->cfg.opa_bottom = opa_bottom;
param->cfg.y_top = y_top;
param->cfg.y_bottom = y_bottom;
param->dsc.cb = (lv_draw_mask_cb_t)lv_draw_mask_fade;
param->dsc.cb = (lv_draw_mask_xcb_t)lv_draw_mask_fade;
param->dsc.type = LV_DRAW_MASK_TYPE_FADE;
}
@@ -416,7 +416,7 @@ void lv_draw_mask_map_init(lv_draw_mask_map_param_t * param, const lv_area_t * c
{
lv_area_copy(&param->cfg.coords, coords);
param->cfg.map = map;
param->dsc.cb = (lv_draw_mask_cb_t)lv_draw_mask_map;
param->dsc.cb = (lv_draw_mask_xcb_t)lv_draw_mask_map;
param->dsc.type = LV_DRAW_MASK_TYPE_MAP;
}

View File

@@ -53,13 +53,17 @@ enum {
LV_DRAW_MASK_LINE_SIDE_BOTTOM,
};
typedef lv_draw_mask_res_t (*lv_draw_mask_cb_t)(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
/**
* A common callback type for every mask type.
* Used internally by the library.
*/
typedef lv_draw_mask_res_t (*lv_draw_mask_xcb_t)(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len,
void * p);
typedef uint8_t lv_draw_mask_line_side_t;
typedef struct {
lv_draw_mask_cb_t cb;
lv_draw_mask_xcb_t cb;
lv_draw_mask_type_t type;
} lv_draw_mask_common_dsc_t;

View File

@@ -59,7 +59,7 @@ static int32_t sh_cache_r = -1;
void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
{
memset(dsc, 0x00, sizeof(lv_draw_rect_dsc_t));
lv_memset_00(dsc, sizeof(lv_draw_rect_dsc_t));
dsc->bg_color = LV_COLOR_WHITE;
dsc->bg_grad_color = LV_COLOR_BLACK;
dsc->border_color = LV_COLOR_BLACK;
@@ -273,6 +273,14 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
lv_blend_fill(clip, &fill_area2,
grad_color, mask_buf, mask_res, opa, dsc->bg_blend_mode);
/*Center part*/
if(dsc->bg_grad_dir == LV_GRAD_DIR_VER) {
fill_area2.x1 = coords_bg.x1 + rout;
fill_area2.x2 = coords_bg.x2 - rout;
lv_blend_fill(clip, &fill_area2,
grad_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode);
}
/*Right part*/
fill_area2.x1 = coords_bg.x2 - rout + 1;
fill_area2.x2 = coords_bg.x2;
@@ -281,6 +289,8 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re
if(mask_ofs < 0) mask_ofs = 0;
lv_blend_fill(clip, &fill_area2,
grad_color, mask_buf + mask_ofs, mask_res, opa, dsc->bg_blend_mode);
}
else {
if(dsc->bg_grad_dir == LV_GRAD_DIR_HOR) {

View File

@@ -59,7 +59,7 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t
dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
uint32_t px = dsc->header.w * y * px_size + x * px_size;
memcpy(&p_color, &buf_u8[px], sizeof(lv_color_t));
lv_memcpy_small(&p_color, &buf_u8[px], sizeof(lv_color_t));
#if LV_COLOR_SIZE == 32
p_color.ch.alpha = 0xFF; /*Only the color should be get so use a deafult alpha value*/
#endif
@@ -246,12 +246,12 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
uint32_t px = dsc->header.w * y * px_size + x * px_size;
memcpy(&buf_u8[px], &c, px_size);
lv_memcpy_small(&buf_u8[px], &c, px_size);
}
else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
uint32_t px = dsc->header.w * y * px_size + x * px_size;
memcpy(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/
lv_memcpy_small(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/
}
else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
buf_u8 += sizeof(lv_color32_t) * 2; /*Skip the palette*/
@@ -319,7 +319,7 @@ void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c)
lv_color32_t c32;
c32.full = lv_color_to32(c);
uint8_t * buf = (uint8_t *)dsc->data;
memcpy(&buf[id * sizeof(c32)], &c32, sizeof(c32));
lv_memcpy_small(&buf[id * sizeof(c32)], &c32, sizeof(c32));
}
/**
@@ -507,12 +507,12 @@ bool lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t
px_size = LV_COLOR_SIZE >> 3;
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size;
memcpy(&dsc->res.color, &src_u8[pxi], px_size);
lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size);
}
else {
px_size = LV_IMG_PX_SIZE_ALPHA_BYTE;
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size;
memcpy(&dsc->res.color, &src_u8[pxi], px_size - 1);
lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size - 1);
dsc->res.opa = src_u8[pxi + px_size - 1];
}
}
@@ -669,9 +669,9 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc)
lv_opa_t a11 = 0;
if(dsc->tmp.native_color) {
memcpy(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t));
memcpy(&c10, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn], sizeof(lv_color_t));
memcpy(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn],
lv_memcpy_small(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t));
lv_memcpy_small(&c10, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn], sizeof(lv_color_t));
lv_memcpy_small(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn],
sizeof(lv_color_t));
if(dsc->tmp.has_alpha) {
a10 = src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1];

View File

@@ -130,8 +130,8 @@ lv_img_cache_entry_t * lv_img_cache_open(const void * src, lv_color_t color)
if(open_res == LV_RES_INV) {
LV_LOG_WARN("Image draw cannot open the image resource");
lv_img_decoder_close(&cached_src->dec_dsc);
memset(&cached_src->dec_dsc, 0, sizeof(lv_img_decoder_dsc_t));
memset(cached_src, 0, sizeof(lv_img_cache_entry_t));
lv_memset_00(&cached_src->dec_dsc, sizeof(lv_img_decoder_dsc_t));
lv_memset_00(cached_src, sizeof(lv_img_cache_entry_t));
cached_src->life = INT32_MIN; /*Make the empty entry very "weak" to force its use */
return NULL;
}
@@ -175,8 +175,8 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt)
/*Clean the cache*/
uint16_t i;
for(i = 0; i < entry_cnt; i++) {
memset(&LV_GC_ROOT(_lv_img_cache_array)[i].dec_dsc, 0, sizeof(lv_img_decoder_dsc_t));
memset(&LV_GC_ROOT(_lv_img_cache_array)[i], 0, sizeof(lv_img_cache_entry_t));
lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i].dec_dsc, sizeof(lv_img_decoder_dsc_t));
lv_memset_00(&LV_GC_ROOT(_lv_img_cache_array)[i], sizeof(lv_img_cache_entry_t));
}
}
@@ -197,8 +197,8 @@ void lv_img_cache_invalidate_src(const void * src)
lv_img_decoder_close(&cache[i].dec_dsc);
}
memset(&cache[i].dec_dsc, 0, sizeof(lv_img_decoder_dsc_t));
memset(&cache[i], 0, sizeof(lv_img_cache_entry_t));
lv_memset_00(&cache[i].dec_dsc, sizeof(lv_img_decoder_dsc_t));
lv_memset_00(&cache[i], sizeof(lv_img_cache_entry_t));
}
}
}

View File

@@ -151,7 +151,7 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co
}
if(res == LV_RES_INV) {
memset(dsc, 0, sizeof(lv_img_decoder_dsc_t));
lv_memset_00(dsc, sizeof(lv_img_decoder_dsc_t));
}
return res;
@@ -201,7 +201,7 @@ lv_img_decoder_t * lv_img_decoder_create(void)
LV_ASSERT_MEM(decoder);
if(decoder == NULL) return NULL;
memset(decoder, 0, sizeof(lv_img_decoder_t));
lv_memset_00(decoder, sizeof(lv_img_decoder_t));
return decoder;
}
@@ -341,7 +341,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
return LV_RES_INV;
}
memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t));
lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t));
}
lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
@@ -353,7 +353,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
return LV_RES_INV;
}
memcpy(user_data->f, &f, sizeof(f));
lv_memcpy_small(user_data->f, &f, sizeof(f));
#else
LV_LOG_WARN("Image built-in decoder cannot read file because LV_USE_FILESYSTEM = 0");
@@ -399,7 +399,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
lv_img_decoder_built_in_close(decoder, dsc);
return LV_RES_INV;
}
memset(dsc->user_data, 0, sizeof(lv_img_decoder_built_in_data_t));
lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t));
}
lv_img_decoder_built_in_data_t * user_data = dsc->user_data;

View File

@@ -171,6 +171,34 @@ LV_FONT_DECLARE(lv_font_montserrat_30)
LV_FONT_DECLARE(lv_font_montserrat_32)
#endif
#if LV_FONT_MONTSERRAT_36
LV_FONT_DECLARE(lv_font_montserrat_36)
#endif
#if LV_FONT_MONTSERRAT_38
LV_FONT_DECLARE(lv_font_montserrat_38)
#endif
#if LV_FONT_MONTSERRAT_40
LV_FONT_DECLARE(lv_font_montserrat_40)
#endif
#if LV_FONT_MONTSERRAT_42
LV_FONT_DECLARE(lv_font_montserrat_42)
#endif
#if LV_FONT_MONTSERRAT_44
LV_FONT_DECLARE(lv_font_montserrat_44)
#endif
#if LV_FONT_MONTSERRAT_46
LV_FONT_DECLARE(lv_font_montserrat_46)
#endif
#if LV_FONT_MONTSERRAT_48
LV_FONT_DECLARE(lv_font_montserrat_48)
#endif
#if LV_FONT_MONTSERRAT_28_COMPRESSED
LV_FONT_DECLARE(lv_font_montserrat_28_compressed)
#endif

View File

@@ -6,11 +6,19 @@ CSRCS += lv_font_montserrat_16.c
CSRCS += lv_font_montserrat_18.c
CSRCS += lv_font_montserrat_20.c
CSRCS += lv_font_montserrat_22.c
CSRCS += lv_font_montserrat_14.c
CSRCS += lv_font_montserrat_24.c
CSRCS += lv_font_montserrat_26.c
CSRCS += lv_font_montserrat_28.c
CSRCS += lv_font_montserrat_30.c
CSRCS += lv_font_montserrat_32.c
CSRCS += lv_font_montserrat_34.c
CSRCS += lv_font_montserrat_36.c
CSRCS += lv_font_montserrat_38.c
CSRCS += lv_font_montserrat_40.c
CSRCS += lv_font_montserrat_42.c
CSRCS += lv_font_montserrat_44.c
CSRCS += lv_font_montserrat_46.c
CSRCS += lv_font_montserrat_48.c
CSRCS += lv_font_montserrat_12_subpx.c
CSRCS += lv_font_montserrat_28_compressed.c
CSRCS += lv_font_unscii_8.c

View File

@@ -40,7 +40,6 @@ static int32_t kern_pair_16_compare(const void * ref, const void * element);
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp);
static inline void decompress_line(uint8_t * out, lv_coord_t w);
static inline uint8_t get_bits(const uint8_t * in, uint32_t bit_pos, uint8_t len);
static inline void bits_write(uint8_t * out, uint32_t bit_pos, uint8_t val, uint8_t len);
static inline void rle_init(const uint8_t * in, uint8_t bpp);
static inline uint8_t rle_next(void);
@@ -94,24 +93,8 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
uint32_t gsize = gdsc->box_w * gdsc->box_h;
if(gsize == 0) return NULL;
uint32_t buf_size = gsize;
switch(fdsc->bpp) {
case 1:
buf_size = (gsize >> 3) + 4;
break;
case 2:
buf_size = (gsize >> 2) + 4;
break;
case 3:
buf_size = (gsize >> 1) + 4;
break;
case 4:
buf_size = (gsize >> 1) + 4;
break;
}
if(lv_mem_get_size(buf) < buf_size) {
buf = lv_mem_realloc(buf, buf_size);
if(lv_mem_get_size(buf) < gsize) {
buf = lv_mem_realloc(buf, gsize);
LV_ASSERT_MEM(buf);
if(buf == NULL) return NULL;
}
@@ -168,7 +151,7 @@ bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t *
dsc_out->box_w = gdsc->box_w;
dsc_out->ofs_x = gdsc->ofs_x;
dsc_out->ofs_y = gdsc->ofs_y;
dsc_out->bpp = (uint8_t)fdsc->bpp;
dsc_out->bpp = fdsc->bitmap_format == LV_FONT_FMT_TXT_PLAIN ? (uint8_t)fdsc->bpp : 8;
if(is_tab) dsc_out->box_w = dsc_out->box_w * 2;
@@ -324,12 +307,30 @@ static int32_t kern_pair_16_compare(const void * ref, const void * element)
*/
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp)
{
uint32_t wrp = 0;
uint8_t wr_size = bpp;
if(bpp == 3) wr_size = 4;
rle_init(in, bpp);
const uint8_t * bpp_opa_table;
switch(bpp) {
case 1:
bpp_opa_table = _lv_bpp1_opa_table;
break;
case 2:
bpp_opa_table = _lv_bpp2_opa_table;
break;
case 3:
bpp_opa_table = _lv_bpp3_opa_table;
break;
case 4:
bpp_opa_table = _lv_bpp4_opa_table;
break;
case 8:
bpp_opa_table = _lv_bpp8_opa_table;
break;
default:
LV_LOG_WARN("Invalid bpp (%d)", bpp);
return;
}
uint8_t * line_buf1 = lv_mem_buf_get(w);
uint8_t * line_buf2 = lv_mem_buf_get(w);
@@ -339,8 +340,8 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
lv_coord_t x;
for(x = 0; x < w; x++) {
bits_write(out, wrp, line_buf1[x], bpp);
wrp += wr_size;
*out = bpp_opa_table[line_buf1[x]];
out++;
}
for(y = 1; y < h; y++) {
@@ -348,8 +349,8 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
for(x = 0; x < w; x++) {
line_buf1[x] = line_buf2[x] ^ line_buf1[x];
bits_write(out, wrp, line_buf1[x], bpp);
wrp += wr_size;
*out = bpp_opa_table[line_buf1[x]];
out++;
}
}
@@ -412,55 +413,6 @@ static inline uint8_t get_bits(const uint8_t * in, uint32_t bit_pos, uint8_t len
}
}
/**
* Write `val` data to `bit_pos` position of `out`. The write can NOT cross byte boundary.
* @param out buffer where to write
* @param bit_pos bit index to write
* @param val value to write
* @param len length of bits to write from `val`. (Counted from the LSB).
* @note `len == 3` will be converted to `len = 4` and `val` will be upscaled too
*/
static inline void bits_write(uint8_t * out, uint32_t bit_pos, uint8_t val, uint8_t len)
{
if(len == 3) {
len = 4;
switch(val) {
case 0:
val = 0;
break;
case 1:
val = 2;
break;
case 2:
val = 4;
break;
case 3:
val = 6;
break;
case 4:
val = 9;
break;
case 5:
val = 11;
break;
case 6:
val = 13;
break;
case 7:
val = 15;
break;
}
}
uint16_t byte_pos = bit_pos >> 3;
bit_pos = bit_pos & 0x7;
bit_pos = 8 - bit_pos - len;
uint8_t bit_mask = (uint16_t)((uint16_t) 1 << len) - 1;
out[byte_pos] &= ((~bit_mask) << bit_pos);
out[byte_pos] |= (val << bit_pos);
}
static inline void rle_init(const uint8_t * in, uint8_t bpp)
{
rle_in = in;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -56,7 +56,7 @@ static lv_disp_t * disp_def;
*/
void lv_disp_drv_init(lv_disp_drv_t * driver)
{
memset(driver, 0, sizeof(lv_disp_drv_t));
lv_memset_00(driver, sizeof(lv_disp_drv_t));
driver->flush_cb = NULL;
driver->hor_res = LV_HOR_RES_MAX;
@@ -103,7 +103,7 @@ void lv_disp_drv_init(lv_disp_drv_t * driver)
*/
void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size_in_px_cnt)
{
memset(disp_buf, 0, sizeof(lv_disp_buf_t));
lv_memset_00(disp_buf, sizeof(lv_disp_buf_t));
disp_buf->buf1 = buf1;
disp_buf->buf2 = buf2;
@@ -125,9 +125,9 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
return NULL;
}
memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t));
memset(&disp->inv_area_joined, 0, sizeof(disp->inv_area_joined));
memset(&disp->inv_areas, 0, sizeof(disp->inv_areas));
lv_memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t));
lv_memset_00(&disp->inv_area_joined, sizeof(disp->inv_area_joined));
lv_memset_00(&disp->inv_areas, sizeof(disp->inv_areas));
lv_ll_init(&disp->scr_ll, sizeof(lv_obj_t));
disp->last_activity_time = 0;

View File

@@ -52,10 +52,10 @@ typedef struct {
void * buf_act;
uint32_t size; /*In pixel count*/
lv_area_t area;
volatile uint32_t flushing :1;
volatile uint32_t flushing_last :1;
volatile uint32_t last_area :1;
volatile uint32_t last_part :1;
volatile int flushing; /*1: flushing is in progress. (It can't be a bitfield because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
volatile int flushing_last; /*1: It was the last chunk to flush. (It can't be a bitfield because when it's cleared from IRQ Read-Modify-Write issue might occur)*/
volatile uint32_t last_area :1; /*1: the last area is being rendered*/
volatile uint32_t last_part :1; /*1: the last part of the current area is being rendered*/
} lv_disp_buf_t;
/**
@@ -133,7 +133,7 @@ struct _lv_obj_t;
/**
* Display structure.
* ::lv_disp_drv_t is the first member of the structure.
* @note `lv_disp_drv_t` should be the first member of the structure.
*/
typedef struct _disp_t {
/**< Driver to the display*/
@@ -262,6 +262,8 @@ uint32_t lv_disp_get_dpi(lv_disp_t * disp);
*/
lv_disp_size_t lv_disp_get_size_category(lv_disp_t * disp);
//! @cond Doxygen_Suppress
/**
* 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
@@ -276,6 +278,8 @@ LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv);
*/
LV_ATTRIBUTE_FLUSH_READY bool lv_disp_flush_is_last(lv_disp_drv_t * disp_drv);
//! @endcond
/**
* Get the next display.
* @param disp pointer to the current display. NULL to initialize.

View File

@@ -51,7 +51,7 @@
*/
void lv_indev_drv_init(lv_indev_drv_t * driver)
{
memset(driver, 0, sizeof(lv_indev_drv_t));
lv_memset_00(driver, sizeof(lv_indev_drv_t));
driver->type = LV_INDEV_TYPE_NONE;
driver->drag_limit = LV_INDEV_DEF_DRAG_LIMIT;
@@ -84,8 +84,8 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
return NULL;
}
memset(indev, 0, sizeof(lv_indev_t));
memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t));
lv_memset_00(indev, sizeof(lv_indev_t));
lv_memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t));
indev->proc.reset_query = 1;
indev->cursor = NULL;
@@ -131,7 +131,7 @@ bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data)
{
bool cont = false;
memset(data, 0, sizeof(lv_indev_data_t));
lv_memset_00(data, sizeof(lv_indev_data_t));
/* For touchpad sometimes users don't the last pressed coordinate on release.
* So be sure a coordinates are initialized to the last point */

View File

@@ -45,6 +45,7 @@ static bool anim_ready_handler(lv_anim_t * a);
static uint32_t last_task_run;
static bool anim_list_changed;
static lv_task_t * _lv_anim_task;
const lv_anim_path_t lv_anim_path_def = {.cb = lv_anim_path_linear};
/**********************
* MACROS
@@ -77,11 +78,11 @@ void lv_anim_core_init(void)
*/
void lv_anim_init(lv_anim_t * a)
{
memset(a, 0, sizeof(lv_anim_t));
lv_memset_00(a, sizeof(lv_anim_t));
a->time = 500;
a->start = 0;
a->end = 100;
a->path_cb = lv_anim_path_linear;
lv_memcpy_small(&a->path, &lv_anim_path_def, sizeof(lv_anim_path_cb_t));
a->repeat_cnt = 1;
a->early_apply = 1;
}
@@ -107,7 +108,7 @@ void lv_anim_start(lv_anim_t * a)
/*Initialize the animation descriptor*/
a->time_orig = a->time;
memcpy(new_anim, a, sizeof(lv_anim_t));
lv_memcpy(new_anim, a, sizeof(lv_anim_t));
/*Set the start value*/
if(new_anim->early_apply) {
@@ -221,7 +222,7 @@ void lv_anim_refr_now(void)
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_linear(const lv_anim_t * a)
lv_anim_value_t lv_anim_path_linear(const lv_anim_path_t * path, const lv_anim_t * a)
{
/*Calculate the current step*/
uint32_t step;
@@ -247,7 +248,7 @@ lv_anim_value_t lv_anim_path_linear(const lv_anim_t * a)
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_in(const lv_anim_t * a)
lv_anim_value_t lv_anim_path_ease_in(const lv_anim_path_t * path, const lv_anim_t * a)
{
/*Calculate the current step*/
uint32_t t;
@@ -271,7 +272,7 @@ lv_anim_value_t lv_anim_path_ease_in(const lv_anim_t * a)
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_out(const lv_anim_t * a)
lv_anim_value_t lv_anim_path_ease_out(const lv_anim_path_t * path, const lv_anim_t * a)
{
/*Calculate the current step*/
@@ -296,7 +297,7 @@ lv_anim_value_t lv_anim_path_ease_out(const lv_anim_t * a)
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_t * a)
lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_path_t * path, const lv_anim_t * a)
{
/*Calculate the current step*/
@@ -321,7 +322,7 @@ lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_t * a)
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_overshoot(const lv_anim_t * a)
lv_anim_value_t lv_anim_path_overshoot(const lv_anim_path_t * path, const lv_anim_t * a)
{
/*Calculate the current step*/
@@ -347,7 +348,7 @@ lv_anim_value_t lv_anim_path_overshoot(const lv_anim_t * a)
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_bounce(const lv_anim_t * a)
lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t * a)
{
/*Calculate the current step*/
uint32_t t;
@@ -409,7 +410,7 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_t * a)
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_step(const lv_anim_t * a)
lv_anim_value_t lv_anim_path_step(const lv_anim_path_t * path, const lv_anim_t * a)
{
if(a->act_time >= a->time)
return a->end;
@@ -458,7 +459,8 @@ static void anim_task(lv_task_t * param)
if(a->act_time > a->time) a->act_time = a->time;
int32_t new_value;
new_value = a->path_cb(a);
if(a->path.cb) new_value = a->path.cb(&a->path, a);
else new_value = lv_anim_path_linear(&a->path, a);
/*Apply the calculated value*/
if(a->exec_cb) a->exec_cb(a->var, new_value);
@@ -490,7 +492,7 @@ static void anim_task(lv_task_t * param)
static bool anim_ready_handler(lv_anim_t * a)
{
/*In the end of a forward anim decrement repeat cnt.*/
if(a->playback_now == 0 && a->repeat_cnt > 0 && a->repeat_cnt != LV_ANIM_REPEAT_INFINIT) {
if(a->playback_now == 0 && a->repeat_cnt > 0 && a->repeat_cnt != LV_ANIM_REPEAT_INFINITE) {
a->repeat_cnt--;
}
@@ -502,7 +504,7 @@ static bool anim_ready_handler(lv_anim_t * a)
/*Create copy from the animation and delete the animation from the list.
* This way the `ready_cb` will see the animations like it's animation is ready deleted*/
lv_anim_t a_tmp;
memcpy(&a_tmp, a, sizeof(lv_anim_t));
lv_memcpy(&a_tmp, a, sizeof(lv_anim_t));
lv_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a);
lv_mem_free(a);
/*Flag that the list has changed */

View File

@@ -18,6 +18,7 @@ extern "C" {
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "lv_mem.h"
/*********************
* DEFINES
@@ -40,9 +41,20 @@ typedef lv_coord_t lv_anim_value_t;
#if LV_USE_ANIMATION
#define LV_ANIM_REPEAT_INFINIT 0xFFFF
#define LV_ANIM_REPEAT_INFINITE 0xFFFF
struct _lv_anim_t;
struct _lv_anim_path_t;
/** Get the current value during an animation*/
typedef lv_anim_value_t (*lv_anim_path_cb_t)(const struct _lv_anim_path_t *, const struct _lv_anim_t *);
typedef struct _lv_anim_path_t{
lv_anim_path_cb_t cb;
void * user_data;
}lv_anim_path_t;
/** Generic prototype of "animator" functions.
* First parameter is the variable to animate.
@@ -56,9 +68,6 @@ typedef void (*lv_anim_exec_xcb_t)(void *, lv_anim_value_t);
* It's more consistent but less convenient. Might be used by binding generator functions.*/
typedef void (*lv_anim_custom_exec_cb_t)(struct _lv_anim_t *, lv_anim_value_t);
/** Get the current value during an animation*/
typedef lv_anim_value_t (*lv_anim_path_cb_t)(const struct _lv_anim_t *);
/** Callback to call when the animation is ready*/
typedef void (*lv_anim_ready_cb_t)(struct _lv_anim_t *);
@@ -69,9 +78,9 @@ typedef void (*lv_anim_start_cb_t)(struct _lv_anim_t *);
typedef struct _lv_anim_t {
void * var; /**<Variable to animate*/
lv_anim_exec_xcb_t exec_cb; /**< Function to execute to animate*/
lv_anim_path_cb_t path_cb; /**< Function to get the steps of animations*/
lv_anim_start_cb_t start_cb; /**< Call it when the animation is starts (considering `delay`)*/
lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/
lv_anim_path_t path; /**< Describe the path (curve) of animations*/
int32_t start; /**< Start value*/
int32_t end; /**< End value*/
uint32_t time; /**< Animation time in ms*/
@@ -187,9 +196,9 @@ static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec
* @param path_cb a function the get the current value of the animation.
* The built in functions starts with `lv_anim_path_...`
*/
static inline void lv_anim_set_path_cb(lv_anim_t * a, lv_anim_path_cb_t path_cb)
static inline void lv_anim_set_path(lv_anim_t * a, const lv_anim_path_t * path)
{
a->path_cb = path_cb;
lv_memcpy_small(&a->path, path, sizeof(lv_anim_path_t));
}
@@ -259,6 +268,34 @@ static inline void lv_anim_set_repeat_delay(lv_anim_t * a, uint16_t delay)
*/
void lv_anim_start(lv_anim_t * a);
/**
* Initialize an animation path
* @param path pointer to path
*/
static inline void lv_anim_path_init(lv_anim_path_t * path)
{
lv_memset_00(path, sizeof(lv_anim_path_t));
}
/**
* Set a callback for a path
* @param path pointer to an initialized path
* @param cb the callback
*/
static inline void lv_anim_path_set_cb(lv_anim_path_t * path, lv_anim_path_cb_t cb)
{
path->cb = cb;
}
/**
* Set a user data for a path
* @param path pointer to an initialized path
* @param user_data pointer to the user data
*/
static inline void lv_anim_path_set_user_data(lv_anim_path_t * path, void * user_data)
{
path->user_data = user_data;
}
/**
* Get a delay before starting the animation
@@ -333,42 +370,42 @@ void lv_anim_refr_now(void);
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_linear(const lv_anim_t * a);
lv_anim_value_t lv_anim_path_linear(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation slowing down the start phase
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_in(const lv_anim_t * a);
lv_anim_value_t lv_anim_path_ease_in(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation slowing down the end phase
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_out(const lv_anim_t * a);
lv_anim_value_t lv_anim_path_ease_out(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation applying an "S" characteristic (cosine)
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_t * a);
lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation with overshoot at the end
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_overshoot(const lv_anim_t * a);
lv_anim_value_t lv_anim_path_overshoot(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation with 3 bounces
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_bounce(const lv_anim_t * a);
lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation applying step characteristic.
@@ -376,7 +413,12 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_t * a);
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_step(const lv_anim_t * a);
lv_anim_value_t lv_anim_path_step(const lv_anim_path_t * path, const lv_anim_t * a);
/**********************
* GLOBAL VARIABLES
**********************/
extern const lv_anim_path_t lv_anim_path_def;
/**********************
* MACROS

View File

@@ -17,6 +17,7 @@ extern "C" {
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include "lv_mem.h"
/*********************
* DEFINES
@@ -98,7 +99,7 @@ void lv_area_set(lv_area_t * area_p, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2
*/
inline static void lv_area_copy(lv_area_t * dest, const lv_area_t * src)
{
memcpy(dest, src, sizeof(lv_area_t));
lv_memcpy_small(dest, src, sizeof(lv_area_t));
}
/**

View File

@@ -57,7 +57,7 @@ lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data)
/* Set the task's user data */
task->user_data = info;
lv_task_once(task);
lv_task_set_repeat_count(task, 1);
return LV_RES_OK;
}

View File

@@ -311,7 +311,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len
if(rd) {
if(base_dir == LV_BIDI_DIR_LTR) {
if(str_out) {
memcpy(&str_out[wr], str_in, rd);
lv_memcpy(&str_out[wr], str_in, rd);
wr += rd;
}
if(pos_conv_out) {
@@ -334,7 +334,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len
if(base_dir == LV_BIDI_DIR_LTR) {
if(run_dir == LV_BIDI_DIR_LTR) {
if(str_out) memcpy(&str_out[wr], &str_in[rd], run_len);
if(str_out) lv_memcpy(&str_out[wr], &str_in[rd], run_len);
if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd);
}
else rtl_reverse(str_out ? &str_out[wr] : NULL, &str_in[rd], run_len, pos_conv_out ? &pos_conv_out[pos_conv_wr] : NULL,
@@ -346,7 +346,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len
wr -= run_len;
pos_conv_wr -= pos_conv_run_len;
if(run_dir == LV_BIDI_DIR_LTR) {
if(str_out) memcpy(&str_out[wr], &str_in[rd], run_len);
if(str_out) lv_memcpy(&str_out[wr], &str_in[rd], run_len);
if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd);
}
else rtl_reverse(str_out ? &str_out[wr] : NULL, &str_in[rd], run_len, pos_conv_out ? &pos_conv_out[pos_conv_wr] : NULL,
@@ -523,7 +523,7 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *
pos_conv_first_weak = 0;
}
if(dest) memcpy(&dest[wr], &src[first_weak], last_weak - first_weak + 1);
if(dest) lv_memcpy(&dest[wr], &src[first_weak], last_weak - first_weak + 1);
if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_last_weak - pos_conv_first_weak + 1,
pos_conv_rd_base + pos_conv_first_weak);
wr += last_weak - first_weak + 1;
@@ -543,7 +543,7 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *
}
/*Just store the letter*/
else {
if(dest) memcpy(&dest[wr], &src[i], letter_size);
if(dest) lv_memcpy(&dest[wr], &src[i], letter_size);
if(pos_conv_out) pos_conv_out[pos_conv_wr] = SET_RTL_POS(pos_conv_rd_base + pos_conv_i, true);
wr += letter_size;
pos_conv_wr++;

View File

@@ -87,6 +87,7 @@ enum {
#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!"
#endif
/*---------------------------------------
* Macros for all existing color depths
* to set/get values of the color channels
@@ -255,7 +256,6 @@ typedef lv_color32_t lv_color_t;
#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!"
#endif
typedef uint8_t lv_opa_t;
typedef struct {
uint16_t h;
@@ -263,6 +263,11 @@ typedef struct {
uint8_t v;
} lv_color_hsv_t;
//! @cond Doxygen_Suppress
/*No idea where the guard is required but else throws warnings in the docs*/
typedef uint8_t lv_opa_t;
//! @endcond
/**********************
* GLOBAL PROTOTYPES
**********************/
@@ -280,7 +285,6 @@ typedef struct {
* ----------------------
* Shift right with 5 - 3 = 2
*/
static inline uint8_t lv_color_to1(lv_color_t color)
{
#if LV_COLOR_DEPTH == 1
@@ -409,6 +413,7 @@ static inline uint32_t lv_color_to32(lv_color_t color)
* 5 129 33 1 255
* 6 259 3 0 255
*/
lv_color32_t ret;
LV_COLOR_SET_R32(ret, (LV_COLOR_GET_R(color) * 263 + 7) >> 5);
LV_COLOR_SET_G32(ret, (LV_COLOR_GET_G(color) * 259 + 3) >> 6);
@@ -420,13 +425,13 @@ static inline uint32_t lv_color_to32(lv_color_t color)
#endif
}
/**
* Mix two colors with a given ratio.
* @param c1
* @param c2
* @param c1 the first color to mix (usually the foreground)
* @param c2 the second color to mix (usually the background)
* @param mix The ratio of the colors. 0: full `c2`, 255: full `c1`, 127: half `c1` and half`c2`
* @return the mixed color
* @note 255 won't give clearly `c1`.
*/
static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix)
{
@@ -552,7 +557,6 @@ static inline void lv_color_mix_with_alpha(lv_color_t bg_color, lv_opa_t bg_opa,
}
}
/**
* Get the brightness of a color
* @param color a color
@@ -628,6 +632,7 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8);
*/
lv_color_hsv_t lv_color_to_hsv(lv_color_t color);
/**********************
* MACROS
**********************/

View File

@@ -475,7 +475,7 @@ lv_fs_res_t lv_fs_free_space(char letter, uint32_t * total_p, uint32_t * free_p)
*/
void lv_fs_drv_init(lv_fs_drv_t * drv)
{
memset(drv, 0, sizeof(lv_fs_drv_t));
lv_memset_00(drv, sizeof(lv_fs_drv_t));
}
/**
@@ -491,7 +491,7 @@ void lv_fs_drv_register(lv_fs_drv_t * drv_p)
LV_ASSERT_MEM(new_drv);
if(new_drv == NULL) return;
memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t));
lv_memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t));
}
/**

View File

@@ -44,7 +44,7 @@
void lv_gc_clear_roots(void)
{
#define LV_CLEAR_ROOT(root_type, root_name) memset(&LV_GC_ROOT(root_name), 0, sizeof(LV_GC_ROOT(root_name)));
#define LV_CLEAR_ROOT(root_type, root_name) lv_memset_00(&LV_GC_ROOT(root_name), sizeof(LV_GC_ROOT(root_name)));
LV_ITERATE_ROOTS(LV_CLEAR_ROOT)
}

View File

@@ -299,7 +299,7 @@ void * lv_ll_get_next(const lv_ll_t * ll_p, const void * n_act)
if(ll_p != NULL) {
const lv_ll_node_t * n_act_d = n_act;
memcpy(&next, n_act_d + LL_NEXT_P_OFFSET(ll_p), sizeof(void *));
lv_memcpy_small(&next, n_act_d + LL_NEXT_P_OFFSET(ll_p), sizeof(void *));
}
return next;
@@ -317,7 +317,7 @@ void * lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act)
if(ll_p != NULL) {
const lv_ll_node_t * n_act_d = n_act;
memcpy(&prev, n_act_d + LL_PREV_P_OFFSET(ll_p), sizeof(void *));
lv_memcpy_small(&prev, n_act_d + LL_PREV_P_OFFSET(ll_p), sizeof(void *));
}
return prev;
@@ -404,9 +404,9 @@ static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * pre
uint32_t node_p_size = sizeof(lv_ll_node_t *);
if(prev)
memcpy(act + LL_PREV_P_OFFSET(ll_p), &prev, node_p_size);
lv_memcpy_small(act + LL_PREV_P_OFFSET(ll_p), &prev, node_p_size);
else
memset(act + LL_PREV_P_OFFSET(ll_p), 0, node_p_size);
lv_memset_00(act + LL_PREV_P_OFFSET(ll_p), node_p_size);
}
/**
@@ -421,7 +421,7 @@ static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * nex
uint32_t node_p_size = sizeof(lv_ll_node_t *);
if(next)
memcpy(act + LL_NEXT_P_OFFSET(ll_p), &next, node_p_size);
lv_memcpy_small(act + LL_NEXT_P_OFFSET(ll_p), &next, node_p_size);
else
memset(act + LL_NEXT_P_OFFSET(ll_p), 0, node_p_size);
lv_memset_00(act + LL_NEXT_P_OFFSET(ll_p), node_p_size);
}

View File

@@ -312,7 +312,7 @@ void * lv_mem_realloc(void * data_p, size_t new_size)
if(data_p != NULL) {
/*Copy the old data to the new. Use the smaller size*/
if(old_size != 0) {
memcpy(new_p, data_p, LV_MATH_MIN(new_size, old_size));
lv_memcpy(new_p, data_p, LV_MATH_MIN(new_size, old_size));
lv_mem_free(data_p);
}
}
@@ -382,8 +382,11 @@ lv_res_t lv_mem_test(void)
lv_mem_ent_t * e;
e = ent_get_next(NULL);
while(e) {
if((e->header.s.used && e->header.s.d_size > LV_MEM_SIZE) ||
(e->header.s.used == 0 && e->header.s.d_size > LV_MEM_SIZE)) {
if(e->header.s.d_size > LV_MEM_SIZE) {
return LV_RES_INV;
}
uint8_t * e8 = (uint8_t*) e;
if(e8 + e->header.s.d_size > work_mem + LV_MEM_SIZE) {
return LV_RES_INV;
}
e = ent_get_next(e);
@@ -530,7 +533,6 @@ void lv_mem_buf_free_all(void)
/**
* Same as `memcpy` but optimized for 4 byte operation.
* `dst` and `src` should be word aligned else normal `memcpy` will be used
* @param dst pointer to the destination buffer
* @param src pointer to the source buffer
* @param len number of byte to copy

View File

@@ -135,13 +135,31 @@ void lv_mem_buf_free_all(void);
/**
* Same as `memcpy` but optimized for 4 byte operation.
* `dst` and `src` should be word aligned else normal `memcpy` will be used
* @param dst pointer to the destination buffer
* @param src pointer to the source buffer
* @param len number of byte to copy
*/
void * lv_memcpy(void * dst, const void * src, size_t len);
/**
* Same as `memcpy` but optimized to copy only a few bytes.
* @param dst pointer to the destination buffer
* @param src pointer to the source buffer
* @param len number of byte to copy
*/
static inline void * lv_memcpy_small(void * dst, const void * src, size_t len)
{
uint8_t * d8 = (uint8_t *)dst;
const uint8_t * s8 = (const uint8_t *)src;
while(len) {
*d8 = *s8; d8++; s8++;
len--;
}
return dst;
}
/**
* Same as `memset` but optimized for 4 byte operation.
* `dst` should be word aligned else normal `memcpy` will be used

View File

@@ -236,7 +236,7 @@ lv_task_t * lv_task_create_basic(void)
new_task->task_cb = NULL;
new_task->prio = DEF_PRIO;
new_task->once = 0;
new_task->repeat_count = -1;
new_task->last_run = lv_tick_get();
new_task->user_data = NULL;
@@ -341,12 +341,13 @@ void lv_task_ready(lv_task_t * task)
}
/**
* Delete the lv_task after one call
* Set the number of times a task will repeat.
* @param task pointer to a lv_task.
* @param repeat_count -1 : infinity; 0 : stop ; n>0: residual times
*/
void lv_task_once(lv_task_t * task)
void lv_task_set_repeat_count(lv_task_t * task, int32_t repeat_count)
{
task->once = 1;
task->repeat_count = repeat_count;
}
/**
@@ -398,7 +399,10 @@ static bool lv_task_exec(lv_task_t * task)
/*Delete if it was a one shot lv_task*/
if(task_deleted == false) { /*The task might be deleted by itself as well*/
if(task->once != 0) {
if(task->repeat_count > 0) {
task->repeat_count--;
}
if(task->repeat_count == 0) {
lv_task_del(task);
}
}

View File

@@ -64,8 +64,8 @@ typedef struct _lv_task_t {
void * user_data; /**< Custom user data */
int32_t repeat_count; /**< 1: Task times; -1 : infinity; 0 : stop ; n>0: residual times */
uint8_t prio : 3; /**< Task priority */
uint8_t once : 1; /**< 1: one shot task */
} lv_task_t;
/**********************
@@ -140,10 +140,11 @@ void lv_task_set_period(lv_task_t * task, uint32_t period);
void lv_task_ready(lv_task_t * task);
/**
* Delete the lv_task after one call
* Set the number of times a task will repeat.
* @param task pointer to a lv_task.
* @param repeat_count -1 : infinity; 0 : stop ; n>0: residual times
*/
void lv_task_once(lv_task_t * task);
void lv_task_set_repeat_count(lv_task_t * task, int32_t repeat_count);
/**
* Reset a lv_task.

View File

@@ -445,7 +445,7 @@ void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt)
}
/* Copy the text into the new space*/
memcpy(txt_buf + pos, ins_txt, ins_len);
lv_memcpy_small(txt_buf + pos, ins_txt, ins_len);
}
/**
@@ -537,7 +537,7 @@ static uint32_t lv_txt_utf8_conv_wc(uint32_t c)
if((c & 0x80) != 0) {
uint32_t swapped;
uint8_t c8[4];
memcpy(c8, &c, 4);
lv_memcpy_small(c8, &c, 4);
swapped = (c8[0] << 24) + (c8[1] << 16) + (c8[2] << 8) + (c8[3]);
uint8_t i;
for(i = 0; i < 4; i++) {

View File

@@ -17,19 +17,25 @@ extern "C" {
/*********************
* DEFINES
*********************/
// Check windows
#ifdef _WIN64
#define LV_ARCH_64
#if __STDC_VERSION__ >= 199901L // If c99 or newer, use stdint.h to determine arch size
#include <stdint.h>
#endif
/* Check GCC */
#ifdef __GNUC__
#if defined(__x86_64__) || defined(__ppc64__)
// If __UINTPTR_MAX__ or UINTPTR_MAX are available, use them to determine arch size
#if defined(__UINTPTR_MAX__) && __UINTPTR_MAX__ > 0xFFFFFFFF
#define LV_ARCH_64
#endif
#elif defined(UINTPTR_MAX) && UINTPTR_MAX > 0xFFFFFFFF
#define LV_ARCH_64
// Otherwise use compiler-dependent means to determine arch size
#elif defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined (__aarch64__)
#define LV_ARCH_64
#endif
#define LV_UNUNSED(x) (void)x;
/**********************
* TYPEDEFS
@@ -45,12 +51,24 @@ enum {
};
typedef uint8_t lv_res_t;
#if __STDC_VERSION__ >= 199901L
// If c99 or newer, use the definition of uintptr_t directly from <stdint.h>
typedef uintptr_t lv_uintptr_t;
#else
// Otherwise, use the arch size determination
#ifdef LV_ARCH_64
typedef uint64_t lv_uintptr_t;
#else
typedef uint32_t lv_uintptr_t;
#endif
#endif
/**********************
* GLOBAL PROTOTYPES
**********************/
@@ -64,3 +82,4 @@ typedef uint32_t lv_uintptr_t;
#endif
#endif /*LV_TYPES_H*/

View File

@@ -109,7 +109,7 @@ uint32_t lv_theme_get_flags(void)
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name)
{
act_theme->apply_cb(obj, name);
act_theme->apply_xcb(obj, name);
}

View File

@@ -144,7 +144,7 @@ typedef enum {
} lv_theme_style_t;
typedef struct {
void (*apply_cb)(lv_obj_t *, lv_theme_style_t);
void (*apply_xcb)(lv_obj_t *, lv_theme_style_t);
lv_color_t color_primary;
lv_color_t color_secondary;
const lv_font_t * font_small;

View File

@@ -62,7 +62,7 @@ lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_seco
lv_style_init(&opa_cover);
lv_style_set_bg_opa(&opa_cover, LV_STATE_DEFAULT, LV_OPA_COVER);
theme.apply_cb = lv_theme_empty_apply;
theme.apply_xcb = lv_theme_empty_apply;
return &theme;
}

View File

@@ -63,7 +63,7 @@
#define COLOR_BG_SEC_TEXT_DIS (IS_LIGHT ? lv_color_hex(0xaaaaaa) : lv_color_hex(0xa5a8ad))
#define TRANSITION_TIME 150
#define BORDER_WIDTH LV_DPX(3)
#define BORDER_WIDTH LV_DPX(2)
#define IS_LIGHT (theme.flags & LV_THEME_MATERIAL_FLAG_LIGHT)
/**********************
@@ -146,6 +146,9 @@ static lv_style_t pad_small;
#if LV_USE_PAGE
static lv_style_t sb;
#if LV_USE_ANIMATION
static lv_style_t edge_flash;
#endif
#endif
#if LV_USE_ROLLER
@@ -200,6 +203,7 @@ static void basic_init(void)
lv_style_set_bg_color(&bg, LV_STATE_DEFAULT, COLOR_BG);
lv_style_set_border_color(&bg, LV_STATE_DEFAULT, COLOR_BG_BORDER);
lv_style_set_border_color(&bg, LV_STATE_FOCUSED, theme.color_primary);
lv_style_set_border_color(&bg, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_border_width(&bg, LV_STATE_DEFAULT, BORDER_WIDTH);
lv_style_set_border_post(&bg, LV_STATE_DEFAULT, true);
lv_style_set_text_font(&bg, LV_STATE_DEFAULT, theme.font_normal);
@@ -289,6 +293,7 @@ static void basic_init(void)
lv_style_set_outline_opa(&btn, LV_STATE_DEFAULT, LV_OPA_0);
lv_style_set_outline_opa(&btn, LV_STATE_FOCUSED, LV_OPA_50);
lv_style_set_outline_color(&btn, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_outline_color(&btn, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_transition_time(&btn, LV_STATE_DEFAULT, TRANSITION_TIME);
lv_style_set_transition_prop_4(&btn, LV_STATE_DEFAULT, LV_STYLE_BORDER_OPA);
lv_style_set_transition_prop_5(&btn, LV_STATE_DEFAULT, LV_STYLE_BG_COLOR);
@@ -337,6 +342,7 @@ static void bar_init(void)
lv_style_set_bg_color(&bar_bg, LV_STATE_DEFAULT, COLOR_BG_SEC);
lv_style_set_value_color(&bar_bg, LV_STATE_DEFAULT, IS_LIGHT ? lv_color_hex(0x31404f) : LV_COLOR_WHITE);
lv_style_set_outline_color(&bar_bg, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_outline_color(&bar_bg, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_outline_opa(&bar_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_outline_opa(&bar_bg, LV_STATE_FOCUSED, LV_OPA_50);
lv_style_set_outline_width(&bar_bg, LV_STATE_DEFAULT, 3);
@@ -570,6 +576,7 @@ static void cpicker_init(void)
lv_style_set_border_width(&cpicker_indic, LV_STATE_DEFAULT, 2);
lv_style_set_border_color(&cpicker_indic, LV_STATE_DEFAULT, LV_COLOR_GRAY);
lv_style_set_border_color(&cpicker_indic, LV_STATE_FOCUSED, theme.color_primary);
lv_style_set_border_color(&cpicker_indic, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_pad_left(&cpicker_indic, LV_STATE_DEFAULT,LV_DPX(13));
lv_style_set_pad_right(&cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13));
lv_style_set_pad_top(&cpicker_indic, LV_STATE_DEFAULT, LV_DPX(13));
@@ -612,6 +619,7 @@ static void keyboard_init(void)
lv_style_set_border_width(&kb_bg, LV_STATE_DEFAULT, LV_DPX(4));
lv_style_set_border_side(&kb_bg, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP);
lv_style_set_border_color(&kb_bg, LV_STATE_DEFAULT, IS_LIGHT ? COLOR_BG_TEXT : LV_COLOR_BLACK);
lv_style_set_border_color(&kb_bg, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_pad_left(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_pad_right(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10));
lv_style_set_pad_top(&kb_bg, LV_STATE_DEFAULT, LV_DPX(10));
@@ -641,6 +649,11 @@ static void page_init(void)
lv_style_set_pad_right(&sb, LV_STATE_DEFAULT, LV_DPX(7));
lv_style_set_pad_bottom(&sb, LV_STATE_DEFAULT, LV_DPX(7));
#if LV_USE_ANIMATION
style_init_reset(&edge_flash);
lv_style_set_bg_opa(&edge_flash, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&edge_flash, LV_STATE_DEFAULT, lv_color_hex3(0x888));
#endif
#endif
}
@@ -774,10 +787,12 @@ static void tabview_init(void)
lv_style_set_pad_top(&tabview_btns, LV_STATE_DEFAULT, LV_DPX(20));
lv_style_set_pad_bottom(&tabview_btns, LV_STATE_DEFAULT, LV_DPX(20));
lv_style_set_text_color(&tabview_btns, LV_STATE_FOCUSED, theme.color_primary);
lv_style_set_text_color(&tabview_btns, LV_STATE_EDITED, theme.color_secondary);
style_init_reset(&tabview_indic);
lv_style_set_bg_opa(&tabview_indic, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&tabview_indic, LV_STATE_DEFAULT, theme.color_primary);
lv_style_set_bg_color(&tabview_indic, LV_STATE_EDITED, theme.color_secondary);
lv_style_set_size(&tabview_indic, LV_STATE_DEFAULT, LV_DPX(5));
lv_style_set_radius(&tabview_indic, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
@@ -878,7 +893,7 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s
table_init();
win_init();
theme.apply_cb = lv_theme_material_apply;
theme.apply_xcb = lv_theme_material_apply;
inited = true;
@@ -1095,13 +1110,19 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name)
list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
lv_style_list_add_style(list, &bg);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCRL);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCRL);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
lv_style_list_add_style(list, &pad_inner);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCRLBAR);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCRLBAR);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR);
lv_style_list_add_style(list, &sb);
#if LV_USE_ANIMATION
lv_obj_clean_style_list(obj, LV_PAGE_PART_EDGE_FLASH);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_EDGE_FLASH);
lv_style_list_add_style(list, &edge_flash);
#endif
break;
#endif
#if LV_USE_TABVIEW
@@ -1128,8 +1149,8 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name)
case LV_THEME_TABVIEW_PAGE:
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCRL);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCRL);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
lv_style_list_add_style(list, &tabview_page_scrl);
break;
@@ -1145,9 +1166,11 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name)
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCRLBAR);
lv_style_list_add_style(list, &sb);
#if LV_USE_ANIMATION
lv_obj_clean_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH);
lv_style_list_add_style(list, &btn);
lv_style_list_add_style(list, &edge_flash);
#endif
break;
#endif
@@ -1265,12 +1288,12 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name)
list = lv_obj_get_style_list(obj, LV_WIN_PART_BG);
lv_style_list_add_style(list, &scr);
lv_obj_clean_style_list(obj, LV_WIN_PART_SCRLBAR);
list = lv_obj_get_style_list(obj, LV_WIN_PART_SCRLBAR);
lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR);
lv_style_list_add_style(list, &sb);
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCRL);
list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCRL);
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
lv_style_list_add_style(list, &tabview_page_scrl);
lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER);
@@ -1353,8 +1376,8 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name)
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
lv_style_list_add_style(list, &cpicker_bg);
lv_obj_clean_style_list(obj, LV_CPICKER_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_INDIC);
lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB);
lv_style_list_add_style(list, &cpicker_indic);
break;
#endif

View File

@@ -527,7 +527,7 @@ lv_theme_t * lv_theme_mono_init(lv_color_t color_primary, lv_color_t color_secon
table_init();
win_init();
theme.apply_cb = lv_theme_mono_apply;
theme.apply_xcb = lv_theme_mono_apply;
return &theme;
}
@@ -760,12 +760,12 @@ void lv_theme_mono_apply(lv_obj_t * obj, lv_theme_style_t name)
list = lv_obj_get_style_list(obj, LV_PAGE_PART_BG);
lv_style_list_add_style(list, &style_bg);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCRL);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCRL);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
lv_style_list_add_style(list, &style_pad_inner);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCRLBAR);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCRLBAR);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLBAR);
lv_style_list_add_style(list, &style_sb);
break;
#endif
@@ -794,8 +794,8 @@ void lv_theme_mono_apply(lv_obj_t * obj, lv_theme_style_t name)
case LV_THEME_TABVIEW_PAGE:
lv_obj_clean_style_list(obj, LV_PAGE_PART_BG);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCRL);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCRL);
lv_obj_clean_style_list(obj, LV_PAGE_PART_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_PAGE_PART_SCROLLABLE);
lv_style_list_add_style(list, &style_pad_normal);
break;
@@ -939,12 +939,12 @@ void lv_theme_mono_apply(lv_obj_t * obj, lv_theme_style_t name)
list = lv_obj_get_style_list(obj, LV_WIN_PART_BG);
lv_style_list_add_style(list, &style_bg);
lv_obj_clean_style_list(obj, LV_WIN_PART_SCRLBAR);
list = lv_obj_get_style_list(obj, LV_WIN_PART_SCRLBAR);
lv_obj_clean_style_list(obj, LV_WIN_PART_SCROLLBAR);
list = lv_obj_get_style_list(obj, LV_WIN_PART_SCROLLBAR);
lv_style_list_add_style(list, &style_sb);
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCRL);
list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCRL);
lv_obj_clean_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
list = lv_obj_get_style_list(obj, LV_WIN_PART_CONTENT_SCROLLABLE);
lv_style_list_add_style(list, &style_bg);
lv_obj_clean_style_list(obj, LV_WIN_PART_HEADER);
@@ -1032,8 +1032,8 @@ void lv_theme_mono_apply(lv_obj_t * obj, lv_theme_style_t name)
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
lv_style_list_add_style(list, &style_bg);
lv_obj_clean_style_list(obj, LV_CPICKER_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_INDIC);
lv_obj_clean_style_list(obj, LV_CPICKER_PART_KNOB);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_KNOB);
lv_style_list_add_style(list, &style_bg);
lv_style_list_add_style(list, &style_round);
break;

View File

@@ -382,7 +382,7 @@ lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_s
table_init();
win_init();
theme.apply_cb = lv_theme_material_apply;
theme.apply_xcb = lv_theme_material_apply;
return &theme;
}

View File

@@ -137,27 +137,26 @@ void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
switch(state) {
case LV_BTN_STATE_RELEASED:
lv_obj_clear_state(btn, LV_STATE_PRESSED | LV_STATE_CHECKED | LV_STATE_DISABLED);
lv_obj_clear_state(btn, LV_STATE_PRESSED | LV_STATE_CHECKED);
break;
case LV_BTN_STATE_PRESSED:
lv_obj_clear_state(btn, LV_STATE_CHECKED | LV_STATE_DISABLED);
lv_obj_clear_state(btn, LV_STATE_CHECKED);
lv_obj_add_state(btn, LV_STATE_PRESSED);
break;
case LV_BTN_STATE_CHECKED_RELEASED:
lv_obj_add_state(btn, LV_STATE_CHECKED);
lv_obj_clear_state(btn, LV_STATE_PRESSED | LV_STATE_DISABLED);
lv_obj_clear_state(btn, LV_STATE_PRESSED);
break;
case LV_BTN_STATE_CHECKED_PRESSED:
lv_obj_add_state(btn, LV_STATE_PRESSED | LV_STATE_CHECKED | LV_STATE_DISABLED);
lv_obj_add_state(btn, LV_STATE_PRESSED | LV_STATE_CHECKED);
break;
case LV_BTN_STATE_DISABLED:
lv_obj_clear_state(btn, LV_STATE_PRESSED | LV_STATE_CHECKED);
lv_obj_add_state(btn, LV_STATE_DISABLED);
break;
case LV_BTN_STATE_ACTIVE:
lv_obj_clear_state(btn, LV_STATE_DISABLED);
break;
}
// /*Make the state change happen immediately, without transition*/
// btn->prev_state = btn->state;
}
/**
@@ -185,26 +184,25 @@ void lv_btn_toggle(lv_obj_t * btn)
/**
* Get the current state of the button
* @param btn pointer to a button object
* @return the state of the button (from lv_btn_state_t enum)
* @return the state of the button (from lv_btn_state_t enum).
* If the button is in disabled state `LV_BTN_STATE_DISABLED` will be ORed to the other button states.
*/
lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn)
{
LV_ASSERT_OBJ(btn, LV_OBJX_NAME);
lv_state_t state = lv_obj_get_state(btn, LV_BTN_PART_MAIN);
lv_state_t obj_state = lv_obj_get_state(btn, LV_BTN_PART_MAIN);
lv_btn_state_t btn_state = 0;
if(obj_state & LV_STATE_DISABLED) btn_state = LV_BTN_STATE_DISABLED;
if(state & LV_STATE_DISABLED) {
return LV_BTN_STATE_DISABLED;
}
else if(state & LV_STATE_CHECKED) {
if(state & LV_STATE_PRESSED) return LV_BTN_STATE_CHECKED_PRESSED;
else return LV_BTN_STATE_CHECKED_RELEASED;
if(obj_state & LV_STATE_CHECKED) {
if(obj_state & LV_STATE_PRESSED) return btn_state | LV_BTN_STATE_CHECKED_PRESSED;
else return btn_state | LV_BTN_STATE_CHECKED_RELEASED;
}
else {
if(state & LV_STATE_PRESSED) return LV_BTN_STATE_PRESSED;
else return LV_BTN_STATE_RELEASED;
if(obj_state & LV_STATE_PRESSED) return btn_state | LV_BTN_STATE_PRESSED;
else return btn_state | LV_BTN_STATE_RELEASED;
}
}
/**

View File

@@ -36,12 +36,13 @@ extern "C" {
/** Possible states of a button.
* It can be used not only by buttons but other button-like objects too*/
enum {
LV_BTN_STATE_ACTIVE,
LV_BTN_STATE_RELEASED,
LV_BTN_STATE_PRESSED,
LV_BTN_STATE_CHECKED_RELEASED,
LV_BTN_STATE_CHECKED_PRESSED,
LV_BTN_STATE_DISABLED,
_LV_BTN_STATE_LAST, /* Number of states*/
_LV_BTN_STATE_LAST = LV_BTN_STATE_CHECKED_PRESSED + 1, /* Number of states*/
LV_BTN_STATE_DISABLED = 0x80
};
typedef uint8_t lv_btn_state_t;
@@ -153,6 +154,7 @@ static inline void lv_btn_set_fit(lv_obj_t * btn, lv_fit_t fit)
* Get the current state of the button
* @param btn pointer to a button object
* @return the state of the button (from lv_btn_state_t enum)
* If the button is in disabled state `LV_BTN_STATE_DISABLED` will be ORed to the other button states.
*/
lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn);

View File

@@ -275,7 +275,7 @@ void lv_btnmatrix_set_ctrl_map(lv_obj_t * btnm, const lv_btnmatrix_ctrl_t ctrl_m
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
memcpy(ext->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * ext->btn_cnt);
lv_memcpy(ext->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * ext->btn_cnt);
lv_btnmatrix_set_map(btnm, ext->map_p);
}
@@ -497,7 +497,7 @@ uint16_t lv_btnmatrix_get_focused_btn(const lv_obj_t * btnm)
LV_ASSERT_OBJ(btnm, LV_OBJX_NAME);
lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm);
return ext->btn_id_pr;
return ext->btn_id_focused;
}
/**
@@ -612,7 +612,6 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
lv_draw_rect_dsc_t draw_rect_tmp_dsc;
lv_draw_label_dsc_t draw_label_tmp_dsc;
/*The state changes without re-caching the styles, disable the use of cache*/
lv_state_t state_ori = btnm->state;
btnm->state = LV_STATE_DEFAULT;
@@ -689,7 +688,10 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
btnm->state = LV_STATE_DEFAULT;
if(tgl_state) btnm->state = LV_STATE_CHECKED;
if(ext->btn_id_pr == btn_i) btnm->state |= LV_STATE_PRESSED;
if(ext->btn_id_focused == btn_i) btnm->state |= LV_STATE_FOCUSED;
if(ext->btn_id_focused == btn_i) {
btnm->state |= LV_STATE_FOCUSED;
if(state_ori & LV_STATE_EDITED) btnm->state |= LV_STATE_EDITED;
}
lv_draw_rect_dsc_init(&draw_rect_tmp_dsc);
lv_draw_label_dsc_init(&draw_label_tmp_dsc);
@@ -1079,7 +1081,7 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * btnm, const char **
LV_ASSERT_MEM(ext->ctrl_bits);
if(ext->button_areas == NULL || ext->ctrl_bits == NULL) btn_cnt = 0;
memset(ext->ctrl_bits, 0, sizeof(lv_btnmatrix_ctrl_t) * btn_cnt);
lv_memset_00(ext->ctrl_bits, sizeof(lv_btnmatrix_ctrl_t) * btn_cnt);
ext->btn_cnt = btn_cnt;
}

View File

@@ -253,7 +253,7 @@ void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, l
uint8_t * to_copy8 = (uint8_t *)to_copy;
lv_coord_t i;
for(i = 0; i < h; i++) {
memcpy((void *)&ext->dsc.data[px], to_copy8, w * px_size);
lv_memcpy((void *)&ext->dsc.data[px], to_copy8, w * px_size);
px += ext->dsc.header.w * px_size;
to_copy8 += w * px_size;
}
@@ -425,7 +425,7 @@ void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r)
lv_color_t c;
lv_opa_t opa = LV_OPA_TRANSP;
memcpy(line_buf, &ext->dsc.data[y * line_w], line_w);
lv_memcpy(line_buf, &ext->dsc.data[y * line_w], line_w);
for(x = a.x1 - r_back; x <= a.x1 + r_front; x++) {

View File

@@ -108,9 +108,9 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
ext->point_cnt = LV_CHART_PNUM_DEF;
ext->type = LV_CHART_TYPE_LINE;
ext->update_mode = LV_CHART_UPDATE_MODE_SHIFT;
memset(&ext->x_axis, 0, sizeof(ext->x_axis));
memset(&ext->y_axis, 0, sizeof(ext->y_axis));
memset(&ext->secondary_y_axis, 0, sizeof(ext->secondary_y_axis));
lv_memset_00(&ext->x_axis, sizeof(ext->x_axis));
lv_memset_00(&ext->y_axis, sizeof(ext->y_axis));
lv_memset_00(&ext->secondary_y_axis, sizeof(ext->secondary_y_axis));
ext->x_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO;
ext->x_axis.minor_tick_len = LV_CHART_TICK_LENGTH_AUTO;
ext->y_axis.major_tick_len = LV_CHART_TICK_LENGTH_AUTO;
@@ -147,9 +147,9 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy)
ext->hdiv_cnt = ext_copy->hdiv_cnt;
ext->vdiv_cnt = ext_copy->vdiv_cnt;
ext->point_cnt = ext_copy->point_cnt;
memcpy(&ext->x_axis, &ext_copy->x_axis, sizeof(lv_chart_axis_cfg_t));
memcpy(&ext->y_axis, &ext_copy->y_axis, sizeof(lv_chart_axis_cfg_t));
memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t));
lv_memcpy(&ext->x_axis, &ext_copy->x_axis, sizeof(lv_chart_axis_cfg_t));
lv_memcpy(&ext->y_axis, &ext_copy->y_axis, sizeof(lv_chart_axis_cfg_t));
lv_memcpy(&ext->secondary_y_axis, &ext_copy->secondary_y_axis, sizeof(lv_chart_axis_cfg_t));
/*Refresh the style with new signal function*/
lv_obj_refresh_style(chart, LV_STYLE_PROP_ALL);
@@ -1087,7 +1087,7 @@ static lv_chart_label_iterator_t create_axis_label_iter(const char * list, uint8
*/
static void get_next_axis_label(lv_chart_label_iterator_t * iterator, char * buf)
{
uint8_t label_len = 0;
uint32_t label_len = 0;
if(iterator->is_reverse_iter) {
const char * label_start;
/* count the length of the current label*/

View File

@@ -310,6 +310,7 @@ static lv_style_list_t * lv_cont_get_style(lv_obj_t * cont, uint8_t type)
*/
static void lv_cont_refr_layout(lv_obj_t * cont)
{
if(lv_obj_is_protected(cont, LV_PROTECT_CHILD_CHG)) return;
lv_layout_t type = lv_cont_get_layout(cont);
/*'cont' has to be at least 1 child*/
@@ -379,7 +380,7 @@ static void lv_cont_layout_col(lv_obj_t * cont)
LV_LL_READ_BACK(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
lv_style_int_t mtop = lv_obj_get_style_margin_top(child, LV_OBJ_PART_MAIN);
lv_style_int_t mbottom = lv_obj_get_style_margin_top(child, LV_OBJ_PART_MAIN);
lv_style_int_t mbottom = lv_obj_get_style_margin_bottom(child, LV_OBJ_PART_MAIN);
lv_style_int_t mleft = lv_obj_get_style_margin_left(child, LV_OBJ_PART_MAIN);
lv_obj_align(child, cont, align, hpad_corr + mleft, last_cord + mtop);
last_cord += lv_obj_get_height(child) + inner + mtop + mbottom;
@@ -648,21 +649,10 @@ static void lv_cont_layout_pretty(lv_obj_t * cont)
*/
static void lv_cont_layout_grid(lv_obj_t * cont)
{
lv_obj_t * child;
lv_coord_t w_tot = lv_obj_get_width(cont);
lv_coord_t w_obj = lv_obj_get_width(lv_obj_get_child(cont, NULL));
lv_coord_t w_fit = lv_obj_get_width_fit(cont);
lv_coord_t h_obj = lv_obj_get_height(lv_obj_get_child(cont, NULL));
lv_coord_t inner = lv_obj_get_style_pad_inner(cont, LV_CONT_PART_MAIN);
uint16_t obj_row = (w_fit) / (w_obj + inner); /*Obj. num. in a row*/
lv_coord_t x_ofs;
if(obj_row > 1) {
x_ofs = w_obj + (w_fit - (obj_row * w_obj)) / (obj_row - 1);
}
else {
x_ofs = w_tot / 2 - w_obj / 2;
}
lv_coord_t y_ofs = h_obj + inner;
lv_coord_t y_ofs = inner + lv_obj_get_height(lv_obj_get_child(cont, NULL));
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
@@ -672,24 +662,17 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
lv_coord_t left = lv_obj_get_style_pad_left(cont, LV_CONT_PART_MAIN);
lv_coord_t act_x = left;
lv_coord_t act_y = lv_obj_get_style_pad_top(cont, LV_CONT_PART_MAIN);
uint16_t obj_cnt = 0;
lv_obj_t * child;
LV_LL_READ_BACK(cont->child_ll, child) {
if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
if(obj_row > 1) {
lv_obj_set_pos(child, act_x, act_y);
act_x += x_ofs;
}
else {
lv_obj_set_pos(child, x_ofs, act_y);
}
obj_cnt++;
if(obj_cnt >= obj_row) {
obj_cnt = 0;
act_x = left;
lv_coord_t obj_w = lv_obj_get_width(child);
if(act_x + inner + obj_w > w_fit) {
act_x = left;
act_y += y_ofs;
}
lv_obj_set_pos(child, act_x, act_y);
act_x += inner + obj_w;
}
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
@@ -701,6 +684,7 @@ static void lv_cont_layout_grid(lv_obj_t * cont)
*/
static void lv_cont_refr_autofit(lv_obj_t * cont)
{
if(lv_obj_is_protected(cont, LV_PROTECT_CHILD_CHG)) return;
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
if(ext->fit_left == LV_FIT_NONE && ext->fit_right == LV_FIT_NONE && ext->fit_top == LV_FIT_NONE &&
@@ -734,14 +718,27 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
LV_LL_READ(cont->child_ll, child_i) {
if(lv_obj_get_hidden(child_i) != false) continue;
lv_style_int_t mleft = lv_obj_get_style_margin_left(child_i, LV_OBJ_PART_MAIN);
lv_style_int_t mright = lv_obj_get_style_margin_right(child_i, LV_OBJ_PART_MAIN);
lv_style_int_t mtop = lv_obj_get_style_margin_top(child_i, LV_OBJ_PART_MAIN);
lv_style_int_t mbottom = lv_obj_get_style_margin_bottom(child_i, LV_OBJ_PART_MAIN);
tight_area.x1 = LV_MATH_MIN(tight_area.x1, child_i->coords.x1 - mleft);
tight_area.y1 = LV_MATH_MIN(tight_area.y1, child_i->coords.y1 - mtop);
tight_area.x2 = LV_MATH_MAX(tight_area.x2, child_i->coords.x2 + mright);
tight_area.y2 = LV_MATH_MAX(tight_area.y2, child_i->coords.y2 + mbottom);
if(ext->fit_left != LV_FIT_PARENT)
{
lv_style_int_t mleft = lv_obj_get_style_margin_left(child_i, LV_OBJ_PART_MAIN);
tight_area.x1 = LV_MATH_MIN(tight_area.x1, child_i->coords.x1 - mleft);
}
if(ext->fit_right != LV_FIT_PARENT) {
lv_style_int_t mright = lv_obj_get_style_margin_right(child_i, LV_OBJ_PART_MAIN);
tight_area.x2 = LV_MATH_MAX(tight_area.x2, child_i->coords.x2 + mright);
}
if(ext->fit_top != LV_FIT_PARENT) {
lv_style_int_t mtop = lv_obj_get_style_margin_top(child_i, LV_OBJ_PART_MAIN);
tight_area.y1 = LV_MATH_MIN(tight_area.y1, child_i->coords.y1 - mtop);
}
if(ext->fit_bottom != LV_FIT_PARENT) {
lv_style_int_t mbottom = lv_obj_get_style_margin_bottom(child_i, LV_OBJ_PART_MAIN);
tight_area.y2 = LV_MATH_MAX(tight_area.y2, child_i->coords.y2 + mbottom);
}
}
tight_area.x1 -= lv_obj_get_style_pad_left(cont, LV_CONT_PART_MAIN);

View File

@@ -62,13 +62,13 @@ static bool lv_cpicker_hit(lv_obj_t * cpicker, const lv_point_t * p);
static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask);
static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask);
static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask);
static void invalidate_indic(lv_obj_t * cpicker);
static lv_area_t get_indic_area(lv_obj_t * cpicker);
static void draw_knob(lv_obj_t * cpicker, const lv_area_t * mask);
static void invalidate_knob(lv_obj_t * cpicker);
static lv_area_t get_knob_area(lv_obj_t * cpicker);
static void next_color_mode(lv_obj_t * cpicker);
static lv_res_t double_click_reset(lv_obj_t * cpicker);
static void refr_indic_pos(lv_obj_t * cpicker);
static void refr_knob_pos(lv_obj_t * cpicker);
static lv_color_t angle_to_mode_color(lv_obj_t * cpicker, uint16_t angle);
static uint16_t get_angle(lv_obj_t * cpicker);
@@ -114,13 +114,13 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy)
/*Initialize the allocated 'ext' */
ext->type = LV_CPICKER_DEF_TYPE;
ext->hsv = LV_CPICKER_DEF_HSV;
ext->indic.colored = 1;
ext->knob.colored = 1;
ext->color_mode = LV_CPICKER_COLOR_MODE_HUE;
ext->color_mode_fixed = 0;
ext->last_click_time = 0;
ext->last_change_time = 0;
lv_style_list_init(&ext->indic.style_list);
lv_style_list_init(&ext->knob.style_list);
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(cpicker, lv_cpicker_signal);
@@ -140,13 +140,13 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy)
ext->color_mode = copy_ext->color_mode;
ext->color_mode_fixed = copy_ext->color_mode_fixed;
ext->hsv = copy_ext->hsv;
ext->indic.colored = copy_ext->indic.colored;
ext->knob.colored = copy_ext->knob.colored;
lv_style_list_copy(&ext->indic.style_list, &copy_ext->indic.style_list);
lv_style_list_copy(&ext->knob.style_list, &copy_ext->knob.style_list);
/*Refresh the style with new signal function*/
lv_obj_refresh_style(cpicker, LV_STYLE_PROP_ALL);
}
refr_indic_pos(cpicker);
refr_knob_pos(cpicker);
LV_LOG_INFO("color_picker created");
@@ -171,7 +171,7 @@ void lv_cpicker_set_type(lv_obj_t * cpicker, lv_cpicker_type_t type)
ext->type = type;
lv_obj_refresh_ext_draw_pad(cpicker);
refr_indic_pos(cpicker);
refr_knob_pos(cpicker);
lv_obj_invalidate(cpicker);
}
@@ -235,7 +235,7 @@ bool lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv)
ext->hsv = hsv;
refr_indic_pos(cpicker);
refr_knob_pos(cpicker);
if(ext->type == LV_CPICKER_TYPE_DISC) {
lv_obj_invalidate(cpicker);
@@ -273,7 +273,7 @@ void lv_cpicker_set_color_mode(lv_obj_t * cpicker, lv_cpicker_color_mode_t mode)
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
ext->color_mode = mode;
refr_indic_pos(cpicker);
refr_knob_pos(cpicker);
lv_obj_invalidate(cpicker);
}
@@ -292,17 +292,17 @@ void lv_cpicker_set_color_mode_fixed(lv_obj_t * cpicker, bool fixed)
}
/**
* Make the indicator to be colored to the current color
* Make the knob to be colored to the current color
* @param cpicker pointer to colorpicker object
* @param en true: color the indicator; false: not color the indicator
* @param en true: color the knob; false: not color the knob
*/
void lv_cpicker_set_indic_colored(lv_obj_t * cpicker, bool en)
void lv_cpicker_set_knob_colored(lv_obj_t * cpicker, bool en)
{
LV_ASSERT_OBJ(cpicker, LV_OBJX_NAME);
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
ext->indic.colored = en ? 1 : 0;
invalidate_indic(cpicker);
ext->knob.colored = en ? 1 : 0;
invalidate_knob(cpicker);
}
/*=====================
@@ -408,17 +408,17 @@ lv_color_t lv_cpicker_get_color(lv_obj_t * cpicker)
}
/**
* Whether the indicator is colored to the current color or not
* @param cpicker pointer to colorpicker object
* @return true: color the indicator; false: not color the indicator
* Whether the knob is colored to the current color or not
* @param cpicker pointer to color picker object
* @return true: color the knob; false: not color the knob
*/
bool lv_cpicker_get_indic_colored(lv_obj_t * cpicker)
bool lv_cpicker_get_knob_colored(lv_obj_t * cpicker)
{
LV_ASSERT_OBJ(cpicker, LV_OBJX_NAME);
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
return ext->indic.colored ? true : false;
return ext->knob.colored ? true : false;
}
/*=====================
@@ -457,7 +457,7 @@ static lv_design_res_t lv_cpicker_design(lv_obj_t * cpicker, const lv_area_t * c
draw_rect_grad(cpicker, clip_area);
}
draw_indic(cpicker, clip_area);
draw_knob(cpicker, clip_area);
}
/*Post draw when the children are drawn*/
else if(mode == LV_DESIGN_DRAW_POST) {
@@ -576,47 +576,48 @@ static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask)
/*scale angle (hue/sat/val) to linear coordinate*/
lv_coord_t xi = (i * grad_w) / 360;
lv_coord_t xi2 = ((i+i_step) * grad_w) / 360;
rect_area.x1 = LV_MATH_MIN(grad_area.x1 + xi, grad_area.x1 + grad_w - i_step);
rect_area.y1 = grad_area.y1;
rect_area.x2 = rect_area.x1 + i_step;
rect_area.x2 = LV_MATH_MIN(grad_area.x1 + xi2, grad_area.x1 + grad_w - i_step);
rect_area.y2 = grad_area.y2;
lv_draw_rect(&rect_area, mask, &bg_dsc);
}
}
static void draw_indic(lv_obj_t * cpicker, const lv_area_t * mask)
static void draw_knob(lv_obj_t * cpicker, const lv_area_t * mask)
{
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
lv_draw_rect_dsc_t cir_dsc;
lv_draw_rect_dsc_init(&cir_dsc);
lv_obj_init_draw_rect_dsc(cpicker, LV_CPICKER_PART_INDIC, &cir_dsc);
lv_obj_init_draw_rect_dsc(cpicker, LV_CPICKER_PART_KNOB, &cir_dsc);
cir_dsc.radius = LV_RADIUS_CIRCLE;
if(ext->indic.colored) {
if(ext->knob.colored) {
cir_dsc.bg_color = lv_cpicker_get_color(cpicker);
}
lv_area_t indic_area = get_indic_area(cpicker);
lv_area_t knob_area = get_knob_area(cpicker);
lv_draw_rect(&indic_area, mask, &cir_dsc);
lv_draw_rect(&knob_area, mask, &cir_dsc);
}
static void invalidate_indic(lv_obj_t * cpicker)
static void invalidate_knob(lv_obj_t * cpicker)
{
lv_area_t indic_area = get_indic_area(cpicker);
lv_area_t knob_area = get_knob_area(cpicker);
lv_obj_invalidate_area(cpicker, &indic_area);
lv_obj_invalidate_area(cpicker, &knob_area);
}
static lv_area_t get_indic_area(lv_obj_t * cpicker)
static lv_area_t get_knob_area(lv_obj_t * cpicker)
{
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
/*Get indicator's radius*/
/*Get knob's radius*/
uint16_t r = 0;
if(ext->type == LV_CPICKER_TYPE_DISC) {
r = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN) / 2;
@@ -626,18 +627,18 @@ static lv_area_t get_indic_area(lv_obj_t * cpicker)
r = h / 2;
}
lv_style_int_t left = lv_obj_get_style_pad_left(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t right = lv_obj_get_style_pad_right(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t top = lv_obj_get_style_pad_top(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t left = lv_obj_get_style_pad_left(cpicker, LV_CPICKER_PART_KNOB);
lv_style_int_t right = lv_obj_get_style_pad_right(cpicker, LV_CPICKER_PART_KNOB);
lv_style_int_t top = lv_obj_get_style_pad_top(cpicker, LV_CPICKER_PART_KNOB);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(cpicker, LV_CPICKER_PART_KNOB);
lv_area_t indic_area;
indic_area.x1 = cpicker->coords.x1 + ext->indic.pos.x - r - left;
indic_area.y1 = cpicker->coords.y1 + ext->indic.pos.y - r - right;
indic_area.x2 = cpicker->coords.x1 + ext->indic.pos.x + r + top;
indic_area.y2 = cpicker->coords.y1 + ext->indic.pos.y + r + bottom;
lv_area_t knob_area;
knob_area.x1 = cpicker->coords.x1 + ext->knob.pos.x - r - left;
knob_area.y1 = cpicker->coords.y1 + ext->knob.pos.y - r - right;
knob_area.x2 = cpicker->coords.x1 + ext->knob.pos.x + r + top;
knob_area.y2 = cpicker->coords.y1 + ext->knob.pos.y + r + bottom;
return indic_area;
return knob_area;
}
/**
@@ -666,22 +667,22 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
if(sign == LV_SIGNAL_CLEANUP) {
lv_obj_clean_style_list(cpicker, LV_CPICKER_PART_INDIC);
lv_obj_clean_style_list(cpicker, LV_CPICKER_PART_KNOB);
}
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
lv_style_int_t left = lv_obj_get_style_pad_left(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t right = lv_obj_get_style_pad_right(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t top = lv_obj_get_style_pad_top(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t left = lv_obj_get_style_pad_left(cpicker, LV_CPICKER_PART_KNOB);
lv_style_int_t right = lv_obj_get_style_pad_right(cpicker, LV_CPICKER_PART_KNOB);
lv_style_int_t top = lv_obj_get_style_pad_top(cpicker, LV_CPICKER_PART_KNOB);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(cpicker, LV_CPICKER_PART_KNOB);
lv_coord_t indic_pad = LV_MATH_MAX4(left, right, top, bottom) + 2;
lv_coord_t knob_pad = LV_MATH_MAX4(left, right, top, bottom) + 2;
if(ext->type == LV_CPICKER_TYPE_DISC) {
cpicker->ext_draw_pad = LV_MATH_MAX(cpicker->ext_draw_pad, indic_pad);
cpicker->ext_draw_pad = LV_MATH_MAX(cpicker->ext_draw_pad, knob_pad);
}
else {
indic_pad += lv_obj_get_height(cpicker) / 2;
cpicker->ext_draw_pad = LV_MATH_MAX(cpicker->ext_draw_pad, indic_pad);
knob_pad += lv_obj_get_height(cpicker) / 2;
cpicker->ext_draw_pad = LV_MATH_MAX(cpicker->ext_draw_pad, knob_pad);
}
}
else if(sign == LV_SIGNAL_COORD_CHG) {
@@ -689,14 +690,14 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
if(lv_obj_get_width(cpicker) != lv_area_get_width(param) ||
lv_obj_get_height(cpicker) != lv_area_get_height(param)) {
lv_obj_refresh_ext_draw_pad(cpicker);
refr_indic_pos(cpicker);
refr_knob_pos(cpicker);
lv_obj_invalidate(cpicker);
}
}
else if(sign == LV_SIGNAL_STYLE_CHG) {
/*Refresh extended draw area to make knob visible*/
lv_obj_refresh_ext_draw_pad(cpicker);
refr_indic_pos(cpicker);
refr_knob_pos(cpicker);
lv_obj_invalidate(cpicker);
}
else if(sign == LV_SIGNAL_CONTROL) {
@@ -873,8 +874,8 @@ static lv_style_list_t * lv_cpicker_get_style(lv_obj_t * cpicker, uint8_t part)
case LV_CPICKER_PART_MAIN :
style_dsc_p = &cpicker->style_list;
break;
case LV_CPICKER_PART_INDIC:
style_dsc_p = &ext->indic.style_list;
case LV_CPICKER_PART_KNOB:
style_dsc_p = &ext->knob.style_list;
break;
default:
style_dsc_p = NULL;
@@ -903,13 +904,13 @@ static void next_color_mode(lv_obj_t * cpicker)
{
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
ext->color_mode = (ext->color_mode + 1) % 3;
refr_indic_pos(cpicker);
refr_knob_pos(cpicker);
lv_obj_invalidate(cpicker);
}
static void refr_indic_pos(lv_obj_t * cpicker)
static void refr_knob_pos(lv_obj_t * cpicker)
{
invalidate_indic(cpicker);
invalidate_knob(cpicker);
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
lv_coord_t w = lv_obj_get_width(cpicker);
@@ -929,20 +930,20 @@ static void refr_indic_pos(lv_obj_t * cpicker)
break;
}
ext->indic.pos.x = ind_pos;
ext->indic.pos.y = h / 2;
ext->knob.pos.x = ind_pos;
ext->knob.pos.y = h / 2;
}
else if(ext->type == LV_CPICKER_TYPE_DISC) {
lv_style_int_t scale_w = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN);
lv_coord_t r = (w - scale_w) / 2;
uint16_t angle = get_angle(cpicker);
ext->indic.pos.x = (((int32_t)r * lv_trigo_sin(angle)) >> LV_TRIGO_SHIFT);
ext->indic.pos.y = (((int32_t)r * lv_trigo_sin(angle + 90)) >> LV_TRIGO_SHIFT);
ext->indic.pos.x = ext->indic.pos.x + w / 2;
ext->indic.pos.y = ext->indic.pos.y + h / 2;
ext->knob.pos.x = (((int32_t)r * lv_trigo_sin(angle)) >> LV_TRIGO_SHIFT);
ext->knob.pos.y = (((int32_t)r * lv_trigo_sin(angle + 90)) >> LV_TRIGO_SHIFT);
ext->knob.pos.x = ext->knob.pos.x + w / 2;
ext->knob.pos.y = ext->knob.pos.y + h / 2;
}
invalidate_indic(cpicker);
invalidate_knob(cpicker);
}
static lv_res_t double_click_reset(lv_obj_t * cpicker)

View File

@@ -50,7 +50,7 @@ typedef struct {
lv_point_t pos;
uint8_t colored : 1;
} indic;
} knob;
uint32_t last_click_time;
uint32_t last_change_time;
lv_point_t last_press_point;
@@ -62,7 +62,7 @@ typedef struct {
/*Parts*/
enum {
LV_CPICKER_PART_MAIN = LV_OBJ_PART_MAIN,
LV_CPICKER_PART_INDIC = _LV_OBJ_PART_VIRTUAL_LAST,
LV_CPICKER_PART_KNOB = _LV_OBJ_PART_VIRTUAL_LAST,
_LV_CPICKER_PART_VIRTUAL_LAST,
_LV_CPICKER_PART_REAL_LAST = _LV_OBJ_PART_REAL_LAST,
};
@@ -146,11 +146,11 @@ void lv_cpicker_set_color_mode(lv_obj_t * cpicker, lv_cpicker_color_mode_t mode)
void lv_cpicker_set_color_mode_fixed(lv_obj_t * cpicker, bool fixed);
/**
* Make the indicator to be colored to the current color
* Make the knob to be colored to the current color
* @param cpicker pointer to colorpicker object
* @param en true: color the indicator; false: not color the indicator
* @param en true: color the knob; false: not color the knob
*/
void lv_cpicker_set_indic_colored(lv_obj_t * cpicker, bool en);
void lv_cpicker_set_knob_colored(lv_obj_t * cpicker, bool en);
/*=====================
* Getter functions
@@ -206,11 +206,11 @@ lv_color_hsv_t lv_cpicker_get_hsv(lv_obj_t * cpicker);
lv_color_t lv_cpicker_get_color(lv_obj_t * cpicker);
/**
* Whether the indicator is colored to the current color or not
* @param cpicker pointer to colorpicker object
* @return true: color the indicator; false: not color the indicator
* Whether the knob is colored to the current color or not
* @param cpicker pointer to color picker object
* @return true: color the knob; false: not color the knob
*/
bool lv_cpicker_get_indic_colored(lv_obj_t * cpicker);
bool lv_cpicker_get_knob_colored(lv_obj_t * cpicker);
/**
* Whether the preview is enabled or not

View File

@@ -123,6 +123,7 @@ lv_obj_t * lv_dropdown_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new drop down list drop down list*/
if(copy == NULL) {
lv_obj_set_width(ddlist, LV_DPX(150));
lv_dropdown_set_static_options(ddlist, "Option 1\nOption 2\nOption 3");
lv_theme_apply(ddlist, LV_THEME_DROPDOWN);
}
@@ -604,8 +605,8 @@ void lv_dropdown_open(lv_obj_t * ddlist)
lv_obj_set_signal_cb(lv_page_get_scrl(ext->page), lv_dropdown_page_scrl_signal);
lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_BG), &ext->style_page);
lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCRLBAR), &ext->style_scrlbar);
lv_obj_clean_style_list(ext->page, LV_PAGE_PART_SCRL);
lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCROLLBAR), &ext->style_scrlbar);
lv_obj_clean_style_list(ext->page, LV_PAGE_PART_SCROLLABLE);
lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL);
lv_page_set_scrl_fit(ext->page, LV_FIT_TIGHT);
@@ -902,13 +903,20 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p
lv_dropdown_close(ddlist);
}
else if(sign == LV_SIGNAL_RELEASED) {
if(lv_indev_is_dragging(lv_indev_get_act()) == false) {
lv_indev_t * indev = lv_indev_get_act();
if(lv_indev_is_dragging(indev) == false) {
if(ext->page) {
lv_dropdown_close(ddlist);
if(ext->sel_opt_id_orig != ext->sel_opt_id) {
ext->sel_opt_id_orig = ext->sel_opt_id;
lv_obj_invalidate(ddlist);
}
#if LV_USE_GROUP
lv_indev_type_t indev_type = lv_indev_get_type(indev);
if(indev_type == LV_INDEV_TYPE_ENCODER) {
lv_group_set_editing(lv_obj_get_group(ddlist), false);
}
#endif
}
else {
lv_dropdown_open(ddlist);

View File

@@ -73,10 +73,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(imgbtn);
/*Initialize the allocated 'ext' */
memset((void *)ext->img_src_mid, 0, sizeof(ext->img_src_mid));
lv_memset_00((void *)ext->img_src_mid, sizeof(ext->img_src_mid));
#if LV_IMGBTN_TILED
memset(ext->img_src_left, 0, sizeof(ext->img_src_left));
memset(ext->img_src_right, 0, sizeof(ext->img_src_right));
lv_memset_00(ext->img_src_left, sizeof(ext->img_src_left));
lv_memset_00(ext->img_src_right, sizeof(ext->img_src_right));
#endif
ext->tiled = 0;
@@ -93,10 +93,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
/*Copy an existing image button*/
else {
lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
memcpy((void *)ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid));
lv_memcpy((void *)ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid));
#if LV_IMGBTN_TILED
memcpy((void *)ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left));
memcpy((void *)ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right));
lv_memcpy((void *)ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left));
lv_memcpy((void *)ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right));
#endif
ext->tiled = copy_ext->tiled;
/*Refresh the style with new signal function*/

View File

@@ -147,7 +147,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
ext->text = lv_mem_realloc(ext->text, lv_mem_get_size(copy_ext->text));
LV_ASSERT_MEM(ext->text);
if(ext->text == NULL) return NULL;
memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text));
lv_memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text));
}
if(copy_ext->dot_tmp_alloc && copy_ext->dot.tmp_ptr) {
@@ -155,7 +155,7 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
lv_label_set_dot_tmp(new_label, ext->dot.tmp_ptr, len);
}
else {
memcpy(ext->dot.tmp, copy_ext->dot.tmp, sizeof(ext->dot.tmp));
lv_memcpy(ext->dot.tmp, copy_ext->dot.tmp, sizeof(ext->dot.tmp));
}
ext->dot_tmp_alloc = copy_ext->dot_tmp_alloc;
ext->dot_end = copy_ext->dot_end;
@@ -1208,7 +1208,7 @@ static void lv_label_refr_text(lv_obj_t * label)
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, label);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_playback_delay(&a, (((lv_font_get_glyph_width(font, ' ', ' ') + letter_space) * 1000) /
ext->anim_speed) *
LV_LABEL_WAIT_CHAR_COUNT);
@@ -1291,7 +1291,7 @@ static void lv_label_refr_text(lv_obj_t * label)
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, label);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
bool hor_anim = false;
if(size.x > lv_area_get_width(&txt_coords)) {
@@ -1450,14 +1450,14 @@ static bool lv_label_set_dot_tmp(lv_obj_t * label, char * data, uint16_t len)
LV_LOG_ERROR("Failed to allocate memory for dot_tmp_ptr");
return false;
}
memcpy(ext->dot.tmp_ptr, data, len);
lv_memcpy(ext->dot.tmp_ptr, data, len);
ext->dot.tmp_ptr[len] = '\0';
ext->dot_tmp_alloc = true;
}
else {
/* Characters can be directly stored in object */
ext->dot_tmp_alloc = false;
memcpy(ext->dot.tmp, data, len);
lv_memcpy(ext->dot.tmp, data, len);
}
return true;
}

View File

@@ -138,7 +138,6 @@ void lv_list_clean(lv_obj_t * list)
/*======================
* Add/remove functions
*=====================*/
/**
* Add a list element to the list
* @param list pointer to list object
@@ -156,10 +155,15 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
lv_coord_t pos_x_ori = lv_obj_get_x(list);
lv_coord_t pos_y_ori = lv_obj_get_y(list);
lv_obj_t * scrl = lv_page_get_scrl(list);
lv_obj_add_protect(scrl, LV_PROTECT_CHILD_CHG);
/*Create a list element with the image an the text*/
lv_obj_t * btn;
btn = lv_btn_create(list, NULL);
lv_obj_add_protect(btn, LV_PROTECT_CHILD_CHG);
/*Save the original signal function because it will be required in `lv_list_btn_signal`*/
if(ancestor_btn_signal == NULL) ancestor_btn_signal = lv_obj_get_signal_cb(btn);
@@ -189,6 +193,7 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
lv_obj_add_protect(btn, LV_PROTECT_PRESS_LOST);
lv_obj_set_signal_cb(btn, lv_list_btn_signal);
#if LV_USE_IMG != 0
lv_obj_t * img = NULL;
if(img_src) {
@@ -225,6 +230,10 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
}
#endif
lv_obj_clear_protect(scrl, LV_PROTECT_CHILD_CHG);
lv_obj_clear_protect(btn, LV_PROTECT_CHILD_CHG);
btn->signal_cb(btn, LV_SIGNAL_CHILD_CHG, NULL);
lv_obj_set_pos(list, pos_x_ori, pos_y_ori);
return btn;

View File

@@ -57,10 +57,10 @@ typedef struct {
/** List styles. */
enum {
LV_LIST_PART_BG = LV_PAGE_PART_BG, /**< List background style */
LV_LIST_PART_SCRLBAR = LV_PAGE_PART_SCRLBAR, /**< List scrollbar style. */
LV_LIST_PART_SCRLBAR = LV_PAGE_PART_SCROLLBAR, /**< List scrollbar style. */
LV_LIST_PART_EDGE_FLASH = LV_PAGE_PART_EDGE_FLASH, /**< List edge flash style. */
_LV_LIST_PART_VIRTUAL_LAST = _LV_PAGE_PART_VIRTUAL_LAST,
LV_LIST_PART_SCRL = LV_PAGE_PART_SCRL, /**< List scrollable area style. */
LV_LIST_PART_SCRL = LV_PAGE_PART_SCROLLABLE, /**< List scrollable area style. */
_LV_LIST_PART_REAL_LAST = _LV_PAGE_PART_REAL_LAST,
};
typedef uint8_t lv_list_style_t;

View File

@@ -162,6 +162,13 @@ void lv_msgbox_add_btns(lv_obj_t * mbox, const char * btn_map[])
lv_obj_set_event_cb(ext->btnm, lv_msgbox_btnm_event_cb);
if(lv_obj_is_focused(mbox)) {
lv_state_t state = lv_obj_get_state(mbox, LV_MSGBOX_PART_BG);
if(state & LV_STATE_EDITED) {
lv_obj_set_state(ext->btnm, LV_STATE_FOCUSED | LV_STATE_EDITED);
} else {
lv_obj_set_state(ext->btnm, LV_STATE_FOCUSED);
}
lv_btnmatrix_set_focused_btn(ext->btnm, 0);
}
@@ -312,10 +319,14 @@ uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox)
LV_ASSERT_OBJ(mbox, LV_OBJX_NAME);
lv_msgbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
if(ext->btnm)
return lv_btnmatrix_get_active_btn(ext->btnm);
else
return LV_BTNMATRIX_BTN_NONE;
if(ext->btnm == NULL) return LV_BTNMATRIX_BTN_NONE;
uint16_t id = lv_btnmatrix_get_active_btn(ext->btnm);
if(id == LV_BTNMATRIX_BTN_NONE) {
id = lv_btnmatrix_get_focused_btn(ext->btnm);
}
return id;
}
/**
@@ -442,7 +453,7 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param
}
else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btnm) {
uint32_t btn_id = lv_btnmatrix_get_active_btn(ext->btnm);
uint32_t btn_id = lv_btnmatrix_get_focused_btn(ext->btnm);
if(btn_id != LV_BTNMATRIX_BTN_NONE) lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id);
}
}
@@ -454,20 +465,33 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param
/* The button matrix with ENCODER input supposes it's in a group but in this case it isn't
* (Only the message box's container) So so some actions here instead*/
if(sign == LV_SIGNAL_FOCUS) {
#if LV_USE_GROUP
if(sign == LV_SIGNAL_FOCUS) {
lv_indev_t * indev = lv_indev_get_act();
lv_indev_type_t indev_type = lv_indev_get_type(indev);
if(indev_type == LV_INDEV_TYPE_ENCODER) {
/*In navigation mode don't select any button but in edit mode select the fist*/
lv_btnmatrix_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btnm);
if(lv_group_get_editing(lv_obj_get_group(mbox)))
btnm_ext->btn_id_pr = 0;
else
btnm_ext->btn_id_pr = LV_BTNMATRIX_BTN_NONE;
if(lv_group_get_editing(lv_obj_get_group(mbox))) lv_btnmatrix_set_focused_btn(ext->btnm, 0);
else lv_btnmatrix_set_focused_btn(ext->btnm, LV_BTNMATRIX_BTN_NONE);
}
#endif
}
if(ext->btnm && (sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS)) {
lv_state_t state = lv_obj_get_state(mbox, LV_MSGBOX_PART_BG);
if(state & LV_STATE_FOCUSED) {
lv_obj_set_state(ext->btnm, LV_STATE_FOCUSED);
} else {
lv_obj_clear_state(ext->btnm, LV_STATE_FOCUSED);
}
if(state & LV_STATE_EDITED) {
lv_obj_set_state(ext->btnm, LV_STATE_EDITED);
} else {
lv_obj_clear_state(ext->btnm, LV_STATE_EDITED);
}
}
#endif
}
return res;

View File

@@ -121,7 +121,7 @@ lv_objmask_mask_t * lv_objmask_add_mask(lv_obj_t * objmask, void * param)
LV_ASSERT_MEM(m->param);
if(m->param == NULL) return NULL;
memcpy(m->param, param, param_size);
lv_memcpy(m->param, param, param_size);
lv_obj_invalidate(objmask);

View File

@@ -54,6 +54,7 @@ static void refr_ext_draw_pad(lv_obj_t * page);
#if LV_USE_ANIMATION
static void edge_flash_anim(void * page, lv_anim_value_t v);
static void edge_flash_anim_end(lv_anim_t * a);
static void get_edge_flash_area(lv_obj_t * page, lv_area_t * area, lv_coord_t state);
#endif
/**********************
@@ -391,7 +392,7 @@ lv_coord_t lv_page_get_width_grid(lv_obj_t * page, uint8_t div, uint8_t span)
{
lv_coord_t obj_w = lv_page_get_width_fit(page);
lv_style_int_t pinner = lv_obj_get_style_pad_inner(page, LV_PAGE_PART_SCRL);
lv_style_int_t pinner = lv_obj_get_style_pad_inner(page, LV_PAGE_PART_SCROLLABLE);
lv_coord_t r = (obj_w - (div - 1) * pinner) / div;
@@ -413,7 +414,7 @@ lv_coord_t lv_page_get_width_grid(lv_obj_t * page, uint8_t div, uint8_t span)
lv_coord_t lv_page_get_height_grid(lv_obj_t * page, uint8_t div, uint8_t span)
{
lv_coord_t obj_h = lv_page_get_height_fit(page);
lv_style_int_t pinner = lv_obj_get_style_pad_inner(page, LV_PAGE_PART_SCRL);
lv_style_int_t pinner = lv_obj_get_style_pad_inner(page, LV_PAGE_PART_SCROLLABLE);
lv_coord_t r = (obj_h - (div - 1) * pinner) / div;
@@ -704,7 +705,7 @@ static lv_design_res_t lv_page_design(lv_obj_t * page, const lv_area_t * clip_ar
/*Draw the scrollbars*/
lv_draw_rect_dsc_t rect_dsc;
lv_draw_rect_dsc_init(&rect_dsc);
lv_obj_init_draw_rect_dsc(page, LV_PAGE_PART_SCRLBAR, &rect_dsc);
lv_obj_init_draw_rect_dsc(page, LV_PAGE_PART_SCROLLBAR, &rect_dsc);
if(ext->scrlbar.hor_draw && (ext->scrlbar.mode & LV_SCRLBAR_MODE_HIDE) == 0) {
lv_draw_rect(&sb_hor_area, clip_area, &rect_dsc);
}
@@ -716,38 +717,13 @@ static lv_design_res_t lv_page_design(lv_obj_t * page, const lv_area_t * clip_ar
#if LV_USE_ANIMATION
{
lv_coord_t page_w = lv_obj_get_width(page);
lv_coord_t page_h = lv_obj_get_height(page);
lv_area_t flash_area;
if(ext->edge_flash.top_ip) {
flash_area.x1 = page->coords.x1 - page_w;
flash_area.x2 = page->coords.x2 + page_w;
flash_area.y1 = page->coords.y1 - 3 * page_w + ext->edge_flash.state;
flash_area.y2 = page->coords.y1 + ext->edge_flash.state;
}
else if(ext->edge_flash.bottom_ip) {
flash_area.x1 = page->coords.x1 - page_w;
flash_area.x2 = page->coords.x2 + page_w;
flash_area.y1 = page->coords.y2 - ext->edge_flash.state;
flash_area.y2 = page->coords.y2 + 3 * page_w - ext->edge_flash.state;
}
else if(ext->edge_flash.right_ip) {
flash_area.x1 = page->coords.x2 - ext->edge_flash.state;
flash_area.x2 = page->coords.x2 + 3 * page_h - ext->edge_flash.state;
flash_area.y1 = page->coords.y1 - page_h;
flash_area.y2 = page->coords.y2 + page_h;
}
else if(ext->edge_flash.left_ip) {
flash_area.x1 = page->coords.x1 - 3 * page_h + ext->edge_flash.state;
flash_area.x2 = page->coords.x1 + ext->edge_flash.state;
flash_area.y1 = page->coords.y1 - page_h;
flash_area.y2 = page->coords.y2 + page_h;
}
if(ext->edge_flash.left_ip || ext->edge_flash.right_ip || ext->edge_flash.top_ip ||
ext->edge_flash.bottom_ip) {
lv_area_t flash_area;
get_edge_flash_area(page, &flash_area, ext->edge_flash.state);
lv_draw_rect_dsc_t edge_draw_dsc;
lv_draw_rect_dsc_init(&edge_draw_dsc);
lv_obj_init_draw_rect_dsc(page, LV_PAGE_PART_EDGE_FLASH, &edge_draw_dsc);
@@ -781,7 +757,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
}
else if(sign == LV_SIGNAL_GET_STATE_DSC) {
lv_get_state_info_t * info = param;
if(info->part == LV_PAGE_PART_SCRL) info->result = lv_obj_get_state(lv_page_get_scrl(page), LV_CONT_PART_MAIN);
if(info->part == LV_PAGE_PART_SCROLLABLE) info->result = lv_obj_get_state(lv_page_get_scrl(page), LV_CONT_PART_MAIN);
else info->result = lv_obj_get_state(page, info->part);
return LV_RES_OK;
}
@@ -802,7 +778,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
}
}
lv_obj_clean_style_list(page, LV_PAGE_PART_SCRLBAR);
lv_obj_clean_style_list(page, LV_PAGE_PART_SCROLLBAR);
#if LV_USE_ANIMATION
lv_obj_clean_style_list(page, LV_PAGE_PART_EDGE_FLASH);
#endif
@@ -853,7 +829,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
}
}
else if(sign == LV_SIGNAL_STYLE_CHG) {
lv_style_int_t sb_width = lv_obj_get_style_size(page, LV_PAGE_PART_SCRLBAR);
lv_style_int_t sb_width = lv_obj_get_style_size(page, LV_PAGE_PART_SCROLLBAR);
lv_area_set_height(&ext->scrlbar.hor_area, sb_width);
lv_area_set_width(&ext->scrlbar.ver_area, sb_width);
@@ -1091,10 +1067,10 @@ static lv_style_list_t * lv_page_get_style(lv_obj_t * page, uint8_t part)
case LV_PAGE_PART_BG:
style_dsc_p = &page->style_list;
break;
case LV_PAGE_PART_SCRL:
case LV_PAGE_PART_SCROLLABLE:
style_dsc_p = lv_obj_get_style_list(ext->scrl, LV_CONT_PART_MAIN);
break;
case LV_PAGE_PART_SCRLBAR:
case LV_PAGE_PART_SCROLLBAR:
style_dsc_p = &ext->scrlbar.style;
break;
#if LV_USE_ANIMATION
@@ -1190,9 +1166,9 @@ static void scrlbar_refresh(lv_obj_t * page)
lv_coord_t obj_w = lv_obj_get_width(page);
lv_coord_t obj_h = lv_obj_get_height(page);
lv_style_int_t sb_width = lv_obj_get_style_size(page, LV_PAGE_PART_SCRLBAR);
lv_style_int_t sb_right = lv_obj_get_style_pad_right(page, LV_PAGE_PART_SCRLBAR);
lv_style_int_t sb_bottom = lv_obj_get_style_pad_bottom(page, LV_PAGE_PART_SCRLBAR);
lv_style_int_t sb_width = lv_obj_get_style_size(page, LV_PAGE_PART_SCROLLBAR);
lv_style_int_t sb_right = lv_obj_get_style_pad_right(page, LV_PAGE_PART_SCROLLBAR);
lv_style_int_t sb_bottom = lv_obj_get_style_pad_bottom(page, LV_PAGE_PART_SCROLLBAR);
lv_style_int_t bg_left = lv_obj_get_style_pad_left(page, LV_PAGE_PART_BG);
lv_style_int_t bg_right = lv_obj_get_style_pad_right(page, LV_PAGE_PART_BG);
@@ -1314,8 +1290,8 @@ static void scrlbar_refresh(lv_obj_t * page)
static void refr_ext_draw_pad(lv_obj_t * page)
{
lv_style_int_t sb_bottom = lv_obj_get_style_pad_bottom(page, LV_PAGE_PART_SCRLBAR);
lv_style_int_t sb_right = lv_obj_get_style_pad_right(page, LV_PAGE_PART_SCRLBAR);
lv_style_int_t sb_bottom = lv_obj_get_style_pad_bottom(page, LV_PAGE_PART_SCROLLBAR);
lv_style_int_t sb_right = lv_obj_get_style_pad_right(page, LV_PAGE_PART_SCROLLBAR);
/*Ensure ext. size for the scrollbars if they are out of the page*/
if(page->ext_draw_pad < (-sb_right)) page->ext_draw_pad = -sb_right;
@@ -1327,18 +1303,60 @@ static void edge_flash_anim(void * page, lv_anim_value_t v)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
ext->edge_flash.state = v;
lv_obj_invalidate(page);
lv_area_t flash_area;
get_edge_flash_area(page, &flash_area, LV_PAGE_END_FLASH_SIZE);
lv_obj_invalidate_area(page, &flash_area);
}
static void edge_flash_anim_end(lv_anim_t * a)
{
lv_area_t flash_area;
get_edge_flash_area(a->var, &flash_area, LV_PAGE_END_FLASH_SIZE);
lv_obj_invalidate_area(a->var, &flash_area);
lv_page_ext_t * ext = lv_obj_get_ext_attr(a->var);
ext->edge_flash.top_ip = 0;
ext->edge_flash.bottom_ip = 0;
ext->edge_flash.left_ip = 0;
ext->edge_flash.right_ip = 0;
lv_obj_invalidate(a->var);
}
static void get_edge_flash_area(lv_obj_t * page, lv_area_t * flash_area, lv_coord_t state)
{
lv_coord_t page_w = lv_obj_get_width(page);
lv_coord_t page_h = lv_obj_get_height(page);
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
if(ext->edge_flash.top_ip) {
flash_area->x1 = page->coords.x1 - page_w;
flash_area->x2 = page->coords.x2 + page_w;
flash_area->y1 = page->coords.y1 - 3 * page_w + state;
flash_area->y2 = page->coords.y1 + state;
}
else if(ext->edge_flash.bottom_ip) {
flash_area->x1 = page->coords.x1 - page_w;
flash_area->x2 = page->coords.x2 + page_w;
flash_area->y1 = page->coords.y2 - state;
flash_area->y2 = page->coords.y2 + 3 * page_w - state;
}
else if(ext->edge_flash.right_ip) {
flash_area->x1 = page->coords.x2 - state;
flash_area->x2 = page->coords.x2 + 3 * page_h - state;
flash_area->y1 = page->coords.y1 - page_h;
flash_area->y2 = page->coords.y2 + page_h;
}
else if(ext->edge_flash.left_ip) {
flash_area->x1 = page->coords.x1 - 3 * page_h + state;
flash_area->x2 = page->coords.x1 + state;
flash_area->y1 = page->coords.y1 - page_h;
flash_area->y2 = page->coords.y2 + page_h;
} else {
lv_area_set(flash_area, 0, 0, -1, -1);
}
}
#endif
#endif

View File

@@ -85,11 +85,11 @@ typedef struct {
enum {
LV_PAGE_PART_BG = LV_CONT_PART_MAIN,
LV_PAGE_PART_SCRLBAR = _LV_OBJ_PART_VIRTUAL_LAST,
LV_PAGE_PART_SCROLLBAR = _LV_OBJ_PART_VIRTUAL_LAST,
LV_PAGE_PART_EDGE_FLASH,
_LV_PAGE_PART_VIRTUAL_LAST,
LV_PAGE_PART_SCRL = _LV_OBJ_PART_REAL_LAST,
LV_PAGE_PART_SCROLLABLE = _LV_OBJ_PART_REAL_LAST,
_LV_PAGE_PART_REAL_LAST,
};
typedef uint8_t lv_part_style_t;

View File

@@ -111,7 +111,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_signal_cb(scrl, lv_roller_scrl_signal);
lv_obj_clean_style_list(roller, LV_PAGE_PART_SCRL); /*Use a transparent scrollable*/
lv_obj_clean_style_list(roller, LV_PAGE_PART_SCROLLABLE); /*Use a transparent scrollable*/
lv_theme_apply(roller, LV_THEME_ROLLER);
refr_height(roller);
@@ -479,8 +479,10 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
}
/* Include the ancient signal function */
res = ancestor_signal(roller, sign, param);
if(res != LV_RES_OK) return res;
if(sign != LV_SIGNAL_CONTROL) { /*Don't let the page to scroll on keys*/
res = ancestor_signal(roller, sign, param);
if(res != LV_RES_OK) return res;
}
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);

View File

@@ -108,10 +108,9 @@ static inline void lv_slider_set_range(lv_obj_t * slider, int16_t min, int16_t m
}
/**
* Make the slider symmetric to zero. The indicator will grow from zero instead of the minimum
* position.
* @param slider pointer to a slider object
* @param en true: enable disable symmetric behavior; false: disable
* Set the animation time of the slider
* @param slider pointer to a bar object
* @param anim_time the animation time in milliseconds.
*/
static inline void lv_slider_set_anim_time(lv_obj_t * slider, uint16_t anim_time)
{
@@ -119,9 +118,10 @@ static inline void lv_slider_set_anim_time(lv_obj_t * slider, uint16_t anim_time
}
/**
* Set the animation time of the slider
* @param slider pointer to a bar object
* @param anim_time the animation time in milliseconds.
* Make the slider symmetric to zero. The indicator will grow from zero instead of the minimum
* position.
* @param slider pointer to a slider object
* @param en true: enable disable symmetric behavior; false: disable
*/
static inline void lv_slider_set_type(lv_obj_t * slider, lv_slider_type_t type)
{

View File

@@ -217,6 +217,8 @@ void lv_spinbox_set_range(lv_obj_t * spinbox, int32_t range_min, int32_t range_m
ext->value = ext->range_min;
lv_obj_invalidate(spinbox);
}
lv_spinbox_updatevalue(spinbox);
}
/**
@@ -512,7 +514,7 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
char buf[LV_SPINBOX_MAX_DIGIT_COUNT + 8];
memset(buf, 0, sizeof(buf));
lv_memset_00(buf, sizeof(buf));
char * buf_p = buf;
uint8_t cur_shift_left = 0;

View File

@@ -168,12 +168,16 @@ void lv_spinner_set_type(lv_obj_t * spinner, lv_spinner_type_t type)
switch(type) {
case LV_SPINNER_TYPE_FILLSPIN_ARC: {
ext->anim_type = LV_SPINNER_TYPE_FILLSPIN_ARC;
lv_anim_path_t path;
lv_anim_path_init(&path);
lv_anim_path_set_cb(&path, lv_anim_path_ease_in_out);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, spinner);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_anim_cb);
lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
lv_anim_set_path(&a, &path);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_set_time(&a, ext->time);
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) lv_anim_set_values(&a, 0, 360);
else lv_anim_set_values(&a, 360, 0);
@@ -191,13 +195,18 @@ void lv_spinner_set_type(lv_obj_t * spinner, lv_spinner_type_t type)
case LV_SPINNER_TYPE_SPINNING_ARC:
default: {
ext->anim_type = type;
lv_anim_path_t path;
lv_anim_path_init(&path);
lv_anim_path_set_cb(&path, (LV_SPINNER_TYPE_CONSTANT_ARC == type ? lv_anim_path_linear : lv_anim_path_ease_in_out));
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, spinner);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_spinner_anim_cb);
lv_anim_set_time(&a, ext->time);
lv_anim_set_path_cb(&a, (LV_SPINNER_TYPE_CONSTANT_ARC == type ? lv_anim_path_linear : lv_anim_path_ease_in_out));
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
lv_anim_set_path(&a, &path);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
if(ext->anim_dir == LV_SPINNER_DIR_FORWARD) lv_anim_set_values(&a, 0, 360);
else lv_anim_set_values(&a, 360, 0);
lv_anim_start(&a);

View File

@@ -79,6 +79,7 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy)
ext->cell_data = NULL;
ext->col_cnt = 0;
ext->row_cnt = 0;
ext->row_h = NULL;
ext->cell_types = 1;
uint16_t i;
@@ -199,8 +200,12 @@ void lv_table_set_row_cnt(lv_obj_t * table, uint16_t row_cnt)
if(old_row_cnt < row_cnt) {
uint16_t old_cell_cnt = old_row_cnt * ext->col_cnt;
uint32_t new_cell_cnt = ext->col_cnt * ext->row_cnt;
memset(&ext->cell_data[old_cell_cnt], 0, (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0]));
lv_memset_00(&ext->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0]));
}
ext->row_h = lv_mem_realloc(ext->row_h, ext->row_cnt * sizeof(ext->row_h[0]));
LV_ASSERT_MEM(ext->cell_data);
if(ext->cell_data == NULL) return;
}
else {
lv_mem_free(ext->cell_data);
@@ -237,7 +242,7 @@ void lv_table_set_col_cnt(lv_obj_t * table, uint16_t col_cnt)
if(old_col_cnt < col_cnt) {
uint16_t old_cell_cnt = old_col_cnt * ext->row_cnt;
uint32_t new_cell_cnt = ext->col_cnt * ext->row_cnt;
memset(&ext->cell_data[old_cell_cnt], 0, (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0]));
lv_memset_00(&ext->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0]));
}
}
@@ -652,29 +657,9 @@ lv_res_t lv_table_get_pressed_cell(lv_obj_t * table, uint16_t * row, uint16_t *
*row = 0;
tmp = 0;
lv_style_int_t cell_left[LV_TABLE_CELL_STYLE_CNT];
lv_style_int_t cell_right[LV_TABLE_CELL_STYLE_CNT];
lv_style_int_t cell_top[LV_TABLE_CELL_STYLE_CNT];
lv_style_int_t cell_bottom[LV_TABLE_CELL_STYLE_CNT];
lv_style_int_t letter_space[LV_TABLE_CELL_STYLE_CNT];
lv_style_int_t line_space[LV_TABLE_CELL_STYLE_CNT];
const lv_font_t * font[LV_TABLE_CELL_STYLE_CNT];
uint16_t i;
for(i = 0; i < LV_TABLE_CELL_STYLE_CNT; i++) {
if((ext->cell_types & (1 << i)) == 0) continue; /*Skip unused cell types*/
cell_left[i] = lv_obj_get_style_pad_left(table, LV_TABLE_PART_CELL1 + i);
cell_right[i] = lv_obj_get_style_pad_right(table, LV_TABLE_PART_CELL1 + i);
cell_top[i] = lv_obj_get_style_pad_top(table, LV_TABLE_PART_CELL1 + i);
cell_bottom[i] = lv_obj_get_style_pad_bottom(table, LV_TABLE_PART_CELL1 + i);
letter_space[i] = lv_obj_get_style_text_letter_space(table, LV_TABLE_PART_CELL1 + i);
line_space[i] = lv_obj_get_style_text_line_space(table, LV_TABLE_PART_CELL1 + i);
font[i] = lv_obj_get_style_text_font(table, LV_TABLE_PART_CELL1 + i);
}
for(*row = 0; *row < ext->row_cnt; (*row)++) {
tmp += get_row_height(table, *row, font, letter_space, line_space,
cell_left, cell_right, cell_top, cell_bottom);
tmp += ext->row_h[*row];
if(y < tmp) break;
}
}
@@ -726,9 +711,6 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_
lv_style_int_t cell_right[LV_TABLE_CELL_STYLE_CNT];
lv_style_int_t cell_top[LV_TABLE_CELL_STYLE_CNT];
lv_style_int_t cell_bottom[LV_TABLE_CELL_STYLE_CNT];
lv_style_int_t letter_space[LV_TABLE_CELL_STYLE_CNT];
lv_style_int_t line_space[LV_TABLE_CELL_STYLE_CNT];
const lv_font_t * font[LV_TABLE_CELL_STYLE_CNT];
uint16_t i;
for(i = 0; i < LV_TABLE_CELL_STYLE_CNT; i++) {
@@ -746,9 +728,6 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_
cell_right[i] = lv_obj_get_style_pad_right(table, LV_TABLE_PART_CELL1 + i);
cell_top[i] = lv_obj_get_style_pad_top(table, LV_TABLE_PART_CELL1 + i);
cell_bottom[i] = lv_obj_get_style_pad_bottom(table, LV_TABLE_PART_CELL1 + i);
letter_space[i] = label_dsc[i].letter_space;
line_space[i] = label_dsc[i].line_space;
font[i] = label_dsc[i].font;
}
uint16_t col;
@@ -757,8 +736,7 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_
cell_area.y2 = table->coords.y1 + bg_top - 1;
for(row = 0; row < ext->row_cnt; row++) {
lv_coord_t h_row = get_row_height(table, row, font, letter_space, line_space,
cell_left, cell_right, cell_top, cell_bottom);
lv_coord_t h_row = ext->row_h[row];
cell_area.y1 = cell_area.y2 + 1;
cell_area.y2 = cell_area.y1 + h_row - 1;
@@ -935,7 +913,8 @@ static lv_res_t lv_table_signal(lv_obj_t * table, lv_signal_t sign, void * param
}
}
if(ext->cell_data != NULL) lv_mem_free(ext->cell_data);
if(ext->cell_data) lv_mem_free(ext->cell_data);
if(ext->row_h) lv_mem_free(ext->row_h);
for(i = 0; i < LV_TABLE_CELL_STYLE_CNT; i++) {
lv_obj_clean_style_list(table, LV_TABLE_PART_CELL1 + i);
@@ -1018,8 +997,9 @@ static void refr_size(lv_obj_t * table)
for(i = 0; i < ext->row_cnt; i++) {
h += get_row_height(table, i, font, letter_space, line_space,
ext->row_h[i] = get_row_height(table, i, font, letter_space, line_space,
cell_left, cell_right, cell_top, cell_bottom);
h += ext->row_h[i];
}
lv_style_int_t bg_top = lv_obj_get_style_pad_top(table, LV_TABLE_PART_BG);

View File

@@ -58,6 +58,7 @@ typedef struct {
uint16_t col_cnt;
uint16_t row_cnt;
char ** cell_data;
lv_coord_t * row_h;
lv_style_list_t cell_style[LV_TABLE_CELL_STYLE_CNT];
lv_coord_t col_w[LV_TABLE_COL_MAX];
uint8_t cell_types : 4; /*Keep track which cell types exists to avoid dealing with unused ones*/

View File

@@ -176,10 +176,10 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
for(i = 0; i < copy_ext->tab_cnt; i++) {
lv_obj_t * new_tab = lv_tabview_add_tab(tabview, copy_ext->tab_name_ptr[i]);
lv_obj_t * copy_tab = lv_tabview_get_tab(copy, i);
lv_style_list_copy(lv_obj_get_style_list(new_tab, LV_PAGE_PART_SCRL), lv_obj_get_style_list(copy_tab,
LV_PAGE_PART_SCRL));
lv_style_list_copy(lv_obj_get_style_list(new_tab, LV_PAGE_PART_SCRLBAR), lv_obj_get_style_list(copy_tab,
LV_PAGE_PART_SCRLBAR));
lv_style_list_copy(lv_obj_get_style_list(new_tab, LV_PAGE_PART_SCROLLABLE), lv_obj_get_style_list(copy_tab,
LV_PAGE_PART_SCROLLABLE));
lv_style_list_copy(lv_obj_get_style_list(new_tab, LV_PAGE_PART_SCROLLBAR), lv_obj_get_style_list(copy_tab,
LV_PAGE_PART_SCROLLBAR));
lv_obj_refresh_style(new_tab, LV_STYLE_PROP_ALL);
}
@@ -340,8 +340,8 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
}
lv_coord_t cont_x;
lv_style_int_t scrl_inner = lv_obj_get_style_pad_inner(ext->content, LV_PAGE_PART_SCRL);
lv_style_int_t scrl_left = lv_obj_get_style_pad_left(ext->content, LV_PAGE_PART_SCRL);
lv_style_int_t scrl_inner = lv_obj_get_style_pad_inner(ext->content, LV_PAGE_PART_SCROLLABLE);
lv_style_int_t scrl_left = lv_obj_get_style_pad_left(ext->content, LV_PAGE_PART_SCROLLABLE);
switch(ext->btns_pos) {
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
@@ -599,7 +599,7 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
if(info->part == LV_TABVIEW_PART_TAB_BG) info->result = lv_obj_get_state(ext->btns, LV_BTNMATRIX_PART_BG);
else if(info->part == LV_TABVIEW_PART_TAB_BTN) info->result = lv_obj_get_state(ext->btns, LV_BTNMATRIX_PART_BTN);
else if(info->part == LV_TABVIEW_PART_INDIC) info->result = lv_obj_get_state(ext->indic, LV_OBJ_PART_MAIN);
else if(info->part == LV_TABVIEW_PART_BG_SCRL) info->result = lv_obj_get_state(ext->content, LV_PAGE_PART_SCRL);
else if(info->part == LV_TABVIEW_PART_BG_SCRL) info->result = lv_obj_get_state(ext->content, LV_PAGE_PART_SCROLLABLE);
return LV_RES_OK;
}
@@ -652,17 +652,34 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
/* The button matrix is not in a group (the tab view is in it) but it should handle the
* group signals. So propagate the related signals to the button matrix manually*/
if(ext->btns) {
ext->btns->signal_cb(ext->btns, sign, param);
ext->btns->signal_cb(ext->btns, sign, param);
/*Make the active tab's button focused*/
if(sign == LV_SIGNAL_FOCUS) {
lv_btnmatrix_set_focused_btn(ext->btns, ext->tab_cur);
}
if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS) {
lv_state_t state = lv_obj_get_state(tabview, LV_TABVIEW_PART_BG);
if(state & LV_STATE_FOCUSED) {
lv_obj_set_state(ext->btns, LV_STATE_FOCUSED);
lv_obj_set_state(ext->indic, LV_STATE_FOCUSED);
} else {
lv_obj_clear_state(ext->btns, LV_STATE_FOCUSED);
lv_obj_clear_state(ext->indic, LV_STATE_FOCUSED);
}
if(state & LV_STATE_EDITED) {
lv_obj_set_state(ext->btns, LV_STATE_EDITED);
lv_obj_set_state(ext->indic, LV_STATE_EDITED);
} else {
lv_obj_clear_state(ext->btns, LV_STATE_EDITED);
lv_obj_clear_state(ext->indic, LV_STATE_EDITED);
/*Make the active tab's button focused*/
if(sign == LV_SIGNAL_FOCUS) {
lv_btnmatrix_set_focused_btn(ext->btns, ext->tab_cur);
}
}
}
return res;
}
@@ -751,7 +768,7 @@ static lv_style_list_t * lv_tabview_get_style(lv_obj_t * tabview, uint8_t part)
style_dsc_p = &tabview->style_list;
break;
case LV_TABVIEW_PART_BG_SCRL:
style_dsc_p = lv_obj_get_style_list(ext->content, LV_PAGE_PART_SCRL);
style_dsc_p = lv_obj_get_style_list(ext->content, LV_PAGE_PART_SCROLLABLE);
break;
case LV_TABVIEW_PART_TAB_BG:
style_dsc_p = lv_obj_get_style_list(ext->btns, LV_BTNMATRIX_PART_BG);
@@ -782,6 +799,8 @@ static void tab_btnm_event_cb(lv_obj_t * tab_btnm, lv_event_t event)
uint16_t btn_id = lv_btnmatrix_get_active_btn(tab_btnm);
if(btn_id == LV_BTNMATRIX_BTN_NONE) return;
if(lv_btnmatrix_get_btn_ctrl(tab_btnm, btn_id, LV_BTNMATRIX_CTRL_DISABLED)) return;
lv_btnmatrix_clear_btn_ctrl_all(tab_btnm, LV_BTNMATRIX_CTRL_CHECK_STATE);
lv_btnmatrix_set_btn_ctrl(tab_btnm, btn_id, LV_BTNMATRIX_CTRL_CHECK_STATE);
@@ -794,6 +813,12 @@ static void tab_btnm_event_cb(lv_obj_t * tab_btnm, lv_event_t event)
lv_res_t res = LV_RES_OK;
if(id_prev != id_new) res = lv_event_send(tabview, LV_EVENT_VALUE_CHANGED, &id_new);
#if LV_USE_GROUP
if(lv_indev_get_type(lv_indev_get_act()) == LV_INDEV_TYPE_ENCODER) {
lv_group_set_editing(lv_obj_get_group(tabview), false);
}
#endif
if(res != LV_RES_OK) return;
}

View File

@@ -150,7 +150,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_size(ta, LV_TEXTAREA_DEF_WIDTH, LV_TEXTAREA_DEF_HEIGHT);
lv_textarea_set_sb_mode(ta, LV_SCRLBAR_MODE_DRAG);
lv_obj_reset_style_list(ta, LV_PAGE_PART_SCRL);
lv_obj_reset_style_list(ta, LV_PAGE_PART_SCROLLABLE);
lv_theme_apply(ta, LV_THEME_TEXTAREA);
}
@@ -181,7 +181,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy)
LV_ASSERT_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return NULL;
memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len);
lv_memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len);
}
if(copy_ext->one_line) lv_textarea_set_one_line(ta, true);
@@ -193,6 +193,10 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy)
#if LV_USE_ANIMATION
if(ext->cursor.blink_time) {
/*Create a cursor blinker animation*/
lv_anim_path_t path;
lv_anim_path_init(&path);
lv_anim_path_set_cb(&path, lv_anim_path_step);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, ta);
@@ -200,8 +204,8 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy)
lv_anim_set_time(&a, ext->cursor.blink_time);
lv_anim_set_playback_time(&a, ext->cursor.blink_time);
lv_anim_set_values(&a, 0, 1);
lv_anim_set_path_cb(&a, lv_anim_path_step);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
lv_anim_set_path(&a, &path);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);
}
#endif
@@ -281,13 +285,17 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c)
#if LV_USE_ANIMATION
/*Auto hide characters*/
lv_anim_path_t path;
lv_anim_path_init(&path);
lv_anim_path_set_cb(&path, lv_anim_path_step);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, ta);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim);
lv_anim_set_time(&a, ext->pwd_show_time);
lv_anim_set_values(&a, 0, 1);
lv_anim_set_path_cb(&a, lv_anim_path_step);
lv_anim_set_path(&a, &path);
lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready);
lv_anim_start(&a);
@@ -364,13 +372,16 @@ void lv_textarea_add_text(lv_obj_t * ta, const char * txt)
#if LV_USE_ANIMATION
/*Auto hide characters*/
lv_anim_path_t path;
lv_anim_path_init(&path);
lv_anim_path_set_cb(&path, lv_anim_path_step);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, ta);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim);
lv_anim_set_time(&a, ext->pwd_show_time);
lv_anim_set_values(&a, 0, 1);
lv_anim_set_path_cb(&a, lv_anim_path_step);
lv_anim_set_path(&a, &path);
lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready);
lv_anim_start(&a);
#else
@@ -521,13 +532,17 @@ void lv_textarea_set_text(lv_obj_t * ta, const char * txt)
#if LV_USE_ANIMATION
/*Auto hide characters*/
lv_anim_path_t path;
lv_anim_path_init(&path);
lv_anim_path_set_cb(&path, lv_anim_path_step);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, ta);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)pwd_char_hider_anim);
lv_anim_set_time(&a, ext->pwd_show_time);
lv_anim_set_values(&a, 0, 1);
lv_anim_set_path_cb(&a, lv_anim_path_step);
lv_anim_set_path(&a, &path);
lv_anim_set_ready_cb(&a, pwd_char_hider_anim_ready);
lv_anim_start(&a);
#else
@@ -640,6 +655,10 @@ void lv_textarea_set_cursor_pos(lv_obj_t * ta, int16_t pos)
#if LV_USE_ANIMATION
if(ext->cursor.blink_time) {
/*Reset cursor blink animation*/
lv_anim_path_t path;
lv_anim_path_init(&path);
lv_anim_path_set_cb(&path, lv_anim_path_step);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, ta);
@@ -647,8 +666,8 @@ void lv_textarea_set_cursor_pos(lv_obj_t * ta, int16_t pos)
lv_anim_set_time(&a, ext->cursor.blink_time);
lv_anim_set_playback_time(&a, ext->cursor.blink_time);
lv_anim_set_values(&a, 1, 0);
lv_anim_set_path_cb(&a, lv_anim_path_step);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINIT);
lv_anim_set_path(&a, &path);
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
lv_anim_start(&a);
}
#endif
@@ -901,6 +920,10 @@ void lv_textarea_set_cursor_blink_time(lv_obj_t * ta, uint16_t time)
#if LV_USE_ANIMATION
if(ext->cursor.blink_time) {
/*Reset cursor blink animation*/
lv_anim_path_t path;
lv_anim_path_init(&path);
lv_anim_path_set_cb(&path, lv_anim_path_step);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, ta);
@@ -908,7 +931,7 @@ void lv_textarea_set_cursor_blink_time(lv_obj_t * ta, uint16_t time)
lv_anim_set_time(&a, ext->cursor.blink_time);
lv_anim_set_playback_time(&a, ext->cursor.blink_time);
lv_anim_set_values(&a, 1, 0);
lv_anim_set_path_cb(&a, lv_anim_path_step);
lv_anim_set_path(&a, &path);
lv_anim_start(&a);
}
else {
@@ -1351,7 +1374,7 @@ static lv_design_res_t lv_textarea_scrollable_design(lv_obj_t * scrl, const lv_a
lv_draw_rect(&cur_area, clip_area, &cur_dsc);
char letter_buf[8] = {0};
memcpy(letter_buf, &txt[ext->cursor.txt_byte_pos], lv_txt_encoded_size(&txt[ext->cursor.txt_byte_pos]));
lv_memcpy(letter_buf, &txt[ext->cursor.txt_byte_pos], lv_txt_encoded_size(&txt[ext->cursor.txt_byte_pos]));
if(cur_dsc.bg_opa == LV_OPA_COVER) {
lv_style_int_t left = lv_obj_get_style_pad_left(ta, LV_TEXTAREA_PART_CURSOR);
@@ -1637,7 +1660,7 @@ static void pwd_char_hider(lv_obj_t * ta)
char * txt_tmp = lv_mem_buf_get(enc_len * bullet_len + 1);
uint16_t i;
for(i = 0; i < enc_len; i++) {
memcpy(&txt_tmp[i * bullet_len], bullet, bullet_len);
lv_memcpy(&txt_tmp[i * bullet_len], bullet, bullet_len);
}
txt_tmp[i * bullet_len] = '\0';

View File

@@ -78,7 +78,7 @@ typedef struct {
/** Possible text areas tyles. */
enum {
LV_TEXTAREA_PART_BG = LV_PAGE_PART_BG, /**< Text area background style */
LV_TEXTAREA_PART_SCRLBAR = LV_PAGE_PART_SCRLBAR, /**< Scrollbar style */
LV_TEXTAREA_PART_SCRLBAR = LV_PAGE_PART_SCROLLBAR, /**< Scrollbar style */
LV_TEXTAREA_PART_EDGE_FLASH = LV_PAGE_PART_EDGE_FLASH, /**< Edge flash style */
LV_TEXTAREA_PART_CURSOR = _LV_PAGE_PART_VIRTUAL_LAST, /**< Cursor style */
LV_TEXTAREA_PART_PLACEHOLDER, /**< Placeholder style */

View File

@@ -118,7 +118,7 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
lv_page_set_scrl_fit(new_tileview, LV_FIT_TIGHT);
lv_obj_reset_style_list(new_tileview, LV_PAGE_PART_SCRL);
lv_obj_reset_style_list(new_tileview, LV_PAGE_PART_SCROLLABLE);
lv_theme_apply(new_tileview, LV_THEME_TILEVIEW);
}
/*Copy an existing tileview*/
@@ -233,13 +233,11 @@ void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, l
lv_coord_t x_act = lv_obj_get_x(scrl);
lv_coord_t y_act = lv_obj_get_y(scrl);
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_var(&a, scrl);
lv_anim_set_exec_cb(&a, (lv_anim_exec_xcb_t)lv_obj_set_x);
lv_anim_set_time(&a, ext->anim_time);
lv_anim_set_path_cb(&a, lv_anim_path_linear);
if(x_coord != x_act) {

View File

@@ -46,7 +46,7 @@ typedef struct {
/*Parts of the Tileview*/
enum {
LV_TILEVIEW_PART_BG = LV_PAGE_PART_BG,
LV_TILEVIEW_PART_SCRLBAR = LV_PAGE_PART_SCRLBAR,
LV_TILEVIEW_PART_SCRLBAR = LV_PAGE_PART_SCROLLBAR,
LV_TILEVIEW_PART_EDGE_FLASH = LV_PAGE_PART_EDGE_FLASH,
_LV_TILEVIEW_PART_VIRTUAL_LAST = _LV_PAGE_PART_VIRTUAL_LAST,
_LV_TILEVIEW_PART_REAL_LAST = _LV_PAGE_PART_REAL_LAST

View File

@@ -104,7 +104,7 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_add_protect(ext->header, LV_PROTECT_PARENT);
lv_obj_set_parent(ext->header, new_win);
if(ancestor_header_design == NULL) ancestor_header_design = lv_obj_get_design_cb(ext->header);
lv_obj_set_height(ext->header, LV_DPI / 2);
lv_obj_set_height(ext->header, LV_DPX(65));
lv_obj_set_design_cb(ext->header, lv_win_header_design);
lv_obj_set_signal_cb(new_win, lv_win_signal);
@@ -544,9 +544,9 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param)
else if(sign == LV_SIGNAL_GET_STATE_DSC) {
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
lv_get_state_info_t * info = param;
if(info->part == LV_WIN_PART_CONTENT_SCRL) info->result = lv_obj_get_state(lv_page_get_scrl(ext->page),
if(info->part == LV_WIN_PART_CONTENT_SCROLLABLE) info->result = lv_obj_get_state(lv_page_get_scrl(ext->page),
LV_CONT_PART_MAIN);
else if(info->part == LV_WIN_PART_SCRLBAR) info->result = lv_obj_get_state(ext->page, LV_PAGE_PART_SCRLBAR);
else if(info->part == LV_WIN_PART_SCROLLBAR) info->result = lv_obj_get_state(ext->page, LV_PAGE_PART_SCROLLBAR);
else if(info->part == LV_WIN_PART_HEADER) info->result = lv_obj_get_state(ext->header, LV_OBJ_PART_MAIN);
return LV_RES_OK;
}
@@ -616,11 +616,11 @@ static lv_style_list_t * lv_win_get_style(lv_obj_t * win, uint8_t part)
case LV_WIN_PART_HEADER:
style_dsc_p = lv_obj_get_style_list(ext->header, LV_OBJ_PART_MAIN);
break;
case LV_WIN_PART_SCRLBAR:
style_dsc_p = lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCRLBAR);
case LV_WIN_PART_SCROLLBAR:
style_dsc_p = lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCROLLBAR);
break;
case LV_WIN_PART_CONTENT_SCRL:
style_dsc_p = lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCRL);
case LV_WIN_PART_CONTENT_SCROLLABLE:
style_dsc_p = lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCROLLABLE);
break;
default:
style_dsc_p = NULL;

View File

@@ -64,8 +64,8 @@ enum {
LV_WIN_PART_BG = LV_OBJ_PART_MAIN, /**< Window object background style. */
_LV_WIN_PART_VIRTUAL_LAST,
LV_WIN_PART_HEADER = _LV_OBJ_PART_REAL_LAST, /**< Window titlebar background style. */
LV_WIN_PART_CONTENT_SCRL, /**< Window content style. */
LV_WIN_PART_SCRLBAR, /**< Window scrollbar style. */
LV_WIN_PART_CONTENT_SCROLLABLE, /**< Window content style. */
LV_WIN_PART_SCROLLBAR, /**< Window scrollbar style. */
_LV_WIN_PART_REAL_LAST
};

View File

@@ -5,7 +5,7 @@ CC ?= gcc
LVGL_DIR ?= ${shell pwd}/../..
LVGL_DIR_NAME ?= lvgl
WARNINGS ?= -Werror -Wall -Wextra -Wshadow -Wundef -Wmaybe-uninitialized -Wmissing-prototypes -Wno-discarded-qualifiers -Wall -Wextra -Wno-unused-function -Wundef -Wno-error=strict-prototypes -Wpointer-arith -fno-strict-aliasing -Wno-error=cpp -Wuninitialized -Wmaybe-uninitialized -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wno-cast-qual -Wunreachable-code -Wno-switch-default -Wno-switch-enum -Wreturn-type -Wmultichar -Wformat-security -Wno-ignored-qualifiers -Wno-error=pedantic -Wno-sign-compare -Wno-error=missing-prototypes -Wdouble-promotion -Wclobbered -Wdeprecated -Wempty-body -Wtype-limits -Wshift-negative-value -Wstack-usage=1024 -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers -Wuninitialized -Wmaybe-uninitialized -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wpointer-arith -Wno-cast-qual -Wmissing-prototypes -Wunreachable-code -Wno-switch-default -Wswitch-enum -Wreturn-type -Wmultichar -Wno-discarded-qualifiers -Wformat-security -Wno-ignored-qualifiers -Wno-sign-compare
WARNINGS ?= -Werror -Wall -Wextra -Wshadow -Wundef -Wmaybe-uninitialized -Wmissing-prototypes -Wno-discarded-qualifiers -Wall -Wextra -Wno-unused-function -Wundef -Wno-error=strict-prototypes -Wpointer-arith -fno-strict-aliasing -Wno-error=cpp -Wuninitialized -Wmaybe-uninitialized -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wno-cast-qual -Wunreachable-code -Wno-switch-default -Wno-switch-enum -Wreturn-type -Wmultichar -Wformat-security -Wno-ignored-qualifiers -Wno-error=pedantic -Wno-sign-compare -Wno-error=missing-prototypes -Wdouble-promotion -Wclobbered -Wdeprecated -Wempty-body -Wtype-limits -Wshift-negative-value -Wstack-usage=2048 -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers -Wuninitialized -Wmaybe-uninitialized -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wpointer-arith -Wno-cast-qual -Wmissing-prototypes -Wunreachable-code -Wno-switch-default -Wswitch-enum -Wreturn-type -Wmultichar -Wno-discarded-qualifiers -Wformat-security -Wno-ignored-qualifiers -Wno-sign-compare
OPTIMIZATION ?= -O3 -g0

View File

@@ -204,7 +204,7 @@ all_obj_all_features = {
"LV_MEM_SIZE":32*1024,
"LV_HOR_RES_MAX":480,
"LV_VER_RES_MAX":320,
"LV_COLOR_DEPTH":16,
"LV_COLOR_DEPTH":32,
"LV_USE_GROUP":1,
"LV_USE_ANIMATION":1,
"LV_ANTIALIAS":1,
@@ -281,6 +281,7 @@ advanced_features = {
"LV_HOR_RES_MAX":800,
"LV_VER_RES_MAX":480,
"LV_COLOR_DEPTH":16,
"LV_COLOR_16_SWAP":1,
"LV_COLOR_SCREEN_TRANSP":1,
"LV_USE_GROUP":1,
"LV_USE_ANIMATION":1,

View File

@@ -85,7 +85,7 @@ static void empty_style(void)
found = lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'opa' property");
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_INV, found, "Get a 'ptr' property");
found = lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
@@ -120,7 +120,7 @@ static void add_remove_read_prop(void)
found = lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'opa' property");
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'ptr' property");
found = lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
@@ -129,7 +129,7 @@ static void add_remove_read_prop(void)
lv_test_print("Set properties and read back the values");
_lv_style_set_int(&style, LV_STYLE_TEXT_LINE_SPACE, 5);
_lv_style_set_opa(&style, LV_STYLE_BG_OPA, LV_OPA_50);
_lv_style_set_data_ptr(&style, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL);
_lv_style_set_ptr(&style, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL);
_lv_style_set_color(&style, LV_STYLE_BG_COLOR, LV_COLOR_RED);
found = lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
@@ -140,7 +140,7 @@ static void add_remove_read_prop(void)
lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'opa' property");
lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'opa' property");
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'ptr' property");
lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL, ptr, "Get the value of a 'ptr' property");
@@ -156,7 +156,7 @@ static void add_remove_read_prop(void)
found = lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'opa' property from a reseted style");
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'ptr' property from a reseted style");
found = lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
@@ -194,7 +194,7 @@ static void cascade(void)
_lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE, 5);
_lv_style_set_opa(&style_first, LV_STYLE_BG_OPA, LV_OPA_50);
_lv_style_set_data_ptr(&style_first, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL);
_lv_style_set_ptr(&style_first, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL);
_lv_style_set_color(&style_first, LV_STYLE_BG_COLOR, LV_COLOR_RED);
found = lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
@@ -205,7 +205,7 @@ static void cascade(void)
lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property");
lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'opa' property");
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'ptr' property");
lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL, ptr, "Get the value of a 'ptr' property");
@@ -217,7 +217,7 @@ static void cascade(void)
_lv_style_set_int(&style_second, LV_STYLE_TEXT_LINE_SPACE, 10);
_lv_style_set_opa(&style_second, LV_STYLE_BG_OPA, LV_OPA_60);
_lv_style_set_data_ptr(&style_second, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 1);
_lv_style_set_ptr(&style_second, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 1);
_lv_style_set_color(&style_second, LV_STYLE_BG_COLOR, LV_COLOR_BLUE);
found = lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
@@ -228,7 +228,7 @@ static void cascade(void)
lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'opa' property");
lv_test_assert_int_eq(LV_OPA_60, opa, "Get the value of an overwritten 'opa' property");
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'ptr' property");
lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL + 1, ptr, "Get the value of an overwritten 'ptr' property");
@@ -240,7 +240,7 @@ static void cascade(void)
lv_test_print("Overwrite the properties with the local style");
lv_style_list_set_local_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, 20);
lv_style_list_set_local_opa(&style_list, LV_STYLE_BG_OPA, LV_OPA_70);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 2);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 2);
lv_style_list_set_local_color(&style_list, LV_STYLE_BG_COLOR, LV_COLOR_LIME);
found = lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
@@ -251,7 +251,7 @@ static void cascade(void)
lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'opa' property");
lv_test_assert_int_eq(LV_OPA_70, opa, "Get the value of a local 'opa' property");
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'ptr' property");
lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL + 2, ptr, "Get the value of a local'ptr' property");
@@ -470,17 +470,17 @@ static void mem_leak(void)
lv_test_print("Use local style");
lv_mem_monitor(&mon_start);
for(i = 0; i < 100; i++) {
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL);
lv_style_list_reset(&style_list);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_reset(&style_list);
}
@@ -559,7 +559,7 @@ static void mem_leak(void)
for(i = 0; i < 100; i++) {
if(i % 2 == 0) {
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
}
_lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
@@ -571,7 +571,7 @@ static void mem_leak(void)
if(i % 4 == 0) {
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
}
lv_style_list_remove_style(&style_list, &style1);
@@ -586,7 +586,7 @@ static void mem_leak(void)
lv_style_list_add_style(&style_list, &style2);
if(i % 8 == 0) {
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
}
lv_style_list_add_style(&style_list, &style2);
@@ -604,14 +604,14 @@ static void mem_leak(void)
_lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 12);
_lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 23);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_add_style(&style_list, &style3);
lv_style_list_add_style(&style_list, &style2);