Dart Documentationdock_spawnDockManager

DockManager Class

Dock manager manages all the dock panels in a hierarchy, similar to visual studio. It owns a Html Div element inside which all panels are docked Initially the document manager takes up the central space and acts as the root node

Implements

DialogEventListener

Constructors

Code new DockManager(DivElement element) #

DockManager(this.element) {
  mouseMoveHandler = onMouseMoved;
}

Methods

Code DockNode dockDialogDown(DockNode referenceNode, Dialog dialog) #

Dock the dialog below the referenceNode node

DockNode dockDialogDown(DockNode referenceNode, Dialog dialog) {
  return _requestDockDialog(referenceNode, dialog, layoutEngine.dockDown);
}

Code DockNode dockDialogFill(DockNode referenceNode, Dialog dialog) #

Dock the dialog as a tab inside the referenceNode node

DockNode dockDialogFill(DockNode referenceNode, Dialog dialog) {
  return _requestDockDialog(referenceNode, dialog, layoutEngine.dockFill);
}

Code DockNode dockDialogLeft(DockNode referenceNode, Dialog dialog) #

Dock the dialog to the left of the referenceNode node

DockNode dockDialogLeft(DockNode referenceNode, Dialog dialog) {
  return _requestDockDialog(referenceNode, dialog, layoutEngine.dockLeft);
}

Code DockNode dockDialogRight(DockNode referenceNode, Dialog dialog) #

Dock the dialog to the right of the referenceNode node

DockNode dockDialogRight(DockNode referenceNode, Dialog dialog) {
  return _requestDockDialog(referenceNode, dialog, layoutEngine.dockRight);
}

Code DockNode dockDialogUp(DockNode referenceNode, Dialog dialog) #

Dock the dialog above the referenceNode node

DockNode dockDialogUp(DockNode referenceNode, Dialog dialog) {
  return _requestDockDialog(referenceNode, dialog, layoutEngine.dockUp);
}

Code DockNode dockDown(DockNode referenceNode, IDockContainer container, [num ratio]) #

Dock the container below the referenceNode node

DockNode dockDown(DockNode referenceNode, IDockContainer container, [num ratio]) {
  return _requestDockContainer(referenceNode, container, layoutEngine.dockDown, ratio);
}

Code DockNode dockFill(DockNode referenceNode, IDockContainer container) #

Dock the container as a tab inside the referenceNode node

DockNode dockFill(DockNode referenceNode, IDockContainer container) {
  return _requestDockContainer(referenceNode, container, layoutEngine.dockFill, null);
}

Code DockNode dockLeft(DockNode referenceNode, IDockContainer container, [num ratio]) #

Dock the container to the left of the referenceNode node

DockNode dockLeft(DockNode referenceNode, IDockContainer container, [num ratio]) {
  return _requestDockContainer(referenceNode, container, layoutEngine.dockLeft, ratio);
}

Code DockNode dockRight(DockNode referenceNode, IDockContainer container, [num ratio]) #

Dock the container to the right of the referenceNode node

DockNode dockRight(DockNode referenceNode, IDockContainer container, [num ratio]) {
  return _requestDockContainer(referenceNode, container, layoutEngine.dockRight, ratio);
}

Code DockNode dockUp(DockNode referenceNode, IDockContainer container, [num ratio]) #

Dock the container above the referenceNode node

DockNode dockUp(DockNode referenceNode, IDockContainer container, [num ratio]) {
  return _requestDockContainer(referenceNode, container, layoutEngine.dockUp, ratio);
}

Code void initialize() #

void initialize() {
  context = new DockManagerContext(this);
  DockNode documentNode = new DockNode(context.documentManagerView);
  context.model.rootNode = documentNode;
  context.model.documentManagerNode = documentNode;
  setRootNode(context.model.rootNode);
  // Resize the layout
  resize(element.$dom_clientWidth, element.$dom_clientHeight);
  dockWheel = new DockWheel(this);
  layoutEngine = new DockLayoutEngine(this);
  
  rebuildLayout(context.model.rootNode);
}

Code void invalidate() #

void invalidate() {
  resize(element.$dom_clientWidth, element.$dom_clientHeight);
}

Code void loadState(String json) #

void loadState(String json) {
  var deserializer = new DockGraphDeserializer(this);
  context.model = deserializer.deserialize(json);
  setModel(context.model);
}

Code void onDialogDragEnded(Dialog sender, MouseEvent e) #

void onDialogDragEnded(Dialog sender, MouseEvent e) {
  window.on.mouseMove.remove(mouseMoveHandler);
  dockWheel.onDialogDropped(sender);
  dockWheel.hideWheel();
  dockWheel.activeDialog = null;
}

Code void onDialogDragStarted(Dialog sender, MouseEvent e) #

void onDialogDragStarted(Dialog sender, MouseEvent e) {
  dockWheel.activeNode = _findNodeOnPoint(e.pageX, e.pageY);
  dockWheel.activeDialog = sender;
  dockWheel.showWheel();
  window.on.mouseMove.add(mouseMoveHandler);
}

Code void onMouseMoved(MouseEvent e) #

void onMouseMoved(MouseEvent e) {
  dockWheel.activeNode = _findNodeOnPoint(e.pageX, e.pageY);
}

Code void rebuildLayout(DockNode node) #

void rebuildLayout(DockNode node) {
  node.children.forEach((child) => rebuildLayout(child));
  node.performLayout();
}

Code DockNode requestRemove(IDockContainer container) #

Removes a dock container from the dock layout hierarcy Returns the node that was removed from the dock tree

DockNode requestRemove(IDockContainer container) {
  DockNode node = _findNodeFromContainer(container);
  DockNode parent = node.parent;
  node.detachFromParent();
  if (parent != null) {
    rebuildLayout(parent);
  }
  return node;
}

Code void requestUndock(IDockContainer container) #

Undocks a panel and converts it into a floating dialog window It is assumed that only leaf nodes (panels) can be undocked

void requestUndock(IDockContainer container) {
  DockNode node = _findNodeFromContainer(container);
  layoutEngine.undock(node);
}

Code Dialog requestUndockToDialog(IDockContainer container, MouseEvent event, Point2 dragOffset) #

Undocks a panel and converts it into a floating dialog window It is assumed that only leaf nodes (panels) can be undocked

Dialog requestUndockToDialog(IDockContainer container, MouseEvent event, Point2 dragOffset) {
  DockNode node = _findNodeFromContainer(container);
  layoutEngine.undock(node);

  // Create a new dialog window for the undocked panel
  var dialog = new Dialog(node.container, this);

  // Adjust the relative position
  num dialogWidth = dialog.elementDialog.$dom_clientWidth;
  if (dragOffset.x > dialogWidth) {
    dragOffset.x = 0.75 * dialogWidth;
  }
  dialog.setPosition(
      event.pageX - dragOffset.x, 
      event.pageY - dragOffset.y);
  dialog.draggable.onMouseDown(event);

  return dialog;
}

Code void resize(int width, int height) #

void resize(int width, int height) {
  element.style.width = "${width}px";
  element.style.height = "${height}px";
  context.model.rootNode.container.resize(width, height);
}

Code String saveState() #

String saveState() {
  var serializer = new DockGraphSerializer();
  return serializer.serialize(context.model);
}

Code void setModel(DockModel model) #

Reset the dock model . This happens when the state is loaded from json

void setModel(DockModel model) {
  context.documentManagerView.containerElement.remove();
  context.model = model;
  setRootNode(model.rootNode);
  
  rebuildLayout(model.rootNode);
  invalidate();
}

Code void setRootNode(DockNode node) #

void setRootNode(DockNode node) {
  if (context.model.rootNode != null) {
    // detach it from the dock manager's base element
//      context.model.rootNode.detachFromParent();
  }

  // Attach the new node to the dock manager's base element and set as root node
  node.detachFromParent();
  context.model.rootNode = node;
  element.nodes.add(node.container.containerElement);
}

Fields

Code DockManagerContext context #

DockManagerContext context;

Code DockWheel dockWheel #

DockWheel dockWheel;

Code DivElement element #

DivElement element;

Code DockLayoutEngine layoutEngine #

DockLayoutEngine layoutEngine;

Code var mouseMoveHandler #

var mouseMoveHandler;