MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / paintEvent

Method paintEvent

Telegram/SourceFiles/window/window_media_preview.cpp:79–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void MediaPreviewWidget::paintEvent(QPaintEvent *e) {
80 auto p = QPainter(this);
81
82 if (_customRadius > 0) {
83 auto hq = PainterHighQualityEnabler(p);
84 const auto r = rect() - _backgroundMargins;
85 auto path = QPainterPath();
86 path.addRoundedRect(r, _customRadius, _customRadius);
87 p.setClipPath(path);
88 }
89
90 const auto r = e->rect();
91 const auto factor = style::DevicePixelRatio();
92 const auto dimensions = currentDimensions();
93 const auto frame = (_lottie && _lottie->ready())
94 ? _lottie->frameInfo({
95 .box = dimensions * factor,
96 .colored = ((_document && _document->emojiUsesTextColor())
97 ? st::windowFg->c
98 : QColor(0, 0, 0, 0)),
99 })
100 : Lottie::Animation::FrameInfo();
101 const auto effect = (_effect && _effect->ready())
102 ? _effect->frameInfo({ dimensions * kPremiumMultiplier * factor })
103 : Lottie::Animation::FrameInfo();
104 const auto image = frame.image;
105 const auto effectImage = effect.image;
106 //const auto framesCount = !image.isNull() ? _lottie->framesCount() : 1;
107 //const auto effectsCount = !effectImage.isNull()
108 // ? _effect->framesCount()
109 // : 1;
110 const auto pixmap = image.isNull() ? currentImage() : QPixmap();
111 const auto size = image.isNull() ? pixmap.size() : image.size();
112 const auto w = size.width() / factor;
113 const auto h = size.height() / factor;
114 const auto shown = _a_shown.value(_hiding ? 0. : 1.);
115 if (!_a_shown.animating()) {
116 if (_hiding) {
117 hide();
118 _controller->disableGifPauseReason(
119 Window::GifPauseReason::MediaPreview);
120 return;
121 }
122 } else {
123 p.setOpacity(shown);
124// w = qMax(qRound(w * (st::stickerPreviewMin
125// + ((1. - st::stickerPreviewMin) * shown)) / 2.) * 2
126// + int(w % 2), 1);
127// h = qMax(qRound(h * (st::stickerPreviewMin
128// + ((1. - st::stickerPreviewMin) * shown)) / 2.) * 2
129// + int(h % 2), 1);
130 }
131 if (_backgroundMargins.isNull()) {
132 p.fillRect(r, st::stickerPreviewBg);
133 } else {
134 p.fillRect(rect() - _backgroundMargins, st::stickerPreviewBg);
135 }
136 if (!_customPadding.isNull()) {

Callers

nothing calls this directly

Calls 15

QPainterPathClass · 0.85
frameInfoMethod · 0.80
emojiUsesTextColorMethod · 0.80
disableGifPauseReasonMethod · 0.80
QPainterClass · 0.50
QColorClass · 0.50
FrameInfoClass · 0.50
rectMethod · 0.45
readyMethod · 0.45
isNullMethod · 0.45
sizeMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected