Click on root pinned bar throws to replies start.

This commit is contained in:
John Preston 2020-09-21 19:56:22 +03:00
parent e484bc78d0
commit 27f85df562
2 changed files with 25 additions and 1 deletions

View File

@ -270,7 +270,7 @@ void RepliesWidget::setupRootView() {
raw->resize(raw->width(), st::historyReplyHeight);
raw->paintRequest(
) | rpl::start_with_next([=](QRect clip) {
auto p = Painter(_rootView->entity());
auto p = Painter(raw);
p.fillRect(clip, st::historyPinnedBg);
auto top = st::msgReplyPadding.top();
@ -308,6 +308,25 @@ void RepliesWidget::setupRootView() {
}
}, raw->lifetime());
raw->setCursor(style::cur_pointer);
const auto pressed = raw->lifetime().make_state<bool>();
raw->events(
) | rpl::start_with_next([=](not_null<QEvent*> e) {
const auto mouse = static_cast<QMouseEvent*>(e.get());
if (e->type() == QEvent::MouseButtonPress) {
if (mouse->button() == Qt::LeftButton) {
*pressed = true;
}
} else if (e->type() == QEvent::MouseButtonRelease) {
if (mouse->button() == Qt::LeftButton) {
if (base::take(*pressed)
&& raw->rect().contains(mouse->pos())) {
showAtStart();
}
}
}
}, raw->lifetime());
_rootView->geometryValue(
) | rpl::start_with_next([=](QRect rect) {
_rootShadow->moveToLeft(
@ -1068,6 +1087,10 @@ void RepliesWidget::scrollDownClicked() {
}
}
void RepliesWidget::showAtStart() {
showAtPosition(Data::MinMessagePosition);
}
void RepliesWidget::showAtEnd() {
showAtPosition(Data::MaxMessagePosition);
}

View File

@ -141,6 +141,7 @@ private:
void updateAdaptiveLayout();
void saveState(not_null<RepliesMemento*> memento);
void restoreState(not_null<RepliesMemento*> memento);
void showAtStart();
void showAtEnd();
void showAtPosition(
Data::MessagePosition position,