mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Add effect animation for heart-like.
This commit is contained in:
parent
4bd925ac2c
commit
40b274e1b4
5 changed files with 33 additions and 23 deletions
|
@ -114,6 +114,10 @@ struct SameDayRange {
|
|||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] Data::ReactionId HeartReactionId() {
|
||||
return { QString() + QChar(10084) };
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class Controller::PhotoPlayback final {
|
||||
|
@ -309,10 +313,11 @@ Controller::Controller(not_null<Delegate*> delegate)
|
|||
|
||||
_reactions->chosen(
|
||||
) | rpl::start_with_next([=](HistoryView::Reactions::ChosenReaction id) {
|
||||
startReactionAnimation(id.id, {
|
||||
.type = Ui::MessageSendingAnimationFrom::Type::Emoji,
|
||||
.globalStartGeometry = id.globalGeometry,
|
||||
.frame = id.icon,
|
||||
startReactionAnimation({
|
||||
.id = id.id,
|
||||
.flyIcon = id.icon,
|
||||
.flyFrom = _wrap->mapFromGlobal(id.globalGeometry),
|
||||
.scaleOutDuration = st::fadeWrapDuration * 2,
|
||||
}, _wrap.get());
|
||||
_replyArea->sendReaction(id.id);
|
||||
unfocusReply();
|
||||
|
@ -597,6 +602,13 @@ rpl::producer<bool> Controller::likedValue() const {
|
|||
|
||||
void Controller::toggleLiked(bool liked) {
|
||||
_liked = liked;
|
||||
if (liked) {
|
||||
startReactionAnimation({
|
||||
.id = HeartReactionId(),
|
||||
.scaleOutDuration = st::fadeWrapDuration * 2,
|
||||
.effectOnly = true,
|
||||
}, _replyArea->likeAnimationTarget());
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::showFullCaption() {
|
||||
|
@ -1045,6 +1057,8 @@ void Controller::ready() {
|
|||
}
|
||||
_started = true;
|
||||
updatePlayingAllowed();
|
||||
uiShow()->session().data().reactions().preloadAnimationsFor(
|
||||
HeartReactionId());
|
||||
}
|
||||
|
||||
void Controller::updateVideoPlayback(const Player::TrackState &state) {
|
||||
|
@ -1563,17 +1577,10 @@ void Controller::updatePowerSaveBlocker(const Player::TrackState &state) {
|
|||
}
|
||||
|
||||
void Controller::startReactionAnimation(
|
||||
Data::ReactionId id,
|
||||
Ui::MessageSendingAnimationFrom from,
|
||||
Ui::ReactionFlyAnimationArgs args,
|
||||
not_null<QWidget*> target) {
|
||||
Expects(shown());
|
||||
|
||||
auto args = Ui::ReactionFlyAnimationArgs{
|
||||
.id = id,
|
||||
.flyIcon = from.frame,
|
||||
.flyFrom = _wrap->mapFromGlobal(from.globalStartGeometry),
|
||||
.scaleOutDuration = st::fadeWrapDuration * 2,
|
||||
};
|
||||
_reactionAnimation = std::make_unique<Ui::EmojiFlyAnimation>(
|
||||
_wrap,
|
||||
&shownUser()->owner().reactions(),
|
||||
|
|
|
@ -35,7 +35,7 @@ class CachedIconFactory;
|
|||
|
||||
namespace Ui {
|
||||
class RpWidget;
|
||||
struct MessageSendingAnimationFrom;
|
||||
struct ReactionFlyAnimationArgs;
|
||||
class EmojiFlyAnimation;
|
||||
class BoxContent;
|
||||
} // namespace Ui
|
||||
|
@ -238,8 +238,7 @@ private:
|
|||
int index);
|
||||
|
||||
void startReactionAnimation(
|
||||
Data::ReactionId id,
|
||||
Ui::MessageSendingAnimationFrom from,
|
||||
Ui::ReactionFlyAnimationArgs from,
|
||||
not_null<QWidget*> target);
|
||||
|
||||
const not_null<Delegate*> _delegate;
|
||||
|
|
|
@ -1031,8 +1031,8 @@ QSize OverlayWidget::flipSizeByRotation(QSize size) const {
|
|||
bool OverlayWidget::hasCopyMediaRestriction(bool skipPremiumCheck) const {
|
||||
if (const auto story = _stories ? _stories->story() : nullptr) {
|
||||
return skipPremiumCheck
|
||||
? story->canDownloadIfPremium()
|
||||
: story->canDownloadChecked();
|
||||
? !story->canDownloadIfPremium()
|
||||
: !story->canDownloadChecked();
|
||||
}
|
||||
return (_history && !_history->peer->allowsForwarding())
|
||||
|| (_message && _message->forbidsSaving());
|
||||
|
@ -1261,9 +1261,12 @@ void OverlayWidget::showPremiumDownloadPromo() {
|
|||
.text = tr::lng_stories_save_promo(
|
||||
tr::now,
|
||||
lt_link,
|
||||
Ui::Text::Bold(tr::lng_send_as_premium_required_link(tr::now)),
|
||||
Ui::Text::Link(
|
||||
Ui::Text::Bold(
|
||||
tr::lng_send_as_premium_required_link(tr::now))),
|
||||
Ui::Text::WithEntities),
|
||||
.duration = kStorySavePromoDuration,
|
||||
.adaptive = true,
|
||||
.filter = filter,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -111,11 +111,13 @@ ReactionFlyAnimation::ReactionFlyAnimation(
|
|||
});
|
||||
return true;
|
||||
};
|
||||
if (!_custom && !resolve(_center, centerIcon, size)) {
|
||||
generateMiniCopies(size + size / 2);
|
||||
if (args.effectOnly) {
|
||||
_custom = nullptr;
|
||||
} else if (!_custom && !resolve(_center, centerIcon, size)) {
|
||||
return;
|
||||
}
|
||||
resolve(_effect, aroundAnimation, size * 2);
|
||||
generateMiniCopies(size + size / 2);
|
||||
if (!args.flyIcon.isNull()) {
|
||||
_flyIcon = std::move(args.flyIcon);
|
||||
_fly.start(flyCallback(), 0., 1., kFlyDuration);
|
||||
|
@ -210,8 +212,6 @@ void ReactionFlyAnimation::paintCenterFrame(
|
|||
QRect target,
|
||||
const QColor &colored,
|
||||
crl::time now) const {
|
||||
Expects(_center || _custom);
|
||||
|
||||
const auto size = QSize(
|
||||
int(base::SafeRound(target.width() * _centerSizeMultiplier)),
|
||||
int(base::SafeRound(target.height() * _centerSizeMultiplier)));
|
||||
|
@ -222,7 +222,7 @@ void ReactionFlyAnimation::paintCenterFrame(
|
|||
size.width(),
|
||||
size.height());
|
||||
p.drawImage(rect, _center->frame(st::windowFg->c));
|
||||
} else {
|
||||
} else if (_custom) {
|
||||
const auto scaled = (size.width() != _customSize);
|
||||
_custom->paint(p, {
|
||||
.textColor = colored,
|
||||
|
|
|
@ -28,6 +28,7 @@ struct ReactionFlyAnimationArgs {
|
|||
QImage flyIcon;
|
||||
QRect flyFrom;
|
||||
crl::time scaleOutDuration = 0;
|
||||
bool effectOnly = false;
|
||||
|
||||
[[nodiscard]] ReactionFlyAnimationArgs translated(QPoint point) const;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue