2017-02-28 12:29:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Copyright (c) 2017 GitHub, Inc.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Use of this source code is governed by the MIT license that can be
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// found in the LICENSE file.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-04 12:19:40 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#ifndef SHELL_BROWSER_UI_COCOA_ELECTRON_TOUCH_BAR_H_
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define SHELL_BROWSER_UI_COCOA_ELECTRON_TOUCH_BAR_H_
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 12:29:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#import <Cocoa/Cocoa.h>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <map>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <string>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <vector>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 16:44:03 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "base/mac/scoped_nsobject.h"
							 | 
						
					
						
							
								
									
										
										
										
											2019-06-19 13:46:59 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "shell/browser/native_window.h"
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-31 16:56:00 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "shell/common/gin_helper/persistent_dictionary.h"
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 12:29:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-04 12:19:40 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@interface ElectronTouchBar : NSObject <NSScrubberDelegate,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                        NSScrubberDataSource,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                        NSScrubberFlowLayoutDelegate> {
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 12:29:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 @protected
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-31 16:56:00 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  std::vector<gin_helper::PersistentDictionary> ordered_settings_;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  std::map<std::string, gin_helper::PersistentDictionary> settings_;
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 12:29:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  id<NSTouchBarDelegate> delegate_;
							 | 
						
					
						
							
								
									
										
										
										
											2019-06-19 14:23:04 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  electron::NativeWindow* window_;
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 12:29:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (id)initWithDelegate:(id<NSTouchBarDelegate>)delegate
							 | 
						
					
						
							
								
									
										
										
										
											2019-06-19 14:23:04 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                window:(electron::NativeWindow*)window
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-31 16:56:00 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								              settings:(std::vector<gin_helper::PersistentDictionary>)settings;
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 12:29:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 16:45:26 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (NSTouchBar*)makeTouchBar API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (NSTouchBar*)touchBarFromItemIdentifiers:(NSMutableArray*)items
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (NSMutableArray*)identifiersFromSettings:
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-31 16:56:00 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    (const std::vector<gin_helper::PersistentDictionary>&)settings;
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                         id:(const std::string&)item_id
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (void)addNonDefaultTouchBarItems:
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-31 16:56:00 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    (const std::vector<gin_helper::PersistentDictionary>&)items;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								- (void)setEscapeTouchBarItem:(gin_helper::PersistentDictionary)item
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                  forTouchBar:(NSTouchBar*)touchBar
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2017-03-02 10:23:24 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (NSString*)idFromIdentifier:(NSString*)identifier
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                   withPrefix:(NSString*)prefix;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								- (NSTouchBarItemIdentifier)identifierFromID:(const std::string&)item_id
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                        type:(const std::string&)typere;
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 17:12:35 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (bool)hasItemWithID:(const std::string&)item_id;
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 12:29:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								- (NSColor*)colorFromHexColorString:(const std::string&)colorString;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Selector actions
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								- (void)buttonAction:(id)sender;
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 16:45:26 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (void)colorPickerAction:(id)sender API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								- (void)sliderAction:(id)sender API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 12:29:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Helpers to create touch bar items
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 16:45:26 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (NSTouchBarItem*)makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (NSTouchBarItem*)makeButtonForID:(NSString*)id
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    withIdentifier:(NSString*)identifier
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (NSTouchBarItem*)makeLabelForID:(NSString*)id
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                   withIdentifier:(NSString*)identifier
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (NSTouchBarItem*)makeColorPickerForID:(NSString*)id
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                         withIdentifier:(NSString*)identifier
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (NSTouchBarItem*)makeSliderForID:(NSString*)id
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    withIdentifier:(NSString*)identifier
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (NSTouchBarItem*)makePopoverForID:(NSString*)id
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                     withIdentifier:(NSString*)identifier
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (NSTouchBarItem*)makeGroupForID:(NSString*)id
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                   withIdentifier:(NSString*)identifier
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 12:29:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Helpers to update touch bar items
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (void)updateButton:(NSCustomTouchBarItem*)item
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-31 16:56:00 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        withSettings:(const gin_helper::PersistentDictionary&)settings
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (void)updateLabel:(NSCustomTouchBarItem*)item
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-31 16:56:00 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								       withSettings:(const gin_helper::PersistentDictionary&)settings
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (void)updateColorPicker:(NSColorPickerTouchBarItem*)item
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-31 16:56:00 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             withSettings:(const gin_helper::PersistentDictionary&)settings
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (void)updateSlider:(NSSliderTouchBarItem*)item
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-31 16:56:00 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        withSettings:(const gin_helper::PersistentDictionary&)settings
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-17 21:44:10 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								- (void)updatePopover:(NSPopoverTouchBarItem*)item
							 | 
						
					
						
							
								
									
										
										
										
											2019-10-31 16:56:00 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         withSettings:(const gin_helper::PersistentDictionary&)settings
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-18 15:39:45 +05:30
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    API_AVAILABLE(macosx(10.12.2));
							 | 
						
					
						
							
								
									
										
										
										
											2017-02-28 12:29:23 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								@end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2020-02-04 12:19:40 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#endif  // SHELL_BROWSER_UI_COCOA_ELECTRON_TOUCH_BAR_H_
							 |