[gtk-theme-engine-clearlooks] Implement render_arrow()



commit c240e88276365f5d8ff0e58ad6a92c8a4b82394e
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Nov 16 00:52:04 2010 +0100

    Implement render_arrow()

 src/clearlooks_draw.c   |   21 +++---------------
 src/clearlooks_engine.c |   52 +++++++++++++++++-----------------------------
 src/clearlooks_types.h  |    2 +-
 3 files changed, 24 insertions(+), 51 deletions(-)
---
diff --git a/src/clearlooks_draw.c b/src/clearlooks_draw.c
index e504af8..2cc2acb 100644
--- a/src/clearlooks_draw.c
+++ b/src/clearlooks_draw.c
@@ -2711,26 +2711,13 @@ clearlooks_draw_combo_arrow (cairo_t *cr, const CairoColor *color,
 
 static void
 _clearlooks_draw_arrow (cairo_t *cr, const CairoColor *color,
-                        ClearlooksDirection dir, ClearlooksArrowType type,
+                        gdouble angle, ClearlooksArrowType type,
                         double x, double y, double width, double height)
 {
-	double rotate;
-
-	if (dir == CL_DIRECTION_LEFT)
-		rotate = G_PI*1.5;
-	else if (dir == CL_DIRECTION_RIGHT)
-		rotate = G_PI*0.5;
-	else if (dir == CL_DIRECTION_UP)
-		rotate = G_PI;
-	else if (dir == CL_DIRECTION_DOWN)
-		rotate = 0;
-	else
-		return;
-
 	if (type == CL_ARROW_NORMAL)
 	{
 		cairo_translate (cr, x, y);
-		cairo_rotate (cr, -rotate);
+		cairo_rotate (cr, angle - G_PI);
 		clearlooks_draw_normal_arrow (cr, color, 0, 0, width, height);
 	}
 	else if (type == CL_ARROW_COMBO)
@@ -2764,12 +2751,12 @@ clearlooks_draw_arrow (cairo_t *cr,
                 cairo_save (cr);
 		clearlooks_lookup_shade (engine, 0, (GdkRGBA *) &shade);
 		_clearlooks_draw_arrow (cr, &shade,
-		                        arrow->direction, arrow->type,
+		                        arrow->angle, arrow->type,
 		                        tx+0.5, ty+0.5, width, height);
                 cairo_restore (cr);
 	}
 
-	_clearlooks_draw_arrow (cr, color, arrow->direction, arrow->type,
+	_clearlooks_draw_arrow (cr, color, arrow->angle, arrow->type,
 	                        tx, ty, width, height);
 
 	gdk_rgba_free ((GdkRGBA *) color);
diff --git a/src/clearlooks_engine.c b/src/clearlooks_engine.c
index 7fdc6de..aa44709 100644
--- a/src/clearlooks_engine.c
+++ b/src/clearlooks_engine.c
@@ -1297,53 +1297,38 @@ clearlooks_style_draw_tab (DRAW_ARGS)
 	STYLE_FUNCTION(draw_arrow) (cr, colors, &params, &arrow, x, y, width, height);
 }
 
+#endif
+
 static void
-clearlooks_style_draw_arrow (GtkStyle      *style,
-                             cairo_t       *cr,
-                             GtkStateType   state_type,
-                             GtkShadowType  shadow,
-                             GtkWidget     *widget,
-                             const gchar   *detail,
-                             GtkArrowType   arrow_type,
-                             gboolean       fill,
-                             gint           x,
-                             gint           y,
-                             gint           width,
-                             gint           height)
+clearlooks_engine_render_arrow (GtkThemingEngine *engine,
+				cairo_t          *cr,
+				gdouble           angle,
+				gdouble           x,
+				gdouble           y,
+				gdouble           size)
 {
-	ClearlooksStyle  *clearlooks_style = CLEARLOOKS_STYLE (style);
-	ClearlooksColors *colors = &clearlooks_style->colors;
+	ClearlooksStyleFunctions *style_functions;
+	ClearlooksEngine  *clearlooks_engine = CLEARLOOKS_ENGINE (engine);
 	WidgetParameters params;
 	ArrowParameters  arrow;
 
-	CHECK_ARGS
-
-	if (arrow_type == GTK_ARROW_NONE)
-	      return;
+	GE_CAIRO_INIT;
 
-	clearlooks_set_widget_parameters (widget, style, state_type, &params);
 	arrow.type = CL_ARROW_NORMAL;
-	arrow.direction = (ClearlooksDirection)arrow_type;
+	arrow.angle = angle;
 
-	if (ge_is_combo_box (widget, FALSE) && !ge_is_combo_box_entry (widget))
+	if (gtk_theming_engine_has_class (engine, "combo") &&
+	    !gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_ENTRY))
 	{
 		arrow.type = CL_ARROW_COMBO;
 	}
 
-	/* I have no idea why, but the arrow of GtkCombo is larger than in other places.
-	 * Subtracting 3 seems to fix this. */
-	if (widget && gtk_widget_get_parent (widget) && GE_IS_COMBO (gtk_widget_get_parent (gtk_widget_get_parent (widget))))
-	{
-		if (params.ltr)
-			x += 1;
-		else
-			x += 2;
-		width -= 3;
-	}
-
-	STYLE_FUNCTION(draw_arrow) (cr, colors, &params, &arrow, x, y, width, height);
+	clearlooks_lookup_functions (CLEARLOOKS_ENGINE (engine),
+				     &style_functions, NULL);
+	style_functions->draw_arrow (cr, engine, &arrow, x, y, size, size);
 }
 
+#if 0
 static void
 clearlooks_style_realize (GtkStyle * style)
 {
@@ -1756,6 +1741,7 @@ clearlooks_engine_class_init (ClearlooksEngineClass * klass)
 {
 	GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass);
 
+	engine_class->render_arrow = clearlooks_engine_render_arrow;
 	engine_class->render_layout = clearlooks_engine_render_layout;
 	engine_class->render_icon_pixbuf = clearlooks_engine_render_icon_pixbuf;
 
diff --git a/src/clearlooks_types.h b/src/clearlooks_types.h
index eae5cdf..e41e461 100644
--- a/src/clearlooks_types.h
+++ b/src/clearlooks_types.h
@@ -319,7 +319,7 @@ typedef struct
 typedef struct
 {
 	ClearlooksArrowType type;
-	ClearlooksDirection direction;
+	gdouble angle;
 } ArrowParameters;
 
 typedef struct



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