cellview: Implement snapshot()

This also adds gtk_cell_area_snapshot().
This commit is contained in:
Benjamin Otte 2016-12-19 16:34:25 +01:00
parent 2034e83a20
commit 94e906c802
3 changed files with 69 additions and 14 deletions

View File

@ -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 @areas 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 @areas cells according to @areas 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,

View File

@ -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,

View File

@ -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;
}