MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / scrollToDefault

Method scrollToDefault

Telegram/SourceFiles/dialogs/dialogs_widget.cpp:2307–2345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2305}
2306
2307void Widget::scrollToDefault(bool verytop) {
2308 if (verytop) {
2309 //_scroll->verticalScrollBar()->setMinimum(0);
2310 }
2311 _scrollToAnimation.stop();
2312 auto scrollTop = _scroll->scrollTop();
2313 const auto scrollTo = 0;
2314 if (scrollTop == scrollTo) {
2315 return;
2316 }
2317 const auto maxAnimatedDelta = _scroll->height();
2318 if (scrollTo + maxAnimatedDelta < scrollTop) {
2319 scrollTop = scrollTo + maxAnimatedDelta;
2320 _scroll->scrollToY(scrollTop);
2321 }
2322
2323 startScrollUpButtonAnimation(false);
2324
2325 const auto scroll = [=] {
2326 const auto animated = qRound(_scrollToAnimation.value(scrollTo));
2327 const auto animatedDelta = animated - scrollTo;
2328 const auto realDelta = _scroll->scrollTop() - scrollTo;
2329 if (base::OppositeSigns(realDelta, animatedDelta)) {
2330 // We scrolled manually to the other side of target 'scrollTo'.
2331 _scrollToAnimation.stop();
2332 } else if (std::abs(realDelta) > std::abs(animatedDelta)) {
2333 // We scroll by animation only if it gets us closer to target.
2334 _scroll->scrollToY(animated);
2335 }
2336 };
2337
2338 _scrollAnimationTo = scrollTo;
2339 _scrollToAnimation.start(
2340 scroll,
2341 scrollTop,
2342 scrollTo,
2343 st::slideDuration,
2344 anim::sineInOut);
2345}
2346
2347[[nodiscard]] QPixmap Widget::grabNonNarrowScrollFrame() {
2348 auto scrollGeometry = _scroll->geometry();

Callers

nothing calls this directly

Calls 6

stopMethod · 0.45
scrollTopMethod · 0.45
heightMethod · 0.45
scrollToYMethod · 0.45
valueMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected