KFlowRects proposal (planned for next Monday)

Richard Dale rdale at foton.es
Mon Aug 6 18:34:34 BST 2007


On Monday 06 August 2007, Matthew Woehlke wrote:
> I would like to add (next Monday) this class to kdelibs (probably kdeui?
> where is a good place?). This class takes some information about items
> and "flows" them in a container. The container is a rectangle, with
> fixed-size items and fixed spacing between the items. The purpose it to
> determine the coordinates of the n'th item by "flowing" items in the
> container with the requested size and spacing.
>
> So if you have 7 items with different sized containers, this sort of
> gives an idea what it going on:
>
> +---------+
>
> | 1 2 3 4 |
> | 5 6 7   |
>
> +---------+
>
> +--------+
>
> | 1 2 3  |
> | 4 5 6  |
> | 7      |
>
> +--------+
>
> The API looks something like this (pseudocode, please ignore not-consts,
> not-references, etc.):
>
> void setContainerSize(QRect container)
> void setContainerSize(QSize container) // sets top-left to (0,0)
> void setContainerSize(int x, int y, int w, int h)
> void setContainerSize(int w, int h) // sets top-left to (0,0)
>
> void setItemSize(QSize size)
> void setItemSize(int w, int h)
>
> void setItemSpacing(int h, int v)
> void setItemHSpacing(int h)
> void setItemVSpacing(int v)
>
> // the useful part :-)
> QRect itemPos(int index)
>
>
> I will use as my API-freeze excuse that I am moving/improving a kdefx
> class (KPixmapSplitter) :-). In fact the only change (besides naming) is
> that the ctors no longer require a QPixmap to set the container size.
>
> Suggestions for better names welcomed. Also getters are probably wanted.
> Are the convenience overloads too much? (Should there be ctors that look
> like setContainerSize? Although I would like to not have anything
> unchangeable after construction...)
From reading the KPixmapSplitter header it doesn't sound like a layouting 
component at all. It sounds as though it takes one big pixmap, and splits it 
up into individual smaller pixmaps to use as icons.

-- Richard






More information about the kde-core-devel mailing list