mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Merge branch 'beta' into dev-5.2
This commit is contained in:
commit
a23a6f7c90
@ -104,8 +104,6 @@
|
||||
/* More info about fonts: https://littlevgl.com/basics#fonts
|
||||
* To enable a built-in font use 1,2,4 or 8 values
|
||||
* which will determine the bit-per-pixel */
|
||||
#define LV_FONT_DEFAULT &lv_font_dejavu_20 /*Always set a default font from the built-in fonts*/
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_10 0
|
||||
#define USE_LV_FONT_DEJAVU_10_LATIN_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_10_CYRILLIC 0
|
||||
@ -126,6 +124,16 @@
|
||||
#define USE_LV_FONT_DEJAVU_40_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_40 0
|
||||
|
||||
/* Optionally declare your custom fonts here.
|
||||
* You can use these fonts as defult font too
|
||||
* and they will be avialale globally. E.g.
|
||||
* #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \
|
||||
* LV_FONT_DECLARE(my_font_2) \
|
||||
*/
|
||||
#define LV_FONT_CUSTOM_DECLARE
|
||||
|
||||
#define LV_FONT_DEFAULT &lv_font_dejavu_20 /*Always set a default font from the built-in fonts*/
|
||||
|
||||
/*===================
|
||||
* LV_OBJ SETTINGS
|
||||
*==================*/
|
||||
|
@ -152,9 +152,9 @@ int16_t lv_font_get_width_sparse(const lv_font_t * font, uint32_t unicode_letter
|
||||
**********************/
|
||||
#define LV_FONT_DECLARE(font_name) extern lv_font_t font_name;
|
||||
|
||||
/******************************
|
||||
* FONT DECLARATION INCLUDES
|
||||
*****************************/
|
||||
/**********************
|
||||
* FONT DECLARATION
|
||||
**********************/
|
||||
|
||||
/*10 px */
|
||||
#if USE_LV_FONT_DEJAVU_10
|
||||
@ -224,6 +224,9 @@ LV_FONT_DECLARE(lv_font_dejavu_40_cyrillic);
|
||||
LV_FONT_DECLARE(lv_font_symbol_40);
|
||||
#endif
|
||||
|
||||
/*Declare the custom (user defined) fonts*/
|
||||
LV_FONT_CUSTOM_DECLARE
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -449,7 +449,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
rect_area.y1 += ext->sel_opt_id * (font_h + style->text.line_space);
|
||||
rect_area.y1 -= style->text.line_space / 2;
|
||||
|
||||
rect_area.y2 = rect_area.y1 + font_h + style->text.line_space;
|
||||
rect_area.y2 = rect_area.y1 + font_h + style->text.line_space - 1;
|
||||
rect_area.x1 = ddlist->coords.x1;
|
||||
rect_area.x2 = ddlist->coords.x2;
|
||||
|
||||
@ -476,7 +476,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
|
||||
area_sel.y1 += ext->sel_opt_id * (font_h + style->text.line_space);
|
||||
area_sel.y1 -= style->text.line_space / 2;
|
||||
|
||||
area_sel.y2 = area_sel.y1 + font_h + style->text.line_space;
|
||||
area_sel.y2 = area_sel.y1 + font_h + style->text.line_space - 1;
|
||||
area_sel.x1 = ddlist->coords.x1;
|
||||
area_sel.x2 = ddlist->coords.x2;
|
||||
lv_area_t mask_sel;
|
||||
@ -636,9 +636,12 @@ static lv_res_t lv_ddlist_release_action(lv_obj_t * ddlist)
|
||||
|
||||
uint16_t new_opt = 0;
|
||||
const char * txt = lv_label_get_text(ext->label);
|
||||
uint16_t i;
|
||||
for(i = 0; i < letter_i; i++) {
|
||||
if(txt[i] == '\n') new_opt ++;
|
||||
uint32_t i = 0;
|
||||
uint32_t line_cnt = 0;
|
||||
uint32_t letter;
|
||||
for(line_cnt = 0; line_cnt < letter_i; line_cnt++) {
|
||||
letter = lv_txt_utf8_next(txt, &i);
|
||||
if(letter == '\n') new_opt ++;
|
||||
}
|
||||
|
||||
ext->sel_opt_id = new_opt;
|
||||
@ -679,9 +682,9 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
||||
if(anim_en == 0) {
|
||||
lv_obj_set_height(ddlist, new_height);
|
||||
lv_ddlist_pos_current_option(ddlist);
|
||||
#if USE_LV_ANIMATION
|
||||
lv_anim_del(ddlist, (lv_anim_fp_t)lv_obj_set_height); /*If an animation is in progress then it will overwrite this changes*/
|
||||
} else {
|
||||
#if USE_LV_ANIMATION
|
||||
lv_anim_t a;
|
||||
a.var = ddlist;
|
||||
a.start = lv_obj_get_height(ddlist);
|
||||
|
@ -21,6 +21,7 @@
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_PAGE_SB_MIN_SIZE (LV_DPI / 8)
|
||||
#define LV_PAGE_GROUP_SCROLL_ANIM_TIME 200
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@ -292,6 +293,16 @@ void lv_page_glue_obj(lv_obj_t * obj, bool glue)
|
||||
*/
|
||||
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
|
||||
{
|
||||
|
||||
#if USE_LV_ANIMATION == 0
|
||||
anim_time = 0;
|
||||
#else
|
||||
/* Be sure there is no position changing animation in progress
|
||||
* because it can overide the current changes*/
|
||||
lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_y);
|
||||
lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_pos);
|
||||
#endif
|
||||
|
||||
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
||||
lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||
lv_style_t * style_scrl = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
||||
@ -327,8 +338,8 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
|
||||
|
||||
if(anim_time == 0) {
|
||||
lv_obj_set_y(ext->scrl, scrlable_y);
|
||||
} else {
|
||||
#if USE_LV_ANIMATION
|
||||
} else {
|
||||
lv_anim_t a;
|
||||
a.act_time = 0;
|
||||
a.start = lv_obj_get_y(ext->scrl);
|
||||
@ -525,6 +536,49 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
/*Ensure ext. size for the scrollbars if they are out of the page*/
|
||||
if(page->ext_size < (-ext->sb.style->body.padding.hor)) page->ext_size = -ext->sb.style->body.padding.hor;
|
||||
if(page->ext_size < (-ext->sb.style->body.padding.ver)) page->ext_size = -ext->sb.style->body.padding.ver;
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
uint32_t c = *((uint32_t *) param);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(page);
|
||||
if(c == LV_GROUP_KEY_DOWN || c == LV_GROUP_KEY_RIGHT) {
|
||||
#if USE_LV_ANIMATION
|
||||
lv_anim_t a;
|
||||
a.var = scrl;
|
||||
a.start = lv_obj_get_y(scrl);
|
||||
a.end = a.start - LV_DPI / 2;
|
||||
a.fp = (lv_anim_fp_t)lv_obj_set_y;
|
||||
a.path = lv_anim_path_linear;
|
||||
a.end_cb = NULL;
|
||||
a.act_time = 0;
|
||||
a.time = LV_PAGE_GROUP_SCROLL_ANIM_TIME;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
lv_anim_create(&a);
|
||||
#else
|
||||
lv_obj_set_y(scrl, lv_obj_get_y(scrl) - LV_DPI / 2);
|
||||
#endif
|
||||
|
||||
} else if(c == LV_GROUP_KEY_UP || c == LV_GROUP_KEY_LEFT) {
|
||||
#if USE_LV_ANIMATION
|
||||
lv_anim_t a;
|
||||
a.var = scrl;
|
||||
a.start = lv_obj_get_y(scrl);
|
||||
a.end = a.start + LV_DPI / 2;
|
||||
a.fp = (lv_anim_fp_t)lv_obj_set_y;
|
||||
a.path = lv_anim_path_linear;
|
||||
a.end_cb = NULL;
|
||||
a.act_time = 0;
|
||||
a.time = LV_PAGE_GROUP_SCROLL_ANIM_TIME;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
lv_anim_create(&a);
|
||||
#else
|
||||
lv_obj_set_y(scrl, lv_obj_get_y(scrl) - LV_DPI / 2);
|
||||
#endif
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
uint8_t i;
|
||||
|
@ -229,7 +229,8 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
|
||||
lv_coord_t font_h = lv_font_get_height(font);
|
||||
lv_area_t rect_area;
|
||||
rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space / 2;
|
||||
rect_area.y2 = rect_area.y1 + font_h + style->text.line_space;
|
||||
if((font_h & 0x1) && (style->text.line_space & 0x1)) rect_area.y1 --; /*Compensate the two rounding error*/
|
||||
rect_area.y2 = rect_area.y1 + font_h + style->text.line_space - 1;
|
||||
rect_area.x1 = roller->coords.x1;
|
||||
rect_area.x2 = roller->coords.x2;
|
||||
|
||||
@ -246,7 +247,8 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
|
||||
/*Redraw the text on the selected area with a different color*/
|
||||
lv_area_t rect_area;
|
||||
rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space / 2;
|
||||
rect_area.y2 = rect_area.y1 + font_h + style->text.line_space;
|
||||
if((font_h & 0x1) && (style->text.line_space & 0x1)) rect_area.y1 --; /*Compensate the two rounding error*/
|
||||
rect_area.y2 = rect_area.y1 + font_h + style->text.line_space - 1;
|
||||
rect_area.x1 = roller->coords.x1;
|
||||
rect_area.x2 = roller->coords.x2;
|
||||
lv_area_t mask_sel;
|
||||
|
@ -255,7 +255,7 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en)
|
||||
lv_style_t * style = lv_obj_get_style(ext->content);
|
||||
|
||||
if(id >= ext->tab_cnt) id = ext->tab_cnt - 1;
|
||||
if(ext->tab_load_action) ext->tab_load_action(tabview, id);
|
||||
if(ext->tab_load_action && id != ext->tab_cur) ext->tab_load_action(tabview, id);
|
||||
|
||||
ext->tab_cur = id;
|
||||
|
||||
@ -723,7 +723,7 @@ static void tabpage_press_lost_handler(lv_obj_t * tabview, lv_obj_t * tabpage)
|
||||
if(tab_cur < ext->tab_cnt - 1) tab_cur++;
|
||||
}
|
||||
|
||||
if(tab_cur != ext->tab_cur) lv_tabview_set_tab_act(tabview, tab_cur, true);
|
||||
lv_tabview_set_tab_act(tabview, tab_cur, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user