evas_object_resize(win, 320, 300);
evas_object_show(win);
}
+
+/* The same test of toolbar, but using hide shrink mode instead of menu */
+void
+test_toolbar4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Evas_Object *win, *bg, *bx, *tb, *ph, *menu;
+ Evas_Object *ph1, *ph2, *ph3, *ph4;
+ Elm_Toolbar_Item *item;
+ Elm_Menu_Item *menu_item;
+ char buf[PATH_MAX];
+
+ win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC);
+ elm_win_title_set(win, "Toolbar 4");
+ elm_win_autodel_set(win, EINA_TRUE);
+
+ bg = elm_bg_add(win);
+ elm_win_resize_object_add(win, bg);
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(bg);
+
+ bx = elm_box_add(win);
+ elm_win_resize_object_add(win, bx);
+ evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(bx);
+
+ tb = elm_toolbar_add(win);
+ elm_toolbar_homogenous_set(tb, 0);
+ elm_toolbar_mode_shrink_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);
+
+ ph1 = elm_photo_add(win);
+ ph2 = elm_photo_add(win);
+ ph3 = elm_photo_add(win);
+ ph4 = elm_photo_add(win);
+
+ item = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1);
+ elm_toolbar_item_disabled_set(item, EINA_TRUE);
+ elm_toolbar_item_priority_set(item, 100);
+
+ item = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1);
+ elm_toolbar_item_priority_set(item, -100);
+
+ item = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4);
+ elm_toolbar_item_priority_set(item, 150);
+
+ item = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4);
+ elm_toolbar_item_priority_set(item, 0);
+
+ item = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4);
+ elm_toolbar_item_priority_set(item, -200);
+
+ item = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL);
+ elm_toolbar_item_menu_set(item, 1);
+ elm_toolbar_item_priority_set(item, -999999);
+ elm_toolbar_menu_parent_set(tb, win);
+ menu = elm_toolbar_item_menu_get(item);
+
+ elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4);
+ menu_item = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4);
+ elm_menu_item_add(menu, menu_item, "edit-paste", "is set to", tb_4, ph4);
+ elm_menu_item_add(menu, NULL, "edit-delete", "Menu", tb_5, ph4);
+
+ elm_box_pack_end(bx, tb);
+ evas_object_show(tb);
+
+ tb = elm_table_add(win);
+ evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
+ evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ ph = ph1;
+ elm_photo_size_set(ph, 40);
+ snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", PACKAGE_DATA_DIR);
+ elm_photo_file_set(ph, buf);
+ evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(ph, 0.5, 0.5);
+ elm_table_pack(tb, ph, 0, 0, 1, 1);
+ evas_object_show(ph);
+
+ ph = ph2;
+ elm_photo_size_set(ph, 80);
+ evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(ph, 0.5, 0.5);
+ elm_table_pack(tb, ph, 1, 0, 1, 1);
+ evas_object_show(ph);
+
+ ph = ph3;
+ elm_photo_size_set(ph, 20);
+ snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", PACKAGE_DATA_DIR);
+ elm_photo_file_set(ph, buf);
+ evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(ph, 0.5, 0.5);
+ elm_table_pack(tb, ph, 0, 1, 1, 1);
+ evas_object_show(ph);
+
+ ph = ph4;
+ elm_photo_size_set(ph, 60);
+ snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", PACKAGE_DATA_DIR);
+ elm_photo_file_set(ph, buf);
+ evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(ph, 0.5, 0.5);
+ elm_table_pack(tb, ph, 1, 1, 1, 1);
+ evas_object_show(ph);
+
+ elm_box_pack_end(bx, tb);
+ evas_object_show(tb);
+
+ evas_object_resize(win, 320, 300);
+ evas_object_show(win);
+}
#endif
switch (wd->shrink_mode)
{
case ELM_TOOLBAR_SHRINK_MENU: /* fallthrough */
+ case ELM_TOOLBAR_SHRINK_HIDE: /* fallthrough */
case ELM_TOOLBAR_SHRINK_SCROLL: minw = w - vw; break;
case ELM_TOOLBAR_SHRINK_NONE: minw = minw + (w - vw); break;
}
return eti2->prio.priority - eti1->prio.priority;
}
+static void
+_fix_items_visibility(Widget_Data *wd, Evas_Coord *iw, Evas_Coord vw)
+{
+ Elm_Toolbar_Item *it;
+ Eina_List *sorted = NULL;
+
+ EINA_INLIST_FOREACH(wd->items, it)
+ {
+ sorted = eina_list_sorted_insert(sorted,
+ _toolbar_item_prio_compare_cb, it);
+ }
+
+ EINA_LIST_FREE(sorted, it)
+ {
+ Evas_Coord ciw;
+
+ evas_object_geometry_get(it->base.view, NULL, NULL, &ciw, NULL);
+ *iw += ciw;
+ it->prio.visible = (*iw <= vw);
+ }
+}
+
static void
_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
{
Evas_Coord iw = 0;
- Eina_List *sorted = NULL;
-
- EINA_INLIST_FOREACH(wd->items, it)
- {
- sorted = eina_list_sorted_insert(sorted,
- _toolbar_item_prio_compare_cb, it);
- }
+ _fix_items_visibility(wd, &iw, vw);
- EINA_LIST_FREE(sorted, it)
- {
- Evas_Coord ciw;
-
- evas_object_geometry_get(it->base.view, NULL, NULL, &ciw, NULL);
- iw += ciw;
- it->prio.visible = (iw <= vw);
- }
-
- /* All items are removed from the box object, since removing individual items won't trigger
- a resize. Items are be readded below. */
+ /* All items are removed from the box object, since removing individual
+ * items won't trigger a resize. Items are be readded below. */
evas_object_box_remove_all(wd->bx, EINA_FALSE);
if (iw > vw)
{
}
else
{
- /* All items are visible, show them all (except for the "More" button, of course). */
+ /* All items are visible, show them all (except for the "More"
+ * button, of course). */
EINA_INLIST_FOREACH(wd->items, it)
{
if (it == wd->more_item)
}
}
}
+ else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
+ {
+ Evas_Coord iw = 0;
+ _fix_items_visibility(wd, &iw, vw);
+ evas_object_box_remove_all(wd->bx, EINA_FALSE);
+ if (iw > vw)
+ {
+ EINA_INLIST_FOREACH(wd->items, it)
+ {
+ if (!it->prio.visible)
+ evas_object_hide(it->base.view);
+ else
+ {
+ evas_object_box_append(wd->bx, it->base.view);
+ evas_object_show(it->base.view);
+ }
+ }
+ }
+ else
+ {
+ /* All items are visible, show them all */
+ EINA_INLIST_FOREACH(wd->items, it)
+ {
+ evas_object_show(it->base.view);
+ evas_object_box_append(wd->bx, it->base.view);
+ }
+ }
+ }
else
{
EINA_INLIST_FOREACH(wd->items, it)
}
/**
- * Sets the priority of a toolbar item. This is used only when the toolbar expand mode
- * is set to ELM_TOOLBAR_SHRINK_MENU: when space is at a premium, items with low priority
- * will be removed from the toolbar and added to a dynamically-created menu, while items
- * with higher priority will remain on the toolbar, with the same order they were added.
+ * Sets the priority of a toolbar item. This is used only when the toolbar
+ * shrink mode is set to ELM_TOOLBAR_SHRINK_MENU or ELM_TOOLBAR_SHRINK_HIDE:
+ * when space is at a premium, items with low priority will be removed from
+ * the toolbar and added to a dynamically-created menu, while items with
+ * higher priority will remain on the toolbar, with the same order they were
+ * added.
*
* @param item The toolbar item.
* @param priority The item priority. The default is zero.
}
/**
- * Set the expand state of toolbar @p obj.
+ * Set the shrink state of toolbar @p obj.
*
* @param obj The toolbar object
* @param shrink_mode The toolbar won't scroll if ELM_TOOLBAR_SHRINK_NONE,
- * will scroll if ELM_TOOLBAR_SHRINK_SCROLL, and will create a button to
+ * but will enforce a minimun size so all the items will fit, won't scroll
+ * and won't show the items that don't fit if ELM_TOOLBAR_SHRINK_HIDE,
+ * will scroll if ELM_TOOLBAR_SHRINK_SCROLL, and will create a button to
* pop up excess elements with ELM_TOOLBAR_SHRINK_MENU.
*
* @ingroup Toolbar
NULL, NULL);
elm_toolbar_item_priority_set(wd->more_item, INT_MAX);
}
+ else if (shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
+ elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
+ ELM_SMART_SCROLLER_POLICY_OFF);
else
- elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_AUTO, ELM_SMART_SCROLLER_POLICY_OFF);
+ elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_AUTO,
+ ELM_SMART_SCROLLER_POLICY_OFF);
_sizing_eval(obj);
}