2
* This file is part of the dis-Emi-A HaXe Library. Copyright © edA-qa mort-ora-y
3
* For full copyright and license information please refer to doc/license.txt.
9
* This demonstrates how to create an automatic vertical layout of
10
* several items. It provides examples of how to use automatic
11
* sizing, relative sizing, and fixed sizing
13
class LinearLayout extends ui.StageLayout
15
var layout : ui.LinearLayout;
21
//create an empty vertical layout
22
layout = ui.LinearLayout.vertical();
25
//create a simple text item, allow itself to auto size
27
ui.StaticText.singleLine( "Auto-sizing text" )
30
//add a box which is always 10% the height of the entire layout
33
draw.Brush.solid( draw.Color.rgb( 1, 0, 0 ) ),
34
draw.Pen.solid( 2, draw.Color.rgb( 0.5, 0, 0 ) )
36
ui.SizeType.Primary( 0.1 )
39
//now add some text which is always two-lines high (since the text
40
//expands to fill the area, what we mean is two-line heights of normal
43
ui.StaticText.singleLine( "2 Text Rows High text" ),
44
ui.SizeType.Lines( 2 )
47
//then create a box which is always 10units high, not relative to any size
50
draw.Brush.solid( draw.Color.rgb( 0, 1, 0 ) ),
51
draw.Pen.solid( 1, draw.Color.rgb( 0, 0.5, 0 ) )
53
ui.SizeType.Fixed( 10 )
56
//now fill the remaining space with these two items. They used a weighting
57
//system for allocation: all the weights are added together, and each item
58
//gets its ratio of that weight, in this example:
59
// Total Weight = 4 + 1 = 5
60
// First Item = 4 / 5 = 80%
61
// Second Item = 1 / 5 = 20%
62
//Note that the Fill size type only uses up the remaining space, so these
63
//items could actually shrink to nothing (look at using Min/Max size types
64
//to alleviate that problem)
66
ui.Box.plain( draw.Brush.solid( draw.Color.rgb( 0, 0, 0.5 ) ) ),
70
ui.Box.plain( draw.Brush.solid( draw.Color.rgb( 0, 0.5, 0 ) ) ),
75
override function _resize( w : Float, h : Float )
77
//make the layout use the entire stage area
78
layout.resize( w, h );
81
static public function main()
83
ui.StageLayout.setup( LinearLayout );