feat(style) add user_data paramter to lv_style_transition_dsc_init
This commit is contained in:
@@ -47,7 +47,7 @@ void lv_example_btn_2(void)
|
||||
/*Add a transition to the the outline*/
|
||||
static lv_style_transition_dsc_t trans;
|
||||
static lv_style_prop_t props[] = {LV_STYLE_OUTLINE_WIDTH, LV_STYLE_OUTLINE_OPA, 0};
|
||||
lv_style_transition_dsc_init(&trans, props, lv_anim_path_linear, 300, 0);
|
||||
lv_style_transition_dsc_init(&trans, props, lv_anim_path_linear, 300, 0, NULL);
|
||||
|
||||
lv_style_set_transition(&style_pr, &trans);
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@ void lv_example_btn_3(void)
|
||||
/*Transition descriptor when going back to the default state.
|
||||
*Add some delay to be sure the press transition is visible even if the press was very short*/
|
||||
static lv_style_transition_dsc_t transition_dsc_def;
|
||||
lv_style_transition_dsc_init(&transition_dsc_def, props, lv_anim_path_overshoot, 250, 100);
|
||||
lv_style_transition_dsc_init(&transition_dsc_def, props, lv_anim_path_overshoot, 250, 100, NULL);
|
||||
|
||||
/*Transition descriptor when going to pressed state.
|
||||
*No delay, go to presses state immediately*/
|
||||
static lv_style_transition_dsc_t transition_dsc_pr;
|
||||
lv_style_transition_dsc_init(&transition_dsc_pr, props, lv_anim_path_ease_in_out, 250, 0);
|
||||
lv_style_transition_dsc_init(&transition_dsc_pr, props, lv_anim_path_ease_in_out, 250, 0, NULL);
|
||||
|
||||
/*Add only the new transition to he default state*/
|
||||
static lv_style_t style_def;
|
||||
|
||||
@@ -10,7 +10,7 @@ void lv_example_imgbtn_1(void)
|
||||
/*Create a transition animation on width transformation and recolor.*/
|
||||
static lv_style_prop_t tr_prop[] = {LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_IMG_RECOLOR_OPA, 0};
|
||||
static lv_style_transition_dsc_t tr;
|
||||
lv_style_transition_dsc_init(&tr, tr_prop, lv_anim_path_linear, 200, 0);
|
||||
lv_style_transition_dsc_init(&tr, tr_prop, lv_anim_path_linear, 200, 0, NULL);
|
||||
|
||||
static lv_style_t style_def;
|
||||
lv_style_init(&style_def);
|
||||
|
||||
@@ -11,7 +11,7 @@ void lv_example_slider_2(void)
|
||||
/*Create a transition*/
|
||||
static const lv_style_prop_t props[] = {LV_STYLE_BG_COLOR, 0};
|
||||
static lv_style_transition_dsc_t transition_dsc;
|
||||
lv_style_transition_dsc_init(&transition_dsc, props, lv_anim_path_linear, 300, 0);
|
||||
lv_style_transition_dsc_init(&transition_dsc, props, lv_anim_path_linear, 300, 0, NULL);
|
||||
|
||||
static lv_style_t style_main;
|
||||
static lv_style_t style_indicator;
|
||||
|
||||
@@ -213,10 +213,10 @@ static void style_init(void)
|
||||
color_grey = theme.flags & MODE_DARK ? DARK_COLOR_GREY : LIGHT_COLOR_GREY;
|
||||
|
||||
static lv_style_transition_dsc_t trans_delayed;
|
||||
lv_style_transition_dsc_init(&trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70);
|
||||
lv_style_transition_dsc_init(&trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70, NULL);
|
||||
|
||||
static lv_style_transition_dsc_t trans_normal;
|
||||
lv_style_transition_dsc_init(&trans_normal, trans_props, lv_anim_path_linear, TRANSITION_TIME, 0);
|
||||
lv_style_transition_dsc_init(&trans_normal, trans_props, lv_anim_path_linear, TRANSITION_TIME, 0, NULL);
|
||||
|
||||
style_init_reset(&styles->transition_delayed);
|
||||
lv_style_set_transition(&styles->transition_delayed, &trans_delayed); /*Go back to default state with delay*/
|
||||
|
||||
@@ -210,13 +210,16 @@ lv_res_t lv_style_get_prop(lv_style_t * style, lv_style_prop_t prop, lv_style_va
|
||||
return lv_style_get_prop_inlined(style, prop, value);
|
||||
}
|
||||
|
||||
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[], lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay)
|
||||
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[], lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay, void * user_data)
|
||||
{
|
||||
lv_memset_00(tr, sizeof(lv_style_transition_dsc_t));
|
||||
tr->props = props;
|
||||
tr->path_xcb = path_cb == NULL ? lv_anim_path_linear : path_cb;
|
||||
tr->time = time;
|
||||
tr->delay = delay;
|
||||
#if LV_USE_USER_DATA
|
||||
tr->user_data = user_data;
|
||||
#endif
|
||||
}
|
||||
|
||||
lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop)
|
||||
|
||||
@@ -385,15 +385,16 @@ static inline lv_res_t lv_style_get_prop_inlined(lv_style_t * style, lv_style_pr
|
||||
* Initialize a transition descriptor.
|
||||
* @param tr pointer to a transition descriptor to initialize
|
||||
* @param props an array with the properties to transition. The last element must be zero.
|
||||
* @param path_cb and animation path (ease) callback. If `NULL` liner path will be used.
|
||||
* @param path_cb an animation path (ease) callback. If `NULL` liner path will be used.
|
||||
* @param time duration of the transition in [ms]
|
||||
* @param delay delay before the transition in [ms]
|
||||
* @param user_data any custom data that will be saved in the transition animation and will be available when `path_cb` is called
|
||||
* @example
|
||||
* const static lv_style_prop_t trans_props[] = { LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, 0 };
|
||||
* static lv_style_transition_dsc_t trans1;
|
||||
* lv_style_transition_dsc_init(&trans1, trans_props, NULL, 300, 0);
|
||||
* lv_style_transition_dsc_init(&trans1, trans_props, NULL, 300, 0, NULL);
|
||||
*/
|
||||
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[], lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay);
|
||||
void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style_prop_t props[], lv_anim_path_cb_t path_cb, uint32_t time, uint32_t delay, void * user_data);
|
||||
|
||||
/**
|
||||
* Get the default value of a property
|
||||
|
||||
Reference in New Issue
Block a user