mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
views: mac: Support dynamic resize of title bar height (see #3189)
This is intended for usage with frameless windows that show the standard window buttons, where resizing the title bar height changes the button offset. Returning a different value from CefWindowDelegate::GetTitlebarHeight and forcing a resize of the NSWindow's theme frame (see ViewsWindow::NudgeWindow) will update the title bar height. To test: 1. Run `cefclient --use-views --hide-frame --show-window-buttons --url=http://tests/window` 2. Enter a new value for title bar height and click the "Set Titlebar Height" button
This commit is contained in:
committed by
Marshall Greenblatt
parent
0a2c7a1070
commit
c83b3cda24
@@ -399,6 +399,16 @@ bool ViewsWindow::GetWindowRestorePreferences(
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewsWindow::SetTitlebarHeight(const std::optional<float>& height) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
if (height.has_value()) {
|
||||
override_titlebar_height_ = height;
|
||||
} else {
|
||||
override_titlebar_height_ = default_titlebar_height_;
|
||||
}
|
||||
NudgeWindow();
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserViewDelegate> ViewsWindow::GetDelegateForPopupBrowserView(
|
||||
CefRefPtr<CefBrowserView> browser_view,
|
||||
const CefBrowserSettings& settings,
|
||||
@@ -735,8 +745,8 @@ bool ViewsWindow::GetTitlebarHeight(CefRefPtr<CefWindow> window,
|
||||
float* titlebar_height) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
#if defined(OS_MAC)
|
||||
if (frameless_ && with_standard_buttons_) {
|
||||
*titlebar_height = kTitleBarHeight;
|
||||
if (override_titlebar_height_.has_value()) {
|
||||
*titlebar_height = override_titlebar_height_.value();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@@ -925,6 +935,13 @@ ViewsWindow::ViewsWindow(Delegate* delegate,
|
||||
// If window has frame or flag passed explicitly
|
||||
with_standard_buttons_ = !frameless_ || show_window_buttons;
|
||||
|
||||
#if defined(OS_MAC)
|
||||
if (frameless_ && with_standard_buttons_) {
|
||||
default_titlebar_height_ = kTitleBarHeight;
|
||||
override_titlebar_height_ = kTitleBarHeight;
|
||||
}
|
||||
#endif
|
||||
|
||||
const std::string& toolbar_type =
|
||||
command_line->GetSwitchValue(switches::kShowChromeToolbar);
|
||||
chrome_toolbar_type_ = CalculateChromeToolbarType(toolbar_type, hide_toolbar,
|
||||
@@ -1262,4 +1279,10 @@ void ViewsWindow::OnExtensionWindowClosed() {
|
||||
extension_button_pressed_lock_ = nullptr;
|
||||
}
|
||||
|
||||
#if !defined(OS_MAC)
|
||||
void ViewsWindow::NudgeWindow() {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace client
|
||||
|
Reference in New Issue
Block a user