fix: expose scrolling inspector controls to host accessibility and constrain drawing
这个提交包含在:
1 父节点
2330eb737e
当前提交
ce7e0a3371
8 个文件已更改
+597
-6
没有与搜索条件相匹配的文件
+69
-3
@@ -39,9 +39,54 @@ static NSString *DYNumber(double value,NSDictionary *d) {
|
||||
}
|
||||
@end
|
||||
|
||||
// FxPlug's remote view bridge needs an explicit container tree; an ignored
|
||||
// NSView document can otherwise make a populated NSScrollView appear empty.
|
||||
static NSArray *DYAccessibleSubviews(NSView *view, BOOL visibleOnly) {
|
||||
NSMutableArray *children=[NSMutableArray array];
|
||||
NSRect visible=view.visibleRect;
|
||||
for(NSView *child in view.subviews) {
|
||||
if(child.hidden)continue;
|
||||
if(visibleOnly&&!NSIntersectsRect(child.frame,visible))continue;
|
||||
[children addObject:child];
|
||||
}
|
||||
return NSAccessibilityUnignoredChildren(children);
|
||||
}
|
||||
|
||||
@interface DYFlippedView : NSView @end
|
||||
@implementation DYFlippedView
|
||||
- (instancetype)initWithFrame:(NSRect)frame {
|
||||
if((self=[super initWithFrame:frame]))self.clipsToBounds=YES;
|
||||
return self;
|
||||
}
|
||||
- (BOOL)isFlipped { return YES; }
|
||||
- (BOOL)isAccessibilityElement { return YES; }
|
||||
- (NSAccessibilityRole)accessibilityRole { return NSAccessibilityGroupRole; }
|
||||
- (NSArray *)accessibilityChildren { return DYAccessibleSubviews(self,NO); }
|
||||
- (NSArray *)accessibilityVisibleChildren { return DYAccessibleSubviews(self,YES); }
|
||||
- (NSArray *)accessibilityChildrenInNavigationOrder { return self.accessibilityChildren; }
|
||||
- (void)viewDidMoveToWindow {
|
||||
[super viewDidMoveToWindow];
|
||||
// The ancestor is layer backed. Keep AppKit's drawing clip and the layer
|
||||
// clip aligned without creating a separate layer for every control row.
|
||||
if(self.layer)self.layer.masksToBounds=YES;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface DYInspectorScrollView : NSScrollView @end
|
||||
@implementation DYInspectorScrollView
|
||||
- (BOOL)isAccessibilityElement { return YES; }
|
||||
- (NSAccessibilityRole)accessibilityRole { return NSAccessibilityScrollAreaRole; }
|
||||
- (NSArray *)accessibilityContents { return self.documentView?@[self.documentView]:@[]; }
|
||||
- (NSArray *)accessibilityChildren {
|
||||
NSMutableArray *children=[NSMutableArray arrayWithArray:self.accessibilityContents];
|
||||
NSScroller *vertical=self.verticalScroller,*horizontal=self.horizontalScroller;
|
||||
if(self.hasVerticalScroller&&vertical&&!vertical.hidden)[children addObject:vertical];
|
||||
if(self.hasHorizontalScroller&&horizontal&&!horizontal.hidden)[children addObject:horizontal];
|
||||
return NSAccessibilityUnignoredChildren(children);
|
||||
}
|
||||
- (NSArray *)accessibilityVisibleChildren { return self.accessibilityChildren; }
|
||||
- (NSArray *)accessibilityChildrenInNavigationOrder { return self.accessibilityChildren; }
|
||||
- (id)accessibilityVerticalScrollBar { return self.hasVerticalScroller?self.verticalScroller:nil; }
|
||||
@end
|
||||
|
||||
@interface DYCard : DYFlippedView @end
|
||||
@@ -281,7 +326,9 @@ static NSImage *DYWheelImage(void) {
|
||||
_cards=[[NSMutableArray alloc] init]; _controls=[[NSMutableDictionary alloc] init];
|
||||
_assetButtons=[[NSMutableDictionary alloc] init]; _graphics=[[NSMutableArray alloc] init];
|
||||
self.autoresizingMask=NSViewWidthSizable;
|
||||
self.wantsLayer=YES; self.layer.backgroundColor=[[NSColor colorWithSRGBRed:.018 green:.074 blue:.12 alpha:1] CGColor];
|
||||
self.clipsToBounds=YES;
|
||||
self.wantsLayer=YES; self.layer.masksToBounds=YES;
|
||||
self.layer.backgroundColor=[[NSColor colorWithSRGBRed:.018 green:.074 blue:.12 alpha:1] CGColor];
|
||||
_brand=[DYLabel(@"大鱼调色",20) retain]; _brand.font=[NSFont boldSystemFontOfSize:20];
|
||||
_subtitle=[DYLabel(@"颜色 · 光影 · 风格",10) retain]; _subtitle.textColor=DYAccent();
|
||||
_resetAll=[DYButton(@"全部还原",self,@selector(resetAll:)) retain]; _resetAll.toolTip=@"恢复全部调色参数与 LUT";
|
||||
@@ -289,10 +336,15 @@ static NSImage *DYWheelImage(void) {
|
||||
_load=[DYButton(@"载入预设",self,@selector(loadPreset:)) retain];
|
||||
_export=[DYButton(@"导出 LUT",self,@selector(exportLUT:)) retain];
|
||||
for(NSView *v in @[_brand,_subtitle,_resetAll,_save,_load,_export]) [self addSubview:v];
|
||||
_scroll=[[NSScrollView alloc] initWithFrame:NSZeroRect];
|
||||
_scroll=[[DYInspectorScrollView alloc] initWithFrame:NSZeroRect];
|
||||
_scroll.hasVerticalScroller=YES; _scroll.hasHorizontalScroller=NO; _scroll.drawsBackground=NO;
|
||||
_scroll.autohidesScrollers=YES; _scroll.borderType=NSNoBorder;
|
||||
_scroll.clipsToBounds=YES;_scroll.wantsLayer=YES;_scroll.layer.masksToBounds=YES;
|
||||
_scroll.contentView.clipsToBounds=YES;
|
||||
_scroll.contentView.wantsLayer=YES;_scroll.contentView.layer.masksToBounds=YES;
|
||||
_scroll.accessibilityLabel=@"调色参数滚动区";
|
||||
_document=[[DYFlippedView alloc] initWithFrame:NSMakeRect(0,0,360,1000)];
|
||||
_document.accessibilityLabel=@"调色参数";
|
||||
_scroll.documentView=_document; [self addSubview:_scroll];
|
||||
[self buildCards];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modelChanged:) name:@"DYModelChanged" object:_manager];
|
||||
@@ -308,8 +360,19 @@ static NSImage *DYWheelImage(void) {
|
||||
[super dealloc];
|
||||
}
|
||||
- (BOOL)isFlipped { return YES; }
|
||||
- (BOOL)isAccessibilityElement { return YES; }
|
||||
- (NSAccessibilityRole)accessibilityRole { return NSAccessibilityGroupRole; }
|
||||
- (NSArray *)accessibilityChildren { return DYAccessibleSubviews(self,NO); }
|
||||
- (NSArray *)accessibilityVisibleChildren { return DYAccessibleSubviews(self,YES); }
|
||||
- (NSArray *)accessibilityChildrenInNavigationOrder { return self.accessibilityChildren; }
|
||||
- (NSSize)intrinsicContentSize { return NSMakeSize(360,780); }
|
||||
- (void)viewDidMoveToWindow { [super viewDidMoveToWindow]; if(self.window) [self refresh]; }
|
||||
- (void)viewDidMoveToWindow {
|
||||
[super viewDidMoveToWindow];
|
||||
if(self.window) {
|
||||
[self refresh];
|
||||
NSAccessibilityPostNotification(self,NSAccessibilityLayoutChangedNotification);
|
||||
}
|
||||
}
|
||||
- (void)modelChanged:(NSNotification *)n {
|
||||
if([NSThread isMainThread]) [self refresh];
|
||||
else dispatch_async(dispatch_get_main_queue(),^{ [self refresh]; });
|
||||
@@ -318,6 +381,7 @@ static NSImage *DYWheelImage(void) {
|
||||
NSInteger index=0;
|
||||
for(NSDictionary *section in _sections) {
|
||||
DYCard *card=[[[DYCard alloc] initWithFrame:NSZeroRect] autorelease];
|
||||
card.accessibilityLabel=section[@"title"];
|
||||
[_document addSubview:card];
|
||||
DYHeader *header=[[[DYHeader alloc] initWithFrame:NSZeroRect] autorelease];
|
||||
header.title=[@"▾ " stringByAppendingString:section[@"title"]?:@""];
|
||||
@@ -362,6 +426,7 @@ static NSImage *DYWheelImage(void) {
|
||||
}
|
||||
for(NSDictionary *d in section[@"rows"]) {
|
||||
DYFlippedView *row=[[[DYFlippedView alloc] initWithFrame:NSZeroRect] autorelease];
|
||||
row.accessibilityLabel=d[@"title"];
|
||||
[card addSubview:row]; [body addObject:row];
|
||||
NSNumber *pid=d[@"pid"]; if(!pid)continue;
|
||||
NSTextField *label=DYLabel(d[@"title"]?:d[@"key"],11); label.toolTip=d[@"title"];
|
||||
@@ -558,6 +623,7 @@ static NSImage *DYWheelImage(void) {
|
||||
NSMutableDictionary *card=_cards[sender.tag];BOOL collapsed=![card[@"collapsed"] boolValue];card[@"collapsed"]=@(collapsed);
|
||||
sender.title=[(collapsed?@"▸ ":@"▾ ") stringByAppendingString:card[@"section"][@"title"]?:@""];
|
||||
[self setNeedsLayout:YES];
|
||||
NSAccessibilityPostNotification(self,NSAccessibilityLayoutChangedNotification);
|
||||
}
|
||||
- (void)resetSection:(NSButton *)sender {
|
||||
if(sender.tag>=_cards.count)return;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<string>2</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string></string>
|
||||
<key>PlugInKit</key>
|
||||
|
||||
在新工单中引用
屏蔽一个用户