Display premium stickers in comments/pinned/scheduled.

This commit is contained in:
John Preston 2022-05-02 13:58:12 +04:00
parent 8890f263af
commit 5adf95fc28
4 changed files with 24 additions and 11 deletions

View File

@ -2940,9 +2940,6 @@ void HistoryInner::updateSize() {
if (_historyPaddingTop != newHistoryPaddingTop) {
_historyPaddingTop = newHistoryPaddingTop;
_emojiInteractions->visibleAreaUpdated(
_visibleAreaTop - _historyPaddingTop,
_visibleAreaBottom - _historyPaddingTop);
}
int newHeight = _historyPaddingTop + itemsHeight + st::historyPaddingBottom;

View File

@ -162,7 +162,7 @@ void EmojiInteractions::play(
QString filepath,
bool incoming,
bool premium) {
const auto top = view->block()->y() + view->y();
const auto top = _itemTop(view);
const auto bottom = top + view->height();
if (_visibleTop >= bottom
|| _visibleBottom <= top
@ -278,14 +278,13 @@ QRect EmojiInteractions::computeRect(
const auto sticker = premium ? _premiumSize : _emojiSize;
const auto size = sizeFor(premium);
const auto shift = size.width() / 40;
const auto skip = (view->hasFromPhoto() ? st::msgPhotoSkip : 0)
+ st::msgMargin.left();
const auto inner = view->innerGeometry();
const auto rightAligned = view->hasOutLayout()
&& !view->delegate()->elementIsChatWide();
const auto left = rightAligned
? (fullWidth - skip + shift - size.width())
: (skip - shift);
const auto viewTop = _itemTop(view) + view->marginTop();
? (inner.x() + inner.width() + shift - size.width())
: (inner.x() - shift);
const auto viewTop = _itemTop(view) + inner.y();
if (viewTop < 0) {
return QRect();
}

View File

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/media/history_view_sticker.h"
#include "history/view/history_view_context_menu.h"
#include "history/view/history_view_element.h"
#include "history/view/history_view_emoji_interactions.h"
#include "history/view/history_view_message.h"
#include "history/view/history_view_service_message.h"
#include "history/view/history_view_cursor_state.h"
@ -264,6 +265,9 @@ ListWidget::ListWidget(
: RpWidget(parent)
, _delegate(delegate)
, _controller(controller)
, _emojiInteractions(std::make_unique<EmojiInteractions>(
&controller->session(),
[=](not_null<const Element*> view) { return itemTop(view); }))
, _context(_delegate->listContext())
, _itemAverageHeight(itemMinimalHeight())
, _pathGradient(
@ -381,6 +385,11 @@ ListWidget::ListWidget(
_isChatWide = wide;
}, lifetime());
_emojiInteractions->updateRequests(
) | rpl::start_with_next([=](QRect rect) {
update(rect);
}, lifetime());
_selectScroll.scrolls(
) | rpl::start_with_next([=](int d) {
delegate->listScrollTo(_visibleTop + d);
@ -804,6 +813,8 @@ void ListWidget::visibleTopBottomUpdated(
_controller->floatPlayerAreaUpdated();
session().data().itemVisibilitiesUpdated();
_applyUpdatedScrollState.call();
_emojiInteractions->visibleAreaUpdated(_visibleTop, _visibleBottom);
}
void ListWidget::applyUpdatedScrollState() {
@ -1520,11 +1531,13 @@ void ListWidget::elementStartInteraction(not_null<const Element*> view) {
}
void ListWidget::elementStartPremium(
not_null<const Element*> view,
Element *replacing) {
not_null<const Element*> view,
Element *replacing) {
_emojiInteractions->playPremiumEffect(view, replacing);
}
void ListWidget::elementCancelPremium(not_null<const Element*> view) {
_emojiInteractions->cancelPremiumEffect(view);
}
void ListWidget::elementShowSpoilerAnimation() {
@ -1917,6 +1930,7 @@ void ListWidget::paintEvent(QPaintEvent *e) {
});
_reactionsManager->paint(p, context);
_emojiInteractions->paint(p);
}
}

View File

@ -45,6 +45,7 @@ namespace HistoryView {
struct TextState;
struct StateRequest;
class EmojiInteractions;
enum class CursorState : char;
enum class PointState : char;
enum class Context : char;
@ -546,6 +547,8 @@ private:
const not_null<ListDelegate*> _delegate;
const not_null<Window::SessionController*> _controller;
const std::unique_ptr<EmojiInteractions> _emojiInteractions;
Data::MessagePosition _aroundPosition;
Data::MessagePosition _shownAtPosition;
Context _context;