chore: remove c-style conversion for vibrantView (#29724)

This commit is contained in:
Cheng Zhao 2021-06-17 02:13:42 +09:00 committed by GitHub
parent d59e2d7b2e
commit 330c3bc136
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 19 deletions

View file

@ -1308,10 +1308,9 @@ void NativeWindowMac::SetAutoHideCursor(bool auto_hide) {
}
void NativeWindowMac::UpdateVibrancyRadii(bool fullscreen) {
NSView* vibrant_view = [window_ vibrantView];
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
NSVisualEffectView* vibrantView = [window_ vibrantView];
if (effect_view != nil && !vibrancy_type_.empty()) {
if (vibrantView != nil && !vibrancy_type_.empty()) {
const bool no_rounded_corner =
[window_ styleMask] & NSWindowStyleMaskFullSizeContentView;
if (!has_frame() && !is_modal() && !no_rounded_corner) {
@ -1341,43 +1340,42 @@ void NativeWindowMac::UpdateVibrancyRadii(bool fullscreen) {
[maskImage setCapInsets:NSEdgeInsetsMake(radius, radius, radius, radius)];
[maskImage setResizingMode:NSImageResizingModeStretch];
[effect_view setMaskImage:maskImage];
[vibrantView setMaskImage:maskImage];
[window_ setCornerMask:maskImage];
}
}
}
void NativeWindowMac::SetVibrancy(const std::string& type) {
NSView* vibrant_view = [window_ vibrantView];
NSVisualEffectView* vibrantView = [window_ vibrantView];
if (type.empty()) {
if (vibrant_view == nil)
if (vibrantView == nil)
return;
[vibrant_view removeFromSuperview];
[vibrantView removeFromSuperview];
[window_ setVibrantView:nil];
return;
}
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
if (effect_view == nil) {
effect_view = [[[NSVisualEffectView alloc]
if (vibrantView == nil) {
vibrantView = [[[NSVisualEffectView alloc]
initWithFrame:[[window_ contentView] bounds]] autorelease];
[window_ setVibrantView:(NSView*)effect_view];
[window_ setVibrantView:vibrantView];
[effect_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
[vibrantView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[vibrantView setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
if (visual_effect_state_ == VisualEffectState::kActive) {
[effect_view setState:NSVisualEffectStateActive];
[vibrantView setState:NSVisualEffectStateActive];
} else if (visual_effect_state_ == VisualEffectState::kInactive) {
[effect_view setState:NSVisualEffectStateInactive];
[vibrantView setState:NSVisualEffectStateInactive];
} else {
[effect_view setState:NSVisualEffectStateFollowsWindowActiveState];
[vibrantView setState:NSVisualEffectStateFollowsWindowActiveState];
}
[[window_ contentView] addSubview:effect_view
[[window_ contentView] addSubview:vibrantView
positioned:NSWindowBelow
relativeTo:nil];
@ -1447,7 +1445,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
if (vibrancyType) {
vibrancy_type_ = type;
[effect_view setMaterial:vibrancyType];
[vibrantView setMaterial:vibrancyType];
}
}

View file

@ -35,7 +35,7 @@ class ScopedDisableResize {
@property BOOL enableLargerThanScreen;
@property BOOL disableAutoHideCursor;
@property BOOL disableKeyOrMainWindow;
@property(nonatomic, retain) NSView* vibrantView;
@property(nonatomic, retain) NSVisualEffectView* vibrantView;
@property(nonatomic, retain) NSImage* cornerMask;
- (id)initWithShell:(electron::NativeWindowMac*)shell
styleMask:(NSUInteger)styleMask;