animation: add more control over object animations (e.g. ddlist open/close anim time set by func. instead of define)
This commit is contained in:
@@ -59,7 +59,7 @@ static lv_action_res_t lv_app_win_conf_action(lv_obj_t * set_btn, lv_dispi_t * d
|
||||
|
||||
static lv_action_res_t lv_app_win_open_anim_create(lv_app_inst_t * app);
|
||||
static lv_action_res_t lv_app_win_minim_anim_create(lv_app_inst_t * app);
|
||||
#if LV_APP_EFFECT_ANIM != 0 && LV_APP_ANIM_WIN != 0
|
||||
#if LV_APP_ANIM_WIN != 0
|
||||
static void lv_app_win_open_anim_cb(lv_obj_t * app_win);
|
||||
static void lv_app_win_close_anim_cb(lv_obj_t * app_win);
|
||||
static void lv_app_win_minim_anim_cb(lv_obj_t * app_win);
|
||||
@@ -229,12 +229,8 @@ lv_obj_t * lv_app_sc_open(lv_app_inst_t * app)
|
||||
/*Create a title on top of the shortcut*/
|
||||
app->sc_title = lv_label_create(app->sc, NULL);
|
||||
lv_obj_set_style(app->sc_title, &app_style.sc_title);
|
||||
#if LV_APP_EFFECT_ANIM != 0
|
||||
lv_label_set_long_mode(app->sc_title, LV_LABEL_LONG_SCROLL);
|
||||
#else
|
||||
lv_obj_set_size(app->sc_title, LV_APP_SC_WIDTH, font_get_height(font_get(app_style.sc_title_style.font)) >> FONT_ANTIALIAS);
|
||||
lv_obj_set_size(app->sc_title, LV_APP_SC_WIDTH, font_get_height(app_style.sc_title.font) >> FONT_ANTIALIAS);
|
||||
lv_label_set_long_mode(app->sc_title, LV_LABEL_LONG_DOTS);
|
||||
#endif
|
||||
lv_label_set_text(app->sc_title, app->name);
|
||||
lv_obj_align_us(app->sc_title, NULL, LV_ALIGN_IN_TOP_MID, 0, LV_DPI / 20);
|
||||
} else {
|
||||
@@ -245,11 +241,7 @@ lv_obj_t * lv_app_sc_open(lv_app_inst_t * app)
|
||||
app->dsc->sc_open(app, app->sc);
|
||||
|
||||
#if LV_APP_DESKTOP != 0
|
||||
#if LV_APP_EFFECT_ANIM == 0
|
||||
lv_page_focus(sc_page, app->sc, false);
|
||||
#else
|
||||
lv_page_focus(sc_page, app->sc, true);
|
||||
#endif
|
||||
lv_page_focus(sc_page, app->sc, LV_APP_ANIM_DESKTOP);
|
||||
#endif
|
||||
|
||||
return app->sc;
|
||||
@@ -652,7 +644,7 @@ static lv_action_res_t lv_app_sc_rel_action(lv_obj_t * sc, lv_dispi_t * dispi)
|
||||
if(con_send == NULL) {
|
||||
|
||||
#if LV_APP_DESKTOP != 0
|
||||
#if LV_APP_EFFECT_ANIM == 0
|
||||
#if LV_APP_ANIM_DESKTOP == 0
|
||||
lv_page_focus(sc_page, sc, false);
|
||||
#else
|
||||
lv_page_focus(sc_page, sc, true);
|
||||
@@ -744,7 +736,7 @@ static lv_action_res_t lv_app_win_close_action(lv_obj_t * close_btn, lv_dispi_t
|
||||
|
||||
lv_app_kb_close(false);
|
||||
|
||||
#if LV_APP_EFFECT_ANIM != 0 && LV_APP_EFFECT_OPA != 0 && LV_APP_ANIM_WIN != 0
|
||||
#if LV_APP_ANIM_WIN != 0
|
||||
/*Temporally set a simpler style for the window during the animation*/
|
||||
lv_obj_t * win_page = lv_win_get_page(win);
|
||||
lv_page_set_sb_mode(win_page, LV_PAGE_SB_MODE_OFF);
|
||||
@@ -832,7 +824,7 @@ static lv_action_res_t lv_app_win_conf_action(lv_obj_t * set_btn, lv_dispi_t * d
|
||||
static lv_action_res_t lv_app_win_open_anim_create(lv_app_inst_t * app)
|
||||
{
|
||||
/*Make an animation on window open*/
|
||||
#if LV_APP_EFFECT_ANIM != 0 && LV_APP_ANIM_WIN != 0
|
||||
#if USE_ANIM != 0 && LV_APP_ANIM_WIN != 0
|
||||
|
||||
area_t cords; /*If no shortcut simulate one and load the its coordinates*/
|
||||
if(app->sc == NULL) {
|
||||
@@ -863,12 +855,12 @@ static lv_action_res_t lv_app_win_open_anim_create(lv_app_inst_t * app)
|
||||
a.var = app->win;
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
|
||||
a.start = lv_obj_get_width(app->sc);
|
||||
a.start = area_get_width(&cords);
|
||||
a.end = LV_HOR_RES;
|
||||
a.fp = (anim_fp_t) lv_obj_set_width;
|
||||
anim_create(&a);
|
||||
|
||||
a.start = lv_obj_get_height(app->sc);
|
||||
a.start = area_get_height(&cords);
|
||||
a.end = LV_VER_RES;
|
||||
a.fp = (anim_fp_t) lv_obj_set_height;
|
||||
anim_create(&a);
|
||||
@@ -884,16 +876,17 @@ static lv_action_res_t lv_app_win_open_anim_create(lv_app_inst_t * app)
|
||||
a.end_cb = (anim_cb_t)lv_app_win_open_anim_cb;
|
||||
anim_create(&a);
|
||||
|
||||
#endif /*LV_APP_EFFECT_ANIM != 0 && LV_APP_ANIM_WIN != 0*/
|
||||
|
||||
/* Now a screen sized window is created but is is resized by the animations.
|
||||
* Therefore the whole screen invalidated but only a small part is changed.
|
||||
* So clear the invalidate buffer an refresh only the real area.
|
||||
* Independently other parts on the screen might be changed
|
||||
* but they will be covered by the window after the animations*/
|
||||
* but they will be soon covered by the window after the animations*/
|
||||
lv_inv_area(NULL);
|
||||
lv_inv_area(&cords);
|
||||
|
||||
#endif /* LV_APP_ANIM_WIN != 0*/
|
||||
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
@@ -904,7 +897,7 @@ static lv_action_res_t lv_app_win_open_anim_create(lv_app_inst_t * app)
|
||||
*/
|
||||
static lv_action_res_t lv_app_win_minim_anim_create(lv_app_inst_t * app)
|
||||
{
|
||||
#if LV_APP_EFFECT_ANIM != 0 && LV_APP_ANIM_WIN != 0
|
||||
#if LV_APP_ANIM_WIN != 0
|
||||
area_t cords;
|
||||
if(app->sc == NULL) {
|
||||
cords.x1 = LV_HOR_RES / 2 - LV_APP_SC_WIDTH / 2;
|
||||
@@ -935,12 +928,12 @@ static lv_action_res_t lv_app_win_minim_anim_create(lv_app_inst_t * app)
|
||||
|
||||
|
||||
a.start = LV_HOR_RES;
|
||||
a.end = lv_obj_get_width(&cords);
|
||||
a.end = area_get_width(&cords);
|
||||
a.fp = (anim_fp_t) lv_obj_set_width;
|
||||
anim_create(&a);
|
||||
|
||||
a.start = LV_VER_RES;
|
||||
a.end = lv_obj_get_height(&cords);
|
||||
a.end = area_get_height(&cords);
|
||||
a.fp = (anim_fp_t) lv_obj_set_height;
|
||||
anim_create(&a);
|
||||
|
||||
@@ -962,8 +955,7 @@ static lv_action_res_t lv_app_win_minim_anim_create(lv_app_inst_t * app)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if LV_APP_EFFECT_ANIM != 0
|
||||
|
||||
#if LV_APP_ANIM_WIN != 0
|
||||
|
||||
/**
|
||||
* Called when the window open animation is ready to close the application
|
||||
@@ -1049,7 +1041,7 @@ static void lv_app_init_style(void)
|
||||
/*Shortcut styles*/
|
||||
lv_style_get(LV_STYLE_BTN_REL,&app_style.sc_rel);
|
||||
app_style.sc_rel.ccolor = COLOR_MAKE(0x10, 0x18, 0x20);
|
||||
app_style.sc_rel.opa = OPA_80;
|
||||
app_style.sc_rel.opa = OPA_COVER;
|
||||
app_style.sc_rel.mcolor = COLOR_WHITE;
|
||||
app_style.sc_rel.gcolor = COLOR_MAKE(0x20, 0x30, 0x40);
|
||||
app_style.sc_rel.bcolor = COLOR_MAKE(0x40, 0x60, 0x80);
|
||||
@@ -1060,7 +1052,7 @@ static void lv_app_init_style(void)
|
||||
app_style.sc_rel.txt_align = 1;
|
||||
|
||||
memcpy(&app_style.sc_pr, &app_style.sc_rel, sizeof(lv_style_t));
|
||||
app_style.sc_pr.opa = OPA_80;
|
||||
app_style.sc_pr.opa = OPA_COVER;
|
||||
app_style.sc_pr.mcolor = COLOR_MAKE(0xB0, 0xD0, 0xF0);
|
||||
app_style.sc_pr.gcolor = COLOR_MAKE(0x00, 0x00, 0x00);
|
||||
app_style.sc_pr.bcolor = COLOR_MAKE(0xB0, 0xD0, 0xF0);
|
||||
|
||||
@@ -151,7 +151,7 @@ void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t
|
||||
#if LV_APP_ANIM_LEVEL != 0
|
||||
lv_page_focus(lv_win_get_content(kb_win), kb_ta, true);
|
||||
#else
|
||||
lv_page_focus(lv_win_get_page(kb_win), kb_ta, false);
|
||||
lv_page_focus(lv_win_get_page(kb_win), kb_ta, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ static lv_action_res_t lv_app_kb_action(lv_obj_t * btnm, uint16_t i)
|
||||
#if LV_APP_ANIM_LEVEL != 0
|
||||
lv_page_focus(lv_win_get_content(kb_win), kb_ta, true);
|
||||
#else
|
||||
lv_page_focus(lv_win_get_page(kb_win), kb_ta, false);
|
||||
lv_page_focus(lv_win_get_page(kb_win), kb_ta, 0);
|
||||
#endif
|
||||
}
|
||||
return LV_ACTION_RES_OK;
|
||||
|
||||
@@ -23,6 +23,11 @@
|
||||
#define LV_APP_NOTICE_SHOW_TIME 4000
|
||||
#endif
|
||||
|
||||
#ifndef LV_APP_NOTICE_CLOSE_ANIM_TIME
|
||||
#define LV_APP_NOTICE_CLOSE_ANIM_TIME 300
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef LV_APP_NOTICE_MAX_NUM
|
||||
#define LV_APP_NOTICE_MAX_NUM 6
|
||||
#endif
|
||||
@@ -84,7 +89,7 @@ lv_obj_t * lv_app_notice_add(const char * format, ...)
|
||||
lv_mbox_set_text(mbox, txt);
|
||||
|
||||
#if LV_APP_NOTICE_SHOW_TIME != 0
|
||||
lv_mbox_start_auto_close(mbox, LV_APP_NOTICE_SHOW_TIME);
|
||||
lv_mbox_start_auto_close(mbox, LV_APP_NOTICE_SHOW_TIME, LV_APP_NOTICE_CLOSE_ANIM_TIME);
|
||||
#endif
|
||||
|
||||
/*Delete the last children if there are too many*/
|
||||
|
||||
@@ -97,9 +97,6 @@
|
||||
|
||||
/*Page (dependencies: lv_rect)*/
|
||||
#define USE_LV_PAGE 1
|
||||
#if USE_LV_PAGE != 0
|
||||
#define LV_PAGE_ANIM_FOCUS_TIME 300 /*List focus animation time [ms] (0: turn off the animation)*/
|
||||
#endif
|
||||
|
||||
/*Window (dependencies: lv_rect, lv_btn, lv_label, lv_img, lv_page)*/
|
||||
#define USE_LV_WIN 1
|
||||
@@ -125,9 +122,6 @@
|
||||
|
||||
/*Message box (dependencies: lv_rect, lv_btn, lv_label)*/
|
||||
#define USE_LV_MBOX 1
|
||||
#if USE_LV_MBOX != 0
|
||||
#define LV_MBOX_ANIM_TIME 200 /*How fast animate out the message box in auto close. 0: no animation [ms]*/
|
||||
#endif
|
||||
|
||||
/*Text area (dependencies: lv_label, lv_page)*/
|
||||
#define USE_LV_TA 1
|
||||
@@ -154,9 +148,6 @@
|
||||
|
||||
/*Drop down list (dependencies: lv_page, lv_label)*/
|
||||
#define USE_LV_DDLIST 1
|
||||
#if USE_LV_DDLIST != 0
|
||||
#define LV_DDLIST_ANIM_TIME 100 /*DDL open/close animation in milliseconds (0: disable animation)*/
|
||||
#endif
|
||||
|
||||
/*Bar (dependencies: lv_bar)*/
|
||||
#define USE_LV_SLIDER 1
|
||||
@@ -176,37 +167,15 @@
|
||||
#define LV_APP_FONT_MEDIUM LV_FONT_DEFAULT
|
||||
#define LV_APP_FONT_LARGE FONT_DEJAVU_40
|
||||
|
||||
/* Internal icons:
|
||||
* 0: Do not use internal icons (img_close, img_add etc. icons have to be provided)
|
||||
* 1: Use simple sized icons
|
||||
* 2: Use double sized icons*/
|
||||
#define LV_APP_USE_INTERNAL_ICONS 2
|
||||
|
||||
/*Enable or disable the internal icons individually*/
|
||||
#if LV_APP_USE_INTERNAL_ICONS != 0
|
||||
#define USE_IMG_CLOSE 1
|
||||
#define USE_IMG_DOWN 1
|
||||
#define USE_IMG_DRIVER 1
|
||||
#define USE_IMG_FILE 1
|
||||
#define USE_IMG_FOLDER 1
|
||||
#define USE_IMG_LEFT 1
|
||||
#define USE_IMG_OK 1
|
||||
#define USE_IMG_RIGHT 1
|
||||
#define USE_IMG_UP 1
|
||||
#endif
|
||||
|
||||
/*Animation settings*/
|
||||
#define LV_APP_EFFECT_OPA 1 /*Enable the opacity in the application style (can be modified)*/
|
||||
#define LV_APP_EFFECT_ANIM 1 /*Enable the animation of the applications*/
|
||||
#define LV_APP_EFFECT_OPA_ANIM 1 /*Enable the using opacity in the application animations*/
|
||||
#define LV_APP_ANIM_WIN 200 /*Animation time in milliseconds (0: turn off animation)*/
|
||||
#define LV_APP_ANIM_SC 200 /*Animation time in milliseconds (0: turn off animation)*/
|
||||
#define LV_APP_ANIM_NOTICE 300 /*Obsolete, use LV_MBOX_ANIM. */
|
||||
#define LV_APP_ANIM_WIN 200 /*Animation time in milliseconds (0: turn off animation)*/
|
||||
#define LV_APP_ANIM_DESKTOP 200 /*Animation on the desktop (0: turn off animation)*/
|
||||
|
||||
/* App. utility settings */
|
||||
#define LV_APP_NOTICE_SHOW_TIME 4000 /*Notices will be shown for this time [ms]*/
|
||||
#define LV_APP_NOTICE_MAX_NUM 6 /*Max. number of notices*/
|
||||
#define LV_APP_NOTICE_MAX_LEN 256 /*Max. number of characters on a notice*/
|
||||
#define LV_APP_NOTICE_SHOW_TIME 4000 /*Notices will be shown for this time [ms]*/
|
||||
#define LV_APP_NOTICE_CLOSE_ANIM_TIME 300 /*Notice close animation time. [ms] 0: no animation */
|
||||
#define LV_APP_NOTICE_MAX_NUM 6 /*Max. number of notices*/
|
||||
#define LV_APP_NOTICE_MAX_LEN 256 /*Max. number of characters on a notice*/
|
||||
/*==================
|
||||
* LV APP X USAGE
|
||||
* ================*/
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <lvgl/lv_objx/lv_bar.h>
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
@@ -135,6 +136,39 @@ void lv_bar_set_value(lv_obj_t * bar, int16_t value)
|
||||
lv_obj_inv(bar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new value with animation on the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @param value new value
|
||||
* @param anim_time animation time in milliseconds
|
||||
*/
|
||||
void lv_bar_set_value_anim(lv_obj_t * bar, int16_t value, uint16_t anim_time)
|
||||
{
|
||||
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
int16_t new_value;
|
||||
new_value = value > ext->max_value ? ext->max_value : value;
|
||||
new_value = new_value < ext->min_value ? ext->min_value : new_value;
|
||||
|
||||
anim_t a;
|
||||
a.var = bar;
|
||||
a.start = ext->act_value;
|
||||
a.end = new_value;
|
||||
a.fp = (anim_fp_t)lv_bar_set_value;
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
a.end_cb = NULL;
|
||||
a.act_time = 0;
|
||||
a.time = anim_time;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
|
||||
anim_create(&a);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set minimum and the maximum values of a bar
|
||||
* @param bar pointer to he bar object
|
||||
|
||||
@@ -63,6 +63,14 @@ bool lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param);
|
||||
*/
|
||||
void lv_bar_set_value(lv_obj_t * bar, int16_t value);
|
||||
|
||||
/**
|
||||
* Set a new value with animation on the bar
|
||||
* @param bar pointer to a bar object
|
||||
* @param value new value
|
||||
* @param anim_time animation time in milliseconds
|
||||
*/
|
||||
void lv_bar_set_value_anim(lv_obj_t * bar, int16_t value, uint16_t anim_time);
|
||||
|
||||
/**
|
||||
* Set minimum and the maximum values of a bar
|
||||
* @param bar pointer to he bar object
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_DDLIST_ANIM_TIME
|
||||
#define LV_DDLIST_ANIM_TIME 100 /*ms*/
|
||||
#endif
|
||||
#define LV_DDLIST_DEF_ANIM_TIME 200 /*ms*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@@ -29,7 +28,7 @@
|
||||
**********************/
|
||||
static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_mode_t mode);
|
||||
static lv_action_res_t lv_ddlist_rel_action(lv_obj_t * ddlist, lv_dispi_t * dispi);
|
||||
static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en);
|
||||
static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time);
|
||||
static void lv_ddlist_pos_act_option(lv_obj_t * ddlist);
|
||||
|
||||
/**********************
|
||||
@@ -71,6 +70,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->opened = 0;
|
||||
ext->auto_size = 0;
|
||||
ext->sel_opt = 0;
|
||||
ext->anim_time = LV_DDLIST_DEF_ANIM_TIME;
|
||||
ext->style_sel = lv_style_get(LV_STYLE_PLAIN_COLOR, NULL);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
@@ -128,7 +128,7 @@ bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
|
||||
if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_obj_set_style(ext->opt_label, lv_obj_get_style(ddlist));
|
||||
lv_ddlist_refr_size(ddlist, false);
|
||||
lv_ddlist_refr_size(ddlist, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ void lv_ddlist_set_options(lv_obj_t * ddlist, const char ** options)
|
||||
i++;
|
||||
}
|
||||
|
||||
lv_ddlist_refr_size(ddlist, false);
|
||||
lv_ddlist_refr_size(ddlist, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,6 +201,16 @@ void lv_ddlist_set_auto_size(lv_obj_t * ddlist, bool auto_size)
|
||||
ext->auto_size = auto_size == false ? 0 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(ddlist);
|
||||
ext->anim_time = anim_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the style of the rectangle on the selected option
|
||||
@@ -262,14 +272,22 @@ lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist)
|
||||
if(ext->style_sel == NULL) return lv_obj_get_style(ddlist);
|
||||
|
||||
return ext->style_sel;
|
||||
|
||||
}
|
||||
/**
|
||||
* 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(lv_obj_t * ddlist)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
return ext->anim_time;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Handle the drawing related tasks of the drop down lists
|
||||
* @param ddlist pointer to an object
|
||||
@@ -355,11 +373,7 @@ static lv_action_res_t lv_ddlist_rel_action(lv_obj_t * ddlist, lv_dispi_t * disp
|
||||
ext->cb(ddlist, dispi);
|
||||
}
|
||||
}
|
||||
#if LV_DDLIST_ANIM_TIME == 0
|
||||
lv_ddlist_refr_size(ddlist, false);
|
||||
#else
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
#endif
|
||||
lv_ddlist_refr_size(ddlist, ext->anim_time);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
|
||||
@@ -367,10 +381,10 @@ static lv_action_res_t lv_ddlist_rel_action(lv_obj_t * ddlist, lv_dispi_t * disp
|
||||
|
||||
/**
|
||||
* Refresh the size of drop down list according its start (open or closed)
|
||||
* @param ddlist poinr to a drop down list object
|
||||
* @param anim_en true: refresh the size with an animation, false: do not use animations
|
||||
* @param ddlist pointer to a drop down list object
|
||||
* @param anim_time animations time for open/close [ms]
|
||||
*/
|
||||
static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
||||
static void lv_ddlist_refr_size(lv_obj_t * ddlist, uint16_t anim_time)
|
||||
{
|
||||
lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist);
|
||||
lv_style_t * style = lv_obj_get_style(ddlist);
|
||||
@@ -388,7 +402,7 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
||||
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
|
||||
new_height = font_h + 2 * label_style->line_space;
|
||||
}
|
||||
if(anim_en == false) {
|
||||
if(anim_time == 0) {
|
||||
lv_obj_set_height(ddlist, new_height);
|
||||
lv_ddlist_pos_act_option(ddlist);
|
||||
} else {
|
||||
@@ -400,7 +414,7 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
a.end_cb = (anim_cb_t)lv_ddlist_pos_act_option;
|
||||
a.act_time = 0;
|
||||
a.time = LV_DDLIST_ANIM_TIME;
|
||||
a.time = ext->anim_time;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
|
||||
@@ -41,6 +41,7 @@ typedef struct
|
||||
lv_style_t * style_sel; /*Style of the selected option*/
|
||||
lv_action_t cb; /*Pointer to function to call when an option is slected*/
|
||||
uint16_t sel_opt; /*Index of the current option*/
|
||||
uint16_t anim_time; /*Open/Close animation time [ms]*/
|
||||
uint8_t opened :1; /*1: The list is opened*/
|
||||
uint8_t auto_size :1; /*1: Set height to show all options. 0: Set height maximum to the parent bottom*/
|
||||
}lv_ddlist_ext_t;
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Test configurations*/
|
||||
#ifndef LV_MBOX_ANIM_TIME
|
||||
#define LV_MBOX_ANIM_TIME 250 /*How fast animate out the message box in auto close. 0: no animation [ms]*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@@ -256,20 +252,20 @@ void lv_mbox_set_styles_btn(lv_obj_t * mbox, lv_style_t * rel, lv_style_t * pr)
|
||||
* Automatically delete the message box after a given time
|
||||
* @param mbox pointer to a message box object
|
||||
* @param tout a time (in milliseconds) to wait before delete the message box
|
||||
* @param anim_time time of close animation in milliseconds (0: no animation)
|
||||
*/
|
||||
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t tout)
|
||||
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t tout, uint16_t anim_time)
|
||||
{
|
||||
#if LV_MBOX_ANIM_TIME != 0
|
||||
/*Add shrinking animations*/
|
||||
lv_obj_anim(mbox, LV_ANIM_GROW_H| ANIM_OUT, LV_MBOX_ANIM_TIME, tout, NULL);
|
||||
lv_obj_anim(mbox, LV_ANIM_GROW_V| ANIM_OUT, LV_MBOX_ANIM_TIME, tout, lv_obj_del);
|
||||
if(anim_time != 0) {
|
||||
/*Add shrinking animations*/
|
||||
lv_obj_anim(mbox, LV_ANIM_GROW_H| ANIM_OUT, anim_time, tout, NULL);
|
||||
lv_obj_anim(mbox, LV_ANIM_GROW_V| ANIM_OUT, anim_time, tout, lv_obj_del);
|
||||
|
||||
/*When the animations start disable fit to let shrinking work*/
|
||||
lv_obj_anim(mbox, LV_ANIM_NONE, 1, tout, lv_mbox_disable_fit);
|
||||
|
||||
#else
|
||||
lv_obj_anim(mbox, LV_ANIM_NONE, LV_MBOX_ANIM_TIME, tout, lv_obj_del);
|
||||
#endif
|
||||
/*When the animations start disable fit to let shrinking work*/
|
||||
lv_obj_anim(mbox, LV_ANIM_NONE, 1, tout, lv_mbox_disable_fit);
|
||||
} else {
|
||||
lv_obj_anim(mbox, LV_ANIM_NONE, anim_time, tout, lv_obj_del);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -111,7 +111,7 @@ void lv_mbox_set_styles_btn(lv_obj_t * mbox, lv_style_t * rel, lv_style_t * pr);
|
||||
* @param mbox pointer to a message box object
|
||||
* @param tout a time (in milliseconds) to wait before delete the message box
|
||||
*/
|
||||
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t tout);
|
||||
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t tout, uint16_t anim_time);
|
||||
|
||||
/**
|
||||
* Stop the auto. closing of message box
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Test configurations*/
|
||||
#ifndef LV_PAGE_ANIM_FOCUS_TIME
|
||||
#define LV_PAGE_ANIM_FOCUS_TIME 300 /*List focus animation time [ms] (0: turn off the animation)*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@@ -418,9 +414,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_en true: scroll with animation
|
||||
* @param anim_time true: scroll animation time in milliseconds (0: no animation)
|
||||
*/
|
||||
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, bool anim_en)
|
||||
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
|
||||
{
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_style_t * style = lv_obj_get_style(page);
|
||||
@@ -456,29 +452,23 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, bool anim_en)
|
||||
refr = true;
|
||||
}
|
||||
|
||||
if(refr != false) {
|
||||
#if LV_PAGE_ANIM_FOCUS_TIME == 0
|
||||
if(anim_time == 0) {
|
||||
lv_obj_set_y(ext->scrl, scrlable_y);
|
||||
#else
|
||||
if(anim_en == false) {
|
||||
lv_obj_set_y(ext->scrl, scrlable_y);
|
||||
} else {
|
||||
anim_t a;
|
||||
a.act_time = 0;
|
||||
a.start = lv_obj_get_y(ext->scrl);
|
||||
a.end = scrlable_y;
|
||||
a.time = LV_PAGE_ANIM_FOCUS_TIME;//anim_speed_to_time(LV_PAGE_ANIM_SPEED, a.start, a.end);
|
||||
a.end_cb = NULL;
|
||||
a.playback = 0;
|
||||
a.repeat = 0;
|
||||
a.var = ext->scrl;
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
|
||||
a.fp = (anim_fp_t) lv_obj_set_y;
|
||||
anim_create(&a);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
anim_t a;
|
||||
a.act_time = 0;
|
||||
a.start = lv_obj_get_y(ext->scrl);
|
||||
a.end = scrlable_y;
|
||||
a.time = LV_PAGE_ANIM_FOCUS_TIME;//anim_speed_to_time(LV_PAGE_ANIM_SPEED, a.start, a.end);
|
||||
a.end_cb = NULL;
|
||||
a.playback = 0;
|
||||
a.repeat = 0;
|
||||
a.var = ext->scrl;
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
a.fp = (anim_fp_t) lv_obj_set_y;
|
||||
anim_create(&a);
|
||||
}
|
||||
}
|
||||
|
||||
/*=====================
|
||||
|
||||
@@ -124,7 +124,7 @@ void lv_page_glue_obj(lv_obj_t * obj, bool glue);
|
||||
* @param obj pointer to an object to focus (must be on the page)
|
||||
* @param anim_en true: scroll with animation
|
||||
*/
|
||||
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, bool anim_en);
|
||||
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time);
|
||||
|
||||
/**
|
||||
* Get the scrollable object of a page-
|
||||
|
||||
Reference in New Issue
Block a user