This code places a single Elementary list widgets on a window, exemplifying a part of the widget's API.
First, we will just create a simple list, as done on List widget example :
static const char *lbl[] =
{
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};
Evas_Object * elm_list_add(Evas_Object *parent)
Add a new list widget to the given parent Elementary (container) object.
Definition: elm_list.c:2513
for (i = 0; i < sizeof(lbl) / sizeof(lbl[0]); i++)
#define EVAS_HINT_EXPAND
Use with evas_object_size_hint_weight_set(), evas_object_size_hint_weight_get(), evas_object_size_hin...
Definition: Evas_Common.h:297
Elm_Widget_Item * elm_list_item_append(Elm_List *obj, const char *label, Efl_Canvas_Object *icon, Efl_Canvas_Object *end, Evas_Smart_Cb func, const void *data)
Append a new item to the list object.
Definition: elm_list_eo.legacy.c:129
void elm_win_resize_object_add(Eo *obj, Evas_Object *subobj)
Add subobj as a resize object of window obj.
Definition: efl_ui_win.c:8997
EVAS_API void evas_object_size_hint_weight_set(Evas_Object *obj, double x, double y)
Sets the hints for an object's weight.
Definition: evas_object_main.c:2638
Now, let's customize this list a bit. First we will display items horizontally:
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition: eina_types.h:539
void elm_list_horizontal_set(Elm_List *obj, Eina_Bool horizontal)
Control horizontal mode on the list object.
Definition: elm_list_eo.legacy.c:3
Then we will choose another list mode. There are four of them, and the default Elm_List_Mode is ELM_LIST_SCROLL. Let's set compress mode:
@ ELM_LIST_COMPRESS
The list won't set any of its size hints to inform how a possible container should resize it.
Definition: elm_general.h:432
void elm_list_mode_set(Elm_List *obj, Elm_List_Mode mode)
Control which mode to use for the list object.
Definition: elm_list_eo.legacy.c:63
To enable multiple items selection, we need to enable it, since only one selected item is allowed by default:
void elm_list_multi_select_set(Elm_List *obj, Eina_Bool multi)
Control multiple items selection on the list object.
Definition: elm_list_eo.legacy.c:39
We are not adding items with callback functions here, since we'll explain it better on List - Items management. But if the callback need to be called everytime user clicks an item, even if already selected, it's required to enable this behavior:
@ ELM_OBJECT_SELECT_MODE_ALWAYS
always select mode.
Definition: elm_general.h:39
void elm_list_select_mode_set(Elm_List *obj, Elm_Object_Select_Mode mode)
Control the list select mode.
Definition: elm_list_eo.legacy.c:15
Finally, if a bounce effect is required, or you would like to see scrollbars, it is possible. But, for default theme, list scrollbars will be invisible anyway.
See the full list_example_02.c code, whose window should look like this picture: