Added initial animation of Blobs hiding.
This commit is contained in:
parent
5b0e499932
commit
5437c8865d
3 changed files with 31 additions and 4 deletions
|
|
@ -42,6 +42,8 @@ public:
|
||||||
[[nodiscard]] int size() const;
|
[[nodiscard]] int size() const;
|
||||||
[[nodiscard]] float64 currentLevel() const;
|
[[nodiscard]] float64 currentLevel() const;
|
||||||
|
|
||||||
|
static constexpr auto kHideBlobsDuration = 2000;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,7 @@ private:
|
||||||
QRect _inner;
|
QRect _inner;
|
||||||
|
|
||||||
crl::time _blobsLastTime = 0;
|
crl::time _blobsLastTime = 0;
|
||||||
|
crl::time _blobsHideLastTime = 0;
|
||||||
|
|
||||||
Animations::Basic _animation;
|
Animations::Basic _animation;
|
||||||
|
|
||||||
|
|
@ -174,6 +175,18 @@ BlobsWidget::BlobsWidget(
|
||||||
}) | rpl::distinct_until_changed();
|
}) | rpl::distinct_until_changed();
|
||||||
_blobs.setRadiusesAt(std::move(radiusesChange), i);
|
_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() {
|
void BlobsWidget::init() {
|
||||||
|
|
@ -223,6 +236,11 @@ void BlobsWidget::init() {
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_animation.init([=](crl::time now) {
|
_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);
|
_blobs.updateLevel(now - _blobsLastTime);
|
||||||
_blobsLastTime = now;
|
_blobsLastTime = now;
|
||||||
|
|
||||||
|
|
@ -258,19 +276,25 @@ void BlobsWidget::setGlowBrush(QBrush brush) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlobsWidget::setLevel(float level) {
|
void BlobsWidget::setLevel(float level) {
|
||||||
|
if (_blobsHideLastTime) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_blobs.setLevel(level);
|
_blobs.setLevel(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallMuteButton::CallMuteButton(
|
CallMuteButton::CallMuteButton(
|
||||||
not_null<RpWidget*> parent,
|
not_null<RpWidget*> parent,
|
||||||
|
rpl::producer<bool> &&hideBlobs,
|
||||||
CallMuteButtonState initial)
|
CallMuteButtonState initial)
|
||||||
: _state(initial)
|
: _state(initial)
|
||||||
, _blobs(base::make_unique_q<BlobsWidget>(
|
, _blobs(base::make_unique_q<BlobsWidget>(
|
||||||
parent,
|
parent,
|
||||||
_state.value(
|
rpl::merge(
|
||||||
) | rpl::map([](const CallMuteButtonState &state) {
|
std::move(hideBlobs),
|
||||||
return IsConnecting(state.type);
|
_state.value(
|
||||||
})))
|
) | rpl::map([](const CallMuteButtonState &state) {
|
||||||
|
return IsConnecting(state.type);
|
||||||
|
}))))
|
||||||
, _content(parent, st::callMuteButtonActive, &st::callMuteButtonMuted)
|
, _content(parent, st::callMuteButtonActive, &st::callMuteButtonMuted)
|
||||||
, _radial(nullptr)
|
, _radial(nullptr)
|
||||||
, _colors(Colors())
|
, _colors(Colors())
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ class CallMuteButton final {
|
||||||
public:
|
public:
|
||||||
explicit CallMuteButton(
|
explicit CallMuteButton(
|
||||||
not_null<RpWidget*> parent,
|
not_null<RpWidget*> parent,
|
||||||
|
rpl::producer<bool> &&hideBlobs,
|
||||||
CallMuteButtonState initial = CallMuteButtonState());
|
CallMuteButtonState initial = CallMuteButtonState());
|
||||||
~CallMuteButton();
|
~CallMuteButton();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue