feat: WIP unified workspace shared mask objects and OpenCV tracker core

这个提交包含在:
mac 于 2026-11-05 03:16:17 +08:00 提交
1 父节点 78e53b3889
当前提交 ca352248c1
36 个文件已更改
+5298 -164

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

@@ -53,13 +53,32 @@
NSInteger count=[counts[type]integerValue];counts[type]=@(count+1);if(!base)title=[title stringByAppendingFormat:@" · %ld",(long)(count+1)];
[nodes addObject:@{@"id":ID,@"type":type,@"title":title,@"layer":layer?:@{}}];
}[_nodes release];_nodes=[nodes copy];
NSString *selected=_snapshot[@"selectedNode"];for(NSDictionary *candidate in _nodes)if([candidate[@"id"]isEqual:selected]&&![_nodeID isEqual:selected]){[self finishCapture];[_nodeID release];_nodeID=[selected copy];[_selectedX release];_selectedX=nil;break;}
if(![self node]){[self finishCapture];[_nodeID release];_nodeID=_nodes.count?[_nodes[0][@"id"]copy]:nil;_page=0;[_selectedX release];_selectedX=nil;}}
NSString*type=[self node][@"type"]?:_toolType;NSMutableArray*rows=[NSMutableArray array];
// These are the existing public scalar controls, never hidden curve-slot metadata.
NSArray*sections=[type isEqual:@"base"]?@[@"base",@"color"]:type?@[type]:@[];
if(doc)for(NSString*part in sections)for(NSDictionary*d in DYToolSection(part)[@"rows"]){NSString*k=d[@"key"];if(!d[@"pid"]||[k hasPrefix:@"cmbypass"]||[k isEqual:@"copyAutoGrade"]||([type isEqual:@"curve"]&&![k hasPrefix:@"curveY"]))continue;[rows addObject:d];}
[_rows release];_rows=[rows copy];[_areas removeAllObjects];if(!_bridge||size.width<120||size.height<80)return;
CGFloat s=_scale,margin=8*s,w=MIN(300*s,size.width-2*margin);_capacity=MAX(1,MIN(5,(NSInteger)floor((size.height-124*s)/(46*s))));
CGFloat s=_scale,margin=8*s,w=MIN(300*s,size.width-2*margin);
// Direct image tools have no panel surface, title, catalog or parameter page.
if([@[@"curve",@"lens"]containsObject:type]){
if([type isEqual:@"lens"]){
_panel=viewport;if(!_snapshot||![self node])return;
NSPoint center=NSMakePoint(NSMinX(viewport)+[self graphicValue:@"lensCenterX"]*size.width,NSMinY(viewport)+[self graphicValue:@"lensCenterY"]*size.height);
NSPoint strength=NSMakePoint(NSMinX(viewport)+size.width*.78,NSMinY(viewport)+size.height*.5);
[self addArea:viewport part:22400 kind:@"lensFrame" title:@"" descriptor:nil index:0];
[self addArea:NSMakeRect(center.x-11*s,center.y-11*s,22*s,22*s) part:22401 kind:@"lensCenter" title:@"" descriptor:nil index:0];
[self addArea:NSMakeRect(strength.x-11*s,strength.y-11*s,22*s,22*s) part:22402 kind:@"lensStrength" title:@"" descriptor:nil index:0];return;
}
w=MIN(260*s,size.width-2*margin);CGFloat h=MIN(214*s,size.height-2*margin),x=viewport.origin.x+margin,top=viewport.origin.y+margin;
if(_positioned){x=MAX(viewport.origin.x+margin,MIN(NSMaxX(viewport)-margin-w,viewport.origin.x+_position.x*size.width));top=MAX(viewport.origin.y+margin,MIN(NSMaxY(viewport)-margin-h,viewport.origin.y+_position.y*size.height));}
_panel=NSMakeRect(x,top,w,h);if(!_snapshot||![self node]||w<100*s||h<65*s)return;
for(NSInteger c=0;c<4;c++)[self addArea:NSMakeRect(x+c*24*s,top,23*s,18*s)part:22010+c kind:@"channel" title:@[@"Y",@"R",@"G",@"B"][c] descriptor:nil index:c];
[self addArea:NSMakeRect(x,top+22*s,w,MAX(24*s,h-22*s))part:22000 kind:@"curvePlot" title:@"" descriptor:nil index:0];
if(_selectedX)[self addArea:NSMakeRect(NSMaxX(_panel)-19*s,top,19*s,18*s)part:22020 kind:@"deletePoint" title:@"×" descriptor:nil index:0];return;
}
_capacity=MAX(1,MIN(5,(NSInteger)floor((size.height-124*s)/(46*s))));
_catalogCapacity=MAX(1,MIN(7,(NSInteger)floor((size.height-124*s)/(32*s))));
_page=MIN(MAX(0,_page),MAX(0,((NSInteger)_rows.count-1)/_capacity));_catalogPage=MIN(MAX(0,_catalogPage),MAX(0,((NSInteger)_nodes.count-1)/_catalogCapacity));
BOOL graph=_graphMode&&([@[@"curve",@"grading",@"hsl",@"spider"]containsObject:type]);
@@ -103,7 +122,7 @@
- (void)draw{
if(!_areas.count)return;[NSGraphicsContext saveGraphicsState];NSRectClip(NSIntersectionRect(_panel,NSMakeRect(0,0,_size.width,_size.height)));CGFloat s=_scale;NSColor*ink=DYThemeColor(@"text")?:NSColor.whiteColor,*accent=DYThemeColor(@"accent")?:NSColor.systemCyanColor;
NSBezierPath*panel=[NSBezierPath bezierPathWithRoundedRect:_panel xRadius:9*s yRadius:9*s];BOOL solid=NSWorkspace.sharedWorkspace.accessibilityDisplayShouldReduceTransparency;
[[DYThemeColor(@"surface")?:DYThemeColor(@"background")?:NSColor.blackColor colorWithAlphaComponent:solid?1:.66]setFill];[panel fill];[[ink colorWithAlphaComponent:.32]setStroke];panel.lineWidth=s;[panel stroke];
BOOL minimal=[@[@"curve",@"lens"]containsObject:_toolType];if(minimal){ink=NSColor.whiteColor;accent=NSColor.systemCyanColor;NSShadow *shadow=[[[NSShadow alloc]init]autorelease];shadow.shadowColor=[NSColor colorWithWhite:0 alpha:.95];shadow.shadowBlurRadius=2;shadow.shadowOffset=NSZeroSize;[shadow set];}if(!minimal){[[DYThemeColor(@"surface")?:DYThemeColor(@"background")?:NSColor.blackColor colorWithAlphaComponent:solid?1:.66]setFill];[panel fill];[[ink colorWithAlphaComponent:.32]setStroke];panel.lineWidth=s;[panel stroke];}
for(NSDictionary*a in _areas){NSRect r=[a[@"rect"]rectValue];NSInteger part=[a[@"part"]integerValue];NSString*kind=a[@"kind"];BOOL pressed=_pressed==part,hover=_hover==part;NSDictionary*d=a[@"descriptor"];
if([self graphicKind:kind]){[self drawGraphic:a];continue;}
if([kind isEqual:@"slider"]){double v=[self valueForDescriptor:d],lo=[d[@"min"]doubleValue],hi=[d[@"max"]doubleValue];CGFloat ratio=hi>lo?MAX(0.,MIN(1.,(v-lo)/(hi-lo))):0;NSRect track=[self trackForArea:a];
@@ -113,15 +132,15 @@
DYDrawSoftControl(NSMakeRect(track.origin.x+ratio*track.size.width-6*s,NSMidY(track)-6*s,12*s,12*s),6*s,NO,hover||pressed,pressed);
}else{
BOOL selected=(([kind isEqual:@"channel"]&&[a[@"index"]integerValue]==_channel)||([kind isEqual:@"hslAxis"]&&[a[@"index"]integerValue]==_hslAxis))||([kind isEqual:@"module"]&&[a[@"nodeID"]isEqual:_nodeID])||([kind isEqual:@"tool"]&&[a[@"toolType"]isEqual:[self node][@"type"]]);BOOL on=([kind isEqual:@"bool"]||[kind isEqual:@"headerBool"])&&[self valueForDescriptor:d]>.5;
DYDrawSoftControl(r,5*s,NO,hover||selected||on,pressed);NSString*title=a[@"title"];
if(!minimal)DYDrawSoftControl(r,5*s,NO,hover||selected||on,pressed);NSString*title=a[@"title"];
if(d&&![kind isEqual:@"reset"]){NSString*value=[self valueText:d value:[self valueForDescriptor:d]];title=[kind isEqual:@"headerBool"]?(title.length?title:([self valueForDescriptor:d]>.5?@"●":@"○")):[NSString stringWithFormat:@"%@ %@%@",title,value,[kind isEqual:@"choice"]?@" ›":@""];}
[self text:title rect:NSInsetRect(r,5*s,5*s) size:[kind isEqual:@"open"]?12:11 color:[kind isEqual:@"toolUnavailable"]?[ink colorWithAlphaComponent:.35]:ink alignment:NSTextAlignmentCenter];
[self text:title rect:NSInsetRect(r,5*s,5*s) size:[kind isEqual:@"open"]?12:11 color:[kind isEqual:@"toolUnavailable"]?[ink colorWithAlphaComponent:.35]:(minimal&&(selected||hover||pressed)?accent:ink) alignment:NSTextAlignmentCenter];
}
}
if(_open){NSString*hint=_catalog?@"选择当前工具的图层":(_graphMode&&[_toolType isEqual:@"curve"])?@"点击加点 · 拖动调整":(_graphMode&&[_toolType isEqual:@"grading"])?@"拖动色轮 · 参数查看亮度":@"拖动调节 · ↺ 还原";if(_graphMode&&[_toolType isEqual:@"hsl"])hint=@"拖动色点 · 参数精调";if(_graphMode&&[_toolType isEqual:@"spider"])hint=@"拖点联动 · 固定与还原选中点";if(_hover==20000||_movingPanel)hint=@"拖动标题移动 · 单击折叠";[self text:hint rect:NSMakeRect(_panel.origin.x+40*s,NSMaxY(_panel)-22*s,_panel.size.width-168*s,18*s) size:9 color:ink alignment:NSTextAlignmentCenter];}
if(_open&&!minimal){NSString*hint=_catalog?@"选择当前工具的图层":(_graphMode&&[_toolType isEqual:@"curve"])?@"点击加点 · 拖动调整":(_graphMode&&[_toolType isEqual:@"grading"])?@"拖动色轮 · 参数查看亮度":@"拖动调节 · ↺ 还原";if(_graphMode&&[_toolType isEqual:@"hsl"])hint=@"拖动色点 · 参数精调";if(_graphMode&&[_toolType isEqual:@"spider"])hint=@"拖点联动 · 固定与还原选中点";if(_hover==20000||_movingPanel)hint=@"拖动标题移动 · 单击折叠";[self text:hint rect:NSMakeRect(_panel.origin.x+40*s,NSMaxY(_panel)-22*s,_panel.size.width-168*s,18*s) size:9 color:ink alignment:NSTextAlignmentCenter];}
[NSGraphicsContext restoreGraphicsState];
}
- (NSInteger)partAtPoint:(NSPoint)p{if(!_visible||!std::isfinite(p.x)||!std::isfinite(p.y)||!_bridge||!NSPointInRect(p,NSIntersectionRect(_panel,NSMakeRect(0,0,_size.width,_size.height))))return 0;for(NSDictionary*a in [_areas reverseObjectEnumerator])if(![a[@"kind"]isEqual:@"toolUnavailable"]&&NSPointInRect(p,[a[@"rect"]rectValue]))return [a[@"part"]integerValue];return _open&&NSPointInRect(p,_panel)?20006:0;}
- (NSInteger)partAtPoint:(NSPoint)p{if(!_visible||!std::isfinite(p.x)||!std::isfinite(p.y)||!_bridge||!NSPointInRect(p,NSIntersectionRect(_panel,NSMakeRect(0,0,_size.width,_size.height))))return 0;for(NSDictionary*a in [_areas reverseObjectEnumerator])if(![@[@"toolUnavailable",@"lensFrame"]containsObject:a[@"kind"]]&&NSPointInRect(p,[a[@"rect"]rectValue]))return [a[@"part"]integerValue];return ![@[@"curve",@"lens"]containsObject:_toolType]&&_open&&NSPointInRect(p,_panel)?20006:0;}
- (NSDictionary*)areaForPart:(NSInteger)part{for(NSDictionary*a in _areas)if([a[@"part"]integerValue]==part)return a;return nil;}
- (void)applySliderPoint:(NSPoint)p{
NSRect t=[self trackForArea:_captured];NSDictionary*d=_captured[@"descriptor"];double ratio=MAX(0.,MIN(1.,(p.x-_knobOffset-t.origin.x)/MAX(1.,t.size.width)));_draftValue=[d[@"min"]doubleValue]+ratio*([d[@"max"]doubleValue]-[d[@"min"]doubleValue]);[_bridge changeValue:_draftValue];