diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 4e141e7b5..19934e733 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -5417,7 +5417,8 @@ void HistoryWidget::setupGroupCallTracker() { channel); _groupCallBar = std::make_unique( this, - _groupCallTracker->content()); + _groupCallTracker->content(), + Core::App().appDeactivatedValue()); rpl::single( rpl::empty_value() diff --git a/Telegram/SourceFiles/ui/chat/group_call_bar.cpp b/Telegram/SourceFiles/ui/chat/group_call_bar.cpp index 521d3cb41..04723a0ae 100644 --- a/Telegram/SourceFiles/ui/chat/group_call_bar.cpp +++ b/Telegram/SourceFiles/ui/chat/group_call_bar.cpp @@ -89,7 +89,8 @@ struct GroupCallBar::Userpic { GroupCallBar::GroupCallBar( not_null parent, - rpl::producer content) + rpl::producer content, + rpl::producer &&hideBlobs) : _wrap(parent, object_ptr(parent)) , _inner(_wrap.entity()) , _join(std::make_unique( @@ -147,11 +148,10 @@ GroupCallBar::GroupCallBar( }, lifetime()); _speakingAnimation.init([=](crl::time now) { - //if (const auto &last = _speakingAnimationHideLastTime; (last > 0) - // && (now - last >= kBlobsEnterDuration)) { - // _speakingAnimation.stop(); - // return false; - //} + if (const auto &last = _speakingAnimationHideLastTime; (last > 0) + && (now - last >= kBlobsEnterDuration)) { + _speakingAnimation.stop(); + } for (auto &userpic : _userpics) { if (const auto blobs = userpic.blobsAnimation.get()) { blobs->blobs.updateLevel(now - blobs->lastTime); @@ -161,6 +161,27 @@ GroupCallBar::GroupCallBar( updateUserpics(); }); + rpl::combine( + rpl::single(anim::Disabled()) | rpl::then(anim::Disables()), + std::move(hideBlobs) + ) | rpl::start_with_next([=](bool animDisabled, bool deactivated) { + const auto hide = animDisabled || deactivated; + + if (!(hide && _speakingAnimationHideLastTime)) { + _speakingAnimationHideLastTime = hide ? crl::now() : 0; + } + _skipLevelUpdate = hide; + for (auto &userpic : _userpics) { + if (const auto blobs = userpic.blobsAnimation.get()) { + blobs->blobs.setLevel(0.); + } + } + if (!hide && !_speakingAnimation.animating()) { + _speakingAnimation.start(); + } + _skipLevelUpdate = hide; + }, lifetime()); + setupInner(); } @@ -242,6 +263,7 @@ void GroupCallBar::paintUserpics(Painter &p) { const auto middle = _inner->width() / 2; const auto size = st::historyGroupCallUserpicSize; const auto factor = style::DevicePixelRatio(); + const auto &minScale = kUserpicMinScale; for (auto &userpic : ranges::view::reverse(_userpics)) { const auto shown = userpic.shownAnimation.value( userpic.hiding ? 0. : 1.); @@ -253,10 +275,12 @@ void GroupCallBar::paintUserpics(Painter &p) { const auto left = middle + userpic.leftAnimation.value(userpic.left); const auto blobs = userpic.blobsAnimation.get(); const auto shownScale = 0.5 + shown / 2.; - const auto &minScale = kUserpicMinScale; - const auto scale = shownScale * (blobs - ? (minScale + (1. - minScale) * blobs->blobs.currentLevel()) - : 1.); + const auto scale = shownScale * (!blobs + ? 1. + : (minScale + + (1. - minScale) * (_speakingAnimationHideLastTime + ? (1. - blobs->blobs.currentLevel()) + : blobs->blobs.currentLevel()))); if (blobs) { auto hq = PainterHighQualityEnabler(p); @@ -323,6 +347,9 @@ void GroupCallBar::ensureBlobsAnimation(Userpic &userpic) { } void GroupCallBar::sendRandomLevels() { + if (_skipLevelUpdate) { + return; + } for (auto &userpic : _userpics) { if (const auto blobs = userpic.blobsAnimation.get()) { const auto value = 30 + (openssl::RandomValue() % 70); diff --git a/Telegram/SourceFiles/ui/chat/group_call_bar.h b/Telegram/SourceFiles/ui/chat/group_call_bar.h index 616babafc..2641ef586 100644 --- a/Telegram/SourceFiles/ui/chat/group_call_bar.h +++ b/Telegram/SourceFiles/ui/chat/group_call_bar.h @@ -35,7 +35,8 @@ class GroupCallBar final { public: GroupCallBar( not_null parent, - rpl::producer content); + rpl::producer content, + rpl::producer &&hideBlobs); ~GroupCallBar(); void show(); @@ -89,6 +90,9 @@ private: bool _shouldBeShown = false; bool _forceHidden = false; + bool _skipLevelUpdate = false; + crl::time _speakingAnimationHideLastTime = 0; + GroupCallBarContent _content; };