Table of Contents

Widgets Menu


Toolbar Widgets

This widget is a scrollable list of items and shows a menu when an item is selected. Only one item can be selected at a time.

Table of Contents

Adding a Toolbar

Use the following function to create a toolbar.

Evas_Object *toolbar;
toolbar = elm_toolbar_add(parent);

Using Toolbar Styles

The toolbar has the following styles:

Here, we set the style to “transparent”.

elm_object_style_set(toolbar, "transparent");

Configuring the Toolbar

The toolbar displays its items in one of the following options.

Here we set the Toolbar to ELM_TOOLBAR_SHRINK_NONE.

elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_NONE);

By default, the toolbar displays items homogeneously. Items with long labels occupy a lot of space. To avoid that, we can disable the homogeneous mode.

elm_toolbar_homogeneous_set(toolbar, EINA_FALSE);

Adding Items to the Toolbar

In the following code, we add two items and choose the associated icon, label, and function to call when the item is clicked.

Elm_Object_Item *home_it, *help_it;
home_it = elm_toolbar_item_append(toolbar, "home", "Home", _home_item_pressed_cb, NULL);
help_it = elm_toolbar_item_append(toolbar, "help", "Help", _help_item_pressed_cb, NULL);
static void
_home_item_pressed_cb(void *data, Evas_Object *obj, void *event_info)
{
   printf("Home item clicked\n");
}
static void
_help_item_pressed_cb(void *data, Evas_Object *obj, void *event_info)
{
   printf("Help item clicked \n");
}

An item may be disabled. This is how to disable the help item. The disabled item does not receive input and, if the theme supports it, is themed differently (usually greyed out) from its normal state.

elm_object_item_disabled_set(help_it, EINA_TRUE);

Adding Items with States

Items have two or more states. Each state has its own icon, label, and function to call when an item is clicked. As an example, we create two states to the help item with the same icon but two different labels.

elm_toolbar_item_state_add(help_it, "help", "Help state 1", _help_item_pressed_cb, NULL);
elm_toolbar_item_state_add(help_it, "help", "Help state 2", _help_item_pressed_cb, NULL);

We can cycle through the states of the help item by using the following code.

elm_toolbar_item_state_set(help_it, elm_toolbar_item_state_next(help_it));

Using Toolbar Callbacks

Smart callbacks one can listen to:

This is how to register a callback on the “clicked” signal.

evas_object_smart_callback_add(toolbar, "clicked", _clicked_cb, data);
// Callback function for the "clicked" signal
// This callback is called when a toolbar item is clicked
static void
_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
   Elm_Toolbar_Item * item = event_info;
   printf("Item clicked\n");
}



Widgets Menu