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)
66 fprintf(stderr,"init scene accel\n");
69 gint now = time(NULL);
71 scene = g_new0(Scene, 1);
73 desktop_plugin->priv->scene = scene;
75 actor = init_object(desktop_plugin, "sky", "sky0.png",
77 TRUE , TRUE, 100, 255,
79 scene->actors = g_slist_append(scene->actors, actor);
81 actor = init_object(desktop_plugin, "sun", "sun.png",
84 (gpointer)&change_obj, NULL, NULL);
85 actor->time_start_animation = now;
86 actor->duration_animation = G_MAXINT;
87 scene->actors = g_slist_append(scene->actors, actor);
89 run_long_timeout(desktop_plugin);
93 init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
98 gint now = time(NULL);
101 if (desktop_plugin->priv->rich_animation){
109 //fprintf(stderr, "init scene2 \n");
110 scene = g_new0(Scene, 1);
111 //scene.daytime = get_daytime();
112 scene->actors = NULL;
113 desktop_plugin->priv->scene = scene;
115 actor = init_object(desktop_plugin, "background", "bg.png",
117 TRUE, TRUE, 100, 255,
119 scene->actors = g_slist_append(scene->actors, actor);
121 actor = init_object(desktop_plugin, "symbols", "symbols.png",
123 TRUE, TRUE, 100, 255,
125 scene->actors = g_slist_append(scene->actors, actor);
127 child = g_ptr_array_sized_new(4);
128 actor = init_object(desktop_plugin, "layer1", "layer1_2.png",
130 TRUE, TRUE, 100, 255,
132 //actor->time_start_animation = now;
133 //actor->duration_animation = G_MAXINT;
134 scene->actors = g_slist_append(scene->actors, actor);
135 g_ptr_array_add(child, actor);
137 actor = init_object(desktop_plugin, "layer1", "layer1_1.png",
139 TRUE, TRUE, 100, 255,
141 //actor->time_start_animation = now;
142 //actor->duration_animation = G_MAXINT;
143 scene->actors = g_slist_append(scene->actors, actor);
144 g_ptr_array_add(child, actor);
146 actor = init_object(desktop_plugin, "layer2", "layer2_2.png",
148 TRUE, TRUE, 100, 255,
150 //actor->time_start_animation = now;
151 //actor->duration_animation = G_MAXINT;
152 scene->actors = g_slist_append(scene->actors, actor);
153 g_ptr_array_add(child, actor);
155 actor = init_object(desktop_plugin, "layer2", "layer2_1.png",
157 TRUE, TRUE, 100, 255,
159 //actor->time_start_animation = now;
160 //actor->duration_animation = G_MAXINT;
161 scene->actors = g_slist_append(scene->actors, actor);
162 g_ptr_array_add(child, actor);
164 actor = init_object(desktop_plugin, "layers", "",
166 FALSE, FALSE, 100, 255,
167 (gpointer)&change_layer, NULL, child);
168 actor->time_start_animation = now;
169 actor->duration_animation = G_MAXINT;
170 scene->actors = g_slist_append(scene->actors, actor);
172 run_long_timeout(desktop_plugin);
176 /* Init Modern Scene */
178 init_scene_Modern(AWallpaperPlugin *desktop_plugin)
182 gint now = time(NULL);
187 //fprintf(stderr, "init scene \n");
188 scene = g_new0(Scene, 1);
189 scene->daytime = get_daytime();
190 scene->actors = NULL;
191 scene->wind_orientation = -1;
192 scene->wind_angle = 0.3;
193 /* init value for random */
194 scene->seed = time(NULL);
195 scene->notification = TRUE;
196 desktop_plugin->priv->scene = scene;
197 actor = init_object(desktop_plugin, "sky", "sky0.png",
199 TRUE , TRUE, 100, 255,
200 (gpointer)&change_static_actor, NULL, NULL);
201 scene->actors = g_slist_append(scene->actors, actor);
202 change_static_actor(actor, desktop_plugin);
204 actor = init_object(desktop_plugin, "sun", "sun.png",
206 FALSE, FALSE, 100, 255,
207 (gpointer)&change_sun, NULL, NULL);
208 actor->time_start_animation = now;
209 actor->duration_animation = G_MAXINT;
210 change_sun(actor, desktop_plugin);
211 scene->actors = g_slist_append(scene->actors, actor);
213 //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
214 // TRUE, 100, 255, NULL, NULL);
215 //scene.actors = g_slist_append(scene.actors, actor);
217 actor = init_object(desktop_plugin, "cloud1", "cloud1.png",
218 0, fast_rnd(300)-97, 7, 150, 97,
219 FALSE, FALSE, 100, 255,
220 (gpointer)&change_cloud, NULL, NULL);
221 actor->time_start_animation = now + fast_rnd(20);
222 actor->duration_animation = 3*60;
223 scene->actors = g_slist_append(scene->actors, actor);
225 actor = init_object(desktop_plugin, "cloud2", "cloud2.png",
226 0, fast_rnd(300)-75, 7, 188, 75,
227 FALSE, FALSE, 100, 255,
228 (gpointer)&change_cloud, NULL, NULL);
229 actor->time_start_animation = now + fast_rnd(40)+10;
230 actor->duration_animation = 3*60;
231 scene->actors = g_slist_append(scene->actors, actor);
233 actor = init_object(desktop_plugin, "cloud4", "cloud4.png",
234 0, fast_rnd(300)-75, 7, 150, 75,
235 FALSE, FALSE, 100, 255,
236 (gpointer)&change_cloud, NULL, NULL);
237 actor->time_start_animation = now + fast_rnd(60) + 20;
238 actor->duration_animation = 5*60;
239 scene->actors = g_slist_append(scene->actors, actor);
242 actor = init_object(desktop_plugin, "town", "town0.png",
244 TRUE, TRUE, 100, 255,
245 (gpointer)&change_static_actor, NULL, NULL);
246 change_static_actor(actor, desktop_plugin);
247 scene->actors = g_slist_append(scene->actors, actor);
249 actor = init_object(desktop_plugin, "stend", "stend0.png",
250 452, 166, 9, 300, 305,
251 TRUE, TRUE, 100, 255,
252 (gpointer)&change_static_actor, NULL, NULL);
253 change_static_actor(actor, desktop_plugin);
254 scene->actors = g_slist_append(scene->actors, actor);
257 child = g_ptr_array_sized_new(4);
258 actor = init_object(desktop_plugin, "call", "call.png",
260 FALSE, TRUE, 100, 255,
262 scene->actors = g_slist_append(scene->actors, actor);
263 g_ptr_array_add(child, actor);
265 actor = init_object(desktop_plugin, "chat", "chat.png",
267 FALSE, TRUE, 100, 255,
269 scene->actors = g_slist_append(scene->actors, actor);
270 g_ptr_array_add(child, actor);
272 actor = init_object(desktop_plugin, "mail", "mail.png",
274 FALSE, TRUE, 100, 255,
276 scene->actors = g_slist_append(scene->actors, actor);
277 g_ptr_array_add(child, actor);
279 actor = init_object(desktop_plugin, "sms", "sms.png",
281 FALSE, TRUE, 100, 255,
283 scene->actors = g_slist_append(scene->actors, actor);
284 g_ptr_array_add(child, actor);
286 actor = init_object(desktop_plugin, "billboard_text", "",
287 470, 174, 9, 300, 108,
288 FALSE, FALSE, 100, 255,
289 (gpointer)&change_billboard, NULL, child);
290 create_hildon_actor_text(actor, desktop_plugin);
291 //actor->time_start_animation = time(NULL) + 20;
292 change_billboard(actor, desktop_plugin);
293 scene->actors = g_slist_append(scene->actors, actor);
295 actor = init_object(desktop_plugin, "tram", "tram.png",
296 -300, 225, 10, 350, 210,
297 FALSE, FALSE, 100, 255,
298 (gpointer)&change_tram, NULL, NULL);
299 actor->time_start_animation = time(NULL) + fast_rnd(10);
300 actor->duration_animation = 60;
301 scene->actors = g_slist_append(scene->actors, actor);
303 actor = init_object(desktop_plugin, "border", "border0.png",
304 0, 480-79, 11, 800, 79,
305 TRUE, TRUE, 100, 255,
306 (gpointer)&change_static_actor_with_corner, NULL, NULL);
307 change_static_actor_with_corner(actor, desktop_plugin);
308 scene->actors = g_slist_append(scene->actors, actor);
310 actor = init_object(desktop_plugin, "moon", "moon1.png",
312 FALSE, FALSE, 100, 255,
313 (gpointer)&change_moon, NULL, NULL);
314 change_moon(actor, desktop_plugin);
315 scene->actors = g_slist_append(scene->actors, actor);
317 actor = init_object(desktop_plugin, "wind", "",
319 FALSE, FALSE, 100, 255,
320 (gpointer)&change_wind, NULL, NULL);
321 change_wind(actor, desktop_plugin);
322 scene->actors = g_slist_append(scene->actors, actor);
324 /* windows in 4-th house */
364 for (i=0; i<13; i++){
365 actor = init_object(desktop_plugin, "window1", "window1.png",
366 winds[i][0], winds[i][1], 8, 8, 10,
367 FALSE, FALSE, 100, 255,
368 (gpointer)&change_window1, NULL, NULL);
369 //change_window1(actor, desktop_plugin);
370 actor->time_start_animation = now + fast_rnd(30);
371 scene->actors = g_slist_append(scene->actors, actor);
375 /* windows in 1-th house */
401 actor = init_object(desktop_plugin, "window2", "window2.png",
402 winds[i][0], winds[i][1], 8, 8, 10,
403 FALSE, FALSE, 100, 255,
404 (gpointer)&change_window1, NULL, NULL);
405 //change_window1(actor, desktop_plugin);
406 actor->time_start_animation = now + fast_rnd(30);
407 scene->actors = g_slist_append(scene->actors, actor);
411 /* windows in 3-th house */
443 for (i=0; i<10; i++){
444 actor = init_object(desktop_plugin, "window3", "window3.png",
445 winds[i][0], winds[i][1], 8, 8, 10,
446 FALSE, FALSE, 100, 255,
447 (gpointer)&change_window1, NULL, NULL);
448 //change_window1(actor, desktop_plugin);
449 actor->time_start_animation = now + fast_rnd(30);
450 scene->actors = g_slist_append(scene->actors, actor);
454 /* windows in 5-th house */
478 actor = init_object(desktop_plugin, "window4", "window4.png",
479 winds[i][0], winds[i][1], 8, 8, 10,
480 FALSE, FALSE, 100, 255,
481 (gpointer)&change_window1, NULL, NULL);
482 //change_window1(actor, desktop_plugin);
483 actor->time_start_animation = now + fast_rnd(30);
484 scene->actors = g_slist_append(scene->actors, actor);
488 /* windows in 6-th house */
509 actor = init_object(desktop_plugin, "window5", "window5.png",
510 winds[i][0], winds[i][1], 8, 8, 10,
511 FALSE, FALSE, 100, 255,
512 (gpointer)&change_window1, NULL, NULL);
513 //change_window1(actor, desktop_plugin);
514 actor->time_start_animation = now + fast_rnd(30);
515 scene->actors = g_slist_append(scene->actors, actor);
518 run_long_timeout(desktop_plugin);
521 anim = g_new0(Animation, 1);
524 anim->func_change = &change_tram;
525 anim->func_time = NULL;
526 anim->timestart = time(NULL);
529 scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
533 /* Init Berlin Scene */
535 init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
537 Actor *actor, *actor1, *actor2;
539 gint now = time(NULL);
542 GPtrArray *child = NULL;
544 scene = g_new0(Scene, 1);
545 scene->daytime = get_daytime();
546 scene->actors = NULL;
547 scene->wind_orientation = -1;
548 scene->wind_angle = 0.3;
549 /* init value for random */
550 scene->seed = time(NULL);
551 desktop_plugin->priv->scene = scene;
553 actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480,
554 TRUE, TRUE, 100, 255,
555 (gpointer)&change_static_actor, NULL, NULL);
556 change_static_actor(actor, desktop_plugin);
557 scene->actors = g_slist_append(scene->actors, actor);
560 actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88,
561 FALSE, FALSE, 100, 255,
562 (gpointer)&change_sun, NULL, NULL);
563 actor->time_start_animation = time(NULL);
564 actor->duration_animation = G_MAXINT;
565 change_sun(actor, desktop_plugin);
566 scene->actors = g_slist_append(scene->actors, actor);
569 actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50,
570 TRUE, 100, 255, NULL, NULL);
571 scene.actors = g_slist_append(scene.actors, actor);
574 actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60,
575 FALSE, FALSE, 100, 255,
576 (gpointer)&change_moon, NULL, NULL);
577 change_moon(actor, desktop_plugin);
578 scene->actors = g_slist_append(scene->actors, actor);
580 actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97,
581 FALSE, FALSE, 100, 255,
582 (gpointer)&change_cloud, NULL, NULL);
583 actor->time_start_animation = now + fast_rnd(30) + 10;
584 actor->duration_animation = 3*60;
585 scene->actors = g_slist_append(scene->actors, actor);
587 actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75,
588 FALSE, FALSE, 100, 255,
589 (gpointer)&change_cloud, NULL, NULL);
590 actor->time_start_animation = now + fast_rnd(10);
591 actor->duration_animation = 3*60;
592 scene->actors = g_slist_append(scene->actors, actor);
594 actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75,
595 FALSE, FALSE, 100, 255,
596 (gpointer)&change_cloud, NULL, NULL);
597 actor->time_start_animation = now + fast_rnd(60) + 20;
598 actor->duration_animation = 5*60;
599 scene->actors = g_slist_append(scene->actors, actor);
602 actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50,
603 FALSE, FALSE, 100, 255,
604 (gpointer)&change_plane2, NULL, NULL);
605 actor->time_start_animation = now + fast_rnd(40) + 20;
606 actor->duration_animation = 60;
607 scene->actors = g_slist_append(scene->actors, actor);
609 actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116,
610 FALSE, FALSE, 100, 255,
611 (gpointer)&change_plane1, NULL, NULL);
612 actor->time_start_animation = now + fast_rnd(20);
613 actor->duration_animation = 30;
614 scene->actors = g_slist_append(scene->actors, actor);
616 actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480,
617 TRUE, TRUE, 100, 255,
618 (gpointer)&change_static_actor_with_corner, NULL, NULL);
619 change_static_actor_with_corner(actor, desktop_plugin);
620 scene->actors = g_slist_append(scene->actors, actor);
622 actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0,
623 FALSE, FALSE, 100, 255,
624 (gpointer)&change_wind, NULL, NULL);
625 change_wind(actor, desktop_plugin);
626 scene->actors = g_slist_append(scene->actors, actor);
628 actor1 = init_object(desktop_plugin, "signal_red", "red.png",
629 486, 425, 10, 18, 38,
630 FALSE, TRUE, 100, 255, NULL, NULL, NULL);
631 //actor->time_start_animation = now + fast_rnd(30) + 10;
632 scene->actors = g_slist_append(scene->actors, actor1);
634 actor2 = init_object(desktop_plugin, "signal_green", "green.png",
635 486, 425, 10, 18, 38,
636 TRUE, TRUE, 100, 255, NULL, NULL, NULL);
637 //actor->time_start_animation = now + fast_rnd(30) + 10;
638 scene->actors = g_slist_append(scene->actors, actor2);
639 child = g_ptr_array_sized_new(2);
640 g_ptr_array_add(child, actor1);
641 g_ptr_array_add(child, actor2);
642 actor = init_object(desktop_plugin, "signal", "",
643 486, 425, 10, 18, 38,
644 FALSE, FALSE, 100, 255,
645 (gpointer)&change_signal, NULL, child);
646 actor->time_start_animation = now + fast_rnd(30) + 10;
647 scene->actors = g_slist_append(scene->actors, actor);
688 for (i=0; i<13; i++){
689 actor = init_object(desktop_plugin, "window", "window.png",
690 winds[i][0], winds[i][1], 10, 8, 9,
691 FALSE, TRUE, 100, 255,
692 (gpointer)&change_window1, NULL, NULL);
693 //change_window1(actor, desktop_plugin);
694 actor->time_start_animation = now + fast_rnd(30);
695 scene->actors = g_slist_append(scene->actors, actor);
699 run_long_timeout(desktop_plugin);
704 init_scene_theme(AWallpaperPlugin *desktop_plugin)
706 void (*func)(gpointer);
707 func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
709 (*func)(desktop_plugin);