mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added simple animation of static stickers sending.
This commit is contained in:
parent
b46adec413
commit
d633860e1d
7 changed files with 96 additions and 12 deletions
|
@ -2468,15 +2468,21 @@ void StickersListWidget::fillContextMenu(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (auto sticker = std::get_if<OverSticker>(&selected)) {
|
if (auto sticker = std::get_if<OverSticker>(&selected)) {
|
||||||
Assert(sticker->section >= 0 && sticker->section < sets.size());
|
const auto section = sticker->section;
|
||||||
auto &set = sets[sticker->section];
|
const auto index = sticker->index;
|
||||||
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
|
Assert(section >= 0 && section < sets.size());
|
||||||
|
auto &set = sets[section];
|
||||||
|
Assert(index >= 0 && index < set.stickers.size());
|
||||||
|
|
||||||
const auto document = set.stickers[sticker->index].document;
|
const auto document = set.stickers[sticker->index].document;
|
||||||
const auto send = [=](Api::SendOptions options) {
|
const auto send = [=](Api::SendOptions options) {
|
||||||
_chosen.fire_copy({
|
_chosen.fire({
|
||||||
.document = document,
|
.document = document,
|
||||||
.options = options });
|
.options = options,
|
||||||
|
.messageSendingFrom = options.scheduled
|
||||||
|
? Ui::MessageSendingAnimationFrom()
|
||||||
|
: messageSentAnimationInfo(section, index, document),
|
||||||
|
});
|
||||||
};
|
};
|
||||||
SendMenu::FillSendMenu(
|
SendMenu::FillSendMenu(
|
||||||
menu,
|
menu,
|
||||||
|
@ -2512,6 +2518,23 @@ void StickersListWidget::fillContextMenu(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ui::MessageSendingAnimationFrom StickersListWidget::messageSentAnimationInfo(
|
||||||
|
int section,
|
||||||
|
int index,
|
||||||
|
not_null<DocumentData*> document) {
|
||||||
|
const auto rect = stickerRect(section, index);
|
||||||
|
const auto size = ComputeStickerSize(document, boundingBoxSize());
|
||||||
|
const auto innerPos = QPoint(
|
||||||
|
(rect.width() - size.width()) / 2,
|
||||||
|
(rect.height() - size.height()) / 2);
|
||||||
|
|
||||||
|
return {
|
||||||
|
.localId = session().data().nextLocalMessageId(),
|
||||||
|
.globalStartGeometry = mapToGlobal(
|
||||||
|
QRect(rect.topLeft() + innerPos, size)),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
_previewTimer.cancel();
|
_previewTimer.cancel();
|
||||||
|
|
||||||
|
@ -2550,7 +2573,13 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
if (e->modifiers() & Qt::ControlModifier) {
|
if (e->modifiers() & Qt::ControlModifier) {
|
||||||
showStickerSetBox(document);
|
showStickerSetBox(document);
|
||||||
} else {
|
} else {
|
||||||
_chosen.fire_copy({ .document = document });
|
_chosen.fire({
|
||||||
|
.document = document,
|
||||||
|
.messageSendingFrom = messageSentAnimationInfo(
|
||||||
|
sticker->section,
|
||||||
|
sticker->index,
|
||||||
|
document),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else if (auto set = std::get_if<OverSet>(&pressed)) {
|
} else if (auto set = std::get_if<OverSet>(&pressed)) {
|
||||||
Assert(set->section >= 0 && set->section < sets.size());
|
Assert(set->section >= 0 && set->section < sets.size());
|
||||||
|
|
|
@ -330,6 +330,11 @@ private:
|
||||||
|
|
||||||
void showPreview();
|
void showPreview();
|
||||||
|
|
||||||
|
Ui::MessageSendingAnimationFrom messageSentAnimationInfo(
|
||||||
|
int section,
|
||||||
|
int index,
|
||||||
|
not_null<DocumentData*> document);
|
||||||
|
|
||||||
MTP::Sender _api;
|
MTP::Sender _api;
|
||||||
ChannelData *_megagroupSet = nullptr;
|
ChannelData *_megagroupSet = nullptr;
|
||||||
uint64 _megagroupSetIdRequested = 0;
|
uint64 _megagroupSetIdRequested = 0;
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_common.h"
|
#include "api/api_common.h"
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
|
#include "ui/effects/message_sending_animation_common.h"
|
||||||
#include "ui/effects/panel_animation.h"
|
#include "ui/effects/panel_animation.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
#include "base/object_ptr.h"
|
#include "base/object_ptr.h"
|
||||||
|
@ -56,6 +57,7 @@ public:
|
||||||
struct FileChosen {
|
struct FileChosen {
|
||||||
not_null<DocumentData*> document;
|
not_null<DocumentData*> document;
|
||||||
Api::SendOptions options;
|
Api::SendOptions options;
|
||||||
|
Ui::MessageSendingAnimationFrom messageSendingFrom;
|
||||||
};
|
};
|
||||||
struct PhotoChosen {
|
struct PhotoChosen {
|
||||||
not_null<PhotoData*> photo;
|
not_null<PhotoData*> photo;
|
||||||
|
|
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/toasts/common_toasts.h"
|
#include "ui/toasts/common_toasts.h"
|
||||||
#include "ui/effects/path_shift_gradient.h"
|
#include "ui/effects/path_shift_gradient.h"
|
||||||
|
#include "ui/effects/message_sending_animation_controller.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/boxes/report_box.h"
|
#include "ui/boxes/report_box.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
|
@ -1017,9 +1018,12 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
|
||||||
QRect(0, hdrawtop, width(), clip.top() + clip.height()));
|
QRect(0, hdrawtop, width(), clip.top() + clip.height()));
|
||||||
context.translate(0, -top);
|
context.translate(0, -top);
|
||||||
p.translate(0, top);
|
p.translate(0, top);
|
||||||
|
const auto &sendingAnimation = _controller->sendingAnimation();
|
||||||
while (top < drawToY) {
|
while (top < drawToY) {
|
||||||
const auto height = view->height();
|
const auto height = view->height();
|
||||||
if (context.clip.y() < height && hdrawtop < top + height) {
|
if ((context.clip.y() < height)
|
||||||
|
&& (hdrawtop < top + height)
|
||||||
|
&& !sendingAnimation.hasAnimatedMessage(view->data())) {
|
||||||
context.reactionInfo
|
context.reactionInfo
|
||||||
= _reactionsManager->currentReactionPaintInfo();
|
= _reactionsManager->currentReactionPaintInfo();
|
||||||
context.outbg = view->hasOutLayout();
|
context.outbg = view->hasOutLayout();
|
||||||
|
|
|
@ -34,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
|
#include "ui/effects/message_sending_animation_controller.h"
|
||||||
#include "ui/text/text_utilities.h" // Ui::Text::ToUpper
|
#include "ui/text/text_utilities.h" // Ui::Text::ToUpper
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/chat/forward_options_box.h"
|
#include "ui/chat/forward_options_box.h"
|
||||||
|
@ -996,7 +997,12 @@ void HistoryWidget::initTabbedSelector() {
|
||||||
|
|
||||||
selector->fileChosen(
|
selector->fileChosen(
|
||||||
) | filter | rpl::start_with_next([=](Selector::FileChosen data) {
|
) | filter | rpl::start_with_next([=](Selector::FileChosen data) {
|
||||||
sendExistingDocument(data.document, data.options);
|
controller()->sendingAnimation().appendSending(
|
||||||
|
data.messageSendingFrom);
|
||||||
|
sendExistingDocument(
|
||||||
|
data.document,
|
||||||
|
data.options,
|
||||||
|
data.messageSendingFrom.localId);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
selector->photoChosen(
|
selector->photoChosen(
|
||||||
|
@ -5354,6 +5360,7 @@ void HistoryWidget::startItemRevealAnimations() {
|
||||||
if (const auto view = item->mainView()) {
|
if (const auto view = item->mainView()) {
|
||||||
if (const auto top = _list->itemTop(view); top >= 0) {
|
if (const auto top = _list->itemTop(view); top >= 0) {
|
||||||
if (const auto height = view->height()) {
|
if (const auto height = view->height()) {
|
||||||
|
startMessageSendingAnimation(item);
|
||||||
if (!_itemRevealAnimations.contains(item)) {
|
if (!_itemRevealAnimations.contains(item)) {
|
||||||
auto &animation = _itemRevealAnimations[item];
|
auto &animation = _itemRevealAnimations[item];
|
||||||
animation.startHeight = height;
|
animation.startHeight = height;
|
||||||
|
@ -5374,6 +5381,38 @@ void HistoryWidget::startItemRevealAnimations() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryWidget::startMessageSendingAnimation(
|
||||||
|
not_null<HistoryItem*> item) {
|
||||||
|
auto &sendingAnimation = controller()->sendingAnimation();
|
||||||
|
if (!sendingAnimation.hasLocalMessage(item->fullId().msg)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Assert(item->mainView() != nullptr);
|
||||||
|
Assert(item->mainView()->media() != nullptr);
|
||||||
|
|
||||||
|
auto globalEndGeometry = rpl::merge(
|
||||||
|
_scroll->innerResizes() | rpl::to_empty,
|
||||||
|
session().data().newItemAdded() | rpl::to_empty,
|
||||||
|
geometryValue() | rpl::to_empty,
|
||||||
|
_scroll->geometryValue() | rpl::to_empty,
|
||||||
|
_list->geometryValue() | rpl::to_empty
|
||||||
|
) | rpl::map([=] {
|
||||||
|
const auto view = item->mainView();
|
||||||
|
const auto additional = (_list->height() == _scroll->height())
|
||||||
|
? view->height()
|
||||||
|
: 0;
|
||||||
|
return _list->mapToGlobal(view->innerGeometry().translated(
|
||||||
|
0,
|
||||||
|
_list->itemTop(view) - additional));
|
||||||
|
});
|
||||||
|
|
||||||
|
sendingAnimation.startAnimation({
|
||||||
|
.globalEndGeometry = std::move(globalEndGeometry),
|
||||||
|
.item = item,
|
||||||
|
.theme = _list->theme(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryWidget::updateListSize() {
|
void HistoryWidget::updateListSize() {
|
||||||
Expects(_list != nullptr);
|
Expects(_list != nullptr);
|
||||||
|
|
||||||
|
@ -6376,7 +6415,8 @@ void HistoryWidget::requestMessageData(MsgId msgId) {
|
||||||
|
|
||||||
bool HistoryWidget::sendExistingDocument(
|
bool HistoryWidget::sendExistingDocument(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
Api::SendOptions options) {
|
Api::SendOptions options,
|
||||||
|
std::optional<MsgId> localId) {
|
||||||
const auto error = _peer
|
const auto error = _peer
|
||||||
? Data::RestrictionError(_peer, ChatRestriction::SendStickers)
|
? Data::RestrictionError(_peer, ChatRestriction::SendStickers)
|
||||||
: std::nullopt;
|
: std::nullopt;
|
||||||
|
@ -6393,7 +6433,8 @@ bool HistoryWidget::sendExistingDocument(
|
||||||
|
|
||||||
Api::SendExistingDocument(
|
Api::SendExistingDocument(
|
||||||
Api::MessageToSend(prepareSendAction(options)),
|
Api::MessageToSend(prepareSendAction(options)),
|
||||||
document);
|
document,
|
||||||
|
localId);
|
||||||
|
|
||||||
if (_fieldAutocomplete->stickersShown()) {
|
if (_fieldAutocomplete->stickersShown()) {
|
||||||
clearFieldText();
|
clearFieldText();
|
||||||
|
|
|
@ -264,7 +264,8 @@ public:
|
||||||
[[nodiscard]] SendMenu::Type sendMenuType() const;
|
[[nodiscard]] SendMenu::Type sendMenuType() const;
|
||||||
bool sendExistingDocument(
|
bool sendExistingDocument(
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
Api::SendOptions options);
|
Api::SendOptions options,
|
||||||
|
std::optional<MsgId> localId = std::nullopt);
|
||||||
bool sendExistingPhoto(
|
bool sendExistingPhoto(
|
||||||
not_null<PhotoData*> photo,
|
not_null<PhotoData*> photo,
|
||||||
Api::SendOptions options);
|
Api::SendOptions options);
|
||||||
|
@ -553,6 +554,8 @@ private:
|
||||||
void startItemRevealAnimations();
|
void startItemRevealAnimations();
|
||||||
void revealItemsCallback();
|
void revealItemsCallback();
|
||||||
|
|
||||||
|
void startMessageSendingAnimation(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
// Does any of the shown histories has this flag set.
|
// Does any of the shown histories has this flag set.
|
||||||
bool hasPendingResizedItems() const;
|
bool hasPendingResizedItems() const;
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ void Content::updateCache() {
|
||||||
});
|
});
|
||||||
using Context = Ui::ChatPaintContext;
|
using Context = Ui::ChatPaintContext;
|
||||||
context.skipDrawingParts = Context::SkipDrawingParts::Surrounding;
|
context.skipDrawingParts = Context::SkipDrawingParts::Surrounding;
|
||||||
context.outbg = true;
|
context.outbg = _item->mainView()->hasOutLayout();
|
||||||
p.translate(-innerContentRect.left(), -innerContentRect.top());
|
p.translate(-innerContentRect.left(), -innerContentRect.top());
|
||||||
_media->draw(p, context);
|
_media->draw(p, context);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue