#pragma once

#include "MaterialNode.h"

#include "FontItem.h"
#include "TextData.h"

#include <memory>
#include <string>

class TextNode : public MaterialNode
{
public:
    TextNode(const std::string& content, const DiscretePoint& loc);

    ~TextNode();

    static std::unique_ptr<TextNode> Create(const std::string& content, const DiscretePoint& loc);

    std::string getContent() const;
    std::string getFontLabel() const;

    SceneItem* getSceneItem(std::size_t idx) const override;
    unsigned getNumSceneItems() const override;

    unsigned getWidth() const;
    unsigned getHeight() const;

    void setWidth(unsigned width);
    void setHeight(unsigned height);

    void setContent(const std::string& content);

    void update(FontsManager* fontsManager) override;
private:

    void updateLines(FontsManager* fontsManager);

    TextData mTextData;
    bool mContentIsDirty{true};
    bool mLinesAreDirty{true};

    unsigned mWidth{1};
    unsigned mHeight{1};

    std::unique_ptr<SceneItem> mTextItem;
};

using TextNodetr = std::unique_ptr<TextNode>;
