Make the clone source crosshair draggable without changing target tracks
这个提交包含在:
1 父节点
4fb008e100
当前提交
1f1b7917e7
6 个文件已更改
+61
-15
没有与搜索条件相匹配的文件
@@ -117,7 +117,29 @@
|
||||
DYMaskParameters target=DYMaskAtTime(stamp,kCMTimeZero);
|
||||
run.record(@"native-osc-creates-one-stamp-and-one-undo-from-source-click-and-drag",source.count==4&&fabs([source[0]doubleValue]-.25)<1e-6&&fabs([source[1]doubleValue]-.25)<1e-6&&fabs(target.centerX-.65)<1e-6&&fabs(target.centerY-.5)<1e-6&&base->_undoStarts==undo+1&&base->_undoEnds==undo+1);
|
||||
[osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero];
|
||||
click(251,104);drain(); // first draw has top-down viewport y=30...345, forward button is x=212...290.
|
||||
NSMutableDictionary *tracked=DYMutablePlist(DYReadTools(host,kCMTimeZero).document);
|
||||
NSMutableDictionary *trackedStamp=(id)DYSharedMaskWithID(tracked,stamp[@"id"]);
|
||||
DYMaskParameters moved=target;moved.centerX+=.05f;
|
||||
NSArray *keys=@[DYMaskKey(kCMTimeZero,target,NO,1),DYMaskKey(CMTimeMake(1,25),moved,NO,1)];
|
||||
trackedStamp[@"keys"]=keys;DYWriteTools(host,tracked,kCMTimeZero);
|
||||
[plugin pluginState:&state atTime:kCMTimeZero quality:(FxQuality)0 error:&error];
|
||||
[osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero];
|
||||
undo=base->_undoStarts;
|
||||
part=down(180,291.25);
|
||||
[osc mouseDraggedAtPositionX:236 positionY:259.75 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero];
|
||||
NSArray *preview=[plugin toolCanvasMaskAtTime:kCMTimeZero][@"stampSource"];
|
||||
up(236,259.75,part);drain();
|
||||
NSDictionary *edited=DYSharedMaskWithID(DYReadTools(host,kCMTimeZero).document,stamp[@"id"]);
|
||||
NSArray *relocated=edited[@"stampSource"];
|
||||
run.record(@"native-osc-drag-moves-only-the-stamp-source-and-keeps-tracking-keys",part==7&&fabs([relocated[0]doubleValue]-.35)<1e-6&&fabs([relocated[1]doubleValue]-.35)<1e-6&&[relocated isEqual:preview]&&[edited[@"parameters"]isEqual:trackedStamp[@"parameters"]]&&[edited[@"keys"]isEqual:keys]&&base->_undoStarts==undo+1&&base->_undoEnds==undo+1);
|
||||
[osc drawOSCWithWidth:640 height:400 activePart:0 destinationImage:overlay atTime:kCMTimeZero];
|
||||
part=down(236,259.75);
|
||||
[osc mouseDraggedAtPositionX:270 positionY:240 activePart:part modifiers:0 forceUpdate:&update atTime:kCMTimeZero];
|
||||
BOOL handled=NO;
|
||||
[osc keyDownAtPositionX:270 positionY:240 keyPressed:27 modifiers:0 forceUpdate:&update didHandle:&handled atTime:kCMTimeZero];
|
||||
drain();
|
||||
run.record(@"native-osc-escape-cancels-the-stamp-source-drag-without-another-undo",handled&&[DYSharedMaskWithID(DYReadTools(host,kCMTimeZero).document,stamp[@"id"])[@"stampSource"]isEqual:relocated]&&base->_undoStarts==undo+1);
|
||||
click(251,104);drain(); // top-down viewport y=30...345, forward button is x=212...290.
|
||||
run.record(@"native-osc-stamp-forward-action-starts-the-existing-host-tracker",host->_forwardStarts==1&&host->_backwardStarts==0);
|
||||
[plugin cleanupAnalysis:nil];drain();[(id)osc release];[(id)plugin release];
|
||||
}
|
||||
@@ -8,8 +8,8 @@
|
||||
@synchronized(self){[_toolCanvasDraft release];_toolCanvasDraft=nil;[_toolCanvasOriginal release];_toolCanvasOriginal=nil;_toolDrawingPen=_toolDrawingShape=NO;_toolCanvasHasHover=NO;_toolCanvasEditTime=kCMTimeInvalid;++_toolCanvasRevision;}[self postToolCanvasStatus:nil];
|
||||
}
|
||||
- (void)commitToolCanvasDraftAtTime:(CMTime)eventTime {
|
||||
NSDictionary *draft=nil,*original=nil;NSString *node=nil,*maskID=nil;CMTime time;uint64_t revision;
|
||||
@synchronized(self){if(!_toolCanvasDraft||!_toolCanvasOriginal)return;if(!CMTIME_IS_NUMERIC(eventTime)||CMTimeCompare(eventTime,_toolCanvasEditTime)!=0){[self discardToolCanvasDraft];[self postToolCanvasStatus:@"播放头已移动,请重新绘制。"];return;}draft=[_toolCanvasDraft copy];original=[_toolCanvasOriginal copy];node=[_selectedToolNode copy];maskID=[_selectedToolMask copy];time=_toolCanvasEditTime;
|
||||
NSDictionary *draft=nil,*original=nil;NSString *node=nil,*maskID=nil;CMTime time;uint64_t revision;BOOL sourceEdit;
|
||||
@synchronized(self){if(!_toolCanvasDraft||!_toolCanvasOriginal)return;if(!CMTIME_IS_NUMERIC(eventTime)||CMTimeCompare(eventTime,_toolCanvasEditTime)!=0){[self discardToolCanvasDraft];[self postToolCanvasStatus:@"播放头已移动,请重新绘制。"];return;}draft=[_toolCanvasDraft copy];original=[_toolCanvasOriginal copy];node=[_selectedToolNode copy];maskID=[_selectedToolMask copy];time=_toolCanvasEditTime;sourceEdit=_toolDragPart==DYCloneSourcePart;
|
||||
// Keep the completed path visible until the authoritative write returns.
|
||||
// Discarding it here exposed the new pen mask's default rectangular nodes
|
||||
// during the OSC redraw that immediately follows the closing click.
|
||||
@@ -22,12 +22,12 @@
|
||||
if(!CMTIME_IS_NUMERIC(a.currentTime)||CMTimeCompare(DYHostDisplayedFrameTime(self->_apiManager,a.currentTime),time)!=0){[self postToolCanvasStatus:@"播放头已移动,本次蒙版草稿未写入其它帧。"];return;}
|
||||
NSMutableDictionary *doc=DYMutablePlist(DYReadTools(self->_apiManager,time).document),*current=[self toolMask:maskID node:node document:doc];
|
||||
if(!current||![current isEqual:original]){os_log(OS_LOG_DEFAULT,"dayu_pen_commit conflict current=%{public}d",current!=nil);[self postToolCanvasStatus:@"蒙版已在其它位置修改,本次画面草稿未覆盖它。"];return;}
|
||||
NSMutableDictionary *result=DYMutablePlist(draft);
|
||||
if([current[@"keys"]count]){DYMaskParameters p=DYMaskAtTime(result,time);NSMutableArray *keys=[[current[@"keys"]mutableCopy]autorelease];NSIndexSet *same=[keys indexesOfObjectsPassingTest:^BOOL(NSDictionary *key,NSUInteger i,BOOL *stop){return CMTimeCompare(CMTimeMakeWithEpoch([key[@"value"]longLongValue],[key[@"scale"]intValue],[key[@"epoch"]longLongValue]),time)==0;}];[keys removeObjectsAtIndexes:same];[keys addObject:DYMaskKey(time,p,YES,1)];result[@"keys"]=@[];if(!DYMergeTracking(result,keys))return;}
|
||||
if(DYValidToolMask(result)&&![current isEqual:result]){[current setDictionary:result];id<FxUndoAPI>undo=[self->_apiManager apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:@"编辑工具蒙版"];changed=DYWriteTools(self->_apiManager,doc,time);[undo endUndoGroup];if(changed){DYToolDocument *saved=[[[DYToolDocument alloc]init]autorelease];saved.document=doc;[self adoptToolCanvasDocument:saved.document];}}
|
||||
NSMutableDictionary *result=sourceEdit?[[draft mutableCopy]autorelease]:DYMutablePlist(draft);
|
||||
if(!sourceEdit&&[current[@"keys"]count]){DYMaskParameters p=DYMaskAtTime(result,time);NSMutableArray *keys=[[current[@"keys"]mutableCopy]autorelease];NSIndexSet *same=[keys indexesOfObjectsPassingTest:^BOOL(NSDictionary *key,NSUInteger i,BOOL *stop){return CMTimeCompare(CMTimeMakeWithEpoch([key[@"value"]longLongValue],[key[@"scale"]intValue],[key[@"epoch"]longLongValue]),time)==0;}];[keys removeObjectsAtIndexes:same];[keys addObject:DYMaskKey(time,p,YES,1)];result[@"keys"]=@[];if(!DYMergeTracking(result,keys))return;}
|
||||
if(DYValidToolMask(result)&&![current isEqual:result]){[current setDictionary:result];id<FxUndoAPI>undo=[self->_apiManager apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:sourceEdit?@"移动图章取样点":@"编辑工具蒙版"];changed=DYWriteTools(self->_apiManager,doc,time);[undo endUndoGroup];if(changed){DYToolDocument *saved=[[[DYToolDocument alloc]init]autorelease];saved.document=doc;[self adoptToolCanvasDocument:saved.document];}}
|
||||
}@finally{[a endAction:self];}
|
||||
os_log(OS_LOG_DEFAULT,"dayu_pen_commit result=%{public}d valid=%{public}d",changed,DYValidToolMask(draft));
|
||||
if(changed)[self postToolCanvasStatus:@"蒙版已保存 · 可一次撤销"];
|
||||
if(changed)[self postToolCanvasStatus:sourceEdit?@"图章取样点已移动 · 可一次撤销":@"蒙版已保存 · 可一次撤销"];
|
||||
[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:self->_apiManager];
|
||||
}@finally{@synchronized(self){if(revision==self->_toolCanvasRevision){[self->_toolCanvasDraft release];self->_toolCanvasDraft=nil;[self->_toolCanvasOriginal release];self->_toolCanvasOriginal=nil;self->_toolCanvasEditTime=kCMTimeInvalid;}self->_toolCanvasCommitPending=NO;}[self postToolCanvasStatus:nil];}});[draft release];[original release];[node release];[maskID release];
|
||||
}
|
||||
@@ -74,6 +74,14 @@
|
||||
if(type==NSEventTypeLeftMouseDown){
|
||||
_toolCanvasHasHover=NO;
|
||||
if(_toolDrawingPen&&part==1000&&[_toolCanvasDraft[@"nodes"]length]>=3*sizeof(DYBezierNode)){[self commitToolCanvasDraftAtTime:time];return;}
|
||||
if(part==DYCloneSourcePart){
|
||||
NSDictionary *stamp=[self toolMask:_selectedToolMask node:_selectedToolNode document:_toolCanvasDocument];
|
||||
if([stamp[@"stampSource"]count]!=4)return;
|
||||
[self discardToolCanvasDraft];
|
||||
_toolCanvasOriginal=[stamp mutableCopy];_toolCanvasDraft=[stamp mutableCopy];_toolCanvasEditTime=time;
|
||||
_toolDragStart=point;_toolDragPart=part;
|
||||
return;
|
||||
}
|
||||
if(!_toolCanvasDraft){NSDictionary *mask=[self toolMask:_selectedToolMask node:_selectedToolNode document:_toolCanvasDocument];if(!mask)return;++_toolCanvasRevision;_toolCanvasOriginal=[DYMutablePlist(mask)retain];_toolCanvasDraft=[DYMutablePlist(mask)retain];_toolCanvasEditTime=time;_toolDragParameters=DYMaskAtTime(mask,time);_toolDragParameters.imageAspect=_toolSourceAspect>0?_toolSourceAspect:1;_toolCanvasDraft[@"parameters"]=[NSData dataWithBytes:&_toolDragParameters length:sizeof(DYMaskParameters)];_toolCanvasDraft[@"keys"]=@[];if(_toolDrawingPen)_toolCanvasDraft[@"nodes"]=[NSData data];}
|
||||
if(CMTimeCompare(time,_toolCanvasEditTime)!=0){[self discardToolCanvasDraft];[self postToolCanvasStatus:@"播放头已移动,请重新绘制。"];return;}
|
||||
_toolDragStart=point;_toolDragPart=part;_toolDragParameters=DYMaskAtTime(_toolCanvasDraft,time);
|
||||
@@ -83,6 +91,14 @@
|
||||
if(!_toolCanvasDraft)return;
|
||||
if(CMTimeCompare(time,_toolCanvasEditTime)!=0){[self discardToolCanvasDraft];return;}
|
||||
if(_toolDrawingShape&&(type==NSEventTypeLeftMouseDragged||type==NSEventTypeLeftMouseUp)){[self updateToolShapeDraftAtPoint:point];if(type==NSEventTypeLeftMouseUp){DYMaskParameters p=DYMaskAtTime(_toolCanvasDraft,time);if(p.width<=.001f||p.height<=.001f){[self discardToolCanvasDraft];[self postToolCanvasStatus:@"未拖出有效区域,原蒙版已保留。"];return;}[self commitToolCanvasDraftAtTime:time];}return;}
|
||||
if(_toolDragPart==DYCloneSourcePart&&(type==NSEventTypeLeftMouseDragged||type==NSEventTypeLeftMouseUp)){
|
||||
NSArray *source=_toolCanvasOriginal[@"stampSource"];
|
||||
double x=fmax(0,fmin(1,[source[0]doubleValue]+(point.x-_toolDragStart.x)));
|
||||
double y=fmax(0,fmin(1,[source[1]doubleValue]+(point.y-_toolDragStart.y)));
|
||||
_toolCanvasDraft[@"stampSource"]=@[@(x),@(y),source[2],source[3]];
|
||||
if(type==NSEventTypeLeftMouseUp)[self commitToolCanvasDraftAtTime:time];
|
||||
return;
|
||||
}
|
||||
if(type==NSEventTypeLeftMouseDragged){_toolCanvasHasHover=NO;DYMaskParameters p=_toolDragParameters;float dx=point.x-_toolDragStart.x,dy=point.y-_toolDragStart.y;
|
||||
if(_toolDrawingPen||_toolDragPart>=1000){NSMutableData *data=[[_toolCanvasDraft[@"nodes"]mutableCopy]autorelease];NSUInteger count=data.length/sizeof(DYBezierNode);if(count){auto *nodes=(DYBezierNode*)data.mutableBytes;NSUInteger index=_toolDrawingPen?count-1:(_toolDragPart-1000)/3,handle=_toolDrawingPen?2:(_toolDragPart-1000)%3;float a=p.imageAspect,c=cos(p.angle),s=sin(p.angle),x=((point.x-p.centerX)*a*c+(point.y-p.centerY)*s)/(p.width*a),y=(-(point.x-p.centerX)*a*s+(point.y-p.centerY)*c)/p.height;if(index<count){if(handle==0){float mx=x-nodes[index].x,my=y-nodes[index].y;nodes[index].x=x;nodes[index].y=y;nodes[index].inX+=mx;nodes[index].inY+=my;nodes[index].outX+=mx;nodes[index].outY+=my;}else if(handle==1){nodes[index].inX=x;nodes[index].inY=y;}else{nodes[index].outX=x;nodes[index].outY=y;if(_toolDrawingPen){nodes[index].inX=2*nodes[index].x-x;nodes[index].inY=2*nodes[index].y-y;}}_toolCanvasDraft[@"nodes"]=data;}}}
|
||||
else if(_toolDragPart==6)p.angle=atan2((point.y-p.centerY),(point.x-p.centerX)*p.imageAspect)+M_PI/2;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
static const NSInteger DYCloneSourcePart=7;
|
||||
@class DYPlugIn;
|
||||
static NSMapTable *DYToolCanvasSessions(void){static NSMapTable *map;static dispatch_once_t once;dispatch_once(&once,^{map=[[NSMapTable strongToWeakObjectsMapTable]retain];});return map;}
|
||||
@interface DYPlugIn (ToolCanvas)
|
||||
|
||||
+10
-3
@@ -36,8 +36,11 @@
|
||||
- (NSRect)stampTarget{
|
||||
return NSMakeRect(MIN(_stampStart.x,_stampEnd.x),MIN(_stampStart.y,_stampEnd.y),fabs(_stampStart.x-_stampEnd.x),fabs(_stampStart.y-_stampEnd.y));
|
||||
}
|
||||
- (NSPoint)canvasStampSource:(NSPoint)source{
|
||||
return NSMakePoint(NSMinX(_imageRect)+source.x*NSWidth(_imageRect),NSMinY(_imageRect)+source.y*NSHeight(_imageRect));
|
||||
}
|
||||
- (void)drawStampSource:(NSPoint)source{
|
||||
NSPoint p=NSMakePoint(NSMinX(_imageRect)+source.x*NSWidth(_imageRect),NSMinY(_imageRect)+source.y*NSHeight(_imageRect));
|
||||
NSPoint p=[self canvasStampSource:source];
|
||||
CGFloat r=8*_uiScale;
|
||||
NSBezierPath *mark=[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(p.x-r,p.y-r,2*r,2*r)];
|
||||
[mark moveToPoint:NSMakePoint(p.x-r,p.y)];[mark lineToPoint:NSMakePoint(p.x+r,p.y)];
|
||||
@@ -110,9 +113,13 @@
|
||||
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(_viewerControls.stampArmed)return NSPointInRect(point,_imageRect)?10014:0;
|
||||
if([_mask[@"stampSource"]count]==4){
|
||||
NSInteger count=[_mask[@"tracking"]boolValue]?1:3;
|
||||
NSArray *source=_mask[@"stampSource"];
|
||||
if(source.count==4){
|
||||
BOOL tracking=[_mask[@"tracking"]boolValue];
|
||||
NSInteger count=tracking?1:3;
|
||||
for(NSInteger i=0;i<count;i++)if(NSPointInRect(point,[self stampControlRect:i]))return 10011+i;
|
||||
NSPoint cross=[self canvasStampSource:NSMakePoint([source[0]doubleValue],[source[1]doubleValue])];
|
||||
if(!tracking&&NSPointInRect(point,_imageRect)&&hypot(cross.x-point.x,cross.y-point.y)<=12*_uiScale)return DYCloneSourcePart;
|
||||
}
|
||||
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);
|
||||
|
||||
+3
-3
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.13.0</string>
|
||||
<string>1.13.1</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>83</string>
|
||||
<string>84</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<key>PlugInKit</key>
|
||||
@@ -71,7 +71,7 @@
|
||||
<key>uuid</key>
|
||||
<string>1C17B73B-F229-4C09-A434-EAF6DFF5F22A</string>
|
||||
<key>version</key>
|
||||
<string>1.13.0</string>
|
||||
<string>1.13.1</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>className</key>
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.13.0</string>
|
||||
<string>1.13.1</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>83</string>
|
||||
<string>84</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
在新工单中引用
屏蔽一个用户