Tizen Native API
5.0
|
This code places an Elementary toolbar widget on a window, to exemplify part of the widget's API.
Toolbar widgets has support to items with states. Each state can have it's own label, icon, and callback function.
Let's start populating a toolbar with some regular items. If you don't know how to do that, see Toolbar Example 1.
tb = elm_toolbar_add(win); elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_HIDE); evas_object_size_hint_weight_set(tb, 0.0, 0.0); evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, 0.0); evas_object_show(tb); elm_toolbar_item_append(tb, "document-print", "Print", NULL, NULL); elm_toolbar_item_append(tb, "folder-new", "Folder", NULL, NULL); elm_toolbar_item_append(tb, "clock", "Clock", NULL, NULL); elm_toolbar_item_append(tb, "refresh", "Update", NULL, NULL);
The only difference here is that we set shrink mode to #ELM_TOOLBAR_SHRINK_HIDE, that won't display items that doesn't fit to the window.
Now, let's add an item with states. First, add the item just as any other.
tb_it = elm_toolbar_item_append(tb, "mail-send", "Send Mail", _item_pressed, NULL);
After that states can be added to this item:
elm_toolbar_item_state_add(tb_it, "emptytrash", "Empty Trash", _item_pressed, NULL); elm_toolbar_item_state_add(tb_it, "trashcan_full", "Full Trash", _item_pressed, NULL);
The both states and the item are using the same callback function, that will cycle between states and unselect the item. Unseleting is required because it won't call the callback if an user clicks over an item already selected:
On our example, some items are hidden because we set the window to be small. But if an item should be displayed anyway, is needed to set its priority to be higher than others. Any positive value will be enough in our case. Let's force the item with multiple states to be displayed.
See the full source code for this example.