PDA

View Full Version : [CLOSED][3.0] Container's available size in layout classes. Consistency needed.



Animal
22 Apr 2009, 5:55 AM
FitLayout has



onLayout : function(ct, target){
Ext.layout.FitLayout.superclass.onLayout.call(this, ct, target);
if(!this.container.collapsed){
var sz = (Ext.isIE6 && Ext.isStrict && target.dom == document.body) ? target.getViewSize() : target.getStyleSize();
this.setItemSize(this.activeItem || ct.items.itemAt(0), sz);
}
},


AnchorLayout has



getAnchorViewSize : function(ct, target){
return target.dom == document.body ?
target.getViewSize() : target.getStyleSize();
},



ColumnLayout has



onLayout : function(ct, target){
var cs = ct.items.items, len = cs.length, c, i;

if(!this.innerCt){
target.addClass('x-column-layout-ct');

// the innerCt prevents wrapping and shuffling while
// the container is resizing
this.innerCt = target.createChild({cls:'x-column-inner'});
this.innerCt.createChild({cls:'x-clear'});
}
this.renderAll(ct, this.innerCt);

var size = Ext.isIE && target.dom != Ext.getBody().dom ? target.getStyleSize() : target.getViewSize();
...


BorderLayout has



onLayout : function(ct, target){
var collapsed;
if(!this.rendered){
target.addClass('x-border-layout-ct');
var items = ct.items.items;
collapsed = [];
for(var i = 0, len = items.length; i < len; i++) {
var c = items[i];
var pos = c.region;
if(c.collapsed){
collapsed.push(c);
}
c.collapsed = false;
if(!c.rendered){
c.cls = c.cls ? c.cls +' x-border-panel' : 'x-border-panel';
c.render(target, i);
}
this[pos] = pos != 'center' && c.split ?
new Ext.layout.BorderLayout.SplitRegion(this, c.initialConfig, pos) :
new Ext.layout.BorderLayout.Region(this, c.initialConfig, pos);
this[pos].render(target, c);
}
this.rendered = true;
}

var size = target.getViewSize();
...



BoxLayout has



getTargetSize : function(target){
return (Ext.isIE6 && Ext.isStrict && target.dom == document.body) ? target.getStyleSize() : target.getViewSize();
//return Ext.isIE && target.dom != Ext.getBody().dom ? target.getStyleSize() : target.getViewSize();
}


There should be one method to do this in ContainerLayout.

And I'm still not convinced Element.getStyleSize accounts for padding correctly. It only subtracts getFrameWidth if borderBox. I thought borderBox determines whether the border is counted in size calculations: getFrameWidth only adds padding if borderBox. I think padding should always be added to the frame width if the onlyContentBox. param is passed.

Here's a bug report about that: http://extjs.com/forum/showthread.php?t=65963

Animal
22 Apr 2009, 5:57 AM
Let's get these finally sorted for the 3.0 final!

There are other layout problems too: http://extjs.com/forum/showthread.php?t=46056&highlight=layout+padding

jack.slocum
23 Apr 2009, 11:20 PM
The method of calculating the size is different for different layout types (e.g. floats vs absolute, etc).

With that said, I agree that this code:

return (Ext.isIE6 && Ext.isStrict && target.dom == document.body) ? target.getStyleSize() : target.getViewSize();

should be placed in a higher level class to cut some redundant code!