#ifndef SWITCH_HPP_
#define SWITCH_HPP_

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

/**
 * @brief A switch widget displaying an on/off state, which can be clicked to change.
 */
class Switch : public Widget
{
private:
    static constexpr int width = 27;
    static constexpr int height = 8;

    bool &state;
    std::function<void(bool)> onUpdated;

public:
    /**
     * @brief Construct the switch.
     * 
     * @param state The state variable.
     * @param onUpdated Function called with the new state every time it changes.
     */
    Switch(bool &state, std::function<void(bool)> onUpdated = [](bool){});

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

#endif