[gtk+] colorplane: Implement snapshot()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] colorplane: Implement snapshot()
- Date: Sun, 1 Jan 2017 18:54:03 +0000 (UTC)
commit 4ead5c3ba8bb1ab570b00f392eb654514ce42c4a
Author: Benjamin Otte <otte redhat com>
Date: Sat Dec 31 23:09:35 2016 +0100
colorplane: Implement snapshot()
gtk/gtkcolorplane.c | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkcolorplane.c b/gtk/gtkcolorplane.c
index 4da6f5c..a929565 100644
--- a/gtk/gtkcolorplane.c
+++ b/gtk/gtkcolorplane.c
@@ -19,12 +19,13 @@
#include "gtkcolorplaneprivate.h"
-#include "gtkgesturedrag.h"
-#include "gtkgesturelongpress.h"
#include "gtkaccessible.h"
#include "gtkadjustment.h"
#include "gtkcolorutils.h"
+#include "gtkgesturedrag.h"
+#include "gtkgesturelongpress.h"
#include "gtkintl.h"
+#include "gtksnapshot.h"
struct _GtkColorPlanePrivate
{
@@ -66,21 +67,26 @@ sv_to_xy (GtkColorPlane *plane,
*y = CLAMP (height * (1 - s), 0, height - 1);
}
-static gboolean
-plane_draw (GtkWidget *widget,
- cairo_t *cr)
+static void
+plane_snapshot (GtkWidget *widget,
+ GtkSnapshot *snapshot)
{
GtkColorPlane *plane = GTK_COLOR_PLANE (widget);
gint x, y;
gint width, height;
-
- cairo_set_source_surface (cr, plane->priv->surface, 0, 0);
- cairo_paint (cr);
+ cairo_t *cr;
sv_to_xy (plane, &x, &y);
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
+ cr = gtk_snapshot_append_cairo_node (snapshot,
+ &GRAPHENE_RECT_INIT (0, 0, width, height),
+ "ColorPlane");
+
+ cairo_set_source_surface (cr, plane->priv->surface, 0, 0);
+ cairo_paint (cr);
+
cairo_move_to (cr, 0, y + 0.5);
cairo_line_to (cr, width, y + 0.5);
@@ -104,7 +110,7 @@ plane_draw (GtkWidget *widget,
cairo_stroke (cr);
}
- return FALSE;
+ cairo_destroy (cr);
}
static void
@@ -560,7 +566,7 @@ gtk_color_plane_class_init (GtkColorPlaneClass *class)
object_class->finalize = plane_finalize;
object_class->set_property = plane_set_property;
- widget_class->draw = plane_draw;
+ widget_class->snapshot = plane_snapshot;
widget_class->size_allocate = plane_size_allocate;
widget_class->realize = plane_realize;
widget_class->unrealize = plane_unrealize;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]