Respect FxRemoteWindow geometry and follow host content bounds in LUT browser
这个提交包含在:
1 父节点
e62d5532f2
当前提交
f9dea76a45
11 个文件已更改
+261
-14
没有与搜索条件相匹配的文件
+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;
|
||||
|
||||
在新工单中引用
屏蔽一个用户