Hi Bram!

On Do, 12 Jun 2014, Bram Moolenaar wrote:

> 
> Christian wrote:
> 
> > Bram,
> > I noticed, when displaying icon signs in the gui version of Vim there 
> > might be a small line not overdrawn by the sign, caused by the 
> > 'linespace' setting set to be one. That does look rather ugly, if you 
> > display several signs side by side (see attached screenshot).
> 
> Do you mean that the dark line below the "+" sign should not be there?
> And if 'linespace' is set to zero that black line is indeed gone?

It goes away, if I set linespace to -1. But that has other screen 
problems.
> 
> > Here is a patch. A couple of comments:
> > 1) I am not sure, why a call to gdk_draw_rectangle() is done in the 
> > existing code. I have left it out as it seems to be unnecessary
> 
> I believe this is needed to first clear the area with the background
> color, in case the icon drawn is smaller than the available space.
> Perhaps you can try it with a rectangular icon, vertically and
> horizontally. E.g. something like a red exclamation mark.  There would
> need to be some other sign at first to see any effect.

I used an rectangular icon. But you are right, this was probably done 
for making sure, transparent icons are drawn correctly. I thought about 
using transparent signs, but I don not want to use different icons for 
different builts (e.g. png for GTK and bmp for Windows), so I usually 
use the same icon everywhere.
> 
> > 2) not sure, why a height of 127 was hard coded when drawing the size 
> > area. I have used the actual sign size for that
> 
> The 127 is the value for "alpha_threshold".  At least according to the
> documentation I found.

Ah my bad, I got confused by the non_alpha function.
> 
> > 3) when the sign hight differs from the char_height, it will always be 
> > rescaled. This of course has the additional disadvantage of causing a 
> > performance issue. Not sure, if this is noticeable, though.
> 
> I don't think we should worry about performance.
> 
> It appears that after your change the aspect ratio of the sign is not
> kept.  Although that would be OK for filling the gap, if the sign was
> really a different shape it would look weird.  In your specific case you
> would want the sign to fill the available space and probably don't care
> about keeping the aspect ratio.  Adding a setting for this woule make it
> complicated...
> 
> How about this: if we can fill the available space with a slightly
> different ascpect ratio, e.g., 10% different, filling the gap is nicer
> than the slightly different aspect ratio.  If we change the aspect ratio
> more than 10% or so the icon will start looking weird and we stick to
> the aspect ratio and as a result there will be a gap (either vertically
> or horizontally).
> 
> The names are a bit confusing, SIGN_ASPECT actually means the aspect
> ratio of the space availeble, with "aspect" is the aspect ratio of the
> sign being drawn.
> 
> This also very much depends on the font size, since the space used for
> the icon is two character cells wide and one character cell plus
> 'linespace' high.

Okay, how about the attached patch (it allows 15% deviation to the 
aspect ratio (so one can change linespace value by at most 2 for a sign 
of 16x16 pixel and the sign will be completely filled)

Best,
Christian
-- 
Kennst Du den Unterschied zwischen einem Arbeitslosen und einem Beamten?
Arbeitslose haben schon einmal gearbeitet.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -5967,25 +5967,42 @@ gui_mch_drawsign(int row, int col, int t
 	 * tiny differences in font size.
 	 */
 	need_scale = (width > SIGN_WIDTH + 2
-		      || height > SIGN_HEIGHT + 2
+		      || height != SIGN_HEIGHT /* might differ because of linespaceing */
 		      || (width < 3 * SIGN_WIDTH / 4
 			  && height < 3 * SIGN_HEIGHT / 4));
 	if (need_scale)
 	{
 	    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)
+	    {
+		/* allow to change the aspect ratio by at most 15% so the
+		 * lines will get filled 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 */
+	    {
+		/* 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 */
+	    }
+	    else
+		/* don't decrease reference counter (below) */
+		need_scale = FALSE;
 	}
 
 	/* The origin is the upper-left corner of the pixmap.  Therefore

Raspunde prin e-mail lui