Browse Source

Fix Win32 window size constraints

fixes + revert testing changes
pull/1495/head
Stano Turza 8 years ago
parent
commit
bd33b3076b
  1. 24
      src/Avalonia.Controls/Platform/IWindowBaseImpl.cs
  2. 9
      src/Avalonia.Controls/WindowBase.cs
  3. 8
      src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs
  4. 8
      src/Avalonia.DesignerSupport/Remote/Stubs.cs
  5. 8
      src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs
  6. 8
      src/OSX/Avalonia.MonoMac/WindowBaseImpl.cs
  7. 10
      src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs
  8. 29
      src/Windows/Avalonia.Win32/WindowImpl.cs

24
src/Avalonia.Controls/Platform/IWindowBaseImpl.cs

@ -55,7 +55,7 @@ namespace Avalonia.Platform
/// Gets the platform window handle.
/// </summary>
IPlatformHandle Handle { get; }
/// <summary>
/// Gets the maximum size of a window on the system.
/// </summary>
@ -65,7 +65,27 @@ namespace Avalonia.Platform
/// Sets the client size of the toplevel.
/// </summary>
void Resize(Size clientSize);
/// <summary>
/// Minimum width of the window.
/// </summary>
double MinWidth { get; set; }
/// <summary>
/// Maximum width of the window.
/// </summary>
double MaxWidth { get; set; }
/// <summary>
/// Minimum height of the window.
/// </summary>
double MinHeight { get; set; }
/// <summary>
/// Maximum height of the window.
/// </summary>
double MaxHeight { get; set; }
/// <summary>
/// Gets platform specific display information
/// </summary>

9
src/Avalonia.Controls/WindowBase.cs

@ -197,7 +197,14 @@ namespace Avalonia.Controls
{
using (BeginAutoSizing())
{
PlatformImpl?.Resize(finalSize);
if (PlatformImpl != null)
{
PlatformImpl.MinHeight = MinHeight;
PlatformImpl.MaxHeight = MaxHeight;
PlatformImpl.MinWidth = MinWidth;
PlatformImpl.MaxWidth = MaxWidth;
PlatformImpl.Resize(finalSize);
}
}
return base.ArrangeOverride(PlatformImpl?.ClientSize ?? default(Size));

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

@ -67,6 +67,14 @@ namespace Avalonia.DesignerSupport.Remote
RenderIfNeeded();
}
public double MinWidth { get; set; }
public double MaxWidth { get; set; }
public double MinHeight { get; set; }
public double MaxHeight { get; set; }
public IScreenImpl Screen { get; } = new ScreenStub();
public void Activate()

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

@ -78,6 +78,14 @@ namespace Avalonia.DesignerSupport.Remote
public IScreenImpl Screen { get; } = new ScreenStub();
public double MinWidth { get; set; }
public double MaxWidth { get; set; }
public double MinHeight { get; set; }
public double MaxHeight { get; set; }
public void SetTitle(string title)
{
}

8
src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs

@ -341,6 +341,14 @@ namespace Avalonia.Gtk3
}
}
public double MinWidth { get; set; }
public double MaxWidth { get; set; }
public double MinHeight { get; set; }
public double MaxHeight { get; set; }
public IMouseDevice MouseDevice => Gtk3Platform.Mouse;
public double Scaling => LastKnownScaleFactor = (int) (Native.GtkWidgetGetScaleFactor?.Invoke(GtkWidget) ?? 1);

8
src/OSX/Avalonia.MonoMac/WindowBaseImpl.cs

@ -161,6 +161,14 @@ namespace Avalonia.MonoMac
Position = pos;
}
public double MinWidth { get; set; }
public double MaxWidth { get; set; }
public double MinHeight { get; set; }
public double MaxHeight { get; set; }
public IScreenImpl Screen
{
get;

10
src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs

@ -615,6 +615,16 @@ namespace Avalonia.Win32.Interop
public uint[] cols;
}
[StructLayout(LayoutKind.Sequential)]
public struct MINMAXINFO
{
public POINT ptReserved;
public POINT ptMaxSize;
public POINT ptMaxPosition;
public POINT ptMinTrackSize;
public POINT ptMaxTrackSize;
}
public const int SizeOf_BITMAPINFOHEADER = 40;
[DllImport("user32.dll")]

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

@ -102,6 +102,14 @@ namespace Avalonia.Win32
}
}
public double MinWidth { get; set; }
public double MaxWidth { get; set; }
public double MinHeight { get; set; }
public double MaxHeight { get; set; }
public IScreenImpl Screen
{
get;
@ -611,7 +619,26 @@ namespace Avalonia.Win32
case UnmanagedMethods.WindowsMessage.WM_MOVE:
PositionChanged?.Invoke(new Point((short)(ToInt32(lParam) & 0xffff), (short)(ToInt32(lParam) >> 16)));
return IntPtr.Zero;
case UnmanagedMethods.WindowsMessage.WM_GETMINMAXINFO:
MINMAXINFO mmi = Marshal.PtrToStructure<UnmanagedMethods.MINMAXINFO>(lParam);
if (MinWidth > 0)
mmi.ptMinTrackSize.X = (int)((MinWidth * Scaling) + BorderThickness.Left + BorderThickness.Right);
if (MinHeight > 0)
mmi.ptMinTrackSize.Y = (int)((MinHeight * Scaling) + BorderThickness.Top + BorderThickness.Bottom);
if (!Double.IsInfinity(MaxWidth) && MaxWidth > 0)
mmi.ptMaxTrackSize.X = (int)((MaxWidth * Scaling) + BorderThickness.Left + BorderThickness.Right);
if (!Double.IsInfinity(MaxHeight) && MaxHeight > 0)
mmi.ptMaxTrackSize.Y = (int)((MaxHeight * Scaling) + BorderThickness.Top + BorderThickness.Bottom);
Marshal.StructureToPtr(mmi, lParam, true);
return IntPtr.Zero;
case UnmanagedMethods.WindowsMessage.WM_DISPLAYCHANGE:
(Screen as ScreenImpl)?.InvalidateScreensCache();
return IntPtr.Zero;

Loading…
Cancel
Save