EFL and Elementary allow you to manage different kinds of events and create various types of effects and animations in your application.
EFL relies on events and callbacks. In the case of an event such as a key press, mouse click or a battery running low, the mainloop invokes the callback functions associated with those specific events. After the callbacks have completed, the mainloop takes over and waits for new events, which will trigger new callbacks in turn.
Callbacks should be resource light in order to return to the mainloop as quickly as possible. Failure to return quickly to the mainloop blocks the application's UI making it appear to be frozen. Use an asynchronous mechanism such as ecore_con for network I/O or threads for CPU-intensive tasks to prevent this.
There are several EFL event types. Their use depends on the level of each event. From lower to higher level these are:
Event types in EFL include:
There are also Edje signals, which come from the program sections in themes. These can be used with high-level Elementary APIs or low-level Edje APIs.
Imagine an application which displays a button. When clicked, the button triggers a file download which will be processed. The application also has progress bars to show the status of these operations.
Create the window, then a box set to vertical. 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 invoked. 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. This is contained in ''ecore_main_loop_thread_safe_call_async()'' as GUI operations are not thread-safe.
Events enable operations taking more than a few milliseconds to be executed outside of the mainloop, so UI redraws aren't blocked.
See below the event flow following an onscren click:
This programming guide introduces the animation functions provided by 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, then define a callback function that performs the animation for that period of time.
You can also create animations using Elementary transitions. This allows you to apply various transition effects, such as transformation and rotation to Evas objects. Elementary transitions are mostly based on Ecore animators but provide some transition methods at a higher level too. 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 the principle of transitioning from one state to another. To animate an object with Edje, first define the start and end states of the animation then transition the object accordingly.
Finally, Evas Map animations allow you to apply transformations to all types of objects by way of UV mapping. This involves mapping points in the source object to positions in 3D space within the target object. This allows for rotation, perspective, scale and other transformation effects depending on the map. Each map point can carry a multiplier color which, if properly calculated, can be used to apply 3D shading effects on the target object.