From 19c1764bd1d17b9994e90447046e383eb163d07c Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Sun, 27 Dec 2020 19:35:16 +0300 Subject: [PATCH] Fix rounding of Replies userpic --- Telegram/SourceFiles/ui/empty_userpic.cpp | 75 ++++++++++++++++++++++- Telegram/SourceFiles/ui/empty_userpic.h | 28 +++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/ui/empty_userpic.cpp b/Telegram/SourceFiles/ui/empty_userpic.cpp index d86d294a4..63331974e 100644 --- a/Telegram/SourceFiles/ui/empty_userpic.cpp +++ b/Telegram/SourceFiles/ui/empty_userpic.cpp @@ -373,9 +373,35 @@ void EmptyUserpic::PaintRepliesMessages( int y, int outerWidth, int size) { + switch (cUserpicCornersType()) { + case 0: + PaintRepliesMessagesSquared(p, x, y, outerWidth, size); + break; + + case 1: + PaintRepliesMessagesRounded(p, x, y, outerWidth, size); + break; + + case 2: + PaintRepliesMessagesRoundedLarge(p, x, y, outerWidth, size); + break; + + default: + const auto &bg = st::historyPeerSavedMessagesBg; + const auto &fg = st::historyPeerUserpicFg; + PaintRepliesMessages(p, x, y, outerWidth, size, bg, fg); + } +} + +void EmptyUserpic::PaintRepliesMessagesRoundedLarge( + Painter &p, + int x, + int y, + int outerWidth, + int size) { const auto &bg = st::historyPeerSavedMessagesBg; const auto &fg = st::historyPeerUserpicFg; - PaintRepliesMessages(p, x, y, outerWidth, size, bg, fg); + PaintRepliesMessagesRoundedLarge(p, x, y, outerWidth, size, bg, fg); } void EmptyUserpic::PaintRepliesMessagesRounded( @@ -389,6 +415,17 @@ void EmptyUserpic::PaintRepliesMessagesRounded( PaintRepliesMessagesRounded(p, x, y, outerWidth, size, bg, fg); } +void EmptyUserpic::PaintRepliesMessagesSquared( + Painter &p, + int x, + int y, + int outerWidth, + int size) { + const auto &bg = st::historyPeerSavedMessagesBg; + const auto &fg = st::historyPeerUserpicFg; + PaintRepliesMessagesSquared(p, x, y, outerWidth, size, bg, fg); +} + void EmptyUserpic::PaintRepliesMessages( Painter &p, int x, @@ -407,6 +444,24 @@ void EmptyUserpic::PaintRepliesMessages( PaintRepliesMessagesInner(p, x, y, size, bg, fg); } +void EmptyUserpic::PaintRepliesMessagesRoundedLarge( + Painter &p, + int x, + int y, + int outerWidth, + int size, + const style::color &bg, + const style::color &fg) { + x = rtl() ? (outerWidth - x - size) : x; + + PainterHighQualityEnabler hq(p); + p.setBrush(bg); + p.setPen(Qt::NoPen); + p.drawRoundedRect(x, y, size, size, st::dateRadius, st::dateRadius); + + PaintRepliesMessagesInner(p, x, y, size, bg, fg); +} + void EmptyUserpic::PaintRepliesMessagesRounded( Painter &p, int x, @@ -425,6 +480,24 @@ void EmptyUserpic::PaintRepliesMessagesRounded( PaintRepliesMessagesInner(p, x, y, size, bg, fg); } +void EmptyUserpic::PaintRepliesMessagesSquared( + Painter &p, + int x, + int y, + int outerWidth, + int size, + const style::color &bg, + const style::color &fg) { + x = rtl() ? (outerWidth - x - size) : x; + + PainterHighQualityEnabler hq(p); + p.setBrush(bg); + p.setPen(Qt::NoPen); + p.drawRoundedRect(x, y, size, size, 0, 0); + + PaintRepliesMessagesInner(p, x, y, size, bg, fg); +} + QPixmap EmptyUserpic::GenerateRepliesMessages(int size) { return Generate(size, [&](Painter &p) { PaintRepliesMessages(p, 0, 0, size, size); diff --git a/Telegram/SourceFiles/ui/empty_userpic.h b/Telegram/SourceFiles/ui/empty_userpic.h index 1eeade3fe..e9a4afd77 100644 --- a/Telegram/SourceFiles/ui/empty_userpic.h +++ b/Telegram/SourceFiles/ui/empty_userpic.h @@ -105,12 +105,24 @@ public: int y, int outerWidth, int size); + static void PaintRepliesMessagesRoundedLarge( + Painter &p, + int x, + int y, + int outerWidth, + int size); static void PaintRepliesMessagesRounded( Painter &p, int x, int y, int outerWidth, int size); + static void PaintRepliesMessagesSquared( + Painter &p, + int x, + int y, + int outerWidth, + int size); static void PaintRepliesMessages( Painter &p, int x, @@ -119,6 +131,14 @@ public: int size, const style::color &bg, const style::color &fg); + static void PaintRepliesMessagesRoundedLarge( + Painter &p, + int x, + int y, + int outerWidth, + int size, + const style::color &bg, + const style::color &fg); static void PaintRepliesMessagesRounded( Painter &p, int x, @@ -127,6 +147,14 @@ public: int size, const style::color &bg, const style::color &fg); + static void PaintRepliesMessagesSquared( + Painter &p, + int x, + int y, + int outerWidth, + int size, + const style::color &bg, + const style::color &fg); static QPixmap GenerateRepliesMessages(int size); static QPixmap GenerateRepliesMessagesRounded(int size);