Implement persistent leveling and all standalone module templates; validation pending

这个提交包含在:
mac 于 2026-11-06 12:24:19 +08:00 提交
1 父节点 81b50538b4
当前提交 dc5769492d
33 个文件已更改
+8585 -88

没有与搜索条件相匹配的文件

+14 -14
查看文件
@@ -52,7 +52,7 @@ static void DYDrawCloneStamp(NSRect rect,NSColor *color){
- (NSRect)drawingBounds;
@property(nonatomic) BOOL stampArmed;
@property(nonatomic) NSInteger levelMode; // 0 closed, 1 horizontal, 2 vertical
@property(nonatomic) BOOL levelResetRequested;
@property(nonatomic) BOOL levelResetRequested,levelMeasureOnly,levelMeasureRequested,levelDirectionRequested;
- (NSInteger)partAtPoint:(NSPoint)point;
- (BOOL)event:(NSEventType)type point:(NSPoint)point atTime:(CMTime)time;
- (BOOL)mouseMoved:(NSPoint)point;
@@ -68,7 +68,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;_levelMode=0;_levelResetRequested=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=_levelMeasureRequested=_levelDirectionRequested=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;
@@ -84,9 +84,9 @@ NSRect bounds=NSMakeRect(0,0,size.width,size.height),v=_hasViewport?NSIntersecti
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);
NSArray *labels=@[@"水平",@"垂直",@"重置",@"仅测量"];
for(NSInteger i=0;i<4;i++){
NSRect r=NSMakeRect(NSMaxX(v)-(354-66*i)*railScale,y-34*railScale,62*railScale,26*railScale);
[_areas addObject:@{@"part":@(20031+i),@"kind":@"levelOption",@"index":@(i+1),@"title":labels[i],@"rect":[NSValue valueWithRect:r]}];
}
}
@@ -98,10 +98,10 @@ NSRect bounds=NSMakeRect(0,0,size.width,size.height),v=_hasViewport?NSIntersecti
- (NSInteger)partAtPoint:(NSPoint)p{
if(!_bridge||!std::isfinite(p.x)||!std::isfinite(p.y)||!NSPointInRect(p,_viewport))return 0;
for(NSDictionary*a in _areas)if(NSPointInRect(p,[a[@"rect"]rectValue]))return [a[@"part"]integerValue];if(NSPointInRect(p,_rail))return 20000;
for(NSInteger i=_panels.count-1;i>=0;i--){NSInteger part=[_panels[i]partAtPoint:p];if(part)return 100000+(i+1)*10000+(part-20000);}
if(!_levelMode)for(NSInteger i=_panels.count-1;i>=0;i--){NSInteger part=[_panels[i]partAtPoint:p];if(part)return 100000+(i+1)*10000+(part-20000);}
return 0;
}
- (BOOL)headerAtPoint:(NSPoint)p{if(NSPointInRect(p,_rail))return NO;for(DYViewerParameterPanel*panel in [_panels reverseObjectEnumerator]){NSInteger part=[panel partAtPoint:p];if(part)return part==20000;}return NO;}
- (BOOL)headerAtPoint:(NSPoint)p{if(_levelMode||NSPointInRect(p,_rail))return NO;for(DYViewerParameterPanel*panel in [_panels reverseObjectEnumerator]){NSInteger part=[panel partAtPoint:p];if(part)return part==20000;}return NO;}
- (NSString*)skinNodeInSnapshot:(NSDictionary*)snapshot{
NSDictionary *doc=snapshot[@"document"];if(!doc)return nil;NSString *node=snapshot[@"selectedNode"];
if([node isEqual:@"base:skin"]&&!DYBaseToolRemoved(doc,@"skin"))return node;
@@ -123,13 +123,13 @@ NSRect bounds=NSMakeRect(0,0,size.width,size.height),v=_hasViewport?NSIntersecti
if(!_areas.count)return NSZeroRect;
NSRect rect=_rail;
for(NSDictionary *area in _areas)rect=NSUnionRect(rect,[area[@"rect"] rectValue]);
for(DYViewerParameterPanel *panel in _panels){NSRect bounds=[panel drawingBounds];if(!NSIsEmptyRect(bounds))rect=NSUnionRect(rect,bounds);}
if(!_levelMode)for(DYViewerParameterPanel *panel in _panels){NSRect bounds=[panel drawingBounds];if(!NSIsEmptyRect(bounds))rect=NSUnionRect(rect,bounds);}
// Tooltips and control shadows extend beyond the buttons.
return NSIntersectionRect(_viewport,NSInsetRect(rect,-24*_scale,-32*_scale));
}
- (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)||([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;
if(!_areas.count)return;[NSGraphicsContext saveGraphicsState];NSRectClip(_viewport);CGFloat s=_scale;if(!_levelMode)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)||([a[@"toolType"]isEqual:@"level"]&&_levelMode)||([a[@"kind"]isEqual:@"levelOption"]&&([a[@"index"]integerValue]==_levelMode||([a[@"index"]integerValue]==4&&_levelMeasureOnly)));if(!_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"]){
@@ -157,14 +157,14 @@ 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:@"level"]){[self finishCapture];_stampArmed=NO;_levelMode=_levelMode?0:1;return;}
BOOL returningFromLevel=_levelMode!=0;_levelMode=0;
if([type isEqual:@"cloneStamp"]){_stampArmed=!_stampArmed;return;}
_stampArmed=NO;
if([type isEqual:@"look"]){[_bridge requestWorkspacePage:@"lut"];return;}
if([type isEqual:@"skin"]){[self toggleSkinPreview];return;}
if([type isEqual:@"whiteBalance"]){[_bridge requestWhiteBalanceAtTime:_time];return;}
for(DYViewerParameterPanel*p in [[_panels copy]autorelease])if([p.toolType isEqual:type]){[p finishCapture];p.bridge=nil;[_panels removeObjectIdenticalTo:p];return;}
for(DYViewerParameterPanel*p in [[_panels copy]autorelease])if([p.toolType isEqual:type]){if(returningFromLevel){[_bridge requestTool:type];return;}[p finishCapture];p.bridge=nil;[_panels removeObjectIdenticalTo:p];return;}
[_bridge requestTool:type];DYViewerParameterPanel*p=[[[DYViewerParameterPanel alloc]init]autorelease];p.toolType=type;p.bridge=_bridge;
[_panels addObject:p];
}
@@ -177,7 +177,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:@"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];}
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 if(choice==4)_levelMeasureRequested=YES;else{_levelMode=choice;_levelDirectionRequested=YES;}}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];}