Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GridLayout

Hierarchy

  • GridLayout

Implements

Index

Constructors

constructor

  • new GridLayout(parent: null | GridLayout, x: number, y: number, width: number, cols: number, rowH: number, gap: number): GridLayout

Properties

Readonly cellH

cellH: number

Readonly cellHG

cellHG: number

Readonly cellW

cellW: number

Readonly cellWG

cellWG: number

Readonly cols

cols: number

Protected currCol

currCol: number

Protected currRow

currRow: number

Readonly gap

gap: number

Readonly parent

parent: null | GridLayout

Protected rows

rows: number

Readonly width

width: number

Readonly x

x: number

Readonly y

y: number

Methods

colsForWidth

  • colsForWidth(w: number): number

nest

  • nest(cols: number, spans?: [number, number]): GridLayout
  • Requests a spans sized cell from this layout (via .next()) and creates and returns a new child GridLayout for the returned box / grid cell. This child layout is configured to use cols columns and shares same gap as this (parent) layout. The configured row span only acts as initial minimum vertical space reseervation, but is allowed to grow and if needed will propagate the new space requirements to parent layouts.

    Note: this size child-parent size propagation ONLY works until the next cell is requested from any parent. IOW, child layouts MUST be completed/populated first before continuing with siblings/ancestors of this current layout.

    // single column layout (default config)
    const outer = gridLayout(null, 0, 0, 200, 1, 16, 4);
    
    // add button (full 1st row)
    button(gui, outer, "foo",...);
    
    // 2-column nested layout (2nd row)
    const inner = outer.nest(2)
    // these buttons are on same row
    button(gui, inner, "bar",...);
    button(gui, inner, "baz",...);
    
    // continue with outer, create empty row
    outer.next();
    
    // continue with outer (4th row)
    button(gui, outer, "bye",...);
    

    Parameters

    • cols: number
    • Optional spans: [number, number]

    Returns GridLayout

next

nextSquare

  • Returns a squared LayoutBox based on this layout's column width. This box will consume ceil(columnWidth / rowHeight) rows, but the returned box height might be less to satisfy the square constraint.

    Returns LayoutBox

Protected propagateSize

  • propagateSize(rspan: number): void
  • Updates max rows used in this layout and all of its parents.

    Parameters

    • rspan: number

      -

    Returns void

rowsForHeight

  • rowsForHeight(h: number): number

spansForSize

  • spansForSize(size: ArrayLike<number>): [number, number]
  • spansForSize(w: number, h: number): [number, number]

Generated using TypeDoc