@@ -3,6 +3,7 @@ package com.hendrix.feathers.controls.flex
33 import com.hendrix.feathers.controls.CompsFactory ;
44 import com.hendrix.feathers.controls.utils.TextUtils ;
55
6+ import flash.geom.Rectangle ;
67 import flash.text.TextFormat ;
78
89 import feathers.controls.Button ;
@@ -249,7 +250,7 @@ package com.hendrix.feathers.controls.flex
249250 var calcH: Number ;
250251
251252 _relativeCalcObject = relativeCalcWidthParent;
252-
253+
253254 var calcGap: Number = isNaN (_gap ) ? isNaN (_gapPercentWidth ) ? 0 : _relativeCalcObject . width * _gapPercentWidth : _gap ;
254255
255256 if (isNaN (_paddingTop ))
@@ -274,8 +275,8 @@ package com.hendrix.feathers.controls.flex
274275 if (dataInvalid || sizeInvalid || itemsMovedInvalid)
275276 {
276277 if (_dataProvider ) {
277- calcW = isNaN (_dataProvider [ ix] . percentWidth ) ? (isNaN (_dataProvider [ ix] . width ) ? doRef. width : _dataProvider [ ix] . width ) : ! (_dataProvider [ ix] . hasOwnProperty ("relativeCalcParent" )) ? (_dataProvider [ ix] . percentWidth / 100 )* width : (_dataProvider [ ix] . percentWidth / 100 )* _dataProvider [ ix] . relativeCalcParent. width ;
278- calcH = isNaN (_dataProvider [ ix] . percentHeight ) ? (( isNaN (_dataProvider [ ix] . height ) ? doRef. height : _dataProvider [ ix] . height ) ) : ! (_dataProvider [ ix] . hasOwnProperty ("relativeCalcParent" )) ? (_dataProvider [ ix] . percentHeight / 100 )* height : (_dataProvider [ ix] . percentHeight / 100 )* _dataProvider [ ix] . relativeCalcParent. height ;
278+ calcW = isNaN (_dataProvider [ ix] . percentWidth ) ? (isNaN (_dataProvider [ ix] . width ) ? doRef. width : _dataProvider [ ix] . width ) : ! (_dataProvider [ ix] . hasOwnProperty ("relativeCalcParent" )) ? (_dataProvider [ ix] . percentWidth / 100 )* width : (_dataProvider [ ix] . percentWidth / 100 )* _dataProvider [ ix] . relativeCalcParent. width ;
279+ calcH = isNaN (_dataProvider [ ix] . percentHeight ) ? (isNaN (_dataProvider [ ix] . height ) ? doRef. height : _dataProvider [ ix] . height ) : ! (_dataProvider [ ix] . hasOwnProperty ("relativeCalcParent" )) ? (_dataProvider [ ix] . percentHeight / 100 )* height : (_dataProvider [ ix] . percentHeight / 100 )* _dataProvider [ ix] . relativeCalcParent. height ;
279280
280281 if (calcW)
281282 doRef. width = calcW;
@@ -289,6 +290,29 @@ package com.hendrix.feathers.controls.flex
289290 (doRef as IFeathersControl). validate ();
290291 }
291292
293+ }
294+
295+ // if height was not set, we have to set to it's children bounding box,
296+ // because of vertical alignment considerations.
297+ if (height == 0 ) {
298+ var bbox: Rectangle = computeContentBoundBox();
299+
300+ var w: Number = width ;
301+ var h: Number = height ;
302+
303+ if (w== 0 )
304+ w = bbox. width ;
305+
306+ if (h== 0 )
307+ h = bbox. height ;
308+
309+ setSizeInternal(width , h, false );
310+ }
311+
312+ for (ix = 0 ; ix < numChildren - correct; ix++ )
313+ {
314+ doRef = getChildAt (ix + correct);
315+
292316 doRef. x = posx;
293317
294318 switch (_verticalAlign )
@@ -315,10 +339,10 @@ package com.hendrix.feathers.controls.flex
315339
316340 posx = posx - calcGap + _paddingLeft ;
317341
318- var align : Number = 0 ;
342+ var align : Number = 0 ;
319343
320344 if (_horizontalAlign == HorizontalLayout. HORIZONTAL_ALIGN_CENTER ) {
321- align = (width - posx)* 0.5 ;
345+ align = (width - posx) * 0.5 ;
322346
323347 for (ix = correct; ix < numChildren ; ix++ ) {
324348 doRef = getChildAt (ix);
@@ -334,12 +358,13 @@ package com.hendrix.feathers.controls.flex
334358 }
335359 }
336360
361+ // if width was not set, then we give the width that the children occupy
337362 if (width == 0 ) {
338363 explicitWidth = NaN ;
339364 var c : Number = isNaN (percentHeight ) ? 0 : percentWidth * relativeCalcWidthParent. width ;
340- var a : Boolean = setSizeInternal(Math . max (posx,c ), height , false );
365+ var a : Boolean = setSizeInternal(Math . max (posx, c ), height , false );
341366 }
342-
367+
343368 validateBackground();
344369
345370 if (parent is IFeathersControl){
0 commit comments