Skip to content

Commit

Permalink
core: added appearance and editor layout sub-menus
Browse files Browse the repository at this point in the history
The commit adds the registration of an `appearance` and `editor layout` submenu to the
`view` main-menu.
The `appearance` menu is used to group menu items related to the
appearance of the workbench or layout. The `editor layout` menu groups
items related to splitting the workbench. Commands present in vscode's
appearance and editor layout menu that exist in the framework were moved to these new
submenus.
  • Loading branch information
Archie27376 committed Oct 22, 2021
1 parent 6abc784 commit 67d8cde
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 15 deletions.
56 changes: 43 additions & 13 deletions packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,19 @@ export namespace CommonMenus {

export const VIEW = [...MAIN_MENU_BAR, '4_view'];
export const VIEW_PRIMARY = [...VIEW, '0_primary'];
export const VIEW_VIEWS = [...VIEW, '1_views'];
export const VIEW_LAYOUT = [...VIEW, '2_layout'];
export const VIEW_TOGGLE = [...VIEW, '3_toggle'];
export const VIEW_APPEARANCE = [...VIEW, '1_appearance'];
export const VIEW_APPEARANCE_SUBMENU = [...VIEW_APPEARANCE, '1_appearance_submenu'];
export const VIEW_APPEARANCE_SUBMENU_SCREEN = [...VIEW_APPEARANCE_SUBMENU, '2_appearance_submenu_screen'];
export const VIEW_APPEARANCE_SUBMENU_BAR = [...VIEW_APPEARANCE_SUBMENU, '3_appearance_submenu_bar'];
export const VIEW_EDITOR_SUBMENU = [...VIEW_APPEARANCE, '2_editor_submenu'];
export const VIEW_EDITOR_SUBMENU_SPLIT = [...VIEW_EDITOR_SUBMENU, '1_editor_submenu_split'];
export const VIEW_EDITOR_SUBMENU_ORTHO = [...VIEW_EDITOR_SUBMENU, '2_editor_submenu_ortho'];
export const VIEW_VIEWS = [...VIEW, '2_views'];
export const VIEW_LAYOUT = [...VIEW, '3_layout'];
export const VIEW_TOGGLE = [...VIEW, '4_toggle'];

export const SETTINGS_OPEN = [...SETTINGS_MENU, '1_settings_open'];
export const SETTINGS__THEME = [...SETTINGS_MENU, '2_settings_theme'];

// last menu item
export const HELP = [...MAIN_MENU_BAR, '9_help'];

Expand Down Expand Up @@ -227,6 +233,11 @@ export namespace CommonCommands {
category: VIEW_CATEGORY,
label: 'Toggle Maximized'
};
export const SHOW_MENU_BAR: Command = {
id: 'window.menuBarVisibility',
category: VIEW_CATEGORY,
label: 'Show Menu Bar'
};
export const OPEN_VIEW: Command = {
id: 'core.openView',
category: VIEW_CATEGORY,
Expand Down Expand Up @@ -281,7 +292,6 @@ export namespace CommonCommands {
id: 'workbench.action.configureLanguage',
label: 'Configure Display Language'
}, 'vscode/localizationsActions/configureLocale');

}

export const supportCut = browser.isNative || document.queryCommandSupported('cut');
Expand Down Expand Up @@ -528,18 +538,18 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
order: '3'
});

registry.registerMenuAction(CommonMenus.VIEW_LAYOUT, {
registry.registerMenuAction(CommonMenus.VIEW_APPEARANCE_SUBMENU_BAR, {
commandId: CommonCommands.TOGGLE_BOTTOM_PANEL.id,
order: '0'
order: '1'
});
registry.registerMenuAction(CommonMenus.VIEW_LAYOUT, {
registry.registerMenuAction(CommonMenus.VIEW_APPEARANCE_SUBMENU_BAR, {
commandId: CommonCommands.TOGGLE_STATUS_BAR.id,
order: '1',
order: '2',
label: 'Toggle Status Bar'
});
registry.registerMenuAction(CommonMenus.VIEW_LAYOUT, {
registry.registerMenuAction(CommonMenus.VIEW_APPEARANCE_SUBMENU_BAR, {
commandId: CommonCommands.COLLAPSE_ALL_PANELS.id,
order: '2'
order: '3'
});

registry.registerMenuAction(SHELL_TABBAR_CONTEXT_MENU, {
Expand Down Expand Up @@ -567,10 +577,15 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
label: 'Collapse',
order: '4'
});
registry.registerMenuAction(SHELL_TABBAR_CONTEXT_MENU, {
registry.registerMenuAction(CommonMenus.VIEW_APPEARANCE_SUBMENU_SCREEN, {
commandId: CommonCommands.TOGGLE_MAXIMIZED.id,
label: 'Toggle Maximized',
order: '5'
order: '1'
});
registry.registerMenuAction(CommonMenus.VIEW_APPEARANCE_SUBMENU_BAR, {
commandId: CommonCommands.SHOW_MENU_BAR.id,
label: 'Toggle Menu Bar',
order: '0'
});
registry.registerMenuAction(CommonMenus.HELP, {
commandId: CommonCommands.ABOUT_COMMAND.id,
Expand All @@ -595,6 +610,8 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
registry.registerMenuAction(CommonMenus.SETTINGS__THEME, {
commandId: CommonCommands.SELECT_ICON_THEME.id
});

registry.registerSubmenu(CommonMenus.VIEW_APPEARANCE_SUBMENU, 'Appearance');
}

registerCommands(commandRegistry: CommandRegistry): void {
Expand Down Expand Up @@ -784,6 +801,19 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
commandRegistry.registerCommand(CommonCommands.TOGGLE_STATUS_BAR, {
execute: () => this.preferenceService.updateValue('workbench.statusBar.visible', !this.preferences['workbench.statusBar.visible'])
});
commandRegistry.registerCommand(CommonCommands.SHOW_MENU_BAR, {
isEnabled: () => !isOSX,
isVisible: () => !isOSX,
execute: () => {
const menuBarVisibility = 'window.menuBarVisibility';
const visibility = this.preferences[menuBarVisibility];
if (visibility !== 'compact') {
this.preferenceService.updateValue(menuBarVisibility, 'compact');
} else {
this.preferenceService.updateValue(menuBarVisibility, 'classic');
}
}
});
commandRegistry.registerCommand(CommonCommands.TOGGLE_MAXIMIZED, {
isEnabled: (event?: Event) => this.canToggleMaximized(event),
isVisible: (event?: Event) => this.canToggleMaximized(event),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export namespace ElectronCommands {

export namespace ElectronMenus {
export const VIEW_WINDOW = [...CommonMenus.VIEW, 'window'];
export const VIEW_ZOOM = [...CommonMenus.VIEW, 'zoom'];
export const VIEW_ZOOM = [...CommonMenus.VIEW_APPEARANCE_SUBMENU, '4_appearance_submenu_zoom'];
}

export namespace ElectronMenus {
Expand Down Expand Up @@ -269,5 +269,10 @@ export class ElectronMenuContribution implements FrontendApplicationContribution
registry.registerMenuAction(ElectronMenus.FILE_CLOSE, {
commandId: ElectronCommands.CLOSE_WINDOW.id,
});
registry.registerMenuAction(CommonMenus.VIEW_APPEARANCE_SUBMENU_SCREEN, {
commandId: ElectronCommands.TOGGLE_FULL_SCREEN.id,
label: 'Full Screen',
order: '0'
});
}
}
2 changes: 1 addition & 1 deletion packages/editor/src/browser/editor-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class EditorContribution implements FrontendApplicationContribution, Comm
});
keybindings.registerKeybinding({
command: EditorCommands.SPLIT_EDITOR_VERTICAL.id,
keybinding: 'ctrlcmd+k ctrlcmd+\\',
keybinding: 'ctrlcmd+k',
});
}
}
37 changes: 37 additions & 0 deletions packages/editor/src/browser/editor-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,43 @@ export class EditorMenuContribution implements MenuContribution {
label: 'Render Whitespace',
order: '2'
});
registry.registerMenuAction(CommonMenus.VIEW_EDITOR_SUBMENU_SPLIT, {
commandId: EditorCommands.SPLIT_EDITOR_RIGHT.id,
label: 'Split Editor Right',
order: '0'
});

registry.registerMenuAction(CommonMenus.VIEW_EDITOR_SUBMENU_SPLIT, {
commandId: EditorCommands.SPLIT_EDITOR_LEFT.id,
label: 'Split Editor Left',
order: '1'
});

registry.registerMenuAction(CommonMenus.VIEW_EDITOR_SUBMENU_SPLIT, {
commandId: EditorCommands.SPLIT_EDITOR_UP.id,
label: 'Split Editor Up',
order: '2'
});

registry.registerMenuAction(CommonMenus.VIEW_EDITOR_SUBMENU_SPLIT, {
commandId: EditorCommands.SPLIT_EDITOR_DOWN.id,
label: 'Split Editor Down',
order: '3'
});

registry.registerMenuAction(CommonMenus.VIEW_EDITOR_SUBMENU_ORTHO, {
commandId: EditorCommands.SPLIT_EDITOR_HORIZONTAL.id,
label: 'Split Editor Horizontal',
order: '0'
});

registry.registerMenuAction(CommonMenus.VIEW_EDITOR_SUBMENU_ORTHO, {
commandId: EditorCommands.SPLIT_EDITOR_VERTICAL.id,
label: 'Split Editor Vertical',
order: '1'
});

registry.registerSubmenu(CommonMenus.VIEW_EDITOR_SUBMENU, 'Editor Layout');
}

}

0 comments on commit 67d8cde

Please sign in to comment.