From: YAMAMOTO Mitsuharu Date: Sat, 1 Dec 2012 02:38:11 +0000 (+0800) Subject: Fix drawing of relief rects on X and W32. X-Git-Tag: emacs-24.3.90~173^2~9^2~110 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=75b4f59c279cbab4ad6a056b39f876b9a7518267;p=emacs.git 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. Fixes: debbugs:10500 --- diff --git a/src/ChangeLog b/src/ChangeLog index 4b5e56f5dc2..a6fabdccdea 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2012-12-01 YAMAMOTO Mitsuharu + + * 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 * doc.c (Fdocumentation): Re-add handling of function-documentation, diff --git a/src/w32term.c b/src/w32term.c index ab6afd32c75..84f99c090c8 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -1738,8 +1738,8 @@ w32_draw_relief_rect (struct frame *f, 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 @@ w32_draw_relief_rect (struct frame *f, 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 @@ x_draw_image_foreground (struct glyph_string *s) 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 @@ x_draw_image_relief (struct glyph_string *s) 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); } diff --git a/src/xterm.c b/src/xterm.c index 61e942e10d2..b6bd9e9655a 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -2019,7 +2019,8 @@ x_draw_relief_rect (struct frame *f, 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 @@ x_draw_relief_rect (struct frame *f, 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 @@ x_draw_image_foreground (struct glyph_string *s) 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 @@ x_draw_image_relief (struct glyph_string *s) 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); }