]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcssstyleproperty.c
Some more documentation fixes
[~andy/gtk] / gtk / gtkcssstyleproperty.c
index 7bb1e688e21a303e54c3b0c533a6bad71f3f8077..0b7491524e421174e64c9185dfbc85e64e601ffb 100644 (file)
@@ -38,6 +38,8 @@
 enum {
   PROP_0,
   PROP_ANIMATED,
+  PROP_AFFECTS_SIZE,
+  PROP_AFFECTS_FONT,
   PROP_ID,
   PROP_INHERIT,
   PROP_INITIAL
@@ -45,6 +47,11 @@ enum {
 
 G_DEFINE_TYPE (GtkCssStyleProperty, _gtk_css_style_property, GTK_TYPE_STYLE_PROPERTY)
 
+static GtkBitmask *_properties_affecting_size = NULL;
+static GtkBitmask *_properties_affecting_font = NULL;
+
+static GtkCssStylePropertyClass *gtk_css_style_property_class = NULL;
+
 static void
 gtk_css_style_property_constructed (GObject *object)
 {
@@ -54,6 +61,12 @@ gtk_css_style_property_constructed (GObject *object)
   property->id = klass->style_properties->len;
   g_ptr_array_add (klass->style_properties, property);
 
+  if (property->affects_size)
+    _properties_affecting_size = _gtk_bitmask_set (_properties_affecting_size, property->id, TRUE);
+
+  if (property->affects_font)
+    _properties_affecting_font = _gtk_bitmask_set (_properties_affecting_font, property->id, TRUE);
+
   G_OBJECT_CLASS (_gtk_css_style_property_parent_class)->constructed (object);
 }
 
@@ -70,6 +83,12 @@ gtk_css_style_property_set_property (GObject      *object,
     case PROP_ANIMATED:
       property->animated = g_value_get_boolean (value);
       break;
+    case PROP_AFFECTS_SIZE:
+      property->affects_size = g_value_get_boolean (value);
+      break;
+    case PROP_AFFECTS_FONT:
+      property->affects_font = g_value_get_boolean (value);
+      break;
     case PROP_INHERIT:
       property->inherit = g_value_get_boolean (value);
       break;
@@ -96,6 +115,12 @@ gtk_css_style_property_get_property (GObject    *object,
     case PROP_ANIMATED:
       g_value_set_boolean (value, property->animated);
       break;
+    case PROP_AFFECTS_SIZE:
+      g_value_set_boolean (value, property->affects_size);
+      break;
+    case PROP_AFFECTS_FONT:
+      g_value_set_boolean (value, property->affects_font);
+      break;
     case PROP_ID:
       g_value_set_boolean (value, property->id);
       break;
@@ -251,6 +276,20 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass)
                                                          P_("Set if the value can be animated"),
                                                          FALSE,
                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (object_class,
+                                   PROP_AFFECTS_SIZE,
+                                   g_param_spec_boolean ("affects-size",
+                                                         P_("Affects size"),
+                                                         P_("Set if the value affects the sizing of elements"),
+                                                         TRUE,
+                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (object_class,
+                                   PROP_AFFECTS_FONT,
+                                   g_param_spec_boolean ("affects-font",
+                                                         P_("Affects font"),
+                                                         P_("Set if the value affects the font"),
+                                                         FALSE,
+                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
   g_object_class_install_property (object_class,
                                    PROP_ID,
                                    g_param_spec_uint ("id",
@@ -278,6 +317,11 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass)
   property_class->parse_value = gtk_css_style_property_parse_value;
 
   klass->style_properties = g_ptr_array_new ();
+
+  _properties_affecting_size = _gtk_bitmask_new ();
+  _properties_affecting_font = _gtk_bitmask_new ();
+
+  gtk_css_style_property_class = klass;
 }
 
 static GtkCssValue *
@@ -305,17 +349,13 @@ _gtk_css_style_property_init (GtkCssStyleProperty *property)
 guint
 _gtk_css_style_property_get_n_properties (void)
 {
-  GtkCssStylePropertyClass *klass;
-
-  klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
-  if (G_UNLIKELY (klass == NULL))
+  if (G_UNLIKELY (gtk_css_style_property_class == NULL))
     {
       _gtk_style_property_init_properties ();
-      klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
-      g_assert (klass);
+      g_assert (gtk_css_style_property_class);
     }
 
-  return klass->style_properties->len;
+  return gtk_css_style_property_class->style_properties->len;
 }
 
 /**
@@ -331,18 +371,16 @@ _gtk_css_style_property_get_n_properties (void)
 GtkCssStyleProperty *
 _gtk_css_style_property_lookup_by_id (guint id)
 {
-  GtkCssStylePropertyClass *klass;
 
-  klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
-  if (G_UNLIKELY (klass == NULL))
+  if (G_UNLIKELY (gtk_css_style_property_class == NULL))
     {
       _gtk_style_property_init_properties ();
-      klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
-      g_assert (klass);
+      g_assert (gtk_css_style_property_class);
     }
-  g_return_val_if_fail (id < klass->style_properties->len, NULL);
 
-  return g_ptr_array_index (klass->style_properties, id);
+  g_return_val_if_fail (id < gtk_css_style_property_class->style_properties->len, NULL);
+
+  return g_ptr_array_index (gtk_css_style_property_class->style_properties, id);
 }
 
 /**
@@ -381,6 +419,42 @@ _gtk_css_style_property_is_animated (GtkCssStyleProperty *property)
   return property->animated;
 }
 
+/**
+ * _gtk_css_style_property_affects_size:
+ * @property: the property
+ *
+ * Queries if the given @property affects the size of elements. This is
+ * used for optimizations inside GTK, where a gtk_widget_queue_resize()
+ * can be avoided if the property does not affect size.
+ *
+ * Returns: %TRUE if the property affects sizing of elements.
+ **/
+gboolean
+_gtk_css_style_property_affects_size (GtkCssStyleProperty *property)
+{
+  g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), FALSE);
+
+  return property->affects_size;
+}
+
+/**
+ * _gtk_css_style_property_affects_font:
+ * @property: the property
+ *
+ * Queries if the given @property affects the default font. This is
+ * used for optimizations inside GTK, where clearing pango
+ * layouts can be avoided if the font doesn't change.
+ *
+ * Returns: %TRUE if the property affects the font.
+ **/
+gboolean
+_gtk_css_style_property_affects_font (GtkCssStyleProperty *property)
+{
+  g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), FALSE);
+
+  return property->affects_font;
+}
+
 /**
  * _gtk_css_style_property_get_id:
  * @property: the property
@@ -415,3 +489,15 @@ _gtk_css_style_property_get_initial_value (GtkCssStyleProperty *property)
 
   return property->initial_value;
 }
+
+gboolean
+_gtk_css_style_property_changes_affect_size (const GtkBitmask *changes)
+{
+  return _gtk_bitmask_intersects (changes, _properties_affecting_size);
+}
+
+gboolean
+_gtk_css_style_property_changes_affect_font (const GtkBitmask *changes)
+{
+  return _gtk_bitmask_intersects (changes, _properties_affecting_font);
+}