"border" property of View

The "border" property defines a border around the View. The frame line is described by three attributes:line style, thickness and color.

The value of the "border" property is stored as the BorderProperty interface,which implements the Properties interface (see above). BorderProperty can contain the following properties:

Property Constant Type Description
"left-style" LeftStyle int Left border line style
"right-style" RightStyle int Right border line style
"top-style" TopStyle int Top border line style
"bottom-style" BottomStyle int Bottom border line style
"left-width" LeftWidth SizeUnit Left border line width
"right-width" RightWidth SizeUnit Right border line width
"top-width" TopWidth SizeUnit Top border line width
"bottom-width" BottomWidth SizeUnit Bottom border line width
"left-color" LeftColor Color Left border line color
"right-color" RightColor Color Right border line color
"top-color" TopColor Color Top border line color
"bottom-color" BottomColor Color Bottom border 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.

The NewBorder function is used to create the BorderProperty interface.

If all the lines of the frame are the same, then the following properties can be used to set the style, thickness and color:

Property Constant Type Description
"style" Style int Border line style
"width" Width SizeUnit Border line width
"color" ColorTag Color Border line color

Example

view.Set(rui.Border, NewBorder(rui.Params{
	rui.LeftStyle:   rui.SolidBorder,
	rui.RightStyle:  rui.SolidBorder,
	rui.TopStyle:    rui.SolidBorder,
	rui.BottomStyle: rui.SolidBorder,
	rui.LeftWidth:   rui.Px(1),
	rui.RightWidth:  rui.Px(1),
	rui.TopWidth:    rui.Px(1),
	rui.BottomWidth: rui.Px(1),
	rui.LeftColor:   rui.Black,
	rui.RightColor:  rui.Black,
	rui.TopColor:    rui.Black,
	rui.BottomColor: rui.Black,
}))

equivalent to

view.Set(rui.Border, NewBorder(rui.Params{
	rui.Style   : rui.SolidBorder,
	rui.Width   : rui.Px(1),
	rui.ColorTag: rui.Black,
}))

The BorderProperty interface can be converted to a ViewBorders structure using the Border function.When converted, all text constants are replaced with real values. ViewBorders is described as

 type ViewBorders struct {
	Top, Right, Bottom, Left ViewBorder
}

where the ViewBorder structure is described as

type ViewBorder struct {
	Style int
	Color Color
	Width SizeUnit
}

The ViewBorders structure can be passed as a parameter to the Set function when setting the value of the "border" property.This converts the ViewBorders to BorderProperty. Therefore, when the property is read,the Get function will return the BorderProperty interface, not the ViewBorders structure.You can get the ViewBorders structure without additional transformations using the global function

func GetBorder(view View, subviewID ...string) ViewBorders

Besides the auxiliary properties "style", "width" and "color" there are 4 more: "left", "right", "top" and "bottom".As a value, these properties can only take the ViewBorder structure and allow you to set all the attributes of the line of the side of the same name.

You can also set individual frame attributes using the Set function of the View interface.For this, the following properties are used

Property Constant Type Description
"border-left-style" BorderLeftStyle int Left border line style
"border-right-style" BorderRightStyle int Right border line style
"border-top-style" BorderTopStyle int Top border line style
"border-bottom-style" BorderBottomStyle int Bottom border line style
"border-left-width" BorderLeftWidth SizeUnit Left border line width
"border-right-width" BorderRightWidth SizeUnit Right border line width
"border-top-width" BorderTopWidth SizeUnit Top border line width
"border-bottom-width" BorderBottomWidth SizeUnit Bottom border line width
"border-left-color" BorderLeftColor Color Left border line color
"border-right-color" BorderRightColor Color Right border line color
"border-top-color" BorderTopColor Color Top border line color
"border-bottom-color" BorderBottomColor Color Bottom border line color
"border-style" BorderStyle int Border line style
"border-width" BorderWidth SizeUnit Border line width
"border-color" BorderColor Color Border line color
"border-left" BorderLeft ViewBorder Left border line
"border-right" BorderRight ViewBorder Right border line
"border-top" BorderTop ViewBorder Top border line
"border-bottom" BorderBottom ViewBorder Bottom border line

Example

view.Set(rui.BorderStyle, rui.SolidBorder)
view.Set(rui.BorderWidth, rui.Px(1))
view.Set(rui.BorderColor, rui.Black)

equivalent to

view.Set(rui.Border, NewBorder(rui.Params{
	rui.Style   : rui.SolidBorder,
	rui.Width   : rui.Px(1),
	rui.ColorTag: rui.Black,
}))