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
public sealed class DockPanel : ComponentBase<DockPanel, HTMLElement>, ISpecialCaseStylingAn 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
| Name | Description |
|---|---|
| DockPanel | Initializes a new instance of the DockPanel class. |
Properties
| Name | Description |
|---|---|
| StylingContainer | Gets the element sizing helpers write to. |
| PropagateStylesToWrapper | Gets whether a sizing helper applied to this component should tag it so a wrapper-building container hoists the style onto the wrapper. |
| CurrentPanes | The panes, in layout order. |
| IsNarrow | Whether the panel is below CollapseBelow and shows its pinned panes on the rails. |
public HTMLElement StylingContainerGets the element sizing helpers write to.
public bool PropagateStylesToWrapperGets whether a sizing helper applied to this component should tag it so a wrapper-building container hoists the style onto the wrapper.
public IReadOnlyList<DockPane> CurrentPanesThe panes, in layout order.
Methods
| Name | Description |
|---|---|
| Document | Sets the document: the content in the middle that the panes are docked around. |
| Panes | Adds panes. |
| Add | Adds a pane. A pane whose id is already taken replaces the old one in place. |
| Remove | Removes the pane with the given id. |
| Pane | Returns the pane with the given id, or null. |
| EdgePriority | 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. |
| CollapseBelow | 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. |
| RestoreMenu | Shows or hides the menu of closed panes at the top right of the document. Shown by default. |
| Labels | Replaces the text the panel draws on its own, for translation. |
| 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. |
| OnCloseRequested | Raised when the user asks to close a pane. Return false to keep it open. |
| OnFlyoutOpened | Raised when an unpinned pane slides out from its rail. |
| Open | Opens a closed pane where it was, and selects it if it is a tab. |
| Close | Closes a pane. The restore menu lists it until it is opened again. |
| Pin | Docks an unpinned pane beside the document again. |
| Unpin | Unpins a pane to its edge's rail; it slides out over the document when its tab is clicked. |
| Activate | Selects a pane's tab in its group. |
| Show | 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). |
| Toggle | 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. |
| IsShown | 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. |
| PaneToggle | 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. |
| Move | Moves a pane to another edge, on its own (out of any tab group). |
| ShowFlyout | Slides an unpinned (or collapsed) pane out over the document. |
| GetLayout | Writes the arrangement — every pane's edge, size, share, tab group, pin and open state, and order — as JSON. |
| LoadLayout | 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. |
| Render | Renders the component's root HTML element. |
public DockPanel Document(IComponent document)Sets the document: the content in the middle that the panes are docked around.
public DockPanel Add(DockPane pane)Adds a pane. A pane whose id is already taken replaces the old one in place.
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.
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.
public DockPanel RestoreMenu(bool show = true)Shows or hides the menu of closed panes at the top right of the document. Shown by default.
public DockPanel Labels(DockPanelLabels labels)Replaces the text the panel draws on its own, for translation.
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.
public DockPanel OnCloseRequested(Func<DockPane, bool> onCloseRequested)Raised when the user asks to close a pane. Return false to keep it open.
public DockPanel OnFlyoutOpened(Action<DockPane> onFlyoutOpened)Raised when an unpinned pane slides out from its rail.
public DockPanel Open(string id)Opens a closed pane where it was, and selects it if it is a tab.
public DockPanel Close(string id)Closes a pane. The restore menu lists it until it is opened again.
public DockPanel Unpin(string id)Unpins a pane to its edge's rail; it slides out over the document when its tab is clicked.
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).
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.
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.
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.
public DockPanel Move(string id, DockEdge edge)Moves a pane to another edge, on its own (out of any tab group).
public DockPanel ShowFlyout(string id)Slides an unpinned (or collapsed) pane out over the document.
public string GetLayout()Writes the arrangement — every pane's edge, size, share, tab group, pin and open state, and order — as JSON.
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.
public enum DockEdgeThe side of a DockPanel's document a DockPane is docked to.
- Namespace
- Tesserae
public sealed class DockPaneOne 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
| Name | Description |
|---|---|
| DockPane | Initializes a new instance of the DockPane class. |
Properties
| Name | Description |
|---|---|
| Id | The pane's stable identity. |
| Title | The header, tab and rail text. |
| PaneIcon | An icon drawn before the title, or null. |
| Content | The pane's body. |
| Edge | The edge the pane is docked to. Defaults to Left. |
| TabGroup | Panes on the same edge with the same group name share one slot as tabs. Null for a pane of its own. |
| Size | 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. |
| MinSize | The smallest the user can drag the pane to. |
| MaxSize | The largest the user can drag the pane to. |
| Weight | The pane's share of its edge when several panes are stacked there. Defaults to 1. |
| IsOpen | Whether the pane is shown at all. |
| IsPinned | Whether the pane takes space beside the document; an unpinned pane sits on its edge's rail and slides out over the document. |
| CanClose | Whether the header offers a close button. |
| CanPin | Whether the header offers the auto-hide pin. |
| CanMove | Whether the pane can be dragged by its header to another edge or into a tab group. |
| AllowedEdges | The edges the user may drag the pane to. |
public UIcons? PaneIcon { get; private set; }An icon drawn before the title, or null.
public DockEdge Edge { get; internal set; }The edge the pane is docked to. Defaults to Left.
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.
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.
public double MinSize { get; private set; }The smallest the user can drag the pane to.
public double MaxSize { get; private set; }The largest the user can drag the pane to.
public double Weight { get; internal set; }The pane's share of its edge when several panes are stacked there. Defaults to 1.
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.
public bool CanClose { get; private set; }Whether the header offers a close button.
public bool CanPin { get; private set; }Whether the header offers the auto-hide pin.
public bool CanMove { get; private set; }Whether the pane can be dragged by its header to another edge or into a tab group.
Methods
| Name | Description |
|---|---|
| Left | Docks the pane to the left of the document. |
| Right | Docks the pane to the right of the document. |
| Top | Docks the pane above the document. |
| Bottom | Docks the pane below the document. |
| DockTo | Docks the pane to edge. |
| InTabGroup | Makes the pane a tab of group: panes on the same edge with the same name share one slot. |
| SetSize | Sets the pane's size, in pixels (a width on the left and right edges, a height on the others). Defaults to 260. |
| SizeLimits | Sets how small and how large the user can drag the pane. Defaults to 120 and 720. |
| SetWeight | Sets the pane's share of its edge when several panes are stacked there. Defaults to 1. |
| Icon | Sets the icon drawn before the title. |
| Unpinned | Starts the pane unpinned: on its edge's rail, sliding out over the document when its tab is clicked. |
| Closed | Starts the pane closed. The panel's restore menu, or Open, brings it back. |
| NotClosable | Removes the close button. |
| NotPinnable | Removes the auto-hide pin. |
| NotMovable | Stops the pane from being dragged to another place. |
| AllowEdges | Limits the edges the user may drag the pane to. A pane always may stay where it is. |
| SetTitle | Replaces the pane's title. |
| SetContent | Replaces the pane's body. |
public DockPane InTabGroup(string group)Makes the pane a tab of group: panes on the same edge with the same name share one slot.
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.
public DockPane SizeLimits(double min, double max)Sets how small and how large the user can drag the pane. Defaults to 120 and 720.
public DockPane SetWeight(double weight)Sets the pane's share of its edge when several panes are stacked there. Defaults to 1.
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.
public DockPane Closed(bool value = true)Starts the pane closed. The panel's restore menu, or Open, brings it back.
public DockPane NotMovable()Stops the pane from being dragged to another place.
public DockPane AllowEdges(params DockEdge[] edges)Limits the edges the user may drag the pane to. A pane always may stay where it is.
public sealed class DockPanelLabelsThe text a DockPanel draws on its own, so an application can hand in its translations.
- Namespace
- Tesserae
Properties
| Name | Description |
|---|---|
| AutoHide | The name of the pin on a docked pane, which slides it to the rail. |
| Pin | The name of the pin on a pane slid out from the rail, which docks it again. |
| Close | The name of a pane's close button. |
| ClosedPanes | The name of the button that lists the closed panes. |
| Reopen | The header of the restore menu. |
public string AutoHide { get; set; }The name of the pin on a docked pane, which slides it to the rail.
public string Pin { get; set; }The name of the pin on a pane slid out from the rail, which docks it again.
public string ClosedPanes { get; set; }The name of the button that lists the closed panes.
internal sealed class DockPaneStateThe layout of one pane, as GetLayout writes it.
- Namespace
- Tesserae
internal sealed class DockLayoutStateA whole DockPanel layout, as GetLayout writes it.
- Namespace
- Tesserae