Fix toppeers animation with expanded stories.

This commit is contained in:
John Preston 2024-04-22 11:47:04 +04:00
parent a86e7f035f
commit 8acada9b0f
1 changed files with 29 additions and 9 deletions

View File

@ -1110,7 +1110,6 @@ void Widget::updateHasFocus(not_null<QWidget*> focused) {
void Widget::processSearchFocusChange() { void Widget::processSearchFocusChange() {
_searchSuggestionsLocked = _suggestions && _suggestions->persist(); _searchSuggestionsLocked = _suggestions && _suggestions->persist();
updateCancelSearch(); updateCancelSearch();
updateStoriesVisibility();
updateForceDisplayWide(); updateForceDisplayWide();
updateSuggestions(anim::type::normal); updateSuggestions(anim::type::normal);
} }
@ -1124,7 +1123,13 @@ void Widget::updateSuggestions(anim::type animated) {
} }
if (!suggest && _suggestions) { if (!suggest && _suggestions) {
if (animated == anim::type::normal) { if (animated == anim::type::normal) {
auto taken = base::take(_suggestions);
taken->setVisible(false);
updateStoriesVisibility();
startWidthAnimation(); startWidthAnimation();
taken->setVisible(true);
_suggestions = base::take(taken);
_suggestions->hide(animated, [=, raw = _suggestions.get()] { _suggestions->hide(animated, [=, raw = _suggestions.get()] {
stopWidthAnimation(); stopWidthAnimation();
_hidingSuggestions.erase( _hidingSuggestions.erase(
@ -1144,6 +1149,7 @@ void Widget::updateSuggestions(anim::type animated) {
} else if (suggest && !_suggestions) { } else if (suggest && !_suggestions) {
if (animated == anim::type::normal) { if (animated == anim::type::normal) {
startWidthAnimation(); startWidthAnimation();
updateStoriesVisibility();
} }
_suggestions = std::make_unique<Suggestions>( _suggestions = std::make_unique<Suggestions>(
this, this,
@ -1174,6 +1180,8 @@ void Widget::updateSuggestions(anim::type animated) {
stopWidthAnimation(); stopWidthAnimation();
}); });
_scroll->hide(); _scroll->hide();
} else {
updateStoriesVisibility();
} }
} }
@ -1575,25 +1583,35 @@ void Widget::scrollToDefault(bool verytop) {
[[nodiscard]] QPixmap Widget::grabNonNarrowScrollFrame() { [[nodiscard]] QPixmap Widget::grabNonNarrowScrollFrame() {
auto scrollGeometry = _scroll->geometry(); auto scrollGeometry = _scroll->geometry();
auto grabGeometry = QRect( const auto top = _searchControls->y() + _searchControls->height();
const auto skip = scrollGeometry.y() - top;
auto wideGeometry = QRect(
scrollGeometry.x(), scrollGeometry.x(),
scrollGeometry.y(), scrollGeometry.y(),
std::max(scrollGeometry.width(), st::columnMinimalWidthLeft), std::max(scrollGeometry.width(), st::columnMinimalWidthLeft),
scrollGeometry.height()); scrollGeometry.height());
_scroll->setGeometry(grabGeometry); _scroll->setGeometry(wideGeometry);
_inner->resize(grabGeometry.width(), _inner->height()); _inner->resize(wideGeometry.width(), _inner->height());
_inner->setNarrowRatio(0.); _inner->setNarrowRatio(0.);
Ui::SendPendingMoveResizeEvents(_scroll); Ui::SendPendingMoveResizeEvents(_scroll);
const auto grabSize = QSize(
wideGeometry.width(),
skip + wideGeometry.height());
auto image = QImage( auto image = QImage(
grabGeometry.size() * style::DevicePixelRatio(), grabSize * style::DevicePixelRatio(),
QImage::Format_ARGB32_Premultiplied); QImage::Format_ARGB32_Premultiplied);
image.setDevicePixelRatio(style::DevicePixelRatio()); image.setDevicePixelRatio(style::DevicePixelRatio());
image.fill(Qt::transparent); image.fill(Qt::transparent);
{ {
QPainter p(&image); QPainter p(&image);
Ui::RenderWidget(p, _scroll); Ui::RenderWidget(
p,
this,
QPoint(),
QRect(0, top, wideGeometry.width(), skip));
Ui::RenderWidget(p, _scroll, QPoint(0, skip));
} }
if (scrollGeometry != grabGeometry) { if (scrollGeometry != wideGeometry) {
_scroll->setGeometry(scrollGeometry); _scroll->setGeometry(scrollGeometry);
updateControlsGeometry(); updateControlsGeometry();
} }
@ -3282,9 +3300,11 @@ void Widget::paintEvent(QPaintEvent *e) {
: 0.; : 0.;
const auto suggestionsSkip = suggestionsShown const auto suggestionsSkip = suggestionsShown
* (st::topPeers.height + st::searchedBarHeight); * (st::topPeers.height + st::searchedBarHeight);
const auto top = _scroll->y() + suggestionsSkip; const auto top = _searchControls->y()
+ _searchControls->height()
+ suggestionsSkip;
p.drawPixmapLeft(0, top, width(), _widthAnimationCache); p.drawPixmapLeft(0, top, width(), _widthAnimationCache);
belowTop = _scroll->y() belowTop = top
+ (_widthAnimationCache.height() / style::DevicePixelRatio()); + (_widthAnimationCache.height() / style::DevicePixelRatio());
} }