layout philosophy

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

layout philosophy

Postby carp » Fri Jun 18, 2004 4:16 am

Hi,

I just installed 2.0.1 yesterday -- thanks for exporting those jars, it all works out of the box now.

It took me a while to figure out, how to layout all those widgets properly, possibly because of my experience with the Qt Designer (Qt is a C++ toolkit, see http://doc.trolltech.com/3.3/designer-m ... subsection -- you can download a GPL version at http://www.trolltech.com/download/index.html?cid=20 ).

In Qt Designer, you do not need to know beforehand, how your widgets should be arranged. You simply place all the widgets on the canvas, without specifying any layout manager.

When you're pleased with the widget arrangement, you select multiple widgets at once (shift-click or with a rubberband) and arrange them with one out of three layout options: horizontally, vertically or in a grid.

That's it, the widgets all take their preferred size (which you can influence in the property editor) and if you need some spacing somewhere, simply add a spacer.

I think this approach is easier than being forced into the behavior of the layout managers from the beginning on (especially for prototyping, where you don't know exactly how the result should look like).

So much for the layouting philosophy, the only real problem I have is that the "snapshotting" of the widgets is rather slow and not always successful on X11/KDE. It usually takes a few seconds before the view shows the updated widgets -- and sometimes it only shows garbage.

Well, I'll test some more now.

Thanks,
Carsten[/i]
carp
 
Posts: 5
Joined: Mon Jun 07, 2004 5:43 am

Re: layout philosophy

Postby Eric Clayberg » Fri Jun 18, 2004 10:31 am

I think it is important to keep in mind that in the Java world, there are a large number of different layout managers available. They each have their own strengths and weaknesses. Multiple layout managers exist because there is no such thing as a perfect layout manager that will satisfy every user or use case. The goal of Designer is to support all of the Swing and SWT layout managers and make using them as easy as possible. We specifically don't pass judgement on which layout manager is the "best" one to use. You can go with something simple like null/absolute layout or you can go with something more powerful like GridLayout, GridBagLayout or FormLayout.

carp wrote:In Qt Designer, you do not need to know beforehand, how your widgets should be arranged. You simply place all the widgets on the canvas, without specifying any layout manager.

I think your familiarity with this particular tool is coloring your perceptions a bit. I reviewed the material at the links you provided, and I disagree with your implied assertion that you don't need to understand the layout manager that is used. Qt Designer seems to be using a layout manager that is very similar to the Swing BoxLayout manager. That's a fine layout manager, but you still need to understand how it works to get decent results out of it (e.g., how and when to group widgets, where to use spacers, etc). It is not a magic black box.

carp wrote:I think this approach is easier than being forced into the behavior of the layout managers from the beginning on (especially for prototyping, where you don't know exactly how the result should look like).

You can do essentially the same thing in Designer depending on which layout manager you choose. It sounds like you want to use more of a free form approach and then apply constraints when you have everything positioned the way you want. The best layout manager for that is the SWT FormLayout manager. You can lay widgets out anywhere you want in an X-Y grid. Once you are done, you can apply various constraints to control the widget's resizing behavior (e.g., lock the OK and Cancel buttons to the lower-right corner, have a list box grow to fill any extra space, etc.).

    Image
You also have a palette of alignment controls that you can use to adjust the widget positions.

    Image
carp wrote:So much for the layouting philosophy, the only real problem I have is that the "snapshotting" of the widgets is rather slow and not always successful on X11/KDE. It usually takes a few seconds before the view shows the updated widgets -- and sometimes it only shows garbage.

In that case, you should probably turn on Draft Mode (on the Designer > General preference page).
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby carp » Sat Jun 19, 2004 2:59 am

Multiple layout managers exist because there is no such thing as a perfect layout manager that will satisfy every user or use case. The goal of Designer is to support all of the Swing and SWT layout managers and make using them as easy as possible. We specifically don't pass judgement on which layout manager is the "best" one to use.


Right, and I am glad that Designer allows me to not learn all the details about all those layout managers :)

I think your familiarity with this particular tool is coloring your perceptions a bit.


Possibly :) However, I wanted to pass that idea along, because I haven't seen it anywhere else.

I reviewed the material at the links you provided, and I disagree with your implied assertion that you don't need to understand the layout manager that is used. Qt Designer seems to be using a layout manager that is very similar to the Swing BoxLayout manager. That's a fine layout manager, but you still need to understand how it works to get decent results out of it (e.g., how and when to group widgets, where to use spacers, etc). It is not a magic black box.


Right, it uses BoxLayout managers and a GridLayout manager.

The main advantage of the approach of applying those simple layout managers after laying out manually is, that you don't have to think in hierarchies. I.e. start with a Composite with a FormLayout, add into that another Composite with a GridLayout and into that, a label, a checkbox and another Composite... You just care about the arrangement, not about the technology, how this is achieved.

Another is, that not all widgets are moved around in a funny way when you remove one widget out of a GridLayout or change the number of columns.

It sounds like you want to use more of a free form approach and then apply constraints when you have everything positioned the way you want. The best layout manager for that is the SWT FormLayout manager. You can lay widgets out anywhere you want in an X-Y grid. Once you are done, you can apply various constraints to control the widget's resizing behavior (e.g., lock the OK and Cancel buttons to the lower-right corner, have a list box grow to fill any extra space, etc.).


Yes, that sounds like what I'm looking for. I'll have a look at that -- thanks!

In that case, you should probably turn on Draft Mode (on the Designer > General preference page).


Hmm, the widgets look different now, but it's still taking snapshots, which take so long. Interestingly, in the window being captured (which appears temporarily) I still see the non-draft widgets. Maybe there is a bug?

Thanks a lot for being so helpful and quick in your answers, by the way.

Best wishes
Carsten
carp
 
Posts: 5
Joined: Mon Jun 07, 2004 5:43 am

setBounds leftover after layout

Postby afalck » Tue Jun 22, 2004 8:30 am

Hi,

I added a bunch of Controls on a Composite... then I added a Layout manager to the Composite.

Designer seemed to handle the operations correctly... and the Designer Test looked good... but when I opened the WizardPage in my runtime environment, everything was moved around.

It turns out that Designer had added calls to setBounds when I was placing the components BEFORE setting the layout manager... when I added the layout, it should have removed the setBounds.

Arturo.
afalck
 
Posts: 1
Joined: Tue Jun 22, 2004 8:20 am

Re: setBounds leftover after layout

Postby Eric Clayberg » Fri Jul 02, 2004 1:19 pm

afalck wrote:It turns out that Designer had added calls to setBounds when I was placing the components BEFORE setting the layout manager... when I added the layout, it should have removed the setBounds.

Try this in the new 2004.07.02 build.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest