forked from arpit/openpyro
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathColumnGridLayout.as
More file actions
72 lines (58 loc) · 1.76 KB
/
ColumnGridLayout.as
File metadata and controls
72 lines (58 loc) · 1.76 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package org.openPyro.layout
{
import flash.display.DisplayObject;
import org.openPyro.core.UIContainer;
public class ColumnGridLayout extends AbstractLayout implements ILayout, IContainerMeasurementHelper
{
protected var _numRows:uint;
protected var _columnWidth:Number = NaN;
protected var _rowGap:Number;
protected var _columnGap:Number;
public function ColumnGridLayout(numRows:uint, columnWidth:Number = NaN, rowGap:Number=0, columnGap:Number=0)
{
this._numRows = numRows;
_columnWidth = columnWidth;
_rowGap = rowGap
_columnGap = columnGap
}
private var _container:UIContainer
public function set container(c:UIContainer):void
{
_container = c;
}
override public function calculatePositions(children:Array):Array{
if(children.length == 0 ) return [] ;
layoutDescriptors = [];
var nowX:Number = _initX;
var nowY:Number = _initY;
if(isNaN(_columnWidth)){
_columnWidth = DisplayObject(children[0]).width;
}
for(var i:uint=0; i<children.length; i++)
{
var child:DisplayObject = children[i] as DisplayObject;
if(i>0 && (i%_numRows)==0){
nowX+=_columnWidth+_columnGap;
nowY = _initY;
}
var descriptor:LayoutDescriptor = new LayoutDescriptor(child, nowX, nowY);
layoutDescriptors.push(descriptor);
nowY+=child.height + _rowGap;
}
return layoutDescriptors;
}
public function getMaxWidth(children:Array):Number
{
// TODO: stub ... this needs to cahnge to actually use a calculation
return 300;
}
public function getMaxHeight(children:Array):Number
{
//TODO: stub ... this needs to cahnge to actually use a calculation
return 300;
}
public function calculateSizes(children:Array, container:UIContainer):void
{
}
}
}