mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add initial reaction bubble appear animation.
This commit is contained in:
parent
050916a56a
commit
f5e50409d3
3 changed files with 33 additions and 11 deletions
|
@ -168,6 +168,10 @@ bool SendAnimation::flying() const {
|
||||||
return (_flyIcon != nullptr);
|
return (_flyIcon != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float64 SendAnimation::flyingProgress() const {
|
||||||
|
return _fly.value(1.);
|
||||||
|
}
|
||||||
|
|
||||||
QString SendAnimation::playingAroundEmoji() const {
|
QString SendAnimation::playingAroundEmoji() const {
|
||||||
const auto finished = !_valid
|
const auto finished = !_valid
|
||||||
|| (!_flyIcon && !_center->animating() && !_effect->animating());
|
|| (!_flyIcon && !_center->animating() && !_effect->animating());
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] QString playingAroundEmoji() const;
|
[[nodiscard]] QString playingAroundEmoji() const;
|
||||||
[[nodiscard]] bool flying() const;
|
[[nodiscard]] bool flying() const;
|
||||||
|
[[nodiscard]] float64 flyingProgress() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void flyCallback();
|
void flyCallback();
|
||||||
|
|
|
@ -259,33 +259,46 @@ void InlineList::paint(
|
||||||
}
|
}
|
||||||
p.setFont(st::semiboldFont);
|
p.setFont(st::semiboldFont);
|
||||||
for (const auto &button : _buttons) {
|
for (const auto &button : _buttons) {
|
||||||
|
const auto &geometry = button.geometry;
|
||||||
const auto mine = (_data.chosenReaction == button.emoji);
|
const auto mine = (_data.chosenReaction == button.emoji);
|
||||||
const auto withoutMine = button.count - (mine ? 1 : 0);
|
const auto withoutMine = button.count - (mine ? 1 : 0);
|
||||||
const auto animating = (animated == button.emoji);
|
const auto animating = (animated == button.emoji);
|
||||||
const auto skipImage = animating
|
const auto skipImage = animating
|
||||||
&& (withoutMine < 1 || !_animation->flying());
|
&& (withoutMine < 1 || !_animation->flying());
|
||||||
const auto skipBubble = skipImage && _animation->flying();
|
const auto bubbleProgress = skipImage
|
||||||
const auto &geometry = button.geometry;
|
? _animation->flyingProgress()
|
||||||
|
: 1.;
|
||||||
|
const auto bubbleReady = (bubbleProgress == 1.);
|
||||||
|
const auto bubbleSkip = anim::interpolate(
|
||||||
|
geometry.height() - geometry.width(),
|
||||||
|
0,
|
||||||
|
bubbleProgress);
|
||||||
const auto inner = geometry.marginsRemoved(padding);
|
const auto inner = geometry.marginsRemoved(padding);
|
||||||
const auto chosen = mine
|
const auto chosen = mine
|
||||||
&& (!animating || !_animation->flying());
|
&& (!animating || !_animation->flying() || skipImage);
|
||||||
if (!skipBubble) {
|
if (bubbleProgress > 0.) {
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
if (inbubble) {
|
if (inbubble) {
|
||||||
if (!chosen) {
|
if (!chosen) {
|
||||||
p.setOpacity(context.outbg
|
p.setOpacity(bubbleProgress * (context.outbg
|
||||||
? kOutNonChosenOpacity
|
? kOutNonChosenOpacity
|
||||||
: kInNonChosenOpacity);
|
: kInNonChosenOpacity));
|
||||||
|
} else if (!bubbleReady) {
|
||||||
|
p.setOpacity(bubbleProgress);
|
||||||
}
|
}
|
||||||
p.setBrush(stm->msgFileBg);
|
p.setBrush(stm->msgFileBg);
|
||||||
} else {
|
} else {
|
||||||
|
if (!bubbleReady) {
|
||||||
|
p.setOpacity(bubbleProgress);
|
||||||
|
}
|
||||||
p.setBrush(chosen ? st->msgServiceFg() : st->msgServiceBg());
|
p.setBrush(chosen ? st->msgServiceFg() : st->msgServiceBg());
|
||||||
}
|
}
|
||||||
const auto radius = geometry.height() / 2.;
|
const auto radius = geometry.height() / 2.;
|
||||||
p.drawRoundedRect(geometry, radius, radius);
|
const auto fill = geometry.marginsAdded({ 0, 0, bubbleSkip, 0 });
|
||||||
|
p.drawRoundedRect(fill, radius, radius);
|
||||||
if (inbubble && !chosen) {
|
if (inbubble && !chosen) {
|
||||||
p.setOpacity(1.);
|
p.setOpacity(bubbleProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (button.image.isNull()) {
|
if (button.image.isNull()) {
|
||||||
|
@ -304,13 +317,14 @@ void InlineList::paint(
|
||||||
return _animation->paintGetArea(p, QPoint(), image);
|
return _animation->paintGetArea(p, QPoint(), image);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (skipBubble) {
|
if (bubbleProgress == 0.) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
resolveUserpicsImage(button);
|
resolveUserpicsImage(button);
|
||||||
|
const auto left = inner.x() + bubbleSkip;
|
||||||
if (button.userpics) {
|
if (button.userpics) {
|
||||||
p.drawImage(
|
p.drawImage(
|
||||||
inner.x() + size + st::reactionInlineUserpicsPadding.left(),
|
left + size + st::reactionInlineUserpicsPadding.left(),
|
||||||
geometry.y() + st::reactionInlineUserpicsPadding.top(),
|
geometry.y() + st::reactionInlineUserpicsPadding.top(),
|
||||||
button.userpics->image);
|
button.userpics->image);
|
||||||
} else {
|
} else {
|
||||||
|
@ -330,10 +344,13 @@ void InlineList::paint(
|
||||||
const auto textTop = geometry.y()
|
const auto textTop = geometry.y()
|
||||||
+ ((geometry.height() - st::semiboldFont->height) / 2);
|
+ ((geometry.height() - st::semiboldFont->height) / 2);
|
||||||
p.drawText(
|
p.drawText(
|
||||||
inner.x() + size + st::reactionInlineSkip,
|
left + size + st::reactionInlineSkip,
|
||||||
textTop + st::semiboldFont->ascent,
|
textTop + st::semiboldFont->ascent,
|
||||||
button.countText);
|
button.countText);
|
||||||
}
|
}
|
||||||
|
if (!bubbleReady) {
|
||||||
|
p.setOpacity(1.);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue