more useless elm stuff: vertical toolbar orientation (by cedric's request) along...
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 7 Aug 2011 03:42:28 +0000 (03:42 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 7 Aug 2011 03:42:28 +0000 (03:42 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@62171 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/test.c
src/bin/test_toolbar.c
src/lib/Elementary.h.in
src/lib/elm_toolbar.c

index 80dfa08..693a425 100644 (file)
@@ -46,6 +46,7 @@ void test_toolbar2(void *data, Evas_Object *obj, void *event_info);
 void test_toolbar3(void *data, Evas_Object *obj, void *event_info);
 void test_toolbar4(void *data, Evas_Object *obj, void *event_info);
 void test_toolbar5(void *data, Evas_Object *obj, void *event_info);
+void test_toolbar6(void *data, Evas_Object *obj, void *event_info);
 void test_hoversel(void *data, Evas_Object *obj, void *event_info);
 void test_list(void *data, Evas_Object *obj, void *event_info);
 void test_list_horizontal(void *data, Evas_Object *obj, void *event_info);
@@ -325,6 +326,7 @@ my_win_main(char *autorun, Eina_Bool test_win_only)
    ADD_TEST("Toolbar 3", test_toolbar3);
    ADD_TEST("Toolbar 4", test_toolbar4);
    ADD_TEST("Toolbar 5", test_toolbar5);
+   ADD_TEST("Toolbar 6", test_toolbar6);
    ADD_TEST("Hoversel", test_hoversel);
    ADD_TEST("List", test_list);
    ADD_TEST("List - Horizontal", test_list_horizontal);
index 185b284..d5aa05e 100644 (file)
@@ -615,4 +615,116 @@ test_toolbar5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
    evas_object_resize(win, 320, 300);
    evas_object_show(win);
 }
+
+void
+test_toolbar6(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");
+   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);
+   elm_box_horizontal_set(bx, EINA_TRUE);
+   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_show(bx);
+
+   tb = elm_toolbar_add(win);
+   elm_toolbar_orientation_set(tb, EINA_TRUE);
+   elm_toolbar_mode_shrink_set(tb, ELM_TOOLBAR_SHRINK_MENU);
+   evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+   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);
+   //elm_table_homogeneous_set(tb, 1);
+   evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 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
index 6de886a..436f0ad 100644 (file)
@@ -11912,6 +11912,24 @@ extern "C" {
    EAPI Eina_Bool        elm_toolbar_item_cursor_engine_only_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1);
 
    /**
+    * Change a toolbar's orientation
+    * @param obj The toolbar object
+    * @param vertical If @c EINA_TRUE, the toolbar is vertical
+    * By default, a toolbar will be horizontal. Use this function to create a vertical toolbar.
+    * @ingroup Toolbar
+    */
+   EAPI void             elm_toolbar_orientation_set(Evas_Object *obj, Eina_Bool vertical) EINA_ARG_NONNULL(1);
+
+   /**
+    * Get a toolbar's orientation
+    * @param obj The toolbar object
+    * @return If @c EINA_TRUE, the toolbar is vertical
+    * By default, a toolbar will be horizontal. Use this function to determine whether a toolbar is vertical.
+    * @ingroup Toolbar
+    */
+   EAPI Eina_Bool        elm_toolbar_orientation_get(Evas_Object *obj) EINA_ARG_NONNULL(1);
+
+   /**
     * @}
     */
 
index 8bc4a4a..f46632e 100644 (file)
@@ -15,6 +15,7 @@ struct _Widget_Data
    double align;
    Eina_Bool homogeneous : 1;
    Eina_Bool no_select : 1;
+   Eina_Bool vertical : 1;
    Ecore_Job *resize_job;
 };
 
@@ -355,7 +356,7 @@ static void
 _sizing_eval(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
-   Evas_Coord minw = -1, minh = -1, minw_bx;
+   Evas_Coord minw = -1, minh = -1, minw_bx, minh_bx;
    Evas_Coord vw = 0, vh = 0;
    Evas_Coord w, h;
 
@@ -364,24 +365,37 @@ _sizing_eval(Evas_Object *obj)
    edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
                              &minw, &minh);
    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
+fprintf(stderr, "%i: w=%i, h=%i\n", __LINE__, w, h);
    if (w < minw) w = minw;
    if (h < minh) h = minh;
-
+fprintf(stderr, "%i: w=%i, h=%i\n", __LINE__, w, h);
    evas_object_resize(wd->scr, w, h);
 
    evas_object_size_hint_min_get(wd->bx, &minw, &minh);
    minw_bx = minw;
-   if (w > minw) minw = w;
+   minh_bx = minh;
+fprintf(stderr, "%i: minw=%i, minh=%i\n", __LINE__, minw, minh);
+   if (wd->vertical && (h > minh)) minh = h;
+   if ((!wd->vertical) && (w > minw)) minw = w;
+fprintf(stderr, "%i: minw=%i, minh=%i\n", __LINE__, minw, minh);
    evas_object_resize(wd->bx, minw, minh);
    elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
    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_bx + (w - vw); break;
+      case ELM_TOOLBAR_SHRINK_SCROLL:
+        if (wd->vertical) minh = h - vh;
+        else minw = w - vw;
+        break;
+      case ELM_TOOLBAR_SHRINK_NONE:
+        if (wd->vertical) minh = minh_bx + (h - vh);
+        else minw = minw_bx + (w - vw);
+        break;
      }
+fprintf(stderr, "%i: minw=%i, minh=%i\n", __LINE__, minw, minh);
    minh = minh + (h - vh);
+fprintf(stderr, "%i: minw=%i, minh=%i\n", __LINE__, minw, minh);
    evas_object_size_hint_min_set(obj, minw, minh);
    evas_object_size_hint_max_set(obj, -1, -1);
 }
@@ -614,7 +628,7 @@ _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
    Evas_Object *obj = (Evas_Object *) data;
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   _els_box_layout(o, priv, 1, wd->homogeneous, elm_widget_mirrored_get(obj));
+   _els_box_layout(o, priv, !wd->vertical, wd->homogeneous, elm_widget_mirrored_get(obj));
 }
 
 static Elm_Toolbar_Item *
@@ -678,8 +692,16 @@ _item_new(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb f
    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
    edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
-   evas_object_size_hint_weight_set(it->base.view, -1.0, EVAS_HINT_EXPAND);
-   evas_object_size_hint_align_set(it->base.view, 0.5, EVAS_HINT_FILL);
+   if (wd->vertical)
+     {
+        evas_object_size_hint_weight_set(it->base.view, EVAS_HINT_EXPAND, -1.0);
+        evas_object_size_hint_align_set(it->base.view, EVAS_HINT_FILL, 0.5);
+     }
+   else
+     {
+        evas_object_size_hint_weight_set(it->base.view, -1.0, EVAS_HINT_EXPAND);
+        evas_object_size_hint_align_set(it->base.view, 0.5, EVAS_HINT_FILL);
+     }
    evas_object_size_hint_min_set(it->base.view, mw, mh);
    evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_RESIZE,
                                   _resize_item, obj);
@@ -1126,13 +1148,22 @@ static void
 _elm_toolbar_item_label_update(Elm_Toolbar_Item *item)
 {
    Evas_Coord mw = -1, mh = -1;
+   Widget_Data *wd = elm_widget_data_get(item->base.widget);
    edje_object_part_text_set(item->base.view, "elm.text", item->label);
 
    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
    edje_object_size_min_restricted_calc(item->base.view, &mw, &mh, mw, mh);
    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
-   evas_object_size_hint_weight_set(item->base.view, -1.0, EVAS_HINT_EXPAND);
-   evas_object_size_hint_align_set(item->base.view, 0.5, EVAS_HINT_FILL);
+   if (wd->vertical)
+     {
+        evas_object_size_hint_weight_set(item->base.view, EVAS_HINT_EXPAND, -1.0);
+        evas_object_size_hint_align_set(item->base.view, EVAS_HINT_FILL, 0.5);
+     }
+   else
+     {
+        evas_object_size_hint_weight_set(item->base.view, -1.0, EVAS_HINT_EXPAND);
+        evas_object_size_hint_align_set(item->base.view, 0.5, EVAS_HINT_FILL);
+     }
    evas_object_size_hint_min_set(item->base.view, mw, mh);
 }
 
@@ -1181,6 +1212,7 @@ _elm_toolbar_item_icon_update(Elm_Toolbar_Item *item)
    Elm_Toolbar_Item_State *it_state;
    Eina_List *l;
    Evas_Coord mw = -1, mh = -1;
+   Widget_Data *wd = elm_widget_data_get(item->base.widget);
    Evas_Object *old_icon = edje_object_part_swallow_get(item->base.view,
                                                         "elm.swallow.icon");
    elm_widget_sub_object_del(item->base.view, old_icon);
@@ -1189,8 +1221,16 @@ _elm_toolbar_item_icon_update(Elm_Toolbar_Item *item)
    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
    edje_object_size_min_restricted_calc(item->base.view, &mw, &mh, mw, mh);
    elm_coords_finger_size_adjust(1, &mw, 1, &mh);
-   evas_object_size_hint_weight_set(item->base.view, -1.0, EVAS_HINT_EXPAND);
-   evas_object_size_hint_align_set(item->base.view, 0.5, EVAS_HINT_FILL);
+   if (wd->vertical)
+     {
+        evas_object_size_hint_weight_set(item->base.view, EVAS_HINT_EXPAND, -1.0);
+        evas_object_size_hint_align_set(item->base.view, EVAS_HINT_FILL, 0.5);
+     }
+   else
+     {
+        evas_object_size_hint_weight_set(item->base.view, -1.0, EVAS_HINT_EXPAND);
+        evas_object_size_hint_align_set(item->base.view, 0.5, EVAS_HINT_FILL);
+     }
    evas_object_size_hint_min_set(item->base.view, mw, mh);
 
    EINA_LIST_FOREACH(item->states, l, it_state)
@@ -1677,3 +1717,22 @@ elm_toolbar_icon_order_lookup_get(const Evas_Object *obj)
    if (!wd) return ELM_ICON_LOOKUP_THEME_FDO;
    return wd->lookup_order;
 }
+
+EAPI void
+elm_toolbar_orientation_set(Evas_Object *obj, Eina_Bool vertical)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   wd->vertical = vertical;
+   _sizing_eval(obj);
+}
+
+EAPI Eina_Bool
+elm_toolbar_orientation_get(Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+   return wd->vertical;
+}