#ifndef BASE_GUI_H
#define BASE_GUI_H

#include "input/TextInput.h"
#include "math/Vector.h"
#include "utils/List.h"
#include "utils/Size.h"

struct BaseGUI final {
    static const Vector2 FIXED_SIZE;

    float scale;
    Vector2 scaledSize;

    struct Base {
        Vector2 pos;
        Vector2 size;
        bool hovered;
        bool pressed;
        Base();
    };

    struct Label {
        Base base;
        StringBuffer<50> text;
    };
    List<Label> labels;

    struct Input {
        Base base;
        TextInput text;
    };
    List<Input> inputs;

    struct Button {
        Base base;
        StringBuffer<20> text;
    };
    List<Button> buttons;

    void tick();
    void updateScale();
    void render();
    Vector2 round(const Vector2& v) const;
    void renderString(const Vector2& pos, const char* s);
    Label& addLabel(const char* text);
    Input& addInput();
    Button& addButton(const char* text);
    bool isIn(const Vector2& pos, const Vector2& size,
              const Vector2& point) const;

private:
    void tickBase(Base& b);
    Vector2 renderCenteredString(const Base& b, const char* text);
    void renderBase(const Base& b);
    void renderLabels();
    void renderInputs();
    void renderButtons();
};

#endif