提交 9a7594e8 编写于 作者: T tamas.kiss

Option to hide the status bar implemented

This fixes #6356
上级 8bee53a9
......@@ -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,
......
/*---------------------------------------------------------------------------------------------
* 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<any> {
let hideStatusbar = !this.partService.isStatusBarHidden();
this.partService.setStatusBarHidden(hideStatusbar);
return TPromise.as(null);
}
}
let registry = <IWorkbenchActionRegistry>Registry.as(Extensions.WorkbenchActions);
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleStatusbarVisibilityAction, ID, LABEL), 'View: Toggle Status Bar Visibility', nls.localize('view', "View"));
......@@ -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
......
......@@ -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<boolean>;
private creationPromiseComplete: ValueCallback;
private sideBarHidden: boolean;
private statusBarHidden: boolean;
private sideBarPosition: Position;
private panelHidden: boolean;
private editorBackgroundDelayer: Delayer<void>;
......@@ -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;
}
......
......@@ -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
*/
......
......@@ -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;
}
......
......@@ -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',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册