Add dark defaults, modular effect templates and canvas leveling
这个提交包含在:
1 父节点
ffabdca5b1
当前提交
5ca307414c
25 个文件已更改
+1702
-88
没有与搜索条件相匹配的文件
@@ -43,6 +43,8 @@ static void DYDrawCloneStamp(NSRect rect,NSColor *color){
|
||||
- (void)draw;
|
||||
- (NSRect)drawingBounds;
|
||||
@property(nonatomic) BOOL stampArmed;
|
||||
@property(nonatomic) NSInteger levelMode; // 0 closed, 1 horizontal, 2 vertical
|
||||
@property(nonatomic) BOOL levelResetRequested;
|
||||
- (NSInteger)partAtPoint:(NSPoint)point;
|
||||
- (BOOL)event:(NSEventType)type point:(NSPoint)point atTime:(CMTime)time;
|
||||
- (BOOL)mouseMoved:(NSPoint)point;
|
||||
@@ -58,7 +60,7 @@ static void DYDrawCloneStamp(NSRect rect,NSColor *color){
|
||||
@synthesize bridge=_bridge;
|
||||
- (instancetype)init{if((self=[super init])){_panels=[NSMutableArray new];_areas=[NSMutableArray new];_scale=1;_time=kCMTimeInvalid;}return self;}
|
||||
- (void)dealloc{[self finishCapture];[_bridge release];[_panels release];[_areas release];[super dealloc];}
|
||||
- (void)setBridge:(DYViewerParameterBridge*)bridge{if(bridge==_bridge)return;[self finishCapture];for(DYViewerParameterPanel*p in _panels)p.bridge=nil;[_panels removeAllObjects];[_bridge release];_bridge=[bridge retain];_pendingSkinPreview=NO;_stampArmed=NO;}
|
||||
- (void)setBridge:(DYViewerParameterBridge*)bridge{if(bridge==_bridge)return;[self finishCapture];for(DYViewerParameterPanel*p in _panels)p.bridge=nil;[_panels removeAllObjects];[_bridge release];_bridge=[bridge retain];_pendingSkinPreview=NO;_stampArmed=NO;_levelMode=0;_levelResetRequested=NO;}
|
||||
- (void)setViewport:(NSRect)viewport{_viewport=viewport;_hasViewport=YES;}
|
||||
- (void)prepareWithSize:(NSSize)size scale:(CGFloat)scale atTime:(CMTime)time{
|
||||
_size=size;_time=time;_backingScale=scale;
|
||||
@@ -69,10 +71,17 @@ NSRect bounds=NSMakeRect(0,0,size.width,size.height),v=_hasViewport?NSIntersecti
|
||||
if(_capture&&![_capture capturing])_capture=nil;
|
||||
[_areas removeAllObjects];if(!_bridge||v.size.width<100||v.size.height<80)return;
|
||||
// Only tools that benefit from direct image interaction belong on the canvas.
|
||||
NSArray *types=@[@"curve",@"lens",@"skin",@"look",@"whiteBalance",@"cloneStamp"],*titles=@[@"曲线",@"畸变修复",@"肤色",@"LUT",@"白平衡吸管",@"仿制图章"],*symbols=@[@"point.topleft.down.to.point.bottomright.curvepath",@"pincushion-grid",@"person.crop.circle",@"square.stack.3d.up",@"eyedropper",@"clone-stamp"];
|
||||
CGFloat railScale=MIN(s,v.size.width/480.),y=NSMaxY(v)-33*railScale,w=36*railScale;
|
||||
CGFloat x=NSMaxX(v)-476*railScale;
|
||||
_rail=NSMakeRect(x,y,356*railScale,25*railScale);
|
||||
NSArray *types=@[@"curve",@"lens",@"skin",@"look",@"whiteBalance",@"cloneStamp",@"level"],*titles=@[@"曲线",@"畸变修复",@"肤色",@"LUT",@"白平衡吸管",@"仿制图章",@"水平校正"],*symbols=@[@"point.topleft.down.to.point.bottomright.curvepath",@"pincushion-grid",@"person.crop.circle",@"square.stack.3d.up",@"eyedropper",@"clone-stamp",@"level"];
|
||||
CGFloat railScale=MIN(s,v.size.width/520.),y=NSMaxY(v)-33*railScale,w=36*railScale;
|
||||
CGFloat x=NSMaxX(v)-516*railScale;
|
||||
_rail=NSMakeRect(x,y,396*railScale,25*railScale);
|
||||
if(_levelMode){
|
||||
NSArray *labels=@[@"水平",@"垂直",@"重置"];
|
||||
for(NSInteger i=0;i<3;i++){
|
||||
NSRect r=NSMakeRect(NSMaxX(v)-(276-56*i)*railScale,y-34*railScale,52*railScale,26*railScale);
|
||||
[_areas addObject:@{@"part":@(20031+i),@"kind":@"levelOption",@"index":@(i+1),@"title":labels[i],@"rect":[NSValue valueWithRect:r]}];
|
||||
}
|
||||
}
|
||||
for(NSInteger i=0;i<3;i++)[_areas addObject:@{@"part":@(20010+i),@"kind":@"mask",@"index":@([@[@1,@0,@2][i]integerValue]),@"title":@[@"矩形",@"椭圆",@"钢笔"][i],@"symbol":@[@"rectangle",@"circle",@"pencil.tip"][i],@"rect":[NSValue valueWithRect:NSMakeRect(x+i*40*railScale,y,w,25*railScale)]}];
|
||||
for(NSInteger i=0;i<types.count;i++)[_areas addObject:@{@"part":@(20020+i),@"kind":@"tool",@"toolType":types[i],@"title":titles[i],@"symbol":symbols[i],@"rect":[NSValue valueWithRect:NSMakeRect(x+(i+3)*40*railScale,y,w,25*railScale)]}];
|
||||
CGFloat buttonWidth=100*railScale,buttonHeight=27*railScale;
|
||||
@@ -112,7 +121,7 @@ NSRect bounds=NSMakeRect(0,0,size.width,size.height),v=_hasViewport?NSIntersecti
|
||||
}
|
||||
- (void)draw{
|
||||
if(!_areas.count)return;[NSGraphicsContext saveGraphicsState];NSRectClip(_viewport);CGFloat s=_scale;for(DYViewerParameterPanel*p in _panels)[p draw];
|
||||
for(NSDictionary*a in _areas){NSRect r=[a[@"rect"]rectValue];BOOL selected=([a[@"toolType"]isEqual:@"skin"]&&[self skinPreviewEnabled])||([a[@"toolType"]isEqual:@"cloneStamp"]&&_stampArmed);for(DYViewerParameterPanel*p in _panels)if([p.toolType isEqual:a[@"toolType"]])selected=YES;
|
||||
for(NSDictionary*a in _areas){NSRect r=[a[@"rect"]rectValue];BOOL selected=([a[@"toolType"]isEqual:@"skin"]&&[self skinPreviewEnabled])||([a[@"toolType"]isEqual:@"cloneStamp"]&&_stampArmed)||([a[@"toolType"]isEqual:@"level"]&&_levelMode)||([a[@"kind"]isEqual:@"levelOption"]&&[a[@"index"]integerValue]==_levelMode);for(DYViewerParameterPanel*p in _panels)if([p.toolType isEqual:a[@"toolType"]])selected=YES;
|
||||
BOOL hover=_hover==[a[@"part"]integerValue];
|
||||
BOOL pressed=_pressed==[a[@"part"]integerValue];DYDrawSoftControl(r,4*s,NO,selected||hover,pressed);
|
||||
if(a[@"symbol"]){
|
||||
@@ -139,6 +148,8 @@ NSRect bounds=NSMakeRect(0,0,size.width,size.height),v=_hasViewport?NSIntersecti
|
||||
[NSGraphicsContext restoreGraphicsState];
|
||||
}
|
||||
- (void)activateTool:(NSString*)type{
|
||||
if([type isEqual:@"level"]){_stampArmed=NO;_levelMode=_levelMode?0:1;return;}
|
||||
_levelMode=0;
|
||||
if([type isEqual:@"cloneStamp"]){_stampArmed=!_stampArmed;return;}
|
||||
_stampArmed=NO;
|
||||
if([type isEqual:@"look"]){[_bridge requestWorkspacePage:@"lut"];return;}
|
||||
@@ -157,7 +168,7 @@ NSRect bounds=NSMakeRect(0,0,size.width,size.height),v=_hasViewport?NSIntersecti
|
||||
if(!hit)return NO;_pressed=hit;return YES;
|
||||
}
|
||||
if(!_pressed)return NO;
|
||||
if(type==NSEventTypeLeftMouseUp){NSInteger pressed=_pressed;_pressed=0;if(hit==pressed){for(NSDictionary*a in _areas)if([a[@"part"]integerValue]==hit){NSString*kind=a[@"kind"];if([kind isEqual:@"tool"])[self activateTool:a[@"toolType"]];else if([kind isEqual:@"mask"]){_stampArmed=NO;[_bridge requestMask:[a[@"index"]integerValue]];}else if([kind isEqual:@"workspace"])[_bridge requestWorkspace];else if([kind isEqual:@"hidePanels"]){for(DYViewerParameterPanel*panel in _panels){[panel finishCapture];panel.bridge=nil;}[_panels removeAllObjects];}else if([kind isEqual:@"railPage"])_railPage++;break;}}[self prepareWithSize:_size scale:_backingScale atTime:time];}
|
||||
if(type==NSEventTypeLeftMouseUp){NSInteger pressed=_pressed;_pressed=0;if(hit==pressed){for(NSDictionary*a in _areas)if([a[@"part"]integerValue]==hit){NSString*kind=a[@"kind"];if([kind isEqual:@"tool"])[self activateTool:a[@"toolType"]];else if([kind isEqual:@"levelOption"]){NSInteger choice=[a[@"index"]integerValue];if(choice==3)_levelResetRequested=YES;else _levelMode=choice;}else if([kind isEqual:@"mask"]){_stampArmed=NO;_levelMode=0;[_bridge requestMask:[a[@"index"]integerValue]];}else if([kind isEqual:@"workspace"]){_levelMode=0;[_bridge requestWorkspace];}else if([kind isEqual:@"hidePanels"]){for(DYViewerParameterPanel*panel in _panels){[panel finishCapture];panel.bridge=nil;}[_panels removeAllObjects];}else if([kind isEqual:@"railPage"])_railPage++;break;}}[self prepareWithSize:_size scale:_backingScale atTime:time];}
|
||||
return YES;
|
||||
}
|
||||
- (BOOL)capturing{return _pressed||[_capture capturing];}
|
||||
|
||||
在新工单中引用
屏蔽一个用户