Switch to titleBarStyle for custom window buttons on hover
This commit is contained in:
parent
566e04f1c0
commit
7d10bf229d
3 changed files with 16 additions and 19 deletions
|
@ -127,13 +127,12 @@ class NativeWindowMac : public NativeWindow,
|
|||
NORMAL,
|
||||
HIDDEN,
|
||||
HIDDEN_INSET,
|
||||
CUSTOM_BUTTONS_ON_HOVER,
|
||||
};
|
||||
TitleBarStyle title_bar_style() const { return title_bar_style_; }
|
||||
|
||||
bool zoom_to_page_width() const { return zoom_to_page_width_; }
|
||||
|
||||
bool custom_window_buttons() const { return custom_window_buttons_; }
|
||||
|
||||
protected:
|
||||
// Return a vector of non-draggable regions that fill a window of size
|
||||
// |width| by |height|, but leave gaps where the window should be draggable.
|
||||
|
@ -178,8 +177,6 @@ class NativeWindowMac : public NativeWindow,
|
|||
|
||||
bool zoom_to_page_width_;
|
||||
|
||||
bool custom_window_buttons_;
|
||||
|
||||
NSInteger attention_request_id_; // identifier from requestUserAttention
|
||||
|
||||
// The presentation options before entering kiosk mode.
|
||||
|
|
|
@ -701,14 +701,14 @@ enum {
|
|||
// Custom window button methods
|
||||
|
||||
- (void)performClose:(id)sender {
|
||||
if (shell_->custom_window_buttons())
|
||||
if (shell_->title_bar_style() == atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER)
|
||||
[[self delegate] windowShouldClose:self];
|
||||
else
|
||||
[super performClose:sender];
|
||||
}
|
||||
|
||||
- (void)performMiniaturize:(id)sender {
|
||||
if (shell_->custom_window_buttons())
|
||||
if (shell_->title_bar_style() == atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER)
|
||||
[self miniaturize:self];
|
||||
else
|
||||
[super performMiniaturize:sender];
|
||||
|
@ -782,6 +782,8 @@ struct Converter<atom::NativeWindowMac::TitleBarStyle> {
|
|||
} else if (title_bar_style == "hidden-inset" || // Deprecate this after 2.0
|
||||
title_bar_style == "hiddenInset") {
|
||||
*out = atom::NativeWindowMac::HIDDEN_INSET;
|
||||
} else if (title_bar_style == "customButtonsOnHover") {
|
||||
*out = atom::NativeWindowMac::CUSTOM_BUTTONS_ON_HOVER;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -802,7 +804,6 @@ NativeWindowMac::NativeWindowMac(
|
|||
is_kiosk_(false),
|
||||
was_fullscreen_(false),
|
||||
zoom_to_page_width_(false),
|
||||
custom_window_buttons_(false),
|
||||
attention_request_id_(0),
|
||||
title_bar_style_(NORMAL) {
|
||||
int width = 800, height = 600;
|
||||
|
@ -844,10 +845,8 @@ NativeWindowMac::NativeWindowMac(
|
|||
useStandardWindow = false;
|
||||
}
|
||||
|
||||
options.Get(options::kCustomWindowButtons, &custom_window_buttons_);
|
||||
|
||||
NSUInteger styleMask = NSTitledWindowMask;
|
||||
if (custom_window_buttons_ &&
|
||||
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER &&
|
||||
base::mac::IsAtLeastOS10_10() &&
|
||||
(!useStandardWindow || transparent() || !has_frame())) {
|
||||
styleMask = NSFullSizeContentViewWindowMask;
|
||||
|
@ -906,7 +905,7 @@ NativeWindowMac::NativeWindowMac(
|
|||
if (transparent() || !has_frame()) {
|
||||
if (base::mac::IsAtLeastOS10_10()) {
|
||||
// Don't show title bar.
|
||||
if (custom_window_buttons_) {
|
||||
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER) {
|
||||
[window_ setTitlebarAppearsTransparent:YES];
|
||||
}
|
||||
[window_ setTitleVisibility:NSWindowTitleHidden];
|
||||
|
@ -1692,7 +1691,7 @@ void NativeWindowMac::InstallView() {
|
|||
// The fullscreen button should always be hidden for frameless window.
|
||||
[[window_ standardWindowButton:NSWindowFullScreenButton] setHidden:YES];
|
||||
|
||||
if (custom_window_buttons_) {
|
||||
if (title_bar_style_ == CUSTOM_BUTTONS_ON_HOVER) {
|
||||
NSView* buttons = [[SemaphoreView alloc] initWithFrame:NSZeroRect];
|
||||
buttons.frame = CGRectMake(0,
|
||||
[content_view_ bounds].size.height - buttons.frame.size.height,
|
||||
|
|
|
@ -191,14 +191,20 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
|||
Default is `false`.
|
||||
* `type` String (optional) - The type of window, default is normal window. See more about
|
||||
this below.
|
||||
* `titleBarStyle` String (optional) - The style of window title bar. Default is `default`. Possible values are:
|
||||
* `titleBarStyle` String (optional) - The style of window title bar.
|
||||
Default is `default`. Possible values are:
|
||||
* `default` - Results in the standard gray opaque Mac title
|
||||
bar.
|
||||
* `hidden` - Results in a hidden title bar and a full size content window, yet
|
||||
the title bar still has the standard window controls ("traffic lights") in
|
||||
the top left.
|
||||
* `hidden-inset` - Results in a hidden title bar with an alternative look
|
||||
* `hiddenInset` - Results in a hidden title bar with an alternative look
|
||||
where the traffic light buttons are slightly more inset from the window edge.
|
||||
* `customButtonsOnHover` Boolean (optional) - Draw custom close, minimize,
|
||||
and full screen buttons on macOS frameless windows. These buttons will not
|
||||
display unless hovered over in the top left of the window. These custom
|
||||
buttons prevent issues with mouse events that occur with the standard
|
||||
window toolbar buttons. **Note:** This option is currently experimental.
|
||||
* `thickFrame` Boolean (optional) - Use `WS_THICKFRAME` style for frameless windows on
|
||||
Windows, which adds standard window frame. Setting it to `false` will remove
|
||||
window shadow and window animations. Default is `true`.
|
||||
|
@ -214,11 +220,6 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
|
|||
* `tabbingIdentifier` String (optional) - Tab group name, allows opening the
|
||||
window as a native tab on macOS 10.12+. Windows with the same tabbing
|
||||
identifier will be grouped together.
|
||||
* `customWindowButtons` Boolean (optional) - Draw custom close, minimize,
|
||||
and full screen buttons on macOS frameless windows. These buttons will not
|
||||
display unless hovered over in the top left of the window. These custom
|
||||
buttons prevent issues with mouse events that occur with the standard
|
||||
window toolbar buttons. **Note:** This option is currently experimental.
|
||||
* `webPreferences` Object (optional) - Settings of web page's features.
|
||||
* `devTools` Boolean (optional) - Whether to enable DevTools. If it is set to `false`, can not use `BrowserWindow.webContents.openDevTools()` to open DevTools. Default is `true`.
|
||||
* `nodeIntegration` Boolean (optional) - Whether node integration is enabled. Default
|
||||
|
|
Loading…
Reference in a new issue