Browse Source

fix titlebar size when entering and exiting extended frame mode.

demo1
Dan Walmsley 6 years ago
parent
commit
124f12d5b6
  1. 3
      native/Avalonia.Native/src/OSX/window.h
  2. 53
      native/Avalonia.Native/src/OSX/window.mm

3
native/Avalonia.Native/src/OSX/window.h

@ -29,7 +29,8 @@ class WindowBaseImpl;
-(void) showWindowMenuWithAppMenu;
-(void) applyMenu:(NSMenu* _Nullable)menu;
-(double) getScaling;
-(double) getTitleBarHeight;
-(double) getExtendedTitleBarHeight;
-(void) setIsExtended:(bool)value;
@end
struct INSWindowHolder

53
native/Avalonia.Native/src/OSX/window.mm

@ -35,7 +35,7 @@ public:
View = NULL;
Window = NULL;
}
NSVisualEffectView* VisualEffect;
AutoFitContentVisualEffectView* VisualEffect;
AvnView* View;
AvnWindow* Window;
ComPtr<IAvnWindowBaseEvents> BaseEvents;
@ -826,6 +826,8 @@ private:
View.layer.zPosition = 0;
}
[Window setIsExtended:enable];
UpdateStyle();
return S_OK;
@ -846,7 +848,7 @@ private:
return E_POINTER;
}
*ret = [Window getTitleBarHeight];
*ret = [Window getExtendedTitleBarHeight];
return S_OK;
}
@ -1049,14 +1051,21 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
}
}
-(void)updateSize
{
[self setFrameSize:self.frame.size];
}
-(void)setFrameSize:(NSSize)newSize
{
[super setFrameSize:newSize];
[_content setFrameSize:newSize];
auto window = objc_cast<AvnWindow>([self window]);
// TODO get actual titlebar size
float height = 38;
double height = [window getExtendedTitleBarHeight];
NSRect tbar;
tbar.origin.x = 0;
tbar.origin.y = newSize.height - height;
@ -1595,28 +1604,41 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
bool _canBecomeKeyAndMain;
bool _closed;
bool _isEnabled;
bool _isExtended;
AvnMenu* _menu;
double _lastScaling;
}
-(void) setIsExtended:(bool)value;
{
_isExtended = value;
}
-(double) getScaling
{
return _lastScaling;
}
-(double) getTitleBarHeight
-(double) getExtendedTitleBarHeight
{
for (id subview in self.contentView.superview.subviews)
{
if ([subview isKindOfClass:NSClassFromString(@"NSTitlebarContainerView")])
{
NSView *titlebarView = [subview subviews][0];
return (double)titlebarView.frame.size.height;
}
}
return -1;
if(_isExtended)
{
for (id subview in self.contentView.superview.subviews)
{
if ([subview isKindOfClass:NSClassFromString(@"NSTitlebarContainerView")])
{
NSView *titlebarView = [subview subviews][0];
return (double)titlebarView.frame.size.height;
}
}
return -1;
}
else
{
return 0;
}
}
+(void)closeAll
@ -1737,6 +1759,7 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
[self setOpaque:NO];
[self setBackgroundColor: [NSColor clearColor]];
[self invalidateShadow];
_isExtended = false;
return self;
}

Loading…
Cancel
Save