containing ui setup steps in the profiling again.
[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 #if 0
68         efl_text_font_family_set(o, "Vera-Bold");
69         efl_text_font_size_set(o, 10);
70         efl_text_set(o, icons[i % 13]);
71 #else
72         evas_object_text_font_set(o, "Vera-Bold", 10);
73         evas_object_text_text_set(o, icons[i % 13]);
74 #endif
75         evas_object_text_style_set(o, EVAS_TEXT_STYLE_FAR_SOFT_SHADOW);
76         efl_gfx_color_set(o, 255, 255, 255, 255);
77         evas_object_text_shadow_color_set(o, 0, 0, 0, 24);
78         efl_gfx_entity_visible_set(o, EINA_TRUE);
79         exp_size_get(o, &tw, &th);
80         cent = ICON_SIZE + 16 - tw / 2;
81         efl_gfx_entity_position_set(o, EINA_POSITION2D(x + cent, y + ICON_SIZE + 4));
82         x += ICON_SIZE + 16;
83         if (x > win_w)
84           {
85              x = 0;
86              y += ICON_SIZE + 16;
87           }
88      }
89
90    const char *filter =
91       "blur { 5, dst = a, color = '#ff0' }"
92      ;
93
94    o = efl_add(EFL_CANVAS_SNAPSHOT_CLASS, evas);
95    o_snap = o;
96    efl_gfx_entity_visible_set(o, EINA_TRUE);
97    efl_gfx_entity_position_set(o, EINA_POSITION2D(50, 50));
98    efl_gfx_entity_size_set(o, EINA_SIZE2D(200, 200));
99    efl_gfx_fill_set(o, EINA_RECT(0, 0, 200, 200));
100    efl_gfx_filter_program_set(o, filter, "test");
101
102    done = 0;
103 }
104
105 /* cleanup */
106 static void _cleanup(void)
107 {
108    int i;
109    for (i = 0; i < NUM; i++)
110      {
111         efl_del(o_images[i]);
112         efl_del(o_texts[i]);
113      }
114    efl_del(o_snap);
115 }
116
117 /* loop - do things */
118 static int dx = 2;
119 static int dy = 2;
120
121 static void _loop(double t, int f)
122 {
123    int i;
124    Evas_Coord x, y, tw, th, cent;
125    x = 0;
126    y = 0 - f;
127    for (i = 0; i < NUM; i++)
128      {
129         efl_gfx_entity_position_set(o_images[i], EINA_POSITION2D(x + 8, y));
130         exp_size_get(o_texts[i], &tw, &th);
131         cent = (ICON_SIZE + 16 - tw) / 2;
132         efl_gfx_entity_position_set(o_texts[i], EINA_POSITION2D(x + cent, y + ICON_SIZE + 4));
133         x += ICON_SIZE + 16;
134         if (x > win_w)
135           {
136              x = 0;
137              y += ICON_SIZE + 16;
138           }
139      }
140
141    if (1)
142      {
143         evas_object_geometry_get(o_snap, &x, &y, NULL, NULL);
144         if (dx > 0)
145           {
146              if (x + dx >= win_w) dx = -dx;
147           }
148         else
149           {
150              if (x + dx <= 0) dx = -dx;
151           }
152         x = x + dx;
153
154         if (dy > 0)
155           {
156              if (y + dy >= win_h) dy = -dy;
157           }
158         else
159           {
160              if (y + dy <= 0) dy = -dy;
161           }
162         x = x + dx;
163
164         evas_object_move(o_snap, x, y);
165      }
166
167    FPS_STD(NAME);
168 }
169
170 /* prepend special key handlers if interactive (before STD) */
171 static void _key(const char *key)
172 {
173    KEY_STD;
174 }
175
176
177
178
179
180
181
182
183
184
185
186
187 /* template stuff - ignore */
188 # endif
189 #endif
190
191 #ifdef UI
192 _ui_menu_item_add(ICON, NAME, FNAME);
193 #endif
194
195 #ifdef PROTO
196 void FNAME(void);
197 #endif
198
199 #ifndef PROTO
200 # ifndef UI
201 void FNAME(void)
202 {
203    ui_func_set(_key, _loop, _setup);
204 }
205 # endif
206 #endif
207 #undef FNAME
208 #undef NAME
209 #undef ICON