wip: restore canvas icon buttons, retain closing pen path and add vector sampling

这个提交包含在:
mac 于 2026-11-05 09:30:31 +08:00 提交
1 父节点 38e11aa103
当前提交 57059390d1
4 个文件已更改
+24 -9

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

+7 -4
查看文件
@@ -34,11 +34,11 @@ 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"],*titles=@[@"曲线",@"畸变",@"肤色",@"LUT"];
NSArray *types=@[@"curve",@"lens",@"skin",@"look"],*titles=@[@"曲线",@"畸变",@"肤色",@"LUT"],*symbols=@[@"point.topleft.down.to.point.bottomright.curvepath",@"camera.aperture",@"person.crop.circle",@"square.stack.3d.up"];
CGFloat railScale=MIN(s,MAX(.3,v.size.height/280.));CGFloat x=NSMinX(v)+8*railScale,y=NSMinY(v)+8*railScale,w=36*railScale;
_rail=NSMakeRect(x,y,w,196*railScale);
for(NSInteger i=0;i<3;i++)[_areas addObject:@{@"part":@(20010+i),@"kind":@"mask",@"index":@([@[@1,@0,@2][i]integerValue]),@"title":@[@"矩形",@"椭圆",@"钢笔"][i],@"rect":[NSValue valueWithRect:NSMakeRect(x,y+i*28*railScale,w,25*railScale)]}];
for(NSInteger i=0;i<4;i++)[_areas addObject:@{@"part":@(20020+i),@"kind":@"tool",@"toolType":types[i],@"title":titles[i],@"rect":[NSValue valueWithRect:NSMakeRect(x,y+(i+3)*28*railScale,w,25*railScale)]}];
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,y+i*28*railScale,w,25*railScale)]}];
for(NSInteger i=0;i<4;i++)[_areas addObject:@{@"part":@(20020+i),@"kind":@"tool",@"toolType":types[i],@"title":titles[i],@"symbol":symbols[i],@"rect":[NSValue valueWithRect:NSMakeRect(x,y+(i+3)*28*railScale,w,25*railScale)]}];
CGFloat buttonWidth=MIN(100*s,v.size.width-16*s),buttonHeight=MIN(27*s,MAX(16.,v.size.height*.16));
[_areas addObject:@{@"part":@20001,@"kind":@"workspace",@"title":@"控制面板",@"rect":[NSValue valueWithRect:NSMakeRect(NSMidX(v)-buttonWidth/2,NSMaxY(v)-buttonHeight-8*railScale,buttonWidth,buttonHeight)]}];
}
@@ -70,13 +70,16 @@ NSRect bounds=NSMakeRect(0,0,size.width,size.height),v=_hasViewport?NSIntersecti
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];for(DYViewerParameterPanel*p in _panels)if([p.toolType isEqual:a[@"toolType"]])selected=YES;
BOOL hover=_hover==[a[@"part"]integerValue];
// Text and its narrow shadow stay readable without tinting the review image.
BOOL pressed=_pressed==[a[@"part"]integerValue];DYDrawSoftControl(r,4*s,NO,selected||hover,pressed);
if(a[@"symbol"]){NSImage *icon=[NSImage imageWithSystemSymbolName:a[@"symbol"] accessibilityDescription:a[@"title"]];NSImageSymbolConfiguration *configuration=[[NSImageSymbolConfiguration configurationWithPointSize:14*s weight:NSFontWeightRegular]configurationByApplyingConfiguration:[NSImageSymbolConfiguration configurationWithPaletteColors:@[selected?NSColor.systemCyanColor:NSColor.whiteColor]]];icon=[icon imageWithSymbolConfiguration:configuration];CGFloat side=MIN(17*s,r.size.height-6*s);[icon drawInRect:NSMakeRect(NSMidX(r)-side/2,NSMidY(r)-side/2,side,side) fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1 respectFlipped:YES hints:nil];continue;}
// The bottom workspace entry keeps its explicit text label.
NSMutableParagraphStyle*style=[[[NSMutableParagraphStyle alloc]init]autorelease];style.alignment=NSTextAlignmentCenter;
NSShadow *shadow=[[[NSShadow alloc]init]autorelease];shadow.shadowColor=[NSColor colorWithWhite:0 alpha:.95];shadow.shadowBlurRadius=2;shadow.shadowOffset=NSMakeSize(0,-1);
CGFloat fontSize=MIN(11*s,r.size.height*.44);NSDictionary *attributes=@{NSFontAttributeName:[NSFont systemFontOfSize:fontSize weight:selected||hover?NSFontWeightBold:NSFontWeightMedium],NSForegroundColorAttributeName:selected||hover?NSColor.systemCyanColor:NSColor.whiteColor,NSParagraphStyleAttributeName:style,NSShadowAttributeName:shadow};
[a[@"title"]drawInRect:NSInsetRect(r,1,MAX(1.,(r.size.height-fontSize-3)/2)) withAttributes:attributes];
if(selected){NSBezierPath *mark=[NSBezierPath bezierPath];[mark moveToPoint:NSMakePoint(NSMinX(r),NSMidY(r)-3*s)];[mark lineToPoint:NSMakePoint(NSMinX(r),NSMidY(r)+3*s)];[NSColor.systemCyanColor setStroke];mark.lineWidth=2*s;[mark stroke];}
}
for(NSDictionary *a in _areas)if(a[@"symbol"]&&_hover==[a[@"part"]integerValue]){NSRect r=[a[@"rect"]rectValue],tip=NSMakeRect(NSMaxX(r)+6*s,NSMinY(r),72*s,25*s);DYDrawSoftControl(tip,4*s,NO,NO,NO);[a[@"title"]drawInRect:NSInsetRect(tip,5*s,5*s)withAttributes:@{NSFontAttributeName:[NSFont systemFontOfSize:10*s],NSForegroundColorAttributeName:NSColor.whiteColor}];break;}
[NSGraphicsContext restoreGraphicsState];
}
- (void)activateTool:(NSString*)type{