From 88491ffbd80c4b022a1c91dfe91e7024c36cae51 Mon Sep 17 00:00:00 2001 From: maverickdgg Date: Mon, 9 Jan 2023 09:56:46 +0800 Subject: [PATCH] ToggleButton fix --- Assets/Scenes/UI Test.shade.shmeta | 2 +- SHADE_Engine/src/UI/SHUISystem.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Assets/Scenes/UI Test.shade.shmeta b/Assets/Scenes/UI Test.shade.shmeta index e65c0b8f..ad821810 100644 --- a/Assets/Scenes/UI Test.shade.shmeta +++ b/Assets/Scenes/UI Test.shade.shmeta @@ -1,3 +1,3 @@ Name: UI Test -ID: 96041206 +ID: 88543249 Type: 5 diff --git a/SHADE_Engine/src/UI/SHUISystem.cpp b/SHADE_Engine/src/UI/SHUISystem.cpp index 571eb167..95663bc0 100644 --- a/SHADE_Engine/src/UI/SHUISystem.cpp +++ b/SHADE_Engine/src/UI/SHUISystem.cpp @@ -161,7 +161,9 @@ namespace SHADE windowSize = SHEditorWindowManager::GetEditorWindow()->windowSize; mousePos = SHEditorWindowManager::GetEditorWindow()->viewportMousePos; //mousePos.y = windowSize.y - mousePos.y; + SHLOG_INFO("mouse pos: {}, {}", mousePos.x, mousePos.y) mousePos /= windowSize; + SHLOG_INFO("mouse pos normalized: {}, {}", mousePos.x, mousePos.y) #endif SHVec2 camSize{ cameraSystem->GetCameraWidthHeight(0)}; @@ -169,6 +171,7 @@ namespace SHADE topExtent = CanvasToScreenPoint(topExtent); btmExtent = CanvasToScreenPoint(btmExtent); + //SHLOG_INFO("TopExtent: {}, {} Btm Extent: {}, {}", topExtent.x, topExtent.y, btmExtent.x, btmExtent.y) topExtent /= camSize; btmExtent /= camSize; @@ -210,8 +213,9 @@ namespace SHADE auto cameraSystem = SHSystemManager::GetSystem(); auto uiComp = SHComponentManager::GetComponent(comp.GetEID()); - SHVec4 topExtent4 = uiComp->GetMatrix() * SHVec4(-comp.size.x * 0.5f, comp.size.y * 0.5f, 0.0f, 1.0f); - SHVec4 btmExtent4 = uiComp->GetMatrix() * SHVec4(comp.size.x * 0.5f, -comp.size.y * 0.5f, 0.0f, 1.0f); + SHVec4 topExtent4 = SHMatrix::Translate(-comp.size.x * 0.5f, comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f); + SHVec4 btmExtent4 = SHMatrix::Translate(comp.size.x * 0.5f, -comp.size.y * 0.5f, 0.0f) * uiComp->GetMatrix() * SHVec4(0.0f, 0.0f, 0.0f, 1.0f); + SHVec2 topExtent{ topExtent4.x,topExtent4.y }; SHVec2 btmExtent{ btmExtent4.x,btmExtent4.y };