From: tanya Date: Fri, 23 Apr 2010 21:17:25 +0000 (+0300) Subject: changed struct Actor, init_object, signal logic, Matrix X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=beca89277b7c413ab78efd83f4e30e406648f1d5;p=livewp changed struct Actor, init_object, signal logic, Matrix --- diff --git a/applet/src/livewp-common.h b/applet/src/livewp-common.h index 4fe6bc7..53bbecc 100644 --- a/applet/src/livewp-common.h +++ b/applet/src/livewp-common.h @@ -95,6 +95,7 @@ typedef struct { time_t time_start_animation; gint duration_animation; void (*func_probability)(gpointer); + GPtrArray *child; } Actor; #define LIVEWP_SIGNAL_INTERFACE "org.maemo.livewp" diff --git a/applet/src/livewp-home-widget.c b/applet/src/livewp-home-widget.c index 590cb2f..3e2f606 100644 --- a/applet/src/livewp-home-widget.c +++ b/applet/src/livewp-home-widget.c @@ -185,10 +185,12 @@ init_object(AWallpaperPlugin *desktop_plugin, gint width, gint height, gboolean visible, + gboolean load_image, gint scale, gint opacity, void (*pfunc_change)(Actor*), - void (*pfunc_probability)(Actor*) + void (*pfunc_probability)(Actor*), + GPtrArray *child ) { Actor *actor = NULL; @@ -205,7 +207,8 @@ init_object(AWallpaperPlugin *desktop_plugin, actor->name = g_strdup(name); actor->func_change = (gpointer)pfunc_change; actor->func_probability = (gpointer)pfunc_probability; - if (visible) + actor->child = child; + if (load_image) create_hildon_actor(actor, desktop_plugin); else actor->widget = NULL; @@ -556,6 +559,9 @@ change_window1(Actor * actor, AWallpaperPlugin *desktop_plugin) void change_signal(Actor * actor, AWallpaperPlugin *desktop_plugin) { + gint now = time(NULL); + Actor *a; +#if 0 gchar *newfile; gint now = time(NULL); newfile = g_strdup_printf("%s%d.png", actor->name, scene.daytime); @@ -567,6 +573,24 @@ change_signal(Actor * actor, AWallpaperPlugin *desktop_plugin) actor->filename = newfile; change_hildon_actor(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30) + 10; +#endif + a = g_ptr_array_index(actor->child, 0); + //fprintf(stderr, "actor name= %p \n", child->widget); + if (a->visible) + a->visible = FALSE; + else + a->visible = TRUE; + hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(a->widget), a->visible); + + a = g_ptr_array_index(actor->child, 1); + //fprintf(stderr, "actor name= %s \n", child->name); + if (a->visible) + a->visible = FALSE; + else + a->visible = TRUE; + hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(a->widget), a->visible); + + actor->time_start_animation = now + fast_rnd(30) + 10; } void @@ -577,7 +601,6 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) GtkWidget *image = NULL; gchar *str = NULL; - /* fprintf(stderr, "create_hildon_actor %s\n", actor->name);*/ ha = hildon_animation_actor_new(); str = g_strdup_printf( "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, actor->filename); @@ -585,6 +608,7 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) actor->width, actor->height, NULL); + /*fprintf(stderr, "create_hildon_actor %s %s\n", actor->name, str);*/ if (str) g_free(str); if (pixbuf){ @@ -597,10 +621,10 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) gtk_container_add (GTK_CONTAINER (ha), image); } actor_set_position_full(ha, actor->x, actor->y, actor->z); - hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(ha), actor->visible); hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(ha), (double)actor->scale/100, (double)actor->scale/100); realize(ha); gtk_widget_show_all(ha); + hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(ha), actor->visible); /* TO DO check it */ /* gdk_flush (); */ @@ -694,6 +718,42 @@ change_static_actor_with_corner(Actor * actor, AWallpaperPlugin *desktop_plugin) } void +change_layer(Actor * actor, AWallpaperPlugin *desktop_plugin) +{ + gint y; + Actor *a; + + a = g_ptr_array_index(actor->child, 0); + y = a->y + 10; + if (y > 480) y = -480; + //fprintf(stderr, "!! %s - %d\n", actor->name, y); + actor_set_position_full(a->widget, a->x, y, a->z); + a->y = y; + + a = g_ptr_array_index(actor->child, 1); + y = a->y + 10; + if (y > 480) y = -480; + //fprintf(stderr, "!! %s - %d\n", actor->name, y); + actor_set_position_full(a->widget, a->x, y, a->z); + a->y = y; + + a = g_ptr_array_index(actor->child, 2); + y = a->y + 20; + if (y > 480) y = -480; + //fprintf(stderr, "!! %s - %d\n", actor->name, y); + actor_set_position_full(a->widget, a->x, y, a->z); + a->y = y; + + a = g_ptr_array_index(actor->child, 3); + y = a->y + 20; + if (y > 480) y = -480; + //fprintf(stderr, "!! %s - %d\n", actor->name, y); + actor_set_position_full(a->widget, a->x, y, a->z); + a->y = y; + +} + +void change_layer1(Actor * actor, AWallpaperPlugin *desktop_plugin) { gint y; @@ -761,6 +821,7 @@ static void init_scene2(AWallpaperPlugin *desktop_plugin) { Actor *actor; + GPtrArray *child; gint now = time(NULL); fprintf(stderr, "init scene2 \n"); @@ -770,43 +831,63 @@ init_scene2(AWallpaperPlugin *desktop_plugin) actor = init_object(desktop_plugin, "background", "bg.png", 0, 0, 5, 800, 480, - TRUE, 100, 255, NULL, NULL); + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); scene.actors = g_slist_append(scene.actors, actor); actor = init_object(desktop_plugin, "symbols", "symbols.png", 0, 0, 10, 800, 480, - TRUE, 100, 255, NULL, NULL); + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); scene.actors = g_slist_append(scene.actors, actor); + child = g_ptr_array_sized_new(4); actor = init_object(desktop_plugin, "layer1", "layer1_2.png", 0, -480, 6, 800, 960, - TRUE, 100, 255, (gpointer)&change_layer1, NULL); - actor->time_start_animation = now; - actor->duration_animation = G_MAXINT; - scene.actors = g_slist_append(scene.actors, actor); + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); + //actor->time_start_animation = now; + //actor->duration_animation = G_MAXINT; + //scene.actors = g_slist_append(scene.actors, actor); + g_ptr_array_add(child, actor); actor = init_object(desktop_plugin, "layer1", "layer1_1.png", 0, (-480 - 480), 7, 800, 960, - TRUE, 100, 255, (gpointer)&change_layer1, NULL); - actor->time_start_animation = now; - actor->duration_animation = G_MAXINT; - scene.actors = g_slist_append(scene.actors, actor); + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); + //actor->time_start_animation = now; + //actor->duration_animation = G_MAXINT; + //scene.actors = g_slist_append(scene.actors, actor); + g_ptr_array_add(child, actor); actor = init_object(desktop_plugin, "layer2", "layer2_2.png", 0, -480, 8, 800, 960, - TRUE, 100, 255, (gpointer)&change_layer2, NULL); - actor->time_start_animation = now; - actor->duration_animation = G_MAXINT; - scene.actors = g_slist_append(scene.actors, actor); + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); + //actor->time_start_animation = now; + //actor->duration_animation = G_MAXINT; + //scene.actors = g_slist_append(scene.actors, actor); + g_ptr_array_add(child, actor); actor = init_object(desktop_plugin, "layer2", "layer2_1.png", 0, (-480 - 480), 9, 800, 960, - TRUE, 100, 255, (gpointer)&change_layer2, NULL); + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); + //actor->time_start_animation = now; + //actor->duration_animation = G_MAXINT; + //scene.actors = g_slist_append(scene.actors, actor); + g_ptr_array_add(child, actor); + + actor = init_object(desktop_plugin, "layers", "", + 0, (-480 - 480), 9, 800, 960, + FALSE, FALSE, 100, 255, + (gpointer)&change_layer, NULL, child); actor->time_start_animation = now; actor->duration_animation = G_MAXINT; scene.actors = g_slist_append(scene.actors, actor); run_long_timeout(desktop_plugin); + } /* Init Modern Scene */ static void @@ -825,15 +906,19 @@ init_scene(AWallpaperPlugin *desktop_plugin) /* init value for random */ scene.seed = time(NULL); - + - actor = init_object(desktop_plugin, "sky", "sky0.png", 0, 0, 5, 800, 480, - TRUE, 100, 255, (gpointer)&change_static_actor, NULL); + actor = init_object(desktop_plugin, "sky", "sky0.png", + 0, 0, 5, 800, 480, + TRUE, TRUE, 100, 255, + (gpointer)&change_static_actor, NULL, NULL); change_static_actor(actor, desktop_plugin); scene.actors = g_slist_append(scene.actors, actor); - actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88, - TRUE, 100, 255, (gpointer)&change_sun, &probability_sun); + actor = init_object(desktop_plugin, "sun", "sun.png", + 0, 0, 6, 88, 88, + TRUE, TRUE, 100, 255, + (gpointer)&change_sun, &probability_sun, NULL); actor->time_start_animation = now; actor->duration_animation = G_MAXINT; change_sun(actor, desktop_plugin); @@ -843,48 +928,64 @@ init_scene(AWallpaperPlugin *desktop_plugin) // TRUE, 100, 255, NULL, NULL); //scene.actors = g_slist_append(scene.actors, actor); - actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97, - FALSE, 100, 255, (gpointer)&change_cloud, NULL); + actor = init_object(desktop_plugin, "cloud1", "cloud1.png", + 0, fast_rnd(300)-97, 7, 150, 97, + FALSE, FALSE, 100, 255, + (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(180); actor->duration_animation = 3*60; scene.actors = g_slist_append(scene.actors, actor); - actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75, - FALSE, 100, 255, (gpointer)&change_cloud, NULL); + actor = init_object(desktop_plugin, "cloud2", "cloud2.png", + 0, fast_rnd(300)-75, 7, 188, 75, + FALSE, FALSE, 100, 255, + (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(180); actor->duration_animation = 3*60; scene.actors = g_slist_append(scene.actors, actor); - actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75, - FALSE, 100, 255, (gpointer)&change_cloud, NULL); + actor = init_object(desktop_plugin, "cloud4", "cloud4.png", + 0, fast_rnd(300)-75, 7, 150, 75, + FALSE, FALSE, 100, 255, + (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(180); actor->duration_animation = 5*60; scene.actors = g_slist_append(scene.actors, actor); - actor = init_object(desktop_plugin, "town", "town0.png", 0, 0, 8, 800, 480, - TRUE, 100, 255, (gpointer)&change_static_actor, NULL); + actor = init_object(desktop_plugin, "town", "town0.png", + 0, 0, 8, 800, 480, + TRUE, TRUE, 100, 255, + (gpointer)&change_static_actor, NULL, NULL); change_static_actor(actor, desktop_plugin); scene.actors = g_slist_append(scene.actors, actor); - actor = init_object(desktop_plugin, "tram", "tram.png", -300, 225, 9, 350, 210, - FALSE, 100, 255, (gpointer)&change_tram, NULL); + actor = init_object(desktop_plugin, "tram", "tram.png", + -300, 225, 9, 350, 210, + FALSE, FALSE, 100, 255, + (gpointer)&change_tram, NULL, NULL); actor->time_start_animation = time(NULL) + fast_rnd(10); actor->duration_animation = 60; scene.actors = g_slist_append(scene.actors, actor); - actor = init_object(desktop_plugin, "border", "border0.png", 0, 480-79, 10, 800, 79, - TRUE, 100, 255, (gpointer)&change_static_actor_with_corner, NULL); + actor = init_object(desktop_plugin, "border", "border0.png", + 0, 480-79, 10, 800, 79, + TRUE, TRUE, 100, 255, + (gpointer)&change_static_actor_with_corner, NULL, NULL); change_static_actor_with_corner(actor, desktop_plugin); scene.actors = g_slist_append(scene.actors, actor); - actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 20, 6, 60, 60, - FALSE, 100, 255, (gpointer)&change_moon, NULL); + actor = init_object(desktop_plugin, "moon", "moon1.png", + 400, 20, 6, 60, 60, + FALSE, FALSE, 100, 255, + (gpointer)&change_moon, NULL, NULL); change_moon(actor, desktop_plugin); scene.actors = g_slist_append(scene.actors, actor); - actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0, - FALSE, 100, 255, (gpointer)&change_wind, NULL); + actor = init_object(desktop_plugin, "wind", "", + 0, 0, 5, 0, 0, + FALSE, FALSE, 100, 255, + (gpointer)&change_wind, NULL, NULL); change_wind(actor, desktop_plugin); scene.actors = g_slist_append(scene.actors, actor); @@ -931,7 +1032,8 @@ init_scene(AWallpaperPlugin *desktop_plugin) for (i=0; i<13; i++){ actor = init_object(desktop_plugin, "window1", "window1.png", winds[i][0], winds[i][1], 8, 8, 10, - FALSE, 100, 255, (gpointer)&change_window1, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); scene.actors = g_slist_append(scene.actors, actor); @@ -966,7 +1068,8 @@ init_scene(AWallpaperPlugin *desktop_plugin) for (i=0; i<8; i++){ actor = init_object(desktop_plugin, "window2", "window2.png", winds[i][0], winds[i][1], 8, 8, 10, - FALSE, 100, 255, (gpointer)&change_window1, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); scene.actors = g_slist_append(scene.actors, actor); @@ -1008,7 +1111,8 @@ init_scene(AWallpaperPlugin *desktop_plugin) for (i=0; i<10; i++){ actor = init_object(desktop_plugin, "window3", "window3.png", winds[i][0], winds[i][1], 8, 8, 10, - FALSE, 100, 255, (gpointer)&change_window1, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); scene.actors = g_slist_append(scene.actors, actor); @@ -1041,7 +1145,8 @@ init_scene(AWallpaperPlugin *desktop_plugin) for (i=0; i<7; i++){ actor = init_object(desktop_plugin, "window4", "window4.png", winds[i][0], winds[i][1], 8, 8, 10, - FALSE, 100, 255, (gpointer)&change_window1, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); scene.actors = g_slist_append(scene.actors, actor); @@ -1071,7 +1176,8 @@ init_scene(AWallpaperPlugin *desktop_plugin) for (i=0; i<6; i++){ actor = init_object(desktop_plugin, "window5", "window5.png", winds[i][0], winds[i][1], 8, 8, 10, - FALSE, 100, 255, (gpointer)&change_window1, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); scene.actors = g_slist_append(scene.actors, actor); @@ -1079,6 +1185,7 @@ init_scene(AWallpaperPlugin *desktop_plugin) } run_long_timeout(desktop_plugin); + #if 0 anim = g_new0(Animation, 1); anim->count = 1; @@ -1096,10 +1203,11 @@ init_scene(AWallpaperPlugin *desktop_plugin) static void init_scene1(AWallpaperPlugin *desktop_plugin) { - Actor *actor; + Actor *actor, *actor1, *actor2; gint now = time(NULL); gint i; gint winds[13][2]; + GPtrArray *child = NULL; scene.daytime = get_daytime(); scene.actors = NULL; @@ -1110,13 +1218,15 @@ init_scene1(AWallpaperPlugin *desktop_plugin) actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480, - TRUE, 100, 255, (gpointer)&change_static_actor, NULL); + TRUE, TRUE, 100, 255, + (gpointer)&change_static_actor, NULL, NULL); change_static_actor(actor, desktop_plugin); scene.actors = g_slist_append(scene.actors, actor); actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88, - TRUE, 100, 255, (gpointer)&change_sun, &probability_sun); + TRUE, TRUE, 100, 255, + (gpointer)&change_sun, &probability_sun, NULL); actor->time_start_animation = time(NULL); actor->duration_animation = G_MAXINT; change_sun(actor, desktop_plugin); @@ -1129,55 +1239,79 @@ init_scene1(AWallpaperPlugin *desktop_plugin) #endif actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60, - FALSE, 100, 255, (gpointer)&change_moon, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_moon, NULL, NULL); change_moon(actor, desktop_plugin); scene.actors = g_slist_append(scene.actors, actor); actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97, - FALSE, 100, 255, (gpointer)&change_cloud, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(180); actor->duration_animation = 3*60; scene.actors = g_slist_append(scene.actors, actor); actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75, - FALSE, 100, 255, (gpointer)&change_cloud, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(180); actor->duration_animation = 3*60; scene.actors = g_slist_append(scene.actors, actor); actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75, - FALSE, 100, 255, (gpointer)&change_cloud, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(180); actor->duration_animation = 5*60; scene.actors = g_slist_append(scene.actors, actor); actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50, - FALSE, 100, 255, (gpointer)&change_plane2, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_plane2, NULL, NULL); actor->time_start_animation = now + probability_plane(); actor->duration_animation = 60; scene.actors = g_slist_append(scene.actors, actor); actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116, - FALSE, 100, 255, (gpointer)&change_plane1, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_plane1, NULL, NULL); actor->time_start_animation = now + probability_plane(); actor->duration_animation = 30; scene.actors = g_slist_append(scene.actors, actor); actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480, - TRUE, 100, 255, (gpointer)&change_static_actor_with_corner, NULL); + TRUE, TRUE, 100, 255, + (gpointer)&change_static_actor_with_corner, NULL, NULL); change_static_actor_with_corner(actor, desktop_plugin); scene.actors = g_slist_append(scene.actors, actor); actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0, - FALSE, 100, 255, (gpointer)&change_wind, NULL); + FALSE, FALSE, 100, 255, + (gpointer)&change_wind, NULL, NULL); change_wind(actor, desktop_plugin); scene.actors = g_slist_append(scene.actors, actor); - actor = init_object(desktop_plugin, "signal", "red.png", 486, 425, 10, 18, 38, - TRUE, 100, 255, (gpointer)&change_signal, NULL); - actor->time_start_animation = now + fast_rnd(30) + 10; - scene.actors = g_slist_append(scene.actors, actor);winds[0][0] = 717; + actor1 = init_object(desktop_plugin, "signal_red", "red.png", + 486, 425, 10, 18, 38, + FALSE, TRUE, 100, 255, NULL, NULL, NULL); + //actor->time_start_animation = now + fast_rnd(30) + 10; + //scene.actors = g_slist_append(scene.actors, actor); + + actor2 = init_object(desktop_plugin, "signal_green", "green.png", + 486, 425, 10, 18, 38, + TRUE, TRUE, 100, 255, NULL, NULL, NULL); + //actor->time_start_animation = now + fast_rnd(30) + 10; + //scene.actors = g_slist_append(scene.actors, actor1); + child = g_ptr_array_sized_new(2); + g_ptr_array_add(child, actor1); + g_ptr_array_add(child, actor2); + actor = init_object(desktop_plugin, "signal", "", + 486, 425, 10, 18, 38, + FALSE, FALSE, 100, 255, + (gpointer)&change_signal, NULL, child); + actor->time_start_animation = now + fast_rnd(30) + 10; + scene.actors = g_slist_append(scene.actors, actor); winds[0][0] = 389; winds[0][1] = 305; @@ -1221,7 +1355,8 @@ init_scene1(AWallpaperPlugin *desktop_plugin) for (i=0; i<13; i++){ actor = init_object(desktop_plugin, "window", "window.png", winds[i][0], winds[i][1], 10, 8, 9, - FALSE, 100, 255, (gpointer)&change_window1, NULL); + FALSE, TRUE, 100, 255, + (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); scene.actors = g_slist_append(scene.actors, actor); @@ -1464,7 +1599,7 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin) priv->desktop_plugin = desktop_plugin; priv->visible = TRUE; priv->short_timer = 0; - priv->theme = g_strdup("Berlin"); + priv->theme = g_strdup("Modern"); desktop_plugin->priv->main_widget = gtk_fixed_new(); gtk_widget_set_size_request(desktop_plugin->priv->main_widget, 100, 32);