#include "ICursorHandler.hpp"

#include "IInputManager.hpp"

TSE::ICursorHandler::~ICursorHandler()
{
    if(enabled()) Disable();
}

bool TSE::ICursorHandler::enabled() const
{
    return Enabled;
}

void TSE::ICursorHandler::Enable()
{
    if(!enabled())
    {
        IInputManager::instance()->RegisterCursorHandler(this);
        Enabled = true;
    }
}

void TSE::ICursorHandler::Disable()
{
    if(enabled())
    {
        IInputManager::instance()->UnregisterCursorHandler(this);
        Enabled = false;
    }
}

void TSE::ICursorHandler::onMouseButtonDown(ICursorHandler *handler, const MouseBtn &btn, const Modifier &mods)
{
    handler->OnMouseButtonDown(btn, mods);
}

void TSE::ICursorHandler::onMouseButtonUp(ICursorHandler *handler, const MouseBtn &btn, const Modifier &mods)
{
    handler->OnMouseButtonUp(btn, mods);
}

void TSE::ICursorHandler::onMouseButtonHold(ICursorHandler *handler, const MouseBtn &btn, const Modifier &mods)
{
    handler->OnMouseButtonHold(btn, mods);
}

void TSE::ICursorHandler::onMousePosition(ICursorHandler *handler, const Vector2 &pos)
{
    handler->OnMousePosition(pos);
}

void TSE::ICursorHandler::onMouseScroll(ICursorHandler *handler, const Vector2 &delta)
{
    handler->OnMouseScroll(delta);
}
