} else if (item_type == "scrubber") {
[self updateScrubber:(NSCustomTouchBarItem*)item withSettings:settings];
}
-
+
}
- (void)buttonAction:(id)sender {
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;
settings.Get("items", &items);
scrubber.dataSource = [[AtomScrubberDataSource alloc] initWithItems:items];
scrubber.mode = NSScrubberModeFree;
-
+
[item setView:scrubber];
[self updateScrubber:item withSettings:settings];
#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;
@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;
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