mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Support patterned reactions dropdown.
This commit is contained in:
parent
95e003153a
commit
a7c93a9421
3 changed files with 26 additions and 22 deletions
|
@ -269,7 +269,9 @@ Manager::Manager(
|
||||||
_cacheParts.setDevicePixelRatio(ratio);
|
_cacheParts.setDevicePixelRatio(ratio);
|
||||||
_cacheParts.fill(Qt::transparent);
|
_cacheParts.fill(Qt::transparent);
|
||||||
_cacheForPattern = QImage(
|
_cacheForPattern = QImage(
|
||||||
_outer * ratio,
|
QSize(
|
||||||
|
_outer.width(),
|
||||||
|
_outer.height() + st::reactionCornerAddedHeightMax) * ratio,
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
_cacheForPattern.setDevicePixelRatio(ratio);
|
_cacheForPattern.setDevicePixelRatio(ratio);
|
||||||
_shadowBuffer = QImage(
|
_shadowBuffer = QImage(
|
||||||
|
@ -529,13 +531,13 @@ void Manager::paintButton(
|
||||||
p.setOpacity(opacity);
|
p.setOpacity(opacity);
|
||||||
}
|
}
|
||||||
if (patterned) {
|
if (patterned) {
|
||||||
p.drawImage(
|
const auto source = validateShadow(frameIndex, scale, shadow);
|
||||||
position,
|
paintLongImage(p, geometry, _cacheParts, source);
|
||||||
_cacheParts,
|
|
||||||
validateShadow(frameIndex, scale, shadow));
|
|
||||||
|
|
||||||
validateCacheForPattern(frameIndex, scale, geometry, context);
|
validateCacheForPattern(frameIndex, scale, geometry, context);
|
||||||
p.drawImage(geometry, _cacheForPattern);
|
p.drawImage(
|
||||||
|
geometry,
|
||||||
|
_cacheForPattern,
|
||||||
|
QRect(QPoint(), geometry.size() * style::DevicePixelRatio()));
|
||||||
} else {
|
} else {
|
||||||
const auto &stm = context.st->messageStyle(outbg, false);
|
const auto &stm = context.st->messageStyle(outbg, false);
|
||||||
const auto background = stm.msgBg->c;
|
const auto background = stm.msgBg->c;
|
||||||
|
@ -545,11 +547,7 @@ void Manager::paintButton(
|
||||||
scale,
|
scale,
|
||||||
stm.msgBg->c,
|
stm.msgBg->c,
|
||||||
shadow);
|
shadow);
|
||||||
if (size.height() > _outer.height()) {
|
paintLongImage(p, geometry, _cacheInOut, source);
|
||||||
paintLongImage(p, geometry, _cacheInOut, source);
|
|
||||||
} else {
|
|
||||||
p.drawImage(position, _cacheInOut, source);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto mainEmojiPosition = position + (button->expandUp()
|
const auto mainEmojiPosition = position + (button->expandUp()
|
||||||
|
@ -572,10 +570,14 @@ void Manager::paintButton(
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::paintLongImage(
|
void Manager::paintLongImage(
|
||||||
Painter &p,
|
QPainter &p,
|
||||||
QRect geometry,
|
QRect geometry,
|
||||||
const QImage &image,
|
const QImage &image,
|
||||||
QRect source) {
|
QRect source) {
|
||||||
|
if (geometry.height() == _outer.height()) {
|
||||||
|
p.drawImage(geometry.topLeft(), image, source);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto factor = style::DevicePixelRatio();
|
const auto factor = style::DevicePixelRatio();
|
||||||
const auto part = (source.height() / factor) / 2 - 1;
|
const auto part = (source.height() / factor) / 2 - 1;
|
||||||
const auto fill = geometry.height() - 2 * part;
|
const auto fill = geometry.height() - 2 * part;
|
||||||
|
@ -583,13 +585,13 @@ void Manager::paintLongImage(
|
||||||
const auto top = source.height() - half;
|
const auto top = source.height() - half;
|
||||||
p.drawImage(
|
p.drawImage(
|
||||||
geometry.topLeft(),
|
geometry.topLeft(),
|
||||||
_cacheInOut,
|
image,
|
||||||
QRect(source.x(), source.y(), source.width(), half));
|
QRect(source.x(), source.y(), source.width(), half));
|
||||||
p.drawImage(
|
p.drawImage(
|
||||||
QRect(
|
QRect(
|
||||||
geometry.topLeft() + QPoint(0, part),
|
geometry.topLeft() + QPoint(0, part),
|
||||||
QSize(source.width() / factor, fill)),
|
QSize(source.width() / factor, fill)),
|
||||||
_cacheInOut,
|
image,
|
||||||
QRect(
|
QRect(
|
||||||
source.x(),
|
source.x(),
|
||||||
source.y() + half,
|
source.y() + half,
|
||||||
|
@ -597,7 +599,7 @@ void Manager::paintLongImage(
|
||||||
top - half));
|
top - half));
|
||||||
p.drawImage(
|
p.drawImage(
|
||||||
geometry.topLeft() + QPoint(0, part + fill),
|
geometry.topLeft() + QPoint(0, part + fill),
|
||||||
_cacheInOut,
|
image,
|
||||||
QRect(source.x(), source.y() + top, source.width(), half));
|
QRect(source.x(), source.y() + top, source.width(), half));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,17 +642,18 @@ void Manager::validateCacheForPattern(
|
||||||
float64 scale,
|
float64 scale,
|
||||||
const QRect &geometry,
|
const QRect &geometry,
|
||||||
const PaintContext &context) {
|
const PaintContext &context) {
|
||||||
CopyImagePart(
|
|
||||||
_cacheForPattern,
|
|
||||||
_cacheParts,
|
|
||||||
validateMask(frameIndex, scale));
|
|
||||||
auto q = QPainter(&_cacheForPattern);
|
auto q = QPainter(&_cacheForPattern);
|
||||||
|
|
||||||
|
q.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
|
const auto source = validateMask(frameIndex, scale);
|
||||||
|
paintLongImage(q, QRect(QPoint(), geometry.size()), _cacheParts, source);
|
||||||
|
|
||||||
q.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
q.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||||
Ui::PaintPatternBubblePart(
|
Ui::PaintPatternBubblePart(
|
||||||
q,
|
q,
|
||||||
context.viewport.translated(-geometry.topLeft()),
|
context.viewport.translated(-geometry.topLeft()),
|
||||||
context.bubblesPattern->pixmap,
|
context.bubblesPattern->pixmap,
|
||||||
QRect(QPoint(), _outer));
|
QRect(QPoint(), geometry.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::applyPatternedShadow(const QColor &shadow) {
|
void Manager::applyPatternedShadow(const QColor &shadow) {
|
||||||
|
|
|
@ -157,7 +157,7 @@ private:
|
||||||
float64 scale,
|
float64 scale,
|
||||||
QPoint mainEmojiPosition);
|
QPoint mainEmojiPosition);
|
||||||
void paintLongImage(
|
void paintLongImage(
|
||||||
Painter &p,
|
QPainter &p,
|
||||||
QRect geometry,
|
QRect geometry,
|
||||||
const QImage &image,
|
const QImage &image,
|
||||||
QRect source);
|
QRect source);
|
||||||
|
|
|
@ -150,6 +150,7 @@ constexpr auto kMinAcceptableContrast = 1.14;// 4.5;
|
||||||
|
|
||||||
[[nodiscard]] QImage PrepareBubblesBackground(
|
[[nodiscard]] QImage PrepareBubblesBackground(
|
||||||
const ChatThemeBubblesData &data) {
|
const ChatThemeBubblesData &data) {
|
||||||
|
return QImage(":/gui/art/themeimage.jpg"); AssertIsDebug();
|
||||||
if (data.colors.size() < 2) {
|
if (data.colors.size() < 2) {
|
||||||
return QImage();
|
return QImage();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue