Fix single-colored patterns.

This commit is contained in:
John Preston 2021-08-20 16:24:26 +03:00
parent aaf0015be4
commit b4eb9a0827
2 changed files with 13 additions and 3 deletions

View file

@ -983,9 +983,8 @@ void SetupChatBackground(
}, tile->lifetime());
const auto shown = [=] {
return !background->prepared().isNull()
&& !background->colorForFill()
&& background->gradientForFill().isNull();
return !background->paper().isPattern()
&& !background->colorForFill();
};
tile->toggle(shown(), anim::type::instant);

View file

@ -151,6 +151,17 @@ void SectionWidget::PaintBackground(
const auto &prepared = background->prepared();
if (prepared.isNull()) {
return;
} else if (background->paper().isPattern()) {
const auto w = prepared.width() * fill.height() / prepared.height();
const auto cx = qCeil(fill.width() / float64(w));
const auto cols = (cx / 2) * 2 + 1;
const auto xshift = (fill.width() - w * cols) / 2;
for (auto i = 0; i != cols; ++i) {
p.drawImage(
QRect(xshift + i * w, 0, w, fill.height()),
prepared,
QRect(QPoint(), prepared.size()));
}
} else if (background->tile()) {
const auto &tiled = background->preparedForTiled();
const auto left = clip.left();