mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-09 20:36:32 +00:00
Merge pull request #32 from bcmi-labs/bring-back-menu
PROEDITOR-22: Brought back the menu.
This commit is contained in:
commit
5a97a71d9b
@ -17,6 +17,7 @@
|
||||
"@theia/outline-view": "next",
|
||||
"@theia/workspace": "next",
|
||||
"@theia/navigator": "next",
|
||||
"@theia/terminal": "next",
|
||||
"p-queue": "^5.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
|
@ -15,23 +15,32 @@ import { QuickPickService } from '@theia/core/lib/common/quick-pick-service';
|
||||
import { BoardsListWidgetFrontendContribution } from './boards/boards-widget-frontend-contribution';
|
||||
import { BoardsNotificationService } from './boards-notification-service';
|
||||
import { WorkspaceRootUriAwareCommandHandler, WorkspaceCommands } from '@theia/workspace/lib/browser/workspace-commands';
|
||||
import { SelectionService, MenuModelRegistry } from '@theia/core';
|
||||
import { SelectionService, MenuContribution, MenuModelRegistry, MAIN_MENU_BAR } from '@theia/core';
|
||||
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
||||
import { SketchFactory } from './sketch-factory';
|
||||
import { ArduinoToolbar } from './toolbar/arduino-toolbar';
|
||||
import { EditorManager } from '@theia/editor/lib/browser';
|
||||
import { EditorManager, EditorMainMenu } from '@theia/editor/lib/browser';
|
||||
import { ContextMenuRenderer, OpenerService, Widget } from '@theia/core/lib/browser';
|
||||
import { OpenFileDialogProps, FileDialogService } from '@theia/filesystem/lib/browser/file-dialog';
|
||||
import { FileSystem } from '@theia/filesystem/lib/common';
|
||||
import { ArduinoToolbarContextMenu } from './arduino-file-menu';
|
||||
import { Sketch, SketchesService } from '../common/protocol/sketches-service';
|
||||
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
||||
import { CommonCommands } from '@theia/core/lib/browser/common-frontend-contribution'
|
||||
import { BoardsToolBarItem } from './boards/boards-toolbar-item';
|
||||
import { CommonCommands, CommonMenus } from '@theia/core/lib/browser/common-frontend-contribution';
|
||||
import { FileSystemCommands } from '@theia/filesystem/lib/browser/filesystem-frontend-contribution';
|
||||
import { FileDownloadCommands } from '@theia/filesystem/lib/browser/download/file-download-command-contribution';
|
||||
import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu';
|
||||
import {TerminalMenus} from '@theia/terminal/lib/browser/terminal-frontend-contribution';
|
||||
import { SelectBoardDialog } from './boards/select-board-dialog';
|
||||
import { BoardsToolBarItem } from './boards/boards-toolbar-item';
|
||||
|
||||
export namespace ArduinoMenus {
|
||||
export const SKETCH = [...MAIN_MENU_BAR, '3_sketch'];
|
||||
export const TOOLS = [...MAIN_MENU_BAR, '4_tools'];
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class ArduinoFrontendContribution implements TabBarToolbarContribution, CommandContribution {
|
||||
export class ArduinoFrontendContribution implements TabBarToolbarContribution, CommandContribution, MenuContribution {
|
||||
|
||||
@inject(MessageService)
|
||||
protected readonly messageService: MessageService;
|
||||
@ -180,7 +189,7 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C
|
||||
registerCommands(registry: CommandRegistry): void {
|
||||
registry.registerCommand(ArduinoCommands.VERIFY, {
|
||||
isVisible: widget => this.isArduinoToolbar(widget),
|
||||
isEnabled: widget => this.isArduinoToolbar(widget),
|
||||
isEnabled: widget => true,
|
||||
execute: async () => {
|
||||
const widget = this.getCurrentWidget();
|
||||
if (widget instanceof EditorWidget) {
|
||||
@ -201,7 +210,7 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C
|
||||
});
|
||||
registry.registerCommand(ArduinoCommands.UPLOAD, {
|
||||
isVisible: widget => this.isArduinoToolbar(widget),
|
||||
isEnabled: widget => this.isArduinoToolbar(widget),
|
||||
isEnabled: widget => true,
|
||||
execute: async () => {
|
||||
const widget = this.getCurrentWidget();
|
||||
if (widget instanceof EditorWidget) {
|
||||
@ -292,6 +301,46 @@ export class ArduinoFrontendContribution implements TabBarToolbarContribution, C
|
||||
}
|
||||
this.selectedBoard = board;
|
||||
}
|
||||
|
||||
registerMenus(registry: MenuModelRegistry) {
|
||||
registry.unregisterMenuAction(FileSystemCommands.UPLOAD);
|
||||
registry.unregisterMenuAction(FileDownloadCommands.DOWNLOAD);
|
||||
|
||||
registry.unregisterMenuAction(WorkspaceCommands.NEW_FILE);
|
||||
registry.unregisterMenuAction(WorkspaceCommands.NEW_FOLDER);
|
||||
|
||||
registry.unregisterMenuAction(WorkspaceCommands.OPEN_FOLDER);
|
||||
registry.unregisterMenuAction(WorkspaceCommands.OPEN_WORKSPACE);
|
||||
registry.unregisterMenuAction(WorkspaceCommands.OPEN_RECENT_WORKSPACE);
|
||||
registry.unregisterMenuAction(WorkspaceCommands.SAVE_WORKSPACE_AS);
|
||||
registry.unregisterMenuAction(WorkspaceCommands.CLOSE);
|
||||
|
||||
registry.getMenu(MAIN_MENU_BAR).removeNode(this.getMenuId(MonacoMenus.SELECTION));
|
||||
registry.getMenu(MAIN_MENU_BAR).removeNode(this.getMenuId(EditorMainMenu.GO));
|
||||
registry.getMenu(MAIN_MENU_BAR).removeNode(this.getMenuId(TerminalMenus.TERMINAL));
|
||||
registry.getMenu(MAIN_MENU_BAR).removeNode(this.getMenuId(CommonMenus.VIEW));
|
||||
registry.getMenu(MAIN_MENU_BAR).removeNode(this.getMenuId(CommonMenus.HELP));
|
||||
|
||||
registry.registerSubmenu(ArduinoMenus.SKETCH, 'Sketch');
|
||||
registry.registerMenuAction(ArduinoMenus.SKETCH, {
|
||||
commandId: ArduinoCommands.VERIFY.id,
|
||||
label: 'Verify/Compile',
|
||||
order: '1'
|
||||
});
|
||||
registry.registerMenuAction(ArduinoMenus.SKETCH, {
|
||||
commandId: ArduinoCommands.UPLOAD.id,
|
||||
label: 'Upload',
|
||||
order: '2'
|
||||
});
|
||||
|
||||
registry.registerSubmenu(ArduinoMenus.TOOLS, 'Tools');
|
||||
}
|
||||
|
||||
protected getMenuId(menuPath: string[]): string {
|
||||
const index = menuPath.length - 1;
|
||||
const menuId = menuPath[index];
|
||||
return menuId;
|
||||
}
|
||||
|
||||
protected async openSketchFilesInNewWindow(uri: string) {
|
||||
const location = new URL(window.location.href);
|
||||
|
@ -55,6 +55,7 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
|
||||
// Commands and toolbar items
|
||||
bind(ArduinoFrontendContribution).toSelf().inSingletonScope();
|
||||
bind(CommandContribution).toService(ArduinoFrontendContribution);
|
||||
bind(MenuContribution).toService(ArduinoFrontendContribution);
|
||||
bind(TabBarToolbarContribution).toService(ArduinoFrontendContribution);
|
||||
bind(FrontendApplicationContribution).toService(ArduinoFrontendContribution);
|
||||
bind(MenuContribution).to(ArduinoToolbarMenuContribution).inSingletonScope();
|
||||
|
@ -3,6 +3,8 @@ import { FrontendApplicationContribution } from '@theia/core/lib/browser/fronten
|
||||
import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
|
||||
import { ListWidget } from './list-widget';
|
||||
import { BoardsListWidget } from './boards-list-widget';
|
||||
import { MenuModelRegistry } from '@theia/core';
|
||||
import { ArduinoMenus } from '../arduino-frontend-contribution';
|
||||
|
||||
@injectable()
|
||||
export abstract class ListWidgetFrontendContribution extends AbstractViewContribution<ListWidget> implements FrontendApplicationContribution {
|
||||
@ -16,6 +18,8 @@ export abstract class ListWidgetFrontendContribution extends AbstractViewContrib
|
||||
@injectable()
|
||||
export class BoardsListWidgetFrontendContribution extends ListWidgetFrontendContribution {
|
||||
|
||||
static readonly OPEN_MANAGER = `${BoardsListWidget.WIDGET_ID}:toggle`;
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
widgetId: BoardsListWidget.WIDGET_ID,
|
||||
@ -24,9 +28,18 @@ export class BoardsListWidgetFrontendContribution extends ListWidgetFrontendCont
|
||||
area: 'left',
|
||||
rank: 600
|
||||
},
|
||||
toggleCommandId: `${BoardsListWidget.WIDGET_ID}:toggle`,
|
||||
toggleCommandId: BoardsListWidgetFrontendContribution.OPEN_MANAGER,
|
||||
toggleKeybinding: 'ctrlcmd+shift+b'
|
||||
});
|
||||
}
|
||||
|
||||
registerMenus(menus: MenuModelRegistry): void {
|
||||
if (this.toggleCommand) {
|
||||
menus.registerMenuAction(ArduinoMenus.TOOLS, {
|
||||
commandId: this.toggleCommand.id,
|
||||
label: 'Boards Manager...'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
import { injectable } from "inversify";
|
||||
import { CommonFrontendContribution, CommonMenus, CommonCommands } from "@theia/core/lib/browser";
|
||||
import { MenuModelRegistry } from "@theia/core";
|
||||
|
||||
@injectable()
|
||||
export class CustomCommonFrontendContribution extends CommonFrontendContribution {
|
||||
registerMenus(registry: MenuModelRegistry): void {
|
||||
registry.registerSubmenu(CommonMenus.FILE, 'File');
|
||||
registry.registerSubmenu(CommonMenus.EDIT, 'Edit');
|
||||
|
||||
registry.registerSubmenu(CommonMenus.FILE_SETTINGS_SUBMENU, 'Settings');
|
||||
|
||||
registry.registerMenuAction(CommonMenus.EDIT_UNDO, {
|
||||
commandId: CommonCommands.UNDO.id,
|
||||
order: '0'
|
||||
});
|
||||
registry.registerMenuAction(CommonMenus.EDIT_UNDO, {
|
||||
commandId: CommonCommands.REDO.id,
|
||||
order: '1'
|
||||
});
|
||||
|
||||
registry.registerMenuAction(CommonMenus.EDIT_FIND, {
|
||||
commandId: CommonCommands.FIND.id,
|
||||
order: '0'
|
||||
});
|
||||
registry.registerMenuAction(CommonMenus.EDIT_FIND, {
|
||||
commandId: CommonCommands.REPLACE.id,
|
||||
order: '1'
|
||||
});
|
||||
|
||||
registry.registerMenuAction(CommonMenus.EDIT_CLIPBOARD, {
|
||||
commandId: CommonCommands.CUT.id,
|
||||
order: '0'
|
||||
});
|
||||
registry.registerMenuAction(CommonMenus.EDIT_CLIPBOARD, {
|
||||
commandId: CommonCommands.COPY.id,
|
||||
order: '1'
|
||||
});
|
||||
registry.registerMenuAction(CommonMenus.EDIT_CLIPBOARD, {
|
||||
commandId: CommonCommands.PASTE.id,
|
||||
order: '2'
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
import { injectable } from "inversify";
|
||||
import { FileMenuContribution } from "@theia/workspace/lib/browser";
|
||||
import { MenuModelRegistry } from "@theia/core";
|
||||
|
||||
@injectable()
|
||||
export class CustomFileMenuContribution extends FileMenuContribution {
|
||||
registerMenus(registry: MenuModelRegistry) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
import { injectable } from "inversify";
|
||||
import { MonacoEditorMenuContribution } from "@theia/monaco/lib/browser/monaco-menu";
|
||||
import { MenuModelRegistry } from "@theia/core";
|
||||
|
||||
@injectable()
|
||||
export class CustomMonacoEditorMenuContribution extends MonacoEditorMenuContribution {
|
||||
registerMenus(registry: MenuModelRegistry) {
|
||||
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ import { FrontendApplicationContribution } from '@theia/core/lib/browser/fronten
|
||||
import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
|
||||
import { ListWidget } from './list-widget';
|
||||
import { LibraryListWidget } from './library-list-widget';
|
||||
import { MenuModelRegistry } from '@theia/core';
|
||||
import { ArduinoMenus } from '../arduino-frontend-contribution';
|
||||
|
||||
@injectable()
|
||||
export abstract class ListWidgetFrontendContribution extends AbstractViewContribution<ListWidget> implements FrontendApplicationContribution {
|
||||
@ -29,4 +31,13 @@ export class LibraryListWidgetFrontendContribution extends ListWidgetFrontendCon
|
||||
});
|
||||
}
|
||||
|
||||
registerMenus(menus: MenuModelRegistry): void {
|
||||
if (this.toggleCommand) {
|
||||
menus.registerMenuAction(ArduinoMenus.SKETCH, {
|
||||
commandId: this.toggleCommand.id,
|
||||
label: 'Manage Libraries...'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,14 +5,7 @@ import { FrontendApplication } from "@theia/core/lib/browser";
|
||||
@injectable()
|
||||
export class ArduinoMenuContribution extends BrowserMenuBarContribution {
|
||||
onStart(app: FrontendApplication): void {
|
||||
if (this.isProMode()) {
|
||||
const menu = this.factory.createMenuBar();
|
||||
app.shell.addWidget(menu, { area: 'top' });
|
||||
}
|
||||
}
|
||||
|
||||
protected isProMode(): boolean {
|
||||
// TODO ask for pro preference
|
||||
return false;
|
||||
const menu = this.factory.createMenuBar();
|
||||
app.shell.addWidget(menu, { area: 'top' });
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ import { BrowserMenuBarContribution } from '@theia/core/lib/browser/menu/browser
|
||||
import { ArduinoMenuContribution } from './arduino-menu-contribution';
|
||||
import { ContainerModule, interfaces } from 'inversify';
|
||||
|
||||
import '../../../src/browser/style/browser-menu.css'
|
||||
|
||||
export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind) => {
|
||||
unbind(BrowserMenuBarContribution);
|
||||
bind(BrowserMenuBarContribution).to(ArduinoMenuContribution).inSingletonScope();
|
||||
|
@ -49,7 +49,7 @@ is not optimized for dense, information rich UIs.
|
||||
/* Special font colors */
|
||||
--theia-ui-icon-font-color: #ffffff;
|
||||
--theia-ui-bar-font-color0: var(--theia-ui-font-color0);
|
||||
--theia-ui-bar-font-color1: var(--theia-ui-font-color1);
|
||||
--theia-ui-bar-font-color1: var(--theia-inverse-ui-font-color0); /* var(--theia-ui-font-color1); */
|
||||
/* Use the inverse UI colors against the brand/accent/warn/error colors. */
|
||||
--theia-inverse-ui-font-color0: rgba(255, 255, 255, 1.0);
|
||||
--theia-inverse-ui-font-color2: rgba(255, 255, 255, 0.7);
|
||||
|
19
arduino-ide-extension/src/browser/style/browser-menu.css
Normal file
19
arduino-ide-extension/src/browser/style/browser-menu.css
Normal file
@ -0,0 +1,19 @@
|
||||
#theia-top-panel {
|
||||
min-height: 64px;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.p-TabBar-toolbar {
|
||||
justify-content: flex-end;
|
||||
margin: 0;
|
||||
padding-left: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.p-MenuBar-item.p-mod-active {
|
||||
color: var(--theia-inverse-ui-font-color3);
|
||||
}
|
||||
|
||||
.p-MenuBar.p-mod-active .p-MenuBar-item.p-mod-active {
|
||||
color: var(--theia-ui-bar-font-color0);
|
||||
}
|
@ -7,27 +7,21 @@ import { isOSX } from '@theia/core';
|
||||
@injectable()
|
||||
export class ElectronArduinoMenuContribution extends ElectronMenuContribution {
|
||||
onStart(app: FrontendApplication): void {
|
||||
if (this.isProMode()) {
|
||||
const currentWindow = electron.remote.getCurrentWindow();
|
||||
const createdMenuBar = this.factory.createMenuBar();
|
||||
const currentWindow = electron.remote.getCurrentWindow();
|
||||
const createdMenuBar = this.factory.createMenuBar();
|
||||
|
||||
if (isOSX) {
|
||||
electron.remote.Menu.setApplicationMenu(createdMenuBar);
|
||||
currentWindow.on('focus', () =>
|
||||
// OSX: Recreate the menus when changing windows.
|
||||
// OSX only has one menu bar for all windows, so we need to swap
|
||||
// between them as the user switch windows.
|
||||
electron.remote.Menu.setApplicationMenu(this.factory.createMenuBar())
|
||||
);
|
||||
if (isOSX) {
|
||||
electron.remote.Menu.setApplicationMenu(createdMenuBar);
|
||||
currentWindow.on('focus', () =>
|
||||
// OSX: Recreate the menus when changing windows.
|
||||
// OSX only has one menu bar for all windows, so we need to swap
|
||||
// between them as the user switch windows.
|
||||
electron.remote.Menu.setApplicationMenu(this.factory.createMenuBar())
|
||||
);
|
||||
|
||||
} else {
|
||||
// Unix/Windows: Set the per-window menus
|
||||
currentWindow.setMenu(createdMenuBar);
|
||||
}
|
||||
} else {
|
||||
// Unix/Windows: Set the per-window menus
|
||||
currentWindow.setMenu(createdMenuBar);
|
||||
}
|
||||
}
|
||||
|
||||
protected isProMode(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user