elm_bg - Plain color background.

The full code for this example can be found at bg_example_01.c, in the function test_bg_plain. It's part of the elementary_test suite, and thus has the code for the three examples referenced by this documentation.

This first example just sets a default background with a plain color. The first part consists of creating an Elementary window. It's the common piece of code that you'll see everywhere in Elementary:

elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
win = elm_win_util_standard_add("bg-plain", "Bg Plain");
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition: eina_types.h:539
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339
Eina_Bool elm_policy_set(unsigned int policy, int value)
Set a new policy's value (for a given policy group/identifier).
Definition: elm_main.c:1380
@ ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
quit when the application's last window is closed
Definition: elm_general.h:248
@ ELM_POLICY_QUIT
under which circumstances the application should quit automatically.
Definition: elm_general.h:227
Evas_Object * elm_win_util_standard_add(const char *name, const char *title)
Adds a window object with standard setup.
Definition: efl_ui_win.c:9582
void elm_win_autodel_set(Eo *obj, Eina_Bool autodel)
Set the window's autodel state.
Definition: efl_ui_win.c:6194
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition: Evas_Common.h:185

Now we really create our background object, using the window object as its parent:

Then we set the size hints of the background object so that it will use all space available for it, and then add it as a resize object to the window, making it visible in the end:

See evas_object_size_hint_weight_set() and elm_win_resize_object_add() for more detailed info about these functions.

The end of the example is quite simple, just setting the minimum and maximum size of the background, so the Elementary window knows that it has to have at least the minimum size. The background also won't scale to a size above its maximum. Then we resize the window and show it in the end:

And here we finish our very simple background object usage example.