You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I have a requirement in my application to restrict window sizes to a multiple of a given size, from what I can tell there is no way to directly do this in Avalonia since the resized event cannot be cancelled or rejected. (The desired behaviour is as Windows Terminal behaves, whereby the window size snaps to multiples of the terminal cell size).
Describe the solution you'd like
Either a way to directly cancel/reject a window resize event, or have the relevant methods in Window or WindowBase etc (HandleResized) not be internal so they can be overriden to manually implement the desired behaviour.
Describe alternatives you've considered
The obvious alternative is to simply resize the window if it is not a desired size, and this sort of works, however not only can you see the window borders flickering as the window is rapidly resizing, the layout for the window seems to be affected as you sometimes seem to end up with the window size and the size the layout code used not matching (i.e. window content too large for the window).
Additional context
No response
The text was updated successfully, but these errors were encountered:
In the past, I had requirement to make window follow specific aspect ratio.
In short, it's not really possible in a cross-platform way.
Where on non-windows OS resizing is happening asynchronously.
For platform specific recommendations, I can say:
On Windows use Win32Properties.AddWndProcHookCallback. It will allow you to handle WndProc and "cancel" resizing events before Avalonia gets them.
On macOS you can get window handle via window.TryGetPlatformHandle(), and set aspectRatio property. But I don't think it would be easily possible to snap to terminal cells
On Linux - good luck. You can listen for resizing events, and then change Position property back. Resizing is always async there.
Is your feature request related to a problem? Please describe.
I have a requirement in my application to restrict window sizes to a multiple of a given size, from what I can tell there is no way to directly do this in Avalonia since the resized event cannot be cancelled or rejected. (The desired behaviour is as Windows Terminal behaves, whereby the window size snaps to multiples of the terminal cell size).
Describe the solution you'd like
Either a way to directly cancel/reject a window resize event, or have the relevant methods in Window or WindowBase etc (HandleResized) not be internal so they can be overriden to manually implement the desired behaviour.
Describe alternatives you've considered
The obvious alternative is to simply resize the window if it is not a desired size, and this sort of works, however not only can you see the window borders flickering as the window is rapidly resizing, the layout for the window seems to be affected as you sometimes seem to end up with the window size and the size the layout code used not matching (i.e. window content too large for the window).
Additional context
No response
The text was updated successfully, but these errors were encountered: