-
-
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 #8078 from AvaloniaUI/osx-nswindow-refactor
Osx nswindow refactor: Part 1 # Conflicts: # native/Avalonia.Native/src/OSX/Avalonia.Native.OSX.xcodeproj/project.pbxproj # native/Avalonia.Native/src/OSX/automation.h # native/Avalonia.Native/src/OSX/automation.mm # native/Avalonia.Native/src/OSX/window.h # native/Avalonia.Native/src/OSX/window.mm
- Loading branch information
1 parent
81e5fe8
commit 991d9d8
Showing
19 changed files
with
1,434 additions
and
1,385 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
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 04/05/2022. | ||
// Copyright (c) 2022 Avalonia. All rights reserved. | ||
// | ||
|
||
#ifndef AVALONIA_NATIVE_OSX_INSWINDOWHOLDER_H | ||
#define AVALONIA_NATIVE_OSX_INSWINDOWHOLDER_H | ||
|
||
struct INSWindowHolder | ||
{ | ||
virtual AvnWindow* _Nonnull GetNSWindow () = 0; | ||
virtual AvnView* _Nonnull GetNSView () = 0; | ||
}; | ||
|
||
#endif //AVALONIA_NATIVE_OSX_INSWINDOWHOLDER_H |
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,18 @@ | ||
// | ||
// Created by Dan Walmsley on 04/05/2022. | ||
// Copyright (c) 2022 Avalonia. All rights reserved. | ||
// | ||
|
||
#ifndef AVALONIA_NATIVE_OSX_IWINDOWSTATECHANGED_H | ||
#define AVALONIA_NATIVE_OSX_IWINDOWSTATECHANGED_H | ||
|
||
struct IWindowStateChanged | ||
{ | ||
virtual void WindowStateChanged () = 0; | ||
virtual void StartStateTransition () = 0; | ||
virtual void EndStateTransition () = 0; | ||
virtual SystemDecorations Decorations () = 0; | ||
virtual AvnWindowState WindowState () = 0; | ||
}; | ||
|
||
#endif //AVALONIA_NATIVE_OSX_IWINDOWSTATECHANGED_H |
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,23 @@ | ||
// | ||
// Created by Dan Walmsley on 04/05/2022. | ||
// Copyright (c) 2022 Avalonia. All rights reserved. | ||
// | ||
|
||
#ifndef AVALONIA_NATIVE_OSX_RESIZESCOPE_H | ||
#define AVALONIA_NATIVE_OSX_RESIZESCOPE_H | ||
|
||
#include "window.h" | ||
#include "avalonia-native.h" | ||
|
||
class ResizeScope | ||
{ | ||
public: | ||
ResizeScope(AvnView* _Nonnull view, AvnPlatformResizeReason reason); | ||
|
||
~ResizeScope(); | ||
private: | ||
AvnView* _Nonnull _view; | ||
AvnPlatformResizeReason _restore; | ||
}; | ||
|
||
#endif //AVALONIA_NATIVE_OSX_RESIZESCOPE_H |
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,17 @@ | ||
// | ||
// Created by Dan Walmsley on 04/05/2022. | ||
// Copyright (c) 2022 Avalonia. All rights reserved. | ||
// | ||
|
||
#import <AppKit/AppKit.h> | ||
#include "ResizeScope.h" | ||
|
||
ResizeScope::ResizeScope(AvnView *view, AvnPlatformResizeReason reason) { | ||
_view = view; | ||
_restore = [view getResizeReason]; | ||
[view setResizeReason:reason]; | ||
} | ||
|
||
ResizeScope::~ResizeScope() { | ||
[_view setResizeReason:_restore]; | ||
} |
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,119 @@ | ||
// | ||
// Created by Dan Walmsley on 04/05/2022. | ||
// Copyright (c) 2022 Avalonia. All rights reserved. | ||
// | ||
|
||
#ifndef AVALONIA_NATIVE_OSX_WINDOWBASEIMPL_H | ||
#define AVALONIA_NATIVE_OSX_WINDOWBASEIMPL_H | ||
|
||
#import "rendertarget.h" | ||
#include "INSWindowHolder.h" | ||
|
||
class WindowBaseImpl : public virtual ComObject, | ||
public virtual IAvnWindowBase, | ||
public INSWindowHolder { | ||
private: | ||
NSCursor *cursor; | ||
|
||
public: | ||
FORWARD_IUNKNOWN() | ||
|
||
BEGIN_INTERFACE_MAP() | ||
INTERFACE_MAP_ENTRY(IAvnWindowBase, IID_IAvnWindowBase) | ||
END_INTERFACE_MAP() | ||
|
||
virtual ~WindowBaseImpl() { | ||
View = NULL; | ||
Window = NULL; | ||
} | ||
|
||
AutoFitContentView *StandardContainer; | ||
AvnView *View; | ||
AvnWindow *Window; | ||
ComPtr<IAvnWindowBaseEvents> BaseEvents; | ||
ComPtr<IAvnGlContext> _glContext; | ||
NSObject <IRenderTarget> *renderTarget; | ||
AvnPoint lastPositionSet; | ||
NSString *_lastTitle; | ||
|
||
bool _shown; | ||
bool _inResize; | ||
|
||
WindowBaseImpl(IAvnWindowBaseEvents *events, IAvnGlContext *gl); | ||
|
||
virtual HRESULT ObtainNSWindowHandle(void **ret) override; | ||
|
||
virtual HRESULT ObtainNSWindowHandleRetained(void **ret) override; | ||
|
||
virtual HRESULT ObtainNSViewHandle(void **ret) override; | ||
|
||
virtual HRESULT ObtainNSViewHandleRetained(void **ret) override; | ||
|
||
virtual AvnWindow *GetNSWindow() override; | ||
|
||
virtual AvnView *GetNSView() override; | ||
|
||
virtual HRESULT Show(bool activate, bool isDialog) override; | ||
|
||
virtual bool ShouldTakeFocusOnShow(); | ||
|
||
virtual HRESULT Hide() override; | ||
|
||
virtual HRESULT Activate() override; | ||
|
||
virtual HRESULT SetTopMost(bool value) override; | ||
|
||
virtual HRESULT Close() override; | ||
|
||
virtual HRESULT GetClientSize(AvnSize *ret) override; | ||
|
||
virtual HRESULT GetFrameSize(AvnSize *ret) override; | ||
|
||
virtual HRESULT GetScaling(double *ret) override; | ||
|
||
virtual HRESULT SetMinMaxSize(AvnSize minSize, AvnSize maxSize) override; | ||
|
||
virtual HRESULT Resize(double x, double y, AvnPlatformResizeReason reason) override; | ||
|
||
virtual HRESULT Invalidate(__attribute__((unused)) AvnRect rect) override; | ||
|
||
virtual HRESULT SetMainMenu(IAvnMenu *menu) override; | ||
|
||
virtual HRESULT BeginMoveDrag() override; | ||
|
||
virtual HRESULT BeginResizeDrag(__attribute__((unused)) AvnWindowEdge edge) override; | ||
|
||
virtual HRESULT GetPosition(AvnPoint *ret) override; | ||
|
||
virtual HRESULT SetPosition(AvnPoint point) override; | ||
|
||
virtual HRESULT PointToClient(AvnPoint point, AvnPoint *ret) override; | ||
|
||
virtual HRESULT PointToScreen(AvnPoint point, AvnPoint *ret) override; | ||
|
||
virtual HRESULT ThreadSafeSetSwRenderedFrame(AvnFramebuffer *fb, IUnknown *dispose) override; | ||
|
||
virtual HRESULT SetCursor(IAvnCursor *cursor) override; | ||
|
||
virtual void UpdateCursor(); | ||
|
||
virtual HRESULT CreateGlRenderTarget(IAvnGlSurfaceRenderTarget **ppv) override; | ||
|
||
virtual HRESULT CreateNativeControlHost(IAvnNativeControlHost **retOut) override; | ||
|
||
virtual HRESULT SetBlurEnabled(bool enable) override; | ||
|
||
virtual HRESULT BeginDragAndDropOperation(AvnDragDropEffects effects, AvnPoint point, | ||
IAvnClipboard *clipboard, IAvnDndResultCallback *cb, | ||
void *sourceHandle) override; | ||
|
||
virtual bool IsDialog(); | ||
|
||
protected: | ||
virtual NSWindowStyleMask GetStyle(); | ||
|
||
void UpdateStyle(); | ||
|
||
}; | ||
|
||
#endif //AVALONIA_NATIVE_OSX_WINDOWBASEIMPL_H |
Oops, something went wrong.