Browse Source

Added an underline for the fake title bar

demo1
Nikita Tsukanov 6 years ago
committed by Dan Walmsley
parent
commit
ce69cd84af
  1. 22
      native/Avalonia.Native/src/OSX/window.mm

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

@ -1009,6 +1009,7 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
@implementation AutoFitContentVisualEffectView @implementation AutoFitContentVisualEffectView
{ {
NSVisualEffectView* _titleBarMaterial; NSVisualEffectView* _titleBarMaterial;
NSBox* _titleBarUnderline;
AvnView* _content; AvnView* _content;
double _titleBarHeightHint; double _titleBarHeightHint;
} }
@ -1023,21 +1024,21 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
[_titleBarMaterial setWantsLayer:true]; [_titleBarMaterial setWantsLayer:true];
_titleBarMaterial.hidden = true; _titleBarMaterial.hidden = true;
[self addSubview:_titleBarMaterial]; _titleBarUnderline = [NSBox new];
_titleBarUnderline.boxType = NSBoxSeparator;
_titleBarUnderline.fillColor = [NSColor underPageBackgroundColor];
_titleBarUnderline.hidden = true;
[self addSubview:_titleBarMaterial];
[self addSubview:_titleBarUnderline];
[self addSubview:_content]; [self addSubview:_content];
return self; return self;
} }
-(void) ShowTitleBar: (bool) show -(void) ShowTitleBar: (bool) show
{ {
if(show) _titleBarMaterial.hidden = !show;
{ _titleBarUnderline.hidden = !show;
_titleBarMaterial.hidden = false;
}
else
{
_titleBarMaterial.hidden = true;
}
} }
-(void) SetTitleBarHeightHint: (double) height -(void) SetTitleBarHeightHint: (double) height
@ -1058,6 +1059,7 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
// TODO get actual titlebar size // TODO get actual titlebar size
double height = _titleBarHeightHint == -1 ? [window getExtendedTitleBarHeight] : _titleBarHeightHint; double height = _titleBarHeightHint == -1 ? [window getExtendedTitleBarHeight] : _titleBarHeightHint;
NSRect tbar; NSRect tbar;
tbar.origin.x = 0; tbar.origin.x = 0;
tbar.origin.y = newSize.height - height; tbar.origin.y = newSize.height - height;
@ -1065,6 +1067,8 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent
tbar.size.height = height; tbar.size.height = height;
[_titleBarMaterial setFrame:tbar]; [_titleBarMaterial setFrame:tbar];
tbar.size.height = height < 1 ? 0 : 1;
[_titleBarUnderline setFrame:tbar];
} }
@end @end

Loading…
Cancel
Save