mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added hiding of Blob animations in GroupCallBar.
This commit is contained in:
parent
e73b522411
commit
4b41962ff6
3 changed files with 44 additions and 12 deletions
|
@ -5417,7 +5417,8 @@ void HistoryWidget::setupGroupCallTracker() {
|
||||||
channel);
|
channel);
|
||||||
_groupCallBar = std::make_unique<Ui::GroupCallBar>(
|
_groupCallBar = std::make_unique<Ui::GroupCallBar>(
|
||||||
this,
|
this,
|
||||||
_groupCallTracker->content());
|
_groupCallTracker->content(),
|
||||||
|
Core::App().appDeactivatedValue());
|
||||||
|
|
||||||
rpl::single(
|
rpl::single(
|
||||||
rpl::empty_value()
|
rpl::empty_value()
|
||||||
|
|
|
@ -89,7 +89,8 @@ struct GroupCallBar::Userpic {
|
||||||
|
|
||||||
GroupCallBar::GroupCallBar(
|
GroupCallBar::GroupCallBar(
|
||||||
not_null<QWidget*> parent,
|
not_null<QWidget*> parent,
|
||||||
rpl::producer<GroupCallBarContent> content)
|
rpl::producer<GroupCallBarContent> content,
|
||||||
|
rpl::producer<bool> &&hideBlobs)
|
||||||
: _wrap(parent, object_ptr<RpWidget>(parent))
|
: _wrap(parent, object_ptr<RpWidget>(parent))
|
||||||
, _inner(_wrap.entity())
|
, _inner(_wrap.entity())
|
||||||
, _join(std::make_unique<RoundButton>(
|
, _join(std::make_unique<RoundButton>(
|
||||||
|
@ -147,11 +148,10 @@ GroupCallBar::GroupCallBar(
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_speakingAnimation.init([=](crl::time now) {
|
_speakingAnimation.init([=](crl::time now) {
|
||||||
//if (const auto &last = _speakingAnimationHideLastTime; (last > 0)
|
if (const auto &last = _speakingAnimationHideLastTime; (last > 0)
|
||||||
// && (now - last >= kBlobsEnterDuration)) {
|
&& (now - last >= kBlobsEnterDuration)) {
|
||||||
// _speakingAnimation.stop();
|
_speakingAnimation.stop();
|
||||||
// return false;
|
}
|
||||||
//}
|
|
||||||
for (auto &userpic : _userpics) {
|
for (auto &userpic : _userpics) {
|
||||||
if (const auto blobs = userpic.blobsAnimation.get()) {
|
if (const auto blobs = userpic.blobsAnimation.get()) {
|
||||||
blobs->blobs.updateLevel(now - blobs->lastTime);
|
blobs->blobs.updateLevel(now - blobs->lastTime);
|
||||||
|
@ -161,6 +161,27 @@ GroupCallBar::GroupCallBar(
|
||||||
updateUserpics();
|
updateUserpics();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rpl::combine(
|
||||||
|
rpl::single(anim::Disabled()) | rpl::then(anim::Disables()),
|
||||||
|
std::move(hideBlobs)
|
||||||
|
) | rpl::start_with_next([=](bool animDisabled, bool deactivated) {
|
||||||
|
const auto hide = animDisabled || deactivated;
|
||||||
|
|
||||||
|
if (!(hide && _speakingAnimationHideLastTime)) {
|
||||||
|
_speakingAnimationHideLastTime = hide ? crl::now() : 0;
|
||||||
|
}
|
||||||
|
_skipLevelUpdate = hide;
|
||||||
|
for (auto &userpic : _userpics) {
|
||||||
|
if (const auto blobs = userpic.blobsAnimation.get()) {
|
||||||
|
blobs->blobs.setLevel(0.);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hide && !_speakingAnimation.animating()) {
|
||||||
|
_speakingAnimation.start();
|
||||||
|
}
|
||||||
|
_skipLevelUpdate = hide;
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
setupInner();
|
setupInner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +263,7 @@ void GroupCallBar::paintUserpics(Painter &p) {
|
||||||
const auto middle = _inner->width() / 2;
|
const auto middle = _inner->width() / 2;
|
||||||
const auto size = st::historyGroupCallUserpicSize;
|
const auto size = st::historyGroupCallUserpicSize;
|
||||||
const auto factor = style::DevicePixelRatio();
|
const auto factor = style::DevicePixelRatio();
|
||||||
|
const auto &minScale = kUserpicMinScale;
|
||||||
for (auto &userpic : ranges::view::reverse(_userpics)) {
|
for (auto &userpic : ranges::view::reverse(_userpics)) {
|
||||||
const auto shown = userpic.shownAnimation.value(
|
const auto shown = userpic.shownAnimation.value(
|
||||||
userpic.hiding ? 0. : 1.);
|
userpic.hiding ? 0. : 1.);
|
||||||
|
@ -253,10 +275,12 @@ void GroupCallBar::paintUserpics(Painter &p) {
|
||||||
const auto left = middle + userpic.leftAnimation.value(userpic.left);
|
const auto left = middle + userpic.leftAnimation.value(userpic.left);
|
||||||
const auto blobs = userpic.blobsAnimation.get();
|
const auto blobs = userpic.blobsAnimation.get();
|
||||||
const auto shownScale = 0.5 + shown / 2.;
|
const auto shownScale = 0.5 + shown / 2.;
|
||||||
const auto &minScale = kUserpicMinScale;
|
const auto scale = shownScale * (!blobs
|
||||||
const auto scale = shownScale * (blobs
|
? 1.
|
||||||
? (minScale + (1. - minScale) * blobs->blobs.currentLevel())
|
: (minScale
|
||||||
: 1.);
|
+ (1. - minScale) * (_speakingAnimationHideLastTime
|
||||||
|
? (1. - blobs->blobs.currentLevel())
|
||||||
|
: blobs->blobs.currentLevel())));
|
||||||
if (blobs) {
|
if (blobs) {
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
|
|
||||||
|
@ -323,6 +347,9 @@ void GroupCallBar::ensureBlobsAnimation(Userpic &userpic) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCallBar::sendRandomLevels() {
|
void GroupCallBar::sendRandomLevels() {
|
||||||
|
if (_skipLevelUpdate) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (auto &userpic : _userpics) {
|
for (auto &userpic : _userpics) {
|
||||||
if (const auto blobs = userpic.blobsAnimation.get()) {
|
if (const auto blobs = userpic.blobsAnimation.get()) {
|
||||||
const auto value = 30 + (openssl::RandomValue<uint32>() % 70);
|
const auto value = 30 + (openssl::RandomValue<uint32>() % 70);
|
||||||
|
|
|
@ -35,7 +35,8 @@ class GroupCallBar final {
|
||||||
public:
|
public:
|
||||||
GroupCallBar(
|
GroupCallBar(
|
||||||
not_null<QWidget*> parent,
|
not_null<QWidget*> parent,
|
||||||
rpl::producer<GroupCallBarContent> content);
|
rpl::producer<GroupCallBarContent> content,
|
||||||
|
rpl::producer<bool> &&hideBlobs);
|
||||||
~GroupCallBar();
|
~GroupCallBar();
|
||||||
|
|
||||||
void show();
|
void show();
|
||||||
|
@ -89,6 +90,9 @@ private:
|
||||||
bool _shouldBeShown = false;
|
bool _shouldBeShown = false;
|
||||||
bool _forceHidden = false;
|
bool _forceHidden = false;
|
||||||
|
|
||||||
|
bool _skipLevelUpdate = false;
|
||||||
|
crl::time _speakingAnimationHideLastTime = 0;
|
||||||
|
|
||||||
GroupCallBarContent _content;
|
GroupCallBarContent _content;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue