Draw tracking progress directly from the completed frame count
这个提交包含在:
1 父节点
d2b6f8ef81
当前提交
6515e0fa67
4 个文件已更改
+36
-15
没有与搜索条件相匹配的文件
@@ -74,6 +74,34 @@
|
||||
}
|
||||
@end
|
||||
|
||||
@interface DYTrackingProgressBar : NSView
|
||||
@property(nonatomic) double doubleValue;
|
||||
@end
|
||||
|
||||
@implementation DYTrackingProgressBar
|
||||
- (BOOL)isAccessibilityElement {return YES;}
|
||||
- (NSString *)accessibilityRole {return NSAccessibilityProgressIndicatorRole;}
|
||||
- (id)accessibilityValue {return @(_doubleValue);}
|
||||
- (id)accessibilityMinValue {return @0;}
|
||||
- (id)accessibilityMaxValue {return @1;}
|
||||
- (void)setDoubleValue:(double)value {
|
||||
_doubleValue=std::clamp(value,0.,1.);
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
- (void)drawRect:(NSRect)dirty {
|
||||
NSRect rail=NSInsetRect(self.bounds,0,2);
|
||||
CGFloat radius=NSHeight(rail)/2;
|
||||
NSBezierPath *track=[NSBezierPath bezierPathWithRoundedRect:rail xRadius:radius yRadius:radius];
|
||||
[[[NSColor labelColor] colorWithAlphaComponent:.18] setFill];
|
||||
[track fill];
|
||||
if(_doubleValue<=0)return;
|
||||
[NSGraphicsContext saveGraphicsState];[track addClip];
|
||||
NSRect fill=rail;fill.size.width*=_doubleValue;
|
||||
[NSColor.controlAccentColor setFill];NSRectFill(fill);
|
||||
[NSGraphicsContext restoreGraphicsState];
|
||||
}
|
||||
@end
|
||||
|
||||
@interface DYTrackingPreview : NSView
|
||||
- (instancetype)initWithTarget:(id)target action:(SEL)action;
|
||||
- (void)applyUpdate:(NSDictionary *)info;
|
||||
@@ -86,7 +114,7 @@
|
||||
DYTrackingPreviewImage *_preview;
|
||||
NSTextField *_title,*_detail,*_status;
|
||||
NSButton *_action;
|
||||
NSProgressIndicator *_progress;
|
||||
DYTrackingProgressBar *_progress;
|
||||
NSString *_maskID;
|
||||
BOOL _running;
|
||||
}
|
||||
@@ -101,8 +129,7 @@
|
||||
_detail=[DYThemeLabel labelWithString:@""];_detail.font=[NSFont monospacedDigitSystemFontOfSize:10 weight:NSFontWeightRegular];
|
||||
_status=[DYThemeLabel labelWithString:@""];_status.font=[NSFont systemFontOfSize:11];_status.maximumNumberOfLines=2;_status.lineBreakMode=NSLineBreakByWordWrapping;
|
||||
_action=DYWorkspaceButton(@"停止跟踪",target,action);
|
||||
_progress=[[[NSProgressIndicator alloc]init]autorelease];_progress.style=NSProgressIndicatorStyleBar;
|
||||
_progress.controlSize=NSControlSizeSmall;_progress.indeterminate=NO;_progress.minValue=0;_progress.maxValue=1;_progress.accessibilityLabel=@"跟踪进度";
|
||||
_progress=[[[DYTrackingProgressBar alloc]init]autorelease];_progress.accessibilityLabel=@"跟踪进度";
|
||||
_preview=[[[DYTrackingPreviewImage alloc]init]autorelease];[_preview showFrame:nil];
|
||||
for(NSView *view in @[_title,_detail,_status,_action,_progress,_preview])[self addSubview:view];
|
||||
self.hidden=YES;
|
||||
@@ -130,17 +157,11 @@
|
||||
_detail.stringValue=[NSString stringWithFormat:@"%.3fs %@",[info[@"time"] doubleValue],stamp?@"青色取样 · 黄色覆盖":@"黄色轮廓"];
|
||||
}
|
||||
NSUInteger total=[info[@"total"] unsignedIntegerValue];
|
||||
if(active){
|
||||
if(_progress.indeterminate!=(total==0)){
|
||||
_progress.indeterminate=total==0;
|
||||
if(total)[_progress stopAnimation:nil];else [_progress startAnimation:nil];
|
||||
}
|
||||
_progress.doubleValue=total?[info[@"completed"] doubleValue]/total:0;
|
||||
}else [_progress stopAnimation:nil];
|
||||
if(active)_progress.doubleValue=total?[info[@"completed"] doubleValue]/total:0;
|
||||
_running=active;_action.title=active?@"停止跟踪":@"返回示波器";_action.accessibilityLabel=_action.title;
|
||||
_status.stringValue=info[@"message"]?:@"";_status.toolTip=_status.stringValue;
|
||||
}
|
||||
- (void)reset {
|
||||
[_progress stopAnimation:nil];_progress.indeterminate=NO;[_preview showFrame:nil];[_maskID release];_maskID=nil;_running=NO;self.hidden=YES;
|
||||
_progress.doubleValue=0;[_preview showFrame:nil];[_maskID release];_maskID=nil;_running=NO;self.hidden=YES;
|
||||
}
|
||||
@end
|
||||
在新工单中引用
屏蔽一个用户