Loading Packages/AppWindowUtility/Runtime/ResizeHelper.cs +6 −6 Original line number Diff line number Diff line Loading @@ -12,27 +12,27 @@ namespace SatorImaging.AppWindowUtility { if (widthPercentage < marginWidthPercentage) { if (heightPercentage > 1 - marginHeightPercentage) return new Vector2(-1, 1); if (heightPercentage < marginHeightPercentage) return new Vector2(-1, -1); if (heightPercentage < marginHeightPercentage) return new Vector2(-1, 1); return new Vector2(-1, 0); } if (widthPercentage > 1 - marginWidthPercentage) { if (heightPercentage > 1 - marginHeightPercentage) return new Vector2(1, 1); if (heightPercentage < marginHeightPercentage) return new Vector2(1, -1); if (heightPercentage < marginHeightPercentage) return new Vector2(1, 1); return new Vector2(1, 0); } if (heightPercentage > 1 - marginHeightPercentage) return new Vector2(0, 1); return new Vector2(0, -1); if (heightPercentage < marginHeightPercentage) return new Vector2(0, -1); return new Vector2(0, 1); return Vector2.zero; } Loading Packages/AppWindowUtility/Runtime/WindowResizer.cs +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ namespace SatorImaging.AppWindowUtility { if (_resizeDirection.x < 0) _targetPosition.x -= delta.x; if (_resizeDirection.y < 0) if (_resizeDirection.y > 0) _targetPosition.y -= delta.y; } } Loading Packages/AppWindowUtility/Runtime/Windows/Windows.cs +37 −16 Original line number Diff line number Diff line Loading @@ -295,24 +295,45 @@ namespace SatorImaging.AppWindowUtility WinApi.RECT rect; WinApi.GetWindowRect(hWnd, out rect); float resizeFactor = Mathf.Abs(resizeDirection.x) > Mathf.Abs(resizeDirection.y) ? deltaX : deltaY; int x = rect.left; int y = rect.top; int width = (int)(rect.right - rect.left + resizeFactor); //int height = (int)(rect.bottom - rect.top + deltaY); if (resizeDirection.x < 0) { x += (int)resizeFactor; int width = 0; int height = 0; 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); } }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); } int height = (int)(width / aspectRatio); if (resizeDirection.y < 0) { y += (int)resizeFactor; } 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); } } WinApi.SetWindowPos(hWnd, IntPtr.Zero, x, y, width, height, WinApi.SetWindowPosFlags.NoFlag); Loading Packages/AppWindowUtility/Tests/ResizeTest.cs +6 −6 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ public class ResizeTest { [Test] public void CheckTopLeft() { Vector2 mousePos = new(0, 1920); Vector2 mousePos = new(0, 0); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(-1, 1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading @@ -21,7 +21,7 @@ public class ResizeTest { [Test] public void CheckTop() { Vector2 mousePos = new(500, 1920); Vector2 mousePos = new(500, 0); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(0, 1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading @@ -29,7 +29,7 @@ public class ResizeTest { [Test] public void CheckTopRight() { Vector2 mousePos = new(1280, 1920); Vector2 mousePos = new(1280, 0); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(1, 1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading @@ -53,7 +53,7 @@ public class ResizeTest { [Test] public void CheckBottomLeft() { Vector2 mousePos = new(0, 0); Vector2 mousePos = new(0, 1920); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(-1, -1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading @@ -61,7 +61,7 @@ public class ResizeTest { [Test] public void CheckBottom() { Vector2 mousePos = new(500, 0); Vector2 mousePos = new(500, 1920); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(0, -1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading @@ -69,7 +69,7 @@ public class ResizeTest { [Test] public void CheckBottomRight() { Vector2 mousePos = new(1280, 0); Vector2 mousePos = new(1280, 1920); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(1, -1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading Loading
Packages/AppWindowUtility/Runtime/ResizeHelper.cs +6 −6 Original line number Diff line number Diff line Loading @@ -12,27 +12,27 @@ namespace SatorImaging.AppWindowUtility { if (widthPercentage < marginWidthPercentage) { if (heightPercentage > 1 - marginHeightPercentage) return new Vector2(-1, 1); if (heightPercentage < marginHeightPercentage) return new Vector2(-1, -1); if (heightPercentage < marginHeightPercentage) return new Vector2(-1, 1); return new Vector2(-1, 0); } if (widthPercentage > 1 - marginWidthPercentage) { if (heightPercentage > 1 - marginHeightPercentage) return new Vector2(1, 1); if (heightPercentage < marginHeightPercentage) return new Vector2(1, -1); if (heightPercentage < marginHeightPercentage) return new Vector2(1, 1); return new Vector2(1, 0); } if (heightPercentage > 1 - marginHeightPercentage) return new Vector2(0, 1); return new Vector2(0, -1); if (heightPercentage < marginHeightPercentage) return new Vector2(0, -1); return new Vector2(0, 1); return Vector2.zero; } Loading
Packages/AppWindowUtility/Runtime/WindowResizer.cs +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ namespace SatorImaging.AppWindowUtility { if (_resizeDirection.x < 0) _targetPosition.x -= delta.x; if (_resizeDirection.y < 0) if (_resizeDirection.y > 0) _targetPosition.y -= delta.y; } } Loading
Packages/AppWindowUtility/Runtime/Windows/Windows.cs +37 −16 Original line number Diff line number Diff line Loading @@ -295,24 +295,45 @@ namespace SatorImaging.AppWindowUtility WinApi.RECT rect; WinApi.GetWindowRect(hWnd, out rect); float resizeFactor = Mathf.Abs(resizeDirection.x) > Mathf.Abs(resizeDirection.y) ? deltaX : deltaY; int x = rect.left; int y = rect.top; int width = (int)(rect.right - rect.left + resizeFactor); //int height = (int)(rect.bottom - rect.top + deltaY); if (resizeDirection.x < 0) { x += (int)resizeFactor; int width = 0; int height = 0; 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); } }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); } int height = (int)(width / aspectRatio); if (resizeDirection.y < 0) { y += (int)resizeFactor; } 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); } } WinApi.SetWindowPos(hWnd, IntPtr.Zero, x, y, width, height, WinApi.SetWindowPosFlags.NoFlag); Loading
Packages/AppWindowUtility/Tests/ResizeTest.cs +6 −6 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ public class ResizeTest { [Test] public void CheckTopLeft() { Vector2 mousePos = new(0, 1920); Vector2 mousePos = new(0, 0); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(-1, 1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading @@ -21,7 +21,7 @@ public class ResizeTest { [Test] public void CheckTop() { Vector2 mousePos = new(500, 1920); Vector2 mousePos = new(500, 0); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(0, 1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading @@ -29,7 +29,7 @@ public class ResizeTest { [Test] public void CheckTopRight() { Vector2 mousePos = new(1280, 1920); Vector2 mousePos = new(1280, 0); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(1, 1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading @@ -53,7 +53,7 @@ public class ResizeTest { [Test] public void CheckBottomLeft() { Vector2 mousePos = new(0, 0); Vector2 mousePos = new(0, 1920); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(-1, -1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading @@ -61,7 +61,7 @@ public class ResizeTest { [Test] public void CheckBottom() { Vector2 mousePos = new(500, 0); Vector2 mousePos = new(500, 1920); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(0, -1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading @@ -69,7 +69,7 @@ public class ResizeTest { [Test] public void CheckBottomRight() { Vector2 mousePos = new(1280, 0); Vector2 mousePos = new(1280, 1920); Vector2 screenSize = new(1280, 1920); Assert.AreEqual(new Vector2(1, -1), ResizeHelper.GetDirection(mousePos, screenSize)); Loading