Skip to content

Commit b7cf9e6

Browse files
committed
Removed menu, changed colors
Signed-off-by: jbicker <jan.bicker@typefox.io>
1 parent 1d6ba97 commit b7cf9e6

File tree

9 files changed

+1038
-2451
lines changed

9 files changed

+1038
-2451
lines changed

arduino-ide-extension/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
{
4545
"backend": "lib/node/arduino-backend-module",
4646
"frontend": "lib/browser/arduino-frontend-module"
47+
},
48+
{
49+
"frontendElectron": "lib/electron-browser/electron-arduino-frontend-module"
4750
}
4851
]
4952
}

arduino-ide-extension/src/browser/arduino-frontend-module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import { OutlineViewContribution } from '@theia/outline-view/lib/browser/outline
3333
import { SilentOutlineViewContribution } from './customization/silent-outline-contribution';
3434
import { ProblemContribution } from '@theia/markers/lib/browser/problem/problem-contribution';
3535
import { SilentProblemContribution } from './customization/silent-problem-contribution';
36+
import { BrowserMenuBarContribution } from '@theia/core/lib/browser/menu/browser-menu-plugin';
37+
import { ArduinoMenuContribution } from './menu/arduino-menu-contribution';
3638

3739
export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => {
3840
// Commands and toolbar items
@@ -41,6 +43,8 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
4143
bind(TabBarToolbarContribution).toService(ArduinoFrontendContribution);
4244
bind(MenuContribution).to(ArduinoFileMenuContribution).inSingletonScope();
4345

46+
rebind(BrowserMenuBarContribution).to(ArduinoMenuContribution);
47+
4448
// `ino` TextMate grammar
4549
bind(LanguageGrammarDefinitionContribution).to(ArduinoLanguageGrammarContribution).inSingletonScope();
4650

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { injectable } from "inversify";
2+
import { BrowserMenuBarContribution } from "@theia/core/lib/browser/menu/browser-menu-plugin";
3+
import { FrontendApplication } from "@theia/core/lib/browser";
4+
5+
@injectable()
6+
export class ArduinoMenuContribution extends BrowserMenuBarContribution {
7+
onStart(app: FrontendApplication): void {
8+
if (this.isProMode()) {
9+
const menu = this.factory.createMenuBar();
10+
app.shell.addWidget(menu, { area: 'top' });
11+
}
12+
}
13+
14+
protected isProMode(): boolean {
15+
// TODO ask for pro preference
16+
return false;
17+
}
18+
}

arduino-ide-extension/src/browser/style/arduino.useable.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ is not optimized for dense, information rich UIs.
1818

1919
:root {
2020
/* Custom Theme Colors */
21-
--theia-arduino-light: rgb(0, 102, 105);
22-
--theia-arduino-light1: rgb(0, 164, 167);
21+
--theia-arduino-light: rgb(0, 102, 102);
22+
--theia-arduino-light1: rgb(0, 153, 153);
2323
/* Borders: Width and color (bright to dark) */
2424
--theia-border-width: 1px;
2525
--theia-panel-border-width: 2px;
@@ -74,9 +74,9 @@ is not optimized for dense, information rich UIs.
7474
/* Main layout colors (bright to dark)
7575
------------------------------------ */
7676
--theia-layout-color0: #ffffff;
77-
--theia-layout-color1: #f3f3f3;
77+
--theia-layout-color1: var(--theia-arduino-light1);
7878
--theia-layout-color2: #ececec;
79-
--theia-layout-color3: #dcdcdc;
79+
--theia-layout-color3: var(--theia-arduino-light);
8080
--theia-layout-color4: #dcdcdc;
8181
/* Brand colors */
8282
--theia-brand-color0: var(--md-blue-700);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ContainerModule } from "inversify";
2+
import { ElectronArduinoMainMenuFactory } from "./electron-arduino-main-menu-factory";
3+
import { ElectronMainMenuFactory } from "@theia/core/lib/electron-browser/menu/electron-main-menu-factory";
4+
import { ElectronMenuContribution } from "@theia/core/lib/electron-browser/menu/electron-menu-contribution"
5+
import { ElectronArduinoMenuContribution } from "./electron-arduino-menu-contribution";
6+
7+
export default new ContainerModule((bind, unbind, isBound, rebind) => {
8+
bind(ElectronArduinoMainMenuFactory).toSelf().inSingletonScope();
9+
rebind(ElectronMainMenuFactory).to(ElectronArduinoMainMenuFactory);
10+
11+
bind(ElectronArduinoMenuContribution).toSelf().inSingletonScope();
12+
rebind(ElectronMenuContribution).to(ElectronArduinoMenuContribution);
13+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { injectable } from "inversify";
2+
import * as electron from 'electron';
3+
import { ElectronMainMenuFactory } from "@theia/core/lib/electron-browser/menu/electron-main-menu-factory";
4+
import {
5+
isOSX
6+
} from '@theia/core/lib/common';
7+
8+
@injectable()
9+
export class ElectronArduinoMainMenuFactory extends ElectronMainMenuFactory {
10+
createMenuBar(): Electron.Menu {
11+
const menuModel = this.menuProvider.getMenu();
12+
const template = this.fillMenuTemplate([], menuModel);
13+
if (isOSX) {
14+
template.unshift(this.createOSXMenu());
15+
}
16+
const menu = electron.remote.Menu.buildFromTemplate(template);
17+
this._menu = menu;
18+
return menu;
19+
}
20+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import * as electron from 'electron';
2+
import { injectable } from "inversify";
3+
import { ElectronMenuContribution } from "@theia/core/lib/electron-browser/menu/electron-menu-contribution";
4+
import { FrontendApplication } from "@theia/core/lib/browser";
5+
import { isOSX } from '@theia/core';
6+
7+
@injectable()
8+
export class ElectronArduinoMenuContribution extends ElectronMenuContribution {
9+
onStart(app: FrontendApplication): void {
10+
if (this.isProMode()) {
11+
const currentWindow = electron.remote.getCurrentWindow();
12+
const createdMenuBar = this.factory.createMenuBar();
13+
14+
if (isOSX) {
15+
electron.remote.Menu.setApplicationMenu(createdMenuBar);
16+
currentWindow.on('focus', () =>
17+
// OSX: Recreate the menus when changing windows.
18+
// OSX only has one menu bar for all windows, so we need to swap
19+
// between them as the user switch windows.
20+
electron.remote.Menu.setApplicationMenu(this.factory.createMenuBar())
21+
);
22+
23+
} else {
24+
// Unix/Windows: Set the per-window menus
25+
currentWindow.setMenu(createdMenuBar);
26+
}
27+
}
28+
}
29+
30+
protected isProMode(): boolean {
31+
return false;
32+
}
33+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"prepare": "lerna run prepare",
1515
"rebuild:browser": "theia rebuild:browser",
1616
"rebuild:electron": "theia rebuild:electron",
17-
"start": "cd arduino-ide-browser && yarn start"
17+
"start": "cd arduino-ide-browser && yarn start",
18+
"watch": "lerna run watch --parallel"
1819
},
1920
"workspaces": [
2021
"arduino-ide-electron",

0 commit comments

Comments
 (0)