chore: remove c-style conversion for vibrantView (#29724)
This commit is contained in:
parent
d59e2d7b2e
commit
330c3bc136
2 changed files with 17 additions and 19 deletions
|
@ -1308,10 +1308,9 @@ void NativeWindowMac::SetAutoHideCursor(bool auto_hide) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::UpdateVibrancyRadii(bool fullscreen) {
|
void NativeWindowMac::UpdateVibrancyRadii(bool fullscreen) {
|
||||||
NSView* vibrant_view = [window_ vibrantView];
|
NSVisualEffectView* vibrantView = [window_ vibrantView];
|
||||||
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
|
||||||
|
|
||||||
if (effect_view != nil && !vibrancy_type_.empty()) {
|
if (vibrantView != nil && !vibrancy_type_.empty()) {
|
||||||
const bool no_rounded_corner =
|
const bool no_rounded_corner =
|
||||||
[window_ styleMask] & NSWindowStyleMaskFullSizeContentView;
|
[window_ styleMask] & NSWindowStyleMaskFullSizeContentView;
|
||||||
if (!has_frame() && !is_modal() && !no_rounded_corner) {
|
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 setCapInsets:NSEdgeInsetsMake(radius, radius, radius, radius)];
|
||||||
[maskImage setResizingMode:NSImageResizingModeStretch];
|
[maskImage setResizingMode:NSImageResizingModeStretch];
|
||||||
[effect_view setMaskImage:maskImage];
|
[vibrantView setMaskImage:maskImage];
|
||||||
[window_ setCornerMask:maskImage];
|
[window_ setCornerMask:maskImage];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||||
NSView* vibrant_view = [window_ vibrantView];
|
NSVisualEffectView* vibrantView = [window_ vibrantView];
|
||||||
|
|
||||||
if (type.empty()) {
|
if (type.empty()) {
|
||||||
if (vibrant_view == nil)
|
if (vibrantView == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[vibrant_view removeFromSuperview];
|
[vibrantView removeFromSuperview];
|
||||||
[window_ setVibrantView:nil];
|
[window_ setVibrantView:nil];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
if (vibrantView == nil) {
|
||||||
if (effect_view == nil) {
|
vibrantView = [[[NSVisualEffectView alloc]
|
||||||
effect_view = [[[NSVisualEffectView alloc]
|
|
||||||
initWithFrame:[[window_ contentView] bounds]] autorelease];
|
initWithFrame:[[window_ contentView] bounds]] autorelease];
|
||||||
[window_ setVibrantView:(NSView*)effect_view];
|
[window_ setVibrantView:vibrantView];
|
||||||
|
|
||||||
[effect_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
[vibrantView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
[effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
[vibrantView setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
||||||
|
|
||||||
if (visual_effect_state_ == VisualEffectState::kActive) {
|
if (visual_effect_state_ == VisualEffectState::kActive) {
|
||||||
[effect_view setState:NSVisualEffectStateActive];
|
[vibrantView setState:NSVisualEffectStateActive];
|
||||||
} else if (visual_effect_state_ == VisualEffectState::kInactive) {
|
} else if (visual_effect_state_ == VisualEffectState::kInactive) {
|
||||||
[effect_view setState:NSVisualEffectStateInactive];
|
[vibrantView setState:NSVisualEffectStateInactive];
|
||||||
} else {
|
} else {
|
||||||
[effect_view setState:NSVisualEffectStateFollowsWindowActiveState];
|
[vibrantView setState:NSVisualEffectStateFollowsWindowActiveState];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[window_ contentView] addSubview:effect_view
|
[[window_ contentView] addSubview:vibrantView
|
||||||
positioned:NSWindowBelow
|
positioned:NSWindowBelow
|
||||||
relativeTo:nil];
|
relativeTo:nil];
|
||||||
|
|
||||||
|
@ -1447,7 +1445,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||||
|
|
||||||
if (vibrancyType) {
|
if (vibrancyType) {
|
||||||
vibrancy_type_ = type;
|
vibrancy_type_ = type;
|
||||||
[effect_view setMaterial:vibrancyType];
|
[vibrantView setMaterial:vibrancyType];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ScopedDisableResize {
|
||||||
@property BOOL enableLargerThanScreen;
|
@property BOOL enableLargerThanScreen;
|
||||||
@property BOOL disableAutoHideCursor;
|
@property BOOL disableAutoHideCursor;
|
||||||
@property BOOL disableKeyOrMainWindow;
|
@property BOOL disableKeyOrMainWindow;
|
||||||
@property(nonatomic, retain) NSView* vibrantView;
|
@property(nonatomic, retain) NSVisualEffectView* vibrantView;
|
||||||
@property(nonatomic, retain) NSImage* cornerMask;
|
@property(nonatomic, retain) NSImage* cornerMask;
|
||||||
- (id)initWithShell:(electron::NativeWindowMac*)shell
|
- (id)initWithShell:(electron::NativeWindowMac*)shell
|
||||||
styleMask:(NSUInteger)styleMask;
|
styleMask:(NSUInteger)styleMask;
|
||||||
|
|
Loading…
Reference in a new issue