From 2ba8927ba5022989ffade7ca2f6556465da6411a Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 10 Mar 2011 18:37:43 -0600 Subject: [PATCH] cocoa: flip vertical slider direction --- collects/mred/private/wx/cocoa/slider.rkt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/collects/mred/private/wx/cocoa/slider.rkt b/collects/mred/private/wx/cocoa/slider.rkt index e735287d69..993d7b98bd 100644 --- a/collects/mred/private/wx/cocoa/slider.rkt +++ b/collects/mred/private/wx/cocoa/slider.rkt @@ -46,12 +46,15 @@ (define vert? (memq 'vertical style)) + (define slider-lo lo) + (define slider-hi hi) + (define slider-cocoa (let ([cocoa (as-objc-allocation (tell (tell MySlider alloc) init))]) (tellv cocoa setMinValue: #:type _double* lo) (tellv cocoa setMaxValue: #:type _double* hi) - (tellv cocoa setDoubleValue: #:type _double* val) + (tellv cocoa setDoubleValue: #:type _double* (flip val)) ;; heuristic: show up to tick marks: (when ((- hi lo) . < . 64) (tellv cocoa setNumberOfTickMarks: #:type _NSUInteger (add1 (- hi lo))) @@ -148,13 +151,17 @@ [event-type 'slider] [time-stamp (current-milliseconds)]))) + (define/private (flip v) + (if vert? + (+ slider-lo (- slider-hi v)) + v)) (define/public (set-value v) (atomically - (tellv slider-cocoa setDoubleValue: #:type _double* v) + (tellv slider-cocoa setDoubleValue: #:type _double* (flip v)) (update-message v))) (define/public (get-value) - (inexact->exact (floor (tell #:type _double slider-cocoa doubleValue)))) + (flip (inexact->exact (floor (tell #:type _double slider-cocoa doubleValue))))) (define/public (update-message [val (get-value)]) (tellv message-cocoa setTitleWithMnemonic: #:type _NSString (format "~a" val)))