Пример #1
0
IntSize DragScrollTimer::scrollDistanceFor(FrameView* view, const WebPoint& location) const
{
    static const int scrollMargin = 30;

    IntRect bounds(0, 0, view->visibleWidth(), view->visibleHeight());
    if (!bounds.contains(location))
        return IntSize(0, 0); // The location is outside the border belt.

    bounds.setY(bounds.y() + scrollMargin);
    bounds.setHeight(bounds.height() - scrollMargin * 2);
    bounds.setX(bounds.x() + scrollMargin);
    bounds.setWidth(bounds.width() - scrollMargin * 2);

    if (bounds.contains(location))
        return IntSize(0, 0); // The location is inside the border belt.

    // The location is over the border belt.
    return distanceToRect(location, bounds);
}
Пример #2
0
    HistoryElement* findNearest(const QPoint& p)
    {
        // find direct hit
        foreach (const ToolTipElement& tte, toolTipElements)
        {
            if (tte.first.contains(p))
            {
                return tte.second;
            }
        }

        // find nearest
        float nearest = 0;
        HistoryElement* nearestElement = 0;
        foreach (const ToolTipElement& tte, toolTipElements)
        {
            float distance = distanceToRect(p, tte.first);
            if (!nearestElement || distance < nearest)
            {
                nearest = distance;
                nearestElement = tte.second;
            }
        }