Allow using text color -> preview color algo outside.
This commit is contained in:
parent
8649a55727
commit
770b5d0e59
2 changed files with 8 additions and 3 deletions
|
|
@ -89,6 +89,11 @@ void PaintScaledImage(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
QColor PreviewColorFromTextColor(QColor color) {
|
||||||
|
color.setAlpha((color.alpha() + 1) / 8);
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
Preview::Preview(QPainterPath path, float64 scale)
|
Preview::Preview(QPainterPath path, float64 scale)
|
||||||
: _data(ScaledPath{ std::move(path), scale }) {
|
: _data(ScaledPath{ std::move(path), scale }) {
|
||||||
}
|
}
|
||||||
|
|
@ -131,9 +136,7 @@ void Preview::paintPath(
|
||||||
const Context &context,
|
const Context &context,
|
||||||
const ScaledPath &path) {
|
const ScaledPath &path) {
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
auto copy = context.textColor.value();
|
p.setBrush(PreviewColorFromTextColor(context.textColor));
|
||||||
copy.setAlpha((copy.alpha() + 1) / 8);
|
|
||||||
p.setBrush(copy);
|
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
const auto scale = path.scale;
|
const auto scale = path.scale;
|
||||||
const auto required = (scale != 1.) || context.scaled;
|
const auto required = (scale != 1.) || context.scaled;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ namespace Ui::CustomEmoji {
|
||||||
|
|
||||||
using Context = Ui::Text::CustomEmoji::Context;
|
using Context = Ui::Text::CustomEmoji::Context;
|
||||||
|
|
||||||
|
[[nodiscard]] QColor PreviewColorFromTextColor(QColor color);
|
||||||
|
|
||||||
class Preview final {
|
class Preview final {
|
||||||
public:
|
public:
|
||||||
Preview() = default;
|
Preview() = default;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue