minor API changes

This commit is contained in:
Gabor Kiss-Vamosi
2019-06-19 00:35:35 +02:00
parent b9081cacef
commit 6cfcc3fa55
17 changed files with 2625 additions and 180 deletions
+1
View File
@@ -2,3 +2,4 @@
**/*.swp
**/*.swo
tags
docs/api_doc
+2455
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -2,6 +2,7 @@
* GENERATED FILE, DO NOT EDIT IT!
* @file lv_conf_checker.h
* Make sure all the defines of lv_conf.h have a default value
* \internal
**/
#ifndef LV_CONF_CHECKER_H
+6 -6
View File
@@ -37,14 +37,14 @@ extern "C" {
* TYPEDEFS
**********************/
/* Button states
/** Possible states of a button.
* It can be used not only by buttons but other button-like objects too*/
enum {
LV_BTN_STATE_REL,
LV_BTN_STATE_PR,
LV_BTN_STATE_TGL_REL,
LV_BTN_STATE_TGL_PR,
LV_BTN_STATE_INA,
LV_BTN_STATE_REL, /**Released*/
LV_BTN_STATE_PR, /**Pressed*/
LV_BTN_STATE_TGL_REL, /**Toggled released*/
LV_BTN_STATE_TGL_PR, /**Toggled pressed*/
LV_BTN_STATE_INA, /**Inactive*/
LV_BTN_STATE_NUM,
};
typedef uint8_t lv_btn_state_t;
+4 -34
View File
@@ -21,11 +21,7 @@
/*********************
* DEFINES
*********************/
#if LV_USE_ANIMATION
#ifndef LV_DDLIST_DEF_ANIM_TIME
#define LV_DDLIST_DEF_ANIM_TIME 200 /*ms*/
#endif
#else
#if LV_USE_ANIMATION == 0
#undef LV_DDLIST_DEF_ANIM_TIME
#define LV_DDLIST_DEF_ANIM_TIME 0 /*No animation*/
#endif
@@ -97,7 +93,6 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
ext->sel_opt_id = 0;
ext->sel_opt_id_ori = 0;
ext->option_cnt = 0;
ext->anim_time = LV_DDLIST_DEF_ANIM_TIME;
ext->sel_style = &lv_style_plain_color;
ext->draw_arrow = 0; /*Do not draw arrow by default*/
ext->stay_open = 0;
@@ -109,6 +104,8 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new drop down list drop down list*/
if(copy == NULL) {
lv_page_set_anim_time(new_ddlist, LV_DDLIST_DEF_ANIM_TIME);
lv_obj_t * scrl = lv_page_get_scrl(new_ddlist);
lv_obj_set_drag(scrl, false);
lv_page_set_scrl_fit2(new_ddlist, LV_FIT_FILL, LV_FIT_TIGHT);
@@ -142,7 +139,6 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
ext->fix_height = copy_ext->fix_height;
ext->option_cnt = copy_ext->option_cnt;
ext->sel_style = copy_ext->sel_style;
ext->anim_time = copy_ext->anim_time;
ext->draw_arrow = copy_ext->draw_arrow;
ext->stay_open = copy_ext->stay_open;
@@ -273,21 +269,6 @@ void lv_ddlist_set_stay_open(lv_obj_t * ddlist, bool en)
ext->stay_open = en ? 1 : 0;
}
/**
* Set the open/close animation time.
* @param ddlist pointer to a drop down list
* @param anim_time: open/close animation time [ms]
*/
void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
#if LV_USE_ANIMATION == 0
anim_time = 0;
#endif
ext->anim_time = anim_time;
}
/**
* Set a style of a drop down list
* @param ddlist pointer to a drop down list object
@@ -414,17 +395,6 @@ bool lv_ddlist_get_stay_open(lv_obj_t * ddlist)
return ext->stay_open ? true : false;
}
/**
* Get the open/close animation time.
* @param ddlist pointer to a drop down list
* @return open/close animation time [ms]
*/
uint16_t lv_ddlist_get_anim_time(const lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->anim_time;
}
/**
* Get a style of a drop down list
* @param ddlist pointer to a drop down list object
@@ -888,7 +858,7 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, lv_anim_enable_t anim)
a.path_cb = lv_anim_path_linear;
a.ready_cb = lv_ddlist_anim_ready_cb;
a.act_time = 0;
a.time = ext->anim_time;
a.time = lv_ddlist_get_anim_time(ddlist);
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
+19 -1
View File
@@ -51,7 +51,6 @@ typedef struct
uint16_t option_cnt; /*Number of options*/
uint16_t sel_opt_id; /*Index of the current option*/
uint16_t sel_opt_id_ori; /*Store the original index on focus*/
uint16_t anim_time; /*Open/Close animation time [ms]*/
uint8_t opened : 1; /*1: The list is opened (handled by the library)*/
uint8_t force_sel : 1; /*1: Keep the selection highlight even if the list is closed*/
uint8_t draw_arrow : 1; /*1: Draw arrow*/
@@ -134,6 +133,15 @@ static inline void lv_ddlist_set_sb_mode(lv_obj_t * ddlist, lv_sb_mode_t mode)
{
lv_page_set_sb_mode(ddlist, mode);
}
/**
* Set the open/close animation time.
* @param ddlist pointer to a drop down list
* @param anim_time: open/close animation time [ms]
*/
static inline void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time)
{
lv_page_set_anim_time(ddlist, anim_time);
}
/**
* Set the open/close animation time.
@@ -212,6 +220,16 @@ static inline lv_sb_mode_t lv_ddlist_get_sb_mode(const lv_obj_t * ddlist)
return lv_page_get_sb_mode(ddlist);
}
/**
* Get the open/close animation time.
* @param ddlist pointer to a drop down list
* @return open/close animation time [ms]
*/
static inline uint16_t lv_ddlist_get_anim_time(const lv_obj_t * ddlist)
{
return lv_page_get_anim_time(ddlist);
}
/**
* Get the open/close animation time.
* @param ddlist pointer to a drop down list
-18
View File
@@ -206,24 +206,6 @@ void lv_img_set_auto_size(lv_obj_t * img, bool en)
ext->auto_size = (en == false ? 0 : 1);
}
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
* @param img pointer to an image
* @param x: the new offset along x axis.
* @param y: the new offset along y axis.
*/
void lv_img_set_offset(lv_obj_t * img, lv_coord_t x, lv_coord_t y)
{
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
if((x < ext->w - 1) && (y < ext->h - 1)) {
ext->offset.x = x;
ext->offset.y = y;
lv_obj_invalidate(img);
}
}
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
-21
View File
@@ -76,18 +76,6 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy);
*/
void lv_img_set_src(lv_obj_t * img, const void * src_img);
/**
* Obsolete since v5.1. Just for compatibility with v5.0. Will be removed in v6.0.
* Use 'lv_img_set_src()' instead.
* @param img -
* @param fn -
*/
static inline void lv_img_set_file(lv_obj_t * img, const char * fn)
{
(void)img;
(void)fn;
}
/**
* Enable the auto size feature.
* If enabled the object size will be same as the picture size.
@@ -96,15 +84,6 @@ static inline void lv_img_set_file(lv_obj_t * img, const char * fn)
*/
void lv_img_set_auto_size(lv_obj_t * img, bool autosize_en);
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
* @param img pointer to an image
* @param x: the new offset along x axis.
* @param y: the new offset along y axis.
*/
void lv_img_set_offset(lv_obj_t * img, lv_coord_t x, lv_coord_t y);
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
+7 -7
View File
@@ -278,7 +278,7 @@ void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
ext->offset.x = 0;
ext->offset.y = 0;
if(long_mode == LV_LABEL_LONG_ROLL || long_mode == LV_LABEL_LONG_ROLL_CIRC || long_mode == LV_LABEL_LONG_CROP)
if(long_mode == LV_LABEL_LONG_SROLL || long_mode == LV_LABEL_LONG_SROLL_CIRC || long_mode == LV_LABEL_LONG_CROP)
ext->expand = 1;
else
ext->expand = 0;
@@ -354,7 +354,7 @@ void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed)
ext->anim_speed = anim_speed;
if(ext->long_mode == LV_LABEL_LONG_ROLL || ext->long_mode == LV_LABEL_LONG_ROLL_CIRC) {
if(ext->long_mode == LV_LABEL_LONG_SROLL || ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) {
lv_label_refr_text(label);
}
#endif
@@ -838,7 +838,7 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
/* In ROLL mode the CENTER and RIGHT are pointless so remove them.
* (In addition they will result mis-alignment is this case)*/
if((ext->long_mode == LV_LABEL_LONG_ROLL || ext->long_mode == LV_LABEL_LONG_ROLL_CIRC) &&
if((ext->long_mode == LV_LABEL_LONG_SROLL || ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) &&
(ext->align == LV_LABEL_ALIGN_CENTER || ext->align == LV_LABEL_ALIGN_RIGHT)) {
lv_point_t size;
lv_txt_get_size(&size, ext->text, style->text.font, style->text.letter_space, style->text.line_space,
@@ -850,12 +850,12 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
}
lv_draw_label_hint_t * hint = &ext->hint;
if(ext->long_mode == LV_LABEL_LONG_ROLL_CIRC || lv_obj_get_height(label) < LV_LABEL_HINT_HEIGHT_LIMIT) hint = NULL;
if(ext->long_mode == LV_LABEL_LONG_SROLL_CIRC || lv_obj_get_height(label) < LV_LABEL_HINT_HEIGHT_LIMIT) hint = NULL;
lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ext->offset,
lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label), hint);
if(ext->long_mode == LV_LABEL_LONG_ROLL_CIRC) {
if(ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) {
lv_point_t size;
lv_txt_get_size(&size, ext->text, style->text.font, style->text.letter_space, style->text.line_space,
LV_COORD_MAX, flag);
@@ -971,7 +971,7 @@ static void lv_label_refr_text(lv_obj_t * label)
lv_obj_set_size(label, size.x, size.y);
}
/*In roll mode keep the size but start offset animations*/
else if(ext->long_mode == LV_LABEL_LONG_ROLL) {
else if(ext->long_mode == LV_LABEL_LONG_SROLL) {
#if LV_USE_ANIMATION
lv_anim_t anim;
anim.var = label;
@@ -1014,7 +1014,7 @@ static void lv_label_refr_text(lv_obj_t * label)
#endif
}
/*In roll inf. mode keep the size but start offset animations*/
else if(ext->long_mode == LV_LABEL_LONG_ROLL_CIRC) {
else if(ext->long_mode == LV_LABEL_LONG_SROLL_CIRC) {
#if LV_USE_ANIMATION
lv_anim_t anim;
anim.var = label;
+2 -2
View File
@@ -44,8 +44,8 @@ enum {
LV_LABEL_LONG_BREAK, /*Keep the object width, break the too long lines and expand the object
height*/
LV_LABEL_LONG_DOT, /*Keep the size and write dots at the end if the text is too long*/
LV_LABEL_LONG_ROLL, /*Keep the size and roll the text back and forth*/
LV_LABEL_LONG_ROLL_CIRC, /*Keep the size and roll the text circularly*/
LV_LABEL_LONG_SROLL, /*Keep the size and roll the text back and forth*/
LV_LABEL_LONG_SROLL_CIRC, /*Keep the size and roll the text circularly*/
LV_LABEL_LONG_CROP, /*Keep the size and crop the text out of it*/
};
typedef uint8_t lv_label_long_mode_t;
+8 -48
View File
@@ -19,13 +19,7 @@
*********************/
#define LV_LIST_LAYOUT_DEF LV_LAYOUT_COL_M
#if LV_USE_ANIMATION
/*Animation time of focusing to the a list element [ms] (0: no animation) */
#ifndef LV_LIST_DEF_ANIM_TIME
#define LV_LIST_DEF_ANIM_TIME 100
#endif
#else
/*No animations*/
#if LV_USE_ANIMATION == 0
#undef LV_LIST_DEF_ANIM_TIME
#define LV_LIST_DEF_ANIM_TIME 0
#endif
@@ -39,7 +33,7 @@
**********************/
static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param);
static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param);
static void lv_list_btn_single_selected(lv_obj_t * btn);
static void lv_list_btn_single_select(lv_obj_t * btn);
static bool lv_list_is_list_btn(lv_obj_t * list_btn);
static bool lv_list_is_list_img(lv_obj_t * list_btn);
static bool lv_list_is_list_label(lv_obj_t * list_btn);
@@ -94,9 +88,6 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
ext->styles_btn[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_rel;
ext->styles_btn[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pr;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
#if LV_USE_ANIMATION
ext->anim_time = LV_LIST_DEF_ANIM_TIME;
#endif
ext->single_mode = false;
ext->size = 0;
@@ -109,6 +100,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
/*Init the new list object*/
if(copy == NULL) {
lv_page_set_anim_time(new_list, LV_LIST_DEF_ANIM_TIME);
lv_page_set_scrl_fit2(new_list, LV_FIT_FLOOD, LV_FIT_TIGHT);
lv_obj_set_size(new_list, 2 * LV_DPI, 3 * LV_DPI);
lv_page_set_scrl_layout(new_list, LV_LIST_LAYOUT_DEF);
@@ -223,7 +215,7 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
lv_obj_t * label = lv_label_create(liste, NULL);
lv_label_set_text(label, txt);
lv_obj_set_click(label, false);
lv_label_set_long_mode(label, LV_LABEL_LONG_ROLL_CIRC);
lv_label_set_long_mode(label, LV_LABEL_LONG_SROLL_CIRC);
lv_obj_set_width(label, liste->coords.x2 - label->coords.x1 - btn_hor_pad);
if(label_signal == NULL) label_signal = lv_obj_get_signal_cb(label);
}
@@ -304,7 +296,7 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
ext->selected_btn = btn;
/*Don't forgat whci hbutton was selected.
/*Don't forget which button was selected.
* It will be restored when the list is focused.*/
if(btn != NULL) {
ext->last_sel = btn;
@@ -323,22 +315,6 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
#endif
/**
* Set scroll animation duration on 'list_up()' 'list_down()' 'list_focus()'
* @param list pointer to a list object
* @param anim_time duration of animation [ms]
*/
void lv_list_set_anim_time(lv_obj_t * list, uint16_t anim_time)
{
#if LV_USE_ANIMATION
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
anim_time = 0;
if(ext->anim_time == anim_time) return;
ext->anim_time = anim_time;
#endif
}
/**
* Set a style of a list
* @param list pointer to a list object
@@ -558,21 +534,6 @@ lv_obj_t * lv_list_get_btn_selected(const lv_obj_t * list)
#endif
/**
* Get scroll animation duration
* @param list pointer to a list object
* @return duration of animation [ms]
*/
uint16_t lv_list_get_anim_time(const lv_obj_t * list)
{
#if LV_USE_ANIMATION
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
return ext->anim_time;
#else
return 0;
#endif
}
/**
* Get a style of a list
* @param list pointer to a list object
@@ -900,7 +861,7 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para
last_clicked_btn = btn;
#endif
if(lv_indev_is_dragging(lv_indev_get_act()) == false && ext->single_mode) {
lv_list_btn_single_selected(btn);
lv_list_btn_single_select(btn);
}
} else if(sign == LV_SIGNAL_PRESS_LOST) {
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
@@ -919,11 +880,10 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para
}
/**
* Make a single button selected in the list, deselect others, should be called in list btns call
* back.
* Make a single button selected in the list, deselect others.
* @param btn pointer to the currently pressed list btn object
*/
static void lv_list_btn_single_selected(lv_obj_t * btn)
static void lv_list_btn_single_select(lv_obj_t * btn)
{
lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn));
+21 -18
View File
@@ -55,9 +55,6 @@ typedef struct
const lv_style_t * styles_btn[LV_BTN_STATE_NUM]; /*Styles of the list element buttons*/
const lv_style_t * style_img; /*Style of the list element images on buttons*/
uint16_t size; /*the number of items(buttons) in the list*/
#if LV_USE_ANIMATION
uint16_t anim_time; /*Scroll animation time*/
#endif
uint8_t single_mode : 1; /* whether single selected mode is enabled */
@@ -128,7 +125,7 @@ bool lv_list_remove(const lv_obj_t * list, uint16_t index);
/**
* Set single button selected mode, only one button will be selected if enabled.
* @param list pointer to the currently pressed list object
* @param mode, enable(true)/disable(false) single selected mode.
* @param mode enable(true)/disable(false) single selected mode.
*/
void lv_list_set_single_mode(lv_obj_t * list, bool mode);
@@ -143,13 +140,6 @@ void lv_list_set_single_mode(lv_obj_t * list, bool mode);
void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn);
#endif
/**
* Set scroll animation duration on 'list_up()' 'list_down()' 'list_focus()'
* @param list pointer to a list object
* @param anim_time duration of animation [ms]
*/
void lv_list_set_anim_time(lv_obj_t * list, uint16_t anim_time);
/**
* Set the scroll bar mode of a list
* @param list pointer to a list object
@@ -181,6 +171,16 @@ static inline void lv_list_set_edge_flash(lv_obj_t * list, bool en)
lv_page_set_edge_flash(list, en);
}
/**
* Set scroll animation duration on 'list_up()' 'list_down()' 'list_focus()'
* @param list pointer to a list object
* @param anim_time duration of animation [ms]
*/
static inline void lv_list_set_anim_time(lv_obj_t * list, uint16_t anim_time)
{
lv_page_set_anim_time(list, anim_time);
}
/**
* Set a style of a list
* @param list pointer to a list object
@@ -259,13 +259,6 @@ uint16_t lv_list_get_size(const lv_obj_t * list);
lv_obj_t * lv_list_get_btn_selected(const lv_obj_t * list);
#endif
/**
* Get scroll animation duration
* @param list pointer to a list object
* @return duration of animation [ms]
*/
uint16_t lv_list_get_anim_time(const lv_obj_t * list);
/**
* Get the scroll bar mode of a list
* @param list pointer to a list object
@@ -296,6 +289,16 @@ static inline bool lv_list_get_edge_flash(lv_obj_t * list)
return lv_page_get_edge_flash(list);
}
/**
* Get scroll animation duration
* @param list pointer to a list object
* @return duration of animation [ms]
*/
static inline uint16_t lv_list_get_anim_time(const lv_obj_t * list)
{
return lv_page_get_anim_time(list);
}
/**
* Get a style of a list
* @param list pointer to a list object
+35 -7
View File
@@ -205,6 +205,20 @@ void lv_page_set_sb_mode(lv_obj_t * page, lv_sb_mode_t sb_mode)
lv_obj_invalidate(page);
}
/**
* Set the animation time for the page
* @param page pointer to a page object
* @param anim_time animation time in milliseconds
*/
void lv_page_set_anim_time(lv_obj_t * page, uint16_t anim_time)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
#if LV_USE_ANIMATION
ext->anim_time = anim_time;
#endif
}
/**
* Enable/Disable scrolling with arrows if the page is in group (arrows:
* LV_KEY_LEFT/RIGHT/UP/DOWN)
@@ -288,6 +302,21 @@ lv_obj_t * lv_page_get_scrl(const lv_obj_t * page)
return ext->scrl;
}
/**
* Get the animation time
* @param page pointer to a page object
* @return the animation time in milliseconds
*/
uint16_t lv_page_get_anim_time(const lv_obj_t * page)
{
#if LV_USE_ANIMATION
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
return ext->anim_time;
#else
return 0;
#endif
}
/**
* Set the scroll bar mode on a page
* @param page pointer to a page object
@@ -432,13 +461,14 @@ void lv_page_glue_obj(lv_obj_t * obj, bool glue)
lv_obj_set_drag(obj, glue);
}
/**
* Focus on an object. It ensures that the object will be visible on the page.
* @param page pointer to a page object
* @param obj pointer to an object to focus (must be on the page)
* @param anim_time scroll animation time in milliseconds (0: no animation)
* @param anim_en LV_ANIM_ON to focus with animation; LV_ANIM_OFF to focus without animation
*/
void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time)
void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_en)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
@@ -449,8 +479,6 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time)
lv_anim_del(page, (lv_anim_exec_xcb_t)lv_obj_set_y);
lv_anim_del(ext->scrl, (lv_anim_exec_xcb_t)lv_obj_set_x);
lv_anim_del(ext->scrl, (lv_anim_exec_xcb_t)lv_obj_set_y);
#else
anim_time = 0;
#endif
const lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
@@ -502,16 +530,16 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time)
scrlable_x += page_w - obj_w;
}
if(anim_time == 0) {
if(ext->anim_time == 0) {
lv_obj_set_y(ext->scrl, scrlable_y);
lv_obj_set_x(ext->scrl, scrlable_x);
#if LV_USE_ANIMATION
} else {
#if LV_USE_ANIMATION
lv_anim_t a;
a.act_time = 0;
a.start = lv_obj_get_y(ext->scrl);
a.end = scrlable_y;
a.time = anim_time;
a.time = ext->anim_time;
a.ready_cb = NULL;
a.playback = 0;
a.repeat = 0;
+18 -2
View File
@@ -84,6 +84,8 @@ typedef struct
uint8_t left_ip : 1; /*Used internally to show that left most position is reached (flash is
In Progress)*/
} edge_flash;
uint16_t anim_time; /*Scroll animation time*/
#endif
uint8_t arrow_scroll : 1; /*1: Enable scrolling with LV_KEY_LEFT/RIGHT/UP/DOWN*/
@@ -124,6 +126,13 @@ void lv_page_clean(lv_obj_t * obj);
*/
lv_obj_t * lv_page_get_scrl(const lv_obj_t * page);
/**
* Get the animation time
* @param page pointer to a page object
* @return the animation time in milliseconds
*/
uint16_t lv_page_get_anim_time(const lv_obj_t * page);
/*=====================
* Setter functions
*====================*/
@@ -135,6 +144,13 @@ lv_obj_t * lv_page_get_scrl(const lv_obj_t * page);
*/
void lv_page_set_sb_mode(lv_obj_t * page, lv_sb_mode_t sb_mode);
/**
* Set the animation time for the page
* @param page pointer to a page object
* @param anim_time animation time in milliseconds
*/
void lv_page_set_anim_time(lv_obj_t * page, uint16_t anim_time);
/**
* Enable/Disable scrolling with arrows if the page is in group (arrows:
* LV_KEY_LEFT/RIGHT/UP/DOWN)
@@ -380,9 +396,9 @@ void lv_page_glue_obj(lv_obj_t * obj, bool glue);
* Focus on an object. It ensures that the object will be visible on the page.
* @param page pointer to a page object
* @param obj pointer to an object to focus (must be on the page)
* @param anim_time scroll animation time in milliseconds (0: no animation)
* @param anim_en LV_ANIM_ON to focus with animation; LV_ANIM_OFF to focus without animation
*/
void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time);
void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_en);
/**
* Scroll the page horizontally
+9 -11
View File
@@ -16,11 +16,7 @@
/*********************
* DEFINES
*********************/
#if LV_USE_ANIMATION
#ifndef LV_ROLLER_DEF_ANIM_TIME
#define LV_ROLLER_DEF_ANIM_TIME 200 /*ms*/
#endif
#else
#if LV_USE_ANIMATION == 0
#undef LV_ROLLER_DEF_ANIM_TIME
#define LV_ROLLER_DEF_ANIM_TIME 0 /*No animation*/
#endif
@@ -596,23 +592,25 @@ static void draw_bg(lv_obj_t * roller, const lv_area_t * mask)
/**
* Refresh the position of the roller. It uses the id stored in: ext->ddlist.selected_option_id
* @param roller pointer to a roller object
* @param anim LV_ANIM_ON: refresh with animation; LV_ANOM_OFF: without animation
* @param anim_en LV_ANIM_ON: refresh with animation; LV_ANOM_OFF: without animation
*/
static void refr_position(lv_obj_t * roller, lv_anim_enable_t anim)
static void refr_position(lv_obj_t * roller, lv_anim_enable_t anim_en)
{
#if LV_USE_ANIMATION == 0
anim = LV_ANOM_OFF;
anim_en = LV_ANIM_OFF;
#endif
lv_obj_t * roller_scrl = lv_page_get_scrl(roller);
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
const lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
const lv_font_t * font = style_label->text.font;
lv_coord_t font_h = lv_font_get_line_height(font);
lv_coord_t h = lv_obj_get_height(roller);
uint16_t anim_time = lv_roller_get_anim_time(roller);
/* Normally the animtaion's `end_cb` sets correct position of the roller is infinite.
* But without animations do it manually*/
if(anim == LV_ANIM_OFF || ext->ddlist.anim_time == 0) {
if(anim_en == LV_ANIM_OFF || anim_time == 0) {
inf_normalize(roller_scrl);
}
@@ -621,7 +619,7 @@ static void refr_position(lv_obj_t * roller, lv_anim_enable_t anim)
id * (font_h + style_label->text.line_space) + ext->ddlist.label->coords.y1 - roller_scrl->coords.y1;
lv_coord_t new_y = -line_y1 + (h - font_h) / 2;
if(anim == LV_ANIM_OFF || ext->ddlist.anim_time == 0) {
if(anim_en == LV_ANIM_OFF || anim_time == 0) {
lv_obj_set_y(roller_scrl, new_y);
} else {
#if LV_USE_ANIMATION
@@ -633,7 +631,7 @@ static void refr_position(lv_obj_t * roller, lv_anim_enable_t anim)
a.path_cb = lv_anim_path_linear;
a.ready_cb = scroll_anim_ready_cb;
a.act_time = 0;
a.time = ext->ddlist.anim_time;
a.time = anim_time;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
+22 -3
View File
@@ -253,6 +253,15 @@ void lv_win_set_sb_mode(lv_obj_t * win, lv_sb_mode_t sb_mode)
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
lv_page_set_sb_mode(ext->page, sb_mode);
}
/**
* Set focus animation duration on `lv_win_focus()`
* @param win pointer to a window object
* @param anim_time duration of animation [ms]
*/
void lv_win_set_anim_time(lv_obj_t * win, uint16_t anim_time)
{
lv_page_set_anim_time(lv_win_get_content(win), anim_time);
}
/**
* Set a style of a window
@@ -381,6 +390,16 @@ lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t * win)
return lv_page_get_sb_mode(ext->page);
}
/**
* Get focus animation duration
* @param win pointer to a window object
* @return duration of animation [ms]
*/
uint16_t lv_win_get_anim_time(const lv_obj_t * win)
{
return lv_page_get_anim_time(lv_win_get_content(win));
}
/**
* Get width of the content area (page scrollable) of the window
* @param win pointer to a window object
@@ -428,12 +447,12 @@ const lv_style_t * lv_win_get_style(const lv_obj_t * win, lv_win_style_t type)
* Focus on an object. It ensures that the object will be visible in the window.
* @param win pointer to a window object
* @param obj pointer to an object to focus (must be in the window)
* @param anim_time scroll animation time in milliseconds (0: no animation)
* @param anim_en LV_ANIM_ON focus with an animation; LV_ANIM_OFF focus without animation
*/
void lv_win_focus(lv_obj_t * win, lv_obj_t * obj, uint16_t anim_time)
void lv_win_focus(lv_obj_t * win, lv_obj_t * obj, lv_anim_enable_t anim_en)
{
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
lv_page_focus(ext->page, obj, anim_time);
lv_page_focus(ext->page, obj, anim_en);
}
/**********************
+17 -2
View File
@@ -147,6 +147,13 @@ void lv_win_set_layout(lv_obj_t * win, lv_layout_t layout);
*/
void lv_win_set_sb_mode(lv_obj_t * win, lv_sb_mode_t sb_mode);
/**
* Set focus animation duration on `lv_win_focus()`
* @param win pointer to a window object
* @param anim_time duration of animation [ms]
*/
void lv_win_set_anim_time(lv_obj_t * win, uint16_t anim_time);
/**
* Set a style of a window
* @param win pointer to a window object
@@ -209,6 +216,13 @@ lv_layout_t lv_win_get_layout(lv_obj_t * win);
*/
lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t * win);
/**
* Get focus animation duration
* @param win pointer to a window object
* @return duration of animation [ms]
*/
uint16_t lv_win_get_anim_time(const lv_obj_t * win);
/**
* Get width of the content area (page scrollable) of the window
* @param win pointer to a window object
@@ -216,6 +230,7 @@ lv_sb_mode_t lv_win_get_sb_mode(lv_obj_t * win);
*/
lv_coord_t lv_win_get_width(lv_obj_t * win);
/**
* Get a style of a window
* @param win pointer to a button object
@@ -242,9 +257,9 @@ static inline bool lv_win_get_drag(const lv_obj_t * win)
* Focus on an object. It ensures that the object will be visible in the window.
* @param win pointer to a window object
* @param obj pointer to an object to focus (must be in the window)
* @param anim_time scroll animation time in milliseconds (0: no animation)
* @param anim_en LV_ANIM_ON focus with an animation; LV_ANIM_OFF focus without animation
*/
void lv_win_focus(lv_obj_t * win, lv_obj_t * obj, uint16_t anim_time);
void lv_win_focus(lv_obj_t * win, lv_obj_t * obj, lv_anim_enable_t anim_en);
/**
* Scroll the window horizontally