WIP: native per-layer controls, host OSC and Metal mask tracking; GPU and callback regressions added, formal host acceptance pending
这个提交包含在:
1 父节点
f72aa2609d
当前提交
cec044f124
26 个文件已更改
+475
-40
没有与搜索条件相匹配的文件
@@ -12,6 +12,10 @@
|
||||
@synthesize contentHeight=_contentHeight;
|
||||
- (instancetype)initWithManager:(id<PROAPIAccessing>)manager nodeID:(NSString*)nodeID{
|
||||
if((self=[super initWithFrame:NSZeroRect])){_host=manager;_nodeID=[nodeID copy];_rows=[NSMutableArray new];_tracking=[NSMutableArray new];self.identifier=@"toolMasks";
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(trackingStatus:) name:@"DYToolTrackingStatus" object:_host];
|
||||
}return self;
|
||||
}
|
||||
- (void)buildControls{if(_list)return;
|
||||
_list=[[NSPopUpButton alloc]initWithFrame:NSZeroRect pullsDown:NO];_list.target=self;_list.action=@selector(selection:);_list.font=[NSFont systemFontOfSize:10];_list.accessibilityLabel=@"本层蒙版";[self addSubview:_list];
|
||||
_eye=[DYButton(@"",self,@selector(enabled:))retain];_eye.image=[NSImage imageWithSystemSymbolName:@"eye" accessibilityDescription:@"蒙版启用"];_eye.bordered=NO;[_eye setButtonType:NSButtonTypePushOnPushOff];[self addSubview:_eye];
|
||||
_add=[DYButton(@"+",self,@selector(add:))retain];_add.toolTip=@"再添加一个蒙版";_add.accessibilityLabel=_add.toolTip;[self addSubview:_add];
|
||||
@@ -25,23 +29,21 @@
|
||||
NSArray *titles=@[@"◀ 单帧",@"◀ 跟踪",@"双向",@"跟踪 ▶",@"单帧 ▶",@"取消"];
|
||||
for(int i=0;i<6;i++){NSButton *b=DYButton(titles[i],self,@selector(track:));b.tag=((int[]){-2,-1,0,1,2,9})[i];b.font=[NSFont systemFontOfSize:9];b.accessibilityLabel=@[@"反向跟踪一帧",@"反向蒙版跟踪",@"双向蒙版跟踪",@"正向蒙版跟踪",@"正向跟踪一帧",@"取消蒙版跟踪"][i];[self addSubview:b];[_tracking addObject:b];}
|
||||
_status=[DYLabel(@"",10)retain];_status.maximumNumberOfLines=2;[self addSubview:_status];_contentHeight=0;
|
||||
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(trackingStatus:) name:@"DYToolTrackingStatus" object:_host];
|
||||
}return self;
|
||||
}
|
||||
- (void)dealloc{[NSNotificationCenter.defaultCenter removeObserver:self];[_nodeID release];[_maskID release];[_document release];[_list release];[_combine release];[_eye release];[_add release];[_remove release];[_invert release];[_canvas release];[_clear release];[_rows release];[_tracking release];[_status release];[super dealloc];}
|
||||
- (NSDictionary*)mask{for(NSDictionary *m in DYMasksForTool(_document,_nodeID))if([m[@"id"]isEqual:_maskID])return m;return nil;}
|
||||
- (void)refreshWithDocument:(NSDictionary*)doc time:(CMTime)time{
|
||||
_refreshing=YES;NSDictionary *saved=[doc copy];[_document release];_document=saved;_time=time;NSArray *masks=DYMasksForTool(doc,_nodeID);[_list removeAllItems];NSInteger selected=0,index=0;
|
||||
_refreshing=YES;NSDictionary *saved=[doc copy];[_document release];_document=saved;_time=time;NSArray *masks=DYMasksForTool(doc,_nodeID);if(masks.count)[self buildControls];[_list removeAllItems];NSInteger selected=0,index=0;
|
||||
for(NSDictionary *m in masks){DYMaskParameters p=DYMaskAtTime(m,time);[_list addItemWithTitle:[NSString stringWithFormat:@"%@ %ld",@[@"椭圆",@"矩形",@"钢笔",@"线性渐变",@"HSL 选区",@"亮度选区"][p.kind],(long)index+1]];if([m[@"id"]isEqual:_maskID])selected=index;index++;}
|
||||
if(!masks.count){_contentHeight=0;_refreshing=NO;return;}[_list selectItemAtIndex:selected];[_maskID release];_maskID=[masks[selected][@"id"]copy];NSDictionary *m=[self mask];DYMaskParameters p=DYMaskAtTime(m,time);
|
||||
_eye.state=[m[@"enabled"]boolValue]?NSControlStateValueOn:NSControlStateValueOff;_eye.image=[NSImage imageWithSystemSymbolName:[m[@"enabled"]boolValue]?@"eye":@"eye.slash" accessibilityDescription:@"启用蒙版"];[_combine selectItemAtIndex:[m[@"combine"]integerValue]];_invert.state=(p.flags&DYMaskInvert)?NSControlStateValueOn:NSControlStateValueOff;
|
||||
float values[]={p.strength,p.feather,p.centerX,p.centerY,p.width,p.height,float(p.angle*180.f/M_PI),p.gradientWidth,p.hueCenterTurns*360.f,p.hueCoreHalfWidth*360.f,p.hueSoftWidth*360.f,p.saturationRange.low,p.saturationRange.high,p.lightnessRange.low,p.lightnessRange.high,p.inputBlack,p.inputWhite,p.inputGamma};
|
||||
NSInteger visible=0;for(NSInteger i=0;i<_rows.count;i++){BOOL show=i==0||(i==1&&p.kind<3)||(i>=2&&i<=6&&p.kind<4)||(i==7&&p.kind==3)||(i>=8&&i<=14&&p.kind==4)||(i>=15&&p.kind>=4);NSDictionary *row=_rows[i];for(NSView *v in row.allValues)v.hidden=!show;if(!show)continue;visible++;double lo=0,hi=1;if(i==2||i==3)lo=-1,hi=2;if(i==4||i==5||i==7)lo=.001,hi=2;if(i==6)lo=-180,hi=180;if(i==8)hi=360;if(i==9||i==10)hi=180;if(i==15)hi=.99;if(i==16)lo=.01,hi=2;if(i==17)lo=.01,hi=4;NSSlider *slider=row[@"slider"];slider.minValue=lo;slider.maxValue=hi;slider.doubleValue=values[i];[row[@"field"]setStringValue:[NSString stringWithFormat:@"%.3f",values[i]]];}
|
||||
BOOL shape=p.kind<3;for(NSButton *b in _tracking)b.hidden=!shape;_clear.hidden=!shape;_clear.enabled=[m[@"keys"]count]>0;
|
||||
_status.stringValue=m[@"status"]?:([m[@"keys"]count]?[NSString stringWithFormat:@"%lu 个轨迹键 · 修改几何会在当前帧建立手工键",(unsigned long)[m[@"keys"]count]]:p.kind==2?@"画面编辑:拖动节点;⌘ 点击加点,回车闭合。":@"各蒙版只影响当前工具层");
|
||||
_status.stringValue=m[@"status"]?:([m[@"keys"]count]?[NSString stringWithFormat:@"%lu 个轨迹键 · 修改几何会在当前帧建立手工键",(unsigned long)[m[@"keys"]count]]:p.kind==2?@"钢笔:在画面工具栏选择钢笔重画,回车闭合;拖动节点和手柄。":@"各蒙版只影响当前工具层");
|
||||
_contentHeight=108+visible*27+(shape?63:0)+36;[self setNeedsLayout:YES];_refreshing=NO;
|
||||
}
|
||||
- (void)layout{[super layout];CGFloat w=self.bounds.size.width;_eye.frame=NSMakeRect(0,2,20,24);_list.frame=NSMakeRect(22,1,MAX(60,w-82),26);_add.frame=NSMakeRect(w-57,1,26,25);_remove.frame=NSMakeRect(w-29,1,26,25);_combine.frame=NSMakeRect(0,33,83,25);_invert.frame=NSMakeRect(88,34,58,23);_canvas.frame=NSMakeRect(w-94,33,94,25);CGFloat y=67;for(NSDictionary *r in _rows){NSTextField *label=r[@"label"];if(label.hidden)continue;label.frame=NSMakeRect(2,y+4,68,18);[r[@"slider"]setFrame:NSMakeRect(72,y+4,MAX(20,w-133),18)];[r[@"field"]setFrame:NSMakeRect(w-57,y+1,55,23)];y+=27;}if(![_tracking[0]isHidden]){CGFloat bw=(w-8)/3;for(int i=0;i<6;i++)[_tracking[i]setFrame:NSMakeRect((i%3)*(bw+4),y+(i/3)*28,bw,25)];y+=58;_clear.frame=NSMakeRect(0,y,w,25);y+=29;}_status.frame=NSMakeRect(2,y+2,w-4,33);}
|
||||
- (void)layout{[super layout];CGFloat w=self.bounds.size.width;_eye.frame=NSMakeRect(0,2,20,24);_list.frame=NSMakeRect(22,1,MAX(60,w-82),26);_add.frame=NSMakeRect(w-57,1,26,25);_remove.frame=NSMakeRect(w-29,1,26,25);_combine.frame=NSMakeRect(0,33,83,25);_invert.frame=NSMakeRect(88,34,58,23);_canvas.frame=NSMakeRect(w-94,33,94,25);CGFloat y=67;for(NSDictionary *r in _rows){NSTextField *label=r[@"label"];if(label.hidden)continue;label.frame=NSMakeRect(2,y+4,68,18);[r[@"slider"]setFrame:NSMakeRect(72,y+4,MAX(20,w-133),18)];[r[@"field"]setFrame:NSMakeRect(w-57,y+1,55,23)];y+=27;}if(_tracking.count&&![_tracking[0]isHidden]){CGFloat bw=(w-8)/3;for(int i=0;i<6;i++)[_tracking[i]setFrame:NSMakeRect((i%3)*(bw+4),y+(i/3)*28,bw,25)];y+=58;_clear.frame=NSMakeRect(0,y,w,25);y+=29;}_status.frame=NSMakeRect(2,y+2,w-4,33);}
|
||||
- (void)edit:(NSString*)title block:(void (^)(NSMutableDictionary*,NSMutableDictionary*))block{
|
||||
id<FxCustomParameterActionAPI_v4>a=[_host apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];if(!a)return;[a startAction:self];@try{NSMutableDictionary *doc=DYMutablePlist(DYReadTools(_host,a.currentTime).document);NSMutableArray *masks=(id)DYMasksForTool(doc,_nodeID);NSMutableDictionary *mask=nil;for(NSMutableDictionary *m in masks)if([m[@"id"]isEqual:_maskID])mask=m;if(!mask)return;block(doc,mask);if(!DYValidToolDocument(doc)){NSBeep();return;}id<FxUndoAPI>undo=[_host apiForProtocol:@protocol(FxUndoAPI)];[undo startUndoGroup:title];DYWriteTools(_host,doc,a.currentTime);[undo endUndoGroup];}@finally{[a endAction:self];}[NSNotificationCenter.defaultCenter postNotificationName:DYModelChanged object:_host];}
|
||||
- (void)add:(id)sender{[self addMenu:_add];}
|
||||
|
||||
在新工单中引用
屏蔽一个用户