Browse Source

use thickness as the ExtendClientArea hint.

demo1
Dan Walmsley 6 years ago
parent
commit
68e8541f75
  1. 2
      src/Avalonia.Controls/Platform/IWindowImpl.cs
  2. 10
      src/Avalonia.Controls/Window.cs
  3. 2
      src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs
  4. 2
      src/Avalonia.DesignerSupport/Remote/Stubs.cs
  5. 2
      src/Avalonia.Native/WindowImpl.cs
  6. 2
      src/Avalonia.X11/X11Window.cs
  7. 19
      src/Windows/Avalonia.Win32/WindowImpl.cs

2
src/Avalonia.Controls/Platform/IWindowImpl.cs

@ -95,7 +95,7 @@ namespace Avalonia.Platform
/// ///
void SetMinMaxSize(Size minSize, Size maxSize); void SetMinMaxSize(Size minSize, Size maxSize);
bool ExtendClientAreaToDecorationsHint { get; set; } Thickness ExtendClientAreaToDecorationsHint { get; set; }
Action<bool> ExtendClientAreaToDecorationsChanged { get; set; } Action<bool> ExtendClientAreaToDecorationsChanged { get; set; }

10
src/Avalonia.Controls/Window.cs

@ -92,8 +92,8 @@ namespace Avalonia.Controls
/// <summary> /// <summary>
/// Defines the <see cref="ExtendClientAreaToDecorationsHint"/> property. /// Defines the <see cref="ExtendClientAreaToDecorationsHint"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<bool> ExtendClientAreaToDecorationsHintProperty = public static readonly StyledProperty<Thickness> ExtendClientAreaToDecorationsHintProperty =
AvaloniaProperty.Register<Window, bool>(nameof(ExtendClientAreaToDecorationsHint), false); AvaloniaProperty.Register<Window, Thickness>(nameof(ExtendClientAreaToDecorationsHint), default);
/// <summary> /// <summary>
@ -109,7 +109,7 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
public static readonly DirectProperty<Window, Thickness> WindowDecorationMarginsProperty = public static readonly DirectProperty<Window, Thickness> WindowDecorationMarginsProperty =
AvaloniaProperty.RegisterDirect<Window, Thickness>(nameof(WindowDecorationMargins), AvaloniaProperty.RegisterDirect<Window, Thickness>(nameof(WindowDecorationMargins),
o => o.WindowDecorationMargins); o => o.WindowDecorationMargins);
/// <summary> /// <summary>
@ -190,7 +190,7 @@ namespace Avalonia.Controls
(w, e) => { if (w.PlatformImpl != null) w.PlatformImpl.WindowState = (WindowState)e.NewValue; }); (w, e) => { if (w.PlatformImpl != null) w.PlatformImpl.WindowState = (WindowState)e.NewValue; });
ExtendClientAreaToDecorationsHintProperty.Changed.AddClassHandler<Window>( ExtendClientAreaToDecorationsHintProperty.Changed.AddClassHandler<Window>(
(w, e) => { if (w.PlatformImpl != null) w.PlatformImpl.ExtendClientAreaToDecorationsHint = (bool)e.NewValue; }); (w, e) => { if (w.PlatformImpl != null) w.PlatformImpl.ExtendClientAreaToDecorationsHint = (Thickness)e.NewValue; });
MinWidthProperty.Changed.AddClassHandler<Window>((w, e) => w.PlatformImpl?.SetMinMaxSize(new Size((double)e.NewValue, w.MinHeight), new Size(w.MaxWidth, w.MaxHeight))); MinWidthProperty.Changed.AddClassHandler<Window>((w, e) => w.PlatformImpl?.SetMinMaxSize(new Size((double)e.NewValue, w.MinHeight), new Size(w.MaxWidth, w.MaxHeight)));
MinHeightProperty.Changed.AddClassHandler<Window>((w, e) => w.PlatformImpl?.SetMinMaxSize(new Size(w.MinWidth, (double)e.NewValue), new Size(w.MaxWidth, w.MaxHeight))); MinHeightProperty.Changed.AddClassHandler<Window>((w, e) => w.PlatformImpl?.SetMinMaxSize(new Size(w.MinWidth, (double)e.NewValue), new Size(w.MaxWidth, w.MaxHeight)));
@ -269,7 +269,7 @@ namespace Avalonia.Controls
/// <summary> /// <summary>
/// Gets or sets if the ClientArea is Extended into the Window Decorations (chrome or border). /// Gets or sets if the ClientArea is Extended into the Window Decorations (chrome or border).
/// </summary> /// </summary>
public bool ExtendClientAreaToDecorationsHint public Thickness ExtendClientAreaToDecorationsHint
{ {
get { return GetValue(ExtendClientAreaToDecorationsHintProperty); } get { return GetValue(ExtendClientAreaToDecorationsHintProperty); }
set { SetValue(ExtendClientAreaToDecorationsHintProperty, value); } set { SetValue(ExtendClientAreaToDecorationsHintProperty, value); }

2
src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs

@ -85,7 +85,7 @@ namespace Avalonia.DesignerSupport.Remote
public IScreenImpl Screen { get; } = new ScreenStub(); public IScreenImpl Screen { get; } = new ScreenStub();
public Action GotInputWhenDisabled { get; set; } public Action GotInputWhenDisabled { get; set; }
public bool ExtendClientAreaToDecorationsHint { get; set; } public Thickness ExtendClientAreaToDecorationsHint { get; set; }
public Action<bool> ExtendClientAreaToDecorationsChanged { get; set; } public Action<bool> ExtendClientAreaToDecorationsChanged { get; set; }

2
src/Avalonia.DesignerSupport/Remote/Stubs.cs

@ -39,7 +39,7 @@ namespace Avalonia.DesignerSupport.Remote
public Action<WindowTransparencyLevel> TransparencyLevelChanged { get; set; } public Action<WindowTransparencyLevel> TransparencyLevelChanged { get; set; }
public bool ExtendClientAreaToDecorationsHint { get; set; } public Thickness ExtendClientAreaToDecorationsHint { get; set; }
public Action<bool> ExtendClientAreaToDecorationsChanged { get; set; } public Action<bool> ExtendClientAreaToDecorationsChanged { get; set; }

2
src/Avalonia.Native/WindowImpl.cs

@ -98,7 +98,7 @@ namespace Avalonia.Native
public Action<WindowState> WindowStateChanged { get; set; } public Action<WindowState> WindowStateChanged { get; set; }
public bool ExtendClientAreaToDecorationsHint { get; set; } public Thickness ExtendClientAreaToDecorationsHint { get; set; }
public Action<bool> ExtendClientAreaToDecorationsChanged { get; set; } public Action<bool> ExtendClientAreaToDecorationsChanged { get; set; }

2
src/Avalonia.X11/X11Window.cs

@ -311,7 +311,7 @@ namespace Avalonia.X11
set => _transparencyHelper.TransparencyLevelChanged = value; set => _transparencyHelper.TransparencyLevelChanged = value;
} }
public bool ExtendClientAreaToDecorationsHint { get; set; } public Thickness ExtendClientAreaToDecorationsHint { get; set; }
public Action<bool> ExtendClientAreaToDecorationsChanged { get; set; } public Action<bool> ExtendClientAreaToDecorationsChanged { get; set; }

19
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -69,7 +69,7 @@ namespace Avalonia.Win32
private Size _maxSize; private Size _maxSize;
private POINT _maxTrackSize; private POINT _maxTrackSize;
private WindowImpl _parent; private WindowImpl _parent;
private bool _extendClientAreaToDecorationsHint; private Thickness _extendClientAreaToDecorationsHint;
public WindowImpl() public WindowImpl()
{ {
@ -666,7 +666,7 @@ namespace Avalonia.Win32
TaskBarList.MarkFullscreen(_hwnd, fullscreen); TaskBarList.MarkFullscreen(_hwnd, fullscreen);
} }
private void ExtendClientArea () private void ExtendClientArea (Thickness thickness)
{ {
if (!_isClientAreaExtended) if (!_isClientAreaExtended)
{ {
@ -690,10 +690,10 @@ namespace Avalonia.Win32
} }
// Extend the frame into the client area. // Extend the frame into the client area.
margins.cxLeftWidth = border_thickness.left; margins.cxLeftWidth = thickness.Left == -1 ? border_thickness.left : (int)(thickness.Left * Scaling);
margins.cxRightWidth = border_thickness.right; margins.cxRightWidth = thickness.Right == -1 ? border_thickness.right : (int)(thickness.Right * Scaling);
margins.cyBottomHeight = border_thickness.bottom; margins.cyBottomHeight = thickness.Bottom == -1 ? border_thickness.bottom : (int)(thickness.Bottom * Scaling);
margins.cyTopHeight = border_thickness.top; margins.cyTopHeight = thickness.Top == -1 ? border_thickness.top : (int)(thickness.Top * Scaling);
var hr = DwmExtendFrameIntoClientArea(_hwnd, ref margins); var hr = DwmExtendFrameIntoClientArea(_hwnd, ref margins);
@ -948,15 +948,14 @@ namespace Avalonia.Win32
IntPtr EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Handle => Handle.Handle; IntPtr EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Handle => Handle.Handle;
public bool ExtendClientAreaToDecorationsHint public Thickness ExtendClientAreaToDecorationsHint
{ {
get => _extendClientAreaToDecorationsHint; get => _extendClientAreaToDecorationsHint;
set set
{ {
_extendClientAreaToDecorationsHint = true; _extendClientAreaToDecorationsHint = value;
ExtendClientArea(); ExtendClientArea(value);
// TODO Trigger transition.
} }
} }

Loading…
Cancel
Save