ListLayout

Vertical orientation

Horizontal orientation

A container where items are arranged in a list-like structure

Create from source

func NewListLayout(session Session, params Params) ListLayout

Create new list layout object and returns its interface

Create from resource

ListLayout {
    id = listLayout,
    width = 100%,
    height = 100%,
    content = [],
}

Interface description

Inherit methods, properties and events from ViewsContainer

UpdateContent()

Updates child Views if the "content" property value is set to ListAdapter, otherwise does nothing

Properties

Inherit all properties of ViewsContainer

"Order"

Used in child views to specify visual order of the view inside the ListLayout. Items in a container are sorted by ascending order value and then by their addition to the container order

Constant: Order

Types: int, string

Values

int string Description
< 0 < "0" Views with lower value will be at the beginning
>= 0 >= "0" Views with higher value will be at the end

"content"

Defines an array of child views or can be an implementation of ListAdapter interface

Constant: Content

Types: []View, ListAdapter, View, string, []string

Internal type is either []View or ListAdapter, other types converted to []View during assignment

Conversion rules

View - view which describe one item, converted to []View

[]View - describe several items, stored as is

string - text representation of the view which describe one item, converted to []View

[]string - an array of text representation of the views which describe several items, converted to []View

ListAdapter - interface which describe several items, see ListAdapter description for more details

Examples

ListLayout {
    width = 100%,
    content = [
        "Item 1",
        ImageView {
            src = "search.png",
        },
        EditView {
            hint = "Enter name or description",
        },
    ],
}
list := rui.NewListLayout(session, rui.Params{
    rui.Width: rui.Percent(100),
    rui.Content: []string{
        "Item 1",
        "ImageView { src = \"search.png\",}",
        "EditView { hint = \"Enter name or description\",}",
    },
})
list := rui.NewListLayout(session, rui.Params{
    rui.Width: rui.Percent(100),
    rui.Content: []rui.View{
        rui.NewTextView(session, rui.Params{
            rui.Text: "Item 1",
        }),
        rui.NewImageView(session, rui.Params{
            rui.Source: "search.png",
        }),
        rui.NewEditView(session, rui.Params{
            rui.Hint: "Enter name or description",
        }),
    },
})

"gap"

Specify both "list-column-gap" and "list-row-gap"

Constant: Gap

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

ListLayout {
    gap = 1em,
    content = [
        "Item 1",
        "Item 2",
        "Item 3",
    ],
}
list := rui.NewListLayout(session, rui.Params{
    rui.Gap: rui.Em(1),
    rui.Content: []string{
        "Item 1",
        "Item 2",
        "Item 3",
    },
})

"horizontal-align"

Sets the horizontal alignment of the content inside a block element

Constant: HorizontalAlign

Types: int, string

Values

int string Description
0(LeftAlign) "left" Left alignment
1(RightAlign) "right" Right alignment
2(CenterAlign) "center" Center alignment
3(StretchAlign) "stretch" Width alignment

"list-column-gap"

Set the distance between the columns of the ListLayout. Default value 0px

Constant: ListColumnGap

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

ListLayout {
    list-column-gap = 1em,
    content = [
        "Item 1",
        "Item 2",
        "Item 3",
    ],
}
list := rui.NewListLayout(session, rui.Params{
    rui.ListColumnGap: rui.Em(1),
    rui.Content: []string{
        "Item 1",
        "Item 2",
        "Item 3",
    },
})

"list-row-gap"

Set the distance between the rows of the ListLayout. Default value 0px

Constant: ListRowGap

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

ListLayout {
    list-row-gap = 1em,
    orientation = up-down,
    content = [
        "Item 1",
        "Item 2",
        "Item 3",
    ],
}
list := rui.NewListLayout(session, rui.Params{
    rui.ListRowGap: rui.Em(1),
    rui.Orientation: rui.TopDownOrientation,
    rui.Content: []string{
        "Item 1",
        "Item 2",
        "Item 3",
    },
})

"list-wrap"

Defines the position of elements in case of reaching the border of the container

Constant: ListWrap

Types: int, string

Values

int string Description
0(ListWrapOff) "off" The column or row of elements continues and goes beyond the bounds of the visible area
1(ListWrapOn) "on" Starts a new column or row of elements as necessary. The new column is positioned towards the end
2(ListWrapReverse) "reverse" Starts a new column or row of elements as necessary. The new column is positioned towards the beginning

"orientation"

Specifies how the children will be positioned relative to each other

Constant: Orientation

Types: int, string

Values

int string Description
0(TopDownOrientation) "up-down" Child elements are arranged in a column from top to bottom
1(StartToEndOrientation) "start-to-end" Child elements are laid out in a row from beginning to end
2(BottomUpOrientation) "bottom-up" Child elements are arranged in a column from bottom to top
3(EndToStartOrientation) "end-to-start" Child elements are laid out in a line from end to beginning

"vertical-align"

Sets the vertical alignment of the content inside a block element

Constant: VerticalAlign

Types: int, string

Values

int string Description
0(TopAlign) "top" Top alignment
1(BottomAlign) "bottom" Bottom alignment
2(CenterAlign) "center" Center alignment
3(StretchAlign) "stretch" Height alignment
func GetListColumnGap(view View, subviewID ...string) SizeUnit

Returns the gap between ListLayout or ListView columns. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetListHorizontalAlign(view View, subviewID ...string) int

Returns the vertical align of a ListLayout or ListView subview: LeftAlign (0), RightAlign (1), CenterAlign (2) and StretchAlign (3). If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetListOrientation(view View, subviewID ...string) int

Returns the orientation of a ListLayout or ListView subview: TopDownOrientation (0), StartToEndOrientation (1), BottomUpOrientation (2) and EndToStartOrientation (3). If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetListRowGap(view View, subviewID ...string) SizeUnit

Returns the gap between ListLayout or ListView rows. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetListVerticalAlign(view View, subviewID ...string) int

Returns the vertical align of a ListLayout or ListView sibview: TopAlign (0), BottomAlign (1), CenterAlign (2) and StretchAlign (3). If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetListWrap(view View, subviewID ...string) int

Returns the wrap type of a ListLayout or ListView subview: ListWrapOff (0), ListWrapOn (1) and ListWrapReverse (2). If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func ListLayoutByID(rootView View, id string) ListLayout

Return a ListLayout with id equal to the argument of the function or nil if there is no such View or View is not ListLayout

func UpdateContent(view View, subviewID ...string)

Updates child Views of ListLayout or GridLayout subview if the "content" property value is set to ListAdapter or GridAdapter, otherwise does nothing. If the second argument (subviewID) is not specified or is an empty string then the first argument (view) updates