Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 226172

Summary: GridLayout.layout(...) ignores border insets
Product: [Tools] GEF Reporter: Adrian Price <adrianp.quatinus>
Component: GEF-Legacy Draw2dAssignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: ahunter.eclipse, mseele, nyssen
Version: unspecified   
Target Milestone: 3.5.0 (Galileo) M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
proposed patch nyssen: iplog+

Description Adrian Price CLA 2008-04-08 14:37:20 EDT
Build ID: I20070625-1500

Steps To Reproduce:
1. Apply a GridLayout to a figure which has a border with non-zero insets.
2. Add some child figures.
3. When rendered, the top-level figure is clipped because its preferred size as computed by GridLayout.layout(IFigure, boolean, int, int, int, int, boolean) is incorrect, because it does not account for the insets required by the figure's border.

More information:
See the fix descibed in BUG#71684 Comment#9:

"To fix the problem I put the following lines at the end of the layout(~) method:

    ...
    Border border = container.getBorder();
    if (border != null) {
        Insets insets = border.getInsets(container);
        totalDefaultHeight += insets.getHeight();
        totalDefaultWidth += insets.getWidth();
    }
    return new Dimension(totalDefaultWidth, totalDefaultHeight);
  }
"

I left the 'version' field set to 'unspecified' because it was unclear to me whether this was supposed to be the Eclipse version (3.3.2) or the Draw2D version (3.2.100).
Comment 1 Alex Boyko CLA 2008-10-03 15:34:26 EDT
Created attachment 114220 [details]
proposed patch

#layout() works with the client area and GridLayout#layout() doesw work with the client area. I think you actually need the fix in GridLayout#calculatePreferredSize(...). The fix-patch is attached.
Comment 2 Anthony Hunter CLA 2008-10-15 14:18:07 EDT
Hi Adrian, Can you confirm the patch fixes your issue?
Comment 3 Adrian Price CLA 2008-10-20 06:28:00 EDT
(In reply to comment #2)
> Hi Adrian, Can you confirm the patch fixes your issue?

Hi Alex and Anthony,

The patch seems to do the trick for my application. It is almost identical to the calculatePreferredSize() override that I have been using, other than that the patch accounts in addition for the border's preferred size.

Many thanks,

Adrian.
(Senior Architect, TIBCO Software Inc.)
Comment 4 Michael Seele CLA 2008-11-14 07:32:24 EST
will the fix be released in the next draw2d version? that will be great!
Comment 5 Anthony Hunter CLA 2009-03-06 11:37:53 EST
Committed to HEAD for GEF (draw2d) 3.5