From: jaehwan Date: Thu, 7 Jun 2012 07:32:55 +0000 (+0000) Subject: Remove the APIs elm_toolbar_items_max_set/get. X-Git-Tag: 1.0.0+svn.70492slp2+build19~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e824cc46296c8e3cbe7c44cb4537e24e29ea1847;p=framework%2Fuifw%2Felementary.git Remove the APIs elm_toolbar_items_max_set/get. Instead of them, add the APIs elm_toolbar_standard_priority_set/get. The items which are lower than standard priority are located in more menu or panel. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@71777 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 Conflicts: ChangeLog --- diff --git a/src/bin/test_toolbar.c b/src/bin/test_toolbar.c index 6288bce..2c8b942 100644 --- a/src/bin/test_toolbar.c +++ b/src/bin/test_toolbar.c @@ -124,7 +124,7 @@ test_toolbar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); elm_toolbar_item_menu_set(tb_it, EINA_TRUE); - elm_toolbar_item_priority_set(tb_it, -999999); + elm_toolbar_item_priority_set(tb_it, -9999); elm_toolbar_menu_parent_set(tb, win); menu = elm_toolbar_item_menu_get(tb_it); @@ -228,7 +228,7 @@ test_toolbar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in item = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); elm_toolbar_item_menu_set(item, EINA_TRUE); - elm_toolbar_item_priority_set(item, -999999); + elm_toolbar_item_priority_set(item, -9999); elm_toolbar_menu_parent_set(tb, win); menu = elm_toolbar_item_menu_get(item); @@ -332,7 +332,7 @@ test_toolbar3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); elm_toolbar_item_menu_set(tb_it, EINA_TRUE); - elm_toolbar_item_priority_set(tb_it, 999999); + elm_toolbar_item_priority_set(tb_it, 9999); elm_toolbar_menu_parent_set(tb, win); menu = elm_toolbar_item_menu_get(tb_it); @@ -436,7 +436,7 @@ test_toolbar4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); elm_toolbar_item_menu_set(tb_it, EINA_TRUE); - elm_toolbar_item_priority_set(tb_it, -999999); + elm_toolbar_item_priority_set(tb_it, -9999); elm_toolbar_menu_parent_set(tb, win); menu = elm_toolbar_item_menu_get(tb_it); @@ -545,7 +545,7 @@ test_toolbar5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); elm_toolbar_item_menu_set(tb_it, EINA_TRUE); - elm_toolbar_item_priority_set(tb_it, -999999); + elm_toolbar_item_priority_set(tb_it, -9999); elm_toolbar_menu_parent_set(tb, win); menu = elm_toolbar_item_menu_get(tb_it); @@ -650,7 +650,7 @@ test_toolbar6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); elm_toolbar_item_menu_set(tb_it, EINA_TRUE); - elm_toolbar_item_priority_set(tb_it, -999999); + elm_toolbar_item_priority_set(tb_it, -9999); elm_toolbar_menu_parent_set(tb, win); menu = elm_toolbar_item_menu_get(tb_it); @@ -754,7 +754,7 @@ test_toolbar7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); elm_toolbar_item_menu_set(tb_it, EINA_TRUE); - elm_toolbar_item_priority_set(tb_it, -999999); + elm_toolbar_item_priority_set(tb_it, -9999); elm_toolbar_menu_parent_set(tb, win); menu = elm_toolbar_item_menu_get(tb_it); @@ -831,7 +831,7 @@ test_toolbar8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in tb = elm_toolbar_add(win); elm_toolbar_homogeneous_set(tb, EINA_FALSE); elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_EXPAND); - elm_toolbar_items_max_set(tb, 9); + elm_toolbar_standard_priority_set(tb, 0); 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); diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c index ff95df0..5087b22 100644 --- a/src/lib/elm_toolbar.c +++ b/src/lib/elm_toolbar.c @@ -16,8 +16,8 @@ struct _Widget_Data Elm_Toolbar_Shrink_Mode shrink_mode; Elm_Icon_Lookup_Order lookup_order; int icon_size; + int standard_priority; unsigned int item_count; - unsigned int item_max; double align; Elm_Object_Select_Mode select_mode; Eina_Bool homogeneous : 1; @@ -617,45 +617,13 @@ _toolbar_item_prio_compare_cb(const void *i1, const void *i2) } static void -_fix_items_visibility(Widget_Data *wd, Evas_Coord *iw, Evas_Coord vw) +_fix_items_visibility(Widget_Data *wd, Evas_Coord *iw, Evas_Coord vw, Eina_Bool *more) { Elm_Toolbar_Item *it, *prev; Eina_List *sorted = NULL; Evas_Coord ciw = 0, cih = 0; - - EINA_INLIST_FOREACH(wd->items, it) - { - sorted = eina_list_sorted_insert(sorted, - _toolbar_item_prio_compare_cb, it); - } - - if (wd->more_item) - { - evas_object_geometry_get(wd->VIEW(more_item), NULL, NULL, &ciw, &cih); - if (wd->vertical) *iw += cih; - else *iw += ciw; - } - EINA_LIST_FREE(sorted, it) - { - evas_object_geometry_get(VIEW(it), NULL, NULL, &ciw, &cih); - if (wd->vertical) *iw += cih; - else *iw += ciw; - if (!it->separator) - it->prio.visible = (*iw <= vw); - else - { - prev = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev); - it->prio.visible = prev->prio.visible; - } - } -} - -static void -_fix_items_visibility_by_number(Widget_Data *wd, unsigned int *count) -{ - Elm_Toolbar_Item *it, *prev, *next, *max = NULL; - Eina_List *sorted = NULL; - *count = 0; + int count = 0, i = 0; + *more = EINA_FALSE; EINA_INLIST_FOREACH(wd->items, it) { @@ -672,37 +640,33 @@ _fix_items_visibility_by_number(Widget_Data *wd, unsigned int *count) _toolbar_item_prio_compare_cb, it); } + if (wd->more_item) + { + evas_object_geometry_get(wd->VIEW(more_item), NULL, NULL, &ciw, &cih); + if (wd->vertical) *iw += cih; + else *iw += ciw; + } + EINA_LIST_FREE(sorted, it) { - *count += 1; - if(*count <= wd->item_max) + if (it->prio.priority > wd->standard_priority) { - it->prio.visible = EINA_TRUE; + evas_object_geometry_get(VIEW(it), NULL, NULL, &ciw, &cih); + if (wd->vertical) *iw += cih; + else *iw += ciw; + it->prio.visible = (*iw <= vw); it->in_box = wd->bx; - if (*count == wd->item_max) - max = it; + if (!it->separator) count++; } else { it->prio.visible = EINA_FALSE; - if (wd->item_count < (wd->item_max * 2) || - *count <= (wd->item_count + wd->item_max) / 2) + if (!it->separator) i++; + if (i <= (count + 1)) it->in_box = wd->bx_more; else it->in_box = wd->bx_more2; - - if (max) - { - max->prio.visible = EINA_FALSE; - max->in_box = wd->bx_more; - next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(max)->next); - if (next && next->separator) - { - next->prio.visible = max->prio.visible; - next->in_box = max->in_box; - } - max = NULL; - } + *more = EINA_TRUE; } } } @@ -722,6 +686,7 @@ _resize_job(void *data) Evas_Coord mw, mh, vw = 0, vh = 0, w = 0, h = 0; Elm_Toolbar_Item *it; Eina_List *list; + Eina_Bool more; if (!wd) return; wd->resize_job = NULL; @@ -735,12 +700,12 @@ _resize_job(void *data) if (wd->vertical) { evas_object_resize(wd->bx, w, vh); - _fix_items_visibility(wd, &ih, vh); + _fix_items_visibility(wd, &ih, vh, &more); } else { evas_object_resize(wd->bx, vw, h); - _fix_items_visibility(wd, &iw, vw); + _fix_items_visibility(wd, &iw, vw, &more); } evas_object_geometry_get(wd->VIEW(more_item), NULL, NULL, &more_w, &more_h); @@ -757,7 +722,7 @@ _resize_job(void *data) * items won't trigger a resize. Items are be readded below. */ evas_object_box_remove_all(wd->bx, EINA_FALSE); if (((wd->vertical) && (ih > vh)) || - ((!wd->vertical) && (iw > vw))) + ((!wd->vertical) && (iw > vw)) || more) { Evas_Object *menu; @@ -811,16 +776,16 @@ _resize_job(void *data) if (wd->vertical) { evas_object_resize(wd->bx, w, vh); - _fix_items_visibility(wd, &ih, vh); + _fix_items_visibility(wd, &ih, vh, &more); } else { evas_object_resize(wd->bx, vw, h); - _fix_items_visibility(wd, &iw, vw); + _fix_items_visibility(wd, &iw, vw, &more); } evas_object_box_remove_all(wd->bx, EINA_FALSE); if (((wd->vertical) && (ih > vh)) || - ((!wd->vertical) && (iw > vw))) + ((!wd->vertical) && (iw > vw)) || more) { EINA_INLIST_FOREACH(wd->items, it) { @@ -845,14 +810,18 @@ _resize_job(void *data) } else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND) { - unsigned int count; + Evas_Coord iw = 0, ih = 0; if ((vw >= mw) && (vh >= mh)) evas_object_resize(wd->bx, vw, vh); else if (vw < mw) evas_object_resize(wd->bx, mw, vh); else if (vh < mh) evas_object_resize(wd->bx, vw, mh); - _fix_items_visibility_by_number(wd, &count); + + if (wd->vertical) + _fix_items_visibility(wd, &ih, vh, &more); + else + _fix_items_visibility(wd, &iw, vw, &more); evas_object_box_remove_all(wd->bx, EINA_FALSE); evas_object_box_remove_all(wd->bx_more, EINA_FALSE); @@ -865,7 +834,7 @@ _resize_job(void *data) evas_object_show(VIEW(it)); } } - if (count > wd->item_max) + if (more) { evas_object_box_append(wd->bx, wd->VIEW(more_item)); evas_object_show(wd->VIEW(more_item)); @@ -901,6 +870,7 @@ _resize_job(void *data) (VIEW(it) == eina_list_nth(list, eina_list_count(list)-1)))) { evas_object_box_remove(wd->bx_more, VIEW(it)); + evas_object_move(VIEW(it), -9999, -9999); evas_object_hide(VIEW(it)); } } @@ -911,6 +881,7 @@ _resize_job(void *data) (VIEW(it) == eina_list_nth(list, eina_list_count(list)-1)))) { evas_object_box_remove(wd->bx_more2, VIEW(it)); + evas_object_move(VIEW(it), -9999, -9999); evas_object_hide(VIEW(it)); } } @@ -1407,7 +1378,7 @@ elm_toolbar_add(Evas_Object *parent) wd->more_item = NULL; wd->selected_item = NULL; - wd->item_max = 9999; + wd->standard_priority = -99999; wd->scr = elm_smart_scroller_add(e); elm_smart_scroller_widget_set(wd->scr, obj); elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", "default"); @@ -2242,21 +2213,22 @@ elm_toolbar_items_count(const Evas_Object *obj) } EAPI void -elm_toolbar_items_max_set(Evas_Object *obj, unsigned int max) +elm_toolbar_standard_priority_set(Evas_Object *obj, int priority) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; - wd->item_max = max; + wd->standard_priority = priority; + _resize(obj, NULL, NULL, NULL); } -EAPI unsigned int -elm_toolbar_items_max_get(const Evas_Object *obj) +EAPI int +elm_toolbar_standard_priority_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) 0; Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return 0; - return wd->item_max; + return wd->standard_priority; } EAPI void diff --git a/src/lib/elm_toolbar.h b/src/lib/elm_toolbar.h index 3d912c6..87fda24 100644 --- a/src/lib/elm_toolbar.h +++ b/src/lib/elm_toolbar.h @@ -871,29 +871,29 @@ EAPI Eina_Bool elm_toolbar_horizontal_get(const Evas_Object * EAPI unsigned int elm_toolbar_items_count(const Evas_Object *obj); /** - * Set the max number of visible items in a toolbar + * Set the standard priority of visible items in a toolbar * @param obj The toolbar object - * @param max The max number of visible items + * @param priority The standard_priority of visible items * - * When it is the ELM_TOOLBAR_SHRINK_EXPAND mode, the items are shown only up to max number. + * When it is the ELM_TOOLBAR_SHRINK_EXPAND mode, the items are shown only up to standard priority. * The other items are located in more panel. The more panel can be shown when the more item is clicked. * - * @see elm_toolbar_items_max_get() + * @see elm_toolbar_standard_priority_get() * * @ingroup Toolbar */ -EAPI void elm_toolbar_items_max_set(Evas_Object *obj, unsigned int max); +EAPI void elm_toolbar_standard_priority_set(Evas_Object *obj, int priority); /** - * Get the max number of visible items in a toolbar + * Get the standard_priority of visible items in a toolbar * @param obj The toolbar object - * @return The max number of items in @p obj toolbar + * @return The standard priority of items in @p obj toolbar * - * @see elm_toolbar_items_max_set() + * @see elm_toolbar_standard_priority_set() * * @ingroup Toolbar */ -EAPI unsigned int elm_toolbar_items_max_get(const Evas_Object *obj); +EAPI int elm_toolbar_standard_priority_get(const Evas_Object *obj); /** * Set the toolbar select mode.