refactor(anim) replace lv_anim_value_t with int32_t

see #2086
This commit is contained in:
Gabor Kiss-Vamosi
2021-02-22 19:01:40 +01:00
parent 9b6516617b
commit 757c18e430
16 changed files with 55 additions and 60 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
#include "../../../lvgl.h"
#if LV_USE_FLEX && LV_BUILD_EXAMPLES
static void row_gap_anim(lv_obj_t * obj, lv_anim_value_t v)
static void row_gap_anim(lv_obj_t * obj, int32_t v)
{
lv_obj_set_style_pad_row(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
}
static void column_gap_anim(lv_obj_t * obj, lv_anim_value_t v)
static void column_gap_anim(lv_obj_t * obj, int32_t v)
{
lv_obj_set_style_pad_column(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
}
+2 -2
View File
@@ -1,12 +1,12 @@
#include "../../../lvgl.h"
#if LV_USE_GRID && LV_BUILD_EXAMPLES
static void row_gap_anim(lv_obj_t * obj, lv_anim_value_t v)
static void row_gap_anim(lv_obj_t * obj, int32_t v)
{
lv_obj_set_style_pad_row(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
}
static void column_gap_anim(lv_obj_t * obj, lv_anim_value_t v)
static void column_gap_anim(lv_obj_t * obj, int32_t v)
{
lv_obj_set_style_pad_column(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
}
+1 -1
View File
@@ -1,7 +1,7 @@
#include "../../../lvgl.h"
#if LV_USE_BAR && LV_BUILD_EXAMPLES
static void set_value(lv_obj_t *bar, lv_anim_value_t v)
static void set_value(lv_obj_t *bar, int32_t v)
{
lv_bar_set_value(bar, v, LV_ANIM_OFF);
}
+2 -2
View File
@@ -1,12 +1,12 @@
#include "../../../lvgl.h"
#if LV_USE_IMG && LV_BUILD_EXAMPLES
static void set_angle(void * img, lv_anim_value_t v)
static void set_angle(void * img, int32_t v)
{
lv_img_set_angle(img, v);
}
static void set_zoom(void * img, lv_anim_value_t v)
static void set_zoom(void * img, int32_t v)
{
lv_img_set_zoom(img, v);
}
+1 -1
View File
@@ -3,7 +3,7 @@
static lv_obj_t * meter;
static void set_value(lv_meter_indicator_t * indic, lv_anim_value_t v)
static void set_value(lv_meter_indicator_t * indic, int32_t v)
{
lv_meter_set_indicator_value(meter, indic, v);
}
+1 -1
View File
@@ -3,7 +3,7 @@
static lv_obj_t * meter;
static void set_value(lv_meter_indicator_t * indic, lv_anim_value_t v)
static void set_value(lv_meter_indicator_t * indic, int32_t v)
{
lv_meter_set_indicator_end_value(meter, indic, v);
}
+1 -1
View File
@@ -3,7 +3,7 @@
static lv_obj_t * meter;
static void set_value(lv_meter_indicator_t * indic, lv_anim_value_t v)
static void set_value(lv_meter_indicator_t * indic, int32_t v)
{
lv_meter_set_indicator_end_value(meter, indic, v);
}
+4 -4
View File
@@ -20,8 +20,8 @@
/**********************
* STATIC PROTOTYPES
**********************/
static void arc_anim_start_angle(void * obj, lv_anim_value_t v);
static void arc_anim_end_angle(void * obj, lv_anim_value_t v);
static void arc_anim_start_angle(void * obj, int32_t v);
static void arc_anim_end_angle(void * obj, int32_t v);
/**********************
* STATIC VARIABLES
@@ -82,13 +82,13 @@ lv_obj_t * lv_spinner_create(lv_obj_t * par, uint32_t time, uint32_t arc_length)
* STATIC FUNCTIONS
**********************/
static void arc_anim_start_angle(void * obj, lv_anim_value_t v)
static void arc_anim_start_angle(void * obj, int32_t v)
{
lv_arc_set_start_angle(obj, (uint16_t) v);
}
static void arc_anim_end_angle(void * obj, lv_anim_value_t v)
static void arc_anim_end_angle(void * obj, int32_t v)
{
lv_arc_set_end_angle(obj, (uint16_t) v);
}
+2 -2
View File
@@ -23,7 +23,7 @@
**********************/
static void scr_load_anim_start(lv_anim_t * a);
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v);
static void opa_scale_anim(lv_obj_t * obj, int32_t v);
static void scr_anim_ready(lv_anim_t * a);
/**********************
@@ -377,7 +377,7 @@ static void scr_load_anim_start(lv_anim_t * a)
lv_disp_load_scr(a->var);
}
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v)
static void opa_scale_anim(lv_obj_t * obj, int32_t v)
{
lv_obj_set_style_opa(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
}
+4 -4
View File
@@ -28,8 +28,8 @@ void lv_obj_move_children_by(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_dif
/**********************
* STATIC PROTOTYPES
**********************/
static void scroll_anim_x_cb(lv_obj_t * obj, lv_anim_value_t v);
static void scroll_anim_y_cb(lv_obj_t * obj, lv_anim_value_t v);
static void scroll_anim_x_cb(lv_obj_t * obj, int32_t v);
static void scroll_anim_y_cb(lv_obj_t * obj, int32_t v);
static void scroll_anim_ready_cb(lv_anim_t * a);
/**********************
@@ -390,12 +390,12 @@ void lv_obj_scroll_to_view_recursive(lv_obj_t * obj, lv_anim_enable_t anim_en)
* STATIC FUNCTIONS
**********************/
static void scroll_anim_x_cb(lv_obj_t * obj, lv_anim_value_t v)
static void scroll_anim_x_cb(lv_obj_t * obj, int32_t v)
{
_lv_obj_scroll_by_raw(obj, v + lv_obj_get_scroll_x(obj), 0);
}
static void scroll_anim_y_cb(lv_obj_t * obj, lv_anim_value_t v)
static void scroll_anim_y_cb(lv_obj_t * obj, int32_t v)
{
_lv_obj_scroll_by_raw(obj, 0, v + lv_obj_get_scroll_y(obj));
}
+4 -4
View File
@@ -55,10 +55,10 @@ static cache_t read_cache(const lv_obj_t * obj, lv_part_t part, lv_style_prop_t
static void report_style_change_core(void * style, lv_obj_t * obj);
static void refresh_children_style(lv_obj_t * obj);
static bool trans_del(lv_obj_t * obj, uint8_t part, lv_style_prop_t prop, trans_t * tr_limit);
static void trans_anim_cb(trans_t * tr, lv_anim_value_t v);
static void trans_anim_cb(trans_t * tr, int32_t v);
static void trans_anim_start_cb(lv_anim_t * a);
static void trans_anim_ready_cb(lv_anim_t * a);
static void fade_anim_cb(lv_obj_t * obj, lv_anim_value_t v);
static void fade_anim_cb(lv_obj_t * obj, int32_t v);
static void fade_in_anim_ready(lv_anim_t * a);
/**********************
@@ -848,7 +848,7 @@ static bool trans_del(lv_obj_t * obj, uint8_t part, lv_style_prop_t prop, trans_
return removed;
}
static void trans_anim_cb(trans_t * tr, lv_anim_value_t v)
static void trans_anim_cb(trans_t * tr, int32_t v)
{
lv_obj_style_list_t * list = &tr->obj->style_list;
@@ -968,7 +968,7 @@ static void trans_anim_ready_cb(lv_anim_t * a)
}
}
static void fade_anim_cb(lv_obj_t * obj, lv_anim_value_t v)
static void fade_anim_cb(lv_obj_t * obj, int32_t v)
{
lv_obj_set_style_opa(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
}
+8 -8
View File
@@ -207,7 +207,7 @@ uint16_t lv_anim_count_running(void)
* @param end end value of the animation
* @return the required time [ms] for the animation with the given parameters
*/
uint32_t lv_anim_speed_to_time(uint32_t speed, lv_anim_value_t start, lv_anim_value_t end)
uint32_t lv_anim_speed_to_time(uint32_t speed, int32_t start, int32_t end)
{
uint32_t d = LV_ABS(start - end);
uint32_t time = (d * 1000) / speed;
@@ -235,7 +235,7 @@ void lv_anim_refr_now(void)
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_linear(const lv_anim_path_t * path, const lv_anim_t * a)
int32_t lv_anim_path_linear(const lv_anim_path_t * path, const lv_anim_t * a)
{
LV_UNUSED(path);
@@ -257,7 +257,7 @@ lv_anim_value_t lv_anim_path_linear(const lv_anim_path_t * path, const lv_anim_t
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_in(const lv_anim_path_t * path, const lv_anim_t * a)
int32_t lv_anim_path_ease_in(const lv_anim_path_t * path, const lv_anim_t * a)
{
LV_UNUSED(path);
@@ -279,7 +279,7 @@ lv_anim_value_t lv_anim_path_ease_in(const lv_anim_path_t * path, const lv_anim_
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_out(const lv_anim_path_t * path, const lv_anim_t * a)
int32_t lv_anim_path_ease_out(const lv_anim_path_t * path, const lv_anim_t * a)
{
LV_UNUSED(path);
@@ -300,7 +300,7 @@ lv_anim_value_t lv_anim_path_ease_out(const lv_anim_path_t * path, const lv_anim
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_path_t * path, const lv_anim_t * a)
int32_t lv_anim_path_ease_in_out(const lv_anim_path_t * path, const lv_anim_t * a)
{
LV_UNUSED(path);
@@ -321,7 +321,7 @@ lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_path_t * path, const lv_a
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_overshoot(const lv_anim_path_t * path, const lv_anim_t * a)
int32_t lv_anim_path_overshoot(const lv_anim_path_t * path, const lv_anim_t * a)
{
LV_UNUSED(path);
@@ -343,7 +343,7 @@ lv_anim_value_t lv_anim_path_overshoot(const lv_anim_path_t * path, const lv_ani
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t * a)
int32_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t * a)
{
LV_UNUSED(path);
@@ -402,7 +402,7 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_step(const lv_anim_path_t * path, const lv_anim_t * a)
int32_t lv_anim_path_step(const lv_anim_path_t * path, const lv_anim_t * a)
{
LV_UNUSED(path);
+14 -19
View File
@@ -29,22 +29,17 @@ extern "C" {
**********************/
/** Can be used to indicate if animations are enabled or disabled in a case*/
enum {
typedef enum {
LV_ANIM_OFF,
LV_ANIM_ON,
};
typedef uint8_t lv_anim_enable_t;
/** Type of the animated value*/
typedef lv_coord_t lv_anim_value_t;
}lv_anim_enable_t;
#define LV_ANIM_REPEAT_INFINITE 0xFFFF
struct _lv_anim_t;
struct _lv_anim_path_t;
/** Get the current value during an animation*/
typedef lv_anim_value_t (*lv_anim_path_cb_t)(const struct _lv_anim_path_t *, const struct _lv_anim_t *);
typedef int32_t (*lv_anim_path_cb_t)(const struct _lv_anim_path_t *, const struct _lv_anim_t *);
typedef struct _lv_anim_path_t {
lv_anim_path_cb_t cb;
@@ -57,11 +52,11 @@ typedef struct _lv_anim_path_t {
* Compatible with `lv_xxx_set_yyy(obj, value)` functions
* The `x` in `_xcb_t` means its not a fully generic prototype because
* it doesn't receive `lv_anim_t *` as its first argument*/
typedef void (*lv_anim_exec_xcb_t)(void *, lv_anim_value_t);
typedef void (*lv_anim_exec_xcb_t)(void *, int32_t);
/** Same as `lv_anim_exec_xcb_t` but receives `lv_anim_t *` as the first parameter.
* It's more consistent but less convenient. Might be used by binding generator functions.*/
typedef void (*lv_anim_custom_exec_cb_t)(struct _lv_anim_t *, lv_anim_value_t);
typedef void (*lv_anim_custom_exec_cb_t)(struct _lv_anim_t *, int32_t);
/** Callback to call when the animation is ready*/
typedef void (*lv_anim_ready_cb_t)(struct _lv_anim_t *);
@@ -163,7 +158,7 @@ static inline void lv_anim_set_delay(lv_anim_t * a, uint32_t delay)
* @param start the start value
* @param end the end value
*/
static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_anim_value_t end)
static inline void lv_anim_set_values(lv_anim_t * a, int32_t start, int32_t end)
{
a->start = start;
a->current = start;
@@ -342,7 +337,7 @@ uint16_t lv_anim_count_running(void);
* @param end end value of the animation
* @return the required time [ms] for the animation with the given parameters
*/
uint32_t lv_anim_speed_to_time(uint32_t speed, lv_anim_value_t start, lv_anim_value_t end);
uint32_t lv_anim_speed_to_time(uint32_t speed, int32_t start, int32_t end);
/**
* Manually refresh the state of the animations.
@@ -357,42 +352,42 @@ void lv_anim_refr_now(void);
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_linear(const lv_anim_path_t * path, const lv_anim_t * a);
int32_t lv_anim_path_linear(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation slowing down the start phase
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_in(const lv_anim_path_t * path, const lv_anim_t * a);
int32_t lv_anim_path_ease_in(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation slowing down the end phase
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_out(const lv_anim_path_t * path, const lv_anim_t * a);
int32_t lv_anim_path_ease_out(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation applying an "S" characteristic (cosine)
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_path_t * path, const lv_anim_t * a);
int32_t lv_anim_path_ease_in_out(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation with overshoot at the end
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_overshoot(const lv_anim_path_t * path, const lv_anim_t * a);
int32_t lv_anim_path_overshoot(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation with 3 bounces
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t * a);
int32_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t * a);
/**
* Calculate the current value of an animation applying step characteristic.
@@ -400,7 +395,7 @@ lv_anim_value_t lv_anim_path_bounce(const lv_anim_path_t * path, const lv_anim_t
* @param a pointer to an animation
* @return the current value to set
*/
lv_anim_value_t lv_anim_path_step(const lv_anim_path_t * path, const lv_anim_t * a);
int32_t lv_anim_path_step(const lv_anim_path_t * path, const lv_anim_t * a);
/**********************
* GLOBAL VARIABLES
+2 -2
View File
@@ -53,7 +53,7 @@ static void draw_indic(lv_obj_t * bar, const lv_area_t * clip_area);
static void lv_bar_set_value_with_anim(lv_obj_t * obj, int16_t new_value, int16_t * value_ptr,
lv_bar_anim_t * anim_info, lv_anim_enable_t en);
static void lv_bar_init_anim(lv_obj_t * bar, lv_bar_anim_t * bar_anim);
static void lv_bar_anim(lv_bar_anim_t * bar, lv_anim_value_t value);
static void lv_bar_anim(lv_bar_anim_t * bar, int32_t value);
static void lv_bar_anim_ready(lv_anim_t * a);
/**********************
@@ -497,7 +497,7 @@ static lv_res_t lv_bar_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
return res;
}
static void lv_bar_anim(lv_bar_anim_t * var, lv_anim_value_t value)
static void lv_bar_anim(lv_bar_anim_t * var, int32_t value)
{
var->anim_state = value;
lv_obj_invalidate(var->bar);
+3 -3
View File
@@ -39,9 +39,9 @@ typedef uint8_t lv_bar_type_t;
typedef struct {
lv_obj_t * bar;
lv_anim_value_t anim_start;
lv_anim_value_t anim_end;
lv_anim_value_t anim_state;
int32_t anim_start;
int32_t anim_end;
int32_t anim_state;
} lv_bar_anim_t;
typedef struct {
+4 -4
View File
@@ -49,8 +49,8 @@ static void lv_textarea_constructor(lv_obj_t * obj, const lv_obj_t * copy);
static void lv_textarea_destructor(lv_obj_t * obj);
static lv_draw_res_t lv_textarea_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode);
static lv_res_t lv_textarea_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
static void cursor_blink_anim_cb(lv_obj_t * obj, lv_anim_value_t show);
static void pwd_char_hider_anim(lv_obj_t * obj, lv_anim_value_t x);
static void cursor_blink_anim_cb(lv_obj_t * obj, int32_t show);
static void pwd_char_hider_anim(lv_obj_t * obj, int32_t x);
static void pwd_char_hider_anim_ready(lv_anim_t * a);
static void pwd_char_hider(lv_obj_t * obj);
static bool char_is_accepted(lv_obj_t * obj, uint32_t c);
@@ -1130,7 +1130,7 @@ static lv_res_t lv_textarea_signal(lv_obj_t * obj, lv_signal_t sign, void * para
* @param ta pointer to a text area
* @param hide 1: hide the cursor, 0: show it
*/
static void cursor_blink_anim_cb(lv_obj_t * obj, lv_anim_value_t show)
static void cursor_blink_anim_cb(lv_obj_t * obj, int32_t show)
{
lv_textarea_t * ta = (lv_textarea_t *) obj;
if(show != ta->cursor.show) {
@@ -1152,7 +1152,7 @@ static void cursor_blink_anim_cb(lv_obj_t * obj, lv_anim_value_t show)
* @param ta unused
* @param x unused
*/
static void pwd_char_hider_anim(lv_obj_t * obj, lv_anim_value_t x)
static void pwd_char_hider_anim(lv_obj_t * obj, int32_t x)
{
LV_UNUSED(obj);
LV_UNUSED(x);