Implement adaptive inspector and responsive canvas controls for 1.12.1
这个提交包含在:
1 父节点
91b66eb2d8
当前提交
585c83c8a1
21 个文件已更改
+316
-68
没有与搜索条件相匹配的文件
@@ -15,11 +15,10 @@
|
||||
}
|
||||
- (void)addHandle:(NSPoint)p part:(NSInteger)part{[_handles addObject:@{@"point":[NSValue valueWithPoint:p],@"part":@(part)}];}
|
||||
- (NSRect)toolbarRectForItem:(NSInteger)item{
|
||||
// Only the two temporary pen actions remain. The permanent tools live in the
|
||||
// transparent left rail; the middle of the bottom edge opens the workspace.
|
||||
// Keep the temporary pen actions clear of the permanent tool rail.
|
||||
if(![_mask[@"drawing"]boolValue]||(item!=9&&item!=10))return NSZeroRect;
|
||||
NSRect v=NSIntersectionRect(_imageRect,NSMakeRect(0,0,_canvasWidth,_height));CGFloat scale=MAX(.01,MIN(_uiScale,MIN(v.size.width/300.,v.size.height/100.)));
|
||||
return NSMakeRect(NSMidX(v)+(item==9?-144:80)*scale,NSMaxY(v)-32*scale,64*scale,24*scale);
|
||||
return NSMakeRect(NSMinX(v)+(item==9?8:76)*scale,NSMaxY(v)-61*scale,64*scale,24*scale);
|
||||
}
|
||||
- (void)drawOSCWithWidth:(NSInteger)width height:(NSInteger)height activePart:(NSInteger)activePart destinationImage:(FxImageTile*)destination atTime:(CMTime)time {@synchronized(self){@autoreleasepool{
|
||||
if(!_device||_device.registryID!=destination.deviceRegistryID){[_device release];_device=nil;NSArray *devices=MTLCopyAllDevices();for(id<MTLDevice>d in devices)if(d.registryID==destination.deviceRegistryID)_device=[d retain];[devices release];[_queue release];_queue=[_device newCommandQueue];[_context release];_context=_device?[[CIContext contextWithMTLDevice:_device options:@{kCIContextWorkingColorSpace:NSNull.null,kCIContextOutputColorSpace:NSNull.null}]retain]:nil;}
|
||||
@@ -52,8 +51,10 @@
|
||||
}[commands commit];[commands waitUntilCompleted];
|
||||
}}}
|
||||
- (NSInteger)partAtPoint:(NSPoint)point {
|
||||
BOOL drawing=[_mask[@"drawing"]boolValue];
|
||||
if(drawing)for(NSInteger i=9;i<=10;i++)if(NSPointInRect(point,[self toolbarRectForItem:i]))return 10000+i;
|
||||
NSInteger viewerHit=[_viewerControls partAtPoint:point];if(viewerHit)return viewerHit;
|
||||
if(!_mask)return 0;BOOL drawing=[_mask[@"drawing"]boolValue];if(drawing)for(NSInteger i=9;i<=10;i++)if(NSPointInRect(point,[self toolbarRectForItem:i]))return 10000+i;if([_mask[@"drawShape"]boolValue])return NSPointInRect(point,_imageRect)?1:0;
|
||||
if(!_mask)return 0;if([_mask[@"drawShape"]boolValue])return NSPointInRect(point,_imageRect)?1:0;
|
||||
DYMaskParameters p;[_mask[@"parameters"]getBytes:&p length:sizeof(p)];p.imageAspect=_imageRect.size.width/MAX(1.,_imageRect.size.height);
|
||||
if(drawing){NSData *data=_mask[@"nodes"];if(data.length>=3*sizeof(DYBezierNode)){const DYBezierNode *nodes=(const DYBezierNode*)data.bytes;NSPoint first=[self canvasPoint:nodes[0].x y:nodes[0].y parameters:p];if(hypot(point.x-first.x,point.y-first.y)<=10*_uiScale)return 1000;}return NSPointInRect(point,_imageRect)?1:0;}
|
||||
for(NSDictionary *h in _handles){NSPoint q=[h[@"point"]pointValue];if(hypot(q.x-point.x,q.y-point.y)<=9*_uiScale)return [h[@"part"]integerValue];}
|
||||
@@ -65,7 +66,8 @@
|
||||
if(_maskCapturing&&plugin!=_maskCaptureOwner){_maskCapturing=NO;_maskCaptureOwner=nil;return NO;}
|
||||
BOOL ownedMask=_maskCapturing&&(type==NSEventTypeLeftMouseDragged||type==NSEventTypeLeftMouseUp);
|
||||
if(type==NSEventTypeKeyDown&&key==27&&[_viewerControls capturing])return [_viewerControls finishCapture];
|
||||
if(!ownedMask&&type!=NSEventTypeKeyDown&&[_viewerControls event:type point:canvasPoint atTime:time])return YES;
|
||||
BOOL penAction=type==NSEventTypeLeftMouseDown&&(part==10009||part==10010);
|
||||
if(!ownedMask&&!penAction&&type!=NSEventTypeKeyDown&&[_viewerControls event:type point:canvasPoint atTime:time])return YES;
|
||||
if(!plugin||![plugin toolCanvasVisible]||_imageRect.size.width<=0||_imageRect.size.height<=0){_maskCapturing=NO;return NO;}
|
||||
NSPoint point=NSMakePoint((x-_imageRect.origin.x)/_imageRect.size.width,(_height-y-_imageRect.origin.y)/_imageRect.size.height);
|
||||
if(type==NSEventTypeLeftMouseDown){_maskCapturing=part>0&&part<10000;_maskCaptureOwner=_maskCapturing?plugin:nil;}
|
||||
|
||||
在新工单中引用
屏蔽一个用户