Added initial animation of Blobs hiding.

This commit is contained in:
23rd 2020-12-03 18:09:10 +03:00
parent 5b0e499932
commit 5437c8865d
3 changed files with 31 additions and 4 deletions

View file

@ -42,6 +42,8 @@ public:
[[nodiscard]] int size() const;
[[nodiscard]] float64 currentLevel() const;
static constexpr auto kHideBlobsDuration = 2000;
private:
void init();

View file

@ -148,6 +148,7 @@ private:
QRect _inner;
crl::time _blobsLastTime = 0;
crl::time _blobsHideLastTime = 0;
Animations::Basic _animation;
@ -174,6 +175,18 @@ BlobsWidget::BlobsWidget(
}) | rpl::distinct_until_changed();
_blobs.setRadiusesAt(std::move(radiusesChange), i);
}
std::move(
hideBlobs
) | rpl::start_with_next([=](bool hide) {
if (hide) {
setLevel(0.);
}
_blobsHideLastTime = hide ? crl::now() : 0;
if (!hide && !_animation.animating()) {
_animation.start();
}
}, lifetime());
}
void BlobsWidget::init() {
@ -223,6 +236,11 @@ void BlobsWidget::init() {
}, lifetime());
_animation.init([=](crl::time now) {
if (const auto &last = _blobsHideLastTime; (last > 0)
&& (now - last >= Paint::Blobs::kHideBlobsDuration)) {
_animation.stop();
return false;
}
_blobs.updateLevel(now - _blobsLastTime);
_blobsLastTime = now;
@ -258,19 +276,25 @@ void BlobsWidget::setGlowBrush(QBrush brush) {
}
void BlobsWidget::setLevel(float level) {
if (_blobsHideLastTime) {
return;
}
_blobs.setLevel(level);
}
CallMuteButton::CallMuteButton(
not_null<RpWidget*> parent,
rpl::producer<bool> &&hideBlobs,
CallMuteButtonState initial)
: _state(initial)
, _blobs(base::make_unique_q<BlobsWidget>(
parent,
_state.value(
) | rpl::map([](const CallMuteButtonState &state) {
return IsConnecting(state.type);
})))
rpl::merge(
std::move(hideBlobs),
_state.value(
) | rpl::map([](const CallMuteButtonState &state) {
return IsConnecting(state.type);
}))))
, _content(parent, st::callMuteButtonActive, &st::callMuteButtonMuted)
, _radial(nullptr)
, _colors(Colors())

View file

@ -34,6 +34,7 @@ class CallMuteButton final {
public:
explicit CallMuteButton(
not_null<RpWidget*> parent,
rpl::producer<bool> &&hideBlobs,
CallMuteButtonState initial = CallMuteButtonState());
~CallMuteButton();