From 60b5c439a45fd78c6a67e2c9cd37337d6b698e4e Mon Sep 17 00:00:00 2001 From: SteVen Batten Date: Tue, 18 Jan 2022 16:15:35 -0800 Subject: [PATCH] remove toggle panel alignment setting --- src/vs/workbench/browser/contextkeys.ts | 7 ++++++- src/vs/workbench/browser/layout.ts | 7 ++++++- src/vs/workbench/browser/layoutState.ts | 8 -------- .../workbench/browser/parts/panel/panelActions.ts | 4 ++-- src/vs/workbench/browser/workbench.contribution.ts | 14 -------------- src/vs/workbench/common/panel.ts | 3 ++- .../services/layout/browser/layoutService.ts | 11 +++++++++++ .../test/browser/workbenchTestServices.ts | 4 ++-- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/vs/workbench/browser/contextkeys.ts b/src/vs/workbench/browser/contextkeys.ts index 878df5e5db6..781200500af 100644 --- a/src/vs/workbench/browser/contextkeys.ts +++ b/src/vs/workbench/browser/contextkeys.ts @@ -17,7 +17,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic import { WorkbenchState, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { SideBarVisibleContext } from 'vs/workbench/common/viewlet'; import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService'; -import { PanelMaximizedContext, PanelVisibleContext } from 'vs/workbench/common/panel'; +import { PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext } from 'vs/workbench/common/panel'; import { getRemoteName, getVirtualWorkspaceScheme } from 'vs/platform/remote/common/remoteHosts'; import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService'; import { isNative } from 'vs/base/common/platform'; @@ -83,6 +83,7 @@ export class WorkbenchContextKeysHandler extends Disposable { private sideBarVisibleContext: IContextKey; private editorAreaVisibleContext: IContextKey; private panelVisibleContext: IContextKey; + private panelAlignmentContext: IContextKey; private panelMaximizedContext: IContextKey; private auxiliaryBarVisibleContext: IContextKey; private editorTabsVisibleContext: IContextKey; @@ -201,6 +202,8 @@ export class WorkbenchContextKeysHandler extends Disposable { this.panelVisibleContext.set(this.layoutService.isVisible(Parts.PANEL_PART)); this.panelMaximizedContext = PanelMaximizedContext.bindTo(this.contextKeyService); this.panelMaximizedContext.set(this.layoutService.isPanelMaximized()); + this.panelAlignmentContext = PanelAlignmentContext.bindTo(this.contextKeyService); + this.panelAlignmentContext.set(this.layoutService.getPanelAlignment()); // Auxiliary Bar this.auxiliaryBarVisibleContext = AuxiliaryBarVisibleContext.bindTo(this.contextKeyService); @@ -245,6 +248,8 @@ export class WorkbenchContextKeysHandler extends Disposable { this._register(this.layoutService.onDidChangeFullscreen(fullscreen => this.isFullscreenContext.set(fullscreen))); this._register(this.layoutService.onDidChangeCenteredLayout(centered => this.isCenteredLayoutContext.set(centered))); + this._register(this.layoutService.onDidChangePanelAlignment(alignment => this.panelAlignmentContext.set(alignment))); + this._register(this.paneCompositeService.onDidPaneCompositeClose(() => this.updateSideBarContextKeys())); this._register(this.paneCompositeService.onDidPaneCompositeOpen(() => this.updateSideBarContextKeys())); diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index 6f46aeaa46c..e69477fe22b 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -114,6 +114,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi private readonly _onDidChangeCenteredLayout = this._register(new Emitter()); readonly onDidChangeCenteredLayout = this._onDidChangeCenteredLayout.event; + private readonly _onDidChangePanelAlignment = this._register(new Emitter()); + readonly onDidChangePanelAlignment = this._onDidChangePanelAlignment.event; + private readonly _onDidChangeWindowMaximized = this._register(new Emitter()); readonly onDidChangeWindowMaximized = this._onDidChangeWindowMaximized.event; @@ -1494,6 +1497,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi this.stateModel.setRuntimeValue(LayoutStateKeys.PANEL_ALIGNMENT, alignment); this.adjustPartPositions(this.getSideBarPosition(), alignment); + + this._onDidChangePanelAlignment.fire(alignment); } private setPanelHidden(hidden: boolean, skipLayout?: boolean): void { @@ -1681,7 +1686,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi return this.stateModel.getRuntimeValue(LayoutStateKeys.SIDEBAR_POSITON); } - private getPanelAlignment(): PanelAlignment { + getPanelAlignment(): PanelAlignment { return this.stateModel.getRuntimeValue(LayoutStateKeys.PANEL_ALIGNMENT); } diff --git a/src/vs/workbench/browser/layoutState.ts b/src/vs/workbench/browser/layoutState.ts index 214b45d9c03..7122f1da29a 100644 --- a/src/vs/workbench/browser/layoutState.ts +++ b/src/vs/workbench/browser/layoutState.ts @@ -108,10 +108,6 @@ export class LayoutStateModel extends Disposable { this.setRuntimeValueAndFire(LayoutStateKeys.STATUSBAR_HIDDEN, !this.configurationService.getValue(LegacyWorkbenchLayoutSettings.STATUSBAR_VISIBLE)); } - if (configurationChangeEvent.affectsConfiguration(LegacyWorkbenchLayoutSettings.PANEL_ALIGNMENT)) { - this.setRuntimeValueAndFire(LayoutStateKeys.PANEL_ALIGNMENT, this.configurationService.getValue(LegacyWorkbenchLayoutSettings.PANEL_ALIGNMENT)); - } - if (configurationChangeEvent.affectsConfiguration(LegacyWorkbenchLayoutSettings.SIDEBAR_POSITION)) { this.setRuntimeValueAndFire(LayoutStateKeys.SIDEBAR_POSITON, positionFromString(this.configurationService.getValue(LegacyWorkbenchLayoutSettings.SIDEBAR_POSITION) ?? 'left')); } @@ -127,8 +123,6 @@ export class LayoutStateModel extends Disposable { this.configurationService.updateValue(LegacyWorkbenchLayoutSettings.ACTIVITYBAR_VISIBLE, !value); } else if (key === LayoutStateKeys.STATUSBAR_HIDDEN) { this.configurationService.updateValue(LegacyWorkbenchLayoutSettings.STATUSBAR_VISIBLE, !value); - } else if (key === LayoutStateKeys.PANEL_ALIGNMENT) { - this.configurationService.updateValue(LegacyWorkbenchLayoutSettings.PANEL_ALIGNMENT, value); } else if (key === LayoutStateKeys.SIDEBAR_POSITON) { this.configurationService.updateValue(LegacyWorkbenchLayoutSettings.SIDEBAR_POSITION, positionToString(value as Position)); } @@ -150,7 +144,6 @@ export class LayoutStateModel extends Disposable { // Apply legacy settings this.stateCache.set(LayoutStateKeys.ACTIVITYBAR_HIDDEN.name, !this.configurationService.getValue(LegacyWorkbenchLayoutSettings.ACTIVITYBAR_VISIBLE)); this.stateCache.set(LayoutStateKeys.STATUSBAR_HIDDEN.name, !this.configurationService.getValue(LegacyWorkbenchLayoutSettings.STATUSBAR_VISIBLE)); - this.stateCache.set(LayoutStateKeys.PANEL_ALIGNMENT.name, this.configurationService.getValue(LegacyWorkbenchLayoutSettings.PANEL_ALIGNMENT)); this.stateCache.set(LayoutStateKeys.SIDEBAR_POSITON.name, positionFromString(this.configurationService.getValue(LegacyWorkbenchLayoutSettings.SIDEBAR_POSITION) ?? 'left')); // Set dynamic defaults: part sizing and side bar visibility @@ -260,5 +253,4 @@ enum LegacyWorkbenchLayoutSettings { ACTIVITYBAR_VISIBLE = 'workbench.activityBar.visible', // Deprecated to UI State STATUSBAR_VISIBLE = 'workbench.statusBar.visible', // Deprecated to UI State SIDEBAR_POSITION = 'workbench.sideBar.location', // Deprecated to UI State - PANEL_ALIGNMENT = 'workbench.experimental.panel.alignment', // Deprecated to UI State } diff --git a/src/vs/workbench/browser/parts/panel/panelActions.ts b/src/vs/workbench/browser/parts/panel/panelActions.ts index 3e2bbd66abc..91891fbee02 100644 --- a/src/vs/workbench/browser/parts/panel/panelActions.ts +++ b/src/vs/workbench/browser/parts/panel/panelActions.ts @@ -13,7 +13,7 @@ import { IWorkbenchActionRegistry, Extensions as WorkbenchExtensions, CATEGORIES import { IWorkbenchLayoutService, PanelAlignment, Parts, Position, positionToString } from 'vs/workbench/services/layout/browser/layoutService'; import { ActivityAction, ToggleCompositePinnedAction, ICompositeBar } from 'vs/workbench/browser/parts/compositeBarActions'; import { IActivity } from 'vs/workbench/common/activity'; -import { ActivePanelContext, PanelMaximizedContext, PanelPositionContext, PanelVisibleContext } from 'vs/workbench/common/panel'; +import { ActivePanelContext, PanelAlignmentContext, PanelMaximizedContext, PanelPositionContext, PanelVisibleContext } from 'vs/workbench/common/panel'; import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey'; import { Codicon } from 'vs/base/common/codicons'; import { registerIcon } from 'vs/platform/theme/common/iconRegistry'; @@ -112,7 +112,7 @@ function createPositionPanelActionConfig(id: string, alias: string, label: strin } function createAlignmentPanelActionConfig(id: string, alias: string, label: string, shortLabel: string, alignment: PanelAlignment): PanelActionConfig { - return createPanelActionConfig(id, alias, label, shortLabel, alignment, ContextKeyExpr.notEquals('config.workbench.experimental.panel.alignment', alignment)); + return createPanelActionConfig(id, alias, label, shortLabel, alignment, PanelAlignmentContext.notEqualsTo(alignment)); } diff --git a/src/vs/workbench/browser/workbench.contribution.ts b/src/vs/workbench/browser/workbench.contribution.ts index 3f619452c63..15f7cebe8ff 100644 --- a/src/vs/workbench/browser/workbench.contribution.ts +++ b/src/vs/workbench/browser/workbench.contribution.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import product from 'vs/platform/product/common/product'; import { Registry } from 'vs/platform/registry/common/platform'; import { localize } from 'vs/nls'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry'; @@ -363,19 +362,6 @@ const registry = Registry.as(ConfigurationExtensions.Con 'default': false, 'description': localize('layoutControlEnabled', "Controls whether the layout control button in the custom title bar is enabled."), }, - 'workbench.experimental.panel.alignment': { - 'type': 'string', - 'enum': ['left', 'center', 'right', 'justify'], - 'enumDescriptions': [ - localize('panel.alignment.left', "The panel spans from the far left of the window to the right side of the editor area."), - localize('panel.alignment.center', "The panel spans beneath the editor area."), - localize('panel.alignment.right', "The panel spans from the left side of the editor area to the far right of the window."), - localize('panel.alignment.justify', "The panel spans the full width of the window."), - ], - 'default': 'center', - 'description': localize('panelAlignment', "Controls the alignment of the panel (terminal, debug console, output, problems) and whether or not it spans beneath the side bar and side panel. Note that this setting only takes effect when the panel is positioned at the bottom of the screen."), - 'included': product.quality !== 'stable' - }, } }); diff --git a/src/vs/workbench/common/panel.ts b/src/vs/workbench/common/panel.ts index 2c29fb16de3..db1883df11f 100644 --- a/src/vs/workbench/common/panel.ts +++ b/src/vs/workbench/common/panel.ts @@ -8,6 +8,7 @@ import { RawContextKey } from 'vs/platform/contextkey/common/contextkey'; export const ActivePanelContext = new RawContextKey('activePanel', '', localize('activePanel', "The identifier of the active panel")); export const PanelFocusContext = new RawContextKey('panelFocus', false, localize('panelFocus', "Whether the panel has keyboard focus")); -export const PanelPositionContext = new RawContextKey('panelPosition', 'bottom', localize('panelPosition', "The position of the panel, either 'left', 'right' or 'bottom'")); +export const PanelPositionContext = new RawContextKey('panelPosition', 'bottom', localize('panelPosition', "The position of the panel, always 'bottom'")); +export const PanelAlignmentContext = new RawContextKey('panelAlignment', 'center', localize('panelAlignment', "The alignment of the panel, either 'center', 'left', 'right' or 'justify'")); export const PanelVisibleContext = new RawContextKey('panelVisible', false, localize('panelVisible', "Whether the panel is visible")); export const PanelMaximizedContext = new RawContextKey('panelMaximized', false, localize('panelMaximized', "Whether the panel is maximized")); diff --git a/src/vs/workbench/services/layout/browser/layoutService.ts b/src/vs/workbench/services/layout/browser/layoutService.ts index 10b30b72e08..4120a59a8a2 100644 --- a/src/vs/workbench/services/layout/browser/layoutService.ts +++ b/src/vs/workbench/services/layout/browser/layoutService.ts @@ -99,6 +99,11 @@ export interface IWorkbenchLayoutService extends ILayoutService { */ readonly onDidChangeCenteredLayout: Event; + /** + * Emit when panel alignment changes. + */ + readonly onDidChangePanelAlignment: Event; + /** * Emit when part visibility changes */ @@ -196,6 +201,12 @@ export interface IWorkbenchLayoutService extends ILayoutService { */ toggleMenuBar(): void; + /** + * + * Gets the panel alignement. + */ + getPanelAlignment(): PanelAlignment; + /** * Sets the panel alignment. */ diff --git a/src/vs/workbench/test/browser/workbenchTestServices.ts b/src/vs/workbench/test/browser/workbenchTestServices.ts index 4cfeaac60b0..912f1c875d1 100644 --- a/src/vs/workbench/test/browser/workbenchTestServices.ts +++ b/src/vs/workbench/test/browser/workbenchTestServices.ts @@ -542,7 +542,7 @@ export class TestLayoutService implements IWorkbenchLayoutService { onDidChangeCenteredLayout: Event = Event.None; onDidChangeFullscreen: Event = Event.None; onDidChangeWindowMaximized: Event = Event.None; - onDidChangePanelPosition: Event = Event.None; + onDidChangePanelAlignment: Event = Event.None; onDidChangePartVisibility: Event = Event.None; onDidLayout = Event.None; onDidChangeNotificationsVisibility = Event.None; @@ -576,7 +576,7 @@ export class TestLayoutService implements IWorkbenchLayoutService { getMenubarVisibility(): MenuBarVisibility { throw new Error('not implemented'); } toggleMenuBar(): void { } getSideBarPosition() { return 0; } - getPanelPosition() { return 0; } + getPanelAlignment(): PanelAlignment { return 'center'; } async setPanelPosition(_position: PartPosition): Promise { } async setPanelAlignment(_alignment: PanelAlignment): Promise { } addClass(_clazz: string): void { }