Transit¶
Widget description¶
Transit is designed to apply various animated transition effects to
Evas_Object
, such like translation, rotation, etc. For using these
effects, create a Transit
and add the desired transition effects.
Once the effects are added into transit, they will be automatically managed (their callback will be called for the set duration and they will be deleted upon completion).
Example:
from efl.elementary.transit import Transit, ELM_TRANSIT_TWEEN_MODE_DECELERATE
t = Transit()
t.object_add(obj)
t.effect_translation_add(0, 0, 280, 280)
t.duration = 1
t.auto_reverse = True
t.tween_mode = ELM_TRANSIT_TWEEN_MODE_DECELERATE
t.repeat_times = 3
Some transition effects are used to change the properties of objects. They are:
Other transition effects are used to make one object disappear and another object appear on its place. These effects are:
It’s also possible to make a transition chain with
chain_transit_add()
.
Warning
We strongly recommend to use elm_transit just when edje can not do the trick. Edje is better at handling transitions than Elm_Transit. Edje has more flexibility and animations can be manipulated inside the theme.
Enumerations¶
Flip effects¶
- efl.elementary.ELM_TRANSIT_EFFECT_FLIP_AXIS_X¶
Flip on X axis
- efl.elementary.ELM_TRANSIT_EFFECT_FLIP_AXIS_Y¶
Flip on Y axis
Wipe effects¶
- efl.elementary.ELM_TRANSIT_EFFECT_WIPE_DIR_LEFT¶
Wipe to the left
- efl.elementary.ELM_TRANSIT_EFFECT_WIPE_DIR_RIGHT¶
Wipe to the right
- efl.elementary.ELM_TRANSIT_EFFECT_WIPE_DIR_UP¶
Wipe up
- efl.elementary.ELM_TRANSIT_EFFECT_WIPE_DIR_DOWN¶
Wipe down
Wipe types¶
- efl.elementary.ELM_TRANSIT_EFFECT_WIPE_TYPE_HIDE¶
Hide the object during the animation.
- efl.elementary.ELM_TRANSIT_EFFECT_WIPE_TYPE_SHOW¶
Show the object during the animation.
Tween modes¶
- efl.elementary.ELM_TRANSIT_TWEEN_MODE_LINEAR¶
Constant speed
- efl.elementary.ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL¶
Starts slow, increase speed over time, then decrease again and stop slowly
- efl.elementary.ELM_TRANSIT_TWEEN_MODE_DECELERATE¶
Starts fast and decrease speed over time
- efl.elementary.ELM_TRANSIT_TWEEN_MODE_ACCELERATE¶
Starts slow and increase speed over time
- efl.elementary.ELM_TRANSIT_TWEEN_MODE_DIVISOR_INTERP¶
Start at gradient v1, interpolated via power of v2 curve
New in version 1.13.
- efl.elementary.ELM_TRANSIT_TWEEN_MODE_BOUNCE¶
Start at 0.0 then “drop” like a ball bouncing to the ground at 1.0, and bounce v2 times, with decay factor of v1
New in version 1.13.
- efl.elementary.ELM_TRANSIT_TWEEN_MODE_SPRING¶
Start at 0.0 then “wobble” like a spring rest position 1.0, and wobble v2 times, with decay factor of v1
New in version 1.13.
- efl.elementary.ELM_TRANSIT_TWEEN_MODE_BEZIER_CURVE¶
Follow the cubic-bezier curve calculated with the control points (x1, y1), (x2, y2)
New in version 1.13.
Inheritance diagram¶
- class efl.elementary.Transit(*args, **kwargs)¶
Bases:
object
This is the class that actually implement the widget.
Note
It is not necessary to delete the transit object, it will be deleted at the end of its operation.
Note
The transit will start playing when the program enters the main loop.
- Parameters
**kwargs – All the remaining keyword arguments are interpreted as properties of the instance
- auto_reverse¶
If auto reverse is set, after running the effects with the progress parameter from 0 to 1, it will call the effects again with the progress from 1 to 0.
The transit will last for a time equal to (2 * duration * repeat), where the duration was set with the function elm_transit_add and the repeat with the function
repeat_times
.- Type
bool
- chain_transit_add(chain_transit)¶
Makes the chain relationship between two transits.
This function adds
chain_transit
transition to a chain after thetransit
, and will be started as soon astransit
ends.Note
chain_transit
can not be None. Chain transits could be chained to the only one transit.- Parameters
chain_transit – The chain transit object. This transit will be operated after transit is done.
- chain_transit_del(chain_transit)¶
Cut off the chain relationship between two transits.
This function removes the
chain_transit
transition from thetransit
.Note
chain_transit
can not be None. Chain transits should be chained to thetransit
.- Parameters
chain_transit – The chain transit object.
- chain_transits¶
Get the current chain transit list.
- Type
list
- del_cb_set(func, *args, **kwargs)¶
Set the user-callback function when the transit is deleted.
Note
Using this function twice will overwrite the first function set.
Note
the
transit
object will be deleted after callfunc
function.- Parameters
func – Callback function. This function will be called before the deletion of the transit.
data – Callback function user data. It is the
op
parameter.
- delete()¶
Stops the animation and delete the
transit
object.Call this function if you want to stop the animation before the transit time. Make sure the
transit
object is still alive withdel_cb_set()
function. All added effects will be deleted, calling its respective data_free_cb functions. The function set bydel_cb_set()
will be called.
- duration¶
Set the transit animation time
- Type
float
- effect_add(effect)¶
Add a new effect to the transit.
Example:
class MyEffect(TransitCustomEffect): # define your methods... t = Transit() e = MyEffect() t.effect_add(e)
Warning
The transit will free the context data at the and of the transition with the data_free_cb function. Do not share the context data in between different transit objects.
Note
The cb function and the data are the key to the effect. If you try to add an existing effect, nothing is done.
Note
After the first addition of an effect to
transit
, if its effect list become empty again, thetransit
will be killed bydelete()
function.- Parameters
effect – The context data of the effect.
- effect_blend_add()¶
Add the Blend Effect to Elm_Transit.
Note
This API is one of the facades. It creates blend effect context and add it’s required APIs to elm_transit_effect_add.
Note
This effect is applied to each pair of objects in the order they are listed in the transit list of objects. The first object in the pair will be the “before” object and the second will be the “after” object.
See also
- Returns
Blend effect context data.
- Return type
Elm_Transit_Effect
Warning
It is highly recommended just create a transit with this effect when the window that the objects of the transit belongs has already been created. This is because this effect needs the color information about the objects, and if the window was not created yet, it can get a wrong information.
- effect_color_add(from_r, from_g, from_b, from_a, to_r, to_g, to_b, to_a)¶
Add the Color Effect to Elm_Transit.
Note
This API is one of the facades. It creates color effect context and add it’s required APIs to elm_transit_effect_add.
See also
- Parameters
from_r – RGB R when effect begins.
from_g – RGB G when effect begins.
from_b – RGB B when effect begins.
from_a – RGB A when effect begins.
to_r – RGB R when effect ends.
to_g – RGB G when effect ends.
to_b – RGB B when effect ends.
to_a – RGB A when effect ends.
- Returns
Color effect context data.
- Return type
Elm_Transit_Effect
- effect_del(effect)¶
Delete an added effect.
This function will remove the effect from the
transit
, calling the data_free_cb to free thedata
.See also
Note
If the effect is not found, nothing is done.
Note
If the effect list become empty, this function will call elm_transit_del(transit), i.e., it will kill the
transit
.- Parameters
effect – The context data of the effect.
- effect_fade_add()¶
Add the Fade Effect to Elm_Transit.
Note
This API is one of the facades. It creates fade effect context and add it’s required APIs to elm_transit_effect_add.
Note
This effect is applied to each pair of objects in the order they are listed in the transit list of objects. The first object in the pair will be the “before” object and the second will be the “after” object.
See also
- Returns
Fade effect context data.
- Return type
Elm_Transit_Effect
Warning
It is highly recommended just create a transit with this effect when the window that the objects of the transit belongs has already been created. This is because this effect needs the color information about the objects, and if the window was not created yet, it can get a wrong information.
- effect_flip_add(axis, cw)¶
Add the Flip Effect to Elm_Transit.
Note
This API is one of the facades. It creates flip effect context and add it’s required APIs to elm_transit_effect_add.
Note
This effect is applied to each pair of objects in the order they are listed in the transit list of objects. The first object in the pair will be the “front” object and the second will be the “back” object.
See also
- Parameters
axis (Flip axis) – Flipping Axis(X or Y).
cw (bool) – Flipping Direction. True is clock-wise.
- Returns
Flip effect context data.
- Return type
Elm_Transit_Effect
Warning
It is highly recommended just create a transit with this effect when the window that the objects of the transit belongs has already been created. This is because this effect needs the geometry information about the objects, and if the window was not created yet, it can get a wrong information.
- effect_image_animation_add(images)¶
Add the ImageAnimation Effect to Elm_Transit.
Example:
t = Transit() images = [] images.append("%s/images/icon_11.png" % PACKAGE_DATA_DIR) images.append("%s/images/logo_small.png" % PACKAGE_DATA_DIR) t.effect_image_animation_add(images)
Note
This API is one of the facades. It creates image animation effect context and add it’s required APIs to elm_transit_effect_add. The
images
parameter is a list images paths. This list and its contents will be deleted at the end of the effect by elm_transit_effect_image_animation_context_free() function.See also
- Parameters
images (list) – A list of images file paths. This list and its contents will be deleted at the end of the effect by elm_transit_effect_image_animation_context_free() function.
- Returns
Image Animation effect context data.
- Return type
Elm_Transit_Effect
- effect_resizable_flip_add(axis, cw)¶
Add the Resizeable Flip Effect to Elm_Transit.
Note
This API is one of the facades. It creates resizable flip effect context and add it’s required APIs to elm_transit_effect_add.
Note
This effect is applied to each pair of objects in the order they are listed in the transit list of objects. The first object in the pair will be the “front” object and the second will be the “back” object.
See also
- Parameters
axis (Flip axis) – Flipping Axis(X or Y).
cw (bool) – Flipping Direction. True is clock-wise.
- Returns
Resizeable flip effect context data.
- Return type
Elm_Transit_Effect
Warning
It is highly recommended just create a transit with this effect when the window that the objects of the transit belongs has already been created. This is because this effect needs the geometry information about the objects, and if the window was not created yet, it can get a wrong information.
- effect_resizing_add(from_w, from_h, to_w, to_h)¶
Add the Resizing Effect to Elm_Transit.
Note
This API is one of the facades. It creates resizing effect context and adds its required APIs to elm_transit_effect_add.
See also
- Parameters
from_w (Evas_Coord (int)) – Object width size when effect begins.
from_h (Evas_Coord (int)) – Object height size when effect begins.
to_w (Evas_Coord (int)) – Object width size when effect ends.
to_h (Evas_Coord (int)) – Object height size when effect ends.
- Returns
Resizing effect context data.
- Return type
Elm_Transit_Effect
- effect_rotation_add(from_degree, to_degree)¶
Add the Rotation Effect to Elm_Transit.
Note
This API is one of the facades. It creates rotation effect context and add it’s required APIs to elm_transit_effect_add.
See also
- Parameters
from_degree (float) – Degree when effect begins.
to_degree (float) – Degree when effect is ends.
- Returns
Rotation effect context data.
- Return type
Elm_Transit_Effect
Warning
It is highly recommended just create a transit with this effect when the window that the objects of the transit belongs has already been created. This is because this effect needs the geometry information about the objects, and if the window was not created yet, it can get a wrong information.
- effect_translation_add(from_dx, from_dy, to_dx, to_dy)¶
Add the Translation Effect to Elm_Transit.
Note
This API is one of the facades. It creates translation effect context and adds its required APIs to elm_transit_effect_add.
See also
- Parameters
from_dx – X Position variation when effect begins.
from_dy – Y Position variation when effect begins.
to_dx – X Position variation when effect ends.
to_dy – Y Position variation when effect ends.
- Returns
Translation effect context data.
- Return type
Elm_Transit_Effect
Warning
It is highly recommended just create a transit with this effect when the window that the objects of the transit belongs has already been created. This is because this effect needs the geometry information about the objects, and if the window was not created yet, it can get a wrong information.
- effect_wipe_add(wipe_type, wipe_dir)¶
Add the Wipe Effect to Elm_Transit.
Note
This API is one of the facades. It creates wipe effect context and add it’s required APIs to elm_transit_effect_add.
See also
- Parameters
wipe_type (Wipe type) – Wipe type. Hide or show.
wipe_dir (Wipe direction) – Wipe Direction.
- Returns
Wipe effect context data.
- Return type
Elm_Transit_Effect
Warning
It is highly recommended just create a transit with this effect when the window that the objects of the transit belongs has already been created. This is because this effect needs the geometry information about the objects, and if the window was not created yet, it can get a wrong information.
- effect_zoom_add(from_rate, to_rate)¶
Add the Zoom Effect to Elm_Transit.
Note
This API is one of the facades. It creates zoom effect context and adds its required APIs to elm_transit_effect_add.
See also
- Parameters
from_rate – Scale rate when effect begins (1 is current rate).
to_rate – Scale rate when effect ends.
- Returns
Zoom effect context data.
- Return type
Elm_Transit_Effect
Warning
It is highly recommended just create a transit with this effect when the window that the objects of the transit belongs has already been created. This is because this effect needs the geometry information about the objects, and if the window was not created yet, it can get a wrong information.
- event_enabled¶
Set the event enabled when transit is operating.
If
enabled
is True, the objects of the transit will receive events from mouse and keyboard during the animation.Note
When you add an object with
object_add()
, its state from evas_object_freeze_events_get(obj) is saved, and it is applied when the transit ends. If you change this state with evas_object_freeze_events_set() after adding the object, this state will change again whentransit
stops to run.- Type
bool
- go()¶
Starts the transition. Once this API is called, the transit begins to measure the time.
- go_in(seconds)¶
Starts the transition in given seconds.
- Parameters
seconds (float) – The interval value in seconds
New in version 1.14.
- object_add(obj)¶
Add new object to apply the effects.
Note
After the first addition of an object to
transit
, if its object list become empty again, thetransit
will be killed by elm_transit_del(transit) function.Note
If the
obj
belongs to another transit, theobj
will be removed from it and it will only belong to the othertransit
. If the old transit stays without objects, it will die.Note
When you add an object into the
transit
, its state from evas_object_pass_events_get(obj) is saved, and it is applied when the transit ends, if you change this state with evas_object_pass_events_set() after add the object, this state will change again whentransit
stops.- Parameters
obj – Object to be animated.
Warning
It is not allowed to add a new object after transit begins.
- object_remove(obj)¶
Removes an added object from the transit.
Note
If the
obj
is not in thetransit
, nothing is done.Note
If the list become empty, this function will call transit.delete(), i.e., it will kill the
transit
.- Parameters
obj – Object to be removed from
transit
.
Warning
It is not allowed to remove objects after transit begins.
- objects¶
The objects of the transit.
type: list
- objects_final_state_keep¶
Enable/disable keeping up the objects states.
If it is not kept, the objects states will be reset when transition ends.
Note
One state includes geometry, color, map data.
- Type
bool
- paused¶
Pause/Resume the transition.
If you call elm_transit_go again, the transit will be started from the beginning, and will be played.
- Type
bool
- progress_value¶
Get the time progression of the animation (a double value between 0.0 and 1.0).
The value returned is a fraction (current time / total time). It represents the progression position relative to the total.
- Type
float
- repeat_times¶
The transit repeat count. Effect will be repeated by repeat count.
This property reflects the number of repetition the transit will run after the first one, i.e., if
repeat
is 1, the transit will run 2 times. If therepeat
is a negative number, it will repeat infinite times.Note
If this function is called during the transit execution, the transit will run
repeat
times, ignoring the times it already performed.- Type
int
- revert()¶
This can be used to reverse play an ongoing transition.
It shows effect only when an animation is going on. If this function is called twice transition will go in forward direction as normal one. If a repeat count is set, this function call will revert just the ongoing cycle and once it is reverted back completely, the transition will go in forward direction. If an autoreverse is set for the transition and this function is called in the midst of the transition the ongoing transition will be reverted and once it is done, the transition will begin again and complete a full auto reverse cycle.
- Returns
True
if the transition is reverted,False
otherwise.- Return type
bool
New in version 1.18.
- smooth¶
Smooth effect for a transit.
This sets smoothing for transit map rendering. If the object added in a transit is a type that has its own smoothing settings, then both the smooth settings for this object and the map must be turned off. By default smooth maps are enabled.
- Type
bool
- See
New in version 1.8.
- smooth_get()¶
- smooth_set(smooth)¶
- tween_mode¶
The transit animation acceleration type.
- Type
- tween_mode_factor¶
Transit animation acceleration factor.
If you use the below tween modes, you have to set the factor using this API.
- ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL
Start slow, speed up then slow down at end, v1 being a power factor, 0.0 being linear, 1.0 being default, 2.0 being much more pronounced sinusoidal(squared), 3.0 being cubed, etc.
- ELM_TRANSIT_TWEEN_MODE_DECELERATE
Start fast then slow down, v1 being a power factor, 0.0 being linear, 1.0 being ELM_TRANSIT_TWEEN_MODE_DECELERATE default, 2.0 being much more pronounced decelerate (squared), 3.0 being cubed, etc.
- ELM_TRANSIT_TWEEN_MODE_ACCELERATE
Start slow then speed up, v1 being a power factor, 0.0 being linear, 1.0 being ELM_TRANSIT_TWEEN_MODE_ACCELERATE default, 2.0 being much more pronounced accelerate (squared), 3.0 being cubed, etc.
- ELM_TRANSIT_TWEEN_MODE_DIVISOR_INTERP
Start at gradient * v1, interpolated via power of v2 curve
- ELM_TRANSIT_TWEEN_MODE_BOUNCE
Start at 0.0 then “drop” like a ball bouncing to the ground at 1.0, and bounce v2 times, with decay factor of v1
- ELM_TRANSIT_TWEEN_MODE_SPRING
Start at 0.0 then “wobble” like a spring rest position 1.0, and wobble v2 times, with decay factor of v1
- Type
(float v1, float v2) (defaults are 1.0, 0.0)
See also
New in version 1.8.
- tween_mode_factor_get()¶
- tween_mode_factor_n¶
Set the transit animation acceleration factors.
This is the same as
tween_mode_factor
, but lets you specify more than 2 values. Actually only need for the ELM_TRANSIT_TWEEN_MODE_BEZIER_CURVE mode.- ELM_TRANSIT_TWEEN_MODE_BEZIER_CURVE
Use an interpolated cubic-bezier curve ajusted with 4 parameters: (x1, y1, x2, y2)
- Type
list of doubles
See also
New in version 1.13.
- tween_mode_factor_n_set(values)¶
- tween_mode_factor_set(v1, v2)¶