touch_bar_forward_declarations.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_UI_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_
  5. #define ATOM_BROWSER_UI_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_
  6. // Once Chrome no longer supports OSX 10.12.0, this file can be deleted.
  7. #import <Foundation/Foundation.h>
  8. #if !defined(MAC_OS_X_VERSION_10_12_1)
  9. #pragma clang assume_nonnull begin
  10. @class NSTouchBar, NSTouchBarItem;
  11. @class NSScrubber, NSScrubberItemView, NSScrubberArrangedView,
  12. NSScrubberTextItemView, NSScrubberImageItemView, NSScrubberSelectionStyle;
  13. @protocol NSTouchBarDelegate
  14. , NSScrubberDelegate, NSScrubberDataSource, NSScrubberFlowLayoutDelegate,
  15. NSScrubberFlowLayout;
  16. typedef float NSTouchBarItemPriority;
  17. static const NSTouchBarItemPriority NSTouchBarItemPriorityHigh = 1000;
  18. static const NSTouchBarItemPriority NSTouchBarItemPriorityNormal = 0;
  19. static const NSTouchBarItemPriority NSTouchBarItemPriorityLow = -1000;
  20. enum NSScrubberMode { NSScrubberModeFixed = 0, NSScrubberModeFree };
  21. typedef NSString* NSTouchBarItemIdentifier;
  22. typedef NSString* NSTouchBarCustomizationIdentifier;
  23. static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierFixedSpaceSmall =
  24. @"NSTouchBarItemIdentifierFixedSpaceSmall";
  25. static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierFixedSpaceLarge =
  26. @"NSTouchBarItemIdentifierFixedSpaceLarge";
  27. static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierFlexibleSpace =
  28. @"NSTouchBarItemIdentifierFlexibleSpace";
  29. static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy =
  30. @"NSTouchBarItemIdentifierOtherItemsProxy";
  31. @interface NSTouchBar : NSObject <NSCoding>
  32. - (instancetype)init NS_DESIGNATED_INITIALIZER;
  33. - (nullable instancetype)initWithCoder:(NSCoder*)aDecoder
  34. NS_DESIGNATED_INITIALIZER;
  35. @property(copy, nullable)
  36. NSTouchBarCustomizationIdentifier customizationIdentifier;
  37. @property(copy) NSArray* customizationAllowedItemIdentifiers;
  38. @property(copy) NSArray* customizationRequiredItemIdentifiers;
  39. @property(copy) NSArray* defaultItemIdentifiers;
  40. @property(copy, readonly) NSArray* itemIdentifiers;
  41. @property(copy, nullable) NSTouchBarItemIdentifier principalItemIdentifier;
  42. @property(copy, nullable)
  43. NSTouchBarItemIdentifier escapeKeyReplacementItemIdentifier;
  44. @property(copy) NSSet* templateItems;
  45. @property(nullable, weak) id<NSTouchBarDelegate> delegate;
  46. - (nullable __kindof NSTouchBarItem*)itemForIdentifier:
  47. (NSTouchBarItemIdentifier)identifier;
  48. @property(readonly, getter=isVisible) BOOL visible;
  49. @end
  50. @interface NSTouchBarItem : NSObject <NSCoding>
  51. - (instancetype)initWithIdentifier:(NSTouchBarItemIdentifier)identifier
  52. NS_DESIGNATED_INITIALIZER;
  53. - (nullable instancetype)initWithCoder:(NSCoder*)coder
  54. NS_DESIGNATED_INITIALIZER;
  55. - (instancetype)init NS_UNAVAILABLE;
  56. @property(readonly, copy) NSTouchBarItemIdentifier identifier;
  57. @property NSTouchBarItemPriority visibilityPriority;
  58. @property(readonly, nullable) NSView* view;
  59. @property(readonly, nullable) NSViewController* viewController;
  60. @property(readwrite, copy) NSString* customizationLabel;
  61. @property(readonly, getter=isVisible) BOOL visible;
  62. @end
  63. @interface NSGroupTouchBarItem : NSTouchBarItem
  64. + (NSGroupTouchBarItem*)groupItemWithIdentifier:
  65. (NSTouchBarItemIdentifier)identifier
  66. items:(NSArray*)items;
  67. @property(strong) NSTouchBar* groupTouchBar;
  68. @property(readwrite, copy, null_resettable) NSString* customizationLabel;
  69. @end
  70. @interface NSCustomTouchBarItem : NSTouchBarItem
  71. @property(readwrite, strong) __kindof NSView* view;
  72. @property(readwrite, strong, nullable)
  73. __kindof NSViewController* viewController;
  74. @property(readwrite, copy, null_resettable) NSString* customizationLabel;
  75. @end
  76. @interface NSColorPickerTouchBarItem : NSTouchBarItem
  77. @property SEL action;
  78. @property(weak) id target;
  79. @property(copy) NSColor* color;
  80. @property(strong) NSColorList* colorList;
  81. @end
  82. @interface NSPopoverTouchBarItem : NSTouchBarItem
  83. @property BOOL showsCloseButton;
  84. @property(strong) NSImage* collapsedRepresentationImage;
  85. @property(strong) NSString* collapsedRepresentationLabel;
  86. @property(strong) NSTouchBar* popoverTouchBar;
  87. @end
  88. @interface NSSliderTouchBarItem : NSTouchBarItem
  89. @property SEL action;
  90. @property(weak) id target;
  91. @property(copy) NSString* label;
  92. @property(strong) NSSlider* slider;
  93. @end
  94. @interface NSScrubber : NSView
  95. @property(weak) id<NSScrubberDelegate> delegate;
  96. @property(weak) id<NSScrubberDataSource> dataSource;
  97. @property NSScrubberMode mode;
  98. @property BOOL showsArrowButtons;
  99. @property(getter=isContinuous) BOOL continuous;
  100. @property(strong, nullable) NSScrubberSelectionStyle* selectionBackgroundStyle;
  101. @property(strong, nullable) NSScrubberSelectionStyle* selectionOverlayStyle;
  102. - (void)registerClass:(Class)itemViewClass
  103. forItemIdentifier:(NSString*)itemIdentifier;
  104. - (__kindof NSScrubberItemView*)makeItemWithIdentifier:(NSString*)itemIdentifier
  105. owner:(id)owner;
  106. - (void)reloadData;
  107. @end
  108. @interface NSScrubberFlowLayout : NSObject
  109. @end
  110. @interface NSScrubberSelectionStyle : NSObject <NSCoding>
  111. @property(class, strong, readonly)
  112. NSScrubberSelectionStyle* outlineOverlayStyle;
  113. @property(class, strong, readonly)
  114. NSScrubberSelectionStyle* roundedBackgroundStyle;
  115. @end
  116. @interface NSScrubberArrangedView : NSView
  117. @end
  118. @interface NSScrubberItemView : NSScrubberArrangedView
  119. @end
  120. @interface NSScrubberTextItemView : NSScrubberItemView
  121. @property(copy) NSString* title;
  122. @end
  123. @interface NSScrubberImageItemView : NSScrubberItemView
  124. @property(copy) NSImage* image;
  125. @end
  126. @interface NSWindow (TouchBarSDK)
  127. @property(strong, readwrite, nullable) NSTouchBar* touchBar;
  128. @end
  129. @interface NSButton (TouchBarSDK)
  130. @property(copy) NSColor* bezelColor;
  131. + (instancetype)buttonWithTitle:(NSString*)title
  132. target:(id)target
  133. action:(SEL)action;
  134. @end
  135. @interface NSTextField (TouchBarSDK)
  136. + (instancetype)labelWithString:(NSString*)stringValue;
  137. @end
  138. @interface NSSegmentedControl (TouchBarSDK)
  139. + (instancetype)segmentedControlWithLabels:(NSArray*)labels
  140. trackingMode:(NSSegmentSwitchTracking)trackingMode
  141. target:(id)target
  142. action:(SEL)action;
  143. @end
  144. @protocol NSTouchBarDelegate <NSObject>
  145. @optional
  146. - (nullable NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
  147. makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier;
  148. @end
  149. @protocol NSScrubberDelegate <NSObject>
  150. - (void)scrubber:(NSScrubber*)scrubber
  151. didHighlightItemAtIndex:(NSInteger)highlightedIndex;
  152. - (void)scrubber:(NSScrubber*)scrubber
  153. didSelectItemAtIndex:(NSInteger)selectedIndex;
  154. @end
  155. @protocol NSScrubberDataSource <NSObject>
  156. - (NSInteger)numberOfItemsForScrubber:(NSScrubber*)scrubber;
  157. - (__kindof NSScrubberItemView*)scrubber:(NSScrubber*)scrubber
  158. viewForItemAtIndex:(NSInteger)index;
  159. @end
  160. @protocol NSScrubberFlowLayoutDelegate <NSObject>
  161. - (NSSize)scrubber:(NSScrubber*)scrubber
  162. layout:(NSScrubberFlowLayout*)layout
  163. sizeForItemAtIndex:(NSInteger)itemIndex;
  164. @end
  165. #pragma clang assume_nonnull end
  166. #elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1
  167. // When compiling against the 10.12.1 SDK or later, just provide forward
  168. // declarations to suppress the partial availability warnings.
  169. @class NSCustomTouchBarItem;
  170. @class NSGroupTouchBarItem;
  171. @class NSTouchBar;
  172. @protocol NSTouchBarDelegate;
  173. @class NSTouchBarItem;
  174. @interface NSWindow (TouchBarSDK)
  175. @property(strong, readonly) NSTouchBar* touchBar API_AVAILABLE(macosx(10.12.2));
  176. @end
  177. #endif // MAC_OS_X_VERSION_10_12_1
  178. #endif // ATOM_BROWSER_UI_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_