fixed time to change image, added icons to slideshow and flash, added change image...
[livewp] / applet / src / livewp-actor.c
index b12a2c5..8d468f1 100644 (file)
@@ -249,6 +249,16 @@ set_actor_scale(Actor *actor, double scalex, double scaley)
 
 }
 void
+set_actor_opacity(Actor *actor, gint opacity)
+{
+    hildon_animation_actor_set_opacity(
+            HILDON_ANIMATION_ACTOR(actor->widget),
+            opacity
+    );
+
+}
+
+void
 set_actor_rotation(Actor *actor, gint axis, double degrees, gint x, gint y, gint z)
 {
     hildon_animation_actor_set_rotation(
@@ -904,31 +914,55 @@ void
 change_slideshow(Actor *actor, AWallpaperPlugin *desktop_plugin)
 {
        gint num, next, prev, now;
-       Actor *a;
-       num = actor->scale;
-       prev = actor->opacity;
-       now = time(NULL);
-       srand(now);
-       next = rand()%num;
-       while (num > 1 && next == prev)
-               next = rand()%num;
+       Actor *a1 = NULL, *a2 = NULL;
+    
+    struct timeval tvb;
+    suseconds_t ms;
+    long sec;
+    double t;
 
-       fprintf(stderr, "change slideshow num=%d prev=%d next=%d\n", num, prev, next);
+    now = time(NULL);
+       num = actor->scale; // total number of images
+       prev = actor->opacity; // number of current image
+    next = actor->z; // number of new image
+    if (next < 0){
+        // new image not selected, first step of animation
+           srand(now);
+           next = rand()%num;
+           while (num > 1 && next == prev)
+                   next = rand()%num;
+        a2 = g_ptr_array_index(actor->child, next);
+           a2->visible = TRUE;
+           create_hildon_actor(a2, desktop_plugin);
+        set_actor_opacity(a2, 0);
+        actor->z = next;
+    }else {
+        a2 = g_ptr_array_index(actor->child, next);
+    }
+           
+    gettimeofday(&tvb, NULL);
+
+    ms = tvb.tv_usec;
+    sec = tvb.tv_sec;
+
+    t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation;
+    
+    set_actor_opacity(a2, path_line(0, 255, t));
 
        if (prev > -1){
-               //hide prev
-               fprintf(stderr, "desctory %d\n", prev);
-               a = g_ptr_array_index(actor->child, prev);
-               a->visible = FALSE;
-               destroy_hildon_actor(a);
+               a1 = g_ptr_array_index(actor->child, prev);
+        set_actor_opacity(a1, path_line(255, 0, t));
        }
-       //show next
-       fprintf(stderr, "show %d\n", next);
-       a = g_ptr_array_index(actor->child, next);
-       a->visible = TRUE;
-       create_hildon_actor(a, desktop_plugin);
-       actor->opacity = next;
-       actor->time_start_animation = now + 5;
+    if (t >= 1){
+        // last step of animation
+               actor->opacity = next;
+        actor->z = -1;
+        if (prev > -1){
+                   a1->visible = FALSE;
+                   destroy_hildon_actor(a1);
+        }
+           actor->time_start_animation = now + desktop_plugin->priv->theme_int_parametr1;
+    }
 }
 
 void