Colorize status in premium promo and pack preview.
This commit is contained in:
		
							parent
							
								
									c13221a984
								
							
						
					
					
						commit
						e32031963b
					
				
					 4 changed files with 34 additions and 2 deletions
				
			
		| 
						 | 
					@ -305,6 +305,7 @@ private:
 | 
				
			||||||
	std::vector<Element> _elements;
 | 
						std::vector<Element> _elements;
 | 
				
			||||||
	std::unique_ptr<Lottie::MultiPlayer> _lottiePlayer;
 | 
						std::unique_ptr<Lottie::MultiPlayer> _lottiePlayer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						mutable Ui::Text::CustomEmojiColored _colored;
 | 
				
			||||||
	base::flat_map<
 | 
						base::flat_map<
 | 
				
			||||||
		not_null<DocumentData*>,
 | 
							not_null<DocumentData*>,
 | 
				
			||||||
		std::unique_ptr<Ui::Text::CustomEmoji>> _customEmoji;
 | 
							std::unique_ptr<Ui::Text::CustomEmoji>> _customEmoji;
 | 
				
			||||||
| 
						 | 
					@ -1268,8 +1269,10 @@ void StickerSetBox::Inner::paintSticker(
 | 
				
			||||||
		(_singleSize.height() - size.height()) / 2);
 | 
							(_singleSize.height() - size.height()) / 2);
 | 
				
			||||||
	auto lottieFrame = QImage();
 | 
						auto lottieFrame = QImage();
 | 
				
			||||||
	if (element.emoji) {
 | 
						if (element.emoji) {
 | 
				
			||||||
 | 
							_colored.color = st::profileVerifiedCheckBg->c;
 | 
				
			||||||
		element.emoji->paint(p, {
 | 
							element.emoji->paint(p, {
 | 
				
			||||||
			.preview = st::windowBgOver->c,
 | 
								.preview = st::windowBgOver->c,
 | 
				
			||||||
 | 
								.colored = &_colored,
 | 
				
			||||||
			.now = now,
 | 
								.now = now,
 | 
				
			||||||
			.position = ppos,
 | 
								.position = ppos,
 | 
				
			||||||
			.paused = paused,
 | 
								.paused = paused,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -782,6 +782,10 @@ Session &CustomEmojiManager::owner() const {
 | 
				
			||||||
	return *_owner;
 | 
						return *_owner;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint64 CustomEmojiManager::coloredSetId() const {
 | 
				
			||||||
 | 
						return _coloredSetId;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int FrameSizeFromTag(SizeTag tag) {
 | 
					int FrameSizeFromTag(SizeTag tag) {
 | 
				
			||||||
	const auto emoji = EmojiSizeFromTag(tag);
 | 
						const auto emoji = EmojiSizeFromTag(tag);
 | 
				
			||||||
	const auto factor = style::DevicePixelRatio();
 | 
						const auto factor = style::DevicePixelRatio();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,6 +77,8 @@ public:
 | 
				
			||||||
	[[nodiscard]] Main::Session &session() const;
 | 
						[[nodiscard]] Main::Session &session() const;
 | 
				
			||||||
	[[nodiscard]] Session &owner() const;
 | 
						[[nodiscard]] Session &owner() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						[[nodiscard]] uint64 coloredSetId() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	static constexpr auto kSizeCount = int(SizeTag::kCount);
 | 
						static constexpr auto kSizeCount = int(SizeTag::kCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -437,12 +437,16 @@ public:
 | 
				
			||||||
	void paint(QPainter &p);
 | 
						void paint(QPainter &p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	QPixmap paintedPixmap(const QSize &size) const;
 | 
						[[nodiscard]] QPixmap paintedPixmap(const QSize &size) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void resolveIsColored();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QRectF _rect;
 | 
						QRectF _rect;
 | 
				
			||||||
	std::shared_ptr<Data::DocumentMedia> _media;
 | 
						std::shared_ptr<Data::DocumentMedia> _media;
 | 
				
			||||||
	std::unique_ptr<HistoryView::StickerPlayer> _player;
 | 
						std::unique_ptr<HistoryView::StickerPlayer> _player;
 | 
				
			||||||
	bool _paused = false;
 | 
						bool _paused = false;
 | 
				
			||||||
 | 
						bool _isColored = false;
 | 
				
			||||||
 | 
						bool _isColoredResolved = false;
 | 
				
			||||||
	rpl::lifetime _lifetime;
 | 
						rpl::lifetime _lifetime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -508,12 +512,31 @@ QPixmap EmojiStatusTopBar::paintedPixmap(const QSize &size) const {
 | 
				
			||||||
	return QPixmap();
 | 
						return QPixmap();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void EmojiStatusTopBar::resolveIsColored() {
 | 
				
			||||||
 | 
						if (_isColoredResolved) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						const auto document = _media->owner();
 | 
				
			||||||
 | 
						const auto manager = &document->owner().customEmojiManager();
 | 
				
			||||||
 | 
						const auto coloredSetId = manager->coloredSetId();
 | 
				
			||||||
 | 
						if (!coloredSetId) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_isColoredResolved = true;
 | 
				
			||||||
 | 
						const auto sticker = document->sticker();
 | 
				
			||||||
 | 
						const auto setId = sticker ? sticker->set.id : 0;
 | 
				
			||||||
 | 
						_isColored = sticker && (sticker->set.id == coloredSetId);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void EmojiStatusTopBar::paint(QPainter &p) {
 | 
					void EmojiStatusTopBar::paint(QPainter &p) {
 | 
				
			||||||
	if (_player) {
 | 
						if (_player) {
 | 
				
			||||||
		if (_player->ready()) {
 | 
							if (_player->ready()) {
 | 
				
			||||||
 | 
								resolveIsColored();
 | 
				
			||||||
			const auto frame = _player->frame(
 | 
								const auto frame = _player->frame(
 | 
				
			||||||
				_rect.size().toSize(),
 | 
									_rect.size().toSize(),
 | 
				
			||||||
				Qt::transparent,
 | 
									(_isColored
 | 
				
			||||||
 | 
										? st::profileVerifiedCheckBg->c
 | 
				
			||||||
 | 
										: QColor(0, 0, 0, 0)),
 | 
				
			||||||
				false,
 | 
									false,
 | 
				
			||||||
				crl::now(),
 | 
									crl::now(),
 | 
				
			||||||
				_paused);
 | 
									_paused);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue