titlebar & close btn

This commit is contained in:
punkfairie 2023-05-13 12:26:25 -07:00
parent 5dd978e491
commit e34000e84e
3 changed files with 76 additions and 53 deletions

View file

@ -4,9 +4,17 @@
<meta charset="UTF-8">
<title>ED Safari v0.0.1</title>
</head>
<body>
<body data-bs-theme="dark">
<div id="titlebar" class="draggable container-fluid mt-2">
<div class="row justify-content-end">
<div class="col-auto">
<button type="button" class="btn-close" onclick="closeApp()"></button>
</div>
</div>
</div>
<!-- CURRENT LOCATION -->
<div class="container-fluid">
<div class="container-fluid draggable">
<div class="row separator align-items-center">
<div class="col"><hr class="separator"></div>
<div class="col-auto">Current Location</div>

View file

@ -176,4 +176,17 @@ div b.active.landable {
/* SET THIS TO PARENT VIA CSS */
.form-control:focus {
border-color: var(--main);
}
.draggable {
-webkit-app-region: drag;
-webkit-user-select: none;
user-select: none;
}
#titlebar .btn-close {
-webkit-app-region: no-drag;
filter: drop-shadow(0 0px 3px var(--grey-text)) var(--bs-btn-close-white-filter);
width: 0.4em;
height: 0.4em;
}

View file

@ -14,6 +14,8 @@ const createWindow = () => {
mainWindow = new BrowserWindow({
width: 1000,
height: 800,
backgroundColor: 'black',
frame: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
@ -60,60 +62,60 @@ app.on('activate', () => {
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
const openSettings = async () => {
settingsWindow = new BrowserWindow({
width: 800,
height: 600,
parent: mainWindow,
modal: true,
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
additionalArguments: [`EDS-ENV=${app.isPackaged}`],
},
});
// const openSettings = async () => {
// settingsWindow = new BrowserWindow({
// width: 800,
// height: 600,
// parent: mainWindow,
// modal: true,
// show: false,
// webPreferences: {
// nodeIntegration: true,
// contextIsolation: false,
// additionalArguments: [`EDS-ENV=${app.isPackaged}`],
// },
// });
if (SETTINGS_WINDOW_VITE_DEV_SERVER_URL) {
settingsWindow.loadURL(`${SETTINGS_WINDOW_VITE_DEV_SERVER_URL}/settings.html`);
} else {
settingsWindow.loadFile(path.join(__dirname, `../renderer/${SETTINGS_WINDOW_VITE_NAME}/settings.html`));
}
// if (SETTINGS_WINDOW_VITE_DEV_SERVER_URL) {
// settingsWindow.loadURL(`${SETTINGS_WINDOW_VITE_DEV_SERVER_URL}/settings.html`);
// } else {
// settingsWindow.loadFile(path.join(__dirname, `../renderer/${SETTINGS_WINDOW_VITE_NAME}/settings.html`));
// }
// Open the DevTools.
if (!app.isPackaged) {
settingsWindow.webContents.openDevTools();
}
// // Open the DevTools.
// if (!app.isPackaged) {
// settingsWindow.webContents.openDevTools();
// }
settingsWindow.show();
// settingsWindow.show();
// Make sure window is destroyed on close, or else it won't open again.
settingsWindow.on('closed', () => {
settingsWindow = undefined;
});
}
// // Make sure window is destroyed on close, or else it won't open again.
// settingsWindow.on('closed', () => {
// settingsWindow = undefined;
// });
// }
const menuTemplate = [
{
label: 'File',
submenu: [
{ label: 'Settings', click: async () => { openSettings(); } },
{ role: 'quit' }
]
},
{
role: 'help',
submenu: [
{
label: 'Github',
click: async () => {
const { shell } = require('electron');
await shell.openExternal('https://github.com/punkfairie/ed-safari');
}
}
]
}
]
// const menuTemplate = [
// {
// label: 'File',
// submenu: [
// { label: 'Settings', click: async () => { openSettings(); } },
// { role: 'quit' }
// ]
// },
// {
// role: 'help',
// submenu: [
// {
// label: 'Github',
// click: async () => {
// const { shell } = require('electron');
// await shell.openExternal('https://github.com/punkfairie/ed-safari');
// }
// }
// ]
// }
// ]
const menu = Menu.buildFromTemplate(menuTemplate)
Menu.setApplicationMenu(menu)
// const menu = Menu.buildFromTemplate(menuTemplate)
// Menu.setApplicationMenu(menu)