feat: add recent LUT shortcuts and move canvas controls to the lower corners
这个提交包含在:
1 父节点
16b20af39a
当前提交
beccf2fc01
9 个文件已更改
+83
-25
没有与搜索条件相匹配的文件
+35
-8
@@ -82,6 +82,7 @@ static void DYBrowserGeometrySample(NSView *root,NSString *phase){
|
||||
@property BOOL chosen;
|
||||
@property BOOL doubleClicked;
|
||||
@property BOOL listLayout;
|
||||
@property BOOL shortcut;
|
||||
@end
|
||||
@implementation DYBrowserTile
|
||||
- (BOOL)isFlipped{return YES;}
|
||||
@@ -92,7 +93,7 @@ static void DYBrowserGeometrySample(NSView *root,NSString *phase){
|
||||
- (void)dealloc{[_thumbnail release];[_displayName release];[_failure release];[_palette release];[super dealloc];}
|
||||
- (NSString *)accessibilityLabel{return _displayName?:@"LUT";}
|
||||
- (id)accessibilityValue{return _chosen?@"已选择":_failure.length?@"LUT 无效":_thumbnail?@"可应用":@"正在生成缩略图";}
|
||||
- (NSString *)accessibilityHelp{return _failure?:@"单击应用此 LUT,双击应用并关闭浏览器";}
|
||||
- (NSString *)accessibilityHelp{return _failure?:_shortcut?@"点击将此 LUT 应用到当前风格图层":@"单击应用此 LUT,双击应用并关闭浏览器";}
|
||||
- (void)drawRect:(NSRect)dirty{
|
||||
NSRect bounds=NSInsetRect(self.bounds,1,1);
|
||||
NSBezierPath *outline=[NSBezierPath bezierPathWithRoundedRect:bounds xRadius:7 yRadius:7];
|
||||
@@ -163,7 +164,8 @@ static void DYBrowserGeometrySample(NSView *root,NSString *phase){
|
||||
NSCache *_thumbnailCache;
|
||||
dispatch_queue_t _previewQueue;
|
||||
DYBrowserWork *_work;
|
||||
BOOL _closed,_sizing,_visible,_remoteMode,_importing,_layingOut,_detached,_embedded;
|
||||
BOOL _closed,_sizing,_visible,_remoteMode,_importing,_layingOut,_detached,_embedded,_compactRecent;
|
||||
NSArray *_recentSnapshot;
|
||||
NSProgress *_libraryTask,*_selectionTask;
|
||||
NSTimer *_progressTimer;
|
||||
NSUInteger _libraryGeneration,_selectionGeneration;
|
||||
@@ -233,6 +235,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
return self;
|
||||
}
|
||||
- (void)dealloc{
|
||||
[_recentSnapshot release];
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self];[[NSNotificationCenter defaultCenter]removeObserver:self];
|
||||
[_libraryTask cancel];[_libraryTask release];[_selectionTask cancel];[_selectionTask release];[_progressTimer invalidate];[_progressTimer release];
|
||||
_work.cancelled=YES;_work.owner=nil;[_work release];self.window.delegate=nil;
|
||||
@@ -274,6 +277,23 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
- (void)embedInView:(NSView *)parent close:(void (^)(void))closeAction{
|
||||
_embedded=YES;_folderScroll.hasVerticalScroller=YES;_gridScroll.hasVerticalScroller=YES;_gridScroll.hasHorizontalScroller=NO;_gridScroll.scrollerStyle=NSScrollerStyleOverlay;[self showInRemoteParent:parent close:closeAction];_done.title=@"返回调整";
|
||||
}
|
||||
- (void)embedRecentInView:(NSView *)parent{
|
||||
_compactRecent=YES;_embedded=YES;
|
||||
[_folder release];_folder=[DYBrowserRecentFolder copy];
|
||||
_root.accessibilityLabel=@"最近使用 LUT 快捷入口";
|
||||
_titleLabel.stringValue=@"最近使用";_titleLabel.font=[NSFont systemFontOfSize:11 weight:NSFontWeightSemibold];
|
||||
[_layoutMenu selectItemAtIndex:0];_sizeSlider.doubleValue=120;
|
||||
for(NSView *view in @[_search,_importFiles,_importFolder,_reveal,_refresh,_none,_done,_sizeLabel,_sizeSlider,_layoutMenu,_splitView])view.hidden=YES;
|
||||
[_root addSubview:_gridScroll];_gridScroll.hasHorizontalScroller=NO;_gridScroll.scrollerStyle=NSScrollerStyleOverlay;
|
||||
[self showInRemoteParent:parent close:nil];[self refreshRecentSelection:_selectedPath];
|
||||
}
|
||||
- (void)refreshRecentSelection:(NSString *)path{
|
||||
if(!_compactRecent||_closed)return;
|
||||
if(![_selectedPath isEqualToString:path]){NSString *next=[path copy];[_selectedPath release];_selectedPath=next;}
|
||||
NSArray *paths=_library.recentPaths;
|
||||
if(![_recentSnapshot isEqual:paths]){[_recentSnapshot release];_recentSnapshot=[paths copy];[self rebuildGrid];}
|
||||
for(DYBrowserTile *tile in _tiles.allValues){tile.chosen=[tile.identifier isEqualToString:_selectedPath];[tile setNeedsDisplay:YES];}
|
||||
}
|
||||
- (void)fitRemoteParent{
|
||||
NSView *parent=_root.superview;if(_closed||!_remoteMode||!parent)return;
|
||||
// A scaled-display ViewBridge service can hand us its top-level content
|
||||
@@ -358,6 +378,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
- (void)layoutBrowser{
|
||||
if(_layingOut)return;_layingOut=YES;
|
||||
CGFloat w=_root.bounds.size.width,h=_root.bounds.size.height;
|
||||
if(!_compactRecent){
|
||||
_titleLabel.frame=NSMakeRect(14,12,160,20);_countLabel.frame=NSMakeRect(180,14,120,18);
|
||||
_search.frame=NSMakeRect(14,46,MAX(125,w-350),24);
|
||||
_importFiles.frame=NSMakeRect(w-322,44,100,28);_importFolder.frame=NSMakeRect(w-218,44,113,28);_refresh.frame=NSMakeRect(w-101,44,82,28);
|
||||
@@ -367,7 +388,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
_sizeLabel.frame=NSMakeRect(211,h-39,74,18);_sizeSlider.frame=NSMakeRect(288,h-41,MIN(150,MAX(80,w-550)),20);
|
||||
_done.frame=NSMakeRect(w-98,h-44,78,27);
|
||||
CGFloat statusX=NSMaxX(_sizeSlider.frame)+14;_statusLabel.frame=NSMakeRect(statusX,h-39,MAX(0,w-statusX-112),18);
|
||||
if(_embedded){
|
||||
if(_embedded&&!_compactRecent){
|
||||
_search.frame=NSMakeRect(12,36,MAX(125,w-310),24);
|
||||
_importFiles.frame=NSMakeRect(w-284,34,88,28);_importFolder.frame=NSMakeRect(w-192,34,100,28);_refresh.frame=NSMakeRect(w-88,34,76,28);
|
||||
_splitView.frame=NSMakeRect(8,68,MAX(1,w-16),MAX(1,h-108));[_splitView adjustSubviews];
|
||||
@@ -376,9 +397,15 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
BOOL small=w<650;_sizeLabel.hidden=small;_sizeSlider.hidden=small;_statusLabel.hidden=small;
|
||||
if(!small){_sizeLabel.frame=NSMakeRect(174,h-29,68,18);_sizeSlider.frame=NSMakeRect(246,h-31,100,20);_statusLabel.frame=NSMakeRect(354,h-29,MAX(0,w-454),18);}
|
||||
}
|
||||
CGFloat fw=MAX(100,_folderScroll.contentSize.width);
|
||||
}
|
||||
if(_compactRecent){
|
||||
_titleLabel.frame=NSMakeRect(0,2,92,18);_countLabel.frame=NSMakeRect(94,2,100,18);
|
||||
_statusLabel.hidden=NO;_statusLabel.frame=NSMakeRect(0,MAX(24,h-19),MAX(0,w),18);
|
||||
_gridScroll.frame=NSMakeRect(0,26,MAX(1,w),MAX(1,h-49));
|
||||
}
|
||||
if(!_compactRecent){CGFloat fw=MAX(100,_folderScroll.contentSize.width);
|
||||
_folderDocument.frame=NSMakeRect(0,0,fw,MAX(_folderPaths.count*35+4,_folderScroll.contentSize.height));
|
||||
[self updateVisibleFolders];
|
||||
[self updateVisibleFolders];}
|
||||
CGFloat available=MAX(80,_gridScroll.contentSize.width),tileWidth=_sizeSlider.doubleValue,gap=10;
|
||||
BOOL list=_layoutMenu.indexOfSelectedItem==1;NSInteger columns=list?1:MAX(1,(NSInteger)floor((available+gap)/(tileWidth+gap)));tileWidth=list?MAX(110,available-14):MIN(tileWidth,(available-gap*(columns-1)-14)/columns);tileWidth=MAX(70,tileWidth);
|
||||
_columns=columns;_tileWidth=tileWidth;_tileHeight=list?70:ceil(tileWidth*9/16)+24;
|
||||
@@ -389,7 +416,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
- (CGFloat)splitView:(NSSplitView *)split constrainMinCoordinate:(CGFloat)proposed ofSubviewAt:(NSInteger)index{return 128;}
|
||||
- (CGFloat)splitView:(NSSplitView *)split constrainMaxCoordinate:(CGFloat)proposed ofSubviewAt:(NSInteger)index{return MIN(360,split.bounds.size.width*.45);}
|
||||
- (void)splitViewDidResizeSubviews:(NSNotification *)notification{
|
||||
if(_closed||_layingOut)return;_sidebarWidth=_folderScroll.frame.size.width;[NSUserDefaults.standardUserDefaults setDouble:_sidebarWidth forKey:DYBrowserPreference(DYBrowserSidebarPreference,_library)];[self layoutBrowser];
|
||||
if(_closed||_layingOut||_compactRecent)return;_sidebarWidth=_folderScroll.frame.size.width;[NSUserDefaults.standardUserDefaults setDouble:_sidebarWidth forKey:DYBrowserPreference(DYBrowserSidebarPreference,_library)];[self layoutBrowser];
|
||||
}
|
||||
- (void)layoutChanged:(id)sender{[NSUserDefaults.standardUserDefaults setInteger:_layoutMenu.indexOfSelectedItem forKey:DYBrowserPreference(DYBrowserLayoutPreference,_library)];[self layoutBrowser];}
|
||||
- (void)resetThumbnailWork {
|
||||
@@ -404,7 +431,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
for(NSUInteger i=first;i<end;i++){
|
||||
NSDictionary *entry=_visibleEntries[i];NSString *path=entry[@"path"];[wanted addObject:path];DYBrowserTile *tile=_tiles[path];
|
||||
if(!tile){tile=[[[DYBrowserTile alloc]initWithFrame:NSZeroRect]autorelease];tile.identifier=path;tile.displayName=entry[@"name"];tile.toolTip=entry[@"relativePath"]?:path;tile.palette=_palette;tile.chosen=[path isEqualToString:_selectedPath];tile.target=self;tile.action=@selector(thumbnailClicked:);tile.enabled=YES;[_gridDocument addSubview:tile];_tiles[path]=tile;changed=YES;}
|
||||
tile.listLayout=_layoutMenu.indexOfSelectedItem==1;tile.frame=NSMakeRect(7+(i%_columns)*(_tileWidth+10),8+(i/_columns)*step,_tileWidth,_tileHeight);
|
||||
tile.shortcut=_compactRecent;tile.listLayout=_layoutMenu.indexOfSelectedItem==1;tile.frame=NSMakeRect(7+(i%_columns)*(_tileWidth+10),8+(i/_columns)*step,_tileWidth,_tileHeight);
|
||||
}
|
||||
for(NSString *path in _tiles.allKeys)if(![wanted containsObject:path]){[_tiles[path]removeFromSuperview];[_tiles removeObjectForKey:path];changed=YES;}
|
||||
if(changed||!_work)[self resetThumbnailWork];
|
||||
@@ -542,7 +569,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
- (void)thumbnailClicked:(DYBrowserTile *)sender{
|
||||
if(!sender.enabled||sender.failure.length)return;
|
||||
[_selectionTask cancel];[_selectionTask release];NSUInteger generation=++_selectionGeneration;
|
||||
NSString *path=sender.identifier,*name=sender.displayName;BOOL closeAfter=sender.doubleClicked;[self setStatus:[@"正在载入 " stringByAppendingString:name]];
|
||||
NSString *path=sender.identifier,*name=sender.displayName;BOOL closeAfter=sender.doubleClicked&&!_compactRecent;[self setStatus:[@"正在载入 " stringByAppendingString:name]];
|
||||
void (^applied)(NSError *)=^(NSError *error){
|
||||
if(_closed||generation!=_selectionGeneration)return;[_selectionTask release];_selectionTask=nil;
|
||||
if(error){[self setStatus:error.localizedDescription];return;}
|
||||
|
||||
在新工单中引用
屏蔽一个用户