void RevealHoverLight::GotoLightState()

in dev/Lights/RevealHoverLight.cpp [378:562]


void RevealHoverLight::GotoLightState(LightEvents e)
{
    // Update pointer flags before transitioning to the next state
    switch (e)
    {
    case LightEvents::GotoNormal:
    {
        m_centerLight = true;
        m_isPointerOver = false;
        m_isPressed = false;
    }
    break;

    case LightEvents::GotoPointerOver:
    {
        m_centerLight = false;
        m_isPointerOver = true;
        m_isPressed = false;
    }
    break;

    case LightEvents::GotoPressed:
    {
        m_isPressed = true;
    }
    break;
    case LightEvents::AnimationComplete:
        break;
    }

    const auto initState = m_currentLightState;
    switch (initState)
    {
    case LightStates::Off:
        switch (e)
        {
        case LightEvents::GotoNormal:
            break;
        case LightEvents::GotoPointerOver:
            GotoLightStateHelper(LightStates::AnimToHover);
            break;
        case LightEvents::GotoPressed:
            GotoLightStateHelper(LightStates::Pressing);
            break;
        case LightEvents::AnimationComplete:
            break;
        }
        break;

    case LightStates::AnimToHover:
        switch (e)
        {
        case LightEvents::GotoNormal:
            GotoLightStateHelper(LightStates::AnimToOff);
            break;
        case LightEvents::GotoPointerOver:
            break;
        case LightEvents::GotoPressed:
            GotoLightStateHelper(LightStates::Pressing);
            break;
        case LightEvents::AnimationComplete:
            GotoLightStateHelper(LightStates::Hover);
            break;
        }
        break;

    case LightStates::AnimToOff:
        switch (e)
        {
        case LightEvents::GotoNormal:
            break;
        case LightEvents::GotoPointerOver:
            GotoLightStateHelper(LightStates::AnimToHover);
            break;
        case LightEvents::GotoPressed:
            GotoLightStateHelper(LightStates::Pressing);
            break;
        case LightEvents::AnimationComplete:
            GotoLightStateHelper(LightStates::Off);
            break;
        }
        break;

    case LightStates::Hover:
        switch (e)
        {
        case LightEvents::GotoNormal:
            GotoLightStateHelper(LightStates::AnimToOff);
            break;
        case LightEvents::GotoPointerOver:
            break;
        case LightEvents::GotoPressed:
            GotoLightStateHelper(LightStates::Pressing);
            break;
        case LightEvents::AnimationComplete:
            break;
        }
        break;

    case LightStates::Pressing:
    {
        // Once the press is done, we always reset to pointer-based offset
        if (m_compositionSpotLight)
        {
            m_offsetAnimation.Expression(c_PointerOffsetExpression);
            m_compositionSpotLight.StartAnimation(L"Offset", m_offsetAnimation);
        }

        switch (e)
        {
        case LightEvents::GotoNormal:
            GotoLightStateHelper(LightStates::AnimToOff);
            break;
        case LightEvents::GotoPointerOver:
            break;
        case LightEvents::GotoPressed:
        {
            // This indicates a press, then release then press again while the first press animation is still going
            GotoLightStateHelper(LightStates::AnimToHover, true);
            GotoLightStateHelper(LightStates::Pressing);
        }
        break;
        case LightEvents::AnimationComplete:
        {
            if (m_isPressed)
            {
                GotoLightStateHelper(LightStates::SlowRelease);
            }
            else
            {
                GotoLightStateHelper(LightStates::FastRelease);
            }
        }
        break;
        }
    }
    break;

    case LightStates::FastRelease:
        switch (e)
        {
        case LightEvents::GotoNormal:
            GotoLightStateHelper(LightStates::AnimToOff);
            break;
        case LightEvents::GotoPointerOver:
            break;
        case LightEvents::GotoPressed:
            // This indicates a press, then release then press again while the first press animation is still going
            GotoLightStateHelper(LightStates::AnimToHover, true);
            GotoLightStateHelper(LightStates::Pressing);
            break;
        case LightEvents::AnimationComplete:
            if (!m_isPressed && m_isPointerOver)
            {
                GotoLightStateHelper(LightStates::AnimToHover, true);
            }
            break;
        }
        break;

    case LightStates::SlowRelease:
        switch (e)
        {
        case LightEvents::GotoNormal:
            GotoLightStateHelper(LightStates::AnimToOff);
            break;
        case LightEvents::GotoPointerOver:
            // This indicates a semi-long press, where button is released before it's done. Complete it with a FastRelease animation.
            GotoLightStateHelper(LightStates::FastRelease);
            break;
        case LightEvents::GotoPressed:
            // This indicates a press, then release then press again while the first press animation is still going
            GotoLightStateHelper(LightStates::AnimToHover, true);
            GotoLightStateHelper(LightStates::Pressing);
            break;
        case LightEvents::AnimationComplete:
            if (!m_isPressed && m_isPointerOver)
            {
                GotoLightStateHelper(LightStates::AnimToHover, true);
            }
            break;
        }
        break;
    }
}