[gtk+] revealer: Implement snapshot()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] revealer: Implement snapshot()
- Date: Tue, 20 Dec 2016 18:27:13 +0000 (UTC)
commit acaa04c031f131d3bd1febe704668cf66dc566ae
Author: Benjamin Otte <otte redhat com>
Date: Tue Dec 20 19:06:07 2016 +0100
revealer: Implement snapshot()
The revealer needs to clip the child during animations, whcih draw() did
automatically, but snapshot() does not.
gtk/gtkrevealer.c | 44 ++++++++++++++++++++++++++++++++++++++++----
1 files changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c
index e42be2e..351c735 100644
--- a/gtk/gtkrevealer.c
+++ b/gtk/gtkrevealer.c
@@ -21,13 +21,15 @@
*/
#include "config.h"
+
#include "gtkrevealer.h"
-#include <gdk/gdk.h>
-#include "gtktypebuiltins.h"
+
+#include "gtkintl.h"
#include "gtkprivate.h"
-#include "gtksettingsprivate.h"
#include "gtkprogresstrackerprivate.h"
-#include "gtkintl.h"
+#include "gtksettingsprivate.h"
+#include "gtksnapshot.h"
+#include "gtktypebuiltins.h"
#include "fallback-c89.c"
@@ -107,6 +109,8 @@ static void gtk_revealer_measure (GtkWidget *widget,
int *natural,
int *minimum_baseline,
int *natural_baseline);
+static void gtk_revealer_snapshot (GtkWidget *widget,
+ GtkSnapshot *snapshot);
G_DEFINE_TYPE_WITH_PRIVATE (GtkRevealer, gtk_revealer, GTK_TYPE_BIN)
@@ -219,6 +223,7 @@ gtk_revealer_class_init (GtkRevealerClass *klass)
widget_class->map = gtk_revealer_real_map;
widget_class->unmap = gtk_revealer_real_unmap;
widget_class->measure = gtk_revealer_measure;
+ widget_class->snapshot = gtk_revealer_snapshot;
container_class->add = gtk_revealer_real_add;
@@ -818,6 +823,37 @@ gtk_revealer_measure (GtkWidget *widget,
set_height_with_paddings (GTK_REVEALER (widget), min_size, nat_size, minimum, natural);
}
+static void
+gtk_revealer_snapshot (GtkWidget *widget,
+ GtkSnapshot *snapshot)
+{
+ GtkRevealer *revealer = GTK_REVEALER (widget);
+ GtkRevealerTransitionType transition;
+ GtkWidget *child;
+
+ child = gtk_bin_get_child (GTK_BIN (revealer));
+ if (child == NULL || !gtk_widget_get_mapped (child))
+ return;
+
+ transition = effective_transition (revealer);
+ if (transition == GTK_REVEALER_TRANSITION_TYPE_NONE)
+ {
+ gtk_container_snapshot_child (GTK_CONTAINER (revealer), child, snapshot);
+ }
+ else
+ {
+ gtk_snapshot_push_clip (snapshot,
+ &GRAPHENE_RECT_INIT(
+ 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget)
+ ),
+ "RevealerClip");
+ gtk_container_snapshot_child (GTK_CONTAINER (revealer), child, snapshot);
+ gtk_snapshot_pop_and_append (snapshot);
+ }
+}
+
/**
* gtk_revealer_get_transition_duration:
* @revealer: a #GtkRevealer
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]