pointvec/main.js

72 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-11-04 20:52:05 -04:00
const {app, BrowserWindow, webFrame, Menu} = require('electron')
const path = require('path')
const url = require('url')
2017-12-26 17:14:58 -05:00
const shell = require('electron').shell
2017-11-04 20:52:05 -04:00
let win
2018-01-12 03:09:26 -05:00
app.inspect = function()
{
win.webContents.openDevTools();
}
app.inject_menu = function(m)
{
Menu.setApplicationMenu(Menu.buildFromTemplate(m));
}
2017-11-04 20:52:05 -04:00
app.on('ready', () =>
{
2017-12-26 17:12:23 -05:00
win = new BrowserWindow({width: 400, height: 420, minWidth: 400, minHeight: 400, backgroundColor:"#000", frame:false, autoHideMenuBar: true, icon: __dirname + '/icon.ico'})
2017-11-04 20:52:05 -04:00
let is_shown = true;
2017-12-26 17:12:23 -05:00
Menu.setApplicationMenu(Menu.buildFromTemplate([
{ label: 'File', submenu: [
{ label: 'Inspector', accelerator: 'CmdOrCtrl+.', click: () => { win.webContents.openDevTools(); }},
{ label: 'Guide', accelerator: 'CmdOrCtrl+,', click: () => { shell.openExternal('https://github.com/hundredrabbits/Dotgrid'); }},
{ label: 'Quit', accelerator: 'CmdOrCtrl+Q', click: () => { force_quit=true; app.exit(); }}
]
},
{ label: 'Window', submenu : [
{ label: 'Hide', accelerator: 'CmdOrCtrl+H',click: () => { if(is_shown){ win.hide(); } else{ win.show(); }}},
{ label: 'Minimize', accelerator: 'CmdOrCtrl+M',click: () => { win.minimize(); }},
{ label: 'Fullscreen', accelerator: 'CmdOrCtrl+Enter',click: () => { win.setFullScreen(win.isFullScreen() ? false : true); }}
]
}
]));
2017-11-04 20:52:05 -04:00
2018-01-12 03:09:26 -05:00
win.loadURL(`file://${__dirname}/sources/index.html`)
win.webContents.on('did-finish-load', () => {
win.webContents.send('controller-access', "hello");
})
2017-11-04 20:52:05 -04:00
win.on('closed', () => {
win = null
app.quit()
})
win.on('hide',function() {
is_shown = false;
})
win.on('show',function() {
2018-01-12 03:09:26 -05:00
var something = {name:"fuck"}
2017-11-04 20:52:05 -04:00
is_shown = true;
})
})
app.on('window-all-closed', () =>
{
app.quit()
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
else{
}
})