add some touchbar goodness

master
Dave Conway-Jones 2020-10-03 18:50:44 +01:00
rodzic ad7b3d00fc
commit 54040e45ce
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 88BA2B8A411BE9FF
2 zmienionych plików z 47 dodań i 8 usunięć

42
main.js
Wyświetl plik

@ -36,11 +36,12 @@ const express = require("express");
const electron = require('electron');
const isDev = require('electron-is-dev');
const {app, Menu} = electron;
const {app, Menu, TouchBar} = electron;
const ipc = electron.ipcMain;
const dialog = electron.dialog;
const BrowserWindow = electron.BrowserWindow;
const Tray = electron.Tray;
const { TouchBarButton } = TouchBar;
var RED = require("node-red");
var red_app = express();
@ -313,6 +314,15 @@ function createConsole() {
conWindow = null;
});
//conWindow.webContents.openDevTools();
const touchButton4 = new TouchBarButton({
label: 'Clear Log',
backgroundColor: '#910000',
click: () => { logBuffer = []; conWindow.webContents.send('logBuff', logBuffer); }
});
const consoleTouchBar = new TouchBar({
items: [ touchButton4 ]
});
conWindow.setTouchBar(consoleTouchBar);
}
// Create the main browser window
@ -374,6 +384,35 @@ function createWindow() {
mainWindow = null;
});
// If on a Mac add some touchbar buttons...
if (process.platform === 'darwin') {
const touchButton1 = new TouchBarButton({
label: 'Editor',
backgroundColor: '#910000',
click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urledit); }
});
const touchButton2 = new TouchBarButton({
label: 'Dashboard',
backgroundColor: '#910000',
click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urldash); }
});
const touchButton3 = new TouchBarButton({
label: 'Map',
backgroundColor: '#910000',
click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urlmap); }
});
var items = [ touchButton2 ];
if (editable) { items.push(touchButton1) }
if (showMap) { items.push(touchButton3) }
const mainTouchBar = new TouchBar({ items: items });
mainWindow.setTouchBar(mainTouchBar);
}
// Start the app full screen
//mainWindow.setFullScreen(true)
@ -410,7 +449,6 @@ app.on('ready', () => {
})
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar

Wyświetl plik

@ -52,13 +52,14 @@
},
"homepage": "https://github.com/dceejay/electron-node-red#readme",
"devDependencies": {
"electron": "~10.1.1",
"electron-builder": "^22.8.0"
"electron": "~10.1.3",
"electron-builder": "^22.8.1"
},
"build": {
"appId": "com.electron.node-red",
"productName": "Node-RED Electron",
"copyright": "Copyright © 2018,2020 D.Conway-Jones",
"buildDependenciesFromSource": true,
"files": [
"**/*",
{