[gnome-themes-standard] expander: use stock render_frame and render_background



commit 85ef85147886833848fecfcc95379ccbb1e19ac1
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon May 9 13:53:01 2011 -0400

    expander: use stock render_frame and render_background
    
    Don't use custom code to render frame and background for the expander,
    and make the rendering engine code more generic.

 src/adwaita_engine.c                   |   59 ++++++++++++++++++-------------
 themes/Adwaita/gtk-3.0/gtk-widgets.css |   16 +++++++-
 2 files changed, 48 insertions(+), 27 deletions(-)
---
diff --git a/src/adwaita_engine.c b/src/adwaita_engine.c
index c3acea7..b3e5a01 100644
--- a/src/adwaita_engine.c
+++ b/src/adwaita_engine.c
@@ -909,46 +909,55 @@ adwaita_engine_render_expander (GtkThemingEngine *engine,
 				gdouble           width,
 				gdouble           height)
 {
-	GdkRGBA border, bg, fg;
+	GdkRGBA fg;
 	GtkStateFlags state;
-	gint side;
+	gdouble side, offset;
+	gint line_width;
+	GtkBorder border;
 
-	side = MIN (width, height);
+	side = floor (MIN (width, height));
 
-	x += ((int) width / 2) - (side / 2);
-	y += ((int) height / 2) - (side / 2);
+	/* make sure the side length is always odd */
+	if (((gint) side % 2) == 0) {
+		side -= 1.0;
+	}
 
-	state = gtk_theming_engine_get_state (engine);
+	x += width / 2 - side / 2;
+	y += height / 2 - side / 2;
 
-	gtk_theming_engine_get_border_color (engine, state, &border);
-	gtk_theming_engine_get_background_color (engine, state, &bg);
-	gtk_theming_engine_get_color (engine, state, &fg);
+	GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background
+		(engine, cr, x, y, side, side);
+	GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_frame
+		(engine, cr, x, y, side, side);
 
-	cairo_save (cr);
-
-	cairo_set_line_width (cr, 1);
+	state = gtk_theming_engine_get_state (engine);
+	gtk_theming_engine_get_color (engine, state, &fg);
+	gtk_theming_engine_get_border (engine, state, &border);
 
-	_cairo_round_rectangle_sides (cr, 2,
-				      x + 0.5, y + 0.5,
-				      side, side,
-				      SIDE_ALL, GTK_JUNCTION_NONE);
-	gdk_cairo_set_source_rgba (cr, &bg);
-	cairo_fill_preserve (cr);
+	line_width = 1;
+	offset = (1 + line_width / 2.0);
 
-	gdk_cairo_set_source_rgba (cr, &border);
-	cairo_stroke (cr);
+	cairo_save (cr);
 
-	cairo_set_line_width (cr, 1);
+	cairo_set_line_width (cr, line_width);
 	cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
 	gdk_cairo_set_source_rgba (cr, &fg);
 
-	cairo_move_to (cr, x + 3, y + side / 2 + 0.5);
-	cairo_line_to (cr, x + side - 2, y + side / 2 + 0.5);
+	cairo_move_to (cr,
+		       x + border.left + offset,
+		       y + side / 2);
+	cairo_line_to (cr,
+		       x + side - (border.right + offset),
+		       y + side / 2);
 
 	if ((state & GTK_STATE_FLAG_ACTIVE) == 0)
 	{
-		cairo_move_to (cr, x + side / 2 + 0.5, y + 3);
-		cairo_line_to (cr, x + side / 2 + 0.5, y + side - 2);
+		cairo_move_to (cr,
+			       x + side / 2,
+			       y + border.top + offset);
+		cairo_line_to (cr,
+			       x + side / 2,
+			       y + side - (border.bottom + offset));
 	}
 
 	cairo_stroke (cr);
diff --git a/themes/Adwaita/gtk-3.0/gtk-widgets.css b/themes/Adwaita/gtk-3.0/gtk-widgets.css
index 7fb8eaa..c716f84 100644
--- a/themes/Adwaita/gtk-3.0/gtk-widgets.css
+++ b/themes/Adwaita/gtk-3.0/gtk-widgets.css
@@ -999,7 +999,7 @@ GtkIconView.view.cell:selected:focused {
 
 GtkTreeView {
     -GtkTreeView-vertical-separator: 0;
-    -GtkTreeView-expander-size: 8;
+    -GtkTreeView-expander-size: 9;
 
     -GtkWidget-focus-line-width: 1;
     -adwaita-focus-border-radius: 0;
@@ -1060,13 +1060,19 @@ row:selected {
 }
 
 .expander {
-    color: @internal_element_color;
+    border-style: solid;
+    border-width: 1;
+    border-radius: 2;
     border-color: @internal_element_color;
 
+    color: @internal_element_color;
     background-color: @theme_base_color;
 }
 
 .expander:active {
+    border-style: solid;
+    border-width: 1;
+
     color: @internal_element_color;
     border-color: @internal_element_color;
 
@@ -1074,6 +1080,9 @@ row:selected {
 }
 
 .expander:prelight {
+    border-style: solid;
+    border-width: 1;
+
     color: @internal_element_color;
     border-color: @internal_element_color;
 
@@ -1082,6 +1091,9 @@ row:selected {
 
 .expander row:selected,
 .expander row:selected:focused {
+    border-style: solid;
+    border-width: 1;
+
     border-color: @expander_row_selected_color;
     color: @expander_row_selected_color;
     background-color: @theme_selected_bg_color;



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