update asserts
This commit is contained in:
@@ -230,7 +230,7 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item)
|
||||
*cross_pos += t.track_cross_size + gap + track_gap;
|
||||
}
|
||||
}
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
LV_ASSERT_MALLOC_INTEGRITY();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,8 +54,8 @@ static lv_coord_t grid_place(lv_coord_t cont_size, bool auto_size, uint8_t plac
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
const static lv_coord_t grid_12_template[12] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1),
|
||||
LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1)};
|
||||
const static lv_coord_t grid_12_template[12] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1),
|
||||
LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1)};
|
||||
const lv_grid_t grid_12 = {.base.update_cb = grid_update, .col_dsc = grid_12_template, .col_dsc_len = 12, .row_dsc = grid_12_template, .row_dsc_len = 12};
|
||||
|
||||
/**********************
|
||||
@@ -211,7 +211,7 @@ static void calc(struct _lv_obj_t * cont, _lv_grid_calc_t * calc_out)
|
||||
lv_coord_t cont_h = lv_obj_get_height_fit(cont);
|
||||
calc_out->grid_h = grid_place(cont_h, auto_h, g->row_place, row_gap, calc_out->row_num, calc_out->h, calc_out->y, false);
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
LV_ASSERT_MALLOC_INTEGRITY();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,8 +13,8 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "layouts/flex/lv_flex.h"
|
||||
#include "layouts/grid/lv_grid.h"
|
||||
#include "flex/lv_flex.h"
|
||||
#include "grid/lv_grid.h"
|
||||
|
||||
|
||||
/*********************
|
||||
|
||||
@@ -780,6 +780,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
lv_obj_add_style(obj, LV_PART_SCROLLBAR, LV_STATE_SCROLLED, &styles->scrollbar_scrolled);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_COLORWHEEL
|
||||
else if(lv_obj_check_type(obj, &lv_colorwheel_class)) {
|
||||
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->pad_normal);
|
||||
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->bg_color_panel);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file lv_colorwheel.c
|
||||
*
|
||||
* Based on the work of @AloyseTech and @paulpv.
|
||||
* Based on the work of @AloyseTech and @paulpv.
|
||||
*/
|
||||
|
||||
/*********************
|
||||
@@ -13,6 +13,7 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS &lv_colorwheel_class
|
||||
|
||||
#define LV_CPICKER_DEF_QF 3
|
||||
|
||||
@@ -23,8 +24,6 @@
|
||||
*/
|
||||
#define OUTER_MASK_WIDTH 3
|
||||
|
||||
#define DRAG_LIMIT (LV_DPI / 10)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@@ -32,28 +31,32 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_draw_res_t lv_colorwheel_draw(lv_obj_t * colorwheel, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_colorwheel_signal(lv_obj_t * colorwheel, lv_signal_t sign, void * param);
|
||||
static lv_style_list_t * lv_colorwheel_get_style(lv_obj_t * colorwheel, uint8_t part);
|
||||
static bool lv_colorwheel_hit(lv_obj_t * colorwheel, const lv_point_t * p);
|
||||
static void lv_colorwheel_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
|
||||
static lv_draw_res_t lv_colorwheel_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
|
||||
static lv_res_t lv_colorwheel_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
static void draw_disc_grad(lv_obj_t * colorwheel, const lv_area_t * mask);
|
||||
static void draw_knob(lv_obj_t * colorwheel, const lv_area_t * mask);
|
||||
static void invalidate_knob(lv_obj_t * colorwheel);
|
||||
static lv_area_t get_knob_area(lv_obj_t * colorwheel);
|
||||
static void draw_disc_grad(lv_obj_t * obj, const lv_area_t * mask);
|
||||
static void draw_knob(lv_obj_t * obj, const lv_area_t * mask);
|
||||
static void invalidate_knob(lv_obj_t * obj);
|
||||
static lv_area_t get_knob_area(lv_obj_t * obj);
|
||||
|
||||
static void next_color_mode(lv_obj_t * colorwheel);
|
||||
static lv_res_t double_click_reset(lv_obj_t * colorwheel);
|
||||
static void refr_knob_pos(lv_obj_t * colorwheel);
|
||||
static lv_color_t angle_to_mode_color(lv_obj_t * colorwheel, uint16_t angle);
|
||||
static uint16_t get_angle(lv_obj_t * colorwheel);
|
||||
static void next_color_mode(lv_obj_t * obj);
|
||||
static lv_res_t double_click_reset(lv_obj_t * obj);
|
||||
static void refr_knob_pos(lv_obj_t * obj);
|
||||
static lv_color_t angle_to_mode_color(lv_obj_t * obj, uint16_t angle);
|
||||
static uint16_t get_angle(lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_signal_cb_t ancestor_signal;
|
||||
static lv_draw_cb_t ancestor_draw;
|
||||
static bool inited;
|
||||
const lv_obj_class_t lv_colorwheel_class = {.instance_size = sizeof(lv_colorwheel_t), .base_class = &lv_obj_class,
|
||||
.constructor_cb = lv_colorwheel_constructor,
|
||||
.draw_cb = lv_colorwheel_draw,
|
||||
.signal_cb = lv_colorwheel_signal,
|
||||
.editable = LV_OBJ_CLASS_EDITABLE_TRUE,
|
||||
};
|
||||
|
||||
static bool create_knob_recolor;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@@ -71,54 +74,8 @@ static bool inited;
|
||||
*/
|
||||
lv_obj_t * lv_colorwheel_create(lv_obj_t * parent, bool knob_recolor)
|
||||
{
|
||||
static lv_style_t style_knob;
|
||||
if(!inited) {
|
||||
lv_style_init(&style_knob);
|
||||
lv_style_set_bg_color(&style_knob, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||
lv_style_set_border_color(&style_knob, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
lv_style_set_border_width(&style_knob, LV_STATE_DEFAULT, LV_DPX(1));
|
||||
lv_style_set_bg_opa(&style_knob, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||
lv_style_set_radius(&style_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_pad_all(&style_knob, LV_STATE_DEFAULT, LV_DPX(5));
|
||||
inited = true;
|
||||
}
|
||||
lv_obj_t * colorwheel = lv_obj_create(parent, NULL);
|
||||
LV_ASSERT_MEM(colorwheel);
|
||||
if(colorwheel == NULL) return NULL;
|
||||
|
||||
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(colorwheel);
|
||||
if(ancestor_draw == NULL) ancestor_draw = lv_obj_get_draw_cb(colorwheel);
|
||||
|
||||
/*Allocate the extended data*/
|
||||
lv_colorwheel_ext_t * ext = lv_obj_allocate_ext_attr(colorwheel, sizeof(lv_colorwheel_ext_t));
|
||||
LV_ASSERT_MEM(ext);
|
||||
if(ext == NULL) {
|
||||
lv_obj_del(colorwheel);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*Initialize the allocated 'ext' */
|
||||
ext->hsv.h = 0;
|
||||
ext->hsv.s = 100;
|
||||
ext->hsv.v = 100;
|
||||
ext->mode = LV_COLORWHEEL_MODE_HUE;
|
||||
ext->mode_fixed = 0;
|
||||
ext->last_click_time = 0;
|
||||
ext->last_change_time = 0;
|
||||
ext->knob.recolor = knob_recolor;
|
||||
|
||||
lv_style_list_init(&ext->knob.style_list);
|
||||
|
||||
/*The signal and draw functions are not copied so set them here*/
|
||||
lv_obj_set_signal_cb(colorwheel, lv_colorwheel_signal);
|
||||
lv_obj_set_draw_cb(colorwheel, lv_colorwheel_draw);
|
||||
|
||||
lv_obj_set_size(colorwheel, LV_DPI * 2, LV_DPI * 2);
|
||||
lv_obj_add_flag(colorwheel, LV_OBJ_FLAG_ADV_HITTEST);
|
||||
lv_obj_add_style(colorwheel, LV_COLORWHEEL_PART_KNOB, &style_knob);
|
||||
refr_knob_pos(colorwheel);
|
||||
|
||||
return colorwheel;
|
||||
create_knob_recolor = knob_recolor;
|
||||
return lv_obj_create_from_class(&lv_colorwheel_class, parent, NULL);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@@ -131,21 +88,21 @@ lv_obj_t * lv_colorwheel_create(lv_obj_t * parent, bool knob_recolor)
|
||||
* @param color current selected hsv
|
||||
* @return true if changed, otherwise false
|
||||
*/
|
||||
bool lv_colorwheel_set_hsv(lv_obj_t * colorwheel, lv_color_hsv_t hsv)
|
||||
bool lv_colorwheel_set_hsv(lv_obj_t * obj, lv_color_hsv_t hsv)
|
||||
{
|
||||
if(hsv.h > 360) hsv.h %= 360;
|
||||
if(hsv.s > 100) hsv.s = 100;
|
||||
if(hsv.v > 100) hsv.v = 100;
|
||||
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
|
||||
if(ext->hsv.h == hsv.h && ext->hsv.s == hsv.s && ext->hsv.v == hsv.v) return false;
|
||||
if(colorwheel->hsv.h == hsv.h && colorwheel->hsv.s == hsv.s && colorwheel->hsv.v == hsv.v) return false;
|
||||
|
||||
ext->hsv = hsv;
|
||||
colorwheel->hsv = hsv;
|
||||
|
||||
refr_knob_pos(colorwheel);
|
||||
refr_knob_pos(obj);
|
||||
|
||||
lv_obj_invalidate(colorwheel);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -156,13 +113,12 @@ bool lv_colorwheel_set_hsv(lv_obj_t * colorwheel, lv_color_hsv_t hsv)
|
||||
* @param color current selected color
|
||||
* @return true if changed, otherwise false
|
||||
*/
|
||||
bool lv_colorwheel_set_rgb(lv_obj_t * colorwheel, lv_color_t color)
|
||||
bool lv_colorwheel_set_rgb(lv_obj_t * obj, lv_color_t color)
|
||||
{
|
||||
lv_color32_t c32;
|
||||
c32.full = lv_color_to32(color);
|
||||
|
||||
return lv_colorwheel_set_hsv(colorwheel,
|
||||
lv_color_rgb_to_hsv(c32.ch.red, c32.ch.green, c32.ch.blue));
|
||||
return lv_colorwheel_set_hsv(obj, lv_color_rgb_to_hsv(c32.ch.red, c32.ch.green, c32.ch.blue));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,13 +126,13 @@ bool lv_colorwheel_set_rgb(lv_obj_t * colorwheel, lv_color_t color)
|
||||
* @param colorwheel pointer to color wheel object
|
||||
* @param mode color mode (hue/sat/val)
|
||||
*/
|
||||
void lv_colorwheel_set_mode(lv_obj_t * colorwheel, lv_colorwheel_mode_t mode)
|
||||
void lv_colorwheel_set_mode(lv_obj_t * obj, lv_colorwheel_mode_t mode)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
|
||||
ext->mode = mode;
|
||||
refr_knob_pos(colorwheel);
|
||||
lv_obj_invalidate(colorwheel);
|
||||
colorwheel->mode = mode;
|
||||
refr_knob_pos(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,11 +140,11 @@ void lv_colorwheel_set_mode(lv_obj_t * colorwheel, lv_colorwheel_mode_t mode)
|
||||
* @param colorwheel pointer to color wheel object
|
||||
* @param fixed color mode cannot be changed on long press
|
||||
*/
|
||||
void lv_colorwheel_set_mode_fixed(lv_obj_t * colorwheel, bool fixed)
|
||||
void lv_colorwheel_set_mode_fixed(lv_obj_t * obj, bool fixed)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
|
||||
ext->mode_fixed = fixed;
|
||||
colorwheel->mode_fixed = fixed;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@@ -201,11 +157,11 @@ void lv_colorwheel_set_mode_fixed(lv_obj_t * colorwheel, bool fixed)
|
||||
* @param colorwheel pointer to color wheel object
|
||||
* @return current selected hsv
|
||||
*/
|
||||
lv_color_hsv_t lv_colorwheel_get_hsv(lv_obj_t * colorwheel)
|
||||
lv_color_hsv_t lv_colorwheel_get_hsv(lv_obj_t * obj)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
|
||||
return ext->hsv;
|
||||
return colorwheel->hsv;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,11 +169,11 @@ lv_color_hsv_t lv_colorwheel_get_hsv(lv_obj_t * colorwheel)
|
||||
* @param colorwheel pointer to color wheel object
|
||||
* @return color current selected color
|
||||
*/
|
||||
lv_color_t lv_colorwheel_get_rgb(lv_obj_t * colorwheel)
|
||||
lv_color_t lv_colorwheel_get_rgb(lv_obj_t * obj)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
|
||||
return lv_color_hsv_to_rgb(ext->hsv.h, ext->hsv.s, ext->hsv.v);
|
||||
return lv_color_hsv_to_rgb(colorwheel->hsv.h, colorwheel->hsv.s, colorwheel->hsv.v);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,11 +181,11 @@ lv_color_t lv_colorwheel_get_rgb(lv_obj_t * colorwheel)
|
||||
* @param colorwheel pointer to color wheel object
|
||||
* @return color mode (hue/sat/val)
|
||||
*/
|
||||
lv_colorwheel_mode_t lv_colorwheel_get_color_mode(lv_obj_t * colorwheel)
|
||||
lv_colorwheel_mode_t lv_colorwheel_get_color_mode(lv_obj_t * obj)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
|
||||
return ext->mode;
|
||||
return colorwheel->mode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,11 +193,11 @@ lv_colorwheel_mode_t lv_colorwheel_get_color_mode(lv_obj_t * colorwheel)
|
||||
* @param colorwheel pointer to color wheel object
|
||||
* @return mode cannot be changed on long press
|
||||
*/
|
||||
bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * colorwheel)
|
||||
bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * obj)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
|
||||
return ext->mode_fixed;
|
||||
return colorwheel->mode_fixed;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
@@ -252,150 +208,139 @@ bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * colorwheel)
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the color_picker
|
||||
* @param colorwheel pointer to an object
|
||||
* @param mask the object will be drawn only in this area
|
||||
* @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
||||
* (return 'true' if yes)
|
||||
* LV_DRAW_DRAW: draw the object (always return 'true')
|
||||
* LV_DRAW_DRAW_POST: drawing after every children are drawn
|
||||
* @return return an element of `lv_draw_res_t`
|
||||
*/
|
||||
static lv_draw_res_t lv_colorwheel_draw(lv_obj_t * colorwheel, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
static void lv_colorwheel_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy)
|
||||
{
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
colorwheel->hsv.h = 0;
|
||||
colorwheel->hsv.s = 100;
|
||||
colorwheel->hsv.v = 100;
|
||||
colorwheel->mode = LV_COLORWHEEL_MODE_HUE;
|
||||
colorwheel->mode_fixed = 0;
|
||||
colorwheel->last_click_time = 0;
|
||||
colorwheel->last_change_time = 0;
|
||||
colorwheel->knob.recolor = create_knob_recolor;
|
||||
|
||||
lv_obj_set_size(obj, LV_DPI_DEF * 2, LV_DPI_DEF * 2);
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_ADV_HITTEST);
|
||||
refr_knob_pos(obj);
|
||||
}
|
||||
|
||||
static lv_draw_res_t lv_colorwheel_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
|
||||
{
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
if(mode == LV_DRAW_COVER_CHK) {
|
||||
if(mode == LV_DRAW_MODE_COVER_CHECK) {
|
||||
return LV_DRAW_RES_NOT_COVER;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if(mode == LV_DRAW_DRAW_MAIN) {
|
||||
draw_disc_grad(colorwheel, clip_area);
|
||||
draw_knob(colorwheel, clip_area);
|
||||
else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
|
||||
draw_disc_grad(obj, clip_area);
|
||||
draw_knob(obj, clip_area);
|
||||
}
|
||||
/*Post draw when the children are drawn*/
|
||||
else if(mode == LV_DRAW_DRAW_POST) {
|
||||
else if(mode == LV_DRAW_MODE_POST_DRAW) {
|
||||
}
|
||||
|
||||
return LV_DRAW_RES_OK;
|
||||
}
|
||||
|
||||
static void draw_disc_grad(lv_obj_t * colorwheel, const lv_area_t * mask)
|
||||
static void draw_disc_grad(lv_obj_t * obj, const lv_area_t * mask)
|
||||
{
|
||||
lv_coord_t w = lv_obj_get_width(colorwheel);
|
||||
lv_coord_t h = lv_obj_get_height(colorwheel);
|
||||
lv_coord_t cx = colorwheel->coords.x1 + w / 2;
|
||||
lv_coord_t cy = colorwheel->coords.y1 + h / 2;
|
||||
lv_coord_t w = lv_obj_get_width(obj);
|
||||
lv_coord_t h = lv_obj_get_height(obj);
|
||||
lv_coord_t cx = obj->coords.x1 + w / 2;
|
||||
lv_coord_t cy = obj->coords.y1 + h / 2;
|
||||
lv_coord_t r = w / 2;
|
||||
|
||||
lv_draw_line_dsc_t line_dsc;
|
||||
lv_draw_line_dsc_init(&line_dsc);
|
||||
lv_obj_init_draw_line_dsc(colorwheel, LV_COLORWHEEL_PART_MAIN, &line_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_MAIN, &line_dsc);
|
||||
|
||||
line_dsc.width = (r * 628 / (360 / LV_CPICKER_DEF_QF)) / 100;
|
||||
line_dsc.width += 2;
|
||||
uint16_t i;
|
||||
lv_coord_t cir_w = lv_obj_get_style_scale_width(colorwheel, LV_COLORWHEEL_PART_MAIN);
|
||||
lv_coord_t cir_w = lv_obj_get_style_arc_width(obj, LV_PART_MAIN);
|
||||
|
||||
/* Mask outer ring of widget to tidy up ragged edges of lines while drawing outer ring */
|
||||
lv_area_t mask_area_out;
|
||||
lv_area_copy(&mask_area_out, &colorwheel->coords);
|
||||
mask_area_out.x1 += OUTER_MASK_WIDTH;
|
||||
mask_area_out.x2 -= OUTER_MASK_WIDTH;
|
||||
mask_area_out.y1 += OUTER_MASK_WIDTH;
|
||||
mask_area_out.y2 -= OUTER_MASK_WIDTH;
|
||||
lv_draw_mask_radius_param_t mask_out_param;
|
||||
lv_draw_mask_radius_init(&mask_out_param, &mask_area_out, LV_RADIUS_CIRCLE, false);
|
||||
lv_draw_mask_radius_init(&mask_out_param, &obj->coords, LV_RADIUS_CIRCLE, false);
|
||||
int16_t mask_out_id = lv_draw_mask_add(&mask_out_param, 0);
|
||||
|
||||
|
||||
lv_area_t mask_area;
|
||||
lv_area_copy(&mask_area, &obj->coords);
|
||||
mask_area.x1 += cir_w;
|
||||
mask_area.x2 -= cir_w;
|
||||
mask_area.y1 += cir_w;
|
||||
mask_area.y2 -= cir_w;
|
||||
lv_draw_mask_radius_param_t mask_in_param;
|
||||
lv_draw_mask_radius_init(&mask_in_param, &mask_area, LV_RADIUS_CIRCLE, true);
|
||||
int16_t mask_in_id = lv_draw_mask_add(&mask_in_param, 0);
|
||||
|
||||
/* The inner line ends will be masked out.
|
||||
* So make lines a little bit longer because the masking makes a more even result */
|
||||
lv_coord_t cir_w_extra = cir_w + line_dsc.width;
|
||||
|
||||
|
||||
for(i = 0; i <= 360; i += LV_CPICKER_DEF_QF) {
|
||||
line_dsc.color = angle_to_mode_color(colorwheel, i);
|
||||
line_dsc.color = angle_to_mode_color(obj, i);
|
||||
|
||||
lv_point_t p[2];
|
||||
p[0].x = cx + (r * lv_trigo_sin(i) >> LV_TRIGO_SHIFT);
|
||||
p[0].y = cy + (r * lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT);
|
||||
p[0].x = cx + ((r + line_dsc.width) * lv_trigo_sin(i) >> LV_TRIGO_SHIFT);
|
||||
p[0].y = cy + ((r + line_dsc.width) * lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT);
|
||||
p[1].x = cx + ((r - cir_w_extra) * lv_trigo_sin(i) >> LV_TRIGO_SHIFT);
|
||||
p[1].y = cy + ((r - cir_w_extra) * lv_trigo_sin(i + 90) >> LV_TRIGO_SHIFT);
|
||||
|
||||
lv_draw_line(&p[0], &p[1], mask, &line_dsc);
|
||||
}
|
||||
/* Now remove mask to continue with inner part */
|
||||
lv_draw_mask_remove_id(mask_out_id);
|
||||
lv_draw_mask_remove_id(mask_in_id);
|
||||
|
||||
/*Mask out the inner area*/
|
||||
lv_draw_rect_dsc_t bg_dsc;
|
||||
lv_draw_rect_dsc_init(&bg_dsc);
|
||||
lv_obj_init_draw_rect_dsc(colorwheel, LV_COLORWHEEL_PART_MAIN, &bg_dsc);
|
||||
bg_dsc.radius = LV_RADIUS_CIRCLE;
|
||||
|
||||
lv_area_t area_mid;
|
||||
lv_area_copy(&area_mid, &colorwheel->coords);
|
||||
area_mid.x1 += cir_w;
|
||||
area_mid.y1 += cir_w;
|
||||
area_mid.x2 -= cir_w;
|
||||
area_mid.y2 -= cir_w;
|
||||
|
||||
lv_draw_rect(&area_mid, mask, &bg_dsc);
|
||||
|
||||
lv_coord_t inner = cir_w / 2;
|
||||
lv_color_t color = lv_colorwheel_get_rgb(colorwheel);
|
||||
bg_dsc.bg_color = color;
|
||||
area_mid.x1 += inner;
|
||||
area_mid.y1 += inner;
|
||||
area_mid.x2 -= inner;
|
||||
area_mid.y2 -= inner;
|
||||
|
||||
lv_draw_rect(&area_mid, mask, &bg_dsc);
|
||||
}
|
||||
|
||||
static void draw_knob(lv_obj_t * colorwheel, const lv_area_t * mask)
|
||||
static void draw_knob(lv_obj_t * obj, const lv_area_t * mask)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
|
||||
lv_draw_rect_dsc_t cir_dsc;
|
||||
lv_draw_rect_dsc_init(&cir_dsc);
|
||||
lv_obj_init_draw_rect_dsc(colorwheel, LV_COLORWHEEL_PART_KNOB, &cir_dsc);
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_KNOB, &cir_dsc);
|
||||
|
||||
cir_dsc.radius = LV_RADIUS_CIRCLE;
|
||||
|
||||
if(ext->knob.recolor) {
|
||||
cir_dsc.bg_color = lv_colorwheel_get_rgb(colorwheel);
|
||||
if(colorwheel->knob.recolor) {
|
||||
cir_dsc.bg_color = lv_colorwheel_get_rgb(obj);
|
||||
}
|
||||
|
||||
lv_area_t knob_area = get_knob_area(colorwheel);
|
||||
lv_area_t knob_area = get_knob_area(obj);
|
||||
|
||||
lv_draw_rect(&knob_area, mask, &cir_dsc);
|
||||
}
|
||||
|
||||
static void invalidate_knob(lv_obj_t * colorwheel)
|
||||
static void invalidate_knob(lv_obj_t * obj)
|
||||
{
|
||||
lv_area_t knob_area = get_knob_area(colorwheel);
|
||||
lv_area_t knob_area = get_knob_area(obj);
|
||||
|
||||
lv_obj_invalidate_area(colorwheel, &knob_area);
|
||||
lv_obj_invalidate_area(obj, &knob_area);
|
||||
}
|
||||
|
||||
static lv_area_t get_knob_area(lv_obj_t * colorwheel)
|
||||
static lv_area_t get_knob_area(lv_obj_t * obj)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
|
||||
/*Get knob's radius*/
|
||||
uint16_t r = 0;
|
||||
r = lv_obj_get_style_scale_width(colorwheel, LV_COLORWHEEL_PART_MAIN) / 2;
|
||||
r = lv_obj_get_style_arc_width(obj, LV_PART_MAIN) / 2;
|
||||
|
||||
lv_coord_t left = lv_obj_get_style_pad_left(colorwheel, LV_COLORWHEEL_PART_KNOB);
|
||||
lv_coord_t right = lv_obj_get_style_pad_right(colorwheel, LV_COLORWHEEL_PART_KNOB);
|
||||
lv_coord_t top = lv_obj_get_style_pad_top(colorwheel, LV_COLORWHEEL_PART_KNOB);
|
||||
lv_coord_t bottom = lv_obj_get_style_pad_bottom(colorwheel, LV_COLORWHEEL_PART_KNOB);
|
||||
lv_coord_t left = lv_obj_get_style_pad_left(obj, LV_PART_KNOB);
|
||||
lv_coord_t right = lv_obj_get_style_pad_right(obj, LV_PART_KNOB);
|
||||
lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_KNOB);
|
||||
lv_coord_t bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB);
|
||||
|
||||
lv_area_t knob_area;
|
||||
knob_area.x1 = colorwheel->coords.x1 + ext->knob.pos.x - r - left;
|
||||
knob_area.y1 = colorwheel->coords.y1 + ext->knob.pos.y - r - right;
|
||||
knob_area.x2 = colorwheel->coords.x1 + ext->knob.pos.x + r + top;
|
||||
knob_area.y2 = colorwheel->coords.y1 + ext->knob.pos.y + r + bottom;
|
||||
knob_area.x1 = obj->coords.x1 + colorwheel->knob.pos.x - r - left;
|
||||
knob_area.y1 = obj->coords.y1 + colorwheel->knob.pos.y - r - right;
|
||||
knob_area.x2 = obj->coords.x1 + colorwheel->knob.pos.x + r + top;
|
||||
knob_area.y2 = obj->coords.y1 + colorwheel->knob.pos.y + r + bottom;
|
||||
|
||||
return knob_area;
|
||||
}
|
||||
@@ -407,31 +352,20 @@ static lv_area_t get_knob_area(lv_obj_t * colorwheel)
|
||||
* @param param pointer to a signal specific variable
|
||||
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
|
||||
*/
|
||||
static lv_res_t lv_colorwheel_signal(lv_obj_t * colorwheel, lv_signal_t sign, void * param)
|
||||
static lv_res_t lv_colorwheel_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
|
||||
{
|
||||
/* Include the ancient signal function */
|
||||
lv_res_t res;
|
||||
lv_res_t res = lv_obj_signal_base(MY_CLASS, obj, sign, param);
|
||||
|
||||
if(sign == LV_SIGNAL_GET_STYLE) {
|
||||
lv_get_style_info_t * info = param;
|
||||
info->result = lv_colorwheel_get_style(colorwheel, info->part);
|
||||
if(info->result != NULL) return LV_RES_OK;
|
||||
else return ancestor_signal(colorwheel, sign, param);
|
||||
}
|
||||
|
||||
res = ancestor_signal(colorwheel, sign, param);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
|
||||
if(sign == LV_SIGNAL_CLEANUP) {
|
||||
_lv_obj_reset_style_list_no_refr(colorwheel, LV_COLORWHEEL_PART_KNOB);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
|
||||
lv_coord_t left = lv_obj_get_style_pad_left(colorwheel, LV_COLORWHEEL_PART_KNOB);
|
||||
lv_coord_t right = lv_obj_get_style_pad_right(colorwheel, LV_COLORWHEEL_PART_KNOB);
|
||||
lv_coord_t top = lv_obj_get_style_pad_top(colorwheel, LV_COLORWHEEL_PART_KNOB);
|
||||
lv_coord_t bottom = lv_obj_get_style_pad_bottom(colorwheel, LV_COLORWHEEL_PART_KNOB);
|
||||
if(sign == LV_SIGNAL_REFR_EXT_DRAW_SIZE) {
|
||||
lv_coord_t left = lv_obj_get_style_pad_left(obj, LV_PART_KNOB);
|
||||
lv_coord_t right = lv_obj_get_style_pad_right(obj, LV_PART_KNOB);
|
||||
lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_KNOB);
|
||||
lv_coord_t bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB);
|
||||
|
||||
lv_coord_t knob_pad = LV_MAX4(left, right, top, bottom) + 2;
|
||||
lv_coord_t * s = param;
|
||||
@@ -439,67 +373,65 @@ static lv_res_t lv_colorwheel_signal(lv_obj_t * colorwheel, lv_signal_t sign, vo
|
||||
}
|
||||
else if(sign == LV_SIGNAL_COORD_CHG) {
|
||||
/*Refresh extended draw area to make knob visible*/
|
||||
if(lv_obj_get_width(colorwheel) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(colorwheel) != lv_area_get_height(param)) {
|
||||
refr_knob_pos(colorwheel);
|
||||
if(lv_obj_get_width(obj) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(obj) != lv_area_get_height(param)) {
|
||||
refr_knob_pos(obj);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*Refresh extended draw area to make knob visible*/
|
||||
refr_knob_pos(colorwheel);
|
||||
refr_knob_pos(obj);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROL) {
|
||||
#if LV_USE_GROUP
|
||||
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
|
||||
|
||||
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
|
||||
lv_color_hsv_t hsv_cur;
|
||||
hsv_cur = ext->hsv;
|
||||
hsv_cur = colorwheel->hsv;
|
||||
|
||||
switch(ext->mode) {
|
||||
switch(colorwheel->mode) {
|
||||
case LV_COLORWHEEL_MODE_HUE:
|
||||
hsv_cur.h = (ext->hsv.h + 1) % 360;
|
||||
hsv_cur.h = (colorwheel->hsv.h + 1) % 360;
|
||||
break;
|
||||
case LV_COLORWHEEL_MODE_SATURATION:
|
||||
hsv_cur.s = (ext->hsv.s + 1) % 100;
|
||||
hsv_cur.s = (colorwheel->hsv.s + 1) % 100;
|
||||
break;
|
||||
case LV_COLORWHEEL_MODE_VALUE:
|
||||
hsv_cur.v = (ext->hsv.v + 1) % 100;
|
||||
hsv_cur.v = (colorwheel->hsv.v + 1) % 100;
|
||||
break;
|
||||
}
|
||||
|
||||
if(lv_colorwheel_set_hsv(colorwheel, hsv_cur)) {
|
||||
res = lv_event_send(colorwheel, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(lv_colorwheel_set_hsv(obj, hsv_cur)) {
|
||||
res = lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
}
|
||||
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
|
||||
lv_color_hsv_t hsv_cur;
|
||||
hsv_cur = ext->hsv;
|
||||
hsv_cur = colorwheel->hsv;
|
||||
|
||||
switch(ext->mode) {
|
||||
switch(colorwheel->mode) {
|
||||
case LV_COLORWHEEL_MODE_HUE:
|
||||
hsv_cur.h = ext->hsv.h > 0 ? (ext->hsv.h - 1) : 360;
|
||||
hsv_cur.h = colorwheel->hsv.h > 0 ? (colorwheel->hsv.h - 1) : 360;
|
||||
break;
|
||||
case LV_COLORWHEEL_MODE_SATURATION:
|
||||
hsv_cur.s = ext->hsv.s > 0 ? (ext->hsv.s - 1) : 100;
|
||||
hsv_cur.s = colorwheel->hsv.s > 0 ? (colorwheel->hsv.s - 1) : 100;
|
||||
break;
|
||||
case LV_COLORWHEEL_MODE_VALUE:
|
||||
hsv_cur.v = ext->hsv.v > 0 ? (ext->hsv.v - 1) : 100;
|
||||
hsv_cur.v = colorwheel->hsv.v > 0 ? (colorwheel->hsv.v - 1) : 100;
|
||||
break;
|
||||
}
|
||||
|
||||
if(lv_colorwheel_set_hsv(colorwheel, hsv_cur)) {
|
||||
res = lv_event_send(colorwheel, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(lv_colorwheel_set_hsv(obj, hsv_cur)) {
|
||||
res = lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSED) {
|
||||
ext->last_change_time = lv_tick_get();
|
||||
lv_indev_get_point(lv_indev_get_act(), &ext->last_press_point);
|
||||
res = double_click_reset(colorwheel);
|
||||
colorwheel->last_change_time = lv_tick_get();
|
||||
lv_indev_get_point(lv_indev_get_act(), &colorwheel->last_press_point);
|
||||
res = double_click_reset(obj);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
@@ -509,39 +441,40 @@ static lv_res_t lv_colorwheel_signal(lv_obj_t * colorwheel, lv_signal_t sign, vo
|
||||
lv_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
lv_point_t p;
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER || indev_type == LV_INDEV_TYPE_KEYPAD) {
|
||||
p.x = colorwheel->coords.x1 + lv_obj_get_width(colorwheel) / 2;
|
||||
p.y = colorwheel->coords.y1 + lv_obj_get_height(colorwheel) / 2;
|
||||
p.x = obj->coords.x1 + lv_obj_get_width(obj) / 2;
|
||||
p.y = obj->coords.y1 + lv_obj_get_height(obj) / 2;
|
||||
}
|
||||
else {
|
||||
lv_indev_get_point(indev, &p);
|
||||
}
|
||||
|
||||
if((LV_ABS(p.x - ext->last_press_point.x) > DRAG_LIMIT) ||
|
||||
(LV_ABS(p.y - ext->last_press_point.y) > DRAG_LIMIT)) {
|
||||
ext->last_change_time = lv_tick_get();
|
||||
ext->last_press_point.x = p.x;
|
||||
ext->last_press_point.y = p.y;
|
||||
lv_coord_t drag_limit = indev->driver.scroll_limit;
|
||||
if((LV_ABS(p.x - colorwheel->last_press_point.x) > drag_limit) ||
|
||||
(LV_ABS(p.y - colorwheel->last_press_point.y) > drag_limit)) {
|
||||
colorwheel->last_change_time = lv_tick_get();
|
||||
colorwheel->last_press_point.x = p.x;
|
||||
colorwheel->last_press_point.y = p.y;
|
||||
}
|
||||
|
||||
p.x -= colorwheel->coords.x1;
|
||||
p.y -= colorwheel->coords.y1;
|
||||
p.x -= obj->coords.x1;
|
||||
p.y -= obj->coords.y1;
|
||||
|
||||
/*Ignore pressing in the inner area*/
|
||||
uint16_t w = lv_obj_get_width(colorwheel);
|
||||
uint16_t w = lv_obj_get_width(obj);
|
||||
|
||||
int16_t angle = 0;
|
||||
lv_coord_t cir_w = lv_obj_get_style_scale_width(colorwheel, LV_COLORWHEEL_PART_MAIN);
|
||||
lv_coord_t cir_w = lv_obj_get_style_arc_width(obj, LV_PART_MAIN);
|
||||
|
||||
lv_coord_t r_in = w / 2;
|
||||
p.x -= r_in;
|
||||
p.y -= r_in;
|
||||
bool on_ring = true;
|
||||
r_in -= cir_w;
|
||||
if(r_in > LV_DPI / 2) {
|
||||
if(r_in > LV_DPI_DEF / 2) {
|
||||
lv_coord_t inner = cir_w / 2;
|
||||
r_in -= inner;
|
||||
|
||||
if(r_in < LV_DPI / 2) r_in = LV_DPI / 2;
|
||||
if(r_in < LV_DPI_DEF / 2) r_in = LV_DPI_DEF / 2;
|
||||
}
|
||||
|
||||
if(p.x * p.x + p.y * p.y < r_in * r_in) {
|
||||
@@ -549,9 +482,9 @@ static lv_res_t lv_colorwheel_signal(lv_obj_t * colorwheel, lv_signal_t sign, vo
|
||||
}
|
||||
|
||||
/*If the inner area is being pressed, go to the next color mode on long press*/
|
||||
uint32_t diff = lv_tick_elaps(ext->last_change_time);
|
||||
if(!on_ring && diff > indev->driver.long_press_time && !ext->mode_fixed) {
|
||||
next_color_mode(colorwheel);
|
||||
uint32_t diff = lv_tick_elaps(colorwheel->last_change_time);
|
||||
if(!on_ring && diff > indev->driver.long_press_time && !colorwheel->mode_fixed) {
|
||||
next_color_mode(obj);
|
||||
lv_indev_wait_release(lv_indev_get_act());
|
||||
return res;
|
||||
}
|
||||
@@ -562,9 +495,9 @@ static lv_res_t lv_colorwheel_signal(lv_obj_t * colorwheel, lv_signal_t sign, vo
|
||||
angle = lv_atan2(p.x, p.y) % 360;
|
||||
|
||||
lv_color_hsv_t hsv_cur;
|
||||
hsv_cur = ext->hsv;
|
||||
hsv_cur = colorwheel->hsv;
|
||||
|
||||
switch(ext->mode) {
|
||||
switch(colorwheel->mode) {
|
||||
case LV_COLORWHEEL_MODE_HUE:
|
||||
hsv_cur.h = angle;
|
||||
break;
|
||||
@@ -576,92 +509,59 @@ static lv_res_t lv_colorwheel_signal(lv_obj_t * colorwheel, lv_signal_t sign, vo
|
||||
break;
|
||||
}
|
||||
|
||||
if(lv_colorwheel_set_hsv(colorwheel, hsv_cur)) {
|
||||
res = lv_event_send(colorwheel, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(lv_colorwheel_set_hsv(obj, hsv_cur)) {
|
||||
res = lv_event_send(obj, 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_colorwheel_hit(colorwheel, info->point);
|
||||
|
||||
/*Valid clicks can be only in the circle*/
|
||||
info->result = _lv_area_is_point_on(&obj->coords, info->point, LV_RADIUS_CIRCLE);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the style_list descriptor of a part of the object
|
||||
* @param colorwheel pointer the object
|
||||
* @param part the part of the colorwheel. (LV_PAGE_CPICKER_...)
|
||||
* @return pointer to the style_list descriptor of the specified part
|
||||
*/
|
||||
static lv_style_list_t * lv_colorwheel_get_style(lv_obj_t * colorwheel, uint8_t part)
|
||||
|
||||
static void next_color_mode(lv_obj_t * obj)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_style_list_t * style_dsc_p;
|
||||
|
||||
switch(part) {
|
||||
case LV_COLORWHEEL_PART_MAIN :
|
||||
style_dsc_p = &colorwheel->style_list;
|
||||
break;
|
||||
case LV_COLORWHEEL_PART_KNOB:
|
||||
style_dsc_p = &ext->knob.style_list;
|
||||
break;
|
||||
default:
|
||||
style_dsc_p = NULL;
|
||||
}
|
||||
|
||||
return style_dsc_p;
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
colorwheel->mode = (colorwheel->mode + 1) % 3;
|
||||
refr_knob_pos(obj);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
static bool lv_colorwheel_hit(lv_obj_t * colorwheel, const lv_point_t * p)
|
||||
static void refr_knob_pos(lv_obj_t * obj)
|
||||
{
|
||||
bool is_point_on_coords = _lv_obj_is_click_point_on(colorwheel, p);
|
||||
if(!is_point_on_coords) return false;
|
||||
invalidate_knob(obj);
|
||||
|
||||
/*Valid clicks can be only in the circle*/
|
||||
if(_lv_area_is_point_on(&colorwheel->coords, p, LV_RADIUS_CIRCLE)) return true;
|
||||
else return false;
|
||||
}
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
lv_coord_t w = lv_obj_get_width(obj);
|
||||
|
||||
static void next_color_mode(lv_obj_t * colorwheel)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
ext->mode = (ext->mode + 1) % 3;
|
||||
refr_knob_pos(colorwheel);
|
||||
lv_obj_invalidate(colorwheel);
|
||||
}
|
||||
|
||||
static void refr_knob_pos(lv_obj_t * colorwheel)
|
||||
{
|
||||
invalidate_knob(colorwheel);
|
||||
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_coord_t w = lv_obj_get_width(colorwheel);
|
||||
lv_coord_t h = lv_obj_get_height(colorwheel);
|
||||
|
||||
lv_coord_t scale_w = lv_obj_get_style_scale_width(colorwheel, LV_COLORWHEEL_PART_MAIN);
|
||||
lv_coord_t scale_w = lv_obj_get_style_arc_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t r = (w - scale_w) / 2;
|
||||
uint16_t angle = get_angle(colorwheel);
|
||||
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;
|
||||
uint16_t angle = get_angle(obj);
|
||||
colorwheel->knob.pos.x = (((int32_t)r * lv_trigo_sin(angle)) >> LV_TRIGO_SHIFT);
|
||||
colorwheel->knob.pos.y = (((int32_t)r * lv_trigo_cos(angle)) >> LV_TRIGO_SHIFT);
|
||||
colorwheel->knob.pos.x = colorwheel->knob.pos.x + w / 2;
|
||||
colorwheel->knob.pos.y = colorwheel->knob.pos.y + w / 2;
|
||||
|
||||
invalidate_knob(colorwheel);
|
||||
invalidate_knob(obj);
|
||||
}
|
||||
|
||||
static lv_res_t double_click_reset(lv_obj_t * colorwheel)
|
||||
static lv_res_t double_click_reset(lv_obj_t * obj)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
/*Double clicked? Use long press time as double click time out*/
|
||||
if(lv_tick_elaps(ext->last_click_time) < indev->driver.long_press_time) {
|
||||
if(lv_tick_elaps(colorwheel->last_click_time) < indev->driver.long_press_time) {
|
||||
lv_color_hsv_t hsv_cur;
|
||||
hsv_cur = ext->hsv;
|
||||
hsv_cur = colorwheel->hsv;
|
||||
|
||||
switch(ext->mode) {
|
||||
switch(colorwheel->mode) {
|
||||
case LV_COLORWHEEL_MODE_HUE:
|
||||
hsv_cur.h = 0;
|
||||
break;
|
||||
@@ -675,51 +575,51 @@ static lv_res_t double_click_reset(lv_obj_t * colorwheel)
|
||||
|
||||
lv_indev_wait_release(indev);
|
||||
|
||||
if(lv_colorwheel_set_hsv(colorwheel, hsv_cur)) {
|
||||
lv_res_t res = lv_event_send(colorwheel, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(lv_colorwheel_set_hsv(obj, hsv_cur)) {
|
||||
lv_res_t res = lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
}
|
||||
ext->last_click_time = lv_tick_get();
|
||||
colorwheel->last_click_time = lv_tick_get();
|
||||
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
static lv_color_t angle_to_mode_color(lv_obj_t * colorwheel, uint16_t angle)
|
||||
static lv_color_t angle_to_mode_color(lv_obj_t * obj, uint16_t angle)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
lv_color_t color;
|
||||
angle = angle % 360;
|
||||
|
||||
switch(ext->mode) {
|
||||
switch(colorwheel->mode) {
|
||||
default:
|
||||
case LV_COLORWHEEL_MODE_HUE:
|
||||
color = lv_color_hsv_to_rgb(angle, ext->hsv.s, ext->hsv.v);
|
||||
color = lv_color_hsv_to_rgb(angle, colorwheel->hsv.s, colorwheel->hsv.v);
|
||||
break;
|
||||
case LV_COLORWHEEL_MODE_SATURATION:
|
||||
color = lv_color_hsv_to_rgb(ext->hsv.h, (angle * 100) / 360, ext->hsv.v);
|
||||
color = lv_color_hsv_to_rgb(colorwheel->hsv.h, (angle * 100) / 360, colorwheel->hsv.v);
|
||||
break;
|
||||
case LV_COLORWHEEL_MODE_VALUE:
|
||||
color = lv_color_hsv_to_rgb(ext->hsv.h, ext->hsv.s, (angle * 100) / 360);
|
||||
color = lv_color_hsv_to_rgb(colorwheel->hsv.h, colorwheel->hsv.s, (angle * 100) / 360);
|
||||
break;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
static uint16_t get_angle(lv_obj_t * colorwheel)
|
||||
static uint16_t get_angle(lv_obj_t * obj)
|
||||
{
|
||||
lv_colorwheel_ext_t * ext = lv_obj_get_ext_attr(colorwheel);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *) obj;
|
||||
uint16_t angle;
|
||||
switch(ext->mode) {
|
||||
switch(colorwheel->mode) {
|
||||
default:
|
||||
case LV_COLORWHEEL_MODE_HUE:
|
||||
angle = ext->hsv.h;
|
||||
angle = colorwheel->hsv.h;
|
||||
break;
|
||||
case LV_COLORWHEEL_MODE_SATURATION:
|
||||
angle = (ext->hsv.s * 360) / 100;
|
||||
angle = (colorwheel->hsv.s * 360) / 100;
|
||||
break;
|
||||
case LV_COLORWHEEL_MODE_VALUE:
|
||||
angle = (ext->hsv.v * 360) / 100 ;
|
||||
angle = (colorwheel->hsv.v * 360) / 100 ;
|
||||
break;
|
||||
}
|
||||
return angle;
|
||||
|
||||
@@ -13,7 +13,7 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../../lv_core/lv_obj.h"
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_COLORWHEEL
|
||||
|
||||
@@ -35,9 +35,9 @@ typedef uint8_t lv_colorwheel_mode_t;
|
||||
|
||||
/*Data of color picker*/
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
lv_color_hsv_t hsv;
|
||||
struct {
|
||||
lv_style_list_t style_list;
|
||||
lv_point_t pos;
|
||||
uint8_t recolor : 1;
|
||||
} knob;
|
||||
@@ -46,15 +46,9 @@ typedef struct {
|
||||
lv_point_t last_press_point;
|
||||
lv_colorwheel_mode_t mode : 2;
|
||||
uint8_t mode_fixed : 1;
|
||||
} lv_colorwheel_ext_t;
|
||||
|
||||
/*Parts*/
|
||||
enum {
|
||||
LV_COLORWHEEL_PART_MAIN = LV_OBJ_PART_MAIN,
|
||||
LV_COLORWHEEL_PART_KNOB,
|
||||
_LV_COLORWHEEL_PART_VIRTUAL_LAST,
|
||||
};
|
||||
} lv_colorwheel_t;
|
||||
|
||||
extern const lv_obj_class_t lv_colorwheel_class;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// * INCLUDES
|
||||
// *********************/
|
||||
//
|
||||
//#include "../lv_misc/lv_debug.h"
|
||||
//#include "../lv_misc/lv_assert.h"
|
||||
//#include "lv_imgbtn.h"
|
||||
//#include "lv_label.h"
|
||||
//
|
||||
@@ -58,12 +58,12 @@
|
||||
//
|
||||
// /*Create the ancestor of image button*/
|
||||
// lv_obj_t * imgbtn = lv_btn_create(par, copy);
|
||||
// LV_ASSERT_MEM(imgbtn);
|
||||
// LV_ASSERT_MALLOC(imgbtn);
|
||||
// if(imgbtn == NULL) return NULL;
|
||||
//
|
||||
// /*Allocate the image button type specific extended data*/
|
||||
// lv_imgbtn_ext_t * ext = lv_obj_allocate_ext_attr(imgbtn, sizeof(lv_imgbtn_ext_t));
|
||||
// LV_ASSERT_MEM(ext);
|
||||
// LV_ASSERT_MALLOC(ext);
|
||||
// if(ext == NULL) {
|
||||
// lv_obj_del(imgbtn);
|
||||
// return NULL;
|
||||
|
||||
@@ -71,14 +71,14 @@ lv_obj_t * lv_led_create(lv_obj_t * parent)
|
||||
|
||||
/*Create the ancestor basic object*/
|
||||
lv_obj_t * led = lv_obj_create(parent, NULL);
|
||||
LV_ASSERT_MEM(led);
|
||||
LV_ASSERT_MALLOC(led);
|
||||
if(led == NULL) return NULL;
|
||||
|
||||
if(ancestor_draw == NULL) ancestor_draw = lv_obj_get_draw_cb(led);
|
||||
|
||||
/*Allocate the object type specific extended data*/
|
||||
lv_led_ext_t * ext = lv_obj_allocate_ext_attr(led, sizeof(lv_led_ext_t));
|
||||
LV_ASSERT_MEM(ext);
|
||||
LV_ASSERT_MALLOC(ext);
|
||||
if(ext == NULL) {
|
||||
lv_obj_del(led);
|
||||
return NULL;
|
||||
|
||||
@@ -23,6 +23,7 @@ extern "C" {
|
||||
#include "tabview/lv_tabview.h"
|
||||
#include "tileview/lv_tileview.h"
|
||||
#include "win/lv_win.h"
|
||||
#include "colorwheel/lv_colorwheel.h"
|
||||
|
||||
|
||||
/*********************
|
||||
|
||||
@@ -50,7 +50,7 @@ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * b
|
||||
lv_obj_remove_style(parent, LV_PART_ANY, LV_STATE_ANY, NULL);
|
||||
|
||||
lv_obj_t * mbox = lv_obj_create_from_class(&lv_msgbox_class, parent, NULL);
|
||||
LV_ASSERT_MEM(mbox);
|
||||
LV_ASSERT_MALLOC(mbox);
|
||||
if(mbox == NULL) return NULL;
|
||||
|
||||
lv_coord_t w = lv_obj_get_width_fit(parent);
|
||||
|
||||
@@ -320,7 +320,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * obj, lv_signal_t sign, void * param
|
||||
if(new_step >= spinbox->range_max) break;
|
||||
spinbox->step = new_step;
|
||||
}
|
||||
lv_spinbox_step_prev(spinbox);
|
||||
lv_spinbox_step_prev(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -365,7 +365,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * obj, lv_signal_t sign, void * param
|
||||
}
|
||||
else if(c == LV_KEY_LEFT) {
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER)
|
||||
lv_spinbox_decrement(spinbox);
|
||||
lv_spinbox_decrement(obj);
|
||||
else
|
||||
lv_spinbox_step_prev(obj);
|
||||
}
|
||||
@@ -453,7 +453,7 @@ static void lv_spinbox_updatevalue(lv_obj_t * obj)
|
||||
|
||||
cur_pos -= cur_shift_left;
|
||||
|
||||
lv_textarea_set_cursor_pos(spinbox, cur_pos);
|
||||
lv_textarea_set_cursor_pos(obj, cur_pos);
|
||||
}
|
||||
|
||||
#endif /*LV_USE_SPINBOX*/
|
||||
|
||||
@@ -44,7 +44,7 @@ lv_obj_t * lv_spinner_create(lv_obj_t * par, uint32_t time, uint32_t arc_length)
|
||||
{
|
||||
/*Create the ancestor of spinner*/
|
||||
lv_obj_t * spinner = lv_arc_create(par, NULL);
|
||||
LV_ASSERT_MEM(spinner);
|
||||
LV_ASSERT_MALLOC(spinner);
|
||||
if(spinner == NULL) return NULL;
|
||||
|
||||
lv_obj_set_size(spinner, LV_DPI_DEF, LV_DPI_DEF);
|
||||
|
||||
@@ -54,7 +54,7 @@ void _lv_group_init(void)
|
||||
lv_group_t * lv_group_create(void)
|
||||
{
|
||||
lv_group_t * group = _lv_ll_ins_head(&LV_GC_ROOT(_lv_group_ll));
|
||||
LV_ASSERT_MEM(group);
|
||||
LV_ASSERT_MALLOC(group);
|
||||
if(group == NULL) return NULL;
|
||||
_lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *));
|
||||
|
||||
@@ -127,7 +127,7 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
||||
obj->spec_attr->group_p = group;
|
||||
|
||||
lv_obj_t ** next = _lv_ll_ins_tail(&group->obj_ll);
|
||||
LV_ASSERT_MEM(next);
|
||||
LV_ASSERT_MALLOC(next);
|
||||
if(next == NULL) return;
|
||||
*next = obj;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "lv_group.h"
|
||||
#include "lv_disp.h"
|
||||
#include "lv_theme.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_misc/lv_anim.h"
|
||||
#include "../lv_misc/lv_timer.h"
|
||||
@@ -41,7 +41,6 @@
|
||||
#define STYLE_TRANSITION_MAX 32
|
||||
#define SCROLLBAR_MIN_SIZE (LV_DPX(10))
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@@ -421,7 +420,7 @@ void lv_obj_add_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb, void * user_dat
|
||||
|
||||
obj->spec_attr->event_dsc_cnt++;
|
||||
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc, obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
|
||||
LV_ASSERT_MEM(obj->spec_attr->event_dsc);
|
||||
LV_ASSERT_MALLOC(obj->spec_attr->event_dsc);
|
||||
|
||||
obj->spec_attr->event_dsc[obj->spec_attr->event_dsc_cnt - 1].cb = event_cb;
|
||||
obj->spec_attr->event_dsc[obj->spec_attr->event_dsc_cnt - 1].user_data = user_data;
|
||||
@@ -527,7 +526,7 @@ void lv_obj_allocate_spec_attr(lv_obj_t * obj)
|
||||
static uint32_t x = 0;
|
||||
x++;
|
||||
obj->spec_attr = lv_mem_alloc(sizeof(lv_obj_spec_attr_t));
|
||||
LV_ASSERT_MEM(obj->spec_attr);
|
||||
LV_ASSERT_MALLOC(obj->spec_attr);
|
||||
if(obj->spec_attr == NULL) return;
|
||||
|
||||
lv_memset_00(obj->spec_attr, sizeof(lv_obj_spec_attr_t));
|
||||
@@ -550,18 +549,24 @@ lv_obj_t * lv_obj_get_focused_obj(const lv_obj_t * obj)
|
||||
return (lv_obj_t *)focus_obj;
|
||||
}
|
||||
|
||||
bool lv_obj_check_type(const lv_obj_t * obj, const void * class_p)
|
||||
bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p)
|
||||
{
|
||||
if(obj == NULL) return false;
|
||||
return obj->class_p == class_p ? true : false;
|
||||
}
|
||||
|
||||
bool _lv_debug_check_obj_type(const lv_obj_t * obj, const char * obj_type)
|
||||
bool lv_obj_has_class(const lv_obj_t * obj, const lv_obj_class_t * class_p)
|
||||
{
|
||||
return true;
|
||||
lv_obj_class_t * obj_class = obj->class_p;
|
||||
while(obj_class) {
|
||||
if(obj_class == class_p) return true;
|
||||
obj_class = obj_class->base_class;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _lv_debug_check_obj_valid(const lv_obj_t * obj)
|
||||
bool lv_obj_is_valid(const lv_obj_t * obj)
|
||||
{
|
||||
lv_disp_t * disp = lv_disp_get_next(NULL);
|
||||
while(disp) {
|
||||
@@ -1135,9 +1140,11 @@ static void base_dir_refr_children(lv_obj_t * obj)
|
||||
static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find)
|
||||
{
|
||||
/*Check all children of `parent`*/
|
||||
uint32_t child_cnt = 0;
|
||||
if(parent->spec_attr) child_cnt = parent->spec_attr->child_cnt;
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(parent); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(parent, i);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = parent->spec_attr->children[i];
|
||||
if(child == obj_to_find) return true;
|
||||
|
||||
/*Check the children*/
|
||||
|
||||
@@ -21,7 +21,7 @@ extern "C" {
|
||||
#include "../lv_misc/lv_types.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_hal/lv_hal.h"
|
||||
|
||||
/*********************
|
||||
@@ -484,7 +484,7 @@ lv_obj_t * lv_obj_get_focused_obj(const lv_obj_t * obj);
|
||||
* @param obj pointer to an object which type should be get
|
||||
* @param buf pointer to an `lv_obj_type_t` buffer to store the types
|
||||
*/
|
||||
bool lv_obj_check_type(const lv_obj_t * obj, const void * class_p);
|
||||
bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p);
|
||||
|
||||
/**
|
||||
* Check if any object has a given type
|
||||
@@ -492,7 +492,7 @@ bool lv_obj_check_type(const lv_obj_t * obj, const void * class_p);
|
||||
* @param obj_type type of the object. (e.g. "lv_btn")
|
||||
* @return true: valid
|
||||
*/
|
||||
bool _lv_debug_check_obj_type(const lv_obj_t * obj, const char * obj_type);
|
||||
bool lv_obj_has_class(const lv_obj_t * obj, const lv_obj_class_t * class_p);
|
||||
|
||||
/**
|
||||
* Check if any object is still "alive", and part of the hierarchy
|
||||
@@ -500,34 +500,20 @@ bool _lv_debug_check_obj_type(const lv_obj_t * obj, const char * obj_type);
|
||||
* @param obj_type type of the object. (e.g. "lv_btn")
|
||||
* @return true: valid
|
||||
*/
|
||||
bool _lv_debug_check_obj_valid(const lv_obj_t * obj);
|
||||
bool lv_obj_is_valid(const lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#if LV_USE_DEBUG
|
||||
#if LV_USE_ASSERT && LV_USE_ASSERT_OBJ
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_class) \
|
||||
LV_ASSERT_MSG(obj_p != NULL, "The object is NULL"); \
|
||||
LV_ASSERT_MSG(lv_obj_has_class(obj_p, obj_class) == true, "Incompatible object type."); \
|
||||
LV_ASSERT_MSG(lv_obj_is_valid(obj_p) == true, "The object is invalid, deleted or corrupted?");
|
||||
|
||||
# ifndef LV_DEBUG_IS_OBJ
|
||||
# define LV_DEBUG_IS_OBJ(obj_p, obj_type) (lv_debug_check_null(obj_p) && \
|
||||
_lv_debug_check_obj_valid(obj_p) && \
|
||||
_lv_debug_check_obj_type(obj_p, obj_type))
|
||||
# endif
|
||||
|
||||
|
||||
# if LV_USE_ASSERT_OBJ
|
||||
# ifndef LV_ASSERT_OBJ
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_type) LV_DEBUG_ASSERT(LV_DEBUG_IS_OBJ(obj_p, obj_type), "Invalid object", obj_p);
|
||||
# endif
|
||||
# else /* LV_USE_ASSERT_OBJ == 0 */
|
||||
# if LV_USE_ASSERT_NULL /*Use at least LV_ASSERT_NULL if enabled*/
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_type) LV_ASSERT_NULL(obj_p)
|
||||
# else
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_type)
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# define LV_ASSERT_OBJ(obj, obj_type)
|
||||
# else
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_class) do{}while(0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_obj.h"
|
||||
#include "lv_disp.h"
|
||||
#include "lv_refr.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -43,7 +45,6 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
if(lv_obj_is_layout_positioned(obj)) {
|
||||
LV_LOG_WARN("Can't set position because the position is set by a layout");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -559,6 +560,11 @@ void lv_obj_get_click_area(const lv_obj_t * obj, lv_area_t * area)
|
||||
|
||||
bool lv_obj_hit_test(lv_obj_t * obj, const lv_point_t * point)
|
||||
{
|
||||
lv_area_t a;
|
||||
lv_obj_get_click_area(obj, &a);
|
||||
bool res = _lv_area_is_point_on(&a, point, 0);
|
||||
if(res == false) return false;
|
||||
|
||||
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_ADV_HITTEST)) {
|
||||
lv_hit_test_info_t hit_info;
|
||||
hit_info.point = point;
|
||||
@@ -566,11 +572,8 @@ bool lv_obj_hit_test(lv_obj_t * obj, const lv_point_t * point)
|
||||
lv_signal_send(obj, LV_SIGNAL_HIT_TEST, &hit_info);
|
||||
return hit_info.result;
|
||||
}
|
||||
else {
|
||||
lv_area_t a;
|
||||
lv_obj_get_click_area(obj, &a);
|
||||
return _lv_area_is_point_on(&a, point, 0);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ void lv_obj_style_create_transition(lv_obj_t * obj, lv_style_prop_t prop, uint8_
|
||||
}
|
||||
|
||||
tr = _lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
|
||||
LV_ASSERT_MEM(tr);
|
||||
LV_ASSERT_MALLOC(tr);
|
||||
if(tr == NULL) return;
|
||||
tr->start_value = v1;
|
||||
tr->end_value = v2;
|
||||
|
||||
@@ -656,9 +656,9 @@ static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p)
|
||||
}
|
||||
|
||||
/*Call the post draw draw function of the parents of the to object*/
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST_BEGIN, mask_p);
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST_BEGIN, (void*)mask_p);
|
||||
call_draw_cb(par, mask_p, LV_DRAW_MODE_POST_DRAW);
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST_END, mask_p);
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST_END, (void*)mask_p);
|
||||
|
||||
/*The new border will be the last parents,
|
||||
*so the 'younger' brothers of parent will be refreshed*/
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "../lv_core/lv_refr.h"
|
||||
#include "../lv_misc/lv_bidi.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -381,7 +381,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
||||
if(pos.y > mask->y2) return;
|
||||
}
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
LV_ASSERT_MALLOC_INTEGRITY();
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#if LV_DRAW_COMPLEX
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_misc/lv_log.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
|
||||
/*********************
|
||||
@@ -331,16 +331,16 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert
|
||||
param->dsc.cb = (lv_draw_mask_xcb_t)lv_draw_mask_angle;
|
||||
param->dsc.type = LV_DRAW_MASK_TYPE_ANGLE;
|
||||
|
||||
LV_ASSERT_MSG(start_angle < 0 && start_angle >= 360, "Unexpected start angle");
|
||||
|
||||
if(start_angle >= 0 && start_angle < 180) {
|
||||
start_side = LV_DRAW_MASK_LINE_SIDE_LEFT;
|
||||
}
|
||||
else if(start_angle >= 180 && start_angle < 360) {
|
||||
start_side = LV_DRAW_MASK_LINE_SIDE_RIGHT;
|
||||
}
|
||||
else {
|
||||
LV_DEBUG_ASSERT(false, "Unexpected start_angle", start_angle);
|
||||
return;
|
||||
}
|
||||
|
||||
LV_ASSERT_MSG(end_angle < 0 && start_angle >= 360, "Unexpected end angle");
|
||||
|
||||
if(end_angle >= 0 && end_angle < 180) {
|
||||
end_side = LV_DRAW_MASK_LINE_SIDE_RIGHT;
|
||||
@@ -348,10 +348,6 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert
|
||||
else if(end_angle >= 180 && end_angle < 360) {
|
||||
end_side = LV_DRAW_MASK_LINE_SIDE_LEFT;
|
||||
}
|
||||
else {
|
||||
LV_DEBUG_ASSERT(false, "Unexpected end_angle", end_angle);
|
||||
return;
|
||||
}
|
||||
|
||||
lv_draw_mask_line_angle_init(¶m->start_line, vertex_x, vertex_y, start_angle, start_side);
|
||||
lv_draw_mask_line_angle_init(¶m->end_line, vertex_x, vertex_y, end_angle, end_side);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_misc/lv_txt_ap.h"
|
||||
#include "../lv_core/lv_refr.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -112,7 +112,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_dra
|
||||
|
||||
draw_outline(coords, clip, dsc);
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
LV_ASSERT_MALLOC_INTEGRITY();
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "lv_img_cache.h"
|
||||
#include "lv_img_decoder.h"
|
||||
#include "lv_draw_img.h"
|
||||
@@ -172,7 +172,7 @@ void lv_img_cache_set_size(uint16_t new_entry_cnt)
|
||||
|
||||
/*Reallocate the cache*/
|
||||
LV_GC_ROOT(_lv_img_cache_array) = lv_mem_alloc(sizeof(lv_img_cache_entry_t) * new_entry_cnt);
|
||||
LV_ASSERT_MEM(LV_GC_ROOT(_lv_img_cache_array));
|
||||
LV_ASSERT_MALLOC(LV_GC_ROOT(_lv_img_cache_array));
|
||||
if(LV_GC_ROOT(_lv_img_cache_array) == NULL) {
|
||||
entry_cnt = 0;
|
||||
return;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_img_decoder.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_draw/lv_draw_img.h"
|
||||
#include "../lv_misc/lv_ll.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
@@ -63,7 +63,7 @@ void _lv_img_decoder_init(void)
|
||||
decoder = lv_img_decoder_create();
|
||||
if(decoder == NULL) {
|
||||
LV_LOG_WARN("lv_img_decoder_init: out of memory");
|
||||
LV_ASSERT_MEM(decoder);
|
||||
LV_ASSERT_MALLOC(decoder);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ lv_img_decoder_t * lv_img_decoder_create(void)
|
||||
{
|
||||
lv_img_decoder_t * decoder;
|
||||
decoder = _lv_ll_ins_head(&LV_GC_ROOT(_lv_img_defoder_ll));
|
||||
LV_ASSERT_MEM(decoder);
|
||||
LV_ASSERT_MALLOC(decoder);
|
||||
if(decoder == NULL) return NULL;
|
||||
|
||||
lv_memset_00(decoder, sizeof(lv_img_decoder_t));
|
||||
@@ -323,7 +323,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
||||
/*If the file was open successfully save the file descriptor*/
|
||||
if(dsc->user_data == NULL) {
|
||||
dsc->user_data = lv_mem_alloc(sizeof(lv_img_decoder_built_in_data_t));
|
||||
LV_ASSERT_MEM(dsc->user_data);
|
||||
LV_ASSERT_MALLOC(dsc->user_data);
|
||||
if(dsc->user_data == NULL) {
|
||||
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
|
||||
return LV_RES_INV;
|
||||
@@ -366,7 +366,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
||||
/*Allocate the palette*/
|
||||
if(dsc->user_data == NULL) {
|
||||
dsc->user_data = lv_mem_alloc(sizeof(lv_img_decoder_built_in_data_t));
|
||||
LV_ASSERT_MEM(dsc->user_data);
|
||||
LV_ASSERT_MALLOC(dsc->user_data);
|
||||
if(dsc->user_data == NULL) {
|
||||
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
|
||||
lv_img_decoder_built_in_close(decoder, dsc);
|
||||
@@ -377,9 +377,9 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
||||
|
||||
lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
|
||||
user_data->palette = lv_mem_alloc(palette_size * sizeof(lv_color_t));
|
||||
LV_ASSERT_MEM(user_data->palette);
|
||||
LV_ASSERT_MALLOC(user_data->palette);
|
||||
user_data->opa = lv_mem_alloc(palette_size * sizeof(lv_opa_t));
|
||||
LV_ASSERT_MEM(user_data->opa);
|
||||
LV_ASSERT_MALLOC(user_data->opa);
|
||||
if(user_data->palette == NULL || user_data->opa == NULL) {
|
||||
LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
|
||||
lv_img_decoder_built_in_close(decoder, dsc);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*********************/
|
||||
#include "lv_font.h"
|
||||
#include "lv_font_fmt_txt.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_misc/lv_types.h"
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
@@ -115,7 +115,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
|
||||
|
||||
if(lv_mem_get_size(LV_GC_ROOT(_lv_font_decompr_buf)) < buf_size) {
|
||||
LV_GC_ROOT(_lv_font_decompr_buf) = lv_mem_realloc(LV_GC_ROOT(_lv_font_decompr_buf), buf_size);
|
||||
LV_ASSERT_MEM(LV_GC_ROOT(_lv_font_decompr_buf));
|
||||
LV_ASSERT_MALLOC(LV_GC_ROOT(_lv_font_decompr_buf));
|
||||
if(LV_GC_ROOT(_lv_font_decompr_buf) == NULL) return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "lv_hal.h"
|
||||
#include "../lv_misc/lv_mem.h"
|
||||
#include "../lv_misc/lv_gc.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_core/lv_obj.h"
|
||||
#include "../lv_core/lv_refr.h"
|
||||
|
||||
@@ -112,7 +112,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
|
||||
{
|
||||
lv_disp_t * disp = _lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll));
|
||||
if(!disp) {
|
||||
LV_ASSERT_MEM(disp);
|
||||
LV_ASSERT_MALLOC(disp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
|
||||
new display*/
|
||||
/*Create a refresh task*/
|
||||
disp->read_task = lv_timer_create(_lv_disp_refr_task, LV_DISP_DEF_REFR_PERIOD, disp);
|
||||
LV_ASSERT_MEM(disp->read_task);
|
||||
LV_ASSERT_MALLOC(disp->read_task);
|
||||
if(disp->read_task == NULL) return NULL;
|
||||
|
||||
disp->inv_p = 0;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_hal/lv_hal_indev.h"
|
||||
#include "../lv_core/lv_indev.h"
|
||||
#include "../lv_misc/lv_mem.h"
|
||||
@@ -81,7 +81,7 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver)
|
||||
|
||||
lv_indev_t * indev = _lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll));
|
||||
if(!indev) {
|
||||
LV_ASSERT_MEM(indev);
|
||||
LV_ASSERT_MALLOC(indev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_hal/lv_hal_tick.h"
|
||||
#include "lv_timer.h"
|
||||
#include "lv_math.h"
|
||||
@@ -96,7 +96,7 @@ void lv_anim_start(lv_anim_t * a)
|
||||
|
||||
/*Add the new animation to the animation linked list*/
|
||||
lv_anim_t * new_anim = _lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll));
|
||||
LV_ASSERT_MEM(new_anim);
|
||||
LV_ASSERT_MALLOC(new_anim);
|
||||
if(new_anim == NULL) return;
|
||||
|
||||
/*Initialize the animation descriptor*/
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* @file lv_debug.c
|
||||
* @file lv_assert.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_debug.h"
|
||||
#include "lv_assert.h"
|
||||
|
||||
#if LV_USE_DEBUG
|
||||
#if LV_USE_ASSERT
|
||||
|
||||
#include "lv_mem.h"
|
||||
#include <string.h>
|
||||
@@ -135,4 +135,4 @@ void lv_debug_log_error(const char * msg, uint64_t value)
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_DEBUG*/
|
||||
#endif /*LV_USE_ASSERT*/
|
||||
100
src/lv_misc/lv_assert.h
Normal file
100
src/lv_misc/lv_assert.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* @file lv_assert.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_ASSERT_H
|
||||
#define LV_ASSERT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#if LV_USE_ASSERT
|
||||
#include <stdbool.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
bool lv_debug_check_null(const void * p);
|
||||
|
||||
bool lv_debug_check_mem_integrity(void);
|
||||
|
||||
bool lv_debug_check_str(const void * str);
|
||||
|
||||
void lv_debug_log_error(const char * msg, uint64_t value);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#define LV_ASSERT(expr) \
|
||||
do { \
|
||||
if(!(expr)) { \
|
||||
LV_LOG_ERROR("Asserted at expression: %s", #expr); \
|
||||
LV_ASSERT_HANDLER \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define LV_ASSERT_MSG(expr, msg) \
|
||||
do { \
|
||||
if(!(expr)) { \
|
||||
LV_LOG_ERROR("Asserted at expression: %s (%s)", #expr, msg); \
|
||||
LV_ASSERT_HANDLER \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
|
||||
/*-----------------
|
||||
* ASSERTS
|
||||
*-----------------*/
|
||||
|
||||
#if LV_USE_ASSERT_NULL
|
||||
# define LV_ASSERT_NULL(p) LV_ASSERT_MSG(p != NULL, "NULL pointer");
|
||||
#else
|
||||
# define LV_ASSERT_NULL(p)
|
||||
#endif
|
||||
|
||||
#if LV_USE_ASSERT_MALLOC
|
||||
# define LV_ASSERT_MALLOC(p) LV_ASSERT_MSG(p != NULL, "Out of memory");
|
||||
#else
|
||||
# define LV_ASSERT_MALLOC(p)
|
||||
#endif
|
||||
|
||||
#if LV_USE_ASSERT_MEM_INTEGRITY
|
||||
# define LV_ASSERT_MALLOC_INTEGRITY() LV_ASSERT_MSG(lv_mem_test() == LV_RES_OK, "Memory integrity error");
|
||||
#else
|
||||
# define LV_ASSERT_MALLOC_INTEGRIT()
|
||||
#endif
|
||||
|
||||
#else /* LV_USE_ASSERT == 0 */
|
||||
|
||||
#define LV_ASSERT(expr) do{}while(0)
|
||||
#define LV_ASSERT_MSG(expr, msg) do{}while(0)
|
||||
|
||||
#define LV_ASSERT_NULL(p)
|
||||
#define LV_ASSERT_MALLOC(p)
|
||||
#define LV_ASSERT_MALLOC_INTEGRITY()
|
||||
|
||||
#endif /* LV_USE_ASSERT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_ASSERT_H*/
|
||||
@@ -1,131 +0,0 @@
|
||||
/**
|
||||
* @file lv_debug.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_DEBUG_H
|
||||
#define LV_DEBUG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#if LV_USE_DEBUG
|
||||
#include <stdbool.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
bool lv_debug_check_null(const void * p);
|
||||
|
||||
bool lv_debug_check_mem_integrity(void);
|
||||
|
||||
bool lv_debug_check_str(const void * str);
|
||||
|
||||
void lv_debug_log_error(const char * msg, uint64_t value);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifndef LV_DEBUG_ASSERT
|
||||
#define LV_DEBUG_ASSERT(expr, msg, value) \
|
||||
do { \
|
||||
if(!(expr)) { \
|
||||
LV_LOG_ERROR(__func__); \
|
||||
lv_debug_log_error(msg, (uint64_t)((uintptr_t)value)); \
|
||||
while(1); \
|
||||
} \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/*----------------
|
||||
* CHECKS
|
||||
*----------------*/
|
||||
|
||||
#ifndef LV_DEBUG_IS_NULL
|
||||
#define LV_DEBUG_IS_NULL(p) (lv_debug_check_null(p))
|
||||
#endif
|
||||
|
||||
#ifndef LV_DEBUG_CHECK_MEM_INTEGRITY
|
||||
#define LV_DEBUG_CHECK_MEM_INTEGRITY() (lv_debug_check_mem_integrity())
|
||||
#endif
|
||||
|
||||
#ifndef LV_DEBUG_IS_STR
|
||||
#define LV_DEBUG_IS_STR(str) (lv_debug_check_null(str) && \
|
||||
lv_debug_check_str(str))
|
||||
#endif
|
||||
|
||||
/*-----------------
|
||||
* ASSERTS
|
||||
*-----------------*/
|
||||
|
||||
/*clang-format off*/
|
||||
|
||||
#if LV_USE_ASSERT_NULL
|
||||
# ifndef LV_ASSERT_NULL
|
||||
# define LV_ASSERT_NULL(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "NULL pointer", p);
|
||||
# endif
|
||||
#else
|
||||
# define LV_ASSERT_NULL(p)
|
||||
#endif
|
||||
|
||||
#if LV_USE_ASSERT_MEM
|
||||
# ifndef LV_ASSERT_MEM
|
||||
# define LV_ASSERT_MEM(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "Out of memory", p);
|
||||
# endif
|
||||
#else
|
||||
# define LV_ASSERT_MEM(p)
|
||||
#endif
|
||||
|
||||
#if LV_USE_ASSERT_MEM_INTEGRITY
|
||||
# ifndef LV_ASSERT_MEM_INTEGRITY
|
||||
# define LV_ASSERT_MEM_INTEGRITY() LV_DEBUG_ASSERT(LV_DEBUG_CHECK_MEM_INTEGRITY(), "Memory integrity error", 0);
|
||||
# endif
|
||||
#else
|
||||
# define LV_ASSERT_MEM_INTEGRITY()
|
||||
#endif
|
||||
|
||||
#if LV_USE_ASSERT_STR
|
||||
# ifndef LV_ASSERT_STR
|
||||
# define LV_ASSERT_STR(str) LV_DEBUG_ASSERT(LV_DEBUG_IS_STR(str), "Strange or invalid string", str);
|
||||
# endif
|
||||
#else /* LV_USE_ASSERT_OBJ == 0 */
|
||||
# if LV_USE_ASSERT_NULL /*Use at least LV_ASSERT_NULL if enabled*/
|
||||
# define LV_ASSERT_STR(str) LV_ASSERT_NULL(str)
|
||||
# else
|
||||
# define LV_ASSERT_STR(str)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#else /* LV_USE_DEBUG == 0 */
|
||||
|
||||
#define LV_DEBUG_ASSERT(expr, msg, value) do{}while(0)
|
||||
|
||||
#define LV_ASSERT_NULL(p)
|
||||
#define LV_ASSERT_MEM(p)
|
||||
#define LV_ASSERT_MEM_INTEGRITY()
|
||||
#define LV_ASSERT_STR(p)
|
||||
#define LV_ASSERT_OBJ(obj, obj_type)
|
||||
|
||||
#endif /* LV_USE_DEBUG */
|
||||
/*clang-format on*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_DEBUG_H*/
|
||||
@@ -8,7 +8,7 @@
|
||||
*********************/
|
||||
#include "lv_fs.h"
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "lv_ll.h"
|
||||
#include <string.h>
|
||||
#include "lv_gc.h"
|
||||
@@ -225,7 +225,7 @@ lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path)
|
||||
}
|
||||
|
||||
rddir_p->dir_d = lv_mem_alloc(rddir_p->drv->rddir_size);
|
||||
LV_ASSERT_MEM(rddir_p->dir_d);
|
||||
LV_ASSERT_MALLOC(rddir_p->dir_d);
|
||||
if(rddir_p->dir_d == NULL) {
|
||||
rddir_p->drv = NULL;
|
||||
return LV_FS_RES_OUT_OF_MEM; /* Out of memory */
|
||||
@@ -288,7 +288,7 @@ void lv_fs_drv_register(lv_fs_drv_t * drv_p)
|
||||
/*Save the new driver*/
|
||||
lv_fs_drv_t * new_drv;
|
||||
new_drv = _lv_ll_ins_head(&LV_GC_ROOT(_lv_drv_ll));
|
||||
LV_ASSERT_MEM(new_drv);
|
||||
LV_ASSERT_MALLOC(new_drv);
|
||||
if(new_drv == NULL) return;
|
||||
|
||||
lv_memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t));
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "lv_mem.h"
|
||||
#include "lv_math.h"
|
||||
#include "lv_gc.h"
|
||||
#include "lv_debug.h"
|
||||
#include "lv_assert.h"
|
||||
#include <string.h>
|
||||
|
||||
#if LV_MEM_CUSTOM != 0
|
||||
@@ -484,10 +484,7 @@ void * lv_mem_buf_get(uint32_t size)
|
||||
if(LV_GC_ROOT(lv_mem_buf[i]).used == 0) {
|
||||
/*if this fails you probably need to increase your LV_MEM_SIZE/heap size*/
|
||||
void * buf = lv_mem_realloc(LV_GC_ROOT(lv_mem_buf[i]).p, size);
|
||||
if(buf == NULL) {
|
||||
LV_DEBUG_ASSERT(false, "Out of memory, can't allocate a new buffer (increase your LV_MEM_SIZE/heap size)", 0x00);
|
||||
return NULL;
|
||||
}
|
||||
LV_ASSERT_MSG(buf != NULL, "Out of memory, can't allocate a new buffer (increase your LV_MEM_SIZE/heap size)");
|
||||
LV_GC_ROOT(lv_mem_buf[i]).used = 1;
|
||||
LV_GC_ROOT(lv_mem_buf[i]).size = size;
|
||||
LV_GC_ROOT(lv_mem_buf[i]).p = buf;
|
||||
@@ -495,7 +492,7 @@ void * lv_mem_buf_get(uint32_t size)
|
||||
}
|
||||
}
|
||||
|
||||
LV_DEBUG_ASSERT(false, "No free buffer. Increase LV_MEM_BUF_MAX_NUM.", 0x00);
|
||||
LV_ASSERT_MSG(false, "No free buffer. Increase LV_MEM_BUF_MAX_NUM.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,14 +41,14 @@
|
||||
void lv_style_init(lv_style_t * style)
|
||||
{
|
||||
#if LV_USE_ASSERT_STYLE
|
||||
if(style->sentinel == LV_DEBUG_STYLE_SENTINEL_VALUE && style->allocated && style->values_and_props != NULL) {
|
||||
if(style->sentinel == LV_STYLE_SENTINEL_VALUE && style->allocated && style->values_and_props != NULL) {
|
||||
LV_LOG_WARN("Style might be already inited. (Potential memory leak)")
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_memset_00(style, sizeof(lv_style_t));
|
||||
#if LV_USE_ASSERT_STYLE
|
||||
style->sentinel = LV_DEBUG_STYLE_SENTINEL_VALUE;
|
||||
style->sentinel = LV_STYLE_SENTINEL_VALUE;
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -70,7 +70,6 @@ lv_style_prop_t lv_style_register_prop(void)
|
||||
|
||||
bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop)
|
||||
{
|
||||
if(style == NULL) return false;
|
||||
LV_ASSERT_STYLE(style);
|
||||
|
||||
if(!style->allocated) {
|
||||
@@ -131,6 +130,8 @@ uint8_t lv_style_get_prop_group(lv_style_prop_t prop)
|
||||
|
||||
void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value)
|
||||
{
|
||||
LV_ASSERT_STYLE(style);
|
||||
|
||||
uint8_t group = lv_style_get_prop_group(prop);
|
||||
style->has_group |= 1 << group;
|
||||
|
||||
@@ -257,6 +258,7 @@ lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop)
|
||||
value.ptr = LV_THEME_FONT_NORMAL;
|
||||
break;
|
||||
case LV_STYLE_SIZE:
|
||||
case LV_STYLE_ARC_WIDTH:
|
||||
value.num = 10;
|
||||
break;
|
||||
default:
|
||||
@@ -275,20 +277,6 @@ bool lv_style_is_empty(const lv_style_t * style)
|
||||
return style->prop_cnt == 0 ? true : false;
|
||||
}
|
||||
|
||||
bool lv_debug_check_style(const lv_style_t * style)
|
||||
{
|
||||
if(style == NULL) return true; /*NULL style is still valid*/
|
||||
|
||||
#if LV_USE_ASSERT_STYLE
|
||||
if(style->sentinel != LV_DEBUG_STYLE_SENTINEL_VALUE) {
|
||||
LV_LOG_WARN("Invalid style (was local variable or not initialized?)");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
@@ -20,13 +20,13 @@ extern "C" {
|
||||
#include "lv_anim.h"
|
||||
#include "lv_txt.h"
|
||||
#include "lv_types.h"
|
||||
#include "lv_debug.h"
|
||||
#include "lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define LV_DEBUG_STYLE_SENTINEL_VALUE 0xAABBCCDD
|
||||
#define LV_STYLE_SENTINEL_VALUE 0xAABBCCDD
|
||||
|
||||
/**
|
||||
* Flags for style properties
|
||||
@@ -362,13 +362,6 @@ lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop);
|
||||
*/
|
||||
bool lv_style_is_empty(const lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Check whether a style is valid (initialized correctly)
|
||||
* @param style pointer to a style
|
||||
* @return true: valid
|
||||
*/
|
||||
bool lv_debug_check_style(const lv_style_t * style);
|
||||
|
||||
static inline void lv_style_set_radius(lv_style_t * style, lv_coord_t value) {
|
||||
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_RADIUS, v); }
|
||||
|
||||
@@ -664,42 +657,11 @@ static inline void lv_style_set_pad_all(lv_style_t * style, lv_coord_t value)
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create and initialize a `static` style
|
||||
* Example:
|
||||
* LV_STYLE_CREATE(my_style, &style_to_copy);
|
||||
* is equivalent to
|
||||
* static lv_style_t my_style;
|
||||
* lv_style_init(&my_style);
|
||||
* lv_style_copy(&my_style, &style_to_copy);
|
||||
*/
|
||||
#define LV_STYLE_CREATE(name, copy_p) static lv_style_t name; lv_style_init(&name); lv_style_copy(&name, copy_p);
|
||||
|
||||
#if LV_USE_DEBUG
|
||||
|
||||
# ifndef LV_DEBUG_IS_STYLE
|
||||
# define LV_DEBUG_IS_STYLE(style_p) (lv_debug_check_style(style_p))
|
||||
# endif
|
||||
|
||||
# ifndef LV_DEBUG_IS_STYLE_LIST
|
||||
# define LV_DEBUG_IS_STYLE_LIST(list_p) (lv_debug_check_style_list(list_p))
|
||||
# endif
|
||||
|
||||
# if LV_USE_ASSERT_STYLE
|
||||
# ifndef LV_ASSERT_STYLE
|
||||
# define LV_ASSERT_STYLE(style_p) LV_DEBUG_ASSERT(LV_DEBUG_IS_STYLE(style_p), "Invalid style", style_p);
|
||||
# endif
|
||||
# ifndef LV_ASSERT_STYLE_LIST
|
||||
# define LV_ASSERT_STYLE_LIST(list_p) LV_DEBUG_ASSERT(LV_DEBUG_IS_STYLE_LIST(list_p), "Invalid style list", list_p);
|
||||
# endif
|
||||
# else
|
||||
# define LV_ASSERT_STYLE(style_p)
|
||||
# define LV_ASSERT_STYLE_LIST(list_p)
|
||||
# endif
|
||||
|
||||
#if LV_USE_ASSERT && LV_USE_ASSERT_STYLE
|
||||
# define LV_ASSERT_STYLE(style_p) LV_ASSERT_MSG(style_p != NULL, "The style is NULL"); \
|
||||
LV_ASSERT_MSG(style_p->sentinel == LV_STYLE_SENTINEL_VALUE, "Style is not initialized or corrupted");
|
||||
#else
|
||||
# define LV_ASSERT_STYLE(p)
|
||||
# define LV_ASSERT_STYLE_LIST(p)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*********************/
|
||||
#include "lv_timer.h"
|
||||
#include <stddef.h>
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_hal/lv_hal_tick.h"
|
||||
#include "lv_gc.h"
|
||||
|
||||
@@ -151,7 +151,7 @@ lv_timer_t * lv_timer_create_basic(void)
|
||||
lv_timer_t * new_timer = NULL;
|
||||
|
||||
new_timer = _lv_ll_ins_head(&LV_GC_ROOT(_lv_timer_ll));
|
||||
LV_ASSERT_MEM(new_timer);
|
||||
LV_ASSERT_MALLOC(new_timer);
|
||||
if(new_timer == NULL) return NULL;
|
||||
|
||||
new_timer->period = DEF_PERIOD;
|
||||
@@ -178,7 +178,7 @@ lv_timer_t * lv_timer_create_basic(void)
|
||||
lv_timer_t * lv_timer_create(lv_timer_cb_t timer_xcb, uint32_t period, void * user_data)
|
||||
{
|
||||
lv_timer_t * new_timer = lv_timer_create_basic();
|
||||
LV_ASSERT_MEM(new_timer);
|
||||
LV_ASSERT_MALLOC(new_timer);
|
||||
if(new_timer == NULL) return NULL;
|
||||
|
||||
lv_timer_set_cb(new_timer, timer_xcb);
|
||||
@@ -307,7 +307,7 @@ static bool lv_timer_exec(lv_timer_t * timer)
|
||||
timer_deleted = false;
|
||||
timer_created = false;
|
||||
if(timer->timer_cb) timer->timer_cb(timer);
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
LV_ASSERT_MALLOC_INTEGRITY();
|
||||
|
||||
/*Delete if it was a one shot lv_timer*/
|
||||
if(timer_deleted == false) { /*The timer might be deleted by itself as well*/
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "lv_math.h"
|
||||
#include "lv_log.h"
|
||||
#include "lv_mem.h"
|
||||
#include "lv_debug.h"
|
||||
#include "lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -493,7 +493,7 @@ char * _lv_txt_set_text_vfmt(const char * fmt, va_list ap)
|
||||
#if LV_USE_ARABIC_PERSIAN_CHARS
|
||||
/*Put together the text according to the format string*/
|
||||
char * raw_txt = lv_mem_buf_get(len + 1);
|
||||
LV_ASSERT_MEM(raw_txt);
|
||||
LV_ASSERT_MALLOC(raw_txt);
|
||||
if(raw_txt == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -503,7 +503,7 @@ char * _lv_txt_set_text_vfmt(const char * fmt, va_list ap)
|
||||
/*Get the size of the Arabic text and process it*/
|
||||
size_t len_ap = _lv_txt_ap_calc_bytes_cnt(raw_txt);
|
||||
text = lv_mem_alloc(len_ap + 1);
|
||||
LV_ASSERT_MEM(text);
|
||||
LV_ASSERT_MALLOC(text);
|
||||
if(text == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -512,7 +512,7 @@ char * _lv_txt_set_text_vfmt(const char * fmt, va_list ap)
|
||||
lv_mem_buf_release(raw_txt);
|
||||
#else
|
||||
text = lv_mem_alloc(len + 1);
|
||||
LV_ASSERT_MEM(text);
|
||||
LV_ASSERT_MALLOC(text);
|
||||
if(text == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_core/lv_indev.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_draw/lv_draw_arc.h"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "lv_bar.h"
|
||||
#if LV_USE_BAR != 0
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_misc/lv_anim.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "lv_btnmatrix.h"
|
||||
#if LV_USE_BTNMATRIX != 0
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_core/lv_indev.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
@@ -857,9 +857,9 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * obj, const char **
|
||||
}
|
||||
|
||||
btnm->button_areas = lv_mem_alloc(sizeof(lv_area_t) * btn_cnt);
|
||||
LV_ASSERT_MEM(btnm->button_areas);
|
||||
LV_ASSERT_MALLOC(btnm->button_areas);
|
||||
btnm->ctrl_bits = lv_mem_alloc(sizeof(lv_btnmatrix_ctrl_t) * btn_cnt);
|
||||
LV_ASSERT_MEM(btnm->ctrl_bits);
|
||||
LV_ASSERT_MALLOC(btnm->ctrl_bits);
|
||||
if(btnm->button_areas == NULL || btnm->ctrl_bits == NULL) btn_cnt = 0;
|
||||
|
||||
lv_memset_00(btnm->ctrl_bits, sizeof(lv_btnmatrix_ctrl_t) * btn_cnt);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*********************/
|
||||
#include <stdlib.h>
|
||||
#include "lv_canvas.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_core/lv_refr.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "lv_chart.h"
|
||||
#if LV_USE_CHART != 0
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_core/lv_refr.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_core/lv_disp.h"
|
||||
@@ -103,7 +103,7 @@ void lv_chart_set_point_count(lv_obj_t * obj, uint16_t cnt)
|
||||
if(!ser->ext_buf_assigned) {
|
||||
if(ser->last_point != 0) {
|
||||
lv_coord_t * new_points = lv_mem_alloc(sizeof(lv_coord_t) * cnt);
|
||||
LV_ASSERT_MEM(new_points);
|
||||
LV_ASSERT_MALLOC(new_points);
|
||||
if(new_points == NULL) return;
|
||||
|
||||
if(cnt >= point_cnt_old) {
|
||||
@@ -128,7 +128,7 @@ void lv_chart_set_point_count(lv_obj_t * obj, uint16_t cnt)
|
||||
}
|
||||
else {
|
||||
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * cnt);
|
||||
LV_ASSERT_MEM(ser->points);
|
||||
LV_ASSERT_MALLOC(ser->points);
|
||||
if(ser->points == NULL) return;
|
||||
/*Initialize the new points*/
|
||||
if(cnt > point_cnt_old) {
|
||||
@@ -333,14 +333,14 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * obj, lv_color_t color, lv_cha
|
||||
|
||||
lv_chart_t * chart = (lv_chart_t *)obj;
|
||||
lv_chart_series_t * ser = _lv_ll_ins_head(&chart->series_ll);
|
||||
LV_ASSERT_MEM(ser);
|
||||
LV_ASSERT_MALLOC(ser);
|
||||
if(ser == NULL) return NULL;
|
||||
|
||||
lv_coord_t def = LV_CHART_POINT_DEF;
|
||||
|
||||
ser->color = color;
|
||||
ser->points = lv_mem_alloc(sizeof(lv_coord_t) * chart->point_cnt);
|
||||
LV_ASSERT_MEM(ser->points);
|
||||
LV_ASSERT_MALLOC(ser->points);
|
||||
if(ser->points == NULL) {
|
||||
_lv_ll_remove(&chart->series_ll, ser);
|
||||
lv_mem_free(ser);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "lv_checkbox.h"
|
||||
#if LV_USE_CHECKBOX != 0
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "lv_dropdown.h"
|
||||
#if LV_USE_DROPDOWN != 0
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_core/lv_indev.h"
|
||||
@@ -105,7 +105,7 @@ void lv_dropdown_set_text(lv_obj_t * obj, const char * txt)
|
||||
void lv_dropdown_set_options(lv_obj_t * obj, const char * options)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
LV_ASSERT_STR(options);
|
||||
LV_ASSERT_NULL(options);
|
||||
|
||||
lv_dropdown_t * dropdown = (lv_dropdown_t *) obj;
|
||||
|
||||
@@ -133,7 +133,7 @@ void lv_dropdown_set_options(lv_obj_t * obj, const char * options)
|
||||
|
||||
dropdown->options = lv_mem_alloc(len);
|
||||
|
||||
LV_ASSERT_MEM(dropdown->options);
|
||||
LV_ASSERT_MALLOC(dropdown->options);
|
||||
if(dropdown->options == NULL) return;
|
||||
|
||||
#if LV_USE_ARABIC_PERSIAN_CHARS == 0
|
||||
@@ -149,7 +149,7 @@ void lv_dropdown_set_options(lv_obj_t * obj, const char * options)
|
||||
void lv_dropdown_set_options_static(lv_obj_t * obj, const char * options)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
LV_ASSERT_STR(options);
|
||||
LV_ASSERT_NULL(options);
|
||||
|
||||
lv_dropdown_t * dropdown = (lv_dropdown_t *) obj;
|
||||
|
||||
@@ -175,7 +175,7 @@ void lv_dropdown_set_options_static(lv_obj_t * obj, const char * options)
|
||||
void lv_dropdown_add_option(lv_obj_t * obj, const char * option, uint32_t pos)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
LV_ASSERT_STR(option);
|
||||
LV_ASSERT_NULL(option);
|
||||
|
||||
lv_dropdown_t * dropdown = (lv_dropdown_t *) obj;
|
||||
|
||||
@@ -185,7 +185,7 @@ void lv_dropdown_add_option(lv_obj_t * obj, const char * option, uint32_t pos)
|
||||
size_t len = strlen(static_options) + 1;
|
||||
|
||||
dropdown->options = lv_mem_alloc(len);
|
||||
LV_ASSERT_MEM(dropdown->options);
|
||||
LV_ASSERT_MALLOC(dropdown->options);
|
||||
if(dropdown->options == NULL) return;
|
||||
|
||||
strcpy(dropdown->options, static_options);
|
||||
@@ -202,7 +202,7 @@ void lv_dropdown_add_option(lv_obj_t * obj, const char * option, uint32_t pos)
|
||||
|
||||
size_t new_len = ins_len + old_len + 2; /* +2 for terminating NULL and possible \n */
|
||||
dropdown->options = lv_mem_realloc(dropdown->options, new_len + 1);
|
||||
LV_ASSERT_MEM(dropdown->options);
|
||||
LV_ASSERT_MALLOC(dropdown->options);
|
||||
if(dropdown->options == NULL) return;
|
||||
|
||||
dropdown->options[old_len] = '\0';
|
||||
@@ -225,7 +225,7 @@ void lv_dropdown_add_option(lv_obj_t * obj, const char * option, uint32_t pos)
|
||||
|
||||
/*Insert the new option, adding \n if necessary*/
|
||||
char * ins_buf = lv_mem_buf_get(ins_len + 2); /* + 2 for terminating NULL and possible \n */
|
||||
LV_ASSERT_MEM(ins_buf);
|
||||
LV_ASSERT_MALLOC(ins_buf);
|
||||
if(ins_buf == NULL) return;
|
||||
#if LV_USE_ARABIC_PERSIAN_CHARS == 0
|
||||
strcpy(ins_buf, option);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "lv_img.h"
|
||||
#if LV_USE_IMG != 0
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_draw/lv_img_decoder.h"
|
||||
#include "../lv_misc/lv_fs.h"
|
||||
#include "../lv_misc/lv_txt.h"
|
||||
@@ -122,7 +122,7 @@ void lv_img_set_src(lv_obj_t * obj, const void * src)
|
||||
old_src = img->src;
|
||||
}
|
||||
char * new_str = lv_mem_alloc(strlen(src) + 1);
|
||||
LV_ASSERT_MEM(new_str);
|
||||
LV_ASSERT_MALLOC(new_str);
|
||||
if(new_str == NULL) return;
|
||||
strcpy(new_str, src);
|
||||
img->src = new_str;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "lv_label.h"
|
||||
#if LV_USE_LABEL != 0
|
||||
#include "../lv_core/lv_obj.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
@@ -89,8 +89,6 @@ void lv_label_set_text(lv_obj_t * obj, const char * text)
|
||||
/*If text is NULL then just refresh with the current text */
|
||||
if(text == NULL) text = label->text;
|
||||
|
||||
LV_ASSERT_STR(text);
|
||||
|
||||
if(label->text == text && label->static_txt == 0) {
|
||||
/*If set its own text then reallocate it (maybe its size changed)*/
|
||||
#if LV_USE_ARABIC_PERSIAN_CHARS
|
||||
@@ -98,7 +96,7 @@ void lv_label_set_text(lv_obj_t * obj, const char * text)
|
||||
size_t len = _lv_txt_ap_calc_bytes_cnt(text);
|
||||
|
||||
label->text = lv_mem_realloc(label->text, len);
|
||||
LV_ASSERT_MEM(label->text);
|
||||
LV_ASSERT_MALLOC(label->text);
|
||||
if(label->text == NULL) return;
|
||||
|
||||
_lv_txt_ap_proc(label->text, label->text);
|
||||
@@ -106,7 +104,7 @@ void lv_label_set_text(lv_obj_t * obj, const char * text)
|
||||
label->text = lv_mem_realloc(label->text, strlen(label->text) + 1);
|
||||
#endif
|
||||
|
||||
LV_ASSERT_MEM(label->text);
|
||||
LV_ASSERT_MALLOC(label->text);
|
||||
if(label->text == NULL) return;
|
||||
}
|
||||
else {
|
||||
@@ -121,7 +119,7 @@ void lv_label_set_text(lv_obj_t * obj, const char * text)
|
||||
size_t len = _lv_txt_ap_calc_bytes_cnt(text);
|
||||
|
||||
label->text = lv_mem_alloc(len);
|
||||
LV_ASSERT_MEM(label->text);
|
||||
LV_ASSERT_MALLOC(label->text);
|
||||
if(label->text == NULL) return;
|
||||
|
||||
_lv_txt_ap_proc(text, label->text);
|
||||
@@ -131,7 +129,7 @@ void lv_label_set_text(lv_obj_t * obj, const char * text)
|
||||
|
||||
/*Allocate space for the new text*/
|
||||
label->text = lv_mem_alloc(len);
|
||||
LV_ASSERT_MEM(label->text);
|
||||
LV_ASSERT_MALLOC(label->text);
|
||||
if(label->text == NULL) return;
|
||||
strcpy(label->text, text);
|
||||
#endif
|
||||
@@ -146,7 +144,7 @@ void lv_label_set_text(lv_obj_t * obj, const char * text)
|
||||
void lv_label_set_text_fmt(lv_obj_t * obj, const char * fmt, ...)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
LV_ASSERT_STR(fmt);
|
||||
LV_ASSERT_NULL(fmt);
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
lv_label_t * label = (lv_label_t *)obj;
|
||||
@@ -638,7 +636,7 @@ uint32_t lv_label_get_text_sel_end(const lv_obj_t * obj)
|
||||
void lv_label_ins_text(lv_obj_t * obj, uint32_t pos, const char * txt)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
LV_ASSERT_STR(txt);
|
||||
LV_ASSERT_NULL(txt);
|
||||
|
||||
lv_label_t * label = (lv_label_t *)obj;
|
||||
|
||||
@@ -652,7 +650,7 @@ void lv_label_ins_text(lv_obj_t * obj, uint32_t pos, const char * txt)
|
||||
size_t ins_len = strlen(txt);
|
||||
size_t new_len = ins_len + old_len;
|
||||
label->text = lv_mem_realloc(label->text, new_len + 1);
|
||||
LV_ASSERT_MEM(label->text);
|
||||
LV_ASSERT_MALLOC(label->text);
|
||||
if(label->text == NULL) return;
|
||||
|
||||
if(pos == LV_LABEL_POS_LAST) {
|
||||
@@ -661,7 +659,7 @@ void lv_label_ins_text(lv_obj_t * obj, uint32_t pos, const char * txt)
|
||||
|
||||
#if LV_USE_BIDI
|
||||
char * bidi_buf = lv_mem_buf_get(ins_len + 1);
|
||||
LV_ASSERT_MEM(bidi_buf);
|
||||
LV_ASSERT_MALLOC(bidi_buf);
|
||||
if(bidi_buf == NULL) return;
|
||||
|
||||
_lv_bidi_process(txt, bidi_buf, lv_obj_get_base_dir(obj));
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "lv_line.h"
|
||||
|
||||
#if LV_USE_LINE != 0
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <lvgl/src/lv_widgets/lv_meter.h>
|
||||
#if LV_USE_METER != 0
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
@@ -67,7 +67,7 @@ lv_meter_scale_t * lv_meter_add_scale(lv_obj_t * obj)
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
|
||||
lv_meter_scale_t * scale = _lv_ll_ins_head(&meter->scale_ll);
|
||||
LV_ASSERT_MEM(scale);
|
||||
LV_ASSERT_MALLOC(scale);
|
||||
lv_memset_00(scale, sizeof(lv_meter_scale_t));
|
||||
|
||||
_lv_ll_init(&scale->indicator_ll, sizeof(lv_meter_indicator_t));
|
||||
@@ -118,7 +118,7 @@ void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t
|
||||
lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width, lv_color_t color, int16_t r_mod)
|
||||
{
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&scale->indicator_ll);
|
||||
LV_ASSERT_MEM(indic);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
lv_memset_00(indic, sizeof(lv_meter_indicator_t));
|
||||
indic->opa = LV_OPA_COVER;
|
||||
|
||||
@@ -134,7 +134,7 @@ lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, lv_meter_scale_t
|
||||
lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, lv_meter_scale_t * scale, const void * src, lv_coord_t pivot_x, lv_coord_t pivot_y)
|
||||
{
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&scale->indicator_ll);
|
||||
LV_ASSERT_MEM(indic);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
lv_memset_00(indic, sizeof(lv_meter_indicator_t));
|
||||
indic->opa = LV_OPA_COVER;
|
||||
|
||||
@@ -150,7 +150,7 @@ lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, lv_meter_scale_t
|
||||
lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width, lv_color_t color, int16_t r_mod)
|
||||
{
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&scale->indicator_ll);
|
||||
LV_ASSERT_MEM(indic);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
lv_memset_00(indic, sizeof(lv_meter_indicator_t));
|
||||
indic->opa = LV_OPA_COVER;
|
||||
|
||||
@@ -166,7 +166,7 @@ lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, lv_meter_scale_t * scale
|
||||
lv_meter_indicator_t * lv_meter_add_scale_lines(lv_obj_t * obj, lv_meter_scale_t * scale, lv_color_t color_start, lv_color_t color_end, bool local, int16_t width_mod)
|
||||
{
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&scale->indicator_ll);
|
||||
LV_ASSERT_MEM(indic);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
lv_memset_00(indic, sizeof(lv_meter_indicator_t));
|
||||
indic->opa = LV_OPA_COVER;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include <lvgl/src/lv_misc/lv_assert.h>
|
||||
//#include "lv_templ.h" /*TODO uncomment this*/
|
||||
|
||||
#if defined(LV_USE_TEMPL) && LV_USE_TEMPL != 0
|
||||
@@ -62,7 +62,7 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Create the ancestor of template*/
|
||||
/*TODO modify it to the ancestor create function */
|
||||
lv_obj_t * new_templ = lv_ANCESTOR_create(par, copy);
|
||||
LV_ASSERT_MEM(new_templ);
|
||||
LV_ASSERT_MALLOC(new_templ);
|
||||
if(new_templ == NULL) return NULL;
|
||||
|
||||
/*Allocate the template type specific extended data*/
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "lv_roller.h"
|
||||
#if LV_USE_ROLLER != 0
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_core/lv_indev.h"
|
||||
@@ -90,7 +90,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * parent, const lv_obj_t * copy)
|
||||
void lv_roller_set_options(lv_obj_t * obj, const char * options, lv_roller_mode_t mode)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
LV_ASSERT_STR(options);
|
||||
LV_ASSERT_NULL(options);
|
||||
|
||||
lv_roller_t * roller = (lv_roller_t*)obj;
|
||||
lv_obj_t * label = get_label(obj);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "lv_slider.h"
|
||||
#if LV_USE_SLIDER != 0
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_core/lv_indev.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#error "lv_sw: lv_slider is required. Enable it in lv_conf.h (LV_USE_SLIDER 1)"
|
||||
#endif
|
||||
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_core/lv_indev.h"
|
||||
#include "../lv_core/lv_disp.h"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#if LV_USE_TABLE != 0
|
||||
|
||||
#include "../lv_core/lv_indev.h"
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_misc/lv_txt.h"
|
||||
#include "../lv_misc/lv_txt_ap.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
@@ -108,13 +108,13 @@ void lv_table_set_cell_value(lv_obj_t * obj, uint16_t row, uint16_t col, const c
|
||||
/*Get the size of the Arabic text and process it*/
|
||||
size_t len_ap = _lv_txt_ap_calc_bytes_cnt(txt);
|
||||
table->cell_data[cell] = lv_mem_realloc(table->cell_data[cell], len_ap + 1);
|
||||
LV_ASSERT_MEM(table->cell_data[cell]);
|
||||
LV_ASSERT_MALLOC(table->cell_data[cell]);
|
||||
if(table->cell_data[cell] == NULL) return;
|
||||
|
||||
_lv_txt_ap_proc(txt, &table->cell_data[cell][1]);
|
||||
#else
|
||||
table->cell_data[cell] = lv_mem_realloc(table->cell_data[cell], strlen(txt) + 2); /*+1: trailing '\0; +1: format byte*/
|
||||
LV_ASSERT_MEM(table->cell_data[cell]);
|
||||
LV_ASSERT_MALLOC(table->cell_data[cell]);
|
||||
|
||||
strcpy(table->cell_data[cell] + 1, txt); /*+1 to skip the format byte*/
|
||||
#endif
|
||||
@@ -133,7 +133,7 @@ void lv_table_set_cell_value(lv_obj_t * obj, uint16_t row, uint16_t col, const c
|
||||
void lv_table_set_cell_value_fmt(lv_obj_t * obj, uint16_t row, uint16_t col, const char * fmt, ...)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
LV_ASSERT_STR(fmt);
|
||||
LV_ASSERT_NULL(fmt);
|
||||
|
||||
lv_table_t * table = (lv_table_t *) obj;
|
||||
if(col >= table->col_cnt) {
|
||||
@@ -170,7 +170,7 @@ void lv_table_set_cell_value_fmt(lv_obj_t * obj, uint16_t row, uint16_t col, con
|
||||
#if LV_USE_ARABIC_PERSIAN_CHARS
|
||||
/*Put together the text according to the format string*/
|
||||
char * raw_txt = lv_mem_buf_get(len + 1);
|
||||
LV_ASSERT_MEM(raw_txt);
|
||||
LV_ASSERT_MALLOC(raw_txt);
|
||||
if(raw_txt == NULL) {
|
||||
va_end(ap2);
|
||||
return;
|
||||
@@ -181,7 +181,7 @@ void lv_table_set_cell_value_fmt(lv_obj_t * obj, uint16_t row, uint16_t col, con
|
||||
/*Get the size of the Arabic text and process it*/
|
||||
size_t len_ap = _lv_txt_ap_calc_bytes_cnt(raw_txt);
|
||||
table->cell_data[cell] = lv_mem_realloc(table->cell_data[cell], len_ap + 1);
|
||||
LV_ASSERT_MEM(table->cell_data[cell]);
|
||||
LV_ASSERT_MALLOC(table->cell_data[cell]);
|
||||
if(table->cell_data[cell] == NULL) {
|
||||
va_end(ap2);
|
||||
return;
|
||||
@@ -191,7 +191,7 @@ void lv_table_set_cell_value_fmt(lv_obj_t * obj, uint16_t row, uint16_t col, con
|
||||
lv_mem_buf_release(raw_txt);
|
||||
#else
|
||||
table->cell_data[cell] = lv_mem_realloc(table->cell_data[cell], len + 2); /*+1: trailing '\0; +1: format byte*/
|
||||
LV_ASSERT_MEM(table->cell_data[cell]);
|
||||
LV_ASSERT_MALLOC(table->cell_data[cell]);
|
||||
if(table->cell_data[cell] == NULL) {
|
||||
va_end(ap2);
|
||||
return;
|
||||
@@ -222,11 +222,11 @@ void lv_table_set_row_cnt(lv_obj_t * obj, uint16_t row_cnt)
|
||||
table->row_cnt = row_cnt;
|
||||
|
||||
table->row_h = lv_mem_realloc(table->row_h, table->row_cnt * sizeof(table->row_h[0]));
|
||||
LV_ASSERT_MEM(table->row_h);
|
||||
LV_ASSERT_MALLOC(table->row_h);
|
||||
if(table->row_h == NULL) return;
|
||||
|
||||
table->cell_data = lv_mem_realloc(table->cell_data, table->row_cnt * table->col_cnt * sizeof(char *));
|
||||
LV_ASSERT_MEM(table->cell_data);
|
||||
LV_ASSERT_MALLOC(table->cell_data);
|
||||
if(table->cell_data == NULL) return;
|
||||
|
||||
/*Initialize the new fields*/
|
||||
@@ -252,11 +252,11 @@ void lv_table_set_col_cnt(lv_obj_t * obj, uint16_t col_cnt)
|
||||
uint16_t old_col_cnt = table->col_cnt;
|
||||
table->col_cnt = col_cnt;
|
||||
table->col_w = lv_mem_realloc(table->col_w, col_cnt * sizeof(table->row_h[0]));
|
||||
LV_ASSERT_MEM(table->col_w);
|
||||
LV_ASSERT_MALLOC(table->col_w);
|
||||
if(table->col_w == NULL) return;
|
||||
|
||||
char ** new_cell_data = lv_mem_alloc(table->row_cnt * table->col_cnt * sizeof(char *));
|
||||
LV_ASSERT_MEM(new_cell_data);
|
||||
LV_ASSERT_MALLOC(new_cell_data);
|
||||
if(new_cell_data == NULL) return;
|
||||
uint32_t new_cell_cnt = table->col_cnt * table->row_cnt;
|
||||
lv_memset_00(new_cell_data, new_cell_cnt * sizeof(table->cell_data[0]));
|
||||
@@ -328,7 +328,7 @@ void lv_table_set_cell_crop(lv_obj_t * obj, uint16_t row, uint16_t col, bool cro
|
||||
|
||||
if(table->cell_data[cell] == NULL) {
|
||||
table->cell_data[cell] = lv_mem_alloc(2); /*+1: trailing '\0; +1: format byte*/
|
||||
LV_ASSERT_MEM(table->cell_data[cell]);
|
||||
LV_ASSERT_MALLOC(table->cell_data[cell]);
|
||||
if(table->cell_data[cell] == NULL) return;
|
||||
|
||||
table->cell_data[cell][0] = 0;
|
||||
@@ -362,7 +362,7 @@ void lv_table_set_cell_merge_right(lv_obj_t * obj, uint16_t row, uint16_t col, b
|
||||
|
||||
if(table->cell_data[cell] == NULL) {
|
||||
table->cell_data[cell] = lv_mem_alloc(2); /*+1: trailing '\0; +1: format byte*/
|
||||
LV_ASSERT_MEM(table->cell_data[cell]);
|
||||
LV_ASSERT_MALLOC(table->cell_data[cell]);
|
||||
if(table->cell_data[cell] == NULL) return;
|
||||
|
||||
table->cell_data[cell][0] = 0;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#if LV_USE_TEXTAREA != 0
|
||||
|
||||
#include <string.h>
|
||||
#include "../lv_misc/lv_debug.h"
|
||||
#include "../lv_misc/lv_assert.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_core/lv_refr.h"
|
||||
#include "../lv_core/lv_indev.h"
|
||||
@@ -152,7 +152,7 @@ void lv_textarea_add_char(lv_obj_t * obj, uint32_t c)
|
||||
|
||||
if(ta->pwd_mode != 0) {
|
||||
ta->pwd_tmp = lv_mem_realloc(ta->pwd_tmp, strlen(ta->pwd_tmp) + strlen(letter_buf) + 1); /*+2: the new char + \0 */
|
||||
LV_ASSERT_MEM(ta->pwd_tmp);
|
||||
LV_ASSERT_MALLOC(ta->pwd_tmp);
|
||||
if(ta->pwd_tmp == NULL) return;
|
||||
|
||||
_lv_txt_ins(ta->pwd_tmp, ta->cursor.pos, (const char *)letter_buf);
|
||||
@@ -223,7 +223,7 @@ void lv_textarea_add_text(lv_obj_t * obj, const char * txt)
|
||||
|
||||
if(ta->pwd_mode != 0) {
|
||||
ta->pwd_tmp = lv_mem_realloc(ta->pwd_tmp, strlen(ta->pwd_tmp) + strlen(txt) + 1);
|
||||
LV_ASSERT_MEM(ta->pwd_tmp);
|
||||
LV_ASSERT_MALLOC(ta->pwd_tmp);
|
||||
if(ta->pwd_tmp == NULL) return;
|
||||
|
||||
_lv_txt_ins(ta->pwd_tmp, ta->cursor.pos, txt);
|
||||
@@ -292,7 +292,7 @@ void lv_textarea_del_char(lv_obj_t * obj)
|
||||
_lv_txt_cut(ta->pwd_tmp, ta->cursor.pos - 1, _lv_txt_encoded_size(&ta->pwd_tmp[byte_pos]));
|
||||
|
||||
ta->pwd_tmp = lv_mem_realloc(ta->pwd_tmp, strlen(ta->pwd_tmp) + 1);
|
||||
LV_ASSERT_MEM(ta->pwd_tmp);
|
||||
LV_ASSERT_MALLOC(ta->pwd_tmp);
|
||||
if(ta->pwd_tmp == NULL) return;
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ void lv_textarea_set_text(lv_obj_t * obj, const char * txt)
|
||||
|
||||
if(ta->pwd_mode != 0) {
|
||||
ta->pwd_tmp = lv_mem_realloc(ta->pwd_tmp, strlen(txt) + 1);
|
||||
LV_ASSERT_MEM(ta->pwd_tmp);
|
||||
LV_ASSERT_MALLOC(ta->pwd_tmp);
|
||||
if(ta->pwd_tmp == NULL) return;
|
||||
strcpy(ta->pwd_tmp, txt);
|
||||
|
||||
@@ -419,7 +419,7 @@ void lv_textarea_set_placeholder_text(lv_obj_t * obj, const char * txt)
|
||||
ta->placeholder_txt = lv_mem_realloc(ta->placeholder_txt, txt_len + 1);
|
||||
|
||||
}
|
||||
LV_ASSERT_MEM(ta->placeholder_txt);
|
||||
LV_ASSERT_MALLOC(ta->placeholder_txt);
|
||||
if(ta->placeholder_txt == NULL) {
|
||||
LV_LOG_ERROR("lv_textarea_set_placeholder_text: couldn't allocate memory for placeholder");
|
||||
return;
|
||||
@@ -510,7 +510,7 @@ void lv_textarea_set_pwd_mode(lv_obj_t * obj, bool en)
|
||||
char * txt = lv_label_get_text(ta->label);
|
||||
size_t len = strlen(txt);
|
||||
ta->pwd_tmp = lv_mem_alloc(len + 1);
|
||||
LV_ASSERT_MEM(ta->pwd_tmp);
|
||||
LV_ASSERT_MALLOC(ta->pwd_tmp);
|
||||
if(ta->pwd_tmp == NULL) return;
|
||||
|
||||
strcpy(ta->pwd_tmp, txt);
|
||||
@@ -994,7 +994,7 @@ static void lv_textarea_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_
|
||||
if(copy_ta->pwd_tmp) {
|
||||
uint32_t len = lv_mem_get_size(copy_ta->pwd_tmp);
|
||||
ta->pwd_tmp = lv_mem_alloc(len);
|
||||
LV_ASSERT_MEM(ta->pwd_tmp);
|
||||
LV_ASSERT_MALLOC(ta->pwd_tmp);
|
||||
if(ta->pwd_tmp == NULL) return;
|
||||
|
||||
lv_memcpy(ta->pwd_tmp, copy_ta->pwd_tmp, len);
|
||||
|
||||
Reference in New Issue
Block a user