From 8dd100d9b0539bc6bb28c95bdd8e7d5329faf42d Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Mon, 5 Aug 2013 16:37:39 +0200 Subject: [PATCH] notebook: Improve the style of the default arrows https://bugzilla.gnome.org/show_bug.cgi?id=707920 --- gtk/gtkthemingengine.c | 55 +++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index ee9a1a40b6..18f7f7403b 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -1262,26 +1262,6 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine, cairo_restore (cr); } -static void -add_path_arrow (cairo_t *cr, - gdouble angle, - gdouble x, - gdouble y, - gdouble size) -{ - cairo_save (cr); - - cairo_translate (cr, x + (size / 2), y + (size / 2)); - cairo_rotate (cr, angle); - - cairo_move_to (cr, 0, - (size / 4)); - cairo_line_to (cr, - (size / 2), (size / 4)); - cairo_line_to (cr, (size / 2), (size / 4)); - cairo_close_path (cr); - - cairo_restore (cr); -} - static void gtk_theming_engine_render_arrow (GtkThemingEngine *engine, cairo_t *cr, @@ -1290,24 +1270,33 @@ gtk_theming_engine_render_arrow (GtkThemingEngine *engine, gdouble y, gdouble size) { - GtkStateFlags flags; - GdkRGBA fg_color; + double line_width; + GtkStateFlags state; + GdkRGBA color; cairo_save (cr); - flags = gtk_theming_engine_get_state (engine); - gtk_theming_engine_get_color (engine, flags, &fg_color); + line_width = size / 3.0 / sqrt (2); + cairo_set_line_width (cr, line_width); + cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); - if (flags & GTK_STATE_FLAG_INSENSITIVE) - { - add_path_arrow (cr, angle, x + 1, y + 1, size); - cairo_set_source_rgb (cr, 1, 1, 1); - cairo_fill (cr); - } + cairo_translate (cr, x + size / 2.0, y + size / 2.0); + cairo_rotate (cr, angle - G_PI_2); + cairo_translate (cr, size / 4.0, 0); - add_path_arrow (cr, angle, x, y, size); - gdk_cairo_set_source_rgba (cr, &fg_color); - cairo_fill (cr); + cairo_scale (cr, + (size / (size + line_width)), + (size / (size + line_width))); + + cairo_move_to (cr, -size / 2.0, -size / 2.0); + cairo_rel_line_to (cr, size / 2.0, size / 2.0); + cairo_rel_line_to (cr, - size / 2.0, size / 2.0); + + state = gtk_theming_engine_get_state (engine); + gtk_theming_engine_get_color (engine, state, &color); + gdk_cairo_set_source_rgba (cr, &color); + cairo_stroke (cr); cairo_restore (cr); }