mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 15:47:11 +02:00
Improve reaction scale animation.
This commit is contained in:
parent
cfc2a959cf
commit
f98c08f4c6
2 changed files with 37 additions and 27 deletions
|
@ -1021,10 +1021,7 @@ void Manager::paintAllEmoji(
|
|||
const auto skip = st::reactionAppearStartSkip;
|
||||
const auto animationRect = clip.marginsRemoved({ 0, skip, 0, skip });
|
||||
|
||||
auto hq = std::optional<PainterHighQualityEnabler>();
|
||||
if (scale != 1. && scale != kHoverScale) {
|
||||
hq.emplace(p);
|
||||
}
|
||||
PainterHighQualityEnabler hq(p);
|
||||
const auto between = st::reactionCornerSkip;
|
||||
const auto oneHeight = st::reactionCornerSize.height() + between;
|
||||
const auto finalSize = CornerImageSize(1.);
|
||||
|
@ -1061,25 +1058,18 @@ void Manager::paintAllEmoji(
|
|||
const auto target = countTarget(icon).translated(emojiPosition);
|
||||
emojiPosition += shift;
|
||||
|
||||
const auto paintFrame = [&](not_null<Lottie::Icon*> animation) {
|
||||
const auto size = int(std::floor(target.width() + 0.01));
|
||||
const auto frame = animation->frame({ size, size }, update);
|
||||
p.drawImage(target, frame.image);
|
||||
};
|
||||
|
||||
if (!target.intersects(clip)) {
|
||||
if (current) {
|
||||
if (const auto appear = icon.appear.get()) {
|
||||
appear->jumpTo(0, nullptr);
|
||||
}
|
||||
if (icon.selected) {
|
||||
setSelectedIcon(-1);
|
||||
}
|
||||
icon.appearAnimated = false;
|
||||
icon.selectAnimated = false;
|
||||
if (const auto select = icon.select.get()) {
|
||||
select->jumpTo(0, nullptr);
|
||||
}
|
||||
icon.selectedScale.stop();
|
||||
clearStateForHidden(icon);
|
||||
}
|
||||
} else if (icon.select && icon.select->animating()) {
|
||||
const auto size = int(base::SafeRound(target.width()));
|
||||
const auto frame = icon.select->frame({ size, size }, update);
|
||||
p.drawImage(target, frame.image);
|
||||
paintFrame(icon.select.get());
|
||||
} else if (const auto appear = icon.appear.get()) {
|
||||
if (current
|
||||
&& !icon.appearAnimated
|
||||
|
@ -1087,19 +1077,37 @@ void Manager::paintAllEmoji(
|
|||
icon.appearAnimated = true;
|
||||
appear->animate(update, 0, appear->framesCount() - 1);
|
||||
}
|
||||
const auto size = int(base::SafeRound(target.width()));
|
||||
const auto frame = appear->frame({ size, size }, update);
|
||||
p.drawImage(target, frame.image);
|
||||
paintFrame(appear);
|
||||
}
|
||||
if (current
|
||||
&& icon.selectAnimated
|
||||
&& !icon.select->animating()
|
||||
&& !icon.selected) {
|
||||
icon.selectAnimated = false;
|
||||
if (current) {
|
||||
clearStateForSelectFinished(icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::clearStateForHidden(ReactionIcons &icon) {
|
||||
if (const auto appear = icon.appear.get()) {
|
||||
appear->jumpTo(0, nullptr);
|
||||
}
|
||||
if (icon.selected) {
|
||||
setSelectedIcon(-1);
|
||||
}
|
||||
icon.appearAnimated = false;
|
||||
icon.selectAnimated = false;
|
||||
if (const auto select = icon.select.get()) {
|
||||
select->jumpTo(0, nullptr);
|
||||
}
|
||||
icon.selectedScale.stop();
|
||||
}
|
||||
|
||||
void Manager::clearStateForSelectFinished(ReactionIcons &icon) {
|
||||
if (icon.selectAnimated
|
||||
&& !icon.select->animating()
|
||||
&& !icon.selected) {
|
||||
icon.selectAnimated = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::applyPatternedShadow(const QColor &shadow) {
|
||||
if (_shadow == shadow) {
|
||||
return;
|
||||
|
|
|
@ -221,6 +221,8 @@ private:
|
|||
void setBackground(const QColor &background);
|
||||
|
||||
void setSelectedIcon(int index) const;
|
||||
void clearStateForHidden(ReactionIcons &icon);
|
||||
void clearStateForSelectFinished(ReactionIcons &icon);
|
||||
|
||||
[[nodiscard]] QMargins innerMargins() const;
|
||||
[[nodiscard]] QRect buttonInner() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue