racket/gui

slider% with [style '(vertical)] fails to render on macOS 13.5.2

Closed this issue · 4 comments

slider% with [style '(vertical)] fails to render

  • macOS 13.5.2 (M1)
  • 8.11.0.3--2023-10-18(-/f) [cs].
image
#lang at-exp racket/gui

(define frame (new frame% [label "Example"]
                   [min-width 350]
                   [min-height 350]))

(new slider%
     [label ":("]
     [min-value 0]
     [max-value 100]
     [min-height 110]
     [min-width 110]
     [parent frame]
     [style '(vertical)])

(send frame show #t)

Correct behaviour on windows
racket-example

It may or may not be related to the following change in AppKit.

AppKit Release Notes (macOS 10.12 and Earlier)

NSSlider isVertical
NSSlider and NSSliderCell's `vertical` property is now readwrite and has changed its type from NSInteger to BOOL. In previous releases, NSSliderCell would try to automatically determine its orientation based on the aspect ratio of a received cell frame. This also led to -1 being returned from `isVertical` if it could not make a determination (e.g. the cell frame had a zero size), and could lead to the slider changing orientation when it was resized.

With 10.12, the vertical property is set at initialization time based on the aspect ratio of the frame parameter, and defaults to horizontal in ambiguous (equal width/height) cases; however it is recommended to explicitly set the vertical property or use the convenience constructors. To dynamically change the orientation of the slider, explicitly set the `vertical` property.

https://developer.apple.com/library/archive/releasenotes/AppKit/RN-AppKitOlderNotes/index.html

works on Linux
Screenshot_2023_10_25_120440

mflatt commented

Thanks for the pointer @soegaard!

The merged repair makes the slider draw, but it doesn't really draw correctly, because for ranges > 63, the slider renders in a way that makes sense for sliding up to higher values (higlighting the region below the slider control instead of above). In that sense, the repair is complete. Maybe the right thing is to support a slider that goes bottom to top, though, and discourage the use of 'vertical. I'll try that as a separate PR.

Edit: added "for ranges > 63," above.