diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 261b512466..c785cd7822 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -13,10 +13,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "dialogs/dialogs_entry.h" #include "history/history.h" #include "history/view/history_view_top_bar_widget.h" +#include "history/view/history_view_contact_status.h" +#include "history/view/history_view_requests_bar.h" +#include "history/view/history_view_group_call_bar.h" +#include "boxes/peers/edit_peer_requests_box.h" #include "ui/widgets/buttons.h" #include "ui/widgets/input_fields.h" #include "ui/wrap/fade_wrap.h" #include "ui/effects/radial_animation.h" +#include "ui/chat/requests_bar.h" +#include "ui/chat/group_call_bar.h" #include "ui/controls/download_bar.h" #include "ui/painter.h" #include "ui/ui_utility.h" @@ -644,6 +650,18 @@ void Widget::updateControlsVisibility(bool fast) { _searchControls->setVisible(!_openedFolder && !_openedForum); if (_openedFolder || _openedForum) { _folderTopBar->show(); + if (_forumTopShadow) { + _forumTopShadow->show(); + } + if (_forumGroupCallBar) { + _forumGroupCallBar->show(); + } + if (_forumRequestsBar) { + _forumRequestsBar->show(); + } + if (_forumReportBar) { + _forumReportBar->show(); + } } else { if (hasFocus()) { _filter->setFocus(); @@ -674,7 +692,7 @@ void Widget::changeOpenedSubsection( _cacheUnder = grabForFolderSlideAnimation(); } change(); - refreshFolderTopBar(); + refreshTopBars(); updateControlsVisibility(true); if (animated == anim::type::normal) { _connecting->setForceHidden(true); @@ -701,7 +719,7 @@ void Widget::changeOpenedForum(ChannelData *forum, anim::type animated) { }, (forum != nullptr), animated); } -void Widget::refreshFolderTopBar() { +void Widget::refreshTopBars() { if (_openedFolder || _openedForum) { if (!_folderTopBar) { _folderTopBar.create(this, controller()); @@ -720,6 +738,68 @@ void Widget::refreshFolderTopBar() { } else { _folderTopBar.destroy(); } + if (_openedForum) { + _openedForum->updateFull(); + + _forumReportBar = std::make_unique( + controller(), + this, + _openedForum); + _forumRequestsBar = std::make_unique( + this, + HistoryView::RequestsBarContentByPeer( + _openedForum, + st::historyRequestsUserpics.size)); + _forumGroupCallBar = std::make_unique( + this, + HistoryView::GroupCallBarContentByPeer( + _openedForum, + st::historyGroupCallUserpics.size), + Core::App().appDeactivatedValue()); + _forumTopShadow = std::make_unique(this); + + _forumRequestsBar->barClicks( + ) | rpl::start_with_next([=] { + RequestsBoxController::Start(controller(), _openedForum); + }, _forumRequestsBar->lifetime()); + + rpl::merge( + _forumGroupCallBar->barClicks(), + _forumGroupCallBar->joinClicks() + ) | rpl::start_with_next([=] { + if (_openedForum->groupCall()) { + controller()->startOrJoinGroupCall(_openedForum); + } + }, _forumGroupCallBar->lifetime()); + + if (_a_show.animating()) { + _forumTopShadow->hide(); + _forumGroupCallBar->hide(); + _forumRequestsBar->hide(); + _forumReportBar->bar().hide(); + } else { + _forumTopShadow->show(); + _forumGroupCallBar->show(); + _forumRequestsBar->show(); + _forumReportBar->show(); + _forumGroupCallBar->finishAnimating(); + _forumRequestsBar->finishAnimating(); + } + + rpl::combine( + _forumGroupCallBar->heightValue(), + _forumRequestsBar->heightValue(), + _forumReportBar->bar().heightValue() + ) | rpl::start_with_next([=] { + updateControlsGeometry(); + }, _forumRequestsBar->lifetime()); + } else { + _forumTopShadow = nullptr; + _forumGroupCallBar = nullptr; + _forumRequestsBar = nullptr; + _forumReportBar = nullptr; + updateControlsGeometry(); + } } QPixmap Widget::grabForFolderSlideAnimation() { @@ -901,6 +981,18 @@ void Widget::startSlideAnimation() { if (_folderTopBar) { _folderTopBar->hide(); } + if (_forumTopShadow) { + _forumTopShadow->hide(); + } + if (_forumGroupCallBar) { + _forumGroupCallBar->hide(); + } + if (_forumRequestsBar) { + _forumRequestsBar->hide(); + } + if (_forumReportBar) { + _forumReportBar->bar().hide(); + } if (_showDirection == Window::SlideDirection::FromLeft) { std::swap(_cacheUnder, _cacheOver); @@ -1792,7 +1884,31 @@ void Widget::updateControlsGeometry() { right -= _jumpToDate->width(); _jumpToDate->moveToLeft(right, _filter->y()); right -= _chooseFromUser->width(); _chooseFromUser->moveToLeft(right, _filter->y()); - auto scrollTop = filterAreaTop + filterAreaHeight; + if (_forumTopShadow) { + _forumTopShadow->setGeometry( + 0, + filterAreaTop + filterAreaHeight, + width(), + st::lineWidth); + } + const auto forumGroupCallTop = filterAreaTop + filterAreaHeight; + if (_forumGroupCallBar) { + _forumGroupCallBar->move(0, forumGroupCallTop); + _forumGroupCallBar->resizeToWidth(width()); + } + const auto forumRequestsTop = forumGroupCallTop + + (_forumGroupCallBar ? _forumGroupCallBar->height() : 0); + if (_forumRequestsBar) { + _forumRequestsBar->move(0, forumRequestsTop); + _forumRequestsBar->resizeToWidth(width()); + } + const auto forumReportTop = forumRequestsTop + + (_forumRequestsBar ? _forumRequestsBar->height() : 0); + if (_forumReportBar) { + _forumReportBar->bar().move(0, forumReportTop); + } + auto scrollTop = forumReportTop + + (_forumReportBar ? _forumReportBar->bar().height() : 0); auto newScrollTop = _scroll->scrollTop() + _topDelta; auto scrollHeight = height() - scrollTop; const auto putBottomButton = [&](auto &button) { diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index 80c4566051..2afb362e4c 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -26,6 +26,7 @@ class Session; namespace HistoryView { class TopBarWidget; +class ContactStatus; } // namespace HistoryView namespace Ui { @@ -35,7 +36,10 @@ class DropdownMenu; class FlatButton; class InputField; class CrossButton; +class PlainShadow; class DownloadBar; +class GroupCallBar; +class RequestsBar; template class FadeWrapScaled; } // namespace Ui @@ -152,7 +156,7 @@ private: void updateJumpToDateVisibility(bool fast = false); void updateSearchFromVisibility(bool fast = false); void updateControlsGeometry(); - void refreshFolderTopBar(); + void refreshTopBars(); void checkUpdateStatus(); void changeOpenedSubsection( FnMut change, @@ -196,6 +200,12 @@ private: object_ptr> _jumpToDate; object_ptr _cancelSearch; object_ptr _lockUnlock; + + std::unique_ptr _forumTopShadow; + std::unique_ptr _forumGroupCallBar; + std::unique_ptr _forumRequestsBar; + std::unique_ptr _forumReportBar; + object_ptr _scroll; QPointer _inner; class BottomButton; diff --git a/Telegram/SourceFiles/history/view/history_view_requests_bar.cpp b/Telegram/SourceFiles/history/view/history_view_requests_bar.cpp index 067593a9f1..17e1b70266 100644 --- a/Telegram/SourceFiles/history/view/history_view_requests_bar.cpp +++ b/Telegram/SourceFiles/history/view/history_view_requests_bar.cpp @@ -105,16 +105,22 @@ rpl::producer RequestsBarContentByPeer( auto lifetime = rpl::lifetime(); auto state = lifetime.make_state(peer); - const auto pushNext = [=] { - if (state->pushScheduled - || (std::min(state->current.count, kRecentRequestsLimit) - != state->users.size())) { + const auto pushNext = [=](bool now = false) { + if (std::min(state->current.count, kRecentRequestsLimit) + != state->users.size()) { + return; + } else if (now) { + state->pushScheduled = false; + consumer.put_next_copy(state->current); + } else if (state->pushScheduled) { return; } state->pushScheduled = true; crl::on_main(&state->guard, [=] { - state->pushScheduled = false; - consumer.put_next_copy(state->current); + if (state->pushScheduled) { + state->pushScheduled = false; + consumer.put_next_copy(state->current); + } }); }; @@ -172,6 +178,7 @@ rpl::producer RequestsBarContentByPeer( } }, lifetime); + pushNext(true); return lifetime; }; } diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 9527c4b923..48a5d2ec13 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -1382,6 +1382,10 @@ void SessionController::showPeer(not_null peer, MsgId msgId) { } } +void SessionController::startOrJoinGroupCall(not_null peer) { + startOrJoinGroupCall(peer, {}); +} + void SessionController::startOrJoinGroupCall( not_null peer, Calls::StartGroupCallArgs args) { diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 8eb6997a50..a2413ba4af 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -401,6 +401,7 @@ public: [[nodiscard]] bool canShowSeparateWindow(not_null peer) const; void showPeer(not_null peer, MsgId msgId = ShowAtUnreadMsgId); + void startOrJoinGroupCall(not_null peer); void startOrJoinGroupCall( not_null peer, Calls::StartGroupCallArgs args);