Bug 19524 - [Workbench] Resizing WorkbenchWindow resizes Views
Summary: [Workbench] Resizing WorkbenchWindow resizes Views
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Stefan Xenos CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate, usability
: 44954 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-06-06 14:34 EDT by Randy Hudson CLA
Modified: 2004-07-19 15:19 EDT (History)
3 users (show)

See Also:


Attachments
Resize patch for M3 (37.85 KB, application/octet-stream)
2002-12-02 16:00 EST, Randy Hudson CLA
no flags Details
Changes on M8 (80.80 KB, application/octet-stream)
2004-04-08 18:26 EDT, Randy Hudson CLA
no flags Details
Previous .jar file, converted into a patch against org.eclipse.ui.internal M8 (18.21 KB, patch)
2004-04-14 18:54 EDT, Stefan Xenos CLA
no flags Details | Diff
Same patch, merged with head on 040414 (18.09 KB, patch)
2004-04-14 19:18 EDT, Stefan Xenos CLA
no flags Details | Diff
Latest patch, with modifications by SX (32.83 KB, patch)
2004-04-15 04:21 EDT, Stefan Xenos CLA
no flags Details | Diff
Updated patch (25.90 KB, patch)
2004-04-22 06:07 EDT, Stefan Xenos CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Randy Hudson CLA 2002-06-06 14:34:28 EDT
Post V2, but I'm reporting it anyway:

When the workbench window is resized, the various docked views such as outline 
and navigator are also resized.  This should only resize the EditorPane, with 
all other views staying a fixed size while size permits.

The fact that all views are resized means the User is constantly resizing Views 
after changing the workbench window size.  The User cannot grow just the 
EditorPane area, which is very common.  Or, when the window is maximized and 
the User "restores" it to do something like DND with File Explorer, all docked 
views get smaller.
Comment 1 Nick Edgar CLA 2002-06-06 15:38:54 EDT
Agree.  Should consider edges adjacent to editor area as unconstrained, and 
resize only the editor area if possible.
However, would still need to resize views proportionally, e.g. if two views are 
docked next to each other on the bottom and you resize horizontally.
Comment 2 Randy Giffen CLA 2002-08-12 10:48:37 EDT
Reopened for investigation
Comment 3 Randy Hudson CLA 2002-09-05 14:19:48 EDT
I understand the lower priority, but why was this changed to enhancement?  I'm 
sure the layout code is working as designed, but I think the design is flawed.  
Views should not resize when I resize the WorkbenchWindow.  I still consider 
this a bug.  I hope you can fix this for 2.1.
Comment 4 Randy Hudson CLA 2002-11-19 11:02:07 EST
Changing this back to "normal". The current behavior is wrong, and cannot be 
found in similar products, such as Visual Studio, or even explorer.exe
Comment 5 Randy Hudson CLA 2002-11-28 19:01:10 EST
>Yes, the new behaviour is better.  However, I should get this behaviour 
>immediately, and should not have to resize things first (yes, I closed all 
>perspectives first).
>I don't think perspectives should have to do anything differently.

This can work.  When setBounds(Rectangle) is called for the first time, Ratios 
that are between 0.0 and 1.0 can be converted to fixed-width ratios, and then 
the new value can be set back into the perspective.

I'm not sure if perspectives should make changes to take advantage of fixed-
sizes.  Probably they should if they know the minimum resolution. Or, you could 
take the ratio and multiply it by 800x600 pixels, assuming that is the minimum 
resolution. Off topic, but the first time a user resizes a sash, he should be 
prompted that his changes can be saved by re-saving the perspective.

>And there's some new, unwanted behaviour: if I close all perspectives then 
>open the resource perspective, the -window- jumps around (if not 
>maximized), apparently centering itself on the screen!

This didn't happen with me during devlopement on M3. Can you reproduce this on 
M3?
Comment 6 Randy Hudson CLA 2002-11-28 19:03:20 EST
The definition of "bias" is in the method JavaDoc, it is not related to aspect 
ratio.
Comment 7 Randy Hudson CLA 2002-12-02 16:00:38 EST
Created attachment 2612 [details]
Resize patch for M3

In this patch, ratios are converted to fixed sizes immediately. The user does
not have to resize the Sash first.

I had to check for the scenario of a perspective opening in a new window.
(lucky for me, I always work in that mode). For some reason, a layout is
performed when the Composite is width==height==0.  I had to add a check to
ignore this layout.
Comment 8 Nick Edgar CLA 2002-12-03 15:09:54 EST
Eduardo, could you please review Randy's patch?

I'd prefer not to reuse the ratio field.  
Comment 9 Randy Hudson CLA 2002-12-03 16:49:05 EST
In the patch, I renamed "ratio" to "sashLocation".  But, it's definition is 
overloaded.  If the location is between 0.0-1.0, it means a percentage.  If it 
is >1.0, it means a fixed distance.

If you make it so that there are 2 separate properties, it is never meaningful 
to use both. If this gets surface in plugin.xml files, it will probably be 
confusing either way. oh well..
Comment 10 Eduardo Pereira CLA 2002-12-16 13:20:01 EST
- I would opt to have a second property.
- I will not have the time to merge/change/test this code for M4.

Randy, if you have the time to apply these changes on top of M4, (once we have 
it) I will try to release it when I get the changes so we do not have to merge 
code. If you do not have the time, I will try to do it for M5.
Comment 11 Kevin Haaland CLA 2003-02-07 15:45:30 EST
There are no plans for the UI team to work on this defect until higher priority 
items are addressed.
Comment 12 Randy Hudson CLA 2003-06-02 17:26:44 EDT
I have continued to maintain and use this patch in 2.1.  It is part of my UI 
hacks download.  I have not heard of or seen any problems using it.
You can download the 2.1.0 version of it from:
http://dev.eclipse.org/viewcvs/index.cgi/gef-home/team/?cvsroot=Tools_Project
Comment 13 Randy Hudson CLA 2003-06-17 14:32:35 EDT
Please schedule a 3.0 milestone for this patch.  Obrigado :-)
Comment 14 Randy Hudson CLA 2003-10-15 16:53:58 EDT
Eduardo, if we add second property, its use will be mutually exclusive from the 
currently existing property.  And, you will have to add a THIRD property (a 
boolean), to indicate which of the other two properties should be used to 
determine size.

Also, new API would be required for these new properties.

On the other hand, extending the use of the existing property requires no new 
fields, and no new API.  You would simply have to broaden the definition of the 
current API.

Let me know what you want to do.  I will re-write this feature if you want 
separate fields.
Comment 15 Randy Hudson CLA 2004-02-12 14:10:47 EST
We are placing the GEF palette inside a workbench view.  The palette layout is 
very sensitive to view width.  It places the items in a column layout, 
wrapping buttons from left to right.  So, if the view width is constantly 
changing, the user does not know where to find their palette items.

BTW, my patch does not handle hide/show editor area :-P.  When the editor area 
goes away, layout nodes which used to have a compression bias will no longer 
have the bias, so they need to go back to using ratios.  So finally, a reason 
to have two separate properties, one a ratio, and one in pixels.

As far as behavior, I think that only one of the two properties should be 
update when the sash is dragged.  Obviously, it would be the property that is 
currently affecting the layout (ratio or absolute size).  Therefore, when you 
toggle editor visibility, it would be like having separate sash locations for 
with and without editor visibility.
Comment 16 Nick Edgar CLA 2004-02-12 14:35:29 EST
Michael, we were planning on including Randy's patch but it got lost in the 
team shuffle last year.  I just found out that some of the views in Lotus 
Workplace also care about maintaining a constant width (see bug 51580).

We should look at changing the resize behaviour as described, although I never 
liked the way the patch overloads the ratio/sashLocation field as describe 
above in comment #9.

Not sure if this patch will still be valid given all the changes that have gone 
on since it was originally provided, particularly for the new look.

Perhaps this is something that Stefan (aka Layout God) could fix up.
Comment 17 Michael Van Meekeren CLA 2004-02-16 15:57:50 EST
stefan, please investage supporting this in the current stream?  If the patch 
is not useful perhaps given the current layout, this may not be too hard to 
code from scratch.
Comment 18 Randy Hudson CLA 2004-02-16 16:31:53 EST
Stefan, I have been merging this patch into every 3.0 milestone manually, 
including M7.  It still works just fine.

However, as mentioned in comment 15, you will want to keep track of both a 
ratio (0.0 to 1.0), and a fixed-width pixel size (int). The patch only keeps 
track of one or the other (by overloading a field).  So this is problematic 
when show editor area is toggled.

When the user drags a sash, you will always store the new percentage, but only 
store the new fixed-width pixel size if there is compression bias.  Otherwise 
just hang onto the previous value.
Comment 19 Stefan Xenos CLA 2004-03-12 01:14:11 EST
Submitted the easy part of the fix: fastviews now maintain a constant size.

I have a question, though: what is the primary concern here? I see two related
issues:

1. There are some views that should never be resized.
2. In general it is better to resize the editor area than views.

Both are useful, but which one is most important here? Both would be equivalent
for views adjacent to the editor area, but item 1 would either require
truncating a view or leaving empty space in the workbench when one dimension of
the workbench is spanned entirely by non-resizable views.
Comment 20 Randy Hudson CLA 2004-03-12 09:21:35 EST
I think that only 2. is reasonable: It is better to resize the editor area than 
the views.  Consider also:

+--+-----+
|  |     |
+--+ edtr|
|  |     |
+--+-----+

When resizing height, the two left views are going to grow vertically. So even 
with the editor visible, 1.) is not possible. Ideally, if there were three left 
views, they would grow vertically the same amount. This could be acheived, but 
I digress.

If you want to get closer to 1)., in the above case, you could consider some UI 
to allow the user to fix the height of one of the two views in the vertical 
column. I have never seen such a UI though.  Perhaps there would be no UI, and 
the plug-in would indicate the views desire to grow/shrink.  For example, 
Progress View doesn't need to grow.
Comment 21 Stefan Xenos CLA 2004-03-12 22:40:51 EST
I guess I was unclear: I was specifically trying to refer to the case you
mentioned in comment 20. The layout algorithm already supports something close
to behavior 1. We needed this to support minimized views (which cannot resize
vertically). You can see the effect of a column of fixed-height views by
minimizing everything in a column and resizing the workbench window -- it's not
pretty, but it maintains the height constraint.

Comment 22 Randy Hudson CLA 2004-03-15 10:18:05 EST
I don't see a problem with minimized views.  Obviously they take priority over 
anything else and can be special-cased to ignore whatever sash location has 
been set.
Comment 23 Stefan Xenos CLA 2004-03-15 13:20:12 EST
There is no problem with minimized views. That's the point. They are an example
of a view which cannot be resized vertically, and they demonstrate that case 1
is possible.
Comment 24 Randy Hudson CLA 2004-04-06 14:46:08 EDT
I'm going to take a shot at solving this on M8
Comment 25 Randy Hudson CLA 2004-04-08 16:15:44 EDT
I have this working now.  The behavior is the same as my previous patch, but 
when the editor area is hidden, it reverts to using ratios instead of fixed 
sizes.

It supports restoring state from ratios, and lazily converting them to fixed 
sizes.  When saved, the layout is saved by saving both the ratio and the fixed 
size.  It is working for rollup, maximize view/editorpane, and with the intro 
view.  Any other test cases? I haven't tried fastviews yet.
Comment 26 Randy Hudson CLA 2004-04-08 18:26:56 EDT
Created attachment 9345 [details]
Changes on M8

Here is the JAR containing the modified classes for this fix.  Instead of
reusing the ratio field, I added two new integer fields, left and right.  Left
and right represent the size in pixels of the top/left and bottom/right parts. 
When there is no compression bias, the value (float)left/right is used to
determine what used to be stored in the ratio field.

Ratio field is no longer used except it is supported at startup and can be
specified by perspectives or mementos.	If the ratio is set, one a layout
occurs, left and right will be initialized to their appropriate values, and
ratio will be set to 0.0 and no longer used.
Comment 27 Nick Edgar CLA 2004-04-09 11:07:21 EDT
Does the patch also maintain the view heights when resizing vertically?
Comment 28 Randy Hudson CLA 2004-04-09 14:15:35 EDT
> Does the patch also maintain the view heights when resizing
> vertically?

yes
Comment 29 Stefan Xenos CLA 2004-04-14 18:41:09 EDT
Randy, I'm investigating this right now. In the future, it would be a lot easier
if you could create a patch file. (right-click on org.eclipse.ui.internal,
Team->Create Patch.. -> Save in File System -> Finish)
Comment 30 Stefan Xenos CLA 2004-04-14 18:54:53 EDT
Created attachment 9508 [details]
Previous .jar file, converted into a patch against org.eclipse.ui.internal M8
Comment 31 Stefan Xenos CLA 2004-04-14 19:18:34 EDT
Created attachment 9509 [details]
Same patch, merged with head on 040414

There seems to be a bug with the patch. When loading an existing workspace, all
of my views started out at their minimum sizes. After closing and reopening my
workspace, everything worked correctly.
Comment 32 Stefan Xenos CLA 2004-04-14 20:52:46 EDT
Some comments:

1. It appears that left, right, ratio, and the combined bounds of the left and
right controls all store the same information. Any of them can be calculated
directly from the others, given the bounds of the LayoutTree (which is known
during a resize). I suspect that it would be possible to code this using only
left and without changing its semantics on the fly.

2. The new PartSashContainer.add(...) method should follow the semantics of
addEnhanced(...), and should only take the size of the newly added part as an
argument (the size of the other part is already known).

3. I'm not fond of how isCompressible() needs to traverse the depth of the tree,
but this is also a problem with isVisible() and fixedHeight(), and it can be
fixed later.
Comment 33 Stefan Xenos CLA 2004-04-15 04:21:05 EDT
Created attachment 9521 [details]
Latest patch, with modifications by SX

Actually, never mind comment 32. I was confused by the precise meaning of the
left/right fields, but they make sense on closer inspection.

I've made the following changes:
- Fixed the bug in comment 31
- Removed the ratio parameter and lazy initialization of the left and right
fields (they are now initialized immediately).
- Changed the way ratios are treated on initialization -- rather than using the
size of the layout at the first resize event, perspectives are always
initialized in 800x600. This means that reset perspective -> resize window ->
resize perspective will not modify the perspective on the second reset, and it
means that a perspective will always look the same at the same resolution,
regardless of the user's initial window size. Unfortunately, it also changes
the initial layout of most perspectives. I want a second opinion on this.

I also started on a drag/drop patch that uses the new resize behavior to avoid
resizing views during drag/drop wherever possible... but I backed out of it for
now because that can be handled as a seperate feature.

Some stuff that still needs to be done before we can check this in:

1. LayoutPartSash needs JavaDoc to describe the precise meaning of
left/right/getLeft()/getRight(). 
2. WorkbenchPage.resizeView relies on ratios to work properly. I took a glance
over the code, and it looks like this method wasn't working correctly anyway
and it doesn't seem to be used. Nick, can you confirm if it's okay to remove
this? If not, we'll need to bring it up to date with the new layout code.
Comment 34 Stefan Xenos CLA 2004-04-15 04:33:21 EDT
Note: with this patch, it's quite easy to make the editor area disappear
entirely by reducing the size of the window. We may also want to address this
(perhaps the editor area can have some minimum size before we start resizing views).
Comment 35 Nick Edgar CLA 2004-04-15 13:36:26 EDT
Please do not delete resizeView.  This is work in progress.  See bug 
If it's currently broken, or needs to be fixed up for this patch, could you
please take care of it, or advise on how it should be fixed up in bug 51580?
Comment 36 Nick Edgar CLA 2004-04-15 13:39:54 EDT
There is already support in the LayoutPart hierarchy for minimum size.  See
LayoutPart.getMinimumWidth() and getMinimumHeight().  
It looks like this doesn't work too well currently for views.
E.g. in a new Java perspective, shrink the Problems view to its minimum height.
It shows some extra highlights, and the status area overlaps.
It should look the same as if the view was minimized.

Comment 37 Stefan Xenos CLA 2004-04-15 14:46:23 EDT
I was unclear. Comment 34 isn't referring to a minimum size for the editor area.
It is suggesting a size below which editors will be resized with the same
priority as views.
Comment 38 Randy Hudson CLA 2004-04-15 14:59:51 EDT
isCompressible() could be implemented to return false at some magical small 
size.  But you would have to know if the person asking is trying to compress 
you horizontally or vertically.  The editor pane may be really short, but have 
plenty of width for compressing.

So, isCompressible could return and INT which would be a bitwise ORing of 
SWT.HOROZONTAL and SWT.VERTICAL.
Comment 39 Stefan Xenos CLA 2004-04-15 15:30:37 EDT
Re: comment 38

This won't work. In order to do this, the editor area must have already been
resized to something too small. This means that you'll get a different layout if
you resize quickly and if you resize slowly. The layout should be entirely
determined by the size of the window.

BTW, I wonder if isCompressable() should really be a method on LayoutPart. This
seems to be an attribute of the PartSashContainer, not of its child parts.
Comment 40 Randy Hudson CLA 2004-04-16 11:36:32 EDT
I know what you mean.  In Draw2d, we have a very elaborate layout mechanism.  
The equivalent here would be:

boolean isCompressible(int wHint, int vHint);

And sashpartcontainers would call:
left.isCompressible(wHint - getRight(), vHint)
and similarly, for the right part, and for vertical orientation.
Comment 41 Stefan Xenos CLA 2004-04-22 06:07:17 EDT
Created attachment 9834 [details]
Updated patch

After chatting with Michael, we agreed that downstream perspectives won't like
having their initial layout changed. I've made this behave more like Randy's
original patch WRT initial view sizes.

I've updated it to work with WorkbenchPage.resizeView and Nick's recent
PartSashContainer changes, but I haven't tested these yet.
Comment 42 Stefan Xenos CLA 2004-04-22 17:29:42 EDT
Fixed in head.

For the final version of the patch, I changed the load/save state methods to
handle missing attributes without NPEs, and support saving workspaces that can
be loaded by earlier versions of Eclipse.
Comment 43 Stefan Xenos CLA 2004-07-19 15:19:40 EDT
*** Bug 44954 has been marked as a duplicate of this bug. ***