mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix scrolling to message in pinned section.
This commit is contained in:
parent
cd5cad72bd
commit
ebbe75ac0a
7 changed files with 31 additions and 17 deletions
|
@ -389,13 +389,13 @@ std::optional<int> ListWidget::scrollTopForView(
|
||||||
return top - std::max((available - height) / 2, 0);
|
return top - std::max((available - height) / 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListWidget::animatedScrollTo(
|
void ListWidget::scrollTo(
|
||||||
int scrollTop,
|
int scrollTop,
|
||||||
Data::MessagePosition attachPosition,
|
Data::MessagePosition attachPosition,
|
||||||
int delta,
|
int delta,
|
||||||
AnimatedScroll type) {
|
AnimatedScroll type) {
|
||||||
_scrollToAnimation.stop();
|
_scrollToAnimation.stop();
|
||||||
if (!delta || _items.empty()) {
|
if (!delta || _items.empty() || type == AnimatedScroll::None) {
|
||||||
_delegate->listScrollTo(scrollTop);
|
_delegate->listScrollTo(scrollTop);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,8 +168,9 @@ public:
|
||||||
enum class AnimatedScroll {
|
enum class AnimatedScroll {
|
||||||
Full,
|
Full,
|
||||||
Part,
|
Part,
|
||||||
|
None,
|
||||||
};
|
};
|
||||||
void animatedScrollTo(
|
void scrollTo(
|
||||||
int scrollTop,
|
int scrollTop,
|
||||||
Data::MessagePosition attachPosition,
|
Data::MessagePosition attachPosition,
|
||||||
int delta,
|
int delta,
|
||||||
|
|
|
@ -178,7 +178,10 @@ void PinnedWidget::showAtPosition(
|
||||||
|
|
||||||
bool PinnedWidget::showAtPositionNow(
|
bool PinnedWidget::showAtPositionNow(
|
||||||
Data::MessagePosition position,
|
Data::MessagePosition position,
|
||||||
HistoryItem *originItem) {
|
HistoryItem *originItem,
|
||||||
|
anim::type animated) {
|
||||||
|
using AnimatedScroll = HistoryView::ListWidget::AnimatedScroll;
|
||||||
|
|
||||||
const auto item = position.fullId
|
const auto item = position.fullId
|
||||||
? _history->owner().message(position.fullId)
|
? _history->owner().message(position.fullId)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
@ -189,13 +192,16 @@ bool PinnedWidget::showAtPositionNow(
|
||||||
const auto fullDelta = (wanted - currentScrollTop);
|
const auto fullDelta = (wanted - currentScrollTop);
|
||||||
const auto limit = _scroll->height();
|
const auto limit = _scroll->height();
|
||||||
const auto scrollDelta = snap(fullDelta, -limit, limit);
|
const auto scrollDelta = snap(fullDelta, -limit, limit);
|
||||||
_inner->animatedScrollTo(
|
const auto type = (animated == anim::type::instant)
|
||||||
|
? AnimatedScroll::None
|
||||||
|
: (std::abs(fullDelta) > limit)
|
||||||
|
? AnimatedScroll::Part
|
||||||
|
: AnimatedScroll::Full;
|
||||||
|
_inner->scrollTo(
|
||||||
wanted,
|
wanted,
|
||||||
use,
|
use,
|
||||||
scrollDelta,
|
scrollDelta,
|
||||||
(std::abs(fullDelta) > limit
|
type);
|
||||||
? HistoryView::ListWidget::AnimatedScroll::Part
|
|
||||||
: HistoryView::ListWidget::AnimatedScroll::Full));
|
|
||||||
if (use != Data::MaxMessagePosition
|
if (use != Data::MaxMessagePosition
|
||||||
&& use != Data::UnreadMessagePosition) {
|
&& use != Data::UnreadMessagePosition) {
|
||||||
_inner->highlightMessage(use.fullId);
|
_inner->highlightMessage(use.fullId);
|
||||||
|
@ -356,7 +362,7 @@ void PinnedWidget::restoreState(not_null<PinnedMemento*> memento) {
|
||||||
.date = TimeId(0),
|
.date = TimeId(0),
|
||||||
};
|
};
|
||||||
_inner->showAroundPosition(position, [=] {
|
_inner->showAroundPosition(position, [=] {
|
||||||
return showAtPositionNow(position, nullptr);
|
return showAtPositionNow(position, nullptr, anim::type::instant);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,8 @@ private:
|
||||||
HistoryItem *originItem = nullptr);
|
HistoryItem *originItem = nullptr);
|
||||||
bool showAtPositionNow(
|
bool showAtPositionNow(
|
||||||
Data::MessagePosition position,
|
Data::MessagePosition position,
|
||||||
HistoryItem *originItem);
|
HistoryItem *originItem,
|
||||||
|
anim::type animated = anim::type::normal);
|
||||||
|
|
||||||
void setupScrollDownButton();
|
void setupScrollDownButton();
|
||||||
void scrollDownClicked();
|
void scrollDownClicked();
|
||||||
|
|
|
@ -1169,7 +1169,9 @@ void RepliesWidget::showAtPosition(
|
||||||
|
|
||||||
bool RepliesWidget::showAtPositionNow(
|
bool RepliesWidget::showAtPositionNow(
|
||||||
Data::MessagePosition position,
|
Data::MessagePosition position,
|
||||||
HistoryItem *originItem) {
|
HistoryItem *originItem,
|
||||||
|
anim::type animated) {
|
||||||
|
using AnimatedScroll = HistoryView::ListWidget::AnimatedScroll;
|
||||||
const auto item = position.fullId
|
const auto item = position.fullId
|
||||||
? _history->owner().message(position.fullId)
|
? _history->owner().message(position.fullId)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
@ -1183,13 +1185,16 @@ bool RepliesWidget::showAtPositionNow(
|
||||||
const auto fullDelta = (wanted - currentScrollTop);
|
const auto fullDelta = (wanted - currentScrollTop);
|
||||||
const auto limit = _scroll->height();
|
const auto limit = _scroll->height();
|
||||||
const auto scrollDelta = snap(fullDelta, -limit, limit);
|
const auto scrollDelta = snap(fullDelta, -limit, limit);
|
||||||
_inner->animatedScrollTo(
|
const auto type = (animated == anim::type::instant)
|
||||||
|
? AnimatedScroll::None
|
||||||
|
: (std::abs(fullDelta) > limit)
|
||||||
|
? AnimatedScroll::Part
|
||||||
|
: AnimatedScroll::Full;
|
||||||
|
_inner->scrollTo(
|
||||||
wanted,
|
wanted,
|
||||||
use,
|
use,
|
||||||
scrollDelta,
|
scrollDelta,
|
||||||
(std::abs(fullDelta) > limit
|
type);
|
||||||
? HistoryView::ListWidget::AnimatedScroll::Part
|
|
||||||
: HistoryView::ListWidget::AnimatedScroll::Full));
|
|
||||||
if (use != Data::MaxMessagePosition
|
if (use != Data::MaxMessagePosition
|
||||||
&& use != Data::UnreadMessagePosition) {
|
&& use != Data::UnreadMessagePosition) {
|
||||||
_inner->highlightMessage(use.fullId);
|
_inner->highlightMessage(use.fullId);
|
||||||
|
|
|
@ -150,7 +150,8 @@ private:
|
||||||
HistoryItem *originItem = nullptr);
|
HistoryItem *originItem = nullptr);
|
||||||
bool showAtPositionNow(
|
bool showAtPositionNow(
|
||||||
Data::MessagePosition position,
|
Data::MessagePosition position,
|
||||||
HistoryItem *originItem);
|
HistoryItem *originItem,
|
||||||
|
anim::type animated = anim::type::normal);
|
||||||
void finishSending();
|
void finishSending();
|
||||||
|
|
||||||
void setupComposeControls();
|
void setupComposeControls();
|
||||||
|
|
|
@ -802,7 +802,7 @@ bool ScheduledWidget::showAtPositionNow(Data::MessagePosition position) {
|
||||||
const auto fullDelta = (wanted - currentScrollTop);
|
const auto fullDelta = (wanted - currentScrollTop);
|
||||||
const auto limit = _scroll->height();
|
const auto limit = _scroll->height();
|
||||||
const auto scrollDelta = snap(fullDelta, -limit, limit);
|
const auto scrollDelta = snap(fullDelta, -limit, limit);
|
||||||
_inner->animatedScrollTo(
|
_inner->scrollTo(
|
||||||
wanted,
|
wanted,
|
||||||
position,
|
position,
|
||||||
scrollDelta,
|
scrollDelta,
|
||||||
|
|
Loading…
Add table
Reference in a new issue