From a4cce651493f357121da5d96843faa4b998dc2c8 Mon Sep 17 00:00:00 2001 From: "Ali G. Jahed" Date: Wed, 20 Mar 2024 23:16:12 +0330 Subject: [PATCH] Add removeMenuBar functionality and docs --- docs/Menubar-Options.md | 11 +++++++++++ src/menubar/menubar-options.ts | 5 +++++ src/titlebar/index.ts | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/docs/Menubar-Options.md b/docs/Menubar-Options.md index 364314f..1a69224 100644 --- a/docs/Menubar-Options.md +++ b/docs/Menubar-Options.md @@ -81,6 +81,17 @@ const options = { }; ``` +## Remove Menu from Title Bar + +This option allows removing the `menubar` from `titlebar`. The default value is `false` + +```js +const options = { + // title bar options + removeMenuBar: true +}; +``` + ## Menu Item Color This is the background color of the menu items when the cursor is hovering over each one. It can be a hexadecimal color using `TitlebarColor.fromHex(color)` or a `TitlebarColor`. diff --git a/src/menubar/menubar-options.ts b/src/menubar/menubar-options.ts index 82541e9..b0e90ac 100644 --- a/src/menubar/menubar-options.ts +++ b/src/menubar/menubar-options.ts @@ -46,6 +46,11 @@ export interface MenuBarOptions { * **The default is false** */ onlyShowMenuBar?: boolean; + /** + * Define if MenuBar exists on TitleBar or not. + * **The default is false** + */ + removeMenuBar?: boolean; /** * The color of the svg icons in the menu * **The default is automatic** diff --git a/src/titlebar/index.ts b/src/titlebar/index.ts index 1a09d96..6da3e70 100644 --- a/src/titlebar/index.ts +++ b/src/titlebar/index.ts @@ -47,6 +47,7 @@ export class CustomTitlebar extends ThemeBar { menuTransparency: 0, minimizable: true, onlyShowMenuBar: false, + removeMenuBar: false, shadow: false, titleHorizontalAlignment: 'center', tooltips: { @@ -186,11 +187,14 @@ export class CustomTitlebar extends ThemeBar { ipcRenderer.invoke('request-application-menu')?.then((menu?: Menu) => this.updateMenu(menu)) const menuPosition = this.currentOptions.menuPosition + const removeMenuBar = this.currentOptions.removeMenuBar if (menuPosition) { this.updateMenuPosition(menuPosition) } + if (removeMenuBar) return + append(this.titlebar, this.menuBarContainer) }