-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Windows Popup Position and Size #1350
Conversation
Additional Information: |
The PR I uploaded today does not support maximizing/minimizing the window that displays the Popup, so we will fix it. |
In order to support maximizing/minimizing the window, the acquisition of the window
This removed the need to get the title bar height. In addition, the calculation formulas for horizontal position and vertical position have been changed. |
src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.windows.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please resolve conflicts?
src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.windows.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.windows.cs
Outdated
Show resolved
Hide resolved
1. Remove standardSize variable 2. Invert if
@VladislavAntonyuk , I resolved the conflict. |
This PR fixes the following:
Description of Change
Modified as follows to update the position of the Popup following the resizing of the Window that displays the Popup.
[src\CommunityToolkit.Maui.Core\Handlers\Popup\PopUpHandler.windows.cs]
Caught Window's SizeChanged event and called SetSize and SetLayout methods.
As a result, the position of the Popup is updated according to the resizing of the Window that displays the Popup.
Next, I added the following code to limit the Content Size to the Size specified in the Popup's Size property.
[src\CommunityToolkit.Maui.Core\Views\Popup\PopupExtensions.windows.cs]
By explicitly specifying the size of the Popup's Child, the size of the Popup is now limited.
Next, I changed the code as follows so that it is displayed at the intended position when Center or End is specified for VerticalOptions of Popup.
I had to get the height of the Window's title bar because it wasn't taking into account the height of the Window's title bar.
The GetTitleBarRectangle method that acquires the Rectangle of the title bar added this time was implemented with reference to the following source code of .NET MAUI.
[src\Platform\Windows\WindowExtensions.cs]
With this fix, when Center or End is specified for VerticalOptions of Popup, it is now displayed at the intended position.
Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information
The following is the verification result when the Content Size exceeds the Size specified in the Popup Size property.
Size = "100, 100" HorizontalOptions = "Start" VerticalOptions = "Center"
You can see that the Popup's Content Size is limited by the Size specified in the Popup's Size property.
Next is the verification result when Center is specified for VerticalOptions of Popup.
Size = "100, 100" HorizontalOptions = "Start" VerticalOptions = "Center"
Size = "100, 100" HorizontalOptions = "Center" VerticalOptions = "Center"
Size = "100, 100" HorizontalOptions = "End" VerticalOptions = "Center"
The red line in the execution result is the horizontal and vertical center.
You can see that the Popup is displayed in the center of the Window from which the Popup is displayed when Center is specified for the VerticalOptions of the Popup.
Next is the verification result when End is specified for VerticalOptions of Popup.
Size = "100, 100" HorizontalOptions = "Start" VerticalOptions = "End"
Size = "100, 100" HorizontalOptions = "Center" VerticalOptions = "End"
Size = "100, 100" HorizontalOptions = "End" VerticalOptions = "End"
You can see that when the Popup's VerticalOptions is set to End, the Popup is displayed so that it fits at the bottom of the Window from which the Popup is displayed.
Next is the verification result when resizing the Window that is the display source of the Popup.
Size = "100, 100" HorizontalOptions = "Start" VerticalOptions = "End" CanBeDismissedByTappingOutsideOfPopup = "False"
You can see that the position of the Popup is updated according to the resizing of the Window that displays the Popup.
Concerns:
I can't verify it because I don't have a verification environment for Windows 10 at hand.