]> gitweb.factorcode.org Git - factor.git/blob - basis/cocoa/touchbar/touchbar.factor
cocoa.touchbar: another experiment for the 10.11 build machine.
[factor.git] / basis / cocoa / touchbar / touchbar.factor
1 ! Copyright (C) 2017 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.c-types cocoa cocoa.classes cocoa.messages
4 cocoa.runtime combinators core-foundation.strings kernel locals
5 ;
6 IN: cocoa.touchbar
7
8 : make-touchbar ( seq self -- touchbar )
9     [ NSTouchBar -> alloc -> init dup ] dip -> setDelegate: {
10         [ swap <CFStringArray> { void { id SEL id } } ?-> setDefaultItemIdentifiers: ]
11         [ swap <CFStringArray> { void { id SEL id } } ?-> setCustomizationAllowedItemIdentifiers: ]
12         [ nip ]
13     } 2cleave ;
14
15 { id { id SEL id id SEL } } cache-stubs
16
17 :: make-NSTouchBar-button ( self identifier label-string action-string -- button )
18     NSCustomTouchBarItem -> alloc
19         identifier <CFString> { id { id SEL id } } ?-> initWithIdentifier: :> item
20         NSButton
21             label-string <CFString>
22             self
23             action-string lookup-selector { id { id SEL id id SEL } } ?-> buttonWithTitle:target:action: :> button
24         item button -> setView:
25         item ;