Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RegionWithChildren<LayoutProps>

A base class for layout regions that have children.

Notes

This class uses a Phosphor panel for managing the lifecycle of the children- subclassers should choose a subclass of Panel appropriate for their use-case. Panel is itself appropriate for subclasses with custom layout algorithms.

Type parameters

Hierarchy

Implements

  • IMessageHandler
  • IObservableDisposable
  • IDisposable
  • IStaleable

Index

Properties

Private _didUpdate

_didUpdate: boolean = false

Private flag that is set to true after an update-request.

This is used by the layout algorithm to ensure that all subtrees updated properly, since some Phosphor containers will skip updating in certain cases.

Private addPartOverlay

addPartOverlay: Panel = new Panel()

calculatedSize

calculatedSize: object | undefined

The absolute size of this region. May be pre-defined, or calculated. May be undefined until the first call to DashboardLayoutRegion#sizeContentToFit()

see

sizeContentToFit

deprecated

Layout algorithms should use top-down styling

constructor

Abstract content

content: Panel

dataset

dataset: DOMStringMap

The dataset for the widget's DOM node.

disposed

disposed: ISignal<this, void>

A signal emitted when the widget is disposed.

id

id: string

An immutable ID assigned to this layout region that is unique within it's dashboard

isAttached

isAttached: boolean

Test whether the widget's node is attached to the DOM.

isDisposed

isDisposed: boolean

Test whether the widget has been disposed.

isHidden

isHidden: boolean

Test whether the widget is explicitly hidden.

isVisible

isVisible: boolean

Test whether the widget is visible.

Notes

A widget is visible when it is attached to the DOM, is not explicitly hidden, and has no explicitly hidden ancestors.

layout

Protected metadata

metadata: ParentMetadata<LayoutProps>

node

node: HTMLElement

Get the DOM node owned by the widget.

parent

parent: Widget | null

Set the parent of the widget.

Notes

Children are typically added to a widget by using a layout, which means user code will not normally set the parent widget directly.

The widget will be automatically removed from its old parent.

This is a no-op if there is no effective parent change.

title

title: Title<Widget>

The title object for the widget.

Notes

The title object is used by some container widgets when displaying the widget alongside some title, such as a tab panel or side bar.

Since not all widgets will use the title, it is created on demand.

The owner property of the title is set to this widget.

titlebar

titlebar: WidgetWrapper

The titlebar for this region.

see

TitleBar

Abstract typeName

typeName: LayoutTypes

Accessors

OnStale

  • get OnStale(): Observable<void>

isFocused

  • get isFocused(): boolean

isStale

  • get isStale(): boolean

Protected owner

parentRegion

properties

  • get properties(): Readonly<Partial<LayoutProps>>
  • set properties(newProps: Readonly<Partial<LayoutProps>>): void

uuid

  • get uuid(): string

widgets

Methods

Private _markSubtreeForUpdate

  • _markSubtreeForUpdate(): void
  • Private method to mark a subtree in an update loop.

    This is only intended for use by the DashboardLayout.

    Returns void

Private _updateSkippedSubtrees

  • _updateSkippedSubtrees(): void
  • Private method to update skipped subtrees in an update loop.

    This is only intended for use by the DashboardLayout.

    Returns void

activate

  • activate(): void
  • Post an 'activate-request' message to the widget.

    Notes

    This is a simple convenience method for posting the message.

    Returns void

addChild

  • Insert a new child at the "end" of this container.

    Notes

    The default implementation of this function calls insertChild() with the length of the children as 'i'.

    see

    insertWidget

    Parameters

    Returns void

addClass

  • addClass(name: string): void
  • Add a class name to the widget's DOM node.

    Parameters

    • name: string

      The class name to add to the node.

      Notes

      If the class name is already added to the node, this is a no-op.

      The class name must not contain whitespace.

    Returns void

attachChrome

  • attachChrome(chromeElement: Widget): void
  • Attach a new element to this region's chrome.

    Region chroming is a way of attaching transient or parent-specific elements to the DOM, without interfering with the base class or the implementation of the region children.

    To remove the chrome, simply #dispose() it.

    Region chroming is automatically cleared whenever the parentRegion changes.

    Parameters

    • chromeElement: Widget

    Returns void

children

  • children(): IIterator<Widget>
  • Create an iterator over the widget's children.

    Returns IIterator<Widget>

    A new iterator over the children of the widget.

    Notes

    The widget must have a populated layout in order to have children.

    If a layout is not installed, the returned iterator will be empty.

clearAttachedProperties

clearFlag

  • clearFlag(flag: Flag): void
  • Clear the given widget flag.

    Notes

    This will not typically be called directly by user code.

    Parameters

    • flag: Flag

    Returns void

close

  • close(): void
  • Send a 'close-request' message to the widget.

    Notes

    This is a simple convenience method for sending the message.

    Returns void

contains

  • contains(widget: Widget): boolean
  • Test whether a widget is a descendant of this widget.

    Parameters

    • widget: Widget

      The descendant widget of interest.

    Returns boolean

    true if the widget is a descendant, false otherwise.

copyAttachedProperties

createDragShadow

  • Create a drag shadow for one of this region's children.

    remarks

    Drag shadows are signifiers of the region being dragged, and indicate to the user what the dragged region is. For some regions (like the Canvas), it's useful to customize this shadow to expose more information (such as how it will be positioned in the CanvasPanel).

    The shadow must be completely static- it will not recieve any events, and will be destroyed at the end of the drag operation.

    Parameters

    • child: DashboardLayoutRegion<any>

      The region that is being dragged

    • clientX: number

      The X coordinate that the drag will start from

    • clientY: number

      The Y coordinate that the drag will start from

    Returns HTMLElement

    A valid HTML node that will follow the mouse during the drag.

dispose

  • dispose(): void

Private findCommonAncestor

Private findPrunableChildren

fit

  • fit(): void
  • Post a 'fit-request' message to the widget.

    Notes

    This is a simple convenience method for posting the message.

    Returns void

focus

  • focus(): void

getAttachedPropertyForChild

Protected getDefault

  • getDefault(propertyName: string): unknown

getLayoutProperty

  • getLayoutProperty<K>(propertyName: K): LayoutProps[K]
  • Return the value of a layout region property.

    This should fall back to default values if the property is undefined, and respect per-property logic (such as flexSize/fixedSize precedence)

    Type parameters

    • K: keyof LayoutProps

    Parameters

    • propertyName: K

      The name of the layout property to retrieve

    Returns LayoutProps[K]

handleEvent

  • handleEvent(ev: IDragEvent): void

hasClass

  • hasClass(name: string): boolean
  • Test whether the widget's DOM node has the given class name.

    Parameters

    • name: string

      The class name of interest.

    Returns boolean

    true if the node has the class, false otherwise.

hide

  • hide(): void
  • Hide the widget and make it hidden to its parent widget.

    Notes

    This causes the isHidden property to be true.

    If the widget is explicitly hidden, this is a no-op.

    Returns void

hideOverlay

  • hideOverlay(): void

hideRootOverlay

  • hideRootOverlay(): void

insertChild

  • Insert a new child into this container at a particular index.

    Notes

    If the widget is already in this region's children, then the widget is moved instead. This matches the behavior of Phosphor panels.

    This function also sets the parentRegion of the widget to this region.

    Parameters

    Returns void

Protected installContentTap

  • installContentTap(): void
  • Installs a message tap on the content to listen for child-removed.

    This tap is necessary for regions that use a custom layout algorithm, since the parent won't necessarily be notified when a Panel child is removed.

    Returns void

Abstract layoutChildren

  • layoutChildren(): void
  • Synchronously arrange the children of this region.

    Notes

    The MavenWorks framework uses a slightly different layout algorithm than Phosphor layouts- MavenWorks is top-down and starts with root-level invariants (such as window size) and moves downwards. This allows many layout panels to use analytical, linear-time algorithms even when flexible boxes are considered.

    The downside of this is that it requires some reinventing-of-the-wheel as Phosphor doesn't map 1:1 with this approach. If a subclass has a trivial setup (such as the Tab Panel), then this may just need to query the size of the node and set CSS maxWidth/maxHeight before calling this.content.fit().

    This function must call DashboardLayoutRegion#sizeContentToFit() on all visible children of this region.

    Returns void

Protected notifyLayout

  • notifyLayout(msg: Message): void
  • Invoke the message processing routine of the widget's layout.

    Parameters

    • msg: Message

      The message to dispatch to the layout.

      Notes

      This is a no-op if the widget does not have a layout.

      This will not typically be called directly by user code.

    Returns void

Protected onActivateRequest

  • onActivateRequest(): void

Protected onAfterAttach

  • onAfterAttach(): void

Protected onAfterBlur

  • onAfterBlur(msg: Message): void

Protected onAfterDetach

  • onAfterDetach(msg: Message): void
  • A message handler invoked on an 'after-detach' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onAfterFocus

  • onAfterFocus(msg: Message): void

Protected onAfterHide

  • onAfterHide(msg: Message): void
  • A message handler invoked on an 'after-hide' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onAfterShow

  • onAfterShow(msg: Message): void
  • A message handler invoked on an 'after-show' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onBeforeAttach

  • onBeforeAttach(msg: Message): void
  • A message handler invoked on a 'before-attach' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onBeforeBlur

  • onBeforeBlur(msg: Message): void

Protected onBeforeDetach

  • onBeforeDetach(): void

Protected onBeforeFocus

  • onBeforeFocus(msg: Message): void

Protected onBeforeHide

  • onBeforeHide(msg: Message): void
  • A message handler invoked on a 'before-hide' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onBeforeShow

  • onBeforeShow(msg: Message): void
  • A message handler invoked on a 'before-show' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onChildAdded

  • onChildAdded(msg: ChildMessage): void
  • A message handler invoked on a 'child-added' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: ChildMessage

    Returns void

Protected onChildRegionAdded

  • Handle that gets called when this region recieves a new child.

    remarks

    Subclassers can override this method to implement custom logic, such as adding UI chroming or CSS classes.

    The default implementation is a no-op.

    Parameters

    Returns void

Protected onChildRegionRemoved

  • Handle that gets called when a child is removed from this region.

    remarks

    Subclassers can override this method to implement custom logic, such as removing CSS classes or event handlers. Custom chroming elements added via Region Chroming will be removed automatically.

    This function is not called until after the oldChild has been moved, and will not be called if the old child is disposed. It will also not be called when this region is being disposed.

    The default implementation of this function is a no-op.

    Parameters

    Returns void

Protected onChildRemoved

  • onChildRemoved(msg: ChildMessage): void
  • A message handler invoked on a 'child-removed' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: ChildMessage

    Returns void

Protected onCloseRequest

  • onCloseRequest(): void

Protected onDragEnter

  • onDragEnter(ev: IDragEvent): void

Protected onDragLeave

  • onDragLeave(ev: IDragEvent): void

Protected onDragOver

  • onDragOver(ev: IDragEvent): void

Protected onDrop

  • onDrop(ev: IDragEvent): void

Protected onFitRequest

  • onFitRequest(msg: Message): void
  • A message handler invoked on a 'fit-request' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onResize

  • onResize(msg: ResizeMessage): void
  • A message handler invoked on a 'resize' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: ResizeMessage

    Returns void

Protected onUpdateRequest

  • onUpdateRequest(msg: Message): void
  • A message handler invoked on an 'update-request' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

processMessage

  • processMessage(msg: Message): void

pruneSubtree

  • pruneSubtree(): void
  • Clean up this subtree by removing auto-generated empty regions.

    Notes

    This is a framework function and not meant to be called by user code. The MavenWorks framework will automatically manage the health of the layout, pruning when useful.

    Whether a region is "prunable" or not is specified by the <a href="../interfaces/regionwithchildren.iprops.html#prunable">prunable</a> layout property. For regions created with SurroundWith, this property is true.

    see

    IRegionWithChildrenProps.prunable

    see

    DashboardActions.SurroundWith

    Returns void

removeClass

  • removeClass(name: string): void
  • Remove a class name from the widget's DOM node.

    Parameters

    • name: string

      The class name to remove from the node.

      Notes

      If the class name is not yet added to the node, this is a no-op.

      The class name must not contain whitespace.

    Returns void

setFlag

  • setFlag(flag: Flag): void
  • Set the given widget flag.

    Notes

    This will not typically be called directly by user code.

    Parameters

    • flag: Flag

    Returns void

setFresh

  • setFresh(): void

setHidden

  • setHidden(hidden: boolean): void
  • Show or hide the widget according to a boolean value.

    Parameters

    • hidden: boolean

      true to hide the widget, or false to show it.

      Notes

      This is a convenience method for hide() and show().

    Returns void

setLayoutProperty

  • setLayoutProperty<K>(propertyName: K, value: LayoutProps[K]): void

setStale

  • setStale(): void
  • Mark this region as having changes that need to be synced with something

    Notes

    Examples of this include layout properties, which need to be saved to a model, and added/removed children, which need the dashboard to issue update requests.

    Returns void

Private setupAddPartOverlay

  • setupAddPartOverlay(): void

show

  • show(): void
  • Show the widget and make it visible to its parent widget.

    Notes

    This causes the isHidden property to be false.

    If the widget is not explicitly hidden, this is a no-op.

    Returns void

showOverlay

  • showOverlay(): void

showRootOverlay

  • showRootOverlay(): void

sizeContentToFit

  • sizeContentToFit(bounds: object): void

startDrag

  • startDrag(clientX: number, clientY: number): void

subtree

testFlag

  • testFlag(flag: Flag): boolean
  • Test whether the given widget flag is set.

    Notes

    This will not typically be called directly by user code.

    Parameters

    • flag: Flag

    Returns boolean

toggleClass

  • toggleClass(name: string, force?: undefined | false | true): boolean
  • Toggle a class name on the widget's DOM node.

    Parameters

    • name: string

      The class name to toggle on the node.

    • Optional force: undefined | false | true

      Whether to force add the class (true) or force remove the class (false). If not provided, the presence of the class will be toggled from its current state.

    Returns boolean

    true if the class is now present, false otherwise.

    Notes

    The class name must not contain whitespace.

update

  • update(): void
  • Post an 'update-request' message to the widget.

    Notes

    This is a simple convenience method for posting the message.

    Returns void

updateFromProperties

  • updateFromProperties(): void

Private updateOverlay

  • updateOverlay(): void

Static GetMetadata

Generated using TypeDoc