svn code merge (ver: 51860-51890)
[framework/uifw/elementary.git] / src / bin / test_launcher.c
1 #include <Elementary.h>
2 #ifndef ELM_LIB_QUICKLAUNCH
3
4 static void
5 mode_cb(void *data, Evas_Object *obj, void *event_info)
6 {
7    Evas_Object *win = data;
8    Evas_Object *mb;
9    Eina_List *mbs, *l;
10    
11    mbs = evas_object_data_get(win, "mbs");
12    EINA_LIST_FOREACH(mbs, l, mb)
13      {
14         if (elm_mapbuf_enabled_get(mb))
15           elm_mapbuf_enabled_set(mb, 0);
16         else
17           elm_mapbuf_enabled_set(mb, 1);
18      }
19 }
20
21 static void
22 full_cb(void *data, Evas_Object *obj, void *event_info)
23 {
24    Evas_Object *win = data;
25    elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
26 }
27
28 static void
29 alpha_cb(void *data, Evas_Object *obj, void *event_info)
30 {
31    Evas_Object *win = data;
32    Evas_Object *mb;
33    Eina_List *mbs, *l;
34    
35    mbs = evas_object_data_get(win, "mbs");
36    EINA_LIST_FOREACH(mbs, l, mb)
37      {
38         elm_mapbuf_alpha_set(mb, elm_check_state_get(obj));
39      }
40 }
41
42 static void
43 smooth_cb(void *data, Evas_Object *obj, void *event_info)
44 {
45    Evas_Object *win = data;
46    Evas_Object *mb;
47    Eina_List *mbs, *l;
48    
49    mbs = evas_object_data_get(win, "mbs");
50    EINA_LIST_FOREACH(mbs, l, mb)
51      {
52         elm_mapbuf_smooth_set(mb, elm_check_state_get(obj));
53      }
54 }
55
56 static void
57 close_cb(void *data, Evas_Object *obj, void *event_info)
58 {
59    evas_object_del(data);
60 }
61
62 static Eina_Bool
63 tim_cb(void *data)
64 {
65    Evas_Object *tb, *sc, *mb;
66    Eina_List *list, *l;
67    
68    evas_object_data_del(data, "timer");
69    tb = evas_object_data_get(data, "tb");
70    sc = evas_object_data_get(data, "sc");
71    mb = evas_object_data_get(data, "mb");
72    elm_object_scroll_freeze_push(sc);
73    evas_object_data_set(data, "dragging", (void *)(1));
74    evas_object_color_set(data, 255, 255, 255, 255);
75    list = (Eina_List *)evas_object_data_get
76       (elm_object_top_widget_get(data), "mbs");
77    EINA_LIST_FOREACH(list, l, mb)
78       evas_object_color_set(mb, 128, 128, 128, 128);
79    elm_table_unpack(tb, data);
80    return EINA_FALSE;
81 }
82
83 static void
84 ic_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
85 {
86    Ecore_Timer *tim;
87    
88    tim = evas_object_data_get(obj, "timer");
89    if (tim)
90      {
91         evas_object_data_del(obj, "timer");
92         ecore_timer_del(tim);
93      }
94 }
95
96 static void
97 ic_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
98 {
99    Evas_Event_Mouse_Down *ev = event_info;
100    Ecore_Timer *tim;
101    Evas_Coord x, y, w, h;
102    
103    evas_object_color_set(data, 128, 0, 0, 128);
104    
105    tim = evas_object_data_get(obj, "timer");
106    if (tim) evas_object_data_del(obj, "timer");
107    tim = ecore_timer_add(1.0, tim_cb, obj);
108    evas_object_data_set(obj, "timer", tim);
109
110    evas_object_geometry_get(data, &x, &y, &w, &h);
111    evas_object_data_set(obj, "x", (void *)(ev->canvas.x));
112    evas_object_data_set(obj, "y", (void *)(ev->canvas.y));
113    evas_object_data_set(obj, "px", (void *)(x));
114    evas_object_data_set(obj, "py", (void *)(y));
115    
116    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
117      {
118         printf("double click %p\n", obj);
119      }
120 }
121
122 static void
123 ic_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
124 {
125    Evas_Event_Mouse_Up *ev = event_info;
126    Ecore_Timer *tim;
127    
128    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
129    evas_object_color_set(data, 255, 255, 255, 255);
130    tim = evas_object_data_get(obj, "timer");
131    if (tim)
132      {
133         evas_object_data_del(obj, "timer");
134         ecore_timer_del(tim);
135      }
136    if (evas_object_data_get(obj, "dragging"))
137      {
138         Evas_Object *tb, *sc, *mb;
139         Eina_List *list, *l;
140         int tbx, tby;
141         
142         evas_object_data_del(obj, "dragging");
143         tb = evas_object_data_get(obj, "tb");
144         sc = evas_object_data_get(obj, "sc");
145         mb = evas_object_data_get(data, "mb");
146         elm_object_scroll_freeze_pop(sc);
147         tbx = (int)evas_object_data_get(obj, "tbx");
148         tby = (int)evas_object_data_get(obj, "tby");
149         elm_table_pack(tb, obj, tbx, tby, 1, 1);
150         list = (Eina_List *)evas_object_data_get
151            (elm_object_top_widget_get(obj), "mbs");
152         EINA_LIST_FOREACH(list, l, mb)
153            evas_object_color_set(mb, 255, 255, 255, 255);
154      }
155 }
156
157 static void
158 ic_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
159 {
160    Evas_Event_Mouse_Move *ev = event_info;
161    if (evas_object_data_get(obj, "dragging"))
162      {
163         Evas_Coord x, y, px, py;
164         
165         x = (Evas_Coord)evas_object_data_get(obj, "x");
166         y = (Evas_Coord)evas_object_data_get(obj, "y");
167         px = (Evas_Coord)evas_object_data_get(obj, "px");
168         py = (Evas_Coord)evas_object_data_get(obj, "py");
169         evas_object_move(obj, 
170                          px + ev->cur.canvas.x - x, 
171                          py + ev->cur.canvas.y - y);
172     }
173    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
174      {
175         Ecore_Timer *tim;
176         
177         tim = evas_object_data_get(obj, "timer");
178         if (tim)
179           {
180              evas_object_data_del(obj, "timer");
181              ecore_timer_del(tim);
182           }
183         evas_object_color_set(data, 255, 255, 255, 255);
184         return;
185      }
186 }
187
188 void
189 test_launcher(void *data, Evas_Object *obj, void *event_info)
190 {
191    Evas_Object *win, *bg, *sc, *tb, *pad, *bt, *ic, *lb, *tb2, *mb, *ck, *bx, *bx2;
192    int i, j, k, n, m;
193    char buf[PATH_MAX];
194    const char *names[] =
195      {
196         "Hello",    "World",    "Spam",  "Egg", 
197         "Ham",      "Good",     "Bad",   "Milk", 
198         "Smell",    "Of",       "Sky",   "Gold",
199         "Hole",     "Pig",      "And",   "Calm"
200      };
201    Eina_List *mbs = NULL;
202    
203    win = elm_win_add(NULL, "launcher", ELM_WIN_BASIC);
204    elm_win_title_set(win, "Launcher");
205    elm_win_autodel_set(win, 1);
206
207    bg = elm_bg_add(win);
208    snprintf(buf, sizeof(buf), "%s/images/sky_04.jpg", PACKAGE_DATA_DIR);
209    elm_bg_file_set(bg, buf, NULL);
210    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
211    elm_win_resize_object_add(win, bg);
212    evas_object_show(bg);
213    
214    bx = elm_box_add(win);
215    elm_box_homogenous_set(bx, 1);
216    elm_box_horizontal_set(bx, 1);
217    
218    sc = elm_scroller_add(win);
219    elm_scroller_bounce_set(sc, 1, 0);
220    elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
221    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
222    evas_object_size_hint_fill_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
223    
224    n = 0; m = 0;
225    for (k = 0 ; k < 8; k++)
226      {
227         tb = elm_table_add(win);
228         evas_object_size_hint_weight_set(tb, 0.0, 0.0);
229         evas_object_size_hint_align_set(tb, 0.5, 0.5);
230
231         pad = evas_object_rectangle_add(evas_object_evas_get(win));
232         evas_object_size_hint_min_set(pad, 470, 4);
233         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
234         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
235         elm_table_pack(tb, pad, 1, 0, 5, 1);
236         
237         pad = evas_object_rectangle_add(evas_object_evas_get(win));
238         evas_object_size_hint_min_set(pad, 470, 4);
239         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
240         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
241         elm_table_pack(tb, pad, 1, 11, 5, 1);
242         
243         pad = evas_object_rectangle_add(evas_object_evas_get(win));
244         evas_object_size_hint_min_set(pad, 4, 4);
245         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
246         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
247         elm_table_pack(tb, pad, 0, 1, 1, 10);
248         
249         pad = evas_object_rectangle_add(evas_object_evas_get(win));
250         evas_object_size_hint_min_set(pad, 4, 4);
251         evas_object_size_hint_weight_set(pad, 0.0, 0.0);
252         evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
253         elm_table_pack(tb, pad, 6, 1, 1, 10);
254
255         mb = elm_mapbuf_add(win);
256         elm_mapbuf_content_set(mb, tb);
257         evas_object_show(tb);
258         
259         for (j = 0; j < 5; j++)
260           {
261              for (i = 0; i < 5; i++)
262                {
263                   ic = elm_icon_add(win);
264                   elm_object_scale_set(ic, 0.5);
265                   snprintf(buf, sizeof(buf), "%s/images/icon_%02i.png", PACKAGE_DATA_DIR, n);
266                   elm_icon_file_set(ic, buf, NULL);
267                   elm_icon_scale_set(ic, 0, 0);
268                   evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
269                   evas_object_size_hint_align_set(ic, 0.5, 0.5);
270                   elm_table_pack(tb, ic, 1 + i, 1 + (j * 2), 1, 1);
271                   evas_object_show(ic);
272                   
273                   lb = elm_label_add(win);
274                   elm_object_style_set(lb, "marker");
275                   elm_label_label_set(lb, names[m]);
276                   evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
277                   evas_object_size_hint_align_set(lb, 0.5, 0.5);
278                   elm_table_pack(tb, lb, 1 + i, 1 + (j * 2) + 1, 1, 1);
279                   evas_object_show(lb);
280                   
281                   evas_object_event_callback_add(ic, EVAS_CALLBACK_DEL, ic_del_cb, ic);
282                   
283                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_DOWN, ic_down_cb, ic);
284                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_UP,   ic_up_cb,   ic);
285                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_MOVE, ic_move_cb, ic);
286                   
287                   evas_object_data_set(ic, "lb", lb);
288                   evas_object_data_set(ic, "tb", tb);
289                   evas_object_data_set(ic, "sc", sc);
290                   evas_object_data_set(ic, "bx", bx);
291                   evas_object_data_set(ic, "mb", mb);
292                   evas_object_data_set(ic, "tbx", (void *)(1 + i));
293                   evas_object_data_set(ic, "tby", (void *)(1 + (j * 2)));
294                   
295                   n++; if (n > 23) n = 0;
296                   m++; if (m > 15) m = 0;
297                }
298           }
299         
300         elm_box_pack_end(bx, mb);
301         evas_object_show(mb);
302         
303         mbs = eina_list_append(mbs, mb);
304      }
305
306    // fixme: free mbs
307    evas_object_data_set(win, "mbs", mbs);
308    
309    bx2 = elm_box_add(win);
310    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
311    elm_box_horizontal_set(bx2, 0);
312    elm_win_resize_object_add(win, bx2);
313    evas_object_show(bx2);
314    
315    elm_scroller_content_set(sc, bx);
316    evas_object_show(bx);
317    
318    elm_scroller_page_relative_set(sc, 1.0, 1.0);
319    evas_object_show(sc);
320
321    tb2 = elm_table_add(win);
322    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, 0.0);
323    evas_object_size_hint_fill_set(tb2, EVAS_HINT_FILL, EVAS_HINT_FILL);
324    elm_box_pack_end(bx2, tb2);
325
326    elm_box_pack_end(bx2, sc);
327    
328    ck = elm_check_add(win);
329    elm_check_label_set(ck, "Map");
330    elm_check_state_set(ck, 0);
331    evas_object_smart_callback_add(ck, "changed", mode_cb, win);
332    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
333    evas_object_size_hint_align_set(ck, 0.05, 0.99);
334    elm_table_pack(tb2, ck, 0, 0, 1, 1);
335    evas_object_show(ck);
336    
337    ck = elm_check_add(win);
338    elm_check_label_set(ck, "A");
339    elm_check_state_set(ck, 1);
340    evas_object_smart_callback_add(ck, "changed", alpha_cb, win);
341    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
342    evas_object_size_hint_align_set(ck, 0.20, 0.99);
343    elm_table_pack(tb2, ck, 1, 0, 1, 1);
344    evas_object_show(ck);
345    
346    ck = elm_check_add(win);
347    elm_check_label_set(ck, "Smo");
348    elm_check_state_set(ck, 1);
349    evas_object_smart_callback_add(ck, "changed", smooth_cb, win);
350    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
351    evas_object_size_hint_align_set(ck, 0.40, 0.99);
352    elm_table_pack(tb2, ck, 2, 0, 1, 1);
353    evas_object_show(ck);
354    
355    ck = elm_check_add(win);
356    elm_check_label_set(ck, "FS");
357    elm_check_state_set(ck, 0);
358    evas_object_smart_callback_add(ck, "changed", full_cb, win);
359    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
360    evas_object_size_hint_align_set(ck, 0.5, 0.99);
361    elm_table_pack(tb2, ck, 3, 0, 1, 1);
362    evas_object_show(ck);
363    
364    bt = elm_button_add(win);
365    elm_button_label_set(bt, "Close");
366    evas_object_smart_callback_add(bt, "clicked", close_cb, win);
367    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
368    evas_object_size_hint_align_set(bt, 0.95, 0.99);
369    elm_table_pack(tb2, bt, 4, 0, 1, 1);
370    evas_object_show(bt);
371    
372    evas_object_show(tb2);
373
374    evas_object_resize(win, 480, 800);
375    evas_object_show(win);
376 }
377
378 void
379 test_launcher2(void *data, Evas_Object *obj, void *event_info)
380 {
381    Evas_Object *win, *bg, *sc, *tb, *pad, *bt, *ic, *lb, *tb2, *mb, *ck, *bx, *rc, *ly;
382    int i, j, k, n, m;
383    char buf[PATH_MAX];
384    Eina_List *mbs = NULL;
385    
386    win = elm_win_add(NULL, "launcher", ELM_WIN_BASIC);
387    elm_win_title_set(win, "Launcher");
388    elm_win_autodel_set(win, 1);
389
390    bg = elm_bg_add(win);
391    snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", PACKAGE_DATA_DIR);
392    elm_bg_file_set(bg, buf, NULL);
393    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
394    elm_win_resize_object_add(win, bg);
395    evas_object_show(bg);
396    
397    bx = elm_box_add(win);
398    elm_box_homogenous_set(bx, 1);
399    elm_box_horizontal_set(bx, 1);
400    
401    for (k = 0 ; k < 8; k++)
402      {
403         ly = elm_layout_add(win);
404         snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
405         elm_layout_file_set(ly, buf, "layout");
406         evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
407         
408         bt = elm_button_add(win);
409         elm_button_label_set(bt, "Button 1");
410         elm_layout_content_set(ly, "element1", bt);
411         evas_object_show(bt);
412         
413         bt = elm_button_add(win);
414         elm_button_label_set(bt, "Button 2");
415         elm_layout_content_set(ly, "element2", bt);
416         evas_object_show(bt);
417         
418         bt = elm_button_add(win);
419         elm_button_label_set(bt, "Button 3");
420         elm_layout_content_set(ly, "element3", bt);
421         evas_object_show(bt);
422         
423         mb = elm_mapbuf_add(win);
424         elm_mapbuf_content_set(mb, ly);
425         evas_object_show(ly);
426         
427         elm_box_pack_end(bx, mb);
428         evas_object_show(mb);
429         
430         mbs = eina_list_append(mbs, mb);
431      }
432
433    // fixme: free mbs
434    evas_object_data_set(win, "mbs", mbs);
435    
436    sc = elm_scroller_add(win);
437    elm_scroller_bounce_set(sc, 1, 0);
438    elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
439    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
440    elm_win_resize_object_add(win, sc);
441    
442    elm_scroller_content_set(sc, bx);
443    evas_object_show(bx);
444    
445    elm_scroller_page_relative_set(sc, 1.0, 1.0);
446    evas_object_show(sc);
447
448    tb2 = elm_table_add(win);
449    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
450    elm_win_resize_object_add(win, tb2);
451    
452    ck = elm_check_add(win);
453    elm_check_label_set(ck, "Map");
454    elm_check_state_set(ck, 0);
455    evas_object_smart_callback_add(ck, "changed", mode_cb, win);
456    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
457    evas_object_size_hint_align_set(ck, 0.05, 0.99);
458    elm_table_pack(tb2, ck, 0, 0, 1, 1);
459    evas_object_show(ck);
460    
461    ck = elm_check_add(win);
462    elm_check_label_set(ck, "A");
463    elm_check_state_set(ck, 1);
464    evas_object_smart_callback_add(ck, "changed", alpha_cb, win);
465    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
466    evas_object_size_hint_align_set(ck, 0.20, 0.99);
467    elm_table_pack(tb2, ck, 1, 0, 1, 1);
468    evas_object_show(ck);
469    
470    ck = elm_check_add(win);
471    elm_check_label_set(ck, "Smo");
472    elm_check_state_set(ck, 1);
473    evas_object_smart_callback_add(ck, "changed", smooth_cb, win);
474    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
475    evas_object_size_hint_align_set(ck, 0.40, 0.99);
476    elm_table_pack(tb2, ck, 2, 0, 1, 1);
477    evas_object_show(ck);
478    
479    ck = elm_check_add(win);
480    elm_check_label_set(ck, "FS");
481    elm_check_state_set(ck, 0);
482    evas_object_smart_callback_add(ck, "changed", full_cb, win);
483    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
484    evas_object_size_hint_align_set(ck, 0.5, 0.99);
485    elm_table_pack(tb2, ck, 3, 0, 1, 1);
486    evas_object_show(ck);
487    
488    bt = elm_button_add(win);
489    elm_button_label_set(bt, "Close");
490    evas_object_smart_callback_add(bt, "clicked", close_cb, win);
491    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
492    evas_object_size_hint_align_set(bt, 0.95, 0.99);
493    elm_table_pack(tb2, bt, 4, 0, 1, 1);
494    evas_object_show(bt);
495    
496    evas_object_show(tb2);
497
498    evas_object_resize(win, 480, 800);
499    evas_object_show(win);
500 }
501
502 static void
503 l3_mode_cb(void *data, Evas_Object *obj, void *event_info)
504 {
505    Evas_Object *win = data;
506    Evas_Object *mb;
507    Eina_List *mbs, *l;
508    
509    mbs = evas_object_data_get(win, "mbs");
510    EINA_LIST_FOREACH(mbs, l, mb)
511      {
512         if (elm_mapbuf_enabled_get(mb))
513           elm_mapbuf_enabled_set(mb, 0);
514         else
515           elm_mapbuf_enabled_set(mb, 1);
516      }
517 }
518
519 static void
520 l3_full_cb(void *data, Evas_Object *obj, void *event_info)
521 {
522    Evas_Object *win = data;
523    elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
524 }
525
526 static void
527 l3_alpha_cb(void *data, Evas_Object *obj, void *event_info)
528 {
529    Evas_Object *win = data;
530    Evas_Object *mb;
531    Eina_List *mbs, *l;
532    
533    mbs = evas_object_data_get(win, "mbs");
534    EINA_LIST_FOREACH(mbs, l, mb)
535      {
536         elm_mapbuf_alpha_set(mb, elm_check_state_get(obj));
537      }
538 }
539
540 static void
541 l3_smooth_cb(void *data, Evas_Object *obj, void *event_info)
542 {
543    Evas_Object *win = data;
544    Evas_Object *mb;
545    Eina_List *mbs, *l;
546    
547    mbs = evas_object_data_get(win, "mbs");
548    EINA_LIST_FOREACH(mbs, l, mb)
549      {
550         elm_mapbuf_smooth_set(mb, elm_check_state_get(obj));
551      }
552 }
553
554 static void
555 l3_close_cb(void *data, Evas_Object *obj, void *event_info)
556 {
557    evas_object_del(data);
558 }
559
560 static Eina_Bool
561 l3_tim_cb(void *data)
562 {
563    Evas_Object *ly, *ly2, *sc, *mb;
564    Eina_List *list, *l;
565    char buf[256];
566    int slx, sly;
567    
568    evas_object_data_del(data, "timer");
569    ly = evas_object_data_get(data, "ly");
570    ly2 = evas_object_data_get(data, "ly2");
571    sc = evas_object_data_get(data, "sc");
572    mb = evas_object_data_get(data, "mb");
573    elm_object_scroll_freeze_push(sc);
574    evas_object_data_set(data, "dragging", (void *)(1));
575    evas_object_color_set(data, 255, 255, 255, 255);
576    list = (Eina_List *)evas_object_data_get
577       (elm_object_top_widget_get(data), "mbs");
578    EINA_LIST_FOREACH(list, l, mb)
579       evas_object_color_set(mb, 128, 128, 128, 128);
580    slx = (int)evas_object_data_get(data, "slx");
581    sly = (int)evas_object_data_get(data, "sly");
582    snprintf(buf, sizeof(buf), "slot.%i.%i", slx, sly);
583    elm_layout_content_unset(ly, buf);
584    edje_object_signal_emit(elm_layout_edje_get(ly2), "drag", "app");
585    return EINA_FALSE;
586 }
587
588 static void
589 l3_ic_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
590 {
591    Ecore_Timer *tim;
592    
593    tim = evas_object_data_get(obj, "timer");
594    if (tim)
595      {
596         evas_object_data_del(obj, "timer");
597         ecore_timer_del(tim);
598      }
599 }
600
601 static void
602 l3_ic_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
603 {
604    Evas_Event_Mouse_Down *ev = event_info;
605    Ecore_Timer *tim;
606    Evas_Coord x, y, w, h;
607    Evas_Object *ly2;
608    
609    tim = evas_object_data_get(obj, "timer");
610    if (tim) evas_object_data_del(obj, "timer");
611    tim = ecore_timer_add(1.0, l3_tim_cb, obj);
612    evas_object_data_set(obj, "timer", tim);
613
614    ly2 = evas_object_data_get(obj, "ly2");
615    evas_object_geometry_get(ly2, &x, &y, &w, &h);
616    evas_object_data_set(obj, "x", (void *)(ev->canvas.x));
617    evas_object_data_set(obj, "y", (void *)(ev->canvas.y));
618    evas_object_data_set(obj, "px", (void *)(x));
619    evas_object_data_set(obj, "py", (void *)(y));
620    
621    edje_object_signal_emit(elm_layout_edje_get(ly2), "click", "app");
622    
623    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
624      {
625         printf("double click %p\n", obj);
626      }
627 }
628
629 static void
630 l3_ic_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
631 {
632    Evas_Event_Mouse_Up *ev = event_info;
633    Ecore_Timer *tim;
634    Evas_Object *ly2;
635    
636    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
637    
638    ly2 = evas_object_data_get(obj, "ly2");
639    tim = evas_object_data_get(obj, "timer");
640    if (tim)
641      {
642         evas_object_data_del(obj, "timer");
643         ecore_timer_del(tim);
644      }
645    if (evas_object_data_get(obj, "dragging"))
646      {
647         Evas_Object *ly, *sc, *mb;
648         Eina_List *list, *l;
649         int slx, sly;
650         char buf[256];
651         
652         evas_object_data_del(obj, "dragging");
653         ly = evas_object_data_get(obj, "ly");
654         sc = evas_object_data_get(obj, "sc");
655         mb = evas_object_data_get(data, "mb");
656         elm_object_scroll_freeze_pop(sc);
657         slx = (int)evas_object_data_get(obj, "slx");
658         sly = (int)evas_object_data_get(obj, "sly");
659         snprintf(buf, sizeof(buf), "slot.%i.%i", slx, sly);
660         elm_layout_content_set(ly, buf, ly2);
661         list = (Eina_List *)evas_object_data_get
662            (elm_object_top_widget_get(obj), "mbs");
663         EINA_LIST_FOREACH(list, l, mb)
664            evas_object_color_set(mb, 255, 255, 255, 255);
665         edje_object_signal_emit(elm_layout_edje_get(ly2), "drop", "app");
666      }
667    else
668       edje_object_signal_emit(elm_layout_edje_get(ly2), "unclick", "app");
669 }
670
671 static void
672 l3_ic_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
673 {
674    Evas_Event_Mouse_Move *ev = event_info;
675    Evas_Object *ly2;
676    
677    ly2 = evas_object_data_get(obj, "ly2");
678    
679    if (evas_object_data_get(obj, "dragging"))
680      {
681         Evas_Coord x, y, px, py;
682         
683         x = (Evas_Coord)evas_object_data_get(obj, "x");
684         y = (Evas_Coord)evas_object_data_get(obj, "y");
685         px = (Evas_Coord)evas_object_data_get(obj, "px");
686         py = (Evas_Coord)evas_object_data_get(obj, "py");
687         evas_object_move(ly2, 
688                          px + ev->cur.canvas.x - x, 
689                          py + ev->cur.canvas.y - y);
690     }
691    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
692      {
693         Ecore_Timer *tim;
694         
695         tim = evas_object_data_get(obj, "timer");
696         if (tim)
697           {
698              evas_object_data_del(obj, "timer");
699              ecore_timer_del(tim);
700           }
701         edje_object_signal_emit(elm_layout_edje_get(ly2), "cancel", "app");
702         return;
703      }
704 }
705
706 void
707 test_launcher3(void *data, Evas_Object *obj, void *event_info)
708 {
709    Evas_Object *win, *bg, *sc, *tb, *pad, *bt, *ic, *lb, *tb2, *mb, *ck, *bx, *bx2, *ly, *ly2;
710    int i, j, k, n, m;
711    char buf[PATH_MAX];
712    const char *names[] =
713      {
714         "Hello",    "World",    "Spam",  "Egg", 
715         "Ham",      "Good",     "Bad",   "Milk", 
716         "Smell",    "Of",       "Sky",   "Gold",
717         "Hole",     "Pig",      "And",   "Calm"
718      };
719    Eina_List *mbs = NULL;
720    
721    win = elm_win_add(NULL, "launcher", ELM_WIN_BASIC);
722    elm_win_title_set(win, "Launcher");
723    elm_win_autodel_set(win, 1);
724
725    bg = elm_bg_add(win);
726    snprintf(buf, sizeof(buf), "%s/images/sky_04.jpg", PACKAGE_DATA_DIR);
727    elm_bg_file_set(bg, buf, NULL);
728    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
729    elm_win_resize_object_add(win, bg);
730    evas_object_show(bg);
731
732    bx = elm_box_add(win);
733    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
734    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
735    elm_box_homogenous_set(bx, 1);
736    elm_box_horizontal_set(bx, 1);
737    
738    sc = elm_scroller_add(win);
739    elm_scroller_bounce_set(sc, 1, 0);
740    elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
741    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
742    evas_object_size_hint_fill_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
743    
744    n = 0; m = 0;
745    for (k = 0 ; k < 8; k++)
746      {
747         tb = elm_table_add(win);
748         evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
749         evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
750
751         pad = evas_object_rectangle_add(evas_object_evas_get(win));
752         evas_object_size_hint_min_set(pad, 450, 10);
753         elm_table_pack(tb, pad, 1, 0, 1, 1);
754         
755         pad = evas_object_rectangle_add(evas_object_evas_get(win));
756         evas_object_size_hint_min_set(pad, 450, 10);
757         elm_table_pack(tb, pad, 1, 2, 1, 1);
758         
759         pad = evas_object_rectangle_add(evas_object_evas_get(win));
760         evas_object_size_hint_min_set(pad, 10, 450);
761         elm_table_pack(tb, pad, 0, 1, 1, 1);
762         
763         pad = evas_object_rectangle_add(evas_object_evas_get(win));
764         evas_object_size_hint_min_set(pad, 10, 450);
765         elm_table_pack(tb, pad, 2, 1, 1, 1);
766
767         mb = elm_mapbuf_add(win);
768         mbs = eina_list_append(mbs, mb);
769         
770         elm_mapbuf_content_set(mb, tb);
771         evas_object_show(tb);
772         elm_box_pack_end(bx, mb);
773         evas_object_show(mb);
774         
775         ly = elm_layout_add(win);
776         snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
777         elm_layout_file_set(ly, buf, "launcher_page");
778         evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
779         evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
780         elm_table_pack(tb, ly, 1, 1, 1, 1);
781         evas_object_show(ly);
782         
783         for (j = 0; j < 4; j++)
784           {
785              for (i = 0; i < 4; i++)
786                {
787                   ly2 = elm_layout_add(win);
788                   snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
789                   elm_layout_file_set(ly2, buf, "launcher_icon");
790                   evas_object_size_hint_weight_set(ly2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
791                   evas_object_size_hint_align_set(ly2, EVAS_HINT_FILL, EVAS_HINT_FILL);
792                   edje_object_part_text_set(elm_layout_edje_get(ly2), "label", names[m]);
793
794                   ic = elm_icon_add(win);
795                   elm_object_scale_set(ic, 0.5);
796                   snprintf(buf, sizeof(buf), "%s/images/icon_%02i.png", PACKAGE_DATA_DIR, n);
797                   elm_icon_file_set(ic, buf, NULL);
798                   elm_icon_scale_set(ic, 0, 0);
799                   evas_object_size_hint_weight_set(ic, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
800                   evas_object_size_hint_align_set(ic, 0.5, 0.5);
801                   elm_layout_content_set(ly2, "slot", ic);
802                   evas_object_show(ic);
803                   
804                   evas_object_event_callback_add(ic, EVAS_CALLBACK_DEL, l3_ic_del_cb, ic);
805                   
806                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_DOWN, l3_ic_down_cb, ic);
807                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_UP,   l3_ic_up_cb,   ic);
808                   evas_object_event_callback_add(ic, EVAS_CALLBACK_MOUSE_MOVE, l3_ic_move_cb, ic);
809                   
810                   evas_object_data_set(ic, "ly", ly);
811                   evas_object_data_set(ic, "ly2", ly2);
812                   evas_object_data_set(ic, "sc", sc);
813                   evas_object_data_set(ic, "bx", bx);
814                   evas_object_data_set(ic, "mb", mb);
815                   evas_object_data_set(ic, "slx", (void *)(i));
816                   evas_object_data_set(ic, "sly", (void *)(j));
817                   
818                   snprintf(buf, sizeof(buf), "slot.%i.%i", i, j);
819                   elm_layout_content_set(ly, buf, ly2);
820                   evas_object_show(ly2);
821                   
822                   n++; if (n > 23) n = 0;
823                   m++; if (m > 15) m = 0;
824                }
825           }
826      }
827
828    // fixme: free mbs
829    evas_object_data_set(win, "mbs", mbs);
830    
831    bx2 = elm_box_add(win);
832    evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
833    elm_box_horizontal_set(bx2, 0);
834    elm_win_resize_object_add(win, bx2);
835    evas_object_show(bx2);
836    
837    elm_scroller_content_set(sc, bx);
838    evas_object_show(bx);
839    
840    elm_scroller_page_relative_set(sc, 1.0, 1.0);
841    evas_object_show(sc);
842
843    tb2 = elm_table_add(win);
844    evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, 0.0);
845    evas_object_size_hint_fill_set(tb2, EVAS_HINT_FILL, EVAS_HINT_FILL);
846    elm_box_pack_end(bx2, tb2);
847
848    elm_box_pack_end(bx2, sc);
849    
850    ck = elm_check_add(win);
851    elm_check_label_set(ck, "Map");
852    elm_check_state_set(ck, 0);
853    evas_object_smart_callback_add(ck, "changed", l3_mode_cb, win);
854    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
855    evas_object_size_hint_align_set(ck, 0.05, 0.99);
856    elm_table_pack(tb2, ck, 0, 0, 1, 1);
857    evas_object_show(ck);
858    
859    ck = elm_check_add(win);
860    elm_check_label_set(ck, "A");
861    elm_check_state_set(ck, 1);
862    evas_object_smart_callback_add(ck, "changed", l3_alpha_cb, win);
863    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
864    evas_object_size_hint_align_set(ck, 0.20, 0.99);
865    elm_table_pack(tb2, ck, 1, 0, 1, 1);
866    evas_object_show(ck);
867    
868    ck = elm_check_add(win);
869    elm_check_label_set(ck, "Smo");
870    elm_check_state_set(ck, 1);
871    evas_object_smart_callback_add(ck, "changed", l3_smooth_cb, win);
872    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
873    evas_object_size_hint_align_set(ck, 0.40, 0.99);
874    elm_table_pack(tb2, ck, 2, 0, 1, 1);
875    evas_object_show(ck);
876    
877    ck = elm_check_add(win);
878    elm_check_label_set(ck, "FS");
879    elm_check_state_set(ck, 0);
880    evas_object_smart_callback_add(ck, "changed", l3_full_cb, win);
881    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
882    evas_object_size_hint_align_set(ck, 0.5, 0.99);
883    elm_table_pack(tb2, ck, 3, 0, 1, 1);
884    evas_object_show(ck);
885    
886    bt = elm_button_add(win);
887    elm_button_label_set(bt, "Close");
888    evas_object_smart_callback_add(bt, "clicked", l3_close_cb, win);
889    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
890    evas_object_size_hint_align_set(bt, 0.95, 0.99);
891    elm_table_pack(tb2, bt, 4, 0, 1, 1);
892    evas_object_show(bt);
893    
894    evas_object_show(tb2);
895
896    evas_object_resize(win, 480, 800);
897    evas_object_show(win);
898 }
899 #endif