#ifndef WIDGET_DISPLAY_HPP_
#define WIDGET_DISPLAY_HPP_

#include <Display/Display.hpp>
#include <Widget/Widget.hpp>

/**
 * @brief A display for showing widgets.
 */
class WidgetDisplay : public Display
{
private:
    static bool m_isTextInputActive;

    glm::ivec2 currentSize;
    Widget* currentWidget;
    glm::ivec2 mousePos;

    void handleTab(SDL_Event &event);

protected:
    /**
     * @brief Should we show the mouse cursor?
     */
    bool showMouse;

public:
    /**
     * @brief Construct a WidgetDisplay.
     */
    WidgetDisplay();

    virtual ~WidgetDisplay();

    /**
     * @brief Set the current widget.
     * 
     * If a widget is already set, then the current one is deleted, and then set to `root`. This
     * method takes ownership of `root`; you must not reference it anymore after passing it to
     * this function.
     * 
     * @param root The root widget, or `nullptr`.
     */
    void setWidget(Widget *root);

    /**
     * @brief Returns true if a widget is currently set.
     */
    bool isWidgetSet();

    void drawPartial(GraphicsContext &context);

    virtual void onEvent(SDL_Event &event) override;
    virtual void update() override;
    virtual void fastUpdate() override;
    virtual void draw(GraphicsContext &context) override;
    virtual void onExposed() override;
};

#endif