Display premium stickers in comments/pinned/scheduled.
This commit is contained in:
		
							parent
							
								
									8890f263af
								
							
						
					
					
						commit
						5adf95fc28
					
				
					 4 changed files with 24 additions and 11 deletions
				
			
		|  | @ -2940,9 +2940,6 @@ void HistoryInner::updateSize() { | ||||||
| 
 | 
 | ||||||
| 	if (_historyPaddingTop != newHistoryPaddingTop) { | 	if (_historyPaddingTop != newHistoryPaddingTop) { | ||||||
| 		_historyPaddingTop = newHistoryPaddingTop; | 		_historyPaddingTop = newHistoryPaddingTop; | ||||||
| 		_emojiInteractions->visibleAreaUpdated( |  | ||||||
| 			_visibleAreaTop - _historyPaddingTop, |  | ||||||
| 			_visibleAreaBottom - _historyPaddingTop); |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	int newHeight = _historyPaddingTop + itemsHeight + st::historyPaddingBottom; | 	int newHeight = _historyPaddingTop + itemsHeight + st::historyPaddingBottom; | ||||||
|  |  | ||||||
|  | @ -162,7 +162,7 @@ void EmojiInteractions::play( | ||||||
| 		QString filepath, | 		QString filepath, | ||||||
| 		bool incoming, | 		bool incoming, | ||||||
| 		bool premium) { | 		bool premium) { | ||||||
| 	const auto top = view->block()->y() + view->y(); | 	const auto top = _itemTop(view); | ||||||
| 	const auto bottom = top + view->height(); | 	const auto bottom = top + view->height(); | ||||||
| 	if (_visibleTop >= bottom | 	if (_visibleTop >= bottom | ||||||
| 		|| _visibleBottom <= top | 		|| _visibleBottom <= top | ||||||
|  | @ -278,14 +278,13 @@ QRect EmojiInteractions::computeRect( | ||||||
| 	const auto sticker = premium ? _premiumSize : _emojiSize; | 	const auto sticker = premium ? _premiumSize : _emojiSize; | ||||||
| 	const auto size = sizeFor(premium); | 	const auto size = sizeFor(premium); | ||||||
| 	const auto shift = size.width() / 40; | 	const auto shift = size.width() / 40; | ||||||
| 	const auto skip = (view->hasFromPhoto() ? st::msgPhotoSkip : 0) | 	const auto inner = view->innerGeometry(); | ||||||
| 		+ st::msgMargin.left(); |  | ||||||
| 	const auto rightAligned = view->hasOutLayout() | 	const auto rightAligned = view->hasOutLayout() | ||||||
| 		&& !view->delegate()->elementIsChatWide(); | 		&& !view->delegate()->elementIsChatWide(); | ||||||
| 	const auto left = rightAligned | 	const auto left = rightAligned | ||||||
| 		? (fullWidth - skip + shift - size.width()) | 		? (inner.x() + inner.width() + shift - size.width()) | ||||||
| 		: (skip - shift); | 		: (inner.x() - shift); | ||||||
| 	const auto viewTop = _itemTop(view) + view->marginTop(); | 	const auto viewTop = _itemTop(view) + inner.y(); | ||||||
| 	if (viewTop < 0) { | 	if (viewTop < 0) { | ||||||
| 		return QRect(); | 		return QRect(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL | ||||||
| #include "history/view/media/history_view_sticker.h" | #include "history/view/media/history_view_sticker.h" | ||||||
| #include "history/view/history_view_context_menu.h" | #include "history/view/history_view_context_menu.h" | ||||||
| #include "history/view/history_view_element.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_message.h" | ||||||
| #include "history/view/history_view_service_message.h" | #include "history/view/history_view_service_message.h" | ||||||
| #include "history/view/history_view_cursor_state.h" | #include "history/view/history_view_cursor_state.h" | ||||||
|  | @ -264,6 +265,9 @@ ListWidget::ListWidget( | ||||||
| : RpWidget(parent) | : RpWidget(parent) | ||||||
| , _delegate(delegate) | , _delegate(delegate) | ||||||
| , _controller(controller) | , _controller(controller) | ||||||
|  | , _emojiInteractions(std::make_unique<EmojiInteractions>( | ||||||
|  | 	&controller->session(), | ||||||
|  | 	[=](not_null<const Element*> view) { return itemTop(view); })) | ||||||
| , _context(_delegate->listContext()) | , _context(_delegate->listContext()) | ||||||
| , _itemAverageHeight(itemMinimalHeight()) | , _itemAverageHeight(itemMinimalHeight()) | ||||||
| , _pathGradient( | , _pathGradient( | ||||||
|  | @ -381,6 +385,11 @@ ListWidget::ListWidget( | ||||||
| 		_isChatWide = wide; | 		_isChatWide = wide; | ||||||
| 	}, lifetime()); | 	}, lifetime()); | ||||||
| 
 | 
 | ||||||
|  | 	_emojiInteractions->updateRequests( | ||||||
|  | 	) | rpl::start_with_next([=](QRect rect) { | ||||||
|  | 		update(rect); | ||||||
|  | 	}, lifetime()); | ||||||
|  | 
 | ||||||
| 	_selectScroll.scrolls( | 	_selectScroll.scrolls( | ||||||
| 	) | rpl::start_with_next([=](int d) { | 	) | rpl::start_with_next([=](int d) { | ||||||
| 		delegate->listScrollTo(_visibleTop + d); | 		delegate->listScrollTo(_visibleTop + d); | ||||||
|  | @ -804,6 +813,8 @@ void ListWidget::visibleTopBottomUpdated( | ||||||
| 	_controller->floatPlayerAreaUpdated(); | 	_controller->floatPlayerAreaUpdated(); | ||||||
| 	session().data().itemVisibilitiesUpdated(); | 	session().data().itemVisibilitiesUpdated(); | ||||||
| 	_applyUpdatedScrollState.call(); | 	_applyUpdatedScrollState.call(); | ||||||
|  | 
 | ||||||
|  | 	_emojiInteractions->visibleAreaUpdated(_visibleTop, _visibleBottom); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ListWidget::applyUpdatedScrollState() { | void ListWidget::applyUpdatedScrollState() { | ||||||
|  | @ -1520,11 +1531,13 @@ void ListWidget::elementStartInteraction(not_null<const Element*> view) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ListWidget::elementStartPremium( | void ListWidget::elementStartPremium( | ||||||
| 	not_null<const Element*> view, | 		not_null<const Element*> view, | ||||||
| 	Element *replacing) { | 		Element *replacing) { | ||||||
|  | 	_emojiInteractions->playPremiumEffect(view, replacing); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ListWidget::elementCancelPremium(not_null<const Element*> view) { | void ListWidget::elementCancelPremium(not_null<const Element*> view) { | ||||||
|  | 	_emojiInteractions->cancelPremiumEffect(view); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ListWidget::elementShowSpoilerAnimation() { | void ListWidget::elementShowSpoilerAnimation() { | ||||||
|  | @ -1917,6 +1930,7 @@ void ListWidget::paintEvent(QPaintEvent *e) { | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		_reactionsManager->paint(p, context); | 		_reactionsManager->paint(p, context); | ||||||
|  | 		_emojiInteractions->paint(p); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -45,6 +45,7 @@ namespace HistoryView { | ||||||
| 
 | 
 | ||||||
| struct TextState; | struct TextState; | ||||||
| struct StateRequest; | struct StateRequest; | ||||||
|  | class EmojiInteractions; | ||||||
| enum class CursorState : char; | enum class CursorState : char; | ||||||
| enum class PointState : char; | enum class PointState : char; | ||||||
| enum class Context : char; | enum class Context : char; | ||||||
|  | @ -546,6 +547,8 @@ private: | ||||||
| 
 | 
 | ||||||
| 	const not_null<ListDelegate*> _delegate; | 	const not_null<ListDelegate*> _delegate; | ||||||
| 	const not_null<Window::SessionController*> _controller; | 	const not_null<Window::SessionController*> _controller; | ||||||
|  | 	const std::unique_ptr<EmojiInteractions> _emojiInteractions; | ||||||
|  | 
 | ||||||
| 	Data::MessagePosition _aroundPosition; | 	Data::MessagePosition _aroundPosition; | ||||||
| 	Data::MessagePosition _shownAtPosition; | 	Data::MessagePosition _shownAtPosition; | ||||||
| 	Context _context; | 	Context _context; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 John Preston
						John Preston