refactoring and fixes

This commit is contained in:
Gabor Kiss-Vamosi
2021-01-23 20:46:42 +01:00
parent 1d6d2eb9d9
commit ea6ee3d198
80 changed files with 1914 additions and 1862 deletions

View File

@@ -1,90 +1,90 @@
props = [ props = [
{'name': 'RADIUS', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'RADIUS', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'CLIP_CORNER', 'style_type': '_int', 'var_type': 'bool' }, {'name': 'CLIP_CORNER', 'style_type': 'num', 'var_type': 'bool' },
{'name': 'TRANSFORM_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'TRANSFORM_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'TRANSFORM_HEIGHT', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'TRANSFORM_HEIGHT', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'TRANSFORM_ZOOM', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'TRANSFORM_ZOOM', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'TRANSFORM_ANGLE', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'TRANSFORM_ANGLE', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, {'name': 'OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'COLOR_FILTER_CB', 'style_type': '_func', 'var_type': 'lv_color_filter_cb_t' }, {'name': 'COLOR_FILTER_CB', 'style_type': 'func', 'var_type': 'lv_color_filter_cb_t' },
{'name': 'COLOR_FILTER_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, {'name': 'COLOR_FILTER_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'PAD_TOP', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'ANIM_TIME', 'style_type': 'num', 'var_type': 'uint32_t' },
{'name': 'PAD_BOTTOM', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'TRANSITION', 'style_type': 'ptr', 'var_type': 'const lv_style_transition_t *' },
{'name': 'PAD_LEFT', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'SIZE', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'PAD_RIGHT', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'BLEND_MODE', 'style_type': 'num', 'var_type': 'lv_blend_mode_t' },
{'name': 'MARGIN_TOP', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'PAD_TOP', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'MARGIN_BOTTOM', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'PAD_BOTTOM', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'MARGIN_LEFT', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'PAD_LEFT', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'MARGIN_RIGHT', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'PAD_RIGHT', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'BG_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'PAD_ROW', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'BG_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'PAD_COLUMN', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'BG_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, {'name': 'BG_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'BG_GRAD_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'BG_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'BG_GRAD_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'BG_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'BG_GRAD_DIR', 'style_type': '_int', 'var_type': 'lv_grad_dir_t' }, {'name': 'BG_GRAD_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'BG_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, {'name': 'BG_GRAD_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'BG_MAIN_STOP', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'BG_GRAD_DIR', 'style_type': 'num', 'var_type': 'lv_grad_dir_t' },
{'name': 'BG_GRAD_STOP', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'BG_MAIN_STOP', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'BORDER_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'BG_GRAD_STOP', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'BORDER_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'BG_IMG_SRC', 'style_type': 'ptr', 'var_type': 'const void *' },
{'name': 'BORDER_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, {'name': 'BG_IMG_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'BORDER_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'BG_IMG_RECOLOR', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'BORDER_SIDE', 'style_type': '_int', 'var_type': 'lv_border_side_t' }, {'name': 'BG_IMG_RECOLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'BORDER_POST', 'style_type': '_int', 'var_type': 'bool' }, {'name': 'BG_IMG_RECOLOR_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'BORDER_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, {'name': 'BG_IMG_TILED', 'style_type': 'num', 'var_type': 'bool' },
{'name': 'TEXT_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'BORDER_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'TEXT_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'BORDER_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'TEXT_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, {'name': 'BORDER_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'TEXT_FONT', 'style_type': '_ptr', 'var_type': 'const lv_font_t *' }, {'name': 'BORDER_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'TEXT_LETTER_SPACE', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'BORDER_SIDE', 'style_type': 'num', 'var_type': 'lv_border_side_t' },
{'name': 'TEXT_LINE_SPACE', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'BORDER_POST', 'style_type': 'num', 'var_type': 'bool' },
{'name': 'TEXT_DECOR', 'style_type': '_int', 'var_type': 'lv_text_decor_t' }, {'name': 'TEXT_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'TEXT_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, {'name': 'TEXT_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'IMG_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, {'name': 'TEXT_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'IMG_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, {'name': 'TEXT_FONT', 'style_type': 'ptr', 'var_type': 'const lv_font_t *' },
{'name': 'IMG_RECOLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'TEXT_LETTER_SPACE', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'IMG_RECOLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'TEXT_LINE_SPACE', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'IMG_RECOLOR_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, {'name': 'TEXT_DECOR', 'style_type': 'num', 'var_type': 'lv_text_decor_t' },
{'name': 'OUTLINE_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'TEXT_ALIGN', 'style_type': 'num', 'var_type': 'lv_text_align_t' },
{'name': 'OUTLINE_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'IMG_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'OUTLINE_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'IMG_RECOLOR', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'OUTLINE_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, {'name': 'IMG_RECOLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'OUTLINE_PAD', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'IMG_RECOLOR_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'OUTLINE_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, {'name': 'OUTLINE_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'SHADOW_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'OUTLINE_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'SHADOW_OFS_X', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'OUTLINE_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'SHADOW_OFS_Y', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'OUTLINE_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'SHADOW_SPREAD', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'OUTLINE_PAD', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'SHADOW_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, {'name': 'SHADOW_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'SHADOW_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'SHADOW_OFS_X', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'SHADOW_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'SHADOW_OFS_Y', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'SHADOW_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, {'name': 'SHADOW_SPREAD', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'LINE_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'SHADOW_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'LINE_BLEND_MODE', 'style_type': '_int', 'var_type': 'lv_blend_mode_t' }, {'name': 'SHADOW_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'LINE_DASH_WIDTH', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'SHADOW_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'LINE_DASH_GAP', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'LINE_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'LINE_ROUNDED', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'LINE_DASH_WIDTH', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'LINE_COLOR', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'LINE_DASH_GAP', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'LINE_COLOR_FILTERED', 'style_type': '_color', 'var_type': 'lv_color_t' }, {'name': 'LINE_ROUNDED', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'LINE_OPA', 'style_type': '_int', 'var_type': 'lv_opa_t' }, {'name': 'LINE_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'CONTENT_SRC', 'style_type': '_ptr', 'var_type': 'const char *' }, {'name': 'LINE_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'CONTENT_ALIGN', 'style_type': '_int', 'var_type': 'lv_align_t' }, {'name': 'LINE_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'CONTENT_OFS_X', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'CONTENT_TEXT', 'style_type': 'ptr', 'var_type': 'const char *' },
{'name': 'CONTENT_OFS_Y', 'style_type': '_int', 'var_type': 'lv_coord_t' }, {'name': 'CONTENT_ALIGN', 'style_type': 'num', 'var_type': 'lv_align_t' },
{'name': 'TRANSITION_TIME', 'style_type': '_int', 'var_type': 'uint16_t' }, {'name': 'CONTENT_OFS_X', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'TRANSITION_DELAY', 'style_type': '_int', 'var_type': 'uint16_t' }, {'name': 'CONTENT_OFS_Y', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'TRANSITION_PATH', 'style_type': '_ptr', 'var_type': 'const lv_anim_path_t *' }, {'name': 'CONTENT_OPA', 'style_type': 'num', 'var_type': 'lv_opa_t' },
{'name': 'TRANSITION_PROP_1', 'style_type': '_int', 'var_type': 'lv_style_prop_t' }, {'name': 'CONTENT_FONT', 'style_type': 'ptr', 'var_type': 'const lv_font_t *' },
{'name': 'TRANSITION_PROP_2', 'style_type': '_int', 'var_type': 'lv_style_prop_t' }, {'name': 'CONTENT_COLOR', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'TRANSITION_PROP_3', 'style_type': '_int', 'var_type': 'lv_style_prop_t' }, {'name': 'CONTENT_COLOR_FILTERED', 'style_type': 'color', 'var_type': 'lv_color_t' },
{'name': 'TRANSITION_PROP_4', 'style_type': '_int', 'var_type': 'lv_style_prop_t' }, {'name': 'CONTENT_LETTER_SPACE', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'TRANSITION_PROP_5', 'style_type': '_int', 'var_type': 'lv_style_prop_t' }, {'name': 'CONTENT_LINE_SPACE', 'style_type': 'num', 'var_type': 'lv_coord_t' },
{'name': 'TRANSITION_PROP_6', 'style_type': '_int', 'var_type': 'lv_style_prop_t' } {'name': 'CONTENT_DECOR', 'style_type': 'num', 'var_type': 'lv_text_decor_t' },
] ]
def obj_style_get(i): def obj_style_get(i):
print("static inline " + props[i]['var_type'] + " lv_obj_get_style_" + props[i]['name'].lower() +"(const struct _lv_obj_t * obj, uint32_t part) {") print("static inline " + props[i]['var_type'] + " lv_obj_get_style_" + props[i]['name'].lower() +"(const struct _lv_obj_t * obj, uint32_t part) {")
print(" lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_" + props[i]['name'] + "); return v." + props[i][ 'style_type'] + "; }") print(" lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_" + props[i]['name'] + "); return (" + props[i]['var_type'] + ") v." + props[i]['style_type'] + "; }")
print("") print("")
@@ -96,4 +96,8 @@ def style_set(i):
for i in range(len(props)): for i in range(len(props)):
obj_style_get(i) style_set(i)

View File

@@ -318,7 +318,7 @@ uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp)
d = lv_disp_get_next(NULL); d = lv_disp_get_next(NULL);
while(d) { while(d) {
uint32_t elaps = lv_tick_elaps(d->last_activity_time); uint32_t elaps = lv_tick_elaps(d->last_activity_time);
t = LV_MATH_MIN(t, elaps); t = LV_MIN(t, elaps);
d = lv_disp_get_next(d); d = lv_disp_get_next(d);
} }

View File

@@ -206,7 +206,7 @@ static inline void lv_scr_load(lv_obj_t * scr)
* 1 dip is 2 px on a 320 DPI screen * 1 dip is 2 px on a 320 DPI screen
* https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dip-dp-and-sp * https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dip-dp-and-sp
*/ */
#define LV_DPX(n) (n == 0 ? 0 :LV_MATH_MAX((( lv_disp_get_dpi(NULL) * (n) + 80) / 160), 1)) /*+80 for rounding*/ #define LV_DPX(n) (n == 0 ? 0 :LV_MAX((( lv_disp_get_dpi(NULL) * (n) + 80) / 160), 1)) /*+80 for rounding*/
static inline lv_coord_t lv_dpx(lv_coord_t n) static inline lv_coord_t lv_dpx(lv_coord_t n)
{ {

View File

@@ -80,7 +80,7 @@ const lv_flex_t lv_flex_even = {
void lv_flex_init(lv_flex_t * flex) void lv_flex_init(lv_flex_t * flex)
{ {
_lv_memset_00(flex, sizeof(lv_flex_t)); lv_memset_00(flex, sizeof(lv_flex_t));
flex->update_cb = flex_update; flex->update_cb = flex_update;
flex->dir = LV_FLEX_FLOW_ROW; flex->dir = LV_FLEX_FLOW_ROW;
flex->item_main_place = LV_FLEX_PLACE_START; flex->item_main_place = LV_FLEX_PLACE_START;
@@ -197,6 +197,11 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t
const lv_flex_t * f = cont->spec_attr->layout_dsc; const lv_flex_t * f = cont->spec_attr->layout_dsc;
bool row = f->dir == LV_FLEX_FLOW_ROW ? true : false; bool row = f->dir == LV_FLEX_FLOW_ROW ? true : false;
bool wrap = f->wrap;
/*Can't wrap if the size if auto (i.e. the size depends on the children)*/
if(wrap && ((row && cont->w_set == LV_SIZE_AUTO) || (!row && cont->h_set == LV_SIZE_AUTO))) {
wrap = false;
}
lv_coord_t(*get_main_size)(const lv_obj_t *) = (row ? lv_obj_get_width : lv_obj_get_height); lv_coord_t(*get_main_size)(const lv_obj_t *) = (row ? lv_obj_get_width : lv_obj_get_height);
lv_coord_t(*get_cross_size)(const lv_obj_t *) = (!row ? lv_obj_get_width : lv_obj_get_height); lv_coord_t(*get_cross_size)(const lv_obj_t *) = (!row ? lv_obj_get_width : lv_obj_get_height);
@@ -217,10 +222,10 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t
grow_item_cnt++; grow_item_cnt++;
} else { } else {
lv_coord_t item_size = get_main_size(item) + item_gap; lv_coord_t item_size = get_main_size(item) + item_gap;
if(f->wrap && t->track_main_size + item_size > max_main_size) break; if(wrap && t->track_main_size + item_size > max_main_size) break;
t->track_main_size += item_size; t->track_main_size += item_size;
} }
t->track_cross_size = LV_MATH_MAX(get_cross_size(item), t->track_cross_size); t->track_cross_size = LV_MAX(get_cross_size(item), t->track_cross_size);
item_id += f->rev ? -1 : +1; item_id += f->rev ? -1 : +1;
item = lv_obj_get_child(cont, item_id); item = lv_obj_get_child(cont, item_id);

View File

@@ -50,7 +50,7 @@ static lv_coord_t grid_place(lv_coord_t cont_size, bool auto_size, uint8_t plac
void lv_grid_init(lv_grid_t * grid) void lv_grid_init(lv_grid_t * grid)
{ {
_lv_memset_00(grid,sizeof(lv_grid_t)); lv_memset_00(grid,sizeof(lv_grid_t));
grid->update_cb = grid_update; grid->update_cb = grid_update;
grid->col_place = LV_GRID_START; grid->col_place = LV_GRID_START;
grid->row_place = LV_GRID_START; grid->row_place = LV_GRID_START;
@@ -105,7 +105,7 @@ static void full_refresh(lv_obj_t * cont)
item_repos_hint_t hint; item_repos_hint_t hint;
_lv_memset_00(&hint, sizeof(hint)); lv_memset_00(&hint, sizeof(hint));
/* Calculate the grids absolute x and y coordinates. /* Calculate the grids absolute x and y coordinates.
* It will be used as helper during item repositioning to avoid calculating this value for every children*/ * It will be used as helper during item repositioning to avoid calculating this value for every children*/
@@ -158,7 +158,7 @@ static void calc(struct _lv_obj_t * cont, _lv_grid_calc_t * calc_out)
if(g->col_dsc_len == 0 || g->row_dsc_len == 0) return; if(g->col_dsc_len == 0 || g->row_dsc_len == 0) return;
if(lv_obj_get_child(cont, 0) == NULL) { if(lv_obj_get_child(cont, 0) == NULL) {
_lv_memset_00(calc_out, sizeof(_lv_grid_calc_t)); lv_memset_00(calc_out, sizeof(_lv_grid_calc_t));
return; return;
} }
@@ -186,10 +186,10 @@ static void calc(struct _lv_obj_t * cont, _lv_grid_calc_t * calc_out)
*/ */
static void calc_free(_lv_grid_calc_t * calc) static void calc_free(_lv_grid_calc_t * calc)
{ {
_lv_mem_buf_release(calc->x); lv_mem_buf_release(calc->x);
_lv_mem_buf_release(calc->y); lv_mem_buf_release(calc->y);
_lv_mem_buf_release(calc->w); lv_mem_buf_release(calc->w);
_lv_mem_buf_release(calc->h); lv_mem_buf_release(calc->h);
} }
static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c) static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c)
@@ -200,8 +200,8 @@ static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c)
lv_coord_t cont_w = lv_obj_get_width_fit(cont); lv_coord_t cont_w = lv_obj_get_width_fit(cont);
c->col_num = grid->col_dsc_len; c->col_num = grid->col_dsc_len;
c->x = _lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num); c->x = lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num);
c->w = _lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num); c->w = lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num);
uint32_t col_fr_cnt = 0; uint32_t col_fr_cnt = 0;
lv_coord_t grid_w = 0; lv_coord_t grid_w = 0;
@@ -238,8 +238,8 @@ static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c)
uint32_t i; uint32_t i;
c->row_num = grid->row_dsc_len; c->row_num = grid->row_dsc_len;
c->y = _lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num); c->y = lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num);
c->h = _lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num); c->h = lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num);
uint32_t row_fr_cnt = 0; uint32_t row_fr_cnt = 0;
lv_coord_t grid_h = 0; lv_coord_t grid_h = 0;

View File

@@ -72,7 +72,7 @@ lv_group_t * lv_group_create(void)
group->wrap = 1; group->wrap = 1;
#if LV_USE_USER_DATA #if LV_USE_USER_DATA
_lv_memset_00(&group->user_data, sizeof(lv_group_user_data_t)); lv_memset_00(&group->user_data, sizeof(lv_group_user_data_t));
#endif #endif
return group; return group;

View File

@@ -1191,8 +1191,8 @@ void indev_gesture(lv_indev_proc_t * proc)
if(gesture_obj == NULL) return; if(gesture_obj == NULL) return;
if((LV_MATH_ABS(proc->types.pointer.vect.x) < indev_act->driver.gesture_min_velocity) && if((LV_ABS(proc->types.pointer.vect.x) < indev_act->driver.gesture_min_velocity) &&
(LV_MATH_ABS(proc->types.pointer.vect.y) < indev_act->driver.gesture_min_velocity)) { (LV_ABS(proc->types.pointer.vect.y) < indev_act->driver.gesture_min_velocity)) {
proc->types.pointer.gesture_sum.x = 0; proc->types.pointer.gesture_sum.x = 0;
proc->types.pointer.gesture_sum.y = 0; proc->types.pointer.gesture_sum.y = 0;
} }
@@ -1201,12 +1201,12 @@ void indev_gesture(lv_indev_proc_t * proc)
proc->types.pointer.gesture_sum.x += proc->types.pointer.vect.x; proc->types.pointer.gesture_sum.x += proc->types.pointer.vect.x;
proc->types.pointer.gesture_sum.y += proc->types.pointer.vect.y; proc->types.pointer.gesture_sum.y += proc->types.pointer.vect.y;
if((LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > indev_act->driver.gesture_limit) || if((LV_ABS(proc->types.pointer.gesture_sum.x) > indev_act->driver.gesture_limit) ||
(LV_MATH_ABS(proc->types.pointer.gesture_sum.y) > indev_act->driver.gesture_limit)) { (LV_ABS(proc->types.pointer.gesture_sum.y) > indev_act->driver.gesture_limit)) {
proc->types.pointer.gesture_sent = 1; proc->types.pointer.gesture_sent = 1;
if(LV_MATH_ABS(proc->types.pointer.gesture_sum.x) > LV_MATH_ABS(proc->types.pointer.gesture_sum.y)) { if(LV_ABS(proc->types.pointer.gesture_sum.x) > LV_ABS(proc->types.pointer.gesture_sum.y)) {
if(proc->types.pointer.gesture_sum.x > 0) if(proc->types.pointer.gesture_sum.x > 0)
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_RIGHT; proc->types.pointer.gesture_dir = LV_GESTURE_DIR_RIGHT;
else else

View File

@@ -268,7 +268,7 @@ static lv_obj_t * find_scroll_obj(lv_indev_proc_t * proc)
/*Decide if it's a horizontal or vertical scroll*/ /*Decide if it's a horizontal or vertical scroll*/
bool hor_en = false; bool hor_en = false;
bool ver_en = false; bool ver_en = false;
if(LV_MATH_ABS(proc->types.pointer.scroll_sum.x) > LV_MATH_ABS(proc->types.pointer.scroll_sum.y)) { if(LV_ABS(proc->types.pointer.scroll_sum.x) > LV_ABS(proc->types.pointer.scroll_sum.y)) {
hor_en = true; hor_en = true;
} }
else { else {
@@ -436,7 +436,7 @@ static lv_coord_t find_snap_point_x(const lv_obj_t * obj, lv_coord_t min, lv_coo
x_child += ofs; x_child += ofs;
if(x_child >= min && x_child <= max) { if(x_child >= min && x_child <= max) {
lv_coord_t x = x_child - x_parent; lv_coord_t x = x_child - x_parent;
if(LV_MATH_ABS(x) < LV_MATH_ABS(dist)) dist = x; if(LV_ABS(x) < LV_ABS(dist)) dist = x;
} }
} }
} }
@@ -483,7 +483,7 @@ static lv_coord_t find_snap_point_y(const lv_obj_t * obj, lv_coord_t min, lv_coo
y_child += ofs; y_child += ofs;
if(y_child >= min && y_child <= max) { if(y_child >= min && y_child <= max) {
lv_coord_t y = y_child - y_parent; lv_coord_t y = y_child - y_parent;
if(LV_MATH_ABS(y) < LV_MATH_ABS(dist)) dist = y; if(LV_ABS(y) < LV_ABS(dist)) dist = y;
} }
} }
} }

View File

@@ -85,7 +85,7 @@ static void lv_obj_destructor(lv_obj_t * obj);
**********************/ **********************/
static bool lv_initialized = false; static bool lv_initialized = false;
static lv_event_temp_data_t * event_temp_data_head; static lv_event_temp_data_t * event_temp_data_head;
static const void * event_act_data; static void * event_act_data;
const lv_obj_class_t lv_obj = { const lv_obj_class_t lv_obj = {
.constructor = lv_obj_constructor, .constructor = lv_obj_constructor,
.destructor = lv_obj_destructor, .destructor = lv_obj_destructor,
@@ -117,7 +117,7 @@ void lv_init(void)
LV_LOG_TRACE("lv_init started"); LV_LOG_TRACE("lv_init started");
/*Initialize the lv_misc modules*/ /*Initialize the lv_misc modules*/
_lv_mem_init(); lv_mem_init();
_lv_timer_core_init(); _lv_timer_core_init();
@@ -193,7 +193,7 @@ void lv_deinit(void)
_lv_gc_clear_roots(); _lv_gc_clear_roots();
lv_disp_set_default(NULL); lv_disp_set_default(NULL);
_lv_mem_deinit(); lv_mem_deinit();
lv_initialized = false; lv_initialized = false;
LV_LOG_INFO("lv_deinit done"); LV_LOG_INFO("lv_deinit done");
@@ -225,7 +225,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class, lv_obj_t * parent, const lv_obj_t * copy) lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class, lv_obj_t * parent, const lv_obj_t * copy)
{ {
lv_obj_t * obj = lv_mem_alloc(class->instance_size); lv_obj_t * obj = lv_mem_alloc(class->instance_size);
_lv_memset_00(obj, class->instance_size); lv_memset_00(obj, class->instance_size);
obj->class_p = class; obj->class_p = class;
class->constructor(obj, parent, copy); class->constructor(obj, parent, copy);
@@ -482,13 +482,10 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
old_parent->spec_attr->children = NULL; old_parent->spec_attr->children = NULL;
} }
/*Add the child to the new parent*/ /*Add the child to the new parent as the last (newest child)*/
parent->spec_attr->child_cnt++; parent->spec_attr->child_cnt++;
parent->spec_attr->children = lv_mem_realloc(parent->spec_attr->children, parent->spec_attr->child_cnt * (sizeof(lv_obj_t *))); parent->spec_attr->children = lv_mem_realloc(parent->spec_attr->children, parent->spec_attr->child_cnt * (sizeof(lv_obj_t *)));
for(i = lv_obj_get_child_cnt(parent) - 1; i > 0 ; i--) { parent->spec_attr->children[lv_obj_get_child_cnt(parent) - 1] = obj;
parent->spec_attr->children[i] = parent->spec_attr->children[i - 1];
}
parent->spec_attr->children[0] = obj;
obj->parent = parent; obj->parent = parent;
@@ -584,7 +581,7 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right
obj->spec_attr->ext_click_pad.y2 = bottom; obj->spec_attr->ext_click_pad.y2 = bottom;
#elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY #elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_TINY
if(obj->spec_attr == NULL) lv_obj_allocate_spec_attr(obj); if(obj->spec_attr == NULL) lv_obj_allocate_spec_attr(obj);
obj->spec_attr->ext_click_pad = LV_MATH_MAX4(left, right, top, bottom); obj->spec_attr->ext_click_pad = LV_MAX4(left, right, top, bottom);
#else #else
LV_UNUSED(obj); LV_UNUSED(obj);
LV_UNUSED(left); LV_UNUSED(left);
@@ -687,8 +684,8 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
/*If there is no difference in styles there is nothing else to do*/ /*If there is no difference in styles there is nothing else to do*/
if(cmp_res == _LV_STYLE_STATE_CMP_SAME) return; if(cmp_res == _LV_STYLE_STATE_CMP_SAME) return;
trans_set_t * ts = _lv_mem_buf_get(sizeof(trans_set_t) * STYLE_TRANSITION_MAX); trans_set_t * ts = lv_mem_buf_get(sizeof(trans_set_t) * STYLE_TRANSITION_MAX);
_lv_memset_00(ts, sizeof(sizeof(trans_set_t) * 64)); lv_memset_00(ts, sizeof(sizeof(trans_set_t) * 64));
uint32_t tsi = 0; uint32_t tsi = 0;
uint32_t i; uint32_t i;
for(i = 0; i < obj->style_list.style_cnt && tsi < STYLE_TRANSITION_MAX; i++) { for(i = 0; i < obj->style_list.style_cnt && tsi < STYLE_TRANSITION_MAX; i++) {
@@ -698,7 +695,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
lv_style_value_t v; lv_style_value_t v;
if(lv_style_get_prop(obj_style->style, LV_STYLE_TRANSITION, &v) == false) continue; if(lv_style_get_prop(obj_style->style, LV_STYLE_TRANSITION, &v) == false) continue;
const lv_style_transiton_t * tr = v.ptr; const lv_style_transition_t * tr = v.ptr;
/*Add the props t the set is not added yet or added but with smaller weight*/ /*Add the props t the set is not added yet or added but with smaller weight*/
uint32_t j; uint32_t j;
@@ -725,7 +722,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
_lv_obj_create_style_transition(obj, ts[i].prop, ts[i].part, prev_state, new_state, ts[i].time, ts[i].delay, ts[i].path); _lv_obj_create_style_transition(obj, ts[i].prop, ts[i].part, prev_state, new_state, ts[i].time, ts[i].delay, ts[i].path);
} }
_lv_mem_buf_release(ts); lv_mem_buf_release(ts);
if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_LAYOUT) _lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_LAYOUT) _lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL);
else if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) _lv_obj_refresh_ext_draw_pad(obj); else if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) _lv_obj_refresh_ext_draw_pad(obj);
@@ -953,7 +950,7 @@ lv_obj_spec_attr_t * lv_obj_allocate_spec_attr(lv_obj_t * obj)
LV_ASSERT_MEM(obj->spec_attr); LV_ASSERT_MEM(obj->spec_attr);
if(obj->spec_attr == NULL) return NULL; if(obj->spec_attr == NULL) return NULL;
_lv_memset_00(obj->spec_attr, sizeof(lv_obj_spec_attr_t)); lv_memset_00(obj->spec_attr, sizeof(lv_obj_spec_attr_t));
obj->spec_attr->scroll_dir = LV_DIR_ALL; obj->spec_attr->scroll_dir = LV_DIR_ALL;
obj->spec_attr->base_dir = LV_BIDI_DIR_INHERIT; obj->spec_attr->base_dir = LV_BIDI_DIR_INHERIT;
@@ -1496,7 +1493,7 @@ static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t
obj->flags = copy->flags; obj->flags = copy->flags;
if(copy->spec_attr) { if(copy->spec_attr) {
lv_obj_allocate_spec_attr(obj); lv_obj_allocate_spec_attr(obj);
_lv_memcpy_small(obj->spec_attr, copy->spec_attr, sizeof(lv_obj_spec_attr_t)); lv_memcpy_small(obj->spec_attr, copy->spec_attr, sizeof(lv_obj_spec_attr_t));
obj->spec_attr->children = NULL; /*Make the child list empty*/ obj->spec_attr->children = NULL; /*Make the child list empty*/
} }
#if LV_USE_GROUP #if LV_USE_GROUP
@@ -1564,8 +1561,9 @@ static lv_draw_res_t lv_obj_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv
if(lv_obj_get_style_bg_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DRAW_RES_NOT_COVER; if(lv_obj_get_style_bg_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DRAW_RES_NOT_COVER;
if(lv_obj_get_style_bg_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER; #if LV_USE_BLEND_MODES
if(lv_obj_get_style_border_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER; if(lv_obj_get_style_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER;
#endif
if(lv_obj_get_style_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DRAW_RES_NOT_COVER; if(lv_obj_get_style_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) return LV_DRAW_RES_NOT_COVER;
return LV_DRAW_RES_COVER; return LV_DRAW_RES_COVER;
@@ -1590,30 +1588,22 @@ static lv_draw_res_t lv_obj_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv
coords.y1 -= h; coords.y1 -= h;
coords.y2 += h; coords.y2 += h;
lv_obj_draw_hook_dsc_t hook_dsc;
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
hook_dsc.draw_area = &coords;
hook_dsc.part = LV_PART_MAIN;
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
lv_draw_rect(&coords, clip_area, &draw_dsc); lv_draw_rect(&coords, clip_area, &draw_dsc);
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) { if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) {
lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
lv_coord_t r = lv_obj_get_style_radius(obj, LV_PART_MAIN); lv_coord_t r = lv_obj_get_style_radius(obj, LV_PART_MAIN);
lv_draw_mask_radius_init(mp, &obj->coords, r, false); lv_draw_mask_radius_init(mp, &obj->coords, r, false);
/*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/ /*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/
lv_draw_mask_add(mp, obj + 8); lv_draw_mask_add(mp, obj + 8);
} }
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
} }
else if(mode == LV_DRAW_MODE_POST_DRAW) { else if(mode == LV_DRAW_MODE_POST_DRAW) {
_lv_obj_draw_scrollbar(obj, clip_area); _lv_obj_draw_scrollbar(obj, clip_area);
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) { if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) {
lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(obj + 8); lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(obj + 8);
_lv_mem_buf_release(param); lv_mem_buf_release(param);
} }
/*If the border is drawn later disable loading other properties*/ /*If the border is drawn later disable loading other properties*/
@@ -1833,7 +1823,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
lv_coord_t * s = param; lv_coord_t * s = param;
lv_coord_t d = _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_MAIN); lv_coord_t d = _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_MAIN);
*s = LV_MATH_MAX(*s, d); *s = LV_MAX(*s, d);
} }
else if(sign == LV_SIGNAL_STYLE_CHG) { else if(sign == LV_SIGNAL_STYLE_CHG) {
/* Padding might have changed so the layout should be recalculated*/ /* Padding might have changed so the layout should be recalculated*/

View File

@@ -257,23 +257,6 @@ enum {
LV_PART_ITEMS, LV_PART_ITEMS,
LV_PART_MARKER, LV_PART_MARKER,
LV_PART_CURSOR, //combine with marker? LV_PART_CURSOR, //combine with marker?
LV_PART_CUSTOM_1,
LV_PART_CUSTOM_2,
LV_PART_CUSTOM_3,
LV_PART_CUSTOM_4,
LV_PART_CUSTOM_5,
LV_PART_CUSTOM_6,
LV_PART_CUSTOM_7,
LV_PART_CUSTOM_8,
LV_PART_CUSTOM_9,
LV_PART_CUSTOM_10,
LV_PART_CUSTOM_11,
LV_PART_CUSTOM_12,
LV_PART_CUSTOM_13,
LV_PART_CUSTOM_14,
LV_PART_CUSTOM_15,
LV_PART_CUSTOM_16,
}; };
typedef uint8_t lv_part_t; typedef uint8_t lv_part_t;

View File

@@ -65,6 +65,10 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
} }
#endif #endif
#if LV_USE_BLEND_MODES
draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part);
#endif
if(draw_dsc->bg_opa != LV_OPA_TRANSP) { if(draw_dsc->bg_opa != LV_OPA_TRANSP) {
draw_dsc->bg_opa = lv_obj_get_style_bg_opa(obj, part); draw_dsc->bg_opa = lv_obj_get_style_bg_opa(obj, part);
if(draw_dsc->bg_opa > LV_OPA_MIN) { if(draw_dsc->bg_opa > LV_OPA_MIN) {
@@ -75,10 +79,6 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
draw_dsc->bg_main_color_stop = lv_obj_get_style_bg_main_stop(obj, part); draw_dsc->bg_main_color_stop = lv_obj_get_style_bg_main_stop(obj, part);
draw_dsc->bg_grad_color_stop = lv_obj_get_style_bg_grad_stop(obj, part); draw_dsc->bg_grad_color_stop = lv_obj_get_style_bg_grad_stop(obj, part);
} }
#if LV_USE_BLEND_MODES
draw_dsc->bg_blend_mode = lv_obj_get_style_bg_blend_mode(obj, part);
#endif
} }
} }
@@ -90,9 +90,6 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
draw_dsc->border_side = lv_obj_get_style_border_side(obj, part); draw_dsc->border_side = lv_obj_get_style_border_side(obj, part);
draw_dsc->border_color = lv_obj_get_style_border_color_filtered(obj, part); draw_dsc->border_color = lv_obj_get_style_border_color_filtered(obj, part);
} }
#if LV_USE_BLEND_MODES
draw_dsc->border_blend_mode = lv_obj_get_style_border_blend_mode(obj, part);
#endif
} }
} }
@@ -105,44 +102,37 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
draw_dsc->outline_pad = lv_obj_get_style_outline_pad(obj, part); draw_dsc->outline_pad = lv_obj_get_style_outline_pad(obj, part);
draw_dsc->outline_color = lv_obj_get_style_outline_color(obj, part); draw_dsc->outline_color = lv_obj_get_style_outline_color(obj, part);
} }
#if LV_USE_BLEND_MODES
draw_dsc->outline_blend_mode = lv_obj_get_style_outline_blend_mode(obj, part);
#endif
} }
} }
#endif #endif
if(draw_dsc->bg_img_opa != LV_OPA_TRANSP) {
draw_dsc->bg_img_src = lv_obj_get_style_bg_img_src(obj, part);
if(draw_dsc->bg_img_src) {
// draw_dsc->bg_img_opa = lv_obj_get_style_bg_img_opa(obj, part); //TODO
if(draw_dsc->bg_img_opa > LV_OPA_MIN) {
draw_dsc->bg_img_recolor = lv_obj_get_style_bg_img_recolor(obj, part);
draw_dsc->bg_img_recolor_opa = lv_obj_get_style_bg_img_recolor_opa(obj, part);
draw_dsc->bg_img_tiled = lv_obj_get_style_bg_img_tiled(obj, part);
}
}
}
#if LV_USE_PATTERN #if LV_USE_PATTERN
if(draw_dsc->content_opa != LV_OPA_TRANSP) { if(draw_dsc->content_opa != LV_OPA_TRANSP) {
draw_dsc->content_src = lv_obj_get_style_content_src(obj, part); draw_dsc->content_text = lv_obj_get_style_content_text(obj, part);
if(draw_dsc->content_src) { if(draw_dsc->content_text) {
draw_dsc->content_ofs_y = lv_obj_get_style_content_ofs_y(obj, part);
draw_dsc->content_ofs_x = lv_obj_get_style_content_ofs_x(obj, part);
draw_dsc->content_align = lv_obj_get_style_content_align(obj, part);
if(lv_img_src_get_type(draw_dsc->content_src) == LV_IMG_SRC_SYMBOL) { draw_dsc->content_opa = lv_obj_get_style_content_opa(obj, part);
draw_dsc->content_opa = lv_obj_get_style_text_opa(obj, part); if(draw_dsc->content_opa > LV_OPA_MIN) {
if(draw_dsc->content_opa > LV_OPA_MIN) { draw_dsc->content_ofs_y = lv_obj_get_style_content_ofs_y(obj, part);
draw_dsc->content_font = lv_obj_get_style_text_font(obj, part); draw_dsc->content_ofs_x = lv_obj_get_style_content_ofs_x(obj, part);
draw_dsc->content_color = lv_obj_get_style_text_color(obj, part); draw_dsc->content_align = lv_obj_get_style_content_align(obj, part);
draw_dsc->content_letter_space = lv_obj_get_style_text_letter_space(obj, part); draw_dsc->content_font = lv_obj_get_style_content_font(obj, part);
draw_dsc->content_line_space = lv_obj_get_style_text_line_space(obj, part); draw_dsc->content_color = lv_obj_get_style_content_color_filtered(obj, part);
#if LV_USE_BLEND_MODES draw_dsc->content_letter_space = lv_obj_get_style_content_letter_space(obj, part);
draw_dsc->content_blend_mode = lv_obj_get_style_text_blend_mode(obj, part); draw_dsc->content_line_space = lv_obj_get_style_content_line_space(obj, part);
#endif
}
}
else {
draw_dsc->content_opa = lv_obj_get_style_img_opa(obj, part);
if(draw_dsc->content_opa > LV_OPA_MIN) {
draw_dsc->content_color = lv_obj_get_style_img_recolor(obj, part);
draw_dsc->content_recolor_opa = lv_obj_get_style_img_recolor_opa(obj, part);
#if LV_USE_BLEND_MODES
draw_dsc->content_blend_mode = lv_obj_get_style_img_blend_mode(obj, part);
#endif
}
} }
} }
} }
@@ -160,9 +150,6 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
draw_dsc->shadow_ofs_y = lv_obj_get_style_shadow_ofs_y(obj, part); draw_dsc->shadow_ofs_y = lv_obj_get_style_shadow_ofs_y(obj, part);
draw_dsc->shadow_spread = lv_obj_get_style_shadow_spread(obj, part); draw_dsc->shadow_spread = lv_obj_get_style_shadow_spread(obj, part);
draw_dsc->shadow_color = lv_obj_get_style_shadow_color(obj, part); draw_dsc->shadow_color = lv_obj_get_style_shadow_color(obj, part);
#if LV_USE_BLEND_MODES
draw_dsc->shadow_blend_mode = lv_obj_get_style_shadow_blend_mode(obj, part);
#endif
} }
} }
} }
@@ -210,7 +197,7 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_
draw_dsc->line_space = lv_obj_get_style_text_line_space(obj, part); draw_dsc->line_space = lv_obj_get_style_text_line_space(obj, part);
draw_dsc->decor = lv_obj_get_style_text_decor(obj, part); draw_dsc->decor = lv_obj_get_style_text_decor(obj, part);
#if LV_USE_BLEND_MODES #if LV_USE_BLEND_MODES
draw_dsc->blend_mode = lv_obj_get_style_text_blend_mode(obj, part); draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part);
#endif #endif
draw_dsc->font = lv_obj_get_style_text_font(obj, part); draw_dsc->font = lv_obj_get_style_text_font(obj, part);
@@ -245,29 +232,29 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_
*/ */
void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t * draw_dsc) void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t * draw_dsc)
{ {
// draw_dsc->opa = lv_obj_get_style_image_opa(obj, part); draw_dsc->opa = lv_obj_get_style_img_opa(obj, part);
// if(draw_dsc->opa <= LV_OPA_MIN) return; if(draw_dsc->opa <= LV_OPA_MIN) return;
//
//#if LV_USE_OPA_SCALE #if LV_USE_OPA_SCALE
// lv_opa_t opa_scale = lv_obj_get_style_opa_scale(obj, part); lv_opa_t opa_scale = lv_obj_get_style_opa(obj, part);
// if(opa_scale < LV_OPA_MAX) { if(opa_scale < LV_OPA_MAX) {
// draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8; draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa_scale) >> 8;
// } }
// if(draw_dsc->opa <= LV_OPA_MIN) return; if(draw_dsc->opa <= LV_OPA_MIN) return;
//#endif #endif
//
// draw_dsc->angle = 0; draw_dsc->angle = 0;
// draw_dsc->zoom = LV_IMG_ZOOM_NONE; draw_dsc->zoom = LV_IMG_ZOOM_NONE;
// draw_dsc->pivot.x = lv_area_get_width(&obj->coords) / 2; draw_dsc->pivot.x = lv_area_get_width(&obj->coords) / 2;
// draw_dsc->pivot.y = lv_area_get_height(&obj->coords) / 2; draw_dsc->pivot.y = lv_area_get_height(&obj->coords) / 2;
//
// draw_dsc->recolor_opa = lv_obj_get_style_image_recolor_opa(obj, part); draw_dsc->recolor_opa = lv_obj_get_style_img_recolor_opa(obj, part);
// if(draw_dsc->recolor_opa > 0) { if(draw_dsc->recolor_opa > 0) {
// draw_dsc->recolor = lv_obj_get_style_image_recolor(obj, part); draw_dsc->recolor = lv_obj_get_style_img_recolor(obj, part);
// } }
//#if LV_USE_BLEND_MODES #if LV_USE_BLEND_MODES
// draw_dsc->blend_mode = lv_obj_get_style_image_blend_mode(obj, part); draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part);
//#endif #endif
} }
@@ -306,10 +293,45 @@ void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t
draw_dsc->round_end = draw_dsc->round_start; draw_dsc->round_end = draw_dsc->round_start;
#if LV_USE_BLEND_MODES #if LV_USE_BLEND_MODES
draw_dsc->blend_mode = lv_obj_get_style_line_blend_mode(obj, part); draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part);
#endif #endif
} }
/**
* Initialize a line draw descriptor from an object's styles in its current state
* @param obj pointer to an object
* @param type type of style. E.g. `LV_LINE_PART_MAIN`
* @param draw_dsc the descriptor the initialize.
* If the `opa` filed is set to or the property is equal to `LV_OPA_TRANSP` the rest won't be initialized.
* Should be initialized with `lv_draw_line_dsc_init(draw_dsc)`.
*/
void lv_obj_init_draw_arc_dsc(lv_obj_t * obj, uint8_t part, lv_draw_arc_dsc_t * draw_dsc)
{
draw_dsc->width = lv_obj_get_style_line_width(obj, part);
if(draw_dsc->width == 0) return;
draw_dsc->opa = lv_obj_get_style_line_opa(obj, part);
if(draw_dsc->opa <= LV_OPA_MIN) return;
#if LV_USE_OPA_SCALE
lv_opa_t opa = lv_obj_get_style_opa(obj, part);
if(opa < LV_OPA_MAX) {
draw_dsc->opa = (uint16_t)((uint16_t)draw_dsc->opa * opa) >> 8;
}
if(draw_dsc->opa <= LV_OPA_MIN) return;
#endif
draw_dsc->color = lv_obj_get_style_line_color(obj, part);
draw_dsc->bg_img_src = lv_obj_get_style_bg_img_src(obj, part);
draw_dsc->rounded = lv_obj_get_style_line_rounded(obj, part);
#if LV_USE_BLEND_MODES
draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part);
#endif
}
/** /**
* Get the required extra size (around the object's part) to draw shadow, outline, value etc. * Get the required extra size (around the object's part) to draw shadow, outline, value etc.
* @param obj pointer to an object * @param obj pointer to an object
@@ -328,8 +350,8 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part)
sh_width += lv_obj_get_style_shadow_spread(obj, part); sh_width += lv_obj_get_style_shadow_spread(obj, part);
lv_coord_t sh_ofs_x = lv_obj_get_style_shadow_ofs_x(obj, part); lv_coord_t sh_ofs_x = lv_obj_get_style_shadow_ofs_x(obj, part);
lv_coord_t sh_ofs_y = lv_obj_get_style_shadow_ofs_y(obj, part); lv_coord_t sh_ofs_y = lv_obj_get_style_shadow_ofs_y(obj, part);
sh_width += LV_MATH_MAX(LV_MATH_ABS(sh_ofs_x), LV_MATH_ABS(sh_ofs_y)); sh_width += LV_MAX(LV_ABS(sh_ofs_x), LV_ABS(sh_ofs_y));
s = LV_MATH_MAX(s, sh_width); s = LV_MAX(s, sh_width);
} }
} }
@@ -338,12 +360,12 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part)
lv_opa_t outline_opa = lv_obj_get_style_outline_opa(obj, part); lv_opa_t outline_opa = lv_obj_get_style_outline_opa(obj, part);
if(outline_opa > LV_OPA_MIN) { if(outline_opa > LV_OPA_MIN) {
lv_coord_t outline_pad = lv_obj_get_style_outline_pad(obj, part); lv_coord_t outline_pad = lv_obj_get_style_outline_pad(obj, part);
s = LV_MATH_MAX(s, outline_pad + outline_width); s = LV_MAX(s, outline_pad + outline_width);
} }
} }
const void * content_src = lv_obj_get_style_content_src(obj, part); const void * content_text = lv_obj_get_style_content_text(obj, part);
if(content_src) { if(content_text) {
lv_opa_t content_opa; lv_opa_t content_opa;
lv_point_t content_size; lv_point_t content_size;
content_opa = lv_obj_get_style_text_opa(obj, part); content_opa = lv_obj_get_style_text_opa(obj, part);
@@ -351,7 +373,7 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part)
lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, part); lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, part);
lv_coord_t line_space = lv_obj_get_style_text_letter_space(obj, part); lv_coord_t line_space = lv_obj_get_style_text_letter_space(obj, part);
const lv_font_t * font = lv_obj_get_style_text_font(obj, part); const lv_font_t * font = lv_obj_get_style_text_font(obj, part);
_lv_txt_get_size(&content_size, content_src, font, letter_space, line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE); _lv_txt_get_size(&content_size, content_text, font, letter_space, line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
lv_area_t content_area; lv_area_t content_area;
content_area.x1 = 0; content_area.x1 = 0;
@@ -370,16 +392,16 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part)
content_area.x2 += p_align.x + xofs; content_area.x2 += p_align.x + xofs;
content_area.y2 += p_align.y + yofs; content_area.y2 += p_align.y + yofs;
s = LV_MATH_MAX(s, obj->coords.x1 - content_area.x1); s = LV_MAX(s, obj->coords.x1 - content_area.x1);
s = LV_MATH_MAX(s, obj->coords.y1 - content_area.y1); s = LV_MAX(s, obj->coords.y1 - content_area.y1);
s = LV_MATH_MAX(s, content_area.x2 - obj->coords.x2); s = LV_MAX(s, content_area.x2 - obj->coords.x2);
s = LV_MATH_MAX(s, content_area.y2 - obj->coords.y2); s = LV_MAX(s, content_area.y2 - obj->coords.y2);
} }
} }
lv_coord_t w = lv_obj_get_style_transform_width(obj, part); lv_coord_t w = lv_obj_get_style_transform_width(obj, part);
lv_coord_t h = lv_obj_get_style_transform_height(obj, part); lv_coord_t h = lv_obj_get_style_transform_height(obj, part);
lv_coord_t wh = LV_MATH_MAX(w, h); lv_coord_t wh = LV_MAX(w, h);
if(wh > 0) s += wh; if(wh > 0) s += wh;
return s; return s;
@@ -387,7 +409,7 @@ lv_coord_t _lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part)
void lv_obj_draw_hook_dsc_init(lv_obj_draw_hook_dsc_t * hook_dsc, const lv_area_t * clip_area) void lv_obj_draw_hook_dsc_init(lv_obj_draw_hook_dsc_t * hook_dsc, const lv_area_t * clip_area)
{ {
_lv_memset_00(hook_dsc, sizeof(lv_obj_draw_hook_dsc_t)); lv_memset_00(hook_dsc, sizeof(lv_obj_draw_hook_dsc_t));
hook_dsc->clip_area = clip_area; hook_dsc->clip_area = clip_area;
} }
@@ -488,7 +510,7 @@ void _lv_obj_draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area)
if(ver_draw && _lv_area_is_on(&area, clip_area)) { if(ver_draw && _lv_area_is_on(&area, clip_area)) {
lv_coord_t content_h = obj_h + st + sb; lv_coord_t content_h = obj_h + st + sb;
lv_coord_t sb_h = ((obj_h - end_space * 2 - hor_req_space) * obj_h) / content_h; lv_coord_t sb_h = ((obj_h - end_space * 2 - hor_req_space) * obj_h) / content_h;
sb_h = LV_MATH_MAX(sb_h, SCROLLBAR_MIN_SIZE); sb_h = LV_MAX(sb_h, SCROLLBAR_MIN_SIZE);
rem = (obj_h - end_space * 2 - hor_req_space) - sb_h; /*Remaining size from the scrollbar track that is not the scrollbar itself*/ rem = (obj_h - end_space * 2 - hor_req_space) - sb_h; /*Remaining size from the scrollbar track that is not the scrollbar itself*/
lv_coord_t scroll_h = content_h - obj_h; /*The size of the content which can be really scrolled*/ lv_coord_t scroll_h = content_h - obj_h; /*The size of the content which can be really scrolled*/
if(scroll_h <= 0) { if(scroll_h <= 0) {
@@ -524,7 +546,7 @@ void _lv_obj_draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area)
if(hor_draw && _lv_area_is_on(&area, clip_area)) { if(hor_draw && _lv_area_is_on(&area, clip_area)) {
lv_coord_t content_w = obj_w + sl + sr; lv_coord_t content_w = obj_w + sl + sr;
lv_coord_t sb_w = ((obj_w - end_space * 2 - ver_reg_space) * obj_w) / content_w; lv_coord_t sb_w = ((obj_w - end_space * 2 - ver_reg_space) * obj_w) / content_w;
sb_w = LV_MATH_MAX(sb_w, SCROLLBAR_MIN_SIZE); sb_w = LV_MAX(sb_w, SCROLLBAR_MIN_SIZE);
rem = (obj_w - end_space * 2 - ver_reg_space) - sb_w; /*Remaining size from the scrollbar track that is not the scrollbar itself*/ rem = (obj_w - end_space * 2 - ver_reg_space) - sb_w; /*Remaining size from the scrollbar track that is not the scrollbar itself*/
lv_coord_t scroll_w = content_w - obj_w; /*The size of the content which can be really scrolled*/ lv_coord_t scroll_w = content_w - obj_w; /*The size of the content which can be really scrolled*/
if(scroll_w <= 0) { if(scroll_w <= 0) {

View File

@@ -40,7 +40,11 @@ typedef struct
lv_draw_label_dsc_t * label_dsc; lv_draw_label_dsc_t * label_dsc;
lv_draw_line_dsc_t * line_dsc; lv_draw_line_dsc_t * line_dsc;
lv_draw_img_dsc_t * img_dsc; lv_draw_img_dsc_t * img_dsc;
lv_draw_arc_dsc_t * arc_dsc;
const lv_area_t * draw_area; const lv_area_t * draw_area;
const lv_point_t * p1;
const lv_point_t * p2;
const lv_coord_t * radius;
const lv_area_t * clip_area; const lv_area_t * clip_area;
uint32_t id; uint32_t id;
uint8_t part; uint8_t part;
@@ -105,6 +109,7 @@ void lv_obj_init_draw_img_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_img_
*/ */
void lv_obj_init_draw_line_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t * draw_dsc); void lv_obj_init_draw_line_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t * draw_dsc);
void lv_obj_init_draw_arc_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_arc_dsc_t * draw_dsc);
bool lv_obj_draw_has_custom(const struct _lv_obj_t * obj, uint8_t part); bool lv_obj_draw_has_custom(const struct _lv_obj_t * obj, uint8_t part);

View File

@@ -130,7 +130,7 @@ lv_coord_t lv_obj_get_scroll_bottom(lv_obj_t * obj)
uint32_t i; uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
lv_obj_t * child = lv_obj_get_child(obj, i); lv_obj_t * child = lv_obj_get_child(obj, i);
child_res = LV_MATH_MAX(child_res, child->coords.y2); child_res = LV_MAX(child_res, child->coords.y2);
} }
lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
@@ -141,7 +141,7 @@ lv_coord_t lv_obj_get_scroll_bottom(lv_obj_t * obj)
lv_coord_t self_h = _lv_obj_get_self_height(obj); lv_coord_t self_h = _lv_obj_get_self_height(obj);
self_h = self_h - (lv_obj_get_height(obj) - pad_top - pad_bottom); self_h = self_h - (lv_obj_get_height(obj) - pad_top - pad_bottom);
self_h -= lv_obj_get_scroll_y(obj); self_h -= lv_obj_get_scroll_y(obj);
return LV_MATH_MAX(child_res, self_h); return LV_MAX(child_res, self_h);
} }
lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj) lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj)
@@ -165,7 +165,7 @@ lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj)
lv_coord_t x1 = LV_COORD_MAX; lv_coord_t x1 = LV_COORD_MAX;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
lv_obj_t * child = lv_obj_get_child(obj, i); lv_obj_t * child = lv_obj_get_child(obj, i);
x1 = LV_MATH_MIN(x1, child->coords.x1); x1 = LV_MIN(x1, child->coords.x1);
} }
@@ -178,7 +178,7 @@ lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj)
self_w = self_w - (lv_obj_get_width(obj) - pad_right - pad_left); self_w = self_w - (lv_obj_get_width(obj) - pad_right - pad_left);
self_w -= lv_obj_get_scroll_x(obj); self_w -= lv_obj_get_scroll_x(obj);
return LV_MATH_MAX(child_res, self_w); return LV_MAX(child_res, self_w);
} }
lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj) lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj)
@@ -197,7 +197,7 @@ lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj)
uint32_t i; uint32_t i;
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
lv_obj_t * child = lv_obj_get_child(obj, i); lv_obj_t * child = lv_obj_get_child(obj, i);
child_res = LV_MATH_MAX(child_res, child->coords.x2); child_res = LV_MAX(child_res, child->coords.x2);
} }
lv_coord_t pad_right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN); lv_coord_t pad_right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
@@ -209,7 +209,7 @@ lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj)
self_w = _lv_obj_get_self_width(obj); self_w = _lv_obj_get_self_width(obj);
self_w = self_w - (lv_obj_get_width(obj) - pad_right - pad_left); self_w = self_w - (lv_obj_get_width(obj) - pad_right - pad_left);
self_w -= lv_obj_get_scroll_x(obj); self_w -= lv_obj_get_scroll_x(obj);
return LV_MATH_MAX(child_res, self_w); return LV_MAX(child_res, self_w);
} }
void lv_obj_get_scroll_end(struct _lv_obj_t * obj, lv_point_t * end) void lv_obj_get_scroll_end(struct _lv_obj_t * obj, lv_point_t * end)
@@ -336,13 +336,13 @@ void lv_obj_scroll_to_view(lv_obj_t * obj, lv_anim_enable_t anim_en)
lv_coord_t y_scroll = 0; lv_coord_t y_scroll = 0;
if((top_diff > 0 || bottom_diff > 0)) { if((top_diff > 0 || bottom_diff > 0)) {
if(LV_MATH_ABS(top_diff) < LV_MATH_ABS(bottom_diff)) y_scroll = top_diff; if(LV_ABS(top_diff) < LV_ABS(bottom_diff)) y_scroll = top_diff;
else y_scroll = -bottom_diff; else y_scroll = -bottom_diff;
} }
lv_coord_t x_scroll = 0; lv_coord_t x_scroll = 0;
if((left_diff > 0 || right_diff > 0)) { if((left_diff > 0 || right_diff > 0)) {
if(LV_MATH_ABS(left_diff) < LV_MATH_ABS(right_diff)) x_scroll = left_diff; if(LV_ABS(left_diff) < LV_ABS(right_diff)) x_scroll = left_diff;
else x_scroll = -right_diff; else x_scroll = -right_diff;
} }

View File

@@ -104,7 +104,7 @@ void lv_obj_add_style_no_refresh(struct _lv_obj_t * obj, uint32_t part, uint32_t
obj->style_list.styles[j] = obj->style_list.styles[j - 1]; obj->style_list.styles[j] = obj->style_list.styles[j - 1];
} }
_lv_memset_00(&obj->style_list.styles[i], sizeof(lv_obj_style_t)); lv_memset_00(&obj->style_list.styles[i], sizeof(lv_obj_style_t));
obj->style_list.styles[i].style = style; obj->style_list.styles[i].style = style;
obj->style_list.styles[i].part = part; obj->style_list.styles[i].part = part;
obj->style_list.styles[i].state = state; obj->style_list.styles[i].state = state;
@@ -460,7 +460,7 @@ lv_obj_style_t * _get_trans_style(lv_obj_t * obj, uint32_t part)
obj->style_list.styles[i] = obj->style_list.styles[i - 1]; obj->style_list.styles[i] = obj->style_list.styles[i - 1];
} }
_lv_memset_00(&obj->style_list.styles[0], sizeof(lv_obj_style_t)); lv_memset_00(&obj->style_list.styles[0], sizeof(lv_obj_style_t));
obj->style_list.styles[0].style = lv_mem_alloc(sizeof(lv_style_t)); obj->style_list.styles[0].style = lv_mem_alloc(sizeof(lv_style_t));
lv_style_init(obj->style_list.styles[0].style); lv_style_init(obj->style_list.styles[0].style);
obj->style_list.styles[0].is_trans = 1; obj->style_list.styles[0].is_trans = 1;
@@ -491,7 +491,7 @@ lv_style_t * lv_obj_get_local_style(lv_obj_t * obj, uint32_t part, uint32_t stat
obj->style_list.styles[i] = obj->style_list.styles[i - 1]; obj->style_list.styles[i] = obj->style_list.styles[i - 1];
} }
_lv_memset_00(&obj->style_list.styles[i], sizeof(lv_obj_style_t)); lv_memset_00(&obj->style_list.styles[i], sizeof(lv_obj_style_t));
obj->style_list.styles[i].style = lv_mem_alloc(sizeof(lv_style_t)); obj->style_list.styles[i].style = lv_mem_alloc(sizeof(lv_style_t));
lv_style_init(obj->style_list.styles[i].style); lv_style_init(obj->style_list.styles[i].style);
obj->style_list.styles[i].is_local = 1; obj->style_list.styles[i].is_local = 1;
@@ -546,8 +546,8 @@ void _lv_obj_create_style_transition(lv_obj_t * obj, lv_style_prop_t prop, uint8
if(v1.num == LV_RADIUS_CIRCLE || v2.num == LV_RADIUS_CIRCLE) { if(v1.num == LV_RADIUS_CIRCLE || v2.num == LV_RADIUS_CIRCLE) {
lv_coord_t whalf = lv_obj_get_width(obj) / 2; lv_coord_t whalf = lv_obj_get_width(obj) / 2;
lv_coord_t hhalf = lv_obj_get_width(obj) / 2; lv_coord_t hhalf = lv_obj_get_width(obj) / 2;
if(v1.num == LV_RADIUS_CIRCLE) v1.num = LV_MATH_MIN(whalf + 1, hhalf + 1); if(v1.num == LV_RADIUS_CIRCLE) v1.num = LV_MIN(whalf + 1, hhalf + 1);
if(v2.num == LV_RADIUS_CIRCLE) v2.num = LV_MATH_MIN(whalf + 1, hhalf + 1); if(v2.num == LV_RADIUS_CIRCLE) v2.num = LV_MIN(whalf + 1, hhalf + 1);
} }
} }
@@ -632,10 +632,14 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_OFS_Y, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_SHADOW_OFS_Y, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_SHADOW_SPREAD, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_SHADOW_SPREAD, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_LINE_WIDTH, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_LINE_WIDTH, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_SRC, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_CONTENT_TEXT, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_OFS_X, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_CONTENT_OFS_X, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_OFS_Y, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_CONTENT_OFS_Y, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_ALIGN, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD; else if(lv_style_get_prop(style, LV_STYLE_CONTENT_ALIGN, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_FONT, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_LINE_SPACE, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_LETTER_SPACE, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else if(lv_style_get_prop(style, LV_STYLE_CONTENT_OPA, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else { else {
if(res != _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) res = _LV_STYLE_STATE_CMP_DIFF_REDRAW; if(res != _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) res = _LV_STYLE_STATE_CMP_DIFF_REDRAW;
} }
@@ -719,16 +723,9 @@ static void update_cache(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop)
list->cache_transform_zero = 0; list->cache_transform_zero = 0;
} }
} }
if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_BG_BLEND_MODE || prop == LV_STYLE_TEXT_BLEND_MODE || prop == LV_STYLE_BORDER_BLEND_MODE) { if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_BLEND_MODE) {
lv_style_value_t va[5]; if(get_prop_core(obj, part, LV_STYLE_BLEND_MODE, &v) == false) v.num = LV_BLEND_MODE_NORMAL;
if(get_prop_core(obj, part, LV_STYLE_BG_BLEND_MODE, &va[0]) == false) va[0].num = 0; list->cache_blend_mode_zero = v.num == LV_BLEND_MODE_NORMAL ? 1 : 0;
if(get_prop_core(obj, part, LV_STYLE_BORDER_BLEND_MODE, &va[1]) == false) va[1].num = 0;
if(get_prop_core(obj, part, LV_STYLE_SHADOW_BLEND_MODE, &va[1]) == false) va[2].num = 0;
if(get_prop_core(obj, part, LV_STYLE_OUTLINE_BLEND_MODE, &va[1]) == false) va[3].num = 0;
if(get_prop_core(obj, part, LV_STYLE_TEXT_BLEND_MODE, &va[2]) == false) va[4].num = 0;
if(va[0].num || va[1].num || va[2].num || va[3].num || va[4].num) list->cache_blend_mode_zero = 1;
else list->cache_blend_mode_zero = 0;
} }
if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_BG_GRAD_DIR) { if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_BG_GRAD_DIR) {
@@ -751,8 +748,8 @@ static void update_cache(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop)
if(v.num == 0) list->cache_img_recolor_opa_zero = 1; if(v.num == 0) list->cache_img_recolor_opa_zero = 1;
else list->cache_img_recolor_opa_zero = 0; else list->cache_img_recolor_opa_zero = 0;
} }
if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_CONTENT_SRC) { if(prop == LV_STYLE_PROP_ALL || prop == LV_STYLE_CONTENT_TEXT) {
if(get_prop_core(obj, part, LV_STYLE_CONTENT_SRC, &v) == false) v.ptr = NULL; if(get_prop_core(obj, part, LV_STYLE_CONTENT_TEXT, &v) == false) v.ptr = NULL;
if(v.ptr == NULL) list->cache_content_src_zero = 1; if(v.ptr == NULL) list->cache_content_src_zero = 1;
else list->cache_content_src_zero = 0; else list->cache_content_src_zero = 0;
} }
@@ -806,19 +803,11 @@ static cache_t read_cache(const lv_obj_t * obj, lv_part_t part, lv_style_prop_t
switch(prop) { switch(prop) {
case LV_STYLE_BG_BLEND_MODE: case LV_STYLE_BLEND_MODE:
case LV_STYLE_BORDER_BLEND_MODE:
case LV_STYLE_SHADOW_BLEND_MODE:
case LV_STYLE_OUTLINE_BLEND_MODE:
if(list->cache_blend_mode_zero ) return CACHE_ZERO; if(list->cache_blend_mode_zero ) return CACHE_ZERO;
else return CACHE_NEED_CHECK; else return CACHE_NEED_CHECK;
break; break;
case LV_STYLE_TEXT_BLEND_MODE:
if(list->cache_blend_mode_zero ) return CACHE_UNSET;
else return CACHE_NEED_CHECK;
break;
case LV_STYLE_OPA: case LV_STYLE_OPA:
if(list->cache_opa_set) return CACHE_NEED_CHECK; if(list->cache_opa_set) return CACHE_NEED_CHECK;
else return CACHE_UNSET; else return CACHE_UNSET;
@@ -871,7 +860,7 @@ static cache_t read_cache(const lv_obj_t * obj, lv_part_t part, lv_style_prop_t
if(list->cache_shadow_width_zero ) return CACHE_ZERO; if(list->cache_shadow_width_zero ) return CACHE_ZERO;
else return CACHE_NEED_CHECK; else return CACHE_NEED_CHECK;
break; break;
case LV_STYLE_CONTENT_SRC: case LV_STYLE_CONTENT_TEXT:
if(list->cache_content_src_zero ) return CACHE_ZERO; if(list->cache_content_src_zero ) return CACHE_ZERO;
else return CACHE_NEED_CHECK; else return CACHE_NEED_CHECK;
break; break;
@@ -1004,12 +993,7 @@ static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v)
case LV_STYLE_BORDER_SIDE: case LV_STYLE_BORDER_SIDE:
case LV_STYLE_BORDER_POST: case LV_STYLE_BORDER_POST:
case LV_STYLE_BG_BLEND_MODE: case LV_STYLE_BLEND_MODE:
case LV_STYLE_BORDER_BLEND_MODE:
case LV_STYLE_OUTLINE_BLEND_MODE:
case LV_STYLE_SHADOW_BLEND_MODE:
case LV_STYLE_TEXT_BLEND_MODE:
case LV_STYLE_LINE_BLEND_MODE:
if(v < 255) value_final.num = tr->start_value.num; if(v < 255) value_final.num = tr->start_value.num;
else value_final.num = tr->end_value.num; else value_final.num = tr->end_value.num;
break; break;

View File

@@ -195,228 +195,245 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(struct _lv_obj_t * obj, lv_sta
/********************* /*********************
* OBJ STYLE GET * OBJ STYLE GET
*********************/ *********************/
static inline lv_coord_t lv_obj_get_style_radius(const struct _lv_obj_t * obj, uint32_t part) { static inline lv_coord_t lv_obj_get_style_radius(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_RADIUS); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_RADIUS); return (lv_coord_t) v.num; }
static inline bool lv_obj_get_style_clip_corner(const struct _lv_obj_t * obj, uint32_t part) { static inline bool lv_obj_get_style_clip_corner(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CLIP_CORNER); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CLIP_CORNER); return (bool) v.num; }
static inline lv_coord_t lv_obj_get_style_transform_width(const struct _lv_obj_t * obj, uint32_t part) { static inline lv_coord_t lv_obj_get_style_transform_width(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_WIDTH); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_WIDTH); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_transform_height(const struct _lv_obj_t * obj, uint32_t part) { static inline lv_coord_t lv_obj_get_style_transform_height(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_HEIGHT); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_HEIGHT); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_transform_zoom(const struct _lv_obj_t * obj, uint32_t part) { static inline lv_coord_t lv_obj_get_style_transform_zoom(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ZOOM); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ZOOM); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_transform_angle(const struct _lv_obj_t * obj, uint32_t part) { static inline lv_coord_t lv_obj_get_style_transform_angle(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ANGLE); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSFORM_ANGLE); return (lv_coord_t) v.num; }
static inline lv_opa_t lv_obj_get_style_opa(const struct _lv_obj_t * obj, uint32_t part) { static inline lv_opa_t lv_obj_get_style_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OPA); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OPA); return (lv_opa_t) v.num; }
static inline lv_opa_t lv_obj_get_style_anim_time(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ANIM_TIME); return v.num; }
static inline lv_color_filter_cb_t lv_obj_get_style_color_filter_cb(const struct _lv_obj_t * obj, uint32_t part) { static inline lv_color_filter_cb_t lv_obj_get_style_color_filter_cb(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_CB); return (lv_color_filter_cb_t)v.func; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_CB); return (lv_color_filter_cb_t) v.func; }
static inline lv_opa_t lv_obj_get_style_color_filter_opa(const struct _lv_obj_t * obj, uint32_t part) { static inline lv_opa_t lv_obj_get_style_color_filter_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_OPA); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_OPA); return (lv_opa_t) v.num; }
static inline lv_coord_t lv_obj_get_style_pad_top(const struct _lv_obj_t * obj, uint32_t part) { static inline uint32_t lv_obj_get_style_anim_time(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_TOP); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ANIM_TIME); return (uint32_t) v.num; }
static inline lv_coord_t lv_obj_get_style_pad_bottom(const struct _lv_obj_t * obj, uint32_t part) { static inline const lv_style_transition_t * lv_obj_get_style_transition(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_BOTTOM); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION); return (const lv_style_transition_t *) v.ptr; }
static inline lv_coord_t lv_obj_get_style_pad_left(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_LEFT); return v.num; }
static inline lv_coord_t lv_obj_get_style_pad_right(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_RIGHT); return v.num; }
static inline lv_coord_t lv_obj_get_style_pad_row(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_ROW); return v.num; }
static inline lv_coord_t lv_obj_get_style_pad_column(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_COLUMN); return v.num; }
static inline lv_color_t lv_obj_get_style_bg_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR); return v.color; }
static inline lv_color_t lv_obj_get_style_bg_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR_FILTERED); return v.color; }
static inline lv_opa_t lv_obj_get_style_bg_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_OPA); return v.num; }
static inline lv_color_t lv_obj_get_style_bg_grad_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR); return v.color; }
static inline lv_color_t lv_obj_get_style_bg_grad_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR_FILTERED); return v.color; }
static inline lv_grad_dir_t lv_obj_get_style_bg_grad_dir(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_DIR); return v.num; }
static inline lv_blend_mode_t lv_obj_get_style_bg_blend_mode(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_BLEND_MODE); return v.num; }
static inline lv_coord_t lv_obj_get_style_bg_main_stop(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_MAIN_STOP); return v.num; }
static inline lv_coord_t lv_obj_get_style_bg_grad_stop(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_STOP); return v.num; }
static inline lv_color_t lv_obj_get_style_border_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR); return v.color; }
static inline lv_color_t lv_obj_get_style_border_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR_FILTERED); return v.color; }
static inline lv_opa_t lv_obj_get_style_border_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_OPA); return v.num; }
static inline lv_coord_t lv_obj_get_style_border_width(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_WIDTH); return v.num; }
static inline lv_border_side_t lv_obj_get_style_border_side(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_SIDE); return v.num; }
static inline bool lv_obj_get_style_border_post(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_POST); return v.num; }
static inline lv_blend_mode_t lv_obj_get_style_border_blend_mode(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_BLEND_MODE); return v.num; }
static inline lv_color_t lv_obj_get_style_text_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR); return v.color; }
static inline lv_color_t lv_obj_get_style_text_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR_FILTERED); return v.color; }
static inline lv_opa_t lv_obj_get_style_text_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_OPA); return v.num; }
static inline const lv_font_t * lv_obj_get_style_text_font(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_FONT); return v.ptr; }
static inline lv_coord_t lv_obj_get_style_text_letter_space(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LETTER_SPACE); return v.num; }
static inline lv_coord_t lv_obj_get_style_text_line_space(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LINE_SPACE); return v.num; }
static inline lv_coord_t lv_obj_get_style_text_align(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_ALIGN); return v.num; }
static inline lv_text_decor_t lv_obj_get_style_text_decor(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_DECOR); return v.num; }
static inline lv_blend_mode_t lv_obj_get_style_text_blend_mode(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_BLEND_MODE); return v.num; }
static inline lv_opa_t lv_obj_get_style_img_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_OPA); return v.num; }
static inline lv_blend_mode_t lv_obj_get_style_img_blend_mode(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_BLEND_MODE); return v.num; }
static inline lv_color_t lv_obj_get_style_img_recolor(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR); return v.color; }
static inline lv_color_t lv_obj_get_style_img_recolor_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR_FILTERED); return v.color; }
static inline lv_opa_t lv_obj_get_style_img_recolor_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR_OPA); return v.num; }
static inline lv_coord_t lv_obj_get_style_outline_width(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_WIDTH); return v.num; }
static inline lv_color_t lv_obj_get_style_outline_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR); return v.color; }
static inline lv_color_t lv_obj_get_style_outline_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR_FILTERED); return v.color; }
static inline lv_opa_t lv_obj_get_style_outline_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_OPA); return v.num; }
static inline lv_coord_t lv_obj_get_style_outline_pad(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_PAD); return v.num; }
static inline lv_blend_mode_t lv_obj_get_style_outline_blend_mode(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_BLEND_MODE); return v.num; }
static inline lv_coord_t lv_obj_get_style_shadow_width(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_WIDTH); return v.num; }
static inline lv_coord_t lv_obj_get_style_shadow_ofs_x(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFS_X); return v.num; }
static inline lv_coord_t lv_obj_get_style_shadow_ofs_y(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFS_Y); return v.num; }
static inline lv_coord_t lv_obj_get_style_shadow_spread(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_SPREAD); return v.num; }
static inline lv_blend_mode_t lv_obj_get_style_shadow_blend_mode(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_BLEND_MODE); return v.num; }
static inline lv_color_t lv_obj_get_style_shadow_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR); return v.color; }
static inline lv_color_t lv_obj_get_style_shadow_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR_FILTERED); return v.color; }
static inline lv_opa_t lv_obj_get_style_shadow_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OPA); return v.num; }
static inline lv_coord_t lv_obj_get_style_line_width(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_WIDTH); return v.num; }
static inline lv_blend_mode_t lv_obj_get_style_line_blend_mode(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_BLEND_MODE); return v.num; }
static inline lv_coord_t lv_obj_get_style_line_dash_width(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_WIDTH); return v.num; }
static inline lv_coord_t lv_obj_get_style_line_dash_gap(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_GAP); return v.num; }
static inline lv_coord_t lv_obj_get_style_line_rounded(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_ROUNDED); return v.num; }
static inline lv_color_t lv_obj_get_style_line_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR); return v.color; }
static inline lv_color_t lv_obj_get_style_line_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR_FILTERED); return v.color; }
static inline lv_opa_t lv_obj_get_style_line_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_OPA); return v.num; }
static inline const char * lv_obj_get_style_content_src(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_SRC); return v.ptr; }
static inline lv_align_t lv_obj_get_style_content_align(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_ALIGN); return v.num; }
static inline lv_coord_t lv_obj_get_style_content_ofs_x(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_X); return v.num; }
static inline lv_coord_t lv_obj_get_style_content_ofs_y(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_Y); return v.num; }
static inline const lv_style_transiton_t * lv_obj_get_style_transition(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TRANSITION); return v.ptr; }
static inline lv_coord_t lv_obj_get_style_size(const struct _lv_obj_t * obj, uint32_t part) { static inline lv_coord_t lv_obj_get_style_size(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SIZE); return v.num; } lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SIZE); return (lv_coord_t) v.num; }
static inline lv_blend_mode_t lv_obj_get_style_blend_mode(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BLEND_MODE); return (lv_blend_mode_t) v.num; }
static inline lv_coord_t lv_obj_get_style_pad_top(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_TOP); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_pad_bottom(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_BOTTOM); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_pad_left(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_LEFT); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_pad_right(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_RIGHT); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_pad_row(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_ROW); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_pad_column(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_PAD_COLUMN); return (lv_coord_t) v.num; }
static inline lv_color_t lv_obj_get_style_bg_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR); return (lv_color_t) v.color; }
static inline lv_color_t lv_obj_get_style_bg_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_COLOR_FILTERED); return (lv_color_t) v.color; }
static inline lv_opa_t lv_obj_get_style_bg_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_OPA); return (lv_opa_t) v.num; }
static inline lv_color_t lv_obj_get_style_bg_grad_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR); return (lv_color_t) v.color; }
static inline lv_color_t lv_obj_get_style_bg_grad_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_COLOR_FILTERED); return (lv_color_t) v.color; }
static inline lv_grad_dir_t lv_obj_get_style_bg_grad_dir(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_DIR); return (lv_grad_dir_t) v.num; }
static inline lv_coord_t lv_obj_get_style_bg_main_stop(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_MAIN_STOP); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_bg_grad_stop(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_GRAD_STOP); return (lv_coord_t) v.num; }
static inline const void * lv_obj_get_style_bg_img_src(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMG_SRC); return (const void *) v.ptr; }
static inline lv_color_t lv_obj_get_style_bg_img_recolor(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMG_RECOLOR); return (lv_color_t) v.color; }
static inline lv_color_t lv_obj_get_style_bg_img_recolor_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMG_RECOLOR_FILTERED); return (lv_color_t) v.color; }
static inline lv_opa_t lv_obj_get_style_bg_img_recolor_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMG_RECOLOR_OPA); return (lv_opa_t) v.num; }
static inline bool lv_obj_get_style_bg_img_tiled(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BG_IMG_TILED); return (bool) v.num; }
static inline lv_color_t lv_obj_get_style_border_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR); return (lv_color_t) v.color; }
static inline lv_color_t lv_obj_get_style_border_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_COLOR_FILTERED); return (lv_color_t) v.color; }
static inline lv_opa_t lv_obj_get_style_border_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_OPA); return (lv_opa_t) v.num; }
static inline lv_coord_t lv_obj_get_style_border_width(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_WIDTH); return (lv_coord_t) v.num; }
static inline lv_border_side_t lv_obj_get_style_border_side(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_SIDE); return (lv_border_side_t) v.num; }
static inline bool lv_obj_get_style_border_post(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_BORDER_POST); return (bool) v.num; }
static inline lv_color_t lv_obj_get_style_text_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR); return (lv_color_t) v.color; }
static inline lv_color_t lv_obj_get_style_text_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_COLOR_FILTERED); return (lv_color_t) v.color; }
static inline lv_opa_t lv_obj_get_style_text_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_OPA); return (lv_opa_t) v.num; }
static inline const lv_font_t * lv_obj_get_style_text_font(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_FONT); return (const lv_font_t *) v.ptr; }
static inline lv_coord_t lv_obj_get_style_text_letter_space(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LETTER_SPACE); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_text_line_space(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_LINE_SPACE); return (lv_coord_t) v.num; }
static inline lv_text_decor_t lv_obj_get_style_text_decor(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_DECOR); return (lv_text_decor_t) v.num; }
static inline lv_text_align_t lv_obj_get_style_text_align(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_TEXT_ALIGN); return (lv_text_align_t) v.num; }
static inline lv_opa_t lv_obj_get_style_img_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_OPA); return (lv_opa_t) v.num; }
static inline lv_color_t lv_obj_get_style_img_recolor(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR); return (lv_color_t) v.color; }
static inline lv_color_t lv_obj_get_style_img_recolor_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR_FILTERED); return (lv_color_t) v.color; }
static inline lv_opa_t lv_obj_get_style_img_recolor_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_IMG_RECOLOR_OPA); return (lv_opa_t) v.num; }
static inline lv_coord_t lv_obj_get_style_outline_width(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_WIDTH); return (lv_coord_t) v.num; }
static inline lv_color_t lv_obj_get_style_outline_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR); return (lv_color_t) v.color; }
static inline lv_color_t lv_obj_get_style_outline_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_COLOR_FILTERED); return (lv_color_t) v.color; }
static inline lv_opa_t lv_obj_get_style_outline_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_OPA); return (lv_opa_t) v.num; }
static inline lv_coord_t lv_obj_get_style_outline_pad(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OUTLINE_PAD); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_shadow_width(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_WIDTH); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_shadow_ofs_x(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFS_X); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_shadow_ofs_y(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OFS_Y); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_shadow_spread(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_SPREAD); return (lv_coord_t) v.num; }
static inline lv_color_t lv_obj_get_style_shadow_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR); return (lv_color_t) v.color; }
static inline lv_color_t lv_obj_get_style_shadow_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_COLOR_FILTERED); return (lv_color_t) v.color; }
static inline lv_opa_t lv_obj_get_style_shadow_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_SHADOW_OPA); return (lv_opa_t) v.num; }
static inline lv_coord_t lv_obj_get_style_line_width(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_WIDTH); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_line_dash_width(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_WIDTH); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_line_dash_gap(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_DASH_GAP); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_line_rounded(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_ROUNDED); return (lv_coord_t) v.num; }
static inline lv_color_t lv_obj_get_style_line_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR); return (lv_color_t) v.color; }
static inline lv_color_t lv_obj_get_style_line_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_COLOR_FILTERED); return (lv_color_t) v.color; }
static inline lv_opa_t lv_obj_get_style_line_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_OPA); return (lv_opa_t) v.num; }
static inline const char * lv_obj_get_style_content_text(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_TEXT); return (const char *) v.ptr; }
static inline lv_align_t lv_obj_get_style_content_align(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_ALIGN); return (lv_align_t) v.num; }
static inline lv_coord_t lv_obj_get_style_content_ofs_x(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_X); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_content_ofs_y(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OFS_Y); return (lv_coord_t) v.num; }
static inline lv_opa_t lv_obj_get_style_content_opa(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_OPA); return (lv_opa_t) v.num; }
static inline const lv_font_t * lv_obj_get_style_content_font(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_FONT); return (const lv_font_t *) v.ptr; }
static inline lv_color_t lv_obj_get_style_content_color(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_COLOR); return (lv_color_t) v.color; }
static inline lv_color_t lv_obj_get_style_content_color_filtered(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_COLOR_FILTERED); return (lv_color_t) v.color; }
static inline lv_coord_t lv_obj_get_style_content_letter_space(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_LETTER_SPACE); return (lv_coord_t) v.num; }
static inline lv_coord_t lv_obj_get_style_content_line_space(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_LINE_SPACE); return (lv_coord_t) v.num; }
static inline lv_text_decor_t lv_obj_get_style_content_decor(const struct _lv_obj_t * obj, uint32_t part) {
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_CONTENT_DECOR); return (lv_text_decor_t) v.num; }
/********************** /**********************
* MACROS * MACROS

View File

@@ -225,7 +225,7 @@ void _lv_disp_refr_task(lv_timer_t * tmr)
#if LV_USE_GPU_STM32_DMA2D #if LV_USE_GPU_STM32_DMA2D
LV_UNUSED(copy_buf); LV_UNUSED(copy_buf);
#else #else
copy_buf = _lv_mem_buf_get(disp_refr->driver.hor_res * sizeof(lv_color_t)); copy_buf = lv_mem_buf_get(disp_refr->driver.hor_res * sizeof(lv_color_t));
#endif #endif
uint8_t * buf_act = (uint8_t *)vdb->buf_act; uint8_t * buf_act = (uint8_t *)vdb->buf_act;
@@ -250,21 +250,21 @@ void _lv_disp_refr_task(lv_timer_t * tmr)
for(y = disp_refr->inv_areas[a].y1; y <= disp_refr->inv_areas[a].y2; y++) { for(y = disp_refr->inv_areas[a].y1; y <= disp_refr->inv_areas[a].y2; y++) {
/* The frame buffer is probably in an external RAM where sequential access is much faster. /* The frame buffer is probably in an external RAM where sequential access is much faster.
* So first copy a line into a buffer and write it back the ext. RAM */ * So first copy a line into a buffer and write it back the ext. RAM */
_lv_memcpy(copy_buf, buf_ina + start_offs, line_length); lv_memcpy(copy_buf, buf_ina + start_offs, line_length);
_lv_memcpy(buf_act + start_offs, copy_buf, line_length); lv_memcpy(buf_act + start_offs, copy_buf, line_length);
start_offs += hres * sizeof(lv_color_t); start_offs += hres * sizeof(lv_color_t);
} }
#endif #endif
} }
} }
if(copy_buf) _lv_mem_buf_release(copy_buf); if(copy_buf) lv_mem_buf_release(copy_buf);
} }
} /*End of true double buffer handling*/ } /*End of true double buffer handling*/
/*Clean up*/ /*Clean up*/
_lv_memset_00(disp_refr->inv_areas, sizeof(disp_refr->inv_areas)); lv_memset_00(disp_refr->inv_areas, sizeof(disp_refr->inv_areas));
_lv_memset_00(disp_refr->inv_area_joined, sizeof(disp_refr->inv_area_joined)); lv_memset_00(disp_refr->inv_area_joined, sizeof(disp_refr->inv_area_joined));
disp_refr->inv_p = 0; disp_refr->inv_p = 0;
elaps = lv_tick_elaps(start); elaps = lv_tick_elaps(start);
@@ -274,7 +274,7 @@ void _lv_disp_refr_task(lv_timer_t * tmr)
} }
} }
_lv_mem_buf_free_all(); lv_mem_buf_free_all();
_lv_font_clean_up_fmt_txt(); _lv_font_clean_up_fmt_txt();
#if LV_USE_PERF_MONITOR && LV_USE_LABEL #if LV_USE_PERF_MONITOR && LV_USE_LABEL

View File

@@ -21,9 +21,6 @@
/********************** /**********************
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static void set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value);
static bool get_prop(const lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value);
static bool remove_prop(lv_style_t * style, lv_style_prop_t prop);
/********************** /**********************
* GLOBAL VARIABLES * GLOBAL VARIABLES
@@ -51,7 +48,7 @@ void _lv_style_system_init(void)
*/ */
void lv_style_init(lv_style_t * style) void lv_style_init(lv_style_t * style)
{ {
_lv_memset_00(style, sizeof(lv_style_t)); lv_memset_00(style, sizeof(lv_style_t));
#if LV_USE_ASSERT_STYLE #if LV_USE_ASSERT_STYLE
style->sentinel = LV_DEBUG_STYLE_SENTINEL_VALUE; style->sentinel = LV_DEBUG_STYLE_SENTINEL_VALUE;
#endif #endif
@@ -75,7 +72,50 @@ uint16_t lv_style_register_prop(bool inherit)
*/ */
bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop) bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop)
{ {
return remove_prop(style, prop); if(style == NULL) return false;
LV_ASSERT_STYLE(style);
if(!style->allocated) {
if(style->prop1 == prop) {
style->prop1 = _LV_STYLE_PROP_INV;
return true;
}
return false;
}
uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t);
uint16_t * props = (uint16_t *) tmp;
uint32_t i;
for(i = 0; i < style->prop_cnt; i++) {
if(props[i] == prop) {
lv_style_value_t * values = (lv_style_value_t *)style->props_and_values;
style->prop_cnt--;
size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t));
uint8_t * new_values_and_props = lv_mem_alloc(size);
uint8_t * tmp = new_values_and_props + style->prop_cnt * sizeof(lv_style_value_t);
uint16_t * new_props = (uint16_t *) tmp;
lv_style_value_t * new_values = (lv_style_value_t *)new_values_and_props;
uint32_t j;
for(j = 0; j < style->prop_cnt + 1; j++) { /* +1: because prop_cnt already reduced but all the old props. needs to be checked. */
if(props[j] != prop) {
*new_values = values[j];
*new_props = props[j];
new_values++;
new_props++;
}
}
lv_mem_free(style->props_and_values);
style->props_and_values = new_values_and_props;
return true;
}
}
return false;
} }
/** /**
@@ -91,17 +131,87 @@ void lv_style_reset(lv_style_t * style)
void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value) void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value)
{ {
set_prop(style, prop, value); if(style->allocated) {
uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t);
uint16_t * props = (uint16_t *) tmp;
int32_t i;
for(i = 0; i < style->prop_cnt; i++) {
if(props[i] == prop) {
lv_style_value_t * values = (lv_style_value_t *)style->props_and_values;
values[i] = value;
return;
}
}
style->prop_cnt++;
size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t));
style->props_and_values = lv_mem_realloc(style->props_and_values, size);
tmp = style->props_and_values + (style->prop_cnt - 1) * sizeof(lv_style_value_t);
props = (uint16_t *) tmp;
/*Shift all props to make place for the value before them*/
for(i = style->prop_cnt - 2; i >= 0; i--) {
props[i + sizeof(lv_style_value_t) /sizeof(uint16_t)] = props[i];
}
/*Go to the new position wit the props*/
tmp = style->props_and_values + (style->prop_cnt) * sizeof(lv_style_value_t);
props = (uint16_t *) tmp;
lv_style_value_t * values = (lv_style_value_t *)style->props_and_values;
/*Set the new property and value*/
props[style->prop_cnt - 1] = prop;
values[style->prop_cnt - 1] = value;
} else if(style->prop_cnt == 1) {
if(style->prop1 == prop) {
style->value1 = value;
return;
}
style->prop_cnt++;
size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t));
uint8_t * props_and_values = lv_mem_alloc(size);
uint8_t * tmp = props_and_values + (style->prop_cnt) * sizeof(lv_style_value_t);
uint16_t * props = (uint16_t *) tmp;
lv_style_value_t * values = (lv_style_value_t *)props_and_values;
props[0] = style->prop1;
props[1] = prop;
values[0] = style->value1;
values[1] = value;
style->props_and_values = props_and_values;
style->allocated = 1;
} else if (style->prop_cnt == 0) {
style->prop_cnt++;
style->prop1 = prop;
style->value1 = value;
}
} }
bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value) bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value)
{ {
return get_prop(style, prop, value); if(style->allocated) {
uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t);
uint16_t * props = (uint16_t *) tmp;
uint32_t i;
for(i = 0; i < style->prop_cnt; i++) {
if(props[i] == prop) {
lv_style_value_t * values = (lv_style_value_t *)style->props_and_values;
*value = values[i];
return true;
}
}
} else {
if(style->prop1 == prop) {
*value = style->value1;
return true;
}
}
return false;
} }
void lv_style_transition_init(lv_style_transiton_t * tr, const lv_style_prop_t * props, const lv_anim_path_t * path, uint32_t time, uint32_t delay) void lv_style_transition_init(lv_style_transition_t * tr, const lv_style_prop_t * props, const lv_anim_path_t * path, uint32_t time, uint32_t delay)
{ {
_lv_memset_00(tr, sizeof(lv_style_transiton_t)); lv_memset_00(tr, sizeof(lv_style_transition_t));
tr->props = props; tr->props = props;
tr->path = path; tr->path = path;
tr->time = time; tr->time = time;
@@ -187,134 +297,3 @@ bool lv_style_is_empty(const lv_style_t * style)
/********************** /**********************
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/
static void set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t value)
{
if(style->allocated) {
uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t);
uint16_t * props = (uint16_t *) tmp;
int32_t i;
for(i = 0; i < style->prop_cnt; i++) {
if(props[i] == prop) {
lv_style_value_t * values = (lv_style_value_t *)style->props_and_values;
values[i] = value;
return;
}
}
style->prop_cnt++;
size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t));
style->props_and_values = lv_mem_realloc(style->props_and_values, size);
tmp = style->props_and_values + (style->prop_cnt - 1) * sizeof(lv_style_value_t);
props = (uint16_t *) tmp;
/*Shift all props to make place for the value before them*/
for(i = style->prop_cnt - 2; i >= 0; i--) {
props[i + sizeof(lv_style_value_t) /sizeof(uint16_t)] = props[i];
}
/*Go to the new position wit the props*/
tmp = style->props_and_values + (style->prop_cnt) * sizeof(lv_style_value_t);
props = (uint16_t *) tmp;
lv_style_value_t * values = (lv_style_value_t *)style->props_and_values;
/*Set the new propery and value*/
props[style->prop_cnt - 1] = prop;
values[style->prop_cnt - 1] = value;
} else if(style->prop_cnt == 1) {
if(style->prop1 == prop) {
style->value1 = value;
return;
}
style->prop_cnt++;
size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t));
uint8_t * props_and_values = lv_mem_alloc(size);
uint8_t * tmp = props_and_values + (style->prop_cnt) * sizeof(lv_style_value_t);
uint16_t * props = (uint16_t *) tmp;
lv_style_value_t * values = (lv_style_value_t *)props_and_values;
props[0] = style->prop1;
props[1] = prop;
values[0] = style->value1;
values[1] = value;
style->props_and_values = props_and_values;
style->allocated = 1;
} else if (style->prop_cnt == 0) {
style->prop_cnt++;
style->prop1 = prop;
style->value1 = value;
}
}
static bool get_prop(const lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value)
{
if(style->allocated) {
uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t);
uint16_t * props = (uint16_t *) tmp;
uint32_t i;
for(i = 0; i < style->prop_cnt; i++) {
if(props[i] == prop) {
lv_style_value_t * values = (lv_style_value_t *)style->props_and_values;
*value = values[i];
return true;
}
}
} else {
if(style->prop1 == prop) {
*value = style->value1;
return true;
}
}
return false;
}
static bool remove_prop(lv_style_t * style, lv_style_prop_t prop)
{
if(style == NULL) return false;
LV_ASSERT_STYLE(style);
if(!style->allocated) {
if(style->prop1 == prop) {
style->prop1 = _LV_STYLE_PROP_INV;
return true;
}
return false;
}
uint8_t * tmp = style->props_and_values + style->prop_cnt * sizeof(lv_style_value_t);
uint16_t * props = (uint16_t *) tmp;
uint32_t i;
for(i = 0; i < style->prop_cnt; i++) {
if(props[i] == prop) {
lv_style_value_t * values = (lv_style_value_t *)style->props_and_values;
style->prop_cnt--;
size_t size = style->prop_cnt * (sizeof(lv_style_value_t) + sizeof(uint16_t));
uint8_t * new_values_and_props = lv_mem_alloc(size);
uint8_t * tmp = new_values_and_props + style->prop_cnt * sizeof(lv_style_value_t);
uint16_t * new_props = (uint16_t *) tmp;
lv_style_value_t * new_values = (lv_style_value_t *)new_values_and_props;
uint32_t j;
for(j = 0; j < style->prop_cnt + 1; j++) { /* +1: because prop_cnt already reduced but all the old props. needs to be checked. */
if(props[j] != prop) {
*new_values = values[j];
*new_props = props[j];
new_values++;
new_props++;
}
}
lv_mem_free(style->props_and_values);
style->props_and_values = new_values_and_props;
return true;
}
}
return false;
}

View File

@@ -63,6 +63,7 @@ typedef enum {
LV_STYLE_ANIM_TIME = 10, LV_STYLE_ANIM_TIME = 10,
LV_STYLE_TRANSITION = 11, LV_STYLE_TRANSITION = 11,
LV_STYLE_SIZE = 12, LV_STYLE_SIZE = 12,
LV_STYLE_BLEND_MODE = 13,
LV_STYLE_PAD_TOP = 20 | LV_STYLE_PROP_LAYOUT_REFR, LV_STYLE_PAD_TOP = 20 | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_PAD_BOTTOM = 21 | LV_STYLE_PROP_LAYOUT_REFR, LV_STYLE_PAD_BOTTOM = 21 | LV_STYLE_PROP_LAYOUT_REFR,
@@ -77,63 +78,70 @@ typedef enum {
LV_STYLE_BG_GRAD_COLOR = 32, LV_STYLE_BG_GRAD_COLOR = 32,
LV_STYLE_BG_GRAD_COLOR_FILTERED = 32 | LV_STYLE_PROP_FILTER, LV_STYLE_BG_GRAD_COLOR_FILTERED = 32 | LV_STYLE_PROP_FILTER,
LV_STYLE_BG_GRAD_DIR = 33, LV_STYLE_BG_GRAD_DIR = 33,
LV_STYLE_BG_BLEND_MODE = 34,
LV_STYLE_BG_MAIN_STOP = 35, LV_STYLE_BG_MAIN_STOP = 35,
LV_STYLE_BG_GRAD_STOP = 36, LV_STYLE_BG_GRAD_STOP = 36,
LV_STYLE_BORDER_COLOR = 40, LV_STYLE_BG_IMG_SRC = 40,
LV_STYLE_BORDER_COLOR_FILTERED = 40 | LV_STYLE_PROP_FILTER, LV_STYLE_BG_IMG_OPA = 41,
LV_STYLE_BORDER_OPA = 41, LV_STYLE_BG_IMG_RECOLOR = 42,
LV_STYLE_BORDER_WIDTH = 42, LV_STYLE_BG_IMG_RECOLOR_FILTERED = 43 | LV_STYLE_PROP_FILTER,
LV_STYLE_BORDER_SIDE = 43, LV_STYLE_BG_IMG_RECOLOR_OPA = 44,
LV_STYLE_BORDER_POST = 44, LV_STYLE_BG_IMG_TILED = 45,
LV_STYLE_BORDER_BLEND_MODE = 45,
LV_STYLE_TEXT_COLOR = 50 | LV_STYLE_PROP_INHERIT, LV_STYLE_BORDER_COLOR = 50,
LV_STYLE_TEXT_COLOR_FILTERED = 50 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_FILTER, LV_STYLE_BORDER_COLOR_FILTERED = 50 | LV_STYLE_PROP_FILTER,
LV_STYLE_TEXT_OPA = 51 | LV_STYLE_PROP_INHERIT, LV_STYLE_BORDER_OPA = 51,
LV_STYLE_TEXT_FONT = 52 | LV_STYLE_PROP_INHERIT, LV_STYLE_BORDER_WIDTH = 52,
LV_STYLE_TEXT_LETTER_SPACE = 53 | LV_STYLE_PROP_INHERIT, LV_STYLE_BORDER_SIDE = 53,
LV_STYLE_TEXT_LINE_SPACE = 54 | LV_STYLE_PROP_INHERIT, LV_STYLE_BORDER_POST = 54,
LV_STYLE_TEXT_DECOR = 55 | LV_STYLE_PROP_INHERIT,
LV_STYLE_TEXT_ALIGN = 56 | LV_STYLE_PROP_INHERIT,
LV_STYLE_TEXT_BLEND_MODE = 57 | LV_STYLE_PROP_INHERIT,
LV_STYLE_IMG_OPA = 60, LV_STYLE_TEXT_COLOR = 60 | LV_STYLE_PROP_INHERIT,
LV_STYLE_IMG_BLEND_MODE = 61, LV_STYLE_TEXT_COLOR_FILTERED = 60 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_FILTER,
LV_STYLE_IMG_RECOLOR = 62, LV_STYLE_TEXT_OPA = 61 | LV_STYLE_PROP_INHERIT,
LV_STYLE_IMG_RECOLOR_FILTERED = 62 | LV_STYLE_PROP_FILTER, LV_STYLE_TEXT_FONT = 62 | LV_STYLE_PROP_INHERIT,
LV_STYLE_IMG_RECOLOR_OPA = 63, LV_STYLE_TEXT_LETTER_SPACE = 63 | LV_STYLE_PROP_INHERIT,
LV_STYLE_TEXT_LINE_SPACE = 64 | LV_STYLE_PROP_INHERIT,
LV_STYLE_TEXT_DECOR = 65 | LV_STYLE_PROP_INHERIT,
LV_STYLE_TEXT_ALIGN = 66 | LV_STYLE_PROP_INHERIT,
LV_STYLE_OUTLINE_WIDTH = 71 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_IMG_OPA = 70,
LV_STYLE_OUTLINE_COLOR = 72, LV_STYLE_IMG_RECOLOR = 71,
LV_STYLE_OUTLINE_COLOR_FILTERED = 72 | LV_STYLE_PROP_FILTER, LV_STYLE_IMG_RECOLOR_FILTERED = 71 | LV_STYLE_PROP_FILTER,
LV_STYLE_OUTLINE_OPA = 73 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_IMG_RECOLOR_OPA = 73,
LV_STYLE_OUTLINE_PAD = 74 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_OUTLINE_BLEND_MODE = 75,
LV_STYLE_SHADOW_WIDTH = 80 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_OUTLINE_WIDTH = 80 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_SHADOW_OFS_X = 81 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_OUTLINE_COLOR = 81,
LV_STYLE_SHADOW_OFS_Y = 82 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_OUTLINE_COLOR_FILTERED = 81 | LV_STYLE_PROP_FILTER,
LV_STYLE_SHADOW_SPREAD = 83 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_OUTLINE_OPA = 82 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_SHADOW_BLEND_MODE = 84, LV_STYLE_OUTLINE_PAD = 83 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_SHADOW_COLOR = 85,
LV_STYLE_SHADOW_COLOR_FILTERED = 85 | LV_STYLE_PROP_FILTER,
LV_STYLE_SHADOW_OPA = 86 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_LINE_WIDTH = 90 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_SHADOW_WIDTH = 90 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_LINE_BLEND_MODE = 91, LV_STYLE_SHADOW_OFS_X = 91 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_LINE_DASH_WIDTH = 92, LV_STYLE_SHADOW_OFS_Y = 92 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_LINE_DASH_GAP = 93, LV_STYLE_SHADOW_SPREAD = 93 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_LINE_ROUNDED = 94, LV_STYLE_SHADOW_COLOR = 94,
LV_STYLE_LINE_COLOR = 95, LV_STYLE_SHADOW_COLOR_FILTERED = 94 | LV_STYLE_PROP_FILTER,
LV_STYLE_LINE_COLOR_FILTERED = 95 | LV_STYLE_PROP_FILTER, LV_STYLE_SHADOW_OPA = 95 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_LINE_OPA = 96,
LV_STYLE_CONTENT_SRC = 100 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_LINE_WIDTH = 100 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_CONTENT_ALIGN = 101 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_LINE_DASH_WIDTH = 101,
LV_STYLE_CONTENT_OFS_X = 102 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_LINE_DASH_GAP = 102,
LV_STYLE_CONTENT_OFS_Y = 103 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_LINE_ROUNDED = 103,
LV_STYLE_LINE_COLOR = 104,
LV_STYLE_LINE_COLOR_FILTERED = 104 | LV_STYLE_PROP_FILTER,
LV_STYLE_LINE_OPA = 105,
LV_STYLE_CONTENT_TEXT = 110 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_CONTENT_ALIGN = 111 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_CONTENT_OFS_X = 112 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_CONTENT_OFS_Y = 113 | LV_STYLE_PROP_EXT_DRAW,
LV_STYLE_CONTENT_FONT = 114 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT,
LV_STYLE_CONTENT_COLOR = 115 | LV_STYLE_PROP_INHERIT,
LV_STYLE_CONTENT_COLOR_FILTERED = 115 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_FILTER,
LV_STYLE_CONTENT_OPA = 116 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT,
LV_STYLE_CONTENT_LETTER_SPACE = 117 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT,
LV_STYLE_CONTENT_LINE_SPACE = 118 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT,
LV_STYLE_CONTENT_DECOR = 119 | LV_STYLE_PROP_EXT_DRAW | LV_STYLE_PROP_INHERIT,
_LV_STYLE_LAST_BUILT_IN_PROP = 128, _LV_STYLE_LAST_BUILT_IN_PROP = 128,
@@ -147,7 +155,7 @@ typedef struct _lv_style_transiton_t{
const lv_anim_path_t * path; const lv_anim_path_t * path;
uint32_t time; uint32_t time;
uint32_t delay; uint32_t delay;
}lv_style_transiton_t; }lv_style_transition_t;
#if LV_USE_ASSERT_STYLE #if LV_USE_ASSERT_STYLE
# define _LV_STYLE_SENTINEL uint32_t sentinel; # define _LV_STYLE_SENTINEL uint32_t sentinel;
@@ -196,7 +204,7 @@ void lv_style_set_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_
bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value); bool lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_value_t * value);
void lv_style_transition_init(lv_style_transiton_t * tr, const lv_style_prop_t * props, const lv_anim_path_t * path, uint32_t time, uint32_t delay); void lv_style_transition_init(lv_style_transition_t * tr, const lv_style_prop_t * props, const lv_anim_path_t * path, uint32_t time, uint32_t delay);
uint32_t lv_style_find_index_num(lv_style_value_t v); uint32_t lv_style_find_index_num(lv_style_value_t v);
uint32_t lv_style_find_index_color(lv_style_value_t v); uint32_t lv_style_find_index_color(lv_style_value_t v);
@@ -213,9 +221,6 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_prop_t prop);
static inline void lv_style_set_radius(lv_style_t * style, lv_coord_t value) { 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); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_RADIUS, v); }
static inline void lv_style_set_anim_time(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_ANIM_TIME, v); }
static inline void lv_style_set_clip_corner(lv_style_t * style, bool value) { static inline void lv_style_set_clip_corner(lv_style_t * style, bool value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CLIP_CORNER, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CLIP_CORNER, v); }
@@ -240,6 +245,18 @@ static inline void lv_style_set_color_filter_cb(lv_style_t * style, lv_color_fil
static inline void lv_style_set_color_filter_opa(lv_style_t * style, lv_opa_t value) { static inline void lv_style_set_color_filter_opa(lv_style_t * style, lv_opa_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_COLOR_FILTER_OPA, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_COLOR_FILTER_OPA, v); }
static inline void lv_style_set_anim_time(lv_style_t * style, uint32_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_ANIM_TIME, v); }
static inline void lv_style_set_transition(lv_style_t * style, const lv_style_transition_t * value) {
lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION, v); }
static inline void lv_style_set_size(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SIZE, v); }
static inline void lv_style_set_blend_mode(lv_style_t * style, lv_blend_mode_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BLEND_MODE, v); }
static inline void lv_style_set_pad_top(lv_style_t * style, lv_coord_t value) { static inline void lv_style_set_pad_top(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_TOP, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_PAD_TOP, v); }
@@ -276,15 +293,27 @@ static inline void lv_style_set_bg_grad_color_filtered(lv_style_t * style, lv_co
static inline void lv_style_set_bg_grad_dir(lv_style_t * style, lv_grad_dir_t value) { static inline void lv_style_set_bg_grad_dir(lv_style_t * style, lv_grad_dir_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_DIR, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_DIR, v); }
static inline void lv_style_set_bg_blend_mode(lv_style_t * style, lv_blend_mode_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_BLEND_MODE, v); }
static inline void lv_style_set_bg_main_stop(lv_style_t * style, lv_coord_t value) { static inline void lv_style_set_bg_main_stop(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_MAIN_STOP, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_MAIN_STOP, v); }
static inline void lv_style_set_bg_grad_stop(lv_style_t * style, lv_coord_t value) { static inline void lv_style_set_bg_grad_stop(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_STOP, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_GRAD_STOP, v); }
static inline void lv_style_set_bg_img_src(lv_style_t * style, const void * value) {
lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_SRC, v); }
static inline void lv_style_set_bg_img_recolor(lv_style_t * style, lv_color_t value) {
lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_RECOLOR, v); }
static inline void lv_style_set_bg_img_recolor_filtered(lv_style_t * style, lv_color_t value) {
lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_RECOLOR_FILTERED, v); }
static inline void lv_style_set_bg_img_recolor_opa(lv_style_t * style, lv_opa_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_RECOLOR_OPA, v); }
static inline void lv_style_set_bg_img_tiled(lv_style_t * style, bool value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BG_IMG_TILED, v); }
static inline void lv_style_set_border_color(lv_style_t * style, lv_color_t value) { static inline void lv_style_set_border_color(lv_style_t * style, lv_color_t value) {
lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BORDER_COLOR, v); } lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_BORDER_COLOR, v); }
@@ -303,9 +332,6 @@ static inline void lv_style_set_border_side(lv_style_t * style, lv_border_side_t
static inline void lv_style_set_border_post(lv_style_t * style, bool value) { static inline void lv_style_set_border_post(lv_style_t * style, bool value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BORDER_POST, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BORDER_POST, v); }
static inline void lv_style_set_border_blend_mode(lv_style_t * style, lv_blend_mode_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_BORDER_BLEND_MODE, v); }
static inline void lv_style_set_text_color(lv_style_t * style, lv_color_t value) { static inline void lv_style_set_text_color(lv_style_t * style, lv_color_t value) {
lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_TEXT_COLOR, v); } lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_TEXT_COLOR, v); }
@@ -327,15 +353,12 @@ static inline void lv_style_set_text_line_space(lv_style_t * style, lv_coord_t v
static inline void lv_style_set_text_decor(lv_style_t * style, lv_text_decor_t value) { static inline void lv_style_set_text_decor(lv_style_t * style, lv_text_decor_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_DECOR, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_DECOR, v); }
static inline void lv_style_set_text_blend_mode(lv_style_t * style, lv_blend_mode_t value) { static inline void lv_style_set_text_align(lv_style_t * style, lv_text_align_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_BLEND_MODE, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_TEXT_ALIGN, v); }
static inline void lv_style_set_img_opa(lv_style_t * style, lv_opa_t value) { static inline void lv_style_set_img_opa(lv_style_t * style, lv_opa_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_IMG_OPA, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_IMG_OPA, v); }
static inline void lv_style_set_img_blend_mode(lv_style_t * style, lv_blend_mode_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_IMG_BLEND_MODE, v); }
static inline void lv_style_set_img_recolor(lv_style_t * style, lv_color_t value) { static inline void lv_style_set_img_recolor(lv_style_t * style, lv_color_t value) {
lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_IMG_RECOLOR, v); } lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_IMG_RECOLOR, v); }
@@ -351,15 +374,15 @@ static inline void lv_style_set_outline_width(lv_style_t * style, lv_coord_t val
static inline void lv_style_set_outline_color(lv_style_t * style, lv_color_t value) { static inline void lv_style_set_outline_color(lv_style_t * style, lv_color_t value) {
lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_COLOR, v); } lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_COLOR, v); }
static inline void lv_style_set_outline_color_filtered(lv_style_t * style, lv_color_t value) {
lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_COLOR_FILTERED, v); }
static inline void lv_style_set_outline_opa(lv_style_t * style, lv_opa_t value) { static inline void lv_style_set_outline_opa(lv_style_t * style, lv_opa_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_OPA, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_OPA, v); }
static inline void lv_style_set_outline_pad(lv_style_t * style, lv_coord_t value) { static inline void lv_style_set_outline_pad(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_PAD, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_PAD, v); }
static inline void lv_style_set_outline_blend_mode(lv_style_t * style, lv_blend_mode_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_OUTLINE_BLEND_MODE, v); }
static inline void lv_style_set_shadow_width(lv_style_t * style, lv_coord_t value) { static inline void lv_style_set_shadow_width(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_WIDTH, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_WIDTH, v); }
@@ -372,9 +395,6 @@ static inline void lv_style_set_shadow_ofs_y(lv_style_t * style, lv_coord_t valu
static inline void lv_style_set_shadow_spread(lv_style_t * style, lv_coord_t value) { static inline void lv_style_set_shadow_spread(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_SPREAD, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_SPREAD, v); }
static inline void lv_style_set_shadow_blend_mode(lv_style_t * style, lv_blend_mode_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_BLEND_MODE, v); }
static inline void lv_style_set_shadow_color(lv_style_t * style, lv_color_t value) { static inline void lv_style_set_shadow_color(lv_style_t * style, lv_color_t value) {
lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_COLOR, v); } lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_SHADOW_COLOR, v); }
@@ -387,9 +407,6 @@ static inline void lv_style_set_shadow_opa(lv_style_t * style, lv_opa_t value) {
static inline void lv_style_set_line_width(lv_style_t * style, lv_coord_t value) { static inline void lv_style_set_line_width(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_WIDTH, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_WIDTH, v); }
static inline void lv_style_set_line_blend_mode(lv_style_t * style, lv_blend_mode_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_BLEND_MODE, v); }
static inline void lv_style_set_line_dash_width(lv_style_t * style, lv_coord_t value) { static inline void lv_style_set_line_dash_width(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_DASH_WIDTH, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_DASH_WIDTH, v); }
@@ -408,8 +425,8 @@ static inline void lv_style_set_line_color_filtered(lv_style_t * style, lv_color
static inline void lv_style_set_line_opa(lv_style_t * style, lv_opa_t value) { static inline void lv_style_set_line_opa(lv_style_t * style, lv_opa_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_OPA, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_LINE_OPA, v); }
static inline void lv_style_set_content_src(lv_style_t * style, const char * value) { static inline void lv_style_set_content_text(lv_style_t * style, const char * value) {
lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_SRC, v); } lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_TEXT, v); }
static inline void lv_style_set_content_align(lv_style_t * style, lv_align_t value) { static inline void lv_style_set_content_align(lv_style_t * style, lv_align_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_ALIGN, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_ALIGN, v); }
@@ -420,11 +437,27 @@ static inline void lv_style_set_content_ofs_x(lv_style_t * style, lv_coord_t val
static inline void lv_style_set_content_ofs_y(lv_style_t * style, lv_coord_t value) { static inline void lv_style_set_content_ofs_y(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OFS_Y, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OFS_Y, v); }
static inline void lv_style_set_transition(lv_style_t * style, const lv_style_transiton_t * value) { static inline void lv_style_set_content_opa(lv_style_t * style, lv_opa_t value) {
lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_TRANSITION, v); } lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_OPA, v); }
static inline void lv_style_set_content_font(lv_style_t * style, const lv_font_t * value) {
lv_style_value_t v = {.ptr = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_FONT, v); }
static inline void lv_style_set_content_color(lv_style_t * style, lv_color_t value) {
lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_COLOR, v); }
static inline void lv_style_set_content_color_filtered(lv_style_t * style, lv_color_t value) {
lv_style_value_t v = {.color = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_COLOR_FILTERED, v); }
static inline void lv_style_set_content_letter_space(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_LETTER_SPACE, v); }
static inline void lv_style_set_content_line_space(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_LINE_SPACE, v); }
static inline void lv_style_set_content_decor(lv_style_t * style, lv_text_decor_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_CONTENT_DECOR, v); }
static inline void lv_style_set_size(lv_style_t * style, lv_coord_t value) {
lv_style_value_t v = {.num = value}; lv_style_set_prop(style, LV_STYLE_SIZE, v); }
static inline void lv_style_set_pad_ver(lv_style_t * style, lv_coord_t value) static inline void lv_style_set_pad_ver(lv_style_t * style, lv_coord_t value)
{ {

View File

@@ -57,6 +57,14 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t thickness
* GLOBAL FUNCTIONS * GLOBAL FUNCTIONS
**********************/ **********************/
LV_ATTRIBUTE_FAST_MEM void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc)
{
lv_memset_00(dsc, sizeof(lv_draw_arc_dsc_t));
dsc->width = 1;
dsc->opa = LV_OPA_COVER;
dsc->color = LV_COLOR_BLACK;
}
/** /**
* Draw an arc. (Can draw pie too with great thickness.) * Draw an arc. (Can draw pie too with great thickness.)
* @param center_x the x coordinate of the center of the arc * @param center_x the x coordinate of the center of the arc
@@ -69,7 +77,7 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t thickness
* @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/ */
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc) const lv_area_t * clip_area, const lv_draw_arc_dsc_t * dsc)
{ {
if(dsc->opa <= LV_OPA_MIN) return; if(dsc->opa <= LV_OPA_MIN) return;
if(dsc->width == 0) return; if(dsc->width == 0) return;
@@ -80,22 +88,27 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
lv_draw_rect_dsc_t cir_dsc; lv_draw_rect_dsc_t cir_dsc;
lv_draw_rect_dsc_init(&cir_dsc); lv_draw_rect_dsc_init(&cir_dsc);
cir_dsc.radius = LV_RADIUS_CIRCLE; cir_dsc.bg_opa = dsc->opa;
cir_dsc.bg_opa = LV_OPA_TRANSP; cir_dsc.bg_color = dsc->color;
cir_dsc.border_opa = dsc->opa; cir_dsc.blend_mode = dsc->blend_mode;
cir_dsc.border_color = dsc->color; cir_dsc.bg_img_src = dsc->bg_img_src;
cir_dsc.border_width = width;
cir_dsc.border_blend_mode = dsc->blend_mode;
lv_area_t area; lv_area_t area_out;
area.x1 = center_x - radius; area_out.x1 = center_x - radius;
area.y1 = center_y - radius; area_out.y1 = center_y - radius;
area.x2 = center_x + radius - 1; /*-1 because the center already belongs to the left/bottom part*/ area_out.x2 = center_x + radius - 1; /*-1 because the center already belongs to the left/bottom part*/
area.y2 = center_y + radius - 1; area_out.y2 = center_y + radius - 1;
lv_area_t area_in;
lv_area_copy(&area_in, &area_out);
area_in.x1 += dsc->width;
area_in.y1 += dsc->width;
area_in.x2 -= dsc->width;
area_in.y2 -= dsc->width;
/*Draw a full ring*/ /*Draw a full ring*/
if(start_angle + 360 == end_angle || start_angle == end_angle + 360) { if(start_angle + 360 == end_angle || start_angle == end_angle + 360) {
lv_draw_rect(&area, clip_area, &cir_dsc); lv_draw_rect(&area_out, clip_area, &cir_dsc);
return; return;
} }
@@ -104,9 +117,17 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
lv_draw_mask_angle_param_t mask_angle_param; lv_draw_mask_angle_param_t mask_angle_param;
lv_draw_mask_angle_init(&mask_angle_param, center_x, center_y, start_angle, end_angle); lv_draw_mask_angle_init(&mask_angle_param, center_x, center_y, start_angle, end_angle);
int16_t mask_angle_id = lv_draw_mask_add(&mask_angle_param, NULL); int16_t mask_angle_id = lv_draw_mask_add(&mask_angle_param, NULL);
/*Create inner the mask*/
lv_draw_mask_radius_param_t mask_in_param;
lv_draw_mask_radius_init(&mask_in_param, &area_in, LV_RADIUS_CIRCLE, true);
int16_t mask_in_id = lv_draw_mask_add(&mask_in_param, NULL);
lv_draw_mask_radius_param_t mask_out_param;
lv_draw_mask_radius_init(&mask_out_param, &area_out, LV_RADIUS_CIRCLE, false);
int16_t mask_out_id = lv_draw_mask_add(&mask_out_param, NULL);
int32_t angle_gap; int32_t angle_gap;
if(end_angle > start_angle) { if(end_angle > start_angle) {
angle_gap = 360 - (end_angle - start_angle); angle_gap = 360 - (end_angle - start_angle);
@@ -126,7 +147,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
q_dsc.end_quarter = (end_angle / 90) & 0x3; q_dsc.end_quarter = (end_angle / 90) & 0x3;
q_dsc.width = width; q_dsc.width = width;
q_dsc.draw_dsc = &cir_dsc; q_dsc.draw_dsc = &cir_dsc;
q_dsc.draw_area = &area; q_dsc.draw_area = &area_out;
q_dsc.clip_area = clip_area; q_dsc.clip_area = clip_area;
draw_quarter_0(&q_dsc); draw_quarter_0(&q_dsc);
@@ -135,35 +156,42 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
draw_quarter_3(&q_dsc); draw_quarter_3(&q_dsc);
} }
else { else {
lv_draw_rect(&area, clip_area, &cir_dsc); lv_draw_rect(&area_out, clip_area, &cir_dsc);
} }
lv_draw_mask_remove_id(mask_angle_id); lv_draw_mask_remove_id(mask_angle_id);
lv_draw_mask_remove_id(mask_out_id);
lv_draw_mask_remove_id(mask_in_id);
if(dsc->round_start || dsc->round_end) { if(dsc->rounded) {
cir_dsc.bg_color = dsc->color;
cir_dsc.bg_opa = dsc->opa; lv_draw_mask_radius_param_t mask_end_param;
cir_dsc.bg_blend_mode = dsc->blend_mode;
cir_dsc.border_width = 0;
lv_area_t round_area; lv_area_t round_area;
if(dsc->round_start) { get_rounded_area(start_angle, radius, width, &round_area);
get_rounded_area(start_angle, radius, width, &round_area); round_area.x1 += center_x;
round_area.x1 += center_x; round_area.x2 += center_x;
round_area.x2 += center_x; round_area.y1 += center_y;
round_area.y1 += center_y; round_area.y2 += center_y;
round_area.y2 += center_y; lv_area_t clip_area2;
if(_lv_area_intersect(&clip_area2, clip_area, &round_area)) {
lv_draw_mask_radius_init(&mask_end_param, &round_area, LV_RADIUS_CIRCLE, false);
int16_t mask_end_id = lv_draw_mask_add(&mask_end_param, NULL);
lv_draw_rect(&round_area, clip_area, &cir_dsc); lv_draw_rect(&area_out, &clip_area2, &cir_dsc);
lv_draw_mask_remove_id(mask_end_id);
} }
if(dsc->round_end) { get_rounded_area(end_angle, radius, width, &round_area);
get_rounded_area(end_angle, radius, width, &round_area); round_area.x1 += center_x;
round_area.x1 += center_x; round_area.x2 += center_x;
round_area.x2 += center_x; round_area.y1 += center_y;
round_area.y1 += center_y; round_area.y2 += center_y;
round_area.y2 += center_y; if(_lv_area_intersect(&clip_area2, clip_area, &round_area)) {
lv_draw_mask_radius_init(&mask_end_param, &round_area, LV_RADIUS_CIRCLE, false);
int16_t mask_end_id = lv_draw_mask_add(&mask_end_param, NULL);
lv_draw_rect(&round_area, clip_area, &cir_dsc); lv_draw_rect(&area_out, &clip_area2, &cir_dsc);
lv_draw_mask_remove_id(mask_end_id);
} }
} }
} }
@@ -178,11 +206,11 @@ static void draw_quarter_0(quarter_draw_dsc_t * q)
if(q->start_quarter == 0 && q->end_quarter == 0 && q->start_angle < q->end_angle) { if(q->start_quarter == 0 && q->end_quarter == 0 && q->start_angle < q->end_angle) {
/*Small arc here*/ /*Small arc here*/
quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT); quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT);
quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -193,8 +221,8 @@ static void draw_quarter_0(quarter_draw_dsc_t * q)
quarter_area.x1 = q->center_x; quarter_area.x1 = q->center_x;
quarter_area.y2 = q->center_y + q->radius; quarter_area.y2 = q->center_y + q->radius;
quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -203,8 +231,8 @@ static void draw_quarter_0(quarter_draw_dsc_t * q)
quarter_area.x2 = q->center_x + q->radius; quarter_area.x2 = q->center_x + q->radius;
quarter_area.y1 = q->center_y; quarter_area.y1 = q->center_y;
quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT); quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT);
quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -231,11 +259,11 @@ static void draw_quarter_1(quarter_draw_dsc_t * q)
if(q->start_quarter == 1 && q->end_quarter == 1 && q->start_angle < q->end_angle) { if(q->start_quarter == 1 && q->end_quarter == 1 && q->start_angle < q->end_angle) {
/*Small arc here*/ /*Small arc here*/
quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT);
quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -246,8 +274,8 @@ static void draw_quarter_1(quarter_draw_dsc_t * q)
quarter_area.x1 = q->center_x - q->radius; quarter_area.x1 = q->center_x - q->radius;
quarter_area.y1 = q->center_y; quarter_area.y1 = q->center_y;
quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT);
quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -256,8 +284,8 @@ static void draw_quarter_1(quarter_draw_dsc_t * q)
quarter_area.x2 = q->center_x - 1; quarter_area.x2 = q->center_x - 1;
quarter_area.y2 = q->center_y + q->radius; quarter_area.y2 = q->center_y + q->radius;
quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -284,11 +312,11 @@ static void draw_quarter_2(quarter_draw_dsc_t * q)
if(q->start_quarter == 2 && q->end_quarter == 2 && q->start_angle < q->end_angle) { if(q->start_quarter == 2 && q->end_quarter == 2 && q->start_angle < q->end_angle) {
/*Small arc here*/ /*Small arc here*/
quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT); quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * q->radius) >> LV_TRIGO_SHIFT);
quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -299,8 +327,8 @@ static void draw_quarter_2(quarter_draw_dsc_t * q)
quarter_area.x2 = q->center_x - 1; quarter_area.x2 = q->center_x - 1;
quarter_area.y1 = q->center_y - q->radius; quarter_area.y1 = q->center_y - q->radius;
quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -309,8 +337,8 @@ static void draw_quarter_2(quarter_draw_dsc_t * q)
quarter_area.x1 = q->center_x - q->radius; quarter_area.x1 = q->center_x - q->radius;
quarter_area.y2 = q->center_y - 1; quarter_area.y2 = q->center_y - 1;
quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->end_angle) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -338,11 +366,11 @@ static void draw_quarter_3(quarter_draw_dsc_t * q)
if(q->start_quarter == 3 && q->end_quarter == 3 && q->start_angle < q->end_angle) { if(q->start_quarter == 3 && q->end_quarter == 3 && q->start_angle < q->end_angle) {
/*Small arc here*/ /*Small arc here*/
quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT);
quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -353,8 +381,8 @@ static void draw_quarter_3(quarter_draw_dsc_t * q)
quarter_area.x2 = q->center_x + q->radius; quarter_area.x2 = q->center_x + q->radius;
quarter_area.y2 = q->center_y - 1; quarter_area.y2 = q->center_y - 1;
quarter_area.x1 = q->center_x + ((_lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.x1 = q->center_x + ((lv_trigo_sin(q->start_angle + 90) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
quarter_area.y1 = q->center_y + ((_lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.y1 = q->center_y + ((lv_trigo_sin(q->start_angle) * (q->radius)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -363,8 +391,8 @@ static void draw_quarter_3(quarter_draw_dsc_t * q)
quarter_area.x1 = q->center_x; quarter_area.x1 = q->center_x;
quarter_area.y1 = q->center_y - q->radius; quarter_area.y1 = q->center_y - q->radius;
quarter_area.x2 = q->center_x + ((_lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT); quarter_area.x2 = q->center_x + ((lv_trigo_sin(q->end_angle + 90) * (q->radius)) >> LV_TRIGO_SHIFT);
quarter_area.y2 = q->center_y + ((_lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT); quarter_area.y2 = q->center_y + ((lv_trigo_sin(q->end_angle) * (q->radius - q->width)) >> LV_TRIGO_SHIFT);
bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area); bool ok = _lv_area_intersect(&quarter_area, &quarter_area, q->clip_area);
if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc); if(ok) lv_draw_rect(q->draw_area, &quarter_area, q->draw_dsc);
@@ -397,8 +425,8 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t thickness
int32_t cir_x; int32_t cir_x;
int32_t cir_y; int32_t cir_y;
cir_x = ((radius - thick_half) * _lv_trigo_sin(90 - angle)) >> (LV_TRIGO_SHIFT - ps); cir_x = ((radius - thick_half) * lv_trigo_sin(90 - angle)) >> (LV_TRIGO_SHIFT - ps);
cir_y = ((radius - thick_half) * _lv_trigo_sin(angle)) >> (LV_TRIGO_SHIFT - ps); cir_y = ((radius - thick_half) * lv_trigo_sin(angle)) >> (LV_TRIGO_SHIFT - ps);
/* Actually the center of the pixel need to be calculated so apply 1/2 px offset*/ /* Actually the center of the pixel need to be calculated so apply 1/2 px offset*/
if(cir_x > 0) { if(cir_x > 0) {

View File

@@ -22,11 +22,22 @@ extern "C" {
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
typedef struct {
lv_color_t color;
lv_coord_t width;
const void * bg_img_src;
lv_opa_t opa;
lv_blend_mode_t blend_mode : 2;
uint8_t rounded : 1;
} lv_draw_arc_dsc_t;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
**********************/ **********************/
LV_ATTRIBUTE_FAST_MEM void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc);
/** /**
* Draw an arc. (Can draw pie too with great thickness.) * Draw an arc. (Can draw pie too with great thickness.)
* @param center_x the x coordinate of the center of the arc * @param center_x the x coordinate of the center of the arc
@@ -39,7 +50,7 @@ extern "C" {
* @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/ */
void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
const lv_area_t * clip_area, const lv_draw_line_dsc_t * dsc); const lv_area_t * clip_area, const lv_draw_arc_dsc_t * dsc);
/********************** /**********************
* MACROS * MACROS

View File

@@ -801,7 +801,7 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
/*Software rendering*/ /*Software rendering*/
for(y = 0; y < draw_area_h; y++) { for(y = 0; y < draw_area_h; y++) {
_lv_memcpy(disp_buf_first, map_buf_first, draw_area_w * sizeof(lv_color_t)); lv_memcpy(disp_buf_first, map_buf_first, draw_area_w * sizeof(lv_color_t));
disp_buf_first += disp_w; disp_buf_first += disp_w;
map_buf_first += map_w; map_buf_first += map_w;
} }
@@ -1041,41 +1041,41 @@ static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color
uint32_t tmp; uint32_t tmp;
#if LV_COLOR_DEPTH == 1 #if LV_COLOR_DEPTH == 1
tmp = bg.full + fg.full; tmp = bg.full + fg.full;
fg.full = LV_MATH_MIN(tmp, 1); fg.full = LV_MIN(tmp, 1);
#else #else
tmp = bg.ch.red + fg.ch.red; tmp = bg.ch.red + fg.ch.red;
#if LV_COLOR_DEPTH == 8 #if LV_COLOR_DEPTH == 8
fg.ch.red = LV_MATH_MIN(tmp, 7); fg.ch.red = LV_MIN(tmp, 7);
#elif LV_COLOR_DEPTH == 16 #elif LV_COLOR_DEPTH == 16
fg.ch.red = LV_MATH_MIN(tmp, 31); fg.ch.red = LV_MIN(tmp, 31);
#elif LV_COLOR_DEPTH == 32 #elif LV_COLOR_DEPTH == 32
fg.ch.red = LV_MATH_MIN(tmp, 255); fg.ch.red = LV_MIN(tmp, 255);
#endif #endif
#if LV_COLOR_DEPTH == 8 #if LV_COLOR_DEPTH == 8
fg.ch.green = LV_MATH_MIN(tmp, 7); fg.ch.green = LV_MIN(tmp, 7);
#elif LV_COLOR_DEPTH == 16 #elif LV_COLOR_DEPTH == 16
#if LV_COLOR_16_SWAP == 0 #if LV_COLOR_16_SWAP == 0
tmp = bg.ch.green + fg.ch.green; tmp = bg.ch.green + fg.ch.green;
fg.ch.green = LV_MATH_MIN(tmp, 63); fg.ch.green = LV_MIN(tmp, 63);
#else #else
tmp = (bg.ch.green_h << 3) + bg.ch.green_l + (fg.ch.green_h << 3) + fg.ch.green_l; tmp = (bg.ch.green_h << 3) + bg.ch.green_l + (fg.ch.green_h << 3) + fg.ch.green_l;
tmp = LV_MATH_MIN(tmp, 63); tmp = LV_MIN(tmp, 63);
fg.ch.green_h = tmp >> 3; fg.ch.green_h = tmp >> 3;
fg.ch.green_l = tmp & 0x7; fg.ch.green_l = tmp & 0x7;
#endif #endif
#elif LV_COLOR_DEPTH == 32 #elif LV_COLOR_DEPTH == 32
fg.ch.green = LV_MATH_MIN(tmp, 255); fg.ch.green = LV_MIN(tmp, 255);
#endif #endif
tmp = bg.ch.blue + fg.ch.blue; tmp = bg.ch.blue + fg.ch.blue;
#if LV_COLOR_DEPTH == 8 #if LV_COLOR_DEPTH == 8
fg.ch.blue = LV_MATH_MIN(tmp, 4); fg.ch.blue = LV_MIN(tmp, 4);
#elif LV_COLOR_DEPTH == 16 #elif LV_COLOR_DEPTH == 16
fg.ch.blue = LV_MATH_MIN(tmp, 31); fg.ch.blue = LV_MIN(tmp, 31);
#elif LV_COLOR_DEPTH == 32 #elif LV_COLOR_DEPTH == 32
fg.ch.blue = LV_MATH_MIN(tmp, 255); fg.ch.blue = LV_MIN(tmp, 255);
#endif #endif
#endif #endif
@@ -1091,20 +1091,20 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co
int32_t tmp; int32_t tmp;
tmp = bg.ch.red - fg.ch.red; tmp = bg.ch.red - fg.ch.red;
fg.ch.red = LV_MATH_MAX(tmp, 0); fg.ch.red = LV_MAX(tmp, 0);
#if LV_COLOR_16_SWAP == 0 #if LV_COLOR_16_SWAP == 0
tmp = bg.ch.green - fg.ch.green; tmp = bg.ch.green - fg.ch.green;
fg.ch.green = LV_MATH_MAX(tmp, 0); fg.ch.green = LV_MAX(tmp, 0);
#else #else
tmp = (bg.ch.green_h << 3) + bg.ch.green_l + (fg.ch.green_h << 3) + fg.ch.green_l; tmp = (bg.ch.green_h << 3) + bg.ch.green_l + (fg.ch.green_h << 3) + fg.ch.green_l;
tmp = LV_MATH_MAX(tmp, 0); tmp = LV_MAX(tmp, 0);
fg.ch.green_h = tmp >> 3; fg.ch.green_h = tmp >> 3;
fg.ch.green_l = tmp & 0x7; fg.ch.green_l = tmp & 0x7;
#endif #endif
tmp = bg.ch.blue - fg.ch.blue; tmp = bg.ch.blue - fg.ch.blue;
fg.ch.blue = LV_MATH_MAX(tmp, 0); fg.ch.blue = LV_MAX(tmp, 0);
if(opa == LV_OPA_COVER) return fg; if(opa == LV_OPA_COVER) return fg;

View File

@@ -56,7 +56,7 @@ static void draw_cleanup(lv_img_cache_entry_t * cache);
void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc) void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc)
{ {
_lv_memset_00(dsc, sizeof(lv_draw_img_dsc_t)); lv_memset_00(dsc, sizeof(lv_draw_img_dsc_t));
dsc->recolor = LV_COLOR_BLACK; dsc->recolor = LV_COLOR_BLACK;
dsc->opa = LV_OPA_COVER; dsc->opa = LV_OPA_COVER;
dsc->zoom = LV_IMG_ZOOM_NONE; dsc->zoom = LV_IMG_ZOOM_NONE;
@@ -289,7 +289,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords,
int32_t width = lv_area_get_width(&mask_com); int32_t width = lv_area_get_width(&mask_com);
uint8_t * buf = _lv_mem_buf_get(lv_area_get_width(&mask_com) * uint8_t * buf = lv_mem_buf_get(lv_area_get_width(&mask_com) *
LV_IMG_PX_SIZE_ALPHA_BYTE); /*+1 because of the possible alpha byte*/ LV_IMG_PX_SIZE_ALPHA_BYTE); /*+1 because of the possible alpha byte*/
lv_area_t line; lv_area_t line;
@@ -308,7 +308,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords,
if(read_res != LV_RES_OK) { if(read_res != LV_RES_OK) {
lv_img_decoder_close(&cdsc->dec_dsc); lv_img_decoder_close(&cdsc->dec_dsc);
LV_LOG_WARN("Image draw can't read the line"); LV_LOG_WARN("Image draw can't read the line");
_lv_mem_buf_release(buf); lv_mem_buf_release(buf);
draw_cleanup(cdsc); draw_cleanup(cdsc);
return LV_RES_INV; return LV_RES_INV;
} }
@@ -319,7 +319,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords,
line.y2++; line.y2++;
y++; y++;
} }
_lv_mem_buf_release(buf); lv_mem_buf_release(buf);
} }
draw_cleanup(cdsc); draw_cleanup(cdsc);
@@ -426,8 +426,8 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
#endif #endif
uint32_t hor_res = (uint32_t) lv_disp_get_hor_res(disp); uint32_t hor_res = (uint32_t) lv_disp_get_hor_res(disp);
uint32_t mask_buf_size = lv_area_get_size(&draw_area) > (uint32_t) hor_res ? hor_res : lv_area_get_size(&draw_area); uint32_t mask_buf_size = lv_area_get_size(&draw_area) > (uint32_t) hor_res ? hor_res : lv_area_get_size(&draw_area);
lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); lv_color_t * map2 = lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t));
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size);
int32_t x; int32_t x;
int32_t y; int32_t y;
@@ -469,20 +469,20 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
_lv_blend_map(clip_area, &blend_area, map2, mask_buf, LV_DRAW_MASK_RES_CHANGED, draw_dsc->opa, draw_dsc->blend_mode); _lv_blend_map(clip_area, &blend_area, map2, mask_buf, LV_DRAW_MASK_RES_CHANGED, draw_dsc->opa, draw_dsc->blend_mode);
} }
_lv_mem_buf_release(mask_buf); lv_mem_buf_release(mask_buf);
_lv_mem_buf_release(map2); lv_mem_buf_release(map2);
} }
/*Most complicated case: transform or other mask or chroma keyed*/ /*Most complicated case: transform or other mask or chroma keyed*/
else { else {
/*Build the image and a mask line-by-line*/ /*Build the image and a mask line-by-line*/
uint32_t hor_res = (uint32_t) lv_disp_get_hor_res(disp); uint32_t hor_res = (uint32_t) lv_disp_get_hor_res(disp);
uint32_t mask_buf_size = lv_area_get_size(&draw_area) > hor_res ? hor_res : lv_area_get_size(&draw_area); uint32_t mask_buf_size = lv_area_get_size(&draw_area) > hor_res ? hor_res : lv_area_get_size(&draw_area);
lv_color_t * map2 = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); lv_color_t * map2 = lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t));
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size);
#if LV_USE_IMG_TRANSFORM #if LV_USE_IMG_TRANSFORM
lv_img_transform_dsc_t trans_dsc; lv_img_transform_dsc_t trans_dsc;
_lv_memset_00(&trans_dsc, sizeof(lv_img_transform_dsc_t)); lv_memset_00(&trans_dsc, sizeof(lv_img_transform_dsc_t));
if(transform) { if(transform) {
lv_img_cf_t cf = LV_IMG_CF_TRUE_COLOR; lv_img_cf_t cf = LV_IMG_CF_TRUE_COLOR;
if(alpha_byte) cf = LV_IMG_CF_TRUE_COLOR_ALPHA; if(alpha_byte) cf = LV_IMG_CF_TRUE_COLOR_ALPHA;
@@ -515,7 +515,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
/*Prepare the `mask_buf`if there are other masks*/ /*Prepare the `mask_buf`if there are other masks*/
if(other_mask_cnt) { if(other_mask_cnt) {
_lv_memset_ff(mask_buf, mask_buf_size); lv_memset_ff(mask_buf, mask_buf_size);
} }
int32_t x; int32_t x;
@@ -600,7 +600,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
mask_res_sub = lv_draw_mask_apply(mask_buf + px_i_start, draw_area.x1 + vdb->area.x1, y + draw_area.y1 + vdb->area.y1, mask_res_sub = lv_draw_mask_apply(mask_buf + px_i_start, draw_area.x1 + vdb->area.x1, y + draw_area.y1 + vdb->area.y1,
lv_area_get_width(&draw_area)); lv_area_get_width(&draw_area));
if(mask_res_sub == LV_DRAW_MASK_RES_TRANSP) { if(mask_res_sub == LV_DRAW_MASK_RES_TRANSP) {
_lv_memset_00(mask_buf + px_i_start, lv_area_get_width(&draw_area)); lv_memset_00(mask_buf + px_i_start, lv_area_get_width(&draw_area));
mask_res = LV_DRAW_MASK_RES_CHANGED; mask_res = LV_DRAW_MASK_RES_CHANGED;
} }
else if(mask_res_sub == LV_DRAW_MASK_RES_CHANGED) { else if(mask_res_sub == LV_DRAW_MASK_RES_CHANGED) {
@@ -625,7 +625,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
/*Prepare the `mask_buf`if there are other masks*/ /*Prepare the `mask_buf`if there are other masks*/
if(other_mask_cnt) { if(other_mask_cnt) {
_lv_memset_ff(mask_buf, mask_buf_size); lv_memset_ff(mask_buf, mask_buf_size);
} }
} }
} }
@@ -636,8 +636,8 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
_lv_blend_map(clip_area, &blend_area, map2, mask_buf, mask_res, draw_dsc->opa, draw_dsc->blend_mode); _lv_blend_map(clip_area, &blend_area, map2, mask_buf, mask_res, draw_dsc->opa, draw_dsc->blend_mode);
} }
_lv_mem_buf_release(mask_buf); lv_mem_buf_release(mask_buf);
_lv_mem_buf_release(map2); lv_mem_buf_release(map2);
} }
} }
} }

View File

@@ -92,7 +92,7 @@ const uint8_t _lv_bpp8_opa_table[256] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1
LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc) LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
{ {
_lv_memset_00(dsc, sizeof(lv_draw_label_dsc_t)); lv_memset_00(dsc, sizeof(lv_draw_label_dsc_t));
dsc->opa = LV_OPA_COVER; dsc->opa = LV_OPA_COVER;
dsc->color = LV_COLOR_BLACK; dsc->color = LV_COLOR_BLACK;
dsc->font = LV_THEME_DEFAULT_FONT_NORMAL; dsc->font = LV_THEME_DEFAULT_FONT_NORMAL;
@@ -162,7 +162,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
/*Check the hint to use the cached info*/ /*Check the hint to use the cached info*/
if(hint && y_ofs == 0 && coords->y1 < 0) { if(hint && y_ofs == 0 && coords->y1 < 0) {
/*If the label changed too much recalculate the hint.*/ /*If the label changed too much recalculate the hint.*/
if(LV_MATH_ABS(hint->coord_y - coords->y1) > LV_LABEL_HINT_UPDATE_TH - 2 * line_height) { if(LV_ABS(hint->coord_y - coords->y1) > LV_LABEL_HINT_UPDATE_TH - 2 * line_height) {
hint->line_start = -1; hint->line_start = -1;
} }
last_line_start = hint->line_start; last_line_start = hint->line_start;
@@ -245,7 +245,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
cmd_state = CMD_STATE_WAIT; cmd_state = CMD_STATE_WAIT;
i = 0; i = 0;
#if LV_USE_BIDI #if LV_USE_BIDI
char * bidi_txt = _lv_mem_buf_get(line_end - line_start + 1); char * bidi_txt = lv_mem_buf_get(line_end - line_start + 1);
_lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, dsc->bidi_dir, NULL, 0); _lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, dsc->bidi_dir, NULL, 0);
#else #else
const char * bidi_txt = txt + line_start; const char * bidi_txt = txt + line_start;
@@ -289,7 +289,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
/*Get the parameter*/ /*Get the parameter*/
if(i - par_start == LABEL_RECOLOR_PAR_LENGTH + 1) { if(i - par_start == LABEL_RECOLOR_PAR_LENGTH + 1) {
char buf[LABEL_RECOLOR_PAR_LENGTH + 1]; char buf[LABEL_RECOLOR_PAR_LENGTH + 1];
_lv_memcpy_small(buf, &bidi_txt[par_start], LABEL_RECOLOR_PAR_LENGTH); lv_memcpy_small(buf, &bidi_txt[par_start], LABEL_RECOLOR_PAR_LENGTH);
buf[LABEL_RECOLOR_PAR_LENGTH] = '\0'; buf[LABEL_RECOLOR_PAR_LENGTH] = '\0';
int r, g, b; int r, g, b;
r = (hex_char_to_num(buf[0]) << 4) + hex_char_to_num(buf[1]); r = (hex_char_to_num(buf[0]) << 4) + hex_char_to_num(buf[1]);
@@ -352,7 +352,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
} }
#if LV_USE_BIDI #if LV_USE_BIDI
_lv_mem_buf_release(bidi_txt); lv_mem_buf_release(bidi_txt);
bidi_txt = NULL; bidi_txt = NULL;
#endif #endif
/*Go to next line*/ /*Go to next line*/
@@ -525,7 +525,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_
lv_coord_t hor_res = lv_disp_get_hor_res(_lv_refr_get_disp_refreshing()); lv_coord_t hor_res = lv_disp_get_hor_res(_lv_refr_get_disp_refreshing());
uint32_t mask_buf_size = box_w * box_h > hor_res ? hor_res : box_w * box_h; uint32_t mask_buf_size = box_w * box_h > hor_res ? hor_res : box_w * box_h;
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size);
int32_t mask_p = 0; int32_t mask_p = 0;
lv_area_t fill_area; lv_area_t fill_area;
@@ -574,7 +574,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, fill_area.x1, fill_area.y2, lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, fill_area.x1, fill_area.y2,
lv_area_get_width(&fill_area)); lv_area_get_width(&fill_area));
if(mask_res == LV_DRAW_MASK_RES_TRANSP) { if(mask_res == LV_DRAW_MASK_RES_TRANSP) {
_lv_memset_00(mask_buf + mask_p_start, lv_area_get_width(&fill_area)); lv_memset_00(mask_buf + mask_p_start, lv_area_get_width(&fill_area));
} }
} }
@@ -605,7 +605,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_
mask_p = 0; mask_p = 0;
} }
_lv_mem_buf_release(mask_buf); lv_mem_buf_release(mask_buf);
} }
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area, static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
@@ -663,10 +663,10 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
col_bit = bit_ofs & 0x7; /* "& 0x7" equals to "% 8" just faster */ col_bit = bit_ofs & 0x7; /* "& 0x7" equals to "% 8" just faster */
int32_t mask_buf_size = box_w * box_h > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : g->box_w * g->box_h; int32_t mask_buf_size = box_w * box_h > LV_HOR_RES_MAX ? LV_HOR_RES_MAX : g->box_w * g->box_h;
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size);
int32_t mask_p = 0; int32_t mask_p = 0;
lv_color_t * color_buf = _lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); lv_color_t * color_buf = lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t));
lv_disp_t * disp = _lv_refr_get_disp_refreshing(); lv_disp_t * disp = _lv_refr_get_disp_refreshing();
lv_disp_buf_t * vdb = lv_disp_get_buf(disp); lv_disp_buf_t * vdb = lv_disp_get_buf(disp);
@@ -779,7 +779,7 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, map_area.x1, map_area.y2, lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, map_area.x1, map_area.y2,
lv_area_get_width(&map_area)); lv_area_get_width(&map_area));
if(mask_res == LV_DRAW_MASK_RES_TRANSP) { if(mask_res == LV_DRAW_MASK_RES_TRANSP) {
_lv_memset_00(mask_buf + mask_p_start, lv_area_get_width(&map_area)); lv_memset_00(mask_buf + mask_p_start, lv_area_get_width(&map_area));
} }
} }
@@ -809,8 +809,8 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
_lv_blend_map(clip_area, &map_area, color_buf, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa, blend_mode); _lv_blend_map(clip_area, &map_area, color_buf, mask_buf, LV_DRAW_MASK_RES_CHANGED, opa, blend_mode);
} }
_lv_mem_buf_release(mask_buf); lv_mem_buf_release(mask_buf);
_lv_mem_buf_release(color_buf); lv_mem_buf_release(color_buf);
#else #else
LV_LOG_WARN("Can't draw sub-pixel rendered letter because LV_USE_FONT_SUBPX == 0 in lv_conf.h"); LV_LOG_WARN("Can't draw sub-pixel rendered letter because LV_USE_FONT_SUBPX == 0 in lv_conf.h");
#endif #endif

View File

@@ -48,7 +48,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const
LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc) LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc)
{ {
_lv_memset_00(dsc, sizeof(lv_draw_line_dsc_t)); lv_memset_00(dsc, sizeof(lv_draw_line_dsc_t));
dsc->width = 1; dsc->width = 1;
dsc->opa = LV_OPA_COVER; dsc->opa = LV_OPA_COVER;
dsc->color = LV_COLOR_BLACK; dsc->color = LV_COLOR_BLACK;
@@ -70,10 +70,10 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_poin
if(point1->x == point2->x && point1->y == point2->y) return; if(point1->x == point2->x && point1->y == point2->y) return;
lv_area_t clip_line; lv_area_t clip_line;
clip_line.x1 = LV_MATH_MIN(point1->x, point2->x) - dsc->width / 2; clip_line.x1 = LV_MIN(point1->x, point2->x) - dsc->width / 2;
clip_line.x2 = LV_MATH_MAX(point1->x, point2->x) + dsc->width / 2; clip_line.x2 = LV_MAX(point1->x, point2->x) + dsc->width / 2;
clip_line.y1 = LV_MATH_MIN(point1->y, point2->y) - dsc->width / 2; clip_line.y1 = LV_MIN(point1->y, point2->y) - dsc->width / 2;
clip_line.y2 = LV_MATH_MAX(point1->y, point2->y) + dsc->width / 2; clip_line.y2 = LV_MAX(point1->y, point2->y) + dsc->width / 2;
bool is_common; bool is_common;
is_common = _lv_area_intersect(&clip_line, &clip_line, clip); is_common = _lv_area_intersect(&clip_line, &clip_line, clip);
@@ -139,8 +139,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const
else if(dashed) simple_mode = false; else if(dashed) simple_mode = false;
lv_area_t draw_area; lv_area_t draw_area;
draw_area.x1 = LV_MATH_MIN(point1->x, point2->x); draw_area.x1 = LV_MIN(point1->x, point2->x);
draw_area.x2 = LV_MATH_MAX(point1->x, point2->x) - 1; draw_area.x2 = LV_MAX(point1->x, point2->x) - 1;
draw_area.y1 = point1->y - w_half1; draw_area.y1 = point1->y - w_half1;
draw_area.y2 = point1->y + w_half0; draw_area.y2 = point1->y + w_half0;
@@ -178,10 +178,10 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const
dash_start = (vdb->area.x1 + draw_area.x1) % (dsc->dash_gap + dsc->dash_width); dash_start = (vdb->area.x1 + draw_area.x1) % (dsc->dash_gap + dsc->dash_width);
} }
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w);
int32_t h; int32_t h;
for(h = draw_area.y1; h <= draw_area.y2; h++) { for(h = draw_area.y1; h <= draw_area.y2; h++) {
_lv_memset_ff(mask_buf, draw_area_w); lv_memset_ff(mask_buf, draw_area_w);
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
if(dashed) { if(dashed) {
@@ -213,7 +213,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const
fill_area.y1++; fill_area.y1++;
fill_area.y2++; fill_area.y2++;
} }
_lv_mem_buf_release(mask_buf); lv_mem_buf_release(mask_buf);
} }
} }
@@ -242,8 +242,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const
lv_area_t draw_area; lv_area_t draw_area;
draw_area.x1 = point1->x - w_half1; draw_area.x1 = point1->x - w_half1;
draw_area.x2 = point1->x + w_half0; draw_area.x2 = point1->x + w_half0;
draw_area.y1 = LV_MATH_MIN(point1->y, point2->y); draw_area.y1 = LV_MIN(point1->y, point2->y);
draw_area.y2 = LV_MATH_MAX(point1->y, point2->y) - 1; draw_area.y2 = LV_MAX(point1->y, point2->y) - 1;
/*If there is no mask then simply draw a rectangle*/ /*If there is no mask then simply draw a rectangle*/
if(simple_mode) { if(simple_mode) {
@@ -274,7 +274,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const
fill_area.y1 = draw_area.y1 + disp_area->y1; fill_area.y1 = draw_area.y1 + disp_area->y1;
fill_area.y2 = fill_area.y1; fill_area.y2 = fill_area.y1;
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w);
lv_coord_t dash_start = 0; lv_coord_t dash_start = 0;
if(dashed) { if(dashed) {
@@ -285,7 +285,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const
int32_t h; int32_t h;
for(h = draw_area.y1; h <= draw_area.y2; h++) { for(h = draw_area.y1; h <= draw_area.y2; h++) {
_lv_memset_ff(mask_buf, draw_area_w); lv_memset_ff(mask_buf, draw_area_w);
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
if(dashed) { if(dashed) {
@@ -308,7 +308,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const
fill_area.y1++; fill_area.y1++;
fill_area.y2++; fill_area.y2++;
} }
_lv_mem_buf_release(mask_buf); lv_mem_buf_release(mask_buf);
} }
} }
@@ -335,7 +335,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons
int32_t xdiff = p2.x - p1.x; int32_t xdiff = p2.x - p1.x;
int32_t ydiff = p2.y - p1.y; int32_t ydiff = p2.y - p1.y;
bool flat = LV_MATH_ABS(xdiff) > LV_MATH_ABS(ydiff) ? true : false; bool flat = LV_ABS(xdiff) > LV_ABS(ydiff) ? true : false;
static const uint8_t wcorr[] = { static const uint8_t wcorr[] = {
128, 128, 128, 129, 129, 130, 130, 131, 128, 128, 128, 129, 129, 130, 130, 131,
@@ -347,18 +347,18 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons
int32_t w = dsc->width; int32_t w = dsc->width;
int32_t wcorr_i = 0; int32_t wcorr_i = 0;
if(flat) wcorr_i = (LV_MATH_ABS(ydiff) << 5) / LV_MATH_ABS(xdiff); if(flat) wcorr_i = (LV_ABS(ydiff) << 5) / LV_ABS(xdiff);
else wcorr_i = (LV_MATH_ABS(xdiff) << 5) / LV_MATH_ABS(ydiff); else wcorr_i = (LV_ABS(xdiff) << 5) / LV_ABS(ydiff);
w = (w * wcorr[wcorr_i] + 63) >> 7; /*+ 63 for rounding*/ w = (w * wcorr[wcorr_i] + 63) >> 7; /*+ 63 for rounding*/
int32_t w_half0 = w >> 1; int32_t w_half0 = w >> 1;
int32_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/ int32_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/
lv_area_t draw_area; lv_area_t draw_area;
draw_area.x1 = LV_MATH_MIN(p1.x, p2.x) - w; draw_area.x1 = LV_MIN(p1.x, p2.x) - w;
draw_area.x2 = LV_MATH_MAX(p1.x, p2.x) + w; draw_area.x2 = LV_MAX(p1.x, p2.x) + w;
draw_area.y1 = LV_MATH_MIN(p1.y, p2.y) - w; draw_area.y1 = LV_MIN(p1.y, p2.y) - w;
draw_area.y2 = LV_MATH_MAX(p1.y, p2.y) + w; draw_area.y2 = LV_MAX(p1.y, p2.y) + w;
/* Get the union of `coords` and `clip`*/ /* Get the union of `coords` and `clip`*/
/* `clip` is already truncated to the `vdb` size /* `clip` is already truncated to the `vdb` size
@@ -425,8 +425,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons
/*Draw the background line by line*/ /*Draw the background line by line*/
int32_t h; int32_t h;
uint32_t hor_res = (uint32_t)lv_disp_get_hor_res(disp); uint32_t hor_res = (uint32_t)lv_disp_get_hor_res(disp);
size_t mask_buf_size = LV_MATH_MIN(lv_area_get_size(&draw_area), hor_res); size_t mask_buf_size = LV_MIN(lv_area_get_size(&draw_area), hor_res);
lv_opa_t * mask_buf = _lv_mem_buf_get(mask_buf_size); lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size);
lv_area_t fill_area; lv_area_t fill_area;
fill_area.x1 = draw_area.x1 + disp_area->x1; fill_area.x1 = draw_area.x1 + disp_area->x1;
@@ -438,13 +438,13 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons
uint32_t mask_p = 0; uint32_t mask_p = 0;
_lv_memset_ff(mask_buf, mask_buf_size); lv_memset_ff(mask_buf, mask_buf_size);
/*Fill the first row with 'color'*/ /*Fill the first row with 'color'*/
for(h = draw_area.y1 + disp_area->y1; h <= draw_area.y2 + disp_area->y1; h++) { for(h = draw_area.y1 + disp_area->y1; h <= draw_area.y2 + disp_area->y1; h++) {
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(&mask_buf[mask_p], x, h, draw_area_w); lv_draw_mask_res_t mask_res = lv_draw_mask_apply(&mask_buf[mask_p], x, h, draw_area_w);
if(mask_res == LV_DRAW_MASK_RES_TRANSP) { if(mask_res == LV_DRAW_MASK_RES_TRANSP) {
_lv_memset_00(&mask_buf[mask_p], draw_area_w); lv_memset_00(&mask_buf[mask_p], draw_area_w);
} }
mask_p += draw_area_w; mask_p += draw_area_w;
@@ -459,7 +459,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons
fill_area.y1 = fill_area.y2 + 1; fill_area.y1 = fill_area.y2 + 1;
fill_area.y2 = fill_area.y1; fill_area.y2 = fill_area.y1;
mask_p = 0; mask_p = 0;
_lv_memset_ff(mask_buf, mask_buf_size); lv_memset_ff(mask_buf, mask_buf_size);
} }
} }
@@ -472,7 +472,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons
} }
_lv_mem_buf_release(mask_buf); lv_mem_buf_release(mask_buf);
lv_draw_mask_remove_id(mask_left_id); lv_draw_mask_remove_id(mask_left_id);
lv_draw_mask_remove_id(mask_right_id); lv_draw_mask_remove_id(mask_right_id);

View File

@@ -189,7 +189,7 @@ LV_ATTRIBUTE_FAST_MEM uint8_t lv_draw_mask_get_cnt(void)
void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t p1y, lv_coord_t p2x, void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t p1y, lv_coord_t p2x,
lv_coord_t p2y, lv_draw_mask_line_side_t side) lv_coord_t p2y, lv_draw_mask_line_side_t side)
{ {
_lv_memset_00(param, sizeof(lv_draw_mask_line_param_t)); lv_memset_00(param, sizeof(lv_draw_mask_line_param_t));
if(p1y > p2y) { if(p1y > p2y) {
lv_coord_t t; lv_coord_t t;
@@ -210,7 +210,7 @@ void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t
param->origo.x = p1x; param->origo.x = p1x;
param->origo.y = p1y; param->origo.y = p1y;
param->flat = (LV_MATH_ABS(p2x - p1x) > LV_MATH_ABS(p2y - p1y)) ? 1 : 0; param->flat = (LV_ABS(p2x - p1x) > LV_ABS(p2y - p1y)) ? 1 : 0;
param->yx_steep = 0; param->yx_steep = 0;
param->xy_steep = 0; param->xy_steep = 0;
param->dsc.cb = (lv_draw_mask_xcb_t)lv_draw_mask_line; param->dsc.cb = (lv_draw_mask_xcb_t)lv_draw_mask_line;
@@ -288,8 +288,8 @@ void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t * param, lv_coord_t
int32_t p2x; int32_t p2x;
int32_t p2y; int32_t p2y;
p2x = (_lv_trigo_sin(angle + 90) >> 5) + p1x; p2x = (lv_trigo_sin(angle + 90) >> 5) + p1x;
p2y = (_lv_trigo_sin(angle) >> 5) + py; p2y = (lv_trigo_sin(angle) >> 5) + py;
lv_draw_mask_line_points_init(param, p1x, py, p2x, p2y, side); lv_draw_mask_line_points_init(param, p1x, py, p2x, p2y, side);
} }
@@ -324,7 +324,7 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert
param->delta_deg = 360 - start_angle + end_angle; param->delta_deg = 360 - start_angle + end_angle;
} }
else { else {
param->delta_deg = LV_MATH_ABS(end_angle - start_angle); param->delta_deg = LV_ABS(end_angle - start_angle);
} }
param->cfg.start_angle = start_angle; param->cfg.start_angle = start_angle;
@@ -372,7 +372,7 @@ void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area
{ {
lv_coord_t w = lv_area_get_width(rect); lv_coord_t w = lv_area_get_width(rect);
lv_coord_t h = lv_area_get_height(rect); lv_coord_t h = lv_area_get_height(rect);
int32_t short_side = LV_MATH_MIN(w, h); int32_t short_side = LV_MIN(w, h);
if(radius > short_side >> 1) radius = short_side >> 1; if(radius > short_side >> 1) radius = short_side >> 1;
lv_area_copy(&param->cfg.rect, rect); lv_area_copy(&param->cfg.rect, rect);
@@ -460,7 +460,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mas
else { else {
int32_t k = - abs_x; int32_t k = - abs_x;
if(k < 0) return LV_DRAW_MASK_RES_TRANSP; if(k < 0) return LV_DRAW_MASK_RES_TRANSP;
if(k >= 0 && k < len) _lv_memset_00(&mask_buf[k], len - k); if(k >= 0 && k < len) lv_memset_00(&mask_buf[k], len - k);
return LV_DRAW_MASK_RES_CHANGED; return LV_DRAW_MASK_RES_CHANGED;
} }
} }
@@ -470,7 +470,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_line(lv_opa_t * mas
int32_t k = - abs_x; int32_t k = - abs_x;
if(k < 0) k = 0; if(k < 0) k = 0;
if(k >= len) return LV_DRAW_MASK_RES_TRANSP; if(k >= len) return LV_DRAW_MASK_RES_TRANSP;
else if(k >= 0 && k < len) _lv_memset_00(&mask_buf[0], k); else if(k >= 0 && k < len) lv_memset_00(&mask_buf[0], k);
return LV_DRAW_MASK_RES_CHANGED; return LV_DRAW_MASK_RES_CHANGED;
} }
} }
@@ -589,7 +589,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_b
return LV_DRAW_MASK_RES_TRANSP; return LV_DRAW_MASK_RES_TRANSP;
} }
if(k >= 0) { if(k >= 0) {
_lv_memset_00(&mask_buf[0], k); lv_memset_00(&mask_buf[0], k);
} }
} }
else { else {
@@ -598,7 +598,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_b
return LV_DRAW_MASK_RES_TRANSP; return LV_DRAW_MASK_RES_TRANSP;
} }
if(k <= len) { if(k <= len) {
_lv_memset_00(&mask_buf[k], len - k); lv_memset_00(&mask_buf[k], len - k);
} }
} }
@@ -668,13 +668,13 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_
if(k >= len) { if(k >= len) {
return LV_DRAW_MASK_RES_TRANSP; return LV_DRAW_MASK_RES_TRANSP;
} }
if(k >= 0) _lv_memset_00(&mask_buf[0], k); if(k >= 0) lv_memset_00(&mask_buf[0], k);
} }
else { else {
if(k > len) k = len; if(k > len) k = len;
if(k == 0) return LV_DRAW_MASK_RES_TRANSP; if(k == 0) return LV_DRAW_MASK_RES_TRANSP;
else if(k > 0) _lv_memset_00(&mask_buf[k], len - k); else if(k > 0) lv_memset_00(&mask_buf[k], len - k);
} }
} }
@@ -703,12 +703,12 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_
k = xsi - abs_x - 1; k = xsi - abs_x - 1;
if(k > len) k = len; if(k > len) k = len;
else if(k > 0) _lv_memset_00(&mask_buf[0], k); else if(k > 0) lv_memset_00(&mask_buf[0], k);
} }
else { else {
if(k > len) return LV_DRAW_MASK_RES_FULL_COVER; if(k > len) return LV_DRAW_MASK_RES_FULL_COVER;
if(k >= 0) _lv_memset_00(&mask_buf[k], len - k); if(k >= 0) lv_memset_00(&mask_buf[k], len - k);
} }
} }
@@ -733,13 +733,13 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_
if(p->inv) { if(p->inv) {
k = xsi - abs_x; k = xsi - abs_x;
if(k > len) return LV_DRAW_MASK_RES_TRANSP; if(k > len) return LV_DRAW_MASK_RES_TRANSP;
if(k >= 0) _lv_memset_00(&mask_buf[0], k); if(k >= 0) lv_memset_00(&mask_buf[0], k);
} }
else { else {
if(k > len) k = len; if(k > len) k = len;
if(k == 0) return LV_DRAW_MASK_RES_TRANSP; if(k == 0) return LV_DRAW_MASK_RES_TRANSP;
else if(k > 0) _lv_memset_00(&mask_buf[k], len - k); else if(k > 0) lv_memset_00(&mask_buf[k], len - k);
} }
} }
} }
@@ -789,7 +789,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * ma
if(tmp > 0) { if(tmp > 0) {
res1 = lv_draw_mask_line(&mask_buf[0], abs_x, abs_y, tmp, &p->start_line); res1 = lv_draw_mask_line(&mask_buf[0], abs_x, abs_y, tmp, &p->start_line);
if(res1 == LV_DRAW_MASK_RES_TRANSP) { if(res1 == LV_DRAW_MASK_RES_TRANSP) {
_lv_memset_00(&mask_buf[0], tmp); lv_memset_00(&mask_buf[0], tmp);
} }
} }
@@ -797,7 +797,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * ma
if(tmp < 0) tmp = 0; if(tmp < 0) tmp = 0;
res2 = lv_draw_mask_line(&mask_buf[tmp], abs_x + tmp, abs_y, len - tmp, &p->end_line); res2 = lv_draw_mask_line(&mask_buf[tmp], abs_x + tmp, abs_y, len - tmp, &p->end_line);
if(res2 == LV_DRAW_MASK_RES_TRANSP) { if(res2 == LV_DRAW_MASK_RES_TRANSP) {
_lv_memset_00(&mask_buf[tmp], len - tmp); lv_memset_00(&mask_buf[tmp], len - tmp);
} }
if(res1 == res2) return res1; if(res1 == res2) return res1;
else return LV_DRAW_MASK_RES_CHANGED; else return LV_DRAW_MASK_RES_CHANGED;
@@ -831,7 +831,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * ma
if(tmp > 0) { if(tmp > 0) {
res1 = lv_draw_mask_line(&mask_buf[0], abs_x, abs_y, tmp, (lv_draw_mask_line_param_t *)&p->end_line); res1 = lv_draw_mask_line(&mask_buf[0], abs_x, abs_y, tmp, (lv_draw_mask_line_param_t *)&p->end_line);
if(res1 == LV_DRAW_MASK_RES_TRANSP) { if(res1 == LV_DRAW_MASK_RES_TRANSP) {
_lv_memset_00(&mask_buf[0], tmp); lv_memset_00(&mask_buf[0], tmp);
} }
} }
@@ -839,7 +839,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * ma
if(tmp < 0) tmp = 0; if(tmp < 0) tmp = 0;
res2 = lv_draw_mask_line(&mask_buf[tmp], abs_x + tmp, abs_y, len - tmp, (lv_draw_mask_line_param_t *)&p->start_line); res2 = lv_draw_mask_line(&mask_buf[tmp], abs_x + tmp, abs_y, len - tmp, (lv_draw_mask_line_param_t *)&p->start_line);
if(res2 == LV_DRAW_MASK_RES_TRANSP) { if(res2 == LV_DRAW_MASK_RES_TRANSP) {
_lv_memset_00(&mask_buf[tmp], len - tmp); lv_memset_00(&mask_buf[tmp], len - tmp);
} }
if(res1 == res2) return res1; if(res1 == res2) return res1;
else return LV_DRAW_MASK_RES_CHANGED; else return LV_DRAW_MASK_RES_CHANGED;
@@ -915,13 +915,13 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
int32_t last = rect.x1 - abs_x; int32_t last = rect.x1 - abs_x;
if(last > len) return LV_DRAW_MASK_RES_TRANSP; if(last > len) return LV_DRAW_MASK_RES_TRANSP;
if(last >= 0) { if(last >= 0) {
_lv_memset_00(&mask_buf[0], last); lv_memset_00(&mask_buf[0], last);
} }
int32_t first = rect.x2 - abs_x + 1; int32_t first = rect.x2 - abs_x + 1;
if(first <= 0) return LV_DRAW_MASK_RES_TRANSP; if(first <= 0) return LV_DRAW_MASK_RES_TRANSP;
else if(first < len) { else if(first < len) {
_lv_memset_00(&mask_buf[first], len - first); lv_memset_00(&mask_buf[first], len - first);
} }
if(last == 0 && first == len) return LV_DRAW_MASK_RES_FULL_COVER; if(last == 0 && first == len) return LV_DRAW_MASK_RES_FULL_COVER;
else return LV_DRAW_MASK_RES_CHANGED; else return LV_DRAW_MASK_RES_CHANGED;
@@ -933,7 +933,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
int32_t last = rect.x2 - abs_x - first + 1; int32_t last = rect.x2 - abs_x - first + 1;
if(first + last > len) last = len - first; if(first + last > len) last = len - first;
if(last >= 0) { if(last >= 0) {
_lv_memset_00(&mask_buf[first], last); lv_memset_00(&mask_buf[first], last);
} }
} }
} }
@@ -971,9 +971,9 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
x0.i = p->y_prev_x.i; x0.i = p->y_prev_x.i;
} }
else { else {
_lv_sqrt(r2 - (y * y), &x0, sqrt_mask); lv_sqrt(r2 - (y * y), &x0, sqrt_mask);
} }
_lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1, sqrt_mask); lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1, sqrt_mask);
p->y_prev = y - 1; p->y_prev = y - 1;
p->y_prev_x.f = x1.f; p->y_prev_x.f = x1.f;
p->y_prev_x.i = x1.i; p->y_prev_x.i = x1.i;
@@ -989,10 +989,10 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
x1.i = p->y_prev_x.i; x1.i = p->y_prev_x.i;
} }
else { else {
_lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1, sqrt_mask); lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1, sqrt_mask);
} }
_lv_sqrt(r2 - (y * y), &x0, sqrt_mask); lv_sqrt(r2 - (y * y), &x0, sqrt_mask);
p->y_prev = y; p->y_prev = y;
p->y_prev_x.f = x0.f; p->y_prev_x.f = x0.f;
p->y_prev_x.i = x0.i; p->y_prev_x.i = x0.i;
@@ -1031,13 +1031,13 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
return LV_DRAW_MASK_RES_TRANSP; return LV_DRAW_MASK_RES_TRANSP;
} }
if(kl >= 0) { if(kl >= 0) {
_lv_memset_00(&mask_buf[0], kl); lv_memset_00(&mask_buf[0], kl);
} }
if(kr < 0) { if(kr < 0) {
return LV_DRAW_MASK_RES_TRANSP; return LV_DRAW_MASK_RES_TRANSP;
} }
if(kr <= len) { if(kr <= len) {
_lv_memset_00(&mask_buf[kr], len - kr); lv_memset_00(&mask_buf[kr], len - kr);
} }
} }
else { else {
@@ -1048,7 +1048,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
int32_t len_tmp = kr - first; int32_t len_tmp = kr - first;
if(len_tmp + first > len) len_tmp = len - first; if(len_tmp + first > len) len_tmp = len - first;
if(first < len && len_tmp >= 0) { if(first < len && len_tmp >= 0) {
_lv_memset_00(&mask_buf[first], len_tmp); lv_memset_00(&mask_buf[first], len_tmp);
} }
} }
} }
@@ -1065,7 +1065,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
int32_t len_tmp = kr - first; int32_t len_tmp = kr - first;
if(len_tmp + first > len) len_tmp = len - first; if(len_tmp + first > len) len_tmp = len - first;
if(first < len && len_tmp >= 0) { if(first < len && len_tmp >= 0) {
_lv_memset_00(&mask_buf[first], len_tmp); lv_memset_00(&mask_buf[first], len_tmp);
} }
} }
@@ -1074,7 +1074,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
lv_sqrt_res_t y_prev; lv_sqrt_res_t y_prev;
lv_sqrt_res_t y_next; lv_sqrt_res_t y_next;
_lv_sqrt(r2 - (x0.i * x0.i), &y_prev, sqrt_mask); lv_sqrt(r2 - (x0.i * x0.i), &y_prev, sqrt_mask);
if(y_prev.f == 0) { if(y_prev.f == 0) {
y_prev.i--; y_prev.i--;
@@ -1083,7 +1083,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
/*The first y intersection is special as it might be in the previous line*/ /*The first y intersection is special as it might be in the previous line*/
if(y_prev.i >= y) { if(y_prev.i >= y) {
_lv_sqrt(r2 - (i * i), &y_next, sqrt_mask); lv_sqrt(r2 - (i * i), &y_next, sqrt_mask);
m = 255 - (((255 - x0.f) * (255 - y_next.f)) >> 9); m = 255 - (((255 - x0.f) * (255 - y_next.f)) >> 9);
if(outer) m = 255 - m; if(outer) m = 255 - m;
@@ -1126,12 +1126,12 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
if(kl > len) { if(kl > len) {
return LV_DRAW_MASK_RES_TRANSP; return LV_DRAW_MASK_RES_TRANSP;
} }
if(kl >= 0) _lv_memset_00(&mask_buf[0], kl); if(kl >= 0) lv_memset_00(&mask_buf[0], kl);
if(kr < 0) { if(kr < 0) {
return LV_DRAW_MASK_RES_TRANSP; return LV_DRAW_MASK_RES_TRANSP;
} }
if(kr < len) _lv_memset_00(&mask_buf[kr], len - kr); if(kr < len) lv_memset_00(&mask_buf[kr], len - kr);
} }
} }
} }
@@ -1227,7 +1227,7 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_opa_t mask_mix(lv_opa_t mask_act, lv_opa_
if(mask_new >= LV_OPA_MAX) return mask_act; if(mask_new >= LV_OPA_MAX) return mask_act;
if(mask_new <= LV_OPA_MIN) return 0; if(mask_new <= LV_OPA_MIN) return 0;
return LV_MATH_UDIV255(mask_act * mask_new);// >> 8); return LV_UDIV255(mask_act * mask_new);// >> 8);
} }
/** /**

View File

@@ -16,6 +16,7 @@ extern "C" {
#include <stdbool.h> #include <stdbool.h>
#include "../lv_misc/lv_area.h" #include "../lv_misc/lv_area.h"
#include "../lv_misc/lv_color.h" #include "../lv_misc/lv_color.h"
#include "../lv_misc/lv_math.h"
/********************* /*********************
* DEFINES * DEFINES

View File

@@ -30,6 +30,8 @@
**********************/ **********************/
LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_area_t * clip,
const lv_draw_rect_dsc_t * dsc); const lv_draw_rect_dsc_t * dsc);
LV_ATTRIBUTE_FAST_MEM static void draw_bg_img(const lv_area_t * coords, const lv_area_t * clip,
const lv_draw_rect_dsc_t * dsc);
LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip, LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip,
const lv_draw_rect_dsc_t * dsc); const lv_draw_rect_dsc_t * dsc);
@@ -71,7 +73,7 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t grad_get(const lv_draw_rect_dsc_t
LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc) LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
{ {
_lv_memset_00(dsc, sizeof(lv_draw_rect_dsc_t)); lv_memset_00(dsc, sizeof(lv_draw_rect_dsc_t));
dsc->bg_color = LV_COLOR_WHITE; dsc->bg_color = LV_COLOR_WHITE;
dsc->bg_grad_color = LV_COLOR_BLACK; dsc->bg_grad_color = LV_COLOR_BLACK;
dsc->border_color = LV_COLOR_BLACK; dsc->border_color = LV_COLOR_BLACK;
@@ -79,6 +81,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
dsc->shadow_color = LV_COLOR_BLACK; dsc->shadow_color = LV_COLOR_BLACK;
dsc->bg_grad_color_stop = 0xFF; dsc->bg_grad_color_stop = 0xFF;
dsc->bg_opa = LV_OPA_COVER; dsc->bg_opa = LV_OPA_COVER;
dsc->bg_img_opa = LV_OPA_COVER;
dsc->outline_opa = LV_OPA_COVER; dsc->outline_opa = LV_OPA_COVER;
dsc->border_opa = LV_OPA_COVER; dsc->border_opa = LV_OPA_COVER;
dsc->content_font = LV_THEME_DEFAULT_FONT_NORMAL; dsc->content_font = LV_THEME_DEFAULT_FONT_NORMAL;
@@ -86,7 +89,6 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
dsc->content_align = LV_ALIGN_CENTER; dsc->content_align = LV_ALIGN_CENTER;
dsc->shadow_opa = LV_OPA_COVER; dsc->shadow_opa = LV_OPA_COVER;
dsc->border_side = LV_BORDER_SIDE_FULL; dsc->border_side = LV_BORDER_SIDE_FULL;
} }
/** /**
@@ -103,6 +105,7 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_dra
#endif #endif
draw_bg(coords, clip, dsc); draw_bg(coords, clip, dsc);
draw_bg_img(coords, clip, dsc);
draw_border(coords, clip, dsc); draw_border(coords, clip, dsc);
@@ -117,41 +120,6 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_dra
LV_ASSERT_MEM_INTEGRITY(); LV_ASSERT_MEM_INTEGRITY();
} }
/**
* Draw a pixel
* @param point the coordinates of the point to draw
* @param mask the pixel will be drawn only in this mask
* @param style pointer to a style
* @param opa_scale scale down the opacity by the factor
*/
void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style)
{
LV_UNUSED(point);
LV_UNUSED(clip_area);
LV_UNUSED(style);
// lv_opa_t opa = style->body.opa;
// if(opa_scale != LV_OPA_COVER) opa = (opa * opa_scale) >> 8;
//
// if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
//
// lv_area_t fill_area;
// fill_area.x1 = point->x;
// fill_area.y1 = point->y;
// fill_area.x2 = point->x;
// fill_area.y2 = point->y;
//
// uint8_t mask_cnt = lv_draw_mask_get_cnt();
//
// if(mask_cnt == 0) {
// lv_blend_fill(clip_area, &fill_area, style->body.main_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, style->body.blend_mode);
// } else {
// uint8_t mask_buf;
// lv_draw_mask_res_t mask_res;
// mask_res = lv_draw_mask_apply(&mask_buf, point->x, point->y, 1);
// lv_blend_fill(clip_area, &fill_area, style->body.main_color, &mask_buf, mask_res, opa, style->body.blend_mode);
// }
}
/********************** /**********************
* STATIC FUNCTIONS * STATIC FUNCTIONS
**********************/ **********************/
@@ -198,7 +166,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
int32_t draw_area_w = lv_area_get_width(&draw_area); int32_t draw_area_w = lv_area_get_width(&draw_area);
/*Create a mask if there is a radius*/ /*Create a mask if there is a radius*/
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w);
lv_grad_dir_t grad_dir = dsc->bg_grad_dir; lv_grad_dir_t grad_dir = dsc->bg_grad_dir;
if(dsc->bg_color.full == dsc->bg_grad_color.full) grad_dir = LV_GRAD_DIR_NONE; if(dsc->bg_color.full == dsc->bg_grad_color.full) grad_dir = LV_GRAD_DIR_NONE;
@@ -215,14 +183,14 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
/*Get the real radius*/ /*Get the real radius*/
int32_t rout = dsc->radius; int32_t rout = dsc->radius;
int32_t short_side = LV_MATH_MIN(coords_w, coords_h); int32_t short_side = LV_MIN(coords_w, coords_h);
if(rout > short_side >> 1) rout = short_side >> 1; if(rout > short_side >> 1) rout = short_side >> 1;
/*Most simple case: just a plain rectangle*/ /*Most simple case: just a plain rectangle*/
if(simple_mode && rout == 0 && (grad_dir == LV_GRAD_DIR_NONE)) { if(simple_mode && rout == 0 && (grad_dir == LV_GRAD_DIR_NONE)) {
_lv_blend_fill(clip, &coords_bg, _lv_blend_fill(clip, &coords_bg,
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa,
dsc->bg_blend_mode); dsc->blend_mode);
} }
/*More complex case: there is a radius, gradient or other mask.*/ /*More complex case: there is a radius, gradient or other mask.*/
else { else {
@@ -241,7 +209,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
lv_color_t * grad_map = NULL; lv_color_t * grad_map = NULL;
/*In case of horizontal gradient pre-compute a line with a gradient*/ /*In case of horizontal gradient pre-compute a line with a gradient*/
if(grad_dir == LV_GRAD_DIR_HOR) { if(grad_dir == LV_GRAD_DIR_HOR) {
grad_map = _lv_mem_buf_get(coords_w * sizeof(lv_color_t)); grad_map = lv_mem_buf_get(coords_w * sizeof(lv_color_t));
int32_t i; int32_t i;
for(i = 0; i < coords_w; i++) { for(i = 0; i < coords_w; i++) {
@@ -269,13 +237,13 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
y < coords_bg.y2 - rout - 1) { y < coords_bg.y2 - rout - 1) {
mask_res = LV_DRAW_MASK_RES_FULL_COVER; mask_res = LV_DRAW_MASK_RES_FULL_COVER;
if(simple_mode == false) { if(simple_mode == false) {
_lv_memset(mask_buf, opa, draw_area_w); lv_memset(mask_buf, opa, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
} }
} }
/*In corner areas apply the mask anyway*/ /*In corner areas apply the mask anyway*/
else { else {
_lv_memset(mask_buf, opa, draw_area_w); lv_memset(mask_buf, opa, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
} }
@@ -303,14 +271,14 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
fill_area2.y2 = fill_area.y2; fill_area2.y2 = fill_area.y2;
_lv_blend_fill(clip, &fill_area2, _lv_blend_fill(clip, &fill_area2,
grad_color, mask_buf, mask_res, opa2, dsc->bg_blend_mode); grad_color, mask_buf, mask_res, opa2, dsc->blend_mode);
/*Center part*/ /*Center part*/
if(grad_dir == LV_GRAD_DIR_VER) { if(grad_dir == LV_GRAD_DIR_VER) {
fill_area2.x1 = coords_bg.x1 + rout; fill_area2.x1 = coords_bg.x1 + rout;
fill_area2.x2 = coords_bg.x2 - rout; fill_area2.x2 = coords_bg.x2 - rout;
_lv_blend_fill(clip, &fill_area2, _lv_blend_fill(clip, &fill_area2,
grad_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode); grad_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->blend_mode);
} }
/*Right part*/ /*Right part*/
@@ -320,21 +288,21 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
int32_t mask_ofs = (coords_bg.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1); int32_t mask_ofs = (coords_bg.x2 - rout + 1) - (vdb->area.x1 + draw_area.x1);
if(mask_ofs < 0) mask_ofs = 0; if(mask_ofs < 0) mask_ofs = 0;
_lv_blend_fill(clip, &fill_area2, _lv_blend_fill(clip, &fill_area2,
grad_color, mask_buf + mask_ofs, mask_res, opa2, dsc->bg_blend_mode); grad_color, mask_buf + mask_ofs, mask_res, opa2, dsc->blend_mode);
} }
else { else {
if(grad_dir == LV_GRAD_DIR_HOR) { if(grad_dir == LV_GRAD_DIR_HOR) {
_lv_blend_map(clip, &fill_area, grad_map, mask_buf, mask_res, opa2, dsc->bg_blend_mode); _lv_blend_map(clip, &fill_area, grad_map, mask_buf, mask_res, opa2, dsc->blend_mode);
} }
else if(grad_dir == LV_GRAD_DIR_VER) { else if(grad_dir == LV_GRAD_DIR_VER) {
_lv_blend_fill(clip, &fill_area, _lv_blend_fill(clip, &fill_area,
grad_color, mask_buf, mask_res, opa2, dsc->bg_blend_mode); grad_color, mask_buf, mask_res, opa2, dsc->blend_mode);
} }
else if(other_mask_cnt != 0 || !split) { else if(other_mask_cnt != 0 || !split) {
_lv_blend_fill(clip, &fill_area, _lv_blend_fill(clip, &fill_area,
grad_color, mask_buf, mask_res, opa2, dsc->bg_blend_mode); grad_color, mask_buf, mask_res, opa2, dsc->blend_mode);
} }
} }
fill_area.y1++; fill_area.y1++;
@@ -349,7 +317,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
fill_area.y2 = coords_bg.y1 + rout; fill_area.y2 = coords_bg.y1 + rout;
_lv_blend_fill(clip, &fill_area, _lv_blend_fill(clip, &fill_area,
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode); dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->blend_mode);
fill_area.y1 = coords_bg.y2 - rout; fill_area.y1 = coords_bg.y2 - rout;
if(fill_area.y1 <= fill_area.y2) fill_area.y1 = fill_area.y2 + 1; /*Avoid overdrawing the last line*/ if(fill_area.y1 <= fill_area.y2) fill_area.y1 = fill_area.y2 + 1; /*Avoid overdrawing the last line*/
@@ -357,7 +325,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
_lv_blend_fill(clip, &fill_area, _lv_blend_fill(clip, &fill_area,
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode); dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->blend_mode);
fill_area.x1 = coords_bg.x1; fill_area.x1 = coords_bg.x1;
fill_area.x2 = coords_bg.x2; fill_area.x2 = coords_bg.x2;
@@ -365,19 +333,64 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg(const lv_area_t * coords, const lv_are
fill_area.y2 = coords_bg.y2 - rout - 1; fill_area.y2 = coords_bg.y2 - rout - 1;
_lv_blend_fill(clip, &fill_area, _lv_blend_fill(clip, &fill_area,
dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->bg_blend_mode); dsc->bg_color, NULL, LV_DRAW_MASK_RES_FULL_COVER, opa, dsc->blend_mode);
} }
if(grad_map) _lv_mem_buf_release(grad_map); if(grad_map) lv_mem_buf_release(grad_map);
} }
lv_draw_mask_remove_id(mask_rout_id); lv_draw_mask_remove_id(mask_rout_id);
_lv_mem_buf_release(mask_buf); lv_mem_buf_release(mask_buf);
} }
LV_ATTRIBUTE_FAST_MEM static void draw_bg_img(const lv_area_t * coords, const lv_area_t * clip,
const lv_draw_rect_dsc_t * dsc)
{
if(dsc->bg_img_src == NULL) return;
if(dsc->bg_img_opa <= LV_OPA_MIN) return;
lv_img_header_t header;
lv_res_t res = lv_img_decoder_get_info(dsc->bg_img_src, &header);
if(res != LV_RES_OK) {
LV_LOG_WARN("Coudn't read the background image");
return;
}
lv_draw_img_dsc_t img_dsc;
lv_draw_img_dsc_init(&img_dsc);
img_dsc.blend_mode = dsc->blend_mode;
img_dsc.recolor = dsc->bg_img_recolor;
img_dsc.recolor_opa = dsc->bg_img_recolor_opa;
img_dsc.opa = dsc->bg_img_opa;
/*Center align*/
if(dsc->bg_img_tiled == false) {
lv_area_t area;
area.x1 = coords->x1 + lv_area_get_width(coords) / 2 - header.w / 2;
area.y1 = coords->y1 + lv_area_get_height(coords) / 2 - header.h / 2;
area.x2 = area.x1 + header.w - 1;
area.y2 = area.y1 + header.h - 1;
lv_draw_img(&area, clip, dsc->bg_img_src, &img_dsc);
} else {
lv_area_t area;
area.y1 = coords->y1;
area.y2 = area.y1 + header.h - 1;
for(; area.y1 <= coords->y2; area.y1 += header.h, area.y2 += header.h) {
area.x1 = coords->x1;
area.x2 = area.x1 + header.w - 1;
for(; area.x1 <= coords->x2; area.x1 += header.w, area.x2 += header.w) {
lv_draw_img(&area, clip, dsc->bg_img_src, &img_dsc);
}
}
}
}
LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip, LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv_area_t * clip,
const lv_draw_rect_dsc_t * dsc) const lv_draw_rect_dsc_t * dsc)
{ {
@@ -391,7 +404,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
/*Get the real radius*/ /*Get the real radius*/
int32_t rout = dsc->radius; int32_t rout = dsc->radius;
int32_t short_side = LV_MATH_MIN(coords_w, coords_h); int32_t short_side = LV_MIN(coords_w, coords_h);
if(rout > short_side >> 1) rout = short_side >> 1; if(rout > short_side >> 1) rout = short_side >> 1;
/*Get the inner area*/ /*Get the inner area*/
@@ -404,7 +417,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
if(dsc->border_side == LV_BORDER_SIDE_FULL) { if(dsc->border_side == LV_BORDER_SIDE_FULL) {
draw_full_border(&area_inner, coords, clip, dsc->radius, false, dsc->border_color, dsc->border_opa, draw_full_border(&area_inner, coords, clip, dsc->radius, false, dsc->border_color, dsc->border_opa,
dsc->border_blend_mode); dsc->blend_mode);
} }
else { else {
lv_opa_t opa = dsc->border_opa; lv_opa_t opa = dsc->border_opa;
@@ -432,7 +445,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
int32_t draw_area_w = lv_area_get_width(&draw_area); int32_t draw_area_w = lv_area_get_width(&draw_area);
/*Create a mask if there is a radius*/ /*Create a mask if there is a radius*/
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w);
/*Create mask for the outer area*/ /*Create mask for the outer area*/
int16_t mask_rout_id = LV_MASK_ID_INV; int16_t mask_rout_id = LV_MASK_ID_INV;
@@ -449,14 +462,14 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rout - dsc->border_width, true); lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rout - dsc->border_width, true);
int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL); int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL);
int32_t corner_size = LV_MATH_MAX(rout, dsc->border_width - 1); int32_t corner_size = LV_MAX(rout, dsc->border_width - 1);
int32_t h; int32_t h;
lv_draw_mask_res_t mask_res; lv_draw_mask_res_t mask_res;
lv_area_t fill_area; lv_area_t fill_area;
lv_color_t color = dsc->border_color; lv_color_t color = dsc->border_color;
lv_blend_mode_t blend_mode = dsc->border_blend_mode; lv_blend_mode_t blend_mode = dsc->blend_mode;
fill_area.x1 = coords->x1; fill_area.x1 = coords->x1;
fill_area.x2 = coords->x2; fill_area.x2 = coords->x2;
@@ -485,7 +498,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
if(normal || if(normal ||
(top_only && fill_area.y1 <= coords->y1 + corner_size) || (top_only && fill_area.y1 <= coords->y1 + corner_size) ||
(bottom_only && fill_area.y1 >= coords->y2 - corner_size)) { (bottom_only && fill_area.y1 >= coords->y2 - corner_size)) {
_lv_memset_ff(mask_buf, draw_area_w); lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
_lv_blend_fill(clip, &fill_area, color, mask_buf + buf_ofs, mask_res, opa, blend_mode); _lv_blend_fill(clip, &fill_area, color, mask_buf + buf_ofs, mask_res, opa, blend_mode);
} }
@@ -495,7 +508,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_border(const lv_area_t * coords, const lv
} }
lv_draw_mask_remove_id(mask_rin_id); lv_draw_mask_remove_id(mask_rin_id);
lv_draw_mask_remove_id(mask_rout_id); lv_draw_mask_remove_id(mask_rout_id);
_lv_mem_buf_release(mask_buf); lv_mem_buf_release(mask_buf);
} }
} }
@@ -574,11 +587,11 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
/*Get the real radius*/ /*Get the real radius*/
int32_t r_bg = dsc->radius; int32_t r_bg = dsc->radius;
int32_t short_side = LV_MATH_MIN(lv_area_get_width(&bg_coords), lv_area_get_height(&bg_coords)); int32_t short_side = LV_MIN(lv_area_get_width(&bg_coords), lv_area_get_height(&bg_coords));
if(r_bg > short_side >> 1) r_bg = short_side >> 1; if(r_bg > short_side >> 1) r_bg = short_side >> 1;
int32_t r_sh = dsc->radius; int32_t r_sh = dsc->radius;
short_side = LV_MATH_MIN(lv_area_get_width(&sh_rect_area), lv_area_get_height(&sh_rect_area)); short_side = LV_MIN(lv_area_get_width(&sh_rect_area), lv_area_get_height(&sh_rect_area));
if(r_sh > short_side >> 1) r_sh = short_side >> 1; if(r_sh > short_side >> 1) r_sh = short_side >> 1;
@@ -589,23 +602,23 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
#if LV_SHADOW_CACHE_SIZE #if LV_SHADOW_CACHE_SIZE
if(sh_cache_size == corner_size && sh_cache_r == r_sh) { if(sh_cache_size == corner_size && sh_cache_r == r_sh) {
/*Use the cache if available*/ /*Use the cache if available*/
sh_buf = _lv_mem_buf_get(corner_size * corner_size); sh_buf = lv_mem_buf_get(corner_size * corner_size);
_lv_memcpy(sh_buf, sh_cache, corner_size * corner_size); lv_memcpy(sh_buf, sh_cache, corner_size * corner_size);
} }
else { else {
/*A larger buffer is required for calculation */ /*A larger buffer is required for calculation */
sh_buf = _lv_mem_buf_get(corner_size * corner_size * sizeof(uint16_t)); sh_buf = lv_mem_buf_get(corner_size * corner_size * sizeof(uint16_t));
shadow_draw_corner_buf(&sh_rect_area, (uint16_t *)sh_buf, dsc->shadow_width, r_sh); shadow_draw_corner_buf(&sh_rect_area, (uint16_t *)sh_buf, dsc->shadow_width, r_sh);
/*Cache the corner if it fits into the cache size*/ /*Cache the corner if it fits into the cache size*/
if(corner_size * corner_size < sizeof(sh_cache)) { if(corner_size * corner_size < sizeof(sh_cache)) {
_lv_memcpy(sh_cache, sh_buf, corner_size * corner_size); lv_memcpy(sh_cache, sh_buf, corner_size * corner_size);
sh_cache_size = corner_size; sh_cache_size = corner_size;
sh_cache_r = r_sh; sh_cache_r = r_sh;
} }
} }
#else #else
sh_buf = _lv_mem_buf_get(corner_size * corner_size * sizeof(uint16_t)); sh_buf = lv_mem_buf_get(corner_size * corner_size * sizeof(uint16_t));
shadow_draw_corner_buf(&sh_rect_area, (uint16_t *)sh_buf, dsc->shadow_width, r_sh); shadow_draw_corner_buf(&sh_rect_area, (uint16_t *)sh_buf, dsc->shadow_width, r_sh);
#endif #endif
@@ -619,7 +632,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
/*Create a mask*/ /*Create a mask*/
lv_draw_mask_res_t mask_res; lv_draw_mask_res_t mask_res;
lv_opa_t * mask_buf = _lv_mem_buf_get(lv_area_get_width(&sh_area)); lv_opa_t * mask_buf = lv_mem_buf_get(lv_area_get_width(&sh_area));
lv_draw_mask_radius_param_t mask_rout_param; lv_draw_mask_radius_param_t mask_rout_param;
lv_draw_mask_radius_init(&mask_rout_param, &bg_coords, r_bg, true); lv_draw_mask_radius_init(&mask_rout_param, &bg_coords, r_bg, true);
@@ -654,12 +667,12 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
fa.y2 = fa.y1; fa.y2 = fa.y1;
for(y = 0; y < h; y++) { for(y = 0; y < h; y++) {
_lv_memcpy(mask_buf, sh_buf_tmp, w); lv_memcpy(mask_buf, sh_buf_tmp, w);
mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w); mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w);
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED; if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
_lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf,
mask_res, opa, dsc->shadow_blend_mode); mask_res, opa, dsc->blend_mode);
fa.y1++; fa.y1++;
fa.y2++; fa.y2++;
sh_buf_tmp += corner_size; sh_buf_tmp += corner_size;
@@ -691,12 +704,12 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
fa.y1 = fa.y2; /*Fill from bottom to top*/ fa.y1 = fa.y2; /*Fill from bottom to top*/
for(y = 0; y < h; y++) { for(y = 0; y < h; y++) {
_lv_memcpy(mask_buf, sh_buf_tmp, w); lv_memcpy(mask_buf, sh_buf_tmp, w);
mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w); mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w);
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED; if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
_lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf,
mask_res, opa, dsc->shadow_blend_mode); mask_res, opa, dsc->blend_mode);
fa.y1--; fa.y1--;
fa.y2--; fa.y2--;
sh_buf_tmp += corner_size; sh_buf_tmp += corner_size;
@@ -712,7 +725,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
has_com = _lv_area_intersect(&ca, &a, clip); has_com = _lv_area_intersect(&ca, &a, clip);
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) { if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
if(simple_mode) ca.x1 = LV_MATH_MAX(ca.x1, coords->x2); if(simple_mode) ca.x1 = LV_MAX(ca.x1, coords->x2);
/*Draw horizontal lines*/ /*Draw horizontal lines*/
lv_coord_t w = lv_area_get_width(&ca); lv_coord_t w = lv_area_get_width(&ca);
if(w > 0) { if(w > 0) {
@@ -727,7 +740,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
fa.y2 = fa.y1; fa.y2 = fa.y1;
mask_res = LV_DRAW_MASK_RES_FULL_COVER; mask_res = LV_DRAW_MASK_RES_FULL_COVER;
for(y = 0; y < h; y++) { for(y = 0; y < h; y++) {
_lv_memcpy(mask_buf, sh_buf_tmp, w); lv_memcpy(mask_buf, sh_buf_tmp, w);
if(simple_mode) { if(simple_mode) {
mask_res = LV_DRAW_MASK_RES_CHANGED; mask_res = LV_DRAW_MASK_RES_CHANGED;
@@ -738,7 +751,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
} }
_lv_blend_fill(clip, &fa, _lv_blend_fill(clip, &fa,
dsc->shadow_color, mask_buf, mask_res, dsc->shadow_opa, dsc->shadow_blend_mode); dsc->shadow_color, mask_buf, mask_res, dsc->shadow_opa, dsc->blend_mode);
fa.y1++; fa.y1++;
fa.y2++; fa.y2++;
} }
@@ -780,12 +793,12 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
fa.y2 = fa.y1; fa.y2 = fa.y1;
for(y = 0; y < h; y++) { for(y = 0; y < h; y++) {
_lv_memcpy(mask_buf, sh_buf_tmp, w); lv_memcpy(mask_buf, sh_buf_tmp, w);
mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w); mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w);
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED; if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
_lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf,
mask_res, opa, dsc->shadow_blend_mode); mask_res, opa, dsc->blend_mode);
fa.y1++; fa.y1++;
fa.y2++; fa.y2++;
sh_buf_tmp += corner_size; sh_buf_tmp += corner_size;
@@ -816,12 +829,12 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
fa.y1 = fa.y2; /*Fill from bottom to top*/ fa.y1 = fa.y2; /*Fill from bottom to top*/
for(y = 0; y < h; y++) { for(y = 0; y < h; y++) {
_lv_memcpy(mask_buf, sh_buf_tmp, w); lv_memcpy(mask_buf, sh_buf_tmp, w);
mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w); mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w);
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED; if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
_lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf,
mask_res, opa, dsc->shadow_blend_mode); mask_res, opa, dsc->blend_mode);
fa.y1--; fa.y1--;
fa.y2--; fa.y2--;
sh_buf_tmp += corner_size; sh_buf_tmp += corner_size;
@@ -837,7 +850,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
has_com = _lv_area_intersect(&ca, &a, clip); has_com = _lv_area_intersect(&ca, &a, clip);
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) { if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
if(simple_mode) ca.x2 = LV_MATH_MIN(coords->x1, ca.x2); if(simple_mode) ca.x2 = LV_MIN(coords->x1, ca.x2);
/*Draw vertical lines*/ /*Draw vertical lines*/
lv_coord_t w = lv_area_get_width(&ca); lv_coord_t w = lv_area_get_width(&ca);
if(w > 0) { if(w > 0) {
@@ -850,7 +863,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
lv_area_copy(&fa, &ca); lv_area_copy(&fa, &ca);
fa.y2 = fa.y1; fa.y2 = fa.y1;
for(y = 0; y < h; y++) { for(y = 0; y < h; y++) {
_lv_memcpy(mask_buf, sh_buf_tmp, w); lv_memcpy(mask_buf, sh_buf_tmp, w);
if(simple_mode) { if(simple_mode) {
mask_res = LV_DRAW_MASK_RES_CHANGED; mask_res = LV_DRAW_MASK_RES_CHANGED;
} }
@@ -860,7 +873,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
} }
_lv_blend_fill(clip, &fa, _lv_blend_fill(clip, &fa,
dsc->shadow_color, mask_buf, mask_res, dsc->shadow_opa, dsc->shadow_blend_mode); dsc->shadow_color, mask_buf, mask_res, dsc->shadow_opa, dsc->blend_mode);
fa.y1++; fa.y1++;
fa.y2++; fa.y2++;
} }
@@ -875,7 +888,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
has_com = _lv_area_intersect(&ca, &a, clip); has_com = _lv_area_intersect(&ca, &a, clip);
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) { if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
if(simple_mode) ca.y2 = LV_MATH_MIN(ca.y2, coords->y1); if(simple_mode) ca.y2 = LV_MIN(ca.y2, coords->y1);
/*Draw horizontal lines*/ /*Draw horizontal lines*/
lv_coord_t w = lv_area_get_width(&ca); lv_coord_t w = lv_area_get_width(&ca);
lv_coord_t h = lv_area_get_height(&ca); lv_coord_t h = lv_area_get_height(&ca);
@@ -890,7 +903,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
lv_opa_t opa_tmp = sh_buf_tmp[0]; lv_opa_t opa_tmp = sh_buf_tmp[0];
if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8; if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8;
_lv_memset(mask_buf, opa_tmp, w); lv_memset(mask_buf, opa_tmp, w);
if(simple_mode) { if(simple_mode) {
mask_res = LV_DRAW_MASK_RES_CHANGED; mask_res = LV_DRAW_MASK_RES_CHANGED;
@@ -901,7 +914,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
} }
_lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf,
mask_res, LV_OPA_COVER, dsc->shadow_blend_mode); mask_res, LV_OPA_COVER, dsc->blend_mode);
fa.y1++; fa.y1++;
fa.y2++; fa.y2++;
sh_buf_tmp += corner_size; sh_buf_tmp += corner_size;
@@ -917,7 +930,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
has_com = _lv_area_intersect(&ca, &a, clip); has_com = _lv_area_intersect(&ca, &a, clip);
if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) { if(has_com && _lv_area_is_in(&a, &bg_coords, r_bg) == false) {
if(simple_mode) ca.y1 = LV_MATH_MAX(ca.y1, coords->y2); if(simple_mode) ca.y1 = LV_MAX(ca.y1, coords->y2);
/*Draw horizontal lines*/ /*Draw horizontal lines*/
lv_coord_t w = lv_area_get_width(&ca); lv_coord_t w = lv_area_get_width(&ca);
lv_coord_t h = lv_area_get_height(&ca); lv_coord_t h = lv_area_get_height(&ca);
@@ -931,7 +944,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
lv_opa_t opa_tmp = sh_buf_tmp[0]; lv_opa_t opa_tmp = sh_buf_tmp[0];
if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8; if(opa_tmp != LV_OPA_COVER || opa != LV_OPA_COVER) opa_tmp = (opa * opa_tmp) >> 8;
_lv_memset(mask_buf, opa_tmp, w); lv_memset(mask_buf, opa_tmp, w);
if(simple_mode) { if(simple_mode) {
mask_res = LV_DRAW_MASK_RES_CHANGED; mask_res = LV_DRAW_MASK_RES_CHANGED;
} }
@@ -941,7 +954,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
} }
_lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf,
mask_res, LV_OPA_COVER, dsc->shadow_blend_mode); mask_res, LV_OPA_COVER, dsc->blend_mode);
fa.y1--; fa.y1--;
fa.y2--; fa.y2--;
sh_buf_tmp += corner_size; sh_buf_tmp += corner_size;
@@ -964,20 +977,20 @@ LV_ATTRIBUTE_FAST_MEM static void draw_shadow(const lv_area_t * coords, const lv
lv_area_copy(&fa, &ca); lv_area_copy(&fa, &ca);
fa.y2 = fa.y1; fa.y2 = fa.y1;
for(y = 0; y < h; y++) { for(y = 0; y < h; y++) {
_lv_memset(mask_buf, dsc->shadow_opa, w); lv_memset(mask_buf, dsc->shadow_opa, w);
mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w); mask_res = lv_draw_mask_apply(mask_buf, fa.x1, fa.y1, w);
if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED; if(mask_res == LV_DRAW_MASK_RES_FULL_COVER) mask_res = LV_DRAW_MASK_RES_CHANGED;
_lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf, _lv_blend_fill(clip, &fa, dsc->shadow_color, mask_buf,
mask_res, LV_OPA_COVER, dsc->shadow_blend_mode); mask_res, LV_OPA_COVER, dsc->blend_mode);
fa.y1++; fa.y1++;
fa.y2++; fa.y2++;
} }
} }
lv_draw_mask_remove_id(mask_rout_id); lv_draw_mask_remove_id(mask_rout_id);
_lv_mem_buf_release(mask_buf); lv_mem_buf_release(mask_buf);
_lv_mem_buf_release(sh_buf); lv_mem_buf_release(sh_buf);
} }
/** /**
@@ -1011,13 +1024,13 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord
#endif #endif
int32_t y; int32_t y;
lv_opa_t * mask_line = _lv_mem_buf_get(size); lv_opa_t * mask_line = lv_mem_buf_get(size);
uint16_t * sh_ups_tmp_buf = (uint16_t *)sh_buf; uint16_t * sh_ups_tmp_buf = (uint16_t *)sh_buf;
for(y = 0; y < size; y++) { for(y = 0; y < size; y++) {
_lv_memset_ff(mask_line, size); lv_memset_ff(mask_line, size);
lv_draw_mask_res_t mask_res = mask_param.dsc.cb(mask_line, 0, y, size, &mask_param); lv_draw_mask_res_t mask_res = mask_param.dsc.cb(mask_line, 0, y, size, &mask_param);
if(mask_res == LV_DRAW_MASK_RES_TRANSP) { if(mask_res == LV_DRAW_MASK_RES_TRANSP) {
_lv_memset_00(sh_ups_tmp_buf, size * sizeof(sh_ups_tmp_buf[0])); lv_memset_00(sh_ups_tmp_buf, size * sizeof(sh_ups_tmp_buf[0]));
} }
else { else {
int32_t i; int32_t i;
@@ -1030,7 +1043,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord
sh_ups_tmp_buf += size; sh_ups_tmp_buf += size;
} }
_lv_mem_buf_release(mask_line); lv_mem_buf_release(mask_line);
if(sw == 1) { if(sw == 1) {
int32_t i; int32_t i;
@@ -1078,7 +1091,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t
if((sw & 1) == 0) s_left--; if((sw & 1) == 0) s_left--;
/*Horizontal blur*/ /*Horizontal blur*/
uint16_t * sh_ups_blur_buf = _lv_mem_buf_get(size * sizeof(uint16_t)); uint16_t * sh_ups_blur_buf = lv_mem_buf_get(size * sizeof(uint16_t));
int32_t x; int32_t x;
int32_t y; int32_t y;
@@ -1101,7 +1114,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t
else left_val = sh_ups_tmp_buf[x - s_left - 1]; else left_val = sh_ups_tmp_buf[x - s_left - 1];
v += left_val; v += left_val;
} }
_lv_memcpy(sh_ups_tmp_buf, sh_ups_blur_buf, size * sizeof(uint16_t)); lv_memcpy(sh_ups_tmp_buf, sh_ups_blur_buf, size * sizeof(uint16_t));
sh_ups_tmp_buf += size; sh_ups_tmp_buf += size;
} }
@@ -1139,7 +1152,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t
} }
} }
_lv_mem_buf_release(sh_ups_blur_buf); lv_mem_buf_release(sh_ups_blur_buf);
} }
#endif #endif
@@ -1171,65 +1184,36 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, const
area_outer.y2 += dsc->outline_width; area_outer.y2 += dsc->outline_width;
draw_full_border(&area_inner, &area_outer, clip, dsc->radius, true, dsc->outline_color, dsc->outline_opa, draw_full_border(&area_inner, &area_outer, clip, dsc->radius, true, dsc->outline_color, dsc->outline_opa,
dsc->outline_blend_mode); dsc->blend_mode);
} }
#endif #endif
#if LV_USE_PATTERN #if LV_USE_PATTERN
static void draw_content(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc) static void draw_content(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc)
{ {
if(dsc->content_src == NULL) return; if(dsc->content_text == NULL) return;
if(dsc->content_opa == LV_OPA_MIN) return; if(dsc->content_opa == LV_OPA_MIN) return;
lv_img_src_t src_type = lv_img_src_get_type(dsc->content_src);
lv_draw_img_dsc_t img_dsc;
lv_draw_label_dsc_t label_dsc; lv_draw_label_dsc_t label_dsc;
int32_t img_w;
int32_t img_h;
if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_VARIABLE) { lv_draw_label_dsc_init(&label_dsc);
lv_img_header_t header; label_dsc.color = dsc->content_color;
lv_res_t res = lv_img_decoder_get_info(dsc->content_src, &header); label_dsc.font = dsc->content_font;
if(res != LV_RES_OK) { label_dsc.opa = dsc->content_opa;
LV_LOG_WARN("draw_img: can't get image info"); lv_point_t s;
return; _lv_txt_get_size(&s, dsc->content_text, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
} LV_TEXT_FLAG_NONE);
img_w = header.w;
img_h = header.h;
lv_draw_img_dsc_init(&img_dsc);
img_dsc.opa = dsc->content_opa;
img_dsc.recolor = dsc->content_color;
img_dsc.recolor_opa = dsc->content_recolor_opa;
}
else if(src_type == LV_IMG_SRC_SYMBOL) {
lv_draw_label_dsc_init(&label_dsc);
label_dsc.color = dsc->content_color;
label_dsc.font = dsc->content_font;
label_dsc.opa = dsc->content_opa;
lv_point_t s;
_lv_txt_get_size(&s, dsc->content_src, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
LV_TEXT_FLAG_NONE);
img_w = s.x;
img_h = s.y;
}
else {
LV_LOG_WARN("image source type is unknown");
return;
}
/*Can't draw zero sized images*/ /*Can't draw zero sized images*/
if(img_w == 0 || img_h == 0) return; if(s.x == 0 || s.y == 0) return;
lv_area_t coords_tmp; lv_area_t coords_tmp;
coords_tmp.x1 = 0; coords_tmp.x1 = 0;
coords_tmp.y1 = 0; coords_tmp.y1 = 0;
coords_tmp.x2 = img_w - 1; coords_tmp.x2 = s.x - 1;
coords_tmp.y2 = img_h - 1; coords_tmp.y2 = s.y - 1;
lv_point_t p_align; lv_point_t p_align;
_lv_area_align(coords, &coords_tmp, dsc->content_align, &p_align); _lv_area_align(coords, &coords_tmp, dsc->content_align, &p_align);
@@ -1239,11 +1223,10 @@ static void draw_content(const lv_area_t * coords, const lv_area_t * clip, const
coords_tmp.x2 += p_align.x + dsc->content_ofs_x; coords_tmp.x2 += p_align.x + dsc->content_ofs_x;
coords_tmp.y2 += p_align.y + dsc->content_ofs_y; coords_tmp.y2 += p_align.y + dsc->content_ofs_y;
if(src_type == LV_IMG_SRC_SYMBOL) lv_draw_label(&coords_tmp, clip, &label_dsc, dsc->content_src, NULL); lv_draw_label(&coords_tmp, clip, &label_dsc, dsc->content_text, NULL);
else lv_draw_img(&coords_tmp, clip, dsc->content_src, &img_dsc);
#if LV_USE_ARABIC_PERSIAN_CHARS #if LV_USE_ARABIC_PERSIAN_CHARS
_lv_mem_buf_release(str); lv_mem_buf_release(str);
#endif #endif
} }
#endif #endif
@@ -1267,7 +1250,7 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are
int32_t rout; int32_t rout;
if(radius_is_in) { if(radius_is_in) {
rin = radius; rin = radius;
int32_t short_side = LV_MATH_MIN(inner_w, inner_h); int32_t short_side = LV_MIN(inner_w, inner_h);
if(rin > short_side >> 1) rin = short_side >> 1; if(rin > short_side >> 1) rin = short_side >> 1;
/*Get the outer area*/ /*Get the outer area*/
@@ -1275,7 +1258,7 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are
} }
else { else {
rout = radius; rout = radius;
int32_t short_side = LV_MATH_MIN(coords_out_w, coords_out_h); int32_t short_side = LV_MIN(coords_out_w, coords_out_h);
if(rout > short_side >> 1) rout = short_side >> 1; if(rout > short_side >> 1) rout = short_side >> 1;
/*Get the outer area*/ /*Get the outer area*/
@@ -1314,9 +1297,9 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are
lv_draw_mask_radius_init(&mask_rout_param, area_outer, rout, false); lv_draw_mask_radius_init(&mask_rout_param, area_outer, rout, false);
int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL);
lv_opa_t * mask_buf = _lv_mem_buf_get(draw_area_w); lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w);
int32_t corner_size = LV_MATH_MAX(rout, border_width - 1); int32_t corner_size = LV_MAX(rout, border_width - 1);
int32_t h; int32_t h;
lv_draw_mask_res_t mask_res; lv_draw_mask_res_t mask_res;
@@ -1332,7 +1315,7 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are
fill_area.y1 = disp_area->y1 + draw_area.y1; fill_area.y1 = disp_area->y1 + draw_area.y1;
fill_area.y2 = fill_area.y1; fill_area.y2 = fill_area.y1;
for(h = draw_area.y1; h <= upper_corner_end; h++) { for(h = draw_area.y1; h <= upper_corner_end; h++) {
_lv_memset_ff(mask_buf, draw_area_w); lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_area_t fill_area2; lv_area_t fill_area2;
@@ -1369,7 +1352,7 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are
fill_area.y1 = disp_area->y1 + lower_corner_end; fill_area.y1 = disp_area->y1 + lower_corner_end;
fill_area.y2 = fill_area.y1; fill_area.y2 = fill_area.y1;
for(h = lower_corner_end; h <= draw_area.y2; h++) { for(h = lower_corner_end; h <= draw_area.y2; h++) {
_lv_memset_ff(mask_buf, draw_area_w); lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
lv_area_t fill_area2; lv_area_t fill_area2;
@@ -1421,7 +1404,7 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are
fill_area.y2 = fill_area.y1; fill_area.y2 = fill_area.y1;
for(h = draw_area.y1; h <= draw_area.y2; h++) { for(h = draw_area.y1; h <= draw_area.y2; h++) {
_lv_memset_ff(mask_buf, draw_area_w); lv_memset_ff(mask_buf, draw_area_w);
mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w);
_lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode); _lv_blend_fill(clip, &fill_area, color, mask_buf, mask_res, opa, blend_mode);
@@ -1432,6 +1415,6 @@ static void draw_full_border(const lv_area_t * area_inner, const lv_area_t * are
} }
lv_draw_mask_remove_id(mask_rin_id); lv_draw_mask_remove_id(mask_rin_id);
lv_draw_mask_remove_id(mask_rout_id); lv_draw_mask_remove_id(mask_rout_id);
_lv_mem_buf_release(mask_buf); lv_mem_buf_release(mask_buf);
} }

View File

@@ -51,30 +51,35 @@ typedef uint8_t lv_grad_dir_t;
typedef struct { typedef struct {
lv_coord_t radius; lv_coord_t radius;
lv_blend_mode_t blend_mode;
/*Background*/ /*Background*/
lv_color_t bg_color; lv_color_t bg_color;
lv_color_t bg_grad_color; lv_color_t bg_grad_color;
lv_grad_dir_t bg_grad_dir;
uint8_t bg_main_color_stop; uint8_t bg_main_color_stop;
uint8_t bg_grad_color_stop; uint8_t bg_grad_color_stop;
lv_opa_t bg_opa; lv_opa_t bg_opa;
lv_blend_mode_t bg_blend_mode; lv_grad_dir_t bg_grad_dir :3;
/*Background img*/
const void * bg_img_src;
lv_color_t bg_img_recolor;
lv_opa_t bg_img_opa;
lv_opa_t bg_img_recolor_opa;
uint8_t bg_img_tiled;
/*Border*/ /*Border*/
lv_color_t border_color; lv_color_t border_color;
lv_coord_t border_width; lv_coord_t border_width;
lv_border_side_t border_side;
lv_opa_t border_opa; lv_opa_t border_opa;
lv_blend_mode_t border_blend_mode;
uint8_t border_post : 1; /*There is a border it will be drawn later. */ uint8_t border_post : 1; /*There is a border it will be drawn later. */
lv_border_side_t border_side :5;
/*Outline*/ /*Outline*/
lv_color_t outline_color; lv_color_t outline_color;
lv_coord_t outline_width; lv_coord_t outline_width;
lv_coord_t outline_pad; lv_coord_t outline_pad;
lv_opa_t outline_opa; lv_opa_t outline_opa;
lv_blend_mode_t outline_blend_mode;
/*Shadow*/ /*Shadow*/
lv_color_t shadow_color; lv_color_t shadow_color;
@@ -83,21 +88,18 @@ typedef struct {
lv_coord_t shadow_ofs_y; lv_coord_t shadow_ofs_y;
lv_coord_t shadow_spread; lv_coord_t shadow_spread;
lv_opa_t shadow_opa; lv_opa_t shadow_opa;
lv_blend_mode_t shadow_blend_mode;
/*Content*/ /*Content*/
const void * content_src; const void * content_text;
const void * content_img;
lv_align_t content_align;
lv_coord_t content_ofs_x;
lv_coord_t content_ofs_y;
lv_opa_t content_opa;
const lv_font_t * content_font; const lv_font_t * content_font;
lv_opa_t content_recolor_opa;
lv_blend_mode_t content_blend_mode;
lv_color_t content_color;
lv_coord_t content_letter_space; lv_coord_t content_letter_space;
lv_coord_t content_line_space; lv_coord_t content_line_space;
lv_coord_t content_ofs_x;
lv_coord_t content_ofs_y;
lv_color_t content_color;
lv_opa_t content_opa;
lv_align_t content_align : 5;
} lv_draw_rect_dsc_t; } lv_draw_rect_dsc_t;
/********************** /**********************

View File

@@ -59,7 +59,7 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are
if(points == NULL) return; if(points == NULL) return;
/*Join adjacent points if they are on the same coordinate*/ /*Join adjacent points if they are on the same coordinate*/
lv_point_t * p = _lv_mem_buf_get(point_cnt * sizeof(lv_point_t)); lv_point_t * p = lv_mem_buf_get(point_cnt * sizeof(lv_point_t));
if(p == NULL) return; if(p == NULL) return;
uint16_t i; uint16_t i;
uint16_t pcnt = 0; uint16_t pcnt = 0;
@@ -78,24 +78,24 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are
point_cnt = pcnt; point_cnt = pcnt;
if(point_cnt < 3) { if(point_cnt < 3) {
_lv_mem_buf_release(p); lv_mem_buf_release(p);
return; return;
} }
lv_area_t poly_coords = {.x1 = LV_COORD_MAX, .y1 = LV_COORD_MAX, .x2 = LV_COORD_MIN, .y2 = LV_COORD_MIN}; lv_area_t poly_coords = {.x1 = LV_COORD_MAX, .y1 = LV_COORD_MAX, .x2 = LV_COORD_MIN, .y2 = LV_COORD_MIN};
for(i = 0; i < point_cnt; i++) { for(i = 0; i < point_cnt; i++) {
poly_coords.x1 = LV_MATH_MIN(poly_coords.x1, p[i].x); poly_coords.x1 = LV_MIN(poly_coords.x1, p[i].x);
poly_coords.y1 = LV_MATH_MIN(poly_coords.y1, p[i].y); poly_coords.y1 = LV_MIN(poly_coords.y1, p[i].y);
poly_coords.x2 = LV_MATH_MAX(poly_coords.x2, p[i].x); poly_coords.x2 = LV_MAX(poly_coords.x2, p[i].x);
poly_coords.y2 = LV_MATH_MAX(poly_coords.y2, p[i].y); poly_coords.y2 = LV_MAX(poly_coords.y2, p[i].y);
} }
bool is_common; bool is_common;
lv_area_t poly_mask; lv_area_t poly_mask;
is_common = _lv_area_intersect(&poly_mask, &poly_coords, clip_area); is_common = _lv_area_intersect(&poly_mask, &poly_coords, clip_area);
if(!is_common) { if(!is_common) {
_lv_mem_buf_release(p); lv_mem_buf_release(p);
return; return;
} }
/*Find the lowest point*/ /*Find the lowest point*/
@@ -109,7 +109,7 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are
} }
} }
lv_draw_mask_line_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_line_param_t) * point_cnt); lv_draw_mask_line_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_line_param_t) * point_cnt);
lv_draw_mask_line_param_t * mp_next = mp; lv_draw_mask_line_param_t * mp_next = mp;
int32_t i_prev_left = y_min_i; int32_t i_prev_left = y_min_i;
@@ -192,8 +192,8 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are
lv_draw_mask_remove_custom(mp); lv_draw_mask_remove_custom(mp);
_lv_mem_buf_release(mp); lv_mem_buf_release(mp);
_lv_mem_buf_release(p); lv_mem_buf_release(p);
} }

View File

@@ -58,7 +58,7 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t
dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) { dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3; uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
uint32_t px = dsc->header.w * y * px_size + x * px_size; uint32_t px = dsc->header.w * y * px_size + x * px_size;
_lv_memcpy_small(&p_color, &buf_u8[px], sizeof(lv_color_t)); lv_memcpy_small(&p_color, &buf_u8[px], sizeof(lv_color_t));
#if LV_COLOR_SIZE == 32 #if LV_COLOR_SIZE == 32
p_color.ch.alpha = 0xFF; /*Only the color should be get so use a default alpha value*/ p_color.ch.alpha = 0xFF; /*Only the color should be get so use a default alpha value*/
#endif #endif
@@ -245,12 +245,12 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_
if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) { if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) {
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3; uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
uint32_t px = dsc->header.w * y * px_size + x * px_size; uint32_t px = dsc->header.w * y * px_size + x * px_size;
_lv_memcpy_small(&buf_u8[px], &c, px_size); lv_memcpy_small(&buf_u8[px], &c, px_size);
} }
else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) { else if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) {
uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3; uint8_t px_size = lv_img_cf_get_px_size(dsc->header.cf) >> 3;
uint32_t px = dsc->header.w * y * px_size + x * px_size; uint32_t px = dsc->header.w * y * px_size + x * px_size;
_lv_memcpy_small(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/ lv_memcpy_small(&buf_u8[px], &c, px_size - 1); /*-1 to not overwrite the alpha value*/
} }
else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) { else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
buf_u8 += sizeof(lv_color32_t) * 2; /*Skip the palette*/ buf_u8 += sizeof(lv_color32_t) * 2; /*Skip the palette*/
@@ -318,7 +318,7 @@ void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c)
lv_color32_t c32; lv_color32_t c32;
c32.full = lv_color_to32(c); c32.full = lv_color_to32(c);
uint8_t * buf = (uint8_t *)dsc->data; uint8_t * buf = (uint8_t *)dsc->data;
_lv_memcpy_small(&buf[id * sizeof(c32)], &c32, sizeof(c32)); lv_memcpy_small(&buf[id * sizeof(c32)], &c32, sizeof(c32));
} }
/** /**
@@ -335,7 +335,7 @@ lv_img_dsc_t * lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
if(dsc == NULL) if(dsc == NULL)
return NULL; return NULL;
_lv_memset_00(dsc, sizeof(lv_img_dsc_t)); lv_memset_00(dsc, sizeof(lv_img_dsc_t));
/* Get image data size */ /* Get image data size */
dsc->data_size = lv_img_buf_get_img_size(w, h, cf); dsc->data_size = lv_img_buf_get_img_size(w, h, cf);
@@ -350,7 +350,7 @@ lv_img_dsc_t * lv_img_buf_alloc(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
lv_mem_free(dsc); lv_mem_free(dsc);
return NULL; return NULL;
} }
_lv_memset_00((uint8_t *)dsc->data, dsc->data_size); lv_memset_00((uint8_t *)dsc->data, dsc->data_size);
/* Fill in header */ /* Fill in header */
dsc->header.always_zero = 0; dsc->header.always_zero = 0;
@@ -426,11 +426,11 @@ void _lv_img_buf_transform_init(lv_img_transform_dsc_t * dsc)
int32_t angle_high = angle_low + 1; int32_t angle_high = angle_low + 1;
int32_t angle_rem = dsc->cfg.angle - (angle_low * 10); int32_t angle_rem = dsc->cfg.angle - (angle_low * 10);
int32_t s1 = _lv_trigo_sin(-angle_low); int32_t s1 = lv_trigo_sin(-angle_low);
int32_t s2 = _lv_trigo_sin(-angle_high); int32_t s2 = lv_trigo_sin(-angle_high);
int32_t c1 = _lv_trigo_sin(-angle_low + 90); int32_t c1 = lv_trigo_sin(-angle_low + 90);
int32_t c2 = _lv_trigo_sin(-angle_high + 90); int32_t c2 = lv_trigo_sin(-angle_high + 90);
dsc->tmp.sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10; dsc->tmp.sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10;
dsc->tmp.cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10; dsc->tmp.cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10;
@@ -503,11 +503,11 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t
int32_t angle_high = angle_low + 1; int32_t angle_high = angle_low + 1;
int32_t angle_rem = angle - (angle_low * 10); int32_t angle_rem = angle - (angle_low * 10);
int32_t s1 = _lv_trigo_sin(angle_low); int32_t s1 = lv_trigo_sin(angle_low);
int32_t s2 = _lv_trigo_sin(angle_high); int32_t s2 = lv_trigo_sin(angle_high);
int32_t c1 = _lv_trigo_sin(angle_low + 90); int32_t c1 = lv_trigo_sin(angle_low + 90);
int32_t c2 = _lv_trigo_sin(angle_high + 90); int32_t c2 = lv_trigo_sin(angle_high + 90);
int32_t sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10; int32_t sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10;
int32_t cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10; int32_t cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10;
@@ -544,10 +544,10 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t
rb.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; rb.x = ((cosma * xt - sinma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x;
rb.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; rb.y = ((sinma * xt + cosma * yt) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y;
res->x1 = LV_MATH_MIN4(lb.x, lt.x, rb.x, rt.x); res->x1 = LV_MIN4(lb.x, lt.x, rb.x, rt.x);
res->x2 = LV_MATH_MAX4(lb.x, lt.x, rb.x, rt.x); res->x2 = LV_MAX4(lb.x, lt.x, rb.x, rt.x);
res->y1 = LV_MATH_MIN4(lb.y, lt.y, rb.y, rt.y); res->y1 = LV_MIN4(lb.y, lt.y, rb.y, rt.y);
res->y2 = LV_MATH_MAX4(lb.y, lt.y, rb.y, rt.y); res->y2 = LV_MAX4(lb.y, lt.y, rb.y, rt.y);
#else #else
LV_UNUSED(angle); LV_UNUSED(angle);
LV_UNUSED(zoom); LV_UNUSED(zoom);
@@ -560,6 +560,95 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t
} }
#if LV_USE_IMG_TRANSFORM #if LV_USE_IMG_TRANSFORM
/**
* Get which color and opa would come to a pixel if it were rotated
* @param dsc a descriptor initialized by `lv_img_buf_rotate_init`
* @param x the coordinate which color and opa should be get
* @param y the coordinate which color and opa should be get
* @return true: there is valid pixel on these x/y coordinates; false: the rotated pixel was out of the image
* @note the result is written back to `dsc->res_color` and `dsc->res_opa`
*/
bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t y)
{
const uint8_t * src_u8 = (const uint8_t *)dsc->cfg.src;
/*Get the target point relative coordinates to the pivot*/
int32_t xt = x - dsc->cfg.pivot_x;
int32_t yt = y - dsc->cfg.pivot_y;
int32_t xs;
int32_t ys;
if(dsc->cfg.zoom == LV_IMG_ZOOM_NONE) {
/*Get the source pixel from the upscaled image*/
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256;
ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256;
}
else if(dsc->cfg.angle == 0) {
xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
xs = xt + dsc->tmp.pivot_x_256;
ys = yt + dsc->tmp.pivot_y_256;
}
else {
xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256;
ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_y_256;
}
/*Get the integer part of the source pixel*/
int32_t xs_int = xs >> 8;
int32_t ys_int = ys >> 8;
if(xs_int >= dsc->cfg.src_w) return false;
else if(xs_int < 0) return false;
if(ys_int >= dsc->cfg.src_h) return false;
else if(ys_int < 0) return false;
uint8_t px_size;
uint32_t pxi;
if(dsc->tmp.native_color) {
if(dsc->tmp.has_alpha == 0) {
px_size = LV_COLOR_SIZE >> 3;
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size;
lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size);
}
else {
px_size = LV_IMG_PX_SIZE_ALPHA_BYTE;
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size;
lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size - 1);
dsc->res.opa = src_u8[pxi + px_size - 1];
}
}
else {
pxi = 0; /*unused*/
px_size = 0; /*unused*/
dsc->res.color = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, xs_int, ys_int, dsc->cfg.color);
dsc->res.opa = lv_img_buf_get_px_alpha(&dsc->tmp.img_dsc, xs_int, ys_int);
}
if(dsc->tmp.chroma_keyed) {
lv_color_t ct = LV_COLOR_TRANSP;
if(dsc->res.color.full == ct.full) return false;
}
if(dsc->cfg.antialias == false) return true;
dsc->tmp.xs = xs;
dsc->tmp.ys = ys;
dsc->tmp.xs_int = xs_int;
dsc->tmp.ys_int = ys_int;
dsc->tmp.pxi = pxi;
dsc->tmp.px_size = px_size;
bool ret;
ret = _lv_img_buf_transform_anti_alias(dsc);
return ret;
}
/** /**
* Continue transformation by taking the neighbors into account * Continue transformation by taking the neighbors into account
* @param dsc pointer to the transformation descriptor * @param dsc pointer to the transformation descriptor
@@ -620,9 +709,9 @@ bool _lv_img_buf_transform_anti_alias(lv_img_transform_dsc_t * dsc)
lv_opa_t a11 = 0; lv_opa_t a11 = 0;
if(dsc->tmp.native_color) { if(dsc->tmp.native_color) {
_lv_memcpy_small(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t)); lv_memcpy_small(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t));
_lv_memcpy_small(&c10, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn], sizeof(lv_color_t)); lv_memcpy_small(&c10, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn], sizeof(lv_color_t));
_lv_memcpy_small(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn], lv_memcpy_small(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn],
sizeof(lv_color_t)); sizeof(lv_color_t));
if(dsc->tmp.has_alpha) { if(dsc->tmp.has_alpha) {
a10 = src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1]; a10 = src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1];

View File

@@ -292,86 +292,8 @@ bool _lv_img_buf_transform_anti_alias(lv_img_transform_dsc_t * dsc);
* @return true: there is valid pixel on these x/y coordinates; false: the rotated pixel was out of the image * @return true: there is valid pixel on these x/y coordinates; false: the rotated pixel was out of the image
* @note the result is written back to `dsc->res_color` and `dsc->res_opa` * @note the result is written back to `dsc->res_color` and `dsc->res_opa`
*/ */
static inline bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t y) bool _lv_img_buf_transform(lv_img_transform_dsc_t * dsc, lv_coord_t x, lv_coord_t y);
{
const uint8_t * src_u8 = (const uint8_t *)dsc->cfg.src;
/*Get the target point relative coordinates to the pivot*/
int32_t xt = x - dsc->cfg.pivot_x;
int32_t yt = y - dsc->cfg.pivot_y;
int32_t xs;
int32_t ys;
if(dsc->cfg.zoom == LV_IMG_ZOOM_NONE) {
/*Get the source pixel from the upscaled image*/
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_x_256;
ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT - 8)) + dsc->tmp.pivot_y_256;
}
else if(dsc->cfg.angle == 0) {
xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
xs = xt + dsc->tmp.pivot_x_256;
ys = yt + dsc->tmp.pivot_y_256;
}
else {
xt = (int32_t)((int32_t)xt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
yt = (int32_t)((int32_t)yt * dsc->tmp.zoom_inv) >> _LV_ZOOM_INV_UPSCALE;
xs = ((dsc->tmp.cosma * xt - dsc->tmp.sinma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_x_256;
ys = ((dsc->tmp.sinma * xt + dsc->tmp.cosma * yt) >> (_LV_TRANSFORM_TRIGO_SHIFT)) + dsc->tmp.pivot_y_256;
}
/*Get the integer part of the source pixel*/
int32_t xs_int = xs >> 8;
int32_t ys_int = ys >> 8;
if(xs_int >= dsc->cfg.src_w) return false;
else if(xs_int < 0) return false;
if(ys_int >= dsc->cfg.src_h) return false;
else if(ys_int < 0) return false;
uint8_t px_size;
uint32_t pxi;
if(dsc->tmp.native_color) {
if(dsc->tmp.has_alpha == 0) {
px_size = LV_COLOR_SIZE >> 3;
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size;
_lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size);
}
else {
px_size = LV_IMG_PX_SIZE_ALPHA_BYTE;
pxi = dsc->cfg.src_w * ys_int * px_size + xs_int * px_size;
_lv_memcpy_small(&dsc->res.color, &src_u8[pxi], px_size - 1);
dsc->res.opa = src_u8[pxi + px_size - 1];
}
}
else {
pxi = 0; /*unused*/
px_size = 0; /*unused*/
dsc->res.color = lv_img_buf_get_px_color(&dsc->tmp.img_dsc, xs_int, ys_int, dsc->cfg.color);
dsc->res.opa = lv_img_buf_get_px_alpha(&dsc->tmp.img_dsc, xs_int, ys_int);
}
if(dsc->tmp.chroma_keyed) {
lv_color_t ct = LV_COLOR_TRANSP;
if(dsc->res.color.full == ct.full) return false;
}
if(dsc->cfg.antialias == false) return true;
dsc->tmp.xs = xs;
dsc->tmp.ys = ys;
dsc->tmp.xs_int = xs_int;
dsc->tmp.ys_int = ys_int;
dsc->tmp.pxi = pxi;
dsc->tmp.px_size = px_size;
bool ret;
ret = _lv_img_buf_transform_anti_alias(dsc);
return ret;
}
#endif #endif
/** /**
* Get the area of a rectangle if its rotated and scaled * Get the area of a rectangle if its rotated and scaled

View File

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

View File

@@ -200,7 +200,7 @@ lv_img_decoder_t * lv_img_decoder_create(void)
LV_ASSERT_MEM(decoder); LV_ASSERT_MEM(decoder);
if(decoder == NULL) return NULL; if(decoder == NULL) return NULL;
_lv_memset_00(decoder, sizeof(lv_img_decoder_t)); lv_memset_00(decoder, sizeof(lv_img_decoder_t));
return decoder; return decoder;
} }
@@ -338,7 +338,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
LV_LOG_ERROR("img_decoder_built_in_open: out of memory"); LV_LOG_ERROR("img_decoder_built_in_open: out of memory");
return LV_RES_INV; return LV_RES_INV;
} }
_lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t)); lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t));
} }
lv_img_decoder_built_in_data_t * user_data = dsc->user_data; lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
@@ -387,7 +387,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
lv_img_decoder_built_in_close(decoder, dsc); lv_img_decoder_built_in_close(decoder, dsc);
return LV_RES_INV; return LV_RES_INV;
} }
_lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t)); lv_memset_00(dsc->user_data, sizeof(lv_img_decoder_built_in_data_t));
} }
lv_img_decoder_built_in_data_t * user_data = dsc->user_data; lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
@@ -631,7 +631,7 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
#if LV_USE_FILESYSTEM #if LV_USE_FILESYSTEM
lv_img_decoder_built_in_data_t * user_data = dsc->user_data; lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
uint8_t * fs_buf = _lv_mem_buf_get(w); uint8_t * fs_buf = lv_mem_buf_get(w);
#endif #endif
const uint8_t * data_tmp = NULL; const uint8_t * data_tmp = NULL;
@@ -665,7 +665,7 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
} }
} }
#if LV_USE_FILESYSTEM #if LV_USE_FILESYSTEM
_lv_mem_buf_release(fs_buf); lv_mem_buf_release(fs_buf);
#endif #endif
return LV_RES_OK; return LV_RES_OK;
@@ -719,7 +719,7 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc,
lv_img_decoder_built_in_data_t * user_data = dsc->user_data; lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
#if LV_USE_FILESYSTEM #if LV_USE_FILESYSTEM
uint8_t * fs_buf = _lv_mem_buf_get(w); uint8_t * fs_buf = lv_mem_buf_get(w);
#endif #endif
const uint8_t * data_tmp = NULL; const uint8_t * data_tmp = NULL;
if(dsc->src_type == LV_IMG_SRC_VARIABLE) { if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
@@ -763,7 +763,7 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc,
} }
} }
#if LV_USE_FILESYSTEM #if LV_USE_FILESYSTEM
_lv_mem_buf_release(fs_buf); lv_mem_buf_release(fs_buf);
#endif #endif
return LV_RES_OK; return LV_RES_OK;
#else #else

View File

@@ -117,7 +117,7 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
break; break;
} }
if(_lv_mem_get_size(LV_GC_ROOT(_lv_font_decompr_buf)) < buf_size) { 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_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_MEM(LV_GC_ROOT(_lv_font_decompr_buf));
if(LV_GC_ROOT(_lv_font_decompr_buf) == NULL) return NULL; if(LV_GC_ROOT(_lv_font_decompr_buf) == NULL) return NULL;
@@ -359,12 +359,12 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
rle_init(in, bpp); rle_init(in, bpp);
uint8_t * line_buf1 = _lv_mem_buf_get(w); uint8_t * line_buf1 = lv_mem_buf_get(w);
uint8_t * line_buf2 = NULL; uint8_t * line_buf2 = NULL;
if(prefilter) { if(prefilter) {
line_buf2 = _lv_mem_buf_get(w); line_buf2 = lv_mem_buf_get(w);
} }
decompress_line(line_buf1, w); decompress_line(line_buf1, w);
@@ -397,8 +397,8 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
} }
} }
_lv_mem_buf_release(line_buf1); lv_mem_buf_release(line_buf1);
_lv_mem_buf_release(line_buf2); lv_mem_buf_release(line_buf2);
} }
/** /**

View File

@@ -443,7 +443,7 @@ static void lv_gpu_nxp_pxp_blit_recolor(lv_color_t * dest, lv_coord_t dest_width
/* Recolor with transparency */ /* Recolor with transparency */
/* Step 1: Recolor with full opacity to temporary buffer */ /* Step 1: Recolor with full opacity to temporary buffer */
lv_color_t * tmpBuf = (lv_color_t *) _lv_mem_buf_get(copy_width * copy_height * sizeof(lv_color_t)); lv_color_t * tmpBuf = (lv_color_t *) lv_mem_buf_get(copy_width * copy_height * sizeof(lv_color_t));
lv_gpu_nxp_pxp_blit_recolor(tmpBuf, copy_width, src, src_width, copy_width, copy_height, LV_OPA_COVER, recolor, lv_gpu_nxp_pxp_blit_recolor(tmpBuf, copy_width, src, src_width, copy_width, copy_height, LV_OPA_COVER, recolor,
recolorOpa); recolorOpa);
@@ -453,7 +453,7 @@ static void lv_gpu_nxp_pxp_blit_recolor(lv_color_t * dest, lv_coord_t dest_width
lv_gpu_nxp_pxp_enable_recolor(recolor, recolorOpa); /* restore state */ lv_gpu_nxp_pxp_enable_recolor(recolor, recolorOpa); /* restore state */
/* Step 3: Clean-up memory */ /* Step 3: Clean-up memory */
_lv_mem_buf_release(tmpBuf); lv_mem_buf_release(tmpBuf);
} }
} }
} }

View File

@@ -56,7 +56,7 @@ static lv_disp_t * disp_def;
*/ */
void lv_disp_drv_init(lv_disp_drv_t * driver) void lv_disp_drv_init(lv_disp_drv_t * driver)
{ {
_lv_memset_00(driver, sizeof(lv_disp_drv_t)); lv_memset_00(driver, sizeof(lv_disp_drv_t));
driver->flush_cb = NULL; driver->flush_cb = NULL;
driver->hor_res = LV_HOR_RES_MAX; driver->hor_res = LV_HOR_RES_MAX;
@@ -103,7 +103,7 @@ void lv_disp_drv_init(lv_disp_drv_t * driver)
*/ */
void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size_in_px_cnt) void lv_disp_buf_init(lv_disp_buf_t * disp_buf, void * buf1, void * buf2, uint32_t size_in_px_cnt)
{ {
_lv_memset_00(disp_buf, sizeof(lv_disp_buf_t)); lv_memset_00(disp_buf, sizeof(lv_disp_buf_t));
disp_buf->buf1 = buf1; disp_buf->buf1 = buf1;
disp_buf->buf2 = buf2; disp_buf->buf2 = buf2;
@@ -125,8 +125,8 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
return NULL; return NULL;
} }
_lv_memset_00(disp, sizeof(lv_disp_t)); lv_memset_00(disp, sizeof(lv_disp_t));
_lv_memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t)); lv_memcpy(&disp->driver, driver, sizeof(lv_disp_drv_t));
disp->last_activity_time = 0; disp->last_activity_time = 0;
@@ -327,7 +327,7 @@ LV_ATTRIBUTE_FLUSH_READY void lv_disp_flush_ready(lv_disp_drv_t * disp_drv)
/*If the screen is transparent initialize it when the flushing is ready*/ /*If the screen is transparent initialize it when the flushing is ready*/
#if LV_COLOR_SCREEN_TRANSP #if LV_COLOR_SCREEN_TRANSP
if(disp_drv->screen_transp) { if(disp_drv->screen_transp) {
_lv_memset_00(disp_drv->buffer->buf_act, disp_drv->buffer->size * sizeof(lv_color32_t)); lv_memset_00(disp_drv->buffer->buf_act, disp_drv->buffer->size * sizeof(lv_color32_t));
} }
#endif #endif

View File

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

View File

@@ -76,11 +76,11 @@ void _lv_anim_core_init(void)
*/ */
void lv_anim_init(lv_anim_t * a) void lv_anim_init(lv_anim_t * a)
{ {
_lv_memset_00(a, sizeof(lv_anim_t)); lv_memset_00(a, sizeof(lv_anim_t));
a->time = 500; a->time = 500;
a->start = 0; a->start = 0;
a->end = 100; a->end = 100;
_lv_memcpy_small(&a->path, &lv_anim_path_def, sizeof(lv_anim_path_cb_t)); lv_memcpy_small(&a->path, &lv_anim_path_def, sizeof(lv_anim_path_cb_t));
a->repeat_cnt = 1; a->repeat_cnt = 1;
a->early_apply = 1; a->early_apply = 1;
} }
@@ -106,7 +106,7 @@ void lv_anim_start(lv_anim_t * a)
/*Initialize the animation descriptor*/ /*Initialize the animation descriptor*/
a->time_orig = a->time; a->time_orig = a->time;
_lv_memcpy(new_anim, a, sizeof(lv_anim_t)); lv_memcpy(new_anim, a, sizeof(lv_anim_t));
/*Set the start value*/ /*Set the start value*/
if(new_anim->early_apply) { if(new_anim->early_apply) {
@@ -120,6 +120,27 @@ void lv_anim_start(lv_anim_t * a)
LV_LOG_TRACE("animation created") LV_LOG_TRACE("animation created")
} }
/**
* Initialize an animation path
* @param path pointer to path
*/
void lv_anim_path_init(lv_anim_path_t * path)
{
lv_memset_00(path, sizeof(lv_anim_path_t));
}
/**
* Set the path (curve) of the animation.
* @param a pointer to an initialized `lv_anim_t` variable
* @param path_cb a function the get the current value of the animation.
* The built in functions starts with `lv_anim_path_...`
*/
void lv_anim_set_path(lv_anim_t * a, const lv_anim_path_t * path)
{
lv_memcpy_small(&a->path, path, sizeof(lv_anim_path_t));
}
/** /**
* Delete an animation of a variable with a given animator function * Delete an animation of a variable with a given animator function
* @param var pointer to variable * @param var pointer to variable
@@ -192,7 +213,7 @@ uint16_t lv_anim_count_running(void)
*/ */
uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end) uint16_t lv_anim_speed_to_time(uint16_t speed, lv_anim_value_t start, lv_anim_value_t end)
{ {
int32_t d = LV_MATH_ABS((int32_t)start - end); int32_t d = LV_ABS((int32_t)start - end);
uint32_t time = (int32_t)((int32_t)(d * 1000) / speed); uint32_t time = (int32_t)((int32_t)(d * 1000) / speed);
if(time > UINT16_MAX) time = UINT16_MAX; if(time > UINT16_MAX) time = UINT16_MAX;
@@ -259,7 +280,7 @@ lv_anim_value_t lv_anim_path_ease_in(const lv_anim_path_t * path, const lv_anim_
else else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = _lv_bezier3(t, 0, 0, 580, 1024); int32_t step = lv_bezier3(t, 0, 0, 580, 1024);
int32_t new_value; int32_t new_value;
new_value = (int32_t)step * (a->end - a->start); new_value = (int32_t)step * (a->end - a->start);
@@ -286,7 +307,7 @@ lv_anim_value_t lv_anim_path_ease_out(const lv_anim_path_t * path, const lv_anim
else else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = _lv_bezier3(t, 0, 420, 1000, 1024); int32_t step = lv_bezier3(t, 0, 420, 1000, 1024);
int32_t new_value; int32_t new_value;
new_value = (int32_t)step * (a->end - a->start); new_value = (int32_t)step * (a->end - a->start);
@@ -313,7 +334,7 @@ lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_path_t * path, const lv_a
else else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = _lv_bezier3(t, 0, 64, 1024 - 64, 1024); int32_t step = lv_bezier3(t, 0, 64, 1024 - 64, 1024);
int32_t new_value; int32_t new_value;
new_value = (int32_t)step * (a->end - a->start); new_value = (int32_t)step * (a->end - a->start);
@@ -340,7 +361,7 @@ lv_anim_value_t lv_anim_path_overshoot(const lv_anim_path_t * path, const lv_ani
else else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time; t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = _lv_bezier3(t, 0, 1000, 1300, 1024); int32_t step = lv_bezier3(t, 0, 1000, 1300, 1024);
int32_t new_value; int32_t new_value;
new_value = (int32_t)step * (a->end - a->start); new_value = (int32_t)step * (a->end - a->start);
@@ -405,7 +426,7 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t
if(t > 1024) t = 1024; if(t > 1024) t = 1024;
if(t < 0) t = 0; if(t < 0) t = 0;
int32_t step = _lv_bezier3(t, 1024, 800, 500, 0); int32_t step = lv_bezier3(t, 1024, 800, 500, 0);
int32_t new_value; int32_t new_value;
new_value = (int32_t)step * diff; new_value = (int32_t)step * diff;
@@ -520,7 +541,7 @@ static bool anim_ready_handler(lv_anim_t * a)
/*Create copy from the animation and delete the animation from the list. /*Create copy from the animation and delete the animation from the list.
* This way the `ready_cb` will see the animations like it's animation is ready deleted*/ * This way the `ready_cb` will see the animations like it's animation is ready deleted*/
lv_anim_t a_tmp; lv_anim_t a_tmp;
_lv_memcpy(&a_tmp, a, sizeof(lv_anim_t)); lv_memcpy(&a_tmp, a, sizeof(lv_anim_t));
_lv_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a); _lv_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a);
lv_mem_free(a); lv_mem_free(a);
/*Flag that the list has changed */ /*Flag that the list has changed */

View File

@@ -18,7 +18,6 @@ extern "C" {
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include "lv_mem.h"
/********************* /*********************
* DEFINES * DEFINES
@@ -197,10 +196,7 @@ static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec
* @param path_cb a function the get the current value of the animation. * @param path_cb a function the get the current value of the animation.
* The built in functions starts with `lv_anim_path_...` * The built in functions starts with `lv_anim_path_...`
*/ */
static inline void lv_anim_set_path(lv_anim_t * a, const lv_anim_path_t * path) void lv_anim_set_path(lv_anim_t * a, const lv_anim_path_t * path);
{
_lv_memcpy_small(&a->path, path, sizeof(lv_anim_path_t));
}
/** /**
@@ -273,10 +269,7 @@ void lv_anim_start(lv_anim_t * a);
* Initialize an animation path * Initialize an animation path
* @param path pointer to path * @param path pointer to path
*/ */
static inline void lv_anim_path_init(lv_anim_path_t * path) void lv_anim_path_init(lv_anim_path_t * path);
{
_lv_memset_00(path, sizeof(lv_anim_path_t));
}
/** /**
* Set a callback for a path * Set a callback for a path

View File

@@ -113,10 +113,10 @@ uint32_t lv_area_get_size(const lv_area_t * area_p)
bool _lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t * a2_p) bool _lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t * a2_p)
{ {
/* Get the smaller area from 'a1_p' and 'a2_p' */ /* Get the smaller area from 'a1_p' and 'a2_p' */
res_p->x1 = LV_MATH_MAX(a1_p->x1, a2_p->x1); res_p->x1 = LV_MAX(a1_p->x1, a2_p->x1);
res_p->y1 = LV_MATH_MAX(a1_p->y1, a2_p->y1); res_p->y1 = LV_MAX(a1_p->y1, a2_p->y1);
res_p->x2 = LV_MATH_MIN(a1_p->x2, a2_p->x2); res_p->x2 = LV_MIN(a1_p->x2, a2_p->x2);
res_p->y2 = LV_MATH_MIN(a1_p->y2, a2_p->y2); res_p->y2 = LV_MIN(a1_p->y2, a2_p->y2);
/*If x1 or y1 greater then x2 or y2 then the areas union is empty*/ /*If x1 or y1 greater then x2 or y2 then the areas union is empty*/
bool union_ok = true; bool union_ok = true;
@@ -134,10 +134,10 @@ bool _lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area
*/ */
void _lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t * a2_p) void _lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t * a2_p)
{ {
a_res_p->x1 = LV_MATH_MIN(a1_p->x1, a2_p->x1); a_res_p->x1 = LV_MIN(a1_p->x1, a2_p->x1);
a_res_p->y1 = LV_MATH_MIN(a1_p->y1, a2_p->y1); a_res_p->y1 = LV_MIN(a1_p->y1, a2_p->y1);
a_res_p->x2 = LV_MATH_MAX(a1_p->x2, a2_p->x2); a_res_p->x2 = LV_MAX(a1_p->x2, a2_p->x2);
a_res_p->y2 = LV_MATH_MAX(a1_p->y2, a2_p->y2); a_res_p->y2 = LV_MAX(a1_p->y2, a2_p->y2);
} }
/** /**
@@ -163,7 +163,7 @@ bool _lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p, lv_coor
} }
lv_coord_t w = lv_area_get_width(a_p) / 2; lv_coord_t w = lv_area_get_width(a_p) / 2;
lv_coord_t h = lv_area_get_height(a_p) / 2; lv_coord_t h = lv_area_get_height(a_p) / 2;
lv_coord_t max_radius = LV_MATH_MIN(w, h); lv_coord_t max_radius = LV_MIN(w, h);
if(radius > max_radius) if(radius > max_radius)
radius = max_radius; radius = max_radius;

View File

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

View File

@@ -138,12 +138,12 @@ uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_
uint32_t visual_pos, bool * is_rtl) uint32_t visual_pos, bool * is_rtl)
{ {
uint32_t pos_conv_len = get_txt_len(str_in, len); uint32_t pos_conv_len = get_txt_len(str_in, len);
char * buf = _lv_mem_buf_get(len + 1); char * buf = lv_mem_buf_get(len + 1);
if(buf == NULL) return (uint16_t) -1; if(buf == NULL) return (uint16_t) -1;
uint16_t * pos_conv_buf = _lv_mem_buf_get(pos_conv_len * sizeof(uint16_t)); uint16_t * pos_conv_buf = lv_mem_buf_get(pos_conv_len * sizeof(uint16_t));
if(pos_conv_buf == NULL) { if(pos_conv_buf == NULL) {
_lv_mem_buf_release(buf); lv_mem_buf_release(buf);
return (uint16_t) -1; return (uint16_t) -1;
} }
@@ -153,9 +153,9 @@ uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_
if(is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[visual_pos]); if(is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[visual_pos]);
if(bidi_txt == NULL) _lv_mem_buf_release(buf); if(bidi_txt == NULL) lv_mem_buf_release(buf);
uint16_t res = GET_POS(pos_conv_buf[visual_pos]); uint16_t res = GET_POS(pos_conv_buf[visual_pos]);
_lv_mem_buf_release(pos_conv_buf); lv_mem_buf_release(pos_conv_buf);
return res; return res;
} }
@@ -175,12 +175,12 @@ uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t
uint32_t logical_pos, bool * is_rtl) uint32_t logical_pos, bool * is_rtl)
{ {
uint32_t pos_conv_len = get_txt_len(str_in, len); uint32_t pos_conv_len = get_txt_len(str_in, len);
char * buf = _lv_mem_buf_get(len + 1); char * buf = lv_mem_buf_get(len + 1);
if(buf == NULL) return (uint16_t) -1; if(buf == NULL) return (uint16_t) -1;
uint16_t * pos_conv_buf = _lv_mem_buf_get(pos_conv_len * sizeof(uint16_t)); uint16_t * pos_conv_buf = lv_mem_buf_get(pos_conv_len * sizeof(uint16_t));
if(pos_conv_buf == NULL) { if(pos_conv_buf == NULL) {
_lv_mem_buf_release(buf); lv_mem_buf_release(buf);
return (uint16_t) -1; return (uint16_t) -1;
} }
@@ -192,14 +192,14 @@ uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t
if(GET_POS(pos_conv_buf[i]) == logical_pos) { if(GET_POS(pos_conv_buf[i]) == logical_pos) {
if(is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[i]); if(is_rtl) *is_rtl = IS_RTL_POS(pos_conv_buf[i]);
_lv_mem_buf_release(pos_conv_buf); lv_mem_buf_release(pos_conv_buf);
if(bidi_txt == NULL) _lv_mem_buf_release(buf); if(bidi_txt == NULL) lv_mem_buf_release(buf);
return i; return i;
} }
} }
_lv_mem_buf_release(pos_conv_buf); lv_mem_buf_release(pos_conv_buf);
if(bidi_txt == NULL) _lv_mem_buf_release(buf); if(bidi_txt == NULL) lv_mem_buf_release(buf);
return (uint16_t) -1; return (uint16_t) -1;
} }
@@ -258,7 +258,7 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le
if(rd) { if(rd) {
if(base_dir == LV_BIDI_DIR_LTR) { if(base_dir == LV_BIDI_DIR_LTR) {
if(str_out) { if(str_out) {
_lv_memcpy(&str_out[wr], str_in, rd); lv_memcpy(&str_out[wr], str_in, rd);
wr += rd; wr += rd;
} }
if(pos_conv_out) { if(pos_conv_out) {
@@ -281,7 +281,7 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le
if(base_dir == LV_BIDI_DIR_LTR) { if(base_dir == LV_BIDI_DIR_LTR) {
if(run_dir == LV_BIDI_DIR_LTR) { if(run_dir == LV_BIDI_DIR_LTR) {
if(str_out) _lv_memcpy(&str_out[wr], &str_in[rd], run_len); if(str_out) lv_memcpy(&str_out[wr], &str_in[rd], run_len);
if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd);
} }
else rtl_reverse(str_out ? &str_out[wr] : NULL, &str_in[rd], run_len, pos_conv_out ? &pos_conv_out[pos_conv_wr] : NULL, else rtl_reverse(str_out ? &str_out[wr] : NULL, &str_in[rd], run_len, pos_conv_out ? &pos_conv_out[pos_conv_wr] : NULL,
@@ -293,7 +293,7 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le
wr -= run_len; wr -= run_len;
pos_conv_wr -= pos_conv_run_len; pos_conv_wr -= pos_conv_run_len;
if(run_dir == LV_BIDI_DIR_LTR) { if(run_dir == LV_BIDI_DIR_LTR) {
if(str_out) _lv_memcpy(&str_out[wr], &str_in[rd], run_len); if(str_out) lv_memcpy(&str_out[wr], &str_in[rd], run_len);
if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd); if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_run_len, pos_conv_rd);
} }
else rtl_reverse(str_out ? &str_out[wr] : NULL, &str_in[rd], run_len, pos_conv_out ? &pos_conv_out[pos_conv_wr] : NULL, else rtl_reverse(str_out ? &str_out[wr] : NULL, &str_in[rd], run_len, pos_conv_out ? &pos_conv_out[pos_conv_wr] : NULL,
@@ -536,7 +536,7 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *
pos_conv_first_weak = 0; pos_conv_first_weak = 0;
} }
if(dest) _lv_memcpy(&dest[wr], &src[first_weak], last_weak - first_weak + 1); if(dest) lv_memcpy(&dest[wr], &src[first_weak], last_weak - first_weak + 1);
if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_last_weak - pos_conv_first_weak + 1, if(pos_conv_out) fill_pos_conv(&pos_conv_out[pos_conv_wr], pos_conv_last_weak - pos_conv_first_weak + 1,
pos_conv_rd_base + pos_conv_first_weak); pos_conv_rd_base + pos_conv_first_weak);
wr += last_weak - first_weak + 1; wr += last_weak - first_weak + 1;
@@ -556,7 +556,7 @@ static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t *
} }
/*Just store the letter*/ /*Just store the letter*/
else { else {
if(dest) _lv_memcpy(&dest[wr], &src[i], letter_size); if(dest) lv_memcpy(&dest[wr], &src[i], letter_size);
if(pos_conv_out) pos_conv_out[pos_conv_wr] = SET_RTL_POS(pos_conv_rd_base + pos_conv_i, true); if(pos_conv_out) pos_conv_out[pos_conv_wr] = SET_RTL_POS(pos_conv_rd_base + pos_conv_i, true);
wr += letter_size; wr += letter_size;
pos_conv_wr++; pos_conv_wr++;

View File

@@ -38,10 +38,10 @@
//{ //{
// lv_base_class_t * c = class_p; // lv_base_class_t * c = class_p;
// const lv_base_class_t * bc = base_p; // const lv_base_class_t * bc = base_p;
// _lv_memset_00(c, class_size); // lv_memset_00(c, class_size);
// //
// /*By default use the same methods as the base*/ // /*By default use the same methods as the base*/
// if(bc) _lv_memcpy(c, base_p, bc->_class_size); // if(bc) lv_memcpy(c, base_p, bc->_class_size);
// //
// c->base_p = base_p; /*Save the base to allow accessing its methods later*/ // c->base_p = base_p; /*Save the base to allow accessing its methods later*/
// c->init = NULL; // c->init = NULL;
@@ -55,7 +55,7 @@
//{ //{
// lv_base_class_t * base_class_p = class_p; // lv_base_class_t * base_class_p = class_p;
// lv_base_t * instance = lv_mem_alloc(base_class_p->_instance_size); // lv_base_t * instance = lv_mem_alloc(base_class_p->_instance_size);
// _lv_memset_00(instance, base_class_p->_instance_size); // lv_memset_00(instance, base_class_p->_instance_size);
// instance->class_p = class_p; // instance->class_p = class_p;
// return instance; // return instance;
//} //}
@@ -84,6 +84,6 @@
//{ //{
// lv_base_t * base_inst = inst; // lv_base_t * base_inst = inst;
// void * class_p = base_inst->class_p; // void * class_p = base_inst->class_p;
// _lv_memset_00(inst, base_inst->class_p->_instance_size); // lv_memset_00(inst, base_inst->class_p->_instance_size);
// base_inst->class_p = class_p; /*Restore class dsc pointer*/ // base_inst->class_p = class_p; /*Restore class dsc pointer*/
//} //}

View File

@@ -234,7 +234,7 @@ lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8)
hsv.v = (100 * rgbMax) >> 10; hsv.v = (100 * rgbMax) >> 10;
int32_t delta = rgbMax - rgbMin; int32_t delta = rgbMax - rgbMin;
if(LV_MATH_ABS(delta) < 3) { if(LV_ABS(delta) < 3) {
hsv.h = 0; hsv.h = 0;
hsv.s = 0; hsv.s = 0;
return hsv; return hsv;

View File

@@ -14,7 +14,6 @@ extern "C" {
* INCLUDES * INCLUDES
*********************/ *********************/
#include "../lv_conf_internal.h" #include "../lv_conf_internal.h"
#include "lv_math.h"
/*Error checking*/ /*Error checking*/
#if LV_COLOR_DEPTH == 24 #if LV_COLOR_DEPTH == 24
@@ -208,6 +207,9 @@ enum {
# define LV_COLOR_GET_A(c) LV_COLOR_GET_A32(c) # define LV_COLOR_GET_A(c) LV_COLOR_GET_A32(c)
#endif #endif
#define LV_UDIV255(x) ((uint32_t)((uint32_t) (x) * 0x8081) >> 0x17)
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
@@ -467,11 +469,11 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t lv_color_mix(lv_color_t c1, lv_co
lv_color_t ret; lv_color_t ret;
#if LV_COLOR_DEPTH != 1 #if LV_COLOR_DEPTH != 1
/*LV_COLOR_DEPTH == 8, 16 or 32*/ /*LV_COLOR_DEPTH == 8, 16 or 32*/
LV_COLOR_SET_R(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) * LV_COLOR_SET_R(ret, LV_UDIV255((uint16_t) LV_COLOR_GET_R(c1) * mix + LV_COLOR_GET_R(c2) *
(255 - mix) + LV_COLOR_MIX_ROUND_OFS)); (255 - mix) + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_G(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) * LV_COLOR_SET_G(ret, LV_UDIV255((uint16_t) LV_COLOR_GET_G(c1) * mix + LV_COLOR_GET_G(c2) *
(255 - mix) + LV_COLOR_MIX_ROUND_OFS)); (255 - mix) + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_B(ret, LV_MATH_UDIV255((uint16_t) LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) * LV_COLOR_SET_B(ret, LV_UDIV255((uint16_t) LV_COLOR_GET_B(c1) * mix + LV_COLOR_GET_B(c2) *
(255 - mix) + LV_COLOR_MIX_ROUND_OFS)); (255 - mix) + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_A(ret, 0xFF); LV_COLOR_SET_A(ret, 0xFF);
#else #else
@@ -513,9 +515,9 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_color_t lv_color_mix_premult(uint16_t * p
lv_color_t ret; lv_color_t ret;
#if LV_COLOR_DEPTH != 1 #if LV_COLOR_DEPTH != 1
/*LV_COLOR_DEPTH == 8, 16 or 32*/ /*LV_COLOR_DEPTH == 8, 16 or 32*/
LV_COLOR_SET_R(ret, LV_MATH_UDIV255((uint16_t) premult_c1[0] + LV_COLOR_GET_R(c2) * mix + LV_COLOR_MIX_ROUND_OFS)); LV_COLOR_SET_R(ret, LV_UDIV255((uint16_t) premult_c1[0] + LV_COLOR_GET_R(c2) * mix + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_G(ret, LV_MATH_UDIV255((uint16_t) premult_c1[1] + LV_COLOR_GET_G(c2) * mix + LV_COLOR_MIX_ROUND_OFS)); LV_COLOR_SET_G(ret, LV_UDIV255((uint16_t) premult_c1[1] + LV_COLOR_GET_G(c2) * mix + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_B(ret, LV_MATH_UDIV255((uint16_t) premult_c1[2] + LV_COLOR_GET_B(c2) * mix + LV_COLOR_MIX_ROUND_OFS)); LV_COLOR_SET_B(ret, LV_UDIV255((uint16_t) premult_c1[2] + LV_COLOR_GET_B(c2) * mix + LV_COLOR_MIX_ROUND_OFS));
LV_COLOR_SET_A(ret, 0xFF); LV_COLOR_SET_A(ret, 0xFF);
#else #else
/*LV_COLOR_DEPTH == 1*/ /*LV_COLOR_DEPTH == 1*/

View File

@@ -99,7 +99,7 @@ void lv_debug_log_error(const char * msg, uint64_t value)
char * bufp = buf; char * bufp = buf;
/*Add the function name*/ /*Add the function name*/
_lv_memcpy(bufp, msg, msg_len); lv_memcpy(bufp, msg, msg_len);
bufp += msg_len; bufp += msg_len;
/*Add value in hey*/ /*Add value in hey*/

View File

@@ -473,7 +473,7 @@ lv_fs_res_t lv_fs_free_space(char letter, uint32_t * total_p, uint32_t * free_p)
*/ */
void lv_fs_drv_init(lv_fs_drv_t * drv) void lv_fs_drv_init(lv_fs_drv_t * drv)
{ {
_lv_memset_00(drv, sizeof(lv_fs_drv_t)); lv_memset_00(drv, sizeof(lv_fs_drv_t));
} }
/** /**
@@ -489,7 +489,7 @@ void lv_fs_drv_register(lv_fs_drv_t * drv_p)
LV_ASSERT_MEM(new_drv); LV_ASSERT_MEM(new_drv);
if(new_drv == NULL) return; if(new_drv == NULL) return;
_lv_memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t)); lv_memcpy(new_drv, drv_p, sizeof(lv_fs_drv_t));
} }
/** /**

View File

@@ -19,7 +19,6 @@ extern "C" {
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "lv_mem.h"
/********************* /*********************
* DEFINES * DEFINES

View File

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

View File

@@ -37,7 +37,7 @@ extern "C" {
f(lv_ll_t, _lv_obj_style_trans_ll) \ f(lv_ll_t, _lv_obj_style_trans_ll) \
f(lv_img_cache_entry_t*, _lv_img_cache_array) \ f(lv_img_cache_entry_t*, _lv_img_cache_array) \
f(lv_timer_t*, _lv_timer_act) \ f(lv_timer_t*, _lv_timer_act) \
f(lv_mem_buf_arr_t , _lv_mem_buf) \ f(lv_mem_buf_arr_t , lv_mem_buf) \
f(_lv_draw_mask_saved_arr_t , _lv_draw_mask_list) \ f(_lv_draw_mask_saved_arr_t , _lv_draw_mask_list) \
f(void * , _lv_theme_material_styles) \ f(void * , _lv_theme_material_styles) \
f(void * , _lv_theme_mono_styles) \ f(void * , _lv_theme_mono_styles) \

View File

@@ -13,7 +13,6 @@ extern "C" {
/********************* /*********************
* INCLUDES * INCLUDES
*********************/ *********************/
#include "lv_mem.h"
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>

View File

@@ -50,7 +50,7 @@ static const int16_t sin0_90_table[] = {
* @param angle * @param angle
* @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767
*/ */
LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_sin(int16_t angle) LV_ATTRIBUTE_FAST_MEM int16_t lv_trigo_sin(int16_t angle)
{ {
int16_t ret = 0; int16_t ret = 0;
angle = angle % 360; angle = angle % 360;
@@ -85,7 +85,7 @@ LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_sin(int16_t angle)
* @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX]
* @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX]
*/ */
int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3) int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3)
{ {
uint32_t t_rem = 1024 - t; uint32_t t_rem = 1024 - t;
uint32_t t_rem2 = (t_rem * t_rem) >> 10; uint32_t t_rem2 = (t_rem * t_rem) >> 10;
@@ -111,7 +111,7 @@ int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3)
* If root < 256: mask = 0x800 * If root < 256: mask = 0x800
* Else: mask = 0x8000 * Else: mask = 0x8000
*/ */
LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask) LV_ATTRIBUTE_FAST_MEM void lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask)
{ {
x = x << 8; /*To get 4 bit precision. (sqrt(256) = 16 = 4 bit)*/ x = x << 8; /*To get 4 bit precision. (sqrt(256) = 16 = 4 bit)*/
@@ -134,7 +134,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask
* @param y * @param y
* @return the angle in degree calculated from the given parameters in range of [0..360] * @return the angle in degree calculated from the given parameters in range of [0..360]
*/ */
uint16_t _lv_atan2(int x, int y) uint16_t lv_atan2(int x, int y)
{ {
// Fast XY vector to integer degree algorithm - Jan 2011 www.RomanBlack.com // Fast XY vector to integer degree algorithm - Jan 2011 www.RomanBlack.com
// Converts any XY values including 0 to a degree value that should be // Converts any XY values including 0 to a degree value that should be
@@ -150,8 +150,6 @@ uint16_t _lv_atan2(int x, int y)
unsigned char tempdegree; unsigned char tempdegree;
unsigned char comp; unsigned char comp;
unsigned int degree; // this will hold the result unsigned int degree; // this will hold the result
//signed int x; // these hold the XY vector at the start
//signed int y; // (and they will be destroyed)
unsigned int ux; unsigned int ux;
unsigned int uy; unsigned int uy;
@@ -218,7 +216,7 @@ uint16_t _lv_atan2(int x, int y)
* @param power * @param power
* @return base raised to the power exponent * @return base raised to the power exponent
*/ */
int64_t _lv_pow(int64_t base, int8_t exp) int64_t lv_pow(int64_t base, int8_t exp)
{ {
int64_t result = 1; int64_t result = 1;
while(exp) { while(exp) {
@@ -240,13 +238,13 @@ int64_t _lv_pow(int64_t base, int8_t exp)
* @param max_out max output range * @param max_out max output range
* @return the mapped number * @return the mapped number
*/ */
int16_t _lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out) int16_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out)
{ {
if(x <= min_in) return min_out; if(x <= min_in) return min_out;
if(x >= max_in) return max_out; if(x >= max_in) return max_out;
/* The equation should be: /* The equation should be:
* ((x - min_in) / delta in) * delta_out + min_out * ((x - min_in) * (delta_out / delta_min)) + min_out
* To avoid rounding error reorder the operations: * To avoid rounding error reorder the operations:
* (((x - min_in) * delta_out) / delta in) + min_out * (((x - min_in) * delta_out) / delta in) + min_out
*/ */

View File

@@ -3,8 +3,8 @@
* *
*/ */
#ifndef LV_MATH_H #ifndef LV_H
#define LV_MATH_H #define LV_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -45,12 +45,12 @@ typedef struct {
* @param angle * @param angle
* @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767
*/ */
LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_sin(int16_t angle); LV_ATTRIBUTE_FAST_MEM int16_t lv_trigo_sin(int16_t angle);
static inline LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_cos(int16_t angle) static inline LV_ATTRIBUTE_FAST_MEM int16_t lv_trigo_cos(int16_t angle)
{ {
return _lv_trigo_sin(angle + 90); return lv_trigo_sin(angle + 90);
} }
//! @endcond //! @endcond
@@ -64,7 +64,7 @@ static inline LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_cos(int16_t angle)
* @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX]
* @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX]
*/ */
int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3); int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3);
/** /**
* Calculate the atan2 of a vector. * Calculate the atan2 of a vector.
@@ -72,7 +72,7 @@ int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3);
* @param y * @param y
* @return the angle in degree calculated from the given parameters in range of [0..360] * @return the angle in degree calculated from the given parameters in range of [0..360]
*/ */
uint16_t _lv_atan2(int x, int y); uint16_t lv_atan2(int x, int y);
//! @cond Doxygen_Suppress //! @cond Doxygen_Suppress
@@ -87,7 +87,7 @@ uint16_t _lv_atan2(int x, int y);
* If root < 256: mask = 0x800 * If root < 256: mask = 0x800
* Else: mask = 0x8000 * Else: mask = 0x8000
*/ */
LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask); LV_ATTRIBUTE_FAST_MEM void lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask);
//! @endcond //! @endcond
@@ -97,7 +97,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask
* @param power * @param power
* @return base raised to the power exponent * @return base raised to the power exponent
*/ */
int64_t _lv_pow(int64_t base, int8_t exp); int64_t lv_pow(int64_t base, int8_t exp);
/** /**
* Get the mapped of a number given an input and output range * Get the mapped of a number given an input and output range
@@ -108,25 +108,23 @@ int64_t _lv_pow(int64_t base, int8_t exp);
* @param max_out max output range * @param max_out max output range
* @return the mapped number * @return the mapped number
*/ */
int16_t _lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min, int32_t max); int16_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min, int32_t max);
/********************** /**********************
* MACROS * MACROS
**********************/ **********************/
#define LV_MATH_MIN(a, b) ((a) < (b) ? (a) : (b)) #define LV_MIN(a, b) ((a) < (b) ? (a) : (b))
#define LV_MATH_MIN3(a, b, c) (LV_MATH_MIN(LV_MATH_MIN(a,b), c)) #define LV_MIN3(a, b, c) (LV_MIN(LV_MIN(a,b), c))
#define LV_MATH_MIN4(a, b, c, d) (LV_MATH_MIN(LV_MATH_MIN(a,b), LV_MATH_MIN(c,d))) #define LV_MIN4(a, b, c, d) (LV_MIN(LV_MIN(a,b), LV_MIN(c,d)))
#define LV_MATH_MAX(a, b) ((a) > (b) ? (a) : (b)) #define LV_MAX(a, b) ((a) > (b) ? (a) : (b))
#define LV_MATH_MAX3(a, b, c) (LV_MATH_MAX(LV_MATH_MAX(a,b), c)) #define LV_MAX3(a, b, c) (LV_MAX(LV_MAX(a,b), c))
#define LV_MATH_MAX4(a, b, c, d) (LV_MATH_MAX(LV_MATH_MAX(a,b), LV_MATH_MAX(c,d))) #define LV_MAX4(a, b, c, d) (LV_MAX(LV_MAX(a,b), LV_MAX(c,d)))
#define LV_CLAMP(min, val, max) (LV_MATH_MAX(min, (LV_MATH_MIN(val, max)))) #define LV_CLAMP(min, val, max) (LV_MAX(min, (LV_MIN(val, max))))
#define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x))) #define LV_ABS(x) ((x) > 0 ? (x) : (-(x)))
#define LV_MATH_UDIV255(x) ((uint32_t)((uint32_t) (x) * 0x8081) >> 0x17)
#define LV_IS_SIGNED(t) (((t)(-1)) < ((t) 0)) #define LV_IS_SIGNED(t) (((t)(-1)) < ((t) 0))
#define LV_UMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0xFULL << ((sizeof(t) * 8ULL) - 4ULL))) #define LV_UMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0xFULL << ((sizeof(t) * 8ULL) - 4ULL)))

View File

@@ -115,7 +115,7 @@ static lv_mem_buf_t mem_buf_small[] = {{.p = mem_buf1_32, .size = MEM_BUF_SMALL_
/** /**
* Initialize the dyn_mem module (work memory and other variables) * Initialize the dyn_mem module (work memory and other variables)
*/ */
void _lv_mem_init(void) void lv_mem_init(void)
{ {
#if LV_MEM_CUSTOM == 0 #if LV_MEM_CUSTOM == 0
@@ -139,10 +139,10 @@ void _lv_mem_init(void)
* Clean up the memory buffer which frees all the allocated memories. * Clean up the memory buffer which frees all the allocated memories.
* @note It work only if `LV_MEM_CUSTOM == 0` * @note It work only if `LV_MEM_CUSTOM == 0`
*/ */
void _lv_mem_deinit(void) void lv_mem_deinit(void)
{ {
#if LV_MEM_CUSTOM == 0 #if LV_MEM_CUSTOM == 0
_lv_memset_00(work_mem, (LV_MEM_SIZE / sizeof(MEM_UNIT)) * sizeof(MEM_UNIT)); lv_memset_00(work_mem, (LV_MEM_SIZE / sizeof(MEM_UNIT)) * sizeof(MEM_UNIT));
lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem; lv_mem_ent_t * full = (lv_mem_ent_t *)work_mem;
full->header.s.used = 0; full->header.s.used = 0;
/*The total mem size id reduced by the first header and the close patterns */ /*The total mem size id reduced by the first header and the close patterns */
@@ -195,7 +195,7 @@ void * lv_mem_alloc(size_t size)
#endif /* LV_MEM_CUSTOM */ #endif /* LV_MEM_CUSTOM */
#if LV_MEM_ADD_JUNK #if LV_MEM_ADD_JUNK
if(alloc != NULL) _lv_memset(alloc, 0xaa, size); if(alloc != NULL) lv_memset(alloc, 0xaa, size);
#endif #endif
if(alloc == NULL) { if(alloc == NULL) {
@@ -233,7 +233,7 @@ void lv_mem_free(const void * data)
/*e points to the header*/ /*e points to the header*/
lv_mem_ent_t * e = (lv_mem_ent_t *)((uint8_t *)data - sizeof(lv_mem_header_t)); lv_mem_ent_t * e = (lv_mem_ent_t *)((uint8_t *)data - sizeof(lv_mem_header_t));
# if LV_MEM_ADD_JUNK # if LV_MEM_ADD_JUNK
_lv_memset((void *)data, 0xbb, _lv_mem_get_size(data)); lv_memset((void *)data, 0xbb, lv_mem_get_size(data));
# endif # endif
#endif #endif
@@ -285,7 +285,7 @@ void * lv_mem_realloc(void * data_p, size_t new_size)
} }
} }
uint32_t old_size = _lv_mem_get_size(data_p); uint32_t old_size = lv_mem_get_size(data_p);
if(old_size == new_size) return data_p; /*Also avoid reallocating the same memory*/ if(old_size == new_size) return data_p; /*Also avoid reallocating the same memory*/
#if LV_MEM_CUSTOM == 0 #if LV_MEM_CUSTOM == 0
@@ -307,7 +307,7 @@ void * lv_mem_realloc(void * data_p, size_t new_size)
if(data_p != NULL) { if(data_p != NULL) {
/*Copy the old data to the new. Use the smaller size*/ /*Copy the old data to the new. Use the smaller size*/
if(old_size != 0) { if(old_size != 0) {
_lv_memcpy(new_p, data_p, LV_MATH_MIN(new_size, old_size)); lv_memcpy(new_p, data_p, LV_MIN(new_size, old_size));
lv_mem_free(data_p); lv_mem_free(data_p);
} }
} }
@@ -394,7 +394,7 @@ lv_res_t lv_mem_test(void)
void lv_mem_monitor(lv_mem_monitor_t * mon_p) void lv_mem_monitor(lv_mem_monitor_t * mon_p)
{ {
/*Init the data*/ /*Init the data*/
_lv_memset(mon_p, 0, sizeof(lv_mem_monitor_t)); lv_memset(mon_p, 0, sizeof(lv_mem_monitor_t));
#if LV_MEM_CUSTOM == 0 #if LV_MEM_CUSTOM == 0
lv_mem_ent_t * e; lv_mem_ent_t * e;
e = NULL; e = NULL;
@@ -436,7 +436,7 @@ void lv_mem_monitor(lv_mem_monitor_t * mon_p)
#if LV_ENABLE_GC == 0 #if LV_ENABLE_GC == 0
uint32_t _lv_mem_get_size(const void * data) uint32_t lv_mem_get_size(const void * data)
{ {
if(data == NULL) return 0; if(data == NULL) return 0;
if(data == &zero_mem) return 0; if(data == &zero_mem) return 0;
@@ -448,7 +448,7 @@ uint32_t _lv_mem_get_size(const void * data)
#else /* LV_ENABLE_GC */ #else /* LV_ENABLE_GC */
uint32_t _lv_mem_get_size(const void * data) uint32_t lv_mem_get_size(const void * data)
{ {
return LV_MEM_CUSTOM_GET_SIZE(data); return LV_MEM_CUSTOM_GET_SIZE(data);
} }
@@ -459,7 +459,7 @@ uint32_t _lv_mem_get_size(const void * data)
* Get a temporal buffer with the given size. * Get a temporal buffer with the given size.
* @param size the required size * @param size the required size
*/ */
void * _lv_mem_buf_get(uint32_t size) void * lv_mem_buf_get(uint32_t size)
{ {
if(size == 0) return NULL; if(size == 0) return NULL;
@@ -477,38 +477,38 @@ void * _lv_mem_buf_get(uint32_t size)
/*Try to find a free buffer with suitable size */ /*Try to find a free buffer with suitable size */
int8_t i_guess = -1; int8_t i_guess = -1;
for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) { for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) {
if(LV_GC_ROOT(_lv_mem_buf[i]).used == 0 && LV_GC_ROOT(_lv_mem_buf[i]).size >= size) { if(LV_GC_ROOT(lv_mem_buf[i]).used == 0 && LV_GC_ROOT(lv_mem_buf[i]).size >= size) {
if(LV_GC_ROOT(_lv_mem_buf[i]).size == size) { if(LV_GC_ROOT(lv_mem_buf[i]).size == size) {
LV_GC_ROOT(_lv_mem_buf[i]).used = 1; LV_GC_ROOT(lv_mem_buf[i]).used = 1;
return LV_GC_ROOT(_lv_mem_buf[i]).p; return LV_GC_ROOT(lv_mem_buf[i]).p;
} }
else if(i_guess < 0) { else if(i_guess < 0) {
i_guess = i; i_guess = i;
} }
/*If size of `i` is closer to `size` prefer it*/ /*If size of `i` is closer to `size` prefer it*/
else if(LV_GC_ROOT(_lv_mem_buf[i]).size < LV_GC_ROOT(_lv_mem_buf[i_guess]).size) { else if(LV_GC_ROOT(lv_mem_buf[i]).size < LV_GC_ROOT(lv_mem_buf[i_guess]).size) {
i_guess = i; i_guess = i;
} }
} }
} }
if(i_guess >= 0) { if(i_guess >= 0) {
LV_GC_ROOT(_lv_mem_buf[i_guess]).used = 1; LV_GC_ROOT(lv_mem_buf[i_guess]).used = 1;
return LV_GC_ROOT(_lv_mem_buf[i_guess]).p; return LV_GC_ROOT(lv_mem_buf[i_guess]).p;
} }
/*Reallocate a free buffer*/ /*Reallocate a free buffer*/
for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) { for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) {
if(LV_GC_ROOT(_lv_mem_buf[i]).used == 0) { if(LV_GC_ROOT(lv_mem_buf[i]).used == 0) {
LV_GC_ROOT(_lv_mem_buf[i]).used = 1; 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]).size = size;
/*if this fails you probably need to increase your LV_MEM_SIZE/heap size*/ /*if this fails you probably need to increase your LV_MEM_SIZE/heap size*/
LV_GC_ROOT(_lv_mem_buf[i]).p = lv_mem_realloc(LV_GC_ROOT(_lv_mem_buf[i]).p, size); LV_GC_ROOT(lv_mem_buf[i]).p = lv_mem_realloc(LV_GC_ROOT(lv_mem_buf[i]).p, size);
if(LV_GC_ROOT(_lv_mem_buf[i]).p == NULL) { if(LV_GC_ROOT(lv_mem_buf[i]).p == NULL) {
LV_DEBUG_ASSERT(false, "Out of memory, can't allocate a new buffer (increase your LV_MEM_SIZE/heap size", 0x00); LV_DEBUG_ASSERT(false, "Out of memory, can't allocate a new buffer (increase your LV_MEM_SIZE/heap size", 0x00);
} }
return LV_GC_ROOT(_lv_mem_buf[i]).p; return LV_GC_ROOT(lv_mem_buf[i]).p;
} }
} }
@@ -520,7 +520,7 @@ void * _lv_mem_buf_get(uint32_t size)
* Release a memory buffer * Release a memory buffer
* @param p buffer to release * @param p buffer to release
*/ */
void _lv_mem_buf_release(void * p) void lv_mem_buf_release(void * p)
{ {
uint8_t i; uint8_t i;
@@ -533,8 +533,8 @@ void _lv_mem_buf_release(void * p)
} }
for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) { for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) {
if(LV_GC_ROOT(_lv_mem_buf[i]).p == p) { if(LV_GC_ROOT(lv_mem_buf[i]).p == p) {
LV_GC_ROOT(_lv_mem_buf[i]).used = 0; LV_GC_ROOT(lv_mem_buf[i]).used = 0;
return; return;
} }
} }
@@ -545,7 +545,7 @@ void _lv_mem_buf_release(void * p)
/** /**
* Free all memory buffers * Free all memory buffers
*/ */
void _lv_mem_buf_free_all(void) void lv_mem_buf_free_all(void)
{ {
uint8_t i; uint8_t i;
for(i = 0; i < sizeof(mem_buf_small) / sizeof(mem_buf_small[0]); i++) { for(i = 0; i < sizeof(mem_buf_small) / sizeof(mem_buf_small[0]); i++) {
@@ -553,11 +553,11 @@ void _lv_mem_buf_free_all(void)
} }
for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) { for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) {
if(LV_GC_ROOT(_lv_mem_buf[i]).p) { if(LV_GC_ROOT(lv_mem_buf[i]).p) {
lv_mem_free(LV_GC_ROOT(_lv_mem_buf[i]).p); lv_mem_free(LV_GC_ROOT(lv_mem_buf[i]).p);
LV_GC_ROOT(_lv_mem_buf[i]).p = NULL; LV_GC_ROOT(lv_mem_buf[i]).p = NULL;
LV_GC_ROOT(_lv_mem_buf[i]).used = 0; LV_GC_ROOT(lv_mem_buf[i]).used = 0;
LV_GC_ROOT(_lv_mem_buf[i]).size = 0; LV_GC_ROOT(lv_mem_buf[i]).size = 0;
} }
} }
} }
@@ -569,7 +569,7 @@ void _lv_mem_buf_free_all(void)
* @param src pointer to the source buffer * @param src pointer to the source buffer
* @param len number of byte to copy * @param len number of byte to copy
*/ */
LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len) LV_ATTRIBUTE_FAST_MEM void * lv_memcpy(void * dst, const void * src, size_t len)
{ {
uint8_t * d8 = dst; uint8_t * d8 = dst;
const uint8_t * s8 = src; const uint8_t * s8 = src;
@@ -633,7 +633,7 @@ LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len
* @param v value to set [0..255] * @param v value to set [0..255]
* @param len number of byte to set * @param len number of byte to set
*/ */
LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len) LV_ATTRIBUTE_FAST_MEM void lv_memset(void * dst, uint8_t v, size_t len)
{ {
uint8_t * d8 = (uint8_t *) dst; uint8_t * d8 = (uint8_t *) dst;
@@ -686,7 +686,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len)
* @param dst pointer to the destination buffer * @param dst pointer to the destination buffer
* @param len number of byte to set * @param len number of byte to set
*/ */
LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len) LV_ATTRIBUTE_FAST_MEM void lv_memset_00(void * dst, size_t len)
{ {
uint8_t * d8 = (uint8_t *) dst; uint8_t * d8 = (uint8_t *) dst;
uintptr_t d_align = (lv_uintptr_t) d8 & ALIGN_MASK; uintptr_t d_align = (lv_uintptr_t) d8 & ALIGN_MASK;
@@ -735,7 +735,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len)
* @param dst pointer to the destination buffer * @param dst pointer to the destination buffer
* @param len number of byte to set * @param len number of byte to set
*/ */
LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len) LV_ATTRIBUTE_FAST_MEM void lv_memset_ff(void * dst, size_t len)
{ {
uint8_t * d8 = (uint8_t *) dst; uint8_t * d8 = (uint8_t *) dst;
uintptr_t d_align = (lv_uintptr_t) d8 & ALIGN_MASK; uintptr_t d_align = (lv_uintptr_t) d8 & ALIGN_MASK;

View File

@@ -57,7 +57,7 @@ typedef struct {
} lv_mem_buf_t; } lv_mem_buf_t;
typedef lv_mem_buf_t lv_mem_buf_arr_t[LV_MEM_BUF_MAX_NUM]; typedef lv_mem_buf_t lv_mem_buf_arr_t[LV_MEM_BUF_MAX_NUM];
extern lv_mem_buf_arr_t _lv_mem_buf; extern lv_mem_buf_arr_t lv_mem_buf;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
@@ -66,13 +66,13 @@ extern lv_mem_buf_arr_t _lv_mem_buf;
/** /**
* Initialize the dyn_mem module (work memory and other variables) * Initialize the dyn_mem module (work memory and other variables)
*/ */
void _lv_mem_init(void); void lv_mem_init(void);
/** /**
* Clean up the memory buffer which frees all the allocated memories. * Clean up the memory buffer which frees all the allocated memories.
* @note It work only if `LV_MEM_CUSTOM == 0` * @note It work only if `LV_MEM_CUSTOM == 0`
*/ */
void _lv_mem_deinit(void); void lv_mem_deinit(void);
/** /**
* Allocate a memory dynamically * Allocate a memory dynamically
@@ -119,24 +119,24 @@ void lv_mem_monitor(lv_mem_monitor_t * mon_p);
* @param data pointer to an allocated memory * @param data pointer to an allocated memory
* @return the size of data memory in bytes * @return the size of data memory in bytes
*/ */
uint32_t _lv_mem_get_size(const void * data); uint32_t lv_mem_get_size(const void * data);
/** /**
* Get a temporal buffer with the given size. * Get a temporal buffer with the given size.
* @param size the required size * @param size the required size
*/ */
void * _lv_mem_buf_get(uint32_t size); void * lv_mem_buf_get(uint32_t size);
/** /**
* Release a memory buffer * Release a memory buffer
* @param p buffer to release * @param p buffer to release
*/ */
void _lv_mem_buf_release(void * p); void lv_mem_buf_release(void * p);
/** /**
* Free all memory buffers * Free all memory buffers
*/ */
void _lv_mem_buf_free_all(void); void lv_mem_buf_free_all(void);
//! @cond Doxygen_Suppress //! @cond Doxygen_Suppress
@@ -149,7 +149,7 @@ void _lv_mem_buf_free_all(void);
* @param src pointer to the source buffer * @param src pointer to the source buffer
* @param len number of byte to copy * @param len number of byte to copy
*/ */
static inline void * _lv_memcpy(void * dst, const void * src, size_t len) static inline void * lv_memcpy(void * dst, const void * src, size_t len)
{ {
return memcpy(dst, src, len); return memcpy(dst, src, len);
} }
@@ -160,7 +160,7 @@ static inline void * _lv_memcpy(void * dst, const void * src, size_t len)
* @param src pointer to the source buffer * @param src pointer to the source buffer
* @param len number of byte to copy * @param len number of byte to copy
*/ */
static inline void * _lv_memcpy_small(void * dst, const void * src, size_t len) static inline void * lv_memcpy_small(void * dst, const void * src, size_t len)
{ {
return memcpy(dst, src, len); return memcpy(dst, src, len);
} }
@@ -171,7 +171,7 @@ static inline void * _lv_memcpy_small(void * dst, const void * src, size_t len)
* @param v value to set [0..255] * @param v value to set [0..255]
* @param len number of byte to set * @param len number of byte to set
*/ */
static inline void _lv_memset(void * dst, uint8_t v, size_t len) static inline void lv_memset(void * dst, uint8_t v, size_t len)
{ {
memset(dst, v, len); memset(dst, v, len);
} }
@@ -181,7 +181,7 @@ static inline void _lv_memset(void * dst, uint8_t v, size_t len)
* @param dst pointer to the destination buffer * @param dst pointer to the destination buffer
* @param len number of byte to set * @param len number of byte to set
*/ */
static inline void _lv_memset_00(void * dst, size_t len) static inline void lv_memset_00(void * dst, size_t len)
{ {
memset(dst, 0x00, len); memset(dst, 0x00, len);
} }
@@ -191,7 +191,7 @@ static inline void _lv_memset_00(void * dst, size_t len)
* @param dst pointer to the destination buffer * @param dst pointer to the destination buffer
* @param len number of byte to set * @param len number of byte to set
*/ */
static inline void _lv_memset_ff(void * dst, size_t len) static inline void lv_memset_ff(void * dst, size_t len)
{ {
memset(dst, 0xFF, len); memset(dst, 0xFF, len);
} }
@@ -203,7 +203,7 @@ static inline void _lv_memset_ff(void * dst, size_t len)
* @param src pointer to the source buffer * @param src pointer to the source buffer
* @param len number of byte to copy * @param len number of byte to copy
*/ */
LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len); LV_ATTRIBUTE_FAST_MEM void * lv_memcpy(void * dst, const void * src, size_t len);
/** /**
* Same as `memcpy` but optimized to copy only a few bytes. * Same as `memcpy` but optimized to copy only a few bytes.
@@ -211,7 +211,7 @@ LV_ATTRIBUTE_FAST_MEM void * _lv_memcpy(void * dst, const void * src, size_t len
* @param src pointer to the source buffer * @param src pointer to the source buffer
* @param len number of byte to copy * @param len number of byte to copy
*/ */
LV_ATTRIBUTE_FAST_MEM static inline void * _lv_memcpy_small(void * dst, const void * src, size_t len) LV_ATTRIBUTE_FAST_MEM static inline void * lv_memcpy_small(void * dst, const void * src, size_t len)
{ {
uint8_t * d8 = (uint8_t *)dst; uint8_t * d8 = (uint8_t *)dst;
const uint8_t * s8 = (const uint8_t *)src; const uint8_t * s8 = (const uint8_t *)src;
@@ -232,21 +232,21 @@ LV_ATTRIBUTE_FAST_MEM static inline void * _lv_memcpy_small(void * dst, const vo
* @param v value to set [0..255] * @param v value to set [0..255]
* @param len number of byte to set * @param len number of byte to set
*/ */
LV_ATTRIBUTE_FAST_MEM void _lv_memset(void * dst, uint8_t v, size_t len); LV_ATTRIBUTE_FAST_MEM void lv_memset(void * dst, uint8_t v, size_t len);
/** /**
* Same as `memset(dst, 0x00, len)` but optimized for 4 byte operation. * Same as `memset(dst, 0x00, len)` but optimized for 4 byte operation.
* @param dst pointer to the destination buffer * @param dst pointer to the destination buffer
* @param len number of byte to set * @param len number of byte to set
*/ */
LV_ATTRIBUTE_FAST_MEM void _lv_memset_00(void * dst, size_t len); LV_ATTRIBUTE_FAST_MEM void lv_memset_00(void * dst, size_t len);
/** /**
* Same as `memset(dst, 0xFF, len)` but optimized for 4 byte operation. * Same as `memset(dst, 0xFF, len)` but optimized for 4 byte operation.
* @param dst pointer to the destination buffer * @param dst pointer to the destination buffer
* @param len number of byte to set * @param len number of byte to set
*/ */
LV_ATTRIBUTE_FAST_MEM void _lv_memset_ff(void * dst, size_t len); LV_ATTRIBUTE_FAST_MEM void lv_memset_ff(void * dst, size_t len);
//! @endcond //! @endcond

View File

@@ -11,6 +11,7 @@
#include "lv_txt_ap.h" #include "lv_txt_ap.h"
#include "lv_math.h" #include "lv_math.h"
#include "lv_log.h" #include "lv_log.h"
#include "lv_mem.h"
#include "lv_debug.h" #include "lv_debug.h"
/********************* /*********************
@@ -125,7 +126,7 @@ void _lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t
lv_coord_t act_line_length = _lv_txt_get_width(&text[line_start], new_line_start - line_start, font, letter_space, lv_coord_t act_line_length = _lv_txt_get_width(&text[line_start], new_line_start - line_start, font, letter_space,
flag); flag);
size_res->x = LV_MATH_MAX(act_line_length, size_res->x); size_res->x = LV_MAX(act_line_length, size_res->x);
line_start = new_line_start; line_start = new_line_start;
} }
@@ -451,7 +452,7 @@ void _lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt)
} }
/* Copy the text into the new space*/ /* Copy the text into the new space*/
_lv_memcpy_small(txt_buf + pos, ins_txt, ins_len); lv_memcpy_small(txt_buf + pos, ins_txt, ins_len);
} }
/** /**
@@ -492,7 +493,7 @@ char * _lv_txt_set_text_vfmt(const char * fmt, va_list ap)
char * text = 0; char * text = 0;
#if LV_USE_ARABIC_PERSIAN_CHARS #if LV_USE_ARABIC_PERSIAN_CHARS
/*Put together the text according to the format string*/ /*Put together the text according to the format string*/
char * raw_txt = _lv_mem_buf_get(len + 1); char * raw_txt = lv_mem_buf_get(len + 1);
LV_ASSERT_MEM(raw_txt); LV_ASSERT_MEM(raw_txt);
if(raw_txt == NULL) { if(raw_txt == NULL) {
return NULL; return NULL;
@@ -509,7 +510,7 @@ char * _lv_txt_set_text_vfmt(const char * fmt, va_list ap)
} }
_lv_txt_ap_proc(raw_txt, text); _lv_txt_ap_proc(raw_txt, text);
_lv_mem_buf_release(raw_txt); lv_mem_buf_release(raw_txt);
#else #else
text = lv_mem_alloc(len + 1); text = lv_mem_alloc(len + 1);
LV_ASSERT_MEM(text); LV_ASSERT_MEM(text);
@@ -592,7 +593,7 @@ static uint32_t lv_txt_utf8_conv_wc(uint32_t c)
if((c & 0x80) != 0) { if((c & 0x80) != 0) {
uint32_t swapped; uint32_t swapped;
uint8_t c8[4]; uint8_t c8[4];
_lv_memcpy_small(c8, &c, 4); lv_memcpy_small(c8, &c, 4);
swapped = (c8[0] << 24) + (c8[1] << 16) + (c8[2] << 8) + (c8[3]); swapped = (c8[0] << 24) + (c8[1] << 16) + (c8[2] << 8) + (c8[3]);
uint8_t i; uint8_t i;
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {

View File

@@ -54,7 +54,7 @@ char * _lv_utils_num_to_str(int32_t num, char * buf)
int8_t i = 0; int8_t i = 0;
if(num < 0) { if(num < 0) {
buf[digitCount++] = '-'; buf[digitCount++] = '-';
num = LV_MATH_ABS(num); num = LV_ABS(num);
++i; ++i;
} }
while(num) { while(num) {

View File

@@ -76,7 +76,7 @@ void lv_theme_apply(lv_obj_t * obj)
*/ */
void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy) void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy)
{ {
_lv_memset_00(theme, sizeof(lv_theme_t)); lv_memset_00(theme, sizeof(lv_theme_t));
if(copy) { if(copy) {
theme->font_small = copy->font_small; theme->font_small = copy->font_small;

View File

@@ -125,7 +125,7 @@ typedef struct {
#endif #endif
#if LV_USE_DROPDOWN #if LV_USE_DROPDOWN
lv_style_t ddlist_page, ddlist_sel; lv_style_t ddlist_flip;
#endif #endif
//#if LV_USE_ROLLER //#if LV_USE_ROLLER
@@ -175,14 +175,16 @@ static void basic_init(void)
LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR,
LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_WIDTH,
LV_STYLE_TRANSFORM_HEIGHT, LV_STYLE_TRANSFORM_HEIGHT,
LV_STYLE_TRANSFORM_ZOOM,
LV_STYLE_TRANSFORM_ANGLE,
LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_CB, LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_CB,
0 0
}; };
static lv_style_transiton_t trans_delayed; static lv_style_transition_t trans_delayed;
lv_style_transition_init(&trans_delayed, trans_props, &lv_anim_path_def, TRANSITION_TIME, 70); lv_style_transition_init(&trans_delayed, trans_props, &lv_anim_path_def, TRANSITION_TIME, 70);
static lv_style_transiton_t trans_normal; static lv_style_transition_t trans_normal;
lv_style_transition_init(&trans_normal, trans_props, &lv_anim_path_def, TRANSITION_TIME, 0); lv_style_transition_init(&trans_normal, trans_props, &lv_anim_path_def, TRANSITION_TIME, 0);
style_init_reset(&styles->transition_delayed); style_init_reset(&styles->transition_delayed);
@@ -299,7 +301,7 @@ static void basic_init(void)
style_init_reset(&styles->grow); style_init_reset(&styles->grow);
lv_style_set_transform_width(&styles->grow, LV_DPX(3)); lv_style_set_transform_width(&styles->grow, LV_DPX(3));
lv_style_set_transform_height(&styles->grow, LV_DPX(3)); lv_style_set_transform_angle(&styles->grow, LV_DPX(3));
style_init_reset(&styles->knob); style_init_reset(&styles->knob);
lv_style_set_bg_color(&styles->knob, IS_LIGHT ? theme.color_primary : LV_COLOR_WHITE); lv_style_set_bg_color(&styles->knob, IS_LIGHT ? theme.color_primary : LV_COLOR_WHITE);
@@ -322,6 +324,13 @@ static void basic_init(void)
style_init_reset(&styles->arc_indic_primary); style_init_reset(&styles->arc_indic_primary);
lv_style_set_line_color(&styles->arc_indic_primary, theme.color_primary); lv_style_set_line_color(&styles->arc_indic_primary, theme.color_primary);
LV_IMG_DECLARE(asd);
lv_style_set_bg_img_src(&styles->arc_indic_primary, &asd);
#endif
#if LV_USE_DROPDOWN
style_init_reset(&styles->ddlist_flip);
lv_style_set_transform_angle(&styles->ddlist_flip, 1800);
#endif #endif
#if LV_USE_CHECKBOX #if LV_USE_CHECKBOX
@@ -334,7 +343,7 @@ static void basic_init(void)
lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2); lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2);
style_init_reset(&styles->cb_marker_checked); style_init_reset(&styles->cb_marker_checked);
lv_style_set_content_src(&styles->cb_marker_checked, LV_SYMBOL_OK); lv_style_set_content_text(&styles->cb_marker_checked, LV_SYMBOL_OK);
lv_style_set_text_color(&styles->cb_marker_checked, LV_COLOR_WHITE); lv_style_set_text_color(&styles->cb_marker_checked, LV_COLOR_WHITE);
lv_style_set_text_font(&styles->cb_marker_checked, theme.font_small); lv_style_set_text_font(&styles->cb_marker_checked, theme.font_small);
#endif #endif
@@ -613,6 +622,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#if LV_USE_DROPDOWN #if LV_USE_DROPDOWN
else if(lv_obj_check_type(obj, &lv_dropdown)) { else if(lv_obj_check_type(obj, &lv_dropdown)) {
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card); lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card);
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_CHECKED, &styles->ddlist_flip);
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_normal);
} }
else if(lv_obj_check_type(obj, &lv_dropdown_list)) { else if(lv_obj_check_type(obj, &lv_dropdown_list)) {
lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card); lv_obj_add_style_no_refresh(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card);

View File

@@ -101,8 +101,8 @@ static bool inited;
#define COLOR_INV(c) ((c).ch.red == 0 ? LV_COLOR_WHITE : LV_COLOR_BLACK) #define COLOR_INV(c) ((c).ch.red == 0 ? LV_COLOR_WHITE : LV_COLOR_BLACK)
#define BG_COLOR theme.color_primary.ch.red == 0 ? LV_COLOR_WHITE : LV_COLOR_BLACK #define BG_COLOR theme.color_primary.ch.red == 0 ? LV_COLOR_WHITE : LV_COLOR_BLACK
#define FG_COLOR COLOR_INV(BG_COLOR) #define FG_COLOR COLOR_INV(BG_COLOR)
#define RADIUS (LV_MATH_MAX(LV_DPI / 30, 2)) #define RADIUS (LV_MAX(LV_DPI / 30, 2))
#define BORDER_WIDTH (LV_MATH_MAX(LV_DPI / 60, 1)) #define BORDER_WIDTH (LV_MAX(LV_DPI / 60, 1))
/********************** /**********************
* STATIC FUNCTIONS * STATIC FUNCTIONS
@@ -127,8 +127,8 @@ static void basic_init(void)
lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED, BORDER_WIDTH * 2); lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED, BORDER_WIDTH * 2);
lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED | LV_STATE_EDITED, BORDER_WIDTH * 3); lv_style_set_border_width(&styles->bg, LV_STATE_FOCUSED | LV_STATE_EDITED, BORDER_WIDTH * 3);
lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_border_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); lv_style_set_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 100, 1));
lv_style_set_scale_end_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); lv_style_set_scale_end_line_width(&styles->bg, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 100, 1));
lv_style_set_line_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_line_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_scale_grad_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_scale_grad_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_scale_end_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_scale_end_color(&styles->bg, LV_STATE_DEFAULT, FG_COLOR);
@@ -211,11 +211,11 @@ static void arc_init(void)
{ {
#if LV_USE_ARC != 0 #if LV_USE_ARC != 0
style_init_reset(&styles->arc_bg); style_init_reset(&styles->arc_bg);
lv_style_set_line_width(&styles->arc_bg, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); lv_style_set_line_width(&styles->arc_bg, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 100, 1));
lv_style_set_line_color(&styles->arc_bg, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_line_color(&styles->arc_bg, LV_STATE_DEFAULT, FG_COLOR);
style_init_reset(&styles->arc_indic); style_init_reset(&styles->arc_indic);
lv_style_set_line_width(&styles->arc_indic, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 10, 3)); lv_style_set_line_width(&styles->arc_indic, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 10, 3));
lv_style_set_line_color(&styles->arc_indic, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_line_color(&styles->arc_indic, LV_STATE_DEFAULT, FG_COLOR);
#endif #endif
} }
@@ -248,7 +248,7 @@ static void chart_init(void)
style_init_reset(&styles->chart_series); style_init_reset(&styles->chart_series);
lv_style_set_size(&styles->chart_series, LV_STATE_DEFAULT, 0); lv_style_set_size(&styles->chart_series, LV_STATE_DEFAULT, 0);
lv_style_set_bg_opa(&styles->chart_series, LV_STATE_DEFAULT, LV_OPA_TRANSP); lv_style_set_bg_opa(&styles->chart_series, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_line_width(&styles->chart_series, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 50, 1)); lv_style_set_line_width(&styles->chart_series, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 50, 1));
#endif #endif
} }
@@ -264,19 +264,19 @@ static void gauge_init(void)
{ {
#if LV_USE_GAUGE != 0 #if LV_USE_GAUGE != 0
style_init_reset(&styles->gauge_needle); style_init_reset(&styles->gauge_needle);
lv_style_set_line_width(&styles->gauge_needle, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 30, 2)); lv_style_set_line_width(&styles->gauge_needle, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 30, 2));
lv_style_set_line_color(&styles->gauge_needle, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_line_color(&styles->gauge_needle, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_size(&styles->gauge_needle, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 10, 4)); lv_style_set_size(&styles->gauge_needle, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 10, 4));
lv_style_set_bg_opa(&styles->gauge_needle, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_opa(&styles->gauge_needle, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->gauge_needle, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_bg_color(&styles->gauge_needle, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_radius(&styles->gauge_needle, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); lv_style_set_radius(&styles->gauge_needle, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
style_init_reset(&styles->gauge_major); style_init_reset(&styles->gauge_major);
lv_style_set_line_width(&styles->gauge_major, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 25, 2)); lv_style_set_line_width(&styles->gauge_major, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 25, 2));
lv_style_set_line_color(&styles->gauge_major, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_line_color(&styles->gauge_major, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_scale_end_color(&styles->gauge_major, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_scale_end_color(&styles->gauge_major, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_scale_grad_color(&styles->gauge_major, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_scale_grad_color(&styles->gauge_major, LV_STATE_DEFAULT, FG_COLOR);
lv_style_set_scale_end_line_width(&styles->gauge_major, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 25, 2)); lv_style_set_scale_end_line_width(&styles->gauge_major, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 25, 2));
#endif #endif
} }
@@ -300,8 +300,8 @@ static void linemeter_init(void)
{ {
#if LV_USE_LINEMETER != 0 #if LV_USE_LINEMETER != 0
style_init_reset(&styles->linemeter); style_init_reset(&styles->linemeter);
lv_style_set_line_width(&styles->linemeter, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 25, 2)); lv_style_set_line_width(&styles->linemeter, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 25, 2));
lv_style_set_scale_end_line_width(&styles->linemeter, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 70, 1)); lv_style_set_scale_end_line_width(&styles->linemeter, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 70, 1));
#endif #endif
} }
@@ -331,7 +331,7 @@ static void textarea_init(void)
#if LV_USE_TEXTAREA #if LV_USE_TEXTAREA
style_init_reset(&styles->ta_cursor); style_init_reset(&styles->ta_cursor);
lv_style_set_bg_opa(&styles->ta_cursor, LV_STATE_DEFAULT, LV_OPA_TRANSP); lv_style_set_bg_opa(&styles->ta_cursor, LV_STATE_DEFAULT, LV_OPA_TRANSP);
lv_style_set_border_width(&styles->ta_cursor, LV_STATE_DEFAULT, LV_MATH_MAX(LV_DPI / 100, 1)); lv_style_set_border_width(&styles->ta_cursor, LV_STATE_DEFAULT, LV_MAX(LV_DPI / 100, 1));
lv_style_set_border_side(&styles->ta_cursor, LV_STATE_DEFAULT, LV_BORDER_SIDE_LEFT); lv_style_set_border_side(&styles->ta_cursor, LV_STATE_DEFAULT, LV_BORDER_SIDE_LEFT);
lv_style_set_border_color(&styles->ta_cursor, LV_STATE_DEFAULT, FG_COLOR); lv_style_set_border_color(&styles->ta_cursor, LV_STATE_DEFAULT, FG_COLOR);

View File

@@ -94,17 +94,17 @@ void lv_arc_set_start_angle(lv_obj_t * obj, uint16_t start)
if(start > 360) start -= 360; if(start > 360) start -= 360;
/*Too large move, the whole arc need to be invalidated anyway*/ /*Too large move, the whole arc need to be invalidated anyway*/
if(LV_MATH_ABS(start -arc->indic_angle_start) >= 180) { if(LV_ABS(start -arc->indic_angle_start) >= 180) {
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
} }
/*Only a smaller incremental move*/ /*Only a smaller incremental move*/
else if(arc->indic_angle_start >arc->indic_angle_end && start >arc->indic_angle_end) { else if(arc->indic_angle_start >arc->indic_angle_end && start >arc->indic_angle_end) {
inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_start, start), LV_MATH_MAX(arc->indic_angle_start, start), inv_arc_area(obj, LV_MIN(arc->indic_angle_start, start), LV_MAX(arc->indic_angle_start, start),
LV_PART_INDICATOR); LV_PART_INDICATOR);
} }
/*Only a smaller incremental move*/ /*Only a smaller incremental move*/
else if(arc->indic_angle_start <arc->indic_angle_end && start <arc->indic_angle_end) { else if(arc->indic_angle_start <arc->indic_angle_end && start <arc->indic_angle_end) {
inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_start, start), LV_MATH_MAX(arc->indic_angle_start, start), inv_arc_area(obj, LV_MIN(arc->indic_angle_start, start), LV_MAX(arc->indic_angle_start, start),
LV_PART_INDICATOR); LV_PART_INDICATOR);
} }
/*Crossing the start angle makes the whole arc change*/ /*Crossing the start angle makes the whole arc change*/
@@ -128,16 +128,16 @@ void lv_arc_set_end_angle(lv_obj_t * obj, uint16_t end)
if(end > (arc->indic_angle_start + 360)) end =arc->indic_angle_start + 360; if(end > (arc->indic_angle_start + 360)) end =arc->indic_angle_start + 360;
/*Too large move, the whole arc need to be invalidated anyway*/ /*Too large move, the whole arc need to be invalidated anyway*/
if(LV_MATH_ABS(end -arc->indic_angle_end) >= 180) { if(LV_ABS(end -arc->indic_angle_end) >= 180) {
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
} }
/*Only a smaller incremental move*/ /*Only a smaller incremental move*/
else if(arc->indic_angle_end >arc->indic_angle_start && end >arc->indic_angle_start) { else if(arc->indic_angle_end >arc->indic_angle_start && end >arc->indic_angle_start) {
inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_end, end), LV_MATH_MAX(arc->indic_angle_end, end), LV_PART_INDICATOR); inv_arc_area(obj, LV_MIN(arc->indic_angle_end, end), LV_MAX(arc->indic_angle_end, end), LV_PART_INDICATOR);
} }
/*Only a smaller incremental move*/ /*Only a smaller incremental move*/
else if(arc->indic_angle_end <arc->indic_angle_start && end <arc->indic_angle_start) { else if(arc->indic_angle_end <arc->indic_angle_start && end <arc->indic_angle_start) {
inv_arc_area(obj, LV_MATH_MIN(arc->indic_angle_end, end), LV_MATH_MAX(arc->indic_angle_end, end), LV_PART_INDICATOR); inv_arc_area(obj, LV_MIN(arc->indic_angle_end, end), LV_MAX(arc->indic_angle_end, end), LV_PART_INDICATOR);
} }
/*Crossing the end angle makes the whole arc change*/ /*Crossing the end angle makes the whole arc change*/
else { else {
@@ -183,16 +183,16 @@ void lv_arc_set_bg_start_angle(lv_obj_t * obj, uint16_t start)
if(start > 360) start -= 360; if(start > 360) start -= 360;
/*Too large move, the whole arc need to be invalidated anyway*/ /*Too large move, the whole arc need to be invalidated anyway*/
if(LV_MATH_ABS(start -arc->bg_angle_start) >= 180) { if(LV_ABS(start -arc->bg_angle_start) >= 180) {
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
} }
/*Only a smaller incremental move*/ /*Only a smaller incremental move*/
else if(arc->bg_angle_start >arc->bg_angle_end && start >arc->bg_angle_end) { else if(arc->bg_angle_start >arc->bg_angle_end && start >arc->bg_angle_end) {
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_start, start), LV_MATH_MAX(arc->bg_angle_start, start), LV_PART_MAIN); inv_arc_area(obj, LV_MIN(arc->bg_angle_start, start), LV_MAX(arc->bg_angle_start, start), LV_PART_MAIN);
} }
/*Only a smaller incremental move*/ /*Only a smaller incremental move*/
else if(arc->bg_angle_start <arc->bg_angle_end && start <arc->bg_angle_end) { else if(arc->bg_angle_start <arc->bg_angle_end && start <arc->bg_angle_end) {
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_start, start), LV_MATH_MAX(arc->bg_angle_start, start), LV_PART_MAIN); inv_arc_area(obj, LV_MIN(arc->bg_angle_start, start), LV_MAX(arc->bg_angle_start, start), LV_PART_MAIN);
} }
/*Crossing the start angle makes the whole arc change*/ /*Crossing the start angle makes the whole arc change*/
else { else {
@@ -218,16 +218,16 @@ void lv_arc_set_bg_end_angle(lv_obj_t * obj, uint16_t end)
if(end > (arc->bg_angle_start + 360)) end =arc->bg_angle_start + 360; if(end > (arc->bg_angle_start + 360)) end =arc->bg_angle_start + 360;
/*Too large move, the whole arc need to be invalidated anyway*/ /*Too large move, the whole arc need to be invalidated anyway*/
if(LV_MATH_ABS(end -arc->bg_angle_end) >= 180) { if(LV_ABS(end -arc->bg_angle_end) >= 180) {
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
} }
/*Only a smaller incremental move*/ /*Only a smaller incremental move*/
else if(arc->bg_angle_end >arc->bg_angle_start && end >arc->bg_angle_start) { else if(arc->bg_angle_end >arc->bg_angle_start && end >arc->bg_angle_start) {
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_end, end), LV_MATH_MAX(arc->bg_angle_end, end), LV_PART_MAIN); inv_arc_area(obj, LV_MIN(arc->bg_angle_end, end), LV_MAX(arc->bg_angle_end, end), LV_PART_MAIN);
} }
/*Only a smaller incremental move*/ /*Only a smaller incremental move*/
else if(arc->bg_angle_end <arc->bg_angle_start && end <arc->bg_angle_start) { else if(arc->bg_angle_end <arc->bg_angle_start && end <arc->bg_angle_start) {
inv_arc_area(obj, LV_MATH_MIN(arc->bg_angle_end, end), LV_MATH_MAX(arc->bg_angle_end, end), LV_PART_MAIN); inv_arc_area(obj, LV_MIN(arc->bg_angle_end, end), LV_MAX(arc->bg_angle_end, end), LV_PART_MAIN);
} }
/*Crossing the end angle makes the whole arc change*/ /*Crossing the end angle makes the whole arc change*/
else { else {
@@ -506,29 +506,19 @@ static lv_draw_res_t lv_arc_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv
lv_arc_t * arc = (lv_arc_t *)obj; lv_arc_t * arc = (lv_arc_t *)obj;
lv_obj_draw_hook_dsc_t hook_dsc;
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
lv_point_t center; lv_point_t center;
lv_coord_t arc_r; lv_coord_t arc_r;
get_center(obj, &center, &arc_r); get_center(obj, &center, &arc_r);
/*Draw the background arc*/ /*Draw the background arc*/
lv_draw_line_dsc_t arc_dsc; lv_draw_arc_dsc_t arc_dsc;
if(arc_r > 0) { if(arc_r > 0) {
lv_draw_line_dsc_init(&arc_dsc); lv_draw_arc_dsc_init(&arc_dsc);
lv_obj_init_draw_line_dsc(obj, LV_PART_MAIN, &arc_dsc); lv_obj_init_draw_arc_dsc(obj, LV_PART_MAIN, &arc_dsc);
hook_dsc.part = LV_PART_MAIN;
hook_dsc.line_dsc = &arc_dsc;
lv_event_send(obj,LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
lv_draw_arc(center.x, center.y, arc_r,arc->bg_angle_start +arc->angle_ofs, lv_draw_arc(center.x, center.y, arc_r,arc->bg_angle_start +arc->angle_ofs,
arc->bg_angle_end + arc->angle_ofs, clip_area, arc->bg_angle_end + arc->angle_ofs, clip_area,
&arc_dsc); &arc_dsc);
lv_event_send(obj,LV_EVENT_DRAW_PART_END, &hook_dsc);
} }
@@ -537,21 +527,15 @@ static lv_draw_res_t lv_arc_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv
lv_coord_t right_indic = lv_obj_get_style_pad_right(obj, LV_PART_INDICATOR); lv_coord_t right_indic = lv_obj_get_style_pad_right(obj, LV_PART_INDICATOR);
lv_coord_t top_indic = lv_obj_get_style_pad_top(obj, LV_PART_INDICATOR); lv_coord_t top_indic = lv_obj_get_style_pad_top(obj, LV_PART_INDICATOR);
lv_coord_t bottom_indic = lv_obj_get_style_pad_bottom(obj, LV_PART_INDICATOR); lv_coord_t bottom_indic = lv_obj_get_style_pad_bottom(obj, LV_PART_INDICATOR);
lv_coord_t indic_r = arc_r - LV_MATH_MAX4(left_indic, right_indic, top_indic, bottom_indic); lv_coord_t indic_r = arc_r - LV_MAX4(left_indic, right_indic, top_indic, bottom_indic);
if(indic_r > 0) { if(indic_r > 0) {
lv_draw_line_dsc_init(&arc_dsc); lv_draw_arc_dsc_init(&arc_dsc);
lv_obj_init_draw_line_dsc(obj, LV_PART_INDICATOR, &arc_dsc); lv_obj_init_draw_arc_dsc(obj, LV_PART_INDICATOR, &arc_dsc);
hook_dsc.part = LV_PART_INDICATOR;
hook_dsc.line_dsc = &arc_dsc;
lv_event_send(obj,LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
lv_draw_arc(center.x, center.y, indic_r,arc->indic_angle_start +arc->angle_ofs, lv_draw_arc(center.x, center.y, indic_r,arc->indic_angle_start +arc->angle_ofs,
arc->indic_angle_end +arc->angle_ofs, clip_area, arc->indic_angle_end +arc->angle_ofs, clip_area,
&arc_dsc); &arc_dsc);
lv_event_send(obj,LV_EVENT_DRAW_PART_END, &hook_dsc);
} }
if(arc->adjustable) { if(arc->adjustable) {
@@ -562,13 +546,7 @@ static lv_draw_res_t lv_arc_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv
lv_draw_rect_dsc_init(&knob_rect_dsc); lv_draw_rect_dsc_init(&knob_rect_dsc);
lv_obj_init_draw_rect_dsc(obj, LV_PART_KNOB, &knob_rect_dsc); lv_obj_init_draw_rect_dsc(obj, LV_PART_KNOB, &knob_rect_dsc);
hook_dsc.part = LV_PART_KNOB;
hook_dsc.rect_dsc = &knob_rect_dsc;
lv_event_send(obj,LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
lv_draw_rect(&knob_area, clip_area, &knob_rect_dsc); lv_draw_rect(&knob_area, clip_area, &knob_rect_dsc);
lv_event_send(obj,LV_EVENT_DRAW_PART_END, &hook_dsc);
} }
} }
@@ -642,7 +620,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
} }
angle = _lv_atan2(p.y, p.x); angle = lv_atan2(p.y, p.x);
angle -=arc->angle_ofs; angle -=arc->angle_ofs;
angle -=arc->bg_angle_start; /*Make the angle relative to the start angle*/ angle -=arc->bg_angle_start; /*Make the angle relative to the start angle*/
if(angle < 0) angle += 360; if(angle < 0) angle += 360;
@@ -655,7 +633,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
/* Do not allow big jumps. /* Do not allow big jumps.
* It's mainly to avoid jumping to the opposite end if the "dead" range between min. an max. is crossed. * It's mainly to avoid jumping to the opposite end if the "dead" range between min. an max. is crossed.
* Check which and was closer on the last valid press (arc->min_close) and prefer that end */ * Check which and was closer on the last valid press (arc->min_close) and prefer that end */
if(LV_MATH_ABS(delta_angle) > 180) { if(LV_ABS(delta_angle) > 180) {
if(arc->min_close) angle = 0; if(arc->min_close) angle = 0;
else angle = deg_range; else angle = deg_range;
} }
@@ -687,7 +665,7 @@ static lv_res_t lv_arc_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
/*Set the new value*/ /*Set the new value*/
int16_t old_value =arc->value; int16_t old_value =arc->value;
int16_t new_value = _lv_map(angle,arc->bg_angle_start, bg_end,arc->min_value,arc->max_value); int16_t new_value = lv_map(angle,arc->bg_angle_start, bg_end,arc->min_value,arc->max_value);
if(new_value != lv_arc_get_value(obj)) { if(new_value != lv_arc_get_value(obj)) {
arc->last_tick = lv_tick_get(); /*Cache timestamp for the next iteration*/ arc->last_tick = lv_tick_get(); /*Cache timestamp for the next iteration*/
lv_arc_set_value(obj, new_value); /*set_value caches the last_angle for the next iteration*/ lv_arc_set_value(obj, new_value); /*set_value caches the last_angle for the next iteration*/
@@ -765,7 +743,7 @@ static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angl
lv_coord_t right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN); lv_coord_t right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
lv_coord_t bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN); lv_coord_t bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
lv_coord_t rout = (LV_MATH_MIN(lv_obj_get_width(obj) - left - right, lv_obj_get_height(obj) - top - bottom)) / 2; lv_coord_t rout = (LV_MIN(lv_obj_get_width(obj) - left - right, lv_obj_get_height(obj) - top - bottom)) / 2;
lv_coord_t x = obj->coords.x1 + rout + left; lv_coord_t x = obj->coords.x1 + rout + left;
lv_coord_t y = obj->coords.y1 + rout + top; lv_coord_t y = obj->coords.y1 + rout + top;
lv_coord_t w = lv_obj_get_style_line_width(obj, part); lv_coord_t w = lv_obj_get_style_line_width(obj, part);
@@ -783,9 +761,9 @@ static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angl
lv_coord_t knob_top = lv_obj_get_style_pad_top(obj, LV_PART_KNOB); lv_coord_t knob_top = lv_obj_get_style_pad_top(obj, LV_PART_KNOB);
lv_coord_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB); lv_coord_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB);
knob_extra_size += LV_MATH_MAX4(knob_left, knob_right, knob_top, knob_bottom); knob_extra_size += LV_MAX4(knob_left, knob_right, knob_top, knob_bottom);
extra_area = LV_MATH_MAX(extra_area, w / 2 + 2 + knob_extra_size); extra_area = LV_MAX(extra_area, w / 2 + 2 + knob_extra_size);
} }
@@ -793,74 +771,74 @@ static void inv_arc_area(lv_obj_t * obj, uint16_t start_angle, uint16_t end_angl
if(start_quarter == end_quarter && start_angle <= end_angle) { if(start_quarter == end_quarter && start_angle <= end_angle) {
if(start_quarter == 0) { if(start_quarter == 0) {
inv_area.y1 = y + ((_lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) - extra_area; inv_area.y1 = y + ((lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.x2 = x + ((_lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; inv_area.x2 = x + ((lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.y2 = y + ((_lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; inv_area.y2 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.x1 = x + ((_lv_trigo_sin(end_angle + 90) * rin) >> LV_TRIGO_SHIFT) - extra_area; inv_area.x1 = x + ((lv_trigo_sin(end_angle + 90) * rin) >> LV_TRIGO_SHIFT) - extra_area;
lv_obj_invalidate_area(obj, &inv_area); lv_obj_invalidate_area(obj, &inv_area);
} }
else if(start_quarter == 1) { else if(start_quarter == 1) {
inv_area.y2 = y + ((_lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; inv_area.y2 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.x2 = x + ((_lv_trigo_sin(start_angle + 90) * rin) >> LV_TRIGO_SHIFT) + extra_area; inv_area.x2 = x + ((lv_trigo_sin(start_angle + 90) * rin) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.y1 = y + ((_lv_trigo_sin(end_angle) * rin) >> LV_TRIGO_SHIFT) - extra_area; inv_area.y1 = y + ((lv_trigo_sin(end_angle) * rin) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.x1 = x + ((_lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; inv_area.x1 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area;
lv_obj_invalidate_area(obj, &inv_area); lv_obj_invalidate_area(obj, &inv_area);
} }
else if(start_quarter == 2) { else if(start_quarter == 2) {
inv_area.x1 = x + ((_lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; inv_area.x1 = x + ((lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.y2 = y + ((_lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area; inv_area.y2 = y + ((lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.y1 = y + ((_lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; inv_area.y1 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.x2 = x + ((_lv_trigo_sin(end_angle + 90) * rin) >> LV_TRIGO_SHIFT) + extra_area; inv_area.x2 = x + ((lv_trigo_sin(end_angle + 90) * rin) >> LV_TRIGO_SHIFT) + extra_area;
lv_obj_invalidate_area(obj, &inv_area); lv_obj_invalidate_area(obj, &inv_area);
} }
else if(start_quarter == 3) { else if(start_quarter == 3) {
/*Small arc here*/ /*Small arc here*/
inv_area.x1 = x + ((_lv_trigo_sin(start_angle + 90) * rin) >> LV_TRIGO_SHIFT) - extra_area; inv_area.x1 = x + ((lv_trigo_sin(start_angle + 90) * rin) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.y1 = y + ((_lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; inv_area.y1 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.x2 = x + ((_lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; inv_area.x2 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.y2 = y + ((_lv_trigo_sin(end_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area; inv_area.y2 = y + ((lv_trigo_sin(end_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area;
lv_obj_invalidate_area(obj, &inv_area); lv_obj_invalidate_area(obj, &inv_area);
} }
} }
else if(start_quarter == 0 && end_quarter == 1) { else if(start_quarter == 0 && end_quarter == 1) {
inv_area.x1 = x + ((_lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; inv_area.x1 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.y1 = y + ((LV_MATH_MIN(_lv_trigo_sin(end_angle), inv_area.y1 = y + ((LV_MIN(lv_trigo_sin(end_angle),
_lv_trigo_sin(start_angle)) * rin) >> LV_TRIGO_SHIFT) - extra_area; lv_trigo_sin(start_angle)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.x2 = x + ((_lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; inv_area.x2 = x + ((lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.y2 = y + rout + extra_area; inv_area.y2 = y + rout + extra_area;
lv_obj_invalidate_area(obj, &inv_area); lv_obj_invalidate_area(obj, &inv_area);
} }
else if(start_quarter == 1 && end_quarter == 2) { else if(start_quarter == 1 && end_quarter == 2) {
inv_area.x1 = x - rout - extra_area; inv_area.x1 = x - rout - extra_area;
inv_area.y1 = y + ((_lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; inv_area.y1 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.x2 = x + ((LV_MATH_MAX(_lv_trigo_sin(start_angle + 90), inv_area.x2 = x + ((LV_MAX(lv_trigo_sin(start_angle + 90),
_lv_trigo_sin(end_angle + 90)) * rin) >> LV_TRIGO_SHIFT) + extra_area; lv_trigo_sin(end_angle + 90)) * rin) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.y2 = y + ((_lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; inv_area.y2 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area;
lv_obj_invalidate_area(obj, &inv_area); lv_obj_invalidate_area(obj, &inv_area);
} }
else if(start_quarter == 2 && end_quarter == 3) { else if(start_quarter == 2 && end_quarter == 3) {
inv_area.x1 = x + ((_lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area; inv_area.x1 = x + ((lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.y1 = y - rout - extra_area; inv_area.y1 = y - rout - extra_area;
inv_area.x2 = x + ((_lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area; inv_area.x2 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
inv_area.y2 = y + (LV_MATH_MAX(_lv_trigo_sin(end_angle) * rin, inv_area.y2 = y + (LV_MAX(lv_trigo_sin(end_angle) * rin,
_lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area; lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area;
lv_obj_invalidate_area(obj, &inv_area); lv_obj_invalidate_area(obj, &inv_area);
} }
else if(start_quarter == 3 && end_quarter == 0) { else if(start_quarter == 3 && end_quarter == 0) {
inv_area.x1 = x + ((LV_MATH_MIN(_lv_trigo_sin(end_angle + 90), inv_area.x1 = x + ((LV_MIN(lv_trigo_sin(end_angle + 90),
_lv_trigo_sin(start_angle + 90)) * rin) >> LV_TRIGO_SHIFT) - extra_area; lv_trigo_sin(start_angle + 90)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.y1 = y + ((_lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area; inv_area.y1 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area;
inv_area.x2 = x + rout + extra_area; inv_area.x2 = x + rout + extra_area;
inv_area.y2 = y + ((_lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area; inv_area.y2 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area;
lv_obj_invalidate_area(obj, &inv_area); lv_obj_invalidate_area(obj, &inv_area);
} }
@@ -876,7 +854,7 @@ static void get_center(lv_obj_t * obj, lv_point_t * center, lv_coord_t * arc_r)
lv_coord_t top_bg = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); lv_coord_t top_bg = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
lv_coord_t bottom_bg = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN); lv_coord_t bottom_bg = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
lv_coord_t r = (LV_MATH_MIN(lv_obj_get_width(obj) - left_bg - right_bg, lv_coord_t r = (LV_MIN(lv_obj_get_width(obj) - left_bg - right_bg,
lv_obj_get_height(obj) - top_bg - bottom_bg)) / 2; lv_obj_get_height(obj) - top_bg - bottom_bg)) / 2;
*arc_r = r; *arc_r = r;
@@ -909,8 +887,8 @@ static void get_knob_area(lv_obj_t * obj, const lv_point_t * center, lv_coord_t
if(arc->value < range_midpoint) angle +=arc->indic_angle_start; if(arc->value < range_midpoint) angle +=arc->indic_angle_start;
else angle +=arc->indic_angle_end; else angle +=arc->indic_angle_end;
} }
lv_coord_t knob_x = (r * _lv_trigo_sin(angle + 90)) >> LV_TRIGO_SHIFT; lv_coord_t knob_x = (r * lv_trigo_sin(angle + 90)) >> LV_TRIGO_SHIFT;
lv_coord_t knob_y = (r * _lv_trigo_sin(angle)) >> LV_TRIGO_SHIFT; lv_coord_t knob_y = (r * lv_trigo_sin(angle)) >> LV_TRIGO_SHIFT;
lv_coord_t left_knob = lv_obj_get_style_pad_left(obj, LV_PART_KNOB); lv_coord_t left_knob = lv_obj_get_style_pad_left(obj, LV_PART_KNOB);
lv_coord_t right_knob = lv_obj_get_style_pad_right(obj, LV_PART_KNOB); lv_coord_t right_knob = lv_obj_get_style_pad_right(obj, LV_PART_KNOB);
@@ -942,22 +920,22 @@ static void value_update(lv_obj_t * obj)
range_midpoint = (int32_t)(arc->min_value +arc->max_value) / 2; range_midpoint = (int32_t)(arc->min_value +arc->max_value) / 2;
if(arc->value < range_midpoint) { if(arc->value < range_midpoint) {
angle = _lv_map(arc->value,arc->min_value, range_midpoint,arc->bg_angle_start, bg_midpoint); angle = lv_map(arc->value,arc->min_value, range_midpoint,arc->bg_angle_start, bg_midpoint);
lv_arc_set_start_angle(obj, angle); lv_arc_set_start_angle(obj, angle);
lv_arc_set_end_angle(obj, bg_midpoint); lv_arc_set_end_angle(obj, bg_midpoint);
} }
else { else {
angle = _lv_map(arc->value, range_midpoint,arc->max_value, bg_midpoint, bg_end); angle = lv_map(arc->value, range_midpoint,arc->max_value, bg_midpoint, bg_end);
lv_arc_set_start_angle(obj, bg_midpoint); lv_arc_set_start_angle(obj, bg_midpoint);
lv_arc_set_end_angle(obj, angle); lv_arc_set_end_angle(obj, angle);
} }
break; break;
case LV_ARC_TYPE_REVERSE: case LV_ARC_TYPE_REVERSE:
angle = _lv_map(arc->value,arc->min_value,arc->max_value,arc->bg_angle_start, bg_end); angle = lv_map(arc->value,arc->min_value,arc->max_value,arc->bg_angle_start, bg_end);
lv_arc_set_start_angle(obj, angle); lv_arc_set_start_angle(obj, angle);
break; break;
default: /** LV_ARC_TYPE_NORMAL*/ default: /** LV_ARC_TYPE_NORMAL*/
angle = _lv_map(arc->value,arc->min_value,arc->max_value,arc->bg_angle_start, bg_end); angle = lv_map(arc->value,arc->min_value,arc->max_value,arc->bg_angle_start, bg_end);
lv_arc_set_end_angle(obj, angle); lv_arc_set_end_angle(obj, angle);
lv_arc_set_start_angle(obj,arc->bg_angle_start); lv_arc_set_start_angle(obj,arc->bg_angle_start);
} }

View File

@@ -474,7 +474,7 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
if(!sym && indic_length_calc(&bar->indic_area) <= 1) return; if(!sym && indic_length_calc(&bar->indic_area) <= 1) return;
uint16_t bg_radius = lv_obj_get_style_radius(obj, LV_PART_MAIN); uint16_t bg_radius = lv_obj_get_style_radius(obj, LV_PART_MAIN);
lv_coord_t short_side = LV_MATH_MIN(barw, barh); lv_coord_t short_side = LV_MIN(barw, barh);
if(bg_radius > short_side >> 1) bg_radius = short_side >> 1; if(bg_radius > short_side >> 1) bg_radius = short_side >> 1;
lv_draw_rect_dsc_t draw_indic_dsc; lv_draw_rect_dsc_t draw_indic_dsc;
@@ -484,14 +484,6 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
lv_area_t indic_area; lv_area_t indic_area;
lv_area_copy(&indic_area, &bar->indic_area); lv_area_copy(&indic_area, &bar->indic_area);
/*Handle custom drawer*/
lv_obj_draw_hook_dsc_t hook_dsc;
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
hook_dsc.draw_area = &indic_area;
hook_dsc.part = LV_PART_INDICATOR;
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
/* Draw only the shadow if the indicator is long enough. /* Draw only the shadow if the indicator is long enough.
* The radius of the bg and the indicator can make a strange shape where * The radius of the bg and the indicator can make a strange shape where
* it'd be very difficult to draw shadow. */ * it'd be very difficult to draw shadow. */
@@ -560,9 +552,6 @@ static void draw_indic(lv_obj_t * obj, const lv_area_t * clip_area)
draw_indic_dsc.content_opa = content_opa; draw_indic_dsc.content_opa = content_opa;
draw_indic_dsc.border_opa = LV_OPA_TRANSP; draw_indic_dsc.border_opa = LV_OPA_TRANSP;
lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc); lv_draw_rect(&bar->indic_area, clip_area, &draw_indic_dsc);
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
} }
/** /**
@@ -587,7 +576,7 @@ static lv_res_t lv_bar_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
/*Bg size is handled by lv_obj*/ /*Bg size is handled by lv_obj*/
lv_coord_t * s = param; lv_coord_t * s = param;
*s = LV_MATH_MAX(*s, indic_size); *s = LV_MAX(*s, indic_size);
} }
return res; return res;

View File

@@ -200,7 +200,7 @@ void lv_btnmatrix_set_ctrl_map(lv_obj_t * obj, const lv_btnmatrix_ctrl_t ctrl_ma
LV_ASSERT_OBJ(obj, LV_OBJX_NAME); LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;
_lv_memcpy(btnm->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * btnm->btn_cnt); lv_memcpy(btnm->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * btnm->btn_cnt);
lv_btnmatrix_set_map(obj, btnm->map_p); lv_btnmatrix_set_map(obj, btnm->map_p);
} }
@@ -591,7 +591,7 @@ static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_ar
#if LV_USE_ARABIC_PERSIAN_CHARS #if LV_USE_ARABIC_PERSIAN_CHARS
const size_t txt_ap_size = 256 ; const size_t txt_ap_size = 256 ;
char * txt_ap = _lv_mem_buf_get(txt_ap_size); char * txt_ap = lv_mem_buf_get(txt_ap_size);
#endif #endif
lv_obj_draw_hook_dsc_t hook_dsc; lv_obj_draw_hook_dsc_t hook_dsc;
@@ -636,8 +636,8 @@ static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_ar
/*Set up the draw descriptors*/ /*Set up the draw descriptors*/
if(btn_state == LV_STATE_DEFAULT) { if(btn_state == LV_STATE_DEFAULT) {
_lv_memcpy(&draw_rect_dsc_act, &draw_rect_def_default, sizeof(lv_draw_rect_dsc_t)); lv_memcpy(&draw_rect_dsc_act, &draw_rect_def_default, sizeof(lv_draw_rect_dsc_t));
_lv_memcpy(&draw_label_dsc_act, &draw_label_def_default, sizeof(lv_draw_label_dsc_t)); lv_memcpy(&draw_label_dsc_act, &draw_label_def_default, sizeof(lv_draw_label_dsc_t));
} }
/*In other cases get the styles directly without caching them*/ /*In other cases get the styles directly without caching them*/
else { else {
@@ -698,7 +698,7 @@ static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_ar
obj->style_list.skip_trans = 0; obj->style_list.skip_trans = 0;
#if LV_USE_ARABIC_PERSIAN_CHARS #if LV_USE_ARABIC_PERSIAN_CHARS
_lv_mem_buf_release(txt_ap); lv_mem_buf_release(txt_ap);
#endif #endif
} }
else if(mode == LV_DRAW_MODE_POST_DRAW) { else if(mode == LV_DRAW_MODE_POST_DRAW) {
@@ -921,7 +921,7 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * par
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
} }
else if(c == LV_KEY_DOWN) { else if(c == LV_KEY_DOWN) {
lv_coord_t col_gap = LV_MATH_MAX(lv_obj_get_style_margin_left(obj, LV_BTNMATRIX_PART_BTN), lv_obj_get_style_margin_right(obj, LV_BTNMATRIX_PART_BTN)); lv_coord_t col_gap = LV_MAX(lv_obj_get_style_margin_left(obj, LV_BTNMATRIX_PART_BTN), lv_obj_get_style_margin_right(obj, LV_BTNMATRIX_PART_BTN));
/*Find the area below the the current*/ /*Find the area below the the current*/
if(btnm->btn_id_focused == LV_BTNMATRIX_BTN_NONE) { if(btnm->btn_id_focused == LV_BTNMATRIX_BTN_NONE) {
@@ -948,7 +948,7 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * par
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
} }
else if(c == LV_KEY_UP) { else if(c == LV_KEY_UP) {
lv_coord_t col_gap = LV_MATH_MAX(lv_obj_get_style_margin_left(obj, LV_BTNMATRIX_PART_BTN), lv_obj_get_style_margin_right(obj, LV_BTNMATRIX_PART_BTN)); lv_coord_t col_gap = LV_MAX(lv_obj_get_style_margin_left(obj, LV_BTNMATRIX_PART_BTN), lv_obj_get_style_margin_right(obj, LV_BTNMATRIX_PART_BTN));
/*Find the area below the the current*/ /*Find the area below the the current*/
if(btnm->btn_id_focused == LV_BTNMATRIX_BTN_NONE) { if(btnm->btn_id_focused == LV_BTNMATRIX_BTN_NONE) {
btnm->btn_id_focused = 0; btnm->btn_id_focused = 0;
@@ -1021,7 +1021,7 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * obj, const char **
LV_ASSERT_MEM(btnm->ctrl_bits); LV_ASSERT_MEM(btnm->ctrl_bits);
if(btnm->button_areas == NULL || btnm->ctrl_bits == NULL) btn_cnt = 0; 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); lv_memset_00(btnm->ctrl_bits, sizeof(lv_btnmatrix_ctrl_t) * btn_cnt);
btnm->btn_cnt = btn_cnt; btnm->btn_cnt = btn_cnt;
} }
@@ -1094,25 +1094,25 @@ static uint16_t get_button_from_point(lv_obj_t * obj, lv_point_t * p)
prow = (prow / 2) + 1 + (prow & 1); prow = (prow / 2) + 1 + (prow & 1);
pcol = (pcol / 2) + 1 + (pcol & 1); pcol = (pcol / 2) + 1 + (pcol & 1);
prow = LV_MATH_MIN(prow, BTN_EXTRA_CLICK_AREA_MAX); prow = LV_MIN(prow, BTN_EXTRA_CLICK_AREA_MAX);
pcol = LV_MATH_MIN(pcol, BTN_EXTRA_CLICK_AREA_MAX); pcol = LV_MIN(pcol, BTN_EXTRA_CLICK_AREA_MAX);
pright = LV_MATH_MIN(pright, BTN_EXTRA_CLICK_AREA_MAX); pright = LV_MIN(pright, BTN_EXTRA_CLICK_AREA_MAX);
ptop = LV_MATH_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX); ptop = LV_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX);
pbottom = LV_MATH_MIN(pbottom, BTN_EXTRA_CLICK_AREA_MAX); pbottom = LV_MIN(pbottom, BTN_EXTRA_CLICK_AREA_MAX);
for(i = 0; i < btnm->btn_cnt; i++) { for(i = 0; i < btnm->btn_cnt; i++) {
lv_area_copy(&btn_area, &btnm->button_areas[i]); lv_area_copy(&btn_area, &btnm->button_areas[i]);
if(btn_area.x1 <= pleft) btn_area.x1 += obj_cords.x1 - LV_MATH_MIN(pleft, BTN_EXTRA_CLICK_AREA_MAX); if(btn_area.x1 <= pleft) btn_area.x1 += obj_cords.x1 - LV_MIN(pleft, BTN_EXTRA_CLICK_AREA_MAX);
else btn_area.x1 += obj_cords.x1 - pcol; else btn_area.x1 += obj_cords.x1 - pcol;
if(btn_area.y1 <= ptop) btn_area.y1 += obj_cords.y1 - LV_MATH_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX); if(btn_area.y1 <= ptop) btn_area.y1 += obj_cords.y1 - LV_MIN(ptop, BTN_EXTRA_CLICK_AREA_MAX);
else btn_area.y1 += obj_cords.y1 - prow; else btn_area.y1 += obj_cords.y1 - prow;
if(btn_area.x2 >= w - pright - 2) btn_area.x2 += obj_cords.x1 + LV_MATH_MIN(pright, if(btn_area.x2 >= w - pright - 2) btn_area.x2 += obj_cords.x1 + LV_MIN(pright,
BTN_EXTRA_CLICK_AREA_MAX); /*-2 for rounding error*/ BTN_EXTRA_CLICK_AREA_MAX); /*-2 for rounding error*/
else btn_area.x2 += obj_cords.x1 + pcol; else btn_area.x2 += obj_cords.x1 + pcol;
if(btn_area.y2 >= h - pbottom - 2) btn_area.y2 += obj_cords.y1 + LV_MATH_MIN(pbottom, if(btn_area.y2 >= h - pbottom - 2) btn_area.y2 += obj_cords.y1 + LV_MIN(pbottom,
BTN_EXTRA_CLICK_AREA_MAX); /*-2 for rounding error*/ BTN_EXTRA_CLICK_AREA_MAX); /*-2 for rounding error*/
else btn_area.y2 += obj_cords.y1 + prow; else btn_area.y2 += obj_cords.y1 + prow;

View File

@@ -219,7 +219,7 @@ void lv_canvas_copy_buf(lv_obj_t * obj, const void * to_copy, lv_coord_t x, lv_c
uint8_t * to_copy8 = (uint8_t *)to_copy; uint8_t * to_copy8 = (uint8_t *)to_copy;
lv_coord_t i; lv_coord_t i;
for(i = 0; i < h; i++) { for(i = 0; i < h; i++) {
_lv_memcpy((void *)&canvas->dsc.data[px], to_copy8, w * px_size); lv_memcpy((void *)&canvas->dsc.data[px], to_copy8, w * px_size);
px += canvas->dsc.header.w * px_size; px += canvas->dsc.header.w * px_size;
to_copy8 += w * px_size; to_copy8 += w * px_size;
} }
@@ -383,7 +383,7 @@ void lv_canvas_blur_hor(lv_obj_t * obj, const lv_area_t * area, uint16_t r)
bool has_alpha = lv_img_cf_has_alpha(canvas->dsc.header.cf); bool has_alpha = lv_img_cf_has_alpha(canvas->dsc.header.cf);
lv_coord_t line_w = lv_img_buf_get_img_size(canvas->dsc.header.w, 1, canvas->dsc.header.cf); lv_coord_t line_w = lv_img_buf_get_img_size(canvas->dsc.header.w, 1, canvas->dsc.header.cf);
uint8_t * line_buf = _lv_mem_buf_get(line_w); uint8_t * line_buf = lv_mem_buf_get(line_w);
lv_img_dsc_t line_img; lv_img_dsc_t line_img;
line_img.data = line_buf; line_img.data = line_buf;
@@ -404,7 +404,7 @@ void lv_canvas_blur_hor(lv_obj_t * obj, const lv_area_t * area, uint16_t r)
lv_color_t c; lv_color_t c;
lv_opa_t opa = LV_OPA_TRANSP; lv_opa_t opa = LV_OPA_TRANSP;
_lv_memcpy(line_buf, &canvas->dsc.data[y * line_w], line_w); lv_memcpy(line_buf, &canvas->dsc.data[y * line_w], line_w);
for(x = a.x1 - r_back; x <= a.x1 + r_front; x++) { for(x = a.x1 - r_back; x <= a.x1 + r_front; x++) {
@@ -476,7 +476,7 @@ void lv_canvas_blur_hor(lv_obj_t * obj, const lv_area_t * area, uint16_t r)
} }
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
_lv_mem_buf_release(line_buf); lv_mem_buf_release(line_buf);
} }
@@ -518,7 +518,7 @@ void lv_canvas_blur_ver(lv_obj_t * obj, const lv_area_t * area, uint16_t r)
bool has_alpha = lv_img_cf_has_alpha(canvas->dsc.header.cf); bool has_alpha = lv_img_cf_has_alpha(canvas->dsc.header.cf);
lv_coord_t col_w = lv_img_buf_get_img_size(1, canvas->dsc.header.h, canvas->dsc.header.cf); lv_coord_t col_w = lv_img_buf_get_img_size(1, canvas->dsc.header.h, canvas->dsc.header.cf);
uint8_t * col_buf = _lv_mem_buf_get(col_w); uint8_t * col_buf = lv_mem_buf_get(col_w);
lv_img_dsc_t line_img; lv_img_dsc_t line_img;
line_img.data = col_buf; line_img.data = col_buf;
@@ -616,7 +616,7 @@ void lv_canvas_blur_ver(lv_obj_t * obj, const lv_area_t * area, uint16_t r)
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
_lv_mem_buf_release(col_buf); lv_mem_buf_release(col_buf);
} }
/** /**
@@ -634,11 +634,11 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa)
if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) { if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT) {
uint32_t row_byte_cnt = (dsc->header.w + 7) >> 3; uint32_t row_byte_cnt = (dsc->header.w + 7) >> 3;
/*+8 skip the palette*/ /*+8 skip the palette*/
_lv_memset((uint8_t *)dsc->data + 8, color.full ? 0xff : 0x00, row_byte_cnt * dsc->header.h); lv_memset((uint8_t *)dsc->data + 8, color.full ? 0xff : 0x00, row_byte_cnt * dsc->header.h);
} }
else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) { else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT) {
uint32_t row_byte_cnt = (dsc->header.w + 7) >> 3; uint32_t row_byte_cnt = (dsc->header.w + 7) >> 3;
_lv_memset((uint8_t *)dsc->data, opa > LV_OPA_50 ? 0xff : 0x00, row_byte_cnt * dsc->header.h); lv_memset((uint8_t *)dsc->data, opa > LV_OPA_50 ? 0xff : 0x00, row_byte_cnt * dsc->header.h);
} }
else { else {
uint32_t x; uint32_t x;
@@ -690,7 +690,7 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
coords.y2 = y + h - 1; coords.y2 = y + h - 1;
lv_disp_t disp; lv_disp_t disp;
_lv_memset_00(&disp, sizeof(lv_disp_t)); lv_memset_00(&disp, sizeof(lv_disp_t));
lv_disp_buf_t disp_buf; lv_disp_buf_t disp_buf;
lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h);
@@ -760,7 +760,7 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord
coords.y2 = dsc->header.h - 1; coords.y2 = dsc->header.h - 1;
lv_disp_t disp; lv_disp_t disp;
_lv_memset_00(&disp, sizeof(lv_disp_t)); lv_memset_00(&disp, sizeof(lv_disp_t));
lv_disp_buf_t disp_buf; lv_disp_buf_t disp_buf;
lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h);
@@ -824,7 +824,7 @@ void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const voi
coords.y2 = y + header.h - 1; coords.y2 = y + header.h - 1;
lv_disp_t disp; lv_disp_t disp;
_lv_memset_00(&disp, sizeof(lv_disp_t)); lv_memset_00(&disp, sizeof(lv_disp_t));
lv_disp_buf_t disp_buf; lv_disp_buf_t disp_buf;
lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h);
@@ -875,7 +875,7 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t
mask.y2 = dsc->header.h - 1; mask.y2 = dsc->header.h - 1;
lv_disp_t disp; lv_disp_t disp;
_lv_memset_00(&disp, sizeof(lv_disp_t)); lv_memset_00(&disp, sizeof(lv_disp_t));
lv_disp_buf_t disp_buf; lv_disp_buf_t disp_buf;
lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h);
@@ -939,7 +939,7 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32
mask.y2 = dsc->header.h - 1; mask.y2 = dsc->header.h - 1;
lv_disp_t disp; lv_disp_t disp;
_lv_memset_00(&disp, sizeof(lv_disp_t)); lv_memset_00(&disp, sizeof(lv_disp_t));
lv_disp_buf_t disp_buf; lv_disp_buf_t disp_buf;
lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h);
@@ -1003,7 +1003,7 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_
mask.y2 = dsc->header.h - 1; mask.y2 = dsc->header.h - 1;
lv_disp_t disp; lv_disp_t disp;
_lv_memset_00(&disp, sizeof(lv_disp_t)); lv_memset_00(&disp, sizeof(lv_disp_t));
lv_disp_buf_t disp_buf; lv_disp_buf_t disp_buf;
lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h);
@@ -1044,6 +1044,8 @@ static void lv_canvas_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ob
{ {
LV_LOG_TRACE("canvas create started"); LV_LOG_TRACE("canvas create started");
lv_obj_construct_base(obj, parent, copy);
lv_canvas_t * canvas = (lv_canvas_t *) obj; lv_canvas_t * canvas = (lv_canvas_t *) obj;
/*Initialize the allocated 'ext' */ /*Initialize the allocated 'ext' */

View File

@@ -47,8 +47,8 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area);
static void draw_series_column(lv_obj_t * obj, const lv_area_t * clip_area); static void draw_series_column(lv_obj_t * obj, const lv_area_t * clip_area);
static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area); static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area);
static void draw_axes(lv_obj_t * obj, const lv_area_t * mask); static void draw_axes(lv_obj_t * obj, const lv_area_t * mask);
static void invalidate_lines(lv_obj_t * obj, uint16_t i); static uint32_t get_index_from_x(lv_obj_t * obj, lv_coord_t x);
static void invalidate_columns(lv_obj_t * obj, uint16_t i); static void invalidate_point(lv_obj_t * obj, uint16_t i);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
@@ -392,8 +392,7 @@ void lv_chart_set_next(lv_obj_t * obj, lv_chart_series_t * ser, lv_coord_t y)
else if(chart->update_mode == LV_CHART_UPDATE_MODE_CIRCULAR) { else if(chart->update_mode == LV_CHART_UPDATE_MODE_CIRCULAR) {
ser->points[ser->start_point] = y; ser->points[ser->start_point] = y;
if(chart->type & LV_CHART_TYPE_LINE) invalidate_lines(obj, ser->start_point); invalidate_point(obj, ser->start_point);
if(chart->type & LV_CHART_TYPE_COLUMN) invalidate_columns(obj, ser->start_point);
ser->start_point = (ser->start_point + 1) % chart->point_cnt; /*update the x for next incoming y*/ ser->start_point = (ser->start_point + 1) % chart->point_cnt; /*update the x for next incoming y*/
} }
@@ -625,25 +624,6 @@ lv_point_t lv_chart_get_cursor_point(lv_obj_t * obj, lv_chart_cursor_t * cursor)
return cursor->point; return cursor->point;
} }
/**
* Get the nearest index to an X coordinate
* @param chart pointer to a chart object
* @param coord the coordination of the point relative to the series area.
* @return the found index
*/
uint16_t lv_chart_get_nearest_index_from_coord(lv_obj_t * obj, lv_coord_t x)
{
lv_coord_t w = lv_obj_get_width(obj);
lv_chart_t * chart = (lv_chart_t *)obj;
if(x < 0) return 0;
if(x > w) return chart->point_cnt - 1;
if(chart->type == LV_CHART_TYPE_LINE) return (x * (chart->point_cnt - 1) + w / 2) / w;
if(chart->type == LV_CHART_TYPE_COLUMN) return (x * chart->point_cnt) / w;
return 0;
}
/** /**
* Get the x coordinate of the an index with respect * Get the x coordinate of the an index with respect
* to the origin of series area of the chart. * to the origin of series area of the chart.
@@ -777,8 +757,8 @@ static void lv_chart_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj
chart->hdiv_cnt = chart_copy->hdiv_cnt; chart->hdiv_cnt = chart_copy->hdiv_cnt;
chart->vdiv_cnt = chart_copy->vdiv_cnt; chart->vdiv_cnt = chart_copy->vdiv_cnt;
chart->point_cnt = chart_copy->point_cnt; chart->point_cnt = chart_copy->point_cnt;
_lv_memcpy_small(chart->ymin, chart_copy->ymin, sizeof(chart->ymin)); lv_memcpy_small(chart->ymin, chart_copy->ymin, sizeof(chart->ymin));
_lv_memcpy_small(chart->ymax, chart_copy->ymax, sizeof(chart->ymax)); lv_memcpy_small(chart->ymax, chart_copy->ymax, sizeof(chart->ymax));
} }
LV_LOG_INFO("chart created"); LV_LOG_INFO("chart created");
} }
@@ -832,7 +812,8 @@ static lv_draw_res_t lv_chart_draw(lv_obj_t * obj, const lv_area_t * clip_area,
lv_chart_t * chart = (lv_chart_t *)obj; lv_chart_t * chart = (lv_chart_t *)obj;
if(chart->type & LV_CHART_TYPE_LINE) draw_series_line(obj, clip_area); if(chart->type & LV_CHART_TYPE_LINE) draw_series_line(obj, clip_area);
if(chart->type & LV_CHART_TYPE_COLUMN) draw_series_column(obj, clip_area); else if(chart->type & LV_CHART_TYPE_COLUMN) draw_series_column(obj, clip_area);
draw_cursors(obj, clip_area); draw_cursors(obj, clip_area);
} }
else if(mode == LV_DRAW_MODE_POST_DRAW) { else if(mode == LV_DRAW_MODE_POST_DRAW) {
@@ -861,7 +842,22 @@ static lv_res_t lv_chart_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
p->y = (lv_obj_get_height(obj) * chart->y_zoom) >> 8; p->y = (lv_obj_get_height(obj) * chart->y_zoom) >> 8;
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { } else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
lv_coord_t * s = param; lv_coord_t * s = param;
*s = LV_MATH_MAX(*s, chart->ext_size); *s = LV_MAX(*s, chart->ext_size);
} else if(sign == LV_SIGNAL_PRESSING) {
lv_indev_t * indev = lv_indev_get_act();
lv_point_t p;
lv_indev_get_point(indev, &p);
p.x -= obj->coords.x1;
uint32_t id = get_index_from_x(obj, p.x);
if(id != chart->pressed_point_id) {
invalidate_point(obj, id);
invalidate_point(obj, chart->pressed_point_id);
chart->pressed_point_id = id;
}
} else if(sign == LV_SIGNAL_PRESSING) {
invalidate_point(obj, chart->pressed_point_id);
chart->pressed_point_id = -1;
} }
return res; return res;
@@ -939,45 +935,33 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
bool mask_ret = _lv_area_intersect(&series_mask, &obj->coords, clip_area); bool mask_ret = _lv_area_intersect(&series_mask, &obj->coords, clip_area);
if(mask_ret == false) return; if(mask_ret == false) return;
lv_draw_line_dsc_t line_dsc; lv_state_t state_ori = obj->state;
lv_draw_line_dsc_init(&line_dsc); obj->state = LV_STATE_DEFAULT;
lv_obj_init_draw_line_dsc(obj, LV_PART_ITEMS, &line_dsc); lv_draw_line_dsc_t line_dsc_default;
lv_draw_line_dsc_init(&line_dsc_default);
lv_obj_init_draw_line_dsc(obj, LV_PART_ITEMS, &line_dsc_default);
lv_draw_mask_fade_param_t mask_fade_p; lv_draw_rect_dsc_t point_dsc_default;
int16_t mask_fade_id = LV_MASK_ID_INV; lv_draw_rect_dsc_init(&point_dsc_default);
lv_draw_rect_dsc_t area_dsc; point_dsc_default.radius = LV_RADIUS_CIRCLE;
bool has_area = lv_obj_get_style_bg_opa(obj, LV_PART_ITEMS) > LV_OPA_MIN ? true : false;
bool has_fade = false;
if(has_area) {
lv_draw_rect_dsc_init(&area_dsc);
lv_obj_init_draw_rect_dsc(obj, LV_PART_ITEMS, &area_dsc);
area_dsc.border_width = 0;
has_fade = area_dsc.bg_grad_dir == LV_GRAD_DIR_VER ? true : false; lv_coord_t point_size = lv_obj_get_style_size(obj, LV_PART_ITEMS);
if(has_fade) {
lv_draw_mask_fade_init(&mask_fade_p, &obj->coords, area_dsc.bg_main_color_stop, obj->coords.y1,
area_dsc.bg_grad_color_stop, obj->coords.y2);
}
}
lv_draw_rect_dsc_t point_dsc; obj->state = LV_STATE_PRESSED;
lv_draw_rect_dsc_init(&point_dsc); lv_coord_t point_size_pr = lv_obj_get_style_size(obj, LV_PART_ITEMS);
point_dsc.bg_opa = line_dsc.opa;
point_dsc.radius = LV_RADIUS_CIRCLE;
obj->state = state_ori;
lv_coord_t point_radius = 5;//lv_obj_get_style_size(obj, LV_PART_ITEMS); lv_coord_t point_size_act;
/*Do not bother with line ending is the point will over it*/ /*Do not bother with line ending is the point will over it*/
if(point_radius > line_dsc.width / 2) line_dsc.raw_end = 1; if(point_size > line_dsc_default.width / 2) line_dsc_default.raw_end = 1;
/*Go through all data lines*/ /*Go through all data lines*/
_LV_LL_READ_BACK(&chart->series_ll, ser) { _LV_LL_READ_BACK(&chart->series_ll, ser) {
if (ser->hidden) continue; if (ser->hidden) continue;
line_dsc.color = ser->color; line_dsc_default.color = ser->color;
point_dsc.bg_color = ser->color; point_dsc_default.bg_color = ser->color;
area_dsc.bg_color = ser->color;
area_dsc.bg_grad_color = ser->color;
lv_coord_t start_point = chart->update_mode == LV_CHART_UPDATE_MODE_SHIFT ? ser->start_point : 0; lv_coord_t start_point = chart->update_mode == LV_CHART_UPDATE_MODE_SHIFT ? ser->start_point : 0;
@@ -990,11 +974,19 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
y_tmp = y_tmp / (chart->ymax[ser->y_axis] - chart->ymin[ser->y_axis]); y_tmp = y_tmp / (chart->ymax[ser->y_axis] - chart->ymin[ser->y_axis]);
p2.y = h - y_tmp + y_ofs; p2.y = h - y_tmp + y_ofs;
lv_obj_draw_hook_dsc_t hook_dsc;
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
hook_dsc.part = LV_PART_ITEMS;
hook_dsc.line_dsc = &line_dsc_default;
hook_dsc.rect_dsc = &point_dsc_default;
for(i = 0; i < chart->point_cnt; i++) { for(i = 0; i < chart->point_cnt; i++) {
p1.x = p2.x; p1.x = p2.x;
p1.y = p2.y; p1.y = p2.y;
if(p1.x > obj->coords.x2 + point_radius) break; point_size_act = p_act == chart->pressed_point_id ? point_size_pr : point_size;
if(p1.x > clip_area->x2 + point_size_act) break;
p2.x = ((w * i) / (chart->point_cnt - 1)) + x_ofs; p2.x = ((w * i) / (chart->point_cnt - 1)) + x_ofs;
p_act = (start_point + i) % chart->point_cnt; p_act = (start_point + i) % chart->point_cnt;
@@ -1003,67 +995,53 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
y_tmp = y_tmp / (chart->ymax[ser->y_axis] - chart->ymin[ser->y_axis]); y_tmp = y_tmp / (chart->ymax[ser->y_axis] - chart->ymin[ser->y_axis]);
p2.y = h - y_tmp + y_ofs; p2.y = h - y_tmp + y_ofs;
if(p2.x < obj->coords.x1 - point_radius) continue; if(p2.x < clip_area->x1 - point_size_act) continue;
hook_dsc.id = p_act;
hook_dsc.p1 = &p1;
hook_dsc.p2 = &p2;
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
/*Don't draw the first point. A second point is also required to draw the line*/ /*Don't draw the first point. A second point is also required to draw the line*/
if(i != 0 && ser->points[p_prev] != LV_CHART_POINT_DEF && ser->points[p_act] != LV_CHART_POINT_DEF) { if(i != 0 && ser->points[p_prev] != LV_CHART_POINT_DEF && ser->points[p_act] != LV_CHART_POINT_DEF) {
lv_draw_line(&p1, &p2, &series_mask, &line_dsc); lv_draw_line(&p1, &p2, &series_mask, &line_dsc_default);
lv_coord_t y_top = LV_MATH_MIN(p1.y, p2.y);
if(has_area && y_top <= clip_area->y2) {
int16_t mask_line_id;
lv_draw_mask_line_param_t mask_line_p;
lv_draw_mask_line_points_init(&mask_line_p, p1.x, p1.y, p2.x, p2.y, LV_DRAW_MASK_LINE_SIDE_BOTTOM);
mask_line_id = lv_draw_mask_add(&mask_line_p, NULL);
lv_area_t a;
a.x1 = p1.x;
a.x2 = p2.x - 1;
a.y1 = y_top;
a.y2 = obj->coords.y2;
if(has_fade) mask_fade_id = lv_draw_mask_add(&mask_fade_p, NULL);
lv_draw_rect(&a, &series_mask, &area_dsc);
lv_draw_mask_remove_id(mask_line_id);
lv_draw_mask_remove_id(mask_fade_id);
}
} }
if(point_radius) { if(point_size_act) {
lv_area_t point_area; lv_area_t point_area;
point_area.x1 = p1.x; point_area.x1 = p1.x;
point_area.x2 = point_area.x1 + point_radius; point_area.x2 = point_area.x1 + point_size_act;
point_area.x1 -= point_radius; point_area.x1 -= point_size_act;
point_area.y1 = p1.y; point_area.y1 = p1.y;
point_area.y2 = point_area.y1 + point_radius; point_area.y2 = point_area.y1 + point_size_act;
point_area.y1 -= point_radius; point_area.y1 -= point_size_act;
if(ser->points[p_act] != LV_CHART_POINT_DEF) { if(ser->points[p_act] != LV_CHART_POINT_DEF) {
lv_draw_rect(&point_area, &series_mask, &point_dsc); lv_draw_rect(&point_area, &series_mask, &point_dsc_default);
} }
} }
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
p_prev = p_act; p_prev = p_act;
} }
/*Draw the last point*/ /*Draw the last point*/
if(point_radius) { if(point_size) {
lv_area_t point_area; lv_area_t point_area;
point_area.x1 = p2.x; point_area.x1 = p2.x;
point_area.x2 = point_area.x1 + point_radius; point_area.x2 = point_area.x1 + point_size;
point_area.x1 -= point_radius; point_area.x1 -= point_size;
point_area.y1 = p2.y; point_area.y1 = p2.y;
point_area.y2 = point_area.y1 + point_radius; point_area.y2 = point_area.y1 + point_size;
point_area.y1 -= point_radius; point_area.y1 -= point_size;
if(ser->points[p_act] != LV_CHART_POINT_DEF) { if(ser->points[p_act] != LV_CHART_POINT_DEF) {
lv_draw_rect(&point_area, &series_mask, &point_dsc); lv_draw_rect(&point_area, &series_mask, &point_dsc_default);
} }
} }
} }
@@ -1164,7 +1142,7 @@ static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area)
point_dsc.bg_opa = line_dsc.opa; point_dsc.bg_opa = line_dsc.opa;
point_dsc.radius = LV_RADIUS_CIRCLE; point_dsc.radius = LV_RADIUS_CIRCLE;
lv_coord_t point_radius = 5;//lv_obj_get_style_size(chart, LV_PART_CURSOR); lv_coord_t point_radius = lv_obj_get_style_size(chart, LV_PART_CURSOR);
/*Do not bother with line ending is the point will over it*/ /*Do not bother with line ending is the point will over it*/
if(point_radius > line_dsc.width / 2) line_dsc.raw_end = 1; if(point_radius > line_dsc.width / 2) line_dsc.raw_end = 1;
@@ -1403,64 +1381,76 @@ static void draw_axes(lv_obj_t * obj, const lv_area_t * mask)
draw_y_ticks(obj, mask, LV_CHART_AXIS_SECONDARY_Y); draw_y_ticks(obj, mask, LV_CHART_AXIS_SECONDARY_Y);
draw_x_ticks(obj, mask); draw_x_ticks(obj, mask);
} }
/**
* Get the nearest index to an X coordinate
* @param chart pointer to a chart object
* @param coord the coordination of the point relative to the series area.
* @return the found index
*/
static uint32_t get_index_from_x(lv_obj_t * obj, lv_coord_t x)
{
lv_coord_t w = lv_obj_get_width(obj);
lv_chart_t * chart = (lv_chart_t *)obj;
if(x < 0) return 0;
if(x > w) return chart->point_cnt - 1;
if(chart->type == LV_CHART_TYPE_LINE) return (x * (chart->point_cnt - 1) + w / 2) / w;
if(chart->type == LV_CHART_TYPE_COLUMN) return (x * chart->point_cnt) / w;
return 0;
}
/** /**
* invalid area of the new line data lines on a chart * invalid area of the new line data lines on a chart
* @param obj pointer to chart object * @param obj pointer to chart object
*/ */
static void invalidate_lines(lv_obj_t * obj, uint16_t i) static void invalidate_point(lv_obj_t * obj, uint16_t i)
{ {
lv_chart_t * chart = (lv_chart_t *)obj; lv_chart_t * chart = (lv_chart_t *)obj;
if(i >= chart->point_cnt) return; if(i >= chart->point_cnt) return;
lv_coord_t w = lv_obj_get_width(obj); lv_coord_t w = lv_obj_get_width(obj);
lv_coord_t x_ofs = obj->coords.x1; if(chart->type == LV_CHART_TYPE_LINE) {
lv_coord_t x_ofs = obj->coords.x1;
lv_coord_t line_width = lv_obj_get_style_line_width(obj, LV_PART_ITEMS); lv_coord_t line_width = lv_obj_get_style_line_width(obj, LV_PART_ITEMS);
lv_coord_t point_radius = 5;//lv_obj_get_style_size(chart, LV_PART_ITEMS); lv_coord_t point_radius = lv_obj_get_style_size(obj, LV_PART_ITEMS);
lv_area_t coords; lv_area_t coords;
lv_area_copy(&coords, &obj->coords); lv_area_copy(&coords, &obj->coords);
coords.y1 -= line_width + point_radius; coords.y1 -= line_width + point_radius;
coords.y2 += line_width + point_radius; coords.y2 += line_width + point_radius;
if(i < chart->point_cnt - 1) { if(i < chart->point_cnt - 1) {
coords.x1 = ((w * i) / (chart->point_cnt - 1)) + x_ofs - line_width - point_radius; coords.x1 = ((w * i) / (chart->point_cnt - 1)) + x_ofs - line_width - point_radius;
coords.x2 = ((w * (i + 1)) / (chart->point_cnt - 1)) + x_ofs + line_width + point_radius; coords.x2 = ((w * (i + 1)) / (chart->point_cnt - 1)) + x_ofs + line_width + point_radius;
lv_obj_invalidate_area(obj, &coords); lv_obj_invalidate_area(obj, &coords);
}
if(i > 0) {
coords.x1 = ((w * (i - 1)) / (chart->point_cnt - 1)) + x_ofs - line_width - point_radius;
coords.x2 = ((w * i) / (chart->point_cnt - 1)) + x_ofs + line_width + point_radius;
lv_obj_invalidate_area(obj, &coords);
}
} }
else if(chart->type == LV_CHART_TYPE_COLUMN) {
lv_area_t col_a;
lv_coord_t col_w = w / ((_lv_ll_get_len(&chart->series_ll) + 1) * chart->point_cnt); /* Suppose + 1 series as separator*/
lv_coord_t x_ofs = col_w / 2; /*Shift with a half col.*/
if(i > 0) { lv_coord_t x_act;
coords.x1 = ((w * (i - 1)) / (chart->point_cnt - 1)) + x_ofs - line_width - point_radius; x_act = (int32_t)((int32_t)w * i) / chart->point_cnt;
coords.x2 = ((w * i) / (chart->point_cnt - 1)) + x_ofs + line_width + point_radius; x_act += obj->coords.x1 + x_ofs;
lv_obj_invalidate_area(obj, &coords);
lv_obj_get_coords(obj, &col_a);
col_a.x1 = x_act;
col_a.x2 = col_a.x1 + col_w;
_lv_inv_area(lv_obj_get_disp(obj), &col_a);
} else {
lv_obj_invalidate(chart);
} }
} }
/**
* invalid area of the new column data lines on a chart
* @param chart pointer to chart object
* @param mask mask, inherited from the draw function
*/
static void invalidate_columns(lv_obj_t * obj, uint16_t i)
{
lv_chart_t * chart = (lv_chart_t *)obj;
lv_area_t col_a;
lv_coord_t w = lv_obj_get_width(obj);
lv_coord_t col_w = w / ((_lv_ll_get_len(&chart->series_ll) + 1) * chart->point_cnt); /* Suppose + 1 series as separator*/
lv_coord_t x_ofs = col_w / 2; /*Shift with a half col.*/
lv_coord_t x_act;
x_act = (int32_t)((int32_t)w * i) / chart->point_cnt;
x_act += obj->coords.x1 + x_ofs;
lv_obj_get_coords(obj, &col_a);
col_a.x1 = x_act;
col_a.x2 = col_a.x1 + col_w;
_lv_inv_area(lv_obj_get_disp(obj), &col_a);
}
#endif #endif

View File

@@ -83,6 +83,7 @@ typedef struct {
lv_coord_t ymin[2]; lv_coord_t ymin[2];
lv_coord_t ymax[2]; lv_coord_t ymax[2];
lv_coord_t ext_size; lv_coord_t ext_size;
int32_t pressed_point_id;
uint8_t hdiv_cnt; /*Number of horizontal division lines*/ uint8_t hdiv_cnt; /*Number of horizontal division lines*/
uint8_t vdiv_cnt; /*Number of vertical division lines*/ uint8_t vdiv_cnt; /*Number of vertical division lines*/
uint8_t sub_tick_cnt[_LV_CHART_AXIS_LAST]; uint8_t sub_tick_cnt[_LV_CHART_AXIS_LAST];

View File

@@ -219,6 +219,7 @@ static lv_draw_res_t lv_checkbox_draw(lv_obj_t * obj, const lv_area_t * clip_are
marker_area_transf.x2 += transf_w; marker_area_transf.x2 += transf_w;
marker_area_transf.y1 -= transf_h; marker_area_transf.y1 -= transf_h;
marker_area_transf.y2 += transf_h; marker_area_transf.y2 += transf_h;
lv_draw_rect(&marker_area_transf, clip_area, &marker_dsc); lv_draw_rect(&marker_area_transf, clip_area, &marker_dsc);
lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
@@ -239,7 +240,6 @@ static lv_draw_res_t lv_checkbox_draw(lv_obj_t * obj, const lv_area_t * clip_are
txt_area.y2 = txt_area.y1 + txt_size.y; txt_area.y2 = txt_area.y1 + txt_size.y;
lv_draw_label(&txt_area, clip_area, &txt_dsc, cb->txt, NULL); lv_draw_label(&txt_area, clip_area, &txt_dsc, cb->txt, NULL);
} else { } else {
lv_obj.draw_cb(obj, clip_area, mode); lv_obj.draw_cb(obj, clip_area, mode);
} }
@@ -283,12 +283,12 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * obj, lv_signal_t sign, void * para
marker_size.y = font_h + marker_topp + marker_bottomp; marker_size.y = font_h + marker_topp + marker_bottomp;
p->x = marker_size.x + txt_size.x + bg_colp; p->x = marker_size.x + txt_size.x + bg_colp;
p->y = LV_MATH_MAX(marker_size.y, txt_size.y); p->y = LV_MAX(marker_size.y, txt_size.y);
} }
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
lv_coord_t *s = param; lv_coord_t *s = param;
lv_coord_t m = _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_MARKER); lv_coord_t m = _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_MARKER);
*s = LV_MATH_MAX(*s, m); *s = LV_MAX(*s, m);
} }
return res; return res;

View File

@@ -41,10 +41,13 @@
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
static void lv_dropdown_destructor(void * obj); static void lv_dropdown_destructor(lv_obj_t * obj);
static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
static lv_res_t lv_dropdown_signal(lv_obj_t * obj, lv_signal_t sign, void * param); static lv_res_t lv_dropdown_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
static void lv_dropdown_list_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy);
static void lv_dropdown_list_destructor(lv_obj_t * obj);
static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
static lv_res_t lv_dropdown_list_signal(lv_obj_t * list, lv_signal_t sign, void * param); static lv_res_t lv_dropdown_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
static void draw_box(lv_obj_t * dropdown_obj, const lv_area_t * clip_area, uint16_t id, lv_state_t state); static void draw_box(lv_obj_t * dropdown_obj, const lv_area_t * clip_area, uint16_t id, lv_state_t state);
static void draw_box_label(lv_obj_t * dropdown_obj, const lv_area_t * clip_area, uint16_t id, lv_state_t state); static void draw_box_label(lv_obj_t * dropdown_obj, const lv_area_t * clip_area, uint16_t id, lv_state_t state);
@@ -57,8 +60,23 @@ static lv_obj_t * get_label(const lv_obj_t * obj);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
**********************/ **********************/
lv_dropdown_class_t lv_dropdown; const lv_obj_class_t lv_dropdown = {
lv_dropdown_list_class_t lv_dropdown_list; .constructor = lv_dropdown_constructor,
.destructor = lv_dropdown_destructor,
.signal_cb = lv_dropdown_signal,
.draw_cb = lv_dropdown_draw,
.instance_size = sizeof(lv_dropdown_t),
.base_class = &lv_obj
};
const lv_obj_class_t lv_dropdown_list = {
.constructor = lv_dropdown_list_constructor,
.destructor = lv_dropdown_list_destructor,
.signal_cb = lv_dropdown_list_signal,
.draw_cb = lv_dropdown_list_draw,
.instance_size = sizeof(lv_dropdown_list_t),
.base_class = &lv_obj
};
/********************** /**********************
@@ -78,20 +96,7 @@ lv_dropdown_list_class_t lv_dropdown_list;
*/ */
lv_obj_t * lv_dropdown_create(lv_obj_t * parent, const lv_obj_t * copy) lv_obj_t * lv_dropdown_create(lv_obj_t * parent, const lv_obj_t * copy)
{ {
if(!lv_dropdown._inited) { return lv_obj_create_from_class(&lv_dropdown, parent, copy);
LV_CLASS_INIT(lv_dropdown, lv_obj);
lv_dropdown.constructor = lv_dropdown_constructor;
lv_dropdown.destructor = lv_dropdown_destructor;
lv_dropdown.draw_cb = lv_dropdown_draw;
lv_dropdown.signal_cb = lv_dropdown_signal;
}
lv_obj_t * obj = lv_class_new(&lv_dropdown);
lv_dropdown.constructor(obj, parent, copy);
lv_obj_create_finish(obj, parent, copy);
return obj;
} }
/*===================== /*=====================
@@ -273,7 +278,7 @@ void lv_dropdown_add_option(lv_obj_t * obj, const char * option, uint32_t pos)
_lv_txt_ins(dropdown->options, _lv_txt_encoded_get_char_id(dropdown->options, insert_pos++), "\n"); _lv_txt_ins(dropdown->options, _lv_txt_encoded_get_char_id(dropdown->options, insert_pos++), "\n");
/*Insert the new option, adding \n if necessary*/ /*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 */ char * ins_buf = lv_mem_buf_get(ins_len + 2); /* + 2 for terminating NULL and possible \n */
LV_ASSERT_MEM(ins_buf); LV_ASSERT_MEM(ins_buf);
if(ins_buf == NULL) return; if(ins_buf == NULL) return;
#if LV_USE_ARABIC_PERSIAN_CHARS == 0 #if LV_USE_ARABIC_PERSIAN_CHARS == 0
@@ -284,7 +289,7 @@ void lv_dropdown_add_option(lv_obj_t * obj, const char * option, uint32_t pos)
if(pos < dropdown->option_cnt) strcat(ins_buf, "\n"); if(pos < dropdown->option_cnt) strcat(ins_buf, "\n");
_lv_txt_ins(dropdown->options, _lv_txt_encoded_get_char_id(dropdown->options, insert_pos), ins_buf); _lv_txt_ins(dropdown->options, _lv_txt_encoded_get_char_id(dropdown->options, insert_pos), ins_buf);
_lv_mem_buf_release(ins_buf); lv_mem_buf_release(ins_buf);
dropdown->option_cnt++; dropdown->option_cnt++;
@@ -346,7 +351,7 @@ void lv_dropdown_set_max_height(lv_obj_t * obj, lv_coord_t h)
* @param ddlist pointer to drop down list object * @param ddlist pointer to drop down list object
* @param symbol a text like `LV_SYMBOL_DOWN` or NULL to not draw icon * @param symbol a text like `LV_SYMBOL_DOWN` or NULL to not draw icon
*/ */
void lv_dropdown_set_symbol(lv_obj_t * obj, const char * symbol) void lv_dropdown_set_symbol(lv_obj_t * obj, const void * symbol)
{ {
LV_ASSERT_OBJ(obj, LV_OBJX_NAME); LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
@@ -524,27 +529,27 @@ void lv_dropdown_open(lv_obj_t * dropdown_obj)
lv_dir_t dir = dropdown->dir; lv_dir_t dir = dropdown->dir;
/*No space on the bottom? See if top is better.*/ /*No space on the bottom? See if top is better.*/
if(dropdown->dir == LV_DIR_BOTTOM) { if(dropdown->dir == LV_DIR_BOTTOM) {
if(dropdown->coords.y2 + list_h > LV_VER_RES) { if(dropdown_obj->coords.y2 + list_h > LV_VER_RES) {
if(dropdown->coords.y1 > LV_VER_RES - dropdown->coords.y2) { if(dropdown_obj->coords.y1 > LV_VER_RES - dropdown_obj->coords.y2) {
/*There is more space on the top, so make it drop up*/ /*There is more space on the top, so make it drop up*/
dir = LV_DIR_TOP; dir = LV_DIR_TOP;
list_h = dropdown->coords.y1; list_h = dropdown_obj->coords.y1;
} }
else { else {
list_h = LV_VER_RES - dropdown->coords.y2; list_h = LV_VER_RES - dropdown_obj->coords.y2;
} }
} }
} }
/*No space on the top? See if bottom is better.*/ /*No space on the top? See if bottom is better.*/
else if(dropdown->dir == LV_DIR_TOP) { else if(dropdown->dir == LV_DIR_TOP) {
if(dropdown->coords.y1 - list_h < 0) { if(dropdown_obj->coords.y1 - list_h < 0) {
if(dropdown->coords.y1 < LV_VER_RES - dropdown->coords.y2) { if(dropdown_obj->coords.y1 < LV_VER_RES - dropdown_obj->coords.y2) {
/*There is more space on the top, so make it drop up*/ /*There is more space on the top, so make it drop up*/
dir = LV_DIR_BOTTOM; dir = LV_DIR_BOTTOM;
list_h = LV_VER_RES - dropdown->coords.y2; list_h = LV_VER_RES - dropdown_obj->coords.y2;
} }
else { else {
list_h = dropdown->coords.y1; list_h = dropdown_obj->coords.y1;
} }
} }
} }
@@ -567,8 +572,19 @@ void lv_dropdown_open(lv_obj_t * dropdown_obj)
} }
} }
if(lv_label_get_align(label) == LV_TEXT_ALIGN_RIGHT) { lv_text_align_t align = lv_obj_get_style_text_align(label, LV_PART_MAIN);
switch(align) {
default:
case LV_TEXT_ALIGN_LEFT:
lv_obj_set_x(label, 0);
break;
case LV_TEXT_ALIGN_RIGHT:
lv_obj_set_x(label, lv_obj_get_width_fit(dropdown->list) - lv_obj_get_width(label)); lv_obj_set_x(label, lv_obj_get_width_fit(dropdown->list) - lv_obj_get_width(label));
break;
case LV_TEXT_ALIGN_CENTER:
lv_obj_set_x(label, lv_obj_get_width_fit(dropdown->list) / 2 - lv_obj_get_width(label) / 2);
break;
} }
} }
@@ -597,31 +613,14 @@ void lv_dropdown_close(lv_obj_t * obj)
*/ */
lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent, const lv_obj_t * copy) lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent, const lv_obj_t * copy)
{ {
if(!lv_dropdown_list._inited) { return lv_obj_create_from_class(&lv_dropdown_list, parent, copy);
LV_CLASS_INIT(lv_dropdown_list, lv_obj);
lv_dropdown_list.constructor = lv_obj.constructor;
lv_dropdown_list.destructor = lv_obj.destructor;
lv_dropdown_list.draw_cb = lv_dropdown_list_draw;
lv_dropdown_list.signal_cb = lv_dropdown_list_signal;
}
lv_obj_t * obj = lv_class_new(&lv_dropdown_list);
lv_dropdown_list.constructor(obj, parent, copy);
lv_obj_create_finish(obj, parent, copy);
lv_obj_t * label = lv_label_create(obj, NULL);
return obj;
} }
static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy)
{ {
LV_LOG_TRACE("dropdown create started"); LV_LOG_TRACE("dropdown create started");
LV_CLASS_CONSTRUCTOR_BEGIN(obj, lv_dropdown) lv_obj_construct_base(obj, parent, copy);
lv_dropdown.base_p->constructor(obj, parent, copy);
lv_dropdown_t * dropdown = (lv_dropdown_t *) obj; lv_dropdown_t * dropdown = (lv_dropdown_t *) obj;
@@ -642,6 +641,7 @@ static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_
((lv_dropdown_list_t*)list_obj)->dropdown = (lv_obj_t *) dropdown; ((lv_dropdown_list_t*)list_obj)->dropdown = (lv_obj_t *) dropdown;
dropdown->list = list_obj; dropdown->list = list_obj;
lv_obj_add_flag(dropdown->list, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(dropdown->list, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(obj, LV_OBJ_FLAG_CHECKABLE);
if(copy == NULL) { if(copy == NULL) {
lv_obj_set_width(obj, LV_DPX(150)); lv_obj_set_width(obj, LV_DPX(150));
@@ -663,11 +663,10 @@ static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_
// dropdown->dir = copy_dropdown->dir; // dropdown->dir = copy_dropdown->dir;
} }
LV_CLASS_CONSTRUCTOR_END(obj, lv_switch)
LV_LOG_INFO("dropdown created"); LV_LOG_INFO("dropdown created");
} }
static void lv_dropdown_destructor(void * obj) static void lv_dropdown_destructor(lv_obj_t * obj)
{ {
// lv_bar_t * bar = obj; // lv_bar_t * bar = obj;
// //
@@ -690,11 +689,11 @@ static void lv_dropdown_destructor(void * obj)
static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) static lv_draw_res_t lv_dropdown_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*/ /*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_obj.draw_cb(obj, clip_area, mode); return lv_obj.draw_cb(obj, clip_area, mode);
} }
/*Draw the object*/ /*Draw the object*/
else if(mode == LV_DRAW_DRAW_MAIN) { else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
lv_obj.draw_cb(obj, clip_area, mode); lv_obj.draw_cb(obj, clip_area, mode);
lv_dropdown_t * dropdown = (lv_dropdown_t *) obj; lv_dropdown_t * dropdown = (lv_dropdown_t *) obj;
@@ -707,70 +706,110 @@ static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_are
lv_draw_label_dsc_init(&label_dsc); lv_draw_label_dsc_init(&label_dsc);
lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &label_dsc); lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &label_dsc);
lv_area_t txt_area;
lv_point_t txt_size;
/*If no text specified use the selected option*/ /*If no text specified use the selected option*/
const char * opt_txt; const char * opt_txt;
if(dropdown->text) opt_txt = dropdown->text; if(dropdown->text) opt_txt = dropdown->text;
else { else {
char * buf = _lv_mem_buf_get(128); char * buf = lv_mem_buf_get(128);
lv_dropdown_get_selected_str(obj, buf, 128); lv_dropdown_get_selected_str(obj, buf, 128);
opt_txt = buf; opt_txt = buf;
} }
const char * txt; bool symbol_to_left = false;
if(dropdown->dir == LV_DIR_LEFT) symbol_to_left = true;
if(lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL) symbol_to_left = true;
bool rev = false; if(dropdown->symbol) {
if(dropdown->dir == LV_DIR_LEFT) rev = true; lv_img_src_t symbol_type = lv_img_src_get_type(dropdown->symbol);
if(lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL) rev = true; lv_coord_t symbol_w;
lv_coord_t symbol_h;
txt = rev ? dropdown->symbol : opt_txt; if(symbol_type == LV_IMG_SRC_SYMBOL) {
if(txt) { lv_point_t size;
_lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, _lv_txt_get_size(&size, dropdown->symbol, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
label_dsc.flag); label_dsc.flag);
symbol_w = size.x;
txt_area.y1 = obj->coords.y1 + top; symbol_h = size.y;
txt_area.y2 = txt_area.y1 + txt_size.y; } else {
lv_img_header_t header;
/*Center align the text if no symbol*/ lv_res_t res = lv_img_decoder_get_info(dropdown->symbol, &header);
if(dropdown->symbol == NULL && txt == opt_txt) { if(res == LV_RES_OK) {
txt_area.x1 = obj->coords.x1 + (lv_obj_get_width(obj) - txt_size.x) / 2; symbol_w = header.w;
txt_area.x2 = txt_area.x1 + txt_size.x; symbol_h = header.h;
} else {
symbol_w = -1;
symbol_h = -1;
}
} }
else {
txt_area.x1 = obj->coords.x1 + left; lv_area_t symbol_area;
txt_area.x2 = txt_area.x1 + txt_size.x; symbol_area.y1 = obj->coords.y1 + top;
symbol_area.y2 = symbol_area.y1 + symbol_h - 1;
if(symbol_to_left) {
symbol_area.x1 = obj->coords.x1 + left;
symbol_area.x2 = symbol_area.x1 + symbol_w - 1;
} else {
symbol_area.x1 = obj->coords.x2 - right - symbol_w;
symbol_area.x2 = symbol_area.x1 + symbol_w - 1;
}
if(symbol_type == LV_IMG_SRC_SYMBOL) {
lv_draw_label(&symbol_area, clip_area, &label_dsc, dropdown->symbol, NULL);
} else {
lv_draw_img_dsc_t img_dsc;
lv_draw_img_dsc_init(&img_dsc);
lv_obj_init_draw_img_dsc(obj, LV_PART_MAIN, &img_dsc);
img_dsc.pivot.x = symbol_w / 2;
img_dsc.pivot.y = symbol_h / 2;
img_dsc.angle = lv_obj_get_style_transform_angle(obj, LV_PART_MAIN);
lv_draw_img(&symbol_area, clip_area, dropdown->symbol, &img_dsc);
} }
lv_draw_label(&txt_area, clip_area, &label_dsc, txt, NULL);
} }
txt = rev ? opt_txt : dropdown->symbol; // txt = rev ? dropdown->symbol : opt_txt;
if(txt) { // if(txt) {
_lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, // _lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
label_dsc.flag); // label_dsc.flag);
txt_area.y1 = obj->coords.y1 + top; //
txt_area.y2 = txt_area.y1 + txt_size.y; // txt_area.y1 = obj->coords.y1 + top;
// txt_area.y2 = txt_area.y1 + txt_size.y;
/*Center align the text if no symbol*/ //
if(dropdown->symbol == NULL && txt == opt_txt) { // /*Center align the text if no symbol*/
txt_area.x1 = obj->coords.x1 + (lv_obj_get_width(obj) - txt_size.x) / 2; // if(dropdown->symbol == NULL && txt == opt_txt) {
txt_area.x2 = txt_area.x1 + txt_size.x; // txt_area.x1 = obj->coords.x1 + (lv_obj_get_width(obj) - txt_size.x) / 2;
} // txt_area.x2 = txt_area.x1 + txt_size.x;
else { // }
txt_area.x1 = obj->coords.x2 - right - txt_size.x; // else {
txt_area.x2 = txt_area.x1 + txt_size.x; // txt_area.x1 = obj->coords.x1 + left;
} // txt_area.x2 = txt_area.x1 + txt_size.x;
// }
lv_draw_label(&txt_area, clip_area, &label_dsc, txt, NULL); // lv_draw_label(&txt_area, clip_area, &label_dsc, txt, NULL);
} // }
//
// txt = rev ? opt_txt : dropdown->symbol;
// if(txt) {
// _lv_txt_get_size(&txt_size, txt, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
// label_dsc.flag);
// txt_area.y1 = obj->coords.y1 + top;
// txt_area.y2 = txt_area.y1 + txt_size.y;
//
// /*Center align the text if no symbol*/
// if(dropdown->symbol == NULL && txt == opt_txt) {
// txt_area.x1 = obj->coords.x1 + (lv_obj_get_width(obj) - txt_size.x) / 2;
// txt_area.x2 = txt_area.x1 + txt_size.x;
// }
// else {
// txt_area.x1 = obj->coords.x2 - right - txt_size.x;
// txt_area.x2 = txt_area.x1 + txt_size.x;
// }
//
// lv_draw_label(&txt_area, clip_area, &label_dsc, txt, NULL);
// }
if(dropdown->text == NULL) { if(dropdown->text == NULL) {
_lv_mem_buf_release((char *)opt_txt); lv_mem_buf_release((char *)opt_txt);
} }
} }
else if(mode == LV_DRAW_DRAW_POST) { else if(mode == LV_DRAW_MODE_POST_DRAW) {
lv_obj.draw_cb(obj, clip_area, mode); lv_obj.draw_cb(obj, clip_area, mode);
} }
@@ -790,11 +829,11 @@ static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_are
static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * list_obj, const lv_area_t * clip_area, lv_draw_mode_t mode) static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * list_obj, const lv_area_t * clip_area, lv_draw_mode_t mode)
{ {
/*Return false if the object is not covers the mask_p area*/ /*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_obj.draw_cb(list_obj, clip_area, mode); return lv_obj.draw_cb(list_obj, clip_area, mode);
} }
/*Draw the object*/ /*Draw the object*/
else if(mode == LV_DRAW_DRAW_MAIN) { else if(mode == LV_DRAW_MODE_MAIN_DRAW) {
lv_obj.draw_cb(list_obj, clip_area, mode); lv_obj.draw_cb(list_obj, clip_area, mode);
lv_dropdown_list_t * list = (lv_dropdown_list_t *)list_obj; lv_dropdown_list_t * list = (lv_dropdown_list_t *)list_obj;
@@ -818,7 +857,7 @@ static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * list_obj, const lv_area_t
} }
} }
/*Post draw when the children are drawn*/ /*Post draw when the children are drawn*/
else if(mode == LV_DRAW_DRAW_POST) { else if(mode == LV_DRAW_MODE_POST_DRAW) {
lv_obj.draw_cb(list_obj, clip_area, mode); lv_obj.draw_cb(list_obj, clip_area, mode);
lv_dropdown_list_t * list = (lv_dropdown_list_t *)list_obj; lv_dropdown_list_t * list = (lv_dropdown_list_t *)list_obj;
@@ -845,6 +884,18 @@ static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * list_obj, const lv_area_t
return LV_DRAW_RES_OK; return LV_DRAW_RES_OK;
} }
static void lv_dropdown_list_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy)
{
lv_obj_construct_base(obj, parent, copy);
lv_label_create(obj, NULL);
}
static void lv_dropdown_list_destructor(lv_obj_t * obj)
{
}
/** /**
* Signal function of the drop down list * Signal function of the drop down list
* @param ddlist pointer to a drop down list object * @param ddlist pointer to a drop down list object
@@ -1042,11 +1093,6 @@ static void draw_box_label(lv_obj_t * dropdown_obj, const lv_area_t * clip_area,
lv_obj_t * label = get_label(dropdown_obj); lv_obj_t * label = get_label(dropdown_obj);
if(label == NULL) return; if(label == NULL) return;
lv_text_align_t align = lv_label_get_align(label);
if(align == LV_TEXT_ALIGN_CENTER) label_dsc.flag |= LV_TEXT_FLAG_CENTER;
else if(align == LV_TEXT_ALIGN_RIGHT) label_dsc.flag |= LV_TEXT_FLAG_RIGHT;
lv_coord_t font_h = lv_font_get_line_height(label_dsc.font); lv_coord_t font_h = lv_font_get_line_height(label_dsc.font);
lv_area_t area_sel; lv_area_t area_sel;

View File

@@ -34,45 +34,28 @@ extern "C" {
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
LV_CLASS_DECLARE_START(lv_dropdown, lv_obj); typedef struct {
lv_obj_t obj;
lv_obj_t * list; /*The dropped down list*/
const char * text; /*Text to display on the ddlist's button*/
const void * symbol; /*Arrow or other icon when the drop-down list is closed*/
char * options;
lv_coord_t max_height; /*Height of the ddlist when opened. (0: auto-size)*/
uint16_t option_cnt; /*Number of options*/
uint16_t sel_opt_id; /*Index of the currently selected option*/
uint16_t sel_opt_id_orig; /*Store the original index on focus*/
uint16_t pr_opt_id; /*Index of the currently pressed option*/
lv_dir_t dir : 4;
uint8_t static_txt : 1;
}lv_dropdown_t;
#define _lv_dropdown_constructor void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy) typedef struct {
lv_obj_t obj;
#define _lv_dropdown_data \
_lv_obj_data \
lv_obj_t * list; /*The dropped down list*/ \
const char * text; /*Text to display on the ddlist's button*/ \
const char * symbol; /*Arrow or other icon when the drop-down list is closed*/ \
char * options; \
lv_coord_t max_height; /*Height of the ddlist when opened. (0: auto-size)*/ \
uint16_t option_cnt; /*Number of options*/ \
uint16_t sel_opt_id; /*Index of the currently selected option*/ \
uint16_t sel_opt_id_orig; /*Store the original index on focus*/ \
uint16_t pr_opt_id; /*Index of the currently pressed option*/ \
lv_dir_t dir : 4; \
uint8_t static_txt : 1;
#define _lv_dropdown_class_dsc \
_lv_obj_class_dsc \
LV_CLASS_DECLARE_END(lv_dropdown, lv_obj);
extern lv_dropdown_class_t lv_dropdown;
LV_CLASS_DECLARE_START(lv_dropdown_list, lv_obj);
#define _lv_dropdown_list_constructor void (*constructor)(struct _lv_obj_t * obj, struct _lv_obj_t * parent, const struct _lv_obj_t * copy)
#define _lv_dropdown_list_data \
_lv_obj_data \
lv_obj_t * dropdown; lv_obj_t * dropdown;
}lv_dropdown_list_t;
#define _lv_dropdown_list_class_dsc \ extern const lv_obj_class_t lv_dropdown;
_lv_obj_class_dsc \ extern const lv_obj_class_t lv_dropdown_list;
LV_CLASS_DECLARE_END(lv_dropdown_list, lv_obj);
extern lv_dropdown_list_class_t lv_dropdown_list;
/********************** /**********************
* GLOBAL PROTOTYPES * GLOBAL PROTOTYPES
@@ -153,7 +136,7 @@ void lv_dropdown_set_max_height(lv_obj_t * ddlist, lv_coord_t h);
* @param ddlist pointer to drop down list object * @param ddlist pointer to drop down list object
* @param symbol a text like `LV_SYMBOL_DOWN` or NULL to not draw icon * @param symbol a text like `LV_SYMBOL_DOWN` or NULL to not draw icon
*/ */
void lv_dropdown_set_symbol(lv_obj_t * ddlist, const char * symbol); void lv_dropdown_set_symbol(lv_obj_t * ddlist, const void * symbol);
/*===================== /*=====================
* Getter functions * Getter functions

View File

@@ -9,11 +9,6 @@
#include "lv_img.h" #include "lv_img.h"
#if LV_USE_IMG != 0 #if LV_USE_IMG != 0
/*Testing of dependencies*/
#if LV_USE_LABEL == 0
#error "lv_img: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
#endif
#include "../lv_misc/lv_debug.h" #include "../lv_misc/lv_debug.h"
#include "../lv_themes/lv_theme.h" #include "../lv_themes/lv_theme.h"
#include "../lv_draw/lv_img_decoder.h" #include "../lv_draw/lv_img_decoder.h"
@@ -549,8 +544,7 @@ static lv_draw_res_t lv_img_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv
} }
#if LV_USE_BLEND_MODES #if LV_USE_BLEND_MODES
if(lv_obj_get_style_bg_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER; if(lv_obj_get_style_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER;
if(lv_obj_get_style_img_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_DRAW_RES_NOT_COVER;
#endif #endif
return LV_DRAW_RES_COVER; return LV_DRAW_RES_COVER;
@@ -705,10 +699,10 @@ static lv_res_t lv_img_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
lv_coord_t h = lv_obj_get_height(obj); lv_coord_t h = lv_obj_get_height(obj);
_lv_img_buf_get_transformed_area(&a, w, h, transf_angle, transf_zoom, &img->pivot); _lv_img_buf_get_transformed_area(&a, w, h, transf_angle, transf_zoom, &img->pivot);
lv_coord_t pad_ori = *s; lv_coord_t pad_ori = *s;
*s = LV_MATH_MAX(*s, pad_ori - a.x1); *s = LV_MAX(*s, pad_ori - a.x1);
*s = LV_MATH_MAX(*s, pad_ori - a.y1); *s = LV_MAX(*s, pad_ori - a.y1);
*s = LV_MATH_MAX(*s, pad_ori + a.x2 - w); *s = LV_MAX(*s, pad_ori + a.x2 - w);
*s = LV_MATH_MAX(*s, pad_ori + a.y2 - h); *s = LV_MAX(*s, pad_ori + a.y2 - h);
} }
/*Handle the padding of the background*/ /*Handle the padding of the background*/
@@ -717,10 +711,10 @@ static lv_res_t lv_img_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN); lv_coord_t top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
lv_coord_t bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN); lv_coord_t bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
*s = LV_MATH_MAX(*s, left); *s = LV_MAX(*s, left);
*s = LV_MATH_MAX(*s, right); *s = LV_MAX(*s, right);
*s = LV_MATH_MAX(*s, top); *s = LV_MAX(*s, top);
*s = LV_MATH_MAX(*s, bottom); *s = LV_MAX(*s, bottom);
} }
else if(sign == LV_SIGNAL_HIT_TEST) { else if(sign == LV_SIGNAL_HIT_TEST) {
lv_hit_test_info_t * info = param; lv_hit_test_info_t * info = param;

View File

@@ -19,7 +19,6 @@ extern "C" {
#include "../lv_core/lv_obj.h" #include "../lv_core/lv_obj.h"
#include "../lv_misc/lv_fs.h" #include "../lv_misc/lv_fs.h"
#include "lv_label.h"
#include "../lv_draw/lv_draw.h" #include "../lv_draw/lv_draw.h"
/********************* /*********************

View File

@@ -75,10 +75,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_draw == NULL) ancestor_draw = lv_obj_get_draw_cb(imgbtn); if(ancestor_draw == NULL) ancestor_draw = lv_obj_get_draw_cb(imgbtn);
/*Initialize the allocated 'ext' */ /*Initialize the allocated 'ext' */
_lv_memset_00((void *)ext->img_src_mid, sizeof(ext->img_src_mid)); lv_memset_00((void *)ext->img_src_mid, sizeof(ext->img_src_mid));
#if LV_IMGBTN_TILED #if LV_IMGBTN_TILED
_lv_memset_00(ext->img_src_left, sizeof(ext->img_src_left)); lv_memset_00(ext->img_src_left, sizeof(ext->img_src_left));
_lv_memset_00(ext->img_src_right, sizeof(ext->img_src_right)); lv_memset_00(ext->img_src_right, sizeof(ext->img_src_right));
#endif #endif
ext->tiled = 0; ext->tiled = 0;
@@ -95,10 +95,10 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy)
/*Copy an existing image button*/ /*Copy an existing image button*/
else { else {
lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy); lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
_lv_memcpy((void *)ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid)); lv_memcpy((void *)ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid));
#if LV_IMGBTN_TILED #if LV_IMGBTN_TILED
_lv_memcpy((void *)ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left)); lv_memcpy((void *)ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left));
_lv_memcpy((void *)ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right)); lv_memcpy((void *)ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right));
#endif #endif
ext->tiled = copy_ext->tiled; ext->tiled = copy_ext->tiled;
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
@@ -298,7 +298,7 @@ static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * imgbtn, const lv_area_t * clip_ar
lv_draw_rect(&bg_coords, clip_area, &bg_dsc); lv_draw_rect(&bg_coords, clip_area, &bg_dsc);
if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) { if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) {
lv_draw_mask_radius_param_t * mp = _lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
lv_coord_t r = lv_obj_get_style_radius(imgbtn, LV_OBJ_PART_MAIN); lv_coord_t r = lv_obj_get_style_radius(imgbtn, LV_OBJ_PART_MAIN);
@@ -409,7 +409,7 @@ static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * imgbtn, const lv_area_t * clip_ar
else if(mode == LV_DRAW_DRAW_POST) { else if(mode == LV_DRAW_DRAW_POST) {
if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) { if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) {
lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(imgbtn + 8); lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(imgbtn + 8);
_lv_mem_buf_release(param); lv_mem_buf_release(param);
} }
lv_draw_rect_dsc_t draw_dsc; lv_draw_rect_dsc_t draw_dsc;
@@ -466,10 +466,10 @@ static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * par
lv_coord_t bottom = lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN); lv_coord_t bottom = lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN);
lv_coord_t * s = param; lv_coord_t * s = param;
*s = LV_MATH_MAX(*s, left); *s = LV_MAX(*s, left);
*s = LV_MATH_MAX(*s, right); *s = LV_MAX(*s, right);
*s = LV_MATH_MAX(*s, top); *s = LV_MAX(*s, top);
*s = LV_MATH_MAX(*s, bottom); *s = LV_MAX(*s, bottom);
} }
else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
refr_img(imgbtn); refr_img(imgbtn);

View File

@@ -454,7 +454,7 @@ void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t
pos->y = y; pos->y = y;
#if LV_USE_BIDI #if LV_USE_BIDI
if(mutable_bidi_txt) _lv_mem_buf_release(mutable_bidi_txt); if(mutable_bidi_txt) lv_mem_buf_release(mutable_bidi_txt);
#endif #endif
} }
@@ -517,7 +517,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in)
} }
#if LV_USE_BIDI #if LV_USE_BIDI
bidi_txt = _lv_mem_buf_get(new_line_start - line_start + 1); bidi_txt = lv_mem_buf_get(new_line_start - line_start + 1);
uint32_t txt_len = new_line_start - line_start; uint32_t txt_len = new_line_start - line_start;
if(new_line_start > 0 && txt[new_line_start - 1] == '\0' && txt_len > 0) txt_len--; if(new_line_start > 0 && txt[new_line_start - 1] == '\0' && txt_len > 0) txt_len--;
_lv_bidi_process_paragraph(txt + line_start, bidi_txt, txt_len, lv_obj_get_base_dir(label), NULL, 0); _lv_bidi_process_paragraph(txt + line_start, bidi_txt, txt_len, lv_obj_get_base_dir(label), NULL, 0);
@@ -582,7 +582,7 @@ uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in)
logical_pos = _lv_bidi_get_logical_pos(&txt[line_start], NULL, logical_pos = _lv_bidi_get_logical_pos(&txt[line_start], NULL,
txt_len, lv_obj_get_base_dir(label), cid, &is_rtl); txt_len, lv_obj_get_base_dir(label), cid, &is_rtl);
if(is_rtl) logical_pos++; if(is_rtl) logical_pos++;
_lv_mem_buf_release(bidi_txt); lv_mem_buf_release(bidi_txt);
} }
#else #else
logical_pos = _lv_txt_encoded_get_char_id(bidi_txt, i); logical_pos = _lv_txt_encoded_get_char_id(bidi_txt, i);
@@ -756,14 +756,14 @@ void lv_label_ins_text(lv_obj_t * obj, uint32_t pos, const char * txt)
} }
#if LV_USE_BIDI #if LV_USE_BIDI
char * bidi_buf = _lv_mem_buf_get(ins_len + 1); char * bidi_buf = lv_mem_buf_get(ins_len + 1);
LV_ASSERT_MEM(bidi_buf); LV_ASSERT_MEM(bidi_buf);
if(bidi_buf == NULL) return; if(bidi_buf == NULL) return;
_lv_bidi_process(txt, bidi_buf, lv_obj_get_base_dir(label)); _lv_bidi_process(txt, bidi_buf, lv_obj_get_base_dir(label));
_lv_txt_ins(label->text, pos, bidi_buf); _lv_txt_ins(label->text, pos, bidi_buf);
_lv_mem_buf_release(bidi_buf); lv_mem_buf_release(bidi_buf);
#else #else
_lv_txt_ins(label->text, pos, txt); _lv_txt_ins(label->text, pos, txt);
#endif #endif
@@ -1286,14 +1286,14 @@ static bool lv_label_set_dot_tmp(lv_obj_t * obj, char * data, uint32_t len)
LV_LOG_ERROR("Failed to allocate memory for dot_tmp_ptr"); LV_LOG_ERROR("Failed to allocate memory for dot_tmp_ptr");
return false; return false;
} }
_lv_memcpy(label->dot.tmp_ptr, data, len); lv_memcpy(label->dot.tmp_ptr, data, len);
label->dot.tmp_ptr[len] = '\0'; label->dot.tmp_ptr[len] = '\0';
label->dot_tmp_alloc = true; label->dot_tmp_alloc = true;
} }
else { else {
/* Characters can be directly stored in object */ /* Characters can be directly stored in object */
label->dot_tmp_alloc = false; label->dot_tmp_alloc = false;
_lv_memcpy(label->dot.tmp, data, len); lv_memcpy(label->dot.tmp, data, len);
} }
return true; return true;
} }

View File

@@ -248,8 +248,8 @@ static lv_res_t lv_line_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
if(line->point_num > 0) { if(line->point_num > 0) {
uint16_t i; uint16_t i;
for(i = 0; i < line->point_num; i++) { for(i = 0; i < line->point_num; i++) {
w = LV_MATH_MAX(line->point_array[i].x, w); w = LV_MAX(line->point_array[i].x, w);
h = LV_MATH_MAX(line->point_array[i].y, h); h = LV_MAX(line->point_array[i].y, h);
} }
lv_coord_t line_width = lv_obj_get_style_line_width(obj, LV_PART_MAIN); lv_coord_t line_width = lv_obj_get_style_line_width(obj, LV_PART_MAIN);

View File

@@ -83,7 +83,7 @@ lv_meter_indicator_t * lv_meter_add_indicator(lv_obj_t * obj)
lv_meter_t * meter = (lv_meter_t *) obj; lv_meter_t * meter = (lv_meter_t *) obj;
lv_meter_indicator_t * indic = _lv_ll_ins_head(&meter->indic_ll); lv_meter_indicator_t * indic = _lv_ll_ins_head(&meter->indic_ll);
_lv_memset_00(indic, sizeof(lv_meter_indicator_t)); lv_memset_00(indic, sizeof(lv_meter_indicator_t));
indic->start_value = meter->min_value; indic->start_value = meter->min_value;
indic->end_value = meter->min_value; indic->end_value = meter->min_value;
indic->type = LV_METER_INDICATOR_TYPE_NEEDLE; indic->type = LV_METER_INDICATOR_TYPE_NEEDLE;
@@ -438,8 +438,8 @@ static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area
line_dsc.width = indic->width; line_dsc.width = indic->width;
line_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8; line_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8;
int32_t start_angle = _lv_map(indic->start_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs; int32_t start_angle = lv_map(indic->start_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs;
int32_t end_angle = _lv_map(indic->end_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs; int32_t end_angle = lv_map(indic->end_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs;
lv_draw_arc(scale_center.x + indic->arc_ofs.x, scale_center.y + indic->arc_ofs.y, r_out + indic->r_mod, start_angle, end_angle, clip_area, &line_dsc); lv_draw_arc(scale_center.x + indic->arc_ofs.x, scale_center.y + indic->arc_ofs.y, r_out + indic->r_mod, start_angle, end_angle, clip_area, &line_dsc);
} }
} }
@@ -496,12 +496,12 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
int32_t angle_rem = angle_upscale & 0xFF; int32_t angle_rem = angle_upscale & 0xFF;
/*Interpolate sine and cos*/ /*Interpolate sine and cos*/
int32_t sin_low = _lv_trigo_sin(angle_low + angle_ofs); int32_t sin_low = lv_trigo_sin(angle_low + angle_ofs);
int32_t sin_high = _lv_trigo_sin(angle_high + angle_ofs); int32_t sin_high = lv_trigo_sin(angle_high + angle_ofs);
int32_t sin_mid = (sin_low * (256 - angle_rem) + sin_high * angle_rem) >> 8; int32_t sin_mid = (sin_low * (256 - angle_rem) + sin_high * angle_rem) >> 8;
int32_t cos_low = _lv_trigo_cos(angle_low + angle_ofs); int32_t cos_low = lv_trigo_cos(angle_low + angle_ofs);
int32_t cos_high = _lv_trigo_cos(angle_high + angle_ofs); int32_t cos_high = lv_trigo_cos(angle_high + angle_ofs);
int32_t cos_mid = (cos_low * (256 - angle_rem) + cos_high * angle_rem) >> 8; int32_t cos_mid = (cos_low * (256 - angle_rem) + cos_high * angle_rem) >> 8;
lv_point_t p_inner; lv_point_t p_inner;
@@ -518,7 +518,7 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
lv_draw_line_dsc_t * line_dsc_act; lv_draw_line_dsc_t * line_dsc_act;
line_dsc_act = marker ? &line_marker_dsc : &line_sub_dsc; line_dsc_act = marker ? &line_marker_dsc : &line_sub_dsc;
int32_t value_of_line = _lv_map(i, 0, meter->line_cnt - 1, meter->min_value, meter->max_value); int32_t value_of_line = lv_map(i, 0, meter->line_cnt - 1, meter->min_value, meter->max_value);
lv_color_t line_color = line_dsc_act->color; lv_color_t line_color = line_dsc_act->color;
lv_color_t line_color_ori = line_dsc_act->color; lv_color_t line_color_ori = line_dsc_act->color;
@@ -540,9 +540,9 @@ static void draw_lines_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
} else { } else {
lv_opa_t ratio; lv_opa_t ratio;
if(indic->scale_color_local) { if(indic->scale_color_local) {
ratio = _lv_map(value_of_line, indic->start_value, indic->end_value, LV_OPA_TRANSP, LV_OPA_COVER); ratio = lv_map(value_of_line, indic->start_value, indic->end_value, LV_OPA_TRANSP, LV_OPA_COVER);
} else { } else {
ratio = _lv_map(value_of_line, meter->min_value, meter->max_value, LV_OPA_TRANSP, LV_OPA_COVER); ratio = lv_map(value_of_line, meter->min_value, meter->max_value, LV_OPA_TRANSP, LV_OPA_COVER);
} }
line_color = lv_color_mix(indic->grad_color, indic->color, ratio); line_color = lv_color_mix(indic->grad_color, indic->color, ratio);
} }
@@ -608,13 +608,13 @@ static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_a
_LV_LL_READ_BACK(&meter->indic_ll, indic) { _LV_LL_READ_BACK(&meter->indic_ll, indic) {
if((indic->type & LV_METER_INDICATOR_TYPE_NEEDLE) == false) continue; if((indic->type & LV_METER_INDICATOR_TYPE_NEEDLE) == false) continue;
int32_t angle = _lv_map(indic->end_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs; int32_t angle = lv_map(indic->end_value, meter->min_value, meter->max_value, 0, meter->scale_angle) + angle_ofs;
/*Draw a line*/ /*Draw a line*/
if(indic->img_src == NULL) { if(indic->img_src == NULL) {
lv_point_t p_end; lv_point_t p_end;
p_end.y = (_lv_trigo_sin(angle) * (r_out + indic->r_mod)) / LV_TRIGO_SIN_MAX + scale_center.x; p_end.y = (lv_trigo_sin(angle) * (r_out + indic->r_mod)) / LV_TRIGO_SIN_MAX + scale_center.x;
p_end.x = (_lv_trigo_cos(angle) * (r_out + indic->r_mod)) / LV_TRIGO_SIN_MAX + scale_center.y; p_end.x = (lv_trigo_cos(angle) * (r_out + indic->r_mod)) / LV_TRIGO_SIN_MAX + scale_center.y;
line_dsc.color = indic->color; line_dsc.color = indic->color;
line_dsc.width = indic->width; line_dsc.width = indic->width;
line_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8; line_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8;

View File

@@ -127,7 +127,7 @@ void lv_roller_set_options(lv_obj_t * obj, const char * options, lv_roller_mode_
roller->mode = LV_ROLLER_MODE_INFINITE; roller->mode = LV_ROLLER_MODE_INFINITE;
size_t opt_len = strlen(options) + 1; /*+1 to add '\n' after option lists*/ size_t opt_len = strlen(options) + 1; /*+1 to add '\n' after option lists*/
char * opt_extra = _lv_mem_buf_get(opt_len * LV_ROLLER_INF_PAGES); char * opt_extra = lv_mem_buf_get(opt_len * LV_ROLLER_INF_PAGES);
uint8_t i; uint8_t i;
for(i = 0; i < LV_ROLLER_INF_PAGES; i++) { for(i = 0; i < LV_ROLLER_INF_PAGES; i++) {
strcpy(&opt_extra[opt_len * i], options); strcpy(&opt_extra[opt_len * i], options);
@@ -135,7 +135,7 @@ void lv_roller_set_options(lv_obj_t * obj, const char * options, lv_roller_mode_
} }
opt_extra[opt_len * LV_ROLLER_INF_PAGES - 1] = '\0'; opt_extra[opt_len * LV_ROLLER_INF_PAGES - 1] = '\0';
lv_label_set_text(label, opt_extra); lv_label_set_text(label, opt_extra);
_lv_mem_buf_release(opt_extra); lv_mem_buf_release(opt_extra);
roller->sel_opt_id = ((LV_ROLLER_INF_PAGES / 2) + 0) * roller->option_cnt; roller->sel_opt_id = ((LV_ROLLER_INF_PAGES / 2) + 0) * roller->option_cnt;
@@ -646,7 +646,7 @@ static lv_res_t lv_roller_label_signal(lv_obj_t * label, lv_signal_t sign, void
lv_obj_t * obj = lv_obj_get_parent(label); lv_obj_t * obj = lv_obj_get_parent(label);
lv_coord_t sel_w = get_selected_label_width(obj); lv_coord_t sel_w = get_selected_label_width(obj);
lv_coord_t label_w = lv_obj_get_width(label); lv_coord_t label_w = lv_obj_get_width(label);
*s = LV_MATH_MAX(*s, sel_w - label_w); *s = LV_MAX(*s, sel_w - label_w);
} }
return res; return res;

View File

@@ -219,8 +219,8 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
} }
else { else {
/* Calculate the distance from each knob */ /* Calculate the distance from each knob */
dist_left = LV_MATH_ABS((slider->left_knob_area.x1 + (slider->left_knob_area.x2 - slider->left_knob_area.x1) / 2) - p.x); dist_left = LV_ABS((slider->left_knob_area.x1 + (slider->left_knob_area.x2 - slider->left_knob_area.x1) / 2) - p.x);
dist_right = LV_MATH_ABS((slider->right_knob_area.x1 + (slider->right_knob_area.x2 - slider->right_knob_area.x1) / 2) - p.x); dist_right = LV_ABS((slider->right_knob_area.x1 + (slider->right_knob_area.x2 - slider->right_knob_area.x1) / 2) - p.x);
/* Use whichever one is closer */ /* Use whichever one is closer */
if(dist_right < dist_left)slider->value_to_set = &slider->bar.cur_value; if(dist_right < dist_left)slider->value_to_set = &slider->bar.cur_value;
@@ -236,8 +236,8 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
} }
else { else {
/* Calculate the distance from each knob */ /* Calculate the distance from each knob */
dist_left = LV_MATH_ABS((slider->left_knob_area.y1 + (slider->left_knob_area.y2 - slider->left_knob_area.y1) / 2) - p.y); dist_left = LV_ABS((slider->left_knob_area.y1 + (slider->left_knob_area.y2 - slider->left_knob_area.y1) / 2) - p.y);
dist_right = LV_MATH_ABS((slider->right_knob_area.y1 + (slider->right_knob_area.y2 - slider->right_knob_area.y1) / 2) - p.y); dist_right = LV_ABS((slider->right_knob_area.y1 + (slider->right_knob_area.y2 - slider->right_knob_area.y1) / 2) - p.y);
/* Use whichever one is closer */ /* Use whichever one is closer */
if(dist_right < dist_left)slider->value_to_set = &slider->bar.cur_value; if(dist_right < dist_left)slider->value_to_set = &slider->bar.cur_value;
@@ -348,15 +348,15 @@ static lv_res_t lv_slider_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
/* The smaller size is the knob diameter*/ /* The smaller size is the knob diameter*/
lv_coord_t trans_w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN); lv_coord_t trans_w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
lv_coord_t trans_h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN); lv_coord_t trans_h = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
lv_coord_t knob_size = LV_MATH_MIN(lv_obj_get_width(obj) + 2 * trans_w, lv_obj_get_height(obj) + 2 * trans_h) >> 1; lv_coord_t knob_size = LV_MIN(lv_obj_get_width(obj) + 2 * trans_w, lv_obj_get_height(obj) + 2 * trans_h) >> 1;
knob_size += LV_MATH_MAX(LV_MATH_MAX(knob_left, knob_right), LV_MATH_MAX(knob_bottom, knob_top)); knob_size += LV_MAX(LV_MAX(knob_left, knob_right), LV_MAX(knob_bottom, knob_top));
knob_size += 2; /*For rounding error*/ knob_size += 2; /*For rounding error*/
knob_size += _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_KNOB); knob_size += _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_KNOB);
/*Indic. size is handled by bar*/ /*Indic. size is handled by bar*/
lv_coord_t * s = param; lv_coord_t * s = param;
*s = LV_MATH_MAX(*s, knob_size); *s = LV_MAX(*s, knob_size);
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
@@ -440,16 +440,8 @@ void draw_knob(lv_obj_t * obj, const lv_area_t * clip_area)
lv_area_copy(&slider->right_knob_area, &knob_area); lv_area_copy(&slider->right_knob_area, &knob_area);
/*Handle custom drawer*/ /*Handle custom drawer*/
lv_obj_draw_hook_dsc_t hook_dsc;
lv_obj_draw_hook_dsc_init(&hook_dsc, clip_area);
hook_dsc.draw_area = &slider->right_knob_area;
hook_dsc.part = LV_PART_KNOB;
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
lv_draw_rect(&slider->right_knob_area, clip_area, &knob_rect_dsc); lv_draw_rect(&slider->right_knob_area, clip_area, &knob_rect_dsc);
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
if(lv_slider_get_type(obj) == LV_SLIDER_TYPE_RANGE) { if(lv_slider_get_type(obj) == LV_SLIDER_TYPE_RANGE) {
/* Draw a second knob for the start_value side */ /* Draw a second knob for the start_value side */
if(hor) { if(hor) {
@@ -462,12 +454,8 @@ void draw_knob(lv_obj_t * obj, const lv_area_t * clip_area)
lv_area_copy(&slider->left_knob_area, &knob_area); lv_area_copy(&slider->left_knob_area, &knob_area);
hook_dsc.draw_area = &slider->left_knob_area;
hook_dsc.id = 1;
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
/*Draw the knob if the custom drawer allows it*/ /*Draw the knob if the custom drawer allows it*/
lv_draw_rect(&slider->left_knob_area, clip_area, &knob_rect_dsc); lv_draw_rect(&slider->left_knob_area, clip_area, &knob_rect_dsc);
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &hook_dsc);
} }
} }

View File

@@ -228,15 +228,15 @@ static lv_res_t lv_switch_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
lv_coord_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB); lv_coord_t knob_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_KNOB);
/* The smaller size is the knob diameter*/ /* The smaller size is the knob diameter*/
lv_coord_t knob_size = LV_MATH_MIN(lv_obj_get_width(obj), lv_obj_get_height(obj)) >> 1; lv_coord_t knob_size = LV_MIN(lv_obj_get_width(obj), lv_obj_get_height(obj)) >> 1;
knob_size += LV_MATH_MAX(LV_MATH_MAX(knob_left, knob_right), LV_MATH_MAX(knob_bottom, knob_top)); knob_size += LV_MAX(LV_MAX(knob_left, knob_right), LV_MAX(knob_bottom, knob_top));
knob_size += 2; /*For rounding error*/ knob_size += 2; /*For rounding error*/
knob_size += _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_KNOB); knob_size += _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_KNOB);
lv_coord_t * s = param; lv_coord_t * s = param;
*s = LV_MATH_MAX(*s, knob_size); *s = LV_MAX(*s, knob_size);
*s = LV_MATH_MAX(*s, _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_INDICATOR)); *s = LV_MAX(*s, _lv_obj_get_draw_rect_ext_pad_size(obj, LV_PART_INDICATOR));
} }
else if(sign == LV_SIGNAL_RELEASED) { else if(sign == LV_SIGNAL_RELEASED) {
lv_obj_invalidate(obj); lv_obj_invalidate(obj);

View File

@@ -172,7 +172,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 #if LV_USE_ARABIC_PERSIAN_CHARS
/*Put together the text according to the format string*/ /*Put together the text according to the format string*/
char * raw_txt = _lv_mem_buf_get(len + 1); char * raw_txt = lv_mem_buf_get(len + 1);
LV_ASSERT_MEM(raw_txt); LV_ASSERT_MEM(raw_txt);
if(raw_txt == NULL) { if(raw_txt == NULL) {
va_end(ap2); va_end(ap2);
@@ -191,7 +191,7 @@ void lv_table_set_cell_value_fmt(lv_obj_t * obj, uint16_t row, uint16_t col, con
} }
_lv_txt_ap_proc(raw_txt, &table->cell_data[cell][1]); _lv_txt_ap_proc(raw_txt, &table->cell_data[cell][1]);
_lv_mem_buf_release(raw_txt); lv_mem_buf_release(raw_txt);
#else #else
table->cell_data[cell] = lv_mem_realloc(table->cell_data[cell], len + 2); /*+1: trailing '\0; +1: format byte*/ 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_MEM(table->cell_data[cell]);
@@ -236,7 +236,7 @@ void lv_table_set_row_cnt(lv_obj_t * obj, uint16_t row_cnt)
if(old_row_cnt < row_cnt) { if(old_row_cnt < row_cnt) {
uint32_t old_cell_cnt = old_row_cnt * table->col_cnt; uint32_t old_cell_cnt = old_row_cnt * table->col_cnt;
uint32_t new_cell_cnt = table->col_cnt * table->row_cnt; uint32_t new_cell_cnt = table->col_cnt * table->row_cnt;
_lv_memset_00(&table->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(table->cell_data[0])); lv_memset_00(&table->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(table->cell_data[0]));
} }
refr_size(obj) ; refr_size(obj) ;
@@ -266,7 +266,7 @@ void lv_table_set_col_cnt(lv_obj_t * obj, uint16_t col_cnt)
if(old_col_cnt < col_cnt) { if(old_col_cnt < col_cnt) {
uint32_t old_cell_cnt = old_col_cnt * table->row_cnt; uint32_t old_cell_cnt = old_col_cnt * table->row_cnt;
uint32_t new_cell_cnt = table->col_cnt * table->row_cnt; uint32_t new_cell_cnt = table->col_cnt * table->row_cnt;
_lv_memset_00(&table->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(table->cell_data[0])); lv_memset_00(&table->cell_data[old_cell_cnt], (new_cell_cnt - old_cell_cnt) * sizeof(table->cell_data[0]));
uint32_t col; uint32_t col;
for(col = old_cell_cnt; col < new_cell_cnt; col++) { for(col = old_cell_cnt; col < new_cell_cnt; col++) {
@@ -737,8 +737,8 @@ static lv_draw_res_t lv_table_draw(lv_obj_t * obj, const lv_area_t * clip_area,
cell_area_border.y2 += rect_dsc_base.border_width / 2 + (rect_dsc_base.border_width & 0x1); cell_area_border.y2 += rect_dsc_base.border_width / 2 + (rect_dsc_base.border_width & 0x1);
} }
_lv_memcpy(&rect_dsc_act, &rect_dsc_base, sizeof(lv_draw_rect_dsc_t)); lv_memcpy(&rect_dsc_act, &rect_dsc_base, sizeof(lv_draw_rect_dsc_t));
_lv_memcpy(&label_dsc_act, &label_dsc_base, sizeof(lv_draw_label_dsc_t)); lv_memcpy(&label_dsc_act, &label_dsc_base, sizeof(lv_draw_label_dsc_t));
hook_dsc.draw_area = &cell_area_border; hook_dsc.draw_area = &cell_area_border;
hook_dsc.id = row * table->col_cnt + col; hook_dsc.id = row * table->col_cnt + col;
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc); lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &hook_dsc);
@@ -886,7 +886,7 @@ static lv_coord_t get_row_height(lv_obj_t * obj, uint16_t row_id, const lv_font_
/*With text crop assume 1 line*/ /*With text crop assume 1 line*/
if(format.s.crop) { if(format.s.crop) {
h_max = LV_MATH_MAX(lv_font_get_line_height(font) + cell_top + cell_bottom, h_max = LV_MAX(lv_font_get_line_height(font) + cell_top + cell_bottom,
h_max); h_max);
} }
/*Without text crop calculate the height of the text in the cell*/ /*Without text crop calculate the height of the text in the cell*/
@@ -896,7 +896,7 @@ static lv_coord_t get_row_height(lv_obj_t * obj, uint16_t row_id, const lv_font_
_lv_txt_get_size(&txt_size, table->cell_data[cell] + 1, font, _lv_txt_get_size(&txt_size, table->cell_data[cell] + 1, font,
letter_space, line_space, txt_w, LV_TEXT_FLAG_NONE); letter_space, line_space, txt_w, LV_TEXT_FLAG_NONE);
h_max = LV_MATH_MAX(txt_size.y + cell_top + cell_bottom, h_max); h_max = LV_MAX(txt_size.y + cell_top + cell_bottom, h_max);
cell += col_merge; cell += col_merge;
col += col_merge; col += col_merge;
} }

View File

@@ -162,12 +162,12 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy)
} }
if(copy_ext->pwd_tmp) { if(copy_ext->pwd_tmp) {
uint32_t len = _lv_mem_get_size(copy_ext->pwd_tmp); uint32_t len = lv_mem_get_size(copy_ext->pwd_tmp);
ext->pwd_tmp = lv_mem_alloc(len); ext->pwd_tmp = lv_mem_alloc(len);
LV_ASSERT_MEM(ext->pwd_tmp); LV_ASSERT_MEM(ext->pwd_tmp);
if(ext->pwd_tmp == NULL) return NULL; if(ext->pwd_tmp == NULL) return NULL;
_lv_memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len); lv_memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len);
} }
if(copy_ext->one_line) lv_textarea_set_one_line(ta, true); if(copy_ext->one_line) lv_textarea_set_one_line(ta, true);
@@ -1447,16 +1447,16 @@ static void pwd_char_hider(lv_obj_t * ta)
else bullet = "*"; else bullet = "*";
size_t bullet_len = strlen(bullet); size_t bullet_len = strlen(bullet);
char * txt_tmp = _lv_mem_buf_get(enc_len * bullet_len + 1); char * txt_tmp = lv_mem_buf_get(enc_len * bullet_len + 1);
int32_t i; int32_t i;
for(i = 0; i < enc_len; i++) { for(i = 0; i < enc_len; i++) {
_lv_memcpy(&txt_tmp[i * bullet_len], bullet, bullet_len); lv_memcpy(&txt_tmp[i * bullet_len], bullet, bullet_len);
} }
txt_tmp[i * bullet_len] = '\0'; txt_tmp[i * bullet_len] = '\0';
lv_label_set_text(ext->label, txt_tmp); lv_label_set_text(ext->label, txt_tmp);
_lv_mem_buf_release(txt_tmp); lv_mem_buf_release(txt_tmp);
refr_cursor_area(ta); refr_cursor_area(ta);
} }
} }
@@ -1771,7 +1771,7 @@ static void draw_cursor(lv_obj_t * ta, const lv_area_t * clip_area)
lv_draw_rect(&cur_area, clip_area, &cur_dsc); lv_draw_rect(&cur_area, clip_area, &cur_dsc);
char letter_buf[8] = {0}; char letter_buf[8] = {0};
_lv_memcpy(letter_buf, &txt[ext->cursor.txt_byte_pos], _lv_txt_encoded_size(&txt[ext->cursor.txt_byte_pos])); lv_memcpy(letter_buf, &txt[ext->cursor.txt_byte_pos], _lv_txt_encoded_size(&txt[ext->cursor.txt_byte_pos]));
if(cur_dsc.bg_opa == LV_OPA_COVER) { if(cur_dsc.bg_opa == LV_OPA_COVER) {
lv_coord_t left = lv_obj_get_style_pad_left(ta, LV_TEXTAREA_PART_CURSOR); lv_coord_t left = lv_obj_get_style_pad_left(ta, LV_TEXTAREA_PART_CURSOR);