-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8085 from AvaloniaUI/osx-nswindow-refactor-part2
Osx nswindow refactor part2
- Loading branch information
Showing
15 changed files
with
888 additions
and
824 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Created by Dan Walmsley on 05/05/2022. | ||
// Copyright (c) 2022 Avalonia. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "avalonia-native.h" | ||
|
||
@interface AutoFitContentView : NSView | ||
-(AutoFitContentView* _Nonnull) initWithContent: (NSView* _Nonnull) content; | ||
-(void) ShowTitleBar: (bool) show; | ||
-(void) SetTitleBarHeightHint: (double) height; | ||
|
||
-(void) ShowBlur: (bool) show; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// | ||
// Created by Dan Walmsley on 05/05/2022. | ||
// Copyright (c) 2022 Avalonia. All rights reserved. | ||
// | ||
|
||
#include "AvnView.h" | ||
#import "AutoFitContentView.h" | ||
|
||
@implementation AutoFitContentView | ||
{ | ||
NSVisualEffectView* _titleBarMaterial; | ||
NSBox* _titleBarUnderline; | ||
NSView* _content; | ||
NSVisualEffectView* _blurBehind; | ||
double _titleBarHeightHint; | ||
bool _settingSize; | ||
} | ||
|
||
-(AutoFitContentView* _Nonnull) initWithContent:(NSView *)content | ||
{ | ||
_titleBarHeightHint = -1; | ||
_content = content; | ||
_settingSize = false; | ||
|
||
[self setAutoresizesSubviews:true]; | ||
[self setWantsLayer:true]; | ||
|
||
_titleBarMaterial = [NSVisualEffectView new]; | ||
[_titleBarMaterial setBlendingMode:NSVisualEffectBlendingModeWithinWindow]; | ||
[_titleBarMaterial setMaterial:NSVisualEffectMaterialTitlebar]; | ||
[_titleBarMaterial setWantsLayer:true]; | ||
_titleBarMaterial.hidden = true; | ||
|
||
_titleBarUnderline = [NSBox new]; | ||
_titleBarUnderline.boxType = NSBoxSeparator; | ||
_titleBarUnderline.fillColor = [NSColor underPageBackgroundColor]; | ||
_titleBarUnderline.hidden = true; | ||
|
||
[self addSubview:_titleBarMaterial]; | ||
[self addSubview:_titleBarUnderline]; | ||
|
||
_blurBehind = [NSVisualEffectView new]; | ||
[_blurBehind setBlendingMode:NSVisualEffectBlendingModeBehindWindow]; | ||
[_blurBehind setMaterial:NSVisualEffectMaterialLight]; | ||
[_blurBehind setWantsLayer:true]; | ||
_blurBehind.hidden = true; | ||
|
||
[_blurBehind setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | ||
[_content setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | ||
|
||
[self addSubview:_blurBehind]; | ||
[self addSubview:_content]; | ||
|
||
[self setWantsLayer:true]; | ||
return self; | ||
} | ||
|
||
-(void) ShowBlur:(bool)show | ||
{ | ||
_blurBehind.hidden = !show; | ||
} | ||
|
||
-(void) ShowTitleBar: (bool) show | ||
{ | ||
_titleBarMaterial.hidden = !show; | ||
_titleBarUnderline.hidden = !show; | ||
} | ||
|
||
-(void) SetTitleBarHeightHint: (double) height | ||
{ | ||
_titleBarHeightHint = height; | ||
|
||
[self setFrameSize:self.frame.size]; | ||
} | ||
|
||
-(void)setFrameSize:(NSSize)newSize | ||
{ | ||
if(_settingSize) | ||
{ | ||
return; | ||
} | ||
|
||
_settingSize = true; | ||
[super setFrameSize:newSize]; | ||
|
||
auto window = objc_cast<AvnWindow>([self window]); | ||
|
||
// TODO get actual titlebar size | ||
|
||
double height = _titleBarHeightHint == -1 ? [window getExtendedTitleBarHeight] : _titleBarHeightHint; | ||
|
||
NSRect tbar; | ||
tbar.origin.x = 0; | ||
tbar.origin.y = newSize.height - height; | ||
tbar.size.width = newSize.width; | ||
tbar.size.height = height; | ||
|
||
[_titleBarMaterial setFrame:tbar]; | ||
tbar.size.height = height < 1 ? 0 : 1; | ||
[_titleBarUnderline setFrame:tbar]; | ||
|
||
_settingSize = false; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// Created by Dan Walmsley on 05/05/2022. | ||
// Copyright (c) 2022 Avalonia. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
|
||
#import <Foundation/Foundation.h> | ||
#import <AppKit/AppKit.h> | ||
#include "window.h" | ||
#import "comimpl.h" | ||
#import "common.h" | ||
#import "WindowImpl.h" | ||
#import "KeyTransform.h" | ||
|
||
@class AvnAccessibilityElement; | ||
|
||
@interface AvnView : NSView<NSTextInputClient, NSDraggingDestination> | ||
-(AvnView* _Nonnull) initWithParent: (WindowBaseImpl* _Nonnull) parent; | ||
-(NSEvent* _Nonnull) lastMouseDownEvent; | ||
-(AvnPoint) translateLocalPoint:(AvnPoint)pt; | ||
-(void) setSwRenderedFrame: (AvnFramebuffer* _Nonnull) fb dispose: (IUnknown* _Nonnull) dispose; | ||
-(void) onClosed; | ||
|
||
-(AvnPlatformResizeReason) getResizeReason; | ||
-(void) setResizeReason:(AvnPlatformResizeReason)reason; | ||
+ (AvnPoint)toAvnPoint:(CGPoint)p; | ||
@end |
Oops, something went wrong.