]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve display of relief rectangles on NS
authorPo Lu <luangruo@yahoo.com>
Tue, 10 May 2022 13:34:19 +0000 (21:34 +0800)
committerPo Lu <luangruo@yahoo.com>
Tue, 10 May 2022 13:34:44 +0000 (21:34 +0800)
* src/nsterm.m (ns_draw_relief): Respect cursor color and draw
corners like X.

src/nsterm.m

index 238a842d789201b42cca98aacc146e8eacb3989a..e25f94e5d80993ca656fbc8563f48fabfc43da5f 100644 (file)
@@ -3477,6 +3477,9 @@ ns_draw_relief (NSRect outer, int hthickness, int vthickness, char raised_p,
   else
     newBaseCol = [NSColor colorWithUnsignedLong: s->face->background];
 
+  if (s->hl == DRAW_CURSOR)
+    newBaseCol = FRAME_CURSOR_COLOR (s->f);
+
   if (newBaseCol == nil)
     newBaseCol = [NSColor grayColor];
 
@@ -3485,18 +3488,31 @@ ns_draw_relief (NSRect outer, int hthickness, int vthickness, char raised_p,
       [baseCol release];
       baseCol = [newBaseCol retain];
       [lightCol release];
-      lightCol = [[baseCol highlightWithLevel: 0.2] retain];
+      lightCol = [[baseCol highlightWithLevel: 0.4] retain];
       [darkCol release];
-      darkCol = [[baseCol shadowWithLevel: 0.3] retain];
+      darkCol = [[baseCol shadowWithLevel: 0.4] retain];
     }
 
   /* Calculate the inner rectangle.  */
-  inner = NSMakeRect (NSMinX (outer) + (left_p ? hthickness : 0),
-                      NSMinY (outer) + (top_p ? vthickness : 0),
-                      NSWidth (outer) - (left_p ? hthickness : 0)
-                     - (right_p ? hthickness : 0),
-                      NSHeight (outer) - (top_p ? vthickness : 0)
-                     - (bottom_p ? vthickness : 0));
+  inner = outer;
+
+  if (left_p)
+    {
+      inner.origin.x += vthickness;
+      inner.size.width -= vthickness;
+    }
+
+  if (right_p)
+    inner.size.width -= vthickness;
+
+  if (top_p)
+    {
+      inner.origin.y += hthickness;
+      inner.size.height -= hthickness;
+    }
+
+  if (bottom_p)
+    inner.size.height -= hthickness;
 
   [(raised_p ? lightCol : darkCol) set];
 
@@ -3508,7 +3524,7 @@ ns_draw_relief (NSRect outer, int hthickness, int vthickness, char raised_p,
       if (top_p)
         {
           [p lineToPoint: NSMakePoint (NSMaxX (outer), NSMinY (outer))];
-          [p lineToPoint :NSMakePoint (NSMaxX (inner), NSMinY (inner))];
+          [p lineToPointNSMakePoint (NSMaxX (inner), NSMinY (inner))];
         }
       [p lineToPoint: NSMakePoint (NSMinX (inner), NSMinY (inner))];
       if (left_p)
@@ -3584,6 +3600,31 @@ ns_draw_relief (NSRect outer, int hthickness, int vthickness, char raised_p,
 
   [darkCol set];
   [p stroke];
+
+  if (vthickness > 1 && hthickness > 1)
+    {
+      [FRAME_BACKGROUND_COLOR (s->f) set];
+
+      if (left_p && top_p)
+       [NSBezierPath fillRect: NSMakeRect (NSMinX (outer),
+                                           NSMinY (outer),
+                                           1, 1)];
+
+      if (right_p && top_p)
+       [NSBezierPath fillRect: NSMakeRect (NSMaxX (outer) - 1,
+                                           NSMinY (outer),
+                                           1, 1)];
+
+      if (right_p && bottom_p)
+       [NSBezierPath fillRect: NSMakeRect (NSMaxX (outer) - 1,
+                                           NSMaxY (outer) - 1,
+                                           1, 1)];
+
+      if (left_p && bottom_p)
+       [NSBezierPath fillRect: NSMakeRect (NSMinX (outer),
+                                           NSMaxY (outer) - 1,
+                                           1, 1)];
+    }
 }