From c987872be8473eb5377fa01b9282db54fcfe29d6 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 5 Nov 2024 18:33:07 +0400 Subject: [PATCH] Start fullscreen support in SeparatePanel. --- .../ui/chat/attach/attach_bot_webview.cpp | 34 +++++++++++++++++-- .../ui/chat/attach/attach_bot_webview.h | 2 ++ Telegram/SourceFiles/ui/menu_icons.style | 2 ++ Telegram/lib_ui | 2 +- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index daab6358f..41fd093d0 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -378,6 +378,13 @@ Panel::Panel( _widget->setWindowFlag(Qt::WindowStaysOnTopHint, false); _widget->setInnerSize(st::botWebViewPanelSize, true); + _fullscreen.value( + ) | rpl::start_with_next([=](bool fullscreen) { + _widget->toggleFullScreen(fullscreen); + layoutButtons(); + sendSafeArea(); + }, _widget->lifetime()); + _widget->closeRequests( ) | rpl::start_with_next([=] { if (_closeNeedConfirmation) { @@ -612,6 +619,15 @@ bool Panel::showWebview( .isAttention = true, }); } + if (_widget->isFullScreen()) { + callback(u"Close Full Screen"_q, [=] { + _fullscreen = false; + }, &st::menuIconPlayerWindowed); + } else { + callback(u"Show Full Screen"_q, [=] { + _fullscreen = true; + }, &st::menuIconPlayerFullScreen); + } }); return true; } @@ -619,7 +635,7 @@ bool Panel::showWebview( void Panel::createWebviewBottom() { _webviewBottom = std::make_unique(_widget.get()); const auto bottom = _webviewBottom.get(); - bottom->show(); + bottom->setVisible(!_fullscreen.current()); const auto &padding = st::paymentsPanelPadding; const auto label = CreateChild( @@ -744,6 +760,8 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) { _themeUpdateForced.fire({}); } else if (command == "web_app_request_viewport") { sendViewport(); + } else if (command == "web_app_request_safe_area") { + sendSafeArea(); } else if (command == "web_app_open_tg_link") { openTgLink(arguments); } else if (command == "web_app_open_link") { @@ -828,6 +846,11 @@ void Panel::sendViewport() { "is_expanded: true }"); } +void Panel::sendSafeArea() { + postEvent("safe_area_changed", + "{ top: 0, right: 0, bottom: 0, left: 0 }"); +} + void Panel::setTitle(rpl::producer title) { _widget->setTitle(std::move(title)); } @@ -1362,12 +1385,15 @@ void Panel::createButton(std::unique_ptr