aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/elementary/test_floating.c
blob: b74cd4a762c8d81a66c5d953e6ca99000ebb3dc5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>

typedef struct _Testitem
{
   Elm_Object_Item *item;
   int mode;
   int onoff;
} Testitem;

static Elm_Genlist_Item_Class itc1;
static char *glf_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
   char buf[256];
   snprintf(buf, sizeof(buf), "Item # %i", (int)(uintptr_t)data);
   return strdup(buf);
}

static Evas_Object *glf_content_get(void *data EINA_UNUSED, Evas_Object *obj, const char *part EINA_UNUSED)
{
   char buf[PATH_MAX];
   Evas_Object *ic = elm_icon_add(obj);
   snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
   elm_image_file_set(ic, buf, NULL);
   evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
   return ic;
}
static Eina_Bool glf_state_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
   return EINA_FALSE;
}
static void glf_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
{
}

static void
gl_sel(void *data, Evas_Object *obj, void *event_info)
{
   printf("sel item data [%p] on genlist obj [%p], item pointer [%p]\n", data, obj, event_info);
}

static Eina_Bool
anim(void *data)
{
   Evas_Object *gl = data;
   Evas_Coord x, y;

   y = 0;
   x = (sin(ecore_loop_time_get()) * 500);
   evas_object_move(gl, x, y);
   return ECORE_CALLBACK_RENEW;
}

static void
_del(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Ecore_Animator *ani = data;

   ecore_animator_del(ani);
}

void
test_floating(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Evas_Object *win, *gl;
   int i;
   Ecore_Animator *ani;

   win = elm_win_util_standard_add("floating", "Floating");
   elm_win_autodel_set(win, EINA_TRUE);

   gl = elm_genlist_add(win);
   evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_move(gl, 800, 0);
   evas_object_resize(gl, 480, 800);
   evas_object_show(gl);

   itc1.item_style     = "default";
   itc1.func.text_get = glf_text_get;
   itc1.func.content_get  = glf_content_get;
   itc1.func.state_get = glf_state_get;
   itc1.func.del       = glf_del;

   for (i = 0; i < 20; i++)
     {
        elm_genlist_item_append(gl, &itc1,
                                (void *)(uintptr_t)i/* item data */,
                                NULL/* parent */,
                                ELM_GENLIST_ITEM_NONE,
                                gl_sel/* func */,
                                (void *)(uintptr_t)(i * 10)/* func data */);
     }
   evas_object_resize(win, 480, 800);
   evas_object_show(win);

   ani = ecore_animator_add(anim, gl);
   evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _del, ani);
}