From 3e2eb535a535d1d87ad57e608d5ffc0577000244 Mon Sep 17 00:00:00 2001 From: Hazel Nut Date: Tue, 6 Feb 2024 21:43:08 -0500 Subject: [PATCH 1/3] Update index.ts --- src/titlebar/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/titlebar/index.ts b/src/titlebar/index.ts index 1a09d96..c45c74b 100644 --- a/src/titlebar/index.ts +++ b/src/titlebar/index.ts @@ -55,7 +55,9 @@ export class CustomTitlebar extends ThemeBar { minimize: 'Minimize', restoreDown: 'Restore Down' }, - unfocusEffect: true + unfocusEffect: true, + minWidth: 400, + minHeight: 270, } private platformIcons: { [key: string]: string } @@ -192,6 +194,8 @@ export class CustomTitlebar extends ThemeBar { } append(this.titlebar, this.menuBarContainer) + + ipcRenderer.send('window-set-minimumSize', this.currentOptions.minWidth, this.currentOptions.minHeight); } private setupTitle() { From 6128f02390f7b08eef88db4ee062b782cef2332f Mon Sep 17 00:00:00 2001 From: Hazel Nut Date: Tue, 6 Feb 2024 21:43:44 -0500 Subject: [PATCH 2/3] Update options.ts --- src/titlebar/options.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/titlebar/options.ts b/src/titlebar/options.ts index c5c6697..4a096b3 100644 --- a/src/titlebar/options.ts +++ b/src/titlebar/options.ts @@ -93,4 +93,15 @@ export interface TitleBarOptions extends MenuBarOptions { * *The default is true* */ unfocusEffect?: boolean; -} \ No newline at end of file + /** + * Controls the Minimum Width the user is allowed to resize the window to. + * **The default is 400* + */ + minWidth: 400; + + /** + * Controls the Minimum Height the user is allowed to resize the window to. + * **The default is 270* + */ + minHeight: 270; +} From 26b78665a6294c14a2252ae295c8b7b4249c2db6 Mon Sep 17 00:00:00 2001 From: Hazel Nut Date: Tue, 6 Feb 2024 21:45:15 -0500 Subject: [PATCH 3/3] Update setup-titlebar.ts --- src/main/setup-titlebar.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/setup-titlebar.ts b/src/main/setup-titlebar.ts index c403978..5510f16 100644 --- a/src/main/setup-titlebar.ts +++ b/src/main/setup-titlebar.ts @@ -45,6 +45,16 @@ export default () => { if (item) item.click(undefined, BrowserWindow.fromWebContents(event.sender), event.sender) }) + // Handle the minimum size. + ipcMain.on('window-set-minimumSize', (event, width, height) => { + const window = BrowserWindow.fromWebContents(event.sender); + + /* eslint-disable indent */ + if (window) { + window?.setMinimumSize(width, height); + } + }); + // Handle menu item icon ipcMain.on('menu-icon', (event, commandId: Number) => { const item = getMenuItemByCommandId(commandId, Menu.getApplicationMenu()) @@ -77,4 +87,4 @@ function getMenuItemByCommandId(commandId: Number, menu: Electron.Menu | null): } return undefined -} \ No newline at end of file +}