Support
Contribute
Contact
Tracker
Navigation
Personal tools
 

Soc2008/Edje layout library


Setup the foundations necessary for creating complex GUIs with Edje. By turning Edje into a complete layout engine by the introduction of new part types representing layout structures like vbox, hbox or table. Besides layout it is necessary to include the basics for custom widget creation, particularly list based widgets. Such endeavor would require certain fundamental changes in Evas, most of which are currently being considered, and to complete or update previous work in "esmart_container" and "edje_container".

Current solutions to these problems are provided by two widget libraries, EWL and ETK, which use Edje for their themes. But this approach introduces new problems and limitations that some types of plain Edje applications shouldn't require.

The original submission, goals and road map can be found in my user page, this article will be updated as the project advances. By the end of the project this page will look like a small manual for developers wanting to extend or create new Evas/Edje layout objects.

Contents

Notes

These are the things that I learned about plain C object oriented programming in general and applied to this particular project.

The object model

Layout objects are simply a kind of Evas smart object that inherit from two "parent" smart objects. The most elemental is evas_object_smart_clipped used to manage a group of Evas objects independently of the relationship among them pretty much like a "layer" seen in programs like The Gimp or Photoshop.

The least elemental is evas_object_layout and it is used to manage a group of objects that are positioned relatively to the others, all the functionality common among different kinds of layouts is implemented in this Object. All in all, the inheritance graph looks so simple I almost didn't include it:

    evas_object_smart_clipped
     |
     + evas_object_layout 
      |
      + evas_object_box
      | | 
      | + evas_object_layout_vbox
      | + evas_object_layout_hbox
      |
      + evas_object_layout_grid
      + evas_object_layout_flow
      + ...

Inheritance

Pretty much unlike what the previous graph would lead us to believe. It's not the evas_object_smart_clipped whom defines the smart class on which the other objects are built.

The smart class is defined in the constructor functions for the child objects.Then is passed to each constructor function (upwards in the tree). After calling it's parent constructor, each instance replace some of the properties set by the lower levels with its own. The class creation finalizes at the constructor function of the child object (vbox, hbox, etc.) then it is used to create a new object.

To define a new type of layout object, like a vbox, the constructor function has to create a new Layout Api which is a C struct containing a pointer to a Smart Class in the first place and to a bunch of functions common among every Evas Layout Object based layout object =). More complex layout objects might define their own Api struct with additional functions but always maintaining the Layout Api struct (and thus the Smart Class) at the beginning of the structure.

Accessing Smart Data

Each level that composes a complete layout object requires some information about itself to be stored inside the final Evas Object. This information is stored and retrieved with evas_object_smart_data_set and evas_object_smart_data_get respectively. These functions are used to maintain a pointer to arbitrary data inside a given Evas Object.

Since Evas objects cannot contain more than one (fast) pointer to arbitrary data the structs for either Api or Data of each child must account for the size of the Api or Data belonging to its parent. In practice it looks similarly to this:

struct Evas_Object_Smart_Clipped_Data
{
   ...
}

struct Evas_Object_Layout_Data
{
    Evas_Object_Smart_Clipped_Data cso;
    ...
}

struct Evas_Object_Box_Data
{
    Evas_Object_Layout_Data ld;
    ...
}

This "nesting" of structures allows functions belonging to the Clipper, the Layout and the Box to extract information from the same pointer. How? by calling evas_object_smart_data_get and assigning the returned pointer to a variable of either type.

Implementation Details

The Box

The most simple layout object. Objects included in a box are "wrapped" in a structure known as item, the objects themselves are placed at the end of each other. Can be oriented horizontally or vertically.

(box) Items

Objects are included unmodified to the box. Items contain a pointer to said objects.

(box) Alignment

The property "balance" will be used to move the group of items along the box's orientation (parallel alignment). The property "align" will be used to move each item perpendicularly to the box's orientation.

(box) Filling

The box or box's items do not contain any special property that alters the way the items fill the box.