emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111050: Fix drawing of relief rects


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111050: Fix drawing of relief rects on X and W32.
Date: Sat, 01 Dec 2012 10:38:11 +0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111050
fixes bug: http://debbugs.gnu.org/10500
author: YAMAMOTO Mitsuharu <address@hidden>
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sat 2012-12-01 10:38:11 +0800
message:
  Fix drawing of relief rects on X and W32.
  
  * xterm.c (x_draw_relief_rect, x_draw_image_relief): Fix relief
  display for sliced images.
  
  * w32term.c (w32_draw_relief_rect, x_draw_image_relief): Likewise.
modified:
  src/ChangeLog
  src/w32term.c
  src/xterm.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-11-30 17:27:41 +0000
+++ b/src/ChangeLog     2012-12-01 02:38:11 +0000
@@ -1,3 +1,10 @@
+2012-12-01  YAMAMOTO Mitsuharu  <address@hidden>
+
+       * xterm.c (x_draw_relief_rect, x_draw_image_relief): Fix relief
+       display for sliced images (Bug#10500).
+
+       * w32term.c (w32_draw_relief_rect, x_draw_image_relief): Likewise.
+
 2012-11-30  Juanma Barranquero  <address@hidden>
 
        * doc.c (Fdocumentation): Re-add handling of function-documentation,

=== modified file 'src/w32term.c'
--- a/src/w32term.c     2012-11-22 09:32:32 +0000
+++ b/src/w32term.c     2012-12-01 02:38:11 +0000
@@ -1738,8 +1738,8 @@
   if (left_p)
     for (i = 0; i < width; ++i)
       w32_fill_area (f, hdc, gc.foreground,
-                    left_x + i, top_y + i, 1,
-                    bottom_y - top_y - 2 * i + 1);
+                    left_x + i, top_y + (i + 1) * top_p, 1,
+                    bottom_y - top_y - (i + 1) * (bot_p + top_p) + 1);
 
   if (raised_p)
     gc.foreground = f->output_data.w32->black_relief.gc->foreground;
@@ -1757,8 +1757,8 @@
   if (right_p)
     for (i = 0; i < width; ++i)
       w32_fill_area (f, hdc, gc.foreground,
-                    right_x - i, top_y + i + 1, 1,
-                    bottom_y - top_y - 2 * i - 1);
+                    right_x - i, top_y + (i + 1) * top_p, 1,
+                    bottom_y - top_y - (i + 1) * (bot_p + top_p) + 1);
 
   w32_set_clip_rectangle (hdc, NULL);
 
@@ -1952,7 +1952,7 @@
 static void
 x_draw_image_relief (struct glyph_string *s)
 {
-  int x0, y0, x1, y1, thick, raised_p;
+  int x1, y1, thick, raised_p, top_p, bot_p, left_p, right_p;
   RECT r;
   int x = s->x;
   int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
@@ -1984,19 +1984,23 @@
       raised_p = s->img->relief > 0;
     }
 
-  x0 = x - thick;
-  y0 = y - thick;
-  x1 = x + s->slice.width + thick - 1;
-  y1 = y + s->slice.height + thick - 1;
+  x1 = x + s->slice.width - 1;
+  y1 = y + s->slice.height - 1;
+  top_p = bot_p = left_p = right_p = 0;
+
+  if (s->slice.x == 0)
+    x -= thick, left_p = 1;
+  if (s->slice.y == 0)
+    y -= thick, top_p = 1;
+  if (s->slice.x + s->slice.width == s->img->width)
+    x1 += thick, right_p = 1;
+  if (s->slice.y + s->slice.height == s->img->height)
+    y1 += thick, bot_p = 1;
 
   x_setup_relief_colors (s);
   get_glyph_string_clip_rect (s, &r);
-  w32_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p,
-                       s->slice.y == 0,
-                       s->slice.y + s->slice.height == s->img->height,
-                       s->slice.x == 0,
-                       s->slice.x + s->slice.width == s->img->width,
-                       &r);
+  w32_draw_relief_rect (s->f, x, y, x1, y1, thick, raised_p,
+                       top_p, bot_p, left_p, right_p, &r);
 }
 
 

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2012-11-22 09:32:32 +0000
+++ b/src/xterm.c       2012-12-01 02:38:11 +0000
@@ -2019,7 +2019,8 @@
 
       for (i = (width > 1 ? 1 : 0); i < width; ++i)
        XDrawLine (dpy, window, gc,
-                  left_x + i, top_y + i, left_x + i, bottom_y - i + 1);
+                  left_x + i, top_y + (i + 1) * top_p,
+                  left_x + i, bottom_y + 1 - (i + 1) * bot_p);
     }
 
   XSetClipMask (dpy, gc, None);
@@ -2061,7 +2062,8 @@
       XClearArea (dpy, window, right_x, bottom_y, 1, 1, False);
       for (i = 0; i < width; ++i)
        XDrawLine (dpy, window, gc,
-                  right_x - i, top_y + i + 1, right_x - i, bottom_y - i);
+                  right_x - i, top_y + (i + 1) * top_p,
+                  right_x - i, bottom_y + 1 - (i + 1) * bot_p);
     }
 
   XSetClipMask (dpy, gc, None);
@@ -2255,7 +2257,7 @@
 static void
 x_draw_image_relief (struct glyph_string *s)
 {
-  int x0, y0, x1, y1, thick, raised_p;
+  int x1, y1, thick, raised_p, top_p, bot_p, left_p, right_p;
   int extra_x, extra_y;
   XRectangle r;
   int x = s->x;
@@ -2301,19 +2303,23 @@
        extra_x = extra_y = XINT (Vtool_bar_button_margin);
     }
 
-  x0 = x - thick - extra_x;
-  y0 = y - thick - extra_y;
-  x1 = x + s->slice.width + thick - 1 + extra_x;
-  y1 = y + s->slice.height + thick - 1 + extra_y;
+  x1 = x + s->slice.width - 1;
+  y1 = y + s->slice.height - 1;
+  top_p = bot_p = left_p = right_p = 0;
+
+  if (s->slice.x == 0)
+    x -= thick, left_p = 1;
+  if (s->slice.y == 0)
+    y -= thick, top_p = 1;
+  if (s->slice.x + s->slice.width == s->img->width)
+    x1 += thick, right_p = 1;
+  if (s->slice.y + s->slice.height == s->img->height)
+    y1 += thick, bot_p = 1;
 
   x_setup_relief_colors (s);
   get_glyph_string_clip_rect (s, &r);
-  x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p,
-                     s->slice.y == 0,
-                     s->slice.y + s->slice.height == s->img->height,
-                     s->slice.x == 0,
-                     s->slice.x + s->slice.width == s->img->width,
-                     &r);
+  x_draw_relief_rect (s->f, x, y, x1, y1, thick, raised_p,
+                     top_p, bot_p, left_p, right_p, &r);
 }
 
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]