1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

merge dev-7.0 into feat-new-style

This commit is contained in:
Gabor Kiss-Vamosi 2019-12-22 22:56:13 +01:00
commit 07bc58aa9c
39 changed files with 437 additions and 116 deletions

View File

@ -13,7 +13,7 @@ extern "C" {
/*********************
* INCLUDES
*********************/
#include "lvgl/lvgl.h"
#include "../lvgl.h"
/*********************
* DEFINES

View File

@ -442,7 +442,7 @@ lv_group_user_data_t * lv_group_get_user_data(lv_group_t * group)
*/
lv_group_style_mod_cb_t lv_group_get_style_mod_cb(const lv_group_t * group)
{
if(!group) return false;
if(!group) return NULL;
return group->style_mod_cb;
}
@ -453,7 +453,7 @@ lv_group_style_mod_cb_t lv_group_get_style_mod_cb(const lv_group_t * group)
*/
lv_group_style_mod_cb_t lv_group_get_style_mod_edit_cb(const lv_group_t * group)
{
if(!group) return false;
if(!group) return NULL;
return group->style_mod_edit_cb;
}
@ -464,7 +464,7 @@ lv_group_style_mod_cb_t lv_group_get_style_mod_edit_cb(const lv_group_t * group)
*/
lv_group_focus_cb_t lv_group_get_focus_cb(const lv_group_t * group)
{
if(!group) return false;
if(!group) return NULL;
return group->focus_cb;
}

View File

@ -39,7 +39,6 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data);
static void indev_proc_press(lv_indev_proc_t * proc);
static void indev_proc_release(lv_indev_proc_t * proc);
static void indev_proc_reset_query_handler(lv_indev_t * indev);
static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj);
static void indev_drag(lv_indev_proc_t * proc);
static void indev_drag_throw(lv_indev_proc_t * proc);
static lv_obj_t * get_dragged_obj(lv_obj_t * obj);
@ -1035,25 +1034,7 @@ lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t *point)
lv_obj_t * found_p = NULL;
/*If the point is on this object check its children too*/
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
lv_area_t ext_area;
ext_area.x1 = obj->coords.x1 - obj->ext_click_pad_hor;
ext_area.x2 = obj->coords.x2 + obj->ext_click_pad_hor;
ext_area.y1 = obj->coords.y1 - obj->ext_click_pad_ver;
ext_area.y2 = obj->coords.y2 + obj->ext_click_pad_ver;
if(lv_area_is_point_on(&ext_area, point)) {
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
lv_area_t ext_area;
ext_area.x1 = obj->coords.x1 - obj->ext_click_pad.x1;
ext_area.x2 = obj->coords.x2 + obj->ext_click_pad.x2;
ext_area.y1 = obj->coords.y1 - obj->ext_click_pad.y1;
ext_area.y2 = obj->coords.y2 + obj->ext_click_pad.y2;
if(lv_area_is_point_on(&ext_area, point)) {
#else
if(lv_area_is_point_on(&obj->coords, point)) {
#endif
if(lv_obj_hittest(obj, point)) {
lv_obj_t * i;
LV_LL_READ(obj->child_ll, i)

View File

@ -123,6 +123,18 @@ void lv_init(void)
LV_LOG_INFO("lv_init ready");
}
#if LV_ENABLE_GC || !LV_MEM_CUSTOM
void lv_deinit(void)
{
lv_gc_clear_roots();
lv_log_register_print_cb(NULL);
lv_disp_set_default(NULL);
lv_mem_deinit();
lv_initialized = false;
LV_LOG_INFO("lv_deinit done");
}
#endif
/*--------------------
* Create and delete
*-------------------*/
@ -201,6 +213,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
new_obj->group_p = NULL;
#endif
/*Set attributes*/
new_obj->adv_hittest = 0;
new_obj->click = 0;
new_obj->drag = 0;
new_obj->drag_throw = 0;
@ -1325,6 +1338,17 @@ void lv_obj_set_hidden(lv_obj_t * obj, bool en)
if(par) par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj);
}
/**
* Set whether advanced hit-testing is enabled on an object
* @param obj pointer to an object
* @param en true: advanced hit-testing is enabled
*/
void lv_obj_set_adv_hittest(lv_obj_t * obj, bool en) {
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
obj->adv_hittest = en == false ? 0 : 1;
}
/**
* Enable or disable the clicking of an object
* @param obj pointer to an object
@ -2355,6 +2379,18 @@ bool lv_obj_get_hidden(const lv_obj_t * obj)
return obj->hidden == 0 ? false : true;
}
/**
* Get whether advanced hit-testing is enabled on an object
* @param obj pointer to an object
* @return true: advanced hit-testing is enabled
*/
bool lv_obj_get_adv_hittest(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
return obj->adv_hittest == 0 ? false : true;
}
/**
* Get the click enable attribute of an object
* @param obj pointer to an object
@ -2645,6 +2681,45 @@ bool lv_obj_is_focused(const lv_obj_t * obj)
* OTHER FUNCTIONS
*------------------*/
/**
* Hit-test an object given a particular point in screen space.
* @param obj object to hit-test
* @param point screen-space point
* @return true if the object is considered under the point
*/
bool lv_obj_hittest(lv_obj_t * obj, lv_point_t * point) {
#if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
lv_area_t ext_area;
ext_area.x1 = obj->coords.x1 - obj->ext_click_pad_hor;
ext_area.x2 = obj->coords.x2 + obj->ext_click_pad_hor;
ext_area.y1 = obj->coords.y1 - obj->ext_click_pad_ver;
ext_area.y2 = obj->coords.y2 + obj->ext_click_pad_ver;
if(!lv_area_is_point_on(&ext_area, point, 0)) {
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL
lv_area_t ext_area;
ext_area.x1 = obj->coords.x1 - obj->ext_click_pad.x1;
ext_area.x2 = obj->coords.x2 + obj->ext_click_pad.x2;
ext_area.y1 = obj->coords.y1 - obj->ext_click_pad.y1;
ext_area.y2 = obj->coords.y2 + obj->ext_click_pad.y2;
if(!lv_area_is_point_on(&ext_area, point, 0)) {
#else
if(!lv_area_is_point_on(&obj->coords, point, 0)) {
#endif
return false;
}
if(obj->adv_hittest) {
lv_hit_test_info_t hit_info;
hit_info.point = point;
hit_info.result = true;
obj->signal_cb(obj, LV_SIGNAL_HIT_TEST, &hit_info);
if(!hit_info.result)
return false;
}
return true;
}
/**
* Used in the signal callback to handle `LV_SIGNAL_GET_TYPE` signal
* @param obj pointer to an object

View File

@ -131,6 +131,7 @@ enum {
LV_SIGNAL_GET_STATE, /**<Get the state of the object*/
/*Input device related*/
LV_SIGNAL_HIT_TEST, /**< Advanced hit-testing */
LV_SIGNAL_PRESSED, /**< The object has been pressed*/
LV_SIGNAL_PRESSING, /**< The object is being pressed (called continuously while pressing)*/
LV_SIGNAL_PRESS_LOST, /**< User is still pressing but slid cursor/finger off of the object */
@ -252,7 +253,8 @@ typedef struct _lv_obj_t
uint8_t parent_event : 1; /**< 1: Send the object's events to the parent too. */
lv_drag_dir_t drag_dir : 3; /**< Which directions the object can be dragged in */
lv_bidi_dir_t base_dir : 2; /**< Base direction of texts related to this object */
uint8_t reserved : 3; /**< Reserved for future use*/
uint8_t adv_hittest : 1; /**< 1: Use advanced hit-testing (slower) */
uint8_t reserved : 2; /**< Reserved for future use*/
uint8_t protect; /**< Automatically happening actions can be prevented. 'OR'ed values from
`lv_protect_t`*/
uint8_t state;
@ -283,6 +285,12 @@ typedef struct
... [x]: "lv_obj" */
} lv_obj_type_t;
typedef struct _lv_hit_test_info_t
{
lv_point_t *point;
bool result;
} lv_hit_test_info_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
@ -292,6 +300,15 @@ typedef struct
*/
void lv_init(void);
/**
* Deinit the 'lv' library
* Currently only implemented when not using custorm allocators, or GC is enabled.
*/
#if LV_ENABLE_GC || !LV_MEM_CUSTOM
void lv_deinit(void);
#endif
/*--------------------
* Create and delete
*-------------------*/
@ -499,6 +516,13 @@ void lv_obj_report_style_mod(lv_style_t * style);
*/
void lv_obj_set_hidden(lv_obj_t * obj, bool en);
/**
* Set whether advanced hit-testing is enabled on an object
* @param obj pointer to an object
* @param en true: advanced hit-testing is enabled
*/
void lv_obj_set_adv_hittest(lv_obj_t * obj, bool en);
/**
* Enable or disable the clicking of an object
* @param obj pointer to an object
@ -856,6 +880,13 @@ void * lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t type, lv_style_propert
*/
bool lv_obj_get_hidden(const lv_obj_t * obj);
/**
* Get whether advanced hit-testing is enabled on an object
* @param obj pointer to an object
* @return true: advanced hit-testing is enabled
*/
bool lv_obj_get_adv_hittest(const lv_obj_t * obj);
/**
* Get the click enable attribute of an object
* @param obj pointer to an object
@ -964,6 +995,8 @@ lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj);
* Other get
*-----------------*/
bool lv_obj_hittest(lv_obj_t * obj, lv_point_t * point);
/**
* Get the ext pointer
* @param obj pointer to an object

View File

@ -73,6 +73,10 @@ void lv_refr_init(void)
*/
void lv_refr_now(lv_disp_t * disp)
{
#if LV_USE_ANIMATION
lv_anim_refr_now();
#endif
if(disp) {
lv_disp_refr_task(disp->refr_task);
} else {

View File

@ -141,6 +141,18 @@ typedef struct {
uint16_t reserved :7;
}lv_style_t;
typedef struct {
lv_style_t local;
lv_style_t ** classes;
uint8_t class_cnt;
#if LV_STYLE_CACHING
lv_style_cache_t cache;
#endif
}lv_style_dsc_t;
typedef int16_t lv_style_value_t;
typedef struct {
const lv_font_t * font;
lv_color_t bg_color;
@ -163,18 +175,6 @@ typedef struct {
lv_opa_t img_opa;
}lv_style_cache_t;
typedef struct {
lv_style_t local;
lv_style_t ** classes;
uint8_t class_cnt;
#if LV_STYLE_CACHING
lv_style_cache_t cache;
#endif
}lv_style_dsc_t;
typedef int16_t lv_style_value_t;
#if LV_USE_ANIMATION
/** Data structure for style animations. */
typedef struct

View File

@ -512,11 +512,11 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc)
if(xs_fract < 0x70) {
xn = - 1;
if(dsc->tmp.xs_int + xn < 0) return false;
if(dsc->tmp.xs_int + xn < 0) xn = 0;
xr = xs_fract + 0x80;
} else if(xs_fract > 0x90) {
xn = 1;
if(dsc->tmp.xs_int + xn >= dsc->cfg.src_w) return false;
if(dsc->tmp.xs_int + xn >= dsc->cfg.src_w) xn = 0;
xr = (0xFF - xs_fract) + 0x80;
} else {
xn = 0;
@ -528,12 +528,12 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc)
if(ys_fract < 0x70) {
yn = - 1;
if(dsc->tmp.ys_int + yn < 0) return false;
if(dsc->tmp.ys_int + yn < 0) yn = 0;
yr = ys_fract + 0x80;
} else if(ys_fract > 0x90) {
yn = 1;
if(dsc->tmp.ys_int + yn >= dsc->cfg.src_h) return false;
if(dsc->tmp.ys_int + yn >= dsc->cfg.src_h) yn = 0;
yr = (0xFF - ys_fract) + 0x80;
} else {

View File

@ -85,7 +85,7 @@ lv_img_cache_entry_t * lv_img_cache_open(const void * src, lv_color_t color)
bool match = false;
lv_img_src_t src_type = lv_img_src_get_type(cache[i].dec_dsc.src);
if(src_type == LV_IMG_SRC_VARIABLE) {
if(cache[i].dec_dsc.src == src) match = true;
if(cache[i].dec_dsc.src == src && cache[i].dec_dsc.color.full == color.full) match = true;
} else if(src_type == LV_IMG_SRC_FILE) {
if(strcmp(cache[i].dec_dsc.src, src) == 0) match = true;
}

View File

@ -172,6 +172,17 @@ uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_va
return time;
}
/**
* Manually refresh the state of the animations.
* Useful to make the animations running in a blocking process where
* `lv_task_handler` can't run for a while.
* Shouldn't be used directly because it is called in `lv_refr_now()`.
*/
void lv_anim_refr_now(void)
{
anim_task(NULL);
}
/**
* Calculate the current value of an animation applying linear characteristic
* @param a pointer to an animation

View File

@ -268,6 +268,14 @@ uint16_t lv_anim_count_running(void);
*/
uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end);
/**
* Manually refresh the state of the animations.
* Useful to make the animations running in a blocking process where
* `lv_task_handler` can't run for a while.
* Shouldn't be used directly because it is called in `lv_refr_now()`.
*/
void lv_anim_refr_now(void);
/**
* Calculate the current value of an animation applying linear characteristic
* @param a pointer to an animation

View File

@ -27,6 +27,8 @@
* STATIC PROTOTYPES
**********************/
static bool lv_point_within_circle(const lv_area_t * area, const lv_point_t * p);
/**********************
* STATIC VARIABLES
**********************/
@ -148,15 +150,62 @@ void lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t *
* @param p_p pointer to a point
* @return false:the point is out of the area
*/
bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p)
bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p, lv_coord_t radius)
{
bool is_on = false;
/*First check the basic area*/
bool is_on_rect = false;
if((p_p->x >= a_p->x1 && p_p->x <= a_p->x2) && ((p_p->y >= a_p->y1 && p_p->y <= a_p->y2))) {
is_on = true;
is_on_rect = true;
}
return is_on;
if(!is_on_rect)
return false;
/*Now handle potential rounded rectangles*/
if(radius <= 0) {
/*No radius, it is within the rectangle*/
return true;
}
lv_coord_t max_radius = LV_MATH_MIN(lv_area_get_width(a_p) / 2, lv_area_get_height(a_p) / 2);
if(radius > max_radius)
radius = max_radius;
/*Check if it's in one of the corners*/
lv_area_t corner_area;
/*Top left*/
corner_area.x1 = a_p->x1;
corner_area.x2 = a_p->x1 + radius;
corner_area.y1 = a_p->y1;
corner_area.y2 = a_p->y1 + radius;
if(lv_area_is_point_on(&corner_area, p_p, 0)) {
corner_area.x2 += radius;
corner_area.y2 += radius;
return lv_point_within_circle(&corner_area, p_p);
}
/*Bottom left*/
corner_area.y1 = a_p->y2 - radius;
corner_area.y2 = a_p->y2;
if(lv_area_is_point_on(&corner_area, p_p, 0)) {
corner_area.x2 += radius;
corner_area.y1 -= radius;
return lv_point_within_circle(&corner_area, p_p);
}
/*Bottom right*/
corner_area.x1 = a_p->x2 - radius;
corner_area.x2 = a_p->x2;
if(lv_area_is_point_on(&corner_area, p_p, 0)) {
corner_area.x1 -= radius;
corner_area.y1 -= radius;
return lv_point_within_circle(&corner_area, p_p);
}
/*Top right*/
corner_area.y1 = a_p->y1;
corner_area.y2 = a_p->y1 + radius;
if(lv_area_is_point_on(&corner_area, p_p, 0)) {
corner_area.x1 -= radius;
corner_area.y2 += radius;
return lv_point_within_circle(&corner_area, p_p);
}
/*Not within corners*/
return false;
}
/**
@ -208,3 +257,24 @@ void lv_area_increment(lv_area_t * a_p, const lv_coord_t amount)
/**********************
* STATIC FUNCTIONS
**********************/
static bool lv_point_within_circle(const lv_area_t * area, const lv_point_t * p)
{
lv_coord_t r = (area->x2 - area->x1) / 2;
/* Circle center */
lv_coord_t cx = area->x1 + r;
lv_coord_t cy = area->y1 + r;
/*Simplify the code by moving everything to (0, 0) */
lv_coord_t px = p->x - cx;
lv_coord_t py = p->y - cy;
int32_t r_sqrd = r*r;
int32_t dist = (px*px) + (py*py);
if(dist <= r_sqrd)
return true;
else
return false;
}

View File

@ -148,9 +148,10 @@ void lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t *
* Check if a point is on an area
* @param a_p pointer to an area
* @param p_p pointer to a point
* @param radius radius of area (e.g. for rounded rectangle)
* @return false:the point is out of the area
*/
bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p);
bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p, lv_coord_t radius);
/**
* Check if two area has common parts

View File

@ -104,9 +104,9 @@ enum {
# define LV_COLOR_GET_B1(c) (c).ch.blue
# define LV_COLOR_GET_A1(c) 1
# define LV_COLOR_SET_R8(c, v) (c).ch.red = (uint8_t)((v) & 0x7);
# define LV_COLOR_SET_G8(c, v) (c).ch.green = (uint8_t)((v) & 0x7);
# define LV_COLOR_SET_B8(c, v) (c).ch.blue = (uint8_t)((v) & 0x3);
# define LV_COLOR_SET_R8(c, v) (c).ch.red = (uint8_t)(v) & 0x7U;
# define LV_COLOR_SET_G8(c, v) (c).ch.green = (uint8_t)(v) & 0x7U;
# define LV_COLOR_SET_B8(c, v) (c).ch.blue = (uint8_t)(v) & 0x3U;
# define LV_COLOR_SET_A8(c, v) do {} while(0)
# define LV_COLOR_GET_R8(c) (c).ch.red
@ -114,10 +114,10 @@ enum {
# define LV_COLOR_GET_B8(c) (c).ch.blue
# define LV_COLOR_GET_A8(c) 0xFF
# define LV_COLOR_SET_R16(c, v) (c).ch.red = (uint8_t)(((uint8_t)(v)) & 0x1F);
# define LV_COLOR_SET_G16(c, v) (c).ch.green = (uint8_t)((v) & 0x3F);
# define LV_COLOR_SET_R16(c, v) (c).ch.red = (uint8_t)(v) & 0x1FU;
# define LV_COLOR_SET_G16(c, v) (c).ch.green = (uint8_t)(v) & 0x3FU;
# define LV_COLOR_SET_G16_SWAP(c, v) {(c).ch.green_h = (uint8_t)(((v) >> 3) & 0x7); (c).ch.green_l = (uint8_t)((v) & 0x7);}
# define LV_COLOR_SET_B16(c, v) (c).ch.blue = (uint8_t)((v) & 0x1F);
# define LV_COLOR_SET_B16(c, v) (c).ch.blue = (uint8_t)(v) & 0x1FU;
# define LV_COLOR_SET_A16(c, v) do {} while(0)
# define LV_COLOR_GET_R16(c) (c).ch.red
@ -532,14 +532,14 @@ static inline uint8_t lv_color_brightness(lv_color_t color)
/* The most simple macro to create a color from R,G and B values */
#if LV_COLOR_DEPTH == 1
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){.full = (b8 >> 7 | g8 >> 7 | r8 >> 7)})
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){.full = ((b8 >> 7) | (g8 >> 7) | (r8 >> 7))})
#elif LV_COLOR_DEPTH == 8
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint8_t)(b8 >> 6), (uint8_t)(g8 >> 5), (uint8_t)(r8 >> 5)}})
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(b8 >> 6) & 0x3U, (g8 >> 5) & 0x7U, (r8 >> 5) & 0x7U}})
#elif LV_COLOR_DEPTH == 16
#if LV_COLOR_16_SWAP == 0
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(uint16_t)(b8 >> 3), (uint16_t)(g8 >> 2), (uint16_t)(r8 >> 3)}})
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(b8 >> 3) & 0x1FU, (g8 >> 2) & 0x3FU, (r8 >> 3) & 0x1FU}})
#else
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{((uint16_t)(g8 >> 5), (uint16_t)(r8 >> 3), (uint16_t)(b8 >> 3), (uint16_t)((g8 >> 2) & 0x7)}})
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{(g8 >> 5) & 0x7U, (r8 >> 3) & 0x1FU, (b8 >> 3) & 0x1FU, (g8 >> 2) & 0x7U}})
#endif
#elif LV_COLOR_DEPTH == 32
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/

View File

@ -8,6 +8,11 @@
*********************/
#include "lv_gc.h"
#include "string.h"
#if defined(LV_GC_INCLUDE)
#include LV_GC_INCLUDE
#endif /* LV_ENABLE_GC */
/*********************
* DEFINES
@ -35,6 +40,12 @@ LV_ROOTS
* GLOBAL FUNCTIONS
**********************/
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)));
LV_ITERATE_ROOTS(LV_CLEAR_ROOT)
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -31,21 +31,22 @@ extern "C" {
* DEFINES
*********************/
#define LV_GC_ROOTS(prefix) \
prefix lv_ll_t _lv_task_ll; /*Linked list to store the lv_tasks*/ \
prefix lv_ll_t _lv_disp_ll; /*Linked list of screens*/ \
prefix lv_ll_t _lv_indev_ll; /*Linked list of screens*/ \
prefix lv_ll_t _lv_drv_ll; \
prefix lv_ll_t _lv_file_ll; \
prefix lv_ll_t _lv_anim_ll; \
prefix lv_ll_t _lv_group_ll; \
prefix lv_ll_t _lv_img_defoder_ll; \
prefix lv_img_cache_entry_t * _lv_img_cache_array; \
prefix void * _lv_task_act; \
prefix lv_mem_buf_t _lv_mem_buf[LV_MEM_BUF_MAX_NUM]; \
#define LV_NO_PREFIX
#define LV_ROOTS LV_GC_ROOTS(LV_NO_PREFIX)
#define LV_ITERATE_ROOTS(f) \
f(lv_ll_t, _lv_task_ll) /*Linked list to store the lv_tasks*/ \
f(lv_ll_t, _lv_disp_ll) /*Linked list of screens*/ \
f(lv_ll_t, _lv_indev_ll) /*Linked list of screens*/ \
f(lv_ll_t, _lv_drv_ll) \
f(lv_ll_t, _lv_file_ll) \
f(lv_ll_t, _lv_anim_ll) \
f(lv_ll_t, _lv_group_ll) \
f(lv_ll_t, _lv_img_defoder_ll) \
f(lv_img_cache_entry_t*, _lv_img_cache_array) \
f(void*, _lv_task_act) \
f(lv_mem_buf_t, _lv_mem_buf[LV_MEM_BUF_MAX_NUM]) \
#define LV_DEFINE_ROOT(root_type, root_name) root_type root_name;
#define LV_ROOTS LV_ITERATE_ROOTS(LV_DEFINE_ROOT)
#if LV_ENABLE_GC == 1
#if LV_MEM_CUSTOM != 1
@ -53,7 +54,8 @@ extern "C" {
#endif /* LV_MEM_CUSTOM */
#else /* LV_ENABLE_GC */
#define LV_GC_ROOT(x) x
LV_GC_ROOTS(extern)
#define LV_EXTERN_ROOT(root_type, root_name) extern root_type root_name;
LV_ITERATE_ROOTS(LV_EXTERN_ROOT)
#endif /* LV_ENABLE_GC */
/**********************
@ -64,6 +66,8 @@ LV_GC_ROOTS(extern)
* GLOBAL PROTOTYPES
**********************/
void lv_gc_clear_roots(void);
/**********************
* MACROS
**********************/

View File

@ -136,7 +136,6 @@ void * lv_ll_ins_tail(lv_ll_t * ll_p)
lv_ll_node_t * n_new;
n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE);
if(n_new == NULL) return NULL;
if(n_new != NULL) {
node_set_next(ll_p, n_new, NULL); /*No next after the new tail*/

View File

@ -103,6 +103,21 @@ void lv_mem_init(void)
#endif
}
/**
* Clean up the memory buffer which frees all the allocated memories.
* @note It work only if `LV_MEM_CUSTOM == 0`
*/
void lv_mem_deinit(void)
{
#if LV_MEM_CUSTOM == 0
memset(work_mem, 0x00, (LV_MEM_SIZE / sizeof(MEM_UNIT)) * sizeof(MEM_UNIT));
lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem;
full->header.s.used = 0;
/*The total mem size id reduced by the first header and the close patterns */
full->header.s.d_size = LV_MEM_SIZE - sizeof(lv_mem_header_t);
#endif
}
/**
* Allocate a memory dynamically
* @param size size of the memory to allocate in bytes
@ -527,11 +542,11 @@ static void ent_trunc(lv_mem_ent_t * e, size_t size)
uint8_t * e_data = &e->first_data;
lv_mem_ent_t * after_new_e = (lv_mem_ent_t *)&e_data[size];
after_new_e->header.s.used = 0;
after_new_e->header.s.d_size = e->header.s.d_size - size - sizeof(lv_mem_header_t);
after_new_e->header.s.d_size = (uint32_t)e->header.s.d_size - size - sizeof(lv_mem_header_t);
}
/* Set the new size for the original entry */
e->header.s.d_size = size;
e->header.s.d_size = (uint32_t)size;
}
#endif

View File

@ -65,6 +65,12 @@ typedef struct {
*/
void lv_mem_init(void);
/**
* Clean up the memory buffer which frees all the allocated memories.
* @note It work only if `LV_MEM_CUSTOM == 0`
*/
void lv_mem_deinit(void);
/**
* Allocate a memory dynamically
* @param size size of the memory to allocate in bytes

View File

@ -200,8 +200,12 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
letter_w = lv_font_get_glyph_width(font, letter, letter_next);
cur_w += letter_w;
if(letter_w > 0) {
cur_w += letter_space;
}
/* Test if this character fits within max_width */
if(break_index == NO_BREAK_FOUND && cur_w > max_width) {
if(break_index == NO_BREAK_FOUND && (cur_w - letter_space) > max_width) {
break_index = i;
break_letter_count = word_len - 1;
/* break_index is now pointing at the character that doesn't fit */
@ -219,9 +223,6 @@ static uint16_t lv_txt_get_next_word(const char * txt, const lv_font_t * font,
/* Update the output width */
if( word_w_ptr != NULL && break_index == NO_BREAK_FOUND ) *word_w_ptr = cur_w;
if(letter_w > 0) {
cur_w += letter_space;
}
i = i_next;
i_next = i_next_next;

View File

@ -17,8 +17,8 @@ extern "C" {
/*********************
* DEFINES
*********************/
/* Check windows*/
#ifdef __WIN64
// Check windows
#ifdef _WIN64
#define LV_ARCH_64
#endif

View File

@ -203,8 +203,8 @@ void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
ext->max_value = max;
ext->min_value = min;
if(lv_bar_get_type(bar) != LV_BAR_TYPE_CUSTOM)
ext->start_value = min;
if(lv_bar_get_type(bar) != LV_BAR_TYPE_CUSTOM)
ext->start_value = min;
if(ext->cur_value > max) {
ext->cur_value = max;
@ -539,7 +539,7 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area, lv_design_mo
ext->indic_area.x2 = zero;
}
} else {
lv_coord_t increment = (anim_start_value * indicw) / range;
lv_coord_t increment = ((anim_start_value-ext->min_value) * indicw) / range;
ext->indic_area.x1 += increment;
ext->indic_area.x2 += increment;
}
@ -557,7 +557,7 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area, lv_design_mo
ext->indic_area.y1 = zero;
}
} else {
lv_coord_t increment = (anim_start_value * objh) / range;
lv_coord_t increment = ((anim_start_value-ext->min_value) * objh) / range;
ext->indic_area.y1 += increment;
ext->indic_area.y2 += increment;
}

View File

@ -1060,7 +1060,7 @@ static uint16_t get_button_from_point(lv_obj_t * btnm, lv_point_t * p)
btn_area.y1 += btnm_cords.y1;
btn_area.x2 += btnm_cords.x1;
btn_area.y2 += btnm_cords.y1;
if(lv_area_is_point_on(&btn_area, p) != false) {
if(lv_area_is_point_on(&btn_area, p, 0) != false) {
break;
}
}

View File

@ -508,7 +508,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
lv_indev_get_point(indev, &p);
/*If the header is pressed mark an arrow as pressed*/
if(lv_area_is_point_on(&header_area, &p)) {
if(lv_area_is_point_on(&header_area, &p, 0)) {
if(p.x < header_area.x1 + lv_area_get_width(&header_area) / 2) {
if(ext->btn_pressing != -1) lv_obj_invalidate(calendar);
ext->btn_pressing = -1;
@ -605,7 +605,7 @@ static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touche
days_area.y1 =
calendar->coords.y1 + get_header_height(calendar) + get_day_names_height(calendar) - style_bg->body.padding.top;
if(lv_area_is_point_on(&days_area, touched_point)) {
if(lv_area_is_point_on(&days_area, touched_point, 0)) {
lv_coord_t w = (days_area.x2 - days_area.x1 + 1) / 7;
lv_coord_t h = (days_area.y2 - days_area.y1 + 1) / 6;
uint8_t x_pos = 0;

View File

@ -188,8 +188,6 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color)
lv_coord_t def = LV_CHART_POINT_DEF;
if(ser == NULL) return NULL;
ser->color = color;
ser->points = lv_mem_alloc(sizeof(lv_coord_t) * ext->point_cnt);
LV_ASSERT_MEM(ser->points);
@ -933,7 +931,6 @@ static void lv_chart_draw_points(lv_obj_t * chart, const lv_area_t * mask)
lv_style_copy(&style_point, &lv_style_plain);
style_point.body.border.width = 0;
style_point.body.radius = LV_RADIUS_CIRCLE;
style_point.body.opa = ext->series.opa;
style_point.body.radius = ext->series.width;

View File

@ -57,6 +57,7 @@
**********************/
static lv_design_res_t lv_cpicker_design(lv_obj_t * cpicker, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * param);
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, lv_opa_t opa_scale);
static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask, lv_opa_t opa_scale);
@ -889,11 +890,33 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
res = lv_event_send(cpicker, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res;
}
} else if(sign == LV_SIGNAL_HIT_TEST) {
lv_hit_test_info_t *info = param;
info->result = lv_cpicker_hit(cpicker, info->point);
}
return res;
}
static bool lv_cpicker_hit(lv_obj_t * cpicker, const lv_point_t * p)
{
lv_cpicker_ext_t * ext = (lv_cpicker_ext_t *)lv_obj_get_ext_attr(cpicker);
if(ext->type != LV_CPICKER_TYPE_DISC || ext->preview)
return true;
const lv_style_t * style_main = lv_cpicker_get_style(cpicker, LV_CPICKER_STYLE_MAIN);
lv_area_t area_mid;
lv_area_copy(&area_mid, &cpicker->coords);
area_mid.x1 += style_main->line.width;
area_mid.y1 += style_main->line.width;
area_mid.x2 -= style_main->line.width;
area_mid.y2 -= style_main->line.width;
if(lv_area_is_point_on(&area_mid, p, LV_RADIUS_CIRCLE))
return false;
return true;
}
static void next_color_mode(lv_obj_t * cpicker)
{
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);

View File

@ -375,6 +375,20 @@ uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist)
return ext->sel_opt_id;
}
/**
* Get the total number of options
* @param ddlist pointer to drop down list object
* @return the total number of options in the list
*/
uint16_t lv_ddlist_get_option_cnt(const lv_obj_t * ddlist)
{
LV_ASSERT_OBJ(ddlist, LV_OBJX_NAME);
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->option_cnt;
}
/**
* Get the current selected option as a string
* @param ddlist pointer to ddlist object

View File

@ -176,6 +176,13 @@ const char * lv_ddlist_get_options(const lv_obj_t * ddlist);
*/
uint16_t lv_ddlist_get_selected(const lv_obj_t * ddlist);
/**
* Get the total number of options
* @param ddlist pointer to drop down list object
* @return the total number of options in the list
*/
uint16_t lv_ddlist_get_option_cnt(const lv_obj_t * ddlist);
/**
* Get the current selected option as a string
* @param ddlist pointer to ddlist object

View File

@ -206,7 +206,7 @@ uint8_t lv_gauge_get_label_count(const lv_obj_t * gauge);
* @param gauge pointer to a gauge object
* @return number of the scale units
*/
static inline uint8_t lv_gauge_get_line_count(const lv_obj_t * gauge)
static inline uint16_t lv_gauge_get_line_count(const lv_obj_t * gauge)
{
return lv_lmeter_get_line_count(gauge);
}

View File

@ -328,7 +328,7 @@ static lv_design_res_t lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * cli
coords.y1 = imgbtn->coords.y1;
coords.x2 = coords.x1 + header.w - 1;
coords.y2 = coords.y1 + header.h - 1;
lv_draw_img(&coords, clip_area, src, style, 0, LV_IMG_ZOOM_NONE, false, opa_scale);
lv_draw_img(&coords, clip_area, src, style, 0, NULL, LV_IMG_ZOOM_NONE, false, opa_scale);
}
src = ext->img_src_right[state];
@ -339,7 +339,7 @@ static lv_design_res_t lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * cli
coords.y1 = imgbtn->coords.y1;
coords.x2 = imgbtn->coords.x2;
coords.y2 = imgbtn->coords.y1 + header.h - 1;
lv_draw_img(&coords, clip_area, src, style, 0, LV_IMG_ZOOM_NONE, false, opa_scale);
lv_draw_img(&coords, clip_area, src, style, 0, NULL, LV_IMG_ZOOM_NONE, false, opa_scale);
}
src = ext->img_src_mid[state];
@ -364,7 +364,7 @@ static lv_design_res_t lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * cli
coords.y2 = imgbtn->coords.y1 + header.h - 1;
for(i = 0; i < obj_w - right_w - left_w; i += header.w) {
lv_draw_img(&coords, &clip_center_area, src, style, 0, LV_IMG_ZOOM_NONE, false, opa_scale);
lv_draw_img(&coords, &clip_center_area, src, style, 0, NULL, LV_IMG_ZOOM_NONE, false, opa_scale);
coords.x1 = coords.x2 + 1;
coords.x2 += header.w;
}

View File

@ -36,7 +36,7 @@ static void lv_kb_updatemap(lv_obj_t * kb);
**********************/
static lv_signal_cb_t ancestor_signal;
/* clang-format off */
static const char * default_kb_map_lc[] = {"1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", LV_SYMBOL_BACKSPACE, "\n",
static const char * const default_kb_map_lc[] = {"1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", LV_SYMBOL_BACKSPACE, "\n",
"ABC", "a", "s", "d", "f", "g", "h", "j", "k", "l", LV_SYMBOL_NEW_LINE, "\n",
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
@ -47,7 +47,7 @@ static const lv_btnm_ctrl_t default_kb_ctrl_lc_map[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
static const char * default_kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", LV_SYMBOL_BACKSPACE, "\n",
static const char * const default_kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", LV_SYMBOL_BACKSPACE, "\n",
"abc", "A", "S", "D", "F", "G", "H", "J", "K", "L", LV_SYMBOL_NEW_LINE, "\n",
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
@ -58,7 +58,7 @@ static const lv_btnm_ctrl_t default_kb_ctrl_uc_map[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
static const char * default_kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", "Bksp", "\n",
static const char * const default_kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", LV_SYMBOL_BACKSPACE, "\n",
"abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};

View File

@ -674,7 +674,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_
pos->y = y;
#if LV_USE_BIDI
if(mutable_bidi_txt) lv_mem_free(mutable_bidi_txt);
if(mutable_bidi_txt) lv_mem_buf_release(mutable_bidi_txt);
#endif
}
@ -993,8 +993,8 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
lv_mem_buf_release(bidi_buf);
#else
lv_txt_ins(ext->text, pos, txt);
lv_label_refr_text(label);
#endif
lv_label_refr_text(label);
}
/**

View File

@ -182,6 +182,13 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
{
LV_ASSERT_OBJ(list, LV_OBJX_NAME);
lv_obj_t * last_btn = lv_list_get_prev_btn(list, NULL);
/*The coordinates may changed due to autofit so revert them at the end*/
lv_coord_t pos_x_ori = lv_obj_get_x(list);
lv_coord_t pos_y_ori = lv_obj_get_y(list);
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
ext->size++;
/*Create a list element with the image an the text*/
@ -200,7 +207,22 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
lv_page_glue_obj(liste, true);
lv_btn_set_layout(liste, LV_LAYOUT_ROW_M);
lv_btn_set_fit2(liste, LV_FIT_FLOOD, LV_FIT_TIGHT);
lv_layout_t list_layout = lv_list_get_layout(list);
bool layout_ver = false;
if(list_layout == LV_LAYOUT_COL_M || list_layout == LV_LAYOUT_COL_L || list_layout == LV_LAYOUT_COL_R) {
layout_ver = true;
}
if(layout_ver) {
lv_btn_set_fit2(liste, LV_FIT_FLOOD, LV_FIT_TIGHT);
} else {
lv_coord_t w = last_btn ? lv_obj_get_width(last_btn) : (LV_DPI * 3) / 2;
lv_btn_set_fit2(liste, LV_FIT_NONE, LV_FIT_TIGHT);
lv_obj_set_width(liste, w);
}
lv_obj_set_protect(liste, LV_PROTECT_PRESS_LOST);
lv_obj_set_signal_cb(liste, lv_list_btn_signal);
@ -236,6 +258,8 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
}
#endif
lv_obj_set_pos(list, pos_x_ori, pos_y_ori);
return liste;
}
@ -402,16 +426,23 @@ void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, const lv_style_t *
while(btn != NULL) {
/*If a column layout set the buttons' width to list width*/
if(layout == LV_LAYOUT_COL_M || layout == LV_LAYOUT_COL_L || layout == LV_LAYOUT_COL_R) {
lv_btn_set_fit2(list, LV_FIT_FLOOD, LV_FIT_TIGHT);
lv_btn_set_fit2(btn, LV_FIT_FLOOD, LV_FIT_TIGHT);
}
/*If a row layout set the buttons' width according to the content*/
else if (layout == LV_LAYOUT_ROW_M || layout == LV_LAYOUT_ROW_T || layout == LV_LAYOUT_ROW_B) {
lv_btn_set_fit(list, LV_FIT_TIGHT);
lv_btn_set_fit(btn, LV_FIT_TIGHT);
}
btn = lv_list_get_prev_btn(list, btn);
}
if(layout == LV_LAYOUT_COL_M || layout == LV_LAYOUT_COL_L || layout == LV_LAYOUT_COL_R) {
lv_page_set_scrl_fit2(list, LV_FIT_FLOOD, LV_FIT_TIGHT);
} else if (layout == LV_LAYOUT_ROW_M || layout == LV_LAYOUT_ROW_T || layout == LV_LAYOUT_ROW_B) {
lv_page_set_scrl_fit2(list, LV_FIT_TIGHT, LV_FIT_TIGHT);
lv_cont_set_fit2(list, LV_FIT_NONE, LV_FIT_TIGHT);
}
lv_page_set_scrl_layout(list, layout);
}

View File

@ -153,16 +153,16 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
ext->scrl = lv_cont_create(new_page, copy_ext->scrl);
lv_obj_set_signal_cb(ext->scrl, lv_page_scrollable_signal);
lv_page_set_sb_mode(new_page, copy_ext->sb.mode);
/* Add the signal function only if 'scrolling' is created
* because everything has to be ready before any signal is received*/
lv_obj_set_signal_cb(new_page, lv_page_signal);
lv_obj_set_design_cb(new_page, lv_page_design);
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, lv_page_get_style(copy, LV_PAGE_STYLE_BG));
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy, LV_PAGE_STYLE_SCRL));
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, lv_page_get_style(copy, LV_PAGE_STYLE_SB));
/* Add the signal function only if 'scrolling' is created
* because everything has to be ready before any signal is received*/
lv_obj_set_signal_cb(new_page, lv_page_signal);
lv_obj_set_design_cb(new_page, lv_page_design);
lv_page_set_sb_mode(new_page, copy_ext->sb.mode);
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_page);

View File

@ -153,8 +153,9 @@ void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mo
/* Make sure the roller's height and the scrollable's height is refreshed.
* They are refreshed in `LV_SIGNAL_COORD_CHG` but if the new options has the same width
* that signal won't be called. (It called because LV_FIT_TIGHT hor fit)*/
* that signal won't be called. (It's called because of LV_FIT_TIGHT hor fit)*/
refr_height(roller);
refr_position(roller, LV_ANIM_OFF);
} else {
ext->mode = LV_ROLLER_MODE_INIFINITE;
@ -276,6 +277,24 @@ uint16_t lv_roller_get_selected(const lv_obj_t * roller)
}
}
/**
* Get the total number of options
* @param roller pointer to a roller object
* @return the total number of options
*/
uint16_t lv_roller_get_option_cnt(const lv_obj_t * roller)
{
LV_ASSERT_OBJ(roller, LV_OBJX_NAME);
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
if(ext->mode == LV_ROLLER_MODE_INIFINITE) {
uint16_t real_id_cnt = ext->ddlist.option_cnt / LV_ROLLER_INF_PAGES;
return real_id_cnt;
} else {
return ext->ddlist.option_cnt;
}
}
/**
* Get the align attribute. Default alignment after _create is LV_LABEL_ALIGN_CENTER
* @param roller pointer to a roller object

View File

@ -146,6 +146,13 @@ void lv_roller_set_style(lv_obj_t * roller, lv_roller_style_t type, const lv_sty
*/
uint16_t lv_roller_get_selected(const lv_obj_t * roller);
/**
* Get the total number of options
* @param roller pointer to a roller object
* @return the total number of options in the list
*/
uint16_t lv_roller_get_option_cnt(const lv_obj_t * roller);
/**
* Get the current selected option as a string
* @param roller pointer to roller object

View File

@ -33,7 +33,7 @@
static lv_design_res_t lv_slider_design(lv_obj_t * slider, const lv_area_t * clip_area, lv_design_mode_t mode);
static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * param);
static void lv_slider_position_knob(lv_obj_t * slider, lv_area_t * knob_area, lv_coord_t knob_size, bool hor);
static void lv_slider_draw_knob(lv_obj_t * slider, lv_area_t * knob_area, lv_area_t * clip_area);
static void lv_slider_draw_knob(lv_obj_t * slider, const lv_area_t * knob_area, const lv_area_t * clip_area);
/**********************
* STATIC VARIABLES
@ -491,7 +491,7 @@ static void lv_slider_position_knob(lv_obj_t * slider, lv_area_t * knob_area, lv
knob_area->y2 += style_knob->body.padding.bottom;
}
static void lv_slider_draw_knob(lv_obj_t * slider, lv_area_t * knob_area, lv_area_t * clip_area) {
static void lv_slider_draw_knob(lv_obj_t * slider, const lv_area_t * knob_area, const lv_area_t * clip_area) {
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
const lv_style_t * style_knob = lv_slider_get_style(slider, LV_SLIDER_STYLE_KNOB);
lv_opa_t opa_scale = lv_obj_get_opa_scale(slider);

View File

@ -409,11 +409,15 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
char buf[LV_SPINBOX_MAX_DIGIT_COUNT + 8];
memset(buf, 0, sizeof(buf));
char * buf_p = buf;
uint8_t cur_shift_left = 0;
if (ext->range_min < 0) { // hide sign if there are only positive values
/*Add the sign*/
(*buf_p) = ext->value >= 0 ? '+' : '-';
buf_p++;
} else {
/*Cursor need shift to left*/
cur_shift_left++;
}
int32_t i;
@ -471,7 +475,7 @@ static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
if(cur_pos > intDigits) cur_pos++; /*Skip teh decimal point*/
cur_pos += ext->digit_padding_left;
cur_pos += (ext->digit_padding_left - cur_shift_left);
lv_ta_set_cursor_pos(spinbox, cur_pos);
}

View File

@ -545,8 +545,8 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
lv_res_t res;
res = lv_img_decoder_get_info(ext->img_knob_off, &info);
if(res == LV_RES_OK) {
knob_off_size = LV_MATH_MAX(knob_on_size, info.w / 2);
knob_off_size = LV_MATH_MAX(knob_on_size, info.h / 2);
knob_off_size = LV_MATH_MAX(knob_off_size, info.w / 2);
knob_off_size = LV_MATH_MAX(knob_off_size, info.h / 2);
} else {
LV_LOG_WARN("slider signal (LV_SIGNAL_REFR_EXT_DRAW_PAD): can't get knob image info")
}