From 3a2c5c6d0aeac9b3208ae9f08fd2fa4a774189ca Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 18 Apr 2024 23:17:18 +0300 Subject: [PATCH] Increased size of stickerset preview in webpages. --- .../view/media/history_view_web_page.cpp | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index 478835fc0..2a6f031ed 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -42,6 +42,7 @@ namespace HistoryView { namespace { constexpr auto kMaxOriginalEntryLines = 8192; +constexpr auto kStickerSetLines = 3; [[nodiscard]] int ArticleThumbWidth(not_null thumb, int height) { const auto size = thumb->location(Data::PhotoSize::Thumbnail); @@ -300,8 +301,8 @@ QSize WebPage::countOptimalSize() { _stickerSet->views.push_back( std::make_unique(_parent, sticker, true)); } - const auto side = std::ceil(_stickerSet->views.size() / 2.); - const auto box = lineHeight * 2; + const auto side = std::ceil(std::sqrt(_stickerSet->views.size())); + const auto box = lineHeight * kStickerSetLines; const auto single = box / side; for (const auto &view : _stickerSet->views) { view->setWebpagePart(); @@ -547,7 +548,11 @@ QSize WebPage::countCurrentSize(int newWidth) { && _sponsoredData->peer); constexpr auto kSponsoredUserpicLines = 2; _pixh = lineHeight - * (specialRightPix ? kSponsoredUserpicLines : linesMax); + * (_stickerSet + ? kStickerSetLines + : specialRightPix + ? kSponsoredUserpicLines + : linesMax); do { _pixw = specialRightPix ? _pixh @@ -755,9 +760,9 @@ void WebPage::draw(Painter &p, const PaintContext &context) const { auto lineHeight = UnitedLineHeight(); if (_stickerSet) { const auto viewsCount = _stickerSet->views.size(); - const auto topLeft = QPoint(inner.left() + paintw - _pixh, tshift); - const auto side = std::ceil(viewsCount / 2.); - const auto box = lineHeight * 2; + const auto box = _pixh; + const auto topLeft = QPoint(inner.left() + paintw - box, tshift); + const auto side = std::ceil(std::sqrt(viewsCount)); const auto single = box / side; for (auto i = 0; i < side; i++) { for (auto j = 0; j < side; j++) { @@ -769,15 +774,15 @@ void WebPage::draw(Painter &p, const PaintContext &context) const { const auto size = view->countOptimalSize(); const auto offsetX = (single - size.width()) / 2.; const auto offsetY = (single - size.height()) / 2.; - const auto x = j * size.width() + offsetX; - const auto y = i * size.height() + offsetY; + const auto x = j * single + offsetX; + const auto y = i * single + offsetY; const auto w = size.width(); const auto h = size.height(); view->draw(p, context, QRect(QPoint(x, y) + topLeft, size)); } } - } - if (asArticle()) { + paintw -= box; + } else if (asArticle()) { ensurePhotoMediaCreated(); auto pix = QPixmap();