#pragma once
#include "node.h"
#include "font.h"

class NodeText : public Node
{
public:
    enum class TextAlign
    {
        Begin,
        Center,
        End,
    };
    TextMesh m_text_mesh;
    std::string m_text;
    std::string m_font_name = "roboto";
    glm::vec4 m_color{ 1, 1, 1, 1 };
    std::string m_font_weight = "regular";
    int m_font_size = 17;
    bool m_font_italic = false;

    bool m_multiline = false;
    glm::vec2 m_off = { 0, 0 };
    TextAlign m_text_align_v = TextAlign::Center;
    TextAlign m_text_align_h = TextAlign::Begin;

    virtual Node* clone_instantiate() const override;
    virtual void clone_copy(Node* dest) const override;
    virtual void create() override;
    virtual void parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr) override;
    virtual void draw() override;
    virtual void handle_resize(glm::vec2 old_size, glm::vec2 new_size, float zoom) override;

    void set_text(const std::string& s);
    void set_text_format(const char* fmt, ...);
    void set_font(const std::string& name, int size, const std::string& weight, bool italic);
    void set_font_size(int size);
    void update_layout();
};
