[gnome-themes-standard] adwaita: use outline properties for focus instead of engine properties



commit 6e641cf46cc70ce770482b3fc331b1fa3cd7af2b
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Oct 2 20:24:57 2012 -0400

    adwaita: use outline properties for focus instead of engine properties
    
    This is a bit of a hack, but the problem is that using custom
    engine properties for focus triggers some sort of slow path in the
    GTK+ style validation, and this makes state changes sluggish in complex
    treeview layouts.
    Until focus rendering in GTK is fixed, the workaround is to use some
    real CSS properties, which get a different caching treatment (but the
    engine still manually queries the final value and does the rendering
    itself).
    This also gives us the occasion to get rid of those custom properties
    altogether.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684499

 src/adwaita_engine.c                               |   27 +++----------------
 .../Adwaita/gtk-3.0/gtk-widgets-dark-overrides.css |    6 ++--
 themes/Adwaita/gtk-3.0/gtk-widgets.css             |   26 ++++++++++---------
 3 files changed, 22 insertions(+), 37 deletions(-)
---
diff --git a/src/adwaita_engine.c b/src/adwaita_engine.c
index 34510d0..39534ae 100644
--- a/src/adwaita_engine.c
+++ b/src/adwaita_engine.c
@@ -119,16 +119,16 @@ adwaita_engine_render_focus (GtkThemingEngine *engine,
   GtkStateFlags state;
   gint line_width, focus_pad;
   gint border_radius;
-  gboolean use_dashes;
   double dashes[2] = { 2.0, 0.2 };
   const GtkWidgetPath *path;
+  GtkBorderStyle border_style;
 
   path = gtk_theming_engine_get_path (engine);
   state = gtk_theming_engine_get_state (engine);
   gtk_theming_engine_get (engine, state,
-                          "-adwaita-focus-border-color", &border_color,
-                          "-adwaita-focus-border-radius", &border_radius,
-                          "-adwaita-focus-border-dashes", &use_dashes,
+                          "outline-color", &border_color,
+                          "outline-style", &border_style,
+                          "outline-offset", &border_radius,
                           NULL);
 
   gtk_theming_engine_get_style (engine,
@@ -170,7 +170,7 @@ adwaita_engine_render_focus (GtkThemingEngine *engine,
                                   width - 1, height - 1,
                                   SIDE_ALL, GTK_JUNCTION_NONE);
 
-  if (use_dashes)
+  if (border_style == GTK_BORDER_STYLE_DASHED)
     cairo_set_dash (cr, dashes, 1, 0.0);
 
   if (border_color != NULL)
@@ -409,28 +409,11 @@ adwaita_engine_class_init (AdwaitaEngineClass *klass)
   engine_class->render_focus = adwaita_engine_render_focus;
   engine_class->render_extension = adwaita_engine_render_extension;
   engine_class->render_expander = adwaita_engine_render_expander;
-
-  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
-                                        g_param_spec_boxed ("focus-border-color",
-                                                            "Focus border color",
-                                                            "Focus border color",
-                                                            GDK_TYPE_RGBA, 0));
-  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
-                                        g_param_spec_int ("focus-border-radius",
-                                                          "Focus border radius",
-                                                          "Focus border radius",
-                                                          0, G_MAXINT, 0,
-                                                          0));
   gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
                                         g_param_spec_boxed ("border-gradient",
                                                             "Border gradient",
                                                             "Border gradient",
                                                             CAIRO_GOBJECT_TYPE_PATTERN, 0));
-  gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
-                                        g_param_spec_boolean ("focus-border-dashes",
-                                                              "Focus border uses dashes",
-                                                              "Focus border uses dashes",
-                                                              FALSE, 0));
 }
 
 static void
diff --git a/themes/Adwaita/gtk-3.0/gtk-widgets-dark-overrides.css b/themes/Adwaita/gtk-3.0/gtk-widgets-dark-overrides.css
index d0646c6..0a92738 100644
--- a/themes/Adwaita/gtk-3.0/gtk-widgets-dark-overrides.css
+++ b/themes/Adwaita/gtk-3.0/gtk-widgets-dark-overrides.css
@@ -10,9 +10,9 @@ GtkIconView.view.cell:selected:focus {
     /* FIXME: this probably needs to be better;
      * see https://bugzilla.gnome.org/show_bug.cgi?id=644157
      */
-    -adwaita-focus-border-color: alpha(@theme_text_color, 0.4);
-    -adwaita-focus-border-radius: 5;
-    -adwaita-focus-border-dashes: true;
+    outline-color: alpha(@theme_text_color, 0.4);
+    outline-style: dashed;
+    outline-offset: 5px;
 }
 
 .button,
diff --git a/themes/Adwaita/gtk-3.0/gtk-widgets.css b/themes/Adwaita/gtk-3.0/gtk-widgets.css
index c14d53a..974401a 100644
--- a/themes/Adwaita/gtk-3.0/gtk-widgets.css
+++ b/themes/Adwaita/gtk-3.0/gtk-widgets.css
@@ -37,11 +37,16 @@
 
     -GtkWidget-focus-padding: 2;
     -GtkWidget-focus-line-width: 1;
-    -adwaita-focus-border-color: alpha(@theme_text_color, 0.3);
-    -adwaita-focus-border-radius: 2;
-    -adwaita-focus-border-dashes: 1;
     -GtkWindow-resize-grip-width: 0;
     -GtkWindow-resize-grip-height: 0;   
+
+    /* We use the outline properties to signal the focus properties
+     * to the adwaita engine: using real CSS properties is faster,
+     * and we don't use any outlines for now.
+     */
+    outline-color: alpha(@theme_text_color, 0.3);
+    outline-style: dashed;
+    outline-offset: 2px;
 }
 
 /***************
@@ -1623,8 +1628,6 @@ GtkLinkButton.button *:active {
                                       @notebook_tab_gradient_a 2px,
                                       @notebook_tab_gradient_a 7px,
                                       @notebook_tab_gradient_b);
-
-    -adwaita-focus-border-radius: 2;
 }
 
 .notebook tab.bottom {
@@ -2951,9 +2954,8 @@ GtkTreeView {
 
     -GtkWidget-focus-line-width: 1;
     -GtkWidget-focus-padding: 1;
-    -adwaita-focus-border-radius: 2;
-    -adwaita-focus-border-dashes: 1;
-    -adwaita-focus-border-color: alpha(@theme_text_color, 0.6);
+
+    outline-color: alpha(@theme_text_color, 0.6);
 }
 
 GtkTreeView.dnd {
@@ -2980,9 +2982,9 @@ GtkIconView.view.cell:selected:focus {
     /* FIXME: this probably needs to be better;
      * see https://bugzilla.gnome.org/show_bug.cgi?id=644157
      */
-    -adwaita-focus-border-color: @treeview_focus_border;
-    -adwaita-focus-border-radius: 3;
-    -adwaita-focus-border-dashes: 0;
+    outline-color: @treeview_focus_border;
+    outline-style: solid;
+    outline-offset: 3px;
 }
 
 .view,
@@ -3018,7 +3020,7 @@ GtkTreeView:backdrop:selected {
 }
 
 GtkTreeView:selected:focus {
-    -adwaita-focus-border-color: mix(@theme_selected_fg_color, @theme_selected_bg_color, 0.30);
+    outline-color: mix(@theme_selected_fg_color, @theme_selected_bg_color, 0.30);
 }
 
 column-header.button,



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