Collapse stories on chat open.
This commit is contained in:
parent
bc7da9309d
commit
aa2cf2f6ca
|
@ -473,8 +473,10 @@ int InnerWidget::dialogsOffset() const {
|
||||||
- skipTopHeight();
|
- skipTopHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<> InnerWidget::scrollToVeryTopRequests() const {
|
rpl::producer<bool> InnerWidget::storiesExpandedRequests() const {
|
||||||
return _stories->expandRequests();
|
return rpl::merge(
|
||||||
|
_stories->toggleExpandedRequests(),
|
||||||
|
_storiesExpandedRequests.events());
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::defaultScrollTop() const {
|
int InnerWidget::defaultScrollTop() const {
|
||||||
|
@ -623,11 +625,6 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
if (_controller->contentOverlapped(this, e)) {
|
if (_controller->contentOverlapped(this, e)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto fillGuard = gsl::finally([&] {
|
|
||||||
// We translate painter down, but it'll be cropped below rect.
|
|
||||||
p.fillRect(rect(), st::dialogsBg);
|
|
||||||
});
|
|
||||||
|
|
||||||
const auto activeEntry = _controller->activeChatEntryCurrent();
|
const auto activeEntry = _controller->activeChatEntryCurrent();
|
||||||
const auto videoPaused = _controller->isGifPausedAtLeastFor(
|
const auto videoPaused = _controller->isGifPausedAtLeastFor(
|
||||||
Window::GifPauseReason::Any);
|
Window::GifPauseReason::Any);
|
||||||
|
@ -648,6 +645,11 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
.paused = videoPaused,
|
.paused = videoPaused,
|
||||||
.narrow = (fullWidth < st::columnMinimalWidthLeft / 2),
|
.narrow = (fullWidth < st::columnMinimalWidthLeft / 2),
|
||||||
};
|
};
|
||||||
|
_stories->setBgOverride(context.currentBg);
|
||||||
|
const auto fillGuard = gsl::finally([&] {
|
||||||
|
// We translate painter down, but it'll be cropped below rect.
|
||||||
|
p.fillRect(rect(), context.currentBg);
|
||||||
|
});
|
||||||
const auto paintRow = [&](
|
const auto paintRow = [&](
|
||||||
not_null<Row*> row,
|
not_null<Row*> row,
|
||||||
bool selected,
|
bool selected,
|
||||||
|
@ -3408,6 +3410,7 @@ ChosenRow InnerWidget::computeChosenRow() const {
|
||||||
bool InnerWidget::chooseRow(
|
bool InnerWidget::chooseRow(
|
||||||
Qt::KeyboardModifiers modifiers,
|
Qt::KeyboardModifiers modifiers,
|
||||||
MsgId pressedTopicRootId) {
|
MsgId pressedTopicRootId) {
|
||||||
|
_storiesExpandedRequests.fire(false);
|
||||||
if (chooseCollapsedRow()) {
|
if (chooseCollapsedRow()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (chooseHashtag()) {
|
} else if (chooseHashtag()) {
|
||||||
|
|
|
@ -104,7 +104,7 @@ public:
|
||||||
const QVector<MTPPeer> &my,
|
const QVector<MTPPeer> &my,
|
||||||
const QVector<MTPPeer> &result);
|
const QVector<MTPPeer> &result);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<> scrollToVeryTopRequests() const;
|
[[nodiscard]] rpl::producer<bool> storiesExpandedRequests() const;
|
||||||
[[nodiscard]] int defaultScrollTop() const;
|
[[nodiscard]] int defaultScrollTop() const;
|
||||||
void setViewportHeight(int viewportHeight);
|
void setViewportHeight(int viewportHeight);
|
||||||
|
|
||||||
|
@ -408,6 +408,7 @@ private:
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
|
|
||||||
const std::unique_ptr<Stories::List> _stories;
|
const std::unique_ptr<Stories::List> _stories;
|
||||||
|
rpl::event_stream<bool> _storiesExpandedRequests;
|
||||||
int _viewportHeight = 0;
|
int _viewportHeight = 0;
|
||||||
|
|
||||||
not_null<IndexedList*> _shownList;
|
not_null<IndexedList*> _shownList;
|
||||||
|
|
|
@ -261,9 +261,11 @@ Widget::Widget(
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_inner->scrollToVeryTopRequests(
|
_inner->storiesExpandedRequests(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=](bool expanded) {
|
||||||
scrollToDefaultChecked(true);
|
if (expanded || _scroll->scrollTop() < _inner->defaultScrollTop()) {
|
||||||
|
scrollToDefaultChecked(expanded);
|
||||||
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_inner->mustScrollTo(
|
_inner->mustScrollTo(
|
||||||
|
@ -1123,7 +1125,7 @@ void Widget::scrollToDefault(bool verytop) {
|
||||||
_scrollToAnimation.stop();
|
_scrollToAnimation.stop();
|
||||||
auto scrollTop = _scroll->scrollTop();
|
auto scrollTop = _scroll->scrollTop();
|
||||||
const auto scrollTo = verytop ? 0 : _inner->defaultScrollTop();
|
const auto scrollTo = verytop ? 0 : _inner->defaultScrollTop();
|
||||||
if (scrollTop <= scrollTo) {
|
if (scrollTop == scrollTo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto maxAnimatedDelta = _scroll->height();
|
const auto maxAnimatedDelta = _scroll->height();
|
||||||
|
@ -2017,6 +2019,7 @@ void Widget::dropEvent(QDropEvent *e) {
|
||||||
|
|
||||||
void Widget::listScrollUpdated() {
|
void Widget::listScrollUpdated() {
|
||||||
const auto scrollTop = _scroll->scrollTop();
|
const auto scrollTop = _scroll->scrollTop();
|
||||||
|
PROFILE_LOG(("SCROLLED: %1").arg(scrollTop));
|
||||||
_inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height());
|
_inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height());
|
||||||
updateScrollUpVisibility();
|
updateScrollUpVisibility();
|
||||||
|
|
||||||
|
|
|
@ -239,8 +239,8 @@ rpl::producer<ToggleShownRequest> List::toggleShown() const {
|
||||||
return _toggleShown.events();
|
return _toggleShown.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<> List::expandRequests() const {
|
rpl::producer<bool> List::toggleExpandedRequests() const {
|
||||||
return _expandRequests.events();
|
return _toggleExpandedRequests.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<> List::entered() const {
|
rpl::producer<> List::entered() const {
|
||||||
|
@ -347,7 +347,7 @@ void List::paintEvent(QPaintEvent *e) {
|
||||||
const auto readUserpicAppearingOpacity = lerp(_st.readOpacity, 0.);
|
const auto readUserpicAppearingOpacity = lerp(_st.readOpacity, 0.);
|
||||||
|
|
||||||
auto p = QPainter(this);
|
auto p = QPainter(this);
|
||||||
p.fillRect(e->rect(), _st.bg);
|
p.fillRect(e->rect(), _bgOverride.value_or(_st.bg));
|
||||||
p.translate(0, height() - layout.shownHeight);
|
p.translate(0, height() - layout.shownHeight);
|
||||||
|
|
||||||
const auto drawSmall = (ratio < 1.);
|
const auto drawSmall = (ratio < 1.);
|
||||||
|
@ -670,7 +670,7 @@ void List::wheelEvent(QWheelEvent *e) {
|
||||||
const auto used = now - delta;
|
const auto used = now - delta;
|
||||||
const auto next = std::clamp(used, 0, _scrollLeftMax);
|
const auto next = std::clamp(used, 0, _scrollLeftMax);
|
||||||
if (next != now) {
|
if (next != now) {
|
||||||
_expandRequests.fire({});
|
_toggleExpandedRequests.fire(true);
|
||||||
_scrollLeft = next;
|
_scrollLeft = next;
|
||||||
updateSelected();
|
updateSelected();
|
||||||
checkLoadMore();
|
checkLoadMore();
|
||||||
|
@ -698,7 +698,7 @@ void List::mouseMoveEvent(QMouseEvent *e) {
|
||||||
if ((_lastMousePosition - *_mouseDownPosition).manhattanLength()
|
if ((_lastMousePosition - *_mouseDownPosition).manhattanLength()
|
||||||
>= QApplication::startDragDistance()) {
|
>= QApplication::startDragDistance()) {
|
||||||
if (_shownHeight() < _st.full.height) {
|
if (_shownHeight() < _st.full.height) {
|
||||||
_expandRequests.fire({});
|
_toggleExpandedRequests.fire(true);
|
||||||
}
|
}
|
||||||
_dragging = true;
|
_dragging = true;
|
||||||
_startDraggingLeft = _scrollLeft;
|
_startDraggingLeft = _scrollLeft;
|
||||||
|
@ -742,13 +742,17 @@ void List::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
updateSelected();
|
updateSelected();
|
||||||
if (_selected == pressed) {
|
if (_selected == pressed) {
|
||||||
if (_selected < 0) {
|
if (_selected < 0) {
|
||||||
_expandRequests.fire({});
|
_toggleExpandedRequests.fire(true);
|
||||||
} else if (_selected < _data.items.size()) {
|
} else if (_selected < _data.items.size()) {
|
||||||
_clicks.fire_copy(_data.items[_selected].element.id);
|
_clicks.fire_copy(_data.items[_selected].element.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void List::setBgOverride(QBrush brush) {
|
||||||
|
_bgOverride = std::move(brush);
|
||||||
|
}
|
||||||
|
|
||||||
void List::contextMenuEvent(QContextMenuEvent *e) {
|
void List::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
_menu = nullptr;
|
_menu = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,12 @@ public:
|
||||||
rpl::producer<Content> content,
|
rpl::producer<Content> content,
|
||||||
Fn<int()> shownHeight);
|
Fn<int()> shownHeight);
|
||||||
|
|
||||||
|
void setBgOverride(QBrush brush);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<uint64> clicks() const;
|
[[nodiscard]] rpl::producer<uint64> clicks() const;
|
||||||
[[nodiscard]] rpl::producer<uint64> showProfileRequests() const;
|
[[nodiscard]] rpl::producer<uint64> showProfileRequests() const;
|
||||||
[[nodiscard]] rpl::producer<ToggleShownRequest> toggleShown() const;
|
[[nodiscard]] rpl::producer<ToggleShownRequest> toggleShown() const;
|
||||||
[[nodiscard]] rpl::producer<> expandRequests() const;
|
[[nodiscard]] rpl::producer<bool> toggleExpandedRequests() const;
|
||||||
[[nodiscard]] rpl::producer<> entered() const;
|
[[nodiscard]] rpl::producer<> entered() const;
|
||||||
[[nodiscard]] rpl::producer<> loadMoreRequests() const;
|
[[nodiscard]] rpl::producer<> loadMoreRequests() const;
|
||||||
|
|
||||||
|
@ -165,10 +167,11 @@ private:
|
||||||
rpl::event_stream<uint64> _clicks;
|
rpl::event_stream<uint64> _clicks;
|
||||||
rpl::event_stream<uint64> _showProfileRequests;
|
rpl::event_stream<uint64> _showProfileRequests;
|
||||||
rpl::event_stream<ToggleShownRequest> _toggleShown;
|
rpl::event_stream<ToggleShownRequest> _toggleShown;
|
||||||
rpl::event_stream<> _expandRequests;
|
rpl::event_stream<bool> _toggleExpandedRequests;
|
||||||
rpl::event_stream<> _entered;
|
rpl::event_stream<> _entered;
|
||||||
rpl::event_stream<> _loadMoreRequests;
|
rpl::event_stream<> _loadMoreRequests;
|
||||||
|
|
||||||
|
std::optional<QBrush> _bgOverride;
|
||||||
Ui::Animations::Simple _shownAnimation;
|
Ui::Animations::Simple _shownAnimation;
|
||||||
|
|
||||||
QPoint _lastMousePosition;
|
QPoint _lastMousePosition;
|
||||||
|
|
Loading…
Reference in New Issue