Make sure that all timeouts in HildonBanner are removed
[hildon] / hildon / hildon-pannable-area.c
index 558fbb3..c05edb0 100644 (file)
 #define SCROLL_FADE_TIMEOUT 100
 #define MOTION_EVENTS_PER_SECOND 25
 #define CURSOR_STOPPED_TIMEOUT 200
 #define SCROLL_FADE_TIMEOUT 100
 #define MOTION_EVENTS_PER_SECOND 25
 #define CURSOR_STOPPED_TIMEOUT 200
-#define MAX_SPEED_THRESHOLD 250
+#define MAX_SPEED_THRESHOLD 280
 #define PANNABLE_MAX_WIDTH 788
 #define PANNABLE_MAX_HEIGHT 378
 #define PANNABLE_MAX_WIDTH 788
 #define PANNABLE_MAX_HEIGHT 378
+#define ACCEL_FACTOR 27
+#define MIN_ACCEL_THRESHOLD 40
+#define FAST_CLICK 125
 
 G_DEFINE_TYPE (HildonPannableArea, hildon_pannable_area, GTK_TYPE_BIN)
 
 
 G_DEFINE_TYPE (HildonPannableArea, hildon_pannable_area, GTK_TYPE_BIN)
 
@@ -85,6 +88,8 @@ struct _HildonPannableAreaPrivate {
   gdouble vmin;
   gdouble vmax;
   gdouble vmax_overshooting;
   gdouble vmin;
   gdouble vmax;
   gdouble vmax_overshooting;
+  gdouble accel_vel_x;
+  gdouble accel_vel_y;
   gdouble vfast_factor;
   gdouble decel;
   gdouble drag_inertia;
   gdouble vfast_factor;
   gdouble decel;
   gdouble drag_inertia;
@@ -405,7 +410,7 @@ hildon_pannable_area_class_init (HildonPannableAreaClass * klass)
                                                        "Maximum scroll velocity",
                                                        "Maximum distance the child widget should scroll "
                                                        "per 'frame', in pixels per frame.",
                                                        "Maximum scroll velocity",
                                                        "Maximum distance the child widget should scroll "
                                                        "per 'frame', in pixels per frame.",
-                                                       0, G_MAXDOUBLE, 500,
+                                                       0, G_MAXDOUBLE, 3500,
                                                        G_PARAM_READWRITE |
                                                        G_PARAM_CONSTRUCT));
 
                                                        G_PARAM_READWRITE |
                                                        G_PARAM_CONSTRUCT));
 
@@ -426,7 +431,7 @@ hildon_pannable_area_class_init (HildonPannableAreaClass * klass)
                                                        "Minimum velocity that is considered 'fast': "
                                                        "children widgets won't receive button presses. "
                                                        "Expressed as a fraction of the maximum velocity.",
                                                        "Minimum velocity that is considered 'fast': "
                                                        "children widgets won't receive button presses. "
                                                        "Expressed as a fraction of the maximum velocity.",
-                                                       0, 1, 0.02,
+                                                       0, 1, 0.01,
                                                        G_PARAM_READWRITE |
                                                        G_PARAM_CONSTRUCT));
 
                                                        G_PARAM_READWRITE |
                                                        G_PARAM_CONSTRUCT));
 
@@ -436,7 +441,7 @@ hildon_pannable_area_class_init (HildonPannableAreaClass * klass)
                                                        "Deceleration multiplier",
                                                        "The multiplier used when decelerating when in "
                                                        "acceleration scrolling mode.",
                                                        "Deceleration multiplier",
                                                        "The multiplier used when decelerating when in "
                                                        "acceleration scrolling mode.",
-                                                       0, 1.0, 0.93,
+                                                       0, 1.0, 0.85,
                                                        G_PARAM_READWRITE |
                                                        G_PARAM_CONSTRUCT));
 
                                                        G_PARAM_READWRITE |
                                                        G_PARAM_CONSTRUCT));
 
@@ -476,7 +481,7 @@ hildon_pannable_area_class_init (HildonPannableAreaClass * klass)
                                                      "Time before starting to fade the scrollbar",
                                                      "Time the scrollbar is going to be visible if the widget is not in"
                                                       "action in miliseconds",
                                                      "Time before starting to fade the scrollbar",
                                                      "Time the scrollbar is going to be visible if the widget is not in"
                                                       "action in miliseconds",
-                                                     0, G_MAXUINT, 3000,
+                                                     0, G_MAXUINT, 1000,
                                                      G_PARAM_READWRITE |
                                                      G_PARAM_CONSTRUCT));
 
                                                      G_PARAM_READWRITE |
                                                      G_PARAM_CONSTRUCT));
 
@@ -723,6 +728,8 @@ hildon_pannable_area_init (HildonPannableArea * area)
   priv->overshot_dist_y = 0;
   priv->overshooting_y = 0;
   priv->overshooting_x = 0;
   priv->overshot_dist_y = 0;
   priv->overshooting_y = 0;
   priv->overshooting_x = 0;
+  priv->accel_vel_x = 0;
+  priv->accel_vel_y = 0;
   priv->idle_id = 0;
   priv->vel_x = 0;
   priv->vel_y = 0;
   priv->idle_id = 0;
   priv->vel_x = 0;
   priv->vel_y = 0;
@@ -1257,6 +1264,13 @@ hildon_pannable_area_size_allocate (GtkWidget * widget,
       gtk_widget_size_allocate (child, &child_allocation);
     }
 
       gtk_widget_size_allocate (child, &child_allocation);
     }
 
+    if (priv->vadjust->page_size >= 0) {
+      priv->accel_vel_y = MIN (priv->vmax,
+                               priv->vadjust->upper/priv->vadjust->page_size*ACCEL_FACTOR);
+      priv->accel_vel_x = MIN (priv->vmax,
+                               priv->hadjust->upper/priv->hadjust->page_size*ACCEL_FACTOR);
+    }
+
     hv = priv->hadjust->value;
     vv = priv->vadjust->value;
 
     hv = priv->hadjust->value;
     vv = priv->vadjust->value;
 
@@ -2146,6 +2160,7 @@ hildon_pannable_axis_scroll (HildonPannableArea *area,
         gtk_widget_queue_resize (GTK_WIDGET (area));
       } else {
         *vel = 0.0;
         gtk_widget_queue_resize (GTK_WIDGET (area));
       } else {
         *vel = 0.0;
+        *scroll_to = -1;
       }
     } else if (dist > adjust->upper - adjust->page_size) {
       if (s) *s = FALSE;
       }
     } else if (dist > adjust->upper - adjust->page_size) {
       if (s) *s = FALSE;
@@ -2160,6 +2175,7 @@ hildon_pannable_axis_scroll (HildonPannableArea *area,
         gtk_widget_queue_resize (GTK_WIDGET (area));
       } else {
         *vel = 0.0;
         gtk_widget_queue_resize (GTK_WIDGET (area));
       } else {
         *vel = 0.0;
+        *scroll_to = -1;
       }
     } else {
       if ((*scroll_to) != -1) {
       }
     } else {
       if ((*scroll_to) != -1) {
@@ -2270,7 +2286,8 @@ hildon_pannable_area_scroll (HildonPannableArea *area,
                                  &priv->overshooting_y, &priv->overshot_dist_y,
                                  &priv->scroll_to_y, priv->vovershoot_max, &sy);
   } else {
                                  &priv->overshooting_y, &priv->overshot_dist_y,
                                  &priv->scroll_to_y, priv->vovershoot_max, &sy);
   } else {
-    priv->vel_y = 0;
+    priv->vel_y = 0.0;
+    priv->scroll_to_y = -1;
   }
 
   if (hscroll_visible) {
   }
 
   if (hscroll_visible) {
@@ -2278,7 +2295,8 @@ hildon_pannable_area_scroll (HildonPannableArea *area,
                                  &priv->overshooting_x, &priv->overshot_dist_x,
                                  &priv->scroll_to_x, priv->hovershoot_max, &sx);
   } else {
                                  &priv->overshooting_x, &priv->overshot_dist_x,
                                  &priv->scroll_to_x, priv->hovershoot_max, &sx);
   } else {
-    priv->vel_x = 0;
+    priv->vel_x = 0.0;
+    priv->scroll_to_x = -1;
   }
 
   if (hv != priv->hadjust->value)
   }
 
   if (hv != priv->hadjust->value)
@@ -2314,6 +2332,10 @@ hildon_pannable_area_timeout (HildonPannableArea * area)
     return FALSE;
   }
 
     return FALSE;
   }
 
+  hildon_pannable_area_scroll (area, priv->vel_x, priv->vel_y);
+
+  gdk_window_process_updates (GTK_WIDGET (area)->window, FALSE);
+
   if (!priv->button_pressed) {
     /* Decelerate gradually when pointer is raised */
     if ((!priv->overshot_dist_y) &&
   if (!priv->button_pressed) {
     /* Decelerate gradually when pointer is raised */
     if ((!priv->overshot_dist_y) &&
@@ -2358,10 +2380,6 @@ hildon_pannable_area_timeout (HildonPannableArea * area)
     return FALSE;
   }
 
     return FALSE;
   }
 
-  hildon_pannable_area_scroll (area, priv->vel_x, priv->vel_y);
-
-  gdk_window_process_updates (GTK_WIDGET (area)->window, FALSE);
-
   return TRUE;
 }
 
   return TRUE;
 }
 
@@ -2758,9 +2776,11 @@ hildon_pannable_area_button_release_cb (GtkWidget * widget,
   priv->button_pressed = FALSE;
 
   /* if widget was moving fast in the panning, increase speed even more */
   priv->button_pressed = FALSE;
 
   /* if widget was moving fast in the panning, increase speed even more */
-  if ((event->time - priv->last_press_time < 200) &&
+  if ((event->time - priv->last_press_time < FAST_CLICK) &&
       ((ABS (priv->old_vel_x) > priv->vmin) ||
       ((ABS (priv->old_vel_x) > priv->vmin) ||
-       (ABS (priv->old_vel_y) > priv->vmin)))
+       (ABS (priv->old_vel_y) > priv->vmin)) &&
+      ((ABS (priv->old_vel_x) > MIN_ACCEL_THRESHOLD) ||
+       (ABS (priv->old_vel_y) > MIN_ACCEL_THRESHOLD)))
     {
       gint symbol = 0;
 
     {
       gint symbol = 0;
 
@@ -2768,7 +2788,8 @@ hildon_pannable_area_button_release_cb (GtkWidget * widget,
         symbol = ((priv->vel_x * priv->old_vel_x) > 0) ? 1 : -1;
 
       priv->vel_x = symbol *
         symbol = ((priv->vel_x * priv->old_vel_x) > 0) ? 1 : -1;
 
       priv->vel_x = symbol *
-        (priv->old_vel_x + ((priv->old_vel_x > 0) ? priv->vmax : -priv->vmax));
+        (priv->old_vel_x + ((priv->old_vel_x > 0) ? priv->accel_vel_x
+                            : -priv->accel_vel_x));
 
       symbol = 0;
 
 
       symbol = 0;
 
@@ -2776,7 +2797,8 @@ hildon_pannable_area_button_release_cb (GtkWidget * widget,
         symbol = ((priv->vel_y * priv->old_vel_y) > 0) ? 1 : -1;
 
       priv->vel_y = symbol *
         symbol = ((priv->vel_y * priv->old_vel_y) > 0) ? 1 : -1;
 
       priv->vel_y = symbol *
-        (priv->old_vel_y + ((priv->old_vel_y > 0) ? priv->vmax : -priv->vmax));
+        (priv->old_vel_y + ((priv->old_vel_y > 0) ? priv->accel_vel_y
+                            : -priv->accel_vel_y));
 
       force_fast = FALSE;
     }
 
       force_fast = FALSE;
     }
@@ -2796,11 +2818,13 @@ hildon_pannable_area_button_release_cb (GtkWidget * widget,
     priv->scroll_indicator_alpha = 1.0;
 
     if (force_fast) {
     priv->scroll_indicator_alpha = 1.0;
 
     if (force_fast) {
-      if (ABS (priv->vel_x) > MAX_SPEED_THRESHOLD)
-        priv->vel_x = (priv->vel_x > 0) ? priv->vmax : -priv->vmax;
+      if ((ABS (priv->vel_x) > MAX_SPEED_THRESHOLD) &&
+          (priv->accel_vel_x > MAX_SPEED_THRESHOLD))
+        priv->vel_x = (priv->vel_x > 0) ? priv->accel_vel_x : -priv->accel_vel_x;
 
 
-      if (ABS (priv->vel_y) > MAX_SPEED_THRESHOLD)
-        priv->vel_y = (priv->vel_y > 0) ? priv->vmax : -priv->vmax;
+      if ((ABS (priv->vel_y) > MAX_SPEED_THRESHOLD) &&
+          (priv->accel_vel_y > MAX_SPEED_THRESHOLD))
+        priv->vel_y = (priv->vel_y > 0) ? priv->accel_vel_y : -priv->accel_vel_y;
     }
 
     if (!priv->idle_id)
     }
 
     if (!priv->idle_id)
@@ -3057,7 +3081,7 @@ hildon_pannable_calculate_vel_factor (HildonPannableArea * self)
     fct += fct_i;
   }
 
     fct += fct_i;
   }
 
-    priv->vel_factor = fct;
+  priv->vel_factor = fct;
 }
 
 /**
 }
 
 /**