Box

It is probable that any window will have its content set to a Box—this is because it's the only control that provides a way to group multiple controls together. It's a control with no visible container, which is the basic layout mechanism within andlabs UI. You can create a new box using ui.NewHorizontalBox() or ui.NewVerticalBox(), which lays out its child controls horizontally or vertically in a linear arrangement. In a horizontal arrangement, the child items will all have the same height (which will match the height required for the tallest child), and in a vertical (stacked) configuration, they will all have the same width.

The method of adding child controls to a box is to call the Append() function, which takes a ui.Control child parameter and a bool stretchy parameter. The child will be added to the list of the components, and the stretchy parameter determines how the available space should be filled. When the stretchy parameter is true, the item will expand to fill extra space; if it's false, the minimum size will be observed. If multiple components have stretchy switched on, the spare space will be divided equally between them.

It's often going to provide a better visual flow for your user interface if widgets are separated by some space. There is a suitable method provided, SetPadded(), which will set a standard space between child widgets in the box. This size is set by the widget toolkit's standard metrics, and will vary from platform to platform. The padding applied in this way is placed between the child components—for outer (surrounding) space, you should set a margin. The margin is available in controls which embed a child controldubbed containers in this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.167.195