ColumnLayout
ColumnLayout is a container that implements the ViewsContainer interface.All child Views are arranged in a vertical list aligned to the left or right and split into several columns.The alignment depends on the "text-direction" property.
To create the ColumnLayout, use the function
func NewColumnLayout(session Session, params Params) ColumnLayout
"column-count" property
The "column-count" int property (ColumnCount constant) sets the number of columns.
If this property is 0 and the "column-width" property is not set,then no column splitting is performed and the container is scrolled down.
If the value of this property is greater than 0, then the list is split into columns.The column height is equal to the ColumnLayout height, and the width is calculatedas the ColumnLayout width divided by "column-count". Each next column is located dependingon the "text-direction" property to the right or left of the previous one, and the container is scrolled horizontally.
You can get the value of this property using the function
func GetColumnCount(view View, subviewID ...string) int
"column-width" property
The "column-width" SizeUnit property (ColumnWidth constant) sets the column width.This property is used only if "column-count" is 0, otherwise it is ignored.
IMPORTANT! Percentages cannot be used as the "column-width" value (i.e. if you specify a value in percent, the system will ignore it)
You can get the value of this property using the function
func GetColumnWidth(view View, subviewID ...string) SizeUnit
"column-gap" property
The "column-gap" SizeUnit property (ColumnGap constant) sets the width of the gap between columns.
You can get the value of this property using the function
func GetColumnGap(view View, subviewID ...string) SizeUnit
"column-separator" property
The "column-separator" property (ColumnSeparator constant) allows you to set a line that will be drawn at column breaks.The separator line is described by three attributes: line style, thickness, and color.
The value of the "column-separator" property is stored as the ColumnSeparatorProperty interface,which implements the Properties interface (see above). ColumnSeparatorProperty can contain the following properties:
Property | Constant | Type | Description |
---|---|---|---|
"style" | Style | int | Line style |
"width" | Width | SizeUnit | Line thickness |
"color" | ColorTag | Color | Line color |
Line style can take the following values:
Value | Constant | Name | Description |
---|---|---|---|
0 | NoneLine | "none" | No frame |
1 | SolidLine | "solid" | Solid line |
2 | DashedLine | "dashed" | Dashed line |
3 | DottedLine | "dotted" | Dotted line |
4 | DoubleLine | "double" | Double solid line |
All other style values are ignored.
To create the ColumnSeparatorProperty interface, use the function
func NewColumnSeparator(params Params) ColumnSeparatorProperty
The ColumnSeparatorProperty interface can be converted to a ViewBorder structure using the ViewBorder function.When converted, all text constants are replaced with real values. ViewBorder is described as
type ViewBorder struct { Style int Color Color Width SizeUnit }
The ViewBorder structure can be passed as a parameter to the Set function when settingthe value of the "column-separator" property. This converts the ViewBorder to ColumnSeparatorProperty.Therefore, when reading the property, the Get function will return the ColumnSeparatorProperty interface,not the ViewBorder structure.
You can get the ViewBorders structure without additional transformations using the global function
func GetColumnSeparator(view View, subviewID ...string) ViewBorder
You can also set individual line attributes using the Set function of the View interface.For this, the following properties are used
Property | Constant | Type | Description |
---|---|---|---|
"column-separator-style" | ColumnSeparatorStyle | int | Line style |
"column-separator-width" | ColumnSeparatorWidth | SizeUnit | Line thickness |
"column-separator-color" | ColumnSeparatorColor | Color | Line color |
For example
view.Set(rui.ColumnSeparatorStyle, rui.SolidBorder) view.Set(rui.ColumnSeparatorWidth, rui.Px(1)) view.Set(rui.ColumnSeparatorColor, rui.Black)
equivalent to
view.Set(rui.ColumnSeparator, ColumnSeparatorProperty(rui.Params{ rui.Style : rui.SolidBorder, rui.Width : rui.Px(1), rui.ColorTag: rui.Black, }))
"column-fill" property
The "column-fill" int property (ColumnFill constant) controls how an ColumnLayout's contents are balanced when broken into columns.Valid values:
Value | Constant | Name | Description |
---|---|---|---|
0 | ColumnFillBalance | "balance" | Content is equally divided between columns (default value) |
1 | ColumnFillAuto | "auto" | Columns are filled sequentially. Content takes up only the room it needs, possibly resulting in some columns remaining empty |
You can get the value of this property using the function
func GetColumnFill(view View, subviewID ...string) int
"avoid-break" property
When forming columns, ColumnLayout can break some types of View, so that the beginningwill be at the end of one column and the end in the next. For example, the TextView,the title of the picture and the picture itself are broken, etc.
The "avoid-break" bool property (AvoidBreak constant) avoids this effect.You must set this property to "true" for a non-breakable View.Accordingly, the value "false" of this property allows the View to be broken.The default is "false".
You can get the value of this property using the function
func GetAvoidBreak(view View, subviewID ...string) bool
"column-span-all" property
The "column-span-all" bool property (ColumnSpanAll constant) is set for Views placed in the ColumnLayout.If this property is set to true, then the View expands to the full width of the ColumnLayout, covering all columns.Such a View will, as it were, break the container.
Typically, this property is used for headers.
The default value is "false".
You can get the value of this property using the function
func IsColumnSpanAll(view View, subviewID ...string) bool