mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Mirror premium sticker thumbnail / path.
This commit is contained in:
@@ -235,7 +235,8 @@ bool PaintStickerThumbnailPath(
|
||||
QPainter &p,
|
||||
not_null<Data::DocumentMedia*> media,
|
||||
QRect target,
|
||||
QLinearGradient *gradient) {
|
||||
QLinearGradient *gradient,
|
||||
bool mirrorHorizontal) {
|
||||
const auto &path = media->thumbnailPath();
|
||||
const auto dimensions = media->owner()->dimensions;
|
||||
if (path.isEmpty() || dimensions.isEmpty() || target.isEmpty()) {
|
||||
@@ -254,6 +255,12 @@ bool PaintStickerThumbnailPath(
|
||||
0);
|
||||
p.setBrush(*gradient);
|
||||
}
|
||||
if (mirrorHorizontal) {
|
||||
const auto c = QPointF(target.width() / 2., target.height() / 2.);
|
||||
p.translate(c);
|
||||
p.scale(-1., 1.);
|
||||
p.translate(-c);
|
||||
}
|
||||
p.scale(
|
||||
target.width() / float64(dimensions.width()),
|
||||
target.height() / float64(dimensions.height()));
|
||||
@@ -266,14 +273,25 @@ bool PaintStickerThumbnailPath(
|
||||
QPainter &p,
|
||||
not_null<Data::DocumentMedia*> media,
|
||||
QRect target,
|
||||
not_null<Ui::PathShiftGradient*> gradient) {
|
||||
not_null<Ui::PathShiftGradient*> gradient,
|
||||
bool mirrorHorizontal) {
|
||||
return gradient->paint([&](const Ui::PathShiftGradient::Background &bg) {
|
||||
if (const auto color = std::get_if<style::color>(&bg)) {
|
||||
p.setBrush(*color);
|
||||
return PaintStickerThumbnailPath(p, media, target);
|
||||
return PaintStickerThumbnailPath(
|
||||
p,
|
||||
media,
|
||||
target,
|
||||
nullptr,
|
||||
mirrorHorizontal);
|
||||
}
|
||||
const auto gradient = v::get<QLinearGradient*>(bg);
|
||||
return PaintStickerThumbnailPath(p, media, target, gradient);
|
||||
return PaintStickerThumbnailPath(
|
||||
p,
|
||||
media,
|
||||
target,
|
||||
gradient,
|
||||
mirrorHorizontal);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -105,13 +105,15 @@ bool PaintStickerThumbnailPath(
|
||||
QPainter &p,
|
||||
not_null<Data::DocumentMedia*> media,
|
||||
QRect target,
|
||||
QLinearGradient *gradient = nullptr);
|
||||
QLinearGradient *gradient = nullptr,
|
||||
bool mirrorHorizontal = false);
|
||||
|
||||
bool PaintStickerThumbnailPath(
|
||||
QPainter &p,
|
||||
not_null<Data::DocumentMedia*> media,
|
||||
QRect target,
|
||||
not_null<Ui::PathShiftGradient*> gradient);
|
||||
not_null<Ui::PathShiftGradient*> gradient,
|
||||
bool mirrorHorizontal = false);
|
||||
|
||||
[[nodiscard]] QSize ComputeStickerSize(
|
||||
not_null<DocumentData*> document,
|
||||
|
Reference in New Issue
Block a user