Skip to content

Commit

Permalink
Merge branch 'feature/open_detail_window' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mamarguerat committed Feb 21, 2024
2 parents 290442c + fea6369 commit 0ab12c5
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Behringer routing tool
A tool to simplify routing with behringer x-consoles, midas m-consoles and behringer wing.

<img src="images/2023-07-19_14-18-10%20(1).gif" >
<img src="public/assets/images/2023-07-19_14-18-10%20(1).gif" >

## Simplify routing
- This tool has a user-friendly user interface to simplify routing
Expand Down
32 changes: 32 additions & 0 deletions device-detail-preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { contextBridge, ipcRenderer } = require('electron')
const path = require('path')

const publicPath =
process.env.NODE_ENV === 'development'
? './public'
: path.join(process.resourcesPath, 'public');
const imagesPath = path.join(publicPath, "assets", "images");

function selectTopDiv(ele) {
while (!ele.classList.contains('device') && ele.tagName != "INPUT") {
ele = ele.parentElement;
}
return ele;
}

function enableDoubleClick(ele) {
ele.ondblclick = function (ev) {
current = selectTopDiv(ev.target);
}
}

function enableRightClick(ele) {
ele.oncontextmenu = function (ev) {
current = selectTopDiv(ev.target);
}
}

ipcRenderer.on('type', (event, arg) => {
console.log(arg)
document.getElementById("canvas").innerHTML += "<div id='0' class='device detail " + arg + "' style='top: 0px; left: 0px;'><img class='detail' draggable='false' src='" + path.join(imagesPath, arg + ".svg") + "'></div>";
});
20 changes: 20 additions & 0 deletions device-detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<script>
window.$ = window.jQuery = require("jquery");
</script>
<link rel="stylesheet" href="./style.css">
<title>Device detail</title>
</head>
<body>
<!--<h1>Mixers routing tool</h1>
<p>👋</p>
<p id="info"></p>
<button type="button" onclick="document.getElementById('demo').innerHTML = Date()">Click Me!</button>
<p id="demo"></p>-->
<div id="canvas">
</div>
</body>
<script src="./device-detail-renderer.js"></script>
</html>
34 changes: 25 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ app.on("ready", () => {
autoUpdater.checkForUpdatesAndNotify();
});


const menuTemplate = [
{ role: 'appMenu' },
{
Expand Down Expand Up @@ -124,6 +123,11 @@ const createWindow = () => {
};

app.whenReady().then(() => {
if (!app.isPackaged)
{
process.env.NODE_ENV = 'development';
}

Menu.setApplicationMenu(menu);
createWindow();

Expand All @@ -141,13 +145,25 @@ app.on('window-all-closed', () => {
}
});

var childWindow;

ipcMain.on('window', (event, arg) => {
const window = new BrowserWindow({
height: 600,
width: 800
});
window.loadURL('https://stackoverflow.com/questions/53390798/opening-new-window-electron');
window.once('ready-to-show', () => {
window.show()
createChildWindow("device-detail.html", "device-detail-preload.js")
childWindow.webContents.send('type', arg)
})

// function to create a child window
function createChildWindow(fileName, preloadFileName) {
childWindow = new BrowserWindow({
width: 1000,
height: 700,
parent : win, // accessing the parent window
webPreferences: {
preload: path.join(__dirname, preloadFileName),
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
}
})
})
childWindow.loadFile(fileName)
}
5 changes: 4 additions & 1 deletion preload.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const { contextBridge, ipcRenderer } = require('electron')
const path = require('path')

// Uncomment for npm start command
// process.env.NODE_ENV = 'development'

const publicPath =
process.env.NODE_ENV === 'development'
? path.join(__dirname, './public')
? './public'
: path.join(process.resourcesPath, 'public');
const imagesPath = path.join(publicPath, "assets", "images");

Expand Down
5 changes: 5 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ html, body {
}
.sd16 img {
width: 200px;
}

.detail {
width: 100% !important;
height: 100% !important;
}

0 comments on commit 0ab12c5

Please sign in to comment.