88import 'vs/workbench/browser/parts/editor/editor.contribution' ;
99import { IThemeService } from 'vs/platform/theme/common/themeService' ;
1010import { Part } from 'vs/workbench/browser/part' ;
11- import { Dimension , isAncestor , toggleClass , addClass } from 'vs/base/browser/dom' ;
11+ import { Dimension , isAncestor , toggleClass , addClass , $ } from 'vs/base/browser/dom' ;
1212import { Event , Emitter , once , Relay , anyEvent } from 'vs/base/common/event' ;
1313import { contrastBorder , editorBackground } from 'vs/platform/theme/common/colorRegistry' ;
1414import { GroupDirection , IAddGroupOptions , GroupsArrangement , GroupOrientation , IMergeGroupOptions , MergeGroupMode , ICopyEditorOptions , GroupsOrder , GroupChangeKind , GroupLocation , IFindGroupScope , EditorGroupLayout , GroupLayoutArgument } from 'vs/workbench/services/group/common/editorGroupsService' ;
1515import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
16- import { Direction , SerializableGrid , Sizing , ISerializedGrid , Orientation , ISerializedNode , GridBranchNode , isGridBranchNode , GridNode , createSerializedGrid } from 'vs/base/browser/ui/grid/grid' ;
16+ import { Direction , SerializableGrid , Sizing , ISerializedGrid , Orientation , ISerializedNode , GridBranchNode , isGridBranchNode , GridNode , createSerializedGrid , Grid } from 'vs/base/browser/ui/grid/grid' ;
1717import { GroupIdentifier , IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor' ;
1818import { values } from 'vs/base/common/map' ;
1919import { EDITOR_GROUP_BORDER } from 'vs/workbench/common/theme' ;
@@ -43,6 +43,48 @@ interface IEditorPartUIState {
4343 mostRecentActiveGroups : GroupIdentifier [ ] ;
4444}
4545
46+ class GridWidgetView < T extends IView > implements IView {
47+
48+ readonly element : HTMLElement = $ ( '.grid-view-container' ) ;
49+
50+ get minimumWidth ( ) : number { return this . gridWidget ? this . gridWidget . minimumWidth : 0 ; }
51+ get maximumWidth ( ) : number { return this . gridWidget ? this . gridWidget . maximumWidth : Number . POSITIVE_INFINITY ; }
52+ get minimumHeight ( ) : number { return this . gridWidget ? this . gridWidget . minimumHeight : 0 ; }
53+ get maximumHeight ( ) : number { return this . gridWidget ? this . gridWidget . maximumHeight : Number . POSITIVE_INFINITY ; }
54+
55+ private _onDidChange = new Relay < { width : number ; height : number ; } > ( ) ;
56+ readonly onDidChange : Event < { width : number ; height : number ; } > = this . _onDidChange . event ;
57+
58+ private _gridWidget : Grid < T > ;
59+
60+ get gridWidget ( ) : Grid < T > {
61+ return this . _gridWidget ;
62+ }
63+
64+ set gridWidget ( grid : Grid < T > ) {
65+ this . element . innerHTML = '' ;
66+
67+ if ( grid ) {
68+ this . element . appendChild ( grid . element ) ;
69+ this . _onDidChange . input = grid . onDidChange ;
70+ } else {
71+ this . _onDidChange . input = Event . None ;
72+ }
73+
74+ this . _gridWidget = grid ;
75+ }
76+
77+ layout ( width : number , height : number ) : void {
78+ if ( this . gridWidget ) {
79+ this . gridWidget . layout ( width , height ) ;
80+ }
81+ }
82+
83+ dispose ( ) : void {
84+ this . _onDidChange . dispose ( ) ;
85+ }
86+ }
87+
4688export class EditorPart extends Part implements EditorGroupsServiceImpl , IEditorGroupsAccessor {
4789
4890 _serviceBrand : any ;
@@ -91,6 +133,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
91133 private container : HTMLElement ;
92134 private centeredLayoutWidget : CenteredViewLayout ;
93135 private gridWidget : SerializableGrid < IEditorGroupView > ;
136+ private gridWidgetView : GridWidgetView < IEditorGroupView > ;
94137
95138 private _whenRestored : TPromise < void > ;
96139 private whenRestoredComplete : TValueCallback < void > ;
@@ -110,6 +153,8 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
110153 ) {
111154 super ( id , { hasTitle : false } , themeService ) ;
112155
156+ this . gridWidgetView = new GridWidgetView < IEditorGroupView > ( ) ;
157+
113158 this . _partOptions = getEditorPartOptions ( this . configurationService . getValue < IWorkbenchEditorConfiguration > ( ) ) ;
114159 this . memento = this . getMemento ( this . storageService , Scope . WORKSPACE ) ;
115160 this . globalMemento = this . getMemento ( this . storageService , Scope . GLOBAL ) ;
@@ -720,26 +765,15 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
720765
721766 // Grid control with center layout
722767 this . doCreateGridControl ( ) ;
723- this . centeredLayoutWidget = this . _register ( new CenteredViewLayout ( this . container , this . getGridAsView ( ) , this . globalMemento [ EditorPart . EDITOR_PART_CENTERED_VIEW_STORAGE_KEY ] ) ) ;
768+
769+ this . centeredLayoutWidget = this . _register ( new CenteredViewLayout ( this . container , this . gridWidgetView , this . globalMemento [ EditorPart . EDITOR_PART_CENTERED_VIEW_STORAGE_KEY ] ) ) ;
724770
725771 // Drop support
726772 this . _register ( this . instantiationService . createInstance ( EditorDropTarget , this , this . container ) ) ;
727773
728774 return this . container ;
729775 }
730776
731- private getGridAsView ( ) : IView {
732- return {
733- element : this . gridWidget . element ,
734- layout : ( width , height ) => this . gridWidget . layout ( width , height ) ,
735- minimumWidth : this . gridWidget . minimumWidth ,
736- maximumWidth : this . gridWidget . maximumWidth ,
737- minimumHeight : this . gridWidget . minimumHeight ,
738- maximumHeight : this . gridWidget . minimumHeight ,
739- onDidChange : this . gridWidget . onDidChange
740- } ;
741- }
742-
743777 centerLayout ( active : boolean ) : void {
744778 this . centeredLayoutWidget . activate ( active ) ;
745779 }
@@ -838,12 +872,9 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
838872 }
839873
840874 this . gridWidget = gridWidget ;
875+ this . gridWidgetView . gridWidget = gridWidget ;
841876
842877 if ( gridWidget ) {
843- if ( this . centeredLayoutWidget ) {
844- this . centeredLayoutWidget . resetView ( this . getGridAsView ( ) ) ;
845- }
846-
847878 this . _onDidSizeConstraintsChange . input = gridWidget . onDidChange ;
848879 }
849880
0 commit comments