Change *[Fast|Animated] to anim::type in FadeWrap.

This commit is contained in:
John Preston 2017-09-30 22:20:40 +03:00
parent 0c4bda71fd
commit 83850d9b86
44 changed files with 201 additions and 224 deletions

View File

@ -120,16 +120,12 @@ void BoxContent::updateShadowsVisibility() {
if (!_scroll) return; if (!_scroll) return;
auto top = _scroll->scrollTop(); auto top = _scroll->scrollTop();
if (top > 0 || _innerTopSkip > 0) { _topShadow->toggle(
_topShadow->showAnimated(); (top > 0 || _innerTopSkip > 0),
} else { anim::type::normal);
_topShadow->hideAnimated(); _bottomShadow->toggle(
} (top < _scroll->scrollTopMax()),
if (top < _scroll->scrollTopMax()) { anim::type::normal);
_bottomShadow->showAnimated();
} else {
_bottomShadow->hideAnimated();
}
} }
void BoxContent::onScroll() { void BoxContent::onScroll() {
@ -165,11 +161,11 @@ void BoxContent::setInnerVisible(bool scrollAreaVisible) {
QPixmap BoxContent::grabInnerCache() { QPixmap BoxContent::grabInnerCache() {
auto isTopShadowVisible = !_topShadow->isHidden(); auto isTopShadowVisible = !_topShadow->isHidden();
auto isBottomShadowVisible = !_bottomShadow->isHidden(); auto isBottomShadowVisible = !_bottomShadow->isHidden();
if (isTopShadowVisible) _topShadow->hide(); if (isTopShadowVisible) _topShadow->setVisible(false);
if (isBottomShadowVisible) _bottomShadow->hide(); if (isBottomShadowVisible) _bottomShadow->setVisible(false);
auto result = myGrab(this, _scroll->geometry()); auto result = myGrab(this, _scroll->geometry());
if (isTopShadowVisible) _topShadow->show(); if (isTopShadowVisible) _topShadow->setVisible(true);
if (isBottomShadowVisible) _bottomShadow->show(); if (isBottomShadowVisible) _bottomShadow->setVisible(true);
return result; return result;
} }
@ -191,8 +187,12 @@ void BoxContent::updateScrollAreaGeometry() {
updateInnerVisibleTopBottom(); updateInnerVisibleTopBottom();
auto top = _scroll->scrollTop(); auto top = _scroll->scrollTop();
_topShadow->toggleFast(top > 0 || _innerTopSkip > 0); _topShadow->toggle(
_bottomShadow->toggleFast(top < _scroll->scrollTopMax()); (top > 0 || _innerTopSkip > 0),
anim::type::instant);
_bottomShadow->toggle(
(top < _scroll->scrollTopMax()),
anim::type::instant);
} }
} }

View File

@ -143,7 +143,7 @@ void AddContactBox::prepare() {
void AddContactBox::setInnerFocus() { void AddContactBox::setInnerFocus() {
if ((_first->getLastText().isEmpty() && _last->getLastText().isEmpty()) || !_phone->isEnabled()) { if ((_first->getLastText().isEmpty() && _last->getLastText().isEmpty()) || !_phone->isEnabled()) {
(_invertOrder ? _last : _first)->setFocusFast(); (_invertOrder ? _last : _first)->setFocusFast();
_phone->finishAnimations(); _phone->finishAnimating();
} else { } else {
_phone->setFocusFast(); _phone->setFocusFast();
} }

View File

@ -38,7 +38,7 @@ void createErrorLabel(
int x, int x,
int y) { int y) {
if (label) { if (label) {
label->hideAnimated(); label->hide(anim::type::normal);
auto context = label.data(); auto context = label.data();
App::CallDelayed( App::CallDelayed(
st::fadeWrapDuration, st::fadeWrapDuration,
@ -55,9 +55,9 @@ void createErrorLabel(
text, text,
Ui::FlatLabel::InitType::Simple, Ui::FlatLabel::InitType::Simple,
st::changePhoneError)); st::changePhoneError));
label->hideFast(); label->hide(anim::type::instant);
label->moveToLeft(x, y); label->moveToLeft(x, y);
label->showAnimated(); label->show(anim::type::normal);
} }
} }

View File

@ -169,7 +169,7 @@ void ConnectionBox::typeChanged(DBIConnectionType type) {
} }
if ((type == dbictHttpProxy) && !_portInput->getLastText().toInt()) { if ((type == dbictHttpProxy) && !_portInput->getLastText().toInt()) {
_portInput->setText(qsl("80")); _portInput->setText(qsl("80"));
_portInput->finishAnimations(); _portInput->finishAnimating();
} }
} }
update(); update();

View File

@ -283,7 +283,7 @@ void EditAdminBox::prepare() {
applyDependencies(nullptr); applyDependencies(nullptr);
for (auto &&checkbox : _checkboxes) { for (auto &&checkbox : _checkboxes) {
checkbox.second->finishAnimations(); checkbox.second->finishAnimating();
} }
resizeToContent(); resizeToContent();
@ -381,7 +381,7 @@ void EditRestrictedBox::prepare() {
applyDependencies(nullptr); applyDependencies(nullptr);
for (auto &&checkbox : _checkboxes) { for (auto &&checkbox : _checkboxes) {
checkbox.second->finishAnimations(); checkbox.second->finishAnimating();
} }
resizeToContent(); resizeToContent();

View File

@ -99,7 +99,7 @@ void PeerListBox::prepare() {
setDimensions(st::boxWideWidth, st::boxMaxListHeight); setDimensions(st::boxWideWidth, st::boxMaxListHeight);
if (_select) { if (_select) {
_select->finishAnimations(); _select->finishAnimating();
_scrollBottomFixed = true; _scrollBottomFixed = true;
onScrollToY(0); onScrollToY(0);
} }

View File

@ -1223,7 +1223,7 @@ void StickersBox::Inner::rebuildMegagroupSet() {
if (_megagroupSetInput.type() != mtpc_inputStickerSetID) { if (_megagroupSetInput.type() != mtpc_inputStickerSetID) {
if (_megagroupSelectedSet) { if (_megagroupSelectedSet) {
_megagroupSetField->setText(QString()); _megagroupSetField->setText(QString());
_megagroupSetField->finishAnimations(); _megagroupSetField->finishAnimating();
} }
_megagroupSelectedSet.reset(); _megagroupSelectedSet.reset();
_megagroupSelectedRemove.destroy(); _megagroupSelectedRemove.destroy();
@ -1249,7 +1249,7 @@ void StickersBox::Inner::rebuildMegagroupSet() {
auto installed = true, official = false, unread = false, archived = false, removed = false; auto installed = true, official = false, unread = false, archived = false, removed = false;
if (!_megagroupSelectedSet || _megagroupSelectedSet->id != it->id) { if (!_megagroupSelectedSet || _megagroupSelectedSet->id != it->id) {
_megagroupSetField->setText(it->shortName); _megagroupSetField->setText(it->shortName);
_megagroupSetField->finishAnimations(); _megagroupSetField->finishAnimating();
} }
_megagroupSelectedSet = std::make_unique<Row>(it->id, sticker, count, title, titleWidth, installed, official, unread, archived, removed, pixw, pixh); _megagroupSelectedSet = std::make_unique<Row>(it->id, sticker, count, title, titleWidth, installed, official, unread, archived, removed, pixw, pixh);
_itemsTop += st::lineWidth + _rowHeight; _itemsTop += st::lineWidth + _rowHeight;

View File

@ -341,8 +341,8 @@ void Panel::initControls() {
reinitControls(); reinitControls();
_decline->finishAnimations(); _decline->finishAnimating();
_cancel->finishAnimations(); _cancel->finishAnimating();
} }
void Panel::reinitControls() { void Panel::reinitControls() {
@ -397,7 +397,7 @@ void Panel::toggleOpacityAnimation(bool visible) {
} }
} }
void Panel::finishAnimation() { void Panel::finishAnimating() {
_animationCache = QPixmap(); _animationCache = QPixmap();
if (_call) { if (_call) {
if (!_visible) { if (!_visible) {
@ -413,8 +413,8 @@ void Panel::finishAnimation() {
void Panel::showControls() { void Panel::showControls() {
Expects(_call != nullptr); Expects(_call != nullptr);
showChildren(); showChildren();
_decline->setVisible(!_decline->isHiddenOrHiding()); _decline->setVisible(_decline->toggled());
_cancel->setVisible(!_cancel->isHiddenOrHiding()); _cancel->setVisible(_cancel->toggled());
} }
void Panel::destroyDelayed() { void Panel::destroyDelayed() {
@ -607,7 +607,7 @@ void Panel::paintEvent(QPaintEvent *e) {
if (!_animationCache.isNull()) { if (!_animationCache.isNull()) {
auto opacity = _opacityAnimation.current(getms(), _call ? 1. : 0.); auto opacity = _opacityAnimation.current(getms(), _call ? 1. : 0.);
if (!_opacityAnimation.animating()) { if (!_opacityAnimation.animating()) {
finishAnimation(); finishAnimating();
if (!_call || isHidden()) return; if (!_call || isHidden()) return;
} else { } else {
Platform::StartTranslucentPaint(p, e); Platform::StartTranslucentPaint(p, e);
@ -722,11 +722,11 @@ void Panel::stateChanged(State state) {
&& (state != State::FailedHangingUp) && (state != State::FailedHangingUp)
&& (state != State::Failed)) { && (state != State::Failed)) {
auto toggleButton = [this](auto &&button, bool visible) { auto toggleButton = [this](auto &&button, bool visible) {
if (isHidden()) { button->toggle(
button->toggleFast(visible); visible,
} else { isHidden()
button->toggleAnimated(visible); ? anim::type::instant
} : anim::type::normal);
}; };
auto incomingWaiting = _call->isIncomingWaiting(); auto incomingWaiting = _call->isIncomingWaiting();
if (incomingWaiting) { if (incomingWaiting) {
@ -734,7 +734,8 @@ void Panel::stateChanged(State state) {
} }
toggleButton(_decline, incomingWaiting); toggleButton(_decline, incomingWaiting);
toggleButton(_cancel, (state == State::Busy)); toggleButton(_cancel, (state == State::Busy));
auto hangupShown = _decline->isHiddenOrHiding() && _cancel->isHiddenOrHiding(); auto hangupShown = !_decline->toggled()
&& !_cancel->toggled();
if (_hangupShown != hangupShown) { if (_hangupShown != hangupShown) {
_hangupShown = hangupShown; _hangupShown = hangupShown;
_hangupShownProgress.start([this] { updateHangupGeometry(); }, _hangupShown ? 0. : 1., _hangupShown ? 1. : 0., st::callPanelDuration, anim::sineInOut); _hangupShownProgress.start([this] { updateHangupGeometry(); }, _hangupShown ? 0. : 1., _hangupShown ? 1. : 0., st::callPanelDuration, anim::sineInOut);

View File

@ -85,7 +85,7 @@ private:
void startDurationUpdateTimer(TimeMs currentDuration); void startDurationUpdateTimer(TimeMs currentDuration);
void fillFingerprint(); void fillFingerprint();
void toggleOpacityAnimation(bool visible); void toggleOpacityAnimation(bool visible);
void finishAnimation(); void finishAnimating();
void destroyDelayed(); void destroyDelayed();
Call *_call = nullptr; Call *_call = nullptr;

View File

@ -259,9 +259,9 @@ void DialogsWidget::showAnimated(Window::SlideDirection direction, const Window:
_mainMenuToggle->hide(); _mainMenuToggle->hide();
if (_forwardCancel) _forwardCancel->hide(); if (_forwardCancel) _forwardCancel->hide();
_filter->hide(); _filter->hide();
_cancelSearch->hideFast(); _cancelSearch->hide();
_jumpToDate->hideFast(); _jumpToDate->hide(anim::type::instant);
_chooseFromUser->hideFast(); _chooseFromUser->hide(anim::type::instant);
_lockUnlock->hide(); _lockUnlock->hide();
int delta = st::slideShift; int delta = st::slideShift;
@ -822,7 +822,7 @@ void DialogsWidget::onFilterUpdate(bool force) {
_peerSearchQuery = QString(); _peerSearchQuery = QString();
} }
if (!_chooseFromUser->isHiddenOrHiding() || _searchFromUser) { if (_chooseFromUser->toggled() || _searchFromUser) {
auto switchToChooseFrom = SwitchToChooseFromQuery(); auto switchToChooseFrom = SwitchToChooseFromQuery();
if (_lastFilterText != switchToChooseFrom if (_lastFilterText != switchToChooseFrom
&& switchToChooseFrom.startsWith(_lastFilterText) && switchToChooseFrom.startsWith(_lastFilterText)
@ -938,22 +938,17 @@ void DialogsWidget::updateLockUnlockVisibility() {
void DialogsWidget::updateJumpToDateVisibility(bool fast) { void DialogsWidget::updateJumpToDateVisibility(bool fast) {
if (_a_show.animating()) return; if (_a_show.animating()) return;
auto jumpToDateVisible = (_searchInPeer && _filter->getLastText().isEmpty()); _jumpToDate->toggle(
if (fast) { (_searchInPeer && _filter->getLastText().isEmpty()),
_jumpToDate->toggleFast(jumpToDateVisible); fast ? anim::type::instant : anim::type::normal);
} else {
_jumpToDate->toggleAnimated(jumpToDateVisible);
}
} }
void DialogsWidget::updateSearchFromVisibility(bool fast) { void DialogsWidget::updateSearchFromVisibility(bool fast) {
auto visible = _searchInPeer && (_searchInPeer->isChat() || _searchInPeer->isMegagroup()) && !_searchFromUser; auto visible = _searchInPeer && (_searchInPeer->isChat() || _searchInPeer->isMegagroup()) && !_searchFromUser;
auto changed = (visible == _chooseFromUser->isHiddenOrHiding()); auto changed = (visible == !_chooseFromUser->toggled());
if (fast) { _chooseFromUser->toggle(
_chooseFromUser->toggleFast(visible); visible,
} else { fast ? anim::type::instant : anim::type::normal);
_chooseFromUser->toggleAnimated(visible);
}
if (changed) { if (changed) {
auto margins = st::dialogsFilter.textMrg; auto margins = st::dialogsFilter.textMrg;
if (visible) { if (visible) {

View File

@ -43,7 +43,7 @@ public:
}; };
void setChecked(bool checked, NotifyAboutChange notify = NotifyAboutChange::Notify); void setChecked(bool checked, NotifyAboutChange notify = NotifyAboutChange::Notify);
void finishAnimations(); void finishAnimating();
QMargins getMargins() const override { QMargins getMargins() const override {
return _st.margin; return _st.margin;
@ -125,8 +125,8 @@ void UserCheckbox::paintEvent(QPaintEvent *e) {
p.drawTextLeft(statusLeft, statusTop, width(), _statusText); p.drawTextLeft(statusLeft, statusTop, width(), _statusText);
} }
void UserCheckbox::finishAnimations() { void UserCheckbox::finishAnimating() {
_check->finishAnimation(); _check->finishAnimating();
} }
int UserCheckbox::resizeGetHeight(int newWidth) { int UserCheckbox::resizeGetHeight(int newWidth) {

View File

@ -1656,7 +1656,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
onBotStart(); onBotStart();
_history->clearLocalDraft(); _history->clearLocalDraft();
applyDraft(); applyDraft();
_send->finishAnimation(); _send->finishAnimating();
} }
return; return;
} }
@ -1791,7 +1791,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
_history->takeLocalDraft(_migrated); _history->takeLocalDraft(_migrated);
} }
applyDraft(false); applyDraft(false);
_send->finishAnimation(); _send->finishAnimating();
_tabbedSelector->showMegagroupSet(_peer->asMegagroup()); _tabbedSelector->showMegagroupSet(_peer->asMegagroup());
@ -3005,7 +3005,7 @@ void HistoryWidget::doneShow() {
} }
} }
void HistoryWidget::finishAnimation() { void HistoryWidget::finishAnimating() {
if (!_a_show.animating()) return; if (!_a_show.animating()) return;
_a_show.finish(); _a_show.finish();
_topShadow->setVisible(_peer != nullptr); _topShadow->setVisible(_peer != nullptr);

View File

@ -250,7 +250,7 @@ public:
return peer() != nullptr; return peer() != nullptr;
} }
void showAnimated(Window::SlideDirection direction, const Window::SectionSlideParams &params); void showAnimated(Window::SlideDirection direction, const Window::SectionSlideParams &params);
void finishAnimation(); void finishAnimating();
void doneShow(); void doneShow();

View File

@ -173,9 +173,9 @@ void WrapWidget::finishShowContent() {
: _content->desiredShadowVisibility()); : _content->desiredShadowVisibility());
if (_topTabs) { if (_topTabs) {
_topTabs->finishAnimations(); _topTabs->finishAnimating();
} }
_topShadow->finishAnimations(); _topShadow->finishAnimating();
updateContentGeometry(); updateContentGeometry();
@ -219,14 +219,14 @@ object_ptr<Media::Widget> WrapWidget::createMediaWidget() {
} }
bool WrapWidget::hasTopBarShadow() const { bool WrapWidget::hasTopBarShadow() const {
return !_topShadow->isHiddenOrHiding(); return _topShadow->toggled();
} }
QPixmap WrapWidget::grabForShowAnimation( QPixmap WrapWidget::grabForShowAnimation(
const Window::SectionSlideParams &params) { const Window::SectionSlideParams &params) {
if (params.withTopBarShadow) _topShadow->hide(); if (params.withTopBarShadow) _topShadow->hide(anim::type::instant);
auto result = myGrab(this); auto result = myGrab(this);
if (params.withTopBarShadow) _topShadow->show(); if (params.withTopBarShadow) _topShadow->show(anim::type::instant);
return result; return result;
} }

View File

@ -59,7 +59,7 @@ Button *Button::toggleOn(rpl::producer<bool> &&toggled) {
| rpl::start_with_next([this](bool toggled) { | rpl::start_with_next([this](bool toggled) {
_toggle->setCheckedAnimated(toggled); _toggle->setCheckedAnimated(toggled);
}, lifetime()); }, lifetime());
_toggle->finishAnimation(); _toggle->finishAnimating();
return this; return this;
} }

View File

@ -68,7 +68,7 @@ object_ptr<Ui::SlideWrap<Ui::VerticalLayout>> CreateTextWithLabel(
layout, layout,
std::move(label), std::move(label),
st::infoLabel)); st::infoLabel));
result->finishAnimations(); result->finishAnimating();
return result; return result;
} }

View File

@ -84,7 +84,7 @@ void PhoneWidget::showPhoneError(base::lambda<QString()> textFactory) {
void PhoneWidget::hidePhoneError() { void PhoneWidget::hidePhoneError() {
hideError(); hideError();
if (_signup) { if (_signup) {
_signup->hideAnimated(); _signup->hide(anim::type::instant);
showDescription(); showDescription();
} }
} }
@ -99,10 +99,10 @@ void PhoneWidget::showSignup() {
_signup->entity()->setLink(2, MakeShared<LambdaClickHandler>([this] { _signup->entity()->setLink(2, MakeShared<LambdaClickHandler>([this] {
toSignUp(); toSignUp();
})); }));
_signup->hideFast(); _signup->hide(anim::type::instant);
updateSignupGeometry(); updateSignupGeometry();
} }
_signup->showAnimated(); _signup->show(anim::type::normal);
hideDescription(); hideDescription();
} }

View File

@ -71,7 +71,7 @@ Widget::Widget(QWidget *parent) : TWidget(parent)
getData()->country = country; getData()->country = country;
_back->entity()->setClickedCallback([this] { historyMove(Direction::Back); }); _back->entity()->setClickedCallback([this] { historyMove(Direction::Back); });
_back->hideFast(); _back->hide(anim::type::instant);
_next->setClickedCallback([this] { getStep()->submit(); }); _next->setClickedCallback([this] { getStep()->submit(); });
@ -84,7 +84,7 @@ Widget::Widget(QWidget *parent) : TWidget(parent)
subscribe(Lang::CurrentCloudManager().firstLanguageSuggestion(), [this] { createLanguageLink(); }); subscribe(Lang::CurrentCloudManager().firstLanguageSuggestion(), [this] { createLanguageLink(); });
createLanguageLink(); createLanguageLink();
if (_changeLanguage) _changeLanguage->finishAnimations(); if (_changeLanguage) _changeLanguage->finishAnimating();
subscribe(Lang::Current().updated(), [this] { refreshLang(); }); subscribe(Lang::Current().updated(), [this] { refreshLang(); });
@ -116,12 +116,11 @@ void Widget::createLanguageLink() {
_changeLanguage.create( _changeLanguage.create(
this, this,
object_ptr<Ui::LinkButton>(this, text)); object_ptr<Ui::LinkButton>(this, text));
_changeLanguage->show(); _changeLanguage->hide(anim::type::instant);
_changeLanguage->hideFast();
_changeLanguage->entity()->setClickedCallback([this, languageId] { _changeLanguage->entity()->setClickedCallback([this, languageId] {
Lang::CurrentCloudManager().switchToLanguage(languageId); Lang::CurrentCloudManager().switchToLanguage(languageId);
}); });
_changeLanguage->toggleAnimated(!_resetAccount); _changeLanguage->toggle(!_resetAccount, anim::type::normal);
updateControlsGeometry(); updateControlsGeometry();
}; };
@ -151,7 +150,9 @@ void Widget::onCheckUpdateStatus() {
this, this,
langFactory(lng_menu_update), langFactory(lng_menu_update),
st::defaultBoxButton)); st::defaultBoxButton));
if (!_a_show.animating()) _update->show(); if (!_a_show.animating()) {
_update->setVisible(true);
}
_update->entity()->setClickedCallback([] { _update->entity()->setClickedCallback([] {
checkReadyUpdate(); checkReadyUpdate();
App::restart(); App::restart();
@ -197,14 +198,14 @@ void Widget::historyMove(Direction direction) {
if (direction == Direction::Back || direction == Direction::Replace) { if (direction == Direction::Back || direction == Direction::Replace) {
delete base::take(wasStep); delete base::take(wasStep);
} }
_back->toggleAnimated(getStep()->hasBack()); _back->toggle(getStep()->hasBack(), anim::type::normal);
auto stepHasCover = getStep()->hasCover(); auto stepHasCover = getStep()->hasCover();
_settings->toggleAnimated(!stepHasCover); _settings->toggle(!stepHasCover, anim::type::normal);
if (_update) _update->toggleAnimated(!stepHasCover); if (_update) _update->toggle(!stepHasCover, anim::type::normal);
if (_changeLanguage) _changeLanguage->toggleAnimated(!_resetAccount); if (_changeLanguage) _changeLanguage->toggle(!_resetAccount, anim::type::normal);
_next->setText([this] { return getStep()->nextButtonText(); }); _next->setText([this] { return getStep()->nextButtonText(); });
if (_resetAccount) _resetAccount->hideAnimated(); if (_resetAccount) _resetAccount->hide(anim::type::normal);
getStep()->showAnimated(direction); getStep()->showAnimated(direction);
fixOrder(); fixOrder();
} }
@ -248,12 +249,12 @@ void Widget::showResetButton() {
_resetAccount.create( _resetAccount.create(
this, this,
std::move(entity)); std::move(entity));
_resetAccount->hideFast(); _resetAccount->hide(anim::type::instant);
_resetAccount->entity()->setClickedCallback([this] { resetAccount(); }); _resetAccount->entity()->setClickedCallback([this] { resetAccount(); });
updateControlsGeometry(); updateControlsGeometry();
} }
_resetAccount->showAnimated(); _resetAccount->show(anim::type::normal);
if (_changeLanguage) _changeLanguage->hideAnimated(); if (_changeLanguage) _changeLanguage->hide(anim::type::normal);
} }
void Widget::resetAccount() { void Widget::resetAccount() {
@ -313,19 +314,19 @@ void Widget::showControls() {
_next->show(); _next->show();
_next->setText([this] { return getStep()->nextButtonText(); }); _next->setText([this] { return getStep()->nextButtonText(); });
auto hasCover = getStep()->hasCover(); auto hasCover = getStep()->hasCover();
_settings->toggleFast(!hasCover); _settings->toggle(!hasCover, anim::type::instant);
if (_update) _update->toggleFast(!hasCover); if (_update) _update->toggle(!hasCover, anim::type::instant);
if (_changeLanguage) _changeLanguage->toggleFast(!_resetAccount); if (_changeLanguage) _changeLanguage->toggle(!_resetAccount, anim::type::instant);
_back->toggleFast(getStep()->hasBack()); _back->toggle(getStep()->hasBack(), anim::type::instant);
} }
void Widget::hideControls() { void Widget::hideControls() {
getStep()->hide(); getStep()->hide();
_next->hide(); _next->hide();
_settings->hideFast(); _settings->hide(anim::type::instant);
if (_update) _update->hideFast(); if (_update) _update->hide(anim::type::instant);
if (_changeLanguage) _changeLanguage->hideFast(); if (_changeLanguage) _changeLanguage->hide(anim::type::instant);
_back->hideFast(); _back->hide(anim::type::instant);
} }
void Widget::showAnimated(const QPixmap &bgAnimCache, bool back) { void Widget::showAnimated(const QPixmap &bgAnimCache, bool back) {
@ -604,11 +605,11 @@ void Widget::Step::fillSentCodeData(const MTPauth_SentCodeType &type) {
} }
void Widget::Step::showDescription() { void Widget::Step::showDescription() {
_description->showAnimated(); _description->show(anim::type::normal);
} }
void Widget::Step::hideDescription() { void Widget::Step::hideDescription() {
_description->hideAnimated(); _description->hide(anim::type::normal);
} }
void Widget::Step::paintContentSnapshot(Painter &p, const QPixmap &snapshot, float64 alpha, float64 howMuchHidden) { void Widget::Step::paintContentSnapshot(Painter &p, const QPixmap &snapshot, float64 alpha, float64 howMuchHidden) {
@ -712,7 +713,7 @@ void Widget::Step::showError(base::lambda<QString()> textFactory) {
void Widget::Step::refreshError() { void Widget::Step::refreshError() {
if (!_errorTextFactory) { if (!_errorTextFactory) {
if (_error) _error->hideAnimated(); if (_error) _error->hide(anim::type::normal);
} else { } else {
if (!_error) { if (!_error) {
_error.create( _error.create(
@ -722,11 +723,11 @@ void Widget::Step::refreshError() {
_errorCentered _errorCentered
? st::introErrorCentered ? st::introErrorCentered
: st::introError)); : st::introError));
_error->hideFast(); _error->hide(anim::type::instant);
} }
_error->entity()->setText(_errorTextFactory()); _error->entity()->setText(_errorTextFactory());
updateLabelsPosition(); updateLabelsPosition();
_error->showAnimated(); _error->show(anim::type::normal);
} }
} }
@ -827,9 +828,9 @@ bool Widget::Step::hasBack() const {
void Widget::Step::activate() { void Widget::Step::activate() {
_title->show(); _title->show();
_description->show(); _description->show(anim::type::instant);
if (_errorTextFactory) { if (_errorTextFactory) {
_error->showFast(); _error->show(anim::type::instant);
} }
} }

View File

@ -2752,7 +2752,7 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool
} else { } else {
_overview->fastShow(); _overview->fastShow();
} }
_history->finishAnimation(); _history->finishAnimating();
if (back) { if (back) {
clearBotStartToken(_history->peer()); clearBotStartToken(_history->peer());
} }
@ -3018,7 +3018,7 @@ void MainWidget::showNewSection(
} }
_mainSection = std::move(newMainSection); _mainSection = std::move(newMainSection);
updateControlsGeometry(); updateControlsGeometry();
_history->finishAnimation(); _history->finishAnimating();
_history->showHistory(0, 0); _history->showHistory(0, 0);
_history->hide(); _history->hide();
if (Adaptive::OneColumn()) _dialogs->hide(); if (Adaptive::OneColumn()) _dialogs->hide();

View File

@ -108,7 +108,7 @@ void PasscodeWidget::showAnimated(const QPixmap &bgAnimCache, bool back) {
showAll(); showAll();
setInnerFocus(); setInnerFocus();
_passcode->finishAnimations(); _passcode->finishAnimating();
(_showBack ? _cacheUnder : _cacheOver) = myGrab(this); (_showBack ? _cacheUnder : _cacheOver) = myGrab(this);
hideAll(); hideAll();

View File

@ -54,7 +54,7 @@ SettingsWidget::SettingsWidget(QWidget *parent, PeerData *peer) : BlockWidget(pa
})); }));
refreshButtons(); refreshButtons();
_enableNotifications->finishAnimations(); _enableNotifications->finishAnimating();
show(); show();
} }

View File

@ -39,7 +39,7 @@ Widget::Widget(QWidget *parent, not_null<Window::Controller*> controller, PeerDa
_fixedBar->resizeToWidth(width()); _fixedBar->resizeToWidth(width());
_fixedBar->show(); _fixedBar->show();
_fixedBarShadow->hideFast(); _fixedBarShadow->hide(anim::type::instant);
_fixedBarShadow->raise(); _fixedBarShadow->raise();
updateAdaptiveLayout(); updateAdaptiveLayout();
subscribe(Adaptive::Changed(), [this]() { updateAdaptiveLayout(); }); subscribe(Adaptive::Changed(), [this]() { updateAdaptiveLayout(); });
@ -65,9 +65,9 @@ bool Widget::hasTopBarShadow() const {
} }
QPixmap Widget::grabForShowAnimation(const Window::SectionSlideParams &params) { QPixmap Widget::grabForShowAnimation(const Window::SectionSlideParams &params) {
if (params.withTopBarShadow || !_scroll->scrollTop()) _fixedBarShadow->hide(); if (params.withTopBarShadow || !_scroll->scrollTop()) _fixedBarShadow->hide(anim::type::instant);
auto result = myGrab(this); auto result = myGrab(this);
if (params.withTopBarShadow) _fixedBarShadow->show(); if (params.withTopBarShadow) _fixedBarShadow->show(anim::type::instant);
return result; return result;
} }
@ -107,7 +107,7 @@ void Widget::restoreState(not_null<SectionMemento*> memento) {
auto scrollTop = memento->getScrollTop(); auto scrollTop = memento->getScrollTop();
_scroll->scrollToY(scrollTop); _scroll->scrollToY(scrollTop);
updateScrollState(); updateScrollState();
_fixedBarShadow->finishAnimations(); _fixedBarShadow->finishAnimating();
} }
void Widget::resizeEvent(QResizeEvent *e) { void Widget::resizeEvent(QResizeEvent *e) {
@ -136,11 +136,7 @@ void Widget::resizeEvent(QResizeEvent *e) {
void Widget::updateScrollState() { void Widget::updateScrollState() {
auto scrollTop = _scroll->scrollTop(); auto scrollTop = _scroll->scrollTop();
_inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height()); _inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height());
if (scrollTop > 0) { _fixedBarShadow->toggle(scrollTop > 0, anim::type::normal);
_fixedBarShadow->showAnimated();
} else {
_fixedBarShadow->hideAnimated();
}
} }
void Widget::onScroll() { void Widget::onScroll() {
@ -154,7 +150,7 @@ void Widget::showAnimatedHook() {
void Widget::showFinishedHook() { void Widget::showFinishedHook() {
_fixedBar->setAnimatingMode(false); _fixedBar->setAnimatingMode(false);
if (!_scroll->scrollTop()) { if (!_scroll->scrollTop()) {
_fixedBarShadow->hide(); _fixedBarShadow->hide(anim::type::instant);
} }
_inner->showFinished(); _inner->showFinished();
} }

View File

@ -20,6 +20,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/ */
#include "settings/settings_layer.h" #include "settings/settings_layer.h"
#include <rpl/mappers.h>
#include "settings/settings_inner_widget.h" #include "settings/settings_inner_widget.h"
#include "settings/settings_fixed_bar.h" #include "settings/settings_fixed_bar.h"
#include "styles/style_settings.h" #include "styles/style_settings.h"
@ -48,15 +49,12 @@ Layer::Layer()
_fixedBarClose->moveToRight(0, 0); _fixedBarClose->moveToRight(0, 0);
_fixedBarShadow->entity()->resize(width(), st::lineWidth); _fixedBarShadow->entity()->resize(width(), st::lineWidth);
_fixedBarShadow->moveToLeft(0, _fixedBar->y() + _fixedBar->height()); _fixedBarShadow->moveToLeft(0, _fixedBar->y() + _fixedBar->height());
_fixedBarShadow->hideFast(); _fixedBarShadow->hide(anim::type::instant);
_scroll->moveToLeft(0, st::settingsFixedBarHeight); _scroll->moveToLeft(0, st::settingsFixedBarHeight);
_scroll->scrollTopValue() using namespace rpl::mappers;
| rpl::map([](int scrollTop) { return scrollTop > 0; }) _fixedBarShadow->toggleOn(_scroll->scrollTopValue()
| rpl::distinct_until_changed() | rpl::map($1 > 0));
| rpl::start_with_next([this](bool scrolled) {
_fixedBarShadow->toggleAnimated(scrolled);
}, lifetime());
} }
void Layer::setCloseClickHandler(base::lambda<void()> callback) { void Layer::setCloseClickHandler(base::lambda<void()> callback) {

View File

@ -182,7 +182,7 @@ void SendButton::setRecordActive(bool recordActive) {
} }
} }
void SendButton::finishAnimation() { void SendButton::finishAnimating() {
_a_typeChanged.finish(); _a_typeChanged.finish();
_a_recordActive.finish(); _a_recordActive.finish();
update(); update();

View File

@ -98,7 +98,7 @@ public:
} }
void setType(Type state); void setType(Type state);
void setRecordActive(bool recordActive); void setRecordActive(bool recordActive);
void finishAnimation(); void finishAnimating();
void setRecordStartCallback(base::lambda<void()> callback) { void setRecordStartCallback(base::lambda<void()> callback) {
_recordStartCallback = std::move(callback); _recordStartCallback = std::move(callback);

View File

@ -201,7 +201,7 @@ public:
} }
void setText(const QString &text, int value); void setText(const QString &text, int value);
void stepAnimation(TimeMs ms); void stepAnimation(TimeMs ms);
void finishAnimation(); void finishAnimating();
void paint(Painter &p, int x, int y, int outerWidth); void paint(Painter &p, int x, int y, int outerWidth);
int countWidth() const; int countWidth() const;
@ -312,7 +312,7 @@ void RoundButton::Numbers::stepAnimation(TimeMs ms) {
_a_ready.step(ms); _a_ready.step(ms);
} }
void RoundButton::Numbers::finishAnimation() { void RoundButton::Numbers::finishAnimating() {
auto width = countWidth(); auto width = countWidth();
_a_ready.finish(); _a_ready.finish();
if (_widthChangedCallback && countWidth() != width) { if (_widthChangedCallback && countWidth() != width) {
@ -398,7 +398,7 @@ void RoundButton::stepNumbersAnimation(TimeMs ms) {
void RoundButton::finishNumbersAnimation() { void RoundButton::finishNumbersAnimation() {
if (_numbers) { if (_numbers) {
_numbers->finishAnimation(); _numbers->finishAnimating();
} }
} }

View File

@ -43,7 +43,7 @@ AbstractCheckView::AbstractCheckView(int duration, bool checked, base::lambda<vo
void AbstractCheckView::setCheckedFast(bool checked) { void AbstractCheckView::setCheckedFast(bool checked) {
_checked = checked; _checked = checked;
finishAnimation(); finishAnimating();
if (_updateCallback) { if (_updateCallback) {
_updateCallback(); _updateCallback();
} }
@ -63,7 +63,7 @@ void AbstractCheckView::setCheckedAnimated(bool checked) {
} }
} }
void AbstractCheckView::finishAnimation() { void AbstractCheckView::finishAnimating() {
_toggleAnimation.finish(); _toggleAnimation.finish();
} }
@ -372,8 +372,8 @@ void Checkbox::setChecked(bool checked, NotifyAboutChange notify) {
} }
} }
void Checkbox::finishAnimations() { void Checkbox::finishAnimating() {
_check->finishAnimation(); _check->finishAnimating();
} }
int Checkbox::naturalWidth() const { int Checkbox::naturalWidth() const {
@ -462,7 +462,7 @@ void Checkbox::onStateChanged(State was, StateChangeSource source) {
if (isDisabled() && !(was & StateFlag::Disabled)) { if (isDisabled() && !(was & StateFlag::Disabled)) {
setCursor(style::cur_default); setCursor(style::cur_default);
finishAnimations(); finishAnimating();
_checkCache = grabCheckCache(); _checkCache = grabCheckCache();
} else if (!isDisabled() && (was & StateFlag::Disabled)) { } else if (!isDisabled() && (was & StateFlag::Disabled)) {
setCursor(style::cur_pointer); setCursor(style::cur_pointer);

View File

@ -32,7 +32,7 @@ public:
void setCheckedFast(bool checked); void setCheckedFast(bool checked);
void setCheckedAnimated(bool checked); void setCheckedAnimated(bool checked);
void finishAnimation(); void finishAnimating();
void setUpdateCallback(base::lambda<void()> updateCallback); void setUpdateCallback(base::lambda<void()> updateCallback);
bool checked() const { bool checked() const {
return _checked; return _checked;
@ -140,7 +140,7 @@ public:
void setChecked(bool checked, NotifyAboutChange notify = NotifyAboutChange::Notify); void setChecked(bool checked, NotifyAboutChange notify = NotifyAboutChange::Notify);
base::Observable<bool> checkedChanged; base::Observable<bool> checkedChanged;
void finishAnimations(); void finishAnimating();
QMargins getMargins() const override { QMargins getMargins() const override {
return _st.margin; return _st.margin;

View File

@ -56,10 +56,10 @@ void DiscreteSlider::timerEvent(QTimerEvent *e) {
void DiscreteSlider::setActiveSectionFast(int index) { void DiscreteSlider::setActiveSectionFast(int index) {
setActiveSection(index); setActiveSection(index);
finishAnimations(); finishAnimating();
} }
void DiscreteSlider::finishAnimations() { void DiscreteSlider::finishAnimating() {
_a_left.finish(); _a_left.finish();
update(); update();
} }

View File

@ -39,7 +39,7 @@ public:
} }
void setActiveSection(int index); void setActiveSection(int index);
void setActiveSectionFast(int index); void setActiveSectionFast(int index);
void finishAnimations(); void finishAnimating();
auto sectionActivated() const { auto sectionActivated() const {
return _sectionActivated.events(); return _sectionActivated.events();

View File

@ -79,7 +79,7 @@ void InnerDropdown::resizeToContent() {
if (newWidth != width() || newHeight != height()) { if (newWidth != width() || newHeight != height()) {
resize(newWidth, newHeight); resize(newWidth, newHeight);
update(); update();
finishAnimations(); finishAnimating();
} }
} }
@ -194,7 +194,7 @@ void InnerDropdown::hideAnimated(HideOption option) {
startOpacityAnimation(true); startOpacityAnimation(true);
} }
void InnerDropdown::finishAnimations() { void InnerDropdown::finishAnimating() {
if (_a_show.animating()) { if (_a_show.animating()) {
_a_show.finish(); _a_show.finish();
showAnimationCallback(); showAnimationCallback();
@ -211,7 +211,7 @@ void InnerDropdown::finishAnimations() {
void InnerDropdown::showFast() { void InnerDropdown::showFast() {
_hideTimer.stop(); _hideTimer.stop();
finishAnimations(); finishAnimating();
if (isHidden()) { if (isHidden()) {
showChildren(); showChildren();
show(); show();
@ -223,7 +223,7 @@ void InnerDropdown::hideFast() {
if (isHidden()) return; if (isHidden()) return;
_hideTimer.stop(); _hideTimer.stop();
finishAnimations(); finishAnimating();
_hiding = false; _hiding = false;
hideFinished(); hideFinished();
} }

View File

@ -76,7 +76,7 @@ public:
void setOrigin(PanelAnimation::Origin origin); void setOrigin(PanelAnimation::Origin origin);
void showAnimated(PanelAnimation::Origin origin); void showAnimated(PanelAnimation::Origin origin);
void hideAnimated(HideOption option = HideOption::Default); void hideAnimated(HideOption option = HideOption::Default);
void finishAnimations(); void finishAnimating();
void showFast(); void showFast();
void hideFast(); void hideFast();

View File

@ -1796,7 +1796,7 @@ InputArea::InputArea(QWidget *parent, const style::InputField &st, base::lambda<
startBorderAnimation(); startBorderAnimation();
startPlaceholderAnimation(); startPlaceholderAnimation();
finishAnimations(); finishAnimating();
} }
void InputArea::updatePalette() { void InputArea::updatePalette() {
@ -2344,10 +2344,10 @@ void InputArea::onRedoAvailable(bool avail) {
void InputArea::setDisplayFocused(bool focused) { void InputArea::setDisplayFocused(bool focused) {
setFocused(focused); setFocused(focused);
finishAnimations(); finishAnimating();
} }
void InputArea::finishAnimations() { void InputArea::finishAnimating() {
_a_focused.finish(); _a_focused.finish();
_a_error.finish(); _a_error.finish();
_a_placeholderShifted.finish(); _a_placeholderShifted.finish();
@ -2554,7 +2554,7 @@ InputField::InputField(QWidget *parent, const style::InputField &st, base::lambd
startPlaceholderAnimation(); startPlaceholderAnimation();
startBorderAnimation(); startBorderAnimation();
finishAnimations(); finishAnimating();
} }
void InputField::updatePalette() { void InputField::updatePalette() {
@ -3115,10 +3115,10 @@ void InputField::selectAll() {
void InputField::setDisplayFocused(bool focused) { void InputField::setDisplayFocused(bool focused) {
setFocused(focused); setFocused(focused);
finishAnimations(); finishAnimating();
} }
void InputField::finishAnimations() { void InputField::finishAnimating() {
_a_focused.finish(); _a_focused.finish();
_a_error.finish(); _a_error.finish();
_a_placeholderShifted.finish(); _a_placeholderShifted.finish();
@ -3304,7 +3304,7 @@ MaskedInputField::MaskedInputField(QWidget *parent, const style::InputField &st,
startPlaceholderAnimation(); startPlaceholderAnimation();
startBorderAnimation(); startBorderAnimation();
finishAnimations(); finishAnimating();
} }
void MaskedInputField::updatePalette() { void MaskedInputField::updatePalette() {
@ -3579,10 +3579,10 @@ QSize MaskedInputField::minimumSizeHint() const {
void MaskedInputField::setDisplayFocused(bool focused) { void MaskedInputField::setDisplayFocused(bool focused) {
setFocused(focused); setFocused(focused);
finishAnimations(); finishAnimating();
} }
void MaskedInputField::finishAnimations() { void MaskedInputField::finishAnimating() {
_a_focused.finish(); _a_focused.finish();
_a_error.finish(); _a_error.finish();
_a_placeholderShifted.finish(); _a_placeholderShifted.finish();

View File

@ -333,7 +333,7 @@ public:
} }
void setPlaceholder(base::lambda<QString()> placeholderFactory); void setPlaceholder(base::lambda<QString()> placeholderFactory);
void setDisplayFocused(bool focused); void setDisplayFocused(bool focused);
void finishAnimations(); void finishAnimating();
void setFocusFast() { void setFocusFast() {
setDisplayFocused(true); setDisplayFocused(true);
setFocus(); setFocus();
@ -513,7 +513,7 @@ public:
void setPlaceholder(base::lambda<QString()> placeholderFactory); void setPlaceholder(base::lambda<QString()> placeholderFactory);
void setPlaceholderHidden(bool forcePlaceholderHidden); void setPlaceholderHidden(bool forcePlaceholderHidden);
void setDisplayFocused(bool focused); void setDisplayFocused(bool focused);
void finishAnimations(); void finishAnimating();
void setFocusFast() { void setFocusFast() {
setDisplayFocused(true); setDisplayFocused(true);
setFocus(); setFocus();
@ -699,7 +699,7 @@ public:
void setPlaceholder(base::lambda<QString()> placeholderFactory); void setPlaceholder(base::lambda<QString()> placeholderFactory);
void setPlaceholderHidden(bool forcePlaceholderHidden); void setPlaceholderHidden(bool forcePlaceholderHidden);
void setDisplayFocused(bool focused); void setDisplayFocused(bool focused);
void finishAnimations(); void finishAnimating();
void setFocusFast() { void setFocusFast() {
setDisplayFocused(true); setDisplayFocused(true);
setFocus(); setFocus();

View File

@ -112,13 +112,13 @@ void Menu::clearActions() {
} }
} }
void Menu::finishAnimations() { void Menu::finishAnimating() {
for (auto &data : _actionsData) { for (auto &data : _actionsData) {
if (data.ripple) { if (data.ripple) {
data.ripple.reset(); data.ripple.reset();
} }
if (data.toggle) { if (data.toggle) {
data.toggle->finishAnimation(); data.toggle->finishAnimating();
} }
} }
} }

View File

@ -38,7 +38,7 @@ public:
QAction *addAction(const QString &text, base::lambda<void()> callback, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr); QAction *addAction(const QString &text, base::lambda<void()> callback, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr);
QAction *addSeparator(); QAction *addSeparator();
void clearActions(); void clearActions();
void finishAnimations(); void finishAnimating();
void clearSelection(); void clearSelection();

View File

@ -647,7 +647,7 @@ void MultiSelect::Inner::finishItemsBunch(AddItemWay way) {
if (way != AddItemWay::SkipAnimation) { if (way != AddItemWay::SkipAnimation) {
_items.back()->showAnimated(); _items.back()->showAnimated();
} else { } else {
_field->finishAnimations(); _field->finishAnimating();
finishHeightAnimation(); finishHeightAnimation();
} }
} }

View File

@ -38,34 +38,30 @@ FadeWrap<RpWidget> *FadeWrap<RpWidget>::setDuration(int duration) {
return this; return this;
} }
FadeWrap<RpWidget> *FadeWrap<RpWidget>::toggleAnimated( FadeWrap<RpWidget> *FadeWrap<RpWidget>::toggle(
bool shown) { bool shown,
anim::type animated) {
auto updated = (shown != _animation.visible()); auto updated = (shown != _animation.visible());
if (shown) { if (shown) {
_animation.fadeIn(_duration); if (animated == anim::type::normal) {
_animation.fadeIn(_duration);
} else {
_animation.show();
}
} else { } else {
_animation.fadeOut(_duration); if (animated == anim::type::normal) {
_animation.fadeOut(_duration);
} else {
_animation.hide();
}
} }
if (updated) { if (updated) {
_shownUpdated.fire_copy(shown); _toggledChanged.fire_copy(shown);
} }
return this; return this;
} }
FadeWrap<RpWidget> *FadeWrap<RpWidget>::toggleFast(bool shown) { FadeWrap<RpWidget> *FadeWrap<RpWidget>::finishAnimating() {
auto updated = (shown != _animation.visible());
if (shown) {
_animation.show();
} else {
_animation.hide();
}
if (updated) {
_shownUpdated.fire_copy(shown);
}
return this;
}
FadeWrap<RpWidget> *FadeWrap<RpWidget>::finishAnimations() {
_animation.finish(); _animation.finish();
return this; return this;
} }
@ -74,9 +70,9 @@ FadeWrap<RpWidget> *FadeWrap<RpWidget>::toggleOn(
rpl::producer<bool> &&shown) { rpl::producer<bool> &&shown) {
std::move(shown) std::move(shown)
| rpl::start_with_next([this](bool shown) { | rpl::start_with_next([this](bool shown) {
toggleAnimated(shown); toggle(shown, anim::type::normal);
}, lifetime()); }, lifetime());
finishAnimations(); finishAnimating();
return this; return this;
} }
@ -91,7 +87,7 @@ FadeShadow::FadeShadow(QWidget *parent)
FadeShadow::FadeShadow(QWidget *parent, style::color color) FadeShadow::FadeShadow(QWidget *parent, style::color color)
: Parent(parent, object_ptr<PlainShadow>(parent, color)) { : Parent(parent, object_ptr<PlainShadow>(parent, color)) {
hideFast(); hide(anim::type::instant);
} }
} // namespace Ui } // namespace Ui

View File

@ -45,25 +45,24 @@ public:
bool scaled); bool scaled);
FadeWrap *setDuration(int duration); FadeWrap *setDuration(int duration);
FadeWrap *toggleAnimated(bool shown); FadeWrap *toggle(bool shown, anim::type animated);
FadeWrap *toggleFast(bool shown); FadeWrap *show(anim::type animated) {
FadeWrap *showAnimated() { return toggleAnimated(true); } return toggle(true, animated);
FadeWrap *hideAnimated() { return toggleAnimated(false); } }
FadeWrap *showFast() { return toggleFast(true); } FadeWrap *hide(anim::type animated) {
FadeWrap *hideFast() { return toggleFast(false); } return toggle(false, animated);
FadeWrap *finishAnimations(); }
FadeWrap *finishAnimating();
FadeWrap *toggleOn(rpl::producer<bool> &&shown); FadeWrap *toggleOn(rpl::producer<bool> &&shown);
bool animating() const { bool animating() const {
return _animation.animating(); return _animation.animating();
} }
bool toggled() const {
bool isHiddenOrHiding() const { return _animation.visible();
return !_animation.visible();
} }
auto toggledValue() const {
auto shownValue() const { return _toggledChanged.events_starting_with(
return _shownUpdated.events_starting_with(
_animation.visible()); _animation.visible());
} }
@ -71,7 +70,7 @@ protected:
void paintEvent(QPaintEvent *e) final override; void paintEvent(QPaintEvent *e) final override;
private: private:
rpl::event_stream<bool> _shownUpdated; rpl::event_stream<bool> _toggledChanged;
FadeAnimation _animation; FadeAnimation _animation;
int _duration = 0; int _duration = 0;
@ -95,26 +94,17 @@ public:
FadeWrap *setDuration(int duration) { FadeWrap *setDuration(int duration) {
return chain(Parent::setDuration(duration)); return chain(Parent::setDuration(duration));
} }
FadeWrap *toggleAnimated(bool shown) { FadeWrap *toggle(bool shown, anim::type animated) {
return chain(Parent::toggleAnimated(shown)); return chain(Parent::toggle(shown, animated));
} }
FadeWrap *toggleFast(bool shown) { FadeWrap *show(anim::type animated) {
return chain(Parent::toggleFast(shown)); return chain(Parent::show(animated));
} }
FadeWrap *showAnimated() { FadeWrap *hide(anim::type animated) {
return chain(Parent::showAnimated()); return chain(Parent::hide(animated));
} }
FadeWrap *hideAnimated() { FadeWrap *finishAnimating() {
return chain(Parent::hideAnimated()); return chain(Parent::finishAnimating());
}
FadeWrap *showFast() {
return chain(Parent::showFast());
}
FadeWrap *hideFast() {
return chain(Parent::hideFast());
}
FadeWrap *finishAnimations() {
return chain(Parent::finishAnimations());
} }
FadeWrap *toggleOn(rpl::producer<bool> &&shown) { FadeWrap *toggleOn(rpl::producer<bool> &&shown) {
return chain(Parent::toggleOn(std::move(shown))); return chain(Parent::toggleOn(std::move(shown)));

View File

@ -72,11 +72,11 @@ SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleAnimated(
SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleFast(bool shown) { SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleFast(bool shown) {
setShown(shown); setShown(shown);
finishAnimations(); finishAnimating();
return this; return this;
} }
SlideWrap<RpWidget> *SlideWrap<RpWidget>::finishAnimations() { SlideWrap<RpWidget> *SlideWrap<RpWidget>::finishAnimating() {
_animation.finish(); _animation.finish();
animationStep(); animationStep();
return this; return this;
@ -88,7 +88,7 @@ SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleOn(
| rpl::start_with_next([this](bool shown) { | rpl::start_with_next([this](bool shown) {
toggleAnimated(shown); toggleAnimated(shown);
}, lifetime()); }, lifetime());
finishAnimations(); finishAnimating();
return this; return this;
} }

View File

@ -50,7 +50,7 @@ public:
SlideWrap *hideAnimated() { return toggleAnimated(false); } SlideWrap *hideAnimated() { return toggleAnimated(false); }
SlideWrap *showFast() { return toggleFast(true); } SlideWrap *showFast() { return toggleFast(true); }
SlideWrap *hideFast() { return toggleFast(false); } SlideWrap *hideFast() { return toggleFast(false); }
SlideWrap *finishAnimations(); SlideWrap *finishAnimating();
SlideWrap *toggleOn(rpl::producer<bool> &&shown); SlideWrap *toggleOn(rpl::producer<bool> &&shown);
bool animating() const { bool animating() const {
@ -125,8 +125,8 @@ public:
SlideWrap *hideFast() { SlideWrap *hideFast() {
return chain(Parent::hideFast()); return chain(Parent::hideFast());
} }
SlideWrap *finishAnimations() { SlideWrap *finishAnimating() {
return chain(Parent::finishAnimations()); return chain(Parent::finishAnimating());
} }
SlideWrap *toggleOn(rpl::producer<bool> &&shown) { SlideWrap *toggleOn(rpl::producer<bool> &&shown) {
return chain(Parent::toggleOn(std::move(shown))); return chain(Parent::toggleOn(std::move(shown)));

View File

@ -59,7 +59,7 @@ public:
void setCacheImages(QPixmap &&bodyCache, QPixmap &&mainMenuCache, QPixmap &&specialLayerCache, QPixmap &&layerCache); void setCacheImages(QPixmap &&bodyCache, QPixmap &&mainMenuCache, QPixmap &&specialLayerCache, QPixmap &&layerCache);
void startAnimation(Action action); void startAnimation(Action action);
void skipAnimation(Action action); void skipAnimation(Action action);
void finishAnimation(); void finishAnimating();
bool animating() const { bool animating() const {
return _a_mainMenuShown.animating() || _a_specialLayerShown.animating() || _a_layerShown.animating(); return _a_mainMenuShown.animating() || _a_specialLayerShown.animating() || _a_layerShown.animating();
@ -140,7 +140,7 @@ void LayerStackWidget::BackgroundWidget::startAnimation(Action action) {
void LayerStackWidget::BackgroundWidget::skipAnimation(Action action) { void LayerStackWidget::BackgroundWidget::skipAnimation(Action action) {
startAnimation(action); startAnimation(action);
finishAnimation(); finishAnimating();
} }
void LayerStackWidget::BackgroundWidget::checkIfDone() { void LayerStackWidget::BackgroundWidget::checkIfDone() {
@ -314,7 +314,7 @@ void LayerStackWidget::BackgroundWidget::paintEvent(QPaintEvent *e) {
} }
} }
void LayerStackWidget::BackgroundWidget::finishAnimation() { void LayerStackWidget::BackgroundWidget::finishAnimating() {
_a_shown.finish(); _a_shown.finish();
_a_mainMenuShown.finish(); _a_mainMenuShown.finish();
_a_specialLayerShown.finish(); _a_specialLayerShown.finish();
@ -484,8 +484,8 @@ void LayerStackWidget::updateLayerBoxes() {
update(); update();
} }
void LayerStackWidget::finishAnimation() { void LayerStackWidget::finishAnimating() {
_background->finishAnimation(); _background->finishAnimating();
} }
bool LayerStackWidget::canSetFocus() const { bool LayerStackWidget::canSetFocus() const {

View File

@ -92,7 +92,7 @@ public:
Controller *controller() const { Controller *controller() const {
return _controller; return _controller;
} }
void finishAnimation(); void finishAnimating();
void showBox( void showBox(
object_ptr<BoxContent> box, object_ptr<BoxContent> box,

View File

@ -123,7 +123,7 @@ void MainMenu::refreshMenu() {
*_nightThemeAction = action; *_nightThemeAction = action;
action->setCheckable(true); action->setCheckable(true);
action->setChecked(Window::Theme::IsNightTheme()); action->setChecked(Window::Theme::IsNightTheme());
_menu->finishAnimations(); _menu->finishAnimating();
} }
updatePhone(); updatePhone();