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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
#include <Elementary.h>
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#ifndef ELM_LIB_QUICKLAUNCH
static void
_ctxpopup_item_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
printf("ctxpopup item selected: %s\n",
elm_ctxpopup_item_label_get(event_info));
}
#define ITEM_NEW(_hov, _label, _icon) \
if(_icon) \
{ \
ic = elm_icon_add(obj); \
elm_icon_standard_set(ic, _icon); \
elm_icon_scale_set(ic, EINA_FALSE, EINA_FALSE); \
} \
else \
ic = NULL; \
it = elm_ctxpopup_item_append(_hov, _label, ic, _ctxpopup_item_cb, NULL); \
static void
_list_item_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *ctxpopup, *ic;
Elm_Ctxpopup_Item *it;
Evas_Coord x,y;
ctxpopup = elm_ctxpopup_add(obj);
ITEM_NEW(ctxpopup, "Go to home folder", "home");
ITEM_NEW(ctxpopup, "Save file", "file");
ITEM_NEW(ctxpopup, "Delete file", "delete");
ITEM_NEW(ctxpopup, "Navigate to folder", "folder");
elm_ctxpopup_item_disabled_set(it, EINA_TRUE);
ITEM_NEW(ctxpopup, "Edit entry", "edit");
ITEM_NEW(ctxpopup, "Set date and time", "clock");
elm_ctxpopup_item_disabled_set(it, EINA_TRUE);
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_size_hint_max_set(ctxpopup, 240, 240);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
}
static void
_list_item_cb2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *ctxpopup, *ic;
Elm_Ctxpopup_Item *it;
Evas_Coord x,y;
ctxpopup = elm_ctxpopup_add(obj);
ITEM_NEW(ctxpopup, NULL, "home");
ITEM_NEW(ctxpopup, NULL, "file");
ITEM_NEW(ctxpopup, NULL, "delete");
ITEM_NEW(ctxpopup, NULL, "folder");
ITEM_NEW(ctxpopup, NULL, "edit");
elm_ctxpopup_item_disabled_set(it, EINA_TRUE);
ITEM_NEW(ctxpopup, NULL, "clock");
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_size_hint_max_set(ctxpopup, 240, 240);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
}
static void
_list_item_cb3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *ctxpopup, *ic;
Elm_Ctxpopup_Item *it;
Evas_Coord x,y;
ctxpopup = elm_ctxpopup_add(obj);
ITEM_NEW(ctxpopup, "Eina", NULL);
ITEM_NEW(ctxpopup, "Eet", NULL);
ITEM_NEW(ctxpopup, "Evas", NULL);
ITEM_NEW(ctxpopup, "Ecore", NULL);
elm_ctxpopup_item_disabled_set(it, EINA_TRUE);
ITEM_NEW(ctxpopup, "Embryo", NULL);
ITEM_NEW(ctxpopup, "Edje", NULL);
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
}
static void
_list_item_cb4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *ctxpopup, *ic;
Elm_Ctxpopup_Item *it;
Evas_Coord x,y;
ctxpopup = elm_ctxpopup_add(obj);
elm_ctxpopup_horizontal_set(ctxpopup, EINA_TRUE);
ITEM_NEW(ctxpopup, NULL, "home");
ITEM_NEW(ctxpopup, NULL, "file");
ITEM_NEW(ctxpopup, NULL, "delete");
ITEM_NEW(ctxpopup, NULL, "folder");
ITEM_NEW(ctxpopup, NULL, "edit");
ITEM_NEW(ctxpopup, NULL, "clock");
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_size_hint_max_set(ctxpopup, 240, 240);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
}
static void
_list_item_cb5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *ctxpopup, *btn, *sc, *bx;
Evas_Coord x,y;
bx = elm_box_add(obj);
evas_object_size_hint_min_set(bx, 150, 150);
sc = elm_scroller_add(bx);
elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE);
evas_object_size_hint_fill_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(sc);
btn = elm_button_add(sc);
elm_object_text_set(btn, "Enlightenment");
evas_object_size_hint_min_set(btn, 140, 140);
elm_scroller_content_set(sc, btn);
elm_box_pack_end(bx, sc);
ctxpopup = elm_ctxpopup_add(obj);
elm_ctxpopup_content_set(ctxpopup, bx);
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
}
static void _list_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
elm_list_item_selected_set(event_info, EINA_FALSE);
}
void
test_ctxpopup(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *list;
win = elm_win_add(NULL, "Contextual Popup", ELM_WIN_BASIC);
elm_win_title_set(win, "Contextual Popup");
elm_win_autodel_set(win, EINA_TRUE);
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
list = elm_list_add(win);
elm_win_resize_object_add(win, list);
elm_list_mode_set(list, ELM_LIST_COMPRESS);
evas_object_smart_callback_add(list, "selected", _list_clicked, NULL);
#undef ITEM_NEW
elm_list_item_append(list, "Ctxpopup with icons and labels", NULL, NULL,
_list_item_cb, NULL);
elm_list_item_append(list, "Ctxpopup with icons only", NULL, NULL,
_list_item_cb2, NULL);
elm_list_item_append(list, "Ctxpopup with labels only", NULL, NULL,
_list_item_cb3, NULL);
elm_list_item_append(list, "Ctxpopup at horizontal mode", NULL, NULL,
_list_item_cb4, NULL);
elm_list_item_append(list, "Ctxpopup with user content", NULL, NULL,
_list_item_cb5, NULL);
evas_object_show(list);
elm_list_go(list);
evas_object_resize(win, 400, 400);
evas_object_show(win);
}
#endif
|