2016-11-27 11:54:12 +00:00
|
|
|
const {app, BrowserWindow,TouchBar} = require('electron')
|
2016-07-06 18:47:21 +00:00
|
|
|
const path = require('path')
|
2013-07-17 08:21:33 +00:00
|
|
|
|
2016-07-06 18:47:21 +00:00
|
|
|
let mainWindow = null
|
2013-07-17 08:21:33 +00:00
|
|
|
|
|
|
|
// Quit when all windows are closed.
|
2016-05-06 23:53:50 +00:00
|
|
|
app.on('window-all-closed', () => {
|
2016-03-24 20:15:04 +00:00
|
|
|
app.quit()
|
|
|
|
})
|
2013-07-17 08:21:33 +00:00
|
|
|
|
2016-05-06 23:53:50 +00:00
|
|
|
exports.load = (appUrl) => {
|
|
|
|
app.on('ready', () => {
|
2016-07-06 18:47:21 +00:00
|
|
|
const options = {
|
2016-02-04 18:26:11 +00:00
|
|
|
width: 800,
|
|
|
|
height: 600,
|
|
|
|
autoHideMenuBar: true,
|
2016-04-26 16:25:46 +00:00
|
|
|
backgroundColor: '#FFFFFF',
|
2016-03-27 17:38:32 +00:00
|
|
|
useContentSize: true
|
2016-07-06 18:47:21 +00:00
|
|
|
}
|
|
|
|
if (process.platform === 'linux') {
|
|
|
|
options.icon = path.join(__dirname, 'icon.png')
|
|
|
|
}
|
|
|
|
|
|
|
|
mainWindow = new BrowserWindow(options)
|
2016-03-24 20:15:04 +00:00
|
|
|
mainWindow.loadURL(appUrl)
|
|
|
|
mainWindow.focus()
|
2016-11-27 11:54:12 +00:00
|
|
|
|
|
|
|
mainWindow.setTouchBar(new TouchBar([
|
|
|
|
new (TouchBar.Button)({
|
|
|
|
label: 'Hello World!',
|
2016-11-29 07:00:08 +00:00
|
|
|
// image: '/path/to/image',
|
2016-11-28 10:46:32 +00:00
|
|
|
backgroundColor: "FF0000",
|
|
|
|
labelColor: "0000FF",
|
2016-11-27 11:54:12 +00:00
|
|
|
click: () => {
|
|
|
|
console.log('Hello World Clicked')
|
|
|
|
}
|
2016-11-28 07:24:48 +00:00
|
|
|
}),
|
|
|
|
new (TouchBar.Label)({
|
|
|
|
label: 'This is a Label'
|
|
|
|
}),
|
|
|
|
new (TouchBar.ColorPicker)({
|
2016-11-28 10:43:39 +00:00
|
|
|
change: (newColor) => {
|
|
|
|
console.log('Color was changed', newColor)
|
2016-11-28 07:24:48 +00:00
|
|
|
}
|
2016-11-28 10:43:39 +00:00
|
|
|
}),
|
2016-11-29 07:00:08 +00:00
|
|
|
new (TouchBar.PopOver)({
|
|
|
|
// image: '/path/to/image',
|
|
|
|
label: 'foo',
|
|
|
|
showCloseButton: true,
|
|
|
|
touchBar: new TouchBar([
|
2016-11-29 07:36:57 +00:00
|
|
|
new (TouchBar.Group)({
|
|
|
|
items: new TouchBar(
|
|
|
|
[1, 2, 3].map((i) => new (TouchBar.Button)({
|
|
|
|
label: `Button ${i}`,
|
|
|
|
click: () => {
|
|
|
|
console.log(`Button ${i} (group) Clicked`)
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
)
|
2016-11-29 07:00:08 +00:00
|
|
|
})
|
|
|
|
])
|
|
|
|
}),
|
2016-11-28 10:43:39 +00:00
|
|
|
new (TouchBar.Slider)({
|
|
|
|
label: 'Slider 123',
|
|
|
|
minValue: 50,
|
|
|
|
maxValue: 1000,
|
2016-11-28 10:46:32 +00:00
|
|
|
initialValue: 300,
|
2016-11-28 10:43:39 +00:00
|
|
|
change: (newVal) => {
|
|
|
|
console.log('Slider was changed', newVal, typeof newVal)
|
|
|
|
}
|
|
|
|
}),
|
2016-11-27 11:54:12 +00:00
|
|
|
]))
|
2016-03-24 20:15:04 +00:00
|
|
|
})
|
|
|
|
}
|