From b403f600e7bbc467ca7bb53a5b7978513773ce09 Mon Sep 17 00:00:00 2001 From: John Preston <johnprestonmail@gmail.com> Date: Thu, 9 Nov 2023 22:32:54 +0400 Subject: [PATCH] Use correct color for channels in giveaway. --- .../view/media/history_view_giveaway.cpp | 27 ++++++++++--------- .../view/media/history_view_giveaway.h | 5 ++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp b/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp index 350ba3668..f65613ea3 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp @@ -105,6 +105,7 @@ void Giveaway::fillFromData(not_null<Data::Giveaway*> giveaway) { st::msgMinWidth), .thumbnail = Dialogs::Stories::MakeUserpicThumbnail(channel), .link = channel->openLink(), + .colorIndex = channel->colorIndex(), }); } const auto channels = int(_channels.size()); @@ -342,18 +343,6 @@ void Giveaway::paintChannels( const auto st = context.st; const auto stm = context.messageStyle(); const auto selected = context.selected(); - const auto colorIndex = parent()->colorIndex(); - const auto cache = context.outbg - ? stm->replyCache[st->colorPatternIndex(colorIndex)].get() - : st->coloredReplyCache(selected, colorIndex).get(); - if (_channelCorners[0].isNull() || _channelBg != cache->bg) { - _channelBg = cache->bg; - _channelCorners = Images::CornersMask(size / 2); - for (auto &image : _channelCorners) { - style::colorizeImage(image, cache->bg, &image); - } - } - p.setPen(cache->icon); const auto padding = st::chatGiveawayChannelPadding; for (const auto &channel : _channels) { const auto &thumbnail = channel.thumbnail; @@ -364,7 +353,19 @@ void Giveaway::paintChannels( }); } - Ui::DrawRoundedRect(p, geometry, _channelBg, _channelCorners); + const auto colorIndex = channel.colorIndex; + const auto cache = context.outbg + ? stm->replyCache[st->colorPatternIndex(colorIndex)].get() + : st->coloredReplyCache(selected, colorIndex).get(); + if (channel.corners[0].isNull() || channel.bg != cache->bg) { + channel.bg = cache->bg; + channel.corners = Images::CornersMask(size / 2); + for (auto &image : channel.corners) { + style::colorizeImage(image, cache->bg, &image); + } + } + p.setPen(cache->icon); + Ui::DrawRoundedRect(p, geometry, channel.bg, channel.corners); if (channel.ripple) { channel.ripple->paint( p, diff --git a/Telegram/SourceFiles/history/view/media/history_view_giveaway.h b/Telegram/SourceFiles/history/view/media/history_view_giveaway.h index 6529ad497..250e214c2 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_giveaway.h +++ b/Telegram/SourceFiles/history/view/media/history_view_giveaway.h @@ -69,6 +69,9 @@ private: QRect geometry; ClickHandlerPtr link; mutable std::unique_ptr<Ui::RippleAnimation> ripple; + mutable std::array<QImage, 4> corners; + mutable QColor bg; + uint8 colorIndex = 0; }; void paintBadge(Painter &p, const PaintContext &context) const; @@ -94,10 +97,8 @@ private: Ui::Text::String _winnersTitle; Ui::Text::String _winners; - mutable QColor _channelBg; mutable QColor _badgeFg; mutable QColor _badgeBorder; - mutable std::array<QImage, 4> _channelCorners; mutable QImage _badge; mutable QImage _badgeCache;