Skip to content

Commit

Permalink
Add ui split container.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuscu committed Aug 20, 2024
1 parent 85fea86 commit 039ed01
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions packages/rendering/include/rendering/ui/UIContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 039ed01

Please sign in to comment.