From 6c312605bf6d89ae90df8e45121776226bf3550b Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 19 Nov 2017 11:45:55 +0000 Subject: [PATCH] Add window divider faces to NS (bug#29353) * src/nsterm.m (ns_draw_window_divider): Use window-divider-first-pixel and window-divider-last-pixel faces. --- src/nsterm.m | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index 5c29f039e51..cf32a5e8015 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3174,18 +3174,54 @@ ns_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1) -------------------------------------------------------------------------- */ { struct frame *f = XFRAME (WINDOW_FRAME (w)); - struct face *face; - NSRect r = NSMakeRect (x0, y0, x1-x0, y1-y0); + struct face *face = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FACE_ID); + struct face *face_first + = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID); + struct face *face_last + = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID); + unsigned long color = face ? face->foreground : FRAME_FOREGROUND_PIXEL (f); + unsigned long color_first = (face_first + ? face_first->foreground + : FRAME_FOREGROUND_PIXEL (f)); + unsigned long color_last = (face_last + ? face_last->foreground + : FRAME_FOREGROUND_PIXEL (f)); + NSRect divider = NSMakeRect (x0, y0, x1-x0, y1-y0); NSTRACE ("ns_draw_window_divider"); - face = FACE_FROM_ID_OR_NULL (f, WINDOW_DIVIDER_FACE_ID); + ns_focus (f, ÷r, 1); - ns_focus (f, &r, 1); - if (face) - [ns_lookup_indexed_color(face->foreground, f) set]; + if ((y1 - y0 > x1 - x0) && (x1 - x0 >= 3)) + /* A vertical divider, at least three pixels wide: Draw first and + last pixels differently. */ + { + [ns_lookup_indexed_color(color_first, f) set]; + NSRectFill(NSMakeRect (x0, y0, 1, y1 - y0)); + [ns_lookup_indexed_color(color, f) set]; + NSRectFill(NSMakeRect (x0 + 1, y0, x1 - x0 - 2, y1 - y0)); + [ns_lookup_indexed_color(color_last, f) set]; + NSRectFill(NSMakeRect (x1 - 1, y0, 1, y1 - y0)); + } + else if ((x1 - x0 > y1 - y0) && (y1 - y0 >= 3)) + /* A horizontal divider, at least three pixels high: Draw first and + last pixels differently. */ + { + [ns_lookup_indexed_color(color_first, f) set]; + NSRectFill(NSMakeRect (x0, y0, x1 - x0, 1)); + [ns_lookup_indexed_color(color, f) set]; + NSRectFill(NSMakeRect (x0, y0 + 1, x1 - x0, y1 - y0 - 2)); + [ns_lookup_indexed_color(color_last, f) set]; + NSRectFill(NSMakeRect (x0, y1 - 1, x1 - x0, 1)); + } + else + { + /* In any other case do not draw the first and last pixels + differently. */ + [ns_lookup_indexed_color(color, f) set]; + NSRectFill(divider); + } - NSRectFill(r); ns_unfocus (f); } -- 2.39.2