A Box that exists on a HTMLCanvasElement

Hierarchy (view full)

Constructors

Properties

_layoutPosition: undefined | Point
_measuredSize: undefined | Rect
_needsDrawing: boolean = true
_needsLayoutX: boolean = true
_needsMeasuring: boolean = true
_parent: undefined | Box
_ready: boolean = true
bounds: undefined | RectPositioned
canvasRegion: RectPositioned = RectsPlaceholderPositioned

Rectangle Box occupies in canvas/etc

children: Box[] = []
debugHue: number = ...
debugLayout: boolean = false
id: string
takesSpaceWhenInvisible: boolean = false

Accessors

  • get desiredRegion(): undefined | BoxRect
  • Gets the box's desired region, or undefined

    Returns undefined | BoxRect

  • set desiredRegion(v): void
  • Sets the box's desired region. Calls onLayoutNeeded()

    Parameters

    Returns void

  • get root(): Box
  • Returns the root box

    Returns Box

  • get visible(): boolean
  • Gets visible state

    Returns boolean

  • set visible(v): void
  • Sets visible state

    Parameters

    • v: boolean

    Returns void

Methods

  • Called if this is the parent Box

    Parameters

    • element: HTMLElement

    Returns void

  • Debug log from this box context

    Parameters

    • m: any

    Returns void

  • Parameters

    • ctx: CanvasRenderingContext2D
    • force: boolean = false

    Returns void

  • Draw this object

    Parameters

    • _ctx: CanvasRenderingContext2D

    Returns void

  • Parameters

    • _reason: string

    Returns void

  • Returns Generator<never, IterableIterator<[number, Box]>, unknown>

  • Returns true if box is a child

    Parameters

    Returns boolean

  • Calls notifyChildLayoutNeeded

    Parameters

    • reason: string

    Returns void

  • Applies actual size, returning true if size is different than before

    1. Sets _needsLayout to false.
    2. Sets visual to m
    3. Calls measureApply on each child
    4. If there's a change or force, sets needsDrawing to true, and notifies root of measureApplied

    Parameters

    Returns boolean

  • Measure the box

    1. Uses desired rectangle, if possible
    2. Otherwise uses parent's size

    Parameters

    Returns string | Rect

  • Start of measuring

    1. Keeps track of measurements in opts.measurements
    2. If this box takes space 2.1. Measure itself if needed 2.2. Use size
    3. Calls measureStart on each child

    Parameters

    Returns undefined | Measurement

    Measurement

  • Sends a message to all child boxes.

    This first calls onNotify on this instance, before calling notify() on each child.

    Parameters

    • message: string
    • source: Box

    Returns void

  • Notification a child box has been added

    Throws if

    • child has parent as its own child
    • child is same as this
    • child is already child of this

    Parameters

    Returns void

  • Parameters

    Returns void

  • Handles a received message

    Parameters

    • _message: string
    • _source: Box

    Returns void

  • Handler when pointer has left

    Returns void

  • Handler when pointer moves within our region

    Parameters

    Returns void

  • Sets _ready to ready. If includeChildren is true, setReady is called on each child

    Parameters

    • ready: boolean
    • includeChildren: boolean = false

    Returns void

  • Returns void

  • Performs recalculations and drawing as necessary If nothing needs to happen, function returns.

    Parameters

    • context: CanvasRenderingContext2D
    • force: boolean = false

      Force update

    Returns void

  • Parameters

    • _measureChanged: boolean
    • _layoutChanged: boolean

    Returns void

  • Parameters

    • canvasElement: HTMLCanvasElement

    Returns CanvasBox