diff --git a/src/vs/workbench/browser/actions/layoutActions.ts b/src/vs/workbench/browser/actions/layoutActions.ts index 5b42967e77f..8571f489228 100644 --- a/src/vs/workbench/browser/actions/layoutActions.ts +++ b/src/vs/workbench/browser/actions/layoutActions.ts @@ -21,8 +21,9 @@ import { MenuBarVisibility } from 'vs/platform/windows/common/windows'; import { isWindows, isLinux } from 'vs/base/common/platform'; import { IsMacContext } from 'vs/workbench/browser/contextkeys'; import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; -import { InEditorZenModeContext } from 'vs/workbench/common/editor'; +import { InEditorZenModeContext, IsCenteredLayoutContext } from 'vs/workbench/common/editor'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; +import { SideBarVisibleContext } from 'vs/workbench/common/viewlet'; const registry = Registry.as(Extensions.WorkbenchActions); const viewCategory = nls.localize('view', "View"); @@ -61,7 +62,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { group: '2_workbench_layout', command: { id: ToggleActivityBarVisibilityAction.ID, - title: nls.localize({ key: 'miToggleActivityBar', comment: ['&& denotes a mnemonic'] }, "Toggle &&Activity Bar") + title: nls.localize({ key: 'miShowActivityBar', comment: ['&& denotes a mnemonic'] }, "Show &&Activity Bar"), + toggled: ContextKeyExpr.equals('config.workbench.activityBar.visible', true) }, order: 4 }); @@ -95,7 +97,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { group: '1_toggle_view', command: { id: ToggleCenteredLayout.ID, - title: nls.localize('miToggleCenteredLayout', "Toggle Centered Layout") + title: nls.localize('miToggleCenteredLayout', "Centered Layout"), + toggled: IsCenteredLayoutContext }, order: 3 }); @@ -203,11 +206,22 @@ export class ToggleSidebarPositionAction extends Action { registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleSidebarPositionAction, ToggleSidebarPositionAction.ID, ToggleSidebarPositionAction.LABEL), 'View: Toggle Side Bar Position', viewCategory); MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { - group: '2_workbench_layout', + group: '3_workbench_layout_move', command: { id: ToggleSidebarPositionAction.ID, - title: nls.localize({ key: 'miMoveSidebarLeftRight', comment: ['&& denotes a mnemonic'] }, "&&Move Side Bar Left/Right") + title: nls.localize({ key: 'miMoveSidebarRight', comment: ['&& denotes a mnemonic'] }, "&&Move Side Bar Right") }, + when: ContextKeyExpr.notEquals('config.workbench.sideBar.location', 'right'), + order: 2 +}); + +MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { + group: '3_workbench_layout_move', + command: { + id: ToggleSidebarPositionAction.ID, + title: nls.localize({ key: 'miMoveSidebarLeft', comment: ['&& denotes a mnemonic'] }, "&&Move Side Bar Left") + }, + when: ContextKeyExpr.equals('config.workbench.sideBar.location', 'right'), order: 2 }); @@ -266,7 +280,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { group: '2_workbench_layout', command: { id: ToggleSidebarVisibilityAction.ID, - title: nls.localize({ key: 'miToggleSidebar', comment: ['&& denotes a mnemonic'] }, "&&Toggle Side Bar") + title: nls.localize({ key: 'miShowSidebar', comment: ['&& denotes a mnemonic'] }, "Show &&Side Bar"), + toggled: SideBarVisibleContext }, order: 1 }); @@ -305,7 +320,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { group: '2_workbench_layout', command: { id: ToggleStatusbarVisibilityAction.ID, - title: nls.localize({ key: 'miToggleStatusbar', comment: ['&& denotes a mnemonic'] }, "&&Toggle Status Bar") + title: nls.localize({ key: 'miShowStatusbar', comment: ['&& denotes a mnemonic'] }, "Show S&&tatus Bar"), + toggled: ContextKeyExpr.equals('config.workbench.statusBar.visible', true) }, order: 3 }); @@ -370,7 +386,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { group: '1_toggle_view', command: { id: ToggleZenMode.ID, - title: nls.localize('miToggleZenMode', "Toggle Zen Mode") + title: nls.localize('miToggleZenMode', "Zen Mode"), + toggled: InEditorZenModeContext }, order: 2 }); @@ -427,13 +444,13 @@ if (isWindows || isLinux) { } MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { - group: '1_toggle_view', + group: '2_workbench_layout', command: { id: ToggleMenuBarAction.ID, - title: nls.localize({ key: 'miToggleMenuBar', comment: ['&& denotes a mnemonic'] }, "Toggle Menu &&Bar") + title: nls.localize({ key: 'miShowMenuBar', comment: ['&& denotes a mnemonic'] }, "Show Menu &&Bar"), + toggled: ContextKeyExpr.and(IsMacContext.toNegated(), ContextKeyExpr.notEquals('config.window.menuBarVisibility', 'hidden'), ContextKeyExpr.notEquals('config.window.menuBarVisibility', 'toggle')) }, - when: IsMacContext.toNegated(), - order: 4 + order: 0 }); // --- Resize View diff --git a/src/vs/workbench/browser/contextkeys.ts b/src/vs/workbench/browser/contextkeys.ts index a7846a7d257..b147b08289f 100644 --- a/src/vs/workbench/browser/contextkeys.ts +++ b/src/vs/workbench/browser/contextkeys.ts @@ -8,7 +8,7 @@ import { Disposable } from 'vs/base/common/lifecycle'; import { IContextKeyService, IContextKey, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { InputFocusedContext } from 'vs/platform/contextkey/common/contextkeys'; import { IWindowsConfiguration } from 'vs/platform/windows/common/windows'; -import { ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, TEXT_DIFF_EDITOR_ID, SplitEditorsVertically, InEditorZenModeContext } from 'vs/workbench/common/editor'; +import { ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, TEXT_DIFF_EDITOR_ID, SplitEditorsVertically, InEditorZenModeContext, IsCenteredLayoutContext } from 'vs/workbench/common/editor'; import { trackFocus, addDisposableListener, EventType } from 'vs/base/browser/dom'; import { preferredSideBySideGroupDirection, GroupDirection, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; @@ -16,9 +16,10 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/ import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; 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 { IWorkbenchLayoutService, Parts, Position } from 'vs/workbench/services/layout/browser/layoutService'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { isMacintosh, isLinux, isWindows } from 'vs/base/common/platform'; +import { PanelPositionContext } from 'vs/workbench/common/panel'; export const IsMacContext = new RawContextKey('isMac', isMacintosh); export const IsLinuxContext = new RawContextKey('isLinux', isLinux); @@ -38,6 +39,8 @@ export const WorkspaceFolderCountContext = new RawContextKey('workspaceF export const RemoteFileDialogContext = new RawContextKey('remoteFileDialogVisible', false); +export const IsFullscreenContext = new RawContextKey('isFullscreen', false); + export class WorkbenchContextKeysHandler extends Disposable { private inputFocusedContext: IContextKey; @@ -54,8 +57,10 @@ export class WorkbenchContextKeysHandler extends Disposable { private inZenModeContext: IContextKey; - + private isFullscreenContext: IContextKey; + private isCenteredLayoutContext: IContextKey; private sideBarVisibleContext: IContextKey; + private panelPositionContext: IContextKey; constructor( @IContextKeyService private contextKeyService: IContextKeyService, @@ -93,6 +98,9 @@ export class WorkbenchContextKeysHandler extends Disposable { })); this._register(this.layoutService.onZenModeChange(enabled => this.inZenModeContext.set(enabled))); + this._register(this.layoutService.onFullscreenChange(fullscreen => this.isFullscreenContext.set(fullscreen))); + this._register(this.layoutService.onCenteredLayoutChange(centered => this.isCenteredLayoutContext.set(centered))); + this._register(this.layoutService.onPanelPositionChange(position => this.panelPositionContext.set(position))); this._register(this.viewletService.onDidViewletClose(() => this.updateSideBarContextKeys())); this._register(this.viewletService.onDidViewletOpen(() => this.updateSideBarContextKeys())); @@ -140,11 +148,21 @@ export class WorkbenchContextKeysHandler extends Disposable { this.splitEditorsVerticallyContext = SplitEditorsVertically.bindTo(this.contextKeyService); this.updateSplitEditorsVerticallyContext(); + // Fullscreen + this.isFullscreenContext = IsFullscreenContext.bindTo(this.contextKeyService); + // Zen Mode this.inZenModeContext = InEditorZenModeContext.bindTo(this.contextKeyService); + // Centered Layout + this.isCenteredLayoutContext = IsCenteredLayoutContext.bindTo(this.contextKeyService); + // Sidebar this.sideBarVisibleContext = SideBarVisibleContext.bindTo(this.contextKeyService); + + // Panel Position + this.panelPositionContext = PanelPositionContext.bindTo(this.contextKeyService); + this.panelPositionContext.set(this.layoutService.getPanelPosition() === Position.RIGHT ? 'right' : 'bottom'); } private updateEditorContextKeys(): void { diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index 313743ea6e3..fa1ddec1a40 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -63,8 +63,17 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi private readonly _onTitleBarVisibilityChange: Emitter = this._register(new Emitter()); get onTitleBarVisibilityChange(): Event { return this._onTitleBarVisibilityChange.event; } - private readonly _onZenMode: Emitter = this._register(new Emitter()); - get onZenModeChange(): Event { return this._onZenMode.event; } + private readonly _onZenModeChange: Emitter = this._register(new Emitter()); + get onZenModeChange(): Event { return this._onZenModeChange.event; } + + private readonly _onFullscreenChange: Emitter = this._register(new Emitter()); + get onFullscreenChange(): Event { return this._onFullscreenChange.event; } + + private readonly _onCenteredLayoutChange: Emitter = this._register(new Emitter()); + get onCenteredLayoutChange(): Event { return this._onCenteredLayoutChange.event; } + + private readonly _onPanelPositionChange: Emitter = this._register(new Emitter()); + get onPanelPositionChange(): Event { return this._onPanelPositionChange.event; } private readonly _onLayout = this._register(new Emitter()); get onLayout(): Event { return this._onLayout.event; } @@ -242,6 +251,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi this._onTitleBarVisibilityChange.fire(); this.layout(); // handle title bar when fullscreen changes } + + this._onFullscreenChange.fire(this.state.fullscreen); } private doUpdateLayoutConfiguration(skipLayout?: boolean): void { @@ -631,7 +642,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi } // Event - this._onZenMode.fire(this.state.zenMode.active); + this._onZenModeChange.fire(this.state.zenMode.active); } private setStatusBarHidden(hidden: boolean, skipLayout?: boolean): void { @@ -828,6 +839,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi this.layout(); } } + + this._onCenteredLayoutChange.fire(this.state.editor.centered); } resizePart(part: Parts, sizeChange: number): void { @@ -1069,6 +1082,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi } else { this.workbenchGrid.layout(); } + + this._onPanelPositionChange.fire(positionToString(this.state.panel.position)); } private savePanelDimension(): void { diff --git a/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts b/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts index 7f09ad3f84a..f907d999953 100644 --- a/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts +++ b/src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts @@ -496,10 +496,10 @@ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { }); MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, { group: '5_editor', - order: 99, + order: 3, command: { id: 'breadcrumbs.toggle', - title: localize('miToggleBreadcrumbs', "Toggle &&Breadcrumbs"), + title: localize('miShowBreadcrumbs', "Show &&Breadcrumbs"), toggled: ContextKeyExpr.equals('config.breadcrumbs.enabled', true) } }); diff --git a/src/vs/workbench/browser/parts/panel/panelActions.ts b/src/vs/workbench/browser/parts/panel/panelActions.ts index 19f9f0d7f4d..5e9021847a3 100644 --- a/src/vs/workbench/browser/parts/panel/panelActions.ts +++ b/src/vs/workbench/browser/parts/panel/panelActions.ts @@ -16,6 +16,7 @@ import { IWorkbenchLayoutService, Parts, Position } from 'vs/workbench/services/ import { ActivityAction } from 'vs/workbench/browser/parts/compositeBarActions'; import { IActivity } from 'vs/workbench/common/activity'; import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; +import { ActivePanelContext, PanelPositionContext } from 'vs/workbench/common/panel'; export class ClosePanelAction extends Action { @@ -92,8 +93,8 @@ export class TogglePanelPositionAction extends Action { static readonly ID = 'workbench.action.togglePanelPosition'; static readonly LABEL = nls.localize('toggledPanelPosition', "Toggle Panel Position"); - private static readonly MOVE_TO_RIGHT_LABEL = nls.localize('moveToRight', "Move Panel Right"); - private static readonly MOVE_TO_BOTTOM_LABEL = nls.localize('moveToBottom', "Move Panel to Bottom"); + static readonly MOVE_TO_RIGHT_LABEL = nls.localize('moveToRight', "Move Panel Right"); + static readonly MOVE_TO_BOTTOM_LABEL = nls.localize('moveToBottom', "Move Panel to Bottom"); private toDispose: IDisposable[]; @@ -271,16 +272,28 @@ MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { group: '2_workbench_layout', command: { id: TogglePanelAction.ID, - title: nls.localize({ key: 'miTogglePanel', comment: ['&& denotes a mnemonic'] }, "Toggle &&Panel") + title: nls.localize({ key: 'miShowPanel', comment: ['&& denotes a mnemonic'] }, "Show &&Panel"), + toggled: ActivePanelContext }, order: 5 }); MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { - group: '2_workbench_layout', + group: '3_workbench_layout_move', command: { id: TogglePanelPositionAction.ID, - title: TogglePanelPositionAction.LABEL + title: TogglePanelPositionAction.MOVE_TO_RIGHT_LABEL }, - order: 3 + when: PanelPositionContext.isEqualTo('bottom'), + order: 5 +}); + +MenuRegistry.appendMenuItem(MenuId.MenubarAppearanceMenu, { + group: '3_workbench_layout_move', + command: { + id: TogglePanelPositionAction.ID, + title: TogglePanelPositionAction.MOVE_TO_BOTTOM_LABEL + }, + when: PanelPositionContext.isEqualTo('right'), + order: 5 }); diff --git a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts index 32a8c9905cc..d22fb10e022 100644 --- a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts +++ b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts @@ -38,17 +38,12 @@ import { withNullAsUndefined } from 'vs/base/common/types'; export class MenubarControl extends Disposable { private keys = [ - 'files.autoSave', 'window.menuBarVisibility', - 'editor.multiCursorModifier', - 'workbench.sideBar.location', - 'workbench.statusBar.visible', - 'workbench.activityBar.visible', 'window.enableMenuBarMnemonics', 'window.nativeTabs' ]; - private topLevelMenus: { + private menus: { 'File': IMenu; 'Edit': IMenu; 'Selection': IMenu; @@ -103,7 +98,7 @@ export class MenubarControl extends Disposable { super(); - this.topLevelMenus = { + this.menus = { 'File': this._register(this.menuService.createMenu(MenuId.MenubarFileMenu, this.contextKeyService)), 'Edit': this._register(this.menuService.createMenu(MenuId.MenubarEditMenu, this.contextKeyService)), 'Selection': this._register(this.menuService.createMenu(MenuId.MenubarSelectionMenu, this.contextKeyService)), @@ -115,7 +110,7 @@ export class MenubarControl extends Disposable { }; if (isMacintosh) { - this.topLevelMenus['Preferences'] = this._register(this.menuService.createMenu(MenuId.MenubarPreferencesMenu, this.contextKeyService)); + this.menus['Preferences'] = this._register(this.menuService.createMenu(MenuId.MenubarPreferencesMenu, this.contextKeyService)); } this.menuUpdater = this._register(new RunOnceScheduler(() => this.doUpdateMenubar(false), 200)); @@ -124,8 +119,8 @@ export class MenubarControl extends Disposable { this._onFocusStateChange = this._register(new Emitter()); if (isMacintosh || this.currentTitlebarStyleSetting !== 'custom') { - for (const topLevelMenuName of Object.keys(this.topLevelMenus)) { - const menu = this.topLevelMenus[topLevelMenuName]; + for (const topLevelMenuName of Object.keys(this.topLevelTitles)) { + const menu = this.menus[topLevelMenuName]; if (menu) { this._register(menu.onDidChange(() => this.updateMenubar())); } @@ -156,28 +151,6 @@ export class MenubarControl extends Disposable { return enableMenuBarMnemonics; } - private get currentSidebarPosition(): string { - return this.configurationService.getValue('workbench.sideBar.location'); - } - - private get currentStatusBarVisibility(): boolean { - let setting = this.configurationService.getValue('workbench.statusBar.visible'); - if (typeof setting !== 'boolean') { - setting = true; - } - - return setting; - } - - private get currentActivityBarVisibility(): boolean { - let setting = this.configurationService.getValue('workbench.activityBar.visible'); - if (typeof setting !== 'boolean') { - setting = true; - } - - return setting; - } - private get currentMenubarVisibility(): MenuBarVisibility { return this.configurationService.getValue('window.menuBarVisibility'); } @@ -319,30 +292,6 @@ export class MenubarControl extends Disposable { private calculateActionLabel(action: IAction | IMenubarMenuItemAction): string { let label = action.label; switch (action.id) { - case 'workbench.action.toggleSidebarPosition': - if (this.currentSidebarPosition !== 'right') { - label = nls.localize({ key: 'miMoveSidebarRight', comment: ['&& denotes a mnemonic'] }, "&&Move Side Bar Right"); - } else { - label = nls.localize({ key: 'miMoveSidebarLeft', comment: ['&& denotes a mnemonic'] }, "&&Move Side Bar Left"); - } - break; - - case 'workbench.action.toggleStatusbarVisibility': - if (this.currentStatusBarVisibility) { - label = nls.localize({ key: 'miHideStatusbar', comment: ['&& denotes a mnemonic'] }, "&&Hide Status Bar"); - } else { - label = nls.localize({ key: 'miShowStatusbar', comment: ['&& denotes a mnemonic'] }, "&&Show Status Bar"); - } - break; - - case 'workbench.action.toggleActivityBarVisibility': - if (this.currentActivityBarVisibility) { - label = nls.localize({ key: 'miHideActivityBar', comment: ['&& denotes a mnemonic'] }, "Hide &&Activity Bar"); - } else { - label = nls.localize({ key: 'miShowActivityBar', comment: ['&& denotes a mnemonic'] }, "Show &&Activity Bar"); - } - break; - default: break; } @@ -509,7 +458,7 @@ export class MenubarControl extends Disposable { } // Update the menu actions - const updateActions = (menu: IMenu, target: IAction[]) => { + const updateActions = (menu: IMenu, target: IAction[], topLevelTitle: string) => { target.splice(0); let groups = menu.getActions(); for (let group of groups) { @@ -518,11 +467,20 @@ export class MenubarControl extends Disposable { for (let action of actions) { this.insertActionsBefore(action, target); if (action instanceof SubmenuItemAction) { - const submenu = this.menuService.createMenu(action.item.submenu, this.contextKeyService); + if (!this.menus[action.item.submenu]) { + this.menus[action.item.submenu] = this.menuService.createMenu(action.item.submenu, this.contextKeyService); + const submenu = this.menus[action.item.submenu]; + this._register(submenu!.onDidChange(() => { + const actions: IAction[] = []; + updateActions(menu, actions, topLevelTitle); + this.menubar.updateMenu({ actions: actions, label: mnemonicMenuLabel(this.topLevelTitles[topLevelTitle]) }); + }, this)); + } + + const submenu = this.menus[action.item.submenu]!; const submenuActions: SubmenuAction[] = []; - updateActions(submenu, submenuActions); + updateActions(submenu, submenuActions, topLevelTitle); target.push(new SubmenuAction(mnemonicMenuLabel(action.label), submenuActions)); - submenu.dispose(); } else { action.label = mnemonicMenuLabel(this.calculateActionLabel(action)); target.push(action); @@ -535,19 +493,19 @@ export class MenubarControl extends Disposable { target.pop(); }; - for (const title of Object.keys(this.topLevelMenus)) { - const menu = this.topLevelMenus[title]; + for (const title of Object.keys(this.topLevelTitles)) { + const menu = this.menus[title]; if (firstTime && menu) { this._register(menu.onDidChange(() => { const actions: IAction[] = []; - updateActions(menu, actions); + updateActions(menu, actions, title); this.menubar.updateMenu({ actions: actions, label: mnemonicMenuLabel(this.topLevelTitles[title]) }); })); } const actions: IAction[] = []; if (menu) { - updateActions(menu, actions); + updateActions(menu, actions, title); } if (!firstTime) { @@ -588,6 +546,12 @@ export class MenubarControl extends Disposable { if (menuItem instanceof SubmenuItemAction) { const submenu = { items: [] }; + + if (!this.menus[menuItem.item.submenu]) { + this.menus[menuItem.item.submenu] = this.menuService.createMenu(menuItem.item.submenu, this.contextKeyService); + this._register(this.menus[menuItem.item.submenu]!.onDidChange(() => this.updateMenubar())); + } + const menuToDispose = this.menuService.createMenu(menuItem.item.submenu, this.contextKeyService); this.populateMenuItems(menuToDispose, submenu, keybindings); @@ -647,8 +611,8 @@ export class MenubarControl extends Disposable { } menubarData.keybindings = this.getAdditionalKeybindings(); - for (const topLevelMenuName of Object.keys(this.topLevelMenus)) { - const menu = this.topLevelMenus[topLevelMenuName]; + for (const topLevelMenuName of Object.keys(this.topLevelTitles)) { + const menu = this.menus[topLevelMenuName]; if (menu) { const menubarMenu: IMenubarMenu = { items: [] }; this.populateMenuItems(menu, menubarMenu, menubarData.keybindings); diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index 6915bca4890..fff5882b5da 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -33,6 +33,7 @@ export const ActiveEditorGroupEmptyContext = new RawContextKey('activeE export const MultipleEditorGroupsContext = new RawContextKey('multipleEditorGroups', false); export const SingleEditorGroupsContext = MultipleEditorGroupsContext.toNegated(); export const InEditorZenModeContext = new RawContextKey('inZenMode', false); +export const IsCenteredLayoutContext = new RawContextKey('isCenteredLayout', false); export const SplitEditorsVertically = new RawContextKey('splitEditorsVertically', false); /** diff --git a/src/vs/workbench/common/panel.ts b/src/vs/workbench/common/panel.ts index 628846c404a..7b836be9552 100644 --- a/src/vs/workbench/common/panel.ts +++ b/src/vs/workbench/common/panel.ts @@ -8,5 +8,6 @@ import { RawContextKey } from 'vs/platform/contextkey/common/contextkey'; export const ActivePanelContext = new RawContextKey('activePanel', ''); export const PanelFocusContext = new RawContextKey('panelFocus', false); +export const PanelPositionContext = new RawContextKey('panelPosition', 'bottom'); export interface IPanel extends IComposite { } diff --git a/src/vs/workbench/contrib/codeEditor/browser/toggleMinimap.ts b/src/vs/workbench/contrib/codeEditor/browser/toggleMinimap.ts index 96576810093..a7dc0be703a 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/toggleMinimap.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/toggleMinimap.ts @@ -36,7 +36,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, { group: '5_editor', command: { id: ToggleMinimapAction.ID, - title: nls.localize({ key: 'miToggleMinimap', comment: ['&& denotes a mnemonic'] }, "Toggle &&Minimap"), + title: nls.localize({ key: 'miShowMinimap', comment: ['&& denotes a mnemonic'] }, "Show &&Minimap"), toggled: ContextKeyExpr.equals('config.editor.minimap.enabled', true) }, order: 2 diff --git a/src/vs/workbench/contrib/codeEditor/browser/toggleRenderControlCharacter.ts b/src/vs/workbench/contrib/codeEditor/browser/toggleRenderControlCharacter.ts index ce2765e5efe..23410b162b6 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/toggleRenderControlCharacter.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/toggleRenderControlCharacter.ts @@ -37,8 +37,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, { group: '5_editor', command: { id: ToggleRenderControlCharacterAction.ID, - title: nls.localize({ key: 'miToggleRenderControlCharacters', comment: ['&& denotes a mnemonic'] }, "Toggle &&Control Characters"), + title: nls.localize({ key: 'miToggleRenderControlCharacters', comment: ['&& denotes a mnemonic'] }, "Render &&Control Characters"), toggled: ContextKeyExpr.equals('config.editor.renderControlCharacters', true) }, - order: 4 + order: 5 }); diff --git a/src/vs/workbench/contrib/codeEditor/browser/toggleRenderWhitespace.ts b/src/vs/workbench/contrib/codeEditor/browser/toggleRenderWhitespace.ts index db5bbbf573f..e5181da5c2e 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/toggleRenderWhitespace.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/toggleRenderWhitespace.ts @@ -45,8 +45,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarViewMenu, { group: '5_editor', command: { id: ToggleRenderWhitespaceAction.ID, - title: nls.localize({ key: 'miToggleRenderWhitespace', comment: ['&& denotes a mnemonic'] }, "Toggle &&Render Whitespace"), + title: nls.localize({ key: 'miToggleRenderWhitespace', comment: ['&& denotes a mnemonic'] }, "&&Render Whitespace"), toggled: ContextKeyExpr.notEquals('config.editor.renderWhitespace', 'none') }, - order: 3 + order: 4 }); diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index d415c93b8d3..048706c0869 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -21,7 +21,7 @@ import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/co import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { ADD_ROOT_FOLDER_COMMAND_ID } from 'vs/workbench/browser/actions/workspaceCommands'; -import { SupportsWorkspacesContext, IsMacContext, HasMacNativeTabsContext, IsDevelopmentContext, WorkbenchStateContext, WorkspaceFolderCountContext, RemoteFileDialogContext } from 'vs/workbench/browser/contextkeys'; +import { SupportsWorkspacesContext, IsMacContext, HasMacNativeTabsContext, IsDevelopmentContext, WorkbenchStateContext, WorkspaceFolderCountContext, RemoteFileDialogContext, IsFullscreenContext } from 'vs/workbench/browser/contextkeys'; import { NoEditorsVisibleContext, SingleEditorGroupsContext } from 'vs/workbench/common/editor'; import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows'; import { LogStorageAction } from 'vs/platform/storage/node/storageService'; @@ -362,7 +362,8 @@ import { LogStorageAction } from 'vs/platform/storage/node/storageService'; group: '1_toggle_view', command: { id: ToggleFullScreenAction.ID, - title: nls.localize({ key: 'miToggleFullScreen', comment: ['&& denotes a mnemonic'] }, "Toggle &&Full Screen") + title: nls.localize({ key: 'miToggleFullScreen', comment: ['&& denotes a mnemonic'] }, "&&Full Screen"), + toggled: IsFullscreenContext }, order: 1 }); diff --git a/src/vs/workbench/services/layout/browser/layoutService.ts b/src/vs/workbench/services/layout/browser/layoutService.ts index 815af5edeb2..c89bbef87c1 100644 --- a/src/vs/workbench/services/layout/browser/layoutService.ts +++ b/src/vs/workbench/services/layout/browser/layoutService.ts @@ -45,6 +45,21 @@ export interface IWorkbenchLayoutService extends ILayoutService { */ readonly onZenModeChange: Event; + /** + * Emits when fullscreen is enabled or disabled. + */ + readonly onFullscreenChange: Event; + + /** + * Emits when centered layout is enabled or disabled. + */ + readonly onCenteredLayoutChange: Event; + + /** + * Emit when panel position changes. + */ + readonly onPanelPositionChange: Event; + /** * Asks the part service if all parts have been fully restored. For editor part * this means that the contents of editors have loaded. diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 99e06ec62c2..09b4ed6f217 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -456,6 +456,9 @@ export class TestLayoutService implements IWorkbenchLayoutService { container: HTMLElement = window.document.body; onZenModeChange: Event = Event.None; + onCenteredLayoutChange: Event = Event.None; + onFullscreenChange: Event = Event.None; + onPanelPositionChange: Event = Event.None; onLayout = Event.None; private _onTitleBarVisibilityChange = new Emitter();