Skip to content

Commit

Permalink
[Shell] Fix invalid dialog window size
Browse files Browse the repository at this point in the history
  • Loading branch information
BAndysc committed Aug 30, 2023
1 parent 3fe212b commit a204cee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public interface IAbstractWindowView
bool IsMaximized { get; }
(int x, int y) Position { get; }
(int x, int y) Size { get; }
(int x, int y) LogicalSize { get; }
void Reposition(int x, int y, bool isMaximized, int width, int height);
event Action? OnClosing;
}
Expand Down
14 changes: 13 additions & 1 deletion WoWDatabaseEditorCore.Avalonia/Managers/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,25 @@ public bool IsMaximized
}
}

public (int x, int y) LogicalSize
{
get
{
if (window.TryGetTarget(out var target))
{
return ((int)target.Width, (int)target.Height);
}
return (100, 100);
}
}

public (int x, int y) Size
{
get
{
if (window.TryGetTarget(out var target))
{
// we use screen coords for size so that size is custom app scaling independent
// we use screen coords for size so that size is custom app scaling independent
var screenTopLeftPoint = target.PointToScreen(new Point(target.Position.X, target.Position.Y));
var screenBottomRightPoint = target.PointToScreen(new Point(target.Position.X + target.ClientSize.Width, target.Position.Y + target.ClientSize.Height));
var width = screenBottomRightPoint.X - screenTopLeftPoint.X;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void SetupWindow(string key, IAbstractWindowView window)
window.OnClosing += () =>
{
var position = window.Position;
var size = window.Size;
var size = window.LogicalSize; // we use LogicalSize here, because then we set Width directly
var maximized = window.IsMaximized;
UpdateWindowState(key, maximized, position.x, position.y, size.x, size.y);
};
Expand Down

0 comments on commit a204cee

Please sign in to comment.