lkundrak / rpms / vim

Forked from rpms/vim 4 years ago
Clone
27f83df
To: vim_dev@googlegroups.com
27f83df
Subject: Patch 7.4.332
27f83df
Fcc: outbox
27f83df
From: Bram Moolenaar <Bram@moolenaar.net>
27f83df
Mime-Version: 1.0
27f83df
Content-Type: text/plain; charset=UTF-8
27f83df
Content-Transfer-Encoding: 8bit
27f83df
------------
27f83df
27f83df
Patch 7.4.332
27f83df
Problem:    GTK: When a sign icon doesn't fit exactly there can be ugly gaps.
27f83df
Solution:   Scale the sign to fit when the aspect ratio is not too far off.
27f83df
	    (Christian Brabandt)
27f83df
Files:	    src/gui_gtk_x11.c
27f83df
27f83df
27f83df
*** ../vim-7.4.331/src/gui_gtk_x11.c	2014-05-13 20:19:53.573808877 +0200
27f83df
--- src/gui_gtk_x11.c	2014-06-17 18:44:39.900755807 +0200
27f83df
***************
27f83df
*** 5965,5991 ****
27f83df
  	 * Decide whether we need to scale.  Allow one pixel of border
27f83df
  	 * width to be cut off, in order to avoid excessive scaling for
27f83df
  	 * tiny differences in font size.
27f83df
  	 */
27f83df
  	need_scale = (width > SIGN_WIDTH + 2
27f83df
! 		      || height > SIGN_HEIGHT + 2
27f83df
  		      || (width < 3 * SIGN_WIDTH / 4
27f83df
  			  && height < 3 * SIGN_HEIGHT / 4));
27f83df
  	if (need_scale)
27f83df
  	{
27f83df
! 	    double aspect;
27f83df
  
27f83df
  	    /* Keep the original aspect ratio */
27f83df
  	    aspect = (double)height / (double)width;
27f83df
  	    width  = (double)SIGN_WIDTH * SIGN_ASPECT / aspect;
27f83df
  	    width  = MIN(width, SIGN_WIDTH);
27f83df
! 	    height = (double)width * aspect;
27f83df
  
27f83df
! 	    /* This doesn't seem to be worth caching, and doing so
27f83df
! 	     * would complicate the code quite a bit. */
27f83df
! 	    sign = gdk_pixbuf_scale_simple(sign, width, height,
27f83df
! 					   GDK_INTERP_BILINEAR);
27f83df
! 	    if (sign == NULL)
27f83df
! 		return; /* out of memory */
27f83df
  	}
27f83df
  
27f83df
  	/* The origin is the upper-left corner of the pixmap.  Therefore
27f83df
--- 5965,6012 ----
27f83df
  	 * Decide whether we need to scale.  Allow one pixel of border
27f83df
  	 * width to be cut off, in order to avoid excessive scaling for
27f83df
  	 * tiny differences in font size.
27f83df
+ 	 * Do scale to fit the height to avoid gaps because of linespacing.
27f83df
  	 */
27f83df
  	need_scale = (width > SIGN_WIDTH + 2
27f83df
! 		      || height != SIGN_HEIGHT
27f83df
  		      || (width < 3 * SIGN_WIDTH / 4
27f83df
  			  && height < 3 * SIGN_HEIGHT / 4));
27f83df
  	if (need_scale)
27f83df
  	{
27f83df
! 	    double  aspect;
27f83df
! 	    int	    w = width;
27f83df
! 	    int	    h = height;
27f83df
  
27f83df
  	    /* Keep the original aspect ratio */
27f83df
  	    aspect = (double)height / (double)width;
27f83df
  	    width  = (double)SIGN_WIDTH * SIGN_ASPECT / aspect;
27f83df
  	    width  = MIN(width, SIGN_WIDTH);
27f83df
! 	    if (((double)(MAX(height, SIGN_HEIGHT)) /
27f83df
! 		 (double)(MIN(height, SIGN_HEIGHT))) < 1.15)
27f83df
! 	    {
27f83df
! 		/* Change the aspect ratio by at most 15% to fill the
27f83df
! 		 * available space completly. */
27f83df
! 		height = (double)SIGN_HEIGHT * SIGN_ASPECT / aspect;
27f83df
! 		height = MIN(height, SIGN_HEIGHT);
27f83df
! 	    }
27f83df
! 	    else
27f83df
! 		height = (double)width * aspect;
27f83df
  
27f83df
! 	    if (w == width && h == height)
27f83df
! 	    {
27f83df
! 		/* no change in dimensions; don't decrease reference counter
27f83df
! 		 * (below) */
27f83df
! 		need_scale = FALSE;
27f83df
! 	    }
27f83df
! 	    else
27f83df
! 	    {
27f83df
! 		/* This doesn't seem to be worth caching, and doing so would
27f83df
! 		 * complicate the code quite a bit. */
27f83df
! 		sign = gdk_pixbuf_scale_simple(sign, width, height,
27f83df
! 							 GDK_INTERP_BILINEAR);
27f83df
! 		if (sign == NULL)
27f83df
! 		    return; /* out of memory */
27f83df
! 	    }
27f83df
  	}
27f83df
  
27f83df
  	/* The origin is the upper-left corner of the pixmap.  Therefore
27f83df
*** ../vim-7.4.331/src/version.c	2014-06-17 18:16:08.420691059 +0200
27f83df
--- src/version.c	2014-06-17 18:46:49.784760721 +0200
27f83df
***************
27f83df
*** 736,737 ****
27f83df
--- 736,739 ----
27f83df
  {   /* Add new patch number below this line */
27f83df
+ /**/
27f83df
+     332,
27f83df
  /**/
27f83df
27f83df
-- 
27f83df
       "To whoever finds this note -
27f83df
       I have been imprisoned by my father who wishes me to marry
27f83df
       against my will.  Please please please please come and rescue me.
27f83df
       I am in the tall tower of Swamp Castle."
27f83df
   SIR LAUNCELOT's eyes light up with holy inspiration.
27f83df
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
27f83df
27f83df
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
27f83df
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
27f83df
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
27f83df
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///