Limit emoji size to half of sticker size.
This commit is contained in:
		
							parent
							
								
									139b9723d7
								
							
						
					
					
						commit
						b6fafdd8f7
					
				
					 6 changed files with 18 additions and 33 deletions
				
			
		| 
						 | 
					@ -46,9 +46,7 @@ Dice::Dice(not_null<Element*> parent, not_null<Data::MediaDice*> dice)
 | 
				
			||||||
Dice::~Dice() = default;
 | 
					Dice::~Dice() = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QSize Dice::size() {
 | 
					QSize Dice::size() {
 | 
				
			||||||
	return _start
 | 
						return _start ? _start->size() : Sticker::EmojiSize();
 | 
				
			||||||
		? _start->size()
 | 
					 | 
				
			||||||
		: Sticker::GetAnimatedEmojiSize(&_parent->history()->session());
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ClickHandlerPtr Dice::link() {
 | 
					ClickHandlerPtr Dice::link() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
#include "history/view/media/history_view_media_unwrapped.h"
 | 
					#include "history/view/media/history_view_media_unwrapped.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "history/view/media/history_view_media_common.h"
 | 
					#include "history/view/media/history_view_media_common.h"
 | 
				
			||||||
 | 
					#include "history/view/media/history_view_sticker.h"
 | 
				
			||||||
#include "history/view/history_view_element.h"
 | 
					#include "history/view/history_view_element.h"
 | 
				
			||||||
#include "history/view/history_view_cursor_state.h"
 | 
					#include "history/view/history_view_cursor_state.h"
 | 
				
			||||||
#include "history/history_item.h"
 | 
					#include "history/history_item.h"
 | 
				
			||||||
| 
						 | 
					@ -42,7 +43,7 @@ QSize UnwrappedMedia::countOptimalSize() {
 | 
				
			||||||
	_content->refreshLink();
 | 
						_content->refreshLink();
 | 
				
			||||||
	_contentSize = NonEmptySize(DownscaledSize(
 | 
						_contentSize = NonEmptySize(DownscaledSize(
 | 
				
			||||||
		_content->size(),
 | 
							_content->size(),
 | 
				
			||||||
		{ st::maxStickerSize, st::maxStickerSize }));
 | 
							Sticker::Size()));
 | 
				
			||||||
	auto maxWidth = _contentSize.width();
 | 
						auto maxWidth = _contentSize.width();
 | 
				
			||||||
	const auto minimal = st::largeEmojiSize + 2 * st::largeEmojiOutline;
 | 
						const auto minimal = st::largeEmojiSize + 2 * st::largeEmojiOutline;
 | 
				
			||||||
	auto minHeight = std::max(_contentSize.height(), minimal);
 | 
						auto minHeight = std::max(_contentSize.height(), minimal);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -139,9 +139,7 @@ bool SlotMachine::isEndResolved() const {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QSize SlotMachine::size() {
 | 
					QSize SlotMachine::size() {
 | 
				
			||||||
	return _pull
 | 
						return _pull ? _pull->size() : Sticker::EmojiSize();
 | 
				
			||||||
		? _pull->size()
 | 
					 | 
				
			||||||
		: Sticker::GetAnimatedEmojiSize(&_parent->history()->session());
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ClickHandlerPtr SlotMachine::link() {
 | 
					ClickHandlerPtr SlotMachine::link() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,11 +37,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
namespace HistoryView {
 | 
					namespace HistoryView {
 | 
				
			||||||
namespace {
 | 
					namespace {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[nodiscard]] double GetEmojiStickerZoom(not_null<Main::Session*> session) {
 | 
					constexpr auto kMaxSizeFixed = 512;
 | 
				
			||||||
	return session->account().appConfig().get<double>(
 | 
					constexpr auto kMaxEmojiSizeFixed = 256;
 | 
				
			||||||
		"emojies_animated_zoom",
 | 
					 | 
				
			||||||
		0.625);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[nodiscard]] QImage CacheDiceImage(
 | 
					[[nodiscard]] QImage CacheDiceImage(
 | 
				
			||||||
		const QString &emoji,
 | 
							const QString &emoji,
 | 
				
			||||||
| 
						 | 
					@ -97,16 +94,13 @@ bool Sticker::isEmojiSticker() const {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Sticker::initSize() {
 | 
					void Sticker::initSize() {
 | 
				
			||||||
	_size = _data->dimensions;
 | 
					 | 
				
			||||||
	if (isEmojiSticker() || _diceIndex >= 0) {
 | 
						if (isEmojiSticker() || _diceIndex >= 0) {
 | 
				
			||||||
		_size = GetAnimatedEmojiSize(&_data->session(), _size);
 | 
							_size = Sticker::EmojiSize();
 | 
				
			||||||
		if (_diceIndex > 0) {
 | 
							if (_diceIndex > 0) {
 | 
				
			||||||
			[[maybe_unused]] bool result = readyToDrawLottie();
 | 
								[[maybe_unused]] bool result = readyToDrawLottie();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		_size = DownscaledSize(
 | 
							_size = DownscaledSize(_data->dimensions, Sticker::Size());
 | 
				
			||||||
			_size,
 | 
					 | 
				
			||||||
			{ st::maxStickerSize, st::maxStickerSize });
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,18 +129,14 @@ bool Sticker::readyToDrawLottie() {
 | 
				
			||||||
	return (_lottie && _lottie->ready());
 | 
						return (_lottie && _lottie->ready());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QSize Sticker::GetAnimatedEmojiSize(not_null<Main::Session*> session) {
 | 
					QSize Sticker::Size() {
 | 
				
			||||||
	return GetAnimatedEmojiSize(session, { 512, 512 });
 | 
						const auto side = std::min(st::maxStickerSize, kMaxSizeFixed);
 | 
				
			||||||
 | 
						return { side, side };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QSize Sticker::GetAnimatedEmojiSize(
 | 
					QSize Sticker::EmojiSize() {
 | 
				
			||||||
		not_null<Main::Session*> session,
 | 
						const auto side = std::min(st::maxAnimatedEmojiSize, kMaxEmojiSizeFixed);
 | 
				
			||||||
		QSize documentSize) {
 | 
						return { side, side };
 | 
				
			||||||
	const auto zoom = GetEmojiStickerZoom(session);
 | 
					 | 
				
			||||||
	const auto convert = [&](int size) {
 | 
					 | 
				
			||||||
		return int(size * st::maxStickerSize * zoom / kStickerSideSize);
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
	return { convert(documentSize.width()), convert(documentSize.height()) };
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Sticker::draw(
 | 
					void Sticker::draw(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,11 +78,8 @@ public:
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	[[nodiscard]] bool readyToDrawLottie();
 | 
						[[nodiscard]] bool readyToDrawLottie();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] static QSize GetAnimatedEmojiSize(
 | 
						[[nodiscard]] static QSize Size();
 | 
				
			||||||
		not_null<Main::Session*> session);
 | 
						[[nodiscard]] static QSize EmojiSize();
 | 
				
			||||||
	[[nodiscard]] static QSize GetAnimatedEmojiSize(
 | 
					 | 
				
			||||||
		not_null<Main::Session*> session,
 | 
					 | 
				
			||||||
		QSize documentSize);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	[[nodiscard]] bool isEmojiSticker() const;
 | 
						[[nodiscard]] bool isEmojiSticker() const;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,7 +37,8 @@ defaultMessageBar: MessageBar {
 | 
				
			||||||
minPhotoSize: 100px;
 | 
					minPhotoSize: 100px;
 | 
				
			||||||
minVideoSize: 160px;
 | 
					minVideoSize: 160px;
 | 
				
			||||||
maxMediaSize: 430px;
 | 
					maxMediaSize: 430px;
 | 
				
			||||||
maxStickerSize: 228px;
 | 
					maxStickerSize: 224px;
 | 
				
			||||||
 | 
					maxAnimatedEmojiSize: 112px;
 | 
				
			||||||
maxGifSize: 320px;
 | 
					maxGifSize: 320px;
 | 
				
			||||||
maxVideoMessageSize: 240px;
 | 
					maxVideoMessageSize: 240px;
 | 
				
			||||||
maxSignatureSize: 144px;
 | 
					maxSignatureSize: 144px;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue