mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Slightly improved shadows for bubble wraps in userpic emoji builder.
This commit is contained in:
parent
841ddcefab
commit
7c8ada0e78
1 changed files with 46 additions and 21 deletions
|
@ -7,13 +7,39 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "info/userpic/info_userpic_bubble_wrap.h"
|
||||
|
||||
#include "ui/chat/message_bubble.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_info_userpic_builder.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace {
|
||||
|
||||
void PaintExcludeTopShadow(QPainter &p, int radius, const QRect &r) {
|
||||
constexpr auto kHorizontalOffset = 1;
|
||||
constexpr auto kVerticalOffset = 2;
|
||||
const auto opacity = p.opacity();
|
||||
p.setOpacity(opacity * 0.2);
|
||||
p.drawRoundedRect(
|
||||
r + QMargins(kHorizontalOffset, -radius, kHorizontalOffset, 0),
|
||||
radius,
|
||||
radius);
|
||||
p.setOpacity(opacity * 0.2);
|
||||
p.drawRoundedRect(
|
||||
r + QMargins(0, 0, 0, kVerticalOffset),
|
||||
radius,
|
||||
radius);
|
||||
p.setOpacity(opacity * 0.4);
|
||||
p.drawRoundedRect(
|
||||
r + QMargins(0, 0, 0, kVerticalOffset / 2),
|
||||
radius,
|
||||
radius);
|
||||
p.setOpacity(opacity);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
QRect BubbleWrap::innerRect() const {
|
||||
return rect() - st::userpicBuilderEmojiBubblePadding;
|
||||
|
@ -33,29 +59,28 @@ not_null<BubbleWrap*> AddBubbleWrap(
|
|||
container,
|
||||
object_ptr<BubbleWrap>(container)))->entity();
|
||||
bubble->resize(size);
|
||||
const auto rounding = BubbleRounding{
|
||||
.topLeft = BubbleCornerRounding::Small,
|
||||
.topRight = BubbleCornerRounding::Small,
|
||||
.bottomLeft = BubbleCornerRounding::Small,
|
||||
.bottomRight = BubbleCornerRounding::Small,
|
||||
};
|
||||
|
||||
auto cached = QImage(
|
||||
size * style::DevicePixelRatio(),
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
cached.setDevicePixelRatio(style::DevicePixelRatio());
|
||||
cached.fill(Qt::transparent);
|
||||
{
|
||||
auto p = QPainter(&cached);
|
||||
const auto innerRect = bubble->innerRect();
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
const auto radius = st::bubbleRadiusSmall;
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(st::shadowFg);
|
||||
PaintExcludeTopShadow(p, radius, innerRect);
|
||||
p.setBrush(st::boxBg);
|
||||
p.drawRoundedRect(innerRect, radius, radius);
|
||||
}
|
||||
|
||||
bubble->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
) | rpl::start_with_next([bubble, cached = std::move(cached)] {
|
||||
auto p = QPainter(bubble);
|
||||
const auto innerRect = bubble->innerRect();
|
||||
const auto args = SimpleBubble{
|
||||
.st = chatStyle(),
|
||||
.geometry = innerRect,
|
||||
.pattern = nullptr,
|
||||
.patternViewport = innerRect,
|
||||
.outerWidth = bubble->width(),
|
||||
.selected = false,
|
||||
.shadowed = true,
|
||||
.outbg = false,
|
||||
.rounding = rounding,
|
||||
};
|
||||
PaintBubble(p, args);
|
||||
p.drawImage(0, 0, cached);
|
||||
}, bubble->lifetime());
|
||||
|
||||
return bubble;
|
||||
|
|
Loading…
Add table
Reference in a new issue