From 74aa49a29312151c85a9c64d34021a0e0f68fa05 Mon Sep 17 00:00:00 2001 From: Sanders Lauture Date: Thu, 3 Nov 2016 17:35:06 -0400 Subject: [PATCH] Fixes and cleanup Fix bug where activity bar would be visible on startup even if it was set to be hidden Fix bug where settings would not reflect activity bar visibility --- src/vs/code/electron-main/menus.ts | 4 ++-- .../browser/actions/toggleActivityBarVisibility.ts | 2 +- src/vs/workbench/browser/layout.ts | 11 ++++++++++- .../workbench/electron-browser/main.contribution.ts | 2 +- src/vs/workbench/electron-browser/workbench.ts | 5 ++++- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/vs/code/electron-main/menus.ts b/src/vs/code/electron-main/menus.ts index 59f4767dc13..6847cad723c 100644 --- a/src/vs/code/electron-main/menus.ts +++ b/src/vs/code/electron-main/menus.ts @@ -558,9 +558,9 @@ export class VSCodeMenu { let activityBarLabel: string; if (this.currentActivityBarVisible) { - activityBarLabel = 'Show Activity Bar'; + activityBarLabel = nls.localize({ key: 'miHideActivityBar', comment: ['&& denotes a mnemonic'] }, "&&Hide Activity Bar"); } else { - activityBarLabel = 'Hide Activity Bar'; + activityBarLabel = nls.localize({ key: 'miShowActivityBar', comment: ['&& denotes a mnemonic'] }, "&&Show Activity Bar"); } const toggleActivtyBar = this.createMenuItem(activityBarLabel, 'workbench.action.toggleActivityBarVisibility'); diff --git a/src/vs/workbench/browser/actions/toggleActivityBarVisibility.ts b/src/vs/workbench/browser/actions/toggleActivityBarVisibility.ts index 66ccce4edab..6968f8efce8 100644 --- a/src/vs/workbench/browser/actions/toggleActivityBarVisibility.ts +++ b/src/vs/workbench/browser/actions/toggleActivityBarVisibility.ts @@ -19,7 +19,7 @@ export class ToggleActivityBarVisibilityAction extends Action { public static ID = 'workbench.action.toggleActivityBarVisibility'; public static LABEL = nls.localize('toggleActivityBar', "Toggle Activity Bar Visibility"); - private static activityBarVisibleKey = 'workbench.activitybar.visible'; + private static activityBarVisibleKey = 'workbench.activityBar.visible'; constructor( id: string, diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index 99db9c76426..f034303e5e7 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -59,6 +59,7 @@ export interface ILayoutOptions { */ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontalSashLayoutProvider { + private static activityBarWidthSettingsKey = 'workbench.activityBar.width'; private static sashXWidthSettingsKey = 'workbench.sidebar.width'; private static sashYHeightSettingsKey = 'workbench.panel.height'; @@ -76,6 +77,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal private workbenchSize: Dimension; private sashX: Sash; private sashY: Sash; + private activityBarWidth: number; private startSidebarWidth: number; private sidebarWidth: number; private sidebarHeight: number; @@ -129,6 +131,8 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal orientation: Orientation.HORIZONTAL }); + let isActivityBarHidden = this.partService.isActivityBarHidden(); + this.activityBarWidth = isActivityBarHidden ? 0 : this.storageService.getInteger(WorkbenchLayout.activityBarWidthSettingsKey, StorageScope.GLOBAL, 50); this.sidebarWidth = this.storageService.getInteger(WorkbenchLayout.sashXWidthSettingsKey, StorageScope.GLOBAL, -1); this.panelHeight = this.storageService.getInteger(WorkbenchLayout.sashYHeightSettingsKey, StorageScope.GLOBAL, 0); @@ -168,7 +172,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal if (newSashWidth + HIDE_SIDEBAR_WIDTH_THRESHOLD < this.computedStyles.sidebar.minWidth) { let dragCompensation = DEFAULT_MIN_SIDEBAR_PART_WIDTH - HIDE_SIDEBAR_WIDTH_THRESHOLD; this.partService.setSideBarHidden(true); - startX = (sidebarPosition === Position.LEFT) ? Math.max(this.computedStyles.activitybar.minWidth, e.currentX - dragCompensation) : Math.min(e.currentX + dragCompensation, this.workbenchSize.width - this.computedStyles.activitybar.minWidth); + startX = (sidebarPosition === Position.LEFT) ? Math.max(this.activityBarWidth, e.currentX - dragCompensation) : Math.min(e.currentX + dragCompensation, this.workbenchSize.width - this.activityBarWidth); this.sidebarWidth = this.startSidebarWidth; // when restoring sidebar, restore to the sidebar width we started from } @@ -444,6 +448,11 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal panelDimension.height = Math.max(DEFAULT_MIN_PANEL_PART_HEIGHT, panelDimension.height); } + if (!isActivityBarHidden) { + this.activityBarWidth = activityBarSize.width; + this.storageService.store(WorkbenchLayout.activityBarWidthSettingsKey, this.activityBarWidth, StorageScope.GLOBAL); + } + if (!isSidebarHidden) { this.sidebarWidth = sidebarSize.width; this.storageService.store(WorkbenchLayout.sashXWidthSettingsKey, this.sidebarWidth, StorageScope.GLOBAL); diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index f175a5be4ba..5334588791d 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -121,7 +121,7 @@ configurationRegistry.registerConfiguration({ 'default': true, 'description': nls.localize('statusBarVisibility', "Controls the visibility of the status bar at the bottom of the workbench.") }, - 'workbench.activitybar.visible': { + 'workbench.activityBar.visible': { 'type': 'boolean', 'default': true, 'description': nls.localize('activityBarVisibility', "Controls the visibility of the activity bar on the left side of the workbench.") diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 27cc69bdced..ecd0b6c9eca 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -113,7 +113,7 @@ export class Workbench implements IPartService { private static sidebarPositionConfigurationKey = 'workbench.sideBar.location'; private static statusbarVisibleConfigurationKey = 'workbench.statusBar.visible'; - private static activityBarVisibleConfigurationKey = 'workbench.activitybar.visible'; + private static activityBarVisibleConfigurationKey = 'workbench.activityBar.visible'; public _serviceBrand: any; @@ -789,6 +789,9 @@ export class Workbench implements IPartService { if (this.panelHidden) { this.workbench.addClass('nopanel'); } + if (this.activityBarHidden) { + this.workbench.addClass('noactivitybar'); + } // Apply no-workspace state as CSS class if (!this.workbenchParams.workspace) { -- GitLab