]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.332 v7.4.332
authorBram Moolenaar <Bram@vim.org>
Tue, 17 Jun 2014 16:47:02 +0000 (18:47 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 17 Jun 2014 16:47:02 +0000 (18:47 +0200)
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)

src/gui_gtk_x11.c
src/version.c

index 0be60ad014b0422823b58642ec204793a5676af9..97ad6b0689967ba3bf07172d6a2f198b407d992f 100644 (file)
@@ -5965,27 +5965,48 @@ gui_mch_drawsign(int row, int col, int typenr)
         * 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
index be7bccbb4697b5b5e4692a3d0cb41e801af54314..0038a45f8bee2f0f71318921b0fd06f3431eb916 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    332,
 /**/
     331,
 /**/