Tizen Native API
Edje basics example

In this example, we illustrate how to start using the Edje library, with the very basic one needs to instantiate an Edje object.

We place, in the canvas, an Edje object along with a red border image to delimit its geometry. After we instantiate the Edje object, we have to set a file and a group, within that file, to bind to it. For this example, we're using an EDC file which declares two parts (blue and green rectangles) and an item data:

We start by trying to access an unexistant group in the file, so that you can see the usefulness of edje_object_load_error_get() and edje_load_error_str(). Check that the error message will tell you just that -- a group which didn't exist in the file was called for:

Than, we finally bind our Edje object to "example_group", printing a message afterwards:

What follows is a series of Edje API calls which are of general use. The first of them is edje_object_data_get(), which we use to get the value we have put in the "example_data" data field, in our EDC object declaration:

Than, we exemplify edje_object_part_exists():

The next call is to query "part_one"'s geometry, relative to the whole Edje object's area. The part will be situated in the middle of the Edje object's, because it has a restricted forced size (we set its minimum size equal to its maximum, for that) and, by default, parts are aligned to the center of their containers:

We can grab a direct pointer on the rectangle implementing "part_one", by using edje_object_part_object_get(). Since we are not allowed to set properties on it, we just check its color, to assure its really blue, as declared in the EDC:

The "min" and "max" EDC properties can be queried with the following calls:

The next two calls are to make size calculations on our object. Because of the minimum size declared for "part_one" part's default state description, that will be our exact minimum size calculated for the group (remember the "min" declaration at group level is just a hint, not an enforcement). We then exercise the edje_object_size_min_restricted_calc() function, passing a minimum size of 500, in each axis. Since we have no object bigger than that, it will be the minimum size calculated, in the end:

"part_two" part is there with a purpose: since it extrapolates the Edje object's boundaries, the edje_object_parts_extends_calc() function will report origin coordinates for the rectangle grouping both parts with negative values, indicating it extrapolates to the upper left of our group, just as we see it.

To interact with the last features exemplified in the program, there's a command line interface. A help string can be asked for with the 'h' key:

Those commands will change the scaling factors of our Edje objects. The first of them, 's', will change Edje's global scaling factor between 1.0 (no scaling) and 2.0 (double scale). Scaling will be applied to "part_one", only, because that's the part flagged to be scaled at EDC level:

Note, finally, that the 's' command will depend on the 'r' one to have its effects applied. The latter will change "part_one"'s individual scaling factor, which overrides Edje's global scaling factor. Only when the individual one is set to zero, will the global one take effect:

The example's window should look like this picture:

edje-basics-example.png

The full example follows.

To compile use this command:

 * gcc -o edje-basic edje-basic.c -DPACKAGE_BIN_DIR=\"/Where/enlightenment/is/installed/bin\" -DPACKAGE_LIB_DIR=\"/Where/enlightenment/is/installed/lib\"
 * -DPACKAGE_DATA_DIR=\"/Where/enlightenment/is/installed/share\"
 * `pkg-config --cflags --libs evas ecore ecore-evas edje`
 *
 * edje_cc basic.edc
 *