Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Question: Correct implementation of complex component layout(Question: How to correctly implement layout of component hierarchy)
Question: Correct implementation of complex component layout [message #1389219] Fri, 27 June 2014 14:00 Go to next message
Tomas R. is currently offline Tomas R.
Messages: 7
Registered: July 2009
Junior Member
Hello.

I'm now reviewing my older code written in pure SWT+jFace and I can't get it to re-layout correctly after some changes. The thing is that I can't seem to figure out how to correctly layout component hierarchy after some children component has been changed and its preferred size has potentially changed (child.computeSize(SWT.DEFAULT, SWT.DEFAULT)).

What is the correct way to implement such bottom->up re-layout?


My approach was this but does not always work as intended:
Throughout my code I used custom implementation of LayoutListeners that I implemented in my base class for CustomComposite.
@Override
public void layout() {
    // Simplified version
    for (LayoutListener l : layoutListeners) l.beforeLayout();
    super.layout();
    for (LayoutListener l : layoutListeners) l.afterLayout();
}

By registering such layout listener I can be notified of when the children component requests layout and can effectively layout its parent.

But this approach has a few setbacks:
- It sometimes requires more passes to be laid-out correctly: child component is firstly laid-out in boundaries that it previously obtained from the parent layout and then it has to be laid-out again after parent component has determined its preferred_size).
- And sometimes it does not work at all (and due to lack of scriptability for Java, debugging is really painful).

Please advise on correct approach. I hope that I'm not the only one that would benefit from such knowledge.
Re: Question: Correct implementation of complex component layout [message #1389239 is a reply to message #1389219] Fri, 27 June 2014 14:30 Go to previous message
Tomas R. is currently offline Tomas R.
Messages: 7
Registered: July 2009
Junior Member
If you don't understand my question, don't hesitate to say so. I'm perfectly willing to clarify.

I just hope, that this post will not end with 0 replies and 2k> views like the others in the forum. :/
Previous Topic:Set check simbol on a Menu manager
Next Topic:Developing 32bit SWT application on 64bit Linux
Goto Forum:
  


Current Time: Sat Oct 25 02:56:07 GMT 2014

Powered by FUDForum. Page generated in 0.09987 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software