Added hiding of Blob animations at application deactivating.

This commit is contained in:
23rd 2020-12-03 19:34:51 +03:00
parent a57d23f7d9
commit 79d5a49e7c
4 changed files with 30 additions and 3 deletions

View file

@ -250,6 +250,9 @@ private:
base::flat_map<uint32, not_null<Row*>> _speakingRowBySsrc; base::flat_map<uint32, not_null<Row*>> _speakingRowBySsrc;
Ui::Animations::Basic _speakingAnimation; Ui::Animations::Basic _speakingAnimation;
crl::time _speakingAnimationHideLastTime = 0;
bool _skipRowLevelUpdate = false;
Ui::CrossLineAnimation _inactiveCrossLine; Ui::CrossLineAnimation _inactiveCrossLine;
Ui::CrossLineAnimation _coloredCrossLine; Ui::CrossLineAnimation _coloredCrossLine;
@ -513,7 +516,27 @@ MembersController::MembersController(
_coloredCrossLine.invalidate(); _coloredCrossLine.invalidate();
}, _lifetime); }, _lifetime);
Core::App().appDeactivates(
) | rpl::start_with_next([=](bool hide) {
_speakingAnimationHideLastTime = hide ? crl::now() : 0;
for (const auto [_, row] : _speakingRowBySsrc) {
if (hide) {
row->updateLevel(0.);
}
updateRowLevel(row, 0.);
if (!hide && !_speakingAnimation.animating()) {
_speakingAnimation.start();
}
}
_skipRowLevelUpdate = hide;
}, _lifetime);
_speakingAnimation.init([=](crl::time now) { _speakingAnimation.init([=](crl::time now) {
if (const auto &last = _speakingAnimationHideLastTime; (last > 0)
&& (now - last >= Ui::Paint::Blobs::kHideBlobsDuration)) {
_speakingAnimation.stop();
return false;
}
for (const auto [ssrc, row] : _speakingRowBySsrc) { for (const auto [ssrc, row] : _speakingRowBySsrc) {
row->updateBlobAnimation(now); row->updateBlobAnimation(now);
delegate()->peerListUpdateRow(row); delegate()->peerListUpdateRow(row);
@ -683,6 +706,9 @@ void MembersController::removeRow(not_null<Row*> row) {
void MembersController::updateRowLevel( void MembersController::updateRowLevel(
not_null<Row*> row, not_null<Row*> row,
float level) { float level) {
if (_skipRowLevelUpdate) {
return;
}
row->updateLevel(level); row->updateLevel(level);
} }

View file

@ -223,6 +223,7 @@ GroupPanel::GroupPanel(not_null<GroupCall*> call)
, _settings(widget(), st::groupCallSettings) , _settings(widget(), st::groupCallSettings)
, _mute(std::make_unique<Ui::CallMuteButton>( , _mute(std::make_unique<Ui::CallMuteButton>(
widget(), widget(),
Core::App().appDeactivates(),
Ui::CallMuteButtonState{ Ui::CallMuteButtonState{
.text = tr::lng_group_call_connecting(tr::now), .text = tr::lng_group_call_connecting(tr::now),
.type = Ui::CallMuteButtonType::Connecting, .type = Ui::CallMuteButtonType::Connecting,

View file

@ -247,7 +247,7 @@ void Application::run() {
QCoreApplication::instance()->installEventFilter(this); QCoreApplication::instance()->installEventFilter(this);
appDeactivated( appDeactivates(
) | rpl::start_with_next([=](bool deactivated) { ) | rpl::start_with_next([=](bool deactivated) {
if (deactivated) { if (deactivated) {
handleAppDeactivated(); handleAppDeactivated();
@ -652,7 +652,7 @@ void Application::handleAppDeactivated() {
Ui::Tooltip::Hide(); Ui::Tooltip::Hide();
} }
rpl::producer<bool> Application::appDeactivated() const { rpl::producer<bool> Application::appDeactivates() const {
return base::qt_signal_producer( return base::qt_signal_producer(
static_cast<QGuiApplication*>(QCoreApplication::instance()), static_cast<QGuiApplication*>(QCoreApplication::instance()),
&QGuiApplication::applicationStateChanged &QGuiApplication::applicationStateChanged

View file

@ -271,7 +271,7 @@ public:
void handleAppActivated(); void handleAppActivated();
void handleAppDeactivated(); void handleAppDeactivated();
[[nodiscard]] rpl::producer<bool> appDeactivated() const; [[nodiscard]] rpl::producer<bool> appDeactivates() const;
void switchDebugMode(); void switchDebugMode();
void switchFreeType(); void switchFreeType();