@codingame/monaco-vscode-api 2.1.3 → 2.2.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/contributions.js +1 -0
- package/extensions.d.ts +6 -3
- package/extensions.js +18 -7
- package/lifecycle.js +11 -3
- package/missing-services.js +55 -10
- package/monaco.js +7 -3
- package/package.json +8 -8
- package/service-override/tools/editor.js +3 -1
- package/service-override/tools/views.d.ts +98 -0
- package/service-override/tools/views.js +249 -0
- package/services.d.ts +4 -2
- package/services.js +11 -9
- package/vscode/src/vs/base/browser/deviceAccess.js +60 -0
- package/vscode/src/vs/base/browser/dom.js +18 -1
- package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +178 -0
- package/vscode/src/vs/base/browser/ui/grid/grid.js +492 -0
- package/vscode/src/vs/base/browser/ui/grid/gridview.css.js +4 -0
- package/vscode/src/vs/base/browser/ui/grid/gridview.d.ts +1 -0
- package/vscode/src/vs/base/browser/ui/grid/gridview.js +1109 -0
- package/vscode/src/vs/base/browser/ui/sash/sash.js +9 -1
- package/vscode/src/vs/base/browser/ui/splitview/splitview.d.ts +348 -1
- package/vscode/src/vs/base/common/async.js +46 -2
- package/vscode/src/vs/base/common/codicons.d.ts +579 -0
- package/vscode/src/vs/base/common/event.js +11 -2
- package/vscode/src/vs/base/common/keybindingParser.js +87 -0
- package/vscode/src/vs/base/common/network.js +1 -2
- package/vscode/src/vs/base/common/observableInternal/utils.js +1 -1
- package/vscode/src/vs/base/common/platform.js +2 -1
- package/vscode/src/vs/base/common/scrollable.d.ts +28 -0
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/colors.js +17 -0
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/diffEditorItemTemplate.js +214 -0
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorViewModel.js +84 -0
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidget.js +54 -0
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidgetImpl.js +324 -0
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/objectPool.js +46 -0
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/style.css.js +4 -0
- package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/utils.js +11 -0
- package/vscode/src/vs/platform/keyboardLayout/common/keyboardLayout.js +61 -1
- package/vscode/src/vs/platform/languagePacks/common/localizedStrings.js +10 -0
- package/vscode/src/vs/platform/log/browser/log.js +24 -0
- package/vscode/src/vs/platform/product/common/product.js +1 -2
- package/vscode/src/vs/platform/userDataSync/common/abstractSynchronizer.js +772 -0
- package/vscode/src/vs/platform/userDataSync/common/userDataSyncStoreService.js +551 -0
- package/vscode/src/vs/platform/webview/common/mimeTypes.js +22 -0
- package/vscode/src/vs/platform/webview/common/webviewPortMapping.js +62 -0
- package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +788 -0
- package/vscode/src/vs/workbench/browser/actions/listCommands.js +763 -0
- package/vscode/src/vs/workbench/browser/layout.d.ts +26 -0
- package/vscode/src/vs/workbench/browser/media/style.css.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +610 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +148 -0
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/compositeBar.js +603 -0
- package/vscode/src/vs/workbench/browser/parts/compositePart.js +333 -0
- package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +221 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +1406 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +184 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +509 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorPane.d.ts +112 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +1018 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +389 -0
- package/vscode/src/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/media/compositepart.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsActions.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsCenter.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsList.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsToasts.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsActions.js +213 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsAlerts.js +73 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsCenter.js +307 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsList.js +226 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsStatus.js +218 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsToasts.js +433 -0
- package/vscode/src/vs/workbench/browser/parts/notifications/notificationsViewer.js +436 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +643 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +377 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +66 -0
- package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +144 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +220 -0
- package/vscode/src/vs/workbench/browser/window.js +239 -5
- package/vscode/src/vs/workbench/common/configuration.js +11 -1
- package/vscode/src/vs/workbench/common/theme.js +3 -3
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +298 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +363 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +133 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentGlyphWidget.js +90 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentMenus.js +43 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentService.js +317 -2
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadRangeDecorator.js +107 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +395 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/comments.js +3 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +1277 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsFilterOptions.js +17 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsModel.js +123 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +342 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsView.js +451 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentsViewActions.js +176 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/media/panel.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/comments/common/commentModel.js +35 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +16 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +143 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +212 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/media/customEditor.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +76 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.js +61 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +117 -0
- package/vscode/src/vs/workbench/contrib/editSessions/common/editSessions.js +62 -0
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +5 -0
- package/vscode/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.js +77 -0
- package/vscode/src/vs/workbench/contrib/files/browser/editors/fileEditorHandler.js +72 -0
- package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditor.js +254 -0
- package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditorTracker.js +97 -0
- package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.js +442 -0
- package/vscode/src/vs/workbench/contrib/files/browser/explorerService.js +430 -0
- package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +784 -0
- package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +487 -0
- package/vscode/src/vs/workbench/contrib/files/browser/files.contribution.js +521 -0
- package/vscode/src/vs/workbench/contrib/files/browser/workspaceWatcher.js +150 -0
- package/vscode/src/vs/workbench/contrib/files/common/dirtyFilesIndicator.js +61 -0
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveDocumentService.js +25 -1
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.js +178 -0
- package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveHistoryService.js +49 -0
- package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.js +408 -0
- package/vscode/src/vs/workbench/contrib/languageStatus/browser/media/languageStatus.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution.js +145 -0
- package/vscode/src/vs/workbench/contrib/mappedEdits/common/mappedEdits.contribution.js +22 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +691 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +238 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +76 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +40 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +69 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +346 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +96 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +144 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +103 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +399 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +195 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +39 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +126 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +611 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +156 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +262 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +171 -0
- package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService.js +41 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +317 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +56 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +315 -0
- package/vscode/src/vs/workbench/contrib/preferences/browser/keyboardLayoutPicker.js +193 -0
- package/vscode/src/vs/workbench/contrib/preferences/common/preferences.js +2 -1
- package/vscode/src/vs/workbench/contrib/sash/browser/sash.contribution.js +37 -0
- package/vscode/src/vs/workbench/contrib/sash/browser/sash.js +39 -0
- package/vscode/src/vs/workbench/contrib/speech/common/speechService.js +138 -2
- package/vscode/src/vs/workbench/contrib/tags/browser/workspaceTagsService.js +12 -0
- package/vscode/src/vs/workbench/contrib/tags/common/workspaceTags.js +3 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +281 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +358 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +131 -0
- package/vscode/src/vs/workbench/contrib/update/common/update.js +2 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +288 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +94 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/themeing.js +86 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.js +77 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +646 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +63 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +57 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +140 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.js +119 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +67 -0
- package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +233 -0
- package/vscode/src/vs/workbench/services/activity/browser/activityService.js +143 -0
- package/vscode/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.js +0 -3
- package/vscode/src/vs/workbench/services/driver/browser/driver.js +184 -0
- package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +668 -0
- package/vscode/src/vs/workbench/services/history/browser/historyService.js +1482 -0
- package/vscode/src/vs/workbench/services/layout/browser/layoutService.js +17 -1
- package/vscode/src/vs/workbench/services/lifecycle/common/lifecycle.js +8 -1
- package/vscode/src/vs/workbench/services/progress/browser/media/progressService.css.js +4 -0
- package/vscode/src/vs/workbench/services/progress/browser/progressService.js +521 -0
- package/vscode/src/vs/workbench/services/textMate/common/TMGrammars.js +102 -0
- package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js +296 -0
- package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +99 -0
- package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +711 -0
- package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +596 -0
|
@@ -0,0 +1,1109 @@
|
|
|
1
|
+
import { $ } from '../../dom.js';
|
|
2
|
+
import { Sizing, SplitView } from '../splitview/splitview.js';
|
|
3
|
+
import { tail2, equals } from '../../../common/arrays.js';
|
|
4
|
+
import { Color } from '../../../common/color.js';
|
|
5
|
+
import { Event, Relay, Emitter } from '../../../common/event.js';
|
|
6
|
+
import { Disposable, DisposableStore, toDisposable } from '../../../common/lifecycle.js';
|
|
7
|
+
import { rot } from '../../../common/numbers.js';
|
|
8
|
+
import { isUndefined } from '../../../common/types.js';
|
|
9
|
+
import './gridview.css.js';
|
|
10
|
+
const defaultStyles = {
|
|
11
|
+
separatorBorder: Color.transparent
|
|
12
|
+
};
|
|
13
|
+
function orthogonal(orientation) {
|
|
14
|
+
return orientation === 0 ? 1 : 0 ;
|
|
15
|
+
}
|
|
16
|
+
class LayoutController {
|
|
17
|
+
constructor(isLayoutEnabled) {
|
|
18
|
+
this.isLayoutEnabled = isLayoutEnabled;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function toAbsoluteBoundarySashes(sashes, orientation) {
|
|
22
|
+
if (orientation === 1 ) {
|
|
23
|
+
return { left: sashes.start, right: sashes.end, top: sashes.orthogonalStart, bottom: sashes.orthogonalEnd };
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return { top: sashes.start, bottom: sashes.end, left: sashes.orthogonalStart, right: sashes.orthogonalEnd };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function fromAbsoluteBoundarySashes(sashes, orientation) {
|
|
30
|
+
if (orientation === 1 ) {
|
|
31
|
+
return { start: sashes.left, end: sashes.right, orthogonalStart: sashes.top, orthogonalEnd: sashes.bottom };
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return { start: sashes.top, end: sashes.bottom, orthogonalStart: sashes.left, orthogonalEnd: sashes.right };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function validateIndex(index, numChildren) {
|
|
38
|
+
if (Math.abs(index) > numChildren) {
|
|
39
|
+
throw new Error('Invalid index');
|
|
40
|
+
}
|
|
41
|
+
return rot(index, numChildren + 1);
|
|
42
|
+
}
|
|
43
|
+
class BranchNode {
|
|
44
|
+
get size() { return this._size; }
|
|
45
|
+
get orthogonalSize() { return this._orthogonalSize; }
|
|
46
|
+
get absoluteOffset() { return this._absoluteOffset; }
|
|
47
|
+
get absoluteOrthogonalOffset() { return this._absoluteOrthogonalOffset; }
|
|
48
|
+
get styles() { return this._styles; }
|
|
49
|
+
get width() {
|
|
50
|
+
return this.orientation === 1 ? this.size : this.orthogonalSize;
|
|
51
|
+
}
|
|
52
|
+
get height() {
|
|
53
|
+
return this.orientation === 1 ? this.orthogonalSize : this.size;
|
|
54
|
+
}
|
|
55
|
+
get top() {
|
|
56
|
+
return this.orientation === 1 ? this._absoluteOffset : this._absoluteOrthogonalOffset;
|
|
57
|
+
}
|
|
58
|
+
get left() {
|
|
59
|
+
return this.orientation === 1 ? this._absoluteOrthogonalOffset : this._absoluteOffset;
|
|
60
|
+
}
|
|
61
|
+
get minimumSize() {
|
|
62
|
+
return this.children.length === 0 ? 0 : Math.max(...( this.children.map(
|
|
63
|
+
(c, index) => this.splitview.isViewVisible(index) ? c.minimumOrthogonalSize : 0
|
|
64
|
+
)));
|
|
65
|
+
}
|
|
66
|
+
get maximumSize() {
|
|
67
|
+
return Math.min(...( this.children.map(
|
|
68
|
+
(c, index) => this.splitview.isViewVisible(index) ? c.maximumOrthogonalSize : Number.POSITIVE_INFINITY
|
|
69
|
+
)));
|
|
70
|
+
}
|
|
71
|
+
get priority() {
|
|
72
|
+
if (this.children.length === 0) {
|
|
73
|
+
return 0 ;
|
|
74
|
+
}
|
|
75
|
+
const priorities = ( this.children.map(
|
|
76
|
+
c => typeof c.priority === 'undefined' ? 0 : c.priority
|
|
77
|
+
));
|
|
78
|
+
if (( priorities.some(p => p === 2 ))) {
|
|
79
|
+
return 2 ;
|
|
80
|
+
}
|
|
81
|
+
else if (( priorities.some(p => p === 1 ))) {
|
|
82
|
+
return 1 ;
|
|
83
|
+
}
|
|
84
|
+
return 0 ;
|
|
85
|
+
}
|
|
86
|
+
get proportionalLayout() {
|
|
87
|
+
if (this.children.length === 0) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
return this.children.every(c => c.proportionalLayout);
|
|
91
|
+
}
|
|
92
|
+
get minimumOrthogonalSize() {
|
|
93
|
+
return this.splitview.minimumSize;
|
|
94
|
+
}
|
|
95
|
+
get maximumOrthogonalSize() {
|
|
96
|
+
return this.splitview.maximumSize;
|
|
97
|
+
}
|
|
98
|
+
get minimumWidth() {
|
|
99
|
+
return this.orientation === 1 ? this.minimumOrthogonalSize : this.minimumSize;
|
|
100
|
+
}
|
|
101
|
+
get minimumHeight() {
|
|
102
|
+
return this.orientation === 1 ? this.minimumSize : this.minimumOrthogonalSize;
|
|
103
|
+
}
|
|
104
|
+
get maximumWidth() {
|
|
105
|
+
return this.orientation === 1 ? this.maximumOrthogonalSize : this.maximumSize;
|
|
106
|
+
}
|
|
107
|
+
get maximumHeight() {
|
|
108
|
+
return this.orientation === 1 ? this.maximumSize : this.maximumOrthogonalSize;
|
|
109
|
+
}
|
|
110
|
+
get boundarySashes() { return this._boundarySashes; }
|
|
111
|
+
set boundarySashes(boundarySashes) {
|
|
112
|
+
if (this._boundarySashes.start === boundarySashes.start
|
|
113
|
+
&& this._boundarySashes.end === boundarySashes.end
|
|
114
|
+
&& this._boundarySashes.orthogonalStart === boundarySashes.orthogonalStart
|
|
115
|
+
&& this._boundarySashes.orthogonalEnd === boundarySashes.orthogonalEnd) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this._boundarySashes = boundarySashes;
|
|
119
|
+
this.splitview.orthogonalStartSash = boundarySashes.orthogonalStart;
|
|
120
|
+
this.splitview.orthogonalEndSash = boundarySashes.orthogonalEnd;
|
|
121
|
+
for (let index = 0; index < this.children.length; index++) {
|
|
122
|
+
const child = this.children[index];
|
|
123
|
+
const first = index === 0;
|
|
124
|
+
const last = index === this.children.length - 1;
|
|
125
|
+
child.boundarySashes = {
|
|
126
|
+
start: boundarySashes.orthogonalStart,
|
|
127
|
+
end: boundarySashes.orthogonalEnd,
|
|
128
|
+
orthogonalStart: first ? boundarySashes.start : child.boundarySashes.orthogonalStart,
|
|
129
|
+
orthogonalEnd: last ? boundarySashes.end : child.boundarySashes.orthogonalEnd,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
get edgeSnapping() { return this._edgeSnapping; }
|
|
134
|
+
set edgeSnapping(edgeSnapping) {
|
|
135
|
+
if (this._edgeSnapping === edgeSnapping) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
this._edgeSnapping = edgeSnapping;
|
|
139
|
+
for (const child of this.children) {
|
|
140
|
+
if (child instanceof BranchNode) {
|
|
141
|
+
child.edgeSnapping = edgeSnapping;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
this.updateSplitviewEdgeSnappingEnablement();
|
|
145
|
+
}
|
|
146
|
+
constructor(orientation, layoutController, styles, splitviewProportionalLayout, size = 0, orthogonalSize = 0, edgeSnapping = false, childDescriptors) {
|
|
147
|
+
this.orientation = orientation;
|
|
148
|
+
this.layoutController = layoutController;
|
|
149
|
+
this.splitviewProportionalLayout = splitviewProportionalLayout;
|
|
150
|
+
this.children = [];
|
|
151
|
+
this._absoluteOffset = 0;
|
|
152
|
+
this._absoluteOrthogonalOffset = 0;
|
|
153
|
+
this.absoluteOrthogonalSize = 0;
|
|
154
|
+
this._onDidChange = ( new Emitter());
|
|
155
|
+
this.onDidChange = this._onDidChange.event;
|
|
156
|
+
this._onDidVisibilityChange = ( new Emitter());
|
|
157
|
+
this.onDidVisibilityChange = this._onDidVisibilityChange.event;
|
|
158
|
+
this.childrenVisibilityChangeDisposable = ( new DisposableStore());
|
|
159
|
+
this._onDidScroll = ( new Emitter());
|
|
160
|
+
this.onDidScrollDisposable = Disposable.None;
|
|
161
|
+
this.onDidScroll = this._onDidScroll.event;
|
|
162
|
+
this.childrenChangeDisposable = Disposable.None;
|
|
163
|
+
this._onDidSashReset = ( new Emitter());
|
|
164
|
+
this.onDidSashReset = this._onDidSashReset.event;
|
|
165
|
+
this.splitviewSashResetDisposable = Disposable.None;
|
|
166
|
+
this.childrenSashResetDisposable = Disposable.None;
|
|
167
|
+
this._boundarySashes = {};
|
|
168
|
+
this._edgeSnapping = false;
|
|
169
|
+
this._styles = styles;
|
|
170
|
+
this._size = size;
|
|
171
|
+
this._orthogonalSize = orthogonalSize;
|
|
172
|
+
this.element = $('.monaco-grid-branch-node');
|
|
173
|
+
if (!childDescriptors) {
|
|
174
|
+
this.splitview = ( new SplitView(
|
|
175
|
+
this.element,
|
|
176
|
+
{ orientation, styles, proportionalLayout: splitviewProportionalLayout }
|
|
177
|
+
));
|
|
178
|
+
this.splitview.layout(size, { orthogonalSize, absoluteOffset: 0, absoluteOrthogonalOffset: 0, absoluteSize: size, absoluteOrthogonalSize: orthogonalSize });
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const descriptor = {
|
|
182
|
+
views: ( childDescriptors.map(childDescriptor => {
|
|
183
|
+
return {
|
|
184
|
+
view: childDescriptor.node,
|
|
185
|
+
size: childDescriptor.node.size,
|
|
186
|
+
visible: childDescriptor.visible !== false
|
|
187
|
+
};
|
|
188
|
+
})),
|
|
189
|
+
size: this.orthogonalSize
|
|
190
|
+
};
|
|
191
|
+
const options = { proportionalLayout: splitviewProportionalLayout, orientation, styles };
|
|
192
|
+
this.children = ( childDescriptors.map(c => c.node));
|
|
193
|
+
this.splitview = ( new SplitView(this.element, { ...options, descriptor }));
|
|
194
|
+
this.children.forEach((node, index) => {
|
|
195
|
+
const first = index === 0;
|
|
196
|
+
const last = index === this.children.length;
|
|
197
|
+
node.boundarySashes = {
|
|
198
|
+
start: this.boundarySashes.orthogonalStart,
|
|
199
|
+
end: this.boundarySashes.orthogonalEnd,
|
|
200
|
+
orthogonalStart: first ? this.boundarySashes.start : this.splitview.sashes[index - 1],
|
|
201
|
+
orthogonalEnd: last ? this.boundarySashes.end : this.splitview.sashes[index],
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const onDidSashReset = ( Event.map(this.splitview.onDidSashReset, i => [i]));
|
|
206
|
+
this.splitviewSashResetDisposable = onDidSashReset(this._onDidSashReset.fire, this._onDidSashReset);
|
|
207
|
+
this.updateChildrenEvents();
|
|
208
|
+
}
|
|
209
|
+
style(styles) {
|
|
210
|
+
this._styles = styles;
|
|
211
|
+
this.splitview.style(styles);
|
|
212
|
+
for (const child of this.children) {
|
|
213
|
+
if (child instanceof BranchNode) {
|
|
214
|
+
child.style(styles);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
layout(size, offset, ctx) {
|
|
219
|
+
if (!this.layoutController.isLayoutEnabled) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (typeof ctx === 'undefined') {
|
|
223
|
+
throw new Error('Invalid state');
|
|
224
|
+
}
|
|
225
|
+
this._size = ctx.orthogonalSize;
|
|
226
|
+
this._orthogonalSize = size;
|
|
227
|
+
this._absoluteOffset = ctx.absoluteOffset + offset;
|
|
228
|
+
this._absoluteOrthogonalOffset = ctx.absoluteOrthogonalOffset;
|
|
229
|
+
this.absoluteOrthogonalSize = ctx.absoluteOrthogonalSize;
|
|
230
|
+
this.splitview.layout(ctx.orthogonalSize, {
|
|
231
|
+
orthogonalSize: size,
|
|
232
|
+
absoluteOffset: this._absoluteOrthogonalOffset,
|
|
233
|
+
absoluteOrthogonalOffset: this._absoluteOffset,
|
|
234
|
+
absoluteSize: ctx.absoluteOrthogonalSize,
|
|
235
|
+
absoluteOrthogonalSize: ctx.absoluteSize
|
|
236
|
+
});
|
|
237
|
+
this.updateSplitviewEdgeSnappingEnablement();
|
|
238
|
+
}
|
|
239
|
+
setVisible(visible) {
|
|
240
|
+
for (const child of this.children) {
|
|
241
|
+
child.setVisible(visible);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
addChild(node, size, index, skipLayout) {
|
|
245
|
+
index = validateIndex(index, this.children.length);
|
|
246
|
+
this.splitview.addView(node, size, index, skipLayout);
|
|
247
|
+
this.children.splice(index, 0, node);
|
|
248
|
+
this.updateBoundarySashes();
|
|
249
|
+
this.onDidChildrenChange();
|
|
250
|
+
}
|
|
251
|
+
removeChild(index, sizing) {
|
|
252
|
+
index = validateIndex(index, this.children.length);
|
|
253
|
+
const result = this.splitview.removeView(index, sizing);
|
|
254
|
+
this.children.splice(index, 1);
|
|
255
|
+
this.updateBoundarySashes();
|
|
256
|
+
this.onDidChildrenChange();
|
|
257
|
+
return result;
|
|
258
|
+
}
|
|
259
|
+
removeAllChildren() {
|
|
260
|
+
const result = this.splitview.removeAllViews();
|
|
261
|
+
this.children.splice(0, this.children.length);
|
|
262
|
+
this.updateBoundarySashes();
|
|
263
|
+
this.onDidChildrenChange();
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
moveChild(from, to) {
|
|
267
|
+
from = validateIndex(from, this.children.length);
|
|
268
|
+
to = validateIndex(to, this.children.length);
|
|
269
|
+
if (from === to) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (from < to) {
|
|
273
|
+
to -= 1;
|
|
274
|
+
}
|
|
275
|
+
this.splitview.moveView(from, to);
|
|
276
|
+
this.children.splice(to, 0, this.children.splice(from, 1)[0]);
|
|
277
|
+
this.updateBoundarySashes();
|
|
278
|
+
this.onDidChildrenChange();
|
|
279
|
+
}
|
|
280
|
+
swapChildren(from, to) {
|
|
281
|
+
from = validateIndex(from, this.children.length);
|
|
282
|
+
to = validateIndex(to, this.children.length);
|
|
283
|
+
if (from === to) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
this.splitview.swapViews(from, to);
|
|
287
|
+
[this.children[from].boundarySashes, this.children[to].boundarySashes]
|
|
288
|
+
= [this.children[from].boundarySashes, this.children[to].boundarySashes];
|
|
289
|
+
[this.children[from], this.children[to]] = [this.children[to], this.children[from]];
|
|
290
|
+
this.onDidChildrenChange();
|
|
291
|
+
}
|
|
292
|
+
resizeChild(index, size) {
|
|
293
|
+
index = validateIndex(index, this.children.length);
|
|
294
|
+
this.splitview.resizeView(index, size);
|
|
295
|
+
}
|
|
296
|
+
isChildExpanded(index) {
|
|
297
|
+
return this.splitview.isViewExpanded(index);
|
|
298
|
+
}
|
|
299
|
+
distributeViewSizes(recursive = false) {
|
|
300
|
+
this.splitview.distributeViewSizes();
|
|
301
|
+
if (recursive) {
|
|
302
|
+
for (const child of this.children) {
|
|
303
|
+
if (child instanceof BranchNode) {
|
|
304
|
+
child.distributeViewSizes(true);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
getChildSize(index) {
|
|
310
|
+
index = validateIndex(index, this.children.length);
|
|
311
|
+
return this.splitview.getViewSize(index);
|
|
312
|
+
}
|
|
313
|
+
isChildVisible(index) {
|
|
314
|
+
index = validateIndex(index, this.children.length);
|
|
315
|
+
return this.splitview.isViewVisible(index);
|
|
316
|
+
}
|
|
317
|
+
setChildVisible(index, visible) {
|
|
318
|
+
index = validateIndex(index, this.children.length);
|
|
319
|
+
if (this.splitview.isViewVisible(index) === visible) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const wereAllChildrenHidden = this.splitview.contentSize === 0;
|
|
323
|
+
this.splitview.setViewVisible(index, visible);
|
|
324
|
+
const areAllChildrenHidden = this.splitview.contentSize === 0;
|
|
325
|
+
if ((visible && wereAllChildrenHidden) || (!visible && areAllChildrenHidden)) {
|
|
326
|
+
this._onDidVisibilityChange.fire(visible);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
getChildCachedVisibleSize(index) {
|
|
330
|
+
index = validateIndex(index, this.children.length);
|
|
331
|
+
return this.splitview.getViewCachedVisibleSize(index);
|
|
332
|
+
}
|
|
333
|
+
updateBoundarySashes() {
|
|
334
|
+
for (let i = 0; i < this.children.length; i++) {
|
|
335
|
+
this.children[i].boundarySashes = {
|
|
336
|
+
start: this.boundarySashes.orthogonalStart,
|
|
337
|
+
end: this.boundarySashes.orthogonalEnd,
|
|
338
|
+
orthogonalStart: i === 0 ? this.boundarySashes.start : this.splitview.sashes[i - 1],
|
|
339
|
+
orthogonalEnd: i === this.children.length - 1 ? this.boundarySashes.end : this.splitview.sashes[i],
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
onDidChildrenChange() {
|
|
344
|
+
this.updateChildrenEvents();
|
|
345
|
+
this._onDidChange.fire(undefined);
|
|
346
|
+
}
|
|
347
|
+
updateChildrenEvents() {
|
|
348
|
+
const onDidChildrenChange = ( Event.map(Event.any(...( this.children.map(c => c.onDidChange))), () => undefined));
|
|
349
|
+
this.childrenChangeDisposable.dispose();
|
|
350
|
+
this.childrenChangeDisposable = onDidChildrenChange(this._onDidChange.fire, this._onDidChange);
|
|
351
|
+
const onDidChildrenSashReset = Event.any(...( this.children.map((c, i) => ( Event.map(c.onDidSashReset, location => [i, ...location])))));
|
|
352
|
+
this.childrenSashResetDisposable.dispose();
|
|
353
|
+
this.childrenSashResetDisposable = onDidChildrenSashReset(this._onDidSashReset.fire, this._onDidSashReset);
|
|
354
|
+
const onDidScroll = Event.any(Event.signal(this.splitview.onDidScroll), ...( this.children.map(c => c.onDidScroll)));
|
|
355
|
+
this.onDidScrollDisposable.dispose();
|
|
356
|
+
this.onDidScrollDisposable = onDidScroll(this._onDidScroll.fire, this._onDidScroll);
|
|
357
|
+
this.childrenVisibilityChangeDisposable.clear();
|
|
358
|
+
this.children.forEach((child, index) => {
|
|
359
|
+
if (child instanceof BranchNode) {
|
|
360
|
+
this.childrenVisibilityChangeDisposable.add(child.onDidVisibilityChange((visible) => {
|
|
361
|
+
this.setChildVisible(index, visible);
|
|
362
|
+
}));
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
trySet2x2(other) {
|
|
367
|
+
if (this.children.length !== 2 || other.children.length !== 2) {
|
|
368
|
+
return Disposable.None;
|
|
369
|
+
}
|
|
370
|
+
if (this.getChildSize(0) !== other.getChildSize(0)) {
|
|
371
|
+
return Disposable.None;
|
|
372
|
+
}
|
|
373
|
+
const [firstChild, secondChild] = this.children;
|
|
374
|
+
const [otherFirstChild, otherSecondChild] = other.children;
|
|
375
|
+
if (!(firstChild instanceof LeafNode) || !(secondChild instanceof LeafNode)) {
|
|
376
|
+
return Disposable.None;
|
|
377
|
+
}
|
|
378
|
+
if (!(otherFirstChild instanceof LeafNode) || !(otherSecondChild instanceof LeafNode)) {
|
|
379
|
+
return Disposable.None;
|
|
380
|
+
}
|
|
381
|
+
if (this.orientation === 0 ) {
|
|
382
|
+
secondChild.linkedWidthNode = otherFirstChild.linkedHeightNode = firstChild;
|
|
383
|
+
firstChild.linkedWidthNode = otherSecondChild.linkedHeightNode = secondChild;
|
|
384
|
+
otherSecondChild.linkedWidthNode = firstChild.linkedHeightNode = otherFirstChild;
|
|
385
|
+
otherFirstChild.linkedWidthNode = secondChild.linkedHeightNode = otherSecondChild;
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
otherFirstChild.linkedWidthNode = secondChild.linkedHeightNode = firstChild;
|
|
389
|
+
otherSecondChild.linkedWidthNode = firstChild.linkedHeightNode = secondChild;
|
|
390
|
+
firstChild.linkedWidthNode = otherSecondChild.linkedHeightNode = otherFirstChild;
|
|
391
|
+
secondChild.linkedWidthNode = otherFirstChild.linkedHeightNode = otherSecondChild;
|
|
392
|
+
}
|
|
393
|
+
const mySash = this.splitview.sashes[0];
|
|
394
|
+
const otherSash = other.splitview.sashes[0];
|
|
395
|
+
mySash.linkedSash = otherSash;
|
|
396
|
+
otherSash.linkedSash = mySash;
|
|
397
|
+
this._onDidChange.fire(undefined);
|
|
398
|
+
other._onDidChange.fire(undefined);
|
|
399
|
+
return toDisposable(() => {
|
|
400
|
+
mySash.linkedSash = otherSash.linkedSash = undefined;
|
|
401
|
+
firstChild.linkedHeightNode = firstChild.linkedWidthNode = undefined;
|
|
402
|
+
secondChild.linkedHeightNode = secondChild.linkedWidthNode = undefined;
|
|
403
|
+
otherFirstChild.linkedHeightNode = otherFirstChild.linkedWidthNode = undefined;
|
|
404
|
+
otherSecondChild.linkedHeightNode = otherSecondChild.linkedWidthNode = undefined;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
updateSplitviewEdgeSnappingEnablement() {
|
|
408
|
+
this.splitview.startSnappingEnabled = this._edgeSnapping || this._absoluteOrthogonalOffset > 0;
|
|
409
|
+
this.splitview.endSnappingEnabled = this._edgeSnapping || this._absoluteOrthogonalOffset + this._size < this.absoluteOrthogonalSize;
|
|
410
|
+
}
|
|
411
|
+
dispose() {
|
|
412
|
+
for (const child of this.children) {
|
|
413
|
+
child.dispose();
|
|
414
|
+
}
|
|
415
|
+
this._onDidChange.dispose();
|
|
416
|
+
this._onDidSashReset.dispose();
|
|
417
|
+
this._onDidVisibilityChange.dispose();
|
|
418
|
+
this.childrenVisibilityChangeDisposable.dispose();
|
|
419
|
+
this.splitviewSashResetDisposable.dispose();
|
|
420
|
+
this.childrenSashResetDisposable.dispose();
|
|
421
|
+
this.childrenChangeDisposable.dispose();
|
|
422
|
+
this.onDidScrollDisposable.dispose();
|
|
423
|
+
this.splitview.dispose();
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function createLatchedOnDidChangeViewEvent(view) {
|
|
427
|
+
const [onDidChangeViewConstraints, onDidSetViewSize] = Event.split(view.onDidChange, isUndefined);
|
|
428
|
+
return Event.any(onDidSetViewSize, ( Event.map(Event.latch(( Event.map(
|
|
429
|
+
onDidChangeViewConstraints,
|
|
430
|
+
_ => ([view.minimumWidth, view.maximumWidth, view.minimumHeight, view.maximumHeight])
|
|
431
|
+
)), equals), _ => undefined)));
|
|
432
|
+
}
|
|
433
|
+
class LeafNode {
|
|
434
|
+
get size() { return this._size; }
|
|
435
|
+
get orthogonalSize() { return this._orthogonalSize; }
|
|
436
|
+
get linkedWidthNode() { return this._linkedWidthNode; }
|
|
437
|
+
set linkedWidthNode(node) {
|
|
438
|
+
this._onDidLinkedWidthNodeChange.input = node ? node._onDidViewChange : Event.None;
|
|
439
|
+
this._linkedWidthNode = node;
|
|
440
|
+
this._onDidSetLinkedNode.fire(undefined);
|
|
441
|
+
}
|
|
442
|
+
get linkedHeightNode() { return this._linkedHeightNode; }
|
|
443
|
+
set linkedHeightNode(node) {
|
|
444
|
+
this._onDidLinkedHeightNodeChange.input = node ? node._onDidViewChange : Event.None;
|
|
445
|
+
this._linkedHeightNode = node;
|
|
446
|
+
this._onDidSetLinkedNode.fire(undefined);
|
|
447
|
+
}
|
|
448
|
+
constructor(view, orientation, layoutController, orthogonalSize, size = 0) {
|
|
449
|
+
this.view = view;
|
|
450
|
+
this.orientation = orientation;
|
|
451
|
+
this.layoutController = layoutController;
|
|
452
|
+
this._size = 0;
|
|
453
|
+
this.absoluteOffset = 0;
|
|
454
|
+
this.absoluteOrthogonalOffset = 0;
|
|
455
|
+
this.onDidScroll = Event.None;
|
|
456
|
+
this.onDidSashReset = Event.None;
|
|
457
|
+
this._onDidLinkedWidthNodeChange = ( new Relay());
|
|
458
|
+
this._linkedWidthNode = undefined;
|
|
459
|
+
this._onDidLinkedHeightNodeChange = ( new Relay());
|
|
460
|
+
this._linkedHeightNode = undefined;
|
|
461
|
+
this._onDidSetLinkedNode = ( new Emitter());
|
|
462
|
+
this.disposables = ( new DisposableStore());
|
|
463
|
+
this._boundarySashes = {};
|
|
464
|
+
this.cachedWidth = 0;
|
|
465
|
+
this.cachedHeight = 0;
|
|
466
|
+
this.cachedTop = 0;
|
|
467
|
+
this.cachedLeft = 0;
|
|
468
|
+
this._orthogonalSize = orthogonalSize;
|
|
469
|
+
this._size = size;
|
|
470
|
+
const onDidChange = createLatchedOnDidChangeViewEvent(view);
|
|
471
|
+
this._onDidViewChange = ( Event.map(
|
|
472
|
+
onDidChange,
|
|
473
|
+
e => e && (this.orientation === 0 ? e.width : e.height),
|
|
474
|
+
this.disposables
|
|
475
|
+
));
|
|
476
|
+
this.onDidChange = Event.any(this._onDidViewChange, this._onDidSetLinkedNode.event, this._onDidLinkedWidthNodeChange.event, this._onDidLinkedHeightNodeChange.event);
|
|
477
|
+
}
|
|
478
|
+
get width() {
|
|
479
|
+
return this.orientation === 1 ? this.orthogonalSize : this.size;
|
|
480
|
+
}
|
|
481
|
+
get height() {
|
|
482
|
+
return this.orientation === 1 ? this.size : this.orthogonalSize;
|
|
483
|
+
}
|
|
484
|
+
get top() {
|
|
485
|
+
return this.orientation === 1 ? this.absoluteOffset : this.absoluteOrthogonalOffset;
|
|
486
|
+
}
|
|
487
|
+
get left() {
|
|
488
|
+
return this.orientation === 1 ? this.absoluteOrthogonalOffset : this.absoluteOffset;
|
|
489
|
+
}
|
|
490
|
+
get element() {
|
|
491
|
+
return this.view.element;
|
|
492
|
+
}
|
|
493
|
+
get minimumWidth() {
|
|
494
|
+
return this.linkedWidthNode ? Math.max(this.linkedWidthNode.view.minimumWidth, this.view.minimumWidth) : this.view.minimumWidth;
|
|
495
|
+
}
|
|
496
|
+
get maximumWidth() {
|
|
497
|
+
return this.linkedWidthNode ? Math.min(this.linkedWidthNode.view.maximumWidth, this.view.maximumWidth) : this.view.maximumWidth;
|
|
498
|
+
}
|
|
499
|
+
get minimumHeight() {
|
|
500
|
+
return this.linkedHeightNode ? Math.max(this.linkedHeightNode.view.minimumHeight, this.view.minimumHeight) : this.view.minimumHeight;
|
|
501
|
+
}
|
|
502
|
+
get maximumHeight() {
|
|
503
|
+
return this.linkedHeightNode ? Math.min(this.linkedHeightNode.view.maximumHeight, this.view.maximumHeight) : this.view.maximumHeight;
|
|
504
|
+
}
|
|
505
|
+
get minimumSize() {
|
|
506
|
+
return this.orientation === 1 ? this.minimumHeight : this.minimumWidth;
|
|
507
|
+
}
|
|
508
|
+
get maximumSize() {
|
|
509
|
+
return this.orientation === 1 ? this.maximumHeight : this.maximumWidth;
|
|
510
|
+
}
|
|
511
|
+
get priority() {
|
|
512
|
+
return this.view.priority;
|
|
513
|
+
}
|
|
514
|
+
get proportionalLayout() {
|
|
515
|
+
return this.view.proportionalLayout ?? true;
|
|
516
|
+
}
|
|
517
|
+
get snap() {
|
|
518
|
+
return this.view.snap;
|
|
519
|
+
}
|
|
520
|
+
get minimumOrthogonalSize() {
|
|
521
|
+
return this.orientation === 1 ? this.minimumWidth : this.minimumHeight;
|
|
522
|
+
}
|
|
523
|
+
get maximumOrthogonalSize() {
|
|
524
|
+
return this.orientation === 1 ? this.maximumWidth : this.maximumHeight;
|
|
525
|
+
}
|
|
526
|
+
get boundarySashes() { return this._boundarySashes; }
|
|
527
|
+
set boundarySashes(boundarySashes) {
|
|
528
|
+
this._boundarySashes = boundarySashes;
|
|
529
|
+
this.view.setBoundarySashes?.(toAbsoluteBoundarySashes(boundarySashes, this.orientation));
|
|
530
|
+
}
|
|
531
|
+
layout(size, offset, ctx) {
|
|
532
|
+
if (!this.layoutController.isLayoutEnabled) {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (typeof ctx === 'undefined') {
|
|
536
|
+
throw new Error('Invalid state');
|
|
537
|
+
}
|
|
538
|
+
this._size = size;
|
|
539
|
+
this._orthogonalSize = ctx.orthogonalSize;
|
|
540
|
+
this.absoluteOffset = ctx.absoluteOffset + offset;
|
|
541
|
+
this.absoluteOrthogonalOffset = ctx.absoluteOrthogonalOffset;
|
|
542
|
+
this._layout(this.width, this.height, this.top, this.left);
|
|
543
|
+
}
|
|
544
|
+
_layout(width, height, top, left) {
|
|
545
|
+
if (this.cachedWidth === width && this.cachedHeight === height && this.cachedTop === top && this.cachedLeft === left) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
this.cachedWidth = width;
|
|
549
|
+
this.cachedHeight = height;
|
|
550
|
+
this.cachedTop = top;
|
|
551
|
+
this.cachedLeft = left;
|
|
552
|
+
this.view.layout(width, height, top, left);
|
|
553
|
+
}
|
|
554
|
+
setVisible(visible) {
|
|
555
|
+
this.view.setVisible?.(visible);
|
|
556
|
+
}
|
|
557
|
+
dispose() {
|
|
558
|
+
this.disposables.dispose();
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function flipNode(node, size, orthogonalSize) {
|
|
562
|
+
if (node instanceof BranchNode) {
|
|
563
|
+
const result = ( new BranchNode(
|
|
564
|
+
orthogonal(node.orientation),
|
|
565
|
+
node.layoutController,
|
|
566
|
+
node.styles,
|
|
567
|
+
node.splitviewProportionalLayout,
|
|
568
|
+
size,
|
|
569
|
+
orthogonalSize,
|
|
570
|
+
node.edgeSnapping
|
|
571
|
+
));
|
|
572
|
+
let totalSize = 0;
|
|
573
|
+
for (let i = node.children.length - 1; i >= 0; i--) {
|
|
574
|
+
const child = node.children[i];
|
|
575
|
+
const childSize = child instanceof BranchNode ? child.orthogonalSize : child.size;
|
|
576
|
+
let newSize = node.size === 0 ? 0 : Math.round((size * childSize) / node.size);
|
|
577
|
+
totalSize += newSize;
|
|
578
|
+
if (i === 0) {
|
|
579
|
+
newSize += size - totalSize;
|
|
580
|
+
}
|
|
581
|
+
result.addChild(flipNode(child, orthogonalSize, newSize), newSize, 0, true);
|
|
582
|
+
}
|
|
583
|
+
node.dispose();
|
|
584
|
+
return result;
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
const result = ( new LeafNode(
|
|
588
|
+
node.view,
|
|
589
|
+
orthogonal(node.orientation),
|
|
590
|
+
node.layoutController,
|
|
591
|
+
orthogonalSize
|
|
592
|
+
));
|
|
593
|
+
node.dispose();
|
|
594
|
+
return result;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
class GridView {
|
|
598
|
+
get root() { return this._root; }
|
|
599
|
+
set root(root) {
|
|
600
|
+
const oldRoot = this._root;
|
|
601
|
+
if (oldRoot) {
|
|
602
|
+
this.element.removeChild(oldRoot.element);
|
|
603
|
+
oldRoot.dispose();
|
|
604
|
+
}
|
|
605
|
+
this._root = root;
|
|
606
|
+
this.element.appendChild(root.element);
|
|
607
|
+
this.onDidSashResetRelay.input = root.onDidSashReset;
|
|
608
|
+
this._onDidChange.input = ( Event.map(root.onDidChange, () => undefined));
|
|
609
|
+
this._onDidScroll.input = root.onDidScroll;
|
|
610
|
+
}
|
|
611
|
+
get width() { return this.root.width; }
|
|
612
|
+
get height() { return this.root.height; }
|
|
613
|
+
get minimumWidth() { return this.root.minimumWidth; }
|
|
614
|
+
get minimumHeight() { return this.root.minimumHeight; }
|
|
615
|
+
get maximumWidth() { return this.root.maximumHeight; }
|
|
616
|
+
get maximumHeight() { return this.root.maximumHeight; }
|
|
617
|
+
get orientation() { return this._root.orientation; }
|
|
618
|
+
get boundarySashes() { return this._boundarySashes; }
|
|
619
|
+
set orientation(orientation) {
|
|
620
|
+
if (this._root.orientation === orientation) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
const { size, orthogonalSize, absoluteOffset, absoluteOrthogonalOffset } = this._root;
|
|
624
|
+
this.root = flipNode(this._root, orthogonalSize, size);
|
|
625
|
+
this.root.layout(size, 0, { orthogonalSize, absoluteOffset: absoluteOrthogonalOffset, absoluteOrthogonalOffset: absoluteOffset, absoluteSize: size, absoluteOrthogonalSize: orthogonalSize });
|
|
626
|
+
this.boundarySashes = this.boundarySashes;
|
|
627
|
+
}
|
|
628
|
+
set boundarySashes(boundarySashes) {
|
|
629
|
+
this._boundarySashes = boundarySashes;
|
|
630
|
+
this.root.boundarySashes = fromAbsoluteBoundarySashes(boundarySashes, this.orientation);
|
|
631
|
+
}
|
|
632
|
+
set edgeSnapping(edgeSnapping) {
|
|
633
|
+
this.root.edgeSnapping = edgeSnapping;
|
|
634
|
+
}
|
|
635
|
+
constructor(options = {}) {
|
|
636
|
+
this.onDidSashResetRelay = ( new Relay());
|
|
637
|
+
this._onDidScroll = ( new Relay());
|
|
638
|
+
this._onDidChange = ( new Relay());
|
|
639
|
+
this._boundarySashes = {};
|
|
640
|
+
this.disposable2x2 = Disposable.None;
|
|
641
|
+
this.onDidSashReset = this.onDidSashResetRelay.event;
|
|
642
|
+
this.onDidScroll = this._onDidScroll.event;
|
|
643
|
+
this.onDidChange = this._onDidChange.event;
|
|
644
|
+
this.maximizedNode = undefined;
|
|
645
|
+
this._onDidChangeViewMaximized = ( new Emitter());
|
|
646
|
+
this.onDidChangeViewMaximized = this._onDidChangeViewMaximized.event;
|
|
647
|
+
this.element = $('.monaco-grid-view');
|
|
648
|
+
this.styles = options.styles || defaultStyles;
|
|
649
|
+
this.proportionalLayout = typeof options.proportionalLayout !== 'undefined' ? !!options.proportionalLayout : true;
|
|
650
|
+
this.layoutController = ( new LayoutController(false));
|
|
651
|
+
this.root = ( new BranchNode(
|
|
652
|
+
0 ,
|
|
653
|
+
this.layoutController,
|
|
654
|
+
this.styles,
|
|
655
|
+
this.proportionalLayout
|
|
656
|
+
));
|
|
657
|
+
}
|
|
658
|
+
style(styles) {
|
|
659
|
+
this.styles = styles;
|
|
660
|
+
this.root.style(styles);
|
|
661
|
+
}
|
|
662
|
+
layout(width, height, top = 0, left = 0) {
|
|
663
|
+
this.layoutController.isLayoutEnabled = true;
|
|
664
|
+
const [size, orthogonalSize, offset, orthogonalOffset] = this.root.orientation === 1 ? [height, width, top, left] : [width, height, left, top];
|
|
665
|
+
this.root.layout(size, 0, { orthogonalSize, absoluteOffset: offset, absoluteOrthogonalOffset: orthogonalOffset, absoluteSize: size, absoluteOrthogonalSize: orthogonalSize });
|
|
666
|
+
}
|
|
667
|
+
addView(view, size, location) {
|
|
668
|
+
if (this.hasMaximizedView()) {
|
|
669
|
+
this.exitMaximizedView();
|
|
670
|
+
}
|
|
671
|
+
this.disposable2x2.dispose();
|
|
672
|
+
this.disposable2x2 = Disposable.None;
|
|
673
|
+
const [rest, index] = tail2(location);
|
|
674
|
+
const [pathToParent, parent] = this.getNode(rest);
|
|
675
|
+
if (parent instanceof BranchNode) {
|
|
676
|
+
const node = ( new LeafNode(
|
|
677
|
+
view,
|
|
678
|
+
orthogonal(parent.orientation),
|
|
679
|
+
this.layoutController,
|
|
680
|
+
parent.orthogonalSize
|
|
681
|
+
));
|
|
682
|
+
try {
|
|
683
|
+
parent.addChild(node, size, index);
|
|
684
|
+
}
|
|
685
|
+
catch (err) {
|
|
686
|
+
node.dispose();
|
|
687
|
+
throw err;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
else {
|
|
691
|
+
const [, grandParent] = tail2(pathToParent);
|
|
692
|
+
const [, parentIndex] = tail2(rest);
|
|
693
|
+
let newSiblingSize = 0;
|
|
694
|
+
const newSiblingCachedVisibleSize = grandParent.getChildCachedVisibleSize(parentIndex);
|
|
695
|
+
if (typeof newSiblingCachedVisibleSize === 'number') {
|
|
696
|
+
newSiblingSize = Sizing.Invisible(newSiblingCachedVisibleSize);
|
|
697
|
+
}
|
|
698
|
+
const oldChild = grandParent.removeChild(parentIndex);
|
|
699
|
+
oldChild.dispose();
|
|
700
|
+
const newParent = ( new BranchNode(
|
|
701
|
+
parent.orientation,
|
|
702
|
+
parent.layoutController,
|
|
703
|
+
this.styles,
|
|
704
|
+
this.proportionalLayout,
|
|
705
|
+
parent.size,
|
|
706
|
+
parent.orthogonalSize,
|
|
707
|
+
grandParent.edgeSnapping
|
|
708
|
+
));
|
|
709
|
+
grandParent.addChild(newParent, parent.size, parentIndex);
|
|
710
|
+
const newSibling = ( new LeafNode(parent.view, grandParent.orientation, this.layoutController, parent.size));
|
|
711
|
+
newParent.addChild(newSibling, newSiblingSize, 0);
|
|
712
|
+
if (typeof size !== 'number' && size.type === 'split') {
|
|
713
|
+
size = Sizing.Split(0);
|
|
714
|
+
}
|
|
715
|
+
const node = ( new LeafNode(view, grandParent.orientation, this.layoutController, parent.size));
|
|
716
|
+
newParent.addChild(node, size, index);
|
|
717
|
+
}
|
|
718
|
+
this.trySet2x2();
|
|
719
|
+
}
|
|
720
|
+
removeView(location, sizing) {
|
|
721
|
+
if (this.hasMaximizedView()) {
|
|
722
|
+
this.exitMaximizedView();
|
|
723
|
+
}
|
|
724
|
+
this.disposable2x2.dispose();
|
|
725
|
+
this.disposable2x2 = Disposable.None;
|
|
726
|
+
const [rest, index] = tail2(location);
|
|
727
|
+
const [pathToParent, parent] = this.getNode(rest);
|
|
728
|
+
if (!(parent instanceof BranchNode)) {
|
|
729
|
+
throw new Error('Invalid location');
|
|
730
|
+
}
|
|
731
|
+
const node = parent.children[index];
|
|
732
|
+
if (!(node instanceof LeafNode)) {
|
|
733
|
+
throw new Error('Invalid location');
|
|
734
|
+
}
|
|
735
|
+
parent.removeChild(index, sizing);
|
|
736
|
+
node.dispose();
|
|
737
|
+
if (parent.children.length === 0) {
|
|
738
|
+
throw new Error('Invalid grid state');
|
|
739
|
+
}
|
|
740
|
+
if (parent.children.length > 1) {
|
|
741
|
+
this.trySet2x2();
|
|
742
|
+
return node.view;
|
|
743
|
+
}
|
|
744
|
+
if (pathToParent.length === 0) {
|
|
745
|
+
const sibling = parent.children[0];
|
|
746
|
+
if (sibling instanceof LeafNode) {
|
|
747
|
+
return node.view;
|
|
748
|
+
}
|
|
749
|
+
parent.removeChild(0);
|
|
750
|
+
parent.dispose();
|
|
751
|
+
this.root = sibling;
|
|
752
|
+
this.boundarySashes = this.boundarySashes;
|
|
753
|
+
this.trySet2x2();
|
|
754
|
+
return node.view;
|
|
755
|
+
}
|
|
756
|
+
const [, grandParent] = tail2(pathToParent);
|
|
757
|
+
const [, parentIndex] = tail2(rest);
|
|
758
|
+
const isSiblingVisible = parent.isChildVisible(0);
|
|
759
|
+
const sibling = parent.removeChild(0);
|
|
760
|
+
const sizes = ( grandParent.children.map((_, i) => grandParent.getChildSize(i)));
|
|
761
|
+
grandParent.removeChild(parentIndex, sizing);
|
|
762
|
+
parent.dispose();
|
|
763
|
+
if (sibling instanceof BranchNode) {
|
|
764
|
+
sizes.splice(parentIndex, 1, ...( sibling.children.map(c => c.size)));
|
|
765
|
+
const siblingChildren = sibling.removeAllChildren();
|
|
766
|
+
for (let i = 0; i < siblingChildren.length; i++) {
|
|
767
|
+
grandParent.addChild(siblingChildren[i], siblingChildren[i].size, parentIndex + i);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
else {
|
|
771
|
+
const newSibling = ( new LeafNode(
|
|
772
|
+
sibling.view,
|
|
773
|
+
orthogonal(sibling.orientation),
|
|
774
|
+
this.layoutController,
|
|
775
|
+
sibling.size
|
|
776
|
+
));
|
|
777
|
+
const sizing = isSiblingVisible ? sibling.orthogonalSize : Sizing.Invisible(sibling.orthogonalSize);
|
|
778
|
+
grandParent.addChild(newSibling, sizing, parentIndex);
|
|
779
|
+
}
|
|
780
|
+
sibling.dispose();
|
|
781
|
+
for (let i = 0; i < sizes.length; i++) {
|
|
782
|
+
grandParent.resizeChild(i, sizes[i]);
|
|
783
|
+
}
|
|
784
|
+
this.trySet2x2();
|
|
785
|
+
return node.view;
|
|
786
|
+
}
|
|
787
|
+
moveView(parentLocation, from, to) {
|
|
788
|
+
if (this.hasMaximizedView()) {
|
|
789
|
+
this.exitMaximizedView();
|
|
790
|
+
}
|
|
791
|
+
const [, parent] = this.getNode(parentLocation);
|
|
792
|
+
if (!(parent instanceof BranchNode)) {
|
|
793
|
+
throw new Error('Invalid location');
|
|
794
|
+
}
|
|
795
|
+
parent.moveChild(from, to);
|
|
796
|
+
this.trySet2x2();
|
|
797
|
+
}
|
|
798
|
+
swapViews(from, to) {
|
|
799
|
+
if (this.hasMaximizedView()) {
|
|
800
|
+
this.exitMaximizedView();
|
|
801
|
+
}
|
|
802
|
+
const [fromRest, fromIndex] = tail2(from);
|
|
803
|
+
const [, fromParent] = this.getNode(fromRest);
|
|
804
|
+
if (!(fromParent instanceof BranchNode)) {
|
|
805
|
+
throw new Error('Invalid from location');
|
|
806
|
+
}
|
|
807
|
+
const fromSize = fromParent.getChildSize(fromIndex);
|
|
808
|
+
const fromNode = fromParent.children[fromIndex];
|
|
809
|
+
if (!(fromNode instanceof LeafNode)) {
|
|
810
|
+
throw new Error('Invalid from location');
|
|
811
|
+
}
|
|
812
|
+
const [toRest, toIndex] = tail2(to);
|
|
813
|
+
const [, toParent] = this.getNode(toRest);
|
|
814
|
+
if (!(toParent instanceof BranchNode)) {
|
|
815
|
+
throw new Error('Invalid to location');
|
|
816
|
+
}
|
|
817
|
+
const toSize = toParent.getChildSize(toIndex);
|
|
818
|
+
const toNode = toParent.children[toIndex];
|
|
819
|
+
if (!(toNode instanceof LeafNode)) {
|
|
820
|
+
throw new Error('Invalid to location');
|
|
821
|
+
}
|
|
822
|
+
if (fromParent === toParent) {
|
|
823
|
+
fromParent.swapChildren(fromIndex, toIndex);
|
|
824
|
+
}
|
|
825
|
+
else {
|
|
826
|
+
fromParent.removeChild(fromIndex);
|
|
827
|
+
toParent.removeChild(toIndex);
|
|
828
|
+
fromParent.addChild(toNode, fromSize, fromIndex);
|
|
829
|
+
toParent.addChild(fromNode, toSize, toIndex);
|
|
830
|
+
}
|
|
831
|
+
this.trySet2x2();
|
|
832
|
+
}
|
|
833
|
+
resizeView(location, size) {
|
|
834
|
+
if (this.hasMaximizedView()) {
|
|
835
|
+
this.exitMaximizedView();
|
|
836
|
+
}
|
|
837
|
+
const [rest, index] = tail2(location);
|
|
838
|
+
const [pathToParent, parent] = this.getNode(rest);
|
|
839
|
+
if (!(parent instanceof BranchNode)) {
|
|
840
|
+
throw new Error('Invalid location');
|
|
841
|
+
}
|
|
842
|
+
if (!size.width && !size.height) {
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
const [parentSize, grandParentSize] = parent.orientation === 1 ? [size.width, size.height] : [size.height, size.width];
|
|
846
|
+
if (typeof grandParentSize === 'number' && pathToParent.length > 0) {
|
|
847
|
+
const [, grandParent] = tail2(pathToParent);
|
|
848
|
+
const [, parentIndex] = tail2(rest);
|
|
849
|
+
grandParent.resizeChild(parentIndex, grandParentSize);
|
|
850
|
+
}
|
|
851
|
+
if (typeof parentSize === 'number') {
|
|
852
|
+
parent.resizeChild(index, parentSize);
|
|
853
|
+
}
|
|
854
|
+
this.trySet2x2();
|
|
855
|
+
}
|
|
856
|
+
getViewSize(location) {
|
|
857
|
+
if (!location) {
|
|
858
|
+
return { width: this.root.width, height: this.root.height };
|
|
859
|
+
}
|
|
860
|
+
const [, node] = this.getNode(location);
|
|
861
|
+
return { width: node.width, height: node.height };
|
|
862
|
+
}
|
|
863
|
+
getViewCachedVisibleSize(location) {
|
|
864
|
+
const [rest, index] = tail2(location);
|
|
865
|
+
const [, parent] = this.getNode(rest);
|
|
866
|
+
if (!(parent instanceof BranchNode)) {
|
|
867
|
+
throw new Error('Invalid location');
|
|
868
|
+
}
|
|
869
|
+
return parent.getChildCachedVisibleSize(index);
|
|
870
|
+
}
|
|
871
|
+
expandView(location) {
|
|
872
|
+
if (this.hasMaximizedView()) {
|
|
873
|
+
this.exitMaximizedView();
|
|
874
|
+
}
|
|
875
|
+
const [ancestors, node] = this.getNode(location);
|
|
876
|
+
if (!(node instanceof LeafNode)) {
|
|
877
|
+
throw new Error('Invalid location');
|
|
878
|
+
}
|
|
879
|
+
for (let i = 0; i < ancestors.length; i++) {
|
|
880
|
+
ancestors[i].resizeChild(location[i], Number.POSITIVE_INFINITY);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
isViewExpanded(location) {
|
|
884
|
+
if (this.hasMaximizedView()) {
|
|
885
|
+
return false;
|
|
886
|
+
}
|
|
887
|
+
const [ancestors, node] = this.getNode(location);
|
|
888
|
+
if (!(node instanceof LeafNode)) {
|
|
889
|
+
throw new Error('Invalid location');
|
|
890
|
+
}
|
|
891
|
+
for (let i = 0; i < ancestors.length; i++) {
|
|
892
|
+
if (!ancestors[i].isChildExpanded(location[i])) {
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
return true;
|
|
897
|
+
}
|
|
898
|
+
maximizeView(location) {
|
|
899
|
+
const [, nodeToMaximize] = this.getNode(location);
|
|
900
|
+
if (!(nodeToMaximize instanceof LeafNode)) {
|
|
901
|
+
throw new Error('Location is not a LeafNode');
|
|
902
|
+
}
|
|
903
|
+
if (this.maximizedNode === nodeToMaximize) {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
if (this.hasMaximizedView()) {
|
|
907
|
+
this.exitMaximizedView();
|
|
908
|
+
}
|
|
909
|
+
function hideAllViewsBut(parent, exclude) {
|
|
910
|
+
for (let i = 0; i < parent.children.length; i++) {
|
|
911
|
+
const child = parent.children[i];
|
|
912
|
+
if (child instanceof LeafNode) {
|
|
913
|
+
if (child !== exclude) {
|
|
914
|
+
parent.setChildVisible(i, false);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
hideAllViewsBut(child, exclude);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
hideAllViewsBut(this.root, nodeToMaximize);
|
|
923
|
+
this.maximizedNode = nodeToMaximize;
|
|
924
|
+
this._onDidChangeViewMaximized.fire(true);
|
|
925
|
+
}
|
|
926
|
+
exitMaximizedView() {
|
|
927
|
+
if (!this.maximizedNode) {
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
this.maximizedNode = undefined;
|
|
931
|
+
function showViewsInReverseOrder(parent) {
|
|
932
|
+
for (let index = parent.children.length - 1; index >= 0; index--) {
|
|
933
|
+
const child = parent.children[index];
|
|
934
|
+
if (child instanceof LeafNode) {
|
|
935
|
+
parent.setChildVisible(index, true);
|
|
936
|
+
}
|
|
937
|
+
else {
|
|
938
|
+
showViewsInReverseOrder(child);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
showViewsInReverseOrder(this.root);
|
|
943
|
+
this._onDidChangeViewMaximized.fire(false);
|
|
944
|
+
}
|
|
945
|
+
hasMaximizedView() {
|
|
946
|
+
return this.maximizedNode !== undefined;
|
|
947
|
+
}
|
|
948
|
+
isViewMaximized(location) {
|
|
949
|
+
const [, node] = this.getNode(location);
|
|
950
|
+
if (!(node instanceof LeafNode)) {
|
|
951
|
+
throw new Error('Location is not a LeafNode');
|
|
952
|
+
}
|
|
953
|
+
return node === this.maximizedNode;
|
|
954
|
+
}
|
|
955
|
+
distributeViewSizes(location) {
|
|
956
|
+
if (this.hasMaximizedView()) {
|
|
957
|
+
this.exitMaximizedView();
|
|
958
|
+
}
|
|
959
|
+
if (!location) {
|
|
960
|
+
this.root.distributeViewSizes(true);
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
const [, node] = this.getNode(location);
|
|
964
|
+
if (!(node instanceof BranchNode)) {
|
|
965
|
+
throw new Error('Invalid location');
|
|
966
|
+
}
|
|
967
|
+
node.distributeViewSizes();
|
|
968
|
+
this.trySet2x2();
|
|
969
|
+
}
|
|
970
|
+
isViewVisible(location) {
|
|
971
|
+
const [rest, index] = tail2(location);
|
|
972
|
+
const [, parent] = this.getNode(rest);
|
|
973
|
+
if (!(parent instanceof BranchNode)) {
|
|
974
|
+
throw new Error('Invalid from location');
|
|
975
|
+
}
|
|
976
|
+
return parent.isChildVisible(index);
|
|
977
|
+
}
|
|
978
|
+
setViewVisible(location, visible) {
|
|
979
|
+
if (this.hasMaximizedView()) {
|
|
980
|
+
this.exitMaximizedView();
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
const [rest, index] = tail2(location);
|
|
984
|
+
const [, parent] = this.getNode(rest);
|
|
985
|
+
if (!(parent instanceof BranchNode)) {
|
|
986
|
+
throw new Error('Invalid from location');
|
|
987
|
+
}
|
|
988
|
+
parent.setChildVisible(index, visible);
|
|
989
|
+
}
|
|
990
|
+
getView(location) {
|
|
991
|
+
const node = location ? this.getNode(location)[1] : this._root;
|
|
992
|
+
return this._getViews(node, this.orientation);
|
|
993
|
+
}
|
|
994
|
+
static deserialize(json, deserializer, options = {}) {
|
|
995
|
+
if (typeof json.orientation !== 'number') {
|
|
996
|
+
throw new Error('Invalid JSON: \'orientation\' property must be a number.');
|
|
997
|
+
}
|
|
998
|
+
else if (typeof json.width !== 'number') {
|
|
999
|
+
throw new Error('Invalid JSON: \'width\' property must be a number.');
|
|
1000
|
+
}
|
|
1001
|
+
else if (typeof json.height !== 'number') {
|
|
1002
|
+
throw new Error('Invalid JSON: \'height\' property must be a number.');
|
|
1003
|
+
}
|
|
1004
|
+
else if (json.root?.type !== 'branch') {
|
|
1005
|
+
throw new Error('Invalid JSON: \'root\' property must have \'type\' value of branch.');
|
|
1006
|
+
}
|
|
1007
|
+
const orientation = json.orientation;
|
|
1008
|
+
const height = json.height;
|
|
1009
|
+
const result = ( new GridView(options));
|
|
1010
|
+
result._deserialize(json.root, orientation, deserializer, height);
|
|
1011
|
+
return result;
|
|
1012
|
+
}
|
|
1013
|
+
_deserialize(root, orientation, deserializer, orthogonalSize) {
|
|
1014
|
+
this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
|
|
1015
|
+
}
|
|
1016
|
+
_deserializeNode(node, orientation, deserializer, orthogonalSize) {
|
|
1017
|
+
let result;
|
|
1018
|
+
if (node.type === 'branch') {
|
|
1019
|
+
const serializedChildren = node.data;
|
|
1020
|
+
const children = ( serializedChildren.map(serializedChild => {
|
|
1021
|
+
return {
|
|
1022
|
+
node: this._deserializeNode(serializedChild, orthogonal(orientation), deserializer, node.size),
|
|
1023
|
+
visible: serializedChild.visible
|
|
1024
|
+
};
|
|
1025
|
+
}));
|
|
1026
|
+
result = ( new BranchNode(
|
|
1027
|
+
orientation,
|
|
1028
|
+
this.layoutController,
|
|
1029
|
+
this.styles,
|
|
1030
|
+
this.proportionalLayout,
|
|
1031
|
+
node.size,
|
|
1032
|
+
orthogonalSize,
|
|
1033
|
+
undefined,
|
|
1034
|
+
children
|
|
1035
|
+
));
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
result = ( new LeafNode(
|
|
1039
|
+
deserializer.fromJSON(node.data),
|
|
1040
|
+
orientation,
|
|
1041
|
+
this.layoutController,
|
|
1042
|
+
orthogonalSize,
|
|
1043
|
+
node.size
|
|
1044
|
+
));
|
|
1045
|
+
if (node.maximized && !this.maximizedNode) {
|
|
1046
|
+
this.maximizedNode = result;
|
|
1047
|
+
this._onDidChangeViewMaximized.fire(true);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
return result;
|
|
1051
|
+
}
|
|
1052
|
+
_getViews(node, orientation, cachedVisibleSize) {
|
|
1053
|
+
const box = { top: node.top, left: node.left, width: node.width, height: node.height };
|
|
1054
|
+
if (node instanceof LeafNode) {
|
|
1055
|
+
return { view: node.view, box, cachedVisibleSize, maximized: this.maximizedNode === node };
|
|
1056
|
+
}
|
|
1057
|
+
const children = [];
|
|
1058
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
1059
|
+
const child = node.children[i];
|
|
1060
|
+
const cachedVisibleSize = node.getChildCachedVisibleSize(i);
|
|
1061
|
+
children.push(this._getViews(child, orthogonal(orientation), cachedVisibleSize));
|
|
1062
|
+
}
|
|
1063
|
+
return { children, box };
|
|
1064
|
+
}
|
|
1065
|
+
getNode(location, node = this.root, path = []) {
|
|
1066
|
+
if (location.length === 0) {
|
|
1067
|
+
return [path, node];
|
|
1068
|
+
}
|
|
1069
|
+
if (!(node instanceof BranchNode)) {
|
|
1070
|
+
throw new Error('Invalid location');
|
|
1071
|
+
}
|
|
1072
|
+
const [index, ...rest] = location;
|
|
1073
|
+
if (index < 0 || index >= node.children.length) {
|
|
1074
|
+
throw new Error('Invalid location');
|
|
1075
|
+
}
|
|
1076
|
+
const child = node.children[index];
|
|
1077
|
+
path.push(node);
|
|
1078
|
+
return this.getNode(rest, child, path);
|
|
1079
|
+
}
|
|
1080
|
+
trySet2x2() {
|
|
1081
|
+
this.disposable2x2.dispose();
|
|
1082
|
+
this.disposable2x2 = Disposable.None;
|
|
1083
|
+
if (this.root.children.length !== 2) {
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
const [first, second] = this.root.children;
|
|
1087
|
+
if (!(first instanceof BranchNode) || !(second instanceof BranchNode)) {
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
this.disposable2x2 = first.trySet2x2(second);
|
|
1091
|
+
}
|
|
1092
|
+
getViewMap(map, node) {
|
|
1093
|
+
if (!node) {
|
|
1094
|
+
node = this.root;
|
|
1095
|
+
}
|
|
1096
|
+
if (node instanceof BranchNode) {
|
|
1097
|
+
node.children.forEach(child => this.getViewMap(map, child));
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
1100
|
+
map.set(node.view, node.element);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
dispose() {
|
|
1104
|
+
this.onDidSashResetRelay.dispose();
|
|
1105
|
+
this.root.dispose();
|
|
1106
|
+
this.element.parentElement?.removeChild(this.element);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
export { GridView, Sizing, orthogonal };
|