mirror of https://github.com/procxx/kepka.git
Save section expand state in Info memento.
This commit is contained in:
parent
c6c75a1980
commit
76b8078bd9
|
@ -288,7 +288,10 @@ void showPeerHistory(
|
||||||
auto ms = getms();
|
auto ms = getms();
|
||||||
LOG(("Show Peer Start"));
|
LOG(("Show Peer Start"));
|
||||||
if (auto m = App::main()) {
|
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));
|
LOG(("Show Peer End: %1").arg(getms() - ms));
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,7 +437,8 @@ void Widget::onScroll() {
|
||||||
_inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height());
|
_inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::showAnimatedHook() {
|
void Widget::showAnimatedHook(
|
||||||
|
const Window::SectionSlideParams ¶ms) {
|
||||||
_fixedBar->setAnimatingMode(true);
|
_fixedBar->setAnimatingMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,8 @@ protected:
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
void showAnimatedHook() override;
|
void showAnimatedHook(
|
||||||
|
const Window::SectionSlideParams ¶ms) override;
|
||||||
void showFinishedHook() override;
|
void showFinishedHook() override;
|
||||||
void doSetInnerFocus() override;
|
void doSetInnerFocus() override;
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,27 @@ void WrapWidget::createTabs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WrapWidget::showTab(Tab tab) {
|
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) {
|
void WrapWidget::setupTabbedTop(const Section §ion) {
|
||||||
|
@ -276,11 +296,27 @@ QPixmap WrapWidget::grabForShowAnimation(
|
||||||
} else {
|
} else {
|
||||||
_topShadow->toggle(_topShadow->toggled(), anim::type::instant);
|
_topShadow->toggle(_topShadow->toggled(), anim::type::instant);
|
||||||
}
|
}
|
||||||
|
if (params.withTabs && _topTabs) {
|
||||||
|
_topTabs->hide();
|
||||||
|
}
|
||||||
auto result = myGrab(this);
|
auto result = myGrab(this);
|
||||||
if (params.withTopBarShadow) _topShadow->setVisible(true);
|
if (params.withTopBarShadow) {
|
||||||
|
_topShadow->setVisible(true);
|
||||||
|
}
|
||||||
|
if (params.withTabs && _topTabs) {
|
||||||
|
_topTabs->show();
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WrapWidget::showAnimatedHook(
|
||||||
|
const Window::SectionSlideParams ¶ms) {
|
||||||
|
if (params.withTabs && _topTabs) {
|
||||||
|
_topTabs->show();
|
||||||
|
_topTabsBackground->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WrapWidget::doSetInnerFocus() {
|
void WrapWidget::doSetInnerFocus() {
|
||||||
_content->setInnerFocus();
|
_content->setInnerFocus();
|
||||||
}
|
}
|
||||||
|
@ -334,12 +370,14 @@ void WrapWidget::showNewContent(
|
||||||
auto needAnimation = (_content != nullptr)
|
auto needAnimation = (_content != nullptr)
|
||||||
&& (params.animated != anim::type::instant);
|
&& (params.animated != anim::type::instant);
|
||||||
auto animationParams = SectionSlideParams();
|
auto animationParams = SectionSlideParams();
|
||||||
|
auto newContent = object_ptr<ContentWidget>(nullptr);
|
||||||
if (needAnimation) {
|
if (needAnimation) {
|
||||||
auto newContent = createContent(memento);
|
newContent = createContent(memento);
|
||||||
animationParams.withTopBarShadow = hasTopBarShadow()
|
animationParams.withTopBarShadow = hasTopBarShadow()
|
||||||
&& newContent->hasTopBarShadow();
|
&& newContent->hasTopBarShadow();
|
||||||
animationParams.oldContentCache = grabForShowAnimation(
|
animationParams.oldContentCache = grabForShowAnimation(
|
||||||
animationParams);
|
animationParams);
|
||||||
|
// animationParams.withFade = (wrap() == Wrap::Layer);
|
||||||
}
|
}
|
||||||
if (saveToStack) {
|
if (saveToStack) {
|
||||||
auto item = StackItem();
|
auto item = StackItem();
|
||||||
|
@ -351,7 +389,12 @@ void WrapWidget::showNewContent(
|
||||||
} else if (params.way == Window::SectionShow::Way::ClearStack) {
|
} else if (params.way == Window::SectionShow::Way::ClearStack) {
|
||||||
_historyStack.clear();
|
_historyStack.clear();
|
||||||
}
|
}
|
||||||
showNewContent(memento);
|
if (newContent) {
|
||||||
|
setupTop(newContent->section(), newContent->peer()->id);
|
||||||
|
showContent(std::move(newContent));
|
||||||
|
} else {
|
||||||
|
showNewContent(memento);
|
||||||
|
}
|
||||||
if (animationParams) {
|
if (animationParams) {
|
||||||
showAnimated(
|
showAnimated(
|
||||||
saveToStack
|
saveToStack
|
||||||
|
|
|
@ -106,6 +106,8 @@ public:
|
||||||
bool hasTopBarShadow() const override;
|
bool hasTopBarShadow() const override;
|
||||||
QPixmap grabForShowAnimation(
|
QPixmap grabForShowAnimation(
|
||||||
const Window::SectionSlideParams ¶ms) override;
|
const Window::SectionSlideParams ¶ms) override;
|
||||||
|
void showAnimatedHook(
|
||||||
|
const Window::SectionSlideParams ¶ms) override;
|
||||||
|
|
||||||
bool showInternal(
|
bool showInternal(
|
||||||
not_null<Window::SectionMemento*> memento,
|
not_null<Window::SectionMemento*> memento,
|
||||||
|
|
|
@ -20,6 +20,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
*/
|
*/
|
||||||
#include "info/media/info_media_inner_widget.h"
|
#include "info/media/info_media_inner_widget.h"
|
||||||
|
|
||||||
|
#include "ui/widgets/labels.h"
|
||||||
|
|
||||||
namespace Info {
|
namespace Info {
|
||||||
namespace Media {
|
namespace Media {
|
||||||
|
|
||||||
|
@ -30,6 +32,16 @@ InnerWidget::InnerWidget(
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _peer(peer)
|
, _peer(peer)
|
||||||
, _type(type) {
|
, _type(type) {
|
||||||
|
auto text = qsl("Media Overview\n\n");
|
||||||
|
auto label = object_ptr<Ui::FlatLabel>(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(
|
void InnerWidget::visibleTopBottomUpdated(
|
||||||
|
@ -46,8 +58,7 @@ void InnerWidget::restoreState(not_null<Memento*> memento) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::resizeGetHeight(int newWidth) {
|
int InnerWidget::resizeGetHeight(int newWidth) {
|
||||||
auto rowsHeight = _rowsHeightFake;
|
return _rowsHeightFake;
|
||||||
return qMax(rowsHeight, _minHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Media
|
} // namespace Media
|
||||||
|
|
|
@ -41,11 +41,6 @@ public:
|
||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resizeToWidth(int newWidth, int minHeight) {
|
|
||||||
_minHeight = minHeight;
|
|
||||||
return RpWidget::resizeToWidth(newWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveState(not_null<Memento*> memento);
|
void saveState(not_null<Memento*> memento);
|
||||||
void restoreState(not_null<Memento*> memento);
|
void restoreState(not_null<Memento*> memento);
|
||||||
|
|
||||||
|
@ -62,7 +57,6 @@ private:
|
||||||
int _rowsHeightFake = 0;
|
int _rowsHeightFake = 0;
|
||||||
int _visibleTop = 0;
|
int _visibleTop = 0;
|
||||||
int _visibleBottom = 0;
|
int _visibleBottom = 0;
|
||||||
int _minHeight = 0;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,16 @@ SectionWithToggle *SectionWithToggle::setToggleShown(
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SectionWithToggle::toggle(bool toggled) {
|
||||||
|
if (_toggle) {
|
||||||
|
_toggle->setChecked(toggled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SectionWithToggle::toggled() const {
|
||||||
|
return _toggle ? _toggle->checked() : false;
|
||||||
|
}
|
||||||
|
|
||||||
rpl::producer<bool> SectionWithToggle::toggledValue() const {
|
rpl::producer<bool> SectionWithToggle::toggledValue() const {
|
||||||
if (_toggle) {
|
if (_toggle) {
|
||||||
return rpl::single(_toggle->checked())
|
return rpl::single(_toggle->checked())
|
||||||
|
|
|
@ -45,6 +45,8 @@ public:
|
||||||
using FixedHeightWidget::FixedHeightWidget;
|
using FixedHeightWidget::FixedHeightWidget;
|
||||||
|
|
||||||
SectionWithToggle *setToggleShown(rpl::producer<bool> &&shown);
|
SectionWithToggle *setToggleShown(rpl::producer<bool> &&shown);
|
||||||
|
void toggle(bool toggled);
|
||||||
|
bool toggled() const;
|
||||||
rpl::producer<bool> toggledValue() const;
|
rpl::producer<bool> toggledValue() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
#include <rpl/combine.h>
|
#include <rpl/combine.h>
|
||||||
#include <rpl/flatten_latest.h>
|
#include <rpl/flatten_latest.h>
|
||||||
|
#include "info/info_memento.h"
|
||||||
#include "info/profile/info_profile_button.h"
|
#include "info/profile/info_profile_button.h"
|
||||||
#include "info/profile/info_profile_widget.h"
|
#include "info/profile/info_profile_widget.h"
|
||||||
#include "info/profile/info_profile_text.h"
|
#include "info/profile/info_profile_text.h"
|
||||||
|
@ -64,7 +65,7 @@ InnerWidget::InnerWidget(
|
||||||
, _content(setupContent(this, std::move(wrapValue))) {
|
, _content(setupContent(this, std::move(wrapValue))) {
|
||||||
_content->heightValue()
|
_content->heightValue()
|
||||||
| rpl::start_with_next([this](int height) {
|
| rpl::start_with_next([this](int height) {
|
||||||
TWidget::resizeToWidth(width());
|
resizeToWidth(width());
|
||||||
_desiredHeight.fire(countDesiredHeight());
|
_desiredHeight.fire(countDesiredHeight());
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
@ -83,18 +84,17 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
|
||||||
RpWidget *parent,
|
RpWidget *parent,
|
||||||
rpl::producer<Wrap> &&wrapValue) {
|
rpl::producer<Wrap> &&wrapValue) {
|
||||||
auto result = object_ptr<Ui::VerticalLayout>(parent);
|
auto result = object_ptr<Ui::VerticalLayout>(parent);
|
||||||
auto cover = result->add(object_ptr<Cover>(
|
_cover = result->add(object_ptr<Cover>(
|
||||||
result,
|
result,
|
||||||
_peer)
|
_peer));
|
||||||
);
|
_cover->setOnlineCount(rpl::single(0));
|
||||||
cover->setOnlineCount(rpl::single(0));
|
|
||||||
auto details = setupDetails(parent);
|
auto details = setupDetails(parent);
|
||||||
if (canHideDetailsEver()) {
|
if (canHideDetailsEver()) {
|
||||||
cover->setToggleShown(canHideDetails());
|
_cover->setToggleShown(canHideDetails());
|
||||||
result->add(object_ptr<Ui::SlideWrap<>>(
|
_infoWrap = result->add(object_ptr<Ui::SlideWrap<>>(
|
||||||
result,
|
result,
|
||||||
std::move(details))
|
std::move(details))
|
||||||
)->toggleOn(cover->toggledValue());
|
)->toggleOn(_cover->toggledValue());
|
||||||
} else {
|
} else {
|
||||||
result->add(std::move(details));
|
result->add(std::move(details));
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ void InnerWidget::setupUserButtons(
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
|
object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
|
||||||
RpWidget *parent) const {
|
RpWidget *parent) {
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
|
|
||||||
auto content = object_ptr<Ui::VerticalLayout>(parent);
|
auto content = object_ptr<Ui::VerticalLayout>(parent);
|
||||||
|
@ -308,8 +308,9 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
|
||||||
[phrase = mediaText(type)](int count) {
|
[phrase = mediaText(type)](int count) {
|
||||||
return phrase(lt_count, count);
|
return phrase(lt_count, count);
|
||||||
}
|
}
|
||||||
)->entity()->addClickHandler([peer = _peer, type] {
|
)->entity()->addClickHandler([this, peer = _peer, type] {
|
||||||
SharedMediaShowOverview(type, App::history(peer));
|
_controller->showSection(
|
||||||
|
Info::Memento(peer->id, Section(type)));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
auto addCommonGroupsButton = [&](not_null<UserData*> user) {
|
auto addCommonGroupsButton = [&](not_null<UserData*> user) {
|
||||||
|
@ -343,13 +344,13 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
|
||||||
auto layout = result->entity();
|
auto layout = result->entity();
|
||||||
|
|
||||||
layout->add(object_ptr<BoxContentDivider>(result));
|
layout->add(object_ptr<BoxContentDivider>(result));
|
||||||
auto cover = layout->add(object_ptr<SharedMediaCover>(layout));
|
_sharedMediaCover = layout->add(object_ptr<SharedMediaCover>(layout));
|
||||||
if (canHideDetailsEver()) {
|
if (canHideDetailsEver()) {
|
||||||
cover->setToggleShown(canHideDetails());
|
_sharedMediaCover->setToggleShown(canHideDetails());
|
||||||
layout->add(object_ptr<Ui::SlideWrap<>>(
|
_sharedMediaWrap = layout->add(object_ptr<Ui::SlideWrap<>>(
|
||||||
layout,
|
layout,
|
||||||
std::move(content))
|
std::move(content))
|
||||||
)->toggleOn(cover->toggledValue());
|
)->toggleOn(_sharedMediaCover->toggledValue());
|
||||||
} else {
|
} else {
|
||||||
layout->add(std::move(content));
|
layout->add(std::move(content));
|
||||||
}
|
}
|
||||||
|
@ -483,15 +484,25 @@ void InnerWidget::visibleTopBottomUpdated(
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::saveState(not_null<Memento*> memento) {
|
void InnerWidget::saveState(not_null<Memento*> memento) {
|
||||||
|
memento->setInfoExpanded(_cover->toggled());
|
||||||
|
memento->setMediaExpanded(_sharedMediaCover->toggled());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::restoreState(not_null<Memento*> memento) {
|
void InnerWidget::restoreState(not_null<Memento*> memento) {
|
||||||
|
_cover->toggle(memento->infoExpanded());
|
||||||
|
if (_infoWrap) {
|
||||||
|
_infoWrap->finishAnimating();
|
||||||
|
}
|
||||||
|
_sharedMediaCover->toggle(memento->mediaExpanded());
|
||||||
|
if (_sharedMediaWrap) {
|
||||||
|
_sharedMediaWrap->finishAnimating();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::resizeGetHeight(int newWidth) {
|
int InnerWidget::resizeGetHeight(int newWidth) {
|
||||||
_content->resizeToWidth(newWidth);
|
_content->resizeToWidth(newWidth);
|
||||||
_content->moveToLeft(0, 0);
|
_content->moveToLeft(0, 0);
|
||||||
return qMax(_content->heightNoMargins(), _minHeight);
|
return _content->heightNoMargins();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Profile
|
} // namespace Profile
|
||||||
|
|
|
@ -42,6 +42,8 @@ namespace Profile {
|
||||||
|
|
||||||
class Memento;
|
class Memento;
|
||||||
class Members;
|
class Members;
|
||||||
|
class Cover;
|
||||||
|
class SharedMediaCover;
|
||||||
|
|
||||||
class InnerWidget final : public Ui::RpWidget {
|
class InnerWidget final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
|
@ -55,11 +57,6 @@ public:
|
||||||
return _peer;
|
return _peer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resizeToWidth(int newWidth, int minHeight) {
|
|
||||||
_minHeight = minHeight;
|
|
||||||
return RpWidget::resizeToWidth(newWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveState(not_null<Memento*> memento);
|
void saveState(not_null<Memento*> memento);
|
||||||
void restoreState(not_null<Memento*> memento);
|
void restoreState(not_null<Memento*> memento);
|
||||||
|
|
||||||
|
@ -82,7 +79,7 @@ private:
|
||||||
RpWidget *parent,
|
RpWidget *parent,
|
||||||
rpl::producer<Wrap> &&wrapValue);
|
rpl::producer<Wrap> &&wrapValue);
|
||||||
object_ptr<RpWidget> setupDetails(RpWidget *parent) const;
|
object_ptr<RpWidget> setupDetails(RpWidget *parent) const;
|
||||||
object_ptr<RpWidget> setupSharedMedia(RpWidget *parent) const;
|
object_ptr<RpWidget> setupSharedMedia(RpWidget *parent);
|
||||||
object_ptr<RpWidget> setupMuteToggle(RpWidget *parent) const;
|
object_ptr<RpWidget> setupMuteToggle(RpWidget *parent) const;
|
||||||
object_ptr<RpWidget> setupInfo(RpWidget *parent) const;
|
object_ptr<RpWidget> setupInfo(RpWidget *parent) const;
|
||||||
void setupUserButtons(
|
void setupUserButtons(
|
||||||
|
@ -104,9 +101,11 @@ private:
|
||||||
not_null<Window::Controller*> _controller;
|
not_null<Window::Controller*> _controller;
|
||||||
not_null<PeerData*> _peer;
|
not_null<PeerData*> _peer;
|
||||||
|
|
||||||
int _minHeight = 0;
|
|
||||||
|
|
||||||
Members *_members = nullptr;
|
Members *_members = nullptr;
|
||||||
|
Cover *_cover = nullptr;
|
||||||
|
Ui::SlideWrap<RpWidget> *_infoWrap = nullptr;
|
||||||
|
SharedMediaCover *_sharedMediaCover = nullptr;
|
||||||
|
Ui::SlideWrap<RpWidget> *_sharedMediaWrap = nullptr;
|
||||||
object_ptr<RpWidget> _content;
|
object_ptr<RpWidget> _content;
|
||||||
|
|
||||||
rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
|
rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
|
||||||
|
|
|
@ -43,15 +43,22 @@ public:
|
||||||
return Section(Section::Type::Profile);
|
return Section(Section::Type::Profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setScrollTop(int scrollTop) {
|
void setInfoExpanded(bool expanded) {
|
||||||
_scrollTop = scrollTop;
|
_infoExpanded = expanded;
|
||||||
}
|
}
|
||||||
int scrollTop() const {
|
bool infoExpanded() const {
|
||||||
return _scrollTop;
|
return _infoExpanded;
|
||||||
|
}
|
||||||
|
void setMediaExpanded(bool expanded) {
|
||||||
|
_mediaExpanded = expanded;
|
||||||
|
}
|
||||||
|
bool mediaExpanded() const {
|
||||||
|
return _mediaExpanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _scrollTop = 0;
|
bool _infoExpanded = false;
|
||||||
|
bool _mediaExpanded = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -449,7 +449,8 @@ void Widget::onScroll() {
|
||||||
_inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height());
|
_inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::showAnimatedHook() {
|
void Widget::showAnimatedHook(
|
||||||
|
const Window::SectionSlideParams ¶ms) {
|
||||||
_fixedBar->setAnimatingMode(true);
|
_fixedBar->setAnimatingMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
void showAnimatedHook() override;
|
void showAnimatedHook(
|
||||||
|
const Window::SectionSlideParams ¶ms) override;
|
||||||
void showFinishedHook() override;
|
void showFinishedHook() override;
|
||||||
void doSetInnerFocus() override;
|
void doSetInnerFocus() override;
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,8 @@ void Widget::onScroll() {
|
||||||
updateScrollState();
|
updateScrollState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::showAnimatedHook() {
|
void Widget::showAnimatedHook(
|
||||||
|
const Window::SectionSlideParams ¶ms) {
|
||||||
_fixedBar->setAnimatingMode(true);
|
_fixedBar->setAnimatingMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
void showAnimatedHook() override;
|
void showAnimatedHook(
|
||||||
|
const Window::SectionSlideParams ¶ms) override;
|
||||||
void showFinishedHook() override;
|
void showFinishedHook() override;
|
||||||
void doSetInnerFocus() override;
|
void doSetInnerFocus() override;
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ void SectionWidget::showAnimated(
|
||||||
showChildren();
|
showChildren();
|
||||||
auto myContentCache = grabForShowAnimation(params);
|
auto myContentCache = grabForShowAnimation(params);
|
||||||
hideChildren();
|
hideChildren();
|
||||||
showAnimatedHook();
|
showAnimatedHook(params);
|
||||||
|
|
||||||
_showAnimation = std::make_unique<SlideAnimation>();
|
_showAnimation = std::make_unique<SlideAnimation>();
|
||||||
_showAnimation->setDirection(direction);
|
_showAnimation->setDirection(direction);
|
||||||
|
@ -69,6 +69,7 @@ void SectionWidget::showAnimated(
|
||||||
params.oldContentCache,
|
params.oldContentCache,
|
||||||
myContentCache);
|
myContentCache);
|
||||||
_showAnimation->setTopBarShadow(params.withTopBarShadow);
|
_showAnimation->setTopBarShadow(params.withTopBarShadow);
|
||||||
|
_showAnimation->setWithFade(params.withFade);
|
||||||
_showAnimation->start();
|
_showAnimation->start();
|
||||||
|
|
||||||
show();
|
show();
|
||||||
|
|
|
@ -70,6 +70,8 @@ class SectionMemento;
|
||||||
struct SectionSlideParams {
|
struct SectionSlideParams {
|
||||||
QPixmap oldContentCache;
|
QPixmap oldContentCache;
|
||||||
bool withTopBarShadow = false;
|
bool withTopBarShadow = false;
|
||||||
|
bool withTabs = false;
|
||||||
|
bool withFade = false;
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return !oldContentCache.isNull();
|
return !oldContentCache.isNull();
|
||||||
|
@ -147,7 +149,8 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called after the hideChildren() call in showAnimated().
|
// Called after the hideChildren() call in showAnimated().
|
||||||
virtual void showAnimatedHook() {
|
virtual void showAnimatedHook(
|
||||||
|
const Window::SectionSlideParams ¶ms) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called after the showChildren() call in showFinished().
|
// Called after the showChildren() call in showFinished().
|
||||||
|
|
|
@ -45,7 +45,7 @@ struct SectionShow {
|
||||||
ClearStack,
|
ClearStack,
|
||||||
};
|
};
|
||||||
SectionShow(
|
SectionShow(
|
||||||
Way way = Way::ClearStack,
|
Way way = Way::Forward,
|
||||||
anim::type animated = anim::type::normal,
|
anim::type animated = anim::type::normal,
|
||||||
anim::activation activation = anim::activation::normal)
|
anim::activation activation = anim::activation::normal)
|
||||||
: way(way)
|
: way(way)
|
||||||
|
@ -127,26 +127,26 @@ public:
|
||||||
|
|
||||||
void showPeerHistory(
|
void showPeerHistory(
|
||||||
PeerId peerId,
|
PeerId peerId,
|
||||||
const SectionShow ¶ms = SectionShow(),
|
const SectionShow ¶ms = SectionShow::Way::ClearStack,
|
||||||
MsgId msgId = ShowAtUnreadMsgId);
|
MsgId msgId = ShowAtUnreadMsgId);
|
||||||
void showPeerHistory(
|
void showPeerHistory(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const SectionShow ¶ms = SectionShow(),
|
const SectionShow ¶ms = SectionShow::Way::ClearStack,
|
||||||
MsgId msgId = ShowAtUnreadMsgId);
|
MsgId msgId = ShowAtUnreadMsgId);
|
||||||
void showPeerHistory(
|
void showPeerHistory(
|
||||||
not_null<History*> history,
|
not_null<History*> history,
|
||||||
const SectionShow ¶ms = SectionShow(),
|
const SectionShow ¶ms = SectionShow::Way::ClearStack,
|
||||||
MsgId msgId = ShowAtUnreadMsgId);
|
MsgId msgId = ShowAtUnreadMsgId);
|
||||||
|
|
||||||
void showPeerInfo(
|
void showPeerInfo(
|
||||||
PeerId peerId,
|
PeerId peerId,
|
||||||
const SectionShow ¶ms = SectionShow::Way::Forward);
|
const SectionShow ¶ms = SectionShow());
|
||||||
void showPeerInfo(
|
void showPeerInfo(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const SectionShow ¶ms = SectionShow::Way::Forward);
|
const SectionShow ¶ms = SectionShow());
|
||||||
void showPeerInfo(
|
void showPeerInfo(
|
||||||
not_null<History*> history,
|
not_null<History*> history,
|
||||||
const SectionShow ¶ms = SectionShow::Way::Forward);
|
const SectionShow ¶ms = SectionShow());
|
||||||
|
|
||||||
void clearSectionStack(
|
void clearSectionStack(
|
||||||
const SectionShow ¶ms = SectionShow::Way::ClearStack) {
|
const SectionShow ¶ms = SectionShow::Way::ClearStack) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "window/window_slide_animation.h"
|
#include "window/window_slide_animation.h"
|
||||||
|
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
|
#include "styles/style_boxes.h"
|
||||||
|
|
||||||
namespace Window {
|
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".
|
// Animation callback can destroy "this", so we don't pass "ms".
|
||||||
auto progress = _animation.current((_direction == SlideDirection::FromLeft) ? 0. : 1.);
|
auto progress = _animation.current((_direction == SlideDirection::FromLeft) ? 0. : 1.);
|
||||||
auto coordUnder = anim::interpolate(0, -st::slideShift, progress);
|
if (_withFade) {
|
||||||
auto coordOver = anim::interpolate(_cacheOver.width() / cIntRetinaFactor(), 0, progress);
|
p.fillRect(update, st::boxBg);
|
||||||
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));
|
|
||||||
|
|
||||||
|
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) {
|
if (_topBarShadowEnabled) {
|
||||||
p.setOpacity(1);
|
p.setOpacity(1);
|
||||||
p.fillRect(0, st::topBarHeight, _cacheOver.width() / retina, st::lineWidth, st::shadowFg);
|
p.fillRect(0, st::topBarHeight, _cacheOver.width() / retina, st::lineWidth, st::shadowFg);
|
||||||
|
@ -60,6 +90,10 @@ void SlideAnimation::setTopBarShadow(bool enabled) {
|
||||||
_topBarShadowEnabled = enabled;
|
_topBarShadowEnabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SlideAnimation::setWithFade(bool withFade) {
|
||||||
|
_withFade = withFade;
|
||||||
|
}
|
||||||
|
|
||||||
void SlideAnimation::setRepaintCallback(RepaintCallback &&callback) {
|
void SlideAnimation::setRepaintCallback(RepaintCallback &&callback) {
|
||||||
_repaintCallback = std::move(callback);
|
_repaintCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
void setDirection(SlideDirection direction);
|
void setDirection(SlideDirection direction);
|
||||||
void setPixmaps(const QPixmap &oldContentCache, const QPixmap &newContentCache);
|
void setPixmaps(const QPixmap &oldContentCache, const QPixmap &newContentCache);
|
||||||
void setTopBarShadow(bool enabled);
|
void setTopBarShadow(bool enabled);
|
||||||
|
void setWithFade(bool withFade);
|
||||||
|
|
||||||
using RepaintCallback = base::lambda<void()>;
|
using RepaintCallback = base::lambda<void()>;
|
||||||
void setRepaintCallback(RepaintCallback &&callback);
|
void setRepaintCallback(RepaintCallback &&callback);
|
||||||
|
@ -52,6 +53,7 @@ private:
|
||||||
|
|
||||||
SlideDirection _direction = SlideDirection::FromRight;
|
SlideDirection _direction = SlideDirection::FromRight;
|
||||||
bool _topBarShadowEnabled = false;
|
bool _topBarShadowEnabled = false;
|
||||||
|
bool _withFade = false;
|
||||||
|
|
||||||
mutable Animation _animation;
|
mutable Animation _animation;
|
||||||
QPixmap _cacheUnder, _cacheOver;
|
QPixmap _cacheUnder, _cacheOver;
|
||||||
|
|
Loading…
Reference in New Issue