forked from arpit/openpyro
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFlowLayout.as
More file actions
58 lines (44 loc) · 1.36 KB
/
FlowLayout.as
File metadata and controls
58 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package org.openPyro.layout
{
import flare.query.methods.where;
import flash.display.DisplayObject;
import org.openPyro.core.UIContainer;
public class FlowLayout extends AbstractLayout implements ILayout{
public var horizontalGap:Number = 0;
public var verticalGap:Number = 0;
public function FlowLayout(horizontalGap:Number=0, verticalGap:Number=0){
this.horizontalGap = horizontalGap;
this.verticalGap = verticalGap;
}
protected var _container:UIContainer;
public function set container(container:UIContainer):void
{
_container = container;
}
public function getMaxWidth(children:Array):Number{
return NaN;
}
public function getMaxHeight(children:Array):Number{
return NaN
}
override public function calculatePositions(children:Array):Array{
super.calculatePositions(children);
var child:DisplayObject;
var nowX:Number = _initX;
var nowY:Number = _initY;
for(var i:uint=0; i<children.length; i++){
child = children[i] as DisplayObject;
if(nowX + child.width < _container.width){
}
else{
nowX = _initX;
nowY += child.height + verticalGap;
}
var descriptor:LayoutDescriptor = new LayoutDescriptor(child, nowX, nowY);
nowX = child.x+child.width + horizontalGap;
layoutDescriptors.push(descriptor);
}
return layoutDescriptors;
}
}
}