mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Merge branch 'dev-5.3' into embeddedt-dev-5.3
This commit is contained in:
commit
bd38e5a7f2
@ -73,7 +73,7 @@ static bool line_next_x(line_draw_t * line);
|
||||
* @param opa_scale scale down all opacities by the factor
|
||||
*/
|
||||
void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask,
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
const lv_style_t * style, lv_opa_t opa_scale)
|
||||
{
|
||||
|
||||
if(style->line.width == 0) return;
|
||||
@ -279,16 +279,12 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
width = i;
|
||||
#if LV_ANTIALIAS
|
||||
width--;
|
||||
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
line_next(&pattern_line);
|
||||
}
|
||||
} else {
|
||||
pattern[0].x = 0;
|
||||
pattern[0].y = 0;
|
||||
}
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
@ -299,12 +295,22 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
aa_last_corner = 0;
|
||||
#endif
|
||||
|
||||
lv_coord_t x_center_ofs = 0;
|
||||
lv_coord_t y_center_ofs = 0;
|
||||
|
||||
if(width != 0) {
|
||||
x_center_ofs = pattern[width - 1].x / 2;
|
||||
y_center_ofs = pattern[width - 1].y / 2;
|
||||
}
|
||||
else {
|
||||
if(main_line->hor && main_line->p1.y >= main_line->p2.y + dir_ori) pattern[0].y --;
|
||||
if(!main_line->hor && main_line->p1.x >= main_line->p2.x + dir_ori) pattern[0].x --;
|
||||
}
|
||||
|
||||
/* Make the coordinates relative to the center */
|
||||
for(i = 0; i < width; i++) {
|
||||
pattern[i].x -= pattern[width - 1].x / 2;
|
||||
pattern[i].y -= pattern[width - 1].y / 2;
|
||||
pattern[i].x -= x_center_ofs;
|
||||
pattern[i].y -= y_center_ofs;
|
||||
#if LV_ANTIALIAS
|
||||
if(i != 0) {
|
||||
if(main_line->hor) {
|
||||
@ -312,16 +318,16 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
lv_coord_t seg_w = pattern[i].y - pattern[aa_last_corner].y;
|
||||
if(main_line->sy < 0) {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y + seg_w + 1,
|
||||
seg_w, mask, style->line.color, opa);
|
||||
seg_w, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y + seg_w + 1,
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
} else {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y,
|
||||
seg_w, mask, style->line.color, opa);
|
||||
seg_w, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y,
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
}
|
||||
aa_last_corner = i;
|
||||
}
|
||||
@ -330,16 +336,16 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
lv_coord_t seg_w = pattern[i].x - pattern[aa_last_corner].x;
|
||||
if(main_line->sx < 0) {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w + 1, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w, mask, style->line.color, opa);
|
||||
seg_w, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w + 1, main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
} else {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w, mask, style->line.color, opa);
|
||||
seg_w, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x, main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
-seg_w, mask, style->line.color, opa);
|
||||
}
|
||||
aa_last_corner = i;
|
||||
}
|
||||
@ -358,33 +364,33 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
lv_coord_t seg_w = pattern[width_safe - 1].y - pattern[aa_last_corner].y;
|
||||
if(main_line->sy < 0) {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y + seg_w,
|
||||
seg_w + main_line->sy, mask, style->line.color, opa);
|
||||
seg_w + main_line->sy, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y + seg_w,
|
||||
-(seg_w + main_line->sy), mask, style->line.color, opa);
|
||||
-(seg_w + main_line->sy), mask, style->line.color, opa);
|
||||
|
||||
} else {
|
||||
lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, main_line->p1.y + pattern[aa_last_corner].y,
|
||||
seg_w + main_line->sy, mask, style->line.color, opa);
|
||||
seg_w + main_line->sy, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, main_line->p2.y + pattern[aa_last_corner].y,
|
||||
-(seg_w + main_line->sy), mask, style->line.color, opa);
|
||||
-(seg_w + main_line->sy), mask, style->line.color, opa);
|
||||
}
|
||||
} else {
|
||||
lv_coord_t seg_w = pattern[width_safe - 1].x - pattern[aa_last_corner].x;
|
||||
if(main_line->sx < 0) {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w + main_line->sx, mask, style->line.color, opa);
|
||||
seg_w + main_line->sx, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w, main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-(seg_w + main_line->sx), mask, style->line.color, opa);
|
||||
-(seg_w + main_line->sx), mask, style->line.color, opa);
|
||||
|
||||
} else {
|
||||
lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x, main_line->p1.y + pattern[aa_last_corner].y - 1,
|
||||
seg_w + main_line->sx, mask, style->line.color, opa);
|
||||
seg_w + main_line->sx, mask, style->line.color, opa);
|
||||
|
||||
lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x, main_line->p2.y + pattern[aa_last_corner].y + 1,
|
||||
-(seg_w + main_line->sx), mask, style->line.color, opa);
|
||||
-(seg_w + main_line->sx), mask, style->line.color, opa);
|
||||
}
|
||||
|
||||
}
|
||||
@ -441,9 +447,9 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[0].x, prev_p.y + pattern[0].y - aa_shift1,
|
||||
-(main_line->p_act.x - prev_p.x), mask, style->line.color, opa);
|
||||
-(main_line->p_act.x - prev_p.x), mask, style->line.color, opa);
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x, prev_p.y + pattern[width_safe - 1].y + aa_shift2,
|
||||
main_line->p_act.x - prev_p.x, mask, style->line.color, opa);
|
||||
main_line->p_act.x - prev_p.x, mask, style->line.color, opa);
|
||||
#endif
|
||||
|
||||
first_run = false;
|
||||
@ -468,9 +474,9 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[0].x, prev_p.y + pattern[0].y - aa_shift1,
|
||||
-(main_line->p_act.x - prev_p.x + 1), mask, style->line.color, opa);
|
||||
-(main_line->p_act.x - prev_p.x + 1), mask, style->line.color, opa);
|
||||
lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x, prev_p.y + pattern[width_safe - 1].y + aa_shift2,
|
||||
main_line->p_act.x - prev_p.x + 1, mask, style->line.color, opa);
|
||||
main_line->p_act.x - prev_p.x + 1, mask, style->line.color, opa);
|
||||
#endif
|
||||
}
|
||||
/*Rather a vertical line*/
|
||||
@ -495,9 +501,9 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[0].x - aa_shift1, prev_p.y + pattern[0].y,
|
||||
-(main_line->p_act.y - prev_p.y), mask, style->line.color, opa);
|
||||
-(main_line->p_act.y - prev_p.y), mask, style->line.color, opa);
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2, prev_p.y + pattern[width_safe - 1].y,
|
||||
main_line->p_act.y - prev_p.y, mask, style->line.color, opa);
|
||||
main_line->p_act.y - prev_p.y, mask, style->line.color, opa);
|
||||
#endif
|
||||
|
||||
first_run = false;
|
||||
@ -524,9 +530,9 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[0].x - aa_shift1, prev_p.y + pattern[0].y,
|
||||
-(main_line->p_act.y - prev_p.y + 1), mask, style->line.color, opa);
|
||||
-(main_line->p_act.y - prev_p.y + 1), mask, style->line.color, opa);
|
||||
lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2, prev_p.y + pattern[width_safe - 1].y,
|
||||
main_line->p_act.y - prev_p.y + 1, mask, style->line.color, opa);
|
||||
main_line->p_act.y - prev_p.y + 1, mask, style->line.color, opa);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ void lv_font_init(void)
|
||||
* Create a pair from font name and font dsc. get function. After it 'font_get' can be used for this font
|
||||
* @param name name of the font
|
||||
* @param dsc_get_fp the font descriptor get function
|
||||
* @param parent add this font as charter set extension of 'parent'
|
||||
* @param parent add this font as character set extension of 'parent'
|
||||
*/
|
||||
void lv_font_add(lv_font_t * child, lv_font_t * parent)
|
||||
{
|
||||
|
@ -73,8 +73,9 @@ void lv_font_init(void);
|
||||
|
||||
/**
|
||||
* Create a pair from font name and font dsc. get function. After it 'font_get' can be used for this font
|
||||
* @param child pointer to a font to join to the 'parent'
|
||||
* @param parent pointer to a font. 'child' will be joined here
|
||||
* @param name name of the font
|
||||
* @param dsc_get_fp the font descriptor get function
|
||||
* @param parent add this font as character set extension of 'parent'
|
||||
*/
|
||||
void lv_font_add(lv_font_t *child, lv_font_t *parent);
|
||||
|
||||
|
@ -287,6 +287,12 @@ void lv_ddlist_set_style(lv_obj_t * ddlist, lv_ddlist_style_t type, lv_style_t *
|
||||
}
|
||||
}
|
||||
|
||||
void lv_ddlist_set_align(lv_obj_t *ddlist, lv_label_align_t align)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
lv_label_set_align(ext->label, align);
|
||||
}
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@ -407,6 +413,14 @@ lv_style_t * lv_ddlist_get_style(const lv_obj_t * ddlist, lv_ddlist_style_t type
|
||||
/*To avoid warning*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_label_align_t lv_ddlist_get_align(const lv_obj_t *ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
return lv_label_get_align(ext->label);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
@ -447,6 +461,32 @@ void lv_ddlist_close(lv_obj_t * ddlist, bool anim_en)
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get the text alignment flag for a drop down list.
|
||||
* @param ddlist drop down list
|
||||
* @return text alignment flag
|
||||
*/
|
||||
static lv_txt_flag_t lv_ddlist_get_txt_flag(const lv_obj_t *ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
|
||||
|
||||
/*The label might be already deleted so just return with some value*/
|
||||
if(!ext->label) return LV_TXT_FLAG_CENTER;
|
||||
|
||||
lv_label_align_t align = lv_label_get_align(ext->label);
|
||||
|
||||
switch(align)
|
||||
{
|
||||
default:
|
||||
case LV_LABEL_ALIGN_LEFT:
|
||||
return LV_TXT_FLAG_NONE;
|
||||
case LV_LABEL_ALIGN_CENTER:
|
||||
return LV_TXT_FLAG_CENTER;
|
||||
case LV_LABEL_ALIGN_RIGHT:
|
||||
return LV_TXT_FLAG_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the drop down lists
|
||||
* @param ddlist pointer to an object
|
||||
@ -517,8 +557,9 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
lv_style_copy(&new_style, style);
|
||||
new_style.text.color = sel_style->text.color;
|
||||
new_style.text.opa = sel_style->text.opa;
|
||||
lv_txt_flag_t flag = lv_ddlist_get_txt_flag(ddlist);
|
||||
lv_draw_label(&ext->label->coords, &mask_sel, &new_style, opa_scale,
|
||||
lv_label_get_text(ext->label), LV_TXT_FLAG_NONE, NULL);
|
||||
lv_label_get_text(ext->label), flag, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,6 +150,13 @@ void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time);
|
||||
* */
|
||||
void lv_ddlist_set_style(lv_obj_t *ddlist, lv_ddlist_style_t type, lv_style_t *style);
|
||||
|
||||
/**
|
||||
* Set the alignment of the labels in a drop down list
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @param align alignment of labels
|
||||
*/
|
||||
void lv_ddlist_set_align(lv_obj_t *ddlist, lv_label_align_t align);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@ -220,6 +227,13 @@ uint16_t lv_ddlist_get_anim_time(const lv_obj_t * ddlist);
|
||||
*/
|
||||
lv_style_t * lv_ddlist_get_style(const lv_obj_t *ddlist, lv_ddlist_style_t type);
|
||||
|
||||
/**
|
||||
* Get the alignment of the labels in a drop down list
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @return alignment of labels
|
||||
*/
|
||||
lv_label_align_t lv_ddlist_get_align(const lv_obj_t *ddlist);
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
@ -447,10 +447,10 @@ lv_obj_t * lv_list_get_btn_img(const lv_obj_t * btn)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next button from list. (Starts from the bottom button)
|
||||
* Get the previous button from list. (Starts from the top button)
|
||||
* @param list pointer to a list object
|
||||
* @param prev_btn pointer to button. Search the next after it.
|
||||
* @return pointer to the next button or NULL when no more buttons
|
||||
* @param prev_btn pointer to button. Search the previous before it.
|
||||
* @return pointer to the previous button or NULL when no more buttons
|
||||
*/
|
||||
lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
||||
{
|
||||
@ -472,11 +472,12 @@ lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the previous button from list. (Starts from the top button)
|
||||
|
||||
/**
|
||||
* Get the next button from list. (Starts from the bottom button)
|
||||
* @param list pointer to a list object
|
||||
* @param prev_btn pointer to button. Search the previous before it.
|
||||
* @return pointer to the previous button or NULL when no more buttons
|
||||
* @param prev_btn pointer to button. Search the next after it.
|
||||
* @return pointer to the next button or NULL when no more buttons
|
||||
*/
|
||||
lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
||||
{
|
||||
|
@ -334,10 +334,8 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
lv_align_t obj_align = LV_ALIGN_IN_LEFT_MID;
|
||||
|
||||
{
|
||||
if(ext->ddlist.label) {
|
||||
lv_label_align_t label_align = lv_label_get_align(ext->ddlist.label);
|
||||
|
||||
if(LV_LABEL_ALIGN_CENTER == label_align) obj_align = LV_ALIGN_CENTER;
|
||||
else if(LV_LABEL_ALIGN_RIGHT == label_align) obj_align = LV_ALIGN_IN_RIGHT_MID;
|
||||
}
|
||||
|
@ -966,11 +966,12 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_
|
||||
uint32_t byte_pos;
|
||||
#if LV_TXT_UTF8 != 0
|
||||
byte_pos = lv_txt_encoded_get_byte_id(txt, cur_pos);
|
||||
uint32_t letter = lv_txt_encoded_next(&txt[byte_pos], NULL);
|
||||
#else
|
||||
byte_pos = cur_pos;
|
||||
uint32_t letter = txt[byte_pos];
|
||||
#endif
|
||||
|
||||
uint32_t letter = lv_txt_encoded_next(&txt[byte_pos], NULL);
|
||||
lv_coord_t letter_h = lv_font_get_height(label_style->text.font);
|
||||
/*Set letter_w (set not 0 on non printable but valid chars)*/
|
||||
lv_coord_t letter_w;
|
||||
@ -1003,6 +1004,7 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*Draw he cursor according to the type*/
|
||||
lv_area_t cur_area;
|
||||
if(ext->cursor.type == LV_CURSOR_LINE) {
|
||||
|
@ -28,8 +28,6 @@
|
||||
|
||||
static uint16_t _hue;
|
||||
static lv_font_t * _font;
|
||||
static lv_font_t * _font;
|
||||
static lv_font_t * _font;
|
||||
|
||||
static lv_theme_t theme;
|
||||
static lv_style_t def;
|
||||
|
@ -36,7 +36,6 @@ static lv_style_t light_frame;
|
||||
static lv_style_t dark_frame;
|
||||
|
||||
/*Saved input parameters*/
|
||||
static uint16_t _hue;
|
||||
static lv_font_t * _font;
|
||||
|
||||
|
||||
@ -421,7 +420,7 @@ static void win_init(void)
|
||||
|
||||
/**
|
||||
* Initialize the mono theme
|
||||
* @param hue [0..360] hue value from HSV color space to define the theme's base color
|
||||
* @param hue [0..360] hue value from HSV color space to define the theme's base color; is not used in lv_theme_mono
|
||||
* @param font pointer to a font (NULL to use the default)
|
||||
* @return pointer to the initialized theme
|
||||
*/
|
||||
@ -429,7 +428,6 @@ lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font)
|
||||
{
|
||||
if(font == NULL) font = LV_FONT_DEFAULT;
|
||||
|
||||
_hue = hue;
|
||||
_font = font;
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
|
Loading…
x
Reference in New Issue
Block a user