Need to support text alignment

This commit is contained in:
2023-07-09 22:06:50 -07:00
parent 83f5d99c65
commit d8d8c84724
4 changed files with 15 additions and 12 deletions

View File

@ -14,11 +14,9 @@
<child>
<UIRichTextLabel
alignment="0, 0, 65, 192"
alignUnitLeft="UI_COMPONENT_ALIGN_UNIT_PERCENT"
alignUnitRight="UI_COMPONENT_ALIGN_UNIT_PERCENT"
alignX="UI_COMPONENT_ALIGN_MIDDLE"
alignY="UI_COMPONENT_ALIGN_MIDDLE"
alignment="0, 0, 0, 0"
alignX="UI_COMPONENT_ALIGN_STRETCH"
alignY="UI_COMPONENT_ALIGN_STRETCH"
ref="uiLabel"
>
</UIRichTextLabel>

View File

@ -38,9 +38,8 @@ void UIComponent::updateAlignment() {
assertNotNull(dimensional);
float_t parentWidth, parentHeight;
parentWidth = dimensional->getContentWidth();
parentHeight = dimensional->getContentHeight();
parentInnerWidth = dimensional->getContentWidth();
parentInnerHeight = dimensional->getContentHeight();
UIComponent::calculateDimensions(
this->alignX,
@ -48,7 +47,7 @@ void UIComponent::updateAlignment() {
this->alignUnitRight,
&translate.x,
&this->width,
parentWidth,
parentInnerWidth,
this->getContentWidth(),
glm::vec2(align[0], align[2])
);
@ -58,7 +57,7 @@ void UIComponent::updateAlignment() {
this->alignUnitBottom,
&translate.y,
&this->height,
parentHeight,
parentInnerHeight,
this->getContentHeight(),
glm::vec2(align[1], align[3])
);

View File

@ -28,6 +28,8 @@ namespace Dawn {
protected:
float_t width = 1;
float_t height = 1;
float_t parentInnerWidth = 1;
float_t parentInnerHeight = 1;
/**
* Simply returns this UI Components' dimensional parent, used for the

View File

@ -9,7 +9,11 @@ using namespace Dawn;
UIEmpty::UIEmpty(SceneItem *item) : UIComponent(item) { }
float_t UIEmpty::getContentWidth() { return 0.0f; }
float_t UIEmpty::getContentHeight() { return 0.0f; }
float_t UIEmpty::getContentWidth() {
return this->getWidth();
}
float_t UIEmpty::getContentHeight() {
return this->getHeight();
}
float_t UIEmpty::getChildOffsetX() { return 0.0f; }
float_t UIEmpty::getChildOffsetY() { return 0.0f; }