"width", "height", "min-width", "min-height", "max-width", "max-height" properties of View
These properties are set:
Property | Constant | Description |
---|---|---|
"width" | rui.Width | The width of View |
"height" | rui.Height | The height of View |
"min-width" | rui.MinWidth | The minimum width of View |
"min-height" | rui.MinHeight | The minimum height of View |
"max-width" | rui.MaxWidth | The maximum width of View |
"max-height" | rui.MaxHeight | The maximum height of View |
These properties are of type SizeUnit.If the "width" / "height" value is not set or is set to Auto, then the height/width of the Viewis determined by its content and limited to the minimum and maximum height/width.As the value of these properties, you can set the SizeUnit structure,the textual representation of the SizeUnit,or the name of the constant (about the constants below):
view.Set("width", rui.Px(8)) view.Set(rui.MaxHeight, "80%") view.Set(rui.Height, "@viewHeight")
After getting the value with the Get function, you must typecast:
if value := view.Get(rui.Width); value != nil { switch value.(type) { case string: text := value.(string) // TODO case SizeUnit: size := value.(SizeUnit) // TODO } }
This is quite cumbersome, therefore for each property there is a global function of the same name with the Get prefix,which performs the given cast, gets the value of the constant, if necessary, and returns it.All functions of this type have two arguments: View and subviewID ...string.The first argument is the root View, the second is the ID of the child View.If the ID of the child View is not specified or is passed as "", then the value of the root View is returned.For the properties "width", "height", "min-width", "min-height", "max-width", "max-height" these are functions:
func GetWidth(view View, subviewID ...string) SizeUnit func GetHeight(view View, subviewID ...string) SizeUnit func GetMinWidth(view View, subviewID ...string) SizeUnit func GetMinHeight(view View, subviewID ...string) SizeUnit func GetMaxWidth(view View, subviewID ...string) SizeUnit func GetMaxHeight(view View, subviewID ...string) SizeUnit