- Elementary
- Main
- Authors
- Examples
- Files
- Pages
- Types
- Modules

Diskselector widget example

This code places 4 Elementary diskselector widgets on a window, each of them exemplifying a part of the widget's API.

All of them will have weekdays as items, since we won't focus on items management on this example. For an example about this subject, check Diskselector - Items management.

The first of them is a default diskselector.

static const char *lbl[] =
{
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};
ds = elm_diskselector_add(win);
evas_object_size_hint_weight_set(ds, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ds, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, ds);
for (i = 0; i < sizeof(lbl) / sizeof(lbl[0]); i++)
elm_diskselector_item_append(ds, lbl[i], NULL, NULL, NULL);
evas_object_show(ds);

We are just adding the diskselector, so as you can see, defaults for it are:

- Only 3 items visible each time.
- Only 3 characters are displayed for labels on side positions.
- The first added item remains centeres, i.e., it's the selected item.

To add items, we are just appending it on a loop, using function elm_diskselector_item_append(), that will be better explained on items management example.

For a circular diskselector, check the second widget. A circular diskselector will display first item after last, and last previous to the first one. So, as you can see, Sa will appears on left side of selected Sunday. This property is set with elm_diskselector_round_enabled_set().

Also, we decide to display only 2 character for side labels, instead of 3. For this we call elm_diskselector_side_text_max_length_set(). As result, we'll see Mo displayed instead of Mon, when Monday is on a side position.

ds = elm_diskselector_add(win);
evas_object_size_hint_weight_set(ds, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ds, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, ds);
for (i = 0; i < sizeof(lbl) / sizeof(lbl[0]); i++)
elm_diskselector_item_append(ds, lbl[i], NULL, NULL, NULL);
elm_diskselector_round_enabled_set(ds, EINA_TRUE);
elm_diskselector_side_text_max_length_set(ds, 2);
evas_object_show(ds);

But so far, we are only displaying 3 items at once. If more are wanted, is enough to call elm_diskselector_display_item_num_set(), as you can see here:

ds = elm_diskselector_add(win);
evas_object_size_hint_weight_set(ds, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ds, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, ds);
for (i = 0; i < sizeof(lbl) / sizeof(lbl[0]); i++)
elm_diskselector_item_append(ds, lbl[i], NULL, NULL, NULL);
elm_diskselector_display_item_num_set(ds, 5);

Note
  You can't set less than 3 items to be displayed.

You can get the number of items in the diskselector by calling elm_diskselector_display_item_num_get(), as you can see here:

printf("Number of Items in DiskSelector : %d\n", elm_diskselector_display_item_num_get(ds));

Finally, if a bounce effect is required, or you would like to see scrollbars, it is possible. But, for default theme, diskselector scrollbars will be invisible anyway.

ds = elm_diskselector_add(win);
evas_object_size_hint_weight_set(ds, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ds, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, ds);
for (i = 0; i < sizeof(lbl) / sizeof(lbl[0]); i++)
elm_diskselector_item_append(ds, lbl[i], NULL, NULL, NULL);
elm_scroller_bounce_set(ds, EINA_TRUE, EINA_TRUE);
elm_scroller_policy_set(ds, ELM_SCROLLER_POLICY_AUTO,
ELM_SCROLLER_POLICY_ON);
evas_object_show(ds);

See the full diskselector_example_01.c code, whose window should look like this picture:

Copyright ©2000-2014 Enlightenment.org - Samsung Electronics supports the EFL Documentation Project - Generated Wed Jan 8 2014 20:51:07