Browse Source
Merge pull request #9469 from AvaloniaUI/fixes/window-border-for-opaque-windows
[OSX] Use non-opaque window background for non-transparent windows
pull/9479/head
Dan Walmsley
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
19 additions and
15 deletions
-
native/Avalonia.Native/src/OSX/AvnWindow.mm
-
native/Avalonia.Native/src/OSX/WindowBaseImpl.h
-
native/Avalonia.Native/src/OSX/WindowBaseImpl.mm
-
src/Avalonia.Native/WindowImplBase.cs
-
src/Avalonia.Native/avn.idl
|
|
|
@ -171,9 +171,7 @@ |
|
|
|
_closed = false; |
|
|
|
_isEnabled = true; |
|
|
|
|
|
|
|
[self backingScaleFactor]; |
|
|
|
[self setOpaque:NO]; |
|
|
|
[self setBackgroundColor: [NSColor clearColor]]; |
|
|
|
|
|
|
|
_isExtended = false; |
|
|
|
_isTransitioningToFullScreen = false; |
|
|
|
|
|
|
|
@ -90,7 +90,7 @@ BEGIN_INTERFACE_MAP() |
|
|
|
|
|
|
|
virtual HRESULT CreateNativeControlHost(IAvnNativeControlHost **retOut) override; |
|
|
|
|
|
|
|
virtual HRESULT SetBlurEnabled(bool enable) override; |
|
|
|
virtual HRESULT SetTransparencyMode(AvnWindowTransparencyMode mode) override; |
|
|
|
|
|
|
|
virtual HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point, |
|
|
|
IAvnClipboard *clipboard, IAvnDndResultCallback *cb, |
|
|
|
|
|
|
|
@ -489,10 +489,11 @@ HRESULT WindowBaseImpl::CreateNativeControlHost(IAvnNativeControlHost **retOut) |
|
|
|
return S_OK; |
|
|
|
} |
|
|
|
|
|
|
|
HRESULT WindowBaseImpl::SetBlurEnabled(bool enable) { |
|
|
|
HRESULT WindowBaseImpl::SetTransparencyMode(AvnWindowTransparencyMode mode) { |
|
|
|
START_COM_CALL; |
|
|
|
|
|
|
|
[StandardContainer ShowBlur:enable]; |
|
|
|
[Window setBackgroundColor: (mode != Transparent ? [NSColor windowBackgroundColor] : [NSColor clearColor])]; |
|
|
|
[StandardContainer ShowBlur: mode == Blur]; |
|
|
|
|
|
|
|
return S_OK; |
|
|
|
} |
|
|
|
|
|
|
|
@ -501,19 +501,17 @@ namespace Avalonia.Native |
|
|
|
{ |
|
|
|
if (TransparencyLevel != transparencyLevel) |
|
|
|
{ |
|
|
|
if (transparencyLevel >= WindowTransparencyLevel.Blur) |
|
|
|
{ |
|
|
|
if (transparencyLevel > WindowTransparencyLevel.Transparent) |
|
|
|
transparencyLevel = WindowTransparencyLevel.AcrylicBlur; |
|
|
|
} |
|
|
|
|
|
|
|
if(transparencyLevel == WindowTransparencyLevel.None) |
|
|
|
{ |
|
|
|
transparencyLevel = WindowTransparencyLevel.Transparent; |
|
|
|
} |
|
|
|
|
|
|
|
TransparencyLevel = transparencyLevel; |
|
|
|
|
|
|
|
_native?.SetBlurEnabled((TransparencyLevel >= WindowTransparencyLevel.Blur).AsComBool()); |
|
|
|
_native.SetTransparencyMode(transparencyLevel == WindowTransparencyLevel.None |
|
|
|
? AvnWindowTransparencyMode.Opaque |
|
|
|
: transparencyLevel == WindowTransparencyLevel.Transparent |
|
|
|
? AvnWindowTransparencyMode.Transparent |
|
|
|
: AvnWindowTransparencyMode.Blur); |
|
|
|
|
|
|
|
TransparencyLevelChanged?.Invoke(TransparencyLevel); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -466,6 +466,13 @@ enum AvnAutomationControlType |
|
|
|
AutomationSeparator, |
|
|
|
} |
|
|
|
|
|
|
|
enum AvnWindowTransparencyMode |
|
|
|
{ |
|
|
|
Opaque, |
|
|
|
Transparent, |
|
|
|
Blur |
|
|
|
} |
|
|
|
|
|
|
|
[uuid(809c652e-7396-11d2-9771-00a0c9b4d50c)] |
|
|
|
interface IAvaloniaNativeFactory : IUnknown |
|
|
|
{ |
|
|
|
@ -527,7 +534,7 @@ interface IAvnWindowBase : IUnknown |
|
|
|
HRESULT CreateNativeControlHost(IAvnNativeControlHost** retOut); |
|
|
|
HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point, |
|
|
|
IAvnClipboard* clipboard, IAvnDndResultCallback* cb, [intptr]void* sourceHandle); |
|
|
|
HRESULT SetBlurEnabled(bool enable); |
|
|
|
HRESULT SetTransparencyMode(AvnWindowTransparencyMode mode); |
|
|
|
} |
|
|
|
|
|
|
|
[uuid(83e588f3-6981-4e48-9ea0-e1e569f79a91), cpp-virtual-inherits] |
|
|
|
|