Configuration

Binary Window organizes panes using a binary tree structure—hence the name Binary Window.

Concept

Internally, Binary Window uses a binary tree to organize its panes. Each node in this tree is called a sash (a container of panes).

Sash IDs are used to identify panes and muntins. Some APIs require a Sash ID to target a specific pane or muntin.

Config Node

Each config node corresponds a sash.

No Children

Consider following example:

{
  "position": "left",
  "size": 200,
  "content": "Pane content"
}

Because this node does not have children, it renders a pane.

With Children

By design, each node can have at most two children. Consider following example:

{
  "position": "left",
  "size": 200,
  "children": [
    {
      "position": "top",
      "size": 0.4,
      "content": "Top pane content"
    },
    {
      "position": "bottom",
      "size": "60%",
      "content": "Bottom pane content"
    }
  ]
}

Since this node has children, it renders a muntin (a draggable divider between panes).

It is also possible to omit one child node. If omitted, Binary Window infers the missing child's position and size. For instance:

{
  "position": "left",
  "size": 200,
  "children": [
    {
      "position": "top",
      "size": 0.4,
      "content": "Top pane content"
    }
  ]
}

Here, because we specified a top pane as the only one child, the system automatically infers a bottom pane to fill the remaining space.

Root Config Node

The root config node represents the window itself. It carries the same properties as a config node, plus a few additional ones. For example:

{
  "width": 400,
  "height": 300,
  "content": "Single pane content"
}

In many cases, you may want the window to automatically fit its container. Set fitContainer to true to achieve this:

{
  "fitContainer": true,
  "children": ...
}

With fitContainer set, the window will resize to match its parent container.

Putting it All Together

Because of Binary Window's inference features, many properties can be omitted. Below is an example of a multi-pane layout:

{
  "width": 400,
  "height": 300,
  "children": [
    { "position": "left", "size": 200, "content": "Left pane content" },
    {
      "children": [
        { "position": "top", "size": 0.4, "content": "Top right pane content" },
        { "content": "Bottom right pane content" }
      ]
    }
  ]
}

In React, the code below is equivalent, using the Window component's panes prop (instead of children, to avoid conflicts with React's children):

<Window
  width={400}
  height={300}
  panes={[
    {
      position: 'left',
      size: 200,
      content: 'Left pane content',
    },
    {
      children: [
        {
          position: 'top',
          size: '40%',
          content: 'Top right pane content',
        },
        {
          content: 'Bottom right pane content',
        },
      ],
    },
  ]}
/>