diff --git a/Telegram/SourceFiles/calls/calls_top_bar.cpp b/Telegram/SourceFiles/calls/calls_top_bar.cpp index dc82be6444..0ff423ccb3 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.cpp +++ b/Telegram/SourceFiles/calls/calls_top_bar.cpp @@ -275,6 +275,14 @@ TopBar::TopBar( , _updateDurationTimer([=] { updateDurationText(); }) { initControls(); resize(width(), st::callBarHeight); + setupInitialBrush(); +} + +void TopBar::setupInitialBrush() { + Expects(_switchStateCallback != nullptr); + + _switchStateAnimation.stop(); + _switchStateCallback(1.); } void TopBar::initControls() { @@ -316,14 +324,16 @@ void TopBar::initControls() { | MapPushToTalkToActive() | rpl::distinct_until_changed() | rpl::type_erased()), - _groupCall->instanceStateValue(), + rpl::single( + _groupCall->instanceState() + ) | rpl::then(_groupCall->instanceStateValue() | rpl::filter( + _1 != GroupCall::InstanceState::TransitionToRtc)), rpl::single( _groupCall->scheduleDate() ) | rpl::then(_groupCall->real( ) | rpl::map([](not_null call) { return call->scheduleDateValue(); - }) | rpl::flatten_latest()) - ) | rpl::filter(_2 != GroupCall::InstanceState::TransitionToRtc); + }) | rpl::flatten_latest())); std::move( muted ) | rpl::map( @@ -350,7 +360,7 @@ void TopBar::initControls() { const auto crossFrom = (fromMuted != BarState::Active) ? 1. : 0.; const auto crossTo = (toMuted != BarState::Active) ? 1. : 0.; - auto animationCallback = [=](float64 value) { + _switchStateCallback = [=](float64 value) { if (_groupCall) { _groupBrush = QBrush( _gradients.gradient(fromMuted, toMuted, value)); @@ -366,7 +376,7 @@ void TopBar::initControls() { _switchStateAnimation.stop(); const auto duration = (to - from) * kSwitchStateDuration; _switchStateAnimation.start( - std::move(animationCallback), + _switchStateCallback, from, to, duration); @@ -748,6 +758,9 @@ void TopBar::updateControlsGeometry() { _gradients.set_points( QPointF(0, st::callBarHeight / 2), QPointF(width(), st::callBarHeight / 2)); + if (!_switchStateAnimation.animating()) { + _switchStateCallback(1.); + } } void TopBar::paintEvent(QPaintEvent *e) { diff --git a/Telegram/SourceFiles/calls/calls_top_bar.h b/Telegram/SourceFiles/calls/calls_top_bar.h index 0ea23a8182..7b62e6673a 100644 --- a/Telegram/SourceFiles/calls/calls_top_bar.h +++ b/Telegram/SourceFiles/calls/calls_top_bar.h @@ -68,6 +68,7 @@ private: const base::weak_ptr &groupCall); void initControls(); + void setupInitialBrush(); void updateInfoLabels(); void setInfoLabels(); void updateDurationText(); @@ -101,6 +102,7 @@ private: QBrush _groupBrush; anim::linear_gradients _gradients; Ui::Animations::Simple _switchStateAnimation; + Fn _switchStateCallback; base::Timer _updateDurationTimer;