Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/layout/browser/layoutService.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { IDimension } from '../../../base/browser/dom.js';
7
import { Event } from '../../../base/common/event.js';
8
import { DisposableStore } from '../../../base/common/lifecycle.js';
9
import { createDecorator } from '../../instantiation/common/instantiation.js';
10
11
export const ILayoutService = createDecorator<ILayoutService>('layoutService');
12
13
export interface ILayoutOffsetInfo {
14
15
/**
16
* Generic top offset
17
*/
18
readonly top: number;
19
20
/**
21
* Quick pick specific top offset.
22
*/
23
readonly quickPickTop: number;
24
}
25
26
export interface ILayoutService {
27
28
readonly _serviceBrand: undefined;
29
30
/**
31
* An event that is emitted when the main container is layed out.
32
*/
33
readonly onDidLayoutMainContainer: Event<IDimension>;
34
35
/**
36
* An event that is emitted when any container is layed out.
37
*/
38
readonly onDidLayoutContainer: Event<{ readonly container: HTMLElement; readonly dimension: IDimension }>;
39
40
/**
41
* An event that is emitted when the active container is layed out.
42
*/
43
readonly onDidLayoutActiveContainer: Event<IDimension>;
44
45
/**
46
* An event that is emitted when a new container is added. This
47
* can happen in multi-window environments.
48
*/
49
readonly onDidAddContainer: Event<{ readonly container: HTMLElement; readonly disposables: DisposableStore }>;
50
51
/**
52
* An event that is emitted when the active container changes.
53
*/
54
readonly onDidChangeActiveContainer: Event<void>;
55
56
/**
57
* The dimensions of the main container.
58
*/
59
readonly mainContainerDimension: IDimension;
60
61
/**
62
* The dimensions of the active container.
63
*/
64
readonly activeContainerDimension: IDimension;
65
66
/**
67
* Main container of the application.
68
*/
69
readonly mainContainer: HTMLElement;
70
71
/**
72
* Active container of the application. When multiple windows are opened, will return
73
* the container of the active, focused window.
74
*/
75
readonly activeContainer: HTMLElement;
76
77
/**
78
* All the containers of the application. There can be one container per window.
79
*/
80
readonly containers: Iterable<HTMLElement>;
81
82
/**
83
* Get the container for the given window.
84
*/
85
getContainer(window: Window): HTMLElement;
86
87
/**
88
* Ensures that the styles for the container associated
89
* to the window have loaded. For the main window, this
90
* will resolve instantly, but for floating windows, this
91
* will resolve once the styles have been loaded and helps
92
* for when certain layout assumptions are made.
93
*/
94
whenContainerStylesLoaded(window: Window): Promise<void> | undefined;
95
96
/**
97
* An offset to use for positioning elements inside the main container.
98
*/
99
readonly mainContainerOffset: ILayoutOffsetInfo;
100
101
/**
102
* An offset to use for positioning elements inside the container.
103
*/
104
readonly activeContainerOffset: ILayoutOffsetInfo;
105
106
/**
107
* Focus the primary component of the active container.
108
*/
109
focus(): void;
110
}
111
112