change some int16_t types to lv_anim_value_t for animation functions. use LV_USE_ANIMATION macros to remove unused variables when animation capabilities is disabled

This commit is contained in:
Brian Pugh
2019-05-20 09:22:09 -07:00
parent f28efdd9f3
commit a6f0afde4c
24 changed files with 184 additions and 105 deletions

View File

@@ -394,7 +394,7 @@ typedef void * lv_obj_user_data_t;
/*Page (dependencies: lv_cont)*/ /*Page (dependencies: lv_cont)*/
#define LV_USE_PAGE 1 #define LV_USE_PAGE 1
/*Preload (dependencies: lv_arc)*/ /*Preload (dependencies: lv_arc, lv_anim)*/
#define LV_USE_PRELOAD 1 #define LV_USE_PRELOAD 1
#if LV_USE_PRELOAD != 0 #if LV_USE_PRELOAD != 0
# define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/ # define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/

View File

@@ -600,7 +600,7 @@
#define LV_USE_PAGE 1 #define LV_USE_PAGE 1
#endif #endif
/*Preload (dependencies: lv_arc)*/ /*Preload (dependencies: lv_arc, lv_anim)*/
#ifndef LV_USE_PRELOAD #ifndef LV_USE_PRELOAD
#define LV_USE_PRELOAD 1 #define LV_USE_PRELOAD 1
#endif #endif

View File

@@ -30,8 +30,10 @@
static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode_t mode); static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode_t mode);
static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param); static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param);
static void lv_bar_anim(void * bar, int16_t value); #if LV_USE_ANIMATION
static void lv_bar_anim(void * bar, lv_anim_value_t value);
static void lv_bar_anim_ready(lv_anim_t * a); static void lv_bar_anim_ready(lv_anim_t * a);
#endif
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
@@ -73,10 +75,12 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy)
ext->min_value = 0; ext->min_value = 0;
ext->max_value = 100; ext->max_value = 100;
ext->cur_value = 0; ext->cur_value = 0;
#if LV_USE_ANIMATION
ext->anim_time = 200; ext->anim_time = 200;
ext->anim_start = 0; ext->anim_start = 0;
ext->anim_end = 0; ext->anim_end = 0;
ext->anim_state = LV_BAR_ANIM_STATE_INV; ext->anim_state = LV_BAR_ANIM_STATE_INV;
#endif
ext->sym = 0; ext->sym = 0;
ext->style_indic = &lv_style_pretty_color; ext->style_indic = &lv_style_pretty_color;
@@ -241,10 +245,11 @@ int16_t lv_bar_get_value(const lv_obj_t * bar)
{ {
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar); lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
/*If animated tell that it's already at the end value*/ /*If animated tell that it's already at the end value*/
#if LV_USE_ANIMATION
if(ext->anim_state != LV_BAR_ANIM_STATE_INV) return ext->anim_end; if(ext->anim_state != LV_BAR_ANIM_STATE_INV) return ext->anim_end;
#endif
/*No animation, simple return the current value*/ /*No animation, simple return the current value*/
else return ext->cur_value;
return ext->cur_value;
} }
/** /**
@@ -341,7 +346,10 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar); lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
if(ext->cur_value != ext->min_value || ext->sym || if(ext->cur_value != ext->min_value || ext->sym ||
ext->anim_start != LV_BAR_ANIM_STATE_INV) { #if LV_USE_ANIMATION
ext->anim_start != LV_BAR_ANIM_STATE_INV
#endif
) {
const lv_style_t * style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC); const lv_style_t * style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC);
lv_area_t indic_area; lv_area_t indic_area;
lv_area_copy(&indic_area, &bar->coords); lv_area_copy(&indic_area, &bar->coords);
@@ -355,6 +363,7 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
if(w >= h) { if(w >= h) {
/*Horizontal*/ /*Horizontal*/
#if LV_USE_ANIMATION
if(ext->anim_state != LV_BAR_ANIM_STATE_INV) { if(ext->anim_state != LV_BAR_ANIM_STATE_INV) {
/*Calculate the coordinates of anim. start and end*/ /*Calculate the coordinates of anim. start and end*/
lv_coord_t anim_start_x = lv_coord_t anim_start_x =
@@ -369,7 +378,9 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
indic_area.x2 = indic_area.x2 =
anim_start_x + anim_start_x +
(((anim_end_x - anim_start_x) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM); (((anim_end_x - anim_start_x) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM);
} else { }else
#endif
{
indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value)) / indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value)) /
(ext->max_value - ext->min_value); (ext->max_value - ext->min_value);
} }
@@ -388,6 +399,7 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
} }
} }
} else { } else {
#if LV_USE_ANIMATION
if(ext->anim_state != LV_BAR_ANIM_STATE_INV) { if(ext->anim_state != LV_BAR_ANIM_STATE_INV) {
/*Calculate the coordinates of anim. start and end*/ /*Calculate the coordinates of anim. start and end*/
lv_coord_t anim_start_y = lv_coord_t anim_start_y =
@@ -402,7 +414,9 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode
indic_area.y1 = indic_area.y1 =
anim_start_y + anim_start_y +
(((anim_end_y - anim_start_y) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM); (((anim_end_y - anim_start_y) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM);
} else { } else
#endif
{
indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value)) / indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value)) /
(ext->max_value - ext->min_value); (ext->max_value - ext->min_value);
} }
@@ -475,7 +489,8 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
return res; return res;
} }
static void lv_bar_anim(void * bar, int16_t value) #if LV_USE_ANIMATION
static void lv_bar_anim(void * bar, lv_anim_value_t value)
{ {
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar); lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
ext->anim_state = value; ext->anim_state = value;
@@ -488,5 +503,6 @@ static void lv_bar_anim_ready(lv_anim_t * a)
ext->anim_state = LV_BAR_ANIM_STATE_INV; ext->anim_state = LV_BAR_ANIM_STATE_INV;
lv_bar_set_value(a->var, ext->anim_end, false); lv_bar_set_value(a->var, ext->anim_end, false);
} }
#endif
#endif #endif

View File

@@ -22,10 +22,12 @@ extern "C" {
#if LV_USE_BAR != 0 #if LV_USE_BAR != 0
#include "../lv_core/lv_obj.h" #include "../lv_core/lv_obj.h"
#include "../lv_misc/lv_anim.h"
#include "lv_cont.h" #include "lv_cont.h"
#include "lv_btn.h" #include "lv_btn.h"
#include "lv_label.h" #include "lv_label.h"
/********************* /*********************
* DEFINES * DEFINES
*********************/ *********************/
@@ -46,10 +48,12 @@ typedef struct
int16_t cur_value; /*Current value of the bar*/ int16_t cur_value; /*Current value of the bar*/
int16_t min_value; /*Minimum value of the bar*/ int16_t min_value; /*Minimum value of the bar*/
int16_t max_value; /*Maximum value of the bar*/ int16_t max_value; /*Maximum value of the bar*/
int16_t anim_start; #if LV_USE_ANIMATION
int16_t anim_end; lv_anim_value_t anim_start;
int16_t anim_state; lv_anim_value_t anim_end;
uint16_t anim_time; lv_anim_value_t anim_state;
lv_anim_value_t anim_time;
#endif
uint8_t sym : 1; /*Symmetric: means the center is around zero value*/ uint8_t sym : 1; /*Symmetric: means the center is around zero value*/
const lv_style_t * style_indic; /*Style of the indicator*/ const lv_style_t * style_indic; /*Style of the indicator*/
} lv_bar_ext_t; } lv_bar_ext_t;

View File

@@ -35,7 +35,7 @@ static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode
static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param); static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param);
#if LV_USE_ANIMATION && LV_BTN_INK_EFFECT #if LV_USE_ANIMATION && LV_BTN_INK_EFFECT
static void lv_btn_ink_effect_anim(lv_obj_t * btn, int16_t val); static void lv_btn_ink_effect_anim(lv_obj_t * btn, lv_anim_value_t val);
static void lv_btn_ink_effect_anim_ready(lv_anim_t * a); static void lv_btn_ink_effect_anim_ready(lv_anim_t * a);
#endif #endif
@@ -632,7 +632,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
* @param btn pointer to the animated button * @param btn pointer to the animated button
* @param val the new radius * @param val the new radius
*/ */
static void lv_btn_ink_effect_anim(lv_obj_t * btn, int16_t val) static void lv_btn_ink_effect_anim(lv_obj_t * btn, lv_anim_value_t val)
{ {
if(btn) { if(btn) {
ink_act_value = val; ink_act_value = val;

View File

@@ -44,9 +44,11 @@ static lv_res_t release_handler(lv_obj_t * ddlist);
static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en); static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en);
static void lv_ddlist_pos_current_option(lv_obj_t * ddlist); static void lv_ddlist_pos_current_option(lv_obj_t * ddlist);
static void lv_ddlist_refr_width(lv_obj_t* ddlist); static void lv_ddlist_refr_width(lv_obj_t* ddlist);
#if LV_USE_ANIMATION
static void lv_ddlist_anim_ready_cb(lv_anim_t * a); static void lv_ddlist_anim_ready_cb(lv_anim_t * a);
static void lv_ddlist_anim_finish(lv_obj_t* ddlist); static void lv_ddlist_anim_finish(lv_obj_t* ddlist);
static void lv_ddlist_adjust_height(lv_obj_t * ddlist, int16_t height); static void lv_ddlist_adjust_height(lv_obj_t * ddlist, lv_anim_value_t height);
#endif
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
@@ -907,6 +909,7 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
} }
} }
#if LV_USE_ANIMATION
/** /**
* Position the list and remove the selection highlight if it's closed. * Position the list and remove the selection highlight if it's closed.
* Called at end of list animation. * Called at end of list animation.
@@ -930,6 +933,7 @@ static void lv_ddlist_anim_finish(lv_obj_t* ddlist)
ext->force_sel = 0; /*Turn off drawing of selection*/ ext->force_sel = 0; /*Turn off drawing of selection*/
if(ext->opened) lv_page_set_sb_mode(ddlist, LV_SB_MODE_UNHIDE); if(ext->opened) lv_page_set_sb_mode(ddlist, LV_SB_MODE_UNHIDE);
} }
#endif
/** /**
* Adjusts the ddlist's height and then positions the option within it's new height. * Adjusts the ddlist's height and then positions the option within it's new height.
@@ -937,7 +941,7 @@ static void lv_ddlist_anim_finish(lv_obj_t* ddlist)
* @param ddlist Drop down list object * @param ddlist Drop down list object
* @param height New drop down list height * @param height New drop down list height
*/ */
static void lv_ddlist_adjust_height(lv_obj_t * ddlist, int16_t height) static void lv_ddlist_adjust_height(lv_obj_t * ddlist, lv_anim_value_t height)
{ {
lv_obj_set_height(ddlist, height); lv_obj_set_height(ddlist, height);
lv_ddlist_pos_current_option(ddlist); lv_ddlist_pos_current_option(ddlist);

View File

@@ -90,7 +90,9 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
ext->align = LV_LABEL_ALIGN_LEFT; ext->align = LV_LABEL_ALIGN_LEFT;
ext->dot_end = LV_LABEL_DOT_END_INV; ext->dot_end = LV_LABEL_DOT_END_INV;
ext->long_mode = LV_LABEL_LONG_EXPAND; ext->long_mode = LV_LABEL_LONG_EXPAND;
#if LV_USE_ANIMATION
ext->anim_speed = LV_LABEL_DEF_SCROLL_SPEED; ext->anim_speed = LV_LABEL_DEF_SCROLL_SPEED;
#endif
ext->offset.x = 0; ext->offset.x = 0;
ext->offset.y = 0; ext->offset.y = 0;
#if LV_LABEL_TEXT_SEL #if LV_LABEL_TEXT_SEL
@@ -343,6 +345,7 @@ void lv_label_set_body_draw(lv_obj_t * label, bool en)
*/ */
void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed) void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed)
{ {
#if LV_USE_ANIMATION
lv_label_ext_t * ext = lv_obj_get_ext_attr(label); lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
if(ext->anim_speed == anim_speed) return; if(ext->anim_speed == anim_speed) return;
@@ -351,6 +354,7 @@ void lv_label_set_anim_speed(lv_obj_t * label, uint16_t 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_ROLL || ext->long_mode == LV_LABEL_LONG_ROLL_CIRC) {
lv_label_refr_text(label); lv_label_refr_text(label);
} }
#endif
} }
void lv_label_set_text_sel_start( lv_obj_t * label, uint16_t index ) { void lv_label_set_text_sel_start( lv_obj_t * label, uint16_t index ) {
@@ -437,8 +441,12 @@ bool lv_label_get_body_draw(const lv_obj_t * label)
*/ */
uint16_t lv_label_get_anim_speed(const lv_obj_t * label) uint16_t lv_label_get_anim_speed(const lv_obj_t * label)
{ {
#if LV_USE_ANIMATION
lv_label_ext_t * ext = lv_obj_get_ext_attr(label); lv_label_ext_t * ext = lv_obj_get_ext_attr(label);
return ext->anim_speed; return ext->anim_speed;
#else
return 0;
#endif
} }
/** /**

View File

@@ -68,9 +68,12 @@ typedef struct
char tmp[ sizeof(char *) ]; /* Directly store the characters if <=4 characters */ char tmp[ sizeof(char *) ]; /* Directly store the characters if <=4 characters */
} dot; } dot;
uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/ uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/
uint16_t anim_speed; /*Speed of scroll and roll animation in px/sec unit*/
lv_point_t offset; /*Text draw position offset*/ lv_point_t offset; /*Text draw position offset*/
#if LV_USE_ANIMATION
uint16_t anim_speed; /*Speed of scroll and roll animation in px/sec unit*/
#endif
#if LV_LABEL_TEXT_SEL #if LV_LABEL_TEXT_SEL
uint16_t txt_sel_start; /*Left-most selection character*/ uint16_t txt_sel_start; /*Left-most selection character*/
uint16_t txt_sel_end; /*Right-most selection character*/ uint16_t txt_sel_end; /*Right-most selection character*/

View File

@@ -94,7 +94,9 @@ 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_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_TGL_PR] = &lv_style_btn_tgl_pr;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina; ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina;
#if LV_USE_ANIMATION
ext->anim_time = LV_LIST_DEF_ANIM_TIME; ext->anim_time = LV_LIST_DEF_ANIM_TIME;
#endif
ext->single_mode = false; ext->single_mode = false;
ext->size = 0; ext->size = 0;
@@ -249,11 +251,11 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
* lv_list_ext_t.size * lv_list_ext_t.size
* @return true: successfully deleted * @return true: successfully deleted
*/ */
bool lv_list_remove(const lv_obj_t * list, uint32_t index) bool lv_list_remove(const lv_obj_t * list, uint16_t index)
{ {
lv_list_ext_t * ext = lv_obj_get_ext_attr(list); lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
if(index >= ext->size) return false; if(index >= ext->size) return false;
uint32_t count = 0; uint16_t count = 0;
lv_obj_t * e = lv_list_get_next_btn(list, NULL); lv_obj_t * e = lv_list_get_next_btn(list, NULL);
while(e != NULL) { while(e != NULL) {
if(count == index) { if(count == index) {
@@ -318,7 +320,7 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
else if(s == LV_BTN_STATE_TGL_REL) else if(s == LV_BTN_STATE_TGL_REL)
lv_btn_set_state(ext->selected_btn, LV_BTN_STATE_TGL_PR); lv_btn_set_state(ext->selected_btn, LV_BTN_STATE_TGL_PR);
lv_page_focus(list, ext->selected_btn, ext->anim_time); lv_page_focus(list, ext->selected_btn, lv_list_get_anim_time(list) );
} }
} }
@@ -331,13 +333,13 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn)
*/ */
void lv_list_set_anim_time(lv_obj_t * list, uint16_t anim_time) 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); lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
#if LV_USE_ANIMATION == 0
anim_time = 0; anim_time = 0;
#endif
if(ext->anim_time == anim_time) return; if(ext->anim_time == anim_time) return;
ext->anim_time = anim_time; ext->anim_time = anim_time;
#endif
} }
/** /**
@@ -542,7 +544,7 @@ int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn)
* @param list pointer to a list object * @param list pointer to a list object
* @return the number of buttons in the list * @return the number of buttons in the list
*/ */
uint32_t lv_list_get_size(const lv_obj_t * list) uint16_t lv_list_get_size(const lv_obj_t * list)
{ {
lv_list_ext_t * ext = lv_obj_get_ext_attr(list); lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
return ext->size; return ext->size;
@@ -569,8 +571,12 @@ lv_obj_t * lv_list_get_btn_selected(const lv_obj_t * list)
*/ */
uint16_t lv_list_get_anim_time(const lv_obj_t * list) 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); lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
return ext->anim_time; return ext->anim_time;
#else
return 0;
#endif
} }
/** /**
@@ -622,8 +628,7 @@ void lv_list_up(const lv_obj_t * list)
if(e_prev != NULL) { if(e_prev != NULL) {
lv_coord_t new_y = lv_coord_t new_y =
lv_obj_get_height(list) - (lv_obj_get_y(e_prev) + lv_obj_get_height(e_prev)); lv_obj_get_height(list) - (lv_obj_get_y(e_prev) + lv_obj_get_height(e_prev));
lv_list_ext_t * ext = lv_obj_get_ext_attr(list); if(lv_list_get_anim_time(list) == 0) {
if(ext->anim_time == 0) {
lv_obj_set_y(scrl, new_y); lv_obj_set_y(scrl, new_y);
} else { } else {
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
@@ -631,9 +636,9 @@ void lv_list_up(const lv_obj_t * list)
a.var = scrl; a.var = scrl;
a.start = lv_obj_get_y(scrl); a.start = lv_obj_get_y(scrl);
a.end = new_y; a.end = new_y;
a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y; a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y;
a.path_cb = lv_anim_path_linear; a.path_cb = lv_anim_path_linear;
a.ready_cb = NULL; a.ready_cb = NULL;
a.act_time = 0; a.act_time = 0;
a.time = LV_LIST_DEF_ANIM_TIME; a.time = LV_LIST_DEF_ANIM_TIME;
a.playback = 0; a.playback = 0;
@@ -665,8 +670,7 @@ void lv_list_down(const lv_obj_t * list)
while(e != NULL) { while(e != NULL) {
if(e->coords.y1 < list->coords.y1) { if(e->coords.y1 < list->coords.y1) {
lv_coord_t new_y = -lv_obj_get_y(e); lv_coord_t new_y = -lv_obj_get_y(e);
lv_list_ext_t * ext = lv_obj_get_ext_attr(list); if(lv_list_get_anim_time(list) == 0) {
if(ext->anim_time == 0) {
lv_obj_set_y(scrl, new_y); lv_obj_set_y(scrl, new_y);
} else { } else {
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
@@ -674,9 +678,9 @@ void lv_list_down(const lv_obj_t * list)
a.var = scrl; a.var = scrl;
a.start = lv_obj_get_y(scrl); a.start = lv_obj_get_y(scrl);
a.end = new_y; a.end = new_y;
a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y; a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y;
a.path_cb = lv_anim_path_linear; a.path_cb = lv_anim_path_linear;
a.ready_cb = NULL; a.ready_cb = NULL;
a.act_time = 0; a.act_time = 0;
a.time = LV_LIST_DEF_ANIM_TIME; a.time = LV_LIST_DEF_ANIM_TIME;
a.playback = 0; a.playback = 0;
@@ -684,7 +688,6 @@ void lv_list_down(const lv_obj_t * list)
a.repeat = 0; a.repeat = 0;
a.repeat_pause = 0; a.repeat_pause = 0;
lv_anim_create(&a); lv_anim_create(&a);
#endif #endif
} }
break; break;

View File

@@ -52,11 +52,15 @@ typedef struct
{ {
lv_page_ext_t page; /*Ext. of ancestor*/ lv_page_ext_t page; /*Ext. of ancestor*/
/*New data for this type */ /*New data for this type */
uint16_t anim_time; /*Scroll animation time*/
const lv_style_t * styles_btn[LV_BTN_STATE_NUM]; /*Styles of the list element buttons*/ 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*/ const lv_style_t * style_img; /*Style of the list element images on buttons*/
uint32_t size; /*the number of items(buttons) in the list*/ uint16_t size; /*the number of items(buttons) in the list*/
bool single_mode; /* whether single selected mode is enabled */ #if LV_USE_ANIMATION
uint16_t anim_time; /*Scroll animation time*/
#endif
uint8_t single_mode:1; /* whether single selected mode is enabled */
#if LV_USE_GROUP #if LV_USE_GROUP
lv_obj_t * last_sel; /* The last selected button. It will be reverted when the list is focused again */ lv_obj_t * last_sel; /* The last selected button. It will be reverted when the list is focused again */
lv_obj_t * selected_btn; /* The button is currently being selected*/ lv_obj_t * selected_btn; /* The button is currently being selected*/
@@ -116,7 +120,7 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt,
* lv_list_ext_t.size * lv_list_ext_t.size
* @return true: successfully deleted * @return true: successfully deleted
*/ */
bool lv_list_remove(const lv_obj_t * list, uint32_t index); bool lv_list_remove(const lv_obj_t * list, uint16_t index);
/*===================== /*=====================
* Setter functions * Setter functions
@@ -245,7 +249,7 @@ int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn);
* @param list pointer to a list object * @param list pointer to a list object
* @return the number of buttons in the list * @return the number of buttons in the list
*/ */
uint32_t lv_list_get_size(const lv_obj_t * list); uint16_t lv_list_get_size(const lv_obj_t * list);
#if LV_USE_GROUP #if LV_USE_GROUP
/** /**

View File

@@ -77,7 +77,9 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy)
ext->text = NULL; ext->text = NULL;
ext->btnm = NULL; ext->btnm = NULL;
#if LV_USE_ANIMATION
ext->anim_time = LV_MBOX_CLOSE_ANIM_TIME; ext->anim_time = LV_MBOX_CLOSE_ANIM_TIME;
#endif
/*The signal and design functions are not copied so set them here*/ /*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_cb(new_mbox, lv_mbox_signal); lv_obj_set_signal_cb(new_mbox, lv_mbox_signal);
@@ -182,12 +184,14 @@ void lv_mbox_set_text(lv_obj_t * mbox, const char * txt)
*/ */
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time) void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time)
{ {
#if LV_USE_ANIMATION
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox); lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
#if LV_USE_ANIMATION == 0
anim_time = 0; anim_time = 0;
#endif
ext->anim_time = anim_time; ext->anim_time = anim_time;
#else
(void) mbox;
(void) anim_time;
#endif
} }
/** /**
@@ -198,9 +202,7 @@ void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time)
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay) void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
{ {
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox); if(lv_mbox_get_anim_time(mbox) != 0) {
if(ext->anim_time != 0) {
/*Add shrinking animations*/ /*Add shrinking animations*/
lv_anim_t a; lv_anim_t a;
a.var = mbox; a.var = mbox;
@@ -210,7 +212,7 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay)
a.path_cb = lv_anim_path_linear; a.path_cb = lv_anim_path_linear;
a.ready_cb = NULL; a.ready_cb = NULL;
a.act_time = -delay; a.act_time = -delay;
a.time = ext->anim_time; a.time = lv_mbox_get_anim_time(mbox);
a.playback = 0; a.playback = 0;
a.playback_pause = 0; a.playback_pause = 0;
a.repeat = 0; a.repeat = 0;
@@ -356,8 +358,13 @@ const char * lv_mbox_get_active_btn_text(lv_obj_t * mbox)
*/ */
uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox) uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox)
{ {
#if LV_USE_ANIMATION
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox); lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
return ext->anim_time; return ext->anim_time;
#else
(void) mbox;
return 0;
#endif
} }
/** /**

View File

@@ -54,7 +54,9 @@ typedef struct
/*New data for this type */ /*New data for this type */
lv_obj_t * text; /*Text of the message box*/ lv_obj_t * text; /*Text of the message box*/
lv_obj_t * btnm; /*Button matrix for the buttons*/ lv_obj_t * btnm; /*Button matrix for the buttons*/
#if LV_USE_ANIMATION
uint16_t anim_time; /*Duration of close animation [ms] (0: no animation)*/ uint16_t anim_time; /*Duration of close animation [ms] (0: no animation)*/
#endif
} lv_mbox_ext_t; } lv_mbox_ext_t;
enum { enum {

View File

@@ -40,9 +40,11 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo
static bool lv_scrl_design(lv_obj_t * scrl, const lv_area_t * mask, lv_design_mode_t mode); static bool lv_scrl_design(lv_obj_t * scrl, const lv_area_t * mask, lv_design_mode_t mode);
static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param); static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param); static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param);
static void edge_flash_anim(void * page, int16_t v);
static void edge_flash_anim_end(lv_anim_t * a);
static void scrl_def_event_cb(lv_obj_t * scrl, lv_event_t event); static void scrl_def_event_cb(lv_obj_t * scrl, lv_event_t event);
#if LV_USE_ANIMATION
static void edge_flash_anim(void * page, lv_anim_value_t v);
static void edge_flash_anim_end(lv_anim_t * a);
#endif
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
@@ -428,15 +430,15 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time)
{ {
lv_page_ext_t * ext = lv_obj_get_ext_attr(page); lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
#if LV_USE_ANIMATION == 0 #if LV_USE_ANIMATION
anim_time = 0;
#else
/* Be sure there is no position changing animation in progress /* Be sure there is no position changing animation in progress
* because it can overide the current changes*/ * because it can overide the current changes*/
lv_anim_del(page, (lv_anim_exec_cb_t)lv_obj_set_x); lv_anim_del(page, (lv_anim_exec_cb_t)lv_obj_set_x);
lv_anim_del(page, (lv_anim_exec_cb_t)lv_obj_set_y); lv_anim_del(page, (lv_anim_exec_cb_t)lv_obj_set_y);
lv_anim_del(ext->scrl, (lv_anim_exec_cb_t)lv_obj_set_x); lv_anim_del(ext->scrl, (lv_anim_exec_cb_t)lv_obj_set_x);
lv_anim_del(ext->scrl, (lv_anim_exec_cb_t)lv_obj_set_y); lv_anim_del(ext->scrl, (lv_anim_exec_cb_t)lv_obj_set_y);
#else
anim_time = 0;
#endif #endif
const lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG); const lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
@@ -528,9 +530,9 @@ void lv_page_scroll_hor(lv_obj_t * page, lv_coord_t dist)
a.var = scrl; a.var = scrl;
a.start = lv_obj_get_x(scrl); a.start = lv_obj_get_x(scrl);
a.end = a.start + dist; a.end = a.start + dist;
a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x; a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x;
a.path_cb = lv_anim_path_linear; a.path_cb = lv_anim_path_linear;
a.ready_cb = NULL; a.ready_cb = NULL;
a.act_time = 0; a.act_time = 0;
a.time = LV_PAGE_SCROLL_ANIM_TIME; a.time = LV_PAGE_SCROLL_ANIM_TIME;
a.playback = 0; a.playback = 0;
@@ -557,9 +559,9 @@ void lv_page_scroll_ver(lv_obj_t * page, lv_coord_t dist)
a.var = scrl; a.var = scrl;
a.start = lv_obj_get_y(scrl); a.start = lv_obj_get_y(scrl);
a.end = a.start + dist; a.end = a.start + dist;
a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y; a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y;
a.path_cb = lv_anim_path_linear; a.path_cb = lv_anim_path_linear;
a.ready_cb = NULL; a.ready_cb = NULL;
a.act_time = 0; a.act_time = 0;
a.time = LV_PAGE_SCROLL_ANIM_TIME; a.time = LV_PAGE_SCROLL_ANIM_TIME;
a.playback = 0; a.playback = 0;
@@ -1193,7 +1195,8 @@ static void lv_page_sb_refresh(lv_obj_t * page)
} }
} }
static void edge_flash_anim(void * page, int16_t v) #if LV_USE_ANIMATION
static void edge_flash_anim(void * page, lv_anim_value_t v)
{ {
lv_page_ext_t * ext = lv_obj_get_ext_attr(page); lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
ext->edge_flash.state = v; ext->edge_flash.state = v;
@@ -1209,5 +1212,6 @@ static void edge_flash_anim_end(lv_anim_t * a)
ext->edge_flash.right_ip = 0; ext->edge_flash.right_ip = 0;
lv_obj_invalidate(a->var); lv_obj_invalidate(a->var);
} }
#endif
#endif #endif

View File

@@ -28,6 +28,7 @@ extern "C" {
#include "lv_cont.h" #include "lv_cont.h"
#include "../lv_core/lv_indev.h" #include "../lv_core/lv_indev.h"
#include "../lv_misc/lv_anim.h"
/********************* /*********************
* DEFINES * DEFINES
@@ -78,7 +79,7 @@ typedef struct
} sb; } sb;
struct struct
{ {
uint16_t state; /*Store the current size of the edge flash effect*/ lv_anim_value_t state; /*Store the current size of the edge flash effect*/
const lv_style_t * style; /*Style of edge flash effect (usually homogeneous circle)*/ const lv_style_t * style; /*Style of edge flash effect (usually homogeneous circle)*/
uint8_t enabled : 1; /*1: Show a flash animation on the edge*/ uint8_t enabled : 1; /*1: Show a flash animation on the edge*/
uint8_t top_ip : 1; /*Used internally to show that top most position is reached (flash is In uint8_t top_ip : 1; /*Used internally to show that top most position is reached (flash is In

View File

@@ -127,7 +127,7 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy)
* @param preload pointer to a preload object * @param preload pointer to a preload object
* @param deg length of the arc * @param deg length of the arc
*/ */
void lv_preload_set_arc_length(lv_obj_t * preload, int16_t deg) void lv_preload_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg)
{ {
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload); lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
@@ -170,7 +170,6 @@ void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, const lv_
* */ * */
void lv_preload_set_anim_type(lv_obj_t * preload, lv_preload_type_t type) void lv_preload_set_anim_type(lv_obj_t * preload, lv_preload_type_t type)
{ {
#if LV_USE_ANIMATION
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload); lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
/*delete previous animation*/ /*delete previous animation*/
@@ -250,8 +249,6 @@ void lv_preload_set_anim_type(lv_obj_t * preload, lv_preload_type_t type)
break; break;
} }
} }
#endif // LV_USE_ANIMATION
} }
void lv_preload_set_anim_dir(lv_obj_t * preload, lv_preload_dir_t dir) { void lv_preload_set_anim_dir(lv_obj_t * preload, lv_preload_dir_t dir) {
@@ -269,7 +266,7 @@ void lv_preload_set_anim_dir(lv_obj_t * preload, lv_preload_dir_t dir) {
* Get the arc length [degree] of the a pre loader * Get the arc length [degree] of the a pre loader
* @param preload pointer to a pre loader object * @param preload pointer to a pre loader object
*/ */
uint16_t lv_preload_get_arc_length(const lv_obj_t * preload) lv_anim_value_t lv_preload_get_arc_length(const lv_obj_t * preload)
{ {
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload); lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);
return ext->arc_length; return ext->arc_length;
@@ -328,7 +325,7 @@ lv_preload_dir_t lv_preload_get_anim_dir(lv_obj_t * preload) {
* @param ptr pointer to preloader * @param ptr pointer to preloader
* @param val the current desired value [0..360] * @param val the current desired value [0..360]
*/ */
void lv_preload_spinner_anim(void * ptr, int16_t val) void lv_preload_spinner_anim(void * ptr, lv_anim_value_t val)
{ {
lv_obj_t * preload = ptr; lv_obj_t * preload = ptr;
lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload); lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload);

View File

@@ -31,6 +31,7 @@ extern "C" {
#endif #endif
#include "../lv_core/lv_obj.h" #include "../lv_core/lv_obj.h"
#include "../lv_misc/lv_anim.h"
#include "lv_arc.h" #include "lv_arc.h"
/********************* /*********************
@@ -58,7 +59,7 @@ typedef struct
{ {
lv_arc_ext_t arc; /*Ext. of ancestor*/ lv_arc_ext_t arc; /*Ext. of ancestor*/
/*New data for this type */ /*New data for this type */
uint16_t arc_length; /*Length of the spinning indicator in degree*/ lv_anim_value_t arc_length; /*Length of the spinning indicator in degree*/
uint16_t time; /*Time of one round*/ uint16_t time; /*Time of one round*/
lv_preload_type_t anim_type:1; /*Type of the arc animation*/ lv_preload_type_t anim_type:1; /*Type of the arc animation*/
lv_preload_dir_t anim_dir:1; /*Animation Direction*/ lv_preload_dir_t anim_dir:1; /*Animation Direction*/
@@ -92,7 +93,7 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy);
* @param preload pointer to a preload object * @param preload pointer to a preload object
* @param deg length of the arc * @param deg length of the arc
*/ */
void lv_preload_set_arc_length(lv_obj_t * preload, int16_t deg); void lv_preload_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg);
/** /**
* Set the spin time of the arc * Set the spin time of the arc
@@ -135,7 +136,7 @@ void lv_preload_set_anim_dir(lv_obj_t * preload, lv_preload_dir_t dir);
* Get the arc length [degree] of the a pre loader * Get the arc length [degree] of the a pre loader
* @param preload pointer to a pre loader object * @param preload pointer to a pre loader object
*/ */
uint16_t lv_preload_get_arc_length(const lv_obj_t * preload); lv_anim_value_t lv_preload_get_arc_length(const lv_obj_t * preload);
/** /**
* Get the spin time of the arc * Get the spin time of the arc
@@ -175,7 +176,7 @@ lv_preload_dir_t lv_preload_get_anim_dir(lv_obj_t * preload);
* @param type which style should be get * @param type which style should be get
* @return style pointer to the style * @return style pointer to the style
* */ * */
void lv_preload_spinner_anim(void * ptr, int16_t val); void lv_preload_spinner_anim(void * ptr, lv_anim_value_t val);
/********************** /**********************
* MACROS * MACROS

View File

@@ -42,8 +42,7 @@ typedef struct
lv_bar_ext_t bar; /*Ext. of ancestor*/ lv_bar_ext_t bar; /*Ext. of ancestor*/
/*New data for this type */ /*New data for this type */
const lv_style_t * style_knob; /*Style of the knob*/ const lv_style_t * style_knob; /*Style of the knob*/
int16_t int16_t drag_value; /*Store a temporal value during press until release (Handled by the library)*/
drag_value; /*Store a temporal value during press until release (Handled by the library)*/
uint8_t knob_in : 1; /*1: Draw the knob inside the bar*/ uint8_t knob_in : 1; /*1: Draw the knob inside the bar*/
} lv_slider_ext_t; } lv_slider_ext_t;

View File

@@ -202,6 +202,9 @@ void lv_sw_set_anim_time(lv_obj_t * sw, uint16_t anim_time)
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw); lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
ext->anim_time = anim_time; ext->anim_time = anim_time;
#else
(void) sw;
(void) anim_time;
#endif #endif
} }

View File

@@ -107,7 +107,6 @@ bool lv_sw_toggle(lv_obj_t * sw, bool anim);
*/ */
void lv_sw_set_style(lv_obj_t * sw, lv_sw_style_t type, const lv_style_t * style); void lv_sw_set_style(lv_obj_t * sw, lv_sw_style_t type, const lv_style_t * style);
#if LV_USE_ANIMATION
/** /**
* Set the animation time of the switch * Set the animation time of the switch
* @param sw pointer to a switch object * @param sw pointer to a switch object
@@ -115,7 +114,6 @@ void lv_sw_set_style(lv_obj_t * sw, lv_sw_style_t type, const lv_style_t * style
* @return style pointer to a style * @return style pointer to a style
*/ */
void lv_sw_set_anim_time(lv_obj_t * sw, uint16_t anim_time); void lv_sw_set_anim_time(lv_obj_t * sw, uint16_t anim_time);
#endif
/*===================== /*=====================
* Getter functions * Getter functions

View File

@@ -46,9 +46,9 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param);
static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param); static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param);
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
static void cursor_blink_anim(lv_obj_t * ta, uint8_t show); static void cursor_blink_anim(lv_obj_t * ta, uint8_t show);
static void pwd_char_hider_anim(lv_obj_t * ta, int32_t x); static void pwd_char_hider_anim(lv_obj_t * ta, lv_anim_value_t x);
#endif
static void pwd_char_hider_anim_ready(lv_anim_t * a); static void pwd_char_hider_anim_ready(lv_anim_t * a);
#endif
static void pwd_char_hider(lv_obj_t * ta); static void pwd_char_hider(lv_obj_t * ta);
static bool char_is_accepted(lv_obj_t * ta, uint32_t c); static bool char_is_accepted(lv_obj_t * ta, uint32_t c);
static void get_cursor_style(lv_obj_t * ta, lv_style_t * style_res); static void get_cursor_style(lv_obj_t * ta, lv_style_t * style_res);
@@ -165,10 +165,10 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
/*Create a cursor blinker animation*/ /*Create a cursor blinker animation*/
lv_anim_t a; lv_anim_t a;
a.var = new_ta; a.var = new_ta;
a.exec_cb = (lv_anim_exec_cb_t)cursor_blink_anim; a.exec_cb = (lv_anim_exec_cb_t)cursor_blink_anim;
a.time = LV_TA_CURSOR_BLINK_TIME; a.time = LV_TA_CURSOR_BLINK_TIME;
a.act_time = 0; a.act_time = 0;
a.ready_cb = NULL; a.ready_cb = NULL;
a.start = 1; a.start = 1;
a.end = 0; a.end = 0;
a.repeat = 1; a.repeat = 1;
@@ -250,10 +250,10 @@ void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
/*Auto hide characters*/ /*Auto hide characters*/
lv_anim_t a; lv_anim_t a;
a.var = ta; a.var = ta;
a.exec_cb = (lv_anim_exec_cb_t)pwd_char_hider_anim; a.exec_cb = (lv_anim_exec_cb_t)pwd_char_hider_anim;
a.time = LV_TA_PWD_SHOW_TIME; a.time = LV_TA_PWD_SHOW_TIME;
a.act_time = 0; a.act_time = 0;
a.ready_cb = pwd_char_hider_anim_ready; a.ready_cb = pwd_char_hider_anim_ready;
a.start = 0; a.start = 0;
a.end = 1; a.end = 1;
a.repeat = 0; a.repeat = 0;
@@ -576,10 +576,10 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
/*Reset cursor blink animation*/ /*Reset cursor blink animation*/
lv_anim_t a; lv_anim_t a;
a.var = ta; a.var = ta;
a.exec_cb = (lv_anim_exec_cb_t)cursor_blink_anim; a.exec_cb = (lv_anim_exec_cb_t)cursor_blink_anim;
a.time = LV_TA_CURSOR_BLINK_TIME; a.time = LV_TA_CURSOR_BLINK_TIME;
a.act_time = 0; a.act_time = 0;
a.ready_cb = NULL; a.ready_cb = NULL;
a.start = 1; a.start = 1;
a.end = 0; a.end = 0;
a.repeat = 1; a.repeat = 1;
@@ -1386,7 +1386,7 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void
* @param ta pointer to a text area * @param ta pointer to a text area
* @param hide 1: hide the cursor, 0: show it * @param hide 1: hide the cursor, 0: show it
*/ */
static void cursor_blink_anim(lv_obj_t * ta, uint8_t show) static void cursor_blink_anim(lv_obj_t * ta, lv_anim_value_t show)
{ {
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
if(show != ext->cursor.state) { if(show != ext->cursor.state) {
@@ -1411,15 +1411,12 @@ static void cursor_blink_anim(lv_obj_t * ta, uint8_t show)
* @param ta unused * @param ta unused
* @param x unused * @param x unused
*/ */
static void pwd_char_hider_anim(lv_obj_t * ta, int32_t x) static void pwd_char_hider_anim(lv_obj_t * ta, lv_anim_value_t x)
{ {
(void)ta; (void)ta;
(void)x; (void)x;
} }
#endif
/** /**
* Call when an animation is ready to convert all characters to '*' * Call when an animation is ready to convert all characters to '*'
* @param a pointer to the animation * @param a pointer to the animation
@@ -1429,6 +1426,7 @@ static void pwd_char_hider_anim_ready(lv_anim_t * a)
lv_obj_t * ta = a->var; lv_obj_t * ta = a->var;
pwd_char_hider(ta); pwd_char_hider(ta);
} }
#endif
/** /**
* Hide all characters (convert them to '*') * Hide all characters (convert them to '*')

View File

@@ -93,7 +93,9 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
ext->indic = NULL; ext->indic = NULL;
ext->btns = NULL; ext->btns = NULL;
ext->btns_pos = LV_TABVIEW_BTNS_POS_TOP; ext->btns_pos = LV_TABVIEW_BTNS_POS_TOP;
#if LV_USE_ANIMATION
ext->anim_time = LV_TABVIEW_DEF_ANIM_TIME; ext->anim_time = LV_TABVIEW_DEF_ANIM_TIME;
#endif
ext->btns_hide = 0; ext->btns_hide = 0;
/*The signal and design functions are not copied so set them here*/ /*The signal and design functions are not copied so set them here*/
@@ -158,7 +160,9 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy)
ext->btns = lv_btnm_create(new_tabview, copy_ext->btns); ext->btns = lv_btnm_create(new_tabview, copy_ext->btns);
ext->indic = lv_obj_create(ext->btns, copy_ext->indic); ext->indic = lv_obj_create(ext->btns, copy_ext->indic);
ext->content = lv_cont_create(new_tabview, copy_ext->content); ext->content = lv_cont_create(new_tabview, copy_ext->content);
#if LV_USE_ANIMATION
ext->anim_time = copy_ext->anim_time; ext->anim_time = copy_ext->anim_time;
#endif
ext->tab_name_ptr = lv_mem_alloc(sizeof(char *)); ext->tab_name_ptr = lv_mem_alloc(sizeof(char *));
lv_mem_assert(ext->tab_name_ptr); lv_mem_assert(ext->tab_name_ptr);
@@ -371,7 +375,11 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en)
break; break;
} }
if(ext->anim_time == 0 || anim_en == false) { if( anim_en == false ||
#if LV_USE_ANIMATION
ext->anim_time == 0
#endif
) {
lv_obj_set_x(ext->content, cont_x); lv_obj_set_x(ext->content, cont_x);
} else { } else {
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
@@ -379,9 +387,9 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en)
a.var = ext->content; a.var = ext->content;
a.start = lv_obj_get_x(ext->content); a.start = lv_obj_get_x(ext->content);
a.end = cont_x; a.end = cont_x;
a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x; a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x;
a.path_cb = lv_anim_path_linear; a.path_cb = lv_anim_path_linear;
a.ready_cb = NULL; a.ready_cb = NULL;
a.act_time = 0; a.act_time = 0;
a.time = ext->anim_time; a.time = ext->anim_time;
a.playback = 0; a.playback = 0;
@@ -410,7 +418,11 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en)
break; break;
} }
if(ext->anim_time == 0 || anim_en == false) { if( anim_en == false ||
#if LV_USE_ANIMATION
ext->anim_time == 0
#endif
) {
switch(ext->btns_pos) { switch(ext->btns_pos) {
case LV_TABVIEW_BTNS_POS_TOP: case LV_TABVIEW_BTNS_POS_TOP:
case LV_TABVIEW_BTNS_POS_BOTTOM: case LV_TABVIEW_BTNS_POS_BOTTOM:
@@ -431,18 +443,18 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en)
case LV_TABVIEW_BTNS_POS_BOTTOM: case LV_TABVIEW_BTNS_POS_BOTTOM:
a.start = lv_obj_get_x(ext->indic); a.start = lv_obj_get_x(ext->indic);
a.end = indic_pos; a.end = indic_pos;
a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x; a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x;
break; break;
case LV_TABVIEW_BTNS_POS_LEFT: case LV_TABVIEW_BTNS_POS_LEFT:
case LV_TABVIEW_BTNS_POS_RIGHT: case LV_TABVIEW_BTNS_POS_RIGHT:
a.start = lv_obj_get_y(ext->indic); a.start = lv_obj_get_y(ext->indic);
a.end = indic_pos; a.end = indic_pos;
a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y; a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y;
break; break;
} }
a.path_cb = lv_anim_path_linear; a.path_cb = lv_anim_path_linear;
a.ready_cb = NULL; a.ready_cb = NULL;
a.act_time = 0; a.act_time = 0;
a.time = ext->anim_time; a.time = ext->anim_time;
a.playback = 0; a.playback = 0;
@@ -474,11 +486,13 @@ void lv_tabview_set_sliding(lv_obj_t * tabview, bool en)
*/ */
void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time) void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time)
{ {
#if LV_USE_ANIMATION
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview); lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
#if LV_USE_ANIMATION == 0
anim_time = 0;
#endif
ext->anim_time = anim_time; ext->anim_time = anim_time;
#else
(void) tabview;
(void) anim_time;
#endif
} }
/** /**
@@ -621,8 +635,13 @@ bool lv_tabview_get_sliding(const lv_obj_t * tabview)
*/ */
uint16_t lv_tabview_get_anim_time(const lv_obj_t * tabview) uint16_t lv_tabview_get_anim_time(const lv_obj_t * tabview)
{ {
#if LV_USE_ANIMATION
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview); lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
return ext->anim_time; return ext->anim_time;
#else
(void) tabview;
return 0;
#endif
} }
/** /**

View File

@@ -62,7 +62,9 @@ typedef struct
lv_point_t point_last; lv_point_t point_last;
uint16_t tab_cur; uint16_t tab_cur;
uint16_t tab_cnt; uint16_t tab_cnt;
#if LV_USE_ANIMATION
uint16_t anim_time; uint16_t anim_time;
#endif
uint8_t slide_enable : 1; /*1: enable horizontal sliding by touch pad*/ uint8_t slide_enable : 1; /*1: enable horizontal sliding by touch pad*/
uint8_t draging : 1; uint8_t draging : 1;
uint8_t drag_hor : 1; uint8_t drag_hor : 1;

View File

@@ -78,7 +78,9 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_tileview); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_tileview);
/*Initialize the allocated 'ext' */ /*Initialize the allocated 'ext' */
#if LV_USE_ANIMATION
ext->anim_time = LV_TILEVIEW_DEF_ANIM_TIME; ext->anim_time = LV_TILEVIEW_DEF_ANIM_TIME;
#endif
ext->act_id.x = 0; ext->act_id.x = 0;
ext->act_id.y = 0; ext->act_id.y = 0;
ext->valid_pos = NULL; ext->valid_pos = NULL;
@@ -109,7 +111,9 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy)
lv_tileview_ext_t * copy_ext = lv_obj_get_ext_attr(copy); lv_tileview_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
ext->act_id.x = copy_ext->act_id.x; ext->act_id.x = copy_ext->act_id.x;
ext->act_id.y = copy_ext->act_id.y; ext->act_id.y = copy_ext->act_id.y;
#if LV_USE_ANIMATION
ext->anim_time = copy_ext->anim_time; ext->anim_time = copy_ext->anim_time;
#endif
/*Refresh the style with new signal function*/ /*Refresh the style with new signal function*/
lv_obj_refresh_style(new_tileview); lv_obj_refresh_style(new_tileview);
@@ -211,9 +215,9 @@ void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, b
lv_anim_t a; lv_anim_t a;
a.var = scrl; a.var = scrl;
a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x; a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x;
a.path_cb = lv_anim_path_linear; a.path_cb = lv_anim_path_linear;
a.ready_cb = NULL; a.ready_cb = NULL;
a.act_time = 0; a.act_time = 0;
a.time = ext->anim_time; a.time = ext->anim_time;
a.playback = 0; a.playback = 0;
@@ -228,9 +232,9 @@ void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, b
} }
if(y_coord != y_act) { if(y_coord != y_act) {
a.start = y_act; a.start = y_act;
a.end = y_coord; a.end = y_coord;
a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y; a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y;
lv_anim_create(&a); lv_anim_create(&a);
} }
#endif #endif

View File

@@ -37,7 +37,9 @@ typedef struct
lv_page_ext_t page; lv_page_ext_t page;
/*New data for this type */ /*New data for this type */
const lv_point_t * valid_pos; const lv_point_t * valid_pos;
#if LV_USE_ANIMATION
uint16_t anim_time; uint16_t anim_time;
#endif
lv_point_t act_id; lv_point_t act_id;
uint8_t drag_top_en : 1; uint8_t drag_top_en : 1;
uint8_t drag_bottom_en : 1; uint8_t drag_bottom_en : 1;