From f0ad78d808d3063c3e9444363a0f6f0a11261a19 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 1 Oct 2017 11:15:40 +0300 Subject: [PATCH] Change *[Fast|Animated] to anim::type in SlideWrap. --- .../SourceFiles/boxes/edit_privacy_box.cpp | 16 ++++-- Telegram/SourceFiles/boxes/peer_list_box.cpp | 8 +-- .../info/profile/info_profile_text.cpp | 4 +- .../info/profile/info_profile_values.cpp | 2 +- Telegram/SourceFiles/mainwidget.cpp | 30 +++++----- .../settings/settings_advanced_widget.cpp | 12 ++-- .../settings/settings_background_widget.cpp | 6 +- .../settings_chat_settings_widget.cpp | 6 +- .../settings/settings_general_widget.cpp | 10 ++-- .../settings/settings_info_widget.cpp | 2 +- .../settings_notifications_widget.cpp | 25 ++++++--- .../settings/settings_privacy_widget.cpp | 6 +- Telegram/SourceFiles/ui/wrap/fade_wrap.cpp | 4 +- Telegram/SourceFiles/ui/wrap/slide_wrap.cpp | 56 +++++++++---------- Telegram/SourceFiles/ui/wrap/slide_wrap.h | 53 +++++++----------- 15 files changed, 129 insertions(+), 111 deletions(-) diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index 709185e2d..dc530290b 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -316,13 +316,21 @@ void EditPrivacyBox::createWidgets() { _optionGroup->setChangedCallback([this](Option value) { _option = value; - _alwaysLink->toggleAnimated(showExceptionLink(Exception::Always)); - _neverLink->toggleAnimated(showExceptionLink(Exception::Never)); + _alwaysLink->toggle( + showExceptionLink(Exception::Always), + anim::type::normal); + _neverLink->toggle( + showExceptionLink(Exception::Never), + anim::type::normal); }); showChildren(); - _alwaysLink->toggleFast(showExceptionLink(Exception::Always)); - _neverLink->toggleFast(showExceptionLink(Exception::Never)); + _alwaysLink->toggle( + showExceptionLink(Exception::Always), + anim::type::instant); + _neverLink->toggle( + showExceptionLink(Exception::Never), + anim::type::instant); setDimensions(st::boxWideWidth, resizeGetHeight(st::boxWideWidth)); } diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 23ef3e5c1..732b30ad6 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -156,7 +156,7 @@ void PeerListBox::paintEvent(QPaintEvent *e) { } void PeerListBox::setInnerFocus() { - if (!_select || _select->isHiddenOrHiding()) { + if (!_select || !_select->toggled()) { content()->setFocus(); } else { _select->entity()->setInnerFocus(); @@ -191,10 +191,10 @@ void PeerListBox::peerListSetSearchMode(PeerListSearchMode mode) { auto selectVisible = (mode != PeerListSearchMode::Disabled); if (selectVisible && !_select) { createMultiSelect(); - _select->toggleFast(!selectVisible); + _select->toggle(!selectVisible, anim::type::instant); } if (_select) { - _select->toggleAnimated(selectVisible); + _select->toggle(selectVisible, anim::type::normal); _scrollBottomFixed = false; setInnerFocus(); } @@ -256,7 +256,7 @@ void PeerListController::setSearchNoResultsText(const QString &text) { void PeerListBox::addSelectItem(not_null peer, PeerListRow::SetStyle style) { if (!_select) { createMultiSelect(); - _select->toggleFast(false); + _select->hide(anim::type::instant); } if (style == PeerListRow::SetStyle::Fast) { _select->entity()->addItemInBunch(peer->id, peer->shortName(), st::activeButtonBg, PaintUserpicCallback(peer)); diff --git a/Telegram/SourceFiles/info/profile/info_profile_text.cpp b/Telegram/SourceFiles/info/profile/info_profile_text.cpp index 445e7761b..58b260d3c 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_text.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_text.cpp @@ -47,7 +47,7 @@ object_ptr> CreateTextWithLabel( | rpl::before_next([slide = result.data()]( const TextWithEntities &value) { if (value.text.isEmpty()) { - slide->hideAnimated(); + slide->hide(anim::type::normal); } }) | rpl::filter([](const TextWithEntities &value) { @@ -55,7 +55,7 @@ object_ptr> CreateTextWithLabel( }) | rpl::after_next([slide = result.data()]( const TextWithEntities &value) { - slide->showAnimated(); + slide->show(anim::type::normal); }); auto labeled = layout->add(object_ptr( layout, diff --git a/Telegram/SourceFiles/info/profile/info_profile_values.cpp b/Telegram/SourceFiles/info/profile/info_profile_values.cpp index 6bb33bd84..c3d8d1cab 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_values.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_values.cpp @@ -244,7 +244,7 @@ rpl::producer MultiLineTracker::atLeastOneShownValue() const { auto shown = std::vector>(); shown.reserve(_widgets.size()); for (auto &widget : _widgets) { - shown.push_back(widget->shownValue()); + shown.push_back(widget->toggledValue()); } return rpl::combine( std::move(shown), diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index f0edf6b42..e0833322d 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1793,7 +1793,7 @@ void MainWidget::switchToPanelPlayer() { if (_playerUsingPanel) return; _playerUsingPanel = true; - _player->hideAnimated(); + _player->hide(anim::type::normal); _playerVolume.destroyDelayed(); _playerPlaylist->hideIgnoringEnterEvents(); @@ -1807,7 +1807,7 @@ void MainWidget::switchToFixedPlayer() { if (!_player) { createPlayer(); } else { - _player->showAnimated(); + _player->show(anim::type::normal); if (!_playerVolume) { _playerVolume.create(this); _player->entity()->volumeWidgetCreated(_playerVolume); @@ -1824,7 +1824,7 @@ void MainWidget::closeBothPlayers() { _playerUsingPanel = false; _player.destroyDelayed(); } else { - _player->hideAnimated(); + _player->hide(anim::type::normal); } _playerVolume.destroyDelayed(); @@ -1852,16 +1852,16 @@ void MainWidget::createPlayer() { _player->entity()->volumeWidgetCreated(_playerVolume); orderWidgets(); if (_a_show.animating()) { - _player->showFast(); - _player->hide(); + _player->show(anim::type::instant); + _player->setVisible(false); Shortcuts::enableMediaShortcuts(); } else { - _player->hideFast(); + _player->hide(anim::type::instant); } } - if (_player && _player->isHiddenOrHiding()) { + if (_player && !_player->toggled()) { if (!_a_show.animating()) { - _player->showAnimated(); + _player->show(anim::type::normal); _playerHeight = _contentScrollAddToY = _player->contentHeight(); updateControlsGeometry(); Shortcuts::enableMediaShortcuts(); @@ -1910,11 +1910,11 @@ void MainWidget::createCallTopBar() { }, lifetime()); orderWidgets(); if (_a_show.animating()) { - _callTopBar->showFast(); - _callTopBar->hide(); + _callTopBar->show(anim::type::instant); + _callTopBar->setVisible(false); } else { - _callTopBar->hideFast(); - _callTopBar->showAnimated(); + _callTopBar->hide(anim::type::instant); + _callTopBar->show(anim::type::normal); _callTopBarHeight = _contentScrollAddToY = _callTopBar->height(); updateControlsGeometry(); } @@ -1922,7 +1922,7 @@ void MainWidget::createCallTopBar() { void MainWidget::destroyCallTopBar() { if (_callTopBar) { - _callTopBar->hideAnimated(); + _callTopBar->hide(anim::type::normal); } } @@ -3342,7 +3342,7 @@ void MainWidget::hideAll() { _thirdShadow->hide(); } if (_player) { - _player->hide(); + _player->setVisible(false); _playerHeight = 0; } for (auto &instance : _playerFloats) { @@ -3421,7 +3421,7 @@ void MainWidget::showAll() { } } if (_player) { - _player->show(); + _player->setVisible(true); _playerHeight = _player->contentHeight(); } updateControlsGeometry(); diff --git a/Telegram/SourceFiles/settings/settings_advanced_widget.cpp b/Telegram/SourceFiles/settings/settings_advanced_widget.cpp index 397b3f2e3..5ae476f4c 100644 --- a/Telegram/SourceFiles/settings/settings_advanced_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_advanced_widget.cpp @@ -76,11 +76,11 @@ void AdvancedWidget::createControls() { style::margins slidedPadding(0, marginLarge.bottom() / 2, 0, marginLarge.bottom() - (marginLarge.bottom() / 2)); createChildRow(_useDefaultTheme, marginLarge, slidedPadding, lang(lng_settings_bg_use_default), SLOT(onUseDefaultTheme())); if (!Window::Theme::IsNonDefaultUsed()) { - _useDefaultTheme->hideFast(); + _useDefaultTheme->hide(anim::type::instant); } createChildRow(_toggleNightTheme, marginLarge, slidedPadding, getNightThemeToggleText(), SLOT(onToggleNightTheme())); if (Window::Theme::IsNonDefaultUsed()) { - _toggleNightTheme->hideFast(); + _toggleNightTheme->hide(anim::type::instant); } } createChildRow(_telegramFAQ, marginLarge, lang(lng_settings_faq), SLOT(onTelegramFAQ())); @@ -92,9 +92,13 @@ void AdvancedWidget::createControls() { void AdvancedWidget::checkNonDefaultTheme() { if (self()) return; - _useDefaultTheme->toggleAnimated(Window::Theme::IsNonDefaultUsed()); + _useDefaultTheme->toggle( + Window::Theme::IsNonDefaultUsed(), + anim::type::normal); _toggleNightTheme->entity()->setText(getNightThemeToggleText()); - _toggleNightTheme->toggleAnimated(!Window::Theme::IsNonDefaultUsed()); + _toggleNightTheme->toggle( + !Window::Theme::IsNonDefaultUsed(), + anim::type::normal); } void AdvancedWidget::onManageLocalStorage() { diff --git a/Telegram/SourceFiles/settings/settings_background_widget.cpp b/Telegram/SourceFiles/settings/settings_background_widget.cpp index 5125e391b..74e3196ba 100644 --- a/Telegram/SourceFiles/settings/settings_background_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_background_widget.cpp @@ -208,7 +208,9 @@ BackgroundWidget::BackgroundWidget(QWidget *parent, UserData *self) : BlockWidge } }); subscribe(Adaptive::Changed(), [this]() { - _adaptive->toggleAnimated(Global::AdaptiveChatLayout() == Adaptive::ChatLayout::Wide); + _adaptive->toggle( + (Global::AdaptiveChatLayout() == Adaptive::ChatLayout::Wide), + anim::type::normal); }); } @@ -225,7 +227,7 @@ void BackgroundWidget::createControls() { createChildRow(_tile, margin, lang(lng_settings_bg_tile), [this](bool) { onTile(); }, Window::Theme::Background()->tile()); createChildRow(_adaptive, margin, slidedPadding, lang(lng_settings_adaptive_wide), [this](bool) { onAdaptive(); }, Global::AdaptiveForWide()); if (Global::AdaptiveChatLayout() != Adaptive::ChatLayout::Wide) { - _adaptive->hideFast(); + _adaptive->hide(anim::type::instant); } } diff --git a/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp b/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp index a69a298b2..9284b30f7 100644 --- a/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_chat_settings_widget.cpp @@ -166,7 +166,7 @@ void ChatSettingsWidget::createControls() { style::margins marginPath(st::defaultCheck.diameter + st::defaultBoxCheckbox.textPosition.x(), 0, 0, st::settingsSkip); createChildRow(_downloadPath, marginPath, slidedPadding); if (Global::AskDownloadPath()) { - _downloadPath->hideFast(); + _downloadPath->hide(anim::type::instant); } #endif // OS_WIN_STORE @@ -190,7 +190,9 @@ void ChatSettingsWidget::onDontAskDownloadPath() { Global::SetAskDownloadPath(!_dontAskDownloadPath->checked()); Local::writeUserSettings(); #ifndef OS_WIN_STORE - _downloadPath->toggleAnimated(_dontAskDownloadPath->checked()); + _downloadPath->toggle( + _dontAskDownloadPath->checked(), + anim::type::normal); #endif // OS_WIN_STORE } diff --git a/Telegram/SourceFiles/settings/settings_general_widget.cpp b/Telegram/SourceFiles/settings/settings_general_widget.cpp index 862752504..226ad4664 100644 --- a/Telegram/SourceFiles/settings/settings_general_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_general_widget.cpp @@ -180,7 +180,7 @@ void GeneralWidget::refreshControls() { createChildRow(_updateRow, marginLink, slidedPadding); connect(_updateRow->entity(), SIGNAL(restart()), this, SLOT(onRestart())); if (!cAutoUpdate()) { - _updateRow->hideFast(); + _updateRow->hide(anim::type::instant); } #endif // !TDESKTOP_DISABLE_AUTOUPDATE @@ -197,7 +197,7 @@ void GeneralWidget::refreshControls() { _startMinimized->entity()->setChecked(cStartMinimized() && !Global::LocalPasscode()); }); if (!cAutoStart()) { - _startMinimized->hideFast(); + _startMinimized->hide(anim::type::instant); } createChildRow(_addInSendTo, marginSmall, lang(lng_settings_add_sendto), [this](bool) { onAddInSendTo(); }, cSendToMenu()); #endif // OS_WIN_STORE @@ -234,7 +234,9 @@ void GeneralWidget::onRestart() { void GeneralWidget::onUpdateAutomatically() { cSetAutoUpdate(_updateAutomatically->checked()); Local::writeSettings(); - _updateRow->toggleAnimated(cAutoUpdate()); + _updateRow->toggle( + cAutoUpdate(), + anim::type::normal); if (cAutoUpdate()) { Sandbox::startUpdateCheck(); } else { @@ -282,7 +284,7 @@ void GeneralWidget::onAutoStart() { Local::writeSettings(); } } - _startMinimized->toggleAnimated(cAutoStart()); + _startMinimized->toggle(cAutoStart(), anim::type::normal); } void GeneralWidget::onStartMinimized() { diff --git a/Telegram/SourceFiles/settings/settings_info_widget.cpp b/Telegram/SourceFiles/settings/settings_info_widget.cpp index a99d1e7c3..7a633a58e 100644 --- a/Telegram/SourceFiles/settings/settings_info_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_info_widget.cpp @@ -143,7 +143,7 @@ void InfoWidget::setLabeledText( copyText, width()); } - row->toggleAnimated(nonEmptyText); + row->toggle(nonEmptyText, anim::type::normal); } InfoWidget::LabeledWidget::LabeledWidget(QWidget *parent, const style::FlatLabel &valueSt) : RpWidget(parent) diff --git a/Telegram/SourceFiles/settings/settings_notifications_widget.cpp b/Telegram/SourceFiles/settings/settings_notifications_widget.cpp index e8fa5256e..5af67a43c 100644 --- a/Telegram/SourceFiles/settings/settings_notifications_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications_widget.cpp @@ -60,11 +60,11 @@ void NotificationsWidget::createControls() { createChildRow(_showSenderName, margin, slidedPadding, lang(lng_settings_show_name), [this](bool) { onShowSenderName(); }, Global::NotifyView() <= dbinvShowName); createChildRow(_showMessagePreview, margin, slidedPadding, lang(lng_settings_show_preview), [this](bool) { onShowMessagePreview(); }, Global::NotifyView() <= dbinvShowPreview); if (!_showSenderName->entity()->checked()) { - _showMessagePreview->hideFast(); + _showMessagePreview->hide(anim::type::instant); } if (!_desktopNotifications->checked()) { - _showSenderName->hideFast(); - _showMessagePreview->hideFast(); + _showSenderName->hide(anim::type::instant); + _showMessagePreview->hide(anim::type::instant); } createChildRow(_playSound, margin, lang(lng_settings_sound_notify), [this](bool) { onPlaySound(); }, Global::SoundNotify()); createChildRow(_includeMuted, margin, lang(lng_settings_include_muted), [this](bool) { onIncludeMuted(); }, Global::IncludeMuted()); @@ -91,7 +91,7 @@ void NotificationsWidget::createNotificationsControls() { } createChildRow(_advanced, margin, slidedPadding, lang(lng_settings_advanced_notifications), SLOT(onAdvanced())); if (!nativeNotificationsLabel.isEmpty() && Global::NativeNotifications()) { - _advanced->hideFast(); + _advanced->hide(anim::type::instant); } } @@ -106,8 +106,13 @@ void NotificationsWidget::onDesktopNotifications() { void NotificationsWidget::desktopEnabledUpdated() { _desktopNotifications->setChecked(Global::DesktopNotify()); - _showSenderName->toggleAnimated(Global::DesktopNotify()); - _showMessagePreview->toggleAnimated(Global::DesktopNotify() && _showSenderName->entity()->checked()); + _showSenderName->toggle( + Global::DesktopNotify(), + anim::type::normal); + _showMessagePreview->toggle( + Global::DesktopNotify() + && _showSenderName->entity()->checked(), + anim::type::normal); } void NotificationsWidget::onShowSenderName() { @@ -146,7 +151,9 @@ void NotificationsWidget::onShowMessagePreview() { } void NotificationsWidget::viewParamUpdated() { - _showMessagePreview->toggleAnimated(_showSenderName->entity()->checked()); + _showMessagePreview->toggle( + _showSenderName->entity()->checked(), + anim::type::normal); } void NotificationsWidget::onNativeNotifications() { @@ -159,7 +166,9 @@ void NotificationsWidget::onNativeNotifications() { Auth().notifications().createManager(); - _advanced->toggleAnimated(!Global::NativeNotifications()); + _advanced->toggle( + !Global::NativeNotifications(), + anim::type::normal); } void NotificationsWidget::onAdvanced() { diff --git a/Telegram/SourceFiles/settings/settings_privacy_widget.cpp b/Telegram/SourceFiles/settings/settings_privacy_widget.cpp index e8b89f674..b8fe47fe8 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_widget.cpp @@ -191,7 +191,7 @@ void PrivacyWidget::createControls() { auto value = GetAutoLockText(); createChildRow(_autoLock, marginSmall, slidedPadding, label, value, LabeledLink::Type::Primary, SLOT(onAutoLock())); if (!Global::LocalPasscode()) { - _autoLock->hideFast(); + _autoLock->hide(anim::type::instant); } createChildRow(_cloudPasswordState, marginSmall); createChildRow(_showAllSessions, marginSmall, lang(lng_settings_show_sessions), SLOT(onShowSessions())); @@ -204,7 +204,9 @@ void PrivacyWidget::autoLockUpdated() { _autoLock->entity()->link()->setText(value); resizeToWidth(width()); } - _autoLock->toggleAnimated(Global::LocalPasscode()); + _autoLock->toggle( + Global::LocalPasscode(), + anim::type::normal); } void PrivacyWidget::onBlockedUsers() { diff --git a/Telegram/SourceFiles/ui/wrap/fade_wrap.cpp b/Telegram/SourceFiles/ui/wrap/fade_wrap.cpp index bc86bc6ea..4551747c0 100644 --- a/Telegram/SourceFiles/ui/wrap/fade_wrap.cpp +++ b/Telegram/SourceFiles/ui/wrap/fade_wrap.cpp @@ -41,7 +41,7 @@ FadeWrap *FadeWrap::setDuration(int duration) { FadeWrap *FadeWrap::toggle( bool shown, anim::type animated) { - auto updated = (shown != _animation.visible()); + auto changed = (shown != _animation.visible()); if (shown) { if (animated == anim::type::normal) { _animation.fadeIn(_duration); @@ -55,7 +55,7 @@ FadeWrap *FadeWrap::toggle( _animation.hide(); } } - if (updated) { + if (changed) { _toggledChanged.fire_copy(shown); } return this; diff --git a/Telegram/SourceFiles/ui/wrap/slide_wrap.cpp b/Telegram/SourceFiles/ui/wrap/slide_wrap.cpp index 1432b1fb9..412822f4d 100644 --- a/Telegram/SourceFiles/ui/wrap/slide_wrap.cpp +++ b/Telegram/SourceFiles/ui/wrap/slide_wrap.cpp @@ -55,24 +55,29 @@ SlideWrap *SlideWrap::setDuration(int duration) { return this; } -SlideWrap *SlideWrap::toggleAnimated( - bool shown) { - if (_shown != shown) { - setShown(shown); - _animation.start( - [this] { animationStep(); }, - _shown ? 0. : 1., - _shown ? 1. : 0., - _duration, - anim::linear); +SlideWrap *SlideWrap::toggle( + bool shown, + anim::type animated) { + auto changed = (_toggled != shown); + if (changed) { + _toggled = shown; + if (animated == anim::type::normal) { + _animation.start( + [this] { animationStep(); }, + _toggled ? 0. : 1., + _toggled ? 1. : 0., + _duration, + anim::linear); + } + } + if (animated == anim::type::normal) { + animationStep(); + } else { + finishAnimating(); + } + if (changed) { + _toggledChanged.fire_copy(_toggled); } - animationStep(); - return this; -} - -SlideWrap *SlideWrap::toggleFast(bool shown) { - setShown(shown); - finishAnimating(); return this; } @@ -86,7 +91,7 @@ SlideWrap *SlideWrap::toggleOn( rpl::producer &&shown) { std::move(shown) | rpl::start_with_next([this](bool shown) { - toggleAnimated(shown); + toggle(shown, anim::type::normal); }, lifetime()); finishAnimating(); return this; @@ -99,16 +104,16 @@ void SlideWrap::animationStep() { weak->moveToLeft(margins.left(), margins.top()); newWidth = weak->width(); } - auto current = _animation.current(_shown ? 1. : 0.); + auto current = _animation.current(_toggled ? 1. : 0.); auto newHeight = wrapped() ? (_animation.animating() ? anim::interpolate(0, wrapped()->heightNoMargins(), current) - : (_shown ? wrapped()->height() : 0)) + : (_toggled ? wrapped()->height() : 0)) : 0; if (newWidth != width() || newHeight != height()) { resize(newWidth, newHeight); } - auto shouldBeHidden = !_shown && !_animation.animating(); + auto shouldBeHidden = !_toggled && !_animation.animating(); if (shouldBeHidden != isHidden()) { setVisible(!shouldBeHidden); if (shouldBeHidden) { @@ -117,14 +122,9 @@ void SlideWrap::animationStep() { } } -void SlideWrap::setShown(bool shown) { - _shown = shown; - _shownUpdated.fire_copy(_shown); -} - QMargins SlideWrap::getMargins() const { auto result = wrapped()->getMargins(); - return (animating() || !_shown) + return (animating() || !_toggled) ? QMargins(result.left(), 0, result.right(), 0) : result; } @@ -139,7 +139,7 @@ int SlideWrap::resizeGetHeight(int newWidth) { void SlideWrap::wrappedSizeUpdated(QSize size) { if (_animation.animating()) { animationStep(); - } else if (_shown) { + } else if (_toggled) { resize(size); } } diff --git a/Telegram/SourceFiles/ui/wrap/slide_wrap.h b/Telegram/SourceFiles/ui/wrap/slide_wrap.h index c18c644da..70414fc77 100644 --- a/Telegram/SourceFiles/ui/wrap/slide_wrap.h +++ b/Telegram/SourceFiles/ui/wrap/slide_wrap.h @@ -44,39 +44,37 @@ public: const style::margins &padding); SlideWrap *setDuration(int duration); - SlideWrap *toggleAnimated(bool shown); - SlideWrap *toggleFast(bool shown); - SlideWrap *showAnimated() { return toggleAnimated(true); } - SlideWrap *hideAnimated() { return toggleAnimated(false); } - SlideWrap *showFast() { return toggleFast(true); } - SlideWrap *hideFast() { return toggleFast(false); } + SlideWrap *toggle(bool shown, anim::type animated); + SlideWrap *show(anim::type animated) { + return toggle(true, animated); + } + SlideWrap *hide(anim::type animated) { + return toggle(false, animated); + } SlideWrap *finishAnimating(); SlideWrap *toggleOn(rpl::producer &&shown); bool animating() const { return _animation.animating(); } + bool toggled() const { + return _toggled; + } + auto toggledValue() const { + return _toggledChanged.events_starting_with_copy(_toggled); + } QMargins getMargins() const override; - bool isHiddenOrHiding() const { - return !_shown; - } - - auto shownValue() const { - return _shownUpdated.events_starting_with_copy(_shown); - } - protected: int resizeGetHeight(int newWidth) override; void wrappedSizeUpdated(QSize size) override; private: void animationStep(); - void setShown(bool shown); - bool _shown = true; - rpl::event_stream _shownUpdated; + bool _toggled = true; + rpl::event_stream _toggledChanged; Animation _animation; int _duration = 0; @@ -107,23 +105,14 @@ public: SlideWrap *setDuration(int duration) { return chain(Parent::setDuration(duration)); } - SlideWrap *toggleAnimated(bool shown) { - return chain(Parent::toggleAnimated(shown)); + SlideWrap *toggle(bool shown, anim::type animated) { + return chain(Parent::toggle(shown, animated)); } - SlideWrap *toggleFast(bool shown) { - return chain(Parent::toggleFast(shown)); + SlideWrap *show(anim::type animated) { + return chain(Parent::show(animated)); } - SlideWrap *showAnimated() { - return chain(Parent::showAnimated()); - } - SlideWrap *hideAnimated() { - return chain(Parent::hideAnimated()); - } - SlideWrap *showFast() { - return chain(Parent::showFast()); - } - SlideWrap *hideFast() { - return chain(Parent::hideFast()); + SlideWrap *hide(anim::type animated) { + return chain(Parent::hide(animated)); } SlideWrap *finishAnimating() { return chain(Parent::finishAnimating());