[gtk+/wip/actor: 11/42] xxx: actor



commit 2302d4095dddf1aa5c563067ae60622c2ad5cd63
Author: Benjamin Otte <otte redhat com>
Date:   Mon Dec 10 02:57:40 2012 +0100

    xxx: actor

 gtk/actors/gtkactor.c        |   70 +++++++++++++++++++++++++++++++++++++++--
 gtk/actors/gtkactorprivate.h |    5 ++-
 2 files changed, 70 insertions(+), 5 deletions(-)
---
diff --git a/gtk/actors/gtkactor.c b/gtk/actors/gtkactor.c
index d4ebeb9..fe6828a 100644
--- a/gtk/actors/gtkactor.c
+++ b/gtk/actors/gtkactor.c
@@ -324,7 +324,7 @@ gtk_actor_real_unmap (GtkActor *self)
   GtkActorPrivate *priv = self->priv;
   GtkActor *iter;
 
-  for (iter = self->priv->first_child;
+  for (iter = priv->first_child;
        iter != NULL;
        iter = iter->priv->next_sibling)
     {
@@ -353,6 +353,21 @@ gtk_actor_real_unrealize (GtkActor *self)
   g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_REALIZED]);
 }
 
+void
+gtk_actor_real_draw (GtkActor *self,
+                     cairo_t  *cr)
+{
+  GtkActorPrivate *priv = self->priv;
+  GtkActor *iter;
+
+  for (iter = priv->first_child;
+       iter != NULL;
+       iter = iter->priv->next_sibling)
+    {
+      _gtk_actor_draw (iter, cr);
+    }
+}
+
 static void 
 gtk_actor_real_parent_set (GtkActor *self,
                            GtkActor *old_parent)
@@ -434,9 +449,7 @@ _gtk_actor_class_init (GtkActorClass *klass)
   klass->unrealize = gtk_actor_real_unrealize;
   klass->map = gtk_actor_real_map;
   klass->unmap = gtk_actor_real_unmap;
-#if 0
   klass->draw = gtk_actor_real_draw;
-#endif
   klass->parent_set = gtk_actor_real_parent_set;
   klass->queue_relayout = gtk_actor_real_queue_relayout;
   klass->queue_redraw = gtk_actor_real_queue_redraw;
@@ -2234,6 +2247,54 @@ _gtk_actor_hide (GtkActor *self)
 }
 
 /**
+ * _gtk_actor_draw:
+ * @self: The #GtkActor to draw.
+ * @cr: a cairo context to draw to
+ *
+ * Draws @self to @cr. The top left corner of the actor will be
+ * drawn to the currently set origin point of @cr.
+ *
+ * The actor must be visible and a size must be allocated or this
+ * function will not draw anything.
+ *
+ * You should pass a cairo context as @cr argument that is in an
+ * original state. Otherwise the resulting drawing is undefined. For
+ * example changing the operator using cairo_set_operator() or the
+ * line width using cairo_set_line_width() might have unwanted side
+ * effects.
+ * You may however change the context's transform matrix - like with
+ * cairo_scale(), cairo_translate() or cairo_set_matrix() and clip
+ * region with cairo_clip() prior to calling this function. Also, it
+ * is fine to modify the context with cairo_save() and
+ * cairo_push_group() prior to calling this function.
+ *
+ * Since: 3.0
+ **/
+void
+_gtk_actor_draw (GtkActor *self,
+                 cairo_t  *cr)
+{
+  GtkActorPrivate *priv;
+
+  g_return_if_fail (GTK_IS_ACTOR (self));
+  g_return_if_fail (cr != NULL);
+
+  priv = self->priv;
+
+  if (priv->needs_allocation ||
+      !_gtk_actor_get_visible (self))
+    return;
+
+  cairo_save (cr);
+
+  cairo_transform (cr, &priv->transform);
+
+  GTK_ACTOR_GET_CLASS (self)->draw (self, cr);
+
+  cairo_restore (cr);
+}
+
+/**
  * _gtk_actor_is_toplevel:
  * @self: A #GtkActor
  *
@@ -2247,7 +2308,8 @@ _gtk_actor_is_toplevel (GtkActor *self)
 {
   g_return_val_if_fail (GTK_IS_ACTOR (self), FALSE);
 
-  /* XXX */
+  g_warning ("FIXME: implement is_toplevel");
+
   return self->priv->parent == NULL;
 }
 
diff --git a/gtk/actors/gtkactorprivate.h b/gtk/actors/gtkactorprivate.h
index 4965b17..4c959fa 100644
--- a/gtk/actors/gtkactorprivate.h
+++ b/gtk/actors/gtkactorprivate.h
@@ -60,7 +60,8 @@ struct _GtkActorClass
   void                  (* unrealize)            (GtkActor                 *self);
   void                  (* map)                  (GtkActor                 *self);
   void                  (* unmap)                (GtkActor                 *self);
-  void                  (* draw)                 (GtkActor                 *self);
+  void                  (* draw)                 (GtkActor                 *self,
+                                                  cairo_t                  *cr);
   void                  (* parent_set)           (GtkActor                 *self,
                                                   GtkActor                 *old_parent);
   void                  (* queue_relayout)       (GtkActor                 *self);
@@ -108,6 +109,8 @@ void                            _gtk_actor_realize
 void                            _gtk_actor_unrealize                            (GtkActor                   *self);
 void                            _gtk_actor_map                                  (GtkActor                   *self);
 void                            _gtk_actor_unmap                                (GtkActor                   *self);
+void                            _gtk_actor_draw                                 (GtkActor                   *self,
+                                                                                 cairo_t                    *cr);
 void                            _gtk_actor_queue_redraw                         (GtkActor                   *self);
 void                            _gtk_actor_queue_redraw_area                    (GtkActor                   *self,
                                                                                  const cairo_rectangle_t    *box);



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