[gtk+] cellview: Implement snapshot()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cellview: Implement snapshot()
- Date: Tue, 20 Dec 2016 17:15:53 +0000 (UTC)
commit 94e906c802748505dffd9a1f05bbc07a02bdd984
Author: Benjamin Otte <otte redhat com>
Date: Mon Dec 19 16:34:25 2016 +0100
cellview: Implement snapshot()
This also adds gtk_cell_area_snapshot().
gtk/gtkcellarea.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkcellarea.h | 9 +++++++++
gtk/gtkcellview.c | 26 ++++++++++++--------------
3 files changed, 69 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkcellarea.c b/gtk/gtkcellarea.c
index 96f1db8..c50ea1e 100644
--- a/gtk/gtkcellarea.c
+++ b/gtk/gtkcellarea.c
@@ -352,6 +352,7 @@
#include "gtkmarshalers.h"
#include "gtkprivate.h"
#include "gtkrender.h"
+#include "gtksnapshot.h"
#include <gobject/gvaluecollector.h>
@@ -1847,6 +1848,53 @@ gtk_cell_area_render (GtkCellArea *area,
g_type_name (G_TYPE_FROM_INSTANCE (area)));
}
+/**
+ * gtk_cell_area_snapshot:
+ * @area: a #GtkCellArea
+ * @context: the #GtkCellAreaContext for this row of data.
+ * @widget: the #GtkWidget that @area is rendering to
+ * @snapshot: the #GtkSnapshot to draw to
+ * @background_area: the @widget relative coordinates for @area’s background
+ * @cell_area: the @widget relative coordinates for @area
+ * @flags: the #GtkCellRendererState for @area in this row.
+ * @paint_focus: whether @area should paint focus on focused cells for focused rows or not.
+ *
+ * Snapshots @area’s cells according to @area’s layout onto at
+ * the given coordinates.
+ *
+ * Since: 3.90
+ */
+void
+gtk_cell_area_snapshot (GtkCellArea *area,
+ GtkCellAreaContext *context,
+ GtkWidget *widget,
+ GtkSnapshot *snapshot,
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
+ GtkCellRendererState flags,
+ gboolean paint_focus)
+{
+ cairo_t *cr;
+
+ g_return_if_fail (GTK_IS_CELL_AREA (area));
+ g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (snapshot != NULL);
+ g_return_if_fail (background_area != NULL);
+ g_return_if_fail (cell_area != NULL);
+
+ cr = gtk_snapshot_append_cairo_node (snapshot,
+ &GRAPHENE_RECT_INIT (
+ background_area->x,
+ background_area->y,
+ background_area->width,
+ background_area->height
+ ),
+ "CellArea<%s>", G_OBJECT_TYPE_NAME (area));
+ gtk_cell_area_render (area, context, widget, cr, background_area, cell_area, flags, paint_focus);
+ cairo_destroy (cr);
+}
+
static gboolean
get_cell_allocation (GtkCellRenderer *renderer,
const GdkRectangle *cell_area,
diff --git a/gtk/gtkcellarea.h b/gtk/gtkcellarea.h
index 854e32f..d719ba2 100644
--- a/gtk/gtkcellarea.h
+++ b/gtk/gtkcellarea.h
@@ -317,6 +317,15 @@ void gtk_cell_area_render (GtkCellArea
const GdkRectangle *cell_area,
GtkCellRendererState flags,
gboolean paint_focus);
+GDK_AVAILABLE_IN_3_90
+void gtk_cell_area_snapshot (GtkCellArea *area,
+ GtkCellAreaContext *context,
+ GtkWidget *widget,
+ GtkSnapshot *snapshot,
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
+ GtkCellRendererState flags,
+ gboolean paint_focus);
GDK_AVAILABLE_IN_ALL
void gtk_cell_area_get_cell_allocation (GtkCellArea *area,
diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c
index 7acf1b0..ed8e157 100644
--- a/gtk/gtkcellview.c
+++ b/gtk/gtkcellview.c
@@ -69,8 +69,8 @@ static void gtk_cell_view_finalize (GObject *obj
static void gtk_cell_view_dispose (GObject *object);
static void gtk_cell_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-static gboolean gtk_cell_view_draw (GtkWidget *widget,
- cairo_t *cr);
+static void gtk_cell_view_snapshot (GtkWidget *widget,
+ GtkSnapshot *snapshot);
static void gtk_cell_view_set_value (GtkCellView *cell_view,
GtkCellRenderer *renderer,
const char *property,
@@ -126,7 +126,7 @@ static void gtk_cell_view_allocate (GtkCssGadget *gadget,
GtkAllocation *out_clip,
gpointer data);
static gboolean gtk_cell_view_render (GtkCssGadget *gadget,
- cairo_t *cr,
+ GtkSnapshot *snapshot,
int x,
int y,
int width,
@@ -185,7 +185,7 @@ gtk_cell_view_class_init (GtkCellViewClass *klass)
gobject_class->finalize = gtk_cell_view_finalize;
gobject_class->dispose = gtk_cell_view_dispose;
- widget_class->draw = gtk_cell_view_draw;
+ widget_class->snapshot = gtk_cell_view_snapshot;
widget_class->size_allocate = gtk_cell_view_size_allocate;
widget_class->get_request_mode = gtk_cell_view_get_request_mode;
widget_class->measure = gtk_cell_view_measure_;
@@ -451,8 +451,8 @@ gtk_cell_view_init (GtkCellView *cellview)
GTK_WIDGET (cellview),
gtk_cell_view_measure,
gtk_cell_view_allocate,
- gtk_cell_view_render,
NULL,
+ gtk_cell_view_render,
NULL,
NULL);
}
@@ -722,18 +722,16 @@ gtk_cell_view_measure (GtkCssGadget *gadget,
g_signal_handler_unblock (priv->context, priv->size_changed_id);
}
-static gboolean
-gtk_cell_view_draw (GtkWidget *widget,
- cairo_t *cr)
+static void
+gtk_cell_view_snapshot (GtkWidget *widget,
+ GtkSnapshot *snapshot)
{
- gtk_css_gadget_draw (GTK_CELL_VIEW (widget)->priv->gadget, cr);
-
- return FALSE;
+ gtk_css_gadget_snapshot (GTK_CELL_VIEW (widget)->priv->gadget, snapshot);
}
static gboolean
gtk_cell_view_render (GtkCssGadget *gadget,
- cairo_t *cr,
+ GtkSnapshot *snapshot,
int x,
int y,
int width,
@@ -766,8 +764,8 @@ gtk_cell_view_render (GtkCssGadget *gadget,
state = 0;
/* Render the cells */
- gtk_cell_area_render (cellview->priv->area, cellview->priv->context,
- widget, cr, &area, &area, state, FALSE);
+ gtk_cell_area_snapshot (cellview->priv->area, cellview->priv->context,
+ widget, snapshot, &area, &area, state, FALSE);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]