[gtk+/wip/matthiasc/render-node-vfunc: 4/6] box gadget: Implement get_render_node vfunc



commit 7577d28db35b1f4f28e34e27a6754841a2dacc73
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Oct 28 12:57:07 2016 -0400

    box gadget: Implement get_render_node vfunc
    
    This implements get_render_node in the obvious way.

 gtk/gtkboxgadget.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkboxgadget.c b/gtk/gtkboxgadget.c
index fb230c0..e312a2a 100644
--- a/gtk/gtkboxgadget.c
+++ b/gtk/gtkboxgadget.c
@@ -26,6 +26,7 @@
 #include "gtkprivate.h"
 #include "gtksizerequest.h"
 #include "gtkwidgetprivate.h"
+#include "gtkcontainerprivate.h"
 
 /* GtkBoxGadget is a container gadget implementation that arranges its
  * children in a row, either horizontally or vertically. Children can
@@ -518,6 +519,36 @@ gtk_box_gadget_draw (GtkCssGadget *gadget,
   return FALSE;
 }
 
+static GskRenderNode *
+gtk_box_gadget_get_render_node (GtkCssGadget *gadget,
+                                GskRenderer  *renderer,
+                                gboolean      draw_focus)
+{
+  GtkBoxGadgetPrivate *priv = gtk_box_gadget_get_instance_private (GTK_BOX_GADGET (gadget));
+  GtkWidget *owner = gtk_css_gadget_get_owner (gadget);
+  GskRenderNode *res, *node;
+  guint i;
+
+  res = GTK_CSS_GADGET_CLASS (gtk_box_gadget_parent_class)->get_render_node (gadget, renderer, draw_focus);
+
+  for (i = 0; i < priv->children->len; i++)
+    {
+      guint draw_index = priv->draw_reverse ? priv->children->len - 1 - i : i;
+      GtkBoxGadgetChild *child = &g_array_index (priv->children, GtkBoxGadgetChild, draw_index);
+
+      if (GTK_IS_WIDGET (child->object))
+        gtk_container_propagate_render_node_for_child (GTK_CONTAINER (owner), GTK_WIDGET (child->object), 
renderer, res);
+      else
+        {
+          node = gtk_css_gadget_get_render_node (GTK_CSS_GADGET (child->object), renderer, FALSE);
+          gsk_render_node_append_child (res, node);
+          gsk_render_node_unref (node);
+        }
+    }
+
+  return res;
+}
+
 static gboolean
 gtk_box_gadget_has_content (GtkCssGadget *gadget)
 {
@@ -545,6 +576,7 @@ gtk_box_gadget_class_init (GtkBoxGadgetClass *klass)
   gadget_class->get_preferred_size = gtk_box_gadget_get_preferred_size;
   gadget_class->allocate = gtk_box_gadget_allocate;
   gadget_class->draw = gtk_box_gadget_draw;
+  gadget_class->get_render_node = gtk_box_gadget_get_render_node;
   gadget_class->has_content = gtk_box_gadget_has_content;
 }
 


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