Skip to content

Commit ebf3f6c

Browse files
committed
Mac: make MMTabBarView/PSMTabBarControl optional
When `MMTabBarView` and `PSMTabBarControl` are not available, the Racket-implemented tab panel (otherwise selected by the `'flat-portable` style or the `PLT_FLAT_PORTABLE_TAB_PANEL` environment variable) can be used. Closes racket/racket#5385
1 parent ecac746 commit ebf3f6c

File tree

6 files changed

+34
-17
lines changed

6 files changed

+34
-17
lines changed

gui-lib/mred/private/mrpanel.rkt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"mrwindow.rkt"
1212
"mrcontainer.rkt"
1313
"wxtabcanvas.rkt"
14-
"gdi.rkt")
14+
"gdi.rkt"
15+
(only-in "wx/platform.rkt" tab-panel-available?))
1516

1617
(provide pane%
1718
vertical-pane%
@@ -320,7 +321,8 @@
320321
[get-orientation (λ () (send (mred->wx this) get-orientation))])))
321322

322323
(define list-append append)
323-
(define always-use-tab-canvas? (and (getenv "PLT_FLAT_PORTABLE_TAB_PANEL") #t))
324+
(define always-use-tab-canvas? (or (and (getenv "PLT_FLAT_PORTABLE_TAB_PANEL") #t)
325+
(not (tab-panel-available?))))
324326

325327
(define tab-panel%
326328
(class vertical-panel%

gui-lib/mred/private/wx/cocoa/platform.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,5 @@
9696
key-symbol-to-menu-key
9797
needs-grow-box-spacer?
9898
graphical-system-type
99-
white-on-black-panel-scheme?))
99+
white-on-black-panel-scheme?
100+
tab-panel-available?))

gui-lib/mred/private/wx/cocoa/tab-panel.rkt

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
(for-syntax racket/base))
1616

1717
(provide
18-
(protect-out tab-panel%))
18+
(protect-out tab-panel%
19+
tab-panel-available?))
1920

2021
(define-runtime-path psm-tab-bar-dir
2122
'(so "PSMTabBarControl.framework"))
@@ -29,23 +30,29 @@
2930
(directory-exists? mm-tab-bar-dir)))
3031

3132
;; Load MMTabBarView or PSMTabBarControl:
32-
(if use-mm?
33-
(void (ffi-lib (build-path mm-tab-bar-dir "MMTabBarView")))
34-
(void (ffi-lib (build-path psm-tab-bar-dir "PSMTabBarControl"))))
33+
(define tab-ok?
34+
(if use-mm?
35+
(and (ffi-lib (build-path mm-tab-bar-dir "MMTabBarView") #:fail (lambda () #f))
36+
'mm)
37+
(and (ffi-lib (build-path psm-tab-bar-dir "PSMTabBarControl") #:fail (lambda () #f))
38+
'psm)))
39+
(define (tab-panel-available?) tab-ok?)
40+
3541
(define NSNoTabsNoBorder 6)
3642

3743
(define NSDefaultControlTint 0)
3844
(define NSClearControlTint 7)
3945

4046
(import-class NSView NSTabView NSTabViewItem)
4147
(define TabBarControl
42-
(if use-mm?
43-
(let ()
44-
(import-class MMTabBarView)
45-
MMTabBarView)
46-
(let ()
47-
(import-class PSMTabBarControl)
48-
PSMTabBarControl)))
48+
(cond
49+
[(not tab-ok?) #f]
50+
[use-mm?
51+
(import-class MMTabBarView)
52+
MMTabBarView]
53+
[else
54+
(import-class PSMTabBarControl)
55+
PSMTabBarControl]))
4956
(import-protocol NSTabViewDelegate)
5057

5158
(define NSOrderedAscending -1)

gui-lib/mred/private/wx/gtk/procs.rkt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
get-color-from-user
6666
key-symbol-to-menu-key
6767
needs-grow-box-spacer?
68-
graphical-system-type)
68+
graphical-system-type
69+
tab-panel-available?)
6970

7071
(define (find-graphical-system-path what)
7172
(case what
@@ -200,3 +201,5 @@
200201
;; in that case we want to return #f.
201202
(< (luminance (get-label-background-color))
202203
(luminance (get-label-foreground-color))))
204+
205+
(define (tab-panel-available?) #t)

gui-lib/mred/private/wx/platform.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,6 @@
8686
key-symbol-to-menu-key
8787
needs-grow-box-spacer?
8888
graphical-system-type
89-
white-on-black-panel-scheme?)
89+
white-on-black-panel-scheme?
90+
tab-panel-available?)
9091
((dynamic-require platform-lib 'platform-values)))

gui-lib/mred/private/wx/win32/platform.rkt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,14 @@
9999
key-symbol-to-menu-key
100100
needs-grow-box-spacer?
101101
graphical-system-type
102-
white-on-black-panel-scheme?))
102+
white-on-black-panel-scheme?
103+
tab-panel-available?))
103104

104105
(define (white-on-black-panel-scheme?)
105106
;; if the background and foreground are the same
106107
;; color, probably something has gone wrong;
107108
;; in that case we want to return #f.
108109
(< (luminance (get-label-background-color))
109110
(luminance (get-label-foreground-color))))
111+
112+
(define (tab-panel-available?) #t)

0 commit comments

Comments
 (0)