[gtk+] css: Queue resize for properties that affect clip



commit e683e915b80e70574a9e21de087522a6c1e45f24
Author: Benjamin Otte <otte redhat com>
Date:   Thu Oct 2 02:23:34 2014 +0200

    css: Queue resize for properties that affect clip
    
    This fixes shadows that are animated not updating the clip of the widget
    they are drawn on. An example of this are the buttons in the CSS shadows
    example in gtk-demo.
    
    Reftest included

 gtk/gtkcssstylepropertyimpl.c                      |    2 +-
 testsuite/reftests/Makefile.am                     |    4 +
 .../label-text-shadow-changes-modify-clip.c        |   90 ++++++++++++++++++++
 .../label-text-shadow-changes-modify-clip.css      |   19 ++++
 .../label-text-shadow-changes-modify-clip.ref.ui   |   21 +++++
 .../label-text-shadow-changes-modify-clip.ui       |   33 +++++++
 6 files changed, 168 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 5de2a94..3b4186c 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -90,7 +90,7 @@ gtk_css_style_property_register (const char *                   name,
 
   node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
                        "value-type", value_type,
-                       "affects-size", (affects & GTK_CSS_AFFECTS_SIZE) ? TRUE : FALSE,
+                       "affects-size", (affects & (GTK_CSS_AFFECTS_CLIP | GTK_CSS_AFFECTS_SIZE)) ? TRUE : 
FALSE,
                        "affects-font", (affects & GTK_CSS_AFFECTS_FONT) ? TRUE : FALSE,
                        "animated", (flags & GTK_STYLE_PROPERTY_ANIMATED) ? TRUE : FALSE,
                        "inherit", (flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE,
diff --git a/testsuite/reftests/Makefile.am b/testsuite/reftests/Makefile.am
index 47c4864..7479dae 100644
--- a/testsuite/reftests/Makefile.am
+++ b/testsuite/reftests/Makefile.am
@@ -307,6 +307,9 @@ testdata = \
        label-text-shadow-clipping.css \
        label-text-shadow-clipping.ref.ui \
        label-text-shadow-clipping.ui \
+       label-text-shadow-changes-modify-clip.css \
+       label-text-shadow-changes-modify-clip.ref.ui \
+       label-text-shadow-changes-modify-clip.ui \
        label-width-chars-dont-shrink.ref.ui \
        label-width-chars-dont-shrink.ui \
        label-wrap-justify.ref.ui \
@@ -478,6 +481,7 @@ libreftest_la_CFLAGS = $(gtk_reftest_CFLAGS)
 libreftest_la_LIBADD = $(gtk_reftest_LDADD)
 libreftest_la_SOURCES =                        \
        expand-expander.c               \
+       label-text-shadow-changes-modify-clip.c \
        set-default-direction.c         \
        statusbar-remove-all.c          \
        textview-border-windows.c       \
diff --git a/testsuite/reftests/label-text-shadow-changes-modify-clip.c 
b/testsuite/reftests/label-text-shadow-changes-modify-clip.c
new file mode 100644
index 0000000..0507c36
--- /dev/null
+++ b/testsuite/reftests/label-text-shadow-changes-modify-clip.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2014 Red Hat Inc.
+ *
+ * Author:
+ *      Matthias Clasen <mclasen redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include "gtk-reftest.h"
+
+static gboolean 
+tick_callback_for_1_frame (GtkWidget     *widget,
+                           GdkFrameClock *frame_clock,
+                           gpointer       unused)
+{
+  reftest_uninhibit_snapshot ();
+
+  return G_SOURCE_REMOVE;
+}
+
+G_MODULE_EXPORT gboolean
+inhibit_for_1_frame (GtkWidget *widget)
+{
+  reftest_inhibit_snapshot ();
+  gtk_widget_add_tick_callback (widget,
+                                tick_callback_for_1_frame,
+                                NULL, NULL);
+
+  return FALSE;
+}
+
+static gboolean 
+tick_callback_for_2_frames (GtkWidget     *widget,
+                            GdkFrameClock *frame_clock,
+                            gpointer       unused)
+{
+  inhibit_for_1_frame (widget);
+  reftest_uninhibit_snapshot ();
+
+  return G_SOURCE_REMOVE;
+}
+
+G_MODULE_EXPORT gboolean
+inhibit_for_2_frames (GtkWidget *widget)
+{
+  reftest_inhibit_snapshot ();
+  gtk_widget_add_tick_callback (widget,
+                                tick_callback_for_2_frames,
+                                NULL, NULL);
+
+  return FALSE;
+}
+
+static gboolean 
+tick_callback_for_3_frames (GtkWidget     *widget,
+                            GdkFrameClock *frame_clock,
+                            gpointer       unused)
+{
+  inhibit_for_2_frames (widget);
+  reftest_uninhibit_snapshot ();
+
+  return G_SOURCE_REMOVE;
+}
+
+G_MODULE_EXPORT gboolean
+inhibit_for_3_frames (GtkWidget *widget)
+{
+  reftest_inhibit_snapshot ();
+  gtk_widget_add_tick_callback (widget,
+                                tick_callback_for_3_frames,
+                                NULL, NULL);
+
+  return FALSE;
+}
diff --git a/testsuite/reftests/label-text-shadow-changes-modify-clip.css 
b/testsuite/reftests/label-text-shadow-changes-modify-clip.css
new file mode 100644
index 0000000..87bd265
--- /dev/null
+++ b/testsuite/reftests/label-text-shadow-changes-modify-clip.css
@@ -0,0 +1,19 @@
+ import "reset-to-defaults.css";
+
+ keyframes foo {
+  0% { text-shadow: 20px 20px tomato; }
+  100% { text-shadow: 20px 20px tomato; }
+}
+
+GtkLabel {
+  font-size: 40px;
+  animation-name: foo;
+  animation-duration: 100s;
+  animation-timing-function: linear;
+  animation-delay: 1ms;
+}
+
+#reference {
+  animation: initial;
+  text-shadow: 20px 20px tomato;
+}
diff --git a/testsuite/reftests/label-text-shadow-changes-modify-clip.ref.ui 
b/testsuite/reftests/label-text-shadow-changes-modify-clip.ref.ui
new file mode 100644
index 0000000..85245c1
--- /dev/null
+++ b/testsuite/reftests/label-text-shadow-changes-modify-clip.ref.ui
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+  <requires lib="gtk+" version="3.12"/>
+  <object class="GtkWindow" id="window1">
+    <property name="width_request">500</property>
+    <property name="height_request">100</property>
+    <property name="can_focus">False</property>
+    <property name="type">popup</property>
+    <child>
+      <object class="GtkLabel" id="label1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Hello World</property>
+        <style>
+          <class name="reference"/>
+        </style>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/reftests/label-text-shadow-changes-modify-clip.ui 
b/testsuite/reftests/label-text-shadow-changes-modify-clip.ui
new file mode 100644
index 0000000..0d029fd
--- /dev/null
+++ b/testsuite/reftests/label-text-shadow-changes-modify-clip.ui
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+  <requires lib="gtk+" version="3.12"/>
+  <object class="GtkWindow" id="window1">
+    <property name="width_request">500</property>
+    <property name="height_request">100</property>
+    <property name="can_focus">False</property>
+    <property name="type">popup</property>
+    <signal name="map" handler="reftest:inhibit_for_3_frames" swapped="no"/>
+    <child>
+      <object class="GtkBox" id="box2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="halign">center</property>
+        <property name="valign">center</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Hello World</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>


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