From 10ff71e8f65353acd0546aad277347969a3c1f15 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 21 Jan 2022 18:37:41 +0300 Subject: [PATCH] Support svg path outline for Webm stickers. --- .../history/view/media/history_view_gif.cpp | 36 +++++++++++++++---- .../history/view/media/history_view_gif.h | 5 +++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index 96e1fbaa4d..b7929b451a 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -32,12 +32,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text/format_values.h" #include "ui/grouped_layout.h" #include "ui/cached_round_corners.h" +#include "ui/effects/path_shift_gradient.h" #include "data/data_session.h" #include "data/data_streaming.h" #include "data/data_document.h" #include "data/data_file_click_handler.h" #include "data/data_file_origin.h" #include "data/data_document_media.h" +#include "chat_helpers/stickers_lottie.h" // PaintStickerThumbnailPath. #include "styles/style_chat.h" namespace HistoryView { @@ -459,7 +461,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const { const auto normal = _dataMedia->thumbnail(); if (normal) { const auto blurred = (normal->width() < kUseNonBlurredThreshold) - || (normal->height() < kUseNonBlurredThreshold); + && (normal->height() < kUseNonBlurredThreshold); p.drawPixmap( rthumb.topLeft(), normal->pixSingle(size, blurred ? args.blurred() : args)); @@ -481,17 +483,15 @@ void Gif::draw(Painter &p, const PaintContext &context) const { | (roundTop ? RectPart::Top : RectPart::None) | (roundBottom ? RectPart::Bottom : RectPart::None); Ui::FillRoundRect(p, rthumb.marginsAdded({ 0, roundTop ? 0 : margin, 0, roundBottom ? 0 : margin }), st->imageBg(), roundRadius, parts); + } else { + paintPath(p, context, rthumb); } } } } - if (context.selected()) { - if (unwrapped && !isRound) { - // #TODO stickers - } else { - Ui::FillComplexOverlayRect(p, st, rthumb, roundRadius, roundCorners); - } + if (context.selected() && !sticker) { + Ui::FillComplexOverlayRect(p, st, rthumb, roundRadius, roundCorners); } if (radial @@ -692,6 +692,28 @@ void Gif::validateVideoThumbnail() const { : info.thumbnail); } +void Gif::paintPath( + Painter &p, + const PaintContext &context, + const QRect &r) const { + Expects(_dataMedia != nullptr); + + const auto pathGradient = _parent->delegate()->elementPathShiftGradient(); + if (context.selected()) { + pathGradient->overrideColors( + context.st->msgServiceBgSelected(), + context.st->msgServiceBg()); + } else { + pathGradient->clearOverridenColors(); + } + p.setBrush(context.imageStyle()->msgServiceBg); + ChatHelpers::PaintStickerThumbnailPath( + p, + _dataMedia.get(), + r, + pathGradient); +} + void Gif::drawCornerStatus( Painter &p, const PaintContext &context, diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.h b/Telegram/SourceFiles/history/view/media/history_view_gif.h index 95f15308b0..b7abc70c5a 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.h +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.h @@ -177,6 +177,11 @@ private: StateRequest request, QPoint position) const; + void paintPath( + Painter &p, + const PaintContext &context, + const QRect &r) const; + const not_null _data; int _thumbw = 1; int _thumbh = 1;