提交 a7ad8306 编写于 作者: S SteVen Batten

adding toggle editor

上级 a608c35e
......@@ -210,6 +210,32 @@ MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, {
// --- Toggle Sidebar Visibility
export class ToggleEditorVisibilityAction extends Action {
static readonly ID = 'workbench.action.toggleEditorVisibility';
static readonly LABEL = nls.localize('toggleEditor', "Toggle Editor Area");
constructor(
id: string,
label: string,
@IPartService private readonly partService: IPartService
) {
super(id, label);
this.enabled = !!this.partService;
}
run(): Promise<any> {
const hideEditor = this.partService.isVisible(Parts.EDITOR_PART);
this.partService.setEditorHidden(hideEditor);
return Promise.resolve(null);
}
}
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleEditorVisibilityAction, ToggleEditorVisibilityAction.ID, ToggleEditorVisibilityAction.LABEL), 'View: Toggle Editor Area Visibility', viewCategory);
export class ToggleSidebarVisibilityAction extends Action {
static readonly ID = 'workbench.action.toggleSidebarVisibility';
......
......@@ -228,6 +228,7 @@ export class Workbench extends Disposable implements IPartService {
private notificationsCenter: NotificationsCenter;
private notificationsToasts: NotificationsToasts;
private editorHidden: boolean;
private sideBarHidden: boolean;
private statusBarHidden: boolean;
private activityBarHidden: boolean;
......@@ -911,6 +912,9 @@ export class Workbench extends Disposable implements IPartService {
private initSettings(): void {
// Editor visiblity
this.editorHidden = false;
// Sidebar visibility
this.sideBarHidden = this.storageService.getBoolean(Workbench.sidebarHiddenStorageKey, StorageScope.WORKSPACE, this.contextService.getWorkbenchState() === WorkbenchState.EMPTY);
......@@ -1403,27 +1407,6 @@ export class Workbench extends Disposable implements IPartService {
let statusBarInGrid = this.gridHasView(this.statusbarPartView);
let titlebarInGrid = this.gridHasView(this.titlebarPartView);
// Hide parts
if (this.panelHidden) {
this.panelPartView.hide();
}
if (this.statusBarHidden) {
this.statusbarPartView.hide();
}
if (!this.isVisible(Parts.TITLEBAR_PART)) {
this.titlebarPartView.hide();
}
if (this.activityBarHidden) {
this.activitybarPartView.hide();
}
if (this.sideBarHidden) {
this.sidebarPartView.hide();
}
// Add parts to grid
if (!statusBarInGrid) {
this.workbenchGrid.addView(this.statusbarPartView, Sizing.Split, this.editorPartView, Direction.Down);
......@@ -1450,7 +1433,36 @@ export class Workbench extends Disposable implements IPartService {
panelInGrid = true;
}
// Hide parts
if (this.panelHidden) {
this.panelPartView.hide();
}
if (this.statusBarHidden) {
this.statusbarPartView.hide();
}
if (!this.isVisible(Parts.TITLEBAR_PART)) {
this.titlebarPartView.hide();
}
if (this.activityBarHidden) {
this.activitybarPartView.hide();
}
if (this.sideBarHidden) {
this.sidebarPartView.hide();
}
if (this.editorHidden) {
this.editorPartView.hide();
}
// Show visible parts
if (!this.editorHidden) {
this.editorPartView.show();
}
if (!this.statusBarHidden) {
this.statusbarPartView.show();
}
......@@ -1553,6 +1565,23 @@ export class Workbench extends Disposable implements IPartService {
}
}
setEditorHidden(hidden: boolean, skipLayout?: boolean): void {
if (!(this.workbenchGrid instanceof Grid)) {
return;
}
this.editorHidden = hidden;
// The editor and the panel cannot be hidden at the same time
if (this.editorHidden && this.panelHidden) {
this.setPanelHidden(false, true);
}
if (!skipLayout) {
this.layout();
}
}
setSideBarHidden(hidden: boolean, skipLayout?: boolean): void {
this.sideBarHidden = hidden;
this.sideBarVisibleContext.set(!hidden);
......@@ -1639,6 +1668,11 @@ export class Workbench extends Disposable implements IPartService {
this.storageService.remove(Workbench.panelHiddenStorageKey, StorageScope.WORKSPACE);
}
// The editor and panel cannot be hiddne at the same time
if (hidden && this.editorHidden) {
this.setEditorHidden(false, true);
}
// Layout
if (!skipLayout) {
if (this.workbenchGrid instanceof Grid) {
......
......@@ -86,6 +86,12 @@ export interface IPartService {
*/
getTitleBarOffset(): number;
/**
*
* Set editor area hidden or not
*/
setEditorHidden(hidden: boolean): void;
/**
* Set sidebar hidden or not
*/
......
......@@ -492,6 +492,8 @@ export class TestPartService implements IPartService {
return false;
}
public setEditorHidden(_hidden: boolean): Promise<void> { return Promise.resolve(null); }
public setSideBarHidden(_hidden: boolean): Promise<void> { return Promise.resolve(null); }
public isPanelHidden(): boolean {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册