KFlowRects proposal (planned for next Monday)

Benjamin Meyer ben at meyerhome.net
Mon Aug 6 18:46:26 BST 2007


On Aug 6, 2007, at 6:22 PM, 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...)
>
> -- 
> Matthew
> "Braaaaaaaaiins!" -- Zombies


It is normally customary to have the code written before asking to  
add it to kdelibs.  It also doesn't seem to have any docs or two apps  
that use it.

-Benjamin Meyer





More information about the kde-core-devel mailing list