Tizen Native API  5.5
Genlist (Generic list)

genlist_inheritance_tree.png
genlist.png

This widget aims to have more expansive list than the simple list in Elementary that could have more flexible items and allow many more entries while still being fast and low on memory usage. At the same time it was also made to be able to do tree structures. But the price to pay is more complexity when it comes to usage. If all you want is a simple list with icons and a single text, use the normal List object.

Genlist has a fairly large API, mostly because it's relatively complex, trying to be both expansive, powerful and efficient. First we will begin an overview on the theory behind genlist.

This widget inherits from the Layout one, so that all the functions acting on it also work for genlist objects.

This widget implements the elm-scrollable-interface interface, so that all (non-deprecated) functions for the base Scroller widget also work for genlists.

Some calls on the genlist's API are marked as deprecated, as they just wrap the scrollable widgets counterpart functions. Use the ones we point you to, for each case of deprecation here, instead -- eventually the deprecated ones will be discarded (next major release).

Genlist item classes - creating items

In order to have the ability to add and delete items on the fly, genlist implements a class (callback) system where the application provides a structure with information about that type of item (genlist may contain multiple different items with different classes, states and styles). Genlist will call the functions in this struct (methods) when an item is "realized" (i.e., created dynamically, while the user is scrolling the list). All objects will simply be deleted when no longer needed with evas_object_del(). The #Elm_Genlist_Item_Class structure contains the following members:

The function pointers inside func are text_get, content_get, state_get and del. The 3 first functions also receive a part parameter described below. A brief description of these functions follows:

available item styles:

If one wants to use more icons and texts than are offered in theme, there are two solutions. One is to use 'full' style that has one big swallow part. You can swallow anything there. The other solution is to customize genlist item style in application side by using elm_theme_extension_add() and its own edc. Please refer Theme - Using extensions for that.

Structure of items

An item in a genlist can have 0 or more texts (they can be regular text or textblock Evas objects - that's up to the style to determine), 0 or more contents (which are simply objects swallowed into the genlist item's theming Edje object) and 0 or more boolean states, which have the behavior left to the user to define. The Edje part names for each of these properties will be looked up, in the theme file for the genlist, under the Edje (string) data items named "labels", "contents" and "states", respectively. For each of those properties, if more than one part is provided, they must have names listed separated by spaces in the data fields. For the default genlist item theme, we have one text part ("elm.text"), two content parts ("elm.swallow.icon" and "elm.swallow.end") and no state parts.

A genlist item may be at one of several styles. Elementary provides one by default - "default", but this can be extended by system or application custom themes/overlays/extensions (see themes for more details).

Editing and Navigating

Items can be added by several calls. All of them return a Elm_Object_Item handle that is an internal member inside the genlist. They all take a data parameter that is meant to be used for a handle to the applications internal data (eg. the struct with the original item data). The parent parameter is the parent genlist item this belongs to if it is a tree or an indexed group, and NULL if there is no parent. The flags can be a bitmask of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_TREE and ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_TREE is set then this item is displayed as an item that is able to expand and have child items. If ELM_GENLIST_ITEM_GROUP is set then this item is group index item that is displayed at the top until the next group comes. The func parameter is a convenience callback that is called when the item is selected and the data parameter will be the func_data parameter, obj be the genlist object and event_info will be the genlist item.

elm_genlist_item_append() adds an item to the end of the list, or if there is a parent, to the end of all the child items of the parent. elm_genlist_item_prepend() is the same but adds to the beginning of the list or children list. elm_genlist_item_insert_before() inserts at item before another item and elm_genlist_item_insert_after() inserts after the indicated item.

The application can clear the list with elm_genlist_clear() which deletes all the items in the list and elm_object_item_del() will delete a specific item. elm_genlist_item_subitems_clear() will clear all items that are children of the indicated parent item.

To help inspect list items you can jump to the item at the top of the list with elm_genlist_first_item_get() which will return the item pointer, and similarly elm_genlist_last_item_get() gets the item at the end of the list. elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next and previous items respectively relative to the indicated item. Using these calls you can walk the entire item list/tree. Note that as a tree the items are flattened in the list, so elm_genlist_item_parent_get() will let you know which item is the parent (and thus know how to skip them if wanted).

Multi-selection

If the application wants multiple items to be able to be selected, elm_genlist_multi_select_set() can enable this. If the list is single-selection only (the default), then elm_genlist_selected_item_get() will return the selected item, if any, or NULL if none is selected. If the list is multi-select then elm_genlist_selected_items_get() will return a list (that is only valid as long as no items are modified (added, deleted, selected or unselected)).

Usage hints

There are also convenience functions. elm_object_item_widget_get() will return the genlist object the item belongs to. elm_genlist_item_show() will make the scroller scroll to show that specific item so its visible. elm_object_item_data_get() returns the data pointer set by the item creation functions.

If an item changes (state of boolean changes, text or contents change), then use elm_genlist_item_update() to have genlist update the item with the new state. Genlist will re-realize the item and thus call the functions in the _Elm_Genlist_Item_Class for that item.

To programmatically (un)select an item use elm_genlist_item_selected_set(). To get its selected state use elm_genlist_item_selected_get(). Similarly to expand/contract an item and get its expanded state, use elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And again to make an item disabled (unable to be selected and appear differently) use elm_object_item_disabled_set() to set this and elm_object_item_disabled_get() to get the disabled state.

In general to indicate how the genlist should expand items horizontally to fill the list area, use elm_genlist_mode_set(). Valid modes are ELM_LIST_LIMIT, ELM_LIST_COMPRESS and ELM_LIST_SCROLL. 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 if larger than the item, but genlist widget width is limited to the largest item. Do not use ELM_LIST_LIMIT mode with homogeneous mode turned on. ELM_LIST_COMPRESS can be combined with a different style that uses edjes' ellipsis feature (cutting text off like this: "tex...").

Items will call their selection func and callback only once when first becoming selected. Any further clicks will do nothing, unless you enable always select with elm_genlist_select_mode_set() as ELM_OBJECT_SELECT_MODE_ALWAYS. This means even if selected, every click will make the selected callbacks be called. elm_genlist_select_mode_set() as ELM_OBJECT_SELECT_MODE_NONE will turn off the ability to select items entirely and they will neither appear selected nor call selected callback functions.

Remember that you can create new styles and add your own theme augmentation per application with elm_theme_extension_add(). If you absolutely must have a specific style that overrides any theme the user or system sets up you can use elm_theme_overlay_add() to add such a file.

Implementation

Evas tracks every object you create. Every time it processes an event (mouse move, down, up etc.) it needs to walk through objects and find out what event that affects. Even worse every time it renders display updates, in order to just calculate what to re-draw, it needs to walk through many many many objects. Thus, the more objects you keep active, the more overhead Evas has in just doing its work. It is advisable to keep your active objects to the minimum working set you need. Also remember that object creation and deletion carries an overhead, so there is a middle-ground, which is not easily determined. But don't keep massive lists of objects you can't see or use. Genlist does this with list objects. It creates and destroys them dynamically as you scroll around. It groups them into blocks so it can determine the visibility etc. of a whole block at once as opposed to having to walk the whole list. This 2-level list allows for very large numbers of items to be in the list (tests have used up to 2,000,000 items). Also genlist employs a queue for adding items. As items may be different sizes, every item added needs to be calculated as to its size and thus this presents a lot of overhead on populating the list, this genlist employs a queue. Any item added is queued and spooled off over time, actually appearing some time later, so if your list has many members you may find it takes a while for them to all appear, with your process consuming a lot of CPU while it is busy spooling.

Genlist also implements a tree structure for items, but it does so with callbacks to the application, with the application filling in tree structures when requested (allowing for efficient building of a very deep tree that could even be used for file-management). See the above smart signal callbacks for details.

Genlist smart events

This widget emits the following signals, besides the ones sent from Layout:

Supported elm_object_item common APIs

Unsupported elm_object_item common APIs due to the genlist concept. Genlist fills content/text according to the appropriate callback functions. Please use elm_genlist_item_update() or elm_genlist_item_fields_update() instead.

Examples

Here is a list of examples that use the genlist, trying to show some of its capabilities:

Functions

EINA_DEPRECATED void elm_genlist_bounce_set (Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
EINA_DEPRECATED void elm_genlist_bounce_get (const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
EINA_DEPRECATED void elm_genlist_scroller_policy_set (Evas_Object *obj, Elm_Scroller_Policy policy_h, Elm_Scroller_Policy policy_v)
EINA_DEPRECATED void elm_genlist_scroller_policy_get (const Evas_Object *obj, Elm_Scroller_Policy *policy_h, Elm_Scroller_Policy *policy_v)
Elm_Genlist_Item_Classelm_genlist_item_class_new (void)
void elm_genlist_item_class_free (Elm_Genlist_Item_Class *itc)
void elm_genlist_item_class_ref (Elm_Genlist_Item_Class *itc)
void elm_genlist_item_class_unref (Elm_Genlist_Item_Class *itc)
void elm_genlist_item_tooltip_text_set (Elm_Object_Item *it, const char *text)
void elm_genlist_item_tooltip_content_cb_set (Elm_Object_Item *it, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
void elm_genlist_item_tooltip_unset (Elm_Object_Item *it)
void elm_genlist_item_tooltip_style_set (Elm_Object_Item *it, const char *style)
const char * elm_genlist_item_tooltip_style_get (const Elm_Object_Item *it)
void elm_genlist_item_cursor_set (Elm_Object_Item *it, const char *cursor)
const char * elm_genlist_item_cursor_get (const Elm_Object_Item *it)
void elm_genlist_item_cursor_unset (Elm_Object_Item *it)
void elm_genlist_item_cursor_style_set (Elm_Object_Item *it, const char *style)
const char * elm_genlist_item_cursor_style_get (const Elm_Object_Item *it)
void elm_genlist_item_cursor_engine_only_set (Elm_Object_Item *it, Eina_Bool engine_only)
Eina_Bool elm_genlist_item_cursor_engine_only_get (const Elm_Object_Item *it)
Evas_Objectelm_genlist_add (Evas_Object *parent)

Function Documentation

Add a new genlist widget to the given parent Elementary (container) object

Parameters:
parentThe parent object
Returns:
a new genlist widget handle or NULL, on errors

This function inserts a new genlist widget on the canvas.

See also:
elm_genlist_item_append()
elm_object_item_del()
elm_genlist_clear()
Since :
2.3
Examples:
genlist_example_01.c, genlist_example_02.c, genlist_example_03.c, genlist_example_04.c, and genlist_example_05.c.
EINA_DEPRECATED void elm_genlist_bounce_get ( const Evas_Object obj,
Eina_Bool h_bounce,
Eina_Bool v_bounce 
)

Get whether the horizontal and vertical bouncing effect is enabled.

Parameters:
objThe genlist object
h_bouncePointer to a bool to receive if the bounce horizontally option is set.
v_bouncePointer to a bool to receive if the bounce vertically option is set.
Deprecated:
Use elm_scroller_bounce_get() instead.
See also:
elm_scroller_bounce_get()
elm_genlist_bounce_set()
EINA_DEPRECATED void elm_genlist_bounce_set ( Evas_Object obj,
Eina_Bool  h_bounce,
Eina_Bool  v_bounce 
)

Enable/disable horizontal and vertical bouncing effect.

Parameters:
objThe genlist object
h_bounceAllow bounce horizontally (EINA_TRUE = on, EINA_FALSE = off). Default is EINA_FALSE.
v_bounceAllow bounce vertically (EINA_TRUE = on, EINA_FALSE = off). Default is EINA_TRUE.

This will enable or disable the scroller bouncing effect for the genlist. See elm_scroller_bounce_set() for details.

Deprecated:
Use elm_scroller_bounce_set() instead.
See also:
elm_scroller_bounce_set()
elm_genlist_bounce_get()

Remove an item class in a given genlist widget.

Parameters:
itcThe itc to be removed.

This removes item class from the genlist widget. Whenever it has no more references to it, item class is going to be freed. Otherwise it just decreases its reference count.

See also:
elm_genlist_item_class_new()
elm_genlist_item_class_ref()
elm_genlist_item_class_unref()
Since :
2.3

Create a new genlist item class in a given genlist widget.

Returns:
New allocated genlist item class.

This adds genlist item class for the genlist widget. When adding an item, genlist_item_{append, prepend, insert} function needs item class of the item. Given callback parameters are used at retrieving {text, content} of added item. Set as NULL if it's not used. If there's no available memory, return can be NULL.

See also:
elm_genlist_item_class_free()
elm_genlist_item_append()
Since :
2.3
Examples:
combobox_example_01.c, genlist_example_01.c, genlist_example_02.c, genlist_example_03.c, genlist_example_04.c, and genlist_example_05.c.

Increments object reference count for the item class.

Parameters:
itcThe given item class object to reference

This API just increases its reference count for item class management.

See also:
elm_genlist_item_class_unref()
Since :
2.3

Decrements object reference count for the item class.

Parameters:
itcThe given item class object to reference

This API just decreases its reference count for item class management. Reference count can't be less than 0.

See also:
elm_genlist_item_class_ref()
elm_genlist_item_class_free()
Since :
2.3

Get if the (custom) cursor for a given genlist item is being searched in its theme, also, or is only relying on the rendering engine.

Parameters:
ita genlist item
Returns:
EINA_TRUE, if cursors are being looked for only on those provided by the rendering engine, EINA_FALSE if they are being searched on the widget's theme, as well.
See also:
elm_genlist_item_cursor_engine_only_set(), for more details
Since :
2.3

Set if the (custom) cursor for a given genlist item should be searched in its theme, also, or should only rely on the rendering engine.

Parameters:
ititem with custom (custom) cursor already set on
engine_onlyUse EINA_TRUE to have cursors looked for only on those provided by the rendering engine, EINA_FALSE to have them searched on the widget's theme, as well.
Note:
This call is of use only if you've set a custom cursor for genlist items, with elm_genlist_item_cursor_set().
By default, cursors will only be looked for between those provided by the rendering engine.
Since :
2.3
const char* elm_genlist_item_cursor_get ( const Elm_Object_Item it)

Get the type of mouse pointer/cursor decoration set to be shown, when the mouse pointer is over the given genlist widget item

Parameters:
itgenlist item with custom cursor set
Returns:
the cursor type's name or NULL, if no custom cursors were set to item (and on errors)
See also:
elm_object_cursor_get()
elm_genlist_item_cursor_set() for more details
elm_genlist_item_cursor_unset()
Since :
2.3
void elm_genlist_item_cursor_set ( Elm_Object_Item it,
const char *  cursor 
)

Set the type of mouse pointer/cursor decoration to be shown, when the mouse pointer is over the given genlist widget item

Parameters:
itgenlist item to customize cursor on
cursorthe cursor type's name

This function works analogously as elm_object_cursor_set(), but here the cursor's changing area is restricted to the item's area, and not the whole widget's. Note that that item cursors have precedence over widget cursors, so that a mouse over item will always show cursor type.

If this function is called twice for an object, a previously set cursor will be unset on the second call.

See also:
elm_object_cursor_set()
elm_genlist_item_cursor_get()
elm_genlist_item_cursor_unset()
Since :
2.3

Get the current style set for a given genlist item's custom cursor

Parameters:
itgenlist item with custom cursor set.
Returns:
style the cursor style in use. If the object does not have a cursor set, then NULL is returned.
See also:
elm_genlist_item_cursor_style_set() for more details
Since :
2.3
void elm_genlist_item_cursor_style_set ( Elm_Object_Item it,
const char *  style 
)

Set a different style for a given custom cursor set for a genlist item.

Parameters:
itgenlist item with custom cursor set
stylethe theme style to use (e.g. "default", "transparent", etc)

This function only makes sense when one is using custom mouse cursor decorations defined in a theme file , which can have, given a cursor name/type, alternate styles on it. It works analogously as elm_object_cursor_style_set(), but here applied only to genlist item objects.

Warning:
Before you set a cursor style you should have defined a custom cursor previously on the item, with elm_genlist_item_cursor_set()
See also:
elm_genlist_item_cursor_engine_only_set()
elm_genlist_item_cursor_style_get()
Since :
2.3

Unset any custom mouse pointer/cursor decoration set to be shown, when the mouse pointer is over the given genlist widget item, thus making it show the default cursor again.

Parameters:
ita genlist item

Use this call to undo any custom settings on this item's cursor decoration, bringing it back to defaults (no custom style set).

See also:
elm_object_cursor_unset()
elm_genlist_item_cursor_set() for more details
Since :
2.3
void elm_genlist_item_tooltip_content_cb_set ( Elm_Object_Item it,
Elm_Tooltip_Item_Content_Cb  func,
const void *  data,
Evas_Smart_Cb  del_cb 
)

Set the content to be shown in a given genlist item's tooltips

Parameters:
itThe genlist item.
funcThe function returning the tooltip contents.
dataWhat to provide to func as callback data/context.
del_cbCalled when data is not needed anymore, either when another callback replaces func, the tooltip is unset with elm_genlist_item_tooltip_unset() or the owner item dies. This callback receives as its first parameter the given data, being event_info the item handle.

This call will setup the tooltip's contents to item (analogous to elm_object_tooltip_content_cb_set(), but being item tooltips with higher precedence than object tooltips). It can have only one tooltip at a time, so any previous tooltip content will get removed. func (with data) will be called every time Elementary needs to show the tooltip and it should return a valid Evas object, which will be fully managed by the tooltip system, getting deleted when the tooltip is gone.

In order to set just a text as a tooltip, look at elm_genlist_item_tooltip_text_set().

Since :
2.3

Get the style set a given genlist item's tooltip.

Parameters:
itgenlist item with tooltip already set on.
Returns:
style the theme style in use, which defaults to "default". If the object does not have a tooltip set, then NULL is returned.
See also:
elm_genlist_item_tooltip_style_set() for more details
Since :
2.3
void elm_genlist_item_tooltip_style_set ( Elm_Object_Item it,
const char *  style 
)

Set a different style for a given genlist item's tooltip.

Parameters:
itgenlist item with tooltip set
stylethe theme style to use on tooltips (e.g. "default", "transparent", etc)

Tooltips can have alternate styles to be displayed on, which are defined by the theme set on Elementary. This function works analogously as elm_object_tooltip_style_set(), but here applied only to genlist item objects. The default style for tooltips is "default".

Note:
before you set a style you should define a tooltip with elm_genlist_item_tooltip_content_cb_set() or elm_genlist_item_tooltip_text_set()
See also:
elm_genlist_item_tooltip_style_get()
Since :
2.3
void elm_genlist_item_tooltip_text_set ( Elm_Object_Item it,
const char *  text 
)

Set the text to be shown in a given genlist item's tooltips.

Parameters:
itThe genlist item
textThe text to set in the content

This call will setup the text to be used as tooltip to that item (analogous to elm_object_tooltip_text_set(), but being item tooltips with higher precedence than object tooltips). It can have only one tooltip at a time, so any previous tooltip data will get removed.

In order to set a content or something else as a tooltip, look at elm_genlist_item_tooltip_content_cb_set().

Since :
2.3

Unset a tooltip from a given genlist item

Parameters:
itgenlist item to remove a previously set tooltip from.

This call removes any tooltip set on item. The callback provided as del_cb to elm_genlist_item_tooltip_content_cb_set() will be called to notify it is not used anymore (and have resources cleaned, if need be).

See also:
elm_genlist_item_tooltip_content_cb_set()
Since :
2.3

Get the scrollbar policy

Parameters:
objThe genlist object
policy_hPointer to store the horizontal scrollbar policy.
policy_vPointer to store the vertical scrollbar policy.
Deprecated:
Use elm_scroller_policy_get() instead.
See also:
elm_scroller_policy_get()

Set the scrollbar policy

Parameters:
objThe genlist object
policy_hHorizontal scrollbar policy.
policy_vVertical scrollbar policy.

This sets the scrollbar visibility policy for the given genlist scroller. ELM_SCROLLER_POLICY_AUTO means the scrollbar is made visible if it is needed, and otherwise kept hidden. ELM_SCROLLER_POLICY_ON turns it on all the time, and ELM_SCROLLER_POLICY_OFF always keeps it off. This applies respectively for the horizontal and vertical scrollbars. Default is ELM_SCROLLER_POLICY_AUTO

Deprecated:
Use elm_scroller_policy_set() instead.
See also:
elm_scroller_policy_set()