From 10ec0c5d5d04630bb720ad7e77575c80472ad3fd Mon Sep 17 00:00:00 2001 From: Leif Andersen Date: Mon, 24 Oct 2016 11:39:18 -0400 Subject: [PATCH 1/2] Fixes bug in slider% It would occasionally drop the last digit in the message field. This turned out to be a bug where the number, while smaller, was wider. For example: 11111 10101 In variable width fonts the second one will be wider --- gui-lib/mred/private/wx/cocoa/slider.rkt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui-lib/mred/private/wx/cocoa/slider.rkt b/gui-lib/mred/private/wx/cocoa/slider.rkt index ac07d28bf..9080dfafa 100644 --- a/gui-lib/mred/private/wx/cocoa/slider.rkt +++ b/gui-lib/mred/private/wx/cocoa/slider.rkt @@ -164,7 +164,8 @@ (flip (inexact->exact (floor (tell #:type _double slider-cocoa doubleValue))))) (define/public (update-message [val (get-value)]) - (tellv message-cocoa setStringValue: #:type _NSString (format "~a" val))) + (tellv message-cocoa setStringValue: #:type _NSString (format "~a" val)) + (tellv message-cocoa sizeToFit)) (inherit get-cocoa-window) (define/override (post-mouse-down) From a376ae2c36f81cb31bac1980b4bdad3008c3102f Mon Sep 17 00:00:00 2001 From: Leif Andersen Date: Mon, 24 Oct 2016 15:38:51 -0400 Subject: [PATCH 2/2] Slider should still be a fixed size, so use string of Ws --- gui-lib/mred/private/wx/cocoa/slider.rkt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gui-lib/mred/private/wx/cocoa/slider.rkt b/gui-lib/mred/private/wx/cocoa/slider.rkt index 9080dfafa..aa6f4eec6 100644 --- a/gui-lib/mred/private/wx/cocoa/slider.rkt +++ b/gui-lib/mred/private/wx/cocoa/slider.rkt @@ -77,10 +77,12 @@ (tellv cocoa setEditable: #:type _BOOL #f) (tellv cocoa setBordered: #:type _BOOL #f) (tellv cocoa setDrawsBackground: #:type _BOOL #f) - (tellv cocoa setStringValue: #:type _NSString (format "~a" hi)) + (tellv cocoa setStringValue: #:type _NSString ;; Hope 'W' is wider than all digits + (make-string (string-length (format "~a" hi)) #\W)) (tellv cocoa sizeToFit) (let ([r1 (tell #:type _NSRect cocoa frame)]) - (tellv cocoa setStringValue: #:type _NSString (format "~a" lo)) + (tellv cocoa setStringValue: #:type _NSString + (make-string (string-length (format "~a" lo)) #\W)) (tellv cocoa sizeToFit) (let ([r2 (tell #:type _NSRect cocoa frame)]) (tellv cocoa setStringValue: #:type _NSString (format "~a" val)) @@ -164,8 +166,7 @@ (flip (inexact->exact (floor (tell #:type _double slider-cocoa doubleValue))))) (define/public (update-message [val (get-value)]) - (tellv message-cocoa setStringValue: #:type _NSString (format "~a" val)) - (tellv message-cocoa sizeToFit)) + (tellv message-cocoa setStringValue: #:type _NSString (format "~a" val))) (inherit get-cocoa-window) (define/override (post-mouse-down)