[scribus-dev] Fix for the guides/grid/margin painting I broke

Elvis Stansvik elvstone at gmail.com
Tue Aug 2 09:33:55 UTC 2011


Morning-ish all,

It turned out it was me who broke painting of page grid/guides/margin
in my repo (thanks Craig/a-l-e for testing).

So this morning I did a "git bisect" (very handy tool btw!) to find
the offending commit:

commit 4cdb4ca726c05d77ef99c94b6dfa7f3f1ad6411e
Author: Elvis Stansvik <elvstone at gmail.com>
Date:   Sun Jun 19 15:50:41 2011 +0200

    Don't draw stroke if stroke mode is None.

    I really need to ask if this change is OK!

diff --git a/Scribus/scribus/scpainter.cpp b/Scribus/scribus/scpainter.cpp
index ec3c2fc..2df6911 100644
--- a/Scribus/scribus/scpainter.cpp
+++ b/Scribus/scribus/scpainter.cpp
@@ -645,7 +645,8 @@ void ScPainter::strokePath()
 {
 //     if( LineWidth == 0 )
 //             return;
-       drawVPath( 1 );
+       if (strokeMode != None)
+               drawVPath( 1 );
 }

 QColor ScPainter::pen()

I had totally forgot about that one. As the commit message says, I
intended to ask you guys if it was OK.

The reason I added this is that ScPainter::drawRect(...) would stroke
the rect even though the stroke mode was set to None (which is the
default constructed stroke mode of ScPainter btw). This gave me
problems when painting the cell and table background using
drawRect(...) as I didn't want any stroke around the rect when doing
that, and found no way of turning it off.

The problem, as it have turned out, is that
Canvas::DrawPageMarks(...), which is the function that draws page
guides, margins, grid and baseline grid, relies on this (mis?)behavior
of ScPainter.

I've now fixed this in my repo by making DrawPageMarks(...) explicitly
set the stroke mode to Solid:

commit 2e7cdd13d8029f91d13b33524ed7f2cda6d30dc0
Author: Elvis Stansvik <elvstone at gmail.com>
Date:   Tue Aug 2 11:32:44 2011 +0200

    Fix painting of guides, margins, grid and baseline grid:

    The old code relied on the painter doing strokes, even though the stroke
    mode was set to its default constructed value (ScPainter::None). Fix the
    problem by explicitly setting it to ScPainter::Solid before painting.

diff --git a/Scribus/scribus/canvas.cpp b/Scribus/scribus/canvas.cpp
index ff90e65..3eed4ee 100644
--- a/Scribus/scribus/canvas.cpp
+++ b/Scribus/scribus/canvas.cpp
@@ -1775,6 +1775,7 @@ void Canvas::DrawPageMarks(ScPainter *p, Page
*page, QRect clip)
        double pageHeight=page->height();
        double pageWidth=page->width();
        p->setFillMode(ScPainter::None);
+       p->setStrokeMode(ScPainter::Solid);
        p->setPen(Qt::black, lineWidth, Qt::SolidLine, Qt::FlatCap,
Qt::MiterJoin);
        p->drawRect(0, 0, pageWidth, pageHeight);
        //Draw the margins

I've also looked for other places where the old behavior is relied
upon, but haven't found any.

I'd still like to ask you guys if you are OK with the change to
ScPainter that I did? It really shouldn't stroke when the stroke mode
is None, right?

Cheers,
Elvis



More information about the scribus-dev mailing list