Table of Contents

Scalability Menu


Scalability Using Edje

Edje provides an abstraction layer between the application code and the interface. You can use Edje in your EFL applications to create visual elements and control the layout, look, and feel.

Internally, Edje holds a geometry state machine and a state graph that defines, for example, what is visible, where, at what size, and with what colors. These details are described to Edje using an Edje .edj file. The file can be produced by using Edje_cc to take a text file (a .edc file) and “compile” an output .edj file that contains the state graph information, images, and any other needed data.

While creating Edje, you set specific element properties to control the scalable behavior of the UI. Before creating a scalable UI using Edje, you must be familiar with the following scalability properties and part types.

Table of Contents

Part

Parts are used to represent the most basic layout elements, such as a line in a border or a text on an image.

The parts can have the following property:

Description

Every part can have one or more description blocks to define the layout properties of the part.

The descriptions can have the following properties:

Edje part property example
collections
{
   group
   {
      name: "property_test";
 
      images
      {
         image: "panorama.png" COMP;
      }
 
      parts
      {
         part
         {
            name: "rect1";
            type: RECT;
            description
            {
               state: "default" 0.0;
               rel1 {relative: 0.3 0.4;}
               rel2 {relative: 0.7 0.6;}
               color: 0 127 255 255;
            }
         }
         part
         {
            name: "rect2";
            type: RECT;
            // Affected by scaling factor
            scale: 1;
            description
            {
               state: "default" 0.0;
               fixed: 0 1;
               // Height: 100 pixels (when the scaling factor is 1.0)
               min: 0 100;
               rel1 {relative: 0.0 1.0;}
               rel2 {relative: 1.0 1.0;}
               // Bottom-aligned
               align: 0.5 1.0;
               color: 255 127 0 255;
            }
         }
         part
         {
            name: "image";
            // Affected by scaling factor
            scale: 1;
            description
            {
               state: "default" 0.0;
               fixed: 1 1;
               // Image size: 720 x 180 pixels (when the scaling factor is 1.0)
               min: 720 180;
               // Y-axis is positioned relative to "rect2" part
               rel1 {relative: 0.5 0.0; to_y: "rect2";}
               rel2 {relative: 0.5 0.0; to_y: "rect2";}
               // Bottom-aligned
               align: 0.5 1.0;
               image.normal: "panorama.png";
            }
         }
      }
   }
}
Edje part property aspect example
collections
{
   group
   {
      name: "property_test";
 
      images
      {
         image: "island.png" COMP;
      }
 
      parts
      {
         part
         {
            name: "image";
            description
            {
               state: "default" 0.0;
               rel1 {relative: 0.0 0.0;}
               rel2 {relative: 1.0 1.0;}
               image.normal: "island.png";
               aspect: 8/5 8/5;
               // Keep the aspect ratio based on the part width
               aspect_preference: HORIZONTAL;
            }
         }
      }
   }
}

Text

The text elements are used to display text on the screen.

The texts can have the following properties:

Edje text property example
collections
{
   group
   {
      name: "property_test";
 
      parts
      {
         part
         {
            name: "text";
            type: TEXT;
            scale: 1;
            description
            {
               state: "default" 0.0;
               rel1 {relative: 0.0 0.0;}
               rel2 {relative: 1.0 0.0;}
               align: 0.5 0.0;
               color: 108 108 108 255;
               text
               {
                  font: "Sans";
                  // Affected by scaling factor
                  size: 80;
                  // Minimum height of the part container is decided by the
text size
                  min: 0 1;
                  text: "Test properties!!";
               }
            }
         }
      }
   }
}
Edje text property fit example
collections
{
   group
   {
      name: "property_test";
 
      parts
      {
         part
         {
            name: "text";
            type: TEXT;
            description
            {
               state: "default" 0.0;
               rel1 {relative: 0.0 0.0;}
               rel2 {relative: 1.0 0.1;}
               color: 108 108 108 255;
               text
               {
                  font: "Sans";
                  // Resize text to fill the container height
                  fit: 0 1;
                  text: "Test properties!!";
               }
            }
         }
      }
   }
}

Image

The image elements are used to display images on the screen.

The images can have the following properties:

Edje image property example
collections
{
   group
   {
      name: "property_test";
 
      images
      {
         image: "00_button_01_normal.png" COMP;
      }
 
      parts
      {
         part
         {
            name: "image";
            description
            {
               state: "default" 0.0;
               rel1 {relative: 0.0 0.6;}
               rel2 {relative: 1.0 0.7;}
               image.normal: "00_button_01_normal.png";
            }
         }
         part
         {
            name: "ninepatch_image";
            description
            {
               state: "default" 0.0;
               rel1 {relative: 0.0 0.8;}
               rel2 {relative: 1.0 0.9;}
               image
               {
                  normal: "00_button_01_normal.png";
                  border: 4 4 0 0;
                  // Affected by scaling factor
                  border_scale: 1;
               }
            }
         }
      }
   }
}

Image Set

The image set elements are used to display a specific image on the screen based on the container size.

The image sets can have the following properties:

selected and shown.
The image set is used to control resource quality when the image part is scaled to multiple devices. According to the size of the part's container, an appropriate image is loaded.

Edje image set property example
collections
{
   group
   {
      name: "property_test";
 
      images
      {
         set
         {
            name: "alternative_animal";
            image
            {
               image: "pig.png" COMP;
               size: 640 800 1200 1500;
            }
            image
            {
               image: "monkey.png" COMP;
               size: 400 500 639 799;
            }
            image
            {
               image: "cat.png" COMP;
               size: 240 300 399 499;
            }
            image
            {
               image: "mouse.png" COMP;
               size: 80 100 239 299;
            }
            image
            {
               image: "snail.png" COMP;
               size: 0 0 79 99;
            }
         }
      }
 
      parts
      {
         part
         {
            name: "image1";
            description
            {
               state: "default" 0.0;
               rel1 {relative: 0.0 0.0;}
               rel2 {relative: 1.0 0.45;}
               image.normal: "alternative_animal";
               aspect: 4/5 4/5;
               aspect_preference: BOTH;
            }
         }
         part
         {
            name: "image2";
            description
            {
               state: "default" 0.0;
               rel1 {relative: 0.0 0.5;}
               rel2 {relative: 1.0 0.75;}
               image.normal: "alternative_animal";
               aspect: 4/5 4/5;
               aspect_preference: BOTH;
            }
         }
         part
         {
            name: "image3";
            description
            {
               state: "default" 0.0;
               rel1 {relative: 0.0 0.8;}
               rel2 {relative: 1.0 1.0;}
               image.normal: "alternative_animal";
               aspect: 4/5 4/5;
               aspect_preference: BOTH;
            }
         }
      }
   }
}

Part Types

You can use fixed and flexible parts:

Fixed and flexible parts__: ———