From bf61f624c5b8e8be100a81e47150477ddf5fdf29 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 27 Jan 2021 23:48:16 +0300 Subject: [PATCH] Added speaking status animation in list of participants in group calls. --- .../SourceFiles/calls/calls_group_members.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/calls/calls_group_members.cpp b/Telegram/SourceFiles/calls/calls_group_members.cpp index e53244ae16..540f8d08e4 100644 --- a/Telegram/SourceFiles/calls/calls_group_members.cpp +++ b/Telegram/SourceFiles/calls/calls_group_members.cpp @@ -197,6 +197,7 @@ private: } const style::icon &speaker; const std::unique_ptr arcs; + int arcsWidth = 0; rpl::lifetime lifetime; }; @@ -397,12 +398,23 @@ void Row::setSpeaking(bool speaking) { } else if (!_statusIcon) { _statusIcon = std::make_unique( (float)_volume / Group::kMaxVolume); + _statusIcon->arcsWidth = _statusIcon->arcs->finishedWidth(); + + const auto wasArcsWidth = _statusIcon->lifetime.make_state(0); _statusIcon->arcs->startUpdateRequests( ) | rpl::start_with_next([=] { - auto callback = [=] { + if (!_arcsAnimation.animating()) { + *wasArcsWidth = _statusIcon->arcsWidth; + } + auto callback = [=](float64 value) { if (_statusIcon) { _statusIcon->arcs->update(crl::now()); + + _statusIcon->arcsWidth = anim::interpolate( + *wasArcsWidth, + _statusIcon->arcs->finishedWidth(), + value); } _delegate->rowUpdateRow(this); }; @@ -588,7 +600,7 @@ int Row::statusIconWidth() const { } return _speaking ? (_statusIcon->speaker.width() / 2 - + _statusIcon->arcs->width() + + _statusIcon->arcsWidth + st::groupCallMenuVolumeSkip) : 0; }