From: Bluezery <ohpowel@gmail.com>
[framework/uifw/elementary.git] / src / bin / test_box.c
1 #include <Elementary.h>
2 #include "test.h"
3 #ifdef HAVE_CONFIG_H
4 # include "elementary_config.h"
5 #endif
6 #ifndef ELM_LIB_QUICKLAUNCH
7 #define ICON_MAX 24
8
9 typedef enum
10 {
11   BOX_PACK_POSITION_START,
12   BOX_PACK_POSITION_BEFORE,
13   BOX_PACK_POSITION_AFTER,
14   BOX_PACK_POSITION_END
15 } Box_Pack_Position;
16
17 struct _api_data
18 {
19    unsigned int state;  /* What state we are testing       */
20    void *box;           /* Use this to get box content     */
21 };
22 typedef struct _api_data api_data;
23
24 enum _api_state
25 {
26    BOX_PACK_START,
27    BOX_PACK_BEFORE,
28    BOX_PACK_AFTER,
29    BOX_PADDING_SET,
30    BOX_ALIGN_SET,
31    BOX_HOMOGENEOUS_SET,
32    BOX_UNPACK_ALL,
33    BOX_CLEAR,
34    API_STATE_LAST
35 };
36 typedef enum _api_state api_state;
37
38 static void
39 set_api_state(api_data *api)
40 {
41    const Eina_List *items = elm_box_children_get(api->box);
42    if(!eina_list_count(items))
43      return;
44
45    /* use elm_box_children_get() to get list of children */
46    switch(api->state)
47      { /* Put all api-changes under switch */
48       case BOX_PACK_START:  /* Move last item to begining */
49          elm_box_unpack(api->box, eina_list_data_get(eina_list_last(items)));
50          elm_box_pack_start(api->box, eina_list_data_get(eina_list_last(items)));
51          break;
52
53       case BOX_PACK_BEFORE:
54          if(eina_list_count(items) > 1)
55                {  /* Put last item before the one preceeding it */
56                   elm_box_unpack(api->box, eina_list_data_get(eina_list_last(items)));
57                   elm_box_pack_before(api->box,
58                         eina_list_data_get(eina_list_last(items)),
59                         eina_list_nth(items, eina_list_count(items)-2));
60                }
61          break;
62
63       case BOX_PACK_AFTER:
64          if(eina_list_count(items) > 1)
65                {  /* Put item before last to last */
66                   elm_box_unpack(api->box, eina_list_nth(items,
67                            eina_list_count(items)-2));
68                   elm_box_pack_after(api->box,
69                         eina_list_nth(items, eina_list_count(items)-2),
70                         eina_list_data_get(eina_list_last(items)));
71                }
72          break;
73
74       case BOX_PADDING_SET:
75          elm_box_padding_set(api->box, 30, 15);
76          break;
77
78       case BOX_ALIGN_SET:
79          elm_box_align_set(api->box, 0.25, 0.75);
80          break;
81
82       case BOX_HOMOGENEOUS_SET:
83          elm_box_homogeneous_set(api->box, EINA_TRUE);
84          break;
85
86       case BOX_UNPACK_ALL:
87            {
88               Eina_List *l;
89               Evas_Object *data;
90               elm_box_unpack_all(api->box);
91               EINA_LIST_REVERSE_FOREACH(items, l, data)
92                  elm_box_pack_end(api->box, data);
93            }
94          break;
95
96       case BOX_CLEAR:
97          elm_box_clear(api->box);
98          break;
99
100       case API_STATE_LAST:
101
102          break;
103       default:
104          return;
105      }
106 }
107
108 static void
109 _api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
110 {  /* Will add here a SWITCH command containing code to modify test-object */
111    /* in accordance a->state value. */
112    api_data *a = data;
113    char str[128];
114
115    printf("clicked event on API Button: api_state=<%d>\n", a->state);
116    set_api_state(a);
117    a->state++;
118    sprintf(str, "Next API function (%u)", a->state);
119    elm_object_text_set(obj, str);
120    elm_object_disabled_set(obj, a->state == API_STATE_LAST);
121 }
122
123 static void
124 _cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
125 {
126    free(data);
127 }
128
129 void
130 test_box_vert(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
131 {
132    Evas_Object *win, *bg, *bx, *ic, *bxx, *bt;
133    char buf[PATH_MAX];
134    api_data *api = calloc(1, sizeof(api_data));
135
136    win = elm_win_add(NULL, "box-vert", ELM_WIN_BASIC);
137    elm_win_title_set(win, "Box Vert");
138    elm_win_autodel_set(win, EINA_TRUE);
139    evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
140
141    bg = elm_bg_add(win);
142    elm_win_resize_object_add(win, bg);
143    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
144    evas_object_show(bg);
145
146    bxx = elm_box_add(win);
147    elm_win_resize_object_add(win, bxx);
148    evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
149    evas_object_show(bxx);
150
151    bx = elm_box_add(win);
152    api->box = bx;
153    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
154    evas_object_show(bx);
155
156    bt = elm_button_add(win);
157    elm_object_text_set(bt, "Next API function");
158    evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
159    elm_box_pack_end(bxx, bt);
160    elm_object_disabled_set(bt, api->state == API_STATE_LAST);
161    evas_object_show(bt);
162
163    elm_box_pack_end(bxx, bx);
164
165    ic = elm_icon_add(win);
166    snprintf(buf, sizeof(buf), "%s/images/icon_01.png", elm_app_data_dir_get());
167    elm_icon_file_set(ic, buf, NULL);
168    elm_icon_resizable_set(ic, 0, 0);
169    evas_object_size_hint_align_set(ic, 0.5, 0.5);
170    elm_box_pack_end(bx, ic);
171    evas_object_show(ic);
172
173    ic = elm_icon_add(win);
174    snprintf(buf, sizeof(buf), "%s/images/icon_02.png", elm_app_data_dir_get());
175    elm_icon_file_set(ic, buf, NULL);
176    elm_icon_resizable_set(ic, 0, 0);
177    evas_object_size_hint_align_set(ic, 0.0, 0.5);
178    elm_box_pack_end(bx, ic);
179    evas_object_show(ic);
180
181    ic = elm_icon_add(win);
182    snprintf(buf, sizeof(buf), "%s/images/icon_03.png", elm_app_data_dir_get());
183    elm_icon_file_set(ic, buf, NULL);
184    elm_icon_resizable_set(ic, 0, 0);
185    evas_object_size_hint_align_set(ic, EVAS_HINT_EXPAND, 0.5);
186    elm_box_pack_end(bx, ic);
187    evas_object_show(ic);
188
189    evas_object_show(win);
190 }
191
192 static void
193 _del_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
194 {
195    elm_box_unpack(data, obj);
196    evas_object_move(obj, 0, 0);
197    evas_object_color_set(obj, 128, 64, 0, 128);
198 //   evas_object_del(obj);
199 }
200
201 void
202 test_box_vert2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
203 {
204    Evas_Object *win, *bg, *bx, *bt;
205
206    win = elm_win_add(NULL, "box-vert2", ELM_WIN_BASIC);
207    elm_win_title_set(win, "Box Vert 2");
208    elm_win_autodel_set(win, EINA_TRUE);
209
210    bg = elm_bg_add(win);
211    elm_win_resize_object_add(win, bg);
212    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
213    evas_object_show(bg);
214
215    bx = elm_box_add(win);
216    elm_win_resize_object_add(win, bx);
217    elm_box_padding_set(bx, 10, 10);
218    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
219    evas_object_show(bx);
220
221    bt = elm_button_add(win);
222    elm_object_text_set(bt, "Button 1");
223    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
224    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
225    evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
226    elm_box_pack_end(bx, bt);
227    evas_object_show(bt);
228
229    bt = elm_button_add(win);
230    elm_object_text_set(bt, "Button 2");
231    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
232    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
233    evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
234    elm_box_pack_end(bx, bt);
235    evas_object_show(bt);
236
237    bt = elm_button_add(win);
238    elm_object_text_set(bt, "Button 3");
239    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
240    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
241    evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
242    elm_box_pack_end(bx, bt);
243    evas_object_show(bt);
244
245    bt = elm_button_add(win);
246    elm_object_text_set(bt, "Button 4");
247    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
248    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
249    evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
250    elm_box_pack_end(bx, bt);
251    evas_object_show(bt);
252
253    bt = elm_button_add(win);
254    elm_object_text_set(bt, "Button 5");
255    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
256    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
257    evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
258    elm_box_pack_end(bx, bt);
259    evas_object_show(bt);
260
261    evas_object_show(win);
262 }
263
264 void
265 test_box_horiz(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
266 {
267    Evas_Object *win, *bg, *bx, *ic, *bxx, *bt;
268    char buf[PATH_MAX];
269    api_data *api = calloc(1, sizeof(api_data));
270
271    win = elm_win_add(NULL, "box-horiz", ELM_WIN_BASIC);
272    elm_win_title_set(win, "Box Horiz");
273    elm_win_autodel_set(win, EINA_TRUE);
274    evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
275    bg = elm_bg_add(win);
276    elm_win_resize_object_add(win, bg);
277    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
278    evas_object_show(bg);
279
280    bxx = elm_box_add(win);
281    elm_win_resize_object_add(win, bxx);
282    evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
283    evas_object_show(bxx);
284
285    bx = elm_box_add(win);
286    elm_box_horizontal_set(bx, EINA_TRUE);
287    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
288    api->box = bx;
289    evas_object_show(bx);
290
291    bt = elm_button_add(win);
292    elm_object_text_set(bt, "Next API function");
293    evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api);
294    elm_box_pack_end(bxx, bt);
295    elm_object_disabled_set(bt, api->state == API_STATE_LAST);
296    evas_object_show(bt);
297
298    elm_box_pack_end(bxx, bx);
299
300    ic = elm_icon_add(win);
301    snprintf(buf, sizeof(buf), "%s/images/icon_01.png", elm_app_data_dir_get());
302    elm_icon_file_set(ic, buf, NULL);
303    elm_icon_resizable_set(ic, 0, 0);
304    evas_object_size_hint_align_set(ic, 0.5, 0.5);
305    elm_box_pack_end(bx, ic);
306    evas_object_show(ic);
307
308    ic = elm_icon_add(win);
309    snprintf(buf, sizeof(buf), "%s/images/icon_02.png", elm_app_data_dir_get());
310    elm_icon_file_set(ic, buf, NULL);
311    elm_icon_resizable_set(ic, 0, 0);
312    evas_object_size_hint_align_set(ic, 0.5, 0.0);
313    elm_box_pack_end(bx, ic);
314    evas_object_show(ic);
315
316    ic = elm_icon_add(win);
317    snprintf(buf, sizeof(buf), "%s/images/icon_03.png", elm_app_data_dir_get());
318    elm_icon_file_set(ic, buf, NULL);
319    elm_icon_resizable_set(ic, 0, 0);
320    evas_object_size_hint_align_set(ic, 0.0, EVAS_HINT_EXPAND);
321    elm_box_pack_end(bx, ic);
322    evas_object_show(ic);
323
324    evas_object_show(win);
325 }
326
327 static Eina_Bool radio_index[ICON_MAX];
328
329 static int
330 _index_get(void)
331 {
332    int i;
333    for (i = 0; i < ICON_MAX; i++)
334      {
335         if (!radio_index[i])
336           {
337              radio_index[i] = EINA_TRUE;
338              return i;
339           }
340
341      }
342    return -1;
343 }
344
345 static void
346 _index_remove(int i)
347 {
348    if (i >= ICON_MAX) return;
349    radio_index[i] = EINA_FALSE;
350 }
351
352 static void
353 _index_clear()
354 {
355    int i;
356    for (i = 0; i < ICON_MAX; i++)
357      radio_index[i] = EINA_FALSE;
358 }
359
360 static Evas_Object *
361 _radio_new(Evas_Object *obj)
362 {
363    Evas_Object *ic, *rd;
364    int idx;
365    char buf[PATH_MAX];
366    Evas_Object *rdg;
367
368    idx = _index_get();
369    if (idx == -1) return NULL;
370
371    ic = elm_icon_add(obj);
372    snprintf(buf, sizeof(buf), "%s/images/icon_%02d.png",
373             elm_app_data_dir_get(), idx);
374    elm_icon_file_set(ic, buf, NULL);
375    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
376
377    rd = elm_radio_add(obj);
378    elm_radio_state_value_set(rd, idx);
379    evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
380    evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5);
381    elm_object_part_content_set(rd, "icon", ic);
382
383    rdg = evas_object_data_get(obj, "radio-group");
384    if (rdg) elm_radio_group_add(rd, rdg);
385
386    evas_object_show(rd);
387    evas_object_show(ic);
388
389    return rd;
390 }
391
392 static void
393 _pack_start_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
394 {
395    Evas_Object *rd;
396    if (!data) return;
397
398    rd = _radio_new(data);
399    if (!rd) return;
400    elm_box_pack_start(data, rd);
401 }
402
403 static void
404 _pack_before_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
405 {
406    Evas_Object *rd, *selected_rd, *rdg;
407    if (!data) return;
408
409    rdg = evas_object_data_get(data, "radio-group");
410    if (!rdg) return;
411
412    selected_rd = elm_radio_selected_object_get(rdg);
413    if (!selected_rd || (selected_rd == rdg)) return;
414
415    rd = _radio_new(data);
416    if (!rd) return;
417    elm_box_pack_before(data, rd, selected_rd);
418 }
419
420 static void
421 _pack_after_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
422 {
423    Evas_Object *rd, *selected_rd, *rdg;
424    if (!data) return;
425
426    rdg = evas_object_data_get(data, "radio-group");
427    if (!rdg) return;
428
429    selected_rd = elm_radio_selected_object_get(rdg);
430    if (!selected_rd || (selected_rd == rdg)) return;
431
432    rd = _radio_new(data);
433    if (!rd) return;
434    elm_box_pack_after(data, rd, selected_rd);
435 }
436
437 static void
438 _pack_end_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
439 {
440    Evas_Object *rd;
441    if (!data) return;
442
443    rd = _radio_new(data);
444    if (!rd) return;
445    elm_box_pack_end(data, rd);
446 }
447
448 static void
449 _unpack_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
450 {
451    Evas_Object *rdg, *selected_rd;
452    if (!data) return;
453
454    rdg = evas_object_data_get(data, "radio-group");
455    if (!rdg) return;
456
457    selected_rd = elm_radio_selected_object_get(rdg);
458    if (selected_rd == rdg) return;
459
460    _index_remove(elm_radio_value_get(selected_rd));
461    elm_box_unpack(data, selected_rd);
462    evas_object_del(selected_rd);
463    elm_radio_value_set(rdg, -1);
464 }
465
466 static void
467 _unpack_all_btn_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
468 {
469    Evas_Object *radio, *rdg;
470    Eina_List *rl, *l;
471    if (!data) return;
472
473    rdg = evas_object_data_get(data, "radio-group");
474    if (!rdg) return;
475
476    _index_clear();
477    rl = elm_box_children_get(data);
478    EINA_LIST_FOREACH(rl, l, radio)
479      {
480         if (radio != rdg)
481           evas_object_del(radio);
482      }
483    elm_box_unpack_all(data);
484    elm_radio_value_set(rdg, -1);
485 }
486
487 void
488 test_box_pack(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
489 {
490    Evas_Object *win, *sc, *bt;
491    Evas_Object *box, *lbox, *rbox;
492    Evas_Object *rd, *rdg = NULL;
493    int i;
494
495    win = elm_win_util_standard_add("box-pack", "Box Pack");
496    elm_win_autodel_set(win, EINA_TRUE);
497
498    box = elm_box_add(win);
499    elm_box_horizontal_set(box, EINA_TRUE);
500    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
501    evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
502    elm_win_resize_object_add(win, box);
503    evas_object_show(box);
504
505    // left side
506    lbox = elm_box_add(win);
507    evas_object_size_hint_weight_set(lbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
508    evas_object_size_hint_align_set(lbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
509
510    sc = elm_scroller_add(win);
511    elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE);
512    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
513    evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
514
515    rdg = elm_radio_add(win); /* a radio for easy group handling */
516    elm_radio_state_value_set(rdg, -1);
517    evas_object_data_set(lbox, "radio-group", rdg);
518
519    for (i = 0; i < 3; i++)
520      {
521         rd = _radio_new(lbox);
522         elm_box_pack_end(lbox, rd);
523      }
524
525    elm_object_content_set(sc, lbox);
526    evas_object_show(lbox);
527    elm_box_pack_end(box, sc);
528    evas_object_show(sc);
529
530    // right side
531    rbox = elm_box_add(win);
532    evas_object_size_hint_weight_set(rbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
533    evas_object_size_hint_align_set(rbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
534    evas_object_show(rbox);
535    elm_box_pack_end(box, rbox);
536
537    bt = elm_button_add(win);
538    elm_object_text_set(bt, "Pack Start");
539    evas_object_show(bt);
540    elm_box_pack_end(rbox, bt);
541    evas_object_smart_callback_add(bt, "clicked", _pack_start_btn_cb, lbox);
542
543    bt = elm_button_add(win);
544    elm_object_text_set(bt, "Pack Before");
545    evas_object_show(bt);
546    elm_box_pack_end(rbox, bt);
547    evas_object_smart_callback_add(bt, "clicked", _pack_before_btn_cb, lbox);
548
549    bt = elm_button_add(win);
550    elm_object_text_set(bt, "Pack After");
551    evas_object_show(bt);
552    elm_box_pack_end(rbox, bt);
553    evas_object_smart_callback_add(bt, "clicked", _pack_after_btn_cb, lbox);
554
555    bt = elm_button_add(win);
556    elm_object_text_set(bt, "Pack End");
557    evas_object_show(bt);
558    elm_box_pack_end(rbox, bt);
559    evas_object_smart_callback_add(bt, "clicked", _pack_end_btn_cb, lbox);
560
561    bt = elm_button_add(win);
562    elm_object_text_set(bt, "Unpack");
563    evas_object_show(bt);
564    elm_box_pack_end(rbox, bt);
565    evas_object_smart_callback_add(bt, "clicked", _unpack_btn_cb, lbox);
566
567    bt = elm_button_add(win);
568    elm_object_text_set(bt, "Unpack All");
569    evas_object_show(bt);
570    elm_box_pack_end(rbox, bt);
571    evas_object_smart_callback_add(bt, "clicked", _unpack_all_btn_cb, lbox);
572
573    evas_object_resize(win, 320, 320);
574    evas_object_show(win);
575 }
576
577 static void
578 _cb_check_changed(void *data, Evas_Object *obj, void *event __UNUSED__)
579 {
580    Eina_Bool homo;
581    Evas_Object *box = data;
582
583    homo = elm_check_state_get(obj);
584    elm_box_homogeneous_set(box, homo);
585 }
586
587 void
588 test_box_homo(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
589 {
590    Evas_Object *win;
591    Evas_Object *box, *o_bg;
592    Evas_Object *rd;
593    char buf[PATH_MAX];
594
595    win = elm_win_util_standard_add("box-homogeneous", "Box Homogeneous");
596    elm_win_autodel_set(win, EINA_TRUE);
597
598    box = elm_box_add(win);
599    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
600    elm_win_resize_object_add(win, box);
601    evas_object_show(box);
602
603    o_bg = elm_bg_add(win);
604    snprintf(buf, sizeof(buf), "%s/images/twofish.jpg", elm_app_data_dir_get());
605    elm_bg_file_set(o_bg, buf, NULL);
606    evas_object_size_hint_weight_set(o_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
607    evas_object_size_hint_align_set(o_bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
608    elm_box_pack_end(box, o_bg);
609
610    rd = elm_check_add(win);
611    elm_object_text_set(rd, "Homogeneous");
612    evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
613    evas_object_smart_callback_add(rd, "changed", _cb_check_changed, box);
614    elm_box_pack_end(box, rd);
615    evas_object_show(rd);
616    evas_object_show(o_bg);
617
618    evas_object_resize(win, 320, 320);
619    evas_object_show(win);
620 }
621
622 typedef struct
623 {
624    Eina_List *transitions;
625    Evas_Object *box;
626    Evas_Object_Box_Layout last_layout;
627 } Transitions_Data;
628
629 static void
630 _test_box_transition_change(void *data)
631 {
632    Transitions_Data *tdata = data;
633    Elm_Box_Transition *layout_data;
634    Evas_Object_Box_Layout next_layout;
635
636    if (!data) return;
637    next_layout = eina_list_data_get(tdata->transitions);
638    layout_data = elm_box_transition_new(2.0, tdata->last_layout,
639                                         NULL, NULL, next_layout, NULL, NULL,
640                                         _test_box_transition_change, tdata);
641    elm_box_layout_set(tdata->box, elm_box_layout_transition, layout_data, elm_box_transition_free);
642    tdata->last_layout = next_layout;
643
644    tdata->transitions = eina_list_demote_list(tdata->transitions, tdata->transitions);
645 }
646
647 static void
648 _win_del(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
649 {
650    Transitions_Data *tdata = data;
651    if (!data) return;
652    free(tdata);
653 }
654
655 void
656 test_box_transition(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
657 {
658    Evas_Object *win, *bg, *bx, *bt;
659    Transitions_Data *tdata;
660
661    win = elm_win_add(NULL, "box-transition", ELM_WIN_BASIC);
662    elm_win_title_set(win, "Box Transition");
663    elm_win_autodel_set(win, EINA_TRUE);
664
665    bg = elm_bg_add(win);
666    elm_win_resize_object_add(win, bg);
667    evas_object_size_hint_weight_set(bg, 1.0, 1.0);
668    evas_object_show(bg);
669
670    bx = elm_box_add(win);
671    elm_win_resize_object_add(win, bx);
672    evas_object_size_hint_weight_set(bx, 1.0, 1.0);
673    evas_object_show(bx);
674
675    bt = elm_button_add(win);
676    elm_object_text_set(bt, "Button 1");
677    evas_object_size_hint_weight_set(bt, 1.0, 1.0);
678    evas_object_size_hint_align_set(bt, -1.0, -1.0);
679    evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
680    elm_box_pack_end(bx, bt);
681    evas_object_resize(bt, 100, 100);
682    evas_object_show(bt);
683
684    bt = elm_button_add(win);
685    elm_object_text_set(bt, "Button 2");
686    evas_object_size_hint_weight_set(bt, 1.0, 1.0);
687    evas_object_size_hint_align_set(bt, -1.0, -1.0);
688    evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
689    elm_box_pack_end(bx, bt);
690    evas_object_resize(bt, 100, 100);
691    evas_object_show(bt);
692
693    bt = elm_button_add(win);
694    elm_object_text_set(bt, "Button 3");
695    evas_object_size_hint_weight_set(bt, 1.0, 1.0);
696    evas_object_size_hint_align_set(bt, -1.0, -1.0);
697    evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
698    elm_box_pack_end(bx, bt);
699    evas_object_resize(bt, 100, 100);
700    evas_object_show(bt);
701
702    tdata = calloc(1, sizeof(Transitions_Data));
703    tdata->box = bx;
704    tdata->last_layout = evas_object_box_layout_horizontal;
705    tdata->transitions = eina_list_append(tdata->transitions,
706          evas_object_box_layout_vertical);
707    tdata->transitions = eina_list_append(tdata->transitions,
708          evas_object_box_layout_horizontal);
709    tdata->transitions = eina_list_append(tdata->transitions,
710          evas_object_box_layout_stack);
711    tdata->transitions = eina_list_append(tdata->transitions,
712          evas_object_box_layout_homogeneous_vertical);
713    tdata->transitions = eina_list_append(tdata->transitions,
714          evas_object_box_layout_homogeneous_horizontal);
715    tdata->transitions = eina_list_append(tdata->transitions,
716          evas_object_box_layout_flow_vertical);
717    tdata->transitions = eina_list_append(tdata->transitions,
718          evas_object_box_layout_flow_horizontal);
719    tdata->transitions = eina_list_append(tdata->transitions,
720          evas_object_box_layout_stack);
721
722    evas_object_resize(win, 300, 300);
723    evas_object_resize(bx, 300, 300);
724    evas_object_smart_callback_add(win, "delete,request", _win_del, tdata);
725    evas_object_show(win);
726    elm_box_layout_set(bx, evas_object_box_layout_horizontal, NULL, NULL);
727    _test_box_transition_change(tdata);
728 }
729 #endif