1 /*vim: set sw=4 ts=4 et: */
3 * This file is part of Live Wallpaper (livewp)
5 * Copyright (C) 2010 Vlad Vasiliev
6 * Copyright (C) 2010 Tanya Makova
9 * This software is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
14 * This software is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this software; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 /*******************************************************************************/
25 #include "livewp-scene.h"
28 destroy_scene(AWallpaperPlugin *desktop_plugin)
30 if (desktop_plugin->priv->scene){
31 GSList * tmp = desktop_plugin->priv->scene->actors;
33 destroy_actor(tmp->data);
34 tmp = g_slist_next(tmp);
38 desktop_plugin->priv->scene->actors = NULL;
39 if (desktop_plugin->priv->scene){
40 g_free(desktop_plugin->priv->scene);
41 desktop_plugin->priv->scene = NULL;
47 reload_scene(AWallpaperPlugin *desktop_plugin)
49 fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
50 destroy_scene(desktop_plugin);
52 if (!strcmp(desktop_plugin->priv->theme,"Modern"))
53 init_scene_Modern(desktop_plugin);
54 else if (!strcmp(desktop_plugin->priv->theme,"Berlin"))
55 init_scene_Berlin(desktop_plugin);
56 else if (!strcmp(desktop_plugin->priv->theme,"Matrix"))
57 init_scene_Matrix(desktop_plugin);
59 init_scene_theme(desktop_plugin);
64 init_scene_Accel(AWallpaperPlugin *desktop_plugin)
69 gint now = time(NULL);
71 gint sizes[4] = {170, 229, 130, 150},
72 heights[4] = {0, 100, 200, 300},
75 scene = g_new0(Scene, 1);
77 desktop_plugin->priv->scene = scene;
79 actor = init_object(desktop_plugin, "background", "bg.png",
83 scene->actors = g_slist_append(scene->actors, actor);
85 child = g_ptr_array_sized_new(12);
88 str = g_strdup_printf("tape%i_%i.png", n+1, i);
89 actor = init_object(desktop_plugin, "tape", str,
90 700*i, heights[n], 5, 700, sizes[n],
93 scene->actors = g_slist_append(scene->actors, actor);
94 g_ptr_array_add(child, actor);
99 actor = init_object(desktop_plugin, "tape1_1", "tape1_1.png",
101 TRUE, TRUE, 100, 255,
103 scene->actors = g_slist_append(scene->actors, actor);
104 g_ptr_array_add(child, actor);
106 actor = init_object(desktop_plugin, "tape1_2", "tape1_2.png",
107 1400, 0, 5, 700, 170,
108 TRUE, TRUE, 100, 255,
110 scene->actors = g_slist_append(scene->actors, actor);
111 g_ptr_array_add(child, actor);
113 actor = init_object(desktop_plugin, "tape2_0", "tape2_0.png",
115 TRUE, TRUE, 100, 255,
117 scene->actors = g_slist_append(scene->actors, actor);
118 g_ptr_array_add(child, actor);
120 actor = init_object(desktop_plugin, "tape2_1", "tape2_1.png",
121 700, 220, 5, 700, 229,
122 TRUE, TRUE, 100, 255,
124 scene->actors = g_slist_append(scene->actors, actor);
125 g_ptr_array_add(child, actor);
127 actor = init_object(desktop_plugin, "tape2_2", "tape2_2.png",
128 1400, 220, 5, 700, 229,
129 TRUE, TRUE, 100, 255,
131 scene->actors = g_slist_append(scene->actors, actor);
132 g_ptr_array_add(child, actor);
134 actor = init_object(desktop_plugin, "tape", "",
136 FALSE, FALSE, 100, 255,
137 (gpointer)&change_tape, NULL, child);
138 actor->time_start_animation = now;
139 actor->duration_animation = G_MAXINT;
140 scene->actors = g_slist_append(scene->actors, actor);
142 run_long_timeout(desktop_plugin);
146 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
151 gint now = time(NULL);
154 if (desktop_plugin->priv->rich_animation){
162 //fprintf(stderr, "init scene2 \n");
163 scene = g_new0(Scene, 1);
164 //scene.daytime = get_daytime();
165 scene->actors = NULL;
166 desktop_plugin->priv->scene = scene;
168 actor = init_object(desktop_plugin, "background", "bg.png",
170 TRUE, TRUE, 100, 255,
172 scene->actors = g_slist_append(scene->actors, actor);
174 actor = init_object(desktop_plugin, "symbols", "symbols.png",
176 TRUE, TRUE, 100, 255,
178 scene->actors = g_slist_append(scene->actors, actor);
180 child = g_ptr_array_sized_new(4);
181 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
183 TRUE, TRUE, 100, 255,
185 //actor->time_start_animation = now;
186 //actor->duration_animation = G_MAXINT;
187 scene->actors = g_slist_append(scene->actors, actor);
188 g_ptr_array_add(child, actor);
190 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
192 TRUE, TRUE, 100, 255,
194 //actor->time_start_animation = now;
195 //actor->duration_animation = G_MAXINT;
196 scene->actors = g_slist_append(scene->actors, actor);
197 g_ptr_array_add(child, actor);
199 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
201 TRUE, TRUE, 100, 255,
203 //actor->time_start_animation = now;
204 //actor->duration_animation = G_MAXINT;
205 scene->actors = g_slist_append(scene->actors, actor);
206 g_ptr_array_add(child, actor);
208 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
210 TRUE, TRUE, 100, 255,
212 //actor->time_start_animation = now;
213 //actor->duration_animation = G_MAXINT;
214 scene->actors = g_slist_append(scene->actors, actor);
215 g_ptr_array_add(child, actor);
217 actor = init_object(desktop_plugin, "layers", "",
219 FALSE, FALSE, 100, 255,
220 (gpointer)&change_layer, NULL, child);
221 actor->time_start_animation = now;
222 actor->duration_animation = G_MAXINT;
223 scene->actors = g_slist_append(scene->actors, actor);
225 run_long_timeout(desktop_plugin);
229 /* Init Modern Scene */
231 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
235 gint now = time(NULL);
240 //fprintf(stderr, "init scene \n");
241 scene = g_new0(Scene, 1);
242 scene->daytime = get_daytime();
243 scene->actors = NULL;
244 scene->wind_orientation = -1;
245 scene->wind_angle = 0.3;
246 /* init value for random */
247 scene->seed = time(NULL);
248 scene->notification = TRUE;
249 desktop_plugin->priv->scene = scene;
250 actor = init_object(desktop_plugin, "sky", "sky0.png",
252 TRUE , TRUE, 100, 255,
253 (gpointer)&change_static_actor, NULL, NULL);
254 scene->actors = g_slist_append(scene->actors, actor);
255 change_static_actor(actor, desktop_plugin);
257 actor = init_object(desktop_plugin, "sun", "sun.png",
259 FALSE, FALSE, 100, 255,
260 (gpointer)&change_sun, NULL, NULL);
261 actor->time_start_animation = now;
262 actor->duration_animation = G_MAXINT;
263 change_sun(actor, desktop_plugin);
264 scene->actors = g_slist_append(scene->actors, actor);
266 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
267 // TRUE, 100, 255, NULL, NULL);
268 //scene.actors = g_slist_append(scene.actors, actor);
270 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
271 0, fast_rnd(300)-97, 7, 150, 97,
272 FALSE, FALSE, 100, 255,
273 (gpointer)&change_cloud, NULL, NULL);
274 actor->time_start_animation = now + fast_rnd(20);
275 actor->duration_animation = 3*60;
276 scene->actors = g_slist_append(scene->actors, actor);
278 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
279 0, fast_rnd(300)-75, 7, 188, 75,
280 FALSE, FALSE, 100, 255,
281 (gpointer)&change_cloud, NULL, NULL);
282 actor->time_start_animation = now + fast_rnd(40)+10;
283 actor->duration_animation = 3*60;
284 scene->actors = g_slist_append(scene->actors, actor);
286 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
287 0, fast_rnd(300)-75, 7, 150, 75,
288 FALSE, FALSE, 100, 255,
289 (gpointer)&change_cloud, NULL, NULL);
290 actor->time_start_animation = now + fast_rnd(60) + 20;
291 actor->duration_animation = 5*60;
292 scene->actors = g_slist_append(scene->actors, actor);
295 actor = init_object(desktop_plugin, "town", "town0.png",
297 TRUE, TRUE, 100, 255,
298 (gpointer)&change_static_actor, NULL, NULL);
299 change_static_actor(actor, desktop_plugin);
300 scene->actors = g_slist_append(scene->actors, actor);
302 actor = init_object(desktop_plugin, "stend", "stend0.png",
303 452, 166, 9, 300, 305,
304 TRUE, TRUE, 100, 255,
305 (gpointer)&change_static_actor, NULL, NULL);
306 change_static_actor(actor, desktop_plugin);
307 scene->actors = g_slist_append(scene->actors, actor);
310 child = g_ptr_array_sized_new(4);
311 actor = init_object(desktop_plugin, "call", "call.png",
313 FALSE, TRUE, 100, 255,
315 scene->actors = g_slist_append(scene->actors, actor);
316 g_ptr_array_add(child, actor);
318 actor = init_object(desktop_plugin, "chat", "chat.png",
320 FALSE, TRUE, 100, 255,
322 scene->actors = g_slist_append(scene->actors, actor);
323 g_ptr_array_add(child, actor);
325 actor = init_object(desktop_plugin, "mail", "mail.png",
327 FALSE, TRUE, 100, 255,
329 scene->actors = g_slist_append(scene->actors, actor);
330 g_ptr_array_add(child, actor);
332 actor = init_object(desktop_plugin, "sms", "sms.png",
334 FALSE, TRUE, 100, 255,
336 scene->actors = g_slist_append(scene->actors, actor);
337 g_ptr_array_add(child, actor);
339 actor = init_object(desktop_plugin, "billboard_text", "",
340 470, 174, 9, 300, 108,
341 FALSE, FALSE, 100, 255,
342 (gpointer)&change_billboard, NULL, child);
343 create_hildon_actor_text(actor, desktop_plugin);
344 //actor->time_start_animation = time(NULL) + 20;
345 change_billboard(actor, desktop_plugin);
346 scene->actors = g_slist_append(scene->actors, actor);
348 actor = init_object(desktop_plugin, "tram", "tram.png",
349 -300, 225, 10, 350, 210,
350 FALSE, FALSE, 100, 255,
351 (gpointer)&change_tram, NULL, NULL);
352 actor->time_start_animation = time(NULL) + fast_rnd(10);
353 actor->duration_animation = 60;
354 scene->actors = g_slist_append(scene->actors, actor);
356 actor = init_object(desktop_plugin, "border", "border0.png",
357 0, 480-79, 11, 800, 79,
358 TRUE, TRUE, 100, 255,
359 (gpointer)&change_static_actor_with_corner, NULL, NULL);
360 change_static_actor_with_corner(actor, desktop_plugin);
361 scene->actors = g_slist_append(scene->actors, actor);
363 actor = init_object(desktop_plugin, "moon", "moon1.png",
365 FALSE, FALSE, 100, 255,
366 (gpointer)&change_moon, NULL, NULL);
367 change_moon(actor, desktop_plugin);
368 scene->actors = g_slist_append(scene->actors, actor);
370 actor = init_object(desktop_plugin, "wind", "",
372 FALSE, FALSE, 100, 255,
373 (gpointer)&change_wind, NULL, NULL);
374 change_wind(actor, desktop_plugin);
375 scene->actors = g_slist_append(scene->actors, actor);
377 /* windows in 4-th house */
417 for (i=0; i<13; i++){
418 actor = init_object(desktop_plugin, "window1", "window1.png",
419 winds[i][0], winds[i][1], 8, 8, 10,
420 FALSE, FALSE, 100, 255,
421 (gpointer)&change_window1, NULL, NULL);
422 //change_window1(actor, desktop_plugin);
423 actor->time_start_animation = now + fast_rnd(30);
424 scene->actors = g_slist_append(scene->actors, actor);
428 /* windows in 1-th house */
454 actor = init_object(desktop_plugin, "window2", "window2.png",
455 winds[i][0], winds[i][1], 8, 8, 10,
456 FALSE, FALSE, 100, 255,
457 (gpointer)&change_window1, NULL, NULL);
458 //change_window1(actor, desktop_plugin);
459 actor->time_start_animation = now + fast_rnd(30);
460 scene->actors = g_slist_append(scene->actors, actor);
464 /* windows in 3-th house */
496 for (i=0; i<10; i++){
497 actor = init_object(desktop_plugin, "window3", "window3.png",
498 winds[i][0], winds[i][1], 8, 8, 10,
499 FALSE, FALSE, 100, 255,
500 (gpointer)&change_window1, NULL, NULL);
501 //change_window1(actor, desktop_plugin);
502 actor->time_start_animation = now + fast_rnd(30);
503 scene->actors = g_slist_append(scene->actors, actor);
507 /* windows in 5-th house */
531 actor = init_object(desktop_plugin, "window4", "window4.png",
532 winds[i][0], winds[i][1], 8, 8, 10,
533 FALSE, FALSE, 100, 255,
534 (gpointer)&change_window1, NULL, NULL);
535 //change_window1(actor, desktop_plugin);
536 actor->time_start_animation = now + fast_rnd(30);
537 scene->actors = g_slist_append(scene->actors, actor);
541 /* windows in 6-th house */
562 actor = init_object(desktop_plugin, "window5", "window5.png",
563 winds[i][0], winds[i][1], 8, 8, 10,
564 FALSE, FALSE, 100, 255,
565 (gpointer)&change_window1, NULL, NULL);
566 //change_window1(actor, desktop_plugin);
567 actor->time_start_animation = now + fast_rnd(30);
568 scene->actors = g_slist_append(scene->actors, actor);
571 run_long_timeout(desktop_plugin);
574 anim = g_new0(Animation, 1);
577 anim->func_change = &change_tram;
578 anim->func_time = NULL;
579 anim->timestart = time(NULL);
582 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
586 /* Init Berlin Scene */
588 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
590 Actor *actor, *actor1, *actor2;
592 gint now = time(NULL);
595 GPtrArray *child = NULL;
597 scene = g_new0(Scene, 1);
598 scene->daytime = get_daytime();
599 scene->actors = NULL;
600 scene->wind_orientation = -1;
601 scene->wind_angle = 0.3;
602 /* init value for random */
603 scene->seed = time(NULL);
604 desktop_plugin->priv->scene = scene;
606 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
607 TRUE, TRUE, 100, 255,
608 (gpointer)&change_static_actor, NULL, NULL);
609 change_static_actor(actor, desktop_plugin);
610 scene->actors = g_slist_append(scene->actors, actor);
613 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
614 FALSE, FALSE, 100, 255,
615 (gpointer)&change_sun, NULL, NULL);
616 actor->time_start_animation = time(NULL);
617 actor->duration_animation = G_MAXINT;
618 change_sun(actor, desktop_plugin);
619 scene->actors = g_slist_append(scene->actors, actor);
622 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
623 TRUE, 100, 255, NULL, NULL);
624 scene.actors = g_slist_append(scene.actors, actor);
627 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
628 FALSE, FALSE, 100, 255,
629 (gpointer)&change_moon, NULL, NULL);
630 change_moon(actor, desktop_plugin);
631 scene->actors = g_slist_append(scene->actors, actor);
633 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
634 FALSE, FALSE, 100, 255,
635 (gpointer)&change_cloud, NULL, NULL);
636 actor->time_start_animation = now + fast_rnd(30) + 10;
637 actor->duration_animation = 3*60;
638 scene->actors = g_slist_append(scene->actors, actor);
640 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
641 FALSE, FALSE, 100, 255,
642 (gpointer)&change_cloud, NULL, NULL);
643 actor->time_start_animation = now + fast_rnd(10);
644 actor->duration_animation = 3*60;
645 scene->actors = g_slist_append(scene->actors, actor);
647 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
648 FALSE, FALSE, 100, 255,
649 (gpointer)&change_cloud, NULL, NULL);
650 actor->time_start_animation = now + fast_rnd(60) + 20;
651 actor->duration_animation = 5*60;
652 scene->actors = g_slist_append(scene->actors, actor);
655 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
656 FALSE, FALSE, 100, 255,
657 (gpointer)&change_plane2, NULL, NULL);
658 actor->time_start_animation = now + fast_rnd(40) + 20;
659 actor->duration_animation = 60;
660 scene->actors = g_slist_append(scene->actors, actor);
662 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
663 FALSE, FALSE, 100, 255,
664 (gpointer)&change_plane1, NULL, NULL);
665 actor->time_start_animation = now + fast_rnd(20);
666 actor->duration_animation = 30;
667 scene->actors = g_slist_append(scene->actors, actor);
669 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
670 TRUE, TRUE, 100, 255,
671 (gpointer)&change_static_actor_with_corner, NULL, NULL);
672 change_static_actor_with_corner(actor, desktop_plugin);
673 scene->actors = g_slist_append(scene->actors, actor);
675 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
676 FALSE, FALSE, 100, 255,
677 (gpointer)&change_wind, NULL, NULL);
678 change_wind(actor, desktop_plugin);
679 scene->actors = g_slist_append(scene->actors, actor);
681 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
682 486, 425, 10, 18, 38,
683 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
684 //actor->time_start_animation = now + fast_rnd(30) + 10;
685 scene->actors = g_slist_append(scene->actors, actor1);
687 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
688 486, 425, 10, 18, 38,
689 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
690 //actor->time_start_animation = now + fast_rnd(30) + 10;
691 scene->actors = g_slist_append(scene->actors, actor2);
692 child = g_ptr_array_sized_new(2);
693 g_ptr_array_add(child, actor1);
694 g_ptr_array_add(child, actor2);
695 actor = init_object(desktop_plugin, "signal", "",
696 486, 425, 10, 18, 38,
697 FALSE, FALSE, 100, 255,
698 (gpointer)&change_signal, NULL, child);
699 actor->time_start_animation = now + fast_rnd(30) + 10;
700 scene->actors = g_slist_append(scene->actors, actor);
741 for (i=0; i<13; i++){
742 actor = init_object(desktop_plugin, "window", "window.png",
743 winds[i][0], winds[i][1], 10, 8, 9,
744 FALSE, TRUE, 100, 255,
745 (gpointer)&change_window1, NULL, NULL);
746 //change_window1(actor, desktop_plugin);
747 actor->time_start_animation = now + fast_rnd(30);
748 scene->actors = g_slist_append(scene->actors, actor);
752 run_long_timeout(desktop_plugin);
757 init_scene_theme(AWallpaperPlugin *desktop_plugin)
759 void (*func)(gpointer);
760 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
762 (*func)(desktop_plugin);