[Panel-devel] Panel contentSize

Jason Stubbs jasonbstubbs at gmail.com
Mon Nov 26 15:07:11 CET 2007


On Monday 26 November 2007 21:35:17 Sébastien Le Ray wrote:
> Le Mon, 26 Nov 2007 12:36:20 +0100,
> Sebastian Kügler <sebas at kde.org> a écrit :
> > On Monday 26 November 2007 12:32:30 Sébastien Le Ray wrote:
> > > Trying to fit an applet to the inner size of the panel (to avoid the
> > > hardcoded 48 value everywhere)... Should I use the layout margins ?

All you need to do is set your initial size (and possibly minimumSize), 
override expandingDirections() to specify in what directions extra space is 
useful (defaults to both) and then let the layout give you a size.

> > contentSize() returns a height of 48 in the panel, no? The width
> > needs to be set accordingly, but I'd wait fixing that until the panel
> > layout has the necessary features -- i.e. is able to do something
> > sensible with contentSizeHint() from the applet.

It already does. At least that's how I'm managing size changes with my 
systemtray patch. I call updateGeometry and return the minimum size from 
contentSizeHint() and the layout resizes the tray to the width I specify
and the height of the panel. expandingDirections() also works as expected.

> Returned height seems to be more than 48, it also includes margins
> of the background. If we take the standard panel (bottomEdge), looking
> at the code we see that an height is set (to 48) and then we add the
> background margin to this (height += topHeight - 1). So the height used
> in geometry is the height were applets are displayed plus the top
> margin of the background which leads to a situation where contentSize
> gives us an height of 70 (with a panel of 48) so applets (or other
> clients) calling contentSize believe that they can draw on 70 pixels,
> but, the actual displayed size will be 48 since applet is positionned
> below background margins.

I haven't looked into what the height of an applet in the panel should be,
but what it currently is is 51 pixels. Put ksnapshot into region mode and
then go ahead and measure - quite useful. ;)

However, I found yesterday that the panel resizes applets to a height of 55 
pixels. I've just found that the panel's boxlayout is being given a bottom 
margin of -4, which the attached patch fixes. Why the current height is 51 
pixels rather than 48? I don't know.

-- 
Jason Stubbs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: panel-margins.patch
Type: text/x-diff
Size: 704 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/panel-devel/attachments/20071126/e5db3a6f/attachment.bin 


More information about the Panel-devel mailing list