summaryrefslogtreecommitdiff
path: root/src/bin/e_bg.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-06-30 14:07:28 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-06-30 14:07:28 +0000
commit472f87ff96748bd2c5d21386d80b1f74c68e7875 (patch)
tree715ed5f52cb031fae751140fc5ee31d44119bb64 /src/bin/e_bg.c
parent4285b972536ed45eec4d41cab11e57831cd75204 (diff)
ok - desktop changes are done by edje transitions now
i hereby invoke the power of edje on ye desktop wallpapers. SVN revision: 15585
Diffstat (limited to 'src/bin/e_bg.c')
-rw-r--r--src/bin/e_bg.c116
1 files changed, 44 insertions, 72 deletions
diff --git a/src/bin/e_bg.c b/src/bin/e_bg.c
index c849a59..5ed8c9e 100644
--- a/src/bin/e_bg.c
+++ b/src/bin/e_bg.c
@@ -4,7 +4,7 @@
4#include "e.h" 4#include "e.h"
5 5
6/* local subsystem functions */ 6/* local subsystem functions */
7static int _e_bg_animator(void *data); 7static void _e_bg_signal(void *data, Evas_Object *obj, const char *emission, const char *source);
8 8
9/* local subsystem globals */ 9/* local subsystem globals */
10 10
@@ -15,35 +15,13 @@ e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition)
15 Evas_Object *o; 15 Evas_Object *o;
16 Evas_List *l; 16 Evas_List *l;
17 int ok; 17 int ok;
18 18 char *trans = "";
19 if (transition == E_BG_TRANSITION_START) 19
20 { 20 if (transition == E_BG_TRANSITION_START) trans = e_config->transition_start;
21 zone->bg_transition_mode = e_config->desktop_bg_start_transition; 21 else if (transition == E_BG_TRANSITION_DESK) trans = e_config->transition_desk;
22 zone->bg_transition_time = e_config->desktop_bg_start_transition_time; 22 else if (transition == E_BG_TRANSITION_CHANGE) trans = e_config->transition_change;
23 } 23 if (strlen(trans) < 1) transition = E_BG_TRANSITION_NONE;
24 else if (transition == E_BG_TRANSITION_DESK) 24
25 {
26 zone->bg_transition_mode = e_config->desktop_bg_desk_transition;
27 zone->bg_transition_time = e_config->desktop_bg_desk_transition_time;
28 }
29 else if (transition == E_BG_TRANSITION_CHANGE)
30 {
31 zone->bg_transition_mode = e_config->desktop_bg_change_transition;
32 zone->bg_transition_time = e_config->desktop_bg_change_transition_time;
33 }
34 if ((zone->bg_transition_mode == E_BG_TRANSITION_MODE_NONE) ||
35 (zone->bg_transition_time == 0.0))
36 transition = E_BG_TRANSITION_NONE;
37 if (zone->bg_transition_mode == E_BG_TRANSITION_MODE_RANDOM)
38 {
39 zone->bg_transition_mode =
40 (rand() % (E_BG_TRANSITION_MODE_LAST - E_BG_TRANSITION_MODE_RANDOM))
41 + E_BG_TRANSITION_MODE_RANDOM + 1;
42 if (zone->bg_transition_mode <= E_BG_TRANSITION_MODE_RANDOM)
43 zone->bg_transition_mode = E_BG_TRANSITION_MODE_RANDOM + 1;
44 else if (zone->bg_transition_mode >= E_BG_TRANSITION_MODE_LAST)
45 zone->bg_transition_mode = E_BG_TRANSITION_MODE_LAST - 1;
46 }
47 if (transition == E_BG_TRANSITION_NONE) 25 if (transition == E_BG_TRANSITION_NONE)
48 { 26 {
49 if (zone->bg_object) 27 if (zone->bg_object)
@@ -52,15 +30,31 @@ e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition)
52 zone->bg_object = NULL; 30 zone->bg_object = NULL;
53 } 31 }
54 } 32 }
55 if (transition != E_BG_TRANSITION_NONE) 33 else
56 { 34 {
35 char buf[4096];
36
57 if (zone->bg_object) 37 if (zone->bg_object)
58 { 38 {
59 if (zone->prev_bg_object) 39 if (zone->prev_bg_object)
60 evas_object_del(zone->prev_bg_object); 40 evas_object_del(zone->prev_bg_object);
61 zone->prev_bg_object = zone->bg_object; 41 zone->prev_bg_object = zone->bg_object;
42 if (zone->transition_object)
43 evas_object_del(zone->transition_object);
44 zone->transition_object = NULL;
62 zone->bg_object = NULL; 45 zone->bg_object = NULL;
63 } 46 }
47 o = edje_object_add(zone->container->bg_evas);
48 zone->transition_object = o;
49 evas_object_data_set(o, "e_zone", zone);
50 snprintf(buf, sizeof(buf), "transitions/%s", trans);
51 e_theme_edje_object_set(o, "base/theme/transitions", buf);
52 edje_object_signal_callback_add(o, "done", "*", _e_bg_signal, zone);
53 evas_object_move(o, zone->x, zone->y);
54 evas_object_resize(o, zone->w, zone->h);
55 evas_object_layer_set(o, -1);
56 evas_object_clip_set(o, zone->bg_clip_object);
57 evas_object_show(o);
64 } 58 }
65 o = edje_object_add(zone->container->bg_evas); 59 o = edje_object_add(zone->container->bg_evas);
66 zone->bg_object = o; 60 zone->bg_object = o;
@@ -94,9 +88,8 @@ e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition)
94 e_theme_edje_object_set(o, "base/theme/background", 88 e_theme_edje_object_set(o, "base/theme/background",
95 "desktop/background"); 89 "desktop/background");
96 } 90 }
97 evas_object_layer_set(o, -1);
98 evas_object_lower(o);
99 91
92 evas_object_layer_set(o, -1);
100 evas_object_clip_set(o, zone->bg_clip_object); 93 evas_object_clip_set(o, zone->bg_clip_object);
101 evas_object_show(o); 94 evas_object_show(o);
102 95
@@ -117,9 +110,11 @@ e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition)
117 110
118 if (transition != E_BG_TRANSITION_NONE) 111 if (transition != E_BG_TRANSITION_NONE)
119 { 112 {
120 if (!zone->bg_animator) 113 edje_object_part_swallow(zone->transition_object, "bg_prev",
121 zone->bg_animator= ecore_animator_add(_e_bg_animator, zone); 114 zone->prev_bg_object);
122 zone->bg_set_time = ecore_time_get(); 115 edje_object_part_swallow(zone->transition_object, "bg_new",
116 zone->bg_object);
117 edje_object_signal_emit(zone->transition_object, "go", "");
123 } 118 }
124} 119}
125 120
@@ -181,49 +176,26 @@ e_bg_update(void)
181 176
182/* local subsystem functions */ 177/* local subsystem functions */
183 178
184static int 179static void
185_e_bg_animator(void *data) 180_e_bg_signal(void *data, Evas_Object *obj, const char *emission, const char *source)
186{ 181{
187 E_Zone *zone; 182 E_Zone *zone;
188 double t;
189 int a;
190 183
191 zone = data; 184 zone = data;
192 /* t is an animating INDEX 0.0 - 1.0, it is used as a lookup into 185
193 * the effect. 1.0 == finished */
194 t = (ecore_time_get() - zone->bg_set_time) / zone->bg_transition_time;
195 if (t < 0.0) t = 0.0;
196 else if (t > 1.0) t = 1.0;
197
198 if (zone->bg_transition_mode == E_BG_TRANSITION_MODE_FADE)
199 {
200 a = (1.0 - t) * 255.0;
201 if (a < 0) a = 0;
202 else if (a > 255) a = 255;
203 evas_object_color_set(zone->prev_bg_object,
204 255, 255, 255, a);
205 }
206 else if (zone->bg_transition_mode == E_BG_TRANSITION_MODE_SINUSOUDAL_FADE)
207 {
208 double t2;
209
210 t2 = (1.0 - cos(t * M_PI)) / 2.0;
211
212 a = (1.0 - t2) * 255.0;
213 if (a < 0) a = 0;
214 else if (a > 255) a = 255;
215 evas_object_color_set(zone->prev_bg_object,
216 255, 255, 255, a);
217 }
218
219 /* if we still animate.. */
220 if (t < 1.0) return 1;
221
222 if (zone->prev_bg_object) 186 if (zone->prev_bg_object)
223 { 187 {
224 evas_object_del(zone->prev_bg_object); 188 evas_object_del(zone->prev_bg_object);
225 zone->prev_bg_object = NULL; 189 zone->prev_bg_object = NULL;
226 } 190 }
227 zone->bg_animator = NULL; 191 if (zone->transition_object)
228 return 0; 192 {
193 evas_object_del(zone->transition_object);
194 zone->transition_object = NULL;
195 }
196 evas_object_move(zone->bg_object, zone->x, zone->y);
197 evas_object_resize(zone->bg_object, zone->w, zone->h);
198 evas_object_layer_set(zone->bg_object, -1);
199 evas_object_clip_set(zone->bg_object, zone->bg_clip_object);
200 evas_object_show(zone->bg_object);
229} 201}