Beispiel #1
0
bool Form::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
{
    bool eventConsumed = false;

    for (size_t i = 0; i < __forms.size(); ++i)
    {
        Form* form = __forms[i];
        GP_ASSERT(form);

        if (form->isEnabled())
        {
            if (form->_node)
            {
                Vector3 point;
                if (form->projectPoint(x, y, &point))
                {
                    const Rectangle& bounds = form->getBounds();
                    if (form->getState() == Control::FOCUS ||
                        ((evt == Mouse::MOUSE_PRESS_LEFT_BUTTON ||
                          evt == Mouse::MOUSE_PRESS_MIDDLE_BUTTON ||
                          evt == Mouse::MOUSE_PRESS_RIGHT_BUTTON ||
                          evt == Mouse::MOUSE_WHEEL) &&
                         point.x >= bounds.x &&
                         point.x <= bounds.x + bounds.width &&
                         point.y >= bounds.y &&
                         point.y <= bounds.y + bounds.height))
                    {
                        eventConsumed |= form->mouseEvent(evt, point.x - bounds.x, bounds.height - point.y - bounds.y, wheelDelta);
                    }
                }
            }
            else
            {
                // Simply compare with the form's bounds.
                const Rectangle& bounds = form->getBounds();
                if (form->getState() == Control::FOCUS ||
                    ((evt == Mouse::MOUSE_PRESS_LEFT_BUTTON ||
                      evt == Mouse::MOUSE_PRESS_MIDDLE_BUTTON ||
                      evt == Mouse::MOUSE_PRESS_RIGHT_BUTTON ||
                      evt == Mouse::MOUSE_WHEEL) &&
                        x >= bounds.x &&
                        x <= bounds.x + bounds.width &&
                        y >= bounds.y &&
                        y <= bounds.y + bounds.height))
                {
                    // Pass on the event's position relative to the form.
                    eventConsumed |= form->mouseEvent(evt, x - bounds.x, y - bounds.y, wheelDelta);
                }
            }
        }
    }
    return eventConsumed;
}
Beispiel #2
0
bool Form::touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
{
    // Check for a collision with each Form in __forms.
    // Pass the event on.
    bool eventConsumed = false;
    size_t size = __forms.size();
    for (size_t i = 0; i < size; ++i)
    {
        Form* form = __forms[i];
        GP_ASSERT(form);

        if (form->isEnabled())
        {
            if (form->_node)
            {
                Vector3 point;
                if (form->projectPoint(x, y, &point))
                {
                    const Rectangle& bounds = form->getBounds();
                    if (form->getState() == Control::FOCUS ||
                        (evt == Touch::TOUCH_PRESS &&
                         point.x >= bounds.x &&
                         point.x <= bounds.x + bounds.width &&
                         point.y >= bounds.y &&
                         point.y <= bounds.y + bounds.height))
                    {
                        eventConsumed |= form->touchEvent(evt, point.x - bounds.x, bounds.height - point.y - bounds.y, contactIndex);
                    }
                }
            }
            else
            {
                // Simply compare with the form's bounds.
                const Rectangle& bounds = form->getBounds();
                if (form->getState() == Control::FOCUS ||
                    (evt == Touch::TOUCH_PRESS &&
                        x >= bounds.x &&
                        x <= bounds.x + bounds.width &&
                        y >= bounds.y &&
                        y <= bounds.y + bounds.height))
                {
                    // Pass on the event's position relative to the form.
                    eventConsumed |= form->touchEvent(evt, x - bounds.x, y - bounds.y, contactIndex);
                }
            }
        }
    }
    return eventConsumed;
}
Beispiel #3
0
bool Form::touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
{
    // Check for a collision with each Form in __forms.
    // Pass the event on.
    size_t size = __forms.size();
    for (size_t i = 0; i < size; ++i)
    {
        Form* form = __forms[i];
        GP_ASSERT(form);

        if (form->isEnabled() && form->isVisible())
        {
            if (form->_node)
            {
                Vector3 point;
                if (form->projectPoint(x, y, &point))
                {
                    const Rectangle& bounds = form->getBounds();
                    if (shouldPropagateTouchEvent(form->getState(), evt, bounds, point.x, point.y))
                    {
                        if (form->touchEvent(evt, point.x - bounds.x, bounds.height - point.y - bounds.y, contactIndex))
                            return true;
                    }
                }
            }
            else
            {
                // Simply compare with the form's bounds.
                const Rectangle& bounds = form->getBounds();
                if (shouldPropagateTouchEvent(form->getState(), evt, bounds, x, y))
                {
                    // Pass on the event's position relative to the form.
                    if (form->touchEvent(evt, x - bounds.x, y - bounds.y, contactIndex))
                        return true;
                }
            }
        }
    }
    return false;
}
Beispiel #4
0
bool Form::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
{
    for (size_t i = 0; i < __forms.size(); ++i)
    {
        Form* form = __forms[i];
        GP_ASSERT(form);

        if (form->isEnabled() && form->isVisible())
        {
            if (form->_node)
            {
                Vector3 point;
                if (form->projectPoint(x, y, &point))
                {
                    const Rectangle& bounds = form->getBounds();
                    if (shouldPropagateMouseEvent(form->getState(), evt, bounds, point.x, point.y))
                    {
                        if (form->mouseEvent(evt, point.x - bounds.x, bounds.height - point.y - bounds.y, wheelDelta))
                            return true;
                    }
                }
            }
            else
            {
                // Simply compare with the form's bounds.
                const Rectangle& bounds = form->getBounds();
                if (shouldPropagateMouseEvent(form->getState(), evt, bounds, x, y))
                {
                    // Pass on the event's position relative to the form.
                    if (form->mouseEvent(evt, x - bounds.x, y - bounds.y, wheelDelta))
                        return true;
                }
            }
        }
    }
    return false;
}