elm genlist: Deprecated elm_genlist_compress_mode_set/get and

elm_genlist_height_for_width_mode_set/get. Use
elm_genlist_mode_set(obj, ELM_LIST_COMPRESS) instead. This may
introduce bugs or performance issue but I will fix this soon.

Signed-off-by: Daniel Juyung Seo <juyung.seo@samsung.com>

SVN revision: 68985
This commit is contained in:
Daniel Juyung Seo 2012-03-07 16:07:34 +00:00 committed by Daniel Juyung Seo
parent feb7bfe3df
commit 005f2465d9
8 changed files with 92 additions and 146 deletions

View File

@ -48,7 +48,7 @@ set_api_state(api_data *api)
case COMPRESS_MODE_SET: /* 2 */
elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_DEFAULT);
elm_genlist_compress_mode_set(gl, EINA_TRUE);
elm_genlist_mode_set(gl, ELM_LIST_COMPRESS);
break;
case BOUNCE_SET: /* 3 */
@ -840,7 +840,7 @@ test_genlist4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
evas_object_show(bx);
gl = elm_genlist_add(win);
elm_genlist_height_for_width_mode_set(gl, EINA_TRUE);
elm_genlist_mode_set(gl, ELM_LIST_COMPRESS);
elm_genlist_multi_select_set(gl, 1);
evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@ -1996,7 +1996,7 @@ test_genlist12(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i
evas_object_show(bx);
gl = elm_genlist_add(win);
elm_genlist_height_for_width_mode_set(gl, EINA_TRUE);
elm_genlist_mode_set(gl, ELM_LIST_COMPRESS);
evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, gl);

View File

@ -247,7 +247,7 @@ test_store(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
evas_object_show(bx);
gl = elm_genlist_add(win);
elm_genlist_height_for_width_mode_set(gl, EINA_TRUE);
elm_genlist_mode_set(gl, ELM_LIST_COMPRESS);
evas_object_smart_callback_add(gl, "selected", _st_selected, NULL);
evas_object_smart_callback_add(gl, "clicked,double", _st_double_clicked, NULL);
evas_object_smart_callback_add(gl, "longpressed", _st_longpress, NULL);

View File

@ -139,27 +139,22 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
printf("always select: %d\n", always);
elm_genlist_bounce_get(list, &hbounce, &vbounce);
printf("bounce - horizontal: %d, vertical: %d\n", hbounce, vbounce);
printf("compress mode: %d\n", elm_genlist_compress_mode_get(list));
printf("homogeneous: %d\n", elm_genlist_homogeneous_get(list));
printf("horizontal mode: %d\n", elm_genlist_mode_get(list));
printf("longpress timeout: %0.3f\n",
elm_genlist_longpress_timeout_get(list));
printf("multi selection: %d\n", elm_genlist_multi_select_get(list));
printf("no selection mode: %d\n", no_sel);
printf("height for width enabled: %d\n",
elm_genlist_height_for_width_mode_get(list));
elm_genlist_scroller_policy_get(list, &hp, &vp);
printf("scroller policy - horizontal: %d, vertical: %d\n", hp, vp);
printf("block count: %d\n", elm_genlist_block_count_get(list));
printf("\n");
elm_genlist_bounce_set(list, EINA_FALSE, EINA_FALSE);
elm_genlist_compress_mode_set(list, EINA_TRUE);
elm_genlist_homogeneous_set(list, EINA_FALSE);
elm_genlist_mode_set(list, ELM_LIST_LIMIT);
elm_genlist_multi_select_set(list, EINA_TRUE);
elm_genlist_select_mode_set(list, ELM_OBJECT_NORMAL_SELECT);
elm_genlist_height_for_width_mode_set(list, EINA_FALSE);
elm_genlist_scroller_policy_set(list, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON);
elm_genlist_longpress_timeout_set(list, 0.5);
elm_genlist_block_count_set(list, 16);

View File

@ -111,7 +111,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
_itc->func.state_get = NULL;
_itc->func.del = NULL;
}
list = _genlist_add(box);
_genlist_fill(list);
@ -120,11 +120,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
_genlist_fill(list);
list = _genlist_add(box);
elm_genlist_compress_mode_set(list, EINA_TRUE);
_genlist_fill(list);
list = _genlist_add(box);
elm_genlist_height_for_width_mode_set(list, EINA_TRUE);
elm_genlist_mode_set(list, ELM_LIST_COMPRESS);
_genlist_fill(list);
evas_object_size_hint_min_set(bg, 800, 160);

View File

@ -6146,6 +6146,70 @@ EINA_DEPRECATED EAPI Eina_Bool elm_web_forward_possible(Evas_Object *obj
*/
EINA_DEPRECATED EAPI Eina_Bool elm_web_navigate_possible(Evas_Object *obj, int steps);
/*
* Enable/disable compress mode.
*
* @param obj The genlist object
* @param compress The compress mode
* (@c EINA_TRUE = on, @c EINA_FALSE = off). Default is @c EINA_FALSE.
*
* This will enable the compress mode where items are "compressed"
* horizontally to fit the genlist scrollable viewport width. This is
* special for genlist. Do not rely on
* elm_genlist_mode_set() being set to @c ELM_LIST_COMPRESS to
* work as genlist needs to handle it specially.
*
* @deprecated elm_genlist_mode_set(obj, ELM_LIST_COMPRESS)
*/
EINA_DEPRECATED EAPI void elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress);
/**
* Get whether the compress mode is enabled.
*
* @param obj The genlist object
* @return The compress mode
* (@c EINA_TRUE = on, @c EINA_FALSE = off)
*
* @deprecated elm_genlsit_mode_get()
*/
EINA_DEPRECATED EAPI Eina_Bool elm_genlist_compress_mode_get(const Evas_Object *obj);
/**
* Enable/disable height-for-width mode.
*
* @param obj The genlist object
* @param height_for_width The height-for-width mode (@c EINA_TRUE = on,
* @c EINA_FALSE = off). Default is @c EINA_FALSE.
*
* With height-for-width mode the item width will be fixed (restricted
* to a minimum of) to the list width when calculating its size in
* order to allow the height to be calculated based on it. This allows,
* for instance, text block to wrap lines if the Edje part is
* configured with "text.min: 0 1".
*
* @note This mode will make list resize slower as it will have to
* recalculate every item height again whenever the list width
* changes!
*
* @note When height-for-width mode is enabled, it also enables
* compress mode (see elm_genlist_compress_mode_set()) and
* disables homogeneous (see elm_genlist_homogeneous_set()).
*
* @deprecated elm_genlist_mode_set(obj, ELM_LIST_COMPRESS)
*/
EINA_DEPRECATED EAPI void elm_genlist_height_for_width_mode_set(Evas_Object *obj, Eina_Bool height_for_width);
/**
* Get whether the height-for-width mode is enabled.
*
* @param obj The genlist object
* @return The height-for-width mode (@c EINA_TRUE = on, @c EINA_FALSE =
* off)
*
* @deprecated elm_genlist_mode_set(obj, ELM_LIST_COMPRESS)
*/
EINA_DEPRECATED EAPI Eina_Bool elm_genlist_height_for_width_mode_get(const Evas_Object *obj);
/**
* @}
*/

View File

@ -128,7 +128,6 @@ struct _Widget_Data
Eina_Bool multitouched : 1;
Eina_Bool longpressed : 1;
Eina_Bool bring_in : 1; /**< a flag to describe the scroll animation. (show, bring in) */
Eina_Bool compress : 1;
Eina_Bool height_for_width : 1;
Eina_Bool homogeneous : 1;
Eina_Bool swipe : 1;

View File

@ -108,7 +108,6 @@ struct _Item_Cache
const char *item_style; // it->itc->item_style
Eina_Bool tree : 1; // it->group
Eina_Bool compress : 1; // it->wd->compress
Eina_Bool selected : 1; // it->selected
Eina_Bool disabled : 1; // it->disabled
@ -632,7 +631,7 @@ _sizing_eval(Evas_Object *obj)
evas_object_size_hint_min_get(wd->scr, &minw, &minh);
evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
minh = -1;
if (wd->height_for_width)
if (wd->mode == ELM_LIST_COMPRESS)
{
Evas_Coord vw, vh;
@ -650,7 +649,7 @@ _sizing_eval(Evas_Object *obj)
wd->calc_job = ecore_job_add(_calc_job, wd);
}
}
if (wd->mode == ELM_LIST_LIMIT)
else if (wd->mode == ELM_LIST_LIMIT)
{
Evas_Coord vmw, vmh;
@ -1600,7 +1599,6 @@ _item_cache_add(Elm_Gen_Item *it)
evas_object_move(itc->base_view, -9999, -9999);
itc->item_style = eina_stringshare_add(it->itc->item_style);
if (it->item->type & ELM_GENLIST_ITEM_TREE) itc->tree = 1;
itc->compress = (it->wd->compress);
itc->selected = it->selected;
itc->disabled = elm_widget_item_disabled_get(it);
itc->expanded = it->item->expanded;
@ -1652,7 +1650,6 @@ _item_cache_find(Elm_Gen_Item *it)
if ((itc->selected) || (itc->disabled) || (itc->expanded))
continue;
if ((itc->tree == tree) &&
(itc->compress == it->wd->compress) &&
(((!it->itc->item_style) && (!itc->item_style)) ||
(it->itc->item_style && itc->item_style &&
(!strcmp(it->itc->item_style, itc->item_style)))))
@ -2006,9 +2003,9 @@ _item_realize(Elm_Gen_Item *it,
elm_widget_sub_object_add(WIDGET(it), VIEW(it));
if (it->item->type & ELM_GENLIST_ITEM_TREE)
snprintf(buf, sizeof(buf), "tree%s/%s", it->wd->compress ? "_compress" : "", it->itc->item_style ?: "default");
snprintf(buf, sizeof(buf), "tree%s/%s", it->wd->mode == ELM_LIST_COMPRESS ? "_compress" : "", it->itc->item_style ?: "default");
else
snprintf(buf, sizeof(buf), "item%s/%s", it->wd->compress ? "_compress" : "", it->itc->item_style ?: "default");
snprintf(buf, sizeof(buf), "item%s/%s", it->wd->mode == ELM_LIST_COMPRESS ? "_compress" : "", it->itc->item_style ?: "default");
_elm_theme_object_set(WIDGET(it), VIEW(it), "genlist", buf,
elm_widget_style_get(WIDGET(it)));
@ -2107,7 +2104,7 @@ _item_realize(Elm_Gen_Item *it,
if (!it->display_only)
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
if (it->wd->mode == ELM_LIST_COMPRESS) mw = it->wd->prev_viewport_w;
edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
mh);
if (!it->display_only)
@ -2922,7 +2919,7 @@ _pan_resize(Evas_Object *obj,
if (!sd) return;
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
if ((ow == w) && (oh == h)) return;
if ((sd->wd->height_for_width) && (ow != w))
if ((sd->wd->mode == ELM_LIST_COMPRESS) && (ow != w))
{
/* fix me later */
if (sd->resize_job) ecore_job_del(sd->resize_job);
@ -3150,7 +3147,7 @@ _mode_item_realize(Elm_Gen_Item *it)
elm_widget_sub_object_add(WIDGET(it), it->item->mode_view);
strncpy(buf, "item", sizeof(buf));
if (it->wd->compress)
if (it->wd->mode == ELM_LIST_COMPRESS)
strncat(buf, "_compress", sizeof(buf) - strlen(buf));
if (it->item->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
@ -3297,7 +3294,7 @@ _edit_mode_item_realize(Elm_Gen_Item *it, Eina_Bool effect_on)
if (it->item->type & ELM_GENLIST_ITEM_TREE)
strncpy(buf, "tree", sizeof(buf));
else strncpy(buf, "item", sizeof(buf));
if (it->wd->compress)
if (it->wd->mode == ELM_LIST_COMPRESS)
strncat(buf, "_compress", sizeof(buf) - strlen(buf));
strncat(buf, "/", sizeof(buf) - strlen(buf));
@ -5238,6 +5235,8 @@ elm_genlist_mode_set(Evas_Object *obj,
if (!wd) return;
if (wd->mode == mode) return;
wd->mode = mode;
if (wd->mode == ELM_LIST_COMPRESS)
elm_genlist_homogeneous_set(obj, EINA_FALSE);
_sizing_eval(obj);
}
@ -5309,50 +5308,6 @@ elm_genlist_no_select_mode_get(const Evas_Object *obj)
return EINA_FALSE;
}
EAPI void
elm_genlist_compress_mode_set(Evas_Object *obj,
Eina_Bool compress)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
wd->compress = !!compress;
if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
}
EAPI Eina_Bool
elm_genlist_compress_mode_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
return wd->compress;
}
EAPI void
elm_genlist_height_for_width_mode_set(Evas_Object *obj,
Eina_Bool height_for_width)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
wd->height_for_width = !!height_for_width;
if (wd->height_for_width)
{
elm_genlist_homogeneous_set(obj, EINA_FALSE);
elm_genlist_compress_mode_set(obj, EINA_TRUE);
}
}
EAPI Eina_Bool
elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
return wd->height_for_width;
}
EAPI void
elm_genlist_bounce_set(Evas_Object *obj,
Eina_Bool h_bounce,
@ -5385,7 +5340,6 @@ elm_genlist_homogeneous_set(Evas_Object *obj,
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
wd->homogeneous = !!homogeneous;
}

View File

@ -491,12 +491,22 @@ EAPI Eina_Bool elm_genlist_multi_select_get(const Evas_Objec
* @param mode The mode to use (one of #ELM_LIST_SCROLL or #ELM_LIST_LIMIT).
*
* This sets the mode used for sizing items horizontally. Valid modes
* are #ELM_LIST_LIMIT and #ELM_LIST_SCROLL. The default is
* are #ELM_LIST_LIMIT, #ELM_LIST_SCROLL, and #ELM_LIST_COMPRESS. The default is
* ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
* the scroller will scroll horizontally. Otherwise items are expanded
* to fill the width of the viewport of the scroller. If it is
* ELM_LIST_LIMIT, items will be expanded to the viewport width and
* limited to that size.
* limited to that size. If it is ELM_LIST_COMPRESS, the item width will be
* fixed (restricted to a minimum of) to the list width when calculating its
* size in order to allow the height to be calculated based on it. This allows,
* for instance, text block to wrap lines if the Edje part is configured with
* "text.min: 0 1".
* @note ELM_LIST_COMPRESS will make list resize slower as it will have to
* recalculate every item height again whenever the list width
* changes!
* @note When ELM_LIST_COMPRESS mode is enabled, it also enables
* compress mode (see elm_genlist_compress_mode_set()) and
* disables homogeneous (see elm_genlist_homogeneous_set()).
*
* @see elm_genlist_mode_get()
*
@ -1294,78 +1304,6 @@ EAPI void elm_genlist_item_cursor_engine_only_set(Elm_O
*/
EAPI Eina_Bool elm_genlist_item_cursor_engine_only_get(const Elm_Object_Item *it);
/**
* Enable/disable compress mode.
*
* @param obj The genlist object
* @param compress The compress mode
* (@c EINA_TRUE = on, @c EINA_FALSE = off). Default is @c EINA_FALSE.
*
* This will enable the compress mode where items are "compressed"
* horizontally to fit the genlist scrollable viewport width. This is
* special for genlist. Do not rely on
* elm_genlist_mode_set() being set to @c ELM_LIST_COMPRESS to
* work as genlist needs to handle it specially.
*
* @see elm_genlist_compress_mode_get()
*
* @ingroup Genlist
*/
// XXX: kill this. elm_genlist_height_for_width_mode_set() covers this.
EAPI void elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress);
/**
* Get whether the compress mode is enabled.
*
* @param obj The genlist object
* @return The compress mode
* (@c EINA_TRUE = on, @c EINA_FALSE = off)
*
* @see elm_genlist_compress_mode_set()
*
* @ingroup Genlist
*/
EAPI Eina_Bool elm_genlist_compress_mode_get(const Evas_Object *obj);
/**
* Enable/disable height-for-width mode.
*
* @param obj The genlist object
* @param height_for_width The height-for-width mode (@c EINA_TRUE = on,
* @c EINA_FALSE = off). Default is @c EINA_FALSE.
*
* With height-for-width mode the item width will be fixed (restricted
* to a minimum of) to the list width when calculating its size in
* order to allow the height to be calculated based on it. This allows,
* for instance, text block to wrap lines if the Edje part is
* configured with "text.min: 0 1".
*
* @note This mode will make list resize slower as it will have to
* recalculate every item height again whenever the list width
* changes!
*
* @note When height-for-width mode is enabled, it also enables
* compress mode (see elm_genlist_compress_mode_set()) and
* disables homogeneous (see elm_genlist_homogeneous_set()).
*
* @ingroup Genlist
*/
//aspect
//XXX: API name is ambiguous.. How about elm_genlist_mode_fixed_width_set?
EAPI void elm_genlist_height_for_width_mode_set(Evas_Object *obj, Eina_Bool height_for_width);
/**
* Get whether the height-for-width mode is enabled.
*
* @param obj The genlist object
* @return The height-for-width mode (@c EINA_TRUE = on, @c EINA_FALSE =
* off)
*
* @ingroup Genlist
*/
//XXX: API name is ambiguous elm_genlist_mode_fixed_width_get() ?????
EAPI Eina_Bool elm_genlist_height_for_width_mode_get(const Evas_Object *obj);
/**
* Enable/disable homogeneous mode.
*