#ifndef TEXTINPUTNODE_H
#define TEXTINPUTNODE_H

#include "scene/gui/guinode.h"
#include <iostream>

#include "scene/textnode.h"
#include "scene/gui/callback.h"

class TextInputNode : public GUINode
{
    glm::vec2 m_dimension;
    bool m_hasFocus;
    float m_font_size;

    TextNode* m_text_mesh;
    std::string m_text;
    bool m_text_updated;
    glm::vec3 m_text_color;

    MeshNode* m_cursor_mesh;
    unsigned int m_cursor_pos;
    bool m_cursor_pos_updated;

    int m_move_cursor_left;
    int m_move_cursor_right;

    CallBack* m_callback;
    CallBack* m_tab_callback;

public:
    TextInputNode(glm::vec2 dimension);
    void update();
    void updateCursorMesh();
    void updateTextMesh();
    glm::vec2 getDimension(){return m_dimension;}

    void setFocus(bool focus);
    void setTextColor(glm::vec3 color);
    void setText(std::string text);
    std::string getText();
    void setCallBack(CallBack* callback){m_callback = callback;}
    void setTabCallBack(CallBack* callback){m_tab_callback = callback;}
    void setMoveCursorLeft(int action){m_move_cursor_left = action;}
    void setMoveCursorRight(int action){m_move_cursor_right = action;}
    void clearText(){m_text.clear();}
};

#endif // TEXTINPUTNODE_H
