diff --git a/src/engine/core/gui/uiComponent/layout/UiPositioner.cpp b/src/engine/core/gui/uiComponent/layout/UiPositioner.cpp index 905016e..a2ab80d 100644 --- a/src/engine/core/gui/uiComponent/layout/UiPositioner.cpp +++ b/src/engine/core/gui/uiComponent/layout/UiPositioner.cpp @@ -5,7 +5,9 @@ #include "UiPositioner.h" #include "../UiComponent.h" +#include "../UiText.h" #include "../../../Application.h" +#include "../../text/Font.h" void UiPositioner::compute(const Dimensions &parent) { const float screenWidth = static_cast(Application::getInstance().getWindow().GetWidth()); @@ -14,7 +16,13 @@ void UiPositioner::compute(const Dimensions &parent) { screenSpace.x = parent.x + resolve(style.margin.left, parent.width, screenWidth); screenSpace.y = parent.y + resolve(style.margin.top, parent.height, screenHeight); screenSpace.width = resolve(style.width, parent.width, screenWidth); - screenSpace.height = resolve(style.height, parent.height, screenHeight); + + if (auto text = dynamic_cast(&uiComponent)) { + screenSpace.height = text->getFont().getLineHeight() / screenHeight; + } else { + screenSpace.height = resolve(style.height, parent.height, screenHeight); + } + // 3. Kinder rekursiv positionieren mit JustifyContent for (auto& child : uiComponent.children) { @@ -68,7 +76,7 @@ void UiPositioner::compute(const Dimensions &parent) { } if (style.flexDirection == FlexDirection::Column) { - child->uiPositioner.screenSpace.y += currentMainOffset; + child->uiPositioner.screenSpace.y = screenSpace.y + currentMainOffset; currentMainOffset += child->uiPositioner.screenSpace.height; currentMainOffset += child->uiPositioner.resolve(child->uiPositioner.style.margin.top, parent.height, screenHeight); } else { diff --git a/src/game/UILayer.cpp b/src/game/UILayer.cpp index 3da7252..8a0fb2b 100644 --- a/src/game/UILayer.cpp +++ b/src/game/UILayer.cpp @@ -23,7 +23,7 @@ void UILayer::onAttach() { rootContainer = std::make_unique(); LayoutStyle& rootLayout = rootContainer->getLayoutStyle(); - rootLayout.justifyContent = JustifyContent::Start; + rootLayout.justifyContent = JustifyContent::End; auto imageStyle = LayoutStyle(); imageStyle.width = SizeValue(0.25f, SizeUnit::Percent); @@ -47,7 +47,7 @@ void UILayer::onAttach() { ); rootContainer->addChild(std::move(image)); rootContainer->addChild(std::move(image2)); - rootContainer->addChild(std::move(image3)); + //rootContainer->addChild(std::move(image3));