Limit emoji size to half of sticker size.

This commit is contained in:
John Preston 2021-09-15 17:48:48 +03:00
parent 139b9723d7
commit b6fafdd8f7
6 changed files with 18 additions and 33 deletions

View File

@ -46,9 +46,7 @@ Dice::Dice(not_null<Element*> parent, not_null<Data::MediaDice*> dice)
Dice::~Dice() = default;
QSize Dice::size() {
return _start
? _start->size()
: Sticker::GetAnimatedEmojiSize(&_parent->history()->session());
return _start ? _start->size() : Sticker::EmojiSize();
}
ClickHandlerPtr Dice::link() {

View File

@ -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_common.h"
#include "history/view/media/history_view_sticker.h"
#include "history/view/history_view_element.h"
#include "history/view/history_view_cursor_state.h"
#include "history/history_item.h"
@ -42,7 +43,7 @@ QSize UnwrappedMedia::countOptimalSize() {
_content->refreshLink();
_contentSize = NonEmptySize(DownscaledSize(
_content->size(),
{ st::maxStickerSize, st::maxStickerSize }));
Sticker::Size()));
auto maxWidth = _contentSize.width();
const auto minimal = st::largeEmojiSize + 2 * st::largeEmojiOutline;
auto minHeight = std::max(_contentSize.height(), minimal);

View File

@ -139,9 +139,7 @@ bool SlotMachine::isEndResolved() const {
}
QSize SlotMachine::size() {
return _pull
? _pull->size()
: Sticker::GetAnimatedEmojiSize(&_parent->history()->session());
return _pull ? _pull->size() : Sticker::EmojiSize();
}
ClickHandlerPtr SlotMachine::link() {

View File

@ -37,11 +37,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace HistoryView {
namespace {
[[nodiscard]] double GetEmojiStickerZoom(not_null<Main::Session*> session) {
return session->account().appConfig().get<double>(
"emojies_animated_zoom",
0.625);
}
constexpr auto kMaxSizeFixed = 512;
constexpr auto kMaxEmojiSizeFixed = 256;
[[nodiscard]] QImage CacheDiceImage(
const QString &emoji,
@ -97,16 +94,13 @@ bool Sticker::isEmojiSticker() const {
}
void Sticker::initSize() {
_size = _data->dimensions;
if (isEmojiSticker() || _diceIndex >= 0) {
_size = GetAnimatedEmojiSize(&_data->session(), _size);
_size = Sticker::EmojiSize();
if (_diceIndex > 0) {
[[maybe_unused]] bool result = readyToDrawLottie();
}
} else {
_size = DownscaledSize(
_size,
{ st::maxStickerSize, st::maxStickerSize });
_size = DownscaledSize(_data->dimensions, Sticker::Size());
}
}
@ -135,18 +129,14 @@ bool Sticker::readyToDrawLottie() {
return (_lottie && _lottie->ready());
}
QSize Sticker::GetAnimatedEmojiSize(not_null<Main::Session*> session) {
return GetAnimatedEmojiSize(session, { 512, 512 });
QSize Sticker::Size() {
const auto side = std::min(st::maxStickerSize, kMaxSizeFixed);
return { side, side };
}
QSize Sticker::GetAnimatedEmojiSize(
not_null<Main::Session*> session,
QSize documentSize) {
const auto zoom = GetEmojiStickerZoom(session);
const auto convert = [&](int size) {
return int(size * st::maxStickerSize * zoom / kStickerSideSize);
};
return { convert(documentSize.width()), convert(documentSize.height()) };
QSize Sticker::EmojiSize() {
const auto side = std::min(st::maxAnimatedEmojiSize, kMaxEmojiSizeFixed);
return { side, side };
}
void Sticker::draw(

View File

@ -78,11 +78,8 @@ public:
}
[[nodiscard]] bool readyToDrawLottie();
[[nodiscard]] static QSize GetAnimatedEmojiSize(
not_null<Main::Session*> session);
[[nodiscard]] static QSize GetAnimatedEmojiSize(
not_null<Main::Session*> session,
QSize documentSize);
[[nodiscard]] static QSize Size();
[[nodiscard]] static QSize EmojiSize();
private:
[[nodiscard]] bool isEmojiSticker() const;

View File

@ -37,7 +37,8 @@ defaultMessageBar: MessageBar {
minPhotoSize: 100px;
minVideoSize: 160px;
maxMediaSize: 430px;
maxStickerSize: 228px;
maxStickerSize: 224px;
maxAnimatedEmojiSize: 112px;
maxGifSize: 320px;
maxVideoMessageSize: 240px;
maxSignatureSize: 144px;