forked from enlightenment/efl
efl_ui_spotlight: Introduce forward and backward animations
forward_animation and backward_animation are introduced instead of push_setup, pop_setup, and jump_setup. forward_animation is started when active element is changed from lower index to higher index. This includes push() case. e.g. current active index is 0 and new active index becomes 1. backward_animation is started when active element is changed from higher index to lower index. This includes pop() case. e.g. current active index is 1 and new active index becomes 0.
This commit is contained in:
parent
6fd2435c9e
commit
72da9ec8c6
|
@ -1136,7 +1136,8 @@ test_ui_spotlight_animation(void *data EINA_UNUSED,
|
|||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Eo *win, *panes, *navi, *list, *layout, *spotlight, *view, *custom_animation_manager;
|
||||
Efl_Canvas_Animation *jump_animation, *push_animation, *pop_animation;
|
||||
Efl_Canvas_Animation *forward_in_animation, *forward_out_animation;
|
||||
Efl_Canvas_Animation *backward_in_animation, *backward_out_animation;
|
||||
Params *params = NULL;
|
||||
char buf[PATH_MAX];
|
||||
int i;
|
||||
|
@ -1168,23 +1169,25 @@ test_ui_spotlight_animation(void *data EINA_UNUSED,
|
|||
efl_file_load(efl_added),
|
||||
efl_content_set(efl_part(panes, "second"), efl_added));
|
||||
|
||||
forward_in_animation = efl_new(EFL_CANVAS_TRANSLATE_ANIMATION_CLASS);
|
||||
efl_animation_translate_set(forward_in_animation, EINA_POSITION2D(0, 100), EINA_POSITION2D(0, 0));
|
||||
efl_animation_duration_set(forward_in_animation, 0.5);
|
||||
|
||||
jump_animation = efl_new(EFL_CANVAS_ALPHA_ANIMATION_CLASS);
|
||||
efl_animation_alpha_set(jump_animation, 0.0, 1.0);
|
||||
efl_animation_duration_set(jump_animation, 0.5);
|
||||
forward_out_animation = efl_new(EFL_CANVAS_ALPHA_ANIMATION_CLASS);
|
||||
efl_animation_alpha_set(forward_out_animation, 1.0, 0.0);
|
||||
efl_animation_duration_set(forward_out_animation, 0.5);
|
||||
|
||||
push_animation = efl_new(EFL_CANVAS_TRANSLATE_ANIMATION_CLASS);
|
||||
efl_animation_translate_set(push_animation, EINA_POSITION2D(0, 100), EINA_POSITION2D(0, 0));
|
||||
efl_animation_duration_set(push_animation, 0.5);
|
||||
backward_in_animation = efl_new(EFL_CANVAS_ALPHA_ANIMATION_CLASS);
|
||||
efl_animation_alpha_set(backward_in_animation, 0.0, 1.0);
|
||||
efl_animation_duration_set(backward_in_animation, 0.5);
|
||||
|
||||
pop_animation = efl_new(EFL_CANVAS_TRANSLATE_ANIMATION_CLASS);
|
||||
efl_animation_translate_set(pop_animation, EINA_POSITION2D(0, -100), EINA_POSITION2D(0, 0));
|
||||
efl_animation_duration_set(pop_animation, 0.5);
|
||||
backward_out_animation = efl_new(EFL_CANVAS_TRANSLATE_ANIMATION_CLASS);
|
||||
efl_animation_translate_set(backward_out_animation, EINA_POSITION2D(0, 0), EINA_POSITION2D(0, 100));
|
||||
efl_animation_duration_set(backward_out_animation, 0.5);
|
||||
|
||||
custom_animation_manager = efl_new(EFL_UI_SPOTLIGHT_ANIMATION_MANAGER_CLASS,
|
||||
efl_ui_spotlight_manager_animation_push_setup_set(efl_added, push_animation),
|
||||
efl_ui_spotlight_manager_animation_pop_setup_set(efl_added, pop_animation),
|
||||
efl_ui_spotlight_manager_animation_jump_setup_set(efl_added, jump_animation, jump_animation));
|
||||
efl_ui_spotlight_manager_animation_forward_animation_set(efl_added, forward_in_animation, forward_out_animation),
|
||||
efl_ui_spotlight_manager_animation_backward_animation_set(efl_added, backward_in_animation, backward_out_animation));
|
||||
|
||||
spotlight = efl_add(EFL_UI_SPOTLIGHT_CONTAINER_CLASS, layout,
|
||||
efl_ui_spotlight_manager_set(efl_added, custom_animation_manager),
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
typedef struct {
|
||||
Efl_Ui_Spotlight_Container * container;
|
||||
Efl_Canvas_Animation *jump_anim[2], *push_anim, *pop_anim;
|
||||
Efl_Canvas_Animation *forward_anim[2], *backward_anim[2];
|
||||
Efl_Gfx_Entity *content[2];
|
||||
Efl_Gfx_Entity *clipper;
|
||||
int ids[2]; //only used when in animation
|
||||
|
@ -149,23 +149,28 @@ _efl_ui_spotlight_animation_manager_efl_ui_spotlight_manager_switch_to(Eo *obj,
|
|||
Efl_Canvas_Animation *animation = NULL;
|
||||
pd->ids[i] = tmp[i];
|
||||
pd->content[i] = efl_pack_content_get(pd->container, pd->ids[i]);
|
||||
//when pushing, animate the *pushed in* content with the push animation
|
||||
if (reason == EFL_UI_SPOTLIGHT_MANAGER_SWITCH_REASON_PUSH && i == 1)
|
||||
animation = pd->push_anim;
|
||||
//when popping, animate the *popped in* content with the pop animation
|
||||
else if (reason == EFL_UI_SPOTLIGHT_MANAGER_SWITCH_REASON_POP && i == 0)
|
||||
animation = pd->pop_anim;
|
||||
//when pushing, animate the *pushed* content with the forward animation
|
||||
if (reason == EFL_UI_SPOTLIGHT_MANAGER_SWITCH_REASON_PUSH)
|
||||
animation = pd->forward_anim[i];
|
||||
//when popping, animate the *popped* content with the backward animation
|
||||
else if (reason == EFL_UI_SPOTLIGHT_MANAGER_SWITCH_REASON_POP)
|
||||
animation = pd->backward_anim[i];
|
||||
if (!animation)
|
||||
animation = pd->jump_anim[i];
|
||||
{
|
||||
if (to > from)
|
||||
animation = pd->forward_anim[i];
|
||||
else
|
||||
animation = pd->backward_anim[i];
|
||||
}
|
||||
if (pd->animation)
|
||||
efl_canvas_object_animation_start(pd->content[i], animation, -1.0+2.0*i, 0.0);
|
||||
efl_canvas_object_animation_start(pd->content[i], animation, 1.0, 0.0);
|
||||
efl_gfx_entity_visible_set(pd->content[i], EINA_TRUE);
|
||||
}
|
||||
if (pd->animation)
|
||||
{
|
||||
efl_event_callback_add(pd->content[0], EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _hide_object_cb, obj);
|
||||
efl_event_callback_add(pd->content[0], EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _running_cb, obj);
|
||||
efl_gfx_stack_above(pd->content[1], pd->content[0]); //Stack the "to content" above the "from content"
|
||||
//efl_gfx_stack_above(pd->content[1], pd->content[0]); //Stack the "to content" above the "from content"
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -227,32 +232,32 @@ _efl_ui_spotlight_animation_manager_efl_ui_spotlight_manager_animated_transition
|
|||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_spotlight_animation_manager_push_setup_set(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Animation_Manager_Data *pd, Efl_Canvas_Animation *animation)
|
||||
{
|
||||
efl_replace(&pd->push_anim, animation);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_spotlight_animation_manager_pop_setup_set(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Animation_Manager_Data *pd, Efl_Canvas_Animation *animation)
|
||||
{
|
||||
efl_replace(&pd->pop_anim, animation);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_spotlight_animation_manager_jump_setup_set(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Animation_Manager_Data *pd, Efl_Canvas_Animation *in, Efl_Canvas_Animation *out)
|
||||
_efl_ui_spotlight_animation_manager_forward_animation_set(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Animation_Manager_Data *pd, Efl_Canvas_Animation *in, Efl_Canvas_Animation *out)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(out);
|
||||
EINA_SAFETY_ON_NULL_RETURN(in);
|
||||
|
||||
efl_replace(&pd->jump_anim[0], out);
|
||||
efl_replace(&pd->jump_anim[1], in);
|
||||
efl_replace(&pd->forward_anim[0], out);
|
||||
efl_replace(&pd->forward_anim[1], in);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_spotlight_animation_manager_backward_animation_set(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Animation_Manager_Data *pd, Efl_Canvas_Animation *in, Efl_Canvas_Animation *out)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(out);
|
||||
EINA_SAFETY_ON_NULL_RETURN(in);
|
||||
|
||||
efl_replace(&pd->backward_anim[0], out);
|
||||
efl_replace(&pd->backward_anim[1], in);
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Object*
|
||||
_efl_ui_spotlight_animation_manager_efl_object_finalize(Eo *obj, Efl_Ui_Spotlight_Animation_Manager_Data *pd)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->jump_anim[0], NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->jump_anim[1], NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->forward_anim[0], NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->forward_anim[1], NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->backward_anim[0], NULL);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(pd->backward_anim[1], NULL);
|
||||
|
||||
return efl_finalize(efl_super(obj, MY_CLASS));
|
||||
}
|
||||
|
|
|
@ -11,35 +11,19 @@ class @beta Efl.Ui.Spotlight.Animation_Manager extends Efl.Ui.Spotlight.Manager
|
|||
]]
|
||||
c_prefix: efl_ui_spotlight_manager_animation;
|
||||
methods {
|
||||
@property push_setup{
|
||||
[[Animation that is used to animate the $to argument of a switch_to request when the passed $reason is push.
|
||||
|
||||
|
||||
If this animation is $null, the in animation of @.jump_setup will be taken instead.
|
||||
@property forward_animation {
|
||||
[[Set the animation objects you want to play on going forward. (going from lower index page to higher index page)
|
||||
]]
|
||||
values {
|
||||
animation : Efl.Canvas.Animation; [[The animation to play, the implementation will take an additional reference]]
|
||||
in : Efl.Canvas.Animation; [[The animation to play, the implementation will take an additional reference]]
|
||||
out : Efl.Canvas.Animation; [[The animation to play, the implementation will take an additional reference. Can be the same as $in.]]
|
||||
}
|
||||
set { }
|
||||
}
|
||||
@property pop_setup{
|
||||
[[Animation that is used to animate the $from argument of a switch_to request when the passed $reason is pop.
|
||||
set {
|
||||
|
||||
Note: this animations is always played backwards, see the class documentation for the reasoning.
|
||||
|
||||
If this animation is $null, the out animation of @.jump_setup will be taken instead.
|
||||
]]
|
||||
values {
|
||||
animation : Efl.Canvas.Animation; [[The animation to play, the implementation will take an additional reference]]
|
||||
}
|
||||
set { }
|
||||
}
|
||||
@property jump_setup{
|
||||
[[Set the animation objects you want to play on a jump in or jump out.
|
||||
|
||||
When a switch to request is issued, two arguments are getting animated. The $from object, and the $to objects. The $from object will be playing the out animation. The $pop object will be playing the in animation.
|
||||
|
||||
The out animation will always be played backwards, this is to support passing the same animation object to both parameters. (A fade animation will fade in the new object, and fade out the old object).
|
||||
@property backward_animation {
|
||||
[[Set the animation objects you want to play on going backward. (going from higher index page to lower index page)
|
||||
]]
|
||||
values {
|
||||
in : Efl.Canvas.Animation; [[The animation to play, the implementation will take an additional reference]]
|
||||
|
@ -51,7 +35,8 @@ class @beta Efl.Ui.Spotlight.Animation_Manager extends Efl.Ui.Spotlight.Manager
|
|||
}
|
||||
}
|
||||
constructors {
|
||||
.jump_setup;
|
||||
.forward_animation;
|
||||
.backward_animation;
|
||||
}
|
||||
implements {
|
||||
Efl.Ui.Spotlight.Manager.bind;
|
||||
|
|
|
@ -12,16 +12,22 @@ typedef struct {
|
|||
EOLIAN static Efl_Object*
|
||||
_efl_ui_spotlight_fade_manager_efl_object_constructor(Eo *obj, Efl_Ui_Spotlight_Fade_Manager_Data *pd EINA_UNUSED)
|
||||
{
|
||||
Efl_Canvas_Animation *animation;
|
||||
Efl_Canvas_Animation *in_animation, *out_animation;
|
||||
|
||||
obj = efl_constructor(efl_super(obj, EFL_UI_SPOTLIGHT_FADE_MANAGER_CLASS));
|
||||
|
||||
animation = efl_add(EFL_CANVAS_ALPHA_ANIMATION_CLASS, obj);
|
||||
efl_animation_alpha_set(animation, 0.0, 1.0);
|
||||
efl_animation_duration_set(animation, 0.5);
|
||||
in_animation = efl_add(EFL_CANVAS_ALPHA_ANIMATION_CLASS, obj);
|
||||
efl_animation_alpha_set(in_animation, 0.0, 1.0);
|
||||
efl_animation_duration_set(in_animation, 0.5);
|
||||
|
||||
efl_ui_spotlight_manager_animation_jump_setup_set(obj, animation, animation);
|
||||
efl_unref(animation);
|
||||
out_animation = efl_add(EFL_CANVAS_ALPHA_ANIMATION_CLASS, obj);
|
||||
efl_animation_alpha_set(out_animation, 0.0, 1.0);
|
||||
efl_animation_duration_set(out_animation, 0.5);
|
||||
|
||||
efl_ui_spotlight_manager_animation_forward_animation_set(obj, in_animation, out_animation);
|
||||
efl_ui_spotlight_manager_animation_backward_animation_set(obj, in_animation, out_animation);
|
||||
efl_unref(in_animation);
|
||||
efl_unref(out_animation);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue