PDA

View Full Version : [FIXED][3.x svn4476] HBox layout does not honour margins when in stretch mode



Stefan B
18 Jun 2009, 11:51 PM
[Rev 4476]

It seems that HBox layout with align set to "stretch" does not calculate the correct heights for all items if one of the items has its own margins override the defaultMargins of the layout and the overridden margins differ from the default values.


Ext.onReady(function() {

var viewport = new Ext.Viewport({
layout: "hbox",
layoutConfig: {
align: "stretch",
defaultMargins: {top: 5, right: 5, bottom: 5, left: 5}
},
items: [{
frame: true,
width: 300
}, {
frame: true,
// margins: {top: 0, right: 0, bottom: 0, left: 0},
flex: 1
}]
});

});

If you uncomment the margin definition for the second panel you will see that the first panel overflows the lower edge of the browser window.

PS: I have seen and read this thread (http://extjs.com/forum/showthread.php?t=65963) but I don't think it is related.

evant
19 Jun 2009, 12:24 AM
On which browser? On FF3 with the latest SVN build the right one is flush up against the bottom of the window, but it doesn't go over, you can see the tiny white spaces in the corner for where the "frame" is.

Stefan B
19 Jun 2009, 12:30 AM
Checked with IE7, FF 3, Chrome 2, Opera 9.6, Safari 4.
Beware, it's the left panel that goes over the edge.

evant
19 Jun 2009, 12:49 AM
Ah, gotcha, try the latest SVN build.

Stefan B
19 Jun 2009, 12:55 AM
Looks much better.
Man, that was fast! =D>

evant
19 Jun 2009, 1:12 AM
Marking this one as fixed.

bereal
19 Jun 2009, 5:42 AM
Where I can get it? What is the full svn path?

evant
19 Jun 2009, 5:45 AM
http://extjs.com/forum/showthread.php?t=15191
http://extjs.com/forum/showthread.php?t=30633

http://code.extjs.com/svn/ext

bereal
19 Jun 2009, 5:49 AM
Thanks!

Animal
19 Jun 2009, 6:42 AM
One extra request:

Can the margins be parsed the same way as BorderLayout does where you can specify a space-separated list of numbers, and it calculates them in standard CSS manner?



margins: "5 5 5 5"


That would be top, right, bottom, left when there are 4 numbers.

The margin parsing function from BorderLayout can be hoisted to ContainerLayout. It's generally useful.

Condor
19 Jun 2009, 6:46 AM
One extra request:

Can the margins be parsed the same way as BorderLayout does where you can specify a space-separated list of numbers, and it calculates them in standard CSS manner?



margins: "5 5 5 5"


That would be top, right, bottom, left when there are 4 numbers.

The margin parsing function from BorderLayout can be hoisted to ContainerLayout. It's generally useful.

But that is how it currently works!

BoxLayout.renderItem calls ContainerLayout.parseMargins when the margins option contains a string.

evant
19 Jun 2009, 6:51 AM
That's how it works already, it's in ContainerLayout.

Edit: Condor beat me to it.

Animal
19 Jun 2009, 6:52 AM
Ah, I see that now after looknig a bit more. It replaces the margins with the parsed margins on render. Cool!

Stefan B
23 Jun 2009, 11:18 PM
Should be mentioned in the docs.

Stefan B
23 Jun 2009, 11:39 PM
Seems like the "fix for margins" from rev 4489 (dev comments: "multiply by 2 because we've already set the left/top to account for the left/top margin") broke it.

Don't know what multiplying by 2 in the setWidth/setHeight methods is supposed to fix, the added code seems unneccessary to me.

Try the use case from this post:
http://extjs.com/forum/showthread.php?t=71835
Bottom margins should be 5px, but are 10px.

Tested with current versions of FF3, IE7, Opera, Safari and Chrome.

mjlecomte
24 Jun 2009, 5:18 AM
Should be mentioned in the docs.

What specifically? margins is already mentioned in defaultMargins docs for BoxLayout. I could see where we might document "margins" config in say BoxComponent, and add a description similar to how "anchor" is documented (ie. .... only applies when used in BoxLayout.....yada yada yada....).

Stefan B
24 Jun 2009, 8:28 AM
What specifically?

I was refering to the fact that you can pass defaultMargins to the BoxLayout as a space-separated list of integers the same way you would specify margins for BorderLayout regions.
That should be mentioned in the docs.

Stefan B
24 Jun 2009, 8:30 AM
And, as my new bug report titled "Margin calculation for BoxLayout broken again" was merged with this thread, could you remove the FIXED tag from the OP?

Thanks

evant
24 Jun 2009, 8:34 AM
The change was reverted.

mjlecomte
24 Jun 2009, 10:26 AM
I was refering to the fact that you can pass defaultMargins to the BoxLayout as a space-separated list of integers the same way you would specify margins for BorderLayout regions.
That should be mentioned in the docs.

Done.