Setup before starting fps measurement
[platform/upstream/expedite.git] / src / bin / snapshot_widgets_file_icons.c
1 #define EFL_GFX_FILTER_BETA
2
3 #undef FNAME
4 #undef NAME
5 #undef ICON
6
7 /* metadata */
8 #define FNAME snapshot_widgets_file_icons_start
9 #define NAME "Snapshot Widgets File Icons"
10 #define ICON "widgets.png"
11
12 #ifndef PROTO
13 # ifndef UI
14 #  include "main.h"
15
16 /* standard var */
17 static int done = 0;
18 /* private data */
19 #define NUM 512
20 #define ICON_SIZE 64
21 static Evas_Object *o_images[NUM];
22 static Evas_Object *o_texts[NUM];
23 static Evas_Object *o_snap;
24
25 static const char *icons[] =
26 {
27    "bug.png",
28    "bulb.png",
29    "camera.png",
30    "colorbox.png",
31
32    "e.png",
33    "error.png",
34    "flower.png",
35    "house.png",
36
37    "mushroom.png",
38    "pulse.png",
39    "typewriter.png",
40    "warning.png",
41
42    "watch.png"
43 };
44
45 /* setup */
46 static void _setup(void)
47 {
48    Evas_Object *o;
49    Evas_Coord x, y;
50    int i;
51
52    x = y = 0;
53    for (i = 0; i < NUM; i++)
54      {
55         Evas_Coord tw, th, cent;
56
57         o = efl_add(EFL_CANVAS_IMAGE_CLASS, evas);
58         o_images[i] = o;
59         efl_file_simple_load(o, build_path(icons[i % 13]), NULL);
60         efl_gfx_fill_set(o, EINA_RECT(0, 0, ICON_SIZE, ICON_SIZE));
61         efl_gfx_entity_size_set(o, EINA_SIZE2D(ICON_SIZE, ICON_SIZE));
62         efl_gfx_entity_position_set(o, EINA_POSITION2D(x + 8, y));
63         efl_gfx_entity_visible_set(o, EINA_TRUE);
64
65         o = evas_object_text_add(evas);
66         o_texts[i] = o;
67         efl_text_font_family_set(o, "Vera-Bold");
68         efl_text_font_size_set(o, 10);
69         efl_text_set(o, icons[i % 13]);
70         evas_object_text_style_set(o, EVAS_TEXT_STYLE_FAR_SOFT_SHADOW);
71         efl_gfx_color_set(o, 255, 255, 255, 255);
72         evas_object_text_shadow_color_set(o, 0, 0, 0, 24);
73         efl_gfx_entity_visible_set(o, EINA_TRUE);
74         exp_size_get(o, &tw, &th);
75         cent = ICON_SIZE + 16 - tw / 2;
76         efl_gfx_entity_position_set(o, EINA_POSITION2D(x + cent, y + ICON_SIZE + 4));
77         x += ICON_SIZE + 16;
78         if (x > win_w)
79           {
80              x = 0;
81              y += ICON_SIZE + 16;
82           }
83      }
84
85    const char *filter =
86       "blur { 5, dst = a, color = '#ff0' }"
87      ;
88
89    o = efl_add(EFL_CANVAS_SNAPSHOT_CLASS, evas);
90    o_snap = o;
91    efl_gfx_entity_visible_set(o, EINA_TRUE);
92    efl_gfx_entity_position_set(o, EINA_POSITION2D(50, 50));
93    efl_gfx_entity_size_set(o, EINA_SIZE2D(200, 200));
94    efl_gfx_fill_set(o, EINA_RECT(0, 0, 200, 200));
95    efl_gfx_filter_program_set(o, filter, "test");
96
97    done = 0;
98 }
99
100 /* cleanup */
101 static void _cleanup(void)
102 {
103    int i;
104    for (i = 0; i < NUM; i++)
105      {
106         efl_del(o_images[i]);
107         efl_del(o_texts[i]);
108      }
109    efl_del(o_snap);
110 }
111
112 /* loop - do things */
113 static int dx = 2;
114 static int dy = 2;
115
116 static void _loop(double t, int f)
117 {
118    int i;
119    Evas_Coord x, y, tw, th, cent;
120    x = 0;
121    y = 0 - f;
122    for (i = 0; i < NUM; i++)
123      {
124         efl_gfx_entity_position_set(o_images[i], EINA_POSITION2D(x + 8, y));
125         exp_size_get(o_texts[i], &tw, &th);
126         cent = (ICON_SIZE + 16 - tw) / 2;
127         efl_gfx_entity_position_set(o_texts[i], EINA_POSITION2D(x + cent, y + ICON_SIZE + 4));
128         x += ICON_SIZE + 16;
129         if (x > win_w)
130           {
131              x = 0;
132              y += ICON_SIZE + 16;
133           }
134      }
135
136    if (1)
137      {
138         evas_object_geometry_get(o_snap, &x, &y, NULL, NULL);
139         if (dx > 0)
140           {
141              if (x + dx >= win_w) dx = -dx;
142           }
143         else
144           {
145              if (x + dx <= 0) dx = -dx;
146           }
147         x = x + dx;
148
149         if (dy > 0)
150           {
151              if (y + dy >= win_h) dy = -dy;
152           }
153         else
154           {
155              if (y + dy <= 0) dy = -dy;
156           }
157         x = x + dx;
158
159         evas_object_move(o_snap, x, y);
160      }
161
162    FPS_STD(NAME);
163 }
164
165 /* prepend special key handlers if interactive (before STD) */
166 static void _key(const char *key)
167 {
168    KEY_STD;
169 }
170
171
172
173
174
175
176
177
178
179
180
181
182 /* template stuff - ignore */
183 # endif
184 #endif
185
186 #ifdef UI
187 _ui_menu_item_add(ICON, NAME, FNAME);
188 #endif
189
190 #ifdef PROTO
191 void FNAME(void);
192 #endif
193
194 #ifndef PROTO
195 # ifndef UI
196 void FNAME(void)
197 {
198    _setup();
199    ui_func_set(_key, _loop);
200 }
201 # endif
202 #endif
203 #undef FNAME
204 #undef NAME
205 #undef ICON