EFL and Elementary allow you to manage different kinds of events and create various types of effects and animations in your application.
The EFLs rely on events and callbacks. In case of an event, (for example, a key press, mouse click or a battery running low), the mainloop calls the callback functions that are associated to that specific event. After the callbacks have finished, the mainloop takes over and waits for new events, upon which to trigger new callbacks.
It is important to do light work in the callbacks and to return to the mainloop relatively quickly. If there is heavy work to do, it is best to use an asynchronous mechanism like Ecore_con for network I/O or threads for CPU-intensive tasks. Failure to return quickly to the mainloop blocks the application's UI and it appears frozen.
There are several event types in the EFLs, and their use depends on the level of the event. The event types from lower- to higher-level are:
Event types in the EFLs: Inner boxes are more specific than outer ones
A realistic scenario involving various types of events is an application showing a button, which triggers the download of a file to be processed. There are progress bars for the operations.
Create the window, create a box, set it vertical and add a button and two progress bars. At first, only the button is fully visible.
When the user clicks on the button, an evas smart object event named “clicked” is emitted. The callback then starts the download in Ecore_con, displays the first progress bar and adds a callback to monitor the download progress. When the download progress changes, the callback updates the progress bar.
After the download is finished, the second progress bar is displayed and the
file processing is offloaded to another thread through Ecore_thread. The
processing function regularly updates the progress bar (wrapped in
ecore_main_loop_thread_safe_call_async() because GUI operations are not
Events enable operations taking more than a few milliseconds' time to be executed outside of the mainloop, therefore not blocking UI redraws.
Below is an illustration for the event flow that follows a click on the screen.
This programming guide introduces the animation functionalities provided by the EFL: Ecore animators, Elementary transitions, Edje animations, and Evas Map animations.
The first option for creating animations with EFL is to use Ecore animators. To create an Ecore animation, you must first determine the duration of the animation, and then define a callback function that performs the animation with that duration.
You can also create animations using Elementary transitions. Elementary transitions allow you to apply various transition effects, such as translation and rotation, to Evas objects. Elementary transitions are mostly based on Ecore animators, but provide some transition methods at a higher level of abstraction. Elementary transitions provide a simpler way of animating objects than Ecore animators or Edje animations.
A third option for animating objects is to use Edje animations, which are based on a simple principle: transitioning from one state to another. To animate an object with Edje, you have to first define the start and end states of the animation, and then transition the object from the start state to the end state.
Finally, Evas Map animations allow you to apply transformations to all types of objects by way of UV mapping. In UV mapping, you map points in the source object to 3D space positions in the target object. This allows for rotation, perspective, scale, and other transformation effects, depending on the map. In addition, each map point can carry a multiplier color, which, if properly calculated, can be used to apply 3D shading effects on the target object.