Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
98d43f8
Make sure to use the correct p/invoke for 32-bit
mattleibow Feb 9, 2022
7303667
Add the option for 32 apps in the sample
mattleibow Feb 9, 2022
bee4827
hax
mattleibow Feb 10, 2022
b8de480
Use new APIs
mattleibow Feb 10, 2022
a336aca
hax
mattleibow Feb 11, 2022
6cc3c0a
Merge remote-tracking branch 'origin/main' into dev/window-bounds
mattleibow Feb 11, 2022
35c9d6c
Merge remote-tracking branch 'origin/main' into dev/window-bounds
mattleibow Feb 11, 2022
b8f480e
Initial work to get window sizing
mattleibow Feb 11, 2022
4d050d5
Merge remote-tracking branch 'origin/main' into dev/window-bounds
mattleibow Aug 3, 2022
302dd82
Merge remote-tracking branch 'origin/main' into dev/window-bounds
mattleibow Aug 10, 2022
5c8f1b7
Add more things
mattleibow Aug 10, 2022
36fc670
No need for 2 properties
mattleibow Aug 11, 2022
af2d264
Merge branch 'main' into dev/window-bounds
mattleibow Aug 18, 2022
5f6f001
Improve the API a bit
mattleibow Aug 18, 2022
6455951
Add min/max bounds to IWindow
mattleibow Aug 18, 2022
a074222
event EventHandler? SizeChanged
mattleibow Aug 18, 2022
204d3f8
Tests
mattleibow Aug 18, 2022
efdea51
Merge branch 'main' into dev/window-bounds
mattleibow Aug 18, 2022
b92d117
center window test
mattleibow Aug 18, 2022
96b1da4
Merge branch 'main' into dev/window-bounds
mattleibow Aug 18, 2022
c25679f
revert more things
mattleibow Aug 18, 2022
48ba13f
public api
mattleibow Aug 19, 2022
1609afa
Fix warnings about ios13
mattleibow Aug 19, 2022
0c08e45
more fixes
mattleibow Aug 19, 2022
7f8fd71
Merge branch 'main' into dev/window-bounds
mattleibow Aug 19, 2022
d35c8f8
Merge branch 'main' into dev/window-bounds
mattleibow Aug 22, 2022
bdba065
Update PublicAPI.Unshipped.txt
mattleibow Aug 22, 2022
918f6c4
ws
mattleibow Aug 22, 2022
0f9d7ac
reverse logic
mattleibow Aug 22, 2022
09672d2
TESTS
mattleibow Aug 23, 2022
393a19c
Merge remote-tracking branch 'origin/main' into dev/window-bounds
mattleibow Aug 23, 2022
800ff9d
Merge remote-tracking branch 'origin/main' into dev/window-bounds
mattleibow Aug 23, 2022
358e4e5
Initial code to support the window manager
mattleibow Aug 23, 2022
5dbc420
swap
mattleibow Aug 23, 2022
cdc3bf1
rename
mattleibow Aug 23, 2022
a10b22b
ws
mattleibow Aug 23, 2022
54a2434
Merge remote-tracking branch 'origin/main' into dev/window-manager
mattleibow Aug 24, 2022
b159c09
Add unit tests for WindowMessageManager
mattleibow Aug 24, 2022
6b8c94e
More device tests for windows
mattleibow Aug 24, 2022
774977d
Merge branch 'main' into dev/window-bounds
mattleibow Aug 24, 2022
945aca3
Windows display size is the Screen not Window
mattleibow Aug 24, 2022
fc27a3e
Clean up unused externs
mattleibow Aug 24, 2022
4db7a37
Merge branch 'dev/fix-rotation' into dev/wm-fr
mattleibow Aug 24, 2022
5b86660
Merge branch 'dev/wm-fr' into dev/window-bounds
mattleibow Aug 24, 2022
11e6120
Update DeviceDisplay.uwp.cs
mattleibow Aug 24, 2022
0f4611d
Add support for min/max on windows
mattleibow Aug 25, 2022
94b3a10
Merge branch 'main' into dev/window-manager
mattleibow Aug 25, 2022
b63b6ce
Merge remote-tracking branch 'origin/main' into dev/window-manager
mattleibow Aug 25, 2022
6f9576f
Merge branch 'dev/window-manager' into dev/window-bounds
mattleibow Aug 25, 2022
41ffd52
windows tests
mattleibow Aug 25, 2022
74fff93
fix that
mattleibow Aug 25, 2022
e54fd05
add back the tests
mattleibow Aug 25, 2022
c1c7422
Update MauiWinUIWindow.cs
mattleibow Aug 25, 2022
d966e90
Merge branch 'main' into dev/window-manager
mattleibow Aug 26, 2022
5f7a4fc
Merge remote-tracking branch 'origin/main' into dev/window-manager
mattleibow Aug 26, 2022
cb9e362
Merge branch 'dev/window-manager' into dev/window-bounds
mattleibow Aug 26, 2022
fccc00a
Merge branch 'main' into dev/window-bounds
mattleibow Aug 26, 2022
8db79c1
Merge branch 'main' into dev/window-bounds
mattleibow Aug 26, 2022
024cb8f
Fix the min/max logic
mattleibow Aug 26, 2022
cb32db4
Merge branch 'main' into dev/window-bounds
mattleibow Aug 26, 2022
0466051
Clean up the API a bit more
mattleibow Aug 26, 2022
4526c72
Make sure Mac Catalyst has valid values
mattleibow Aug 27, 2022
4a86534
Merge branch 'main' into dev/window-bounds
mattleibow Aug 27, 2022
b4114f7
IWindow.Frame is not actually used
mattleibow Aug 27, 2022
2078ba1
My empty commit with a message
mattleibow Aug 27, 2022
72b807c
useless comment
mattleibow Aug 27, 2022
6d98cb0
device tests can only run on mac catalyst
mattleibow Aug 27, 2022
1c733cf
Fix tests
mattleibow Aug 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions _omnisharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Controls.Foldable", "src\Co
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maps", "src\Core\maps\src\Maps.csproj", "{1C9F9D5A-2CF7-4ADB-A9F5-672ACC05B035}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Graphics", "Graphics", "{E4884871-4A1B-43BC-814F-E3D6E52B1673}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{42AB9AE1-631D-4AD4-85B7-910FF0940BDB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{936C47A9-A7EA-4FBD-8733-CED1D4100E69}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Graphics", "src\Graphics\src\Graphics\Graphics.csproj", "{CF056C95-51C4-4366-9D06-41D2B15EFEE4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Graphics.Tests", "src\Graphics\tests\Graphics.Tests\Graphics.Tests.csproj", "{56BBFDBD-254F-42B6-9984-46E19C53FB00}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -211,6 +221,14 @@ Global
{1C9F9D5A-2CF7-4ADB-A9F5-672ACC05B035}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C9F9D5A-2CF7-4ADB-A9F5-672ACC05B035}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C9F9D5A-2CF7-4ADB-A9F5-672ACC05B035}.Release|Any CPU.Build.0 = Release|Any CPU
{CF056C95-51C4-4366-9D06-41D2B15EFEE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF056C95-51C4-4366-9D06-41D2B15EFEE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF056C95-51C4-4366-9D06-41D2B15EFEE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF056C95-51C4-4366-9D06-41D2B15EFEE4}.Release|Any CPU.Build.0 = Release|Any CPU
{56BBFDBD-254F-42B6-9984-46E19C53FB00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56BBFDBD-254F-42B6-9984-46E19C53FB00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56BBFDBD-254F-42B6-9984-46E19C53FB00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56BBFDBD-254F-42B6-9984-46E19C53FB00}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -254,6 +272,10 @@ Global
{50BCB5CD-DC2A-42AA-B921-D99B19625CE1} = {C564DDD6-DE79-45CD-88EA-3F690481572A}
{F0A48792-ACD7-4B72-83EB-C56A70FA5A3A} = {50C758FE-4E10-409A-94F5-A75480960864}
{1C9F9D5A-2CF7-4ADB-A9F5-672ACC05B035} = {E8AD265B-3C67-4640-AC58-A522F9FB3361}
{42AB9AE1-631D-4AD4-85B7-910FF0940BDB} = {E4884871-4A1B-43BC-814F-E3D6E52B1673}
{936C47A9-A7EA-4FBD-8733-CED1D4100E69} = {E4884871-4A1B-43BC-814F-E3D6E52B1673}
{CF056C95-51C4-4366-9D06-41D2B15EFEE4} = {42AB9AE1-631D-4AD4-85B7-910FF0940BDB}
{56BBFDBD-254F-42B6-9984-46E19C53FB00} = {936C47A9-A7EA-4FBD-8733-CED1D4100E69}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0B8ABEAD-D2B5-4370-A187-62B5ABE4EE50}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,44 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Pages.MultiWindowPage"
xmlns:views="clr-namespace:Maui.Controls.Sample.Pages.Base">
<views:BasePage.Content>
<StackLayout
Margin="12">
<Button
Clicked="OnNewWindowClicked"
Text="Open new Window" />

<Button
Clicked="OnCloseWindowClicked"
Text="Close this Window" />

<Label Text="Window Count: 0" x:Name="label" />
</StackLayout>
</views:BasePage.Content>

<StackLayout
Margin="12">

<Button
Clicked="OnNewWindowClicked"
Text="Open a new Window" />

<Button
Clicked="OnCloseWindowClicked"
Text="Close this Window" />

<Label Text="Window Frame:" />
<Label Text="{Binding Window.X, StringFormat='X = {0:0.00}'}" />
<Label Text="{Binding Window.Y, StringFormat='Y = {0:0.00}'}" />
<Label Text="{Binding Window.Width, StringFormat='W = {0:0.00}'}" />
<Label Text="{Binding Window.Height, StringFormat='H = {0:0.00}'}" />

<Button
Clicked="OnSetMinSize"
Text="Set the minimum size to 640x480" />

<Button
Clicked="OnSetMaxSize"
Text="Set the maximum size to 800x600" />

<Button
Clicked="OnSetFreeSize"
Text="Remove size restrictions" />

<Button
Clicked="OnSetCustomSize"
Text="Set window size to 700x500" />

<Button
Clicked="OnCenterWindow"
Text="Center window" />

</StackLayout>

</views:BasePage>
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using System;
using Maui.Controls.Sample.Pages.Base;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Devices;

namespace Maui.Controls.Sample.Pages
{
public partial class MultiWindowPage : BasePage
{
static int windowCounter = 1;

public MultiWindowPage()
{
InitializeComponent();

label.Text = "Window Count: " + (windowCounter++).ToString();
BindingContext = this;
}

void OnNewWindowClicked(object sender, EventArgs e)
Expand All @@ -22,9 +21,42 @@ void OnNewWindowClicked(object sender, EventArgs e)

void OnCloseWindowClicked(object sender, EventArgs e)
{
var window = this.GetParentWindow();
if (window is not null)
Application.Current.CloseWindow(window);
Application.Current.CloseWindow(Window);
}

void OnSetMaxSize(object sender, EventArgs e)
{
Window.MaximumWidth = 800;
Window.MaximumHeight = 600;
}

void OnSetMinSize(object sender, EventArgs e)
{
Window.MinimumWidth = 640;
Window.MinimumHeight = 480;
}

void OnSetFreeSize(object sender, EventArgs e)
{
Window.MaximumWidth = double.PositiveInfinity;
Window.MaximumHeight = double.PositiveInfinity;

Window.MinimumWidth = -1d;
Window.MinimumHeight = -1d;
}

void OnSetCustomSize(object sender, EventArgs e)
{
Window.Width = 700;
Window.Height = 500;
}

void OnCenterWindow(object sender, EventArgs e)
{
var disp = DeviceDisplay.MainDisplayInfo;

Window.X = (disp.Width / disp.Density - Window.Width) / 2;
Window.Y = (disp.Height / disp.Density - Window.Height) / 2;
}
}
}
140 changes: 140 additions & 0 deletions src/Controls/src/Core/HandlerImpl/Window/Window.Impl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading.Tasks;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;

namespace Microsoft.Maui.Controls
{
Expand All @@ -25,6 +26,30 @@ public partial class Window : NavigableElement, IWindow, IVisualTreeElement, ITo
public static readonly BindableProperty FlowDirectionProperty =
BindableProperty.Create(nameof(FlowDirection), typeof(FlowDirection), typeof(Window), FlowDirection.MatchParent, propertyChanging: FlowDirectionChanging, propertyChanged: FlowDirectionChanged);

public static readonly BindableProperty XProperty = BindableProperty.Create(
nameof(X), typeof(double), typeof(Window), Primitives.Dimension.Unset);

public static readonly BindableProperty YProperty = BindableProperty.Create(
nameof(Y), typeof(double), typeof(Window), Primitives.Dimension.Unset);

public static readonly BindableProperty WidthProperty = BindableProperty.Create(
nameof(Width), typeof(double), typeof(Window), Primitives.Dimension.Unset);

public static readonly BindableProperty HeightProperty = BindableProperty.Create(
nameof(Height), typeof(double), typeof(Window), Primitives.Dimension.Unset);

public static readonly BindableProperty MaximumWidthProperty = BindableProperty.Create(
nameof(MaximumWidth), typeof(double), typeof(Window), Primitives.Dimension.Maximum);

public static readonly BindableProperty MaximumHeightProperty = BindableProperty.Create(
nameof(MaximumHeight), typeof(double), typeof(Window), Primitives.Dimension.Maximum);

public static readonly BindableProperty MinimumWidthProperty = BindableProperty.Create(
nameof(MinimumWidth), typeof(double), typeof(Window), Primitives.Dimension.Minimum);

public static readonly BindableProperty MinimumHeightProperty = BindableProperty.Create(
nameof(MinimumHeight), typeof(double), typeof(Window), Primitives.Dimension.Minimum);

HashSet<IWindowOverlay> _overlays = new HashSet<IWindowOverlay>();
ReadOnlyCollection<Element>? _logicalChildren;
List<IVisualTreeElement> _visualChildren;
Expand All @@ -47,6 +72,8 @@ internal Toolbar? Toolbar
}
}

public event EventHandler? SizeChanged;

public IReadOnlyCollection<IWindowOverlay> Overlays => _overlays.ToList().AsReadOnly();

public IVisualDiagnosticsOverlay VisualDiagnosticsOverlay { get; }
Expand Down Expand Up @@ -86,6 +113,114 @@ public Page? Page
set => SetValue(PageProperty, value);
}

public double X
{
get => (double)GetValue(XProperty);
set => SetValue(XProperty, value);
}

public double Y
{
get => (double)GetValue(YProperty);
set => SetValue(YProperty, value);
}

public double Width
{
get => (double)GetValue(WidthProperty);
set => SetValue(WidthProperty, value);
}

public double Height
{
get => (double)GetValue(HeightProperty);
set => SetValue(HeightProperty, value);
}

public double MaximumWidth
{
get => (double)GetValue(MaximumWidthProperty);
set => SetValue(MaximumWidthProperty, value);
}

public double MaximumHeight
{
get => (double)GetValue(MaximumHeightProperty);
set => SetValue(MaximumHeightProperty, value);
}

public double MinimumWidth
{
get => (double)GetValue(MinimumWidthProperty);
set => SetValue(MinimumWidthProperty, value);
}

public double MinimumHeight
{
get => (double)GetValue(MinimumHeightProperty);
set => SetValue(MinimumHeightProperty, value);
}

double IWindow.X => GetPositionCoordinate(XProperty);

double IWindow.Y => GetPositionCoordinate(YProperty);

double IWindow.Width => GetSizeCoordinate(WidthProperty);

double IWindow.Height => GetSizeCoordinate(HeightProperty);

double IWindow.MaximumWidth => GetSizeCoordinate(MaximumWidthProperty);

double IWindow.MaximumHeight => GetSizeCoordinate(MaximumHeightProperty);

double IWindow.MinimumWidth => GetSizeCoordinate(MinimumWidthProperty);

double IWindow.MinimumHeight => GetSizeCoordinate(MinimumHeightProperty);

double GetPositionCoordinate(BindableProperty property)
{
if (!IsSet(property))
return Primitives.Dimension.Unset;
var coord = (double)GetValue(property);
if (!Primitives.Dimension.IsExplicitSet(coord))
return Primitives.Dimension.Unset;
return coord;
}

double GetSizeCoordinate(BindableProperty property)
{
if (!IsSet(property))
return Primitives.Dimension.Unset;
var coord = (double)GetValue(property);
if (coord == -1 || !Primitives.Dimension.IsExplicitSet(coord))
return Primitives.Dimension.Unset;
return ValidatePositive(coord);
}

int _batchFrameUpdate = 0;

void IWindow.FrameChanged(Rect frame)
{
if (new Rect(X, Y, Width, Height) == frame)
return;

_batchFrameUpdate++;

X = frame.X;
Y = frame.Y;
Width = frame.Width;
Height = frame.Height;

_batchFrameUpdate--;
if (_batchFrameUpdate < 0)
_batchFrameUpdate = 0;

if (_batchFrameUpdate == 0)
{
SizeChanged?.Invoke(this, EventArgs.Empty);
}
}

public event EventHandler<ModalPoppedEventArgs>? ModalPopped;
public event EventHandler<ModalPoppingEventArgs>? ModalPopping;
public event EventHandler<ModalPushedEventArgs>? ModalPushed;
Expand Down Expand Up @@ -519,6 +654,11 @@ bool IWindow.BackButtonClicked()
return this.Page?.SendBackButtonPressed() ?? false;
}

static double ValidatePositive(double value, [CallerMemberName] string? name = null) =>
value >= 0
? value
: throw new InvalidOperationException($"{name} cannot be less than zero.");

class NavigationImpl : NavigationProxy
{
readonly Window _owner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ Microsoft.Maui.Controls.TapGestureRecognizer.Tapped -> System.EventHandler<Micro
Microsoft.Maui.Controls.TappedEventArgs.Buttons.get -> Microsoft.Maui.Controls.ButtonsMask
Microsoft.Maui.Controls.ToolTipProperties
Microsoft.Maui.Controls.ToolTipProperties.ToolTipProperties() -> void
Microsoft.Maui.Controls.Window.Height.get -> double
Microsoft.Maui.Controls.Window.Height.set -> void
Microsoft.Maui.Controls.Window.MaximumHeight.get -> double
Microsoft.Maui.Controls.Window.MaximumHeight.set -> void
Microsoft.Maui.Controls.Window.MaximumWidth.get -> double
Microsoft.Maui.Controls.Window.MaximumWidth.set -> void
Microsoft.Maui.Controls.Window.MinimumHeight.get -> double
Microsoft.Maui.Controls.Window.MinimumHeight.set -> void
Microsoft.Maui.Controls.Window.MinimumWidth.get -> double
Microsoft.Maui.Controls.Window.MinimumWidth.set -> void
Microsoft.Maui.Controls.Window.SizeChanged -> System.EventHandler?
Microsoft.Maui.Controls.Window.Width.get -> double
Microsoft.Maui.Controls.Window.Width.set -> void
Microsoft.Maui.Controls.Window.X.get -> double
Microsoft.Maui.Controls.Window.X.set -> void
Microsoft.Maui.Controls.Window.Y.get -> double
Microsoft.Maui.Controls.Window.Y.set -> void
override Microsoft.Maui.Controls.ContentPresenter.ArrangeOverride(Microsoft.Maui.Graphics.Rect bounds) -> Microsoft.Maui.Graphics.Size
override Microsoft.Maui.Controls.ContentPresenter.MeasureOverride(double widthConstraint, double heightConstraint) -> Microsoft.Maui.Graphics.Size
override Microsoft.Maui.Controls.FlyoutPage.OnDisappearing() -> void
Expand All @@ -51,6 +68,14 @@ static readonly Microsoft.Maui.Controls.PointerGestureRecognizer.PointerExitedCo
static readonly Microsoft.Maui.Controls.PointerGestureRecognizer.PointerMovedCommandParameterProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.PointerGestureRecognizer.PointerMovedCommandProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.ToolTipProperties.TextProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.Window.HeightProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.Window.MaximumHeightProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.Window.MaximumWidthProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.Window.MinimumHeightProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.Window.MinimumWidthProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.Window.WidthProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.Window.XProperty -> Microsoft.Maui.Controls.BindableProperty!
static readonly Microsoft.Maui.Controls.Window.YProperty -> Microsoft.Maui.Controls.BindableProperty!
virtual Microsoft.Maui.Controls.PointerEventArgs.GetPosition(Microsoft.Maui.Controls.Element? relativeTo) -> Microsoft.Maui.Graphics.Point?
virtual Microsoft.Maui.Controls.TappedEventArgs.GetPosition(Microsoft.Maui.Controls.Element? relativeTo) -> Microsoft.Maui.Graphics.Point?
~Microsoft.Maui.Controls.MenuFlyout.Add(Microsoft.Maui.IMenuElement item) -> void
Expand Down
Loading