[gtk/matthiasc/for-master: 20/20] css: Update affects flags for icons



commit e46e0410a36bd5e9bf7b0054daaf254b265fad3c
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 24 19:57:45 2020 -0500

    css: Update affects flags for icons
    
    We want to differentiate what requires recreating the
    texture and what doesn't. In particular, the current
    flags are not handling symbolic icons right.

 gtk/gtkcssstylepropertyimpl.c | 14 +++++++-------
 gtk/gtkcsstypesprivate.h      | 40 ++++++++++++++++++++++------------------
 gtk/gtkiconhelper.c           | 24 ++++++++++++++++--------
 3 files changed, 45 insertions(+), 33 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index e5834b1dfd..15eb99dace 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -935,7 +935,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_PROPERTY_COLOR,
                                           GDK_TYPE_RGBA,
                                           GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
-                                          GTK_CSS_AFFECTS_CONTENT | GTK_CSS_AFFECTS_SYMBOLIC_ICON,
+                                          GTK_CSS_AFFECTS_CONTENT | GTK_CSS_AFFECTS_ICON_REDRAW_SYMBOLIC,
                                           color_parse,
                                           color_query,
                                           gtk_css_color_value_new_white ());
@@ -959,7 +959,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_PROPERTY_ICON_THEME,
                                           G_TYPE_NONE,
                                           GTK_STYLE_PROPERTY_INHERIT,
-                                          GTK_CSS_AFFECTS_ICON | GTK_CSS_AFFECTS_SYMBOLIC_ICON | 
GTK_CSS_AFFECTS_ICON_SIZE,
+                                          GTK_CSS_AFFECTS_ICON_TEXTURE | GTK_CSS_AFFECTS_ICON_SIZE,
                                           icon_theme_value_parse,
                                           NULL,
                                           gtk_css_icon_theme_value_new (NULL));
@@ -967,7 +967,7 @@ _gtk_css_style_property_init_properties (void)
                                          GTK_CSS_PROPERTY_ICON_PALETTE,
                                          G_TYPE_NONE,
                                          GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_INHERIT,
-                                          GTK_CSS_AFFECTS_SYMBOLIC_ICON,
+                                          GTK_CSS_AFFECTS_ICON_REDRAW_SYMBOLIC,
                                          icon_palette_parse,
                                          NULL,
                                          gtk_css_palette_value_new_default ());
@@ -1494,7 +1494,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_PROPERTY_ICON_SOURCE,
                                           G_TYPE_NONE,
                                           GTK_STYLE_PROPERTY_ANIMATED,
-                                          GTK_CSS_AFFECTS_ICON | GTK_CSS_AFFECTS_SYMBOLIC_ICON,
+                                          GTK_CSS_AFFECTS_ICON_TEXTURE,
                                           css_image_value_parse,
                                           NULL,
                                           _gtk_css_image_value_new (NULL));
@@ -1502,7 +1502,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_PROPERTY_ICON_SIZE,
                                           G_TYPE_NONE,
                                           GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
-                                          GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_ICON | 
GTK_CSS_AFFECTS_SYMBOLIC_ICON,
+                                          GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_ICON_SIZE,
                                           icon_size_parse,
                                           NULL,
                                           _gtk_css_number_value_new (16, GTK_CSS_PX));
@@ -1510,7 +1510,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_PROPERTY_ICON_SHADOW,
                                           G_TYPE_NONE,
                                           GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
-                                          GTK_CSS_AFFECTS_ICON | GTK_CSS_AFFECTS_SYMBOLIC_ICON,
+                                          GTK_CSS_AFFECTS_ICON_REDRAW,
                                           shadow_value_parse,
                                           NULL,
                                           gtk_css_shadow_value_new_none ());
@@ -1518,7 +1518,7 @@ _gtk_css_style_property_init_properties (void)
                                           GTK_CSS_PROPERTY_ICON_STYLE,
                                           G_TYPE_NONE,
                                           GTK_STYLE_PROPERTY_INHERIT,
-                                          GTK_CSS_AFFECTS_ICON | GTK_CSS_AFFECTS_SYMBOLIC_ICON | 
GTK_CSS_AFFECTS_ICON_SIZE,
+                                          GTK_CSS_AFFECTS_ICON_TEXTURE | GTK_CSS_AFFECTS_ICON_SIZE,
                                           icon_style_parse,
                                           NULL,
                                           _gtk_css_icon_style_value_new (GTK_CSS_ICON_STYLE_REQUESTED));
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 28ecc7d168..498a8ca8c8 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -132,13 +132,16 @@ typedef guint64 GtkCssChange;
  *   see @GTK_CSS_AFFECTS_TEXT.
  * @GTK_CSS_AFFECTS_BACKGROUND: The background rendering is affected.
  * @GTK_CSS_AFFECTS_BORDER: The border styling is affected.
- * @GTK_CSS_AFFECTS_ICON_SIZE: Icon size is affected.
  * @GTK_CSS_AFFECTS_TEXT_ATTRS: Text attributes are affected.
  * @GTK_CSS_AFFECTS_TEXT_SIZE: Text size is affected.
  * @GTK_CSS_AFFECTS_TEXT_CONTENT: Text rendering is affected, but size or
  *   attributes are not.
- * @GTK_CSS_AFFECTS_ICON: Fullcolor icons and their rendering is affected.
- * @GTK_CSS_AFFECTS_SYMBOLIC_ICON: Symbolic icons and their rendering is affected.
+ * @GTK_CSS_AFFECTS_ICON_SIZE: Icon size is affected.
+ * @GTK_CSS_AFFECTS_ICON_TEXTURE: The icon texture has changed and needs to be
+ *   reloaded.
+ * @GTK_CSS_AFFECTS_ICON_REDRAW: Icons need to be redrawn (both symbolic and
+ *   non-symbolic).
+ * @GTK_CSS_AFFECTS_ICON_REDRAW_SYMBOLIC: Symbolic icons need to be redrawn.
  * @GTK_CSS_AFFECTS_OUTLINE: The outline styling is affected.
  * @GTK_CSS_AFFECTS_SIZE: Changes in this property may have an effect
  *   on the allocated size of the element. Changes in these properties
@@ -154,26 +157,27 @@ typedef guint64 GtkCssChange;
  * Note that multiple values can be set.
  */
 typedef enum {
-  GTK_CSS_AFFECTS_CONTENT       = (1 << 0),
-  GTK_CSS_AFFECTS_BACKGROUND    = (1 << 1),
-  GTK_CSS_AFFECTS_BORDER        = (1 << 2),
-  GTK_CSS_AFFECTS_ICON_SIZE     = (1 << 3),
-  GTK_CSS_AFFECTS_TEXT_ATTRS    = (1 << 4),
-  GTK_CSS_AFFECTS_TEXT_SIZE     = (1 << 5),
-  GTK_CSS_AFFECTS_TEXT_CONTENT  = (1 << 6),
-  GTK_CSS_AFFECTS_ICON          = (1 << 7),
-  GTK_CSS_AFFECTS_SYMBOLIC_ICON = (1 << 8),
-  GTK_CSS_AFFECTS_OUTLINE       = (1 << 9),
-  GTK_CSS_AFFECTS_SIZE          = (1 << 10),
-  GTK_CSS_AFFECTS_POSTEFFECT    = (1 << 11),
-  GTK_CSS_AFFECTS_TRANSFORM     = (1 << 12),
+  GTK_CSS_AFFECTS_CONTENT              = (1 << 0),
+  GTK_CSS_AFFECTS_BACKGROUND           = (1 << 1),
+  GTK_CSS_AFFECTS_BORDER               = (1 << 2),
+  GTK_CSS_AFFECTS_TEXT_ATTRS           = (1 << 3),
+  GTK_CSS_AFFECTS_TEXT_SIZE            = (1 << 4),
+  GTK_CSS_AFFECTS_TEXT_CONTENT         = (1 << 5),
+  GTK_CSS_AFFECTS_ICON_SIZE            = (1 << 6),
+  GTK_CSS_AFFECTS_ICON_TEXTURE         = (1 << 7),
+  GTK_CSS_AFFECTS_ICON_REDRAW          = (1 << 8),
+  GTK_CSS_AFFECTS_ICON_REDRAW_SYMBOLIC = (1 << 9),
+  GTK_CSS_AFFECTS_OUTLINE              = (1 << 10),
+  GTK_CSS_AFFECTS_SIZE                 = (1 << 11),
+  GTK_CSS_AFFECTS_POSTEFFECT           = (1 << 12),
+  GTK_CSS_AFFECTS_TRANSFORM            = (1 << 13),
 } GtkCssAffects;
 
 #define GTK_CSS_AFFECTS_REDRAW (GTK_CSS_AFFECTS_CONTENT |       \
                                 GTK_CSS_AFFECTS_BACKGROUND |    \
                                 GTK_CSS_AFFECTS_BORDER |        \
-                                GTK_CSS_AFFECTS_ICON |          \
-                                GTK_CSS_AFFECTS_SYMBOLIC_ICON | \
+                                GTK_CSS_AFFECTS_ICON_REDRAW |   \
+                                GTK_CSS_AFFECTS_ICON_REDRAW_SYMBOLIC |   \
                                 GTK_CSS_AFFECTS_OUTLINE |       \
                                 GTK_CSS_AFFECTS_POSTEFFECT)
 
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index 3aeeb8b168..932f23ca3e 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -385,19 +385,27 @@ gtk_icon_helper_invalidate_for_change (GtkIconHelper     *self,
                                        GtkCssStyleChange *change)
 {
   if (change == NULL ||
-      ((gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SYMBOLIC_ICON) &&
-        self->texture_is_symbolic) ||
-       (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON) &&
-        !self->texture_is_symbolic)))
+      gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_TEXTURE))
     {
+g_print ("icon helper: change affects icon texture: %s\n", change ? gtk_css_style_change_to_string (change): 
"NULL");
       /* Avoid the queue_resize in gtk_icon_helper_invalidate */
       g_clear_object (&self->paintable);
       self->texture_is_symbolic = FALSE;
+    }
 
-      if (change == NULL ||
-          (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE) &&
-          !GTK_IS_CSS_TRANSIENT_NODE (self->node)))
-        gtk_widget_queue_resize (self->owner);
+  if (change == NULL ||
+      (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE) &&
+       !GTK_IS_CSS_TRANSIENT_NODE (self->node)))
+    {
+g_print ("icon helper: change affects icon size\n");
+      gtk_widget_queue_resize (self->owner);
+    }
+  else if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_REDRAW) ||
+           (self->texture_is_symbolic &&
+            gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_REDRAW_SYMBOLIC)))
+    {
+g_print ("icon helper: change affects icon redraw\n");
+      gtk_widget_queue_draw (self->owner);
     }
 }
 


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