feat: basic window resizing

This commit is contained in:
Gerard Gascón 2024-04-16 01:07:26 +02:00
parent 438b16fc6e
commit ce692af862
18 changed files with 324 additions and 74 deletions

View file

@ -0,0 +1,77 @@
using NUnit.Framework;
using SatorImaging.AppWindowUtility;
using UnityEngine;
public class ResizeTest {
[Test]
public void CheckCenter() {
Vector2 mousePos = new(500, 500);
Vector2 screenSize = new(1280, 1920);
Assert.AreEqual(new Vector2(0, 0), ResizeHelper.GetDirection(mousePos, screenSize));
}
[Test]
public void CheckTopLeft() {
Vector2 mousePos = new(0, 1920);
Vector2 screenSize = new(1280, 1920);
Assert.AreEqual(new Vector2(-1, 1), ResizeHelper.GetDirection(mousePos, screenSize));
}
[Test]
public void CheckTop() {
Vector2 mousePos = new(500, 1920);
Vector2 screenSize = new(1280, 1920);
Assert.AreEqual(new Vector2(0, 1), ResizeHelper.GetDirection(mousePos, screenSize));
}
[Test]
public void CheckTopRight() {
Vector2 mousePos = new(1280, 1920);
Vector2 screenSize = new(1280, 1920);
Assert.AreEqual(new Vector2(1, 1), ResizeHelper.GetDirection(mousePos, screenSize));
}
[Test]
public void CheckLeft() {
Vector2 mousePos = new(0, 500);
Vector2 screenSize = new(1280, 1920);
Assert.AreEqual(new Vector2(-1, 0), ResizeHelper.GetDirection(mousePos, screenSize));
}
[Test]
public void CheckRight() {
Vector2 mousePos = new(1280, 500);
Vector2 screenSize = new(1280, 1920);
Assert.AreEqual(new Vector2(1, 0), ResizeHelper.GetDirection(mousePos, screenSize));
}
[Test]
public void CheckBottomLeft() {
Vector2 mousePos = new(0, 0);
Vector2 screenSize = new(1280, 1920);
Assert.AreEqual(new Vector2(-1, -1), ResizeHelper.GetDirection(mousePos, screenSize));
}
[Test]
public void CheckBottom() {
Vector2 mousePos = new(500, 0);
Vector2 screenSize = new(1280, 1920);
Assert.AreEqual(new Vector2(0, -1), ResizeHelper.GetDirection(mousePos, screenSize));
}
[Test]
public void CheckBottomRight() {
Vector2 mousePos = new(1280, 0);
Vector2 screenSize = new(1280, 1920);
Assert.AreEqual(new Vector2(1, -1), ResizeHelper.GetDirection(mousePos, screenSize));
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec4a69b0e49f65c4c98675104812c31b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,24 @@
{
"name": "SatorImaging.AppWindowUtility.Tests",
"rootNamespace": "",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"SatorImaging.AppWindowUtility"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 39a22fcf88b04a24eb3566b752f8d676
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: