diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index fa2542429..774f97ef7 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -288,7 +288,10 @@ void showPeerHistory( auto ms = getms(); LOG(("Show Peer Start")); if (auto m = App::main()) { - m->ui_showPeerHistory(peer, Window::SectionShow(), msgId); + m->ui_showPeerHistory( + peer, + Window::SectionShow::Way::ClearStack, + msgId); } LOG(("Show Peer End: %1").arg(getms() - ms)); } diff --git a/Telegram/SourceFiles/history/history_admin_log_section.cpp b/Telegram/SourceFiles/history/history_admin_log_section.cpp index 4047a41de..b322ec284 100644 --- a/Telegram/SourceFiles/history/history_admin_log_section.cpp +++ b/Telegram/SourceFiles/history/history_admin_log_section.cpp @@ -437,7 +437,8 @@ void Widget::onScroll() { _inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height()); } -void Widget::showAnimatedHook() { +void Widget::showAnimatedHook( + const Window::SectionSlideParams ¶ms) { _fixedBar->setAnimatingMode(true); } diff --git a/Telegram/SourceFiles/history/history_admin_log_section.h b/Telegram/SourceFiles/history/history_admin_log_section.h index 47a1e718c..ab4ea1387 100644 --- a/Telegram/SourceFiles/history/history_admin_log_section.h +++ b/Telegram/SourceFiles/history/history_admin_log_section.h @@ -114,7 +114,8 @@ protected: void resizeEvent(QResizeEvent *e) override; void paintEvent(QPaintEvent *e) override; - void showAnimatedHook() override; + void showAnimatedHook( + const Window::SectionSlideParams ¶ms) override; void showFinishedHook() override; void doSetInnerFocus() override; diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index acaf3bab3..f9c22e6c8 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -99,7 +99,27 @@ void WrapWidget::createTabs() { } void WrapWidget::showTab(Tab tab) { - showContent(createContent(tab)); + Expects(_content != nullptr); + auto direction = (tab > _tab) + ? SlideDirection::FromRight + : SlideDirection::FromLeft; + auto newAnotherMemento = _content->createMemento(); + auto newContent = _anotherTabMemento + ? createContent(_anotherTabMemento.get()) + : createContent(tab); + auto animationParams = SectionSlideParams(); +// animationParams.withFade = (wrap() == Wrap::Layer); + animationParams.withTabs = true; + animationParams.withTopBarShadow = hasTopBarShadow() + && newContent->hasTopBarShadow(); + animationParams.oldContentCache = grabForShowAnimation( + animationParams); + + showContent(std::move(newContent)); + + showAnimated(direction, animationParams); + + _anotherTabMemento = std::move(newAnotherMemento); } void WrapWidget::setupTabbedTop(const Section §ion) { @@ -276,11 +296,27 @@ QPixmap WrapWidget::grabForShowAnimation( } else { _topShadow->toggle(_topShadow->toggled(), anim::type::instant); } + if (params.withTabs && _topTabs) { + _topTabs->hide(); + } auto result = myGrab(this); - if (params.withTopBarShadow) _topShadow->setVisible(true); + if (params.withTopBarShadow) { + _topShadow->setVisible(true); + } + if (params.withTabs && _topTabs) { + _topTabs->show(); + } return result; } +void WrapWidget::showAnimatedHook( + const Window::SectionSlideParams ¶ms) { + if (params.withTabs && _topTabs) { + _topTabs->show(); + _topTabsBackground->show(); + } +} + void WrapWidget::doSetInnerFocus() { _content->setInnerFocus(); } @@ -334,12 +370,14 @@ void WrapWidget::showNewContent( auto needAnimation = (_content != nullptr) && (params.animated != anim::type::instant); auto animationParams = SectionSlideParams(); + auto newContent = object_ptr(nullptr); if (needAnimation) { - auto newContent = createContent(memento); + newContent = createContent(memento); animationParams.withTopBarShadow = hasTopBarShadow() && newContent->hasTopBarShadow(); animationParams.oldContentCache = grabForShowAnimation( animationParams); +// animationParams.withFade = (wrap() == Wrap::Layer); } if (saveToStack) { auto item = StackItem(); @@ -351,7 +389,12 @@ void WrapWidget::showNewContent( } else if (params.way == Window::SectionShow::Way::ClearStack) { _historyStack.clear(); } - showNewContent(memento); + if (newContent) { + setupTop(newContent->section(), newContent->peer()->id); + showContent(std::move(newContent)); + } else { + showNewContent(memento); + } if (animationParams) { showAnimated( saveToStack diff --git a/Telegram/SourceFiles/info/info_wrap_widget.h b/Telegram/SourceFiles/info/info_wrap_widget.h index 9b9ab97e1..c0a409e10 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.h +++ b/Telegram/SourceFiles/info/info_wrap_widget.h @@ -106,6 +106,8 @@ public: bool hasTopBarShadow() const override; QPixmap grabForShowAnimation( const Window::SectionSlideParams ¶ms) override; + void showAnimatedHook( + const Window::SectionSlideParams ¶ms) override; bool showInternal( not_null memento, diff --git a/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp b/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp index 10bbaa7f9..ba34fa3e6 100644 --- a/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_inner_widget.cpp @@ -20,6 +20,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ #include "info/media/info_media_inner_widget.h" +#include "ui/widgets/labels.h" + namespace Info { namespace Media { @@ -30,6 +32,16 @@ InnerWidget::InnerWidget( : RpWidget(parent) , _peer(peer) , _type(type) { + auto text = qsl("Media Overview\n\n"); + auto label = object_ptr(this); + label->setText(text.repeated(50)); + widthValue() | rpl::start_with_next([inner = label.data()](int w) { + inner->resizeToWidth(w); + }, lifetime()); + label->heightValue() | rpl::start_with_next([this](int h) { + _rowsHeightFake = h; + resizeToWidth(width()); + }, lifetime()); } void InnerWidget::visibleTopBottomUpdated( @@ -46,8 +58,7 @@ void InnerWidget::restoreState(not_null memento) { } int InnerWidget::resizeGetHeight(int newWidth) { - auto rowsHeight = _rowsHeightFake; - return qMax(rowsHeight, _minHeight); + return _rowsHeightFake; } } // namespace Media diff --git a/Telegram/SourceFiles/info/media/info_media_inner_widget.h b/Telegram/SourceFiles/info/media/info_media_inner_widget.h index 6a0a9d99a..07b75cf33 100644 --- a/Telegram/SourceFiles/info/media/info_media_inner_widget.h +++ b/Telegram/SourceFiles/info/media/info_media_inner_widget.h @@ -41,11 +41,6 @@ public: return _type; } - void resizeToWidth(int newWidth, int minHeight) { - _minHeight = minHeight; - return RpWidget::resizeToWidth(newWidth); - } - void saveState(not_null memento); void restoreState(not_null memento); @@ -62,7 +57,6 @@ private: int _rowsHeightFake = 0; int _visibleTop = 0; int _visibleBottom = 0; - int _minHeight = 0; }; diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp index 25e013351..0b9ab5296 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_cover.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_cover.cpp @@ -184,6 +184,16 @@ SectionWithToggle *SectionWithToggle::setToggleShown( return this; } +void SectionWithToggle::toggle(bool toggled) { + if (_toggle) { + _toggle->setChecked(toggled); + } +} + +bool SectionWithToggle::toggled() const { + return _toggle ? _toggle->checked() : false; +} + rpl::producer SectionWithToggle::toggledValue() const { if (_toggle) { return rpl::single(_toggle->checked()) diff --git a/Telegram/SourceFiles/info/profile/info_profile_cover.h b/Telegram/SourceFiles/info/profile/info_profile_cover.h index 9d5bad30c..2b0bd7206 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_cover.h +++ b/Telegram/SourceFiles/info/profile/info_profile_cover.h @@ -45,6 +45,8 @@ public: using FixedHeightWidget::FixedHeightWidget; SectionWithToggle *setToggleShown(rpl::producer &&shown); + void toggle(bool toggled); + bool toggled() const; rpl::producer toggledValue() const; protected: diff --git a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp index c8c3c62fb..214eb567f 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp @@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include #include +#include "info/info_memento.h" #include "info/profile/info_profile_button.h" #include "info/profile/info_profile_widget.h" #include "info/profile/info_profile_text.h" @@ -64,7 +65,7 @@ InnerWidget::InnerWidget( , _content(setupContent(this, std::move(wrapValue))) { _content->heightValue() | rpl::start_with_next([this](int height) { - TWidget::resizeToWidth(width()); + resizeToWidth(width()); _desiredHeight.fire(countDesiredHeight()); }, lifetime()); } @@ -83,18 +84,17 @@ object_ptr InnerWidget::setupContent( RpWidget *parent, rpl::producer &&wrapValue) { auto result = object_ptr(parent); - auto cover = result->add(object_ptr( + _cover = result->add(object_ptr( result, - _peer) - ); - cover->setOnlineCount(rpl::single(0)); + _peer)); + _cover->setOnlineCount(rpl::single(0)); auto details = setupDetails(parent); if (canHideDetailsEver()) { - cover->setToggleShown(canHideDetails()); - result->add(object_ptr>( + _cover->setToggleShown(canHideDetails()); + _infoWrap = result->add(object_ptr>( result, std::move(details)) - )->toggleOn(cover->toggledValue()); + )->toggleOn(_cover->toggledValue()); } else { result->add(std::move(details)); } @@ -262,7 +262,7 @@ void InnerWidget::setupUserButtons( } object_ptr InnerWidget::setupSharedMedia( - RpWidget *parent) const { + RpWidget *parent) { using namespace rpl::mappers; auto content = object_ptr(parent); @@ -308,8 +308,9 @@ object_ptr InnerWidget::setupSharedMedia( [phrase = mediaText(type)](int count) { return phrase(lt_count, count); } - )->entity()->addClickHandler([peer = _peer, type] { - SharedMediaShowOverview(type, App::history(peer)); + )->entity()->addClickHandler([this, peer = _peer, type] { + _controller->showSection( + Info::Memento(peer->id, Section(type))); }); }; auto addCommonGroupsButton = [&](not_null user) { @@ -343,13 +344,13 @@ object_ptr InnerWidget::setupSharedMedia( auto layout = result->entity(); layout->add(object_ptr(result)); - auto cover = layout->add(object_ptr(layout)); + _sharedMediaCover = layout->add(object_ptr(layout)); if (canHideDetailsEver()) { - cover->setToggleShown(canHideDetails()); - layout->add(object_ptr>( + _sharedMediaCover->setToggleShown(canHideDetails()); + _sharedMediaWrap = layout->add(object_ptr>( layout, std::move(content)) - )->toggleOn(cover->toggledValue()); + )->toggleOn(_sharedMediaCover->toggledValue()); } else { layout->add(std::move(content)); } @@ -483,15 +484,25 @@ void InnerWidget::visibleTopBottomUpdated( } void InnerWidget::saveState(not_null memento) { + memento->setInfoExpanded(_cover->toggled()); + memento->setMediaExpanded(_sharedMediaCover->toggled()); } void InnerWidget::restoreState(not_null memento) { + _cover->toggle(memento->infoExpanded()); + if (_infoWrap) { + _infoWrap->finishAnimating(); + } + _sharedMediaCover->toggle(memento->mediaExpanded()); + if (_sharedMediaWrap) { + _sharedMediaWrap->finishAnimating(); + } } int InnerWidget::resizeGetHeight(int newWidth) { _content->resizeToWidth(newWidth); _content->moveToLeft(0, 0); - return qMax(_content->heightNoMargins(), _minHeight); + return _content->heightNoMargins(); } } // namespace Profile diff --git a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h index 6d0453568..941a90e68 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h +++ b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h @@ -42,6 +42,8 @@ namespace Profile { class Memento; class Members; +class Cover; +class SharedMediaCover; class InnerWidget final : public Ui::RpWidget { public: @@ -55,11 +57,6 @@ public: return _peer; } - void resizeToWidth(int newWidth, int minHeight) { - _minHeight = minHeight; - return RpWidget::resizeToWidth(newWidth); - } - void saveState(not_null memento); void restoreState(not_null memento); @@ -82,7 +79,7 @@ private: RpWidget *parent, rpl::producer &&wrapValue); object_ptr setupDetails(RpWidget *parent) const; - object_ptr setupSharedMedia(RpWidget *parent) const; + object_ptr setupSharedMedia(RpWidget *parent); object_ptr setupMuteToggle(RpWidget *parent) const; object_ptr setupInfo(RpWidget *parent) const; void setupUserButtons( @@ -104,9 +101,11 @@ private: not_null _controller; not_null _peer; - int _minHeight = 0; - Members *_members = nullptr; + Cover *_cover = nullptr; + Ui::SlideWrap *_infoWrap = nullptr; + SharedMediaCover *_sharedMediaCover = nullptr; + Ui::SlideWrap *_sharedMediaWrap = nullptr; object_ptr _content; rpl::event_stream _scrollToRequests; diff --git a/Telegram/SourceFiles/info/profile/info_profile_widget.h b/Telegram/SourceFiles/info/profile/info_profile_widget.h index c1512b52e..a46d2c128 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_widget.h +++ b/Telegram/SourceFiles/info/profile/info_profile_widget.h @@ -43,15 +43,22 @@ public: return Section(Section::Type::Profile); } - void setScrollTop(int scrollTop) { - _scrollTop = scrollTop; + void setInfoExpanded(bool expanded) { + _infoExpanded = expanded; } - int scrollTop() const { - return _scrollTop; + bool infoExpanded() const { + return _infoExpanded; + } + void setMediaExpanded(bool expanded) { + _mediaExpanded = expanded; + } + bool mediaExpanded() const { + return _mediaExpanded; } private: - int _scrollTop = 0; + bool _infoExpanded = false; + bool _mediaExpanded = false; }; diff --git a/Telegram/SourceFiles/profile/profile_common_groups_section.cpp b/Telegram/SourceFiles/profile/profile_common_groups_section.cpp index 7059597ec..040202541 100644 --- a/Telegram/SourceFiles/profile/profile_common_groups_section.cpp +++ b/Telegram/SourceFiles/profile/profile_common_groups_section.cpp @@ -449,7 +449,8 @@ void Widget::onScroll() { _inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height()); } -void Widget::showAnimatedHook() { +void Widget::showAnimatedHook( + const Window::SectionSlideParams ¶ms) { _fixedBar->setAnimatingMode(true); } diff --git a/Telegram/SourceFiles/profile/profile_common_groups_section.h b/Telegram/SourceFiles/profile/profile_common_groups_section.h index 64669a702..f9afacac8 100644 --- a/Telegram/SourceFiles/profile/profile_common_groups_section.h +++ b/Telegram/SourceFiles/profile/profile_common_groups_section.h @@ -201,7 +201,8 @@ public: protected: void resizeEvent(QResizeEvent *e) override; - void showAnimatedHook() override; + void showAnimatedHook( + const Window::SectionSlideParams ¶ms) override; void showFinishedHook() override; void doSetInnerFocus() override; diff --git a/Telegram/SourceFiles/profile/profile_widget.cpp b/Telegram/SourceFiles/profile/profile_widget.cpp index e6bd9003e..0f7cbc542 100644 --- a/Telegram/SourceFiles/profile/profile_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_widget.cpp @@ -145,7 +145,8 @@ void Widget::onScroll() { updateScrollState(); } -void Widget::showAnimatedHook() { +void Widget::showAnimatedHook( + const Window::SectionSlideParams ¶ms) { _fixedBar->setAnimatingMode(true); } diff --git a/Telegram/SourceFiles/profile/profile_widget.h b/Telegram/SourceFiles/profile/profile_widget.h index 2cacb3e4a..6fc462d95 100644 --- a/Telegram/SourceFiles/profile/profile_widget.h +++ b/Telegram/SourceFiles/profile/profile_widget.h @@ -61,7 +61,8 @@ public: protected: void resizeEvent(QResizeEvent *e) override; - void showAnimatedHook() override; + void showAnimatedHook( + const Window::SectionSlideParams ¶ms) override; void showFinishedHook() override; void doSetInnerFocus() override; diff --git a/Telegram/SourceFiles/window/section_widget.cpp b/Telegram/SourceFiles/window/section_widget.cpp index e7f05ce0a..c8b6dbc98 100644 --- a/Telegram/SourceFiles/window/section_widget.cpp +++ b/Telegram/SourceFiles/window/section_widget.cpp @@ -59,7 +59,7 @@ void SectionWidget::showAnimated( showChildren(); auto myContentCache = grabForShowAnimation(params); hideChildren(); - showAnimatedHook(); + showAnimatedHook(params); _showAnimation = std::make_unique(); _showAnimation->setDirection(direction); @@ -69,6 +69,7 @@ void SectionWidget::showAnimated( params.oldContentCache, myContentCache); _showAnimation->setTopBarShadow(params.withTopBarShadow); + _showAnimation->setWithFade(params.withFade); _showAnimation->start(); show(); diff --git a/Telegram/SourceFiles/window/section_widget.h b/Telegram/SourceFiles/window/section_widget.h index 80b5b8219..1847ec398 100644 --- a/Telegram/SourceFiles/window/section_widget.h +++ b/Telegram/SourceFiles/window/section_widget.h @@ -70,6 +70,8 @@ class SectionMemento; struct SectionSlideParams { QPixmap oldContentCache; bool withTopBarShadow = false; + bool withTabs = false; + bool withFade = false; explicit operator bool() const { return !oldContentCache.isNull(); @@ -147,7 +149,8 @@ protected: } // Called after the hideChildren() call in showAnimated(). - virtual void showAnimatedHook() { + virtual void showAnimatedHook( + const Window::SectionSlideParams ¶ms) { } // Called after the showChildren() call in showFinished(). diff --git a/Telegram/SourceFiles/window/window_controller.h b/Telegram/SourceFiles/window/window_controller.h index 41805428f..2aeb884a3 100644 --- a/Telegram/SourceFiles/window/window_controller.h +++ b/Telegram/SourceFiles/window/window_controller.h @@ -45,7 +45,7 @@ struct SectionShow { ClearStack, }; SectionShow( - Way way = Way::ClearStack, + Way way = Way::Forward, anim::type animated = anim::type::normal, anim::activation activation = anim::activation::normal) : way(way) @@ -127,26 +127,26 @@ public: void showPeerHistory( PeerId peerId, - const SectionShow ¶ms = SectionShow(), + const SectionShow ¶ms = SectionShow::Way::ClearStack, MsgId msgId = ShowAtUnreadMsgId); void showPeerHistory( not_null peer, - const SectionShow ¶ms = SectionShow(), + const SectionShow ¶ms = SectionShow::Way::ClearStack, MsgId msgId = ShowAtUnreadMsgId); void showPeerHistory( not_null history, - const SectionShow ¶ms = SectionShow(), + const SectionShow ¶ms = SectionShow::Way::ClearStack, MsgId msgId = ShowAtUnreadMsgId); void showPeerInfo( PeerId peerId, - const SectionShow ¶ms = SectionShow::Way::Forward); + const SectionShow ¶ms = SectionShow()); void showPeerInfo( not_null peer, - const SectionShow ¶ms = SectionShow::Way::Forward); + const SectionShow ¶ms = SectionShow()); void showPeerInfo( not_null history, - const SectionShow ¶ms = SectionShow::Way::Forward); + const SectionShow ¶ms = SectionShow()); void clearSectionStack( const SectionShow ¶ms = SectionShow::Way::ClearStack) { diff --git a/Telegram/SourceFiles/window/window_slide_animation.cpp b/Telegram/SourceFiles/window/window_slide_animation.cpp index a2b4a2686..4f03aaf53 100644 --- a/Telegram/SourceFiles/window/window_slide_animation.cpp +++ b/Telegram/SourceFiles/window/window_slide_animation.cpp @@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "window/window_slide_animation.h" #include "styles/style_window.h" +#include "styles/style_boxes.h" namespace Window { @@ -29,18 +30,47 @@ void SlideAnimation::paintContents(Painter &p, const QRect &update) const { // Animation callback can destroy "this", so we don't pass "ms". auto progress = _animation.current((_direction == SlideDirection::FromLeft) ? 0. : 1.); - auto coordUnder = anim::interpolate(0, -st::slideShift, progress); - auto coordOver = anim::interpolate(_cacheOver.width() / cIntRetinaFactor(), 0, progress); - if (coordOver) { - p.drawPixmap(QRect(0, 0, coordOver, _cacheUnder.height() / retina), _cacheUnder, QRect(-coordUnder * retina, 0, coordOver * retina, _cacheUnder.height())); - p.setOpacity(progress); - p.fillRect(0, 0, coordOver, _cacheUnder.height() / retina, st::slideFadeOutBg); - p.setOpacity(1); - } - p.drawPixmap(QRect(coordOver, 0, _cacheOver.width() / retina, _cacheOver.height() / retina), _cacheOver, QRect(0, 0, _cacheOver.width(), _cacheOver.height())); - p.setOpacity(progress); - st::slideShadow.fill(p, QRect(coordOver - st::slideShadow.width(), 0, st::slideShadow.width(), _cacheOver.height() / retina)); + if (_withFade) { + p.fillRect(update, st::boxBg); + auto slideLeft = (_direction == SlideDirection::FromLeft); + auto dt = slideLeft + ? (1. - progress) + : progress; + auto easeOut = anim::easeOutCirc(1., dt); + auto easeIn = anim::easeInCirc(1., dt); + auto arrivingAlpha = easeIn; + auto departingAlpha = 1. - easeOut; + auto leftWidthFull = _cacheUnder.width() / cIntRetinaFactor(); + auto rightWidthFull = _cacheOver.width() / cIntRetinaFactor(); + auto leftCoord = (slideLeft ? anim::interpolate(-leftWidthFull, 0, easeOut) : anim::interpolate(0, -leftWidthFull, easeIn)); + auto leftAlpha = (slideLeft ? arrivingAlpha : departingAlpha); + auto rightCoord = (slideLeft ? anim::interpolate(0, rightWidthFull, easeIn) : anim::interpolate(rightWidthFull, 0, easeOut)); + auto rightAlpha = (slideLeft ? departingAlpha : arrivingAlpha); + + auto leftWidth = (leftWidthFull + leftCoord); + if (leftWidth > 0) { + p.setOpacity(leftAlpha); + p.drawPixmap(0, 0, leftWidth, _cacheUnder.height() / retina, _cacheUnder, (_cacheUnder.width() - leftWidth * cIntRetinaFactor()), 0, leftWidth * cIntRetinaFactor(), _cacheUnder.height()); + } + auto rightWidth = rightWidthFull - rightCoord; + if (rightWidth > 0) { + p.setOpacity(rightAlpha); + p.drawPixmap(rightCoord, 0, _cacheOver, 0, 0, rightWidth * cIntRetinaFactor(), _cacheOver.height()); + } + } else { + auto coordUnder = anim::interpolate(0, -st::slideShift, progress); + auto coordOver = anim::interpolate(_cacheOver.width() / cIntRetinaFactor(), 0, progress); + if (coordOver) { + p.drawPixmap(QRect(0, 0, coordOver, _cacheUnder.height() / retina), _cacheUnder, QRect(-coordUnder * retina, 0, coordOver * retina, _cacheUnder.height())); + p.setOpacity(progress); + p.fillRect(0, 0, coordOver, _cacheUnder.height() / retina, st::slideFadeOutBg); + p.setOpacity(1); + } + p.drawPixmap(QRect(coordOver, 0, _cacheOver.width() / retina, _cacheOver.height() / retina), _cacheOver, QRect(0, 0, _cacheOver.width(), _cacheOver.height())); + p.setOpacity(progress); + st::slideShadow.fill(p, QRect(coordOver - st::slideShadow.width(), 0, st::slideShadow.width(), _cacheOver.height() / retina)); + } if (_topBarShadowEnabled) { p.setOpacity(1); p.fillRect(0, st::topBarHeight, _cacheOver.width() / retina, st::lineWidth, st::shadowFg); @@ -60,6 +90,10 @@ void SlideAnimation::setTopBarShadow(bool enabled) { _topBarShadowEnabled = enabled; } +void SlideAnimation::setWithFade(bool withFade) { + _withFade = withFade; +} + void SlideAnimation::setRepaintCallback(RepaintCallback &&callback) { _repaintCallback = std::move(callback); } diff --git a/Telegram/SourceFiles/window/window_slide_animation.h b/Telegram/SourceFiles/window/window_slide_animation.h index ebbc77b7d..0ef2461fb 100644 --- a/Telegram/SourceFiles/window/window_slide_animation.h +++ b/Telegram/SourceFiles/window/window_slide_animation.h @@ -34,6 +34,7 @@ public: void setDirection(SlideDirection direction); void setPixmaps(const QPixmap &oldContentCache, const QPixmap &newContentCache); void setTopBarShadow(bool enabled); + void setWithFade(bool withFade); using RepaintCallback = base::lambda; void setRepaintCallback(RepaintCallback &&callback); @@ -52,6 +53,7 @@ private: SlideDirection _direction = SlideDirection::FromRight; bool _topBarShadowEnabled = false; + bool _withFade = false; mutable Animation _animation; QPixmap _cacheUnder, _cacheOver;