Use correct color for channels in giveaway.

This commit is contained in:
John Preston 2023-11-09 22:32:54 +04:00
parent 9b2f2b104f
commit b403f600e7
2 changed files with 17 additions and 15 deletions

View file

@ -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,

View file

@ -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;