changeset 5983:8fed02d53b45 v7.4.332

updated for version 7.4.332 Problem: GTK: When a sign icon doesn't fit exactly there can be ugly gaps. Solution: Scale the sign to fit when the aspect ratio is not too far off. (Christian Brabandt)
author Bram Moolenaar <bram@vim.org>
date Tue, 17 Jun 2014 18:47:02 +0200
parents 085deb93b59c
children 6891999bf668
files src/gui_gtk_x11.c src/version.c
diffstat 2 files changed, 33 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -5965,27 +5965,48 @@ gui_mch_drawsign(int row, int col, int t
 	 * Decide whether we need to scale.  Allow one pixel of border
 	 * width to be cut off, in order to avoid excessive scaling for
 	 * tiny differences in font size.
+	 * Do scale to fit the height to avoid gaps because of linespacing.
 	 */
 	need_scale = (width > SIGN_WIDTH + 2
-		      || height > SIGN_HEIGHT + 2
+		      || height != SIGN_HEIGHT
 		      || (width < 3 * SIGN_WIDTH / 4
 			  && height < 3 * SIGN_HEIGHT / 4));
 	if (need_scale)
 	{
-	    double aspect;
+	    double  aspect;
+	    int	    w = width;
+	    int	    h = height;
 
 	    /* Keep the original aspect ratio */
 	    aspect = (double)height / (double)width;
 	    width  = (double)SIGN_WIDTH * SIGN_ASPECT / aspect;
 	    width  = MIN(width, SIGN_WIDTH);
-	    height = (double)width * aspect;
-
-	    /* This doesn't seem to be worth caching, and doing so
-	     * would complicate the code quite a bit. */
-	    sign = gdk_pixbuf_scale_simple(sign, width, height,
-					   GDK_INTERP_BILINEAR);
-	    if (sign == NULL)
-		return; /* out of memory */
+	    if (((double)(MAX(height, SIGN_HEIGHT)) /
+		 (double)(MIN(height, SIGN_HEIGHT))) < 1.15)
+	    {
+		/* Change the aspect ratio by at most 15% to fill the
+		 * available space completly. */
+		height = (double)SIGN_HEIGHT * SIGN_ASPECT / aspect;
+		height = MIN(height, SIGN_HEIGHT);
+	    }
+	    else
+		height = (double)width * aspect;
+
+	    if (w == width && h == height)
+	    {
+		/* no change in dimensions; don't decrease reference counter
+		 * (below) */
+		need_scale = FALSE;
+	    }
+	    else
+	    {
+		/* This doesn't seem to be worth caching, and doing so would
+		 * complicate the code quite a bit. */
+		sign = gdk_pixbuf_scale_simple(sign, width, height,
+							 GDK_INTERP_BILINEAR);
+		if (sign == NULL)
+		    return; /* out of memory */
+	    }
 	}
 
 	/* The origin is the upper-left corner of the pixmap.  Therefore
--- a/src/version.c
+++ b/src/version.c
@@ -735,6 +735,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    332,
+/**/
     331,
 /**/
     330,