Merge pull request #44116 from SrTobi-Forks/centered-zen

Setting to center the layout when turning on the zen mode
This commit is contained in:
Isidor Nikolic 2018-02-21 13:13:19 +01:00 committed by GitHub
commit 32b28ce90b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View file

@ -408,6 +408,11 @@ configurationRegistry.registerConfiguration({
'default': true,
'description': nls.localize('zenMode.fullScreen', "Controls if turning on Zen Mode also puts the workbench into full screen mode.")
},
'zenMode.centeredLayout': {
'type': 'boolean',
'default': true,
'description': nls.localize('zenMode.centeredLayout', "Controls if turning on Zen Mode also centers the layout.")
},
'zenMode.hideTabs': {
'type': 'boolean',
'default': true,

View file

@ -117,6 +117,7 @@ interface WorkbenchParams {
interface IZenModeSettings {
fullScreen: boolean;
centeredLayout: boolean;
hideTabs: boolean;
hideActivityBar: boolean;
hideStatusBar: boolean;
@ -217,6 +218,7 @@ export class Workbench implements IPartService {
private zenMode: {
active: boolean;
transitionedToFullScreen: boolean;
transitionedToCenteredEditorLayout: boolean;
wasSideBarVisible: boolean;
wasPanelVisible: boolean;
};
@ -668,6 +670,7 @@ export class Workbench implements IPartService {
this.zenMode = {
active: false,
transitionedToFullScreen: false,
transitionedToCenteredEditorLayout: false,
wasSideBarVisible: false,
wasPanelVisible: false
};
@ -1315,10 +1318,14 @@ export class Workbench implements IPartService {
// Check if zen mode transitioned to full screen and if now we are out of zen mode -> we need to go out of full screen
let toggleFullScreen = false;
// Same goes for the centered editor layout
let toggleCenteredEditorLayout = false;
if (this.zenMode.active) {
const config = this.configurationService.getValue<IZenModeSettings>('zenMode');
toggleFullScreen = !browser.isFullscreen() && config.fullScreen;
this.zenMode.transitionedToFullScreen = toggleFullScreen;
toggleCenteredEditorLayout = !this.isEditorLayoutCentered() && config.centeredLayout;
this.zenMode.transitionedToCenteredEditorLayout = toggleCenteredEditorLayout;
this.zenMode.wasSideBarVisible = this.isVisible(Parts.SIDEBAR_PART);
this.zenMode.wasPanelVisible = this.isVisible(Parts.PANEL_PART);
this.setPanelHidden(true, true).done(void 0, errors.onUnexpectedError);
@ -1353,10 +1360,15 @@ export class Workbench implements IPartService {
}
toggleFullScreen = this.zenMode.transitionedToFullScreen && browser.isFullscreen();
toggleCenteredEditorLayout = this.zenMode.transitionedToCenteredEditorLayout && this.isEditorLayoutCentered();
}
this.inZenMode.set(this.zenMode.active);
if (toggleCenteredEditorLayout) {
this.toggleCenteredEditorLayout(true);
}
if (!skipLayout) {
this.layout();
}
@ -1370,11 +1382,13 @@ export class Workbench implements IPartService {
return this.centeredEditorLayoutActive;
}
public toggleCenteredEditorLayout(): void {
public toggleCenteredEditorLayout(skipLayout?: boolean): void {
this.centeredEditorLayoutActive = !this.centeredEditorLayoutActive;
this.storageService.store(Workbench.centeredEditorLayoutActiveStorageKey, this.centeredEditorLayoutActive, StorageScope.GLOBAL);
this.layout();
if (!skipLayout) {
this.layout();
}
}
// Resize requested part along the main axis