Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Menubar Implementation #51422

Merged
merged 102 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
f4e80de
Initial changes
rianadon Aug 26, 2017
ddddfde
Add custom titlebar
rianadon Nov 23, 2017
04f2b9b
Revert vibrancy changes, cross-platform support
rianadon Dec 9, 2017
96c530b
Add hover states for titlebar
rianadon Dec 9, 2017
3fc07e3
Implement button actions, make maximize icon change
rianadon Dec 9, 2017
c758472
Merge with master
rianadon Dec 9, 2017
12a1393
Remove debugging statement
rianadon Dec 9, 2017
7f12e76
Remove formatting changes
rianadon Dec 9, 2017
c840d0d
Remove more formatting changes
rianadon Dec 9, 2017
be8cb21
Fix compilation errors
rianadon Dec 9, 2017
a66d521
Fix code formatting
rianadon Dec 10, 2017
bec93d4
Make icon sizes independent of zoom
rianadon Dec 10, 2017
f2648cd
Make positioning of icons same as otherWindows apps
rianadon Dec 10, 2017
c9bf4c9
Use setting, standard titlebar
rianadon Dec 12, 2017
1fdd9ed
Make sizing consistent with Windows
rianadon Dec 12, 2017
ae5e8d4
Make window resiable from top
rianadon Dec 12, 2017
233784d
More consistency
rianadon Dec 12, 2017
80411d3
Make titlebar render correctly on reload
rianadon Dec 12, 2017
94cb977
More positioning changes
rianadon Dec 12, 2017
b5bdbf1
Merge with master
rianadon Dec 12, 2017
a0b33ed
Merge remote-tracking branch 'upstream/master' into titlebar
bpasero Dec 13, 2017
25e5ca6
Make frame show by default on Windows
rianadon Dec 14, 2017
63f86d2
Merge branch 'titlebar' of https://github.com/rianadon/vscode into ti…
rianadon Dec 14, 2017
961ec4c
Try to make window draggable before load
rianadon Dec 14, 2017
a5a0553
Fix drag issue
rianadon Dec 16, 2017
0c7174b
Remove unnecessary console.log
rianadon Dec 16, 2017
8667ae7
Merge remote-tracking branch 'upstream' into titlebar
rianadon Dec 16, 2017
2afb336
Make Linux compatible
rianadon Dec 17, 2017
4ce2f07
Titlebar fixes for linux
rianadon Dec 17, 2017
b3db9ac
Remove unused import
rianadon Dec 17, 2017
0976b51
Make framless window draggable on LInux
rianadon Dec 17, 2017
dc5f62b
Add hover transitions
rianadon Dec 17, 2017
8c8de9f
Make double-clicking icon close window
rianadon Dec 17, 2017
91ac8c8
Merge remote-tracking branch 'upstream/master' into titlebar
bpasero Mar 24, 2018
c1e4b74
Merge remote-tracking branch 'upstream/master' into titlebar
rianadon May 7, 2018
c033035
context menus working on windows
sbatten May 11, 2018
b15089e
addressing some commit feedback
sbatten May 11, 2018
60e8c7c
menubarpart and ipc for native construction
sbatten May 16, 2018
74c2115
make menubarpart independent of titlebarpart
sbatten May 16, 2018
91a93b4
Merge branch 'master' into titlebarplus
sbatten May 16, 2018
739837c
adding separators, more file menu actions, hiding when native, and be…
sbatten May 17, 2018
3716227
more cleanup of ipc and adding fallback mechanic
sbatten May 17, 2018
7ed750e
mouse interaction starting to make sense
sbatten May 18, 2018
8520d3f
cleanup of main process menu and moving preferences and recent to top…
sbatten May 18, 2018
f98d6cc
edit menu
sbatten May 18, 2018
d0e84c4
adding selection menu
sbatten May 18, 2018
4f0ca64
adding holders for the remainder of menus
sbatten May 18, 2018
5e9366f
preferences does not fallback currently, moved to render side
sbatten May 18, 2018
3c93662
changing to svg
sbatten May 28, 2018
71d4f70
adding keyboard navigation
sbatten May 29, 2018
ff427e0
enable mnemonics (need to clean this up)
sbatten May 30, 2018
fc07fa2
get keybindings in menubar
sbatten Jun 1, 2018
06df957
bring titlebarplus up to date
bpasero Jun 4, 2018
475c1a8
toggle mnemonics, add checked functionality, add auto save
sbatten Jun 4, 2018
ba9b008
work for fullscreen and menubar visibility
sbatten Jun 5, 2018
14bc5bb
aria roles
sbatten Jun 7, 2018
bc38091
box shadow around menus
sbatten Jun 7, 2018
0a48719
html context menus
sbatten Jun 7, 2018
ea89fc4
cleaning up titlebar, making context menus match
sbatten Jun 8, 2018
524568a
hover feedback on toplevel menubar
sbatten Jun 8, 2018
20d4bb7
Merge branch 'master' into titlebarplus
sbatten Jun 8, 2018
703ba64
cleanup from merge conflicts
sbatten Jun 8, 2018
b99fad3
more fixes from merge
sbatten Jun 8, 2018
282292b
bugfixes and menubar hiding fix
sbatten Jun 8, 2018
14abe64
fix duplicate editor action and keyboard nav issue
sbatten Jun 8, 2018
2e69619
small menubar toplevel view fix
sbatten Jun 8, 2018
ca7c213
hydrate menus and bring back checked functionality
sbatten Jun 11, 2018
f443d73
remove empty line.
rebornix Jun 11, 2018
1a64f45
removing addMaximizeListener IPC, no references
sbatten Jun 11, 2018
3a67ac6
move toggle autosave action to fileActions
sbatten Jun 11, 2018
ef65a1f
addressing some css feedback and resizability
sbatten Jun 11, 2018
f7dc69a
clean up custom title check
sbatten Jun 11, 2018
e327696
workbench.ts feedback
sbatten Jun 11, 2018
8db6f8d
window.ts move listeners
sbatten Jun 11, 2018
9d89676
titlebarPart.ts feedback
sbatten Jun 11, 2018
929679e
layout.ts
sbatten Jun 12, 2018
b2a078b
move lines back in workbench.ts
sbatten Jun 12, 2018
1636787
unrelated
sbatten Jun 12, 2018
a68a975
add editor layout menu, localize top levels
sbatten Jun 12, 2018
69aa29f
handle menu/title overflow interaction
sbatten Jun 12, 2018
f08cdae
maximize window in window configuration
sbatten Jun 12, 2018
ffc8c1a
several fixes and cleanup for native side
sbatten Jun 13, 2018
a83a514
merge master
sbatten Jun 13, 2018
179eae8
fix from merge and make titlebar position more reliable
sbatten Jun 13, 2018
9f03987
work with menubar visibility toggle
sbatten Jun 14, 2018
15bae1e
handling zoom for titlebar controls and icons as well as toggling title
sbatten Jun 15, 2018
fde576a
handle zoom for menubar
sbatten Jun 15, 2018
0afa3e5
addressing CR from ben
sbatten Jun 15, 2018
cc694df
adjusting relauncher for settings change
sbatten Jun 15, 2018
2067a66
reducing the size of the menus so view doesn't take a huge amoun of s…
sbatten Jun 15, 2018
44e6014
fixing close icon coloring for light theme
sbatten Jun 15, 2018
f4e55b7
move maximized into getUrl
sbatten Jun 15, 2018
bd1a88a
prevent double registering event listener
sbatten Jun 15, 2018
062a11e
Merge branch 'master' into titlebarplus
sbatten Jun 15, 2018
8c5a4fd
revert unintentional change
sbatten Jun 15, 2018
329d38e
fallback to old menubar when using macOS or native title
sbatten Jun 15, 2018
816a3bc
polishing the title position with menubar
sbatten Jun 15, 2018
a065656
app icon url
sbatten Jun 15, 2018
11c186f
some cleanup and :lipstick:
bpasero Jun 17, 2018
37b338d
switching to accessKey, way cleaner
sbatten Jun 18, 2018
794d9de
only do mnemonics on menus
sbatten Jun 18, 2018
07706d0
safer method of setting mnemonic
sbatten Jun 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/vs/base/browser/ui/actionbar/actionbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export class BaseActionItem implements IActionItem {
public _context: any;
public _action: IAction;

static MNEMONIC_REGEX: RegExp = /&&(.)/g;

private _actionRunner: IActionRunner;

constructor(context: any, action: IAction, protected options?: IBaseActionItemOptions) {
Expand Down Expand Up @@ -167,12 +169,14 @@ export class BaseActionItem implements IActionItem {
public focus(): void {
if (this.builder) {
this.builder.domFocus();
this.builder.addClass('focused');
}
}

public blur(): void {
if (this.builder) {
this.builder.domBlur();
this.builder.removeClass('focused');
}
}

Expand Down Expand Up @@ -273,7 +277,11 @@ export class ActionItem extends BaseActionItem {

public _updateLabel(): void {
if (this.options.label) {
this.$e.text(this.getAction().label);
let label = this.getAction().label;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbatten shouldn't the concept of mnemonics only be used when the action shows up in a menu? It seems to me your changes make this happen anywhere the action is showing up. Maybe this should be an option for the action item to pass through to enable this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I followed the pattern I thought was present in the electron menu. If the action item label has &&, it will create a mnemonic. I only pass these in menu creation. I might be able to move this to ui/menu.ts if you prefer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbatten how about an option to control this behaviour? would that be easy to add?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bpasero in the interest of getting some insider testing, are you willing to put off changing this in the next check-in? I'd like to focus on items that need to be fixed for initial insider testing so I can then shift to the milestone goal (this included)

if (label && this.options.isMenu) {
label = label.replace(BaseActionItem.MNEMONIC_REGEX, '$1\u0332');
}
this.$e.text(label);
}
}

Expand Down Expand Up @@ -372,7 +380,6 @@ export class ActionBar implements IActionRunner {

// Items
public items: IActionItem[];

private focusedItem: number;
private focusTracker: DOM.IFocusTracker;

Expand Down Expand Up @@ -487,7 +494,7 @@ export class ActionBar implements IActionRunner {
this.actionsList = document.createElement('ul');
this.actionsList.className = 'actions-container';
if (this.options.isMenu) {
this.actionsList.setAttribute('role', 'menubar');
this.actionsList.setAttribute('role', 'menu');
} else {
this.actionsList.setAttribute('role', 'toolbar');
}
Expand Down Expand Up @@ -558,6 +565,15 @@ export class ActionBar implements IActionRunner {
return this.domNode;
}

private _addMnemonic(action: IAction, actionItemElement: HTMLElement): void {
let matches = BaseActionItem.MNEMONIC_REGEX.exec(action.label);
if (matches && matches.length === 2) {
let mnemonic = matches[1];

actionItemElement.accessKey = mnemonic.toLocaleLowerCase();
}
}

public push(arg: IAction | IAction[], options: IActionOptions = {}): void {

const actions: IAction[] = !Array.isArray(arg) ? [arg] : arg;
Expand All @@ -575,6 +591,10 @@ export class ActionBar implements IActionRunner {
e.stopPropagation();
});

if (options.isMenu) {
this._addMnemonic(action, actionItemElement);
}

let item: IActionItem = null;

if (this.options.actionItemProvider) {
Expand Down Expand Up @@ -808,4 +828,4 @@ export class SelectActionItem extends BaseActionItem {

super.dispose();
}
}
}
4 changes: 4 additions & 0 deletions src/vs/base/browser/ui/menu/menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
color: inherit;
}

.monaco-menu .monaco-action-bar.vertical .action-label.checked:after {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbatten is this used currently anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bpasero this adds the checkmark to items that have been checked in the menu, like auto save

content: ' \2713';
}

/* Context Menu */

.context-view.monaco-menu-container {
Expand Down
8 changes: 6 additions & 2 deletions src/vs/base/browser/ui/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface IMenuOptions {
actionItemProvider?: IActionItemProvider;
actionRunner?: IActionRunner;
getKeyBinding?: (action: IAction) => ResolvedKeybinding;
ariaLabel?: string;
}

export class Menu {
Expand All @@ -27,20 +28,23 @@ export class Menu {

constructor(container: HTMLElement, actions: IAction[], options: IMenuOptions = {}) {
addClass(container, 'monaco-menu-container');
container.setAttribute('role', 'presentation');

let menuContainer = document.createElement('div');
addClass(menuContainer, 'monaco-menu');
menuContainer.setAttribute('role', 'presentation');
container.appendChild(menuContainer);

this.actionBar = new ActionBar(menuContainer, {
orientation: ActionsOrientation.VERTICAL,
actionItemProvider: options.actionItemProvider,
context: options.context,
actionRunner: options.actionRunner,
isMenu: true
isMenu: true,
ariaLabel: options.ariaLabel
});

this.actionBar.push(actions, { icon: true, label: true });
this.actionBar.push(actions, { icon: true, label: true, isMenu: true });
}

public get onDidCancel(): Event<void> {
Expand Down
19 changes: 16 additions & 3 deletions src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { IWindowsService, OpenContext, ActiveWindowManager } from 'vs/platform/w
import { WindowsChannel } from 'vs/platform/windows/common/windowsIpc';
import { WindowsService } from 'vs/platform/windows/electron-main/windowsService';
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
import { CodeMenu } from 'vs/code/electron-main/menus';
import { getShellEnvironment } from 'vs/code/node/shellEnv';
import { IUpdateService } from 'vs/platform/update/common/update';
import { UpdateChannel } from 'vs/platform/update/common/updateIpc';
Expand Down Expand Up @@ -61,6 +60,11 @@ import { LogLevelSetterChannel } from 'vs/platform/log/common/logIpc';
import { setUnexpectedErrorHandler } from 'vs/base/common/errors';
import { ElectronURLListener } from 'vs/platform/url/electron-main/electronUrlListener';
import { serve as serveDriver } from 'vs/platform/driver/electron-main/driver';
import { IMenubarService } from 'vs/platform/menubar/common/menubar';
import { MenubarService } from 'vs/platform/menubar/electron-main/menubarService';
import { MenubarChannel } from 'vs/platform/menubar/common/menubarIpc';
// TODO@sbatten: Remove after conversion to new dynamic menubar
import { CodeMenu } from 'vs/code/electron-main/menus';

export class CodeApplication {

Expand Down Expand Up @@ -340,6 +344,7 @@ export class CodeApplication {
services.set(IWindowsService, new SyncDescriptor(WindowsService, this.sharedProcess));
services.set(ILaunchService, new SyncDescriptor(LaunchService));
services.set(IIssueService, new SyncDescriptor(IssueService, machineId, this.userEnv));
services.set(IMenubarService, new SyncDescriptor(MenubarService));

// Telemtry
if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
Expand Down Expand Up @@ -383,6 +388,10 @@ export class CodeApplication {
this.electronIpcServer.registerChannel('windows', windowsChannel);
this.sharedProcessClient.done(client => client.registerChannel('windows', windowsChannel));

const menubarService = accessor.get(IMenubarService);
const menubarChannel = new MenubarChannel(menubarService);
this.electronIpcServer.registerChannel('menubar', menubarChannel);

const urlService = accessor.get(IURLService);
const urlChannel = new URLServiceChannel(urlService);
this.electronIpcServer.registerChannel('url', urlChannel);
Expand Down Expand Up @@ -447,7 +456,6 @@ export class CodeApplication {
}

private afterWindowOpen(accessor: ServicesAccessor): void {
const appInstantiationService = accessor.get(IInstantiationService);
const windowsMainService = accessor.get(IWindowsMainService);

let windowsMutex: Mutex = null;
Expand Down Expand Up @@ -487,8 +495,13 @@ export class CodeApplication {
}
}

// TODO@sbatten: Remove when menu is converted
// Install Menu
appInstantiationService.createInstance(CodeMenu);
const instantiationService = accessor.get(IInstantiationService);
const configurationService = accessor.get(IConfigurationService);
if (platform.isMacintosh || configurationService.getValue<string>('window.titleBarStyle') !== 'custom') {
instantiationService.createInstance(CodeMenu);
}

// Jump List
this.historyMainService.updateWindowsJumpList();
Expand Down
Loading