|
@@ -67,38 +67,36 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
|
|
|
bool has_other_items_proxy = false;
|
|
|
|
|
|
- if (@available(macOS 10.12.2, *)) {
|
|
|
- for (const auto& item : dicts) {
|
|
|
- std::string type;
|
|
|
- std::string item_id;
|
|
|
- if (item.Get("type", &type) && item.Get("id", &item_id)) {
|
|
|
- NSTouchBarItemIdentifier identifier = nil;
|
|
|
- if (type == "spacer") {
|
|
|
- std::string size;
|
|
|
- item.Get("size", &size);
|
|
|
- if (size == "large") {
|
|
|
- identifier = NSTouchBarItemIdentifierFixedSpaceLarge;
|
|
|
- } else if (size == "flexible") {
|
|
|
- identifier = NSTouchBarItemIdentifierFlexibleSpace;
|
|
|
- } else {
|
|
|
- identifier = NSTouchBarItemIdentifierFixedSpaceSmall;
|
|
|
- }
|
|
|
- } else if (type == "other_items_proxy") {
|
|
|
- identifier = NSTouchBarItemIdentifierOtherItemsProxy;
|
|
|
- has_other_items_proxy = true;
|
|
|
+ for (const auto& item : dicts) {
|
|
|
+ std::string type;
|
|
|
+ std::string item_id;
|
|
|
+ if (item.Get("type", &type) && item.Get("id", &item_id)) {
|
|
|
+ NSTouchBarItemIdentifier identifier = nil;
|
|
|
+ if (type == "spacer") {
|
|
|
+ std::string size;
|
|
|
+ item.Get("size", &size);
|
|
|
+ if (size == "large") {
|
|
|
+ identifier = NSTouchBarItemIdentifierFixedSpaceLarge;
|
|
|
+ } else if (size == "flexible") {
|
|
|
+ identifier = NSTouchBarItemIdentifierFlexibleSpace;
|
|
|
} else {
|
|
|
- identifier = [self identifierFromID:item_id type:type];
|
|
|
+ identifier = NSTouchBarItemIdentifierFixedSpaceSmall;
|
|
|
}
|
|
|
+ } else if (type == "other_items_proxy") {
|
|
|
+ identifier = NSTouchBarItemIdentifierOtherItemsProxy;
|
|
|
+ has_other_items_proxy = true;
|
|
|
+ } else {
|
|
|
+ identifier = [self identifierFromID:item_id type:type];
|
|
|
+ }
|
|
|
|
|
|
- if (identifier) {
|
|
|
- settings_[item_id] = item;
|
|
|
- [identifiers addObject:identifier];
|
|
|
- }
|
|
|
+ if (identifier) {
|
|
|
+ settings_[item_id] = item;
|
|
|
+ [identifiers addObject:identifier];
|
|
|
}
|
|
|
}
|
|
|
- if (!has_other_items_proxy)
|
|
|
- [identifiers addObject:NSTouchBarItemIdentifierOtherItemsProxy];
|
|
|
}
|
|
|
+ if (!has_other_items_proxy)
|
|
|
+ [identifiers addObject:NSTouchBarItemIdentifierOtherItemsProxy];
|
|
|
|
|
|
return identifiers;
|
|
|
}
|
|
@@ -140,8 +138,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
- (void)refreshTouchBarItem:(NSTouchBar*)touchBar
|
|
|
id:(NSTouchBarItemIdentifier)identifier
|
|
|
withType:(const std::string&)item_type
|
|
|
- withSettings:(const gin_helper::PersistentDictionary&)settings
|
|
|
- API_AVAILABLE(macosx(10.12.2)) {
|
|
|
+ withSettings:(const gin_helper::PersistentDictionary&)settings {
|
|
|
NSTouchBarItem* item = [touchBar itemForIdentifier:identifier];
|
|
|
if (!item)
|
|
|
return;
|
|
@@ -289,8 +286,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
}
|
|
|
|
|
|
- (void)scrubber:(NSScrubber*)scrubber
|
|
|
- didSelectItemAtIndex:(NSInteger)selectedIndex
|
|
|
- API_AVAILABLE(macosx(10.12.2)) {
|
|
|
+ didSelectItemAtIndex:(NSInteger)selectedIndex {
|
|
|
base::DictionaryValue details;
|
|
|
details.SetInteger("selectedIndex", selectedIndex);
|
|
|
details.SetString("type", "select");
|
|
@@ -299,8 +295,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
}
|
|
|
|
|
|
- (void)scrubber:(NSScrubber*)scrubber
|
|
|
- didHighlightItemAtIndex:(NSInteger)highlightedIndex
|
|
|
- API_AVAILABLE(macosx(10.12.2)) {
|
|
|
+ didHighlightItemAtIndex:(NSInteger)highlightedIndex {
|
|
|
base::DictionaryValue details;
|
|
|
details.SetInteger("highlightedIndex", highlightedIndex);
|
|
|
details.SetString("type", "highlight");
|
|
@@ -592,8 +587,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
}
|
|
|
|
|
|
- (void)updateGroup:(NSGroupTouchBarItem*)item
|
|
|
- withSettings:(const gin_helper::PersistentDictionary&)settings
|
|
|
- API_AVAILABLE(macosx(10.12.2)) {
|
|
|
+ withSettings:(const gin_helper::PersistentDictionary&)settings {
|
|
|
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
|
|
|
v8::HandleScope handle_scope(isolate);
|
|
|
|
|
@@ -609,8 +603,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
}
|
|
|
|
|
|
- (NSTouchBarItem*)makeSegmentedControlForID:(NSString*)id
|
|
|
- withIdentifier:(NSString*)identifier
|
|
|
- API_AVAILABLE(macosx(10.12.2)) {
|
|
|
+ withIdentifier:(NSString*)identifier {
|
|
|
std::string s_id([id UTF8String]);
|
|
|
if (![self hasItemWithID:s_id])
|
|
|
return nil;
|
|
@@ -635,8 +628,8 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
}
|
|
|
|
|
|
- (void)updateSegmentedControl:(NSCustomTouchBarItem*)item
|
|
|
- withSettings:(const gin_helper::PersistentDictionary&)settings
|
|
|
- API_AVAILABLE(macosx(10.12.2)) {
|
|
|
+ withSettings:
|
|
|
+ (const gin_helper::PersistentDictionary&)settings {
|
|
|
NSSegmentedControl* control = item.view;
|
|
|
|
|
|
std::string segmentStyle;
|
|
@@ -697,8 +690,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
}
|
|
|
|
|
|
- (NSTouchBarItem*)makeScrubberForID:(NSString*)id
|
|
|
- withIdentifier:(NSString*)identifier
|
|
|
- API_AVAILABLE(macosx(10.12.2)) {
|
|
|
+ withIdentifier:(NSString*)identifier {
|
|
|
std::string s_id([id UTF8String]);
|
|
|
if (![self hasItemWithID:s_id])
|
|
|
return nil;
|
|
@@ -729,8 +721,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
}
|
|
|
|
|
|
- (void)updateScrubber:(NSCustomTouchBarItem*)item
|
|
|
- withSettings:(const gin_helper::PersistentDictionary&)settings
|
|
|
- API_AVAILABLE(macosx(10.12.2)) {
|
|
|
+ withSettings:(const gin_helper::PersistentDictionary&)settings {
|
|
|
NSScrubber* scrubber = item.view;
|
|
|
|
|
|
bool showsArrowButtons = false;
|
|
@@ -780,8 +771,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
[scrubber reloadData];
|
|
|
}
|
|
|
|
|
|
-- (NSInteger)numberOfItemsForScrubber:(NSScrubber*)scrubber
|
|
|
- API_AVAILABLE(macosx(10.12.2)) {
|
|
|
+- (NSInteger)numberOfItemsForScrubber:(NSScrubber*)scrubber {
|
|
|
std::string s_id([[scrubber identifier] UTF8String]);
|
|
|
if (![self hasItemWithID:s_id])
|
|
|
return 0;
|
|
@@ -796,8 +786,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
}
|
|
|
|
|
|
- (NSScrubberItemView*)scrubber:(NSScrubber*)scrubber
|
|
|
- viewForItemAtIndex:(NSInteger)index
|
|
|
- API_AVAILABLE(macosx(10.12.2)) {
|
|
|
+ viewForItemAtIndex:(NSInteger)index {
|
|
|
std::string s_id([[scrubber identifier] UTF8String]);
|
|
|
if (![self hasItemWithID:s_id])
|
|
|
return nil;
|
|
@@ -839,7 +828,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
|
|
|
|
|
- (NSSize)scrubber:(NSScrubber*)scrubber
|
|
|
layout:(NSScrubberFlowLayout*)layout
|
|
|
- sizeForItemAtIndex:(NSInteger)itemIndex API_AVAILABLE(macosx(10.12.2)) {
|
|
|
+ sizeForItemAtIndex:(NSInteger)itemIndex {
|
|
|
NSInteger width = 50;
|
|
|
NSInteger height = 30;
|
|
|
NSInteger margin = 15;
|