electron#Rectangle TypeScript Examples
The following examples show how to use
electron#Rectangle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: main.ts From SpaceEye with MIT License | 6 votes |
/**
* Get the position of the Windows taskbar based on the tray bounds.
*
* @param trayBounds - Current bounds of menubar tray
* @returns Position of taskbar
*/
function getWindowsTaskbarLocation(trayBounds: Rectangle): WindowsTaskbarPosition {
if (trayBounds.y === 0) {
return WindowsTaskbarPosition.Top
}
if (trayBounds.x < 50) {
return WindowsTaskbarPosition.Left
}
const currentScreen = screen.getDisplayMatching(trayBounds)
if (trayBounds.y + trayBounds.height === currentScreen.bounds.height) {
return WindowsTaskbarPosition.Bottom
}
return WindowsTaskbarPosition.Right
}
Example #2
Source File: price-check.ts From awakened-poe-trade with MIT License | 6 votes |
function getOffsetX (mousePos: Point, poePos: Rectangle): number {
if (mousePos.x > (poePos.x + poePos.width / 2)) {
// inventory
return (poePos.x + poePos.width) - PoeWindow.uiSidebarWidth - Math.floor(WIDTH_96DPI * DPR * config.get('fontSize'))
} else {
// stash or chat
return poePos.x + PoeWindow.uiSidebarWidth
}
}
Example #3
Source File: window-state.ts From WowUp with GNU General Public License v3.0 | 6 votes |
function doRectanglesOverlap(a: Rectangle, b: Rectangle) {
const ax1 = a.x + a.width;
const bx1 = b.x + b.width;
const ay1 = a.y + a.height;
const by1 = b.y + b.height; // clamp a to b, see if it is non-empty
const cx0 = a.x < b.x ? b.x : a.x;
const cx1 = ax1 < bx1 ? ax1 : bx1;
if (cx1 - cx0 > 0) {
const cy0 = a.y < b.y ? b.y : a.y;
const cy1 = ay1 < by1 ? ay1 : by1;
if (cy1 - cy0 > 0) {
return true;
}
}
return false;
}
Example #4
Source File: windowBoundsController.ts From rocketredis with MIT License | 6 votes |
getWindowBounds = function (): Rectangle {
const { width, height, x, y } = config.get('windowBounds') as Rectangle
return {
width: width || 1100,
height: height || 700,
x,
y
}
}
Example #5
Source File: windowBoundsController.ts From rocketredis with MIT License | 6 votes |
setWindowBounds = function (bounds: Rectangle | undefined): void {
if (!bounds) {
return
}
const { width, height, x, y } = bounds
config.set('windowBounds', {
width: width || 1100,
height: height || 700,
x,
y
})
}
Example #6
Source File: index.ts From Protoman with MIT License | 6 votes |
async function createWindow(): Promise<void> {
const screenWidth = screen.getPrimaryDisplay().workAreaSize.width;
const bounds = config.get('winBounds') as Rectangle;
//default value
let width = screenWidth * WIDTH_RATIO;
let height = screenWidth * WIDTH_RATIO * ASPECT_RATIO;
//if some value
if (bounds != undefined) {
width = bounds.width;
height = bounds.height;
}
console.log('saved bounds ', bounds);
window = new BrowserWindow({
width: width,
height: height,
webPreferences: {
nodeIntegration: true,
},
});
initializeEvents();
Menu.setApplicationMenu(makeMenu());
window.loadFile(path.join(__dirname, 'index.html'));
window.on('close', () => {
console.log('closing the window');
console.log('save window bounds');
config.set('winBounds', window.getBounds());
});
checkUpdateAndNotify(window);
}
Example #7
Source File: window.ts From SideQuest with MIT License | 5 votes |
getBounds(): Rectangle {
const pos = this._window.getPosition();
const dimension = this._window.getSize();
return { x: pos[0], y: pos[1], width: dimension[0], height: dimension[1] };
}
Example #8
Source File: price-check.ts From awakened-poe-trade with MIT License | 5 votes |
function isPointInsideRect (point: Point, rect: Rectangle) {
return (
point.x > rect.x &&
point.x < rect.x + rect.width &&
point.y > rect.y &&
point.y < rect.y + rect.height
)
}
Example #9
Source File: price-check.ts From awakened-poe-trade with MIT License | 5 votes |
activeAreaRect: Rectangle | undefined
Example #10
Source File: index.ts From Protoman with MIT License | 5 votes |
config = new Store<Rectangle>()