From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Box graphic tweak Date: Sat, 27 Nov 2010 13:19:16 +0200 Message-ID: <83pqtr580b.fsf@gnu.org> References: <878w29jmg5.fsf@stupidchicken.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1290856648 7272 80.91.229.12 (27 Nov 2010 11:17:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 27 Nov 2010 11:17:28 +0000 (UTC) Cc: Chong Yidong , emacs-devel@gnu.org To: Jason Rumney Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 27 12:17:24 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PMImR-0005gn-H4 for ged-emacs-devel@m.gmane.org; Sat, 27 Nov 2010 12:17:23 +0100 Original-Received: from localhost ([127.0.0.1]:60346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PMImQ-0004jm-RR for ged-emacs-devel@m.gmane.org; Sat, 27 Nov 2010 06:17:22 -0500 Original-Received: from [140.186.70.92] (port=54384 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PMImG-0004gI-Kl for emacs-devel@gnu.org; Sat, 27 Nov 2010 06:17:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PMImE-0001tS-La for emacs-devel@gnu.org; Sat, 27 Nov 2010 06:17:12 -0500 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:61184) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PMImE-0001sZ-EX; Sat, 27 Nov 2010 06:17:10 -0500 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0LCJ00000J4ZZJ00@a-mtaout21.012.net.il>; Sat, 27 Nov 2010 13:17:08 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([84.229.63.39]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LCJ000D5JCJMM80@a-mtaout21.012.net.il>; Sat, 27 Nov 2010 13:17:08 +0200 (IST) In-reply-to: <878w29jmg5.fsf@stupidchicken.com> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:133187 Archived-At: > From: Chong Yidong > Date: Fri, 08 Oct 2010 01:14:02 -0400 > > I just made a tweak to the way 3D boxes are drawn, to make them more > legible. The W32 code looks like it could use a similar change, but I > didn't want to do the translation without being able to test it. Could > someone on W32 take a look? Thanks. > > * xterm.c (x_draw_relief_rect): If box width is larger than 1, > draw the outermost line using the black relief, for legibility. > Omit drawing the four corner pixels. Jason, could you please do this? I tried, but the differences between the X and the w32 code are substantial to the degree that sufficient knowledge of the underlying primitives is required to DTRT, and I lack that knowledge. Thanks. For reference, here are the diffs for the changes done by Chong: === modified file 'src/xterm.c' --- src/xterm.c 2010-10-03 15:39:21 +0000 +++ src/xterm.c 2010-10-09 03:30:31 +0000 @@ -1942,18 +1942,38 @@ x_draw_relief_rect (struct frame *f, gc = f->output_data.x->black_relief.gc; XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted); + /* This code is more complicated than it has to be, because of two + minor hacks to make the boxes look nicer: (i) if width > 1, draw + the outermost line using the black relief. (ii) Omit the four + corner pixels. */ + /* Top. */ if (top_p) - for (i = 0; i < width; ++i) - XDrawLine (dpy, window, gc, - left_x + i * left_p, top_y + i, - right_x + 1 - i * right_p, top_y + i); + { + if (width == 1) + XDrawLine (dpy, window, gc, + left_x + (left_p ? 1 : 0), top_y, + right_x + (right_p ? 0 : 1), top_y); + + for (i = 1; i < width; ++i) + XDrawLine (dpy, window, gc, + left_x + i * left_p, top_y + i, + right_x + 1 - i * right_p, top_y + i); + } /* Left. */ if (left_p) - for (i = 0; i < width; ++i) - XDrawLine (dpy, window, gc, - left_x + i, top_y + i, left_x + i, bottom_y - i + 1); + { + if (width == 1) + XDrawLine (dpy, window, gc, left_x, top_y + 1, left_x, bottom_y); + + XClearArea (dpy, window, left_x, top_y, 1, 1, False); + XClearArea (dpy, window, left_x, bottom_y, 1, 1, False); + + 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); + } XSetClipMask (dpy, gc, None); if (raised_p) @@ -1962,18 +1982,40 @@ x_draw_relief_rect (struct frame *f, gc = f->output_data.x->white_relief.gc; XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted); + if (width > 1) + { + /* Outermost top line. */ + if (top_p) + XDrawLine (dpy, window, gc, + left_x + (left_p ? 1 : 0), top_y, + right_x + (right_p ? 0 : 1), top_y); + + /* Outermost left line. */ + if (left_p) + XDrawLine (dpy, window, gc, left_x, top_y + 1, left_x, bottom_y); + } + /* Bottom. */ if (bot_p) - for (i = 0; i < width; ++i) + { XDrawLine (dpy, window, gc, - left_x + i * left_p, bottom_y - i, - right_x + 1 - i * right_p, bottom_y - i); + left_x + (left_p ? 1 : 0), bottom_y, + right_x + (right_p ? 0 : 1), bottom_y); + for (i = 1; i < width; ++i) + XDrawLine (dpy, window, gc, + left_x + i * left_p, bottom_y - i, + right_x + 1 - i * right_p, bottom_y - i); + } /* Right. */ if (right_p) - for (i = 0; i < width; ++i) - XDrawLine (dpy, window, gc, - right_x - i, top_y + i + 1, right_x - i, bottom_y - i); + { + XClearArea (dpy, window, right_x, top_y, 1, 1, False); + 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); + } XSetClipMask (dpy, gc, None); }