Get radius working with frameless window.
Right now it's set as a constant `AtomWindowCornerRadius`, but it could be set to a variable.
This commit is contained in:
parent
5d49fc4bee
commit
8f31bf8615
1 changed files with 35 additions and 16 deletions
|
@ -78,6 +78,8 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
static CGFloat const AtomWindowCornerRadius = 5.0;
|
||||||
|
|
||||||
@interface AtomNSWindow : AtomEventProcessingWindow {
|
@interface AtomNSWindow : AtomEventProcessingWindow {
|
||||||
@protected
|
@protected
|
||||||
atom::NativeWindowMac* shell_;
|
atom::NativeWindowMac* shell_;
|
||||||
|
@ -102,6 +104,24 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface AtomFramelessView : NSView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation AtomFramelessView
|
||||||
|
- (void)drawRect:(NSRect) rect {
|
||||||
|
NSBezierPath * shadowPath = [NSBezierPath bezierPathWithRoundedRect:NSInsetRect([self bounds], 0.5, 0.5)
|
||||||
|
xRadius:AtomWindowCornerRadius
|
||||||
|
yRadius:AtomWindowCornerRadius];
|
||||||
|
|
||||||
|
[[NSColor blackColor] set];
|
||||||
|
[shadowPath fill];
|
||||||
|
|
||||||
|
[[NSColor colorWithCalibratedRed: 0.0 green: 0.0 blue: 0.0 alpha:0.7] set];
|
||||||
|
[shadowPath stroke];
|
||||||
|
[shadowPath addClip];
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@interface AtomFramelessNSWindow : AtomNSWindow
|
@interface AtomFramelessNSWindow : AtomNSWindow
|
||||||
- (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view;
|
- (void)drawCustomFrameRect:(NSRect)rect forView:(NSView*)view;
|
||||||
@end
|
@end
|
||||||
|
@ -112,16 +132,6 @@
|
||||||
[[NSBezierPath bezierPathWithRect:rect] addClip];
|
[[NSBezierPath bezierPathWithRect:rect] addClip];
|
||||||
[[NSColor clearColor] set];
|
[[NSColor clearColor] set];
|
||||||
NSRectFill(rect);
|
NSRectFill(rect);
|
||||||
|
|
||||||
// Set up our clip.
|
|
||||||
CGFloat cornerRadius = 40.0;
|
|
||||||
// if ([view respondsToSelector:@selector(roundedCornerRadius)])
|
|
||||||
// cornerRadius = [view roundedCornerRadius];
|
|
||||||
[[NSBezierPath bezierPathWithRoundedRect:[view bounds]
|
|
||||||
xRadius:cornerRadius
|
|
||||||
yRadius:cornerRadius] addClip];
|
|
||||||
[[NSColor clearColor] set];
|
|
||||||
NSRectFill(rect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)canBecomeKeyWindow {
|
- (BOOL)canBecomeKeyWindow {
|
||||||
|
@ -208,10 +218,12 @@ NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
|
||||||
} else {
|
} else {
|
||||||
atomWindow = [[AtomFramelessNSWindow alloc]
|
atomWindow = [[AtomFramelessNSWindow alloc]
|
||||||
initWithContentRect:cocoa_bounds
|
initWithContentRect:cocoa_bounds
|
||||||
styleMask:style_mask
|
styleMask:NSBorderlessWindowMask | NSClosableWindowMask |
|
||||||
|
NSMiniaturizableWindowMask | NSResizableWindowMask
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
defer:YES];
|
defer:YES];
|
||||||
[atomWindow setBottomCornerRounded:YES];
|
[atomWindow setOpaque:NO];
|
||||||
|
[atomWindow setBackgroundColor:[NSColor clearColor]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[atomWindow setShell:this];
|
[atomWindow setShell:this];
|
||||||
|
@ -412,7 +424,7 @@ void NativeWindowMac::SetKiosk(bool kiosk) {
|
||||||
if (kiosk) {
|
if (kiosk) {
|
||||||
NSApplicationPresentationOptions options =
|
NSApplicationPresentationOptions options =
|
||||||
NSApplicationPresentationHideDock +
|
NSApplicationPresentationHideDock +
|
||||||
NSApplicationPresentationHideMenuBar +
|
NSApplicationPresentationHideMenuBar +
|
||||||
NSApplicationPresentationDisableAppleMenu +
|
NSApplicationPresentationDisableAppleMenu +
|
||||||
NSApplicationPresentationDisableProcessSwitching +
|
NSApplicationPresentationDisableProcessSwitching +
|
||||||
NSApplicationPresentationDisableForceQuit +
|
NSApplicationPresentationDisableForceQuit +
|
||||||
|
@ -494,9 +506,17 @@ void NativeWindowMac::InstallView() {
|
||||||
} else {
|
} else {
|
||||||
NSView* frameView = [[window() contentView] superview];
|
NSView* frameView = [[window() contentView] superview];
|
||||||
[view setFrame:[frameView bounds]];
|
[view setFrame:[frameView bounds]];
|
||||||
[frameView addSubview:view];
|
|
||||||
|
AtomFramelessView * shadowView = [[AtomFramelessView alloc] initWithFrame: [frameView bounds]];
|
||||||
|
|
||||||
|
[frameView addSubview:shadowView];
|
||||||
|
[shadowView addSubview:view];
|
||||||
|
|
||||||
|
|
||||||
ClipWebView();
|
ClipWebView();
|
||||||
|
//
|
||||||
|
// [window() setHasShadow: NO];
|
||||||
|
// [window() setHasShadow: YES];
|
||||||
|
|
||||||
[[window() standardWindowButton:NSWindowZoomButton] setHidden:YES];
|
[[window() standardWindowButton:NSWindowZoomButton] setHidden:YES];
|
||||||
[[window() standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
|
[[window() standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
|
||||||
|
@ -513,13 +533,12 @@ void NativeWindowMac::UninstallView() {
|
||||||
void NativeWindowMac::ClipWebView() {
|
void NativeWindowMac::ClipWebView() {
|
||||||
NSView* view = GetWebContents()->GetView()->GetNativeView();
|
NSView* view = GetWebContents()->GetView()->GetNativeView();
|
||||||
|
|
||||||
CGFloat cornerRadius = 40.0;
|
|
||||||
// if ([view respondsToSelector:@selector(roundedCornerRadius)])
|
// if ([view respondsToSelector:@selector(roundedCornerRadius)])
|
||||||
// cornerRadius = [view roundedCornerRadius];
|
// cornerRadius = [view roundedCornerRadius];
|
||||||
|
|
||||||
view.wantsLayer = YES;
|
view.wantsLayer = YES;
|
||||||
view.layer.masksToBounds = YES;
|
view.layer.masksToBounds = YES;
|
||||||
view.layer.cornerRadius = cornerRadius;
|
view.layer.cornerRadius = AtomWindowCornerRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::InstallDraggableRegionViews() {
|
void NativeWindowMac::InstallDraggableRegionViews() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue