summaryrefslogtreecommitdiff
path: root/legacy/elementary/src/bin/test_pager.c
blob: 93a39576d8dc2e0a5aeb1963c8cbcc6b174eb886 (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
#include <Elementary.h>
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#ifndef ELM_LIB_QUICKLAUNCH
typedef struct _Pginfo Pginfo;

struct _Pginfo
{
    Evas_Object *win, *pager, *pg1, *pg2, *pg3, *pg4;
};

static void
my_pager_1(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   Pginfo *info = data;
   elm_pager_content_promote(info->pager, info->pg2);
}

static void
my_pager_2(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   Pginfo *info = data;
   elm_pager_content_promote(info->pager, info->pg3);
}

static void
my_pager_3(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   Pginfo *info = data;
   elm_pager_content_promote(info->pager, info->pg4);
}


static void
my_pager_4(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   Pginfo *info = data;
   elm_pager_content_promote(info->pager, info->pg1);
}


static void
my_pager_pop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   Pginfo *info = data;
   elm_pager_content_pop(info->pager);
}

struct style_tuple {
     const char *label;
     const char *name;
};
static const struct style_tuple styles[] = {
       { "Default", "default"},
       { "Slide", "slide"},
       { "Slide Invisible", "slide_invisible"},
       { "Fade", "fade"},
       { "Fade Translucide", "fade_translucide"},
       { "Fade Invisible", "fade_invisible"},
       { "Flip", "flip"},
};

static void
_style(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
   Evas_Object *pg = data;
   elm_object_style_set(pg, styles[elm_radio_value_get(obj)].name);
}

void
test_pager(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   Evas_Object *win, *bg, *pg, *bx, *lb, *bt;
   static Pginfo info;

   win = elm_win_add(NULL, "pager", ELM_WIN_BASIC);
   elm_win_title_set(win, "Pager");
   elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
   elm_win_autodel_set(win, EINA_TRUE);
   info.win = win;

   bg = elm_bg_add(win);
   elm_win_resize_object_add(win, bg);
   evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(bg);

   pg = elm_pager_add(win);
   evas_object_size_hint_weight_set(pg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_win_resize_object_add(win, pg);
   evas_object_show(pg);

   info.pager = pg;

   bx = elm_box_add(win);
   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(bx);

   lb = elm_label_add(win);
   elm_object_text_set(lb,
		       "This is page 1 in a pager stack.<br>"
		       "<br>"
		       "So what is a pager stack? It is a stack<br>"
		       "of pages that hold widgets in it. The<br>"
		       "pages can be pushed and popped on and<br>"
		       "off the stack, activated and otherwise<br>"
		       "activated if already in the stack<br>"
		       "(activated means promoted to the top of<br>"
		       "the stack).<br>"
		       "<br>"
		       "The theme may define the animation how<br>"
		       "show and hide of pages. Select one theme style:");
   elm_box_pack_end(bx, lb);
   evas_object_show(lb);

   unsigned int i = 0;
   Evas_Object *rdg = NULL, *rd;
   for (i = 0; i < (sizeof(styles) / sizeof(struct style_tuple)); i++)
     {
        rd = elm_radio_add(win);
        elm_object_text_set(rd, styles[i].label);
        elm_radio_state_value_set(rd, i);
        if (rdg)
          elm_radio_group_add(rd, rdg);
        else
          rdg = rd;
        evas_object_smart_callback_add(rd, "changed", _style, pg);
        elm_box_pack_end(bx, rd);
        evas_object_show(rd);
     }
   elm_radio_value_set(rd, 0);

   bt = elm_button_add(win);
   elm_object_text_set(bt, "Flip to 2");
   evas_object_smart_callback_add(bt, "clicked", my_pager_1, &info);
   elm_box_pack_end(bx, bt);
   evas_object_show(bt);

   bt = elm_button_add(win);
   elm_object_text_set(bt, "Popme");
   evas_object_smart_callback_add(bt, "clicked", my_pager_pop, &info);
   elm_box_pack_end(bx, bt);
   evas_object_show(bt);
   elm_pager_content_push(pg, bx);
   info.pg1 = bx;

   bx = elm_box_add(win);
   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(bx);

   lb = elm_label_add(win);
   elm_object_text_set(lb,
		       "This is page 2 in a pager stack.<br>"
		       "<br>"
		       "This is just like the previous page in<br>"
		       "the pager stack."
		       );
   elm_box_pack_end(bx, lb);
   evas_object_show(lb);

   bt = elm_button_add(win);
   elm_object_text_set(bt, "Flip to 3");
   evas_object_smart_callback_add(bt, "clicked", my_pager_2, &info);
   elm_box_pack_end(bx, bt);
   evas_object_show(bt);

   bt = elm_button_add(win);
   elm_object_text_set(bt, "Popme");
   evas_object_smart_callback_add(bt, "clicked", my_pager_pop, &info);
   elm_box_pack_end(bx, bt);
   evas_object_show(bt);
   elm_pager_content_push(pg, bx);
   info.pg2 = bx;

   bx = elm_box_add(win);
   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(bx);

   lb = elm_label_add(win);
   elm_object_text_set(lb,
		       "This is page 3 in a pager stack.<br>"
		       "<br>"
		       "This is just like the previous page in<br>"
		       "the pager stack.");
   elm_box_pack_end(bx, lb);
   evas_object_show(lb);

   bt = elm_button_add(win);
   elm_object_text_set(bt, "Flip to 1");
   evas_object_smart_callback_add(bt, "clicked", my_pager_3, &info);
   elm_box_pack_end(bx, bt);
   evas_object_show(bt);

   bt = elm_button_add(win);
   elm_object_text_set(bt, "Popme");
   evas_object_smart_callback_add(bt, "clicked", my_pager_pop, &info);
   elm_box_pack_end(bx, bt);
   evas_object_show(bt);
   elm_pager_content_push(pg, bx);
   info.pg3 = bx;

   Evas_Object *ly, *ly2;
   char buf[4096];

   ly = elm_layout_add(win);
   snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
   elm_layout_file_set(ly, buf, "test/layout");
   evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(ly);

   ly2 = elm_layout_add(win);
   snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
   elm_layout_file_set(ly2, buf, "layout2");
   evas_object_size_hint_weight_set(ly2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   //elm_win_resize_object_add(win, ly2);
   evas_object_show(ly2);




   bt = elm_button_add(win);
   elm_object_text_set(bt, "Flip to 1");
   evas_object_smart_callback_add(bt, "clicked", my_pager_4, &info);
   elm_layout_content_set(ly2, "element1", bt);
   evas_object_show(bt);

   bt = elm_button_add(win);
   elm_object_text_set(bt, "Popme");
   evas_object_smart_callback_add(bt, "clicked", my_pager_pop, &info);
   evas_object_show(bt);
   elm_layout_content_set(ly2, "element2", bt);

   elm_layout_content_set(ly, "swallow", ly2);
   evas_object_show(ly);

   elm_pager_content_push(pg, ly);
   info.pg4 = ly2;


   evas_object_show(win);
}

static void
my_pager_push(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   Pginfo *info = data;
   Evas_Object *bx, *bt, *lb;
   static int count = 2;
   char buf[32];

   bx = elm_box_add(info->win);
   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(bx);

   lb = elm_label_add(info->win);
   snprintf(buf, sizeof(buf), "This is page %d in the slide pager<br><br>", count++);
   elm_object_text_set(lb, buf);
   elm_box_pack_end(bx, lb);
   evas_object_show(lb);

   bt = elm_button_add(info->win);
   elm_object_text_set(bt, "Push a new page");
   evas_object_smart_callback_add(bt, "clicked", my_pager_push, info);
   elm_box_pack_end(bx, bt);
   evas_object_show(bt);

   bt = elm_button_add(info->win);
   elm_object_text_set(bt, "Go back (pop)");
   evas_object_smart_callback_add(bt, "clicked", my_pager_pop, info);
   elm_box_pack_end(bx, bt);
   evas_object_show(bt);
   elm_pager_content_push(info->pager, bx);
}

void
test_pager_slide(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
   Evas_Object *win, *bg, *pg, *bx, *lb, *bt;
   static Pginfo info;

   win = elm_win_add(NULL, "pager", ELM_WIN_BASIC);
   elm_win_title_set(win, "Pager Slide");
   elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
   elm_win_autodel_set(win, EINA_TRUE);
   info.win = win;

   bg = elm_bg_add(win);
   elm_win_resize_object_add(win, bg);
   evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(bg);

   pg = elm_pager_add(win);
   elm_win_resize_object_add(win, pg);
   elm_object_style_set(pg, "slide");
   evas_object_show(pg);
   info.pager = pg;

   bx = elm_box_add(win);
   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_show(bx);

   lb = elm_label_add(win);
   elm_object_text_set(lb,
		       "This is page 1 in a slide pager.<br>"
		       "<br>"
		       "The slide pager style is useful for browsing<br>"
		       "a hierarchy of objects, as it makes clear<br>"
		       "the direction of the browse.<br>"
		       "This is the 'slide' style, also available<br>"
		       "a fully transparent style named 'slide_invisble'.<br>"
		       "<br>");
   elm_box_pack_end(bx, lb);
   evas_object_show(lb);

   bt = elm_button_add(win);
   elm_object_text_set(bt, "Push a new page");
   evas_object_smart_callback_add(bt, "clicked", my_pager_push, &info);
   elm_box_pack_end(bx, bt);
   evas_object_show(bt);

   bt = elm_button_add(win);
   elm_object_text_set(bt, "Go back (pop)");
   evas_object_smart_callback_add(bt, "clicked", my_pager_pop, &info);
   elm_box_pack_end(bx, bt);
   evas_object_show(bt);
   elm_pager_content_push(pg, bx);

   evas_object_show(win);
}
#endif