瀏覽代碼

Decorations control

Nikita Tsukanov 7 年之前
父節點
當前提交
3eeca6c36c
共有 3 個文件被更改,包括 32 次插入4 次删除
  1. 25 1
      src/Avalonia.Native.OSX/window.mm
  2. 5 2
      src/Avalonia.Native/WindowImpl.cs
  3. 2 1
      src/headers/avalonia-native.h

+ 25 - 1
src/Avalonia.Native.OSX/window.mm

@@ -172,6 +172,10 @@ protected:
 
 class WindowImpl : public WindowBaseImpl, public IAvnWindow
 {
+private:
+    bool _canResize = true;
+    bool _hasDecorations = true;
+    
     BEGIN_INTERFACE_MAP()
     INHERIT_INTERFACE_MAP(WindowBaseImpl)
     INTERFACE_MAP_ENTRY(IAvnWindow, IID_IAvnWindow)
@@ -184,10 +188,30 @@ class WindowImpl : public WindowBaseImpl, public IAvnWindow
         UpdateStyle();
     }
     
+    
+    virtual HRESULT SetCanResize(bool value)
+    {
+        _canResize = value;
+        UpdateStyle();
+        return S_OK;
+    }
+    
+    virtual HRESULT SetHasDecorations(bool value)
+    {
+        _hasDecorations = value;
+        UpdateStyle();
+        return S_OK;
+    }
+    
 protected:
     virtual NSWindowStyleMask GetStyle()
     {
-        return NSWindowStyleMaskBorderless | NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
+        unsigned long s = NSWindowStyleMaskBorderless;
+        if(_hasDecorations)
+            s = s | NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable;
+        if(_canResize)
+            s = s | NSWindowStyleMaskResizable;
+        return s;
     }
 };
 

+ 5 - 2
src/Avalonia.Native/WindowImpl.cs

@@ -7,10 +7,11 @@ namespace Avalonia.Native
 {
     class WindowImpl : WindowBaseImpl, IWindowImpl
     {
+        IAvnWindow _native;
         public WindowImpl(IAvaloniaNativeFactory factory)
         {
             using (var e = new WindowEvents(this))
-                Init(factory.CreateWindow(e));
+                Init(_native = factory.CreateWindow(e));
         }
 
         class WindowEvents : WindowBaseEvents, IAvnWindowEvents
@@ -31,10 +32,12 @@ namespace Avalonia.Native
 
         public void CanResize(bool value)
         {
-
+            _native.CanResize = value;
         }
+
         public void SetSystemDecorations(bool enabled)
         {
+            _native.HasDecorations = enabled;
         }
 
         public void SetTitle(string title)

+ 2 - 1
src/headers/avalonia-native.h

@@ -37,7 +37,8 @@ AVNCOM(IAvnWindowBase, 02) : virtual IUnknown
 
 AVNCOM(IAvnWindow, 03) : virtual IAvnWindowBase
 {
-    
+    virtual HRESULT SetCanResize(bool value) = 0;
+    virtual HRESULT SetHasDecorations(bool value) = 0;
 };
 
 AVNCOM(IAvnWindowBaseEvents, 04) : IUnknown