Background Widgets

The background widget can be used to set a solid background decoration to a window or to a container object. It works like an image, but has some background specific properties, for example it can be set to tiled, centered, scaled or stretched mode. There are no specific signals relative to background object

Table of Contents

Adding a Background

A background is created with the elm_bg_add().

Evas_Object *bg;
 
// Creating a background
bg = elm_bg_add(parent);

Change Color of the Background

You can set the color of the bg with elm_bg_color_set(). Here we set the background color to red.

Evas_Object *bg;
 
// Use red color for background
elm_bg_color_set(bg, 0xFF, 0x00, 0x00);

Change Image of the Background

It is also possible to set an image or an Edje group with elm_bg_file_set(). The display mode of the image in the background can be chosen with elm_bg_option_set(), where the following modes are available:

  • ELM_BG_OPTION_CENTER: center the background image
  • ELM_BG_OPTION_SCALE: scale the background image, retaining aspect ratio
  • ELM_BG_OPTION_STRETCH: stretch the background image to fill the widget's area
  • ELM_BG_OPTION_TILE: tile background image at its original size
Evas_Object *bg;
 
// Set a file on the disk as background image
elm_bg_file_set(bg, "/path/to/the/image", NULL);
// Set an edje group as background image
elm_bg_file_set(bg, "/path/to/the/edje", "edje_group");
elm_bg_option_set(bg, ELM_BG_OPTION_STRETCH)

Using Overlay

An overlay can be set using the “overlay” part name.

elm_object_part_content_set(bg, "overlay", over);

Here, over is an Edje object that will be displayed on top of the current bg object.