From 4ca5a98bd98851cfa9b83fb1cb5eeb3a158cdec7 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Mon, 25 Sep 2023 08:53:30 -0500 Subject: [PATCH] adjust cocoa 'border canvas% style to react to dark mode --- gui-lib/mred/private/wx/cocoa/cg.rkt | 1 + gui-lib/mred/private/wx/cocoa/panel.rkt | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gui-lib/mred/private/wx/cocoa/cg.rkt b/gui-lib/mred/private/wx/cocoa/cg.rkt index b57f0ac0f..69c9bd086 100644 --- a/gui-lib/mred/private/wx/cocoa/cg.rkt +++ b/gui-lib/mred/private/wx/cocoa/cg.rkt @@ -24,6 +24,7 @@ (define-appserv CGContextRestoreGState (_fun _CGContextRef -> _void)) (define-appserv CGContextConcatCTM (_fun _CGContextRef _CGAffineTransform -> _void)) (define-appserv CGContextSetRGBFillColor (_fun _CGContextRef _CGFloat _CGFloat _CGFloat _CGFloat -> _void)) +(define-appserv CGContextSetRGBStrokeColor (_fun _CGContextRef _CGFloat _CGFloat _CGFloat _CGFloat -> _void)) (define-appserv CGContextFillRect (_fun _CGContextRef _NSRect -> _void)) (define-appserv CGContextClearRect (_fun _CGContextRef _NSRect -> _void)) (define-appserv CGContextAddRect (_fun _CGContextRef _NSRect -> _void)) diff --git a/gui-lib/mred/private/wx/cocoa/panel.rkt b/gui-lib/mred/private/wx/cocoa/panel.rkt index bdb3043c7..66d0fadc7 100644 --- a/gui-lib/mred/private/wx/cocoa/panel.rkt +++ b/gui-lib/mred/private/wx/cocoa/panel.rkt @@ -6,7 +6,8 @@ "types.rkt" "utils.rkt" "cg.rkt" - "window.rkt") + "window.rkt" + "procs.rkt") (provide (protect-out panel% @@ -24,11 +25,18 @@ [] (-a #:async-apply (box (void)) _void (drawRect: [_NSRect r]) - (let ([ctx (tell NSGraphicsContext currentContext)]) + (let ([wob? (white-on-black-panel-scheme?)] + [ctx (tell NSGraphicsContext currentContext)]) (tellv ctx saveGraphicsState) (let ([cg (tell #:type _CGContextRef ctx graphicsPort)] [r (tell #:type _NSRect self bounds)]) - (CGContextSetRGBFillColor cg 0 0 0 1.0) + (cond + [wob? + (CGContextSetRGBFillColor cg 0 0 0 1.0) + (CGContextSetRGBStrokeColor cg 0.8 0.8 0.8 1.0)] + [else + (CGContextSetRGBFillColor cg 1.0 1.0 1.0 1.0) + (CGContextSetRGBStrokeColor cg 0 0 0 1.0)]) (CGContextAddRect cg r) (CGContextStrokePath cg)) (tellv ctx restoreGraphicsState))))