Simple List

Basic list__ A list is a scrollable container whose children can be selected. <code c> Evas_Object *list, *icon, *button; list = elm_list_add(win); size giving scrollbar evas_object_resize(list, 320, 70); first item: text Elm_Object_Item *item_text = elm_list_item_append(list, “Text item”, NULL, NULL, NULL, NULL); second item: icon icon = elm_icon_add(list); elm_icon_standard_set(icon, “chat”); Elm_Object_Item *item_icon = elm_list_item_append(list, “Icon item”, icon, NULL, NULL, NULL); third item: button button = elm_button_add(list); elm_object_text_set(button, “Button”); Elm_Object_Item *item_button = elm_list_item_append(list, “Button item”, NULL, button, NULL, NULL); elm_list_go(list); evas_object_show(list); </code> Any Evas Object can be added as an icon, either at the beginning (third parameter) or the end (fourth parameter). List mode__

There are several modes for the list item dimensions:

  • ELM_LIST_COMPRESS The list won't set any of its size hints to inform how a possible container should resize it. Then, if it's not created as a “resize object”, it might end with zeroed dimensions. The list will respect the container's geometry and, if any of its items won't fit into its transverse axis, one won't be able to scroll it in that direction.
  • ELM_LIST_SCROLL Default value. This is the same as ELM_LIST_COMPRESS, with the exception that if any of its items won't fit into its transverse axis, one will be able to scroll it in that direction.
  • ELM_LIST_LIMIT Sets a minimum size hint on the list object, so that containers may respect it (and resize itself to fit the child properly). More specifically, a minimum size hint will be set for its transverse axis, so that the largest item in that direction fits well. This is naturally bound by the list object's maximum size hints, set externally.
  • ELM_LIST_EXPAND Besides setting a minimum size on the transverse axis, just like on ELM_LIST_LIMIT, the list will set a minimum size on the longitudinal axis, trying to reserve space to all its children to be visible at a time. This is naturally bound by the list object's maximum size hints, set externally.
  • ELM_LIST_LAST Indicates error if returned by elm_list_mode_get()
elm_list_mode_set(list, ELM_LIST_COMPRESS);

Scroller policy__ Several effects can be shown on a list. For instance, the scroller can set to bounce at the end on either direction. <code c> elm_scroller_bounce_set(list, EINA_TRUE, EINA_TRUE); </code> The second argument is for the horizontal axis, the third one for the vertical axis. You can also control whether to display scrollbars. <code c> elm_scroller_policy_set(list, ELM_SCROLLER_POLICY_AUTO,ELM_SCOLLER_POLICY_ON); </code> As for the bounce preference, the second argument is for the horizontal axis, the third one for the vertical axis: * ELM_SCROLLER_POLICY_OFF will always hide the scrollbar * ELM_SCROLLER_POLICY_ON will always show the scrollbar * ELM_SCROLLER_POLICY_AUTO means that the scrollbar will be only shown when needed, and hidden otherwise. Events__

A list can respond to several events:

  • activated - The user has double-clicked or pressed (enter|return|spacebar) on an item. The event_info parameter is the item that was activated.
  • clicked,double - The user has double-clicked an item. The event_info parameter is the item that was double-clicked.
  • clicked,right - The user has right-clicked an item. The event_info parameter is the item that was right-clicked. (since 1.13)
  • selected - when the user selected an item
  • unselected - when the user unselected an item
  • longpressed - an item in the list is long-pressed
  • edge,top - the list is scrolled until the top edge
  • edge,bottom - the list is scrolled until the bottom edge
  • edge,left - the list is scrolled until the left edge
  • edge,right - the list is scrolled until the right edge
  • highlighted - an item in the list is highlighted. This is called when the user presses an item or keyboard selection is done so the item is physically highlighted. The event_info parameter is the item that was highlighted.
  • unhighlighted - an item in the list is unhighlighted. This is called when the user releases an item or keyboard selection is moved so the item is physically unhighlighted. The event_info parameter is the item that was unhighlighted.
  • language,changed - the program's language changed
  • focused - When the list has received focus. (since 1.8)
  • unfocused - When the list has lost focus. (since 1.8)
  • item,focused - When the list item has received focus. (since 1.10)
  • item,unfocused - When the list item has lost focus. (since 1.10)

Selected event__ The selected event is received when the user selected an item, below the callback add an new item only if it is the button item which is selected. <code c> static void _prepend_itembutton_cb(void *data, Evas_Object *obj, void *event_info) { Elm_Object_Item *list_it; Evas_Object *li = obj; Elm_Object_Item *selected=elm_list_selected_item_get(li); if(selected == (Elm_Object_Item*)data) { static int counter=0; char label[32]; snprintf(label, sizeof(label), “Item %i”, counter++); list_it = elm_list_item_prepend(li, label, NULL, NULL, NULL, NULL); elm_list_go(li); if (!list_it) printf(“Error adding item\n”); } } evas_object_smart_callback_add(list, “selected”, _prepend_itembutton_cb, item_button); </code> The whole code: list.c