@@ -21,13 +21,20 @@ export interface IViewSize {
2121 readonly height : number ;
2222}
2323
24- interface IBoundarySashes {
24+ interface IRelativeBoundarySashes {
2525 readonly start ?: Sash ;
2626 readonly end ?: Sash ;
2727 readonly orthogonalStart ?: Sash ;
2828 readonly orthogonalEnd ?: Sash ;
2929}
3030
31+ export interface IBoundarySashes {
32+ readonly top ?: Sash ;
33+ readonly right ?: Sash ;
34+ readonly bottom ?: Sash ;
35+ readonly left ?: Sash ;
36+ }
37+
3138export interface IView {
3239 readonly element : HTMLElement ;
3340 readonly minimumWidth : number ;
@@ -39,6 +46,7 @@ export interface IView {
3946 readonly snap ?: boolean ;
4047 layout ( width : number , height : number , top : number , left : number ) : void ;
4148 setVisible ?( visible : boolean ) : void ;
49+ setBoundarySashes ?( sashes : IBoundarySashes ) : void ;
4250}
4351
4452export interface ISerializableView extends IView {
@@ -132,6 +140,22 @@ interface ILayoutContext {
132140 readonly absoluteOrthogonalSize : number ;
133141}
134142
143+ function toAbsoluteBoundarySashes ( sashes : IRelativeBoundarySashes , orientation : Orientation ) : IBoundarySashes {
144+ if ( orientation === Orientation . HORIZONTAL ) {
145+ return { left : sashes . start , right : sashes . end , top : sashes . orthogonalStart , bottom : sashes . orthogonalEnd } ;
146+ } else {
147+ return { top : sashes . start , bottom : sashes . end , left : sashes . orthogonalStart , right : sashes . orthogonalEnd } ;
148+ }
149+ }
150+
151+ function fromAbsoluteBoundarySashes ( sashes : IBoundarySashes , orientation : Orientation ) : IRelativeBoundarySashes {
152+ if ( orientation === Orientation . HORIZONTAL ) {
153+ return { start : sashes . left , end : sashes . right , orthogonalStart : sashes . top , orthogonalEnd : sashes . bottom } ;
154+ } else {
155+ return { start : sashes . top , end : sashes . bottom , orthogonalStart : sashes . left , orthogonalEnd : sashes . right } ;
156+ }
157+ }
158+
135159class BranchNode implements ISplitView < ILayoutContext > , IDisposable {
136160
137161 readonly element : HTMLElement ;
@@ -224,13 +248,26 @@ class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
224248 private splitviewSashResetDisposable : IDisposable = Disposable . None ;
225249 private childrenSashResetDisposable : IDisposable = Disposable . None ;
226250
227- private _boundarySashes : IBoundarySashes = { } ;
228- get boundarySashes ( ) : IBoundarySashes { return this . _boundarySashes ; }
229- set boundarySashes ( boundarySashes : IBoundarySashes ) {
251+ private _boundarySashes : IRelativeBoundarySashes = { } ;
252+ get boundarySashes ( ) : IRelativeBoundarySashes { return this . _boundarySashes ; }
253+ set boundarySashes ( boundarySashes : IRelativeBoundarySashes ) {
230254 this . _boundarySashes = boundarySashes ;
231255
232256 this . splitview . orthogonalStartSash = boundarySashes . orthogonalStart ;
233257 this . splitview . orthogonalEndSash = boundarySashes . orthogonalEnd ;
258+
259+ for ( let index = 0 ; index < this . children . length ; index ++ ) {
260+ const child = this . children [ index ] ;
261+ const first = index === 0 ;
262+ const last = index === this . children . length - 1 ;
263+
264+ child . boundarySashes = {
265+ start : boundarySashes . orthogonalStart ,
266+ end : boundarySashes . orthogonalEnd ,
267+ orthogonalStart : first ? boundarySashes . start : child . boundarySashes . orthogonalStart ,
268+ orthogonalEnd : last ? boundarySashes . end : child . boundarySashes . orthogonalEnd ,
269+ } ;
270+ }
234271 }
235272
236273 constructor (
@@ -694,9 +731,15 @@ class LeafNode implements ISplitView<ILayoutContext>, IDisposable {
694731 return this . orientation === Orientation . HORIZONTAL ? this . maximumWidth : this . maximumHeight ;
695732 }
696733
697- private _boundarySashes : IBoundarySashes = { } ;
698- get boundarySashes ( ) : IBoundarySashes { return this . _boundarySashes ; }
699- set boundarySashes ( boundarySashes : IBoundarySashes ) { this . _boundarySashes = boundarySashes ; }
734+ private _boundarySashes : IRelativeBoundarySashes = { } ;
735+ get boundarySashes ( ) : IRelativeBoundarySashes { return this . _boundarySashes ; }
736+ set boundarySashes ( boundarySashes : IRelativeBoundarySashes ) {
737+ this . _boundarySashes = boundarySashes ;
738+
739+ if ( this . view . setBoundarySashes ) {
740+ this . view . setBoundarySashes ( toAbsoluteBoundarySashes ( boundarySashes , this . orientation ) ) ;
741+ }
742+ }
700743
701744 layout ( size : number , offset : number , ctx : ILayoutContext | undefined ) : void {
702745 if ( ! this . layoutController . isLayoutEnabled ) {
@@ -799,6 +842,7 @@ export class GridView implements IDisposable {
799842 const { size, orthogonalSize } = this . _root ;
800843 this . root = flipNode ( this . _root , orthogonalSize , size ) ;
801844 this . root . layout ( size , 0 , { orthogonalSize, absoluteOffset : 0 , absoluteOrthogonalOffset : 0 , absoluteSize : size , absoluteOrthogonalSize : orthogonalSize } ) ;
845+ this . boundarySashes = this . boundarySashes ;
802846 }
803847
804848 get width ( ) : number { return this . root . width ; }
@@ -812,6 +856,13 @@ export class GridView implements IDisposable {
812856 private _onDidChange = new Relay < IViewSize | undefined > ( ) ;
813857 readonly onDidChange = this . _onDidChange . event ;
814858
859+ private _boundarySashes : IBoundarySashes = { } ;
860+ get boundarySashes ( ) : IBoundarySashes { return this . _boundarySashes ; }
861+ set boundarySashes ( boundarySashes : IBoundarySashes ) {
862+ this . _boundarySashes = boundarySashes ;
863+ this . root . boundarySashes = fromAbsoluteBoundarySashes ( boundarySashes , this . orientation ) ;
864+ }
865+
815866 /**
816867 * The first layout controller makes sure layout only propagates
817868 * to the views after the very first call to gridview.layout()
@@ -933,6 +984,7 @@ export class GridView implements IDisposable {
933984 // we must promote sibling to be the new root
934985 parent . removeChild ( 0 ) ;
935986 this . root = sibling ;
987+ this . boundarySashes = this . boundarySashes ;
936988 return node . view ;
937989 }
938990
0 commit comments