added clouds moving and global wind settings
authorTanya <tanya@bookdmitri.oblgaz>
Sun, 11 Apr 2010 19:17:07 +0000 (22:17 +0300)
committerTanya <tanya@bookdmitri.oblgaz>
Sun, 11 Apr 2010 19:17:07 +0000 (22:17 +0300)
applet/data/theme/Berlin/cloud2.png [new file with mode: 0644]
applet/data/theme/Berlin/cloud4.png [new file with mode: 0644]
applet/src/livewp-home-widget.c
applet/src/livewp-home-widget.h

diff --git a/applet/data/theme/Berlin/cloud2.png b/applet/data/theme/Berlin/cloud2.png
new file mode 100644 (file)
index 0000000..25abdd3
Binary files /dev/null and b/applet/data/theme/Berlin/cloud2.png differ
diff --git a/applet/data/theme/Berlin/cloud4.png b/applet/data/theme/Berlin/cloud4.png
new file mode 100644 (file)
index 0000000..ef46d54
Binary files /dev/null and b/applet/data/theme/Berlin/cloud4.png differ
index e25acb1..265ccfa 100644 (file)
@@ -226,12 +226,11 @@ init_object(AWallpaperPlugin *desktop_plugin,
 void 
 change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin)
 {
-    gint daytime, phase;
+    gint phase;
     char *newfile;
 
     if (actor){
-        daytime = get_daytime();
-        if (daytime == TIME_NIGHT){
+        if (scene.daytime == TIME_NIGHT){
             if (!actor->visible){
                 actor->visible = TRUE;
                 phase = get_moon_phase();
@@ -260,11 +259,10 @@ void
 change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin)
 {
     double alt, azm;
-    gint x, y, daytime;
+    gint x, y;
 
     if (actor){
-        daytime = get_daytime();
-        if (daytime != TIME_NIGHT){
+        if (scene.daytime != TIME_NIGHT){
             if (!actor->visible){
                 actor->visible = TRUE;
 
@@ -284,6 +282,7 @@ change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin)
     }
     
 }
+
 static void 
 change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
 {
@@ -294,7 +293,6 @@ change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
     suseconds_t ms;
     long sec;
     double t;
-    gint daytime = get_daytime();
 
     gettimeofday(&tvb, NULL);
     
@@ -304,7 +302,7 @@ change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin)
    
     if (!actor->visible){
         actor->visible = TRUE;
-        if (daytime == TIME_NIGHT)
+        if (scene.daytime == TIME_NIGHT)
             actor->filename = g_strdup("tram_dark.png");
         else
             actor->filename = g_strdup("tram.png");
@@ -335,7 +333,6 @@ change_plane1(Actor *actor, AWallpaperPlugin *desktop_plugin)
     suseconds_t ms;
     long sec;
     double t;
-    gint daytime = get_daytime();
 
     gettimeofday(&tvb, NULL);
     
@@ -345,7 +342,7 @@ change_plane1(Actor *actor, AWallpaperPlugin *desktop_plugin)
    
     if (!actor->visible){
         actor->visible = TRUE;
-        if (daytime == TIME_NIGHT)
+        if (scene.daytime == TIME_NIGHT)
             actor->filename = g_strdup("tu154.png");
         else
             actor->filename = g_strdup("tu154.png");
@@ -377,7 +374,6 @@ change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin)
     suseconds_t ms;
     long sec;
     double t;
-    gint daytime = get_daytime();
 
     gettimeofday(&tvb, NULL);
     
@@ -387,7 +383,7 @@ change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin)
    
     if (!actor->visible){
         actor->visible = TRUE;
-        if (daytime == TIME_NIGHT)
+        if (scene.daytime == TIME_NIGHT)
             actor->filename = g_strdup("plane3.png");
         else
             actor->filename = g_strdup("plane3.png");
@@ -410,6 +406,58 @@ change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin)
 }
 
 void
+change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin)
+{
+    gint x0, y0 = 300, scale0 = 100,
+         x1, y1 = -actor->height, scale1 = 150, 
+         x, y, scale;
+    struct timeval tvb;     
+    suseconds_t ms;
+    long sec;
+    double t;
+
+    gettimeofday(&tvb, NULL);
+    
+    ms = tvb.tv_usec;
+    sec = tvb.tv_sec;
+//    fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now);
+   
+    if (!actor->visible){
+        actor->visible = TRUE;
+        if (scene.daytime == TIME_NIGHT)
+            actor->filename = actor->filename;
+        else
+            actor->filename = actor->filename;
+        create_hildon_actor(actor, desktop_plugin);
+    }
+    t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
+    
+    if (scene.wind_orientation == 1){
+        x0 = -actor->width;
+        x1 = 800;
+    }
+    else {
+        x0 = 800;
+        x1 = -actor->width;
+    }
+
+    x = path_line(x0, x1, t);    
+    y = -scene.wind_angle * (x - x0) + actor->y;
+    scale = path_line(scale0, scale1, (double)(y - y0)/(y1 - y0));
+
+    //fprintf(stderr, "change cloud t=%f x=%d y=%d scale=%d\n", t, x, y, scale);
+    actor_set_position_full(actor->widget, x, y, actor->z);
+    hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(actor->widget), (double)scale/100, (double)scale/100);
+    if ((y < y1 || y > y0) || t >= 1){
+        /* stop animation */
+        actor->visible = FALSE;
+        destroy_hildon_actor(actor);
+        actor->time_start_animation = sec + 5*60;
+    }
+
+}
+
+void
 create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) 
 {
   GtkWidget *ha = NULL;
@@ -618,6 +666,8 @@ init_scene1(AWallpaperPlugin *desktop_plugin)
 
   scene.daytime = get_daytime();
   scene.actors = NULL;
+  scene.wind_orientation = -1;
+  scene.wind_angle = 0.3;
   
   actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480, 
                       TRUE, 100, 255, (gpointer)&change_static_actor, NULL);
@@ -633,12 +683,12 @@ init_scene1(AWallpaperPlugin *desktop_plugin)
   scene.actors = g_slist_append(scene.actors, actor);
 
 
-  actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 10, 50, 50, 
+  actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, 
                       TRUE, 100, 255, NULL, NULL);
   scene.actors = g_slist_append(scene.actors, actor);
 
 
-  actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 9, 800, 480, 
+  actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480, 
                       TRUE, 100, 255, (gpointer)&change_static_actor, NULL);
   change_static_actor(actor, desktop_plugin);
   scene.actors = g_slist_append(scene.actors, actor);
@@ -648,18 +698,24 @@ init_scene1(AWallpaperPlugin *desktop_plugin)
   change_moon(actor, desktop_plugin);
   scene.actors = g_slist_append(scene.actors, actor);
   
-  actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 7, 160, 50, 
+  actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50, 
                       FALSE, 100, 255, (gpointer)&change_plane2, NULL);
   actor->time_start_animation = time(NULL) + 5;
   actor->duration_animation = 60;
   scene.actors = g_slist_append(scene.actors, actor);
   
-  actor = init_object(desktop_plugin, "plane1", "tu154_small.png", 620, 233, 8, 300, 116, 
+  actor = init_object(desktop_plugin, "plane1", "tu154_small.png", 620, 233, 9, 300, 116, 
                       FALSE, 100, 255, (gpointer)&change_plane1, NULL);
   actor->time_start_animation = time(NULL) + 60;
   actor->duration_animation = 30;
   scene.actors = g_slist_append(scene.actors, actor);
 
+  actor = init_object(desktop_plugin, "cloud1", "cloud2.png", 0, 50, 11, 188, 75, 
+                      FALSE, 100, 255, (gpointer)&change_cloud, NULL);
+  actor->time_start_animation = time(NULL) + 5;
+  actor->duration_animation = 5*60;
+  scene.actors = g_slist_append(scene.actors, actor);
+
 }
 
 
index 37e0e24..0de61a3 100644 (file)
@@ -51,6 +51,8 @@ typedef struct {
     GSList * actors;
     gint daytime;
     gint timer_type;
+    gint wind_orientation; // +/- 1
+    double wind_angle; // [-1 .. 1]
 } Scene;
 /*
 typedef struct {