Пример #1
0
LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const
{
    LayoutUnit result = 0;

    if (!renderer().style().isFlippedLinesWritingMode()) {
        // Annotations under the previous line may push us down.
        if (prevRootBox() && prevRootBox()->hasAnnotationsAfter())
            result = prevRootBox()->computeUnderAnnotationAdjustment(lineTop());

        if (!hasAnnotationsBefore())
            return result;

        // Annotations over this line may push us further down.
        LayoutUnit highestAllowedPosition = prevRootBox() ? std::min(prevRootBox()->lineBottom(), lineTop()) + result : blockFlow().borderBefore();
        result = computeOverAnnotationAdjustment(highestAllowedPosition);
    } else {
        // Annotations under this line may push us up.
        if (hasAnnotationsBefore())
            result = computeUnderAnnotationAdjustment(prevRootBox() ? prevRootBox()->lineBottom() : blockFlow().borderBefore());

        if (!prevRootBox() || !prevRootBox()->hasAnnotationsAfter())
            return result;

        // We have to compute the expansion for annotations over the previous line to see how much we should move.
        LayoutUnit lowestAllowedPosition = std::max(prevRootBox()->lineBottom(), lineTop()) - result;
        result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPosition);
    }

    return result;
}
Пример #2
0
LayoutRect RootInlineBox::paddedLayoutOverflowRect(LayoutUnit endPadding) const
{
    LayoutRect lineLayoutOverflow = layoutOverflowRect(lineTop(), lineBottom());
    if (!endPadding)
        return lineLayoutOverflow;
    
    // FIXME: Audit whether to use pixel snapped values when not using integers for layout: https://bugs.webkit.org/show_bug.cgi?id=63656
    if (isHorizontal()) {
        if (isLeftToRightDirection())
            lineLayoutOverflow.shiftMaxXEdgeTo(std::max<LayoutUnit>(lineLayoutOverflow.maxX(), pixelSnappedLogicalRight() + endPadding));
        else
            lineLayoutOverflow.shiftXEdgeTo(std::min<LayoutUnit>(lineLayoutOverflow.x(), pixelSnappedLogicalLeft() - endPadding));
    } else {
        if (isLeftToRightDirection())
            lineLayoutOverflow.shiftMaxYEdgeTo(std::max<LayoutUnit>(lineLayoutOverflow.maxY(), pixelSnappedLogicalRight() + endPadding));
        else
            lineLayoutOverflow.shiftYEdgeTo(std::min<LayoutUnit>(lineLayoutOverflow.y(), pixelSnappedLogicalLeft() - endPadding));
    }
    
    return lineLayoutOverflow;
}
void KisPerspectiveGridManager::drawDecoration(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter *converter)
{
    Q_UNUSED(updateRect);

    KisImageWSP image = m_view->resourceProvider()->currentImage();
    Q_ASSERT(image);

    KisPerspectiveGrid* pGrid = image->perspectiveGrid();

    QPen mainPen = KisGridPainterConfiguration::mainPen();
    QPen subdivisionPen = KisGridPainterConfiguration::subdivisionPen();
    QPen errorPen = mainPen;
    errorPen.setColor(Qt::red);


    QTransform transform = converter->imageToWidgetTransform();
    gc.save();
    gc.setTransform(transform);

    for (QList<KisSubPerspectiveGrid*>::const_iterator it = pGrid->begin(); it != pGrid->end(); ++it) {
        const KisSubPerspectiveGrid* grid = *it;

        /**
         * Note that the notion of top-bottom-right-left
         * is purely theorical
         */
        LineWrapper lineTop(*grid->topLeft(), *grid->topRight());
        LineWrapper lineRight(*grid->topRight(), *grid->bottomRight());
        LineWrapper lineBottom(*grid->bottomRight(), *grid->bottomLeft());
        LineWrapper lineLeft(*grid->bottomLeft(), *grid->topLeft());

        QPointF horizIntersection;
        QPointF vertIntersection;

        bool linesNotNull = true;
        bool polygonIsConvex = true;

        if(lineTop.isNull(SMALLEST_LINE) ||
           lineBottom.isNull(SMALLEST_LINE) ||
           lineLeft.isNull(SMALLEST_LINE) ||
           lineRight.isNull(SMALLEST_LINE)) {

            linesNotNull = false;
        }

        if(linesNotNull) {
            horizIntersection = lineTop.intersects(lineBottom);
            vertIntersection = lineLeft.intersects(lineRight);

            if(lineTop.contains(horizIntersection) ||
               lineBottom.contains(horizIntersection) ||
               lineLeft.contains(vertIntersection) ||
               lineRight.contains(vertIntersection)) {

                polygonIsConvex = false;
            }
        }

        if(polygonIsConvex && linesNotNull) {
            gc.setPen(subdivisionPen);

            SubdivisionLinesInfo info;
            info = getSubdivisionsInfo(lineTop, lineBottom, vertIntersection,
                                       grid->subdivisions());
            drawSubdivisions(gc, info);

            info = getSubdivisionsInfo(lineLeft, lineRight, horizIntersection,
                                       grid->subdivisions());
            drawSubdivisions(gc, info);
        }

        gc.setPen(polygonIsConvex && linesNotNull ? mainPen : errorPen);
        gc.drawLine(*grid->topLeft(), *grid->topRight());
        gc.drawLine(*grid->topRight(), *grid->bottomRight());
        gc.drawLine(*grid->bottomRight(), *grid->bottomLeft());
        gc.drawLine(*grid->bottomLeft(), *grid->topLeft());
    }
    gc.restore();
}
Пример #4
0
int RootInlineBox::blockDirectionPointInLine() const
{
    return !blockFlow().style().isFlippedBlocksWritingMode() ? std::max(lineTop(), selectionTop()) : std::min(lineBottom(), selectionBottom());
}