fix conflict test_focus.c
[framework/uifw/elementary.git] / src / bin / test_floating.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6 typedef struct _Testitem
7 {
8    Elm_Object_Item *item;
9    int mode;
10    int onoff;
11 } Testitem;
12
13
14 static Elm_Genlist_Item_Class itc1;
15 static char *glf_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
16 {
17    char buf[256];
18    snprintf(buf, sizeof(buf), "Item # %i", (int)(long)data);
19    return strdup(buf);
20 }
21
22 static Evas_Object *glf_content_get(void *data __UNUSED__, Evas_Object *obj, const char *part __UNUSED__)
23 {
24    char buf[PATH_MAX];
25    Evas_Object *ic = elm_icon_add(obj);
26    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
27    elm_icon_file_set(ic, buf, NULL);
28    evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
29    return ic;
30 }
31 static Eina_Bool glf_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
32 {
33    return EINA_FALSE;
34 }
35 static void glf_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
36 {
37 }
38
39 static void
40 gl_sel(void *data, Evas_Object *obj, void *event_info)
41 {
42    printf("sel item data [%p] on genlist obj [%p], item pointer [%p]\n", data, obj, event_info);
43 }
44
45 static Eina_Bool
46 anim(void *data)
47 {
48    Evas_Object *gl = data;
49    Evas_Coord x, y;
50
51    y = 0;
52    x = (sin(ecore_loop_time_get()) * 500);
53    evas_object_move(gl, x, y);
54    return ECORE_CALLBACK_RENEW;
55 }
56
57 static void
58 _del(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
59 {
60    Ecore_Animator *ani = data;
61
62    ecore_animator_del(ani);
63 }
64
65 void
66 test_floating(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
67 {
68    Evas_Object *win, *bg, *gl;
69    int i;
70    Ecore_Animator *ani;
71
72    win = elm_win_add(NULL, "floating", ELM_WIN_BASIC);
73    elm_win_title_set(win, "Floating");
74    elm_win_autodel_set(win, EINA_TRUE);
75
76    bg = elm_bg_add(win);
77    elm_win_resize_object_add(win, bg);
78    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
79    evas_object_show(bg);
80
81    gl = elm_genlist_add(win);
82    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
83    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
84    evas_object_move(gl, 800, 0);
85    evas_object_resize(gl, 480, 800);
86    evas_object_show(gl);
87
88    itc1.item_style     = "default";
89    itc1.func.text_get = glf_text_get;
90    itc1.func.content_get  = glf_content_get;
91    itc1.func.state_get = glf_state_get;
92    itc1.func.del       = glf_del;
93
94    for (i = 0; i < 20; i++)
95      {
96         elm_genlist_item_append(gl, &itc1,
97                                 (void *)(long)i/* item data */,
98                                 NULL/* parent */,
99                                 ELM_GENLIST_ITEM_NONE,
100                                 gl_sel/* func */,
101                                 (void *)(long)(i * 10)/* func data */);
102      }
103    evas_object_resize(win, 480, 800);
104    evas_object_show(win);
105
106    ani = ecore_animator_add(anim, gl);
107    evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _del, ani);
108 }
109 #endif