[gtk+/wip/matthiasc/fancy-overlay] Handle effect on multiple children



commit 8ebd3e05c31eec3abaff6ec4d36756f630b58e1a
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Sep 3 08:56:40 2017 -0400

    Handle effect on multiple children
    
    Just a matter of rearranging this code slightly.

 gtk/gtkoverlay.c |   62 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 36 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c
index b96e5f2..97ee9eb 100644
--- a/gtk/gtkoverlay.c
+++ b/gtk/gtkoverlay.c
@@ -620,51 +620,54 @@ gtk_overlay_snapshot (GtkWidget   *widget,
 {
   GtkWidget *main_widget;
   GtkWidget *child;
-  graphene_rect_t bounds;
-  double blur = 0;
-  GtkAllocation alloc;
-  GtkAllocation effect_alloc;
-  cairo_region_t *clip;
+  GtkAllocation main_alloc;
+  cairo_region_t *clip = NULL;
   int i;
 
+  main_widget = gtk_bin_get_child (GTK_BIN (widget));
+  gtk_widget_get_allocation (widget, &main_alloc);
+
   for (child = _gtk_widget_get_first_child (widget);
        child != NULL;
        child = _gtk_widget_get_next_sibling (child))
     {
+      double blur;
       gtk_container_child_get (GTK_CONTAINER (widget), child, "blur", &blur, NULL);
       if (blur > 0)
         {
-          gtk_widget_get_allocation (child, &effect_alloc);
-          break;
+          GtkAllocation alloc;
+          graphene_rect_t bounds;
+
+          gtk_widget_get_allocation (child, &alloc);
+          graphene_rect_init (&bounds, alloc.x, alloc.y, alloc.width, alloc.height);
+          gtk_snapshot_push_clip (snapshot, &bounds, "Overlay Effect Clip");
+          gtk_snapshot_push_blur (snapshot, blur, "Overlay Effect");
+          gtk_widget_snapshot_child (widget, main_widget, snapshot);
+          gtk_snapshot_pop (snapshot);
+          gtk_snapshot_pop (snapshot);
+
+          if (clip == NULL)
+            {
+              clip = cairo_region_create ();
+              main_alloc.x = main_alloc.y = 0;
+              cairo_region_union_rectangle (clip, (cairo_rectangle_int_t *)&main_alloc);
+            }
+
+          cairo_region_subtract_rectangle (clip, (cairo_rectangle_int_t *)&alloc);
         }
     }
 
-  if (blur == 0)
+  if (clip == NULL)
     {
       GTK_WIDGET_CLASS (gtk_overlay_parent_class)->snapshot (widget, snapshot);
       return;
     }
 
-  main_widget = gtk_bin_get_child (GTK_BIN (widget));
-
-  gtk_widget_get_allocation (widget, &alloc);
-  graphene_rect_init (&bounds, effect_alloc.x, effect_alloc.y, effect_alloc.width, effect_alloc.height);
-  gtk_snapshot_push_clip (snapshot, &bounds, "Overlay Effect Clip");
-  gtk_snapshot_push_blur (snapshot, blur, "Overlay Effect");
-
-  gtk_widget_snapshot_child (widget, main_widget, snapshot);
-
-  gtk_snapshot_pop (snapshot);
-  gtk_snapshot_pop (snapshot);
-
-  clip = cairo_region_create ();
-  alloc.x = alloc.y = 0;
-  cairo_region_union_rectangle (clip, (cairo_rectangle_int_t *)&alloc);
-  cairo_region_subtract_rectangle (clip, (cairo_rectangle_int_t *)&effect_alloc);
-
   for (i = 0; i < cairo_region_num_rectangles (clip); i++)
     {
       cairo_rectangle_int_t rect;
+      graphene_rect_t bounds;
+
       cairo_region_get_rectangle (clip, i, &rect);
       graphene_rect_init (&bounds, rect.x, rect.y, rect.width, rect.height);
       gtk_snapshot_push_clip (snapshot, &bounds, "Overlay Non-Effect Clip");
@@ -713,8 +716,15 @@ gtk_overlay_class_init (GtkOverlayClass *klass)
                             FALSE,
                             GTK_PARAM_READWRITE));
 
+  /**
+   * GtkOverlay:blur:
+   *
+   * Blur the content behind this child with a Gaussian blur of this radius.
+   *
+   * Since: 3.92
+   */
   gtk_container_class_install_child_property (container_class, CHILD_PROP_BLUR,
-      g_param_spec_double ("blur", NULL, NULL,
+      g_param_spec_double ("blur", P_("Blur Radius"), P_("Apply a blur to the content behind this child"),
                            0, 100, 0,
                            GTK_PARAM_READWRITE));
   /**


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