summaryrefslogtreecommitdiff
path: root/exyz.c
blob: 790702da00f068ee49ba8106ac6f1b99ce937821 (plain)
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
#include <Elementary.h>

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

static void
my_gl_update(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Testitem *tit = data;
   tit->mode++;
   elm_genlist_item_update(tit->item);
}

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 void
my_gl_item_check_changed2(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
   Testitem *tit = data;
   tit->onoff = elm_check_state_get(obj);
   printf("item %p onoff = %i\n", tit, tit->onoff);
}

static Elm_Genlist_Item_Class itc5;
static Elm_Genlist_Item_Class itc_group;

char *gll_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part)
{
   const Testitem *tit = data;
   char buf[256];
   if (!strcmp(part, "elm.text"))
     {
        snprintf(buf, sizeof(buf), "Item mode %i", tit->mode);
     }
   else if (!strcmp(part, "elm.text.sub"))
     {
        snprintf(buf, sizeof(buf), "%i bottles on the wall", tit->mode);
     }
   return strdup(buf);
}

Evas_Object *gll_content_get(void *data, Evas_Object *obj, const char *part)
{
   const Testitem *tit = data;
   char buf[PATH_MAX];
   if (!strcmp(part, "elm.swallow.end"))
     {
        Evas_Object *ck;
        ck = elm_check_add(obj);
        evas_object_propagate_events_set(ck, EINA_FALSE);
        elm_check_state_set(ck, tit->onoff);
        evas_object_smart_callback_add(ck, "changed", my_gl_item_check_changed2, data);
        evas_object_show(ck);
        return ck;
     }
   return NULL;
}

Eina_Bool gll_state_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
   return EINA_FALSE;
}

static void
item_drag_up(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
}

static void
item_drag_down(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
}

static void
item_drag_left(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
}

static void
item_drag_right(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
}

static void
scroll_top(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
}

static void
scroll_bottom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
}

static void
scroll_left(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
}

static void
scroll_right(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
}

static void
item_drag(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
}

static void
item_drag_stop(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
}

static void
item_longpress(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
}

Evas_Object *
_content_new(Evas_Object *parent)
{
   Evas_Object *gl, *bx, *bx2, *bt, *nf = parent;
   static Testitem tit[15];

   bx = elm_box_add(nf);
   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_win_resize_object_add(nf, bx);
   evas_object_show(bx);

   gl = elm_genlist_add(nf);
   elm_genlist_select_mode_set(gl, ELM_OBJECT_SELECT_MODE_ALWAYS);
   evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(gl);

   // Not needed
   elm_genlist_homogeneous_set(gl, EINA_TRUE);

   //itc5 = elm_genlist_item_class_new();
   itc5.item_style     = "double_label";
   //itc5.item_style     = "group_index";
   itc5.func.text_get = gll_text_get;
   itc5.func.content_get  = gll_content_get;
   itc5.func.state_get = gll_state_get;
   itc5.func.del       = NULL;

   //itc_group = elm_genlist_item_class_new();
   itc_group.item_style     = "group_index";
   itc_group.func.text_get = gll_text_get;
   itc_group.func.content_get  = NULL;
   itc_group.func.state_get = NULL;
   itc_group.func.del       = NULL;

   tit[0].mode = 0;
   tit[0].item = elm_genlist_item_append(gl, &itc_group, &(tit[0]), NULL, ELM_GENLIST_ITEM_GROUP, gl_sel, NULL);
   elm_genlist_item_select_mode_set(tit[0].item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
   tit[1].mode = 1;
   tit[1].item = elm_genlist_item_append(gl, &itc5, &(tit[1]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[2].mode = 2;
   tit[2].item = elm_genlist_item_append(gl, &itc5, &(tit[2]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[3].mode = 3;
   tit[3].item = elm_genlist_item_append(gl, &itc5, &(tit[3]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[4].mode = 4;
   tit[4].item = elm_genlist_item_append(gl, &itc5, &(tit[4]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[5].mode = 5;
   tit[5].item = elm_genlist_item_append(gl, &itc5, &(tit[5]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[6].mode = 6;
   tit[6].item = elm_genlist_item_append(gl, &itc5, &(tit[6]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[7].mode = 7;
   tit[7].item = elm_genlist_item_append(gl, &itc5, &(tit[7]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[8].mode = 8;
   tit[8].item = elm_genlist_item_append(gl, &itc5, &(tit[8]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[9].mode = 9;
   tit[9].item = elm_genlist_item_append(gl, &itc5, &(tit[9]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[10].mode = 10;
   tit[10].item = elm_genlist_item_append(gl, &itc_group, &(tit[10]), NULL, ELM_GENLIST_ITEM_GROUP, gl_sel, NULL);
   elm_genlist_item_select_mode_set(tit[10].item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
   tit[11].mode = 11;
   tit[11].item = elm_genlist_item_append(gl, &itc5, &(tit[11]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[12].mode = 12;
   tit[12].item = elm_genlist_item_append(gl, &itc5, &(tit[12]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[13].mode = 13;
   tit[13].item = elm_genlist_item_append(gl, &itc5, &(tit[13]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);
   tit[14].mode = 14;
   tit[14].item = elm_genlist_item_append(gl, &itc5, &(tit[14]), NULL, ELM_GENLIST_ITEM_NONE, gl_sel, NULL);

   elm_box_pack_end(bx, gl);
   evas_object_show(bx);

   evas_object_smart_callback_add(gl, "drag,start,up", item_drag_up, NULL);
   evas_object_smart_callback_add(gl, "drag,start,down", item_drag_down, NULL);
   evas_object_smart_callback_add(gl, "drag,start,left", item_drag_left, NULL);
   evas_object_smart_callback_add(gl, "drag,start,right", item_drag_right, NULL);
   evas_object_smart_callback_add(gl, "scroll,edge,top", scroll_top, NULL);
   evas_object_smart_callback_add(gl, "scroll,edge,bottom", scroll_bottom, NULL);
   evas_object_smart_callback_add(gl, "scroll,edge,left", scroll_left, NULL);
   evas_object_smart_callback_add(gl, "scroll,edge,right", scroll_right, NULL);
   evas_object_smart_callback_add(gl, "drag", item_drag, NULL);
   evas_object_smart_callback_add(gl, "drag,stop", item_drag_stop, NULL);
   evas_object_smart_callback_add(gl, "longpressed", item_longpress, NULL);

   bx2 = elm_box_add(nf);
   elm_box_horizontal_set(bx2, EINA_TRUE);
   elm_box_homogeneous_set(bx2, EINA_TRUE);
   evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0);
   evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);

   bt = elm_button_add(nf);
   elm_object_text_set(bt, "Add itenm");
   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
   evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
   elm_box_pack_end(bx2, bt);
   evas_object_show(bt);

   bt = elm_button_add(nf);
   elm_object_text_set(bt, "Edit itenm");
   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[0]));
   evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
   elm_box_pack_end(bx2, bt);
   evas_object_show(bt);

   bt = elm_button_add(nf);
   elm_object_text_set(bt, "Add group");
   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
   evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
   elm_box_pack_end(bx2, bt);
   evas_object_show(bt);

   bt = elm_button_add(nf);
   elm_object_text_set(bt, "Edit group");
   evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
   evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
   elm_box_pack_end(bx2, bt);
   evas_object_show(bt);

   elm_box_pack_end(bx, bx2);
   evas_object_show(bx2);

   return bx;
}

void
_navi_pop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   elm_naviframe_item_pop(data);
}

void
_promote(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   elm_naviframe_item_promote(data);
}

void
_page_projects(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Evas_Object *bt, *content, *nf = data;
   Elm_Object_Item *it;

   bt = elm_button_add(nf);
   evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_smart_callback_add(bt, "clicked", _navi_pop, nf);
   elm_object_text_set(bt, "Next Actions");

   content = _content_new(nf);
   it = elm_naviframe_item_push(nf, "Projects", bt, NULL, content, NULL);
   elm_object_item_part_text_set(it, "subtitle", "List with actions items for all projects");
   evas_object_data_set(nf, "projects", it);
}

void
_page_journal(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
   Evas_Object *bt, *content, *nf = data;
   Elm_Object_Item *it;

   bt = elm_button_add(nf);
   evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_smart_callback_add(bt, "clicked", _promote,
                                  evas_object_data_get(nf, "actions"));
   elm_object_text_set(bt, "Next Actions");

   content = _content_new(nf);
   it = elm_naviframe_item_push(nf, "Journal", bt, bt, content,  NULL);
   elm_object_item_part_text_set(it, "subtitle", "Chronological list with finished items");
   evas_object_data_set(nf, "journal", it);
}

EAPI_MAIN int
elm_main(int argc, char **argv)
{
   Evas_Object *win, *nf, *btn, *btn2, *content;
   Elm_Object_Item *it;

   win = elm_win_util_standard_add("naviframe", "Naviframe");
   elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
   elm_win_autodel_set(win, EINA_TRUE);

   nf = elm_naviframe_add(win);
   evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_win_resize_object_add(win, nf);
   evas_object_show(nf);
   //evas_object_smart_callback_add(nf, "title,clicked", _title_clicked, 0);

   btn = elm_button_add(nf);
   evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_smart_callback_add(btn, "clicked", _page_journal, nf);
   elm_object_text_set(btn, "Journal");
   evas_object_show(btn);

   btn2 = elm_button_add(nf);
   evas_object_size_hint_align_set(btn2, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_smart_callback_add(btn2, "clicked", _page_projects, nf);
   elm_object_text_set(btn2, "Projects");

   content = _content_new(nf);
   it = elm_naviframe_item_push(nf, "Next Actions", btn, btn2, content, NULL);
   evas_object_data_set(nf, "actions", it);
   elm_object_item_part_text_set(it, "subtitle", "Upcoming items");

   evas_object_resize(win, 480, 700);
   evas_object_show(win);

   elm_run();
   elm_shutdown();
   return 0;
}
ELM_MAIN()