| 
									
										
										
										
											2017-05-30 13:09:02 -04:00
										 |  |  | ! Copyright (C) 2017 Doug Coleman. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2017-06-01 12:55:08 -04:00
										 |  |  | USING: accessors alien.c-types alien.enums alien.syntax cocoa | 
					
						
							|  |  |  | cocoa.classes cocoa.messages cocoa.runtime combinators | 
					
						
							|  |  |  | core-foundation.strings kernel locals namespaces sequences words ;
 | 
					
						
							| 
									
										
										
										
											2017-05-30 13:09:02 -04:00
										 |  |  | IN: cocoa.touchbar | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! ui.backend.cocoa.views creates buttons for each of these actions | 
					
						
							|  |  |  | ENUM: default-touchbar refresh-all-action auto-use-action ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : enum>CFStringArray ( seq -- alien )
 | 
					
						
							|  |  |  |     enum>keys | 
					
						
							|  |  |  |     NSArray -> alloc | 
					
						
							|  |  |  |         swap <CFStringArray> -> initWithArray: ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : make-touchbar ( enum self -- touchbar )
 | 
					
						
							|  |  |  |     [ NSTouchBar -> alloc -> init dup ] dip -> setDelegate: { | 
					
						
							| 
									
										
										
										
											2017-06-01 12:55:08 -04:00
										 |  |  |         [ swap enum>CFStringArray { void { id SEL id } } ?-> setDefaultItemIdentifiers: ] | 
					
						
							|  |  |  |         [ swap enum>CFStringArray { void { id SEL id } } ?-> setCustomizationAllowedItemIdentifiers: ] | 
					
						
							| 
									
										
										
										
											2017-05-30 13:09:02 -04:00
										 |  |  |         [ nip ] | 
					
						
							|  |  |  |     } 2cleave ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | :: make-NSTouchBar-button ( self identifier label-string action-string -- button )
 | 
					
						
							|  |  |  |     NSCustomTouchBarItem -> alloc | 
					
						
							| 
									
										
										
										
											2017-06-01 12:55:08 -04:00
										 |  |  |         identifier <CFString> { id { id SEL id } } ?-> initWithIdentifier: :> item | 
					
						
							| 
									
										
										
										
											2017-05-30 13:09:02 -04:00
										 |  |  |         NSButton | 
					
						
							|  |  |  |             label-string <CFString> | 
					
						
							|  |  |  |             self | 
					
						
							| 
									
										
										
										
											2017-06-01 12:55:08 -04:00
										 |  |  |             action-string lookup-selector { id { id SEL id id SEL } } ?-> buttonWithTitle:target:action: :> button | 
					
						
							| 
									
										
										
										
											2017-05-30 13:09:02 -04:00
										 |  |  |         item button -> setView: | 
					
						
							| 
									
										
										
										
											2017-06-01 14:46:32 -04:00
										 |  |  |         item ;
 |