MCPcopy
hub / github.com/mathuo/dockview / layout

Method layout

packages/dockview-core/src/splitview/splitview.ts:674–725  ·  view source on GitHub ↗
(size: number, orthogonalSize: number)

Source from the content-addressed store, hash-verified

672 }
673
674 public layout(size: number, orthogonalSize: number): void {
675 const previousSize = Math.max(this.size, this._contentSize);
676 this.size = size;
677 this.orthogonalSize = orthogonalSize;
678
679 if (!this.proportions) {
680 const indexes = range(this.viewItems.length);
681 const lowPriorityIndexes = indexes.filter(
682 (i) => this.viewItems[i].priority === LayoutPriority.Low
683 );
684 const highPriorityIndexes = indexes.filter(
685 (i) => this.viewItems[i].priority === LayoutPriority.High
686 );
687
688 this.resize(
689 this.viewItems.length - 1,
690 size - previousSize,
691 undefined,
692 lowPriorityIndexes,
693 highPriorityIndexes
694 );
695 } else {
696 let total = 0;
697
698 for (let i = 0; i < this.viewItems.length; i++) {
699 const item = this.viewItems[i];
700 const proportion = this.proportions[i];
701
702 if (typeof proportion === 'number') {
703 total += proportion;
704 } else {
705 size -= item.size;
706 }
707 }
708
709 for (let i = 0; i < this.viewItems.length; i++) {
710 const item = this.viewItems[i];
711 const proportion = this.proportions[i];
712
713 if (typeof proportion === 'number' && total > 0) {
714 item.size = clamp(
715 Math.round((proportion * size) / total),
716 item.minimumSize,
717 item.maximumSize
718 );
719 }
720 }
721 }
722
723 this.distributeEmptySpace();
724 this.layoutViews();
725 }
726
727 private relayout(
728 lowPriorityIndexes?: number[],

Callers

nothing calls this directly

Calls 5

distributeEmptySpaceMethod · 0.95
layoutViewsMethod · 0.95
rangeFunction · 0.90
clampFunction · 0.90
resizeMethod · 0.80

Tested by

no test coverage detected