[gtk+] Add gtk_style_context_scroll_animations()



commit de36dda9251f4f60b0be575231974f3ab7bd879e
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jan 10 20:45:23 2011 +0100

    Add gtk_style_context_scroll_animations()
    
    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 |    1 +
 gtk/gtk.symbols                      |    1 +
 gtk/gtkstylecontext.c                |   70 ++++++++++++++++++++++++++++++++++
 gtk/gtkstylecontext.h                |    4 ++
 4 files changed, 76 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index b52ea6a..2646f6e 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -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
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 3625120..1f99b02 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -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
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 3d1b0aa..bad7409 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -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
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index ceedc52..309e275 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]