Fixed some bugs and added parsing
This commit is contained in:
@ -25,6 +25,14 @@ float_t UIBorder::getContentHeight() {
|
||||
return this->height;
|
||||
}
|
||||
|
||||
float_t UIBorder::getChildOffsetX() {
|
||||
return this->borderSize._realValue.x;
|
||||
}
|
||||
|
||||
float_t UIBorder::getChildOffsetY() {
|
||||
return this->borderSize._realValue.y;
|
||||
}
|
||||
|
||||
std::vector<struct ShaderPassItem> UIBorder::getUIRenderPasses() {
|
||||
struct ShaderPassItem item;
|
||||
auto shader = getGame()->renderManager.uiShader;
|
||||
|
@ -24,6 +24,8 @@ namespace Dawn {
|
||||
|
||||
float_t getContentWidth() override;
|
||||
float_t getContentHeight() override;
|
||||
float_t getChildOffsetX() override;
|
||||
float_t getChildOffsetY() override;
|
||||
std::vector<struct ShaderPassItem> getUIRenderPasses() override;
|
||||
void onStart() override;
|
||||
};
|
||||
|
@ -62,6 +62,14 @@ float_t UICanvas::getContentHeight() {
|
||||
return this->getHeight();
|
||||
}
|
||||
|
||||
float_t UICanvas::getChildOffsetX() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float_t UICanvas::getChildOffsetY() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void UICanvas::onStart() {
|
||||
if(camera == nullptr) camera = getScene()->findComponent<Camera>();
|
||||
|
||||
|
@ -39,6 +39,20 @@ namespace Dawn {
|
||||
* @return Content height of this item.
|
||||
*/
|
||||
virtual float_t getContentHeight() = 0;
|
||||
|
||||
/**
|
||||
* Returns the offset of the child elements of this UI item.
|
||||
*
|
||||
* @return Offset of the child elements of this UI item.
|
||||
*/
|
||||
virtual float_t getChildOffsetX() = 0;
|
||||
|
||||
/**
|
||||
* Returns the offset of the child elements of this UI item.
|
||||
*
|
||||
* @return Offset of the child elements of this UI item.
|
||||
*/
|
||||
virtual float_t getChildOffsetY() = 0;
|
||||
};
|
||||
|
||||
enum UIDrawType {
|
||||
@ -86,6 +100,8 @@ namespace Dawn {
|
||||
float_t getHeight() override;
|
||||
float_t getContentWidth() override;
|
||||
float_t getContentHeight() override;
|
||||
float_t getChildOffsetX() override;
|
||||
float_t getChildOffsetY() override;
|
||||
void onStart() override;
|
||||
void onDispose() override;
|
||||
};
|
||||
|
@ -39,8 +39,8 @@ void UIComponent::updateAlignment() {
|
||||
assertNotNull(dimensional);
|
||||
|
||||
float_t parentWidth, parentHeight;
|
||||
parentWidth = dimensional->getWidth();
|
||||
parentHeight = dimensional->getHeight();
|
||||
parentWidth = dimensional->getContentWidth();
|
||||
parentHeight = dimensional->getContentHeight();
|
||||
|
||||
UIComponent::calculateDimensions(
|
||||
this->alignX,
|
||||
@ -63,6 +63,9 @@ void UIComponent::updateAlignment() {
|
||||
glm::vec2(align[1], align[3])
|
||||
);
|
||||
|
||||
translate.x += dimensional->getChildOffsetX();
|
||||
translate.y += dimensional->getChildOffsetY();
|
||||
|
||||
this->transform->setLocalPosition(translate);
|
||||
this->alignmentNeedsUpdating = false;
|
||||
this->eventAlignmentUpdated.invoke();
|
||||
@ -180,6 +183,14 @@ float_t UIComponent::getHeight() {
|
||||
return this->height;
|
||||
}
|
||||
|
||||
float_t UIComponent::getChildOffsetX() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
float_t UIComponent::getChildOffsetY() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UIComponent::onStart() {
|
||||
useEffect([&]{
|
||||
this->alignmentNeedsUpdating = true;
|
||||
|
@ -109,6 +109,8 @@ namespace Dawn {
|
||||
|
||||
float_t getWidth() override;
|
||||
float_t getHeight() override;
|
||||
float_t getChildOffsetX() override;
|
||||
float_t getChildOffsetY() override;
|
||||
void onStart() override;
|
||||
|
||||
friend class UICanvas;
|
||||
|
@ -25,7 +25,7 @@ void UILabel::onStart() {
|
||||
}
|
||||
|
||||
std::vector<struct ShaderPassItem> UILabel::getUIRenderPasses() {
|
||||
// if(this->texts.size() == 0) return {};
|
||||
if(this->textsBuffered.empty()) return {};
|
||||
|
||||
auto canvas = this->getCanvas();
|
||||
auto shader = getGame()->renderManager.fontShader;
|
||||
@ -264,10 +264,12 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
|
||||
}
|
||||
|
||||
// Create mesh
|
||||
this->mesh.createBuffers(
|
||||
QUAD_VERTICE_COUNT * vertices.size(),
|
||||
QUAD_INDICE_COUNT * vertices.size()
|
||||
);
|
||||
if(!vertices.empty()) {
|
||||
this->mesh.createBuffers(
|
||||
QUAD_VERTICE_COUNT * vertices.size(),
|
||||
QUAD_INDICE_COUNT * vertices.size()
|
||||
);
|
||||
}
|
||||
|
||||
// Now buffer the quads.
|
||||
int32_t j = 0;
|
||||
|
@ -22,6 +22,11 @@ void UIRichTextLabel::onStart() {
|
||||
struct UILabelStyle current;
|
||||
styleStack.push_back(current);
|
||||
std::vector<struct UILabelText> bufferTexts;
|
||||
|
||||
if(this->richText._realValue.empty()) {
|
||||
this->rebufferQuads(bufferTexts);
|
||||
return;
|
||||
}
|
||||
|
||||
std::function<void(Xml*)> parseChildren = [&](Xml *node) {
|
||||
if(node->children.empty()) {
|
||||
|
@ -9,6 +9,7 @@
|
||||
namespace Dawn {
|
||||
class UIRichTextLabel : public UILabel {
|
||||
public:
|
||||
// @innerXml
|
||||
StateProperty<std::string> richText;
|
||||
|
||||
UIRichTextLabel(SceneItem *item);
|
||||
|
Reference in New Issue
Block a user