]> gitweb.factorcode.org Git - factor.git/blob - basis/cocoa/touchbar/touchbar.factor
factor: trim using lists
[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 ;
5 IN: cocoa.touchbar
6
7 : make-touchbar ( seq self -- touchbar )
8     [ NSTouchBar -> alloc -> init dup ] dip -> setDelegate: {
9         [ swap <CFStringArray> { void { id SEL id } } ?-> setDefaultItemIdentifiers: ]
10         [ swap <CFStringArray> { void { id SEL id } } ?-> setCustomizationAllowedItemIdentifiers: ]
11         [ nip ]
12     } 2cleave ;
13
14 :: make-NSTouchBar-button ( self identifier label-string action-string -- button )
15     NSCustomTouchBarItem -> alloc
16         identifier <CFString> { id { id SEL id } } ?-> initWithIdentifier: :> item
17         NSButton
18             label-string <CFString>
19             self
20             action-string lookup-selector { id { id SEL id id SEL } } ?-> buttonWithTitle:target:action: :> button
21         item button -> setView:
22         item ;