Added simple animation of static stickers sending to replies section.

This commit is contained in:
23rd 2022-02-10 23:08:46 +03:00 committed by John Preston
parent e72be4abfc
commit 40875ac8ff
4 changed files with 50 additions and 10 deletions

View file

@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h" #include "ui/toasts/common_toasts.h"
#include "ui/inactive_press.h" #include "ui/inactive_press.h"
#include "ui/effects/message_sending_animation_controller.h"
#include "ui/effects/path_shift_gradient.h" #include "ui/effects/path_shift_gradient.h"
#include "ui/chat/chat_theme.h" #include "ui/chat/chat_theme.h"
#include "ui/chat/chat_style.h" #include "ui/chat/chat_style.h"
@ -1555,6 +1556,7 @@ void ListWidget::resizeToWidth(int newWidth, int minHeight) {
void ListWidget::startItemRevealAnimations() { void ListWidget::startItemRevealAnimations() {
for (const auto &view : base::take(_itemRevealPending)) { for (const auto &view : base::take(_itemRevealPending)) {
if (const auto height = view->height()) { if (const auto height = view->height()) {
startMessageSendingAnimation(view->data());
if (!_itemRevealAnimations.contains(view)) { if (!_itemRevealAnimations.contains(view)) {
auto &animation = _itemRevealAnimations[view]; auto &animation = _itemRevealAnimations[view];
animation.startHeight = height; animation.startHeight = height;
@ -1573,6 +1575,30 @@ void ListWidget::startItemRevealAnimations() {
} }
} }
void ListWidget::startMessageSendingAnimation(
not_null<HistoryItem*> item) {
auto &sendingAnimation = controller()->sendingAnimation();
if (!sendingAnimation.hasLocalMessage(item->fullId().msg)) {
return;
}
auto globalEndGeometry = rpl::merge(
session().data().newItemAdded() | rpl::to_empty,
geometryValue() | rpl::to_empty
) | rpl::map([=] {
const auto view = viewForItem(item);
const auto additional = !_visibleTop ? view->height() : 0;
return mapToGlobal(
view->innerGeometry().translated(0, itemTop(view) - additional));
});
sendingAnimation.startAnimation({
.globalEndGeometry = std::move(globalEndGeometry),
.view = [=] { return viewForItem(item); },
.theme = _delegate->listChatTheme(),
});
}
void ListWidget::revealItemsCallback() { void ListWidget::revealItemsCallback() {
auto revealHeight = 0; auto revealHeight = 0;
for (auto i = begin(_itemRevealAnimations) for (auto i = begin(_itemRevealAnimations)
@ -1744,13 +1770,16 @@ void ListWidget::paintEvent(QPaintEvent *e) {
.clip = clip, .clip = clip,
}).translated(0, -top); }).translated(0, -top);
p.translate(0, top); p.translate(0, top);
const auto &sendingAnimation = _controller->sendingAnimation();
for (auto i = from; i != to; ++i) { for (auto i = from; i != to; ++i) {
const auto view = *i; const auto view = *i;
context.reactionInfo if (!sendingAnimation.hasAnimatedMessage(view->data())) {
= _reactionsManager->currentReactionPaintInfo(); context.reactionInfo
context.outbg = view->hasOutLayout(); = _reactionsManager->currentReactionPaintInfo();
context.selection = itemRenderSelection(view); context.outbg = view->hasOutLayout();
view->draw(p, context); context.selection = itemRenderSelection(view);
view->draw(p, context);
}
_reactionsManager->recordCurrentReactionEffect( _reactionsManager->recordCurrentReactionEffect(
view->data()->fullId(), view->data()->fullId(),
QPoint(0, top)); QPoint(0, top));

View file

@ -504,6 +504,8 @@ private:
void startItemRevealAnimations(); void startItemRevealAnimations();
void revealItemsCallback(); void revealItemsCallback();
void startMessageSendingAnimation(not_null<HistoryItem*> item);
void updateHighlightedMessage(); void updateHighlightedMessage();
void clearHighlightedMessage(); void clearHighlightedMessage();

View file

@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/chat/attach/attach_prepare.h" #include "ui/chat/attach/attach_prepare.h"
#include "ui/chat/attach/attach_send_files_way.h" #include "ui/chat/attach/attach_send_files_way.h"
#include "ui/effects/message_sending_animation_controller.h"
#include "ui/special_buttons.h" #include "ui/special_buttons.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "ui/toasts/common_toasts.h" #include "ui/toasts/common_toasts.h"
@ -546,7 +547,12 @@ void RepliesWidget::setupComposeControls() {
_composeControls->fileChosen( _composeControls->fileChosen(
) | rpl::start_with_next([=](Selector::FileChosen chosen) { ) | rpl::start_with_next([=](Selector::FileChosen chosen) {
sendExistingDocument(chosen.document, chosen.options); controller()->sendingAnimation().appendSending(
chosen.messageSendingFrom);
sendExistingDocument(
chosen.document,
chosen.options,
chosen.messageSendingFrom.localId);
}, lifetime()); }, lifetime());
_composeControls->photoChosen( _composeControls->photoChosen(
@ -1060,7 +1066,7 @@ void RepliesWidget::edit(
void RepliesWidget::sendExistingDocument( void RepliesWidget::sendExistingDocument(
not_null<DocumentData*> document) { not_null<DocumentData*> document) {
sendExistingDocument(document, {}); sendExistingDocument(document, {}, std::nullopt);
// #TODO replies schedule // #TODO replies schedule
//const auto callback = [=](Api::SendOptions options) { //const auto callback = [=](Api::SendOptions options) {
// sendExistingDocument(document, options); // sendExistingDocument(document, options);
@ -1072,7 +1078,8 @@ void RepliesWidget::sendExistingDocument(
bool RepliesWidget::sendExistingDocument( bool RepliesWidget::sendExistingDocument(
not_null<DocumentData*> document, not_null<DocumentData*> document,
Api::SendOptions options) { Api::SendOptions options,
std::optional<MsgId> localId) {
const auto error = Data::RestrictionError( const auto error = Data::RestrictionError(
_history->peer, _history->peer,
ChatRestriction::SendStickers); ChatRestriction::SendStickers);
@ -1087,7 +1094,8 @@ bool RepliesWidget::sendExistingDocument(
Api::SendExistingDocument( Api::SendExistingDocument(
Api::MessageToSend(prepareSendAction(options)), Api::MessageToSend(prepareSendAction(options)),
document); document,
localId);
_composeControls->cancelReplyMessage(); _composeControls->cancelReplyMessage();
finishSending(); finishSending();

View file

@ -245,7 +245,8 @@ private:
void sendExistingDocument(not_null<DocumentData*> document); void sendExistingDocument(not_null<DocumentData*> document);
bool sendExistingDocument( bool sendExistingDocument(
not_null<DocumentData*> document, not_null<DocumentData*> document,
Api::SendOptions options); Api::SendOptions options,
std::optional<MsgId> localId);
void sendExistingPhoto(not_null<PhotoData*> photo); void sendExistingPhoto(not_null<PhotoData*> photo);
bool sendExistingPhoto( bool sendExistingPhoto(
not_null<PhotoData*> photo, not_null<PhotoData*> photo,