#ifndef SHELLBUFFER_H
#define SHELLBUFFER_H

#include "scene/gui/guinode.h"

class TextNode;

class ShellBuffer : public GUINode {
private:
    unsigned int m_max_size;
    int m_zero_offset;
    float m_font_size;
    unsigned int m_index = 0;
    bool m_buffer_modified;
public:
    ShellBuffer(int buffer_size):
        m_max_size(buffer_size),
        m_zero_offset(0),
        m_font_size(16.f),
        m_buffer_modified(false)
    {
        setVisible(true);
        moveTo2D(glm::vec2(0));
    }
    GraphicalNode* operator[](int i){return m_children[(m_zero_offset+i)%m_max_size];}
    void push(TextNode*);
    unsigned int size(){return m_children.size();}

    void update();

    // if this font_size is scaling down, sizes which are power of 2 render better.
    void setFontSize(float font_size){m_font_size = font_size;}
    float getFontSize(){return m_font_size;}

    glm::vec2 getDimension();

    void increaseIndex(){m_index++; m_buffer_modified= true;}
    void decreaseIndex(){m_index--; m_buffer_modified= true;}
    unsigned int getIndex(){return m_index;}
    void clear();
};

#endif // SHELLBUFFER_H
