Bug 152734 - Nested GridLayout allows child to be larger than parent
Summary: Nested GridLayout allows child to be larger than parent
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Veronika Irvine CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-03 10:00 EDT by Chris Merrill CLA
Modified: 2019-09-06 15:31 EDT (History)
2 users (show)

See Also:


Attachments
Example of nested grid layout problem (5.02 KB, text/plain)
2006-08-03 10:01 EDT, Chris Merrill CLA
no flags Details
screenshot of the problem (5.57 KB, image/png)
2006-08-08 13:18 EDT, Chris Merrill CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Merrill CLA 2006-08-03 10:00:15 EDT
My understanding of GridLayout parameters is that the grabExcessHorizontalSpace parameter in GridData allows a child to grab excess space within it's parent, but not grab extra space from outside its parent.

I will attach example code which shows the behavior in the context of a JFace TitleAreaDialog.  The example is a boiled-down version of a problem we encountered in an RCP/plugin project.  

Run the example (you will need core.runtime, jface and swt), press the "push me" and observe the resulting dialog. You can see that inner panel (yellow background) is larger than the outer panel (grey background, bordered by red).  Pushing the "show sizes" button will print the width of the inner and outer panels to system out.  If you then comment out line 104 and enable line 106 (see comments in the code) and re-run, you will see the fields sized correctly.  The only difference is the value of the grabExcessHorizontalSpace parameter in the GridData constructor.
Comment 1 Chris Merrill CLA 2006-08-03 10:01:45 EDT
Created attachment 47321 [details]
Example of nested grid layout problem
Comment 2 Veronika Irvine CLA 2006-08-08 12:09:29 EDT
// use this line to see the bug
_inner_panel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1));

In the code above you are not grabbing excess horizontal space (the value is false), instead you are saying that the child should be its preferred size - the preferred size of the child can be bigger than the available space in the client area of the parent.

// use this line for it to work correctly.
//_inner_panel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));

In the code above you are grabbing excess horizontal space (the value is true).  This means that the child will not be wider than the available area in the parent's client area.

According to your comments, the code above is doing what I would expect, I am not sure what the bug is.  I have not run your code because I do not have JFace installed.  Are your code comments incorrect?
Comment 3 Chris Merrill CLA 2006-08-08 13:16:45 EDT
The comments are correct.  The problem is that when the InnerPanel is allowed to be it's preferred size, it causes the parent container (OuterPanel) to become larger than it's container and causes other controls within the OuterPanel to grow as well. According to the javadocs for GridData.grabExcessHorizontalSpace : "If there is not enough horizontal space available in the parent, the cell will shrink until it reaches its minimum width as specified by GridData.minimumWidth." The default minimum width (0) is used. So, if my understanding of the javadocs is correct, no setting of the grabExcessHorizontalSpace parameter should allow children in a container with a GridLayout to be larger than the parent. Is this incorrect?

I will attach a screenshot. The grey background in the screenshot is the OuterPanel and the yellow background is the InnerPanel. You can see that the InnerPanel and other controls in the OuterPanel become larger than the parent container.  Or maybe the OuterPanel grows larger than _its_ parent (red background) -- but that has a FillLayout and the javadocs for FillLayout indicate that it does not allow its children to be larger than the container, either. I encourage you to find somebody who can run the code so you can see it in action.
Comment 4 Chris Merrill CLA 2006-08-08 13:18:41 EDT
Created attachment 47542 [details]
screenshot of the problem

This shows that children of the OuterPanel (grey background) are allowed to become larger than the container if the InnerPanel (yellow background) is not set to grab excess horizontal space.
Comment 5 Eclipse Webmaster CLA 2019-09-06 15:31:12 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.