Add NSScrubber forward declarations
authorKevin Sawicki <kevinsawicki@gmail.com>
Mon, 13 Mar 2017 17:07:48 +0000 (10:07 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Mon, 13 Mar 2017 17:07:48 +0000 (10:07 -0700)
atom/browser/ui/cocoa/atom_scrubber_data_source.h
atom/browser/ui/cocoa/atom_touch_bar.mm
atom/browser/ui/cocoa/touch_bar_forward_declarations.h

index 5ffcd50..5850e30 100644 (file)
@@ -10,6 +10,7 @@
 #include <string>
 #include <vector>
 
+#include "atom/browser/ui/cocoa/touch_bar_forward_declarations.h"
 #include "native_mate/persistent_dictionary.h"
 
 @interface AtomScrubberDataSource : NSObject<NSScrubberDataSource> {
index aaf1578..093f3d7 100644 (file)
@@ -146,7 +146,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   } else if (item_type == "scrubber") {
     [self updateScrubber:(NSCustomTouchBarItem*)item withSettings:settings];
   }
-  
+
 }
 
 - (void)buttonAction:(id)sender {
@@ -504,15 +504,15 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   base::scoped_nsobject<NSCustomTouchBarItem> item([[NSClassFromString(
       @"NSCustomTouchBarItem") alloc] initWithIdentifier:identifier]);
 
-  
+
   int width = 320;
   int height = 30;
   settings.Get("frameWidth", &width);
   settings.Get("frameHeight", &height);
-  NSScrubber* scrubber = [[NSScrubber alloc] initWithFrame:NSMakeRect(0, 0, width, height)];
+  NSScrubber* scrubber = [[NSClassFromString(@"NSScrubber") alloc] initWithFrame:NSMakeRect(0, 0, width, height)];
 
-  [scrubber registerClass:[NSScrubberTextItemView class] forItemIdentifier:TextScrubberItemIdentifier];
-  [scrubber registerClass:[NSScrubberImageItemView class] forItemIdentifier:ImageScrubberItemIdentifier];
+  [scrubber registerClass:NSClassFromString(@"NSScrubberTextItemView") forItemIdentifier:TextScrubberItemIdentifier];
+  [scrubber registerClass:NSClassFromString(@"NSScrubberImageItemView") forItemIdentifier:ImageScrubberItemIdentifier];
 
   scrubber.delegate = self;
   scrubber.identifier = id;
@@ -520,7 +520,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
   settings.Get("items", &items);
   scrubber.dataSource = [[AtomScrubberDataSource alloc] initWithItems:items];
   scrubber.mode = NSScrubberModeFree;
-  
+
   [item setView:scrubber];
 
   [self updateScrubber:item withSettings:settings];
index 8c7b85e..898bdee 100644 (file)
 #pragma clang assume_nonnull begin
 
 @class NSTouchBar, NSTouchBarItem;
-@protocol NSTouchBarDelegate;
+@class NSScrubber, NSScrubberItemView, NSScrubberArrangedView, NSScrubberTextItemView, NSScrubberImageItemView;
+@protocol NSTouchBarDelegate, NSScrubberDelegate, NSScrubberDataSource;
 
 typedef float NSTouchBarItemPriority;
 static const NSTouchBarItemPriority NSTouchBarItemPriorityHigh = 1000;
 static const NSTouchBarItemPriority NSTouchBarItemPriorityNormal = 0;
 static const NSTouchBarItemPriority NSTouchBarItemPriorityLow = -1000;
 
+enum NSScrubberMode {
+  NSScrubberModeFixed = 0,
+  NSScrubberModeFree
+};
+
 typedef NSString* NSTouchBarItemIdentifier;
 typedef NSString* NSTouchBarCustomizationIdentifier;
 
@@ -123,6 +129,41 @@ static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy =
 
 @end
 
+@interface NSScrubber : NSView
+
+@property(weak) id<NSScrubberDelegate> delegate;
+@property(weak) id<NSScrubberDataSource> dataSource;
+@property NSScrubberMode mode;
+
+- (void)registerClass:(Class)itemViewClass
+    forItemIdentifier:(NSString*)itemIdentifier;
+
+- (__kindof NSScrubberItemView*)makeItemWithIdentifier:(NSString*)itemIdentifier
+                                                 owner:(id)owner;
+- (void)reloadData;
+
+@end
+
+@interface NSScrubberArrangedView : NSView
+
+@end
+
+@interface NSScrubberItemView : NSScrubberArrangedView
+
+@end
+
+@interface NSScrubberTextItemView : NSScrubberItemView
+
+@property(copy) NSString* title;
+
+@end
+
+@interface NSScrubberImageItemView : NSScrubberItemView
+
+@property(copy) NSImage* image;
+
+@end
+
 @interface NSWindow (TouchBarSDK)
 
 @property(strong, readwrite, nullable) NSTouchBar* touchBar;
@@ -160,6 +201,14 @@ static const NSTouchBarItemIdentifier NSTouchBarItemIdentifierOtherItemsProxy =
                makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier;
 @end
 
+@protocol NSScrubberDelegate<NSObject>
+
+@end
+
+@protocol NSScrubberDataSource<NSObject>
+
+@end
+
 #pragma clang assume_nonnull end
 
 #elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1