FIX: Use Correct Line Height
This commit is contained in:
parent
a61e5f4364
commit
8bc3ae69a8
@ -5,7 +5,9 @@
|
|||||||
#include "UiPositioner.h"
|
#include "UiPositioner.h"
|
||||||
|
|
||||||
#include "../UiComponent.h"
|
#include "../UiComponent.h"
|
||||||
|
#include "../UiText.h"
|
||||||
#include "../../../Application.h"
|
#include "../../../Application.h"
|
||||||
|
#include "../../text/Font.h"
|
||||||
|
|
||||||
void UiPositioner::compute(const Dimensions &parent) {
|
void UiPositioner::compute(const Dimensions &parent) {
|
||||||
const float screenWidth = static_cast<float>(Application::getInstance().getWindow().GetWidth());
|
const float screenWidth = static_cast<float>(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.x = parent.x + resolve(style.margin.left, parent.width, screenWidth);
|
||||||
screenSpace.y = parent.y + resolve(style.margin.top, parent.height, screenHeight);
|
screenSpace.y = parent.y + resolve(style.margin.top, parent.height, screenHeight);
|
||||||
screenSpace.width = resolve(style.width, parent.width, screenWidth);
|
screenSpace.width = resolve(style.width, parent.width, screenWidth);
|
||||||
screenSpace.height = resolve(style.height, parent.height, screenHeight);
|
|
||||||
|
if (auto text = dynamic_cast<UiText*>(&uiComponent)) {
|
||||||
|
screenSpace.height = text->getFont().getLineHeight() / screenHeight;
|
||||||
|
} else {
|
||||||
|
screenSpace.height = resolve(style.height, parent.height, screenHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 3. Kinder rekursiv positionieren mit JustifyContent
|
// 3. Kinder rekursiv positionieren mit JustifyContent
|
||||||
for (auto& child : uiComponent.children) {
|
for (auto& child : uiComponent.children) {
|
||||||
@ -68,7 +76,7 @@ void UiPositioner::compute(const Dimensions &parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (style.flexDirection == FlexDirection::Column) {
|
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.screenSpace.height;
|
||||||
currentMainOffset += child->uiPositioner.resolve(child->uiPositioner.style.margin.top, parent.height, screenHeight);
|
currentMainOffset += child->uiPositioner.resolve(child->uiPositioner.style.margin.top, parent.height, screenHeight);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ void UILayer::onAttach() {
|
|||||||
|
|
||||||
rootContainer = std::make_unique<UiContainer>();
|
rootContainer = std::make_unique<UiContainer>();
|
||||||
LayoutStyle& rootLayout = rootContainer->getLayoutStyle();
|
LayoutStyle& rootLayout = rootContainer->getLayoutStyle();
|
||||||
rootLayout.justifyContent = JustifyContent::Start;
|
rootLayout.justifyContent = JustifyContent::End;
|
||||||
|
|
||||||
auto imageStyle = LayoutStyle();
|
auto imageStyle = LayoutStyle();
|
||||||
imageStyle.width = SizeValue(0.25f, SizeUnit::Percent);
|
imageStyle.width = SizeValue(0.25f, SizeUnit::Percent);
|
||||||
@ -47,7 +47,7 @@ void UILayer::onAttach() {
|
|||||||
);
|
);
|
||||||
rootContainer->addChild(std::move(image));
|
rootContainer->addChild(std::move(image));
|
||||||
rootContainer->addChild(std::move(image2));
|
rootContainer->addChild(std::move(image2));
|
||||||
rootContainer->addChild(std::move(image3));
|
//rootContainer->addChild(std::move(image3));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user