summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--data/themes/default.edc3
-rw-r--r--src/bin/test_diskselector.c45
-rw-r--r--src/lib/Elementary.h.in1
-rw-r--r--src/lib/elm_diskselector.c242
5 files changed, 274 insertions, 18 deletions
diff --git a/AUTHORS b/AUTHORS
index 469cf70c7..25a2683db 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -37,3 +37,4 @@ Jeonghyun Yun (arosis) <jh0506.yun@samsung.com>
37Tom Hacohen <tom@stosb.com> 37Tom Hacohen <tom@stosb.com>
38Aharon Hillel <a.hillel@partner.samsung.com> 38Aharon Hillel <a.hillel@partner.samsung.com>
39Jonathan Atton (Watchwolf) <jonathan.atton@gmail.com> 39Jonathan Atton (Watchwolf) <jonathan.atton@gmail.com>
40Shinwoo Kim <kimcinoo@gmail.com>
diff --git a/data/themes/default.edc b/data/themes/default.edc
index 9b39798db..497018e2b 100644
--- a/data/themes/default.edc
+++ b/data/themes/default.edc
@@ -35072,6 +35072,9 @@ collections {
35072 35072
35073 data { 35073 data {
35074 item: "len_threshold" "14"; 35074 item: "len_threshold" "14";
35075 item: "display_item_num" "3";
35076 item: "min_height" "-1";
35077 item: "min_width" "-1";
35075 } 35078 }
35076 35079
35077 parts { 35080 parts {
diff --git a/src/bin/test_diskselector.c b/src/bin/test_diskselector.c
index 9312c2b31..02715670f 100644
--- a/src/bin/test_diskselector.c
+++ b/src/bin/test_diskselector.c
@@ -61,6 +61,15 @@ test_diskselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
61 Evas_Object *win, *bg, *bx, *disk, *ic; 61 Evas_Object *win, *bg, *bx, *disk, *ic;
62 Elm_Diskselector_Item *it; 62 Elm_Diskselector_Item *it;
63 char buf[PATH_MAX]; 63 char buf[PATH_MAX];
64 int idx = 0;
65
66 char *month_list[] = {
67 "Jan", "Feb", "Mar",
68 "Apr", "May", "Jun",
69 "Jul", "Aug", "Sep",
70 "Oct", "Nov", "Dec"
71 };
72 char date[3];
64 73
65 win = elm_win_add(NULL, "diskselector", ELM_WIN_BASIC); 74 win = elm_win_add(NULL, "diskselector", ELM_WIN_BASIC);
66 elm_win_title_set(win, "Disk Selector"); 75 elm_win_title_set(win, "Disk Selector");
@@ -124,6 +133,42 @@ test_diskselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
124 evas_object_show(disk); 133 evas_object_show(disk);
125 evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL); 134 evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
126 135
136 // displayed item number setting example
137 disk = elm_diskselector_add(win);
138 elm_diskselector_display_item_num_set(disk, 5);
139
140 for (idx = 0; idx < (sizeof(month_list) / sizeof(month_list[0])); idx++)
141 {
142 it = elm_diskselector_item_append(disk, month_list[idx], NULL, NULL, NULL);
143 }
144
145 elm_diskselector_item_selected_set(it, EINA_TRUE);
146 elm_diskselector_round_set(disk, EINA_TRUE);
147 evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
148 evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
149 elm_box_pack_end(bx, disk);
150 evas_object_show(disk);
151 evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
152
153 // displayed item number setting example
154 disk = elm_diskselector_add(win);
155 elm_diskselector_display_item_num_set(disk, 7);
156
157 for (idx = 1; idx < 31; idx++)
158 {
159 snprintf(date, sizeof(date), "%d", idx);
160 it = elm_diskselector_item_append(disk, date, NULL, NULL, NULL);
161 }
162
163 elm_diskselector_item_selected_set(it, EINA_TRUE);
164 elm_diskselector_round_set(disk, EINA_TRUE);
165 evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
166 evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
167 elm_box_pack_end(bx, disk);
168 evas_object_show(disk);
169 evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
170
171
127 evas_object_resize(win, 320, 480); 172 evas_object_resize(win, 320, 480);
128 evas_object_show(win); 173 evas_object_show(win);
129} 174}
diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in
index e4c3ca5d1..b3171c459 100644
--- a/src/lib/Elementary.h.in
+++ b/src/lib/Elementary.h.in
@@ -2552,6 +2552,7 @@ extern "C" {
2552 EAPI const char *elm_diskselector_item_cursor_style_get(const Elm_Diskselector_Item *item) EINA_ARG_NONNULL(1); 2552 EAPI const char *elm_diskselector_item_cursor_style_get(const Elm_Diskselector_Item *item) EINA_ARG_NONNULL(1);
2553 EAPI void elm_diskselector_item_cursor_engine_only_set(Elm_Diskselector_Item *item, Eina_Bool engine_only) EINA_ARG_NONNULL(1); 2553 EAPI void elm_diskselector_item_cursor_engine_only_set(Elm_Diskselector_Item *item, Eina_Bool engine_only) EINA_ARG_NONNULL(1);
2554 EAPI Eina_Bool elm_diskselector_item_cursor_engine_only_get(const Elm_Diskselector_Item *item) EINA_ARG_NONNULL(1); 2554 EAPI Eina_Bool elm_diskselector_item_cursor_engine_only_get(const Elm_Diskselector_Item *item) EINA_ARG_NONNULL(1);
2555 EAPI void elm_diskselector_display_item_num_set(Evas_Object *obj, int num) EINA_ARG_NONNULL(1);
2555 /* smart callbacks called: 2556 /* smart callbacks called:
2556 * "selected" - when item is selected (scroller stops) 2557 * "selected" - when item is selected (scroller stops)
2557 */ 2558 */
diff --git a/src/lib/elm_diskselector.c b/src/lib/elm_diskselector.c
index ed011d282..cf2a1543d 100644
--- a/src/lib/elm_diskselector.c
+++ b/src/lib/elm_diskselector.c
@@ -20,6 +20,12 @@
20# define MAX(a, b) (((a) > (b)) ? (a) : (b)) 20# define MAX(a, b) (((a) > (b)) ? (a) : (b))
21#endif 21#endif
22 22
23#ifndef CEIL
24#define CEIL(a) (((a) % 2 != 0) ? ((a) / 2 + 1) : ((a) / 2))
25#endif
26
27#define DISPLAY_ITEM_NUM_MIN 3
28
23typedef struct _Widget_Data Widget_Data; 29typedef struct _Widget_Data Widget_Data;
24 30
25struct _Widget_Data 31struct _Widget_Data
@@ -36,11 +42,15 @@ struct _Widget_Data
36 Elm_Diskselector_Item *last; 42 Elm_Diskselector_Item *last;
37 Eina_List *items; 43 Eina_List *items;
38 Eina_List *r_items; 44 Eina_List *r_items;
39 int item_count, len_threshold, len_side; 45 Eina_List *over_items;
46 Eina_List *under_items;
47 int item_count, len_threshold, len_side, display_item_num;
40 Ecore_Idler *idler; 48 Ecore_Idler *idler;
41 Ecore_Idler *check_idler; 49 Ecore_Idler *check_idler;
50 Evas_Coord minw, minh;
42 Eina_Bool init:1; 51 Eina_Bool init:1;
43 Eina_Bool round:1; 52 Eina_Bool round:1;
53 Eina_Bool display_item_num_by_api:1;
44}; 54};
45 55
46struct _Elm_Diskselector_Item 56struct _Elm_Diskselector_Item
@@ -68,6 +78,10 @@ static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_T
68static void _sub_del(void *data, Evas_Object * obj, void *event_info); 78static void _sub_del(void *data, Evas_Object * obj, void *event_info);
69static void _round_items_del(Widget_Data *wd); 79static void _round_items_del(Widget_Data *wd);
70static void _scroller_move_cb(void *data, Evas_Object *obj, void *event_info); 80static void _scroller_move_cb(void *data, Evas_Object *obj, void *event_info);
81static void _item_click_cb(void *data, Evas_Object *obj __UNUSED__,
82 const char *emission __UNUSED__,
83 const char *source __UNUSED__);
84static void _selected_item_indicate(Elm_Diskselector_Item *it);
71 85
72static const char SIG_SELECTED[] = "selected"; 86static const char SIG_SELECTED[] = "selected";
73static const Evas_Smart_Cb_Description _signals[] = { 87static const Evas_Smart_Cb_Description _signals[] = {
@@ -79,25 +93,25 @@ static void
79_diskselector_object_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) 93_diskselector_object_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
80{ 94{
81 Widget_Data *wd; 95 Widget_Data *wd;
82 Evas_Coord w, h, minw = -1, minh = -1; 96 Evas_Coord w, h;
83 97
84 wd = elm_widget_data_get(data); 98 wd = elm_widget_data_get(data);
85 if (!wd) return; 99 if (!wd) return;
86 100
87 elm_coords_finger_size_adjust(6, &minw, 1, &minh); 101 if (wd->minw == -1 && wd->minh == -1) elm_coords_finger_size_adjust(6, &wd->minw, 1, &wd->minh);
88 edje_object_size_min_restricted_calc(elm_smart_scroller_edje_object_get( 102 edje_object_size_min_restricted_calc(elm_smart_scroller_edje_object_get(
89 wd->scroller), &minw, &minh, minw, minh); 103 wd->scroller), &wd->minw, &wd->minh, wd->minw, wd->minh);
90 evas_object_size_hint_min_set(obj, minw, minh); 104 evas_object_size_hint_min_set(obj, wd->minw, wd->minh);
91 evas_object_size_hint_max_set(obj, -1, -1); 105 evas_object_size_hint_max_set(obj, -1, -1);
92 106
93 evas_object_geometry_get(wd->scroller, NULL, NULL, &w, &h); 107 evas_object_geometry_get(wd->scroller, NULL, NULL, &w, &h);
94 if (wd->round) 108 if (wd->round)
95 evas_object_resize(wd->main_box, w / 3 * (wd->item_count + 4), h); 109 evas_object_resize(wd->main_box, (w / wd->display_item_num) * (wd->item_count + (CEIL(wd->display_item_num) * 2)), h);
96 else 110 else
97 evas_object_resize(wd->main_box, w / 3 * (wd->item_count + 2), h); 111 evas_object_resize(wd->main_box, (w / wd->display_item_num) * (wd->item_count + CEIL(wd->display_item_num)), h);
98 112
99 elm_smart_scroller_paging_set(wd->scroller, 0, 0, 113 elm_smart_scroller_paging_set(wd->scroller, 0, 0,
100 (int)(w / 3), 0); 114 (int)(w / wd->display_item_num), 0);
101 115
102 if (!wd->idler) 116 if (!wd->idler)
103 wd->idler = ecore_idler_add(_move_scroller, data); 117 wd->idler = ecore_idler_add(_move_scroller, data);
@@ -125,7 +139,10 @@ _item_new(Evas_Object *obj, Evas_Object *icon, const char *label, Evas_Smart_Cb
125 evas_object_show(it->base.view); 139 evas_object_show(it->base.view);
126 140
127 if (it->label) 141 if (it->label)
128 edje_object_part_text_set(it->base.view, "elm.text", it->label); 142 {
143 edje_object_part_text_set(it->base.view, "elm.text", it->label);
144 edje_object_signal_callback_add(it->base.view, "elm,action,click", "", _item_click_cb, it);
145 }
129 if (it->icon) 146 if (it->icon)
130 { 147 {
131 evas_object_size_hint_min_set(it->icon, 24, 24); 148 evas_object_size_hint_min_set(it->icon, 24, 24);
@@ -152,8 +169,32 @@ _theme_data_get(Widget_Data *wd)
152{ 169{
153 const char* str; 170 const char* str;
154 str = edje_object_data_get(wd->right_blank, "len_threshold"); 171 str = edje_object_data_get(wd->right_blank, "len_threshold");
155 if (str) wd->len_threshold = atoi(str); 172 if (str) wd->len_threshold = MAX(0, atoi(str));
156 else wd->len_threshold = 0; 173 else wd->len_threshold = 0;
174
175 if (!wd->display_item_num_by_api)
176 {
177 str = edje_object_data_get(wd->right_blank, "display_item_num");
178 if (str) wd->display_item_num = MAX(DISPLAY_ITEM_NUM_MIN, atoi(str));
179 else wd->display_item_num = DISPLAY_ITEM_NUM_MIN;
180 }
181
182 str = edje_object_data_get(wd->right_blank, "min_width");
183 if (str) wd->minw = MAX(-1, atoi(str));
184 else wd->minw = -1;
185
186 str = edje_object_data_get(wd->right_blank, "min_height");
187 if (str) wd->minh = MAX(-1, atoi(str));
188 else wd->minh = -1;
189}
190
191static void
192_default_display_item_num_set(Widget_Data *wd)
193{
194 const char* str;
195 str = edje_object_data_get(wd->right_blank, "display_item_num");
196 if (str) wd->display_item_num = MAX(DISPLAY_ITEM_NUM_MIN, atoi(str));
197 else wd->display_item_num = DISPLAY_ITEM_NUM_MIN;
157} 198}
158 199
159static void 200static void
@@ -168,6 +209,8 @@ static void
168_del_pre_hook(Evas_Object * obj) 209_del_pre_hook(Evas_Object * obj)
169{ 210{
170 Elm_Diskselector_Item *it; 211 Elm_Diskselector_Item *it;
212 Eina_List *l;
213
171 Widget_Data *wd = elm_widget_data_get(obj); 214 Widget_Data *wd = elm_widget_data_get(obj);
172 if (!wd) return; 215 if (!wd) return;
173 216
@@ -200,6 +243,26 @@ _del_pre_hook(Evas_Object * obj)
200 free(wd->first); 243 free(wd->first);
201 } 244 }
202 245
246 EINA_LIST_FOREACH(wd->under_items, l, it)
247 {
248 if (it)
249 {
250 eina_stringshare_del(it->label);
251 evas_object_del(wd->first->base.view);
252 free(it);
253 }
254 }
255
256 EINA_LIST_FOREACH(wd->over_items, l, it)
257 {
258 if (it)
259 {
260 eina_stringshare_del(it->label);
261 evas_object_del(wd->first->base.view);
262 free(it);
263 }
264 }
265
203 EINA_LIST_FREE(wd->items, it) _item_del(it); 266 EINA_LIST_FREE(wd->items, it) _item_del(it);
204 eina_list_free(wd->r_items); 267 eina_list_free(wd->r_items);
205} 268}
@@ -239,6 +302,8 @@ _theme_hook(Evas_Object * obj)
239 elm_widget_style_get(obj)); 302 elm_widget_style_get(obj));
240 } 303 }
241 } 304 }
305 _elm_theme_object_set(obj, wd->right_blank, "diskselector", "item",
306 elm_widget_style_get(obj));
242 _theme_data_get(wd); 307 _theme_data_get(wd);
243 _sizing_eval(obj); 308 _sizing_eval(obj);
244} 309}
@@ -275,6 +340,7 @@ _select_item(Elm_Diskselector_Item *it)
275 if (!it) return; 340 if (!it) return;
276 Widget_Data *wd = elm_widget_data_get(it->base.widget); 341 Widget_Data *wd = elm_widget_data_get(it->base.widget);
277 wd->selected_item = it; 342 wd->selected_item = it;
343 _selected_item_indicate(wd->selected_item);
278 if (it->func) it->func((void *)it->base.data, it->base.widget, it); 344 if (it->func) it->func((void *)it->base.data, it->base.widget, it);
279 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it); 345 evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
280} 346}
@@ -439,6 +505,46 @@ _check_string(void *data)
439} 505}
440 506
441static void 507static void
508_selected_item_indicate(Elm_Diskselector_Item *it)
509{
510 Elm_Diskselector_Item *item;
511 Eina_List *l;
512 Widget_Data *wd;
513 wd = elm_widget_data_get(it->base.widget);
514
515 if (!wd) return;
516
517 EINA_LIST_FOREACH(wd->r_items, l, item)
518 {
519 if (!strcmp(item->label, it->label)) edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
520 else
521 edje_object_signal_emit(item->base.view, "elm,state,default", "elm");
522 }
523}
524
525static void
526_item_click_cb(void *data, Evas_Object *obj __UNUSED__,
527 const char *emission __UNUSED__, const char *source __UNUSED__)
528{
529 Elm_Diskselector_Item *it = data;
530
531 if (!it) return;
532
533 Widget_Data *wd;
534 wd = elm_widget_data_get(it->base.widget);
535
536 if (!wd) return;
537
538 if (wd->selected_item != it)
539 {
540 wd->selected_item = it;
541 _selected_item_indicate(wd->selected_item);
542 }
543
544 if (it->func) it->func((void *)it->base.data, it->base.widget, it);
545}
546
547static void
442_scroller_move_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 548_scroller_move_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
443{ 549{
444 Evas_Coord x, y, w, h, bw; 550 Evas_Coord x, y, w, h, bw;
@@ -450,13 +556,13 @@ _scroller_move_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UN
450 if (wd->round) 556 if (wd->round)
451 { 557 {
452 evas_object_geometry_get(wd->main_box, NULL, NULL, &bw, NULL); 558 evas_object_geometry_get(wd->main_box, NULL, NULL, &bw, NULL);
453 if (x > w / 3 * (wd->item_count + 1)) 559 if (x > ((w / wd->display_item_num) * (wd->item_count + (wd->display_item_num % 2))))
454 elm_smart_scroller_child_region_show(wd->scroller, 560 elm_smart_scroller_child_region_show(wd->scroller,
455 x - w / 3 * wd->item_count, 561 x - ((w / wd->display_item_num) * wd->item_count),
456 y, w, h); 562 y, w, h);
457 else if (x < 0) 563 else if (x < 0)
458 elm_smart_scroller_child_region_show(wd->scroller, 564 elm_smart_scroller_child_region_show(wd->scroller,
459 x + w / 3 * wd->item_count, 565 x + ((w / wd->display_item_num) * wd->item_count),
460 y, w, h); 566 y, w, h);
461 } 567 }
462} 568}
@@ -523,7 +629,7 @@ _move_scroller(void *data)
523 } 629 }
524 630
525 evas_object_geometry_get(wd->scroller, NULL, &y, &w, &h); 631 evas_object_geometry_get(wd->scroller, NULL, &y, &w, &h);
526 elm_smart_scroller_child_region_show(wd->scroller, w / 3 * i, y, w, h); 632 elm_smart_scroller_child_region_show(wd->scroller, w / wd->display_item_num * i, y, w, h);
527 _select_item(dit); 633 _select_item(dit);
528 if (wd->idler) 634 if (wd->idler)
529 { 635 {
@@ -550,6 +656,9 @@ _round_item_del(Widget_Data *wd, Elm_Diskselector_Item *it)
550static void 656static void
551_round_items_del(Widget_Data *wd) 657_round_items_del(Widget_Data *wd)
552{ 658{
659 Eina_List *l;
660 Elm_Diskselector_Item * it;
661
553 _round_item_del(wd, wd->last); 662 _round_item_del(wd, wd->last);
554 wd->last = NULL; 663 wd->last = NULL;
555 _round_item_del(wd, wd->s_last); 664 _round_item_del(wd, wd->s_last);
@@ -558,6 +667,18 @@ _round_items_del(Widget_Data *wd)
558 wd->second = NULL; 667 wd->second = NULL;
559 _round_item_del(wd, wd->first); 668 _round_item_del(wd, wd->first);
560 wd->first = NULL; 669 wd->first = NULL;
670
671 EINA_LIST_FOREACH(wd->under_items, l, it)
672 {
673 _round_item_del(wd, it);
674 it = NULL;
675 }
676
677 EINA_LIST_FOREACH(wd->over_items, l, it)
678 {
679 _round_item_del(wd, it);
680 it = NULL;
681 }
561} 682}
562 683
563static void 684static void
@@ -565,7 +686,8 @@ _round_items_add(Widget_Data *wd)
565{ 686{
566 Elm_Diskselector_Item *dit; 687 Elm_Diskselector_Item *dit;
567 Elm_Diskselector_Item *it; 688 Elm_Diskselector_Item *it;
568 689 Elm_Diskselector_Item *temp_it;
690 int i = 0;
569 dit = it = eina_list_nth(wd->items, 0); 691 dit = it = eina_list_nth(wd->items, 0);
570 if (!dit) return; 692 if (!dit) return;
571 693
@@ -588,6 +710,16 @@ _round_items_add(Widget_Data *wd)
588 wd->r_items = eina_list_append(wd->r_items, wd->second); 710 wd->r_items = eina_list_append(wd->r_items, wd->second);
589 } 711 }
590 712
713 // if more than 3 itmes should be displayed
714 for (i = 2; i < CEIL(wd->display_item_num); i++)
715 {
716 it = eina_list_nth(wd->items, i);
717 if (!it) it = dit;
718 temp_it = _item_new(it->base.widget, it->icon, it->label, it->func, it->base.data);
719 wd->over_items = eina_list_append(wd->over_items, temp_it);
720 wd->r_items = eina_list_append(wd->r_items, temp_it);
721 }
722
591 it = eina_list_nth(wd->items, wd->item_count - 1); 723 it = eina_list_nth(wd->items, wd->item_count - 1);
592 if (!it) 724 if (!it)
593 it = dit; 725 it = dit;
@@ -609,6 +741,16 @@ _round_items_add(Widget_Data *wd)
609 wd->s_last->node = it->node; 741 wd->s_last->node = it->node;
610 wd->r_items = eina_list_prepend(wd->r_items, wd->s_last); 742 wd->r_items = eina_list_prepend(wd->r_items, wd->s_last);
611 } 743 }
744
745 // if more than 3 itmes should be displayed
746 for (i = 3; i <= CEIL(wd->display_item_num); i++)
747 {
748 it = eina_list_nth(wd->items, wd->item_count - i);
749 if (!it) it = dit;
750 temp_it = _item_new(it->base.widget, it->icon, it->label, it->func, it->base.data);
751 wd->under_items = eina_list_append(wd->under_items, temp_it);
752 wd->r_items = eina_list_prepend(wd->r_items, temp_it);
753 }
612} 754}
613 755
614/** 756/**
@@ -644,6 +786,7 @@ elm_diskselector_add(Evas_Object *parent)
644 wd->round = EINA_FALSE; 786 wd->round = EINA_FALSE;
645 wd->init = EINA_FALSE; 787 wd->init = EINA_FALSE;
646 wd->len_side = 3; 788 wd->len_side = 3;
789 wd->display_item_num_by_api = EINA_FALSE;
647 790
648 wd->scroller = elm_smart_scroller_add(e); 791 wd->scroller = elm_smart_scroller_add(e);
649 elm_smart_scroller_widget_set(wd->scroller, obj); 792 elm_smart_scroller_widget_set(wd->scroller, obj);
@@ -736,6 +879,9 @@ elm_diskselector_round_get(const Evas_Object *obj)
736EAPI void 879EAPI void
737elm_diskselector_round_set(Evas_Object * obj, Eina_Bool round) 880elm_diskselector_round_set(Evas_Object * obj, Eina_Bool round)
738{ 881{
882 Eina_List *elist;
883 Elm_Diskselector_Item *it;
884
739 ELM_CHECK_WIDTYPE(obj, widtype); 885 ELM_CHECK_WIDTYPE(obj, widtype);
740 Widget_Data *wd = elm_widget_data_get(obj); 886 Widget_Data *wd = elm_widget_data_get(obj);
741 if (!wd) return; 887 if (!wd) return;
@@ -760,10 +906,19 @@ elm_diskselector_round_set(Evas_Object * obj, Eina_Bool round)
760 elm_box_pack_start(wd->main_box, wd->last->base.view); 906 elm_box_pack_start(wd->main_box, wd->last->base.view);
761 if (wd->s_last) 907 if (wd->s_last)
762 elm_box_pack_start(wd->main_box, wd->s_last->base.view); 908 elm_box_pack_start(wd->main_box, wd->s_last->base.view);
909
910 // if more than 3 items should be displayed
911 EINA_LIST_FOREACH(wd->under_items, elist, it)
912 elm_box_pack_start(wd->main_box, it->base.view);
913
763 if (wd->first) 914 if (wd->first)
764 elm_box_pack_end(wd->main_box, wd->first->base.view); 915 elm_box_pack_end(wd->main_box, wd->first->base.view);
765 if (wd->second) 916 if (wd->second)
766 elm_box_pack_end(wd->main_box, wd->second->base.view); 917 elm_box_pack_end(wd->main_box, wd->second->base.view);
918
919 // if more than 3 items should be displayed
920 EINA_LIST_FOREACH(wd->over_items, elist, it)
921 elm_box_pack_end(wd->main_box, it->base.view);
767 } 922 }
768 else 923 else
769 { 924 {
@@ -773,6 +928,8 @@ elm_diskselector_round_set(Evas_Object * obj, Eina_Bool round)
773 eina_list_free(wd->r_items); 928 eina_list_free(wd->r_items);
774 wd->r_items = NULL; 929 wd->r_items = NULL;
775 } 930 }
931
932 _selected_item_indicate(wd->selected_item);
776 _sizing_eval(obj); 933 _sizing_eval(obj);
777} 934}
778 935
@@ -1015,6 +1172,9 @@ elm_diskselector_item_del(Elm_Diskselector_Item * it)
1015{ 1172{
1016 ELM_DISKSELECTOR_ITEM_CHECK_OR_RETURN(it); 1173 ELM_DISKSELECTOR_ITEM_CHECK_OR_RETURN(it);
1017 Elm_Diskselector_Item *dit; 1174 Elm_Diskselector_Item *dit;
1175 Elm_Diskselector_Item *item;
1176 Eina_List *l;
1177 int i = 0;
1018 Widget_Data *wd = elm_widget_data_get(it->base.widget); 1178 Widget_Data *wd = elm_widget_data_get(it->base.widget);
1019 if (!wd) return; 1179 if (!wd) return;
1020 1180
@@ -1032,6 +1192,8 @@ elm_diskselector_item_del(Elm_Diskselector_Item * it)
1032 wd->selected_item = dit; 1192 wd->selected_item = dit;
1033 else 1193 else
1034 wd->selected_item = eina_list_nth(wd->items, 1); 1194 wd->selected_item = eina_list_nth(wd->items, 1);
1195
1196 _selected_item_indicate(wd->selected_item);
1035 } 1197 }
1036 1198
1037 _item_del(it); 1199 _item_del(it);
@@ -1045,6 +1207,12 @@ elm_diskselector_item_del(Elm_Diskselector_Item * it)
1045 evas_object_hide(wd->second->base.view); 1207 evas_object_hide(wd->second->base.view);
1046 evas_object_hide(wd->last->base.view); 1208 evas_object_hide(wd->last->base.view);
1047 evas_object_hide(wd->s_last->base.view); 1209 evas_object_hide(wd->s_last->base.view);
1210
1211 EINA_LIST_FOREACH(wd->under_items, l, item)
1212 evas_object_hide(item->base.view);
1213
1214 EINA_LIST_FOREACH(wd->over_items, l, item)
1215 evas_object_hide(item->base.view);
1048 } 1216 }
1049 else 1217 else
1050 { 1218 {
@@ -1062,6 +1230,15 @@ elm_diskselector_item_del(Elm_Diskselector_Item * it)
1062 edje_object_part_text_set(wd->second->base.view, "elm.text", 1230 edje_object_part_text_set(wd->second->base.view, "elm.text",
1063 wd->second->label); 1231 wd->second->label);
1064 } 1232 }
1233 // if more than 3 itmes should be displayed
1234 for (i = 2; i < CEIL(wd->display_item_num); i++)
1235 {
1236 dit = eina_list_nth(wd->items, i);
1237 item = eina_list_nth(wd->over_items, i - 2);
1238 eina_stringshare_replace(&item->label, dit->label);
1239 edje_object_part_text_set(item->base.view, "elm.text", item->label);
1240 }
1241
1065 dit = eina_list_nth(wd->items, eina_list_count(wd->items) - 1); 1242 dit = eina_list_nth(wd->items, eina_list_count(wd->items) - 1);
1066 if (dit) 1243 if (dit)
1067 { 1244 {
@@ -1076,6 +1253,14 @@ elm_diskselector_item_del(Elm_Diskselector_Item * it)
1076 edje_object_part_text_set(wd->s_last->base.view, "elm.text", 1253 edje_object_part_text_set(wd->s_last->base.view, "elm.text",
1077 wd->s_last->label); 1254 wd->s_last->label);
1078 } 1255 }
1256 // if more than 3 itmes should be displayed
1257 for (i = 3; i <= CEIL(wd->display_item_num); i++)
1258 {
1259 dit = eina_list_nth(wd->items, wd->item_count - i);
1260 item = eina_list_nth(wd->under_items, i - 3);
1261 eina_stringshare_replace(&item->label, dit->label);
1262 edje_object_part_text_set(item->base.view, "elm.text", item->label);
1263 }
1079 } 1264 }
1080 } 1265 }
1081 wd->check_idler = ecore_idler_add(_check_string, wd); 1266 wd->check_idler = ecore_idler_add(_check_string, wd);
@@ -1157,7 +1342,10 @@ elm_diskselector_item_selected_set(Elm_Diskselector_Item *it, Eina_Bool selected
1157 if ((wd->selected_item == it) && (!selected)) 1342 if ((wd->selected_item == it) && (!selected))
1158 wd->selected_item = eina_list_data_get(wd->items); 1343 wd->selected_item = eina_list_data_get(wd->items);
1159 else 1344 else
1160 wd->selected_item = it; 1345 {
1346 wd->selected_item = it;
1347 _selected_item_indicate(wd->selected_item);
1348 }
1161 1349
1162 if (!wd->idler) 1350 if (!wd->idler)
1163 ecore_idler_add(_move_scroller, it->base.widget); 1351 ecore_idler_add(_move_scroller, it->base.widget);
@@ -1542,3 +1730,21 @@ elm_diskselector_item_cursor_engine_only_get(const Elm_Diskselector_Item *item)
1542 ELM_DISKSELECTOR_ITEM_CHECK_OR_RETURN(item, EINA_FALSE); 1730 ELM_DISKSELECTOR_ITEM_CHECK_OR_RETURN(item, EINA_FALSE);
1543 return elm_widget_item_cursor_engine_only_get(item); 1731 return elm_widget_item_cursor_engine_only_get(item);
1544} 1732}
1733/**
1734 * Set the number of items to be displayed
1735 *
1736 * @param obj The diskselector object
1737 * @param num The number of itmes that diskselector will display
1738 *
1739 * @ingroup Diskselector
1740 */
1741EAPI void
1742elm_diskselector_display_item_num_set(Evas_Object *obj, int num)
1743{
1744 ELM_CHECK_WIDTYPE(obj, widtype);
1745 Widget_Data *wd = elm_widget_data_get(obj);
1746 if (!wd) return;
1747 if (num < DISPLAY_ITEM_NUM_MIN) num = DISPLAY_ITEM_NUM_MIN;
1748 wd->display_item_num = num;
1749 wd->display_item_num_by_api = EINA_TRUE;
1750}