diff --git a/src/vs/code/electron-main/menus.ts b/src/vs/code/electron-main/menus.ts index 76f3aed0c5b02..b513376b4f42c 100644 --- a/src/vs/code/electron-main/menus.ts +++ b/src/vs/code/electron-main/menus.ts @@ -534,6 +534,7 @@ export class VSCodeMenu { let fullscreen = new MenuItem({ label: mnemonicLabel(nls.localize({ key: 'miToggleFullScreen', comment: ['&& denotes a mnemonic'] }, "Toggle &&Full Screen")), accelerator: this.getAccelerator('workbench.action.toggleFullScreen'), click: () => this.windowsManager.getLastActiveWindow().toggleFullScreen(), enabled: this.windowsManager.getWindowCount() > 0 }); let toggleMenuBar = this.createMenuItem(nls.localize({ key: 'miToggleMenuBar', comment: ['&& denotes a mnemonic'] }, "Toggle Menu &&Bar"), 'workbench.action.toggleMenuBar'); let splitEditor = this.createMenuItem(nls.localize({ key: 'miSplitEditor', comment: ['&& denotes a mnemonic'] }, "Split &&Editor"), 'workbench.action.splitEditor'); + let toggleStatusbar = this.createMenuItem(nls.localize({ key: 'miToggleStatusbar', comment: ['&& denotes a mnemonic'] }, "&&Toggle Status Bar"), 'workbench.action.toggleStatusbarVisibility'); let toggleSidebar = this.createMenuItem(nls.localize({ key: 'miToggleSidebar', comment: ['&& denotes a mnemonic'] }, "&&Toggle Side Bar"), 'workbench.action.toggleSidebarVisibility'); let moveSidebar = this.createMenuItem(nls.localize({ key: 'miMoveSidebar', comment: ['&& denotes a mnemonic'] }, "&&Move Side Bar"), 'workbench.action.toggleSidebarPosition'); let togglePanel = this.createMenuItem(nls.localize({ key: 'miTogglePanel', comment: ['&& denotes a mnemonic'] }, "Toggle &&Panel"), 'workbench.action.togglePanel'); @@ -556,6 +557,7 @@ export class VSCodeMenu { platform.isWindows || platform.isLinux ? toggleMenuBar : void 0, __separator__(), splitEditor, + toggleStatusbar, togglePanel, toggleSidebar, moveSidebar, diff --git a/src/vs/workbench/browser/actions/toggleStatusbarVisibility.ts b/src/vs/workbench/browser/actions/toggleStatusbarVisibility.ts new file mode 100644 index 0000000000000..114d7e9f66fd7 --- /dev/null +++ b/src/vs/workbench/browser/actions/toggleStatusbarVisibility.ts @@ -0,0 +1,35 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import {TPromise} from 'vs/base/common/winjs.base'; +import nls = require('vs/nls'); +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'; + +const ID = 'workbench.action.toggleStatusbarVisibility'; +const LABEL = nls.localize('toggleStatusbar', "Toggle Status Bar Visibility"); + +export class ToggleStatusbarVisibilityAction extends Action { + + constructor(id: string, label: string, @IPartService private partService: IPartService) { + super(id, label); + + this.enabled = !!this.partService; + } + + public run(): TPromise { + let hideStatusbar = !this.partService.isStatusBarHidden(); + this.partService.setStatusBarHidden(hideStatusbar); + + return TPromise.as(null); + } +} + +let registry = Registry.as(Extensions.WorkbenchActions); +registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleStatusbarVisibilityAction, ID, LABEL), 'View: Toggle Status Bar Visibility', nls.localize('view', "View")); diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index 877689dba5b1d..a3bb1d58944f1 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -183,6 +183,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal this.sashY.addListener2('change', (e: ISashEvent) => { let doLayout = false; let isPanelHidden = this.partService.isPanelHidden(); + let isStatusbarHidden = this.partService.isStatusBarHidden(); let newSashHeight = this.startPanelHeight - (e.currentY - startY); // Panel visible @@ -191,7 +192,8 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal if (newSashHeight + HIDE_PANEL_HEIGHT_THRESHOLD < this.computedStyles.panel.minHeight) { let dragCompensation = DEFAULT_MIN_PANEL_PART_HEIGHT - HIDE_PANEL_HEIGHT_THRESHOLD; this.partService.setPanelHidden(true); - startY = Math.min(this.sidebarHeight - this.computedStyles.statusbar.height, e.currentY + dragCompensation); + let statusbarHeight = isStatusbarHidden ? 0 : this.computedStyles.statusbar.height; + startY = Math.min(this.sidebarHeight - statusbarHeight, e.currentY + dragCompensation); this.panelHeight = this.startPanelHeight; // when restoring panel, restore to the panel height we started from } @@ -317,6 +319,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal const isSidebarHidden = this.partService.isSideBarHidden(); const isPanelHidden = this.partService.isPanelHidden(); const sidebarPosition = this.partService.getSideBarPosition(); + const isStatusbarHidden = this.partService.isStatusBarHidden(); // Sidebar let sidebarWidth: number; @@ -328,8 +331,13 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal sidebarWidth = this.workbenchSize.width / 5; this.sidebarWidth = sidebarWidth; } + let statusbarHeight = isStatusbarHidden ? 0 : this.computedStyles.statusbar.height; + if (this.statusbar) { + let statusbarStyle = this.statusbar.getContainer().getHTMLElement().style; + statusbarStyle.display = isStatusbarHidden ? 'none' : null; + } - this.sidebarHeight = this.workbenchSize.height - this.computedStyles.statusbar.height; + this.sidebarHeight = this.workbenchSize.height - statusbarHeight; let sidebarSize = new Dimension(sidebarWidth, this.sidebarHeight); // Activity Bar @@ -411,16 +419,16 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal this.editor.getContainer().size(editorSize.width, editorSize.height); this.panel.getContainer().size(panelDimension.width, panelDimension.height); - const editorBottom = this.computedStyles.statusbar.height + panelDimension.height; + const editorBottom = statusbarHeight + panelDimension.height; if (isSidebarHidden) { this.editor.getContainer().position(0, editorSize.remainderRight, editorBottom, editorSize.remainderLeft); - this.panel.getContainer().position(editorDimension.height, editorSize.remainderRight, this.computedStyles.statusbar.height, editorSize.remainderLeft); + this.panel.getContainer().position(editorDimension.height, editorSize.remainderRight, statusbarHeight, editorSize.remainderLeft); } else if (sidebarPosition === Position.LEFT) { this.editor.getContainer().position(0, 0, editorBottom, sidebarSize.width + activityBarSize.width); - this.panel.getContainer().position(editorDimension.height, 0, this.computedStyles.statusbar.height, sidebarSize.width + activityBarSize.width); + this.panel.getContainer().position(editorDimension.height, 0, statusbarHeight, sidebarSize.width + activityBarSize.width); } else { this.editor.getContainer().position(0, sidebarSize.width, editorBottom, 0); - this.panel.getContainer().position(editorDimension.height, sidebarSize.width, this.computedStyles.statusbar.height, 0); + this.panel.getContainer().position(editorDimension.height, sidebarSize.width, statusbarHeight, 0); } // Activity Bar Part @@ -444,7 +452,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal // Statusbar Part if (this.statusbar) { - this.statusbar.getContainer().position(this.workbenchSize.height - this.computedStyles.statusbar.height); + this.statusbar.getContainer().position(this.workbenchSize.height - statusbarHeight); } // Quick open diff --git a/src/vs/workbench/browser/workbench.ts b/src/vs/workbench/browser/workbench.ts index 4494f44b94b7d..e1a12c267143b 100644 --- a/src/vs/workbench/browser/workbench.ts +++ b/src/vs/workbench/browser/workbench.ts @@ -88,6 +88,7 @@ export interface IWorkbenchCallbacks { export class Workbench implements IPartService { private static sidebarPositionSettingKey = 'workbench.sidebar.position'; + private static statusbarHiddenSettingKey = 'workbench.statusbar.hidden'; private static sidebarHiddenSettingKey = 'workbench.sidebar.hidden'; private static panelHiddenSettingKey = 'workbench.panel.hidden'; @@ -115,6 +116,7 @@ export class Workbench implements IPartService { private creationPromise: TPromise; private creationPromiseComplete: ValueCallback; private sideBarHidden: boolean; + private statusBarHidden: boolean; private sideBarPosition: Position; private panelHidden: boolean; private editorBackgroundDelayer: Delayer; @@ -410,6 +412,8 @@ export class Workbench implements IPartService { } private initSettings(): void { + // Statusbar visibility + this.statusBarHidden = this.storageService.getBoolean(Workbench.statusbarHiddenSettingKey, StorageScope.WORKSPACE, false); // Sidebar visibility this.sideBarHidden = this.storageService.getBoolean(Workbench.sidebarHiddenSettingKey, StorageScope.WORKSPACE, false); @@ -491,10 +495,27 @@ export class Workbench implements IPartService { if (part === Parts.PANEL_PART) { return !this.panelHidden; } + if (part === Parts.STATUSBAR_PART) { + return !this.statusBarHidden; + } return true; // any other part cannot be hidden } + public isStatusBarHidden(): boolean { + return this.statusBarHidden; + } + + public setStatusBarHidden(hidden: boolean, skipLayout?: boolean): void { + this.statusBarHidden = hidden; + + // Layout + if (!skipLayout) { + this.workbenchLayout.layout(true); + } + this.storageService.store(Workbench.statusbarHiddenSettingKey, hidden ? 'true' : 'false', StorageScope.WORKSPACE); + } + public isSideBarHidden(): boolean { return this.sideBarHidden; } diff --git a/src/vs/workbench/services/part/common/partService.ts b/src/vs/workbench/services/part/common/partService.ts index fa247ef87ba5c..a16cb256b3a3c 100644 --- a/src/vs/workbench/services/part/common/partService.ts +++ b/src/vs/workbench/services/part/common/partService.ts @@ -50,6 +50,16 @@ export interface IPartService { */ isVisible(part: Parts): boolean; + /** + * Checks if the statusbar is currently hidden or not + */ + isStatusBarHidden(): boolean; + + /** + * Set statusbar hidden or not + */ + setStatusBarHidden(hidden: boolean): void; + /** * Checks if the sidebar is currently hidden or not */ diff --git a/src/vs/workbench/test/common/servicesTestUtils.ts b/src/vs/workbench/test/common/servicesTestUtils.ts index 535c19b56e992..9355d8702e2ab 100644 --- a/src/vs/workbench/test/common/servicesTestUtils.ts +++ b/src/vs/workbench/test/common/servicesTestUtils.ts @@ -144,6 +144,12 @@ export class TestPartService implements PartService.IPartService { return true; } + public isStatusBarHidden(): boolean { + return false; + } + + public setStatusBarHidden(hidden: boolean): void { } + public isSideBarHidden(): boolean { return false; } diff --git a/src/vs/workbench/workbench.main.js b/src/vs/workbench/workbench.main.js index 7500b7252fa7c..21ff9c50f691e 100644 --- a/src/vs/workbench/workbench.main.js +++ b/src/vs/workbench/workbench.main.js @@ -24,6 +24,7 @@ define([ 'vs/languages/languages.main', // Workbench + 'vs/workbench/browser/actions/toggleStatusbarVisibility', 'vs/workbench/browser/actions/toggleSidebarVisibility', 'vs/workbench/browser/actions/toggleSidebarPosition', 'vs/workbench/browser/actions/openSettings',