natiny.view.create
Lua
natiny.view.create([layout [, parent]]) -> view
Creates a view: a rectangle that is sized and placed by the rules set on it
and on its parent, and that lays out its own children by layout.
Parameters
| Name |
Type |
Default |
Description |
layout |
integer |
natiny.view.FREE |
How this view places its children; one of the constants below |
parent |
number |
nil |
View to append the new one to as its last child |
Layouts
| Constant |
Children are placed |
natiny.view.FREE |
Each at the size it needs in the top-left corner of the content box, moved by its offset; one that expands covers the whole box |
natiny.view.VERTICAL |
Top to bottom from the top, gap apart, each stretched to the full width |
natiny.view.HORIZONTAL |
Left to right from the left, gap apart, each stretched to the full height |
natiny.view.CENTER |
Each in the middle of the content box, at the size it needs |
natiny.view.GRID |
In cells, left to right and top to bottom from the top-left corner, each filling its cell; see set_columns and set_rows |
Returns
| Type |
Description |
number |
View handle; raises an error when memory runs out |
Example
Lua
local root = natiny.view.create(natiny.view.VERTICAL)
local header = natiny.view.create(natiny.view.HORIZONTAL, root)
local body = natiny.view.create(natiny.view.FREE, root)
Notes
- A new view asks for no size, does not expand, is visible and pickable,
and has no hooks.