Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [albireo-dev] SWT size/layout management

Gordon Hirsch wrote:
> > In contrast, Swing's relayout mechanism climbs up to the next "validation root",
> > i.e. the next component in the ancestors list which is known to isolate size
> > changes in its children from its parent (i.e. which is known to have constant
> > size, regardless of its children).
> 
> I don't know of any analogous concept in SWT. It's up to the 
> application. In effect, eveything is a validation root.

You mean, by default, every Composite is a "validation root" (shields its
parent component from size changes among its children)? And if a Composite
does not want to behave that way, it overrides layout():

     public void layout() {
       recomputeMyPreferredSize();
       getParent().layout();
       super.layout();
     }

?

> > When the SwingControl's size changes, we do
> > 
> >       getParent().layout();
> 
> We really shouldn't call it at all. I haven't had a chance to study the 
> recent changes, but the code in my current workspace only calls layout() 
> when we *first* get a real size for the embedded AWT component.

This is why, in the RelayoutExample, the size on the SWT side did not
update itself when one presses the Grow/Shrink buttons. You can play
with these buttons and the "SWT-Layout" button to convince yourself
that calling getParent().layout() is necessary for a good application
behaviour.

Bruno


Back to the top