Improve main menu > settings transition animation.

Remove full window cache in case of settings shown as a section.
This commit is contained in:
John Preston 2018-09-06 17:58:43 +03:00
parent 482ecf12ff
commit cfce189201
7 changed files with 42 additions and 5 deletions

View file

@ -2399,6 +2399,9 @@ void MainWidget::showNewSection(
auto direction = (back || settingSection->forceAnimateBack())
? Window::SlideDirection::FromLeft
: Window::SlideDirection::FromRight;
if (Adaptive::OneColumn()) {
_controller->removeLayerBlackout();
}
settingSection->showAnimated(direction, animationParams);
} else {
settingSection->showFast();

View file

@ -372,6 +372,12 @@ void MainWindow::ui_hideSettingsAndLayer(anim::type animated) {
}
}
void MainWindow::ui_removeLayerBlackout() {
if (_layer) {
_layer->removeBodyCache();
}
}
MainWidget *MainWindow::mainWidget() {
return _main;
}

View file

@ -111,6 +111,7 @@ public:
LayerOptions options,
anim::type animated);
void ui_hideSettingsAndLayer(anim::type animated);
void ui_removeLayerBlackout();
bool ui_isLayerShown();
void ui_showMediaPreview(
Data::FileOrigin origin,

View file

@ -43,7 +43,12 @@ public:
}
void setLayerBoxes(const QRect &specialLayerBox, const QRect &layerBox);
void setCacheImages(QPixmap &&bodyCache, QPixmap &&mainMenuCache, QPixmap &&specialLayerCache, QPixmap &&layerCache);
void setCacheImages(
QPixmap &&bodyCache,
QPixmap &&mainMenuCache,
QPixmap &&specialLayerCache,
QPixmap &&layerCache);
void removeBodyCache();
void startAnimation(Action action);
void skipAnimation(Action action);
void finishAnimating();
@ -91,7 +96,11 @@ private:
};
void LayerStackWidget::BackgroundWidget::setCacheImages(QPixmap &&bodyCache, QPixmap &&mainMenuCache, QPixmap &&specialLayerCache, QPixmap &&layerCache) {
void LayerStackWidget::BackgroundWidget::setCacheImages(
QPixmap &&bodyCache,
QPixmap &&mainMenuCache,
QPixmap &&specialLayerCache,
QPixmap &&layerCache) {
_bodyCache = std::move(bodyCache);
_mainMenuCache = std::move(mainMenuCache);
_specialLayerCache = std::move(specialLayerCache);
@ -101,6 +110,13 @@ void LayerStackWidget::BackgroundWidget::setCacheImages(QPixmap &&bodyCache, QPi
setAttribute(Qt::WA_OpaquePaintEvent, !_bodyCache.isNull());
}
void LayerStackWidget::BackgroundWidget::removeBodyCache() {
if (!_bodyCache.isNull()) {
_bodyCache = {};
setAttribute(Qt::WA_OpaquePaintEvent, false);
}
}
void LayerStackWidget::BackgroundWidget::startAnimation(Action action) {
if (action == Action::ShowMainMenu) {
setMainMenuShown(true);
@ -135,8 +151,8 @@ void LayerStackWidget::BackgroundWidget::checkIfDone() {
return;
}
_wasAnimating = false;
_bodyCache = _mainMenuCache = _specialLayerCache = _layerCache = QPixmap();
setAttribute(Qt::WA_OpaquePaintEvent, false);
_mainMenuCache = _specialLayerCache = _layerCache = QPixmap();
removeBodyCache();
if (_doneCallback) {
_doneCallback();
}
@ -392,6 +408,11 @@ void LayerStackWidget::hideTopLayer(anim::type animated) {
}
}
void LayerStackWidget::removeBodyCache() {
_background->removeBodyCache();
setAttribute(Qt::WA_OpaquePaintEvent, false);
}
bool LayerStackWidget::layerShown() const {
return _specialLayer || currentLayer() || _mainMenu;
}
@ -418,7 +439,7 @@ void LayerStackWidget::setCacheImages() {
setFocus();
}
if (_mainMenu) {
setAttribute(Qt::WA_OpaquePaintEvent, false);
removeBodyCache();
hideChildren();
bodyCache = Ui::GrabWidget(parentWidget());
showChildren();

View file

@ -111,6 +111,7 @@ public:
void hideAll(anim::type animated);
void hideTopLayer(anim::type animated);
void setHideByBackgroundClick(bool hide);
void removeBodyCache();
bool showSectionInternal(
not_null<SectionMemento*> memento,

View file

@ -516,6 +516,10 @@ void Controller::showSpecialLayer(
App::wnd()->showSpecialLayer(std::move(layer), animated);
}
void Controller::removeLayerBlackout() {
App::wnd()->ui_removeLayerBlackout();
}
not_null<MainWidget*> Controller::chats() const {
return App::wnd()->chatsWidget();
}

View file

@ -209,6 +209,7 @@ public:
anim::type animated = anim::type::normal) {
showSpecialLayer(nullptr, animated);
}
void removeLayerBlackout();
void showJumpToDate(
Dialogs::Key chat,