mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
feat: Add BrowserWindow.setWindowButtonVisibility()
Fixes #12701 and supersedes #13131. Ideally we would have added `setTitleBarStyle()`, but that is a significantly more involved change. For example, consider the case where we switch from `hidden` to `normal`. We would not only have to show the traffic light buttons, we would also have to switch the window from a frameless to a framed window and deal with various other window state. Lets instead implement a simple solution for #12701.
This commit is contained in:
committed by
Jeremy Apthorp
parent
00c0c180ab
commit
a42ca9eecc
@@ -738,6 +738,13 @@ void TopLevelWindow::AddTabbedWindow(NativeWindow* window,
|
||||
args->ThrowError("AddTabbedWindow cannot be called by a window on itself.");
|
||||
}
|
||||
|
||||
void TopLevelWindow::SetWindowButtonVisibility(bool visible,
|
||||
mate::Arguments* args) {
|
||||
if (!window_->SetWindowButtonVisibility(visible)) {
|
||||
args->ThrowError("Not supported for this window");
|
||||
}
|
||||
}
|
||||
|
||||
void TopLevelWindow::SetAutoHideMenuBar(bool auto_hide) {
|
||||
window_->SetAutoHideMenuBar(auto_hide);
|
||||
}
|
||||
@@ -1030,6 +1037,8 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("moveTabToNewWindow", &TopLevelWindow::MoveTabToNewWindow)
|
||||
.SetMethod("toggleTabBar", &TopLevelWindow::ToggleTabBar)
|
||||
.SetMethod("addTabbedWindow", &TopLevelWindow::AddTabbedWindow)
|
||||
.SetMethod("setWindowButtonVisibility",
|
||||
&TopLevelWindow::SetWindowButtonVisibility)
|
||||
#endif
|
||||
.SetMethod("setAutoHideMenuBar", &TopLevelWindow::SetAutoHideMenuBar)
|
||||
.SetMethod("isMenuBarAutoHide", &TopLevelWindow::IsMenuBarAutoHide)
|
||||
|
||||
@@ -173,6 +173,7 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
||||
void MoveTabToNewWindow();
|
||||
void ToggleTabBar();
|
||||
void AddTabbedWindow(NativeWindow* window, mate::Arguments* args);
|
||||
void SetWindowButtonVisibility(bool visible, mate::Arguments* args);
|
||||
void SetAutoHideMenuBar(bool auto_hide);
|
||||
bool IsMenuBarAutoHide();
|
||||
void SetMenuBarVisibility(bool visible);
|
||||
|
||||
Reference in New Issue
Block a user