Fix scroll position restore with pinned bar.

This commit is contained in:
John Preston 2020-11-09 12:57:49 +03:00
parent 091b62bed4
commit 87e4bb1059
1 changed files with 14 additions and 5 deletions

View File

@ -3183,11 +3183,20 @@ void HistoryWidget::showAnimated(
_a_show.stop(); _a_show.stop();
_cacheUnder = params.oldContentCache; _cacheUnder = params.oldContentCache;
// If we show pinned bar here, we don't want it to change the
// calculated and prepared scrollTop of the messages history.
_preserveScrollTop = true;
show(); show();
_topBar->finishAnimating(); _topBar->finishAnimating();
historyDownAnimationFinish(); historyDownAnimationFinish();
unreadMentionsAnimationFinish(); unreadMentionsAnimationFinish();
if (_pinnedBar) {
_pinnedBar->finishAnimating();
}
_topShadow->setVisible(params.withTopBarShadow ? false : true); _topShadow->setVisible(params.withTopBarShadow ? false : true);
_preserveScrollTop = false;
_cacheOver = controller()->content()->grabForShowAnimation(params); _cacheOver = controller()->content()->grabForShowAnimation(params);
if (_tabbedPanel) { if (_tabbedPanel) {
@ -3216,8 +3225,12 @@ void HistoryWidget::animationCallback() {
if (!_a_show.animating()) { if (!_a_show.animating()) {
historyDownAnimationFinish(); historyDownAnimationFinish();
unreadMentionsAnimationFinish(); unreadMentionsAnimationFinish();
if (_pinnedBar) {
_pinnedBar->finishAnimating();
}
_cacheUnder = _cacheOver = QPixmap(); _cacheUnder = _cacheOver = QPixmap();
doneShow(); doneShow();
synteticScrollToY(_scroll->scrollTop());
} }
} }
@ -4676,12 +4689,8 @@ void HistoryWidget::updateHistoryGeometry(
} }
} }
const auto toY = std::clamp(newScrollTop, 0, _scroll->scrollTopMax()); const auto toY = std::clamp(newScrollTop, 0, _scroll->scrollTopMax());
if (_scroll->scrollTop() == toY) {
visibleAreaUpdated();
} else {
synteticScrollToY(toY); synteticScrollToY(toY);
} }
}
void HistoryWidget::updateListSize() { void HistoryWidget::updateListSize() {
_list->recountHistoryGeometry(); _list->recountHistoryGeometry();