minor fixes

This commit is contained in:
Gabor Kiss-Vamosi
2020-02-13 06:56:14 +01:00
parent 1b690e6238
commit 4cfeb9e985
15 changed files with 198 additions and 178 deletions

View File

@@ -499,12 +499,12 @@ static void draw_border(const lv_area_t * coords, const lv_area_t * clip, lv_dra
fill_area.y1 = disp_area->y1 + draw_area.y1;
fill_area.y2 = fill_area.y1;
if(dsc->border_side == LV_BORDER_SIDE_LEFT) fill_area.x2 = coords->x1 + rout;
else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) fill_area.x1 = coords->x2 - rout;
if(dsc->border_side == LV_BORDER_SIDE_LEFT) fill_area.x2 = coords->x1 + corner_size;
else if(dsc->border_side == LV_BORDER_SIDE_RIGHT) fill_area.x1 = coords->x2 - corner_size;
for(h = draw_area.y1; h <= draw_area.y2; h++) {
if((dsc->border_side == LV_BORDER_SIDE_BOTTOM && fill_area.y1 < coords->y2 - rout - 1) ||
(dsc->border_side == LV_BORDER_SIDE_TOP && fill_area.y1 > coords->y1 + rout + 1)) {
if((dsc->border_side == LV_BORDER_SIDE_BOTTOM && fill_area.y1 < coords->y2 - corner_size - 1) ||
(dsc->border_side == LV_BORDER_SIDE_TOP && fill_area.y1 > coords->y1 + corner_size + 1)) {
fill_area.y1++;
fill_area.y2++;

View File

@@ -476,9 +476,13 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area)
}
/* Set the indicator length */
*axis2 = *axis1 + anim_cur_value_x;
*axis1 += anim_start_value_x;
if(hor) {
*axis2 = *axis1 + anim_cur_value_x;
*axis1 += anim_start_value_x;
} else {
*axis2 -= anim_start_value_x;
*axis1 = *axis2 - anim_cur_value_x;
}
if(sym) {
lv_coord_t zero;
zero = *axis1 + (-ext->min_value * anim_length) / range;

View File

@@ -12,6 +12,7 @@
#include "../lv_misc/lv_math.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_core/lv_refr.h"
#include "../lv_themes/lv_theme.h"
#if LV_USE_CANVAS != 0
@@ -103,12 +104,12 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new canvas canvas*/
if(copy == NULL) {
lv_theme_apply(new_canvas, LV_THEME_CANVAS);
}
/*Copy an existing canvas*/
else {
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_canvas);
/*Do not copy the image data because each canvas needs it's own buffer*/
}
LV_LOG_INFO("canvas created");

View File

@@ -114,10 +114,9 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy)
/*Initialize the allocated 'ext' */
ext->type = LV_CPICKER_DEF_TYPE;
ext->hsv = LV_CPICKER_DEF_HSV;
ext->indic.colored = 0;
ext->indic.colored = 1;
ext->color_mode = LV_CPICKER_COLOR_MODE_HUE;
ext->color_mode_fixed = 0;
ext->preview = 0;
ext->last_click_time = 0;
ext->last_change_time = 0;
@@ -131,6 +130,7 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy)
if(copy == NULL) {
lv_obj_set_size(cpicker, LV_DPI * 2, LV_DPI * 2);
lv_obj_set_protect(cpicker, LV_PROTECT_PRESS_LOST);
lv_obj_set_adv_hittest(cpicker, true);
lv_theme_apply(cpicker, LV_THEME_CPICKER);
}
/*Copy 'copy'*/
@@ -139,7 +139,6 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy)
ext->type = copy_ext->type;
ext->color_mode = copy_ext->color_mode;
ext->color_mode_fixed = copy_ext->color_mode_fixed;
ext->preview = copy_ext->preview;
ext->hsv = copy_ext->hsv;
ext->indic.colored = copy_ext->indic.colored;
@@ -238,7 +237,7 @@ bool lv_cpicker_set_hsv(lv_obj_t * cpicker, lv_color_hsv_t hsv)
refr_indic_pos(cpicker);
if (ext->preview && ext->type == LV_CPICKER_TYPE_DISC) {
if (ext->type == LV_CPICKER_TYPE_DISC) {
lv_obj_invalidate(cpicker);
}
@@ -306,19 +305,6 @@ void lv_cpicker_set_indic_colored(lv_obj_t * cpicker, bool en)
invalidate_indic(cpicker);
}
/**
* Add a color preview in the middle of the DISC type color picker
* @param cpicker pointer to colorpicker object
* @param en true: enable preview; false: disable preview
*/
void lv_cpicker_set_preview(lv_obj_t * cpicker, bool en)
{
LV_ASSERT_OBJ(cpicker, LV_OBJX_NAME);
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
ext->preview = en ? 1 : 0;
lv_obj_invalidate(cpicker);
}
/*=====================
* Getter functions
*====================*/
@@ -435,21 +421,6 @@ bool lv_cpicker_get_indic_colored(lv_obj_t * cpicker)
return ext->indic.colored ? true : false;
}
/**
* Whether the preview is enabled or not
* @param cpicker pointer to colorpicker object
* @return en true: preview is enabled; false: preview is disabled
*/
bool lv_cpicker_get_preview(lv_obj_t * cpicker)
{
LV_ASSERT_OBJ(cpicker, LV_OBJX_NAME);
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
return ext->preview ? true : false;
}
/*=====================
* Other functions
*====================*/
@@ -496,8 +467,6 @@ static lv_design_res_t lv_cpicker_design(lv_obj_t * cpicker, const lv_area_t * c
static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask)
{
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
lv_coord_t w = lv_obj_get_width(cpicker);
lv_coord_t h = lv_obj_get_height(cpicker);
lv_coord_t cx = cpicker->coords.x1 + w / 2;
@@ -526,32 +495,30 @@ static void draw_disc_grad(lv_obj_t * cpicker, const lv_area_t * mask)
}
if(ext->preview) {
lv_draw_rect_dsc_t bg_dsc;
lv_draw_rect_dsc_init(&bg_dsc);
lv_obj_init_draw_rect_dsc(cpicker, LV_CPICKER_PART_MAIN, &bg_dsc);
/*Mask out the inner area*/
lv_draw_rect_dsc_t bg_dsc;
lv_draw_rect_dsc_init(&bg_dsc);
lv_obj_init_draw_rect_dsc(cpicker, LV_CPICKER_PART_MAIN, &bg_dsc);
bg_dsc.radius = LV_RADIUS_CIRCLE;
/*Mask out the center area*/
bg_dsc.radius = LV_RADIUS_CIRCLE;
lv_area_t area_mid;
lv_area_copy(&area_mid, &cpicker->coords);
area_mid.x1 += cir_w;
area_mid.y1 += cir_w;
area_mid.x2 -= cir_w;
area_mid.y2 -= cir_w;
lv_area_t area_mid;
lv_area_copy(&area_mid, &cpicker->coords);
area_mid.x1 += cir_w;
area_mid.y1 += cir_w;
area_mid.x2 -= cir_w;
area_mid.y2 -= cir_w;
lv_draw_rect(&area_mid, mask, &bg_dsc);
lv_draw_rect(&area_mid, mask, &bg_dsc);
lv_style_int_t inner = lv_obj_get_style_pad_inner(cpicker, LV_CPICKER_PART_MAIN);
lv_color_t color = lv_cpicker_get_color(cpicker);
bg_dsc.bg_color = color;
area_mid.x1 += inner;
area_mid.y1 += inner;
area_mid.x2 -= inner;
area_mid.y2 -= inner;
lv_style_int_t inner = lv_obj_get_style_pad_inner(cpicker, LV_CPICKER_PART_MAIN);
lv_color_t color = lv_cpicker_get_color(cpicker);
bg_dsc.bg_color = color;
area_mid.x1 += inner;
area_mid.y1 += inner;
area_mid.x2 -= inner;
area_mid.y2 -= inner;
lv_draw_rect(&area_mid, mask, &bg_dsc);
}
lv_draw_rect(&area_mid, mask, &bg_dsc);
}
static void draw_rect_grad(lv_obj_t * cpicker, const lv_area_t * mask)
@@ -647,17 +614,17 @@ static lv_area_t get_indic_area(lv_obj_t * cpicker)
/*Get indicator's radius*/
uint16_t r = 0;
if(ext->type == LV_CPICKER_TYPE_DISC) {
r = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN);
r = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN) / 2;
}
else if(ext->type == LV_CPICKER_TYPE_RECT) {
lv_coord_t h = lv_obj_get_height(cpicker);
r = h / 2;
}
lv_style_int_t left = lv_obj_get_style_pad_left(cpicker, LV_STYLE_PAD_LEFT);
lv_style_int_t right = lv_obj_get_style_pad_left(cpicker, LV_STYLE_PAD_RIGHT);
lv_style_int_t top = lv_obj_get_style_pad_left(cpicker, LV_STYLE_PAD_TOP);
lv_style_int_t bottom = lv_obj_get_style_pad_left(cpicker, LV_STYLE_PAD_BOTTOM);
lv_style_int_t left = lv_obj_get_style_pad_left(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t right = lv_obj_get_style_pad_right(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t top = lv_obj_get_style_pad_top(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(cpicker, LV_CPICKER_PART_INDIC);
lv_area_t indic_area;
indic_area.x1 = cpicker->coords.x1 + ext->indic.pos.x - r - left;
@@ -696,14 +663,19 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
} else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
lv_style_int_t left = lv_obj_get_style_pad_left(cpicker, LV_STYLE_PAD_LEFT);
lv_style_int_t right = lv_obj_get_style_pad_left(cpicker, LV_STYLE_PAD_RIGHT);
lv_style_int_t top = lv_obj_get_style_pad_left(cpicker, LV_STYLE_PAD_TOP);
lv_style_int_t bottom = lv_obj_get_style_pad_left(cpicker, LV_STYLE_PAD_BOTTOM);
lv_style_int_t left = lv_obj_get_style_pad_left(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t right = lv_obj_get_style_pad_right(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t top = lv_obj_get_style_pad_top(cpicker, LV_CPICKER_PART_INDIC);
lv_style_int_t bottom = lv_obj_get_style_pad_bottom(cpicker, LV_CPICKER_PART_INDIC);
lv_coord_t indic_pad = LV_MATH_MAX4(left, right, top, bottom);
lv_coord_t indic_pad = LV_MATH_MAX4(left, right, top, bottom) + 2;
cpicker->ext_draw_pad = LV_MATH_MAX(cpicker->ext_draw_pad, indic_pad);
if(ext->type == LV_CPICKER_TYPE_DISC) {
cpicker->ext_draw_pad = LV_MATH_MAX(cpicker->ext_draw_pad, indic_pad);
} else {
indic_pad += lv_obj_get_height(cpicker) / 2;
cpicker->ext_draw_pad = LV_MATH_MAX(cpicker->ext_draw_pad, indic_pad);
}
} else if(sign == LV_SIGNAL_COORD_CHG) {
/*Refresh extended draw area to make knob visible*/
if(lv_obj_get_width(cpicker) != lv_area_get_width(param) ||
@@ -810,7 +782,8 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
bool on_ring = true;
r_in -= scale_w;
if(r_in > LV_DPI / 2) {
r_in -= scale_w; /* to let some sensitive space inside*/
lv_style_int_t inner = lv_obj_get_style_pad_inner(cpicker, LV_CPICKER_PART_MAIN);
r_in -= inner;
if(r_in < LV_DPI / 2) r_in = LV_DPI / 2;
}
@@ -821,8 +794,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
/*If the inner area is being pressed, go to the next color mode on long press*/
uint32_t diff = lv_tick_elaps(ext->last_change_time);
if(((!ext->preview && on_ring) || (ext->preview))
&& diff > indev->driver.long_press_time && !ext->color_mode_fixed) {
if(!on_ring && diff > indev->driver.long_press_time && !ext->color_mode_fixed) {
next_color_mode(cpicker);
lv_indev_wait_release(lv_indev_get_act());
return res;
@@ -896,21 +868,13 @@ static bool lv_cpicker_hit(lv_obj_t * cpicker, const lv_point_t * p)
return false;
lv_cpicker_ext_t * ext = (lv_cpicker_ext_t *)lv_obj_get_ext_attr(cpicker);
if(ext->type != LV_CPICKER_TYPE_DISC || ext->preview)
if(ext->type == LV_CPICKER_TYPE_RECT)
return true;
lv_style_int_t scale_w = lv_obj_get_style_scale_width(cpicker, LV_CPICKER_PART_MAIN);
lv_area_t area_mid;
lv_area_copy(&area_mid, &cpicker->coords);
area_mid.x1 += scale_w;
area_mid.y1 += scale_w;
area_mid.x2 -= scale_w;
area_mid.y2 -= scale_w;
if(lv_area_is_point_on(&area_mid, p, LV_RADIUS_CIRCLE))
return false;
return true;
/*Valid clicks can be only in the circle*/
if(lv_area_is_point_on(&cpicker->coords, p, LV_RADIUS_CIRCLE)) return true;
else return false;
}
static void next_color_mode(lv_obj_t * cpicker)

View File

@@ -57,7 +57,6 @@ typedef struct {
lv_cpicker_color_mode_t color_mode :2;
uint8_t color_mode_fixed :1;
lv_cpicker_type_t type :1;
uint8_t preview :1;
} lv_cpicker_ext_t;
/*Parts*/
@@ -153,13 +152,6 @@ void lv_cpicker_set_color_mode_fixed(lv_obj_t * cpicker, bool fixed);
*/
void lv_cpicker_set_indic_colored(lv_obj_t * cpicker, bool en);
/**
* Add a color preview in the middle of the DISC type color picker
* @param cpicker pointer to colorpicker object
* @param en true: enable preview; false: disable preview
*/
void lv_cpicker_set_preview(lv_obj_t * cpicker, bool en);
/*=====================
* Getter functions
*====================*/

View File

@@ -132,15 +132,20 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
}
/*Copy an existing drop down list*/
else {
// lv_ddlist_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
// ext->label = lv_label_create(ddlist, copy_ext->label);
// lv_label_set_text(ext->label, lv_label_get_text(copy_ext->label));
// ext->sel_opt_id = copy_ext->sel_opt_id;
// ext->sel_opt_id_ori = copy_ext->sel_opt_id;
// ext->fix_height = copy_ext->fix_height;
// ext->option_cnt = copy_ext->option_cnt;
// ext->symbol = copy_ext->symbol;
// ext->stay_open = copy_ext->stay_open;
lv_ddlist_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->options = copy_ext->options;
ext->option_cnt = copy_ext->option_cnt;
ext->sel_opt_id = copy_ext->sel_opt_id;
ext->sel_opt_id_orig = copy_ext->sel_opt_id;
ext->symbol = copy_ext->symbol;
ext->max_height = copy_ext->max_height;
ext->anim_time = copy_ext->anim_time;
ext->text = copy_ext->text;
ext->dir = copy_ext->dir;
ext->show_selected = copy_ext->show_selected;
lv_style_list_copy(&ext->style_page, &copy_ext->style_page);
lv_style_list_copy(&ext->style_selected, &copy_ext->style_selected);
lv_style_list_copy(&ext->style_scrlbar, &copy_ext->style_scrlbar);
}
LV_LOG_INFO("drop down list created");
@@ -490,25 +495,19 @@ void lv_ddlist_open(lv_obj_t * ddlist, lv_anim_enable_t anim)
else if(ext->dir == LV_DDLIST_DIR_LEFT) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_LEFT_TOP, 0, 0);
else if(ext->dir == LV_DDLIST_DIR_RIGHT)lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_RIGHT_TOP, 0, 0);
lv_ddlist_dir_t dir = ext->dir;
if(dir == LV_DDLIST_DIR_DOWN && ext->page->coords.y2 >= vres) dir = LV_DDLIST_DIR_UP;
else if(dir == LV_DDLIST_DIR_UP && ext->page->coords.y1 <= 0) dir = LV_DDLIST_DIR_DOWN;
else if(dir == LV_DDLIST_DIR_RIGHT && ext->page->coords.x2 >= hres) dir = LV_DDLIST_DIR_LEFT;
else if(dir == LV_DDLIST_DIR_LEFT && ext->page->coords.x1 <= 0) dir = LV_DDLIST_DIR_RIGHT;
if(dir != ext->dir) {
if(dir == LV_DDLIST_DIR_DOWN) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
else if(dir == LV_DDLIST_DIR_UP) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_TOP_LEFT, 0, 0);
else if(dir == LV_DDLIST_DIR_LEFT) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_LEFT_TOP, 0, 0);
else if(dir == LV_DDLIST_DIR_RIGHT)lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_RIGHT_TOP, 0, 0);
}
lv_obj_t * scr = lv_scr_act();
if(ext->page->coords.y2 > scr->coords.y2) {
lv_obj_set_height(ext->page, lv_obj_get_height(ext->page) - (ext->page->coords.y2 - scr->coords.y2));
if(ext->dir != LV_DDLIST_DIR_UP) {
if(ext->page->coords.y2 > scr->coords.y2) {
lv_obj_set_y(ext->page, lv_obj_get_y(ext->page) - (ext->page->coords.y2 - scr->coords.y2));
}
}
else {
if(ext->page->coords.y1 < 0) {
lv_obj_set_y(ext->page, 0);
}
}
if(dir != LV_DDLIST_DIR_UP) {
if(ext->dir != LV_DDLIST_DIR_UP) {
lv_anim_t a;
lv_anim_init(&a);
lv_anim_set_exec_cb(&a, ddlist, list_anim);

View File

@@ -570,7 +570,7 @@ static lv_design_res_t lv_img_design(lv_obj_t * img, const lv_area_t * clip_area
lv_draw_label_dsc_init(&label_dsc);
lv_obj_init_draw_label_dsc(img, LV_IMG_PART_MAIN, &label_dsc);
label_dsc.color = lv_obj_get_style_image_recolor(img, LV_CANVAS_PART_MAIN);
label_dsc.color = lv_obj_get_style_image_recolor(img, LV_IMG_PART_MAIN);
lv_draw_label(&img_coords, clip_area, &label_dsc, ext->src, NULL);
} else {
/*Trigger the error handler of image drawer*/

View File

@@ -286,6 +286,7 @@ static lv_design_res_t lv_imgbtn_design(lv_obj_t * imgbtn, const lv_area_t * cli
} else {
lv_draw_img_dsc_t img_dsc;
lv_draw_img_dsc_init(&img_dsc);
lv_obj_init_draw_img_dsc(imgbtn, LV_IMGBTN_PART_MAIN, &img_dsc);
lv_draw_img(&imgbtn->coords, clip_area, src, &img_dsc);
}
#else

View File

@@ -666,8 +666,8 @@ static lv_design_res_t lv_page_design(lv_obj_t * page, const lv_area_t * clip_ar
sb_ver_area.x2 += page->coords.x1;
sb_ver_area.y2 += page->coords.y1;
if((ext->sb.hor_draw && lv_area_is_in(&sb_hor_area, clip_area, 0)) ||
(ext->sb.ver_draw && lv_area_is_in(&sb_ver_area, clip_area, 0))) {
if((ext->sb.hor_draw && lv_area_is_on(&sb_hor_area, clip_area)) ||
(ext->sb.ver_draw && lv_area_is_on(&sb_ver_area, clip_area))) {
/*Draw the scrollbars*/
lv_draw_rect_dsc_t rect_dsc;
lv_draw_rect_dsc_init(&rect_dsc);
@@ -1197,7 +1197,7 @@ static void lv_page_sb_refresh(lv_obj_t * page)
lv_area_set_pos(&ext->sb.ver_area,
obj_w - sb_width - sb_right,
sb_ver_pad + (-(lv_obj_get_y(scrl) - sb_bottom) *
sb_ver_pad + (-(lv_obj_get_y(scrl) - bg_left) *
(obj_h - size_tmp - 2 * sb_ver_pad)) /
(scrl_h + bg_top + bg_bottom - obj_h));

View File

@@ -95,7 +95,10 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy)
}
/*Copy an existing slider*/
else {
// lv_slider_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_slider_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_style_list_copy(&ext->style_knob, &copy_ext->style_knob);
lv_area_copy(&ext->left_knob_area, &copy_ext->left_knob_area);
lv_area_copy(&ext->right_knob_area, &copy_ext->right_knob_area);
}
LV_LOG_INFO("slider created");

View File

@@ -86,20 +86,20 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
LV_LOG_TRACE("text area create started");
/*Create the ancestor object*/
lv_obj_t * new_ta = lv_page_create(par, copy);
LV_ASSERT_MEM(new_ta);
if(new_ta == NULL) return NULL;
lv_obj_t * ta = lv_page_create(par, copy);
LV_ASSERT_MEM(ta);
if(ta == NULL) return NULL;
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ta);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_ta);
if(scrl_signal == NULL) scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_ta));
if(scrl_design == NULL) scrl_design = lv_obj_get_design_cb(lv_page_get_scrl(new_ta));
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(ta);
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(ta);
if(scrl_signal == NULL) scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(ta));
if(scrl_design == NULL) scrl_design = lv_obj_get_design_cb(lv_page_get_scrl(ta));
/*Allocate the object type specific extended data*/
lv_ta_ext_t * ext = lv_obj_allocate_ext_attr(new_ta, sizeof(lv_ta_ext_t));
lv_ta_ext_t * ext = lv_obj_allocate_ext_attr(ta, sizeof(lv_ta_ext_t));
LV_ASSERT_MEM(ext);
if(ext == NULL) {
lv_obj_del(new_ta);
lv_obj_del(ta);
return NULL;
}
@@ -128,30 +128,32 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
ext->cursor.blink_time = 0;
#endif
lv_obj_set_signal_cb(new_ta, lv_ta_signal);
lv_obj_set_signal_cb(lv_page_get_scrl(new_ta), lv_ta_scrollable_signal);
lv_obj_set_design_cb(new_ta, lv_ta_design);
lv_obj_set_signal_cb(ta, lv_ta_signal);
lv_obj_set_signal_cb(lv_page_get_scrl(ta), lv_ta_scrollable_signal);
lv_obj_set_design_cb(ta, lv_ta_design);
/*Init the new text area object*/
if(copy == NULL) {
lv_page_set_scrl_fit2(new_ta, LV_FIT_FLOOD, LV_FIT_TIGHT);
lv_page_set_scrl_fit2(ta, LV_FIT_FLOOD, LV_FIT_TIGHT);
ext->label = lv_label_create(new_ta, NULL);
ext->label = lv_label_create(ta, NULL);
lv_obj_set_design_cb(ext->page.scrl, lv_ta_scrollable_design);
lv_label_set_long_mode(ext->label, LV_LABEL_LONG_BREAK);
lv_label_set_text(ext->label, "Text area");
lv_obj_set_click(ext->label, false);
lv_obj_set_size(new_ta, LV_TA_DEF_WIDTH, LV_TA_DEF_HEIGHT);
lv_ta_set_sb_mode(new_ta, LV_SB_MODE_DRAG);
lv_obj_set_size(ta, LV_TA_DEF_WIDTH, LV_TA_DEF_HEIGHT);
lv_ta_set_sb_mode(ta, LV_SB_MODE_DRAG);
lv_theme_apply(ta, LV_THEME_TA);
}
/*Copy an existing object*/
else {
lv_obj_set_design_cb(ext->page.scrl, lv_ta_scrollable_design);
lv_ta_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->label = lv_label_create(new_ta, copy_ext->label);
ext->label = lv_label_create(ta, copy_ext->label);
ext->pwd_mode = copy_ext->pwd_mode;
ext->accapted_chars = copy_ext->accapted_chars;
ext->max_length = copy_ext->max_length;
@@ -159,10 +161,12 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
ext->cursor.pos = copy_ext->cursor.pos;
ext->cursor.valid_x = copy_ext->cursor.valid_x;
if(ext->pwd_mode != 0) pwd_char_hider( new_ta);
lv_style_list_copy(&ext->cursor.style, &copy_ext->cursor.style);
if(ext->pwd_mode != 0) pwd_char_hider( ta);
if(copy_ext->placeholder != NULL)
ext->placeholder = lv_label_create(new_ta, copy_ext->placeholder);
ext->placeholder = lv_label_create(ta, copy_ext->placeholder);
else
ext->placeholder = NULL;
@@ -175,19 +179,17 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len);
}
if(copy_ext->one_line) lv_ta_set_one_line(new_ta, true);
// lv_ta_set_style(new_ta, LV_TA_STYLE_CURSOR, lv_ta_get_style(copy, LV_TA_STYLE_CURSOR));
if(copy_ext->one_line) lv_ta_set_one_line(ta, true);
/*Refresh the style with new signal function*/
// lv_obj_refresh_style(new_ta);
lv_obj_refresh_style(ta);
}
#if LV_USE_ANIMATION
if(ext->cursor.blink_time) {
/*Create a cursor blinker animation*/
lv_anim_t a;
a.var = new_ta;
a.var = ta;
a.exec_cb = (lv_anim_exec_xcb_t)cursor_blink_anim;
a.time = ext->cursor.blink_time;
a.act_time = 0;
@@ -205,7 +207,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
LV_LOG_INFO("text area created");
return new_ta;
return ta;
}
/*======================

View File

@@ -102,7 +102,6 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(tabview, lv_tabview_signal);
// lv_obj_set_design_cb(tabview, NULL);
/*Init the new tab tab*/
if(copy == NULL) {
ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
@@ -129,11 +128,6 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
ext->btns = lv_btnm_create(tabview, NULL);
ext->indic = lv_obj_create(ext->btns, NULL);
// lv_obj_set_design_cb(ext->content, NULL);
// lv_obj_set_design_cb(lv_page_get_scrl(ext->content), NULL);
// lv_obj_set_design_cb(ext->btns, NULL);
// lv_obj_set_design_cb(ext->indic, NULL);
if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(ext->content));
lv_obj_set_signal_cb(lv_page_get_scrl(ext->content), tabview_scrl_signal);

View File

@@ -103,6 +103,8 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy)
lv_obj_set_protect(ext->header, LV_PROTECT_PARENT);
lv_obj_set_parent(ext->header, new_win);
if(ancestor_header_design == NULL) ancestor_header_design= lv_obj_get_design_cb(ext->header);
lv_obj_set_height(ext->header, LV_DPI / 2);
lv_obj_set_design_cb(ext->header, lv_win_header_design);
lv_obj_set_signal_cb(new_win, lv_win_signal);

View File

@@ -81,13 +81,13 @@ typedef enum {
LV_THEME_TA,
LV_THEME_TA_ONELINE,
LV_THEME_TA_CURSOR,
LV_THEME_TA_SCRLBAR,
LV_THEME_LIST,
LV_THEME_LIST_BTN,
LV_THEME_CANVAS,
LV_THEME_CPICKER,
LV_THEME_CALENDAR,
@@ -101,8 +101,6 @@ typedef enum {
LV_THEME_TABLE,
LV_THEME_CPICKER,
LV_THEME_CHART,
LV_THEME_WIN,

View File

@@ -105,6 +105,10 @@ static lv_style_t arc_bg;
static lv_style_t calendar_date_nums, calendar_header, calendar_daynames;
#endif
#if LV_USE_CPICKER
static lv_style_t cpicker_bg, cpicker_indic;
#endif
#if LV_USE_TABVIEW
static lv_style_t tabview_btns, tabview_btns_bg, tabview_indic, tabview_page_scrl;
@@ -502,7 +506,7 @@ static void chart_init(void)
lv_style_set_opa(&chart_series, LV_STYLE_BG_OPA, LV_OPA_100);
lv_style_set_int(&chart_series, LV_STYLE_BG_GRAD_DIR, LV_GRAD_DIR_VER);
lv_style_set_int(&chart_series, LV_STYLE_BG_MAIN_STOP, 96);
lv_style_set_int(&chart_series, LV_STYLE_BG_GRAD_STOP, 32);
lv_style_set_int(&chart_series, LV_STYLE_BG_GRAD_STOP, 0);
#endif
}
@@ -542,6 +546,30 @@ static void calendar_init(void)
#endif
}
static void cpicker_init(void)
{
#if LV_USE_CPICKER
lv_style_init(&cpicker_bg);
lv_style_set_scale_width(&cpicker_bg, LV_STYLE_STATE_NORMAL, LV_DPI / 4);
lv_style_set_bg_opa(&cpicker_bg, LV_STYLE_STATE_NORMAL, LV_OPA_COVER);
lv_style_set_bg_color(&cpicker_bg, LV_STYLE_STATE_NORMAL, COLOR_SCREEN);
lv_style_set_pad_inner(&cpicker_bg, LV_STYLE_STATE_NORMAL, LV_DPI / 10);
lv_style_set_radius(&cpicker_bg, LV_STYLE_STATE_NORMAL, LV_RADIUS_CIRCLE);
lv_style_init(&cpicker_indic);
lv_style_set_radius(&cpicker_indic, LV_STYLE_STATE_NORMAL, LV_RADIUS_CIRCLE);
lv_style_set_bg_color(&cpicker_indic, LV_STYLE_STATE_NORMAL, LV_COLOR_WHITE);
lv_style_set_bg_opa(&cpicker_indic, LV_STYLE_STATE_NORMAL, LV_OPA_COVER);
lv_style_set_border_width(&cpicker_indic, LV_STYLE_STATE_NORMAL, 2);
lv_style_set_border_color(&cpicker_indic, LV_STYLE_STATE_NORMAL, LV_COLOR_GRAY);
lv_style_set_pad_left(&cpicker_indic, LV_STYLE_STATE_NORMAL, LV_DPI / 10);
lv_style_set_pad_right(&cpicker_indic, LV_STYLE_STATE_NORMAL, LV_DPI / 10);
lv_style_set_pad_top(&cpicker_indic, LV_STYLE_STATE_NORMAL, LV_DPI / 10);
lv_style_set_pad_bottom(&cpicker_indic, LV_STYLE_STATE_NORMAL, LV_DPI / 10);
#endif
}
static void cb_init(void)
{
#if LV_USE_CB != 0
@@ -602,7 +630,11 @@ static void kb_init(void)
#if LV_USE_KB
lv_style_init(&kb_bg);
lv_style_copy(&kb_bg, &panel);
lv_style_set_int(&kb_bg, LV_STYLE_PAD_INNER, LV_DPI/10);
lv_style_set_pad_inner(&kb_bg, LV_STYLE_STATE_NORMAL, LV_DPI/20);
lv_style_set_pad_left(&kb_bg, LV_STYLE_STATE_NORMAL, LV_DPI/20);
lv_style_set_pad_right(&kb_bg, LV_STYLE_STATE_NORMAL, LV_DPI/20);
lv_style_set_pad_top(&kb_bg, LV_STYLE_STATE_NORMAL, LV_DPI/20);
lv_style_set_pad_bottom(&kb_bg, LV_STYLE_STATE_NORMAL, LV_DPI/20);
#endif
}
@@ -833,6 +865,7 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font)
preload_init();
chart_init();
calendar_init();
cpicker_init();
cb_init();
btnm_init();
kb_init();
@@ -949,6 +982,13 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
#endif
#if LV_USE_CANVAS
case LV_THEME_CANVAS:
list = lv_obj_get_style_list(obj, LV_CANVAS_PART_MAIN);
lv_style_list_reset(list);
break;
#endif
#if LV_USE_IMG
case LV_THEME_IMAGE:
list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN);
@@ -1192,16 +1232,6 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
break;
#endif
#if LV_USE_CPICKER
case LV_THEME_CPICKER:
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
lv_style_list_reset(list);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_INDIC);
lv_style_list_reset(list);
lv_style_list_add_style(list, &panel);
break;
#endif
#if LV_USE_WIN
case LV_THEME_WIN:
list = lv_obj_get_style_list(obj, LV_WIN_PART_BG);
@@ -1223,11 +1253,29 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
case LV_THEME_WIN_BTN:
list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN);
lv_style_list_reset(list);
lv_style_list_add_style(list, &btn);
lv_style_list_add_style(list, &tabview_btns);
break;
#endif
#if LV_USE_TA
case LV_THEME_TA:
list = lv_obj_get_style_list(obj, LV_TA_PART_BG);
lv_style_list_reset(list);
lv_style_list_add_style(list, &panel);
list = lv_obj_get_style_list(obj, LV_TA_PART_PLACEHOLDER);
lv_style_list_reset(list);
lv_style_list_add_style(list, &ta_placeholder);
list = lv_obj_get_style_list(obj, LV_TA_PART_CURSOR);
lv_style_list_reset(list);
lv_style_list_add_style(list, &ta_cursor);
list = lv_obj_get_style_list(obj, LV_TA_PART_SCRLBAR);
lv_style_list_reset(list);
lv_style_list_add_style(list, &sb);
break;
case LV_THEME_TA_ONELINE:
list = lv_obj_get_style_list(obj, LV_TA_PART_BG);
lv_style_list_reset(list);
@@ -1266,6 +1314,18 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name)
lv_style_list_add_style(list, &calendar_daynames);
break;
#endif
#if LV_USE_CPICKER
case LV_THEME_CPICKER:
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_MAIN);
lv_style_list_reset(list);
lv_style_list_add_style(list, &cpicker_bg);
list = lv_obj_get_style_list(obj, LV_CPICKER_PART_INDIC);
lv_style_list_reset(list);
lv_style_list_add_style(list, &cpicker_indic);
break;
#endif
#if LV_USE_LMETER
case LV_THEME_LMETER:
list = lv_obj_get_style_list(obj, LV_LMETER_PART_MAIN);