diff --git a/Telegram/SourceFiles/window/section_widget.cpp b/Telegram/SourceFiles/window/section_widget.cpp index 3ed5bca4a..dc9b0dfe1 100644 --- a/Telegram/SourceFiles/window/section_widget.cpp +++ b/Telegram/SourceFiles/window/section_widget.cpp @@ -157,6 +157,7 @@ void SectionWidget::showAnimated( _showAnimation->setTopBarShadow(params.withTopBarShadow); _showAnimation->setWithFade(params.withFade); _showAnimation->setTopSkip(params.topSkip); + _showAnimation->setTopBarMask(params.topMask); _showAnimation->start(); show(); diff --git a/Telegram/SourceFiles/window/section_widget.h b/Telegram/SourceFiles/window/section_widget.h index 94372838e..521b7d7cf 100644 --- a/Telegram/SourceFiles/window/section_widget.h +++ b/Telegram/SourceFiles/window/section_widget.h @@ -72,6 +72,7 @@ class SectionMemento; struct SectionSlideParams { QPixmap oldContentCache; int topSkip = 0; + QPixmap topMask; bool withTopBarShadow = false; bool withTabs = false; bool withFade = false; diff --git a/Telegram/SourceFiles/window/window_slide_animation.cpp b/Telegram/SourceFiles/window/window_slide_animation.cpp index 305bbb10b..3368ef08b 100644 --- a/Telegram/SourceFiles/window/window_slide_animation.cpp +++ b/Telegram/SourceFiles/window/window_slide_animation.cpp @@ -39,6 +39,45 @@ void SlideAnimation::paintContents(Painter &p) const { const auto leftWidth = (leftWidthFull + leftCoord); const auto rightWidth = rightWidthFull - rightCoord; + if (!_mask.isNull()) { + auto frame = QImage( + _mask.size(), + QImage::Format_ARGB32_Premultiplied); + frame.setDevicePixelRatio(_mask.devicePixelRatio()); + frame.fill(Qt::transparent); + QPainter q(&frame); + + if (leftWidth > 0) { + q.setOpacity(leftAlpha); + q.drawPixmap( + 0, + 0, + _cacheUnder, + (_cacheUnder.width() - leftWidth * cIntRetinaFactor()), + 0, + leftWidth * cIntRetinaFactor(), + _topSkip * retina); + } + + if (rightWidth > 0) { + q.setOpacity(rightAlpha); + q.drawPixmap( + rightCoord, + 0, + _cacheOver, + 0, + 0, + rightWidth * cIntRetinaFactor(), + _topSkip * retina); + } + + q.setOpacity(1.); + q.setCompositionMode(QPainter::CompositionMode_DestinationIn); + q.drawPixmap(0, 0, _mask); + + p.drawImage(0, 0, frame); + } + if (leftWidth > 0) { p.setOpacity(leftAlpha); p.drawPixmap( @@ -133,6 +172,10 @@ void SlideAnimation::setFinishedCallback(FinishedCallback &&callback) { _finishedCallback = std::move(callback); } +void SlideAnimation::setTopBarMask(const QPixmap &mask) { + _mask = mask; +} + void SlideAnimation::start() { const auto fromLeft = (_direction == SlideDirection::FromLeft); if (fromLeft) { diff --git a/Telegram/SourceFiles/window/window_slide_animation.h b/Telegram/SourceFiles/window/window_slide_animation.h index fd944b894..ba7fbcc5d 100644 --- a/Telegram/SourceFiles/window/window_slide_animation.h +++ b/Telegram/SourceFiles/window/window_slide_animation.h @@ -26,6 +26,7 @@ public: const QPixmap &newContentCache); void setTopBarShadow(bool enabled); void setTopSkip(int skip); + void setTopBarMask(const QPixmap &mask); void setWithFade(bool withFade); using RepaintCallback = Fn; @@ -50,6 +51,7 @@ private: mutable Ui::Animations::Simple _animation; QPixmap _cacheUnder, _cacheOver; + QPixmap _mask; RepaintCallback _repaintCallback; FinishedCallback _finishedCallback;