DockPanel

Description

DockPanel lays out a document with panes docked to its four edges, as an IDE does. Panes on one edge stack with a splitter between them, and panes on one edge that share a tab group become tabs of one slot. Every seam can be dragged to resize.

A pane's header has a pin and a close button. The pin sends the pane to a rail on its edge, from where it slides out over the document when its rail tab is clicked; a closed pane is listed in the menu at the document's top right until it is reopened. Dragging a header or tab shows markers on the panel's borders (dock to that edge) and a compass over the pane under the pointer (join it as a tab, or go before or after it). Below CollapseBelow (600px by default) every pane goes to its rail.

GetLayout() writes the arrangement as JSON and LoadLayout() restores it; OnLayoutChanged reports every change with that JSON.

Usage

Create the panel with DockPanel(), set the document, and add panes made with DockPane(id, title, content). The id is what a saved layout refers to, so keep it stable. Give the panel a height: it fills the box it is given.

Pane toggles

A panel whose secondary panes start .Closed() can hide its restore menu with .RestoreMenu(false) and offer a toolbar of PaneToggle buttons instead, the way an IDE's View menu reaches its tool windows. Each button carries the pane's icon and title, toggles the pane with Toggle(id), and is marked pressed (aria-pressed, class tss-dockpanel-toggle-on) while the pane is in view, following every change made in the panel.

var dock = DockPanel().Document(editor).Panes(
    DockPane("settings", "Settings", settings).Left(),
    DockPane("output", "Output", output).Bottom().Closed())
   .RestoreMenu(false);

var toolbar = HStack().Children(
    dock.CurrentPanes.Select(p => (IComponent)dock.PaneToggle(p.Id).Compact().NoBackground()).ToArray());

Saving the layout

Store the JSON from OnLayoutChanged and pass it to LoadLayout when the page opens. LoadLayout ignores ids it does not know and edges a pane does not allow, clamps sizes to each pane's limits, and returns false without changing anything if the text cannot be read.

DockPane

| Method | Effect | | --- | --- | | Left(), Right(), Top(), Bottom(), DockTo(DockEdge) | the edge the pane is docked to (default left) | | InTabGroup(name) | panes on one edge with the same group share a slot as tabs | | SetSize(px), SizeLimits(min, max) | width on the sides, height on top and bottom (default 260, limits 120 and 720); an edge takes the size of its first pane | | SetWeight(w) | the pane's share of its edge when several are stacked | | Icon(UIcons), SetTitle(text), SetContent(component) | header and body | | Unpinned(), Closed() | starting state | | NotClosable(), NotPinnable(), NotMovable(), AllowEdges(...) | what the user may do |

DockPanel

| Member | Effect | | --- | --- | | Document(component), Panes(...), Add(pane), Remove(id), Pane(id), CurrentPanes | content | | EdgePriority(params DockEdge[]) | which edges own the corners (default Top, Bottom, Left, Right: top and bottom span the full width) | | Open(id), Close(id), Pin(id), Unpin(id), Activate(id), Move(id, edge), ShowFlyout(id) | commands | | Show(id), Toggle(id), IsShown(id) | bring a pane into view whatever its state (open it, select its tab, slide it out from its rail), toggle it, or ask whether it can be seen | | PaneToggle(id) | a Button for a toolbar outside the panel that shows and hides one pane, pressed while the pane is in view | | GetLayout(), LoadLayout(json) | persistence | | OnLayoutChanged(...), OnCloseRequested(Func<DockPane, bool>), OnFlyoutOpened(...) | events; return false from OnCloseRequested to keep a pane open | | CollapseBelow(px), IsNarrow, RestoreMenu(bool), Labels(...) | narrow mode, restore menu, translations |

The panel rebuilds its layout on every change by moving each pane's content element rather than recreating it, so the content keeps its state, and each pane body's scroll position is carried across. A pane that is not on screen (closed, or on its rail) keeps its content mounted in a hidden holder inside the panel, so subscriptions and editors tied to the content's lifetime keep running until the pane is shown again.

API reference

class

DockPanel

public sealed class DockPanel : ComponentBase<DockPanel, HTMLElement>, ISpecialCaseStyling

An IDE-style docking layout: one document in the middle and any number of DockPanes docked around it. Panes on the same edge stack, and share a slot as tabs when they name the same tab group; every seam is a splitter. A pane can be closed (and reopened from the restore menu), unpinned to a rail on its edge from where it slides out over the document, and dragged by its header onto another edge or into another pane's slot, with drop guides showing where it would land. The arrangement can be saved with GetLayout and put back with LoadLayout. The layout is rebuilt on every change, moving each pane's content element rather than recreating it, so the content keeps its state; the scroll position of each pane body is carried across.

Namespace
Tesserae
Inheritance
ComponentBase<DockPanel, HTMLElement> → DockPanel
Implements
ISpecialCaseStyling

Constructors

NameDescription
DockPanelInitializes a new instance of the DockPanel class.
Constructor
DockPanel
public DockPanel()

Initializes a new instance of the DockPanel class.

Properties

NameDescription
StylingContainerGets the element sizing helpers write to.
PropagateStylesToWrapperGets whether a sizing helper applied to this component should tag it so a wrapper-building container hoists the style onto the wrapper.
CurrentPanesThe panes, in layout order.
IsNarrowWhether the panel is below CollapseBelow and shows its pinned panes on the rails.
Property
DockPanel.StylingContainer
public HTMLElement StylingContainer

Gets the element sizing helpers write to.

Property
DockPanel.PropagateStylesToWrapper
public bool PropagateStylesToWrapper

Gets whether a sizing helper applied to this component should tag it so a wrapper-building container hoists the style onto the wrapper.

Property
DockPanel.CurrentPanes
public IReadOnlyList<DockPane> CurrentPanes

The panes, in layout order.

Property
DockPanel.IsNarrow
public bool IsNarrow

Whether the panel is below CollapseBelow and shows its pinned panes on the rails.

Methods

NameDescription
DocumentSets the document: the content in the middle that the panes are docked around.
PanesAdds panes.
AddAdds a pane. A pane whose id is already taken replaces the old one in place.
RemoveRemoves the pane with the given id.
PaneReturns the pane with the given id, or null.
EdgePriorityDecides which edges own the corners. The first edge is laid out outermost and spans the whole panel; each later one fits inside the earlier ones. Defaults to Top, Bottom, Left, Right: the top and bottom panes span the full width.
CollapseBelowBelow this width (in pixels) the panel shows every pinned pane on its rail instead of beside the document, without changing the pane; above it they dock again. Defaults to 600; 0 turns it off.
RestoreMenuShows or hides the menu of closed panes at the top right of the document. Shown by default.
LabelsReplaces the text the panel draws on its own, for translation.
OnLayoutChangedRaised after every change of the arrangement — a pane moved, resized, closed, reopened, pinned or unpinned, a tab selected — with the layout as GetLayout writes it, ready to be saved.
OnCloseRequestedRaised when the user asks to close a pane. Return false to keep it open.
OnFlyoutOpenedRaised when an unpinned pane slides out from its rail.
OpenOpens a closed pane where it was, and selects it if it is a tab.
CloseCloses a pane. The restore menu lists it until it is opened again.
PinDocks an unpinned pane beside the document again.
UnpinUnpins a pane to its edge's rail; it slides out over the document when its tab is clicked.
ActivateSelects a pane's tab in its group.
ShowBrings a pane into view, whatever its state: opens it if it is closed, selects its tab, and slides it out if it is on a rail (unpinned, or every pane is because the panel is narrow).
ToggleHides a pane that is in view and shows one that is not: a docked pane is closed (and listed in the restore menu), a pane slid out from its rail slides back. What a PaneToggle button does.
IsShownWhether a pane can be seen right now: open, its tab selected if it shares a slot, and slid out if it lives on a rail.
PaneToggleA button that shows and hides one pane (Toggle), for a toolbar outside the panel, the way an IDE's View menu reaches its tool windows. It carries the pane's icon and title, is marked pressed (aria-pressed and the tss-dockpanel-toggle-on class) while the pane is in view, and follows every change made in the panel. A panel whose panes start closed can hide its own restore menu (RestoreMenu) and offer these instead.
MoveMoves a pane to another edge, on its own (out of any tab group).
ShowFlyoutSlides an unpinned (or collapsed) pane out over the document.
GetLayoutWrites the arrangement — every pane's edge, size, share, tab group, pin and open state, and order — as JSON.
LoadLayoutRestores an arrangement written by GetLayout. Panes it does not mention keep their place after the ones it does, ids it mentions that are not panes are ignored, an edge the pane does not allow is ignored and sizes are clamped to the pane's limits. Returns false, changing nothing, if the text cannot be read.
RenderRenders the component's root HTML element.
Method
DockPanel.Document
public DockPanel Document(IComponent document)

Sets the document: the content in the middle that the panes are docked around.

Method
DockPanel.Panes
public DockPanel Panes(params DockPane[] panes)

Adds panes.

Method
DockPanel.Add
public DockPanel Add(DockPane pane)

Adds a pane. A pane whose id is already taken replaces the old one in place.

Method
DockPanel.Remove
public DockPanel Remove(string id)

Removes the pane with the given id.

Method
DockPanel.Pane
public DockPane Pane(string id)

Returns the pane with the given id, or null.

Method
DockPanel.EdgePriority
public DockPanel EdgePriority(params DockEdge[] edges)

Decides which edges own the corners. The first edge is laid out outermost and spans the whole panel; each later one fits inside the earlier ones. Defaults to Top, Bottom, Left, Right: the top and bottom panes span the full width.

Method
DockPanel.CollapseBelow
public DockPanel CollapseBelow(double pixels)

Below this width (in pixels) the panel shows every pinned pane on its rail instead of beside the document, without changing the pane; above it they dock again. Defaults to 600; 0 turns it off.

Method
DockPanel.RestoreMenu
public DockPanel RestoreMenu(bool show = true)

Shows or hides the menu of closed panes at the top right of the document. Shown by default.

Method
DockPanel.Labels
public DockPanel Labels(DockPanelLabels labels)

Replaces the text the panel draws on its own, for translation.

Method
DockPanel.OnLayoutChanged
public DockPanel OnLayoutChanged(Action<string> onLayoutChanged)

Raised after every change of the arrangement — a pane moved, resized, closed, reopened, pinned or unpinned, a tab selected — with the layout as GetLayout writes it, ready to be saved.

Method
DockPanel.OnCloseRequested
public DockPanel OnCloseRequested(Func<DockPane, bool> onCloseRequested)

Raised when the user asks to close a pane. Return false to keep it open.

Method
DockPanel.OnFlyoutOpened
public DockPanel OnFlyoutOpened(Action<DockPane> onFlyoutOpened)

Raised when an unpinned pane slides out from its rail.

Method
DockPanel.Open
public DockPanel Open(string id)

Opens a closed pane where it was, and selects it if it is a tab.

Method
DockPanel.Close
public DockPanel Close(string id)

Closes a pane. The restore menu lists it until it is opened again.

Method
DockPanel.Pin
public DockPanel Pin(string id)

Docks an unpinned pane beside the document again.

Method
DockPanel.Unpin
public DockPanel Unpin(string id)

Unpins a pane to its edge's rail; it slides out over the document when its tab is clicked.

Method
DockPanel.Activate
public DockPanel Activate(string id)

Selects a pane's tab in its group.

Method
DockPanel.Show
public DockPanel Show(string id)

Brings a pane into view, whatever its state: opens it if it is closed, selects its tab, and slides it out if it is on a rail (unpinned, or every pane is because the panel is narrow).

Method
DockPanel.Toggle
public DockPanel Toggle(string id)

Hides a pane that is in view and shows one that is not: a docked pane is closed (and listed in the restore menu), a pane slid out from its rail slides back. What a PaneToggle button does.

Method
DockPanel.IsShown
public bool IsShown(string id)

Whether a pane can be seen right now: open, its tab selected if it shares a slot, and slid out if it lives on a rail.

Method
DockPanel.PaneToggle
public Button PaneToggle(string id)

A button that shows and hides one pane (Toggle), for a toolbar outside the panel, the way an IDE's View menu reaches its tool windows. It carries the pane's icon and title, is marked pressed (aria-pressed and the tss-dockpanel-toggle-on class) while the pane is in view, and follows every change made in the panel. A panel whose panes start closed can hide its own restore menu (RestoreMenu) and offer these instead.

Method
DockPanel.Move
public DockPanel Move(string id, DockEdge edge)

Moves a pane to another edge, on its own (out of any tab group).

Method
DockPanel.ShowFlyout
public DockPanel ShowFlyout(string id)

Slides an unpinned (or collapsed) pane out over the document.

Method
DockPanel.GetLayout
public string GetLayout()

Writes the arrangement — every pane's edge, size, share, tab group, pin and open state, and order — as JSON.

Method
DockPanel.LoadLayout
public bool LoadLayout(string layout)

Restores an arrangement written by GetLayout. Panes it does not mention keep their place after the ones it does, ids it mentions that are not panes are ignored, an edge the pane does not allow is ignored and sizes are clamped to the pane's limits. Returns false, changing nothing, if the text cannot be read.

Method
DockPanel.Render
public override HTMLElement Render()

Renders the component's root HTML element.

enum

DockEdge

public enum DockEdge

The side of a DockPanel's document a DockPane is docked to.

Namespace
Tesserae

Values

NameDescription
LeftDocked to the left of the document; its size is a width.
RightDocked to the right of the document; its size is a width.
TopDocked above the document; its size is a height.
BottomDocked below the document; its size is a height.
Value
DockEdge.Left
Left

Docked to the left of the document; its size is a width.

Value
DockEdge.Right
Right

Docked to the right of the document; its size is a width.

Value
DockEdge.Top
Top

Docked above the document; its size is a height.

Value
DockEdge.Bottom
Bottom

Docked below the document; its size is a height.

class

DockPane

public sealed class DockPane

One pane of a DockPanel: a titled piece of content docked to an edge of the document, alone or as a tab of a group. The pane describes where it is (Edge, TabGroup, Size) and what the user may do with it; the panel reads it on every rebuild, and writes the user's changes back to it.

Namespace
Tesserae

Constructors

NameDescription
DockPaneInitializes a new instance of the DockPane class.
Constructor
DockPane
public DockPane(string id, string title, IComponent content)

Initializes a new instance of the DockPane class.

Parameters

id
A stable identity, used by the layout GetLayout saves. Do not derive it from position.
title
The header, tab and rail text.
content
The pane's body.

Properties

NameDescription
IdThe pane's stable identity.
TitleThe header, tab and rail text.
PaneIconAn icon drawn before the title, or null.
ContentThe pane's body.
EdgeThe edge the pane is docked to. Defaults to Left.
TabGroupPanes on the same edge with the same group name share one slot as tabs. Null for a pane of its own.
SizeThe pane's width on the left and right edges, its height on the top and bottom ones, in pixels. The edge takes the size of the first pane on it; dragging the edge's splitter writes the new size to all of them.
MinSizeThe smallest the user can drag the pane to.
MaxSizeThe largest the user can drag the pane to.
WeightThe pane's share of its edge when several panes are stacked there. Defaults to 1.
IsOpenWhether the pane is shown at all.
IsPinnedWhether the pane takes space beside the document; an unpinned pane sits on its edge's rail and slides out over the document.
CanCloseWhether the header offers a close button.
CanPinWhether the header offers the auto-hide pin.
CanMoveWhether the pane can be dragged by its header to another edge or into a tab group.
AllowedEdgesThe edges the user may drag the pane to.
Property
DockPane.Id
public string Id { get; }

The pane's stable identity.

Property
DockPane.Title
public string Title { get; private set; }

The header, tab and rail text.

Property
DockPane.PaneIcon
public UIcons? PaneIcon { get; private set; }

An icon drawn before the title, or null.

Property
DockPane.Content
public IComponent Content { get; private set; }

The pane's body.

Property
DockPane.Edge
public DockEdge Edge { get; internal set; }

The edge the pane is docked to. Defaults to Left.

Property
DockPane.TabGroup
public string TabGroup { get; internal set; }

Panes on the same edge with the same group name share one slot as tabs. Null for a pane of its own.

Property
DockPane.Size
public double Size { get; internal set; }

The pane's width on the left and right edges, its height on the top and bottom ones, in pixels. The edge takes the size of the first pane on it; dragging the edge's splitter writes the new size to all of them.

Property
DockPane.MinSize
public double MinSize { get; private set; }

The smallest the user can drag the pane to.

Property
DockPane.MaxSize
public double MaxSize { get; private set; }

The largest the user can drag the pane to.

Property
DockPane.Weight
public double Weight { get; internal set; }

The pane's share of its edge when several panes are stacked there. Defaults to 1.

Property
DockPane.IsOpen
public bool IsOpen { get; internal set; }

Whether the pane is shown at all.

Property
DockPane.IsPinned
public bool IsPinned { get; internal set; }

Whether the pane takes space beside the document; an unpinned pane sits on its edge's rail and slides out over the document.

Property
DockPane.CanClose
public bool CanClose { get; private set; }

Whether the header offers a close button.

Property
DockPane.CanPin
public bool CanPin { get; private set; }

Whether the header offers the auto-hide pin.

Property
DockPane.CanMove
public bool CanMove { get; private set; }

Whether the pane can be dragged by its header to another edge or into a tab group.

Property
DockPane.AllowedEdges
public IReadOnlyList<DockEdge> AllowedEdges { get; private set; }

The edges the user may drag the pane to.

Methods

NameDescription
LeftDocks the pane to the left of the document.
RightDocks the pane to the right of the document.
TopDocks the pane above the document.
BottomDocks the pane below the document.
DockToDocks the pane to edge.
InTabGroupMakes the pane a tab of group: panes on the same edge with the same name share one slot.
SetSizeSets the pane's size, in pixels (a width on the left and right edges, a height on the others). Defaults to 260.
SizeLimitsSets how small and how large the user can drag the pane. Defaults to 120 and 720.
SetWeightSets the pane's share of its edge when several panes are stacked there. Defaults to 1.
IconSets the icon drawn before the title.
UnpinnedStarts the pane unpinned: on its edge's rail, sliding out over the document when its tab is clicked.
ClosedStarts the pane closed. The panel's restore menu, or Open, brings it back.
NotClosableRemoves the close button.
NotPinnableRemoves the auto-hide pin.
NotMovableStops the pane from being dragged to another place.
AllowEdgesLimits the edges the user may drag the pane to. A pane always may stay where it is.
SetTitleReplaces the pane's title.
SetContentReplaces the pane's body.
Method
DockPane.Left
public DockPane Left()

Docks the pane to the left of the document.

Method
DockPane.Right
public DockPane Right()

Docks the pane to the right of the document.

Method
DockPane.Top
public DockPane Top()

Docks the pane above the document.

Method
DockPane.Bottom
public DockPane Bottom()

Docks the pane below the document.

Method
DockPane.DockTo
public DockPane DockTo(DockEdge edge)

Docks the pane to edge.

Method
DockPane.InTabGroup
public DockPane InTabGroup(string group)

Makes the pane a tab of group: panes on the same edge with the same name share one slot.

Method
DockPane.SetSize
public DockPane SetSize(double pixels)

Sets the pane's size, in pixels (a width on the left and right edges, a height on the others). Defaults to 260.

Method
DockPane.SizeLimits
public DockPane SizeLimits(double min, double max)

Sets how small and how large the user can drag the pane. Defaults to 120 and 720.

Method
DockPane.SetWeight
public DockPane SetWeight(double weight)

Sets the pane's share of its edge when several panes are stacked there. Defaults to 1.

Method
DockPane.Icon
public DockPane Icon(UIcons icon)

Sets the icon drawn before the title.

Method
DockPane.Unpinned
public DockPane Unpinned(bool value = true)

Starts the pane unpinned: on its edge's rail, sliding out over the document when its tab is clicked.

Method
DockPane.Closed
public DockPane Closed(bool value = true)

Starts the pane closed. The panel's restore menu, or Open, brings it back.

Method
DockPane.NotClosable
public DockPane NotClosable()

Removes the close button.

Method
DockPane.NotPinnable
public DockPane NotPinnable()

Removes the auto-hide pin.

Method
DockPane.NotMovable
public DockPane NotMovable()

Stops the pane from being dragged to another place.

Method
DockPane.AllowEdges
public DockPane AllowEdges(params DockEdge[] edges)

Limits the edges the user may drag the pane to. A pane always may stay where it is.

Method
DockPane.SetTitle
public DockPane SetTitle(string title)

Replaces the pane's title.

Method
DockPane.SetContent
public DockPane SetContent(IComponent content)

Replaces the pane's body.

class

DockPanelLabels

public sealed class DockPanelLabels

The text a DockPanel draws on its own, so an application can hand in its translations.

Namespace
Tesserae

Properties

NameDescription
AutoHideThe name of the pin on a docked pane, which slides it to the rail.
PinThe name of the pin on a pane slid out from the rail, which docks it again.
CloseThe name of a pane's close button.
ClosedPanesThe name of the button that lists the closed panes.
ReopenThe header of the restore menu.
Property
DockPanelLabels.AutoHide
public string AutoHide { get; set; }

The name of the pin on a docked pane, which slides it to the rail.

Property
DockPanelLabels.Pin
public string Pin { get; set; }

The name of the pin on a pane slid out from the rail, which docks it again.

Property
DockPanelLabels.Close
public string Close { get; set; }

The name of a pane's close button.

Property
DockPanelLabels.ClosedPanes
public string ClosedPanes { get; set; }

The name of the button that lists the closed panes.

Property
DockPanelLabels.Reopen
public string Reopen { get; set; }

The header of the restore menu.

class

DockPaneState

internal sealed class DockPaneState

The layout of one pane, as GetLayout writes it.

Namespace
Tesserae
class

DockLayoutState

internal sealed class DockLayoutState

A whole DockPanel layout, as GetLayout writes it.

Namespace
Tesserae

See also