-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from AceCentre/create-overlay-to-measure
Create overlay to measure
- Loading branch information
Showing
7 changed files
with
785 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const { ipcRenderer } = require('electron'); | ||
|
||
let isSelecting = false; | ||
let startX, startY, endX, endY; | ||
|
||
// This listens for the mouse events to capture the coordinates | ||
window.addEventListener('mousedown', (event) => { | ||
isSelecting = true; | ||
startX = event.clientX; | ||
startY = event.clientY; | ||
console.log('Selection started at:', { x: startX, y: startY }); | ||
}); | ||
|
||
window.addEventListener('mousemove', (event) => { | ||
if (isSelecting) { | ||
endX = event.clientX; | ||
endY = event.clientY; | ||
console.log('Selection moving:', { endX, endY }); | ||
} | ||
}); | ||
|
||
window.addEventListener('mouseup', (event) => { | ||
if (isSelecting) { | ||
isSelecting = false; | ||
endX = event.clientX; | ||
endY = event.clientY; | ||
console.log('Selection ended at:', { x: endX, y: endY }); | ||
|
||
// Calculate the bounds | ||
const bounds = { | ||
x: Math.min(startX, endX), | ||
y: Math.min(startY, endY), | ||
width: Math.abs(endX - startX), | ||
height: Math.abs(endY - startY) | ||
}; | ||
|
||
console.log('Bounds calculated:', bounds); | ||
|
||
// Send bounds to the main process | ||
ipcRenderer.send('set-capture-area', bounds); | ||
} | ||
}); |
Oops, something went wrong.