From 039ed017d986c1cc530ee0f3aedbe4017ef300e5 Mon Sep 17 00:00:00 2001 From: lnd3 Date: Tue, 20 Aug 2024 17:10:39 +0200 Subject: [PATCH] Add ui split container. --- .../include/rendering/ui/UIContainer.h | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/rendering/include/rendering/ui/UIContainer.h b/packages/rendering/include/rendering/ui/UIContainer.h index 474b24a7..555fc80b 100644 --- a/packages/rendering/include/rendering/ui/UIContainer.h +++ b/packages/rendering/include/rendering/ui/UIContainer.h @@ -92,6 +92,10 @@ namespace l::ui { return transformed; } + float GetWorldScale(float parentScale) { + return parentScale * mScale; + } + // Used in ui container layout, this is where we premultiply parent scale ImVec2 GetWorldPos(float parentScale, ImVec2 parentPos) { ImVec2 worldPos; @@ -100,8 +104,18 @@ namespace l::ui { return worldPos; } - float GetWorldScale(float parentScale) { - return parentScale * mScale; + ImVec2 GetWorldSize(float parentScale) const { + ImVec2 worldSize; + worldSize.x = (mSize.x - mLayout.mBorder * 2.0f) * mScale * parentScale; + worldSize.y = (mSize.y - mLayout.mBorder * 2.0f) * mScale * parentScale; + return worldSize; + } + + ImVec2 GetLocalSize() const { + ImVec2 localSize; + localSize.x = mSize.x / mScale; + localSize.y = mSize.y / mScale; + return localSize; } ImVec2 GetWorldPosLayout(float parentScale, ImVec2 parentPos, ImVec2 contentSize, UIAlignH alignH, UIAlignV alignV) { @@ -131,19 +145,12 @@ namespace l::ui { return worldPos; } - ImVec2 GetWorldSize(float parentScale) const { + ImVec2 GetWorldSizeLayout(float parentScale) const { ImVec2 worldSize; worldSize.x = (mSize.x - mLayout.mBorder * 2.0f) * mScale * parentScale; worldSize.y = (mSize.y - mLayout.mBorder * 2.0f) * mScale * parentScale; return worldSize; } - - ImVec2 GetLocalSize() const { - ImVec2 localSize; - localSize.x = mSize.x / mScale; - localSize.y = mSize.y / mScale; - return localSize; - } }; ImVec2 DragMovement(const ImVec2& prevPos, const ImVec2& curPos, float curScale);