H3lp Yours3lfDocs
api

grid

Arrange items into fixed-column horizontal rows.

Builds a vertical Flex containing horizontal Flex rows. items are assigned in order; columns defaults to 1, and values below 1 are treated as 1.

Example

local ui = require 'openmw.ui'
local util = require 'openmw.util'
local grid = require 'scripts.s3.components.grid'
local itemSlot = require 'scripts.s3.components.itemSlot'

local iconSize = util.vector2(72, 72)
local red = util.color.rgb(1, 0, 0)
local green = util.color.rgb(0, 1, 0)
local blue = util.color.rgb(0, 0, 1)

ui.create {
  type = ui.TYPE.Container,
  layer = 'Windows',
  content = ui.content {
    grid {
      columns = 3,
      items = {
        itemSlot {
          resource = { path = 'white' },
          count = 1,
          iconProps = { size = iconSize, color = red },
        },
        itemSlot {
          resource = { path = 'white' },
          count = 2,
          iconProps = { size = iconSize, color = green },
        },
        itemSlot {
          resource = { path = 'white' },
          count = 3,
          iconProps = { size = iconSize, color = blue },
        },
      },
    },
  },
}

Parameters

FieldTypeDescription
itemstableChild layouts assigned in order.
columnsinteger?Items per row; defaults to 1.
columnGapnumber?Horizontal space inserted between items in each row.
rowGapnumber?Vertical space inserted between generated rows.
rowPropstable?Properties copied to each generated row.
templateopenmw.ui.Template?Replaces the default grid template.

Common layout fields are documented on the UI Components overview.

See also

list · itemSlot · row