[scribus-dev] Question about culling area

Elvis Stansvik elvstone at gmail.com
Thu Aug 11 06:25:09 UTC 2011


After reading my mail I realize it wasn't crystal clear, so in short:

If a cell is being edited, I'd like the painter in
PageItem_Table::DrawObj_Item to be clipped to the content rectangle of
the cell.

In _all_ other cases, I'd like it clipped to the PoLine (frame rectangle).

One way to solve this would be to give PageItem_Table the concept of
an "active cell". E.g. something like

bool m_isEditing;
TableCell m_activeCell
setActiveCell(const TableCell &cell);
TableCell activeCell() const;

And change code in DrawObj_Item(..) to:

if (isEditing)
    p->setupPolygon(polygon); // With polygon created from m_activeCell...
else
    p->setupPolygon(&PoLine); // Just use the PoLine..

p->setClipPath();

I'm currently keeping track of the "active cell" locally in my table
editing canvas mode. I'm not sure it makes sense to keep it on the
table like this.

Any ideas / suggestions?

Elvis

2011/8/11 Elvis Stansvik <elvstone at gmail.com>:
> Hi,
>
> The text frames of the cells are painted as part of the normal table
> painting. However, I obviously don't want to re-paint the entire table
> on each keystroke in a cell.
>
> Currently, PageItem_Table::DrawObj_Item(...) sets the clip path to the
> PoLine (frame rectangle) unconditionally before painting. Like this:
>
> // Set the clip path.
> p->setupPolygon(&PoLine);
> p->setClipPath();
>
> I would like to change this so that it actually respects the QRectF
> argument passed to DrawObj_Item(..). This would allow me to do
> something like this after text is typed in a cell:
>
> m_canvas->update(canvasToLocal(cell.contentRect()));
>
> A lot of unnecessary code paths would still be followed in the table
> painting code, but at least the actual stroking where it's not needed
> would be avoided.
>
> There's a problem however: In PageItem::DrawObj(..), which is the
> function calling my DrawObj_Item(..) there's this snippet of code:
>
> if (cullingArea.isNull())
> {
>        cullingArea = QRectF(QPointF(m_Doc->minCanvasCoordinate.x(),
> m_Doc->minCanvasCoordinate.y()),
>                                                         QPointF(m_Doc->maxCanvasCoordinate.x(),
> m_Doc->maxCanvasCoordinate.y())).toAlignedRect();
> }
>
> This means that if the passed rectangle is null, it's setting the
> culling area to the entire canvas. Why is it doing this? Why not use
> the bounding rectangle of the item?
>
> Because of this, there's really no way for me to know when to use the
> PoLine as clip path, and when to use the passed in rectangle.
>
> I hope you see what I mean.
>
> Regards,
> Elvis
>



More information about the scribus-dev mailing list