edje: add support to control the transition time of edje animation globally.

Summary:
Add the transition scale flag and the transtion scale value.
This flag can be change using "transition_scale_enable" in edje program.
If flag is true, the transition scale value affect the transition speed of edje
The transition scale value can be change by elm_config.

@feature

Test Plan: elementary_config

Reviewers: Hermet, cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2287

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
jiin.moon 2015-06-22 17:56:08 +02:00 committed by Cedric BAIL
parent 8b62177561
commit 6487a26354
7 changed files with 156 additions and 90 deletions

View File

@ -247,6 +247,7 @@ Eina_Bool edje_cc_handlers_wildcard(void);
void edje_cc_handlers_hierarchy_alloc(void);
void edje_cc_handlers_hierarchy_free(void);
void edje_cc_handlers_pop_notify(const char *token);
int get_param_index(char *str);
/* global vars */
extern Eina_List *ext_dirs;

View File

@ -1570,6 +1570,7 @@ _edje_program_copy(Edje_Program *ep, Edje_Program *ep2)
ep->tween.v2 = ep2->tween.v2;
ep->tween.v3 = ep2->tween.v3;
ep->tween.v4 = ep2->tween.v4;
ep->tween.use_duration_factor = ep2->tween.use_duration_factor;
ep->sample_name = STRDUP(ep2->sample_name);
ep->tone_name = STRDUP(ep2->tone_name);
ep->duration = ep2->duration;
@ -12002,6 +12003,7 @@ ob_collections_group_programs_program(void)
ep = mem_alloc(SZ(Edje_Program_Parser));
ep->id = -1;
ep->tween.mode = EDJE_TWEEN_MODE_LINEAR;
ep->tween.use_duration_factor = EINA_FALSE;
ep->after = NULL;
epp = (Edje_Program_Parser *)ep;
epp->can_override = EINA_FALSE;
@ -12486,7 +12488,8 @@ st_collections_group_programs_program_action(void)
static void
st_collections_group_programs_program_transition(void)
{
char *tmp = NULL;
int current = -1, index = -1;
unsigned int required_args = 0;
check_min_arg_count(2);
@ -12522,106 +12525,101 @@ st_collections_group_programs_program_transition(void)
"SPRING", EDJE_TWEEN_MODE_SPRING,
NULL);
current_program->tween.time = FROM_DOUBLE(parse_float_range(1, 0.0, 999999999.0));
if ((current_program->tween.mode >= EDJE_TWEEN_MODE_LINEAR) &&
(current_program->tween.mode <= EDJE_TWEEN_MODE_DECELERATE))
//Check the index of params not related to tweenmode's param
//This index use for count of the tweenmode's param
if ((index = get_param_index("USE_DURATION_FACTOR")) != -1)
{
tmp = NULL;
if ((get_arg_count() == 3) && (!strcmp((tmp = parse_str(2)), "CURRENT")))
{
free(tmp);
current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
}
else if (get_arg_count() != 2)
{
free(tmp);
ERR("parse error %s:%i. Need 2rd parameter to set time",
file_in, line - 1);
exit(-1);
}
current_program->tween.use_duration_factor = parse_bool(index + 1);
required_args += 2;
}
// the following need v1
// EDJE_TWEEN_MODE_ACCELERATE_FACTOR
// EDJE_TWEEN_MODE_DECELERATE_FACTOR
// EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR
// current_program->tween.v1
else if ((current_program->tween.mode >= EDJE_TWEEN_MODE_ACCELERATE_FACTOR) &&
(current_program->tween.mode <= EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR))
if ((current = get_param_index("CURRENT")) != -1)
{
tmp = NULL;
if ((get_arg_count() == 4) && (!strcmp((tmp = parse_str(3)), "CURRENT")))
{
free(tmp);
current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
}
else if (get_arg_count() != 3)
{
free(tmp);
ERR("parse error %s:%i. Need 3rd parameter to set factor",
file_in, line - 1);
exit(-1);
}
current_program->tween.v1 = FROM_DOUBLE(parse_float_range(2, 0.0, 999999999.0));
if (index == -1 || current < index)
index = current;
required_args++;
}
// the followjng also need v2
// EDJE_TWEEN_MODE_DIVISOR_INTERP
// EDJE_TWEEN_MODE_BOUNCE
// EDJE_TWEEN_MODE_SPRING
// current_program->tween.v2
else if ((current_program->tween.mode >= EDJE_TWEEN_MODE_DIVISOR_INTERP) &&
(current_program->tween.mode <= EDJE_TWEEN_MODE_SPRING))
switch(current_program->tween.mode)
{
tmp = NULL;
if ((get_arg_count() == 5) && (!strcmp((tmp = parse_str(4)), "CURRENT")))
case EDJE_TWEEN_MODE_LINEAR:
case EDJE_TWEEN_MODE_SINUSOIDAL:
case EDJE_TWEEN_MODE_ACCELERATE:
case EDJE_TWEEN_MODE_DECELERATE:
{
free(tmp);
current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
required_args += 2;
check_arg_count(required_args);
}
else if (get_arg_count() != 4)
break;
// the following need v1
case EDJE_TWEEN_MODE_ACCELERATE_FACTOR:
case EDJE_TWEEN_MODE_DECELERATE_FACTOR:
case EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR:
{
free(tmp);
ERR("parse error %s:%i. "
"Need 3rd and 4th parameters to set factor and counts",
file_in, line - 1);
exit(-1);
required_args += 3;
check_arg_count(required_args);
if (index == -1 || index > 2)
{
current_program->tween.v1 =
FROM_DOUBLE(parse_float_range(2, -999999999.0, 999999999.0));
break;
}
else
{
ERR("parse error %s:%i. Need 3rd parameter to set factor",
file_in, line - 1);
exit(-1);
}
}
current_program->tween.v1 = FROM_DOUBLE(parse_float_range(2, 0.0, 999999999.0));
current_program->tween.v2 = FROM_DOUBLE(parse_float_range(3, 0.0, 999999999.0));
}
else if (current_program->tween.mode == EDJE_TWEEN_MODE_CUBIC_BEZIER)
{
tmp = NULL;
if ((get_arg_count() == 7) && (!strcmp((tmp = parse_str(4)), "CURRENT")))
case EDJE_TWEEN_MODE_DIVISOR_INTERP:
case EDJE_TWEEN_MODE_BOUNCE:
case EDJE_TWEEN_MODE_SPRING:
{
free(tmp);
current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
required_args += 4;
check_arg_count(required_args);
if (index == -1 || index > 3)
{
current_program->tween.v1 =
FROM_DOUBLE(parse_float_range(2, -999999999.0, 999999999.0));
current_program->tween.v2 =
FROM_DOUBLE(parse_float_range(3, -999999999.0, 999999999.0));
break;
}
else
{
ERR("parse error %s:%i. "
"Need 3rd and 4th parameters to set factor and counts",
file_in, line - 1);
exit(-1);
}
}
else if (get_arg_count() != 6)
case EDJE_TWEEN_MODE_CUBIC_BEZIER:
{
free(tmp);
ERR("parse error %s:%i. "
"Need 3rd, 4th, 5th and 6th parameters to set x1, y1, x2 and y2",
file_in, line - 1);
exit(-1);
required_args += 6;
check_arg_count(required_args);
if (index == -1 || index > 5)
{
current_program->tween.v1 =
FROM_DOUBLE(parse_float_range(2, -999999999.0, 999999999.0));
current_program->tween.v2 =
FROM_DOUBLE(parse_float_range(3, -999999999.0, 999999999.0));
current_program->tween.v3 =
FROM_DOUBLE(parse_float_range(4, -999999999.0, 999999999.0));
current_program->tween.v4 =
FROM_DOUBLE(parse_float_range(5, -999999999.0, 999999999.0));
break;
}
else
{
ERR("parse error %s:%i. "
"Need 3rd, 4th, 5th and 6th parameters to set x1, y1, x2 and y2",
file_in, line - 1);
exit(-1);
}
}
current_program->tween.v1 =
FROM_DOUBLE(parse_float_range(2, -999999999.0, 999999999.0));
current_program->tween.v2 =
FROM_DOUBLE(parse_float_range(3, -999999999.0, 999999999.0));
if (get_arg_count() == 7)
{
current_program->tween.v3 =
FROM_DOUBLE(parse_float_range(5, -999999999.0, 999999999.0));
current_program->tween.v4 =
FROM_DOUBLE(parse_float_range(6, -999999999.0, 999999999.0));
}
else
{
current_program->tween.v3 =
FROM_DOUBLE(parse_float_range(4, -999999999.0, 999999999.0));
current_program->tween.v4 =
FROM_DOUBLE(parse_float_range(5, -999999999.0, 999999999.0));
}
}
}
if (current > 0)
current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
}
static void

View File

@ -1815,3 +1815,15 @@ strstrip(const char *in, char *out, size_t size)
*out = '\0';
return 1;
}
int
get_param_index(char *str)
{
int index ;
for(index = 0; index < get_arg_count(); index++)
{
if(!strcmp(str,_parse_param_get(index)))
return index;
}
return -1;
}

View File

@ -1833,6 +1833,43 @@ EAPI void edje_thaw (void);
*/
EAPI void edje_language_set (const char *locale);
/**
* @brief Set edje trasition's duration factor.
*
* @param scale The edje trasition's duration factor (the default value is @c 1.0)
*
* This function sets the edje transition duration factor
* It will affect the speed of transitions
* which had the @c use_duration_factor property set to @1.
* The default value of @c use_duration_factor property is @c zero,
* but can be changed by @p "USE_DURATION_FACTOR 1" or @p "USE_DURATION_FACTOR 0"
* as parameter of @c "TRANSITION" property at EDC level.
* If the parameter is @p "USE_DURATION_FACTOR 0" or not mentioned about @p "USE_DURATION_FACTOR",
* the duration of transition keeps original duration
*
* @warning The transition's duration factor cannot be set on each translation.
* If you use this function, it will affect transitions globally
*
* @see edje_transition_duration_factor_get()
*
* @since 1.15
*/
EAPI void edje_transition_duration_factor_set (double scale);
/**
* @brief Retrieve trasitions'duration factor.
*
* @return The edje transition duration factor
*
* This function returns the edje transition duration factor.
*
* @see edje_transition_duration_set() for more details
*
* @since 1.15
*
*/
EAPI double edje_transition_duration_factor_get (void);
/**
* @}
*/

View File

@ -580,6 +580,7 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "v2", tween.v2, EDJE_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "v3", tween.v3, EDJE_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "v4", tween.v4, EDJE_T_FLOAT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "use_duration_factor", tween.use_duration_factor, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_program, Edje_Program, "targets", targets, _edje_edd_edje_program_target);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_program, Edje_Program, "after", after, _edje_edd_edje_program_after);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "api.name", api.name, EET_T_STRING);

View File

@ -756,6 +756,7 @@ struct _Edje_Program /* a conditional program to be run */
FLOAT_T v2; /* other value for drag actions */
FLOAT_T v3; /* other value for drag actions */
FLOAT_T v4; /* other value for drag actions */
Eina_Bool use_duration_factor; /* use duration factor or not */
} tween;
Eina_List *targets; /* list of target parts to apply the state to */

View File

@ -7,6 +7,7 @@ static void _edje_param_set(Edje *ed, Edje_Real_Part *part, const char *param, c
int _edje_anim_count = 0;
Ecore_Animator *_edje_timer = NULL;
Eina_List *_edje_animators = NULL;
static double _edje_transition_duration_scale = 0;
static Eina_Bool
_edje_emit_aliased(Edje *ed, const char *part, const char *sig, const char *src)
@ -182,6 +183,18 @@ edje_frametime_get(void)
return ecore_animator_frametime_get();
}
EAPI double
edje_transition_duration_factor_get(void)
{
return _edje_transition_duration_scale;
}
EAPI void
edje_transition_duration_factor_set(double scale)
{
_edje_transition_duration_scale = FROM_DOUBLE(scale);
}
void
edje_object_propagate_callback_add(Evas_Object *obj, void (*func)(void *data, Evas_Object *o, const char *emission, const char *source), void *data)
{
@ -399,7 +412,7 @@ _edje_object_animation_get(Eo *obj EINA_UNUSED, Edje *ed)
Eina_Bool
_edje_program_run_iterate(Edje_Running_Program *runp, double tim)
{
FLOAT_T t, total;
FLOAT_T t, total, t_scale = 1.0;
Eina_List *l;
Edje *ed;
Edje_Program_Target *pt;
@ -410,8 +423,11 @@ _edje_program_run_iterate(Edje_Running_Program *runp, double tim)
_edje_block(ed);
_edje_ref(ed);
_edje_util_freeze(ed);
if (runp->program->tween.use_duration_factor)
t_scale = _edje_transition_duration_scale;
t = FROM_DOUBLE(tim - runp->start_time);
total = runp->program->tween.time;
total = runp->program->tween.time * t_scale;
t = DIV(t, total);
if (t > FROM_INT(1)) t = FROM_INT(1);
EINA_LIST_FOREACH(runp->program->targets, l, pt)