Show sticker / reaction preview over premium gradient.

This commit is contained in:
John Preston 2022-06-08 19:13:22 +04:00
parent 7ba997259c
commit e8933decb1

View file

@ -786,22 +786,33 @@ void Show(
} }
const auto fill = QSize(st::boxWideWidth, st::boxWideWidth); const auto fill = QSize(st::boxWideWidth, st::boxWideWidth);
const auto theme = controller->currentChatTheme(); const auto stops = Ui::Premium::LimitGradientStops();
const auto color = theme->background().colorForFill; //const auto theme = controller->currentChatTheme();
const auto area = QSize(fill.width(), fill.height() * 2); //const auto color = theme->background().colorForFill;
const auto request = theme->cacheBackgroundRequest(area); //const auto area = QSize(fill.width(), fill.height() * 2);
//const auto request = theme->cacheBackgroundRequest(area);
crl::async([=] { crl::async([=] {
using Option = Images::Option; using Option = Images::Option;
auto back = color //auto back = color
? SolidColorImage(area, *color) // ? SolidColorImage(area, *color)
: request.background.waitingForNegativePattern() // : request.background.waitingForNegativePattern()
? SolidColorImage(area, Qt::black) // ? SolidColorImage(area, Qt::black)
: Ui::CacheBackground(request).image; // : Ui::CacheBackground(request).image;
const auto factor = style::DevicePixelRatio(); const auto factor = style::DevicePixelRatio();
auto cropped = back.copy(QRect( //auto cropped = back.copy(QRect(
QPoint(0, fill.height() * factor / 2), // QPoint(0, fill.height() * factor / 2),
fill * factor)); // fill * factor));
//cropped.setDevicePixelRatio(factor);
auto cropped = QImage(
fill * factor,
QImage::Format_ARGB32_Premultiplied);
cropped.setDevicePixelRatio(factor); cropped.setDevicePixelRatio(factor);
auto p = QPainter(&cropped);
auto gradient = QLinearGradient(0, fill.height(), fill.width(), 0);
gradient.setStops(stops);
p.fillRect(QRect(QPoint(), fill), gradient);
p.end();
const auto options = Images::Options() const auto options = Images::Options()
| Option::RoundSkipBottomLeft | Option::RoundSkipBottomLeft
| Option::RoundSkipBottomRight | Option::RoundSkipBottomRight