This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
built_in:layouts [2015/03/07 18:29] octazid completed |
built_in:layouts [2018/12/08 02:02] (current) |
||
---|---|---|---|
Line 10: | Line 10: | ||
Create layouts using the **CreateLayout** function of the [[built_in: | Create layouts using the **CreateLayout** function of the [[built_in: | ||
- | < | + | < |
Add child objects to a layout using the **AddChild** function of the layout object. | Add child objects to a layout using the **AddChild** function of the layout object. | ||
- | < | + | < |
- | The alignment of child objects within a layout can be set by adding the options **" | + | The alignment of child objects within a layout can be set by adding the options **" |
+ | Remove layouts using the **RemoveLayout** function of the app object: | ||
< | < | ||
Line 131: | Line 132: | ||
Absolute layouts allows you to add controls in any position relative to the width and height of your screen from 0 to 1. Absolute layouts ignore all alignment options and allow the absolute positioning of controls by calling the **SetPosition** and **SetSize** functions of each of the child objects. This type of layout is rarely used and you are encouraged use Linear layouts for most of your programs. | Absolute layouts allows you to add controls in any position relative to the width and height of your screen from 0 to 1. Absolute layouts ignore all alignment options and allow the absolute positioning of controls by calling the **SetPosition** and **SetSize** functions of each of the child objects. This type of layout is rarely used and you are encouraged use Linear layouts for most of your programs. | ||
+ | <code javascript> | ||
+ | function OnStart() | ||
+ | { | ||
+ | lay = app.CreateLayout( " | ||
+ | btn = app.CreateButton( "Press Me" ); | ||
+ | btn.SetPosition( 0.4,0.4 ); | ||
+ | btn.SetOnTouch( btn_OnTouch ); | ||
+ | lay.AddChild( btn ); | ||
+ | |||
+ | app.AddLayout( lay ); | ||
+ | } | ||
+ | |||
+ | function btn_OnTouch() | ||
+ | { | ||
+ | app.Alert( "This is a Absolute Layout!" | ||
+ | } | ||
+ | </ | ||
=====Padding and Margins===== | =====Padding and Margins===== | ||
In Linear and Frame Layouts, you can use the **SetPadding** function of a layout to keep a layout' | In Linear and Frame Layouts, you can use the **SetPadding** function of a layout to keep a layout' | ||
Line 154: | Line 172: | ||
===== Methods ===== | ===== Methods ===== | ||
- | ^Method ^Description ^ | + | ^ Method |
- | |Layout.AddChild( child,order ) | | | + | | Layout.AddChild( child,order ) |
- | |Layout.Animate( type, | + | | Layout.Animate( type, callback, time ) | known types: SlideFromLeft,SlideFromRight,SlideFromTop,SlideFromBottom, |
- | ScaleFromLeft | + | | Layout.ChildToFront( child ) |
- | SlideToLeft | + | | Layout.Destroy() |
- | ScaleToLeft | + | | Layout.DestroyChild( child ) |
- | SlideFromRight | + | | Layout.GetAbsHeight() |
- | ScaleFromRight | + | | Layout.GetAbsWidth() |
- | SlideToRight | + | | Layout.GetChildOrder( child ) | This function returns the rang of an Object of a Layout. |
- | ScaleToRight | + | | Layout.GetHeight() |
- | SlideFromTop | + | | Layout.GetPosition() |
- | ScaleFromTop | + | | Layout.GetType() |
- | SlideToTop | + | | Layout.GetVisibility() |
- | ScaleToTop | + | | Layout.GetWidth() |
- | SlideFromBottom | + | | Layout.SetOnTouch( callback ) |Does not work in ' |
- | ScaleFromBottom | + | | Layout.SetOnTouchDown( callback ) |only OnTouchDown works when in ' |
- | SlideToBottom | + | | Layout.SetOnTouchMove( callback ) |Does not work in ' |
- | ScaleToBottom</ | + | | Layout.SetOnTouchUp( callback ) |Does not work in ' |
- | |Layout.ChildToFront( child ) | | | + | | Layout.Release() |
- | |Layout.Destroy() | | | + | | Layout.RemoveChild( child ) | This removes a Child of an Layout, this Child can be added again with Layout.AddChild( child ). |
- | |Layout.DestroyChild( child ) | | | + | | Layout.SetBackColor( colorCode ) |
- | |Layout.GetAbsHeight() | | | + | | Layout.SetBackGradient( color1, |
- | |Layout.GetAbsWidth() | | | + | | Layout.SetBackGradientRadial( x, |
- | |Layout.GetChildOrder( child ) | | | + | | Layout.SetBackground( imageFile, options ) |
- | |Layout.GetHeight() | | | + | | Layout.SetMargins( left, |
- | |Layout.GetPosition() | | | + | | Layout.SetOrientation( orient ) | " |
- | |Layout.GetType() | | | + | | Layout.SetPadding( left, top, right, bottom ) | | |
- | |Layout.GetVisibility() | | | + | | Layout.SetPosition( left, top, width, height ) |
- | |Layout.GetWidth() | | | + | | Layout.SetScale( x,y ) |
- | |Layout.Release() | | | + | | Layout.SetSize( width, height ) | | |
- | |Layout.RemoveChild( child ) | | | + | | Layout.SetTouchable( touchable ) |
- | |Layout.SetBackColor( colorCode ) | | | + | | Layout.SetVisibility( visibility ) |
- | |Layout.SetBackGradient( color1, | + | |
- | |Layout.SetBackGradientRadial( x, | + | |
- | |Layout.SetBackground( imageFile, options ) |options is an optional string that can be “repeat” | | + | |
- | |Layout.SetMargins( left, | + | |
- | |Layout.SetOrientation( orient ) |" | + | |
- | |Layout.SetPadding( left, top, right, bottom ) | | | + | |
- | |Layout.SetPosition( left, top, width, height ) | | | + | |
- | |Layout.SetScale( x,y ) | | | + | |
- | |Layout.SetSize( width, height ) | | | + | |
- | |Layout.SetTouchable( touchable ) | | | + | |
- | |Layout.SetVisibility( visibility ) | " | + | |
===== Options ===== | ===== Options ===== | ||
You can combine options too. Use the comma to seperate the options: | You can combine options too. Use the comma to seperate the options: |