Skip to main content

LensStudio:Ui.GridLayout

Class

Arranges child layouts and widgets in a grid with rows and columns.

Index

Example

const root = new Widget(parent);
const grid = new GridLayout();
grid.spacing = 6;
root.layout = grid;

// Row 0: header spanning 2 columns
const title = new Label(root);
title.text = 'Transform';
title.fontRole = FontRole.TitleBold;
grid.addWidgetWithSpan(title, 0, 0, 1, 2, Alignment.AlignLeft);

// Row 1-3: label + button pairs in a grid
const axes = ['X', 'Y', 'Z'];
const values = [0, 0, 0];
const labels: Label[] = [];

for (let i = 0; i < 3; i++) {
const axisLabel = new Label(root);
axisLabel.text = `${axes[i]}:`;
grid.addWidgetAt(axisLabel, i + 1, 0, Alignment.AlignRight);

const valLabel = new Label(root);
valLabel.text = `${values[i]}`;
valLabel.fontRole = FontRole.Monospace;
labels.push(valLabel);
grid.addWidgetAt(valLabel, i + 1, 1, Alignment.AlignLeft);
}

Extends

Constructors

Constructor

new GridLayout(): GridLayout

Constructor for a grid layout container that arranges child widgets in rows and columns.

Returns

GridLayout

Overrides

Layout.constructor

Properties

enabled

enabled: boolean

Whether the layout is active and responsive to user input.

Inherited from

Layout.enabled


isNull

readonly isNull: boolean

Whether this object references a valid layout.

Inherited from

Layout.isNull


spacing

spacing: number

Distance between widgets in the layout.

Inherited from

Layout.spacing

Methods

addLayout()

addLayout(layout, row, column, alignment): void

Add a layout to the grid at a specific row and column with alignment.

Parameters

ParameterType
layoutLayout
rownumber
columnnumber
alignmentAlignment

Returns

void


addWidget()

addWidget(widget): void

Add a widget to the layout.

Parameters

ParameterType
widgetWidget

Returns

void

Inherited from

Layout.addWidget


addWidgetAt()

addWidgetAt(widget, row, column, alignment): void

Add a widget to the grid at a specific row and column with alignment.

Parameters

ParameterType
widgetWidget
rownumber
columnnumber
alignmentAlignment

Returns

void


addWidgetWithSpan()

addWidgetWithSpan(widget, fromRow, fromColumn, rowSpan, columnSpan, alignment): void

Add a widget to the grid spanning multiple rows and columns with alignment.

Parameters

ParameterType
widgetWidget
fromRownumber
fromColumnnumber
rowSpannumber
columnSpannumber
alignmentAlignment

Returns

void


clear()

clear(behavior): void

Remove all widgets from the layout with specified cleanup behavior.

Parameters

ParameterType
behaviorClearLayoutBehavior

Returns

void

Inherited from

Layout.clear


deleteLater()

deleteLater(): void

Schedule layout for deletion after event processing.

Returns

void

Inherited from

Layout.deleteLater


getColumnMinimumWidth()

getColumnMinimumWidth(column): number

Get the minimum width of a column.

Parameters

ParameterType
columnnumber

Returns

number


getColumnStretch()

getColumnStretch(column): number

Get the stretch factor of a column.

Parameters

ParameterType
columnnumber

Returns

number


getRowMinimumHeight()

getRowMinimumHeight(row): number

Get the minimum height of a row.

Parameters

ParameterType
rownumber

Returns

number


getRowStretch()

getRowStretch(row): number

Get the stretch factor of a row.

Parameters

ParameterType
rownumber

Returns

number


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

Layout.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Layout.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Layout.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

Layout.isSame


setColumnMinimumWidth()

setColumnMinimumWidth(column, minSize): void

Set the minimum width of a column.

Parameters

ParameterType
columnnumber
minSizenumber

Returns

void


setColumnStretch()

setColumnStretch(column, stretch): void

Set the stretch factor of a column.

Parameters

ParameterType
columnnumber
stretchnumber

Returns

void


setContentsMargins()

setContentsMargins(left, top, right, bottom): void

Set the margins around layout contents.

Parameters

ParameterType
leftnumber
topnumber
rightnumber
bottomnumber

Returns

void

Inherited from

Layout.setContentsMargins


setLayoutAlignment()

setLayoutAlignment(layout, alignment): boolean

Set alignment for a nested layout within this layout.

Parameters

ParameterType
layoutLayout
alignmentAlignment

Returns

boolean

Inherited from

Layout.setLayoutAlignment


setRowMinimumHeight()

setRowMinimumHeight(row, minSize): void

Set the minimum height of a row.

Parameters

ParameterType
rownumber
minSizenumber

Returns

void


setRowStretch()

setRowStretch(row, stretch): void

Set the stretch factor of a row.

Parameters

ParameterType
rownumber
stretchnumber

Returns

void


setWidgetAlignment()

setWidgetAlignment(widget, alignment): boolean

Set alignment for a widget within this layout.

Parameters

ParameterType
widgetWidget
alignmentAlignment

Returns

boolean

Inherited from

Layout.setWidgetAlignment