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
| class Rect extends CustomNode
{
public var height: Number;
public var fill: Paint;
override protected function create(): Node
{
Rectangle
{
width: 50, height: height, fill: fill
onMousePressed: function (evt: MouseEvent): Void
{
var r = evt.node.parent as Rect;
println("{r} T {r.translateY} L {r.layoutY} M {r.layoutBounds.minY}");
}
}
}
}
var scene: Scene;
Stage
{
x: 0
title: "Test"
scene: scene = Scene
{
width: 500
height: 500
var vr: Rect;
content:
[
HBox
{
translateX: 50
translateY: 100
spacing: 10
content:
[
Rect { height: 200, id: "Ga", fill: Color.RED,
// No layout, reference...
},
Rect { height: 50, id: "Bu", fill: Color.GREEN,
translateY: 50
},
Rect { height: 50, id: "Zo", fill: Color.BLUE,
layoutY: 50
},
vr = Rect { height: 50, id: "ZoV", fill: Color.VIOLET,
//~ layoutY: bind 50 - vr.layoutBounds.minY // Throws an exception!
layoutY: 100
visible: false
},
Rect { height: 50, id: "Meu", fill: Color.MAGENTA,
layoutInfo: LayoutInfo { vpos: VPos.BOTTOM }
},
Rect { height: 100, id: "Foo", fill: Color.YELLOW,
layoutInfo: LayoutInfo { vpos: VPos.CENTER }
},
Rect { height: 100, id: "Bar", fill: Color.GRAY,
layoutInfo: LayoutInfo { vpos: VPos.BASELINE}
},
Rectangle
{
width: 300, height: 100, fill: Color.rgb(200, 200, 200, 0.5),
layoutInfo: LayoutInfo { managed: false }
layoutX: 30, layoutY: 30
},
]
}
]
}
} |