diff --git a/src/vs/workbench/browser/actions/toggleActivityBarVisibility.ts b/src/vs/workbench/browser/actions/toggleActivityBarVisibility.ts index 6968f8efce8..df97ee7f83c 100644 --- a/src/vs/workbench/browser/actions/toggleActivityBarVisibility.ts +++ b/src/vs/workbench/browser/actions/toggleActivityBarVisibility.ts @@ -12,7 +12,7 @@ import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actionRegistry'; import { IMessageService, Severity } from 'vs/platform/message/common/message'; import { IConfigurationEditingService, ConfigurationTarget } from 'vs/workbench/services/configuration/common/configurationEditing'; -import { IPartService } from 'vs/workbench/services/part/common/partService'; +import { IPartService, Parts } from 'vs/workbench/services/part/common/partService'; export class ToggleActivityBarVisibilityAction extends Action { @@ -34,7 +34,7 @@ export class ToggleActivityBarVisibilityAction extends Action { } public run(): TPromise { - const visibility = !this.partService.isActivityBarHidden(); + const visibility = this.partService.isVisible(Parts.ACTIVITYBAR_PART); const newVisibilityValue = !visibility; this.configurationEditingService.writeConfiguration(ConfigurationTarget.USER, { key: ToggleActivityBarVisibilityAction.activityBarVisibleKey, value: newVisibilityValue }).then(null, error => { diff --git a/src/vs/workbench/browser/actions/toggleSidebarVisibility.ts b/src/vs/workbench/browser/actions/toggleSidebarVisibility.ts index 93db0f5ba89..e31853b1973 100644 --- a/src/vs/workbench/browser/actions/toggleSidebarVisibility.ts +++ b/src/vs/workbench/browser/actions/toggleSidebarVisibility.ts @@ -10,7 +10,7 @@ import { Registry } from 'vs/platform/platform'; import { Action } from 'vs/base/common/actions'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actionRegistry'; -import { IPartService } from 'vs/workbench/services/part/common/partService'; +import { IPartService, Parts } from 'vs/workbench/services/part/common/partService'; import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; export class ToggleSidebarVisibilityAction extends Action { @@ -29,7 +29,7 @@ export class ToggleSidebarVisibilityAction extends Action { } public run(): TPromise { - const hideSidebar = !this.partService.isSideBarHidden(); + const hideSidebar = this.partService.isVisible(Parts.SIDEBAR_PART); this.partService.setSideBarHidden(hideSidebar); return TPromise.as(null); diff --git a/src/vs/workbench/browser/actions/toggleStatusbarVisibility.ts b/src/vs/workbench/browser/actions/toggleStatusbarVisibility.ts index a01cca3e394..40c20df23c3 100644 --- a/src/vs/workbench/browser/actions/toggleStatusbarVisibility.ts +++ b/src/vs/workbench/browser/actions/toggleStatusbarVisibility.ts @@ -12,7 +12,7 @@ import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actionRegistry'; import { IMessageService, Severity } from 'vs/platform/message/common/message'; import { IConfigurationEditingService, ConfigurationTarget } from 'vs/workbench/services/configuration/common/configurationEditing'; -import { IPartService } from 'vs/workbench/services/part/common/partService'; +import { IPartService, Parts } from 'vs/workbench/services/part/common/partService'; export class ToggleStatusbarVisibilityAction extends Action { @@ -34,7 +34,7 @@ export class ToggleStatusbarVisibilityAction extends Action { } public run(): TPromise { - const visibility = !this.partService.isStatusBarHidden(); + const visibility = this.partService.isVisible(Parts.STATUSBAR_PART); const newVisibilityValue = !visibility; this.configurationEditingService.writeConfiguration(ConfigurationTarget.USER, { key: ToggleStatusbarVisibilityAction.statusbarVisibleKey, value: newVisibilityValue }).then(null, error => { diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index c00c5e1559e..f3fe115dd45 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -144,11 +144,11 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal this.sashX.addListener2('change', (e: ISashEvent) => { let doLayout = false; let sidebarPosition = this.partService.getSideBarPosition(); - let isSidebarHidden = this.partService.isSideBarHidden(); + let isSidebarVisible = this.partService.isVisible(Parts.SIDEBAR_PART); let newSashWidth = (sidebarPosition === Position.LEFT) ? this.startSidebarWidth + e.currentX - startX : this.startSidebarWidth - e.currentX + startX; // Sidebar visible - if (!isSidebarHidden) { + if (isSidebarVisible) { // Automatically hide side bar when a certain threshold is met if (newSashWidth + HIDE_SIDEBAR_WIDTH_THRESHOLD < this.computedStyles.sidebar.minWidth) { @@ -182,11 +182,11 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal this.sashY.addListener2('change', (e: ISashEvent) => { let doLayout = false; - let isPanelHidden = this.partService.isPanelHidden(); + let isPanelVisible = this.partService.isVisible(Parts.PANEL_PART); let newSashHeight = this.startPanelHeight - (e.currentY - startY); // Panel visible - if (!isPanelHidden) { + if (isPanelVisible) { // Automatically hide panel when a certain threshold is met if (newSashHeight + HIDE_PANEL_HEIGHT_THRESHOLD < this.computedStyles.panel.minHeight) { @@ -334,7 +334,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal this.workbenchSize = this.getWorkbenchArea(); - const isActivityBarHidden = this.partService.isActivityBarHidden(); + const isActivityBarHidden = !this.partService.isVisible(Parts.ACTIVITYBAR_PART); const isTitlebarHidden = !this.partService.isVisible(Parts.TITLEBAR_PART); const isPanelHidden = !this.partService.isVisible(Parts.PANEL_PART); const isStatusbarHidden = !this.partService.isVisible(Parts.STATUSBAR_PART); @@ -541,14 +541,14 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal } public getVerticalSashLeft(sash: Sash): number { - let isSidebarHidden = this.partService.isSideBarHidden(); + let isSidebarVisible = this.partService.isVisible(Parts.SIDEBAR_PART); let sidebarPosition = this.partService.getSideBarPosition(); if (sidebarPosition === Position.LEFT) { - return !isSidebarHidden ? this.sidebarWidth + this.activitybarWidth : this.activitybarWidth; + return isSidebarVisible ? this.sidebarWidth + this.activitybarWidth : this.activitybarWidth; } - return !isSidebarHidden ? this.workbenchSize.width - this.sidebarWidth - this.activitybarWidth : this.workbenchSize.width - this.activitybarWidth; + return isSidebarVisible ? this.workbenchSize.width - this.sidebarWidth - this.activitybarWidth : this.workbenchSize.width - this.activitybarWidth; } public getVerticalSashHeight(sash: Sash): number { @@ -556,7 +556,8 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal } public getHorizontalSashTop(sash: Sash): number { - return 2 + (this.partService.isPanelHidden() ? this.sidebarHeight + this.titlebarHeight : this.sidebarHeight - this.panelHeight + this.titlebarHeight); // Horizontal sash should be a bit lower than the editor area, thus add 2px #5524 + // Horizontal sash should be a bit lower than the editor area, thus add 2px #5524 + return 2 + (this.partService.isVisible(Parts.PANEL_PART) ? this.sidebarHeight - this.panelHeight + this.titlebarHeight : this.sidebarHeight + this.titlebarHeight); } public getHorizontalSashLeft(sash: Sash): number { diff --git a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts index b6bfd38b323..3f8b9c6a6ff 100644 --- a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts +++ b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts @@ -18,7 +18,7 @@ import { Part } from 'vs/workbench/browser/part'; import { ActivityAction, ActivityActionItem } from 'vs/workbench/browser/parts/activitybar/activityAction'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IActivityService, IBadge } from 'vs/workbench/services/activity/common/activityService'; -import { IPartService } from 'vs/workbench/services/part/common/partService'; +import { IPartService, Parts } from 'vs/workbench/services/part/common/partService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; @@ -187,11 +187,11 @@ class ViewletActivityAction extends ActivityAction { } this.lastRun = now; - const sideBarHidden = this.partService.isSideBarHidden(); + const sideBarVisible = this.partService.isVisible(Parts.SIDEBAR_PART); const activeViewlet = this.viewletService.getActiveViewlet(); // Hide sidebar if selected viewlet already visible - if (!sideBarHidden && activeViewlet && activeViewlet.getId() === this.viewlet.id) { + if (sideBarVisible && activeViewlet && activeViewlet.getId() === this.viewlet.id) { this.partService.setSideBarHidden(true); } else { this.viewletService.openViewlet(this.viewlet.id, true).done(null, errors.onUnexpectedError); diff --git a/src/vs/workbench/browser/parts/panel/panelPart.ts b/src/vs/workbench/browser/parts/panel/panelPart.ts index 5e80429e6b6..d9dae9e1403 100644 --- a/src/vs/workbench/browser/parts/panel/panelPart.ts +++ b/src/vs/workbench/browser/parts/panel/panelPart.ts @@ -19,7 +19,7 @@ import { IPanel } from 'vs/workbench/common/panel'; import { CompositePart } from 'vs/workbench/browser/parts/compositePart'; import { Panel, PanelRegistry, Extensions as PanelExtensions } from 'vs/workbench/browser/panel'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; -import { IPartService } from 'vs/workbench/services/part/common/partService'; +import { IPartService, Parts } from 'vs/workbench/services/part/common/partService'; import { IStorageService } from 'vs/platform/storage/common/storage'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IMessageService } from 'vs/platform/message/common/message'; @@ -80,7 +80,7 @@ export class PanelPart extends CompositePart implements IPanelService { } // First check if panel is hidden and show if so - if (this.partService.isPanelHidden()) { + if (!this.partService.isVisible(Parts.PANEL_PART)) { try { this.blockOpeningPanel = true; this.partService.setPanelHidden(false); @@ -137,11 +137,11 @@ export class TogglePanelAction extends ActivityAction { name: string, @IPartService private partService: IPartService ) { - super(id, name, partService.isPanelHidden() ? 'panel' : 'panel expanded'); + super(id, name, partService.isVisible(Parts.PANEL_PART) ? 'panel expanded' : 'panel'); } public run(): TPromise { - this.partService.setPanelHidden(!this.partService.isPanelHidden()); + this.partService.setPanelHidden(this.partService.isVisible(Parts.PANEL_PART)); return TPromise.as(true); } } @@ -163,7 +163,7 @@ class FocusPanelAction extends Action { public run(): TPromise { // Show panel - if (this.partService.isPanelHidden()) { + if (!this.partService.isVisible(Parts.PANEL_PART)) { this.partService.setPanelHidden(false); } diff --git a/src/vs/workbench/browser/parts/sidebar/sidebarPart.ts b/src/vs/workbench/browser/parts/sidebar/sidebarPart.ts index 9747ef46c13..63dfec32019 100644 --- a/src/vs/workbench/browser/parts/sidebar/sidebarPart.ts +++ b/src/vs/workbench/browser/parts/sidebar/sidebarPart.ts @@ -13,7 +13,7 @@ import { Viewlet, ViewletRegistry, Extensions as ViewletExtensions } from 'vs/wo import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actionRegistry'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; -import { IPartService } from 'vs/workbench/services/part/common/partService'; +import { IPartService, Parts } from 'vs/workbench/services/part/common/partService'; import { IViewlet } from 'vs/workbench/common/viewlet'; import { Scope } from 'vs/workbench/browser/actionBarRegistry'; import { IStorageService } from 'vs/platform/storage/common/storage'; @@ -83,7 +83,7 @@ export class SidebarPart extends CompositePart implements ISidebar { } // First check if sidebar is hidden and show if so - if (this.partService.isSideBarHidden()) { + if (!this.partService.isVisible(Parts.SIDEBAR_PART)) { try { this.blockOpeningViewlet = true; this.partService.setSideBarHidden(false); @@ -125,7 +125,7 @@ class FocusSideBarAction extends Action { public run(): TPromise { // Show side bar - if (this.partService.isSideBarHidden()) { + if (!this.partService.isVisible(Parts.SIDEBAR_PART)) { this.partService.setSideBarHidden(false); } diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index d31d414060a..57970234e3a 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -600,7 +600,7 @@ export class Workbench implements IPartService { return true; // any other part cannot be hidden } - public isTitleBarHidden(): boolean { + private isTitleBarHidden(): boolean { return !this.getCustomTitleBarStyle() || browser.isFullscreen(); } @@ -634,10 +634,6 @@ export class Workbench implements IPartService { return null; } - public isStatusBarHidden(): boolean { - return this.statusBarHidden; - } - private setStatusBarHidden(hidden: boolean, skipLayout?: boolean): void { this.statusBarHidden = hidden; @@ -647,10 +643,6 @@ export class Workbench implements IPartService { } } - public isActivityBarHidden(): boolean { - return this.activityBarHidden; - } - public setActivityBarHidden(hidden: boolean, skipLayout?: boolean): void { this.activityBarHidden = hidden; @@ -660,10 +652,6 @@ export class Workbench implements IPartService { } } - public isSideBarHidden(): boolean { - return this.sideBarHidden; - } - public setSideBarHidden(hidden: boolean, skipLayout?: boolean): void { this.sideBarHidden = hidden; @@ -707,10 +695,6 @@ export class Workbench implements IPartService { this.storageService.store(Workbench.sidebarHiddenSettingKey, hidden ? 'true' : 'false', StorageScope.WORKSPACE); } - public isPanelHidden(): boolean { - return this.panelHidden; - } - public setPanelHidden(hidden: boolean, skipLayout?: boolean): void { this.panelHidden = hidden; @@ -866,12 +850,12 @@ export class Workbench implements IPartService { } const newStatusbarHiddenValue = !this.configurationService.lookup(Workbench.statusbarVisibleConfigurationKey).value; - if (newStatusbarHiddenValue !== this.isStatusBarHidden()) { + if (newStatusbarHiddenValue !== this.statusBarHidden) { this.setStatusBarHidden(newStatusbarHiddenValue); } const newActivityBarHiddenValue = !this.configurationService.lookup(Workbench.activityBarVisibleConfigurationKey).value; - if (newActivityBarHiddenValue !== this.isActivityBarHidden()) { + if (newActivityBarHiddenValue !== this.activityBarHidden) { this.setActivityBarHidden(newActivityBarHiddenValue); } } diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index b05807c58bf..53772e45d32 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -47,7 +47,7 @@ import { TaskError, TaskErrors } from 'vs/workbench/parts/tasks/common/taskSyste import { VIEWLET_ID as EXPLORER_VIEWLET_ID } from 'vs/workbench/parts/files/common/files'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; -import { IPartService } from 'vs/workbench/services/part/common/partService'; +import { IPartService, Parts } from 'vs/workbench/services/part/common/partService'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; @@ -674,7 +674,7 @@ export class DebugService implements debug.IDebugService { this.panelService.openPanel(debug.REPL_ID, false).done(undefined, errors.onUnexpectedError); } - if (!this.viewModel.changedWorkbenchViewState && !this.partService.isSideBarHidden()) { + if (!this.viewModel.changedWorkbenchViewState && this.partService.isVisible(Parts.SIDEBAR_PART)) { // We only want to change the workbench view state on the first debug session #5738 and if the side bar is not hidden this.viewModel.changedWorkbenchViewState = true; this.viewletService.openViewlet(debug.VIEWLET_ID); @@ -827,7 +827,7 @@ export class DebugService implements debug.IDebugService { this.inDebugMode.reset(); this.viewModel.setMultiProcessView(false); - if (!this.partService.isSideBarHidden() && this.configurationService.getConfiguration('debug').openExplorerOnEnd) { + if (this.partService.isVisible(Parts.SIDEBAR_PART) && this.configurationService.getConfiguration('debug').openExplorerOnEnd) { this.viewletService.openViewlet(EXPLORER_VIEWLET_ID).done(null, errors.onUnexpectedError); } } diff --git a/src/vs/workbench/services/part/common/partService.ts b/src/vs/workbench/services/part/common/partService.ts index c111a2e8c0c..d7423882c2a 100644 --- a/src/vs/workbench/services/part/common/partService.ts +++ b/src/vs/workbench/services/part/common/partService.ts @@ -67,46 +67,21 @@ export interface IPartService { */ isVisible(part: Parts): boolean; - /** - * Checks if the activity bar is currently hidden or not - */ - isActivityBarHidden(): boolean; - /** * Set activity bar hidden or not */ setActivityBarHidden(hidden: boolean): void; - /** - * Returns iff the custom titlebar part is visible. - */ - isTitleBarHidden(): boolean; - /** * Number of pixels (adjusted for zooming) that the title bar (if visible) pushes down the workbench contents. */ getTitleBarOffset(): number; - /** - * Checks if the statusbar is currently hidden or not - */ - isStatusBarHidden(): boolean; - - /** - * Checks if the sidebar is currently hidden or not - */ - isSideBarHidden(): boolean; - /** * Set sidebar hidden or not */ setSideBarHidden(hidden: boolean): void; - /** - * Checks if the panel part is currently hidden or not - */ - isPanelHidden(): boolean; - /** * Set panel part hidden or not */