From f721cee70875951ebe7a4926acf0f3f659a778ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerard=20Gasc=C3=B3n?= <52170489+GerardGascon@users.noreply.github.com> Date: Tue, 16 Apr 2024 13:01:29 +0200 Subject: [PATCH] feat: Added minimum window size --- .../AppWindowUtility/Runtime/Windows/Windows.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Packages/AppWindowUtility/Runtime/Windows/Windows.cs b/Packages/AppWindowUtility/Runtime/Windows/Windows.cs index 475d68e..ba84178 100644 --- a/Packages/AppWindowUtility/Runtime/Windows/Windows.cs +++ b/Packages/AppWindowUtility/Runtime/Windows/Windows.cs @@ -303,37 +303,37 @@ namespace SatorImaging.AppWindowUtility if (resizeDirection.x > 0) { if (resizeDirection.y > 0) { width = (int)(rect.right - rect.left + deltaX); - height = (int)(width / aspectRatio); }else if (resizeDirection.y < 0) { width = (int)(rect.right - rect.left + deltaX); - height = (int)(width / aspectRatio); }else { width = (int)(rect.right - rect.left + deltaX); - height = (int)(width / aspectRatio); } + width = Mathf.Max(width, 100); + height = (int)(width / aspectRatio); }else if (resizeDirection.x < 0) { if (resizeDirection.y > 0) { x += (int)deltaX; width = rect.right - x; - height = (int)(width / aspectRatio); }else if (resizeDirection.y < 0) { x += (int)deltaX; width = rect.right - x; - height = (int)(width / aspectRatio); }else { x += (int)deltaX; width = rect.right - x; - height = (int)(width / aspectRatio); } + if (width < 100) x -= 100 - width; + width = Mathf.Max(width, 100); + height = (int)(width / aspectRatio); } else { if (resizeDirection.y > 0) { y += (int)deltaY; height = rect.bottom - y; - width = (int)(height * aspectRatio); }else if (resizeDirection.y < 0) { height = (int)(rect.bottom - rect.top + deltaY); - width = (int)(height * aspectRatio); } + if (height < 150 && resizeDirection.y > 0) y -= 150 - height; + height = Mathf.Max(height, 150); + width = (int)(height * aspectRatio); } WinApi.SetWindowPos(hWnd, IntPtr.Zero, x, y, width, height, WinApi.SetWindowPosFlags.NoFlag);