summaryrefslogtreecommitdiff
path: root/src/bin/e_bg.c
diff options
context:
space:
mode:
authorViktor Kojouharov <vkojouharov@gmail.com>2009-05-07 18:39:55 +0000
committerViktor Kojouharov <vkojouharov@gmail.com>2009-05-07 18:39:55 +0000
commit648d75caab1f7c45f6dcc146b50d7591b5088dd2 (patch)
treecf15d39de3935bc943eea878519ec8bd4c2b017c /src/bin/e_bg.c
parent9825672529a8043491ccdb1bbd91f5870df76d9e (diff)
Larger backgrounds can now be set to scroll whenever a E changes between desks. Kind of like a transition, but uses only one (the first desk's), larger wallpaper instead of several wallpapers for all desks, and it overrides the transition settings if activated.
The option can currently be activated from Virtual Desktops Settings -> Advanced. A better home and preview would be better for these settings. In more detail, this option can make a wallpaper, larger than the geometry of the zone, scroll appropriately with each desk change. Consider a nice panorama picture, which is as wide as the total desks' width. Then, at most, E will scroll the background by 1 / (number of desks) for each desk change. The direction of the scrolling is dependent on the desk change itself. Also, the user can specify a coefficient of maximum scrolling for each axis. If the coefficient is 0, the wallpaper will not move. More advanced animations can be constructed with edje. The data item "directional_freedom" "(1|0) (1|0)" can toggle the actual wallpaper scrolling done by E for each axis. A message with the current x/y position, panning w|h, and zone w|h is sent to the background edje with each desk change animation tick. An example embryo script that handles the message, and changes a hypothetical "a1" part in the "e/desktop/background" group is shown below: public message(Msg_Type:type, id, ...) { if (type == MSG_INT_SET) { new x = getarg(2); new y = getarg(3); // new max_x = getarg(4); // new max_y = getarg(5); // new w = getarg(6); // new h = getarg(7); custom_state(PART:"a1", "default", 0.0); set_state_val(PART:"a1", STATE_FILL_POS, 0.0, 0.0, -x / 4, -y / 4); set_state(PART:"a1", "custom", 0.0); } } SVN revision: 40543
Diffstat (limited to 'src/bin/e_bg.c')
-rw-r--r--src/bin/e_bg.c177
1 files changed, 177 insertions, 0 deletions
diff --git a/src/bin/e_bg.c b/src/bin/e_bg.c
index b196e61..ab05368 100644
--- a/src/bin/e_bg.c
+++ b/src/bin/e_bg.c
@@ -6,11 +6,27 @@
6/* local subsystem functions */ 6/* local subsystem functions */
7static void _e_bg_signal(void *data, Evas_Object *obj, const char *emission, const char *source); 7static void _e_bg_signal(void *data, Evas_Object *obj, const char *emission, const char *source);
8static void _e_bg_event_bg_update_free(void *data, void *event); 8static void _e_bg_event_bg_update_free(void *data, void *event);
9static int _e_bg_slide_animator(void *data);
9 10
10/* local subsystem globals */ 11/* local subsystem globals */
11EAPI int E_EVENT_BG_UPDATE = 0; 12EAPI int E_EVENT_BG_UPDATE = 0;
12static E_Fm2_Mime_Handler *bg_hdl = NULL; 13static E_Fm2_Mime_Handler *bg_hdl = NULL;
13 14
15typedef struct _E_Bg_Anim_Params E_Bg_Anim_Params;
16struct _E_Bg_Anim_Params
17{
18 E_Zone *zone;
19 double start_time;
20 int start_x;
21 int start_y;
22 int end_x;
23 int end_y;
24
25 struct {
26 Eina_Bool x, y;
27 } freedom;
28};
29
14/* externally accessible functions */ 30/* externally accessible functions */
15EAPI int 31EAPI int
16e_bg_init(void) 32e_bg_init(void)
@@ -203,6 +219,7 @@ e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition)
203 else if (transition == E_BG_TRANSITION_DESK) trans = e_config->transition_desk; 219 else if (transition == E_BG_TRANSITION_DESK) trans = e_config->transition_desk;
204 else if (transition == E_BG_TRANSITION_CHANGE) trans = e_config->transition_change; 220 else if (transition == E_BG_TRANSITION_CHANGE) trans = e_config->transition_change;
205 if ((!trans) || (!trans[0])) transition = E_BG_TRANSITION_NONE; 221 if ((!trans) || (!trans[0])) transition = E_BG_TRANSITION_NONE;
222 if (e_config->desk_flip_pan_bg) transition = E_BG_TRANSITION_NONE;
206 223
207 desk = e_desk_current_get(zone); 224 desk = e_desk_current_get(zone);
208 if (desk) 225 if (desk)
@@ -265,6 +282,30 @@ e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition)
265 } 282 }
266 evas_object_clip_set(o, zone->bg_clip_object); 283 evas_object_clip_set(o, zone->bg_clip_object);
267 evas_object_show(o); 284 evas_object_show(o);
285 if (e_config->desk_flip_pan_bg)
286 {
287 int x = 0, y = 0;
288
289 o = zone->bg_scrollframe;
290 if (!o)
291 {
292 o = e_scrollframe_add(zone->container->bg_evas);
293 zone->bg_scrollframe = o;
294 e_scrollframe_custom_theme_set(o, "base/theme/background",
295 "e/desktop/background/scrollframe");
296 e_scrollframe_policy_set(o, E_SCROLLFRAME_POLICY_OFF, E_SCROLLFRAME_POLICY_OFF);
297 e_scrollframe_child_pos_set(o, 0, 0);
298 evas_object_show(o);
299 }
300 e_scrollframe_child_set(o, zone->bg_object);
301 if (desk)
302 {
303 x = desk->x;
304 y = desk->y;
305 }
306 e_bg_zone_slide(zone, x, y);
307 return;
308 }
268 309
269 if (transition != E_BG_TRANSITION_NONE) 310 if (transition != E_BG_TRANSITION_NONE)
270 { 311 {
@@ -281,6 +322,71 @@ e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition)
281} 322}
282 323
283EAPI void 324EAPI void
325e_bg_zone_slide(E_Zone *zone, int prev_x, int prev_y)
326{
327 Evas_Object *o;
328 E_Desk *desk;
329 Evas_Coord w, h, maxw, maxh, step_w, step_h;
330 Ecore_Animator *anim;
331 E_Bg_Anim_Params *params;
332 Evas_Coord vw, vh, px, py;
333 int fx, fy;
334 const void *data;
335
336 desk = e_desk_current_get(zone);
337 edje_object_size_max_get(zone->bg_object, &w, &h);
338 maxw = zone->w * zone->desk_x_count;
339 maxh = zone->h * zone->desk_y_count;
340 if (!w) w = maxw;
341 if (!h) h = maxh;
342 evas_object_resize(zone->bg_object, w, h);
343 if (zone->desk_x_count > 1)
344 step_w = ((double) (w - zone->w)) / (zone->desk_x_count - 1);
345 else step_w = 0;
346 if (zone->desk_y_count > 1)
347 step_h = ((double) (h - zone->h)) / (zone->desk_y_count - 1);
348 else step_h = 0;
349
350 o = zone->bg_scrollframe;
351 evas_object_move(o, zone->x, zone->y);
352 evas_object_resize(o, zone->w, zone->h);
353 evas_object_layer_set(o, -1);
354 evas_object_clip_set(o, zone->bg_clip_object);
355
356 data = edje_object_data_get(zone->bg_object, "directional_freedom");
357 e_scrollframe_child_viewport_size_get(o, &vw, &vh);
358 e_scrollframe_child_pos_get(o, &px, &py);
359 params = evas_object_data_get(zone->bg_object, "switch_animator_params");
360 if (!params)
361 params = E_NEW(E_Bg_Anim_Params, 1);
362 params->zone = zone;
363 params->start_x = px;
364 params->start_y = py;
365 params->end_x = desk->x * step_w * e_config->desk_flip_pan_x_axis_factor;
366 params->end_y = desk->y * step_h * e_config->desk_flip_pan_y_axis_factor;
367 params->start_time = 0.0;
368 if ((data) && (sscanf(data, "%d %d", &fx, &fy) == 2))
369 {
370 if (fx)
371 {
372 params->freedom.x = EINA_TRUE;
373 params->start_x = prev_x * step_w * e_config->desk_flip_pan_x_axis_factor;
374 }
375 if (fy)
376 {
377 params->freedom.y = EINA_TRUE;
378 params->start_y = prev_y * step_h * e_config->desk_flip_pan_y_axis_factor;
379 }
380 }
381
382 anim = evas_object_data_get(zone->bg_object, "switch_animator");
383 if (anim) ecore_animator_del(anim);
384 anim = ecore_animator_add(_e_bg_slide_animator, params);
385 evas_object_data_set(zone->bg_object, "switch_animator", anim);
386 evas_object_data_set(zone->bg_object, "switch_animator_params", params);
387}
388
389EAPI void
284e_bg_default_set(char *file) 390e_bg_default_set(char *file)
285{ 391{
286 E_Event_Bg_Update *ev; 392 E_Event_Bg_Update *ev;
@@ -440,3 +546,74 @@ _e_bg_event_bg_update_free(void *data, void *event)
440{ 546{
441 free(event); 547 free(event);
442} 548}
549
550static int
551_e_bg_slide_animator(void *data)
552{
553 E_Bg_Anim_Params *params;
554 E_Zone *zone;
555 Evas_Object *o;
556 E_Desk *desk;
557 double st;
558 double t, dt, spd;
559 Evas_Coord px, py, rx, ry, bw, bh, panw, panh;
560 Edje_Message_Int_Set *msg;
561
562 params = data;
563 zone = params->zone;
564 desk = e_desk_current_get(zone);
565 t = ecore_loop_time_get();
566 dt = -1.0;
567 spd = e_config->desk_flip_animate_time;
568
569 o = zone->bg_scrollframe;
570 if (!params->start_time)
571 st = params->start_time = t;
572 else
573 st = params->start_time;
574
575 dt = (t - st) / spd;
576 if (dt > 1.0) dt = 1.0;
577 dt = 1.0 - dt;
578 dt *= dt; /* decelerate - could be a better hack */
579
580 if (params->end_x > params->start_x)
581 rx = params->start_x + (params->end_x - params->start_x) * (1.0 - dt);
582 else
583 rx = params->end_x + (params->start_x - params->end_x) * dt;
584 if (params->freedom.x) px = zone->x;
585 else px = rx;
586
587 if (params->end_y > params->start_y)
588 ry = params->start_y + (params->end_y - params->start_y) * (1.0 - dt);
589 else
590 ry = params->end_y + (params->start_y - params->end_y) * dt;
591 if (params->freedom.y) py = zone->y;
592 else py = ry;
593
594 e_scrollframe_child_pos_set(o, px, py);
595
596 evas_object_geometry_get(zone->bg_object, NULL, NULL, &bw, &bh);
597 panw = bw - zone->w;
598 if (panw < 0) panw = 0;
599 panh = bh - zone->h;
600 if (panh < 0) panh = 0;
601 msg = alloca(sizeof(Edje_Message_Int_Set) + (5 * sizeof(int)));
602 msg->count = 6;
603 msg->val[0] = rx;
604 msg->val[1] = ry;
605 msg->val[2] = panw;
606 msg->val[3] = panh;
607 msg->val[4] = bw;
608 msg->val[5] = bh;
609 edje_object_message_send(zone->bg_object, EDJE_MESSAGE_INT_SET, 0, msg);
610
611 if (dt <= 0.0)
612 {
613 evas_object_data_del(zone->bg_object, "switch_animator");
614 evas_object_data_del(zone->bg_object, "switch_animator_params");
615 E_FREE(params);
616 return 0;
617 }
618 return 1;
619}