Hi, below is another patch to reduce the redraws caused by resizing tables. A new method Layout::queueDrawExcept(), that requests the drawing of a rectangle except another rectangle is added. It is then used in widget.cc to redraw the area that was previously occupied by a widget, but is no longer occupied after a resize or move. This makes it possible to redraw less when a table resizes. All in all it should reduce the flicker a bit when loading table based pages. Cheers, Johannes diff --git a/dw/layout.cc b/dw/layout.cc --- a/dw/layout.cc +++ b/dw/layout.cc @@ -610,11 +610,36 @@ void Layout::queueDraw (int x, int y, in area.width = width; area.height = height; + if (area.isEmpty ()) return; + for (container::typed::Iterator <View> it = views->iterator (); it.hasNext (); ) { View *view = it.getNext (); view->queueDraw (&area); } +} + +void Layout::queueDrawExcept (int x, int y, int width, int height, + int ex, int ey, int ewidth, int eheight) { + + if (x == ex && y == ey && width == ewidth && height == eheight) + return; + + // queueDraw() the four rectangles within rectangle (x, y, width, height) + // around rectangle (ex, ey, ewidth, eheight). + // Some or all of these may be empty. + + // upper left corner of the intersection rectangle + int ix1 = misc::max (x, ex); + int iy1 = misc::max (y, ey); + // lower right corner of the intersection rectangle + int ix2 = misc::min (x + width, ex + ewidth); + int iy2 = misc::min (y + height, ey + eheight); + + queueDraw (x, y, width, iy1 - y); + queueDraw (x, iy2, width, y + height - iy2); + queueDraw (x, iy1, ix1 - x, iy2 - iy1); + queueDraw (ix2, iy1, x + width - ix2, iy2 - iy1); } void Layout::queueResize (bool asap) diff --git a/dw/layout.hh b/dw/layout.hh --- a/dw/layout.hh +++ b/dw/layout.hh @@ -133,6 +133,8 @@ private: void updateCursor (); void updateBgColor (); void queueDraw (int x, int y, int width, int height); + void queueDrawExcept (int x, int y, int width, int height, + int ex, int ey, int ewidth, int eheight); void queueResize (bool asap); void removeWidget (); diff --git a/dw/table.cc b/dw/table.cc --- a/dw/table.cc +++ b/dw/table.cc @@ -61,6 +61,7 @@ Table::Table(bool limitTextWidth) hasColPercent = 0; colPercents = new misc::SimpleVector <float> (8); + redrawX = 0; redrawY = 0; } @@ -191,10 +192,11 @@ void Table::sizeAllocateImpl (core::Allo void Table::resizeDrawImpl () { + queueDrawArea (redrawX, 0, allocation.width - redrawX, getHeight ()); queueDrawArea (0, redrawY, allocation.width, getHeight () - redrawY); + redrawX = allocation.width; redrawY = getHeight (); } - void Table::setWidth (int width) { diff --git a/dw/table.hh b/dw/table.hh --- a/dw/table.hh +++ b/dw/table.hh @@ -378,7 +378,7 @@ private: int numRows, numCols, curRow, curCol; misc::SimpleVector<Child*> *children; - int redrawY; + int redrawX, redrawY; /** * \brief The extremes of all columns. @@ -437,11 +437,7 @@ private: void setCumHeight (int row, int value) { if (value != cumHeight->get (row)) { - if (row > 0) { - redrawY = misc::min ( redrawY, cumHeight->get (row - 1) ); - } else { - redrawY = 0; - } + redrawY = misc::min ( redrawY, value ); cumHeight->set (row, value); } } @@ -449,7 +445,7 @@ private: inline void setColWidth (int col, int value) { if (value != colWidths->get (col)) { - redrawY = 0; + redrawX = misc::min (redrawX, value); colWidths->set (col, value); } } diff --git a/dw/types.hh b/dw/types.hh --- a/dw/types.hh +++ b/dw/types.hh @@ -71,6 +71,7 @@ public: bool intersectsWith (Rectangle *otherRect, Rectangle *dest); bool isSubsetOf (Rectangle *otherRect); bool isPointWithin (int x, int y); + bool isEmpty () { return width <= 0 || height <= 0; }; }; /** diff --git a/dw/widget.cc b/dw/widget.cc --- a/dw/widget.cc +++ b/dw/widget.cc @@ -418,6 +418,18 @@ void Widget::sizeAllocate (Allocation *a // widget->allocation.x, widget->allocation.y, // widget->allocation.width, widget->allocation.ascent, // widget->allocation.descent); + + if (wasAllocated ()) { + layout->queueDrawExcept ( + this->allocation.x, + this->allocation.y, + this->allocation.width, + this->allocation.ascent + this->allocation.descent, + allocation->x, + allocation->y, + allocation->width, + allocation->ascent + allocation->descent); + } sizeAllocateImpl (allocation);