Respect FxRemoteWindow geometry and follow host content bounds in LUT browser
这个提交包含在:
1 父节点
e62d5532f2
当前提交
f9dea76a45
11 个文件已更改
+261
-14
没有与搜索条件相匹配的文件
@@ -5,6 +5,7 @@
|
||||
#import "DYRenderer.h"
|
||||
#import "DYAutoGrade.h"
|
||||
#import "DYLUTLibrary.h"
|
||||
#import "DYLUTBrowser.h"
|
||||
#import "DYInspector.h"
|
||||
#include "DYSpiderState.h"
|
||||
#include <string>
|
||||
@@ -198,6 +199,26 @@ extern "C" int DYRunDiagnostics(void) { @autoreleasepool {
|
||||
DYAssetState *copy=[[assets copy]autorelease];copy.paths=@{};run.record(@"asset-copy-is-independent",assets.paths.count==2&©.paths.count==0);
|
||||
// Exercise the real AppKit actions against a separate, in-memory host.
|
||||
[NSApplication sharedApplication];
|
||||
DYLUTLibrary *geometryLibrary=[[[DYLUTLibrary alloc]initWithRootURL:[NSURL fileURLWithPath:[runtime stringByAppendingPathComponent:@"browser-geometry"]]]autorelease];
|
||||
NSString *geometryKey=[@"com.dayu.color.lookLUTPreview.windowFrame|" stringByAppendingString:geometryLibrary.rootURL.path],*staleGeometry=NSStringFromRect(NSMakeRect(-9000,8000,1800,1228));
|
||||
[NSUserDefaults.standardUserDefaults setObject:staleGeometry forKey:geometryKey];
|
||||
NSPanel *geometryHost=[[[NSPanel alloc]initWithContentRect:NSMakeRect(80,100,900,620) styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO]autorelease];
|
||||
NSView *geometryParent=[[[NSView alloc]initWithFrame:geometryHost.contentView.bounds]autorelease];geometryParent.autoresizesSubviews=NO;[geometryHost.contentView addSubview:geometryParent];
|
||||
NSRect geometryFrame=geometryHost.frame;NSSize geometryMin=geometryHost.contentMinSize,geometryMax=geometryHost.contentMaxSize;
|
||||
__block NSUInteger geometryCloses=0;DYLUTBrowser *geometryBrowser=[[[DYLUTBrowser alloc]initWithLibrary:geometryLibrary preview:nil selectedPath:nil palette:@{} selection:nil]autorelease];
|
||||
[geometryBrowser showInRemoteParent:geometryParent close:^{geometryCloses++;}];double geometryDeadline=NSProcessInfo.processInfo.systemUptime+2;
|
||||
while([geometryBrowser valueForKey:@"presentationWindow"]!=geometryHost&&NSProcessInfo.processInfo.systemUptime<geometryDeadline)[[NSRunLoop mainRunLoop]runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.005]];
|
||||
run.need(@"browser-remote-presentation-attached",[geometryBrowser valueForKey:@"presentationWindow"]==geometryHost);
|
||||
run.record(@"browser-remote-preserves-host-window-geometry",NSEqualRects(geometryHost.frame,geometryFrame)&&NSEqualSizes(geometryHost.contentMinSize,geometryMin)&&NSEqualSizes(geometryHost.contentMaxSize,geometryMax));
|
||||
run.record(@"browser-remote-preserves-bridge-resize-policy",!geometryParent.autoresizesSubviews);
|
||||
NSView *geometryRoot=[geometryBrowser valueForKey:@"root"];[geometryParent setFrameSize:NSMakeSize(576,336)];
|
||||
run.record(@"browser-remote-fills-host-capped-bounds",NSEqualRects(geometryRoot.frame,geometryParent.bounds));
|
||||
NSView *geometryDone=[geometryBrowser valueForKey:@"done"],*geometrySplit=[geometryBrowser valueForKey:@"splitView"];
|
||||
run.record(@"browser-remote-footer-and-grid-fit-capped-bounds",NSContainsRect(geometryRoot.bounds,geometryDone.frame)&&NSContainsRect(geometryRoot.bounds,geometrySplit.frame));
|
||||
[geometryParent setBoundsOrigin:NSMakePoint(17,23)];run.record(@"browser-remote-tracks-bounds-origin",NSEqualRects(geometryRoot.frame,geometryParent.bounds));
|
||||
[geometryHost setFrame:NSMakeRect(140,160,1000,700) display:NO];run.record(@"browser-remote-keeps-local-history-isolated",[[NSUserDefaults.standardUserDefaults stringForKey:geometryKey]isEqual:staleGeometry]);
|
||||
[geometryBrowser close];[geometryBrowser close];run.record(@"browser-remote-close-once-without-visible-test-window",geometryCloses==1&&!geometryHost.visible);
|
||||
for(NSString *key in NSUserDefaults.standardUserDefaults.dictionaryRepresentation.allKeys)if([key containsString:geometryLibrary.rootURL.path])[NSUserDefaults.standardUserDefaults removeObjectForKey:key];
|
||||
DYDiagnosticManager *uiHost=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(uiHost,nil);
|
||||
DYInspector *inspector=[[[DYInspector alloc]initWithAPIManager:uiHost]autorelease];[inspector refresh];
|
||||
NSArray *cards=[inspector valueForKey:@"cards"];BOOL initialUI=YES;
|
||||
|
||||
+30
-7
@@ -144,7 +144,8 @@ static NSString *DYBrowserPreference(NSString *key,DYLUTLibrary *library){return
|
||||
NSString *key=[NSString stringWithFormat:@"%@|%@",DYBrowserFramePreference,DYLUTLibrary.defaultRootURL.path];
|
||||
NSString *saved=[[NSUserDefaults standardUserDefaults]stringForKey:key];NSRect frame=saved?NSRectFromString(saved):NSZeroRect;
|
||||
if(!std::isfinite(frame.size.width)||!std::isfinite(frame.size.height)||frame.size.width<720||frame.size.height<420)return NSMakeSize(900,620);
|
||||
return NSMakeSize(MIN(1800,frame.size.width),MIN(1200,MAX(420,frame.size.height-28)));
|
||||
NSSize content=[NSWindow contentRectForFrameRect:frame styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable].size;
|
||||
return NSMakeSize(MIN(1800,MAX(720,content.width)),MIN(1200,MAX(420,content.height)));
|
||||
}
|
||||
static NSTextField *BrowserLabel(NSString *title,CGFloat size){NSTextField *label=[NSTextField labelWithString:title];label.font=[NSFont systemFontOfSize:size];label.lineBreakMode=NSLineBreakByTruncatingTail;return label;}
|
||||
static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *button=[NSButton buttonWithTitle:title target:target action:action];button.font=[NSFont systemFontOfSize:11];button.bezelStyle=NSBezelStyleRounded;return button;}
|
||||
@@ -223,31 +224,52 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
if(_closed||!parent||self.visible)return;
|
||||
_remoteMode=YES;_visible=YES;[_closeAction release];_closeAction=[closeAction copy];
|
||||
self.window.contentView=[[[NSView alloc]initWithFrame:NSMakeRect(0,0,1,1)]autorelease];
|
||||
[_root removeFromSuperview];_root.frame=parent.bounds;_root.autoresizingMask=NSViewWidthSizable|NSViewHeightSizable;parent.autoresizesSubviews=YES;_root.hidden=NO;
|
||||
[_root removeFromSuperview];_root.frame=parent.bounds;_root.autoresizingMask=NSViewWidthSizable|NSViewHeightSizable;_root.hidden=NO;
|
||||
// FxRemoteWindow owns the window and may publish view geometry separately.
|
||||
// Follow the supplied parent without changing the bridge's resize policy.
|
||||
parent.postsFrameChangedNotifications=YES;parent.postsBoundsChangedNotifications=YES;
|
||||
for(NSNotificationName name in @[NSViewFrameDidChangeNotification,NSViewBoundsDidChangeNotification])[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(remoteParentGeometryChanged:) name:name object:parent];
|
||||
[parent addSubview:_root];[self layoutBrowser];[_root setNeedsDisplay:YES];
|
||||
// The SDK reads the first child size as soon as its reply returns.
|
||||
// Restore geometry only after that first synchronous attachment is complete.
|
||||
// Attach synchronously: the SDK reads the first child before reply returns.
|
||||
dispatch_async(dispatch_get_main_queue(),^{if(!_closed)[self configurePresentationWindow];});
|
||||
NSAccessibilityPostNotification(parent,NSAccessibilityLayoutChangedNotification);
|
||||
}
|
||||
- (void)fitRemoteParent{
|
||||
NSView *parent=_root.superview;if(_closed||!_remoteMode||!parent)return;
|
||||
if(!NSEqualRects(_root.frame,parent.bounds))_root.frame=parent.bounds;
|
||||
[self layoutBrowser];[_root setNeedsDisplay:YES];
|
||||
}
|
||||
- (void)remoteParentGeometryChanged:(NSNotification *)notification{
|
||||
if(notification.object==_root.superview)[self fitRemoteParent];
|
||||
}
|
||||
- (void)configurePresentationWindow{
|
||||
NSWindow *window=_root.window;if(!window||window==self.window)return;
|
||||
if(_presentationWindow!=window){[_presentationWindow release];_presentationWindow=[window retain];
|
||||
for(NSNotificationName name in @[NSWindowDidMoveNotification,NSWindowDidResizeNotification])[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(presentationGeometryChanged:) name:name object:window];
|
||||
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(presentationWindowClosed:) name:NSWindowWillCloseNotification object:window];
|
||||
}
|
||||
// The v2 API caps the size to 80% of the host window. A service-side NSWindow
|
||||
// is not authority to override that geometry, metadata or saved position.
|
||||
if(_remoteMode){[self fitRemoteParent];return;}
|
||||
window.title=@"风格 LUT";window.contentMinSize=self.class.minimumContentSize;window.contentMaxSize=self.class.maximumContentSize;
|
||||
if(_detached)window.styleMask|=NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable;
|
||||
NSString *saved=[NSUserDefaults.standardUserDefaults stringForKey:DYBrowserPreference(DYBrowserFramePreference,_library)];
|
||||
NSRect frame=saved?NSRectFromString(saved):[window frameRectForContentRect:(NSRect){window.frame.origin,self.class.preferredContentSize}];
|
||||
if(std::isfinite(frame.origin.x)&&std::isfinite(frame.origin.y)&&std::isfinite(frame.size.width)&&std::isfinite(frame.size.height)&&frame.size.width>=720&&frame.size.height>=420){
|
||||
NSRect screen=(window.screen?:NSScreen.mainScreen).visibleFrame;frame.size.width=MIN(MAX(720,frame.size.width),MIN(1800,screen.size.width));frame.size.height=MIN(MAX(448,frame.size.height),MIN(1228,screen.size.height));
|
||||
frame.origin.x=MAX(NSMinX(screen),MIN(frame.origin.x,NSMaxX(screen)-frame.size.width));frame.origin.y=MAX(NSMinY(screen),MIN(frame.origin.y,NSMaxY(screen)-frame.size.height));[window setFrame:frame display:YES];
|
||||
NSScreen *target=window.screen?:NSScreen.mainScreen;CGFloat largest=0;
|
||||
for(NSScreen *candidate in NSScreen.screens){NSRect overlap=NSIntersectionRect(frame,candidate.visibleFrame);CGFloat area=overlap.size.width*overlap.size.height;if(area>largest){largest=area;target=candidate;}}
|
||||
if(target){
|
||||
NSRect screen=target.visibleFrame;NSSize available=[window contentRectForFrameRect:screen].size,minimum=self.class.minimumContentSize,maximum=self.class.maximumContentSize;
|
||||
minimum=NSMakeSize(MIN(minimum.width,available.width),MIN(minimum.height,available.height));maximum=NSMakeSize(MIN(maximum.width,available.width),MIN(maximum.height,available.height));
|
||||
window.contentMinSize=minimum;window.contentMaxSize=maximum;
|
||||
NSRect content=[window contentRectForFrameRect:frame];content.size=NSMakeSize(MIN(maximum.width,MAX(minimum.width,content.size.width)),MIN(maximum.height,MAX(minimum.height,content.size.height)));frame=[window frameRectForContentRect:content];
|
||||
frame.origin.x=MAX(NSMinX(screen),MIN(frame.origin.x,NSMaxX(screen)-frame.size.width));frame.origin.y=MAX(NSMinY(screen),MIN(frame.origin.y,NSMaxY(screen)-frame.size.height));[window setFrame:frame display:YES];
|
||||
}
|
||||
}
|
||||
[self layoutBrowser];
|
||||
}
|
||||
- (void)presentationGeometryChanged:(NSNotification *)notification{
|
||||
if(_closed||!_presentationWindow)return;NSRect frame=_presentationWindow.frame;
|
||||
if(_closed||!_presentationWindow)return;if(_remoteMode){[self fitRemoteParent];return;}NSRect frame=_presentationWindow.frame;
|
||||
if(std::isfinite(frame.size.width)&&std::isfinite(frame.size.height)&&frame.size.width>=720&&frame.size.height>=420)[NSUserDefaults.standardUserDefaults setObject:NSStringFromRect(frame) forKey:DYBrowserPreference(DYBrowserFramePreference,_library)];
|
||||
[self layoutBrowser];
|
||||
}
|
||||
@@ -272,6 +294,7 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
||||
_closed=YES;_visible=NO;_work.cancelled=YES;_work.owner=nil;[_libraryTask cancel];[_selectionTask cancel];[_progressTimer invalidate];[_progressTimer release];_progressTimer=nil;
|
||||
_popover.delegate=nil;if(_popover.shown)[_popover close];
|
||||
if(_remoteMode&&_root.superview)for(NSNotificationName name in @[NSViewFrameDidChangeNotification,NSViewBoundsDidChangeNotification])[[NSNotificationCenter defaultCenter]removeObserver:self name:name object:_root.superview];
|
||||
[_root removeFromSuperview];[_queuedPaths removeAllObjects];[_thumbnailCache removeAllObjects];
|
||||
[_selection release];_selection=nil;
|
||||
void (^closeAction)(void)=[_closeAction copy];[_closeAction release];_closeAction=nil;
|
||||
|
||||
+3
-3
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.7.1</string>
|
||||
<string>1.7.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>46</string>
|
||||
<string>47</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.7.1</string>
|
||||
<string>1.7.2</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>className</key>
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.7.1</string>
|
||||
<string>1.7.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>46</string>
|
||||
<string>47</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
在新工单中引用
屏蔽一个用户