Keep clone stamp preview through host save and use the action clock
这个提交包含在:
1 父节点
df9b3c0253
当前提交
5032ce70ab
6 个文件已更改
+98
-40
没有与搜索条件相匹配的文件
@@ -23,32 +23,48 @@
|
||||
NSString *node=notification.userInfo[@"node"],*mask=notification.userInfo[@"mask"];if(!node||!mask)return;NSDictionary *document=notification.userInfo[@"document"];if(document&&DYValidToolDocument(document)){DYToolDocument *immutable=[[[DYToolDocument alloc]init]autorelease];immutable.document=document;[self adoptToolCanvasDocument:immutable.document];}os_log(OS_LOG_DEFAULT,"dayu_tool_canvas_selected");
|
||||
@synchronized(self){if(DYSharedMaskWithID(_toolCanvasDocument,mask))node=@"shared";if(_trackingActive.load()&&(![_trackingNode isEqual:node]||![_trackingMaskID isEqual:mask])){_trackingCancelled.store(true);_trackingDiscard=YES;}[_selectedToolNode release];_selectedToolNode=[node copy];[_selectedToolMask release];_selectedToolMask=[mask copy];_toolCanvasHidden=[notification.userInfo[@"hidden"]boolValue];_toolDrawingPen=[notification.userInfo[@"draw"]boolValue];NSDictionary *shape=[self toolMask:mask node:node document:_toolCanvasDocument];DYMaskParameters shapeParameters=DYMaskAtTime(shape,kCMTimeInvalid);_toolDrawingShape=shape&&shapeParameters.kind<2&&[notification.userInfo[@"drawShape"]boolValue];if(_toolDrawingShape)_toolDrawingPen=NO;++_toolCanvasRevision;_toolCanvasEditTime=kCMTimeInvalid;_toolDragPart=0;_toolCanvasHasHover=NO;[_toolCanvasDraft release];_toolCanvasDraft=nil;[_toolCanvasOriginal release];_toolCanvasOriginal=nil;}[self postToolCanvasStatus:_toolDrawingPen?@"钢笔:点击放点,拖出曲柄;点首节点或完成绘制闭合。":_toolDrawingShape?@"在画面按下并拖出蒙版区域;Esc 取消。":@"已选中本层蒙版"];
|
||||
}
|
||||
- (void)addCloneStampFrom:(NSPoint)source target:(NSRect)target atTime:(CMTime)time {
|
||||
- (void)addCloneStampFrom:(NSPoint)source target:(NSRect)target atTime:(CMTime)time completion:(void (^)(NSString *failure))completion {
|
||||
dispatch_async(dispatch_get_main_queue(),^{
|
||||
if(self->_trackingActive.load()||!CMTIME_IS_NUMERIC(time))return;
|
||||
if(self->_trackingActive.load()){completion(@"请先停止跟踪,再绘制图章。");return;}
|
||||
id<FxCustomParameterActionAPI_v4>action=[self->_apiManager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];
|
||||
if(!action)return;
|
||||
if(!action){completion(@"宿主暂时无法保存图章,请重试。");return;}
|
||||
NSDictionary *selection=nil;
|
||||
NSString *failure=nil;
|
||||
[action startAction:self];@try{
|
||||
if(CMTimeCompare(DYHostDisplayedFrameTime(self->_apiManager,action.currentTime),time)!=0)return;
|
||||
NSMutableDictionary *doc=DYMutablePlist(DYReadTools(self->_apiManager,time).document);
|
||||
NSMutableDictionary *stamp=(id)DYAddSharedMask(doc,DYMaskEllipse);
|
||||
if(!stamp){NSBeep();return;}
|
||||
DYMaskParameters p=DYMaskAtTime(stamp,kCMTimeInvalid);
|
||||
p.centerX=NSMidX(target);p.centerY=NSMidY(target);p.width=target.size.width;p.height=target.size.height;
|
||||
stamp[@"parameters"]=[NSData dataWithBytes:&p length:sizeof(p)];
|
||||
stamp[@"stampSource"]=@[@(source.x),@(source.y),@(p.width),@(p.height)];
|
||||
id<FxUndoAPI>undo=[self->_apiManager apiForProtocol:@protocol(FxUndoAPI)];
|
||||
BOOL grouped=[undo startUndoGroup:@"创建仿制图章"];
|
||||
if(DYWriteTools(self->_apiManager,doc,time))selection=@{@"node":@"shared",@"mask":stamp[@"id"],@"document":doc};
|
||||
else NSBeep();
|
||||
if(grouped)[undo endUndoGroup];
|
||||
// A new stamp is clip-wide. The OSC supplies geometry, while the action
|
||||
// supplies the time for accessing this instance's non-animatable document.
|
||||
CMTime writeTime=DYHostDisplayedFrameTime(self->_apiManager,action.currentTime);
|
||||
id<FxParameterRetrievalAPI_v6>get=[self->_apiManager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)];
|
||||
DYToolDocument *stored=nil;
|
||||
if(!CMTIME_IS_NUMERIC(writeTime)||![get getCustomParameterValue:&stored fromParameter:DYToolsParameterID atTime:writeTime]||![stored isKindOfClass:DYToolDocument.class]){
|
||||
failure=@"宿主暂时无法读取当前图章,请重试。";
|
||||
}else{
|
||||
NSMutableDictionary *doc=DYMutablePlist(stored.document);
|
||||
NSMutableDictionary *stamp=(id)DYAddSharedMask(doc,DYMaskEllipse);
|
||||
if(!stamp){
|
||||
failure=DYSharedMasks(doc).count>=DYSharedMaskLimit?@"已达到蒙版与图章数量上限。":@"无法在当前效果中创建图章。";
|
||||
}else{
|
||||
DYMaskParameters p=DYMaskAtTime(stamp,kCMTimeInvalid);
|
||||
p.centerX=NSMidX(target);p.centerY=NSMidY(target);p.width=target.size.width;p.height=target.size.height;
|
||||
stamp[@"parameters"]=[NSData dataWithBytes:&p length:sizeof(p)];
|
||||
stamp[@"stampSource"]=@[@(source.x),@(source.y),@(p.width),@(p.height)];
|
||||
id<FxUndoAPI>undo=[self->_apiManager apiForProtocol:@protocol(FxUndoAPI)];
|
||||
BOOL grouped=[undo startUndoGroup:@"创建仿制图章"];
|
||||
@try{
|
||||
if(DYWriteTools(self->_apiManager,doc,writeTime))selection=@{@"node":@"shared",@"mask":stamp[@"id"],@"document":doc};
|
||||
else failure=@"宿主未保存图章,请重新拖出覆盖区。";
|
||||
}@finally{if(grouped)[undo endUndoGroup];}
|
||||
}
|
||||
}
|
||||
os_log(OS_LOG_DEFAULT,"dayu_clone_commit accepted=%{public}d osc=%{public}.9f action=%{public}.9f",
|
||||
selection!=nil,CMTimeGetSeconds(time),CMTimeGetSeconds(writeTime));
|
||||
}@finally{[action endAction:self];}
|
||||
if(selection){
|
||||
[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:self->_apiManager];
|
||||
[NSNotificationCenter.defaultCenter postNotificationName:@"DYToolCanvasSelection" object:self->_apiManager userInfo:selection];
|
||||
[self postToolCanvasStatus:@"仿制图章已保存 · 可跟踪目标区域"];
|
||||
}
|
||||
}else [self postToolCanvasStatus:failure];
|
||||
completion(failure);
|
||||
});
|
||||
}
|
||||
- (void)trackCloneStamp:(NSString*)stampID direction:(NSInteger)direction{
|
||||
|
||||
在新工单中引用
屏蔽一个用户