electron-util
Version:
Useful utilities for Electron apps and modules
74 lines (63 loc) • 1.78 kB
TypeScript
import { type BrowserWindow, type Rectangle, type Size } from 'electron';
export type GetWindowBoundsCenteredOptions = {
/**
The window to get the bounds of.
Default: Current window
*/
readonly window?: BrowserWindow;
/**
Set a new window size.
Default: Size of `window`
@example
```
{width: 600, height: 400}
```
*/
readonly size?: Size;
/**
Use the full display size when calculating the position.
By default, only the workable screen area is used, which excludes the Windows taskbar and macOS dock.
@default false
*/
readonly useFullBounds?: boolean;
};
export type CenterWindowOptions = {
/**
The window to center.
Default: Current window
*/
readonly window?: BrowserWindow;
/**
Set a new window size.
Default: Size of `window`
@example
```
{width: 600, height: 400}
```
*/
readonly size?: Size;
/**
Animate the change.
@default false
*/
readonly animated?: boolean;
/**
Use the full display size when calculating the position.
By default, only the workable screen area is used, which excludes the Windows taskbar and macOS dock.
@default false
*/
readonly useFullBounds?: boolean;
};
/**
@returns The height of the menu bar on macOS, or `0` if not macOS.
*/
export declare const menuBarHeight: () => number;
/**
Get the [bounds](https://electronjs.org/docs/api/browser-window#wingetbounds) of a window as if it was centered on the screen.
@returns Bounds of a window.
*/
export declare const getWindowBoundsCentered: (options?: GetWindowBoundsCenteredOptions) => Rectangle;
/**
Center a window on the screen.
*/
export declare const centerWindow: (options?: CenterWindowOptions) => void;