natiny.view.set_layout
Lua
natiny.view.set_layout(view, layout)
Sets how a view places its children.
Parameters
| Name |
Type |
Description |
view |
number |
View handle |
layout |
integer |
One of the constants below |
Constants
| Constant |
Children are placed |
natiny.view.FREE |
Independently from the content box's top-left corner |
natiny.view.VERTICAL |
Top to bottom |
natiny.view.HORIZONTAL |
Left to right |
natiny.view.CENTER |
In the center of the content box |
natiny.view.GRID |
In cells, left to right and top to bottom |
Example
Lua
-- stack the toolbar vertically on a narrow window
if natiny.window.get_width(win) < 600 then
natiny.view.set_layout(toolbar, natiny.view.VERTICAL)
else
natiny.view.set_layout(toolbar, natiny.view.HORIZONTAL)
end