Add NSScrubber forward declarations

This commit is contained in:
Kevin Sawicki 2017-03-13 10:07:48 -07:00
parent cfb3798703
commit 634bd7b17f
3 changed files with 57 additions and 7 deletions

View 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> {

View 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];

View file

@ -14,13 +14,19 @@
#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