]> Pileus Git - ~andy/gtk/commitdiff
Add gtk_style_context_scroll_animations()
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 10 Jan 2011 19:45:23 +0000 (20:45 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Mon, 10 Jan 2011 19:49:41 +0000 (20:49 +0100)
This function will be needed in widgets like GtkTreeView,
since gdk_window_scroll() doesn't trigger the usual
mechanisms to update the invalidation area, this function
is needed together with it.

docs/reference/gtk/gtk3-sections.txt
gtk/gtk.symbols
gtk/gtkstylecontext.c
gtk/gtkstylecontext.h

index b52ea6a167e548eb52a116c4cf60d738cf7223ba..2646f6e85d4760c2e7464ce413faddddc84421a6 100644 (file)
@@ -5574,6 +5574,7 @@ gtk_style_context_notify_state_change
 gtk_style_context_pop_animatable_region
 gtk_style_context_push_animatable_region
 gtk_style_context_cancel_animations
+gtk_style_context_scroll_animations
 gtk_style_context_remove_provider
 gtk_style_context_remove_provider_for_screen
 gtk_style_context_reset_widgets
index 3625120374eb4b3d9cf6fee92dbfa4bcd3d81355..1f99b02cf095102fcc57ad17078b2c9a73fa821a 100644 (file)
@@ -2499,6 +2499,7 @@ gtk_style_context_remove_region
 gtk_style_context_reset_widgets
 gtk_style_context_restore
 gtk_style_context_save
+gtk_style_context_scroll_animations
 gtk_style_context_set_background
 gtk_style_context_set_direction
 gtk_style_context_set_junction_sides
index 3d1b0aa530560ce88b69adfdb10841defa31e7e9..bad7409a9057ecef73486ecba10e45d364fb540b 100644 (file)
@@ -2965,6 +2965,76 @@ gtk_style_context_cancel_animations (GtkStyleContext *context,
     }
 }
 
+static gboolean
+is_parent_of (GdkWindow *parent,
+              GdkWindow *child)
+{
+  GtkWidget *child_widget, *parent_widget;
+  GdkWindow *window;
+
+  gdk_window_get_user_data (child, (gpointer *) &child_widget);
+  gdk_window_get_user_data (parent, (gpointer *) &parent_widget);
+
+  if (child_widget != parent_widget &&
+      !gtk_widget_is_ancestor (child_widget, parent_widget))
+    return FALSE;
+
+  window = child;
+
+  while (window)
+    {
+      if (window == parent)
+        return TRUE;
+
+      window = gdk_window_get_parent (window);
+    }
+
+  return FALSE;
+}
+
+/**
+ * gtk_style_context_scroll_animations:
+ * @context: a #GtkStyleContext
+ * @window: a #GdkWindow used previously in
+ *          gtk_style_context_notify_state_change()
+ * @dx: Amount to scroll in the X axis
+ * @dy: Amount to scroll in the Y axis
+ *
+ * This function is analogous to gdk_window_scroll(), and
+ * should be called together with it so the invalidation
+ * areas for any ongoing animation are scrolled together
+ * with it.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_style_context_scroll_animations (GtkStyleContext *context,
+                                     GdkWindow       *window,
+                                     gint             dx,
+                                     gint             dy)
+{
+  GtkStyleContextPrivate *priv;
+  AnimationInfo *info;
+  GSList *l;
+
+  g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
+  g_return_if_fail (GDK_IS_WINDOW (window));
+
+  priv = context->priv;
+  l = priv->animations;
+
+  while (l)
+    {
+      info = l->data;
+      l = l->next;
+
+      if (info->invalidation_region &&
+          (window == info->window ||
+           is_parent_of (window, info->window)))
+        cairo_region_translate (info->invalidation_region, dx, dy);
+    }
+}
+
 /**
  * gtk_style_context_push_animatable_region:
  * @context: a #GtkStyleContext
index ceedc529c0e8ecc84f64b8785ed314e7f32f3be5..309e2755b5fe1ce5d2e676cdefa091a7c46194fc 100644 (file)
@@ -524,6 +524,10 @@ void  gtk_style_context_notify_state_change (GtkStyleContext *context,
                                              gboolean         state_value);
 void  gtk_style_context_cancel_animations   (GtkStyleContext *context,
                                              gpointer         region_id);
+void  gtk_style_context_scroll_animations   (GtkStyleContext *context,
+                                             GdkWindow       *window,
+                                             gint             dx,
+                                             gint             dy);
 
 void gtk_style_context_push_animatable_region (GtkStyleContext *context,
                                                gpointer         region_id);