Programming Principles of EFL
This topic explains the programming principles of EFL. Due to its hierarchical structure, EFL has certain characteristics distinguished from other frameworks, to which you need to pay attention while programming.
Object Type
Evas library is in charge of rendering in EFL, and it renders graphics by displaying a unit called an Evas object. It defines the data structure of the object type and provides the Evas_Object
handle. In short, all graphical objects in EFL have the same data type: Evas_Object
.
The following code snippet shows the return type of several EFL APIs:
Evas_Object* win;
Evas_Object* btn;
Evas_Object* rect;
Evas_Object* img;
win = elm_win_util_standard_add("test", "test");
btn = elm_button_add(parent);
rect = evas_object_rectangle_add(evas);
img = evas_object_image_add(evas);
In the above example, the object created by each function has the Evas_Object*
type:
- The objects created by the Elementary APIs are of the
Evas_Object*
type, whether they are a window or a button. Remember that Elementary is a wrapper of EFL, including Evas for user convenience. - The objects created by Evas APIs are of the
Evas_Object*
type, whether they are a rectangle or an image.
Although Evas treats its objects equally, they have types which define their specific behavior and individual API.
Object Visibility
All graphical objects in EFL (which are of the Evas_Object
type) are hidden by default. This avoids unwanted events, such as mouse in, move, and out events due to objects being created underneath the current pointer position. It is more efficient, as you can show the object after you have finished defining its state. To show an object, you need to call the evas_object_show()
function explicitly.
The following code snippet shows the process of displaying an object:
/* Create a checkbox, which is invisible by default */
check = elm_check_add(parent);
/* Define its state */
elm_check_state_set(check, EINA_TRUE);
/* Switch the checkbox into a visible state */
evas_object_show(check);
API Domain
An EFL function has its own range of effects and you can tell the range by its name:
-
Evas treats its objects equally, so it offers a function set that applies to any Evas object, whichever type that may have. These functions manipulate generic Evas objects:
evas_object_show()
evas_object_hide()
evas_object_del()
evas_object_geometry_get()
For more information, see the Generic Object Functions API (in mobile and wearable applications).
-
Some function usage is limited to a certain object type. The following functions can only be used for the objects generated by the
evas_object_image_add()
function:evas_object_image_file_set()
evas_object_image_size_get()
evas_object_image_preload()
For more information, see the Specific Object Functions API (in mobile and wearable applications).
-
When it comes to Elementary, the UI components are built in a hierarchical fashion. The idea is to factorize as much code as possible between UI components that behave in a similar manner to facilitate the creation of new UI components.
The Elementary UI components inherit a lot of their code from the container UI components and the layout component (a container component that takes a standard Edje design file and wraps it very thinly). You can use the container and layout functions on the Elementary UI components, as well as the Elementary object functions, such as:
elm_object_part_content_set()
elm_object_part_content_get()
elm_object_part_content_unset()
For more information, see the General API (in mobile and wearable applications).
-
A single UI component has its individual API as well. The following functions can only be used for the objects generated by
elm_entry_add()
function:elm_entry_file_set()
elm_entry_bounce_set()
elm_entry_utf8_to_markup()
For more information, see the Elementary Widgets API (in mobile and wearable applications).
-
The
elm_scroller
is a UI component and an implementation of a scrollable interface at the same time. The following functions can be used for all UI components which implement a scrollable interface, such aselm_entry
andelm_genlist
:elm_scroller_region_show()
elm_scroller_region_bring_in()
elm_scroller_gravity_set()
For more information, see the Scroller API (in mobile and wearable applications).
Related Information
- Dependencies
- Tizen 2.4 and Higher for Mobile
- Tizen 2.3.1 and Higher for Wearable