提交 d3c7be9f 编写于 作者: I isidor

zenMode: properly get in and out of center mode

fixes #45610
上级 459e4d49
...@@ -26,11 +26,11 @@ class ToggleCenteredLayout extends Action { ...@@ -26,11 +26,11 @@ class ToggleCenteredLayout extends Action {
} }
public run(): TPromise<any> { public run(): TPromise<any> {
this.partService.toggleCenteredEditorLayout(); this.partService.centerEditorLayout(!this.partService.isEditorLayoutCentered());
return TPromise.as(null); return TPromise.as(null);
} }
} }
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions); const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleCenteredLayout, ToggleCenteredLayout.ID, ToggleCenteredLayout.LABEL), 'View: Toggle Centered Layout', nls.localize('view', "View")); registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleCenteredLayout, ToggleCenteredLayout.ID, ToggleCenteredLayout.LABEL), 'View: Toggle Centered Layout', nls.localize('view', "View"));
\ No newline at end of file
...@@ -1319,13 +1319,11 @@ export class Workbench implements IPartService { ...@@ -1319,13 +1319,11 @@ 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 // 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; let toggleFullScreen = false;
// Same goes for the centered editor layout // Same goes for the centered editor layout
let toggleCenteredEditorLayout = false;
if (this.zenMode.active) { if (this.zenMode.active) {
const config = this.configurationService.getValue<IZenModeSettings>('zenMode'); const config = this.configurationService.getValue<IZenModeSettings>('zenMode');
toggleFullScreen = !browser.isFullscreen() && config.fullScreen; toggleFullScreen = !browser.isFullscreen() && config.fullScreen;
this.zenMode.transitionedToFullScreen = toggleFullScreen; this.zenMode.transitionedToFullScreen = toggleFullScreen;
toggleCenteredEditorLayout = !this.isEditorLayoutCentered() && config.centerLayout; this.zenMode.transitionedToCenteredEditorLayout = !this.isEditorLayoutCentered() && config.centerLayout;
this.zenMode.transitionedToCenteredEditorLayout = toggleCenteredEditorLayout;
this.zenMode.wasSideBarVisible = this.isVisible(Parts.SIDEBAR_PART); this.zenMode.wasSideBarVisible = this.isVisible(Parts.SIDEBAR_PART);
this.zenMode.wasPanelVisible = this.isVisible(Parts.PANEL_PART); this.zenMode.wasPanelVisible = this.isVisible(Parts.PANEL_PART);
this.setPanelHidden(true, true).done(void 0, errors.onUnexpectedError); this.setPanelHidden(true, true).done(void 0, errors.onUnexpectedError);
...@@ -1342,14 +1340,20 @@ export class Workbench implements IPartService { ...@@ -1342,14 +1340,20 @@ export class Workbench implements IPartService {
if (config.hideTabs) { if (config.hideTabs) {
this.editorPart.hideTabs(true); this.editorPart.hideTabs(true);
} }
if (config.centerLayout) {
this.centerEditorLayout(true, true);
}
} else { } else {
if (this.zenMode.wasPanelVisible) { if (this.zenMode.wasPanelVisible) {
this.setPanelHidden(false, true).done(void 0, errors.onUnexpectedError); this.setPanelHidden(false, true).done(void 0, errors.onUnexpectedError);
} }
if (this.zenMode.wasSideBarVisible) { if (this.zenMode.wasSideBarVisible) {
this.setSideBarHidden(false, true).done(void 0, errors.onUnexpectedError); this.setSideBarHidden(false, true).done(void 0, errors.onUnexpectedError);
} }
if (this.zenMode.transitionedToCenteredEditorLayout) {
this.centerEditorLayout(false, true);
}
// Status bar and activity bar visibility come from settings -> update their visibility. // Status bar and activity bar visibility come from settings -> update their visibility.
this.onDidUpdateConfiguration(true); this.onDidUpdateConfiguration(true);
...@@ -1360,15 +1364,10 @@ export class Workbench implements IPartService { ...@@ -1360,15 +1364,10 @@ export class Workbench implements IPartService {
} }
toggleFullScreen = this.zenMode.transitionedToFullScreen && browser.isFullscreen(); toggleFullScreen = this.zenMode.transitionedToFullScreen && browser.isFullscreen();
toggleCenteredEditorLayout = this.zenMode.transitionedToCenteredEditorLayout && this.isEditorLayoutCentered();
} }
this.inZenMode.set(this.zenMode.active); this.inZenMode.set(this.zenMode.active);
if (toggleCenteredEditorLayout) {
this.toggleCenteredEditorLayout(true);
}
if (!skipLayout) { if (!skipLayout) {
this.layout(); this.layout();
} }
...@@ -1382,8 +1381,8 @@ export class Workbench implements IPartService { ...@@ -1382,8 +1381,8 @@ export class Workbench implements IPartService {
return this.centeredEditorLayoutActive; return this.centeredEditorLayoutActive;
} }
public toggleCenteredEditorLayout(skipLayout?: boolean): void { public centerEditorLayout(active: boolean, skipLayout?: boolean): void {
this.centeredEditorLayoutActive = !this.centeredEditorLayoutActive; this.centeredEditorLayoutActive = active;
this.storageService.store(Workbench.centeredEditorLayoutActiveStorageKey, this.centeredEditorLayoutActive, StorageScope.GLOBAL); this.storageService.store(Workbench.centeredEditorLayoutActiveStorageKey, this.centeredEditorLayoutActive, StorageScope.GLOBAL);
if (!skipLayout) { if (!skipLayout) {
......
...@@ -135,12 +135,12 @@ export interface IPartService { ...@@ -135,12 +135,12 @@ export interface IPartService {
isEditorLayoutCentered(): boolean; isEditorLayoutCentered(): boolean;
/** /**
* Toggles the workbench in and out of centered editor layout. * Sets the workbench in and out of centered editor layout.
*/ */
toggleCenteredEditorLayout(): void; centerEditorLayout(active: boolean): void;
/** /**
* Resizes currently focused part on main access * Resizes currently focused part on main access
*/ */
resizePart(part: Parts, sizeChange: number): void; resizePart(part: Parts, sizeChange: number): void;
} }
\ No newline at end of file
...@@ -433,7 +433,7 @@ export class TestPartService implements IPartService { ...@@ -433,7 +433,7 @@ export class TestPartService implements IPartService {
public toggleZenMode(): void { } public toggleZenMode(): void { }
public isEditorLayoutCentered(): boolean { return false; } public isEditorLayoutCentered(): boolean { return false; }
public toggleCenteredEditorLayout(): void { } public centerEditorLayout(active: boolean): void { }
public resizePart(part: Parts, sizeChange: number): void { } public resizePart(part: Parts, sizeChange: number): void { }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册