mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Slightly refactored LinearBlob animation in Calls::TopBar.
This commit is contained in:
parent
de20ff05eb
commit
62fe44bde8
2 changed files with 25 additions and 40 deletions
|
@ -750,16 +750,11 @@ groupCallTitle: WindowTitle(defaultWindowTitle) {
|
||||||
closeIconActiveOver: groupCallTitleCloseIconOver;
|
closeIconActiveOver: groupCallTitleCloseIconOver;
|
||||||
}
|
}
|
||||||
|
|
||||||
groupCallMajorBlobMinRadius: 2px;
|
groupCallMajorBlobIdleRadius: 2px;
|
||||||
groupCallMajorBlobMaxRadius: 2px;
|
groupCallMajorBlobMaxRadius: 4px;
|
||||||
|
|
||||||
groupCallMinorBlobMinRadius: 3px;
|
groupCallMinorBlobIdleRadius: 3px;
|
||||||
groupCallMinorBlobMaxRadius: 9px;
|
groupCallMinorBlobMaxRadius: 12px;
|
||||||
|
|
||||||
groupCallMajorBlobTopOffset: 0px;
|
|
||||||
groupCallMinorBlobTopOffset: 6px;
|
|
||||||
|
|
||||||
groupCallBlobWidthAdditional: 40px;
|
|
||||||
|
|
||||||
callTopBarMuteCrossLine: CrossLineAnimation {
|
callTopBarMuteCrossLine: CrossLineAnimation {
|
||||||
fg: callBarFg;
|
fg: callBarFg;
|
||||||
|
|
|
@ -42,40 +42,37 @@ constexpr auto kSwitchStateDuration = 120;
|
||||||
|
|
||||||
constexpr auto kMinorBlobAlpha = 76. / 255.;
|
constexpr auto kMinorBlobAlpha = 76. / 255.;
|
||||||
|
|
||||||
constexpr auto kBlobLevelDuration1 = 250;
|
constexpr auto kHideBlobsDuration = crl::time(500);
|
||||||
constexpr auto kBlobLevelDuration2 = 120;
|
constexpr auto kBlobLevelDuration = crl::time(250);
|
||||||
constexpr auto kBlobUpdateInterval = crl::time(100);
|
constexpr auto kBlobUpdateInterval = crl::time(100);
|
||||||
|
|
||||||
auto LinearBlobs() -> std::array<Ui::Paint::LinearBlobs::BlobData, 3> {
|
auto LinearBlobs() {
|
||||||
return { {
|
return std::vector<Ui::Paint::LinearBlobs::BlobData>{
|
||||||
{
|
{
|
||||||
.segmentsCount = 5,
|
.segmentsCount = 5,
|
||||||
.minScale = 1.,
|
.minRadius = 0.,
|
||||||
.minRadius = (float)st::groupCallMajorBlobMinRadius,
|
|
||||||
.maxRadius = (float)st::groupCallMajorBlobMaxRadius,
|
.maxRadius = (float)st::groupCallMajorBlobMaxRadius,
|
||||||
|
.idleRadius = (float)st::groupCallMinorBlobIdleRadius,
|
||||||
.speedScale = .3,
|
.speedScale = .3,
|
||||||
.alpha = 1.,
|
.alpha = 1.,
|
||||||
.topOffset = st::groupCallMajorBlobTopOffset,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.segmentsCount = 7,
|
.segmentsCount = 7,
|
||||||
.minScale = 1.,
|
.minRadius = 0.,
|
||||||
.minRadius = (float)st::groupCallMinorBlobMinRadius,
|
|
||||||
.maxRadius = (float)st::groupCallMinorBlobMaxRadius,
|
.maxRadius = (float)st::groupCallMinorBlobMaxRadius,
|
||||||
|
.idleRadius = (float)st::groupCallMinorBlobIdleRadius,
|
||||||
.speedScale = .7,
|
.speedScale = .7,
|
||||||
.alpha = kMinorBlobAlpha,
|
.alpha = kMinorBlobAlpha,
|
||||||
.topOffset = st::groupCallMinorBlobTopOffset,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.segmentsCount = 8,
|
.segmentsCount = 8,
|
||||||
.minScale = 1.,
|
.minRadius = 0.,
|
||||||
.minRadius = (float)st::groupCallMinorBlobMinRadius,
|
|
||||||
.maxRadius = (float)st::groupCallMinorBlobMaxRadius,
|
.maxRadius = (float)st::groupCallMinorBlobMaxRadius,
|
||||||
|
.idleRadius = (float)st::groupCallMinorBlobIdleRadius,
|
||||||
.speedScale = .7,
|
.speedScale = .7,
|
||||||
.alpha = kMinorBlobAlpha,
|
.alpha = kMinorBlobAlpha,
|
||||||
.topOffset = st::groupCallMinorBlobTopOffset,
|
|
||||||
},
|
},
|
||||||
} };
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Colors() {
|
auto Colors() {
|
||||||
|
@ -358,14 +355,12 @@ void TopBar::initBlobsUnder(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr auto kHideDuration = kBlobLevelDuration1 * 2;
|
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
Ui::Paint::LinearBlobs paint = {
|
Ui::Paint::LinearBlobs paint = {
|
||||||
LinearBlobs() | ranges::to_vector,
|
LinearBlobs(),
|
||||||
kBlobLevelDuration1,
|
kBlobLevelDuration,
|
||||||
kBlobLevelDuration2,
|
1.,
|
||||||
1.
|
Ui::Paint::LinearBlob::Direction::TopDown
|
||||||
};
|
};
|
||||||
Ui::Animations::Simple hideAnimation;
|
Ui::Animations::Simple hideAnimation;
|
||||||
Ui::Animations::Basic animation;
|
Ui::Animations::Basic animation;
|
||||||
|
@ -374,8 +369,6 @@ void TopBar::initBlobsUnder(
|
||||||
crl::time lastTime = 0;
|
crl::time lastTime = 0;
|
||||||
float lastLevel = 0.;
|
float lastLevel = 0.;
|
||||||
float levelBeforeLast = 0.;
|
float levelBeforeLast = 0.;
|
||||||
int maxHeight = st::groupCallMinorBlobMinRadius
|
|
||||||
+ st::groupCallMinorBlobMaxRadius;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_blobs = base::make_unique_q<Ui::RpWidget>(blobsParent);
|
_blobs = base::make_unique_q<Ui::RpWidget>(blobsParent);
|
||||||
|
@ -392,7 +385,7 @@ void TopBar::initBlobsUnder(
|
||||||
|
|
||||||
state->animation.init([=](crl::time now) {
|
state->animation.init([=](crl::time now) {
|
||||||
if (const auto last = state->hideLastTime; (last > 0)
|
if (const auto last = state->hideLastTime; (last > 0)
|
||||||
&& (now - last >= kHideDuration)) {
|
&& (now - last >= kHideBlobsDuration)) {
|
||||||
state->animation.stop();
|
state->animation.stop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -448,7 +441,7 @@ void TopBar::initBlobsUnder(
|
||||||
const auto to = hide ? 1. : 0.;
|
const auto to = hide ? 1. : 0.;
|
||||||
state->hideAnimation.start([=](float64) {
|
state->hideAnimation.start([=](float64) {
|
||||||
_blobs->update();
|
_blobs->update();
|
||||||
}, from, to, kHideDuration);
|
}, from, to, kHideBlobsDuration);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
std::move(
|
std::move(
|
||||||
|
@ -456,7 +449,7 @@ void TopBar::initBlobsUnder(
|
||||||
) | rpl::start_with_next([=](QRect rect) {
|
) | rpl::start_with_next([=](QRect rect) {
|
||||||
_blobs->resize(
|
_blobs->resize(
|
||||||
rect.width(),
|
rect.width(),
|
||||||
std::min(state->maxHeight, rect.height()));
|
(int)state->paint.maxRadius());
|
||||||
_blobs->moveToLeft(rect.x(), rect.y() + rect.height());
|
_blobs->moveToLeft(rect.x(), rect.y() + rect.height());
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
@ -478,12 +471,9 @@ void TopBar::initBlobsUnder(
|
||||||
p.setOpacity(1. - hidden);
|
p.setOpacity(1. - hidden);
|
||||||
}
|
}
|
||||||
const auto top = -_blobs->height() * hidden;
|
const auto top = -_blobs->height() * hidden;
|
||||||
const auto drawUnder = QRect(
|
const auto width = _blobs->width();
|
||||||
0,
|
p.translate(0, top);
|
||||||
top,
|
state->paint.paint(p, _groupBrush, width);
|
||||||
_blobs->width() + st::groupCallBlobWidthAdditional,
|
|
||||||
0);
|
|
||||||
state->paint.paint(p, _groupBrush, drawUnder, 0, 0);
|
|
||||||
}, _blobs->lifetime());
|
}, _blobs->lifetime());
|
||||||
|
|
||||||
group->levelUpdates(
|
group->levelUpdates(
|
||||||
|
|
Loading…
Add table
Reference in a new issue