summaryrefslogtreecommitdiff
path: root/compbench.c
blob: d407f1458d0fe9133add358dcbdde8729b65e65d (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
#include <Elementary.h>
#include <Efx.h>
#include <errno.h>

/* screen size
 * broken for multimonitor
 */
static int sw, sh;

static Evas_Object *win, *rect;

static unsigned int max, num = 0;

static void _resize1(void *data EINA_UNUSED, Efx_Map_Data *emd EINA_UNUSED, Evas_Object *o EINA_UNUSED);

static void
_reset(void *data EINA_UNUSED, Efx_Map_Data *emd EINA_UNUSED, Evas_Object *o EINA_UNUSED)
{
   num++;
   if (max && (num == max)) ecore_main_loop_quit();
   efx_resize(rect, EFX_EFFECT_SPEED_LINEAR, NULL, 100, 100, 10.0, _resize1, NULL);
}

static void
_fs_toggle(void *data EINA_UNUSED, Efx_Map_Data *emd EINA_UNUSED, Evas_Object *o EINA_UNUSED)
{
   Eina_Bool fs = elm_win_fullscreen_get(win);

   elm_win_fullscreen_set(win, !fs);
   if (!fs) return;
   efx_resize(win, EFX_EFFECT_SPEED_LINEAR, EFX_POINT(0, 0), 400, 400, 10.0, NULL, NULL);
   efx_resize(rect, EFX_EFFECT_SPEED_LINEAR, NULL, 400, 400, 10.0, _reset, NULL);
}

static void
_queue_setup(void)
{
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(0, 30, 222, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(0, 60, 180, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(0, 90, 150, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(0, 120, 120, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(30, 150, 90, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(60, 180, 60, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(90, 210, 30, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(120, 255, 0, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(150, 220, 0, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(180, 180, 0, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(210, 150, 0, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(230, 100, 0, 255)),
     3.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(255, 0, 0, 255)),
     3.0, _fs_toggle, NULL);
}

static void
_rect_resize3(void *data EINA_UNUSED, Efx_Map_Data *emd EINA_UNUSED, Evas_Object *o EINA_UNUSED)
{
   _queue_setup();
   _queue_setup();
   efx_queue_run(rect);
}

static void
_resize1(void *data EINA_UNUSED, Efx_Map_Data *emd EINA_UNUSED, Evas_Object *o EINA_UNUSED)
{
   Efx_Queue_Data *eqd;

   eqd = efx_queue_append(win, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_RESIZE(NULL, 100, 100)),
     10.0, NULL, NULL);
   efx_queue_append(win, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_RESIZE(EFX_POINT(sw / 2, sh / 2), sw / 2, sh / 2)),
     30.0, NULL, NULL);
   efx_queue_append(win, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_RESIZE(EFX_POINT(0, 0), sw, sh)),
     30.0, NULL, NULL);
   efx_queue_run(win);

   eqd = efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_RESIZE(NULL, 1, 1)),
     10.0, NULL, NULL);
   efx_queue_effect_attach(eqd, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(0, 255, 0, 255)),
     10.0, NULL, NULL);
   eqd = efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_RESIZE(NULL, sw / 2, sh / 2)),
     30.0, NULL, NULL);
   efx_queue_effect_attach(eqd, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_FADE(0, 0, 255, 255)),
     30.0, NULL, NULL);
   efx_queue_append(rect, EFX_EFFECT_SPEED_LINEAR,
     EFX_QUEUED_EFFECT(EFX_EFFECT_RESIZE(EFX_POINT(0, 0), sw, sh)),
     30.0, _rect_resize3, NULL);
   efx_queue_run(rect);
}

int
main(int argc, char *argv[])
{
   if (argc == 2)
     {
        errno = 0;
        max = strtoul(argv[1], NULL, 10);
        if (errno) max = 0;
     }
   elm_init(argc, argv);
   efx_init();
   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add("compbench", "compbench");
   elm_win_autodel_set(win, 1);
   evas_object_show(win);
   elm_win_screen_size_get(win, NULL, NULL, &sw, &sh);
   /* objects start at 0,0
    * need to do some other move to force the 0,0 coords
    */
   evas_object_move(win, -1, -1);
   evas_object_move(win, 0, 0);
   evas_object_resize(win, 400, 400);
   rect = elm_bg_add(win);
   elm_bg_color_set(rect, 0, 0, 0);
   evas_object_size_hint_align_set(rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_size_hint_expand_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_win_resize_object_add(win, rect);
   evas_object_show(rect);

   rect = evas_object_rectangle_add(evas_object_evas_get(win));
   evas_object_resize(rect, 400, 400);
   evas_object_show(rect);
   efx_fade(rect, EFX_EFFECT_SPEED_LINEAR, EFX_COLOR(255, 0, 0), 255, 0.0, NULL, NULL);

   efx_resize(rect, EFX_EFFECT_SPEED_LINEAR, NULL, 100, 100, 10.0, _resize1, NULL);

   efx_queue_run(rect);
   ecore_main_loop_begin();
   return 0;
}