#ifndef COLOR_SELECTOR_HPP_
#define COLOR_SELECTOR_HPP_

#include <Utilities/Extern.hpp>
#include <Utilities/RGBABytes.hpp>
#include <Utilities/StandardLerping.hpp>
#include <Widget/Widget.hpp>
#include <functional>

/**
 * @brief Widget for selecting a color as `RGBABytes`.
 */
class ColorSelector final : public Widget
{
public:
    using ChangedCallback = std::function<void()>;

private:
    RGBABytes &color;
    ChangedCallback onChanged = [](){};
    StandardLerping<glm::vec4> backgroundLerp;

    void activate();

public:
    static constexpr int buttonWidth = 16;
    static constexpr int buttonHeight = 8;
    static constexpr int buttonMargin = 1;

    ColorSelector(RGBABytes &bytes);

    /**
     * @brief Sets the callback for when the color changed, and returns this widget.
     */
    ColorSelector* withChangedCallback(ChangedCallback callback);

    virtual glm::ivec2 getMinSize() override;
    virtual void draw(GraphicsContext &context) override;
    virtual void onKeyDown(SDL_Keycode keycode) override;
    virtual void onMouseDown(Uint8 button) override;
    virtual void getInternalTabOrder(std::vector<Widget*> &tabOrder) override;
};

#endif