Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c (#8525)

* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c

* remove files we don't want

* fix hygiene

* update distro

* update distro

* fix hygiene

* fix strict nulls

* distro

* distro

* fix tests

* fix tests

* add another edit

* fix viewlet icon

* fix azure dialog

* fix some padding

* fix more padding issues
This commit is contained in:
Anthony Dresser
2019-12-04 19:28:22 -08:00
committed by GitHub
parent a8818ab0df
commit f5ce7fb2a5
1507 changed files with 42813 additions and 27370 deletions

View File

@@ -5,7 +5,7 @@
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { Event, Emitter } from 'vs/base/common/event';
import { EventType, addDisposableListener, addClass, removeClass, isAncestor, getClientArea, position, size, Dimension } from 'vs/base/browser/dom';
import { EventType, addDisposableListener, addClass, removeClass, isAncestor, getClientArea, Dimension, toggleClass, position, size } from 'vs/base/browser/dom';
import { onDidChangeFullscreen, isFullscreen } from 'vs/base/browser/browser';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { Registry } from 'vs/platform/registry/common/platform';
@@ -38,6 +38,8 @@ import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
import { coalesce } from 'vs/base/common/arrays';
import { assertIsDefined } from 'vs/base/common/types';
import { INotificationService, NotificationsFilter } from 'vs/platform/notification/common/notification';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { WINDOW_ACTIVE_BORDER, WINDOW_INACTIVE_BORDER } from 'vs/workbench/common/theme';
enum Settings {
ACTIVITYBAR_VISIBLE = 'workbench.activityBar.visible',
@@ -74,7 +76,8 @@ enum Classes {
EDITOR_HIDDEN = 'noeditorarea',
PANEL_HIDDEN = 'nopanel',
STATUSBAR_HIDDEN = 'nostatusbar',
FULLSCREEN = 'fullscreen'
FULLSCREEN = 'fullscreen',
WINDOW_BORDER = 'border'
}
export abstract class Layout extends Disposable implements IWorkbenchLayoutService {
@@ -92,6 +95,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
private readonly _onCenteredLayoutChange: Emitter<boolean> = this._register(new Emitter<boolean>());
readonly onCenteredLayoutChange: Event<boolean> = this._onCenteredLayoutChange.event;
private readonly _onMaximizeChange: Emitter<boolean> = this._register(new Emitter<boolean>());
readonly onMaximizeChange: Event<boolean> = this._onMaximizeChange.event;
private readonly _onPanelPositionChange: Emitter<string> = this._register(new Emitter<string>());
readonly onPanelPositionChange: Event<string> = this._onPanelPositionChange.event;
@@ -135,9 +141,13 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
private contextService!: IWorkspaceContextService;
private backupFileService!: IBackupFileService;
private notificationService!: INotificationService;
private themeService!: IThemeService;
protected readonly state = {
fullscreen: false,
maximized: false,
hasFocus: false,
windowBorder: false,
menuBar: {
visibility: 'default' as MenuBarVisibility,
@@ -204,6 +214,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.contextService = accessor.get(IWorkspaceContextService);
this.storageService = accessor.get(IStorageService);
this.backupFileService = accessor.get(IBackupFileService);
this.themeService = accessor.get(IThemeService);
// Parts
this.editorService = accessor.get(IEditorService);
@@ -257,6 +268,12 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
if ((isWindows || isLinux || isWeb) && getTitleBarStyle(this.configurationService, this.environmentService) === 'custom') {
this._register(this.titleService.onMenubarVisibilityChange(visible => this.onMenubarToggled(visible)));
}
// Theme changes
this._register(this.themeService.onThemeChange(theme => this.updateStyles()));
// Window focus changes
this._register(this.hostService.onDidChangeFocus(e => this.onWindowFocusChanged(e)));
}
private onMenubarToggled(visible: boolean) {
@@ -291,12 +308,23 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
// Propagate to grid
this.workbenchGrid.setViewVisible(this.titleBarPartView, this.isVisible(Parts.TITLEBAR_PART));
this.updateWindowBorder(true);
this.layout(); // handle title bar when fullscreen changes
}
this._onFullscreenChange.fire(this.state.fullscreen);
}
private onWindowFocusChanged(hasFocus: boolean): void {
if (this.state.hasFocus === hasFocus) {
return;
}
this.state.hasFocus = hasFocus;
this.updateWindowBorder();
}
private doUpdateLayoutConfiguration(skipLayout?: boolean): void {
// Sidebar position
@@ -366,6 +394,44 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.layout();
}
private updateWindowBorder(skipLayout: boolean = false) {
if (isWeb || getTitleBarStyle(this.configurationService, this.environmentService) !== 'custom') {
return;
}
const theme = this.themeService.getTheme();
const activeBorder = theme.getColor(WINDOW_ACTIVE_BORDER);
const inactiveBorder = theme.getColor(WINDOW_INACTIVE_BORDER);
let windowBorder = false;
if (!this.state.fullscreen && !this.state.maximized && (activeBorder || inactiveBorder)) {
windowBorder = true;
// If one color is missing, just fallback to the other one
const borderColor = this.state.hasFocus
? activeBorder ?? inactiveBorder
: inactiveBorder ?? activeBorder;
this.container.style.setProperty('--window-border-color', borderColor ? borderColor.toString() : 'transparent');
}
if (windowBorder === this.state.windowBorder) {
return;
}
this.state.windowBorder = windowBorder;
toggleClass(this.container, Classes.WINDOW_BORDER, windowBorder);
if (!skipLayout) {
this.layout();
}
}
private updateStyles() {
this.updateWindowBorder();
}
private initLayoutState(lifecycleService: ILifecycleService, fileService: IFileService): void {
// Fullscreen
@@ -442,6 +508,11 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
// Zen mode enablement
this.state.zenMode.restore = this.storageService.getBoolean(Storage.ZEN_MODE_ENABLED, StorageScope.WORKSPACE, false) && this.configurationService.getValue(Settings.ZEN_MODE_RESTORE);
this.state.hasFocus = this.hostService.hasFocus;
// Window border
this.updateWindowBorder(true);
}
private resolveEditorsToOpen(fileService: IFileService): Promise<IResourceEditor[]> | IResourceEditor[] {
@@ -682,6 +753,13 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
if (config.silentNotifications) {
this.notificationService.setFilter(NotificationsFilter.ERROR);
}
this.state.zenMode.transitionDisposables.add(this.configurationService.onDidChangeConfiguration(c => {
const silentNotificationsKey = 'zenMode.silentNotifications';
if (c.affectsConfiguration(silentNotificationsKey)) {
const filter = this.configurationService.getValue(silentNotificationsKey) ? NotificationsFilter.ERROR : NotificationsFilter.OFF;
this.notificationService.setFilter(filter);
}
}));
if (config.centerLayout) {
this.centerEditorLayout(true, true);
@@ -826,9 +904,13 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
}));
}
getClientArea(): Dimension {
return getClientArea(this.parent);
}
layout(): void {
if (!this.disposed) {
this._dimension = getClientArea(this.parent);
this._dimension = this.getClientArea();
position(this.container, 0, 0, 0, 0, 'relative');
size(this.container, this._dimension.width, this._dimension.height);
@@ -1079,6 +1161,14 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
}
}
hasWindowBorder(): boolean {
return this.state.windowBorder;
}
getWindowBorderRadius(): string | undefined {
return this.state.windowBorder && isMacintosh ? '5px' : undefined;
}
isPanelMaximized(): boolean {
if (!this.workbenchGrid) {
return false;
@@ -1168,8 +1258,23 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this._onPanelPositionChange.fire(positionToString(this.state.panel.position));
}
isWindowMaximized() {
return this.state.maximized;
}
updateWindowMaximizedState(maximized: boolean) {
if (this.state.maximized === maximized) {
return;
}
this.state.maximized = maximized;
this.updateWindowBorder();
this._onMaximizeChange.fire(maximized);
}
private createGridDescriptor(): ISerializedGrid {
const workbenchDimensions = getClientArea(this.parent);
const workbenchDimensions = this.getClientArea();
const width = this.storageService.getNumber(Storage.GRID_WIDTH, StorageScope.GLOBAL, workbenchDimensions.width);
const height = this.storageService.getNumber(Storage.GRID_HEIGHT, StorageScope.GLOBAL, workbenchDimensions.height);
// At some point, we will not fall back to old keys from legacy layout, but for now, let's migrate the keys