Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scaling webm stickers #335

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions Telegram/SourceFiles/history/history_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,15 +640,29 @@ HistoryWidget::HistoryWidget(
"sticker_height"
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {
updateHistoryGeometry();
if (_history) {
_history->forceFullResize();
if (_migrated) {
_migrated->forceFullResize();
}
updateHistoryGeometry();
update();
}
});
}, lifetime());

::Kotato::JsonSettings::Events(
"sticker_scale_both"
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {
updateHistoryGeometry();
if (_history) {
_history->forceFullResize();
if (_migrated) {
_migrated->forceFullResize();
}
updateHistoryGeometry();
update();
}
});
}, lifetime());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ QSize Gif::countThumbSize(int &inOutWidthMax) const {
+ st::msgPadding.right()
: 0;
const auto maxSize = _data->sticker()
? Sticker::Size().width()
? Sticker::Size().height()
: _data->isVideoFile()
? st::maxMediaSize
: _data->isVideoMessage()
Expand Down
13 changes: 6 additions & 7 deletions Telegram/SourceFiles/history/view/media/history_view_sticker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,13 @@ bool Sticker::isEmojiSticker() const {
}

void Sticker::initSize() {
const auto currentStickerHeight = ::Kotato::JsonSettings::GetInt("sticker_height");
const auto currentScaleBoth = ::Kotato::JsonSettings::GetBool("sticker_scale_both");
const auto maxHeight = int(st::maxStickerSize / 256.0 * currentStickerHeight);
const auto maxWidth = currentScaleBoth ? maxHeight : st::maxStickerSize;
if (isEmojiSticker() || _diceIndex >= 0) {
_size = Sticker::EmojiSize();
if (_diceIndex > 0) {
[[maybe_unused]] bool result = readyToDrawLottie();
}
} else {
_size = DownscaledSize(_data->dimensions, { maxWidth, maxHeight });
_size = DownscaledSize(_data->dimensions, Sticker::Size());
}
}

Expand Down Expand Up @@ -135,8 +131,11 @@ bool Sticker::readyToDrawLottie() {
}

QSize Sticker::Size() {
const auto side = std::min(st::maxStickerSize, kMaxSizeFixed);
return { side, side };
const auto currentStickerHeight = ::Kotato::JsonSettings::GetInt("sticker_height");
const auto currentScaleBoth = ::Kotato::JsonSettings::GetBool("sticker_scale_both");
const auto maxHeight = int(st::maxStickerSize / 256.0 * currentStickerHeight);
const auto maxWidth = currentScaleBoth ? maxHeight : st::maxStickerSize;
return { maxWidth, maxHeight };
}

QSize Sticker::EmojiSize() {
Expand Down