#include "TextNode.h" #include "Rectangle.h" #include "FontsManager.h" #include "IFontEngine.h" #include "MeshPrimitives.h" #include "FontItem.h" #include "SceneText.h" #include "Color.h" #include TextNode::TextNode(const std::string& content, const DiscretePoint& loc) : MaterialNode(loc) { mContent= content; } TextNode::~TextNode() { } std::unique_ptr TextNode::Create(const std::string& content, const DiscretePoint& loc) { return std::make_unique(content, loc); } std::string TextNode::getFontLabel() const { return {}; } std::string TextNode::getContent() const { return mContent; } void TextNode::setContent(const std::string& content) { if (mContent != content) { mContent = content; mContentIsDirty = true; } } void TextNode::update(FontsManager* fontsManager) { if (!mSceneItem) { mSceneItem = std::make_unique(); mSceneItem->setName(mName + "_SceneText"); } if (mContentIsDirty) { dynamic_cast(mSceneItem.get())->setContent(mContent); mContentIsDirty = false; } if (mTransformIsDirty) { mSceneItem->updateTransform({mLocation}); mTransformIsDirty = false; } if (mMaterialIsDirty) { mSceneItem->updateUniformColor(mFillColor); mMaterialIsDirty = false; } }