Skip to content

Commit 18d44a1

Browse files
author
as
committed
FlexComp.as - added data
FlexImage.as - added image tinting HGroup.as - added vertical wrap content feature
1 parent f9c02e6 commit 18d44a1

File tree

13 files changed

+206
-69
lines changed

13 files changed

+206
-69
lines changed

bin/Falcon.swc

1.57 KB
Binary file not shown.

src/com/hendrix/feathers/controls/flex/FlexButton.as

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ package com.hendrix.feathers.controls.flex
4242

4343
private var _id: String = null;
4444

45+
private var _data: Object = null;
46+
4547
/**
4648
* font size in percentages based on the control height
4749
*/
@@ -272,6 +274,12 @@ package com.hendrix.feathers.controls.flex
272274
_id = value;
273275
}
274276

277+
public function get data():Object { return _data; }
278+
public function set data(value:Object):void
279+
{
280+
_data = value;
281+
}
282+
275283
public function applyAlignment():void { }
276284
public function get isSensitiveToParent(): Boolean { return false; }
277285
public function setSensitiveToParent(count:uint):void {}

src/com/hendrix/feathers/controls/flex/FlexComp.as

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package com.hendrix.feathers.controls.flex
22
{
33
import com.hendrix.feathers.controls.flex.interfaces.IFlexComp;
44

5+
import flash.geom.Rectangle;
6+
57
import feathers.core.FeathersControl;
68
import feathers.core.IFeathersControl;
79
import feathers.events.FeathersEventType;
@@ -54,6 +56,8 @@ package com.hendrix.feathers.controls.flex
5456
private var _horizontalAlign: String = null;
5557
private var _verticalAlign: String = null;
5658

59+
private var _data: Object = null;
60+
5761
private var _isSensitiveToParent: Boolean = true;
5862

5963
private var _id: String = null;
@@ -241,6 +245,56 @@ package com.hendrix.feathers.controls.flex
241245

242246
}
243247

248+
/**
249+
* compute the content bounding box by it's children
250+
*
251+
* @return <code>Rectangle</code> representing a bounding box.
252+
*
253+
*/
254+
public function computeContentBoundBox(): Rectangle
255+
{
256+
var child: DisplayObject = null;
257+
258+
var minX: Number = Number.POSITIVE_INFINITY;
259+
var maxX: Number = Number.NEGATIVE_INFINITY;
260+
var minY: Number = Number.POSITIVE_INFINITY;
261+
var maxY: Number = Number.NEGATIVE_INFINITY;
262+
263+
for(var ix: uint = 0; ix < numChildren; ix++)
264+
{
265+
child = getChildAt(ix);
266+
267+
minX = Math.min(minX, child.x);
268+
minY = Math.min(minY, child.y);
269+
maxX = Math.max(maxX, child.x + child.width);
270+
maxY = Math.max(maxY, child.y + child.height);
271+
}
272+
273+
return new Rectangle(minX, minY, maxX, maxY);
274+
}
275+
276+
/**
277+
* compute the content width bounding box by it's children
278+
*
279+
* @return the width
280+
*
281+
*/
282+
public function contentWidth(): Number
283+
{
284+
return computeContentBoundBox().width;
285+
}
286+
287+
/**
288+
* compute the content width bounding box by it's children
289+
*
290+
* @return the width
291+
*
292+
*/
293+
public function contentHeight(): Number
294+
{
295+
return computeContentBoundBox().height;
296+
}
297+
244298
// layout
245299

246300
public function get percentWidth(): Number { return _percentWidth; }
@@ -381,6 +435,12 @@ package com.hendrix.feathers.controls.flex
381435
_id = value;
382436
}
383437

438+
public function get data():Object { return _data; }
439+
public function set data(value:Object):void
440+
{
441+
_data = value;
442+
}
443+
384444
override protected function initialize():void
385445
{
386446
super.initialize();
@@ -477,7 +537,7 @@ package com.hendrix.feathers.controls.flex
477537

478538
return validParent;
479539
}
480-
540+
481541
}
482542

483543
}

src/com/hendrix/feathers/controls/flex/FlexImage.as

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package com.hendrix.feathers.controls.flex
1818
* <li>set <code>scaleMode</code> to <code>SCALEMODE_STRECTH, SCALEMODE_LETTERBOX, SCALEMODE_ZOOM, SCALEMODE_NONE</code></li>
1919
* <li>set <code>_forceDisposeConcreteTexture</code> to control disposal of concrete textures</li>
2020
* <li>set <code>source</code> to MrGfxManager package paths ala "packA::map", or disk path "../assets/a.png"</li>
21+
* <li>set <code>color</code> to tint the image</li>
2122
* </ul>
2223
*
2324
* @author Tomer Shalev
@@ -45,6 +46,8 @@ package com.hendrix.feathers.controls.flex
4546
private var _flagDebugMode: Boolean = false;
4647
private var _quad_debug: Quad;
4748

49+
private var _color: int = -1;
50+
4851
/**
4952
* <p>a Flex comp Image container</p>
5053
* <ul>
@@ -60,6 +63,19 @@ package com.hendrix.feathers.controls.flex
6063
super();
6164
}
6265

66+
/**
67+
* a color to tint the image with.
68+
*
69+
*/
70+
public function get color(): int { return _color; }
71+
public function set color(value:int): void
72+
{
73+
_color = value;
74+
75+
if(_img)
76+
_img.color = _color;
77+
}
78+
6379
/**
6480
*
6581
* @return the original texture width
@@ -298,6 +314,9 @@ package com.hendrix.feathers.controls.flex
298314
else {
299315
_img = new Image(_tex);
300316

317+
if(_color >= 0)
318+
_img.color = _color;
319+
301320
if(_flagFadeInLoadedImage) {
302321
_img.alpha = 0.0;
303322
_tweenFade = new Tween(_img, 0.9);

src/com/hendrix/feathers/controls/flex/FlexLabel.as

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ package com.hendrix.feathers.controls.flex
5757

5858
private var _id: String = null;
5959

60+
private var _data: Object = null;
61+
6062
private var _isSensitiveToParent: Boolean = true;
6163
protected var _breakParentSensitivityAfter: Number = 5;
6264

@@ -272,6 +274,12 @@ package com.hendrix.feathers.controls.flex
272274
_id = value;
273275
}
274276

277+
public function get data():Object { return _data; }
278+
public function set data(value:Object):void
279+
{
280+
_data = value;
281+
}
282+
275283
public function applyAlignment():void { }
276284
public function get isSensitiveToParent(): Boolean { return false; }
277285
public function setSensitiveToParent(count:uint):void

src/com/hendrix/feathers/controls/flex/FlexList.as

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ package com.hendrix.feathers.controls.flex
4848
private var _verticalAlign: String = null;
4949

5050
private var _isSensitiveToParent: Boolean = true;
51-
private var _breakParentSensitivityAfter: Number = 3;
51+
private var _breakParentSensitivityAfter: Number = 3;
5252

5353
private var _id: String = null;
5454

55+
private var _data: Object = null;
56+
5557
/**
5658
* a Feather list that implements IFlexComp
5759
* @author Tomer Shalev
@@ -326,6 +328,12 @@ package com.hendrix.feathers.controls.flex
326328
_id = value;
327329
}
328330

331+
public function get data():Object { return _data; }
332+
public function set data(value:Object):void
333+
{
334+
_data = value;
335+
}
336+
329337
protected function internal_parent_observer(on:Boolean = true):void {
330338
var parentWidthDop: DisplayObject = _relativeCalcWidthParent ? _relativeCalcWidthParent as DisplayObject : getValidAncestorWidth() as DisplayObject;
331339
var parentHeightDop: DisplayObject = _relativeCalcHeightParent ? _relativeCalcHeightParent as DisplayObject : getValidAncestorHeight() as DisplayObject;

src/com/hendrix/feathers/controls/flex/FlexQuad.as

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ package com.hendrix.feathers.controls.flex
4848

4949
private var _isSensitiveToParent: Boolean = false;
5050

51+
private var _data: Object = null;
52+
5153
public function setSensitiveToParent(count:uint):void
5254
{
5355
// TODO Auto Generated method stub
@@ -292,6 +294,12 @@ package com.hendrix.feathers.controls.flex
292294
_id = value;
293295
}
294296

297+
public function get data():Object { return _data; }
298+
public function set data(value:Object):void
299+
{
300+
_data = value;
301+
}
302+
295303
override public function dispose():void
296304
{
297305
super.dispose();

src/com/hendrix/feathers/controls/flex/FlexTextInput.as

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ package com.hendrix.feathers.controls.flex
6464
private var _horizontalCenter: Number = NaN;
6565
private var _verticalCenter: Number = NaN;
6666

67-
private var _isSensitiveToParent: Boolean = true;
68-
protected var _breakParentSensitivityAfter: Number = 3;
67+
private var _isSensitiveToParent: Boolean = true;
68+
protected var _breakParentSensitivityAfter: Number = 3;
6969

70-
private var _id: String = null;
70+
private var _id: String = null;
71+
72+
private var _data: Object = null;
7173

7274
private var _relativeCalcWidthParent: DisplayObject = null;
7375
private var _relativeCalcHeightParent: DisplayObject = null;
@@ -303,6 +305,12 @@ package com.hendrix.feathers.controls.flex
303305
_id = value;
304306
}
305307

308+
public function get data():Object { return _data; }
309+
public function set data(value:Object):void
310+
{
311+
_data = value;
312+
}
313+
306314
public function get textCurrent():String
307315
{
308316
return super.text;

src/com/hendrix/feathers/controls/flex/HGroup.as

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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){

src/com/hendrix/feathers/controls/flex/ItemRendererBase.as

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ package com.hendrix.feathers.controls.flex
3232
/**
3333
* @inheritDoc
3434
*/
35-
public function get data(): Object { return this._data; }
35+
public override function get data(): Object { return this._data; }
3636
/**
3737
* @inheritDoc
3838
*/
39-
public function set data(value:Object): void
39+
public override function set data(value:Object): void
4040
{
4141
if(this._data == value)
4242
{

0 commit comments

Comments
 (0)