Allow manually toggle stories expand state.
This commit is contained in:
parent
85795aa376
commit
61b8aac7c4
|
@ -905,6 +905,7 @@ rpl::producer<> ChatFilters::suggestedUpdated() const {
|
||||||
|
|
||||||
rpl::producer<Ui::MoreChatsBarContent> ChatFilters::moreChatsContent(
|
rpl::producer<Ui::MoreChatsBarContent> ChatFilters::moreChatsContent(
|
||||||
FilterId id) {
|
FilterId id) {
|
||||||
|
return rpl::single(Ui::MoreChatsBarContent{ .count = 10 }); // #TODO stories testing
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return rpl::single(Ui::MoreChatsBarContent{ .count = 0 });
|
return rpl::single(Ui::MoreChatsBarContent{ .count = 0 });
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace Dialogs {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kSearchPerPage = 50;
|
constexpr auto kSearchPerPage = 50;
|
||||||
constexpr auto kWaitTillAllowStoriesExpand = crl::time(200);
|
constexpr auto kStoriesExpandDuration = crl::time(200);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -239,19 +239,43 @@ Widget::Widget(
|
||||||
_scrollToTop->raise();
|
_scrollToTop->raise();
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
_scroll->positionValue(),
|
_scroll->positionValue(),
|
||||||
_scroll->movementValue()
|
_scroll->movementValue(),
|
||||||
|
_storiesExplicitExpandValue.value()
|
||||||
) | rpl::start_with_next([=](
|
) | rpl::start_with_next([=](
|
||||||
Ui::ElasticScrollPosition position,
|
Ui::ElasticScrollPosition position,
|
||||||
Ui::ElasticScrollMovement movement) {
|
Ui::ElasticScrollMovement movement,
|
||||||
|
int explicitlyExpanded) {
|
||||||
const auto overscrollTop = std::max(-position.overscroll, 0);
|
const auto overscrollTop = std::max(-position.overscroll, 0);
|
||||||
if (_overscrollTop != overscrollTop) {
|
if (overscrollTop > 0 && _storiesExplicitExpand) {
|
||||||
_overscrollTop = overscrollTop;
|
_scroll->setOverscrollDefaults(
|
||||||
updateControlsGeometry();
|
-st::dialogsStoriesFull.height,
|
||||||
|
0,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
if (explicitlyExpanded > 0 && explicitlyExpanded < overscrollTop) {
|
||||||
|
_storiesExplicitExpandAnimation.stop();
|
||||||
|
_storiesExplicitExpand = false;
|
||||||
|
_storiesExplicitExpandValue = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto above = std::max(explicitlyExpanded, overscrollTop);
|
||||||
|
if (_aboveScrollAdded != above) {
|
||||||
|
_aboveScrollAdded = above;
|
||||||
|
if (_updateScrollGeometryCached) {
|
||||||
|
_updateScrollGeometryCached();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
using Phase = Ui::ElasticScrollMovement;
|
using Phase = Ui::ElasticScrollMovement;
|
||||||
_stories->setExpandedHeight(
|
_stories->setExpandedHeight(
|
||||||
_overscrollTop,
|
_aboveScrollAdded,
|
||||||
(movement == Phase::Momentum || movement == Phase::Returning));
|
(movement == Phase::Momentum || movement == Phase::Returning)
|
||||||
|
&& (explicitlyExpanded < above));
|
||||||
|
if (position.overscroll > 0
|
||||||
|
|| (position.value
|
||||||
|
> (_storiesExplicitExpandScrollTop
|
||||||
|
+ st::dialogsRowHeight))) {
|
||||||
|
storiesToggleExplicitExpand(false);
|
||||||
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_inner->updated(
|
_inner->updated(
|
||||||
|
@ -487,6 +511,8 @@ Widget::Widget(
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::chosenRow(const ChosenRow &row) {
|
void Widget::chosenRow(const ChosenRow &row) {
|
||||||
|
storiesToggleExplicitExpand(false);
|
||||||
|
|
||||||
const auto history = row.key.history();
|
const auto history = row.key.history();
|
||||||
const auto topicJump = history
|
const auto topicJump = history
|
||||||
? history->peer->forumTopicFor(row.message.fullId.msg)
|
? history->peer->forumTopicFor(row.message.fullId.msg)
|
||||||
|
@ -600,6 +626,8 @@ void Widget::setupMoreChatsBar() {
|
||||||
}
|
}
|
||||||
controller()->activeChatsFilter(
|
controller()->activeChatsFilter(
|
||||||
) | rpl::start_with_next([=](FilterId id) {
|
) | rpl::start_with_next([=](FilterId id) {
|
||||||
|
storiesToggleExplicitExpand(false);
|
||||||
|
|
||||||
if (!id && false) { // #TODO stories testing
|
if (!id && false) { // #TODO stories testing
|
||||||
_moreChatsBar = nullptr;
|
_moreChatsBar = nullptr;
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
|
@ -802,17 +830,36 @@ void Widget::setupStories() {
|
||||||
|
|
||||||
_stories->toggleExpandedRequests(
|
_stories->toggleExpandedRequests(
|
||||||
) | rpl::start_with_next([=](bool expanded) {
|
) | rpl::start_with_next([=](bool expanded) {
|
||||||
if (expanded) {
|
const auto position = _scroll->position();
|
||||||
if (!_scrollToAnimation.animating() || _scrollAnimationTo) {
|
if (!expanded) {
|
||||||
scrollToDefault();
|
_scroll->setOverscrollDefaults(0, 0);
|
||||||
}
|
} else if (position.value > 0 || position.overscroll >= 0) {
|
||||||
|
storiesToggleExplicitExpand(true);
|
||||||
|
_scroll->setOverscrollDefaults(0, 0);
|
||||||
|
} else {
|
||||||
|
_scroll->setOverscrollDefaults(
|
||||||
|
-st::dialogsStoriesFull.height,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
_scroll->setOverscrollDefaults(
|
|
||||||
expanded ? -st::dialogsStoriesFull.height : 0,
|
|
||||||
0);
|
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::storiesToggleExplicitExpand(bool expand) {
|
||||||
|
if (_storiesExplicitExpand == expand) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_storiesExplicitExpand = expand;
|
||||||
|
if (!expand) {
|
||||||
|
_scroll->setOverscrollDefaults(0, 0, true);
|
||||||
|
}
|
||||||
|
const auto height = st::dialogsStoriesFull.height;
|
||||||
|
const auto duration = kStoriesExpandDuration;
|
||||||
|
_storiesExplicitExpandScrollTop = _scroll->position().value;
|
||||||
|
_storiesExplicitExpandAnimation.start([=](float64 value) {
|
||||||
|
_storiesExplicitExpandValue = int(base::SafeRound(value));
|
||||||
|
}, expand ? 0 : height, expand ? height : 0, duration, anim::sineInOut);
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::setupShortcuts() {
|
void Widget::setupShortcuts() {
|
||||||
Shortcuts::Requests(
|
Shortcuts::Requests(
|
||||||
) | rpl::filter([=] {
|
) | rpl::filter([=] {
|
||||||
|
@ -957,6 +1004,7 @@ void Widget::changeOpenedFolder(Data::Folder *folder, anim::type animated) {
|
||||||
controller()->closeForum();
|
controller()->closeForum();
|
||||||
_openedFolder = folder;
|
_openedFolder = folder;
|
||||||
_inner->changeOpenedFolder(folder);
|
_inner->changeOpenedFolder(folder);
|
||||||
|
storiesToggleExplicitExpand(false);
|
||||||
}, (folder != nullptr), animated);
|
}, (folder != nullptr), animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -970,6 +1018,7 @@ void Widget::changeOpenedForum(Data::Forum *forum, anim::type animated) {
|
||||||
_openedForum = forum;
|
_openedForum = forum;
|
||||||
_api.request(base::take(_topicSearchRequest)).cancel();
|
_api.request(base::take(_topicSearchRequest)).cancel();
|
||||||
_inner->changeOpenedForum(forum);
|
_inner->changeOpenedForum(forum);
|
||||||
|
storiesToggleExplicitExpand(false);
|
||||||
}, (forum != nullptr), animated);
|
}, (forum != nullptr), animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2575,42 +2624,15 @@ void Widget::updateControlsGeometry() {
|
||||||
barw,
|
barw,
|
||||||
st::lineWidth);
|
st::lineWidth);
|
||||||
}
|
}
|
||||||
const auto moreChatsBarTop = expandedStoriesTop + _overscrollTop;
|
|
||||||
if (_moreChatsBar) {
|
auto bottomSkip = 0;
|
||||||
_moreChatsBar->move(0, moreChatsBarTop);
|
|
||||||
_moreChatsBar->resizeToWidth(barw);
|
|
||||||
}
|
|
||||||
const auto forumGroupCallTop = moreChatsBarTop
|
|
||||||
+ (_moreChatsBar ? _moreChatsBar->height() : 0);
|
|
||||||
if (_forumGroupCallBar) {
|
|
||||||
_forumGroupCallBar->move(0, forumGroupCallTop);
|
|
||||||
_forumGroupCallBar->resizeToWidth(barw);
|
|
||||||
}
|
|
||||||
const auto forumRequestsTop = forumGroupCallTop
|
|
||||||
+ (_forumGroupCallBar ? _forumGroupCallBar->height() : 0);
|
|
||||||
if (_forumRequestsBar) {
|
|
||||||
_forumRequestsBar->move(0, forumRequestsTop);
|
|
||||||
_forumRequestsBar->resizeToWidth(barw);
|
|
||||||
}
|
|
||||||
const auto forumReportTop = forumRequestsTop
|
|
||||||
+ (_forumRequestsBar ? _forumRequestsBar->height() : 0);
|
|
||||||
if (_forumReportBar) {
|
|
||||||
_forumReportBar->bar().move(0, forumReportTop);
|
|
||||||
}
|
|
||||||
auto scrollTop = forumReportTop
|
|
||||||
+ (_forumReportBar ? _forumReportBar->bar().height() : 0);
|
|
||||||
const auto wasScrollTop = _scroll->scrollTop();
|
|
||||||
const auto newScrollTop = (_topDelta < 0 && wasScrollTop <= 0)
|
|
||||||
? wasScrollTop
|
|
||||||
: (wasScrollTop + _topDelta);
|
|
||||||
auto scrollHeight = height() - scrollTop;
|
|
||||||
const auto putBottomButton = [&](auto &button) {
|
const auto putBottomButton = [&](auto &button) {
|
||||||
if (button && !button->isHidden()) {
|
if (button && !button->isHidden()) {
|
||||||
const auto buttonHeight = button->height();
|
const auto buttonHeight = button->height();
|
||||||
scrollHeight -= buttonHeight;
|
bottomSkip += buttonHeight;
|
||||||
button->setGeometry(
|
button->setGeometry(
|
||||||
0,
|
0,
|
||||||
scrollTop + scrollHeight,
|
height() - bottomSkip,
|
||||||
barw,
|
barw,
|
||||||
buttonHeight);
|
buttonHeight);
|
||||||
}
|
}
|
||||||
|
@ -2618,24 +2640,55 @@ void Widget::updateControlsGeometry() {
|
||||||
putBottomButton(_updateTelegram);
|
putBottomButton(_updateTelegram);
|
||||||
putBottomButton(_downloadBar);
|
putBottomButton(_downloadBar);
|
||||||
putBottomButton(_loadMoreChats);
|
putBottomButton(_loadMoreChats);
|
||||||
const auto bottomSkip = (height() - scrollTop) - scrollHeight;
|
|
||||||
if (_connecting) {
|
if (_connecting) {
|
||||||
_connecting->setBottomSkip(bottomSkip);
|
_connecting->setBottomSkip(bottomSkip);
|
||||||
}
|
}
|
||||||
controller()->setConnectingBottomSkip(bottomSkip);
|
controller()->setConnectingBottomSkip(bottomSkip);
|
||||||
|
|
||||||
|
const auto wasScrollTop = _scroll->scrollTop();
|
||||||
|
const auto newScrollTop = (_topDelta < 0 && wasScrollTop <= 0)
|
||||||
|
? wasScrollTop
|
||||||
|
: (wasScrollTop + _topDelta);
|
||||||
|
|
||||||
const auto scrollw = _childList ? _narrowWidth : barw;
|
const auto scrollw = _childList ? _narrowWidth : barw;
|
||||||
const auto wasScrollHeight = _scroll->height();
|
_updateScrollGeometryCached = [=] {
|
||||||
_scroll->setGeometry(0, scrollTop, scrollw, scrollHeight);
|
const auto moreChatsBarTop = expandedStoriesTop + _aboveScrollAdded;
|
||||||
|
if (_moreChatsBar) {
|
||||||
|
_moreChatsBar->move(0, moreChatsBarTop);
|
||||||
|
_moreChatsBar->resizeToWidth(barw);
|
||||||
|
}
|
||||||
|
const auto forumGroupCallTop = moreChatsBarTop
|
||||||
|
+ (_moreChatsBar ? _moreChatsBar->height() : 0);
|
||||||
|
if (_forumGroupCallBar) {
|
||||||
|
_forumGroupCallBar->move(0, forumGroupCallTop);
|
||||||
|
_forumGroupCallBar->resizeToWidth(barw);
|
||||||
|
}
|
||||||
|
const auto forumRequestsTop = forumGroupCallTop
|
||||||
|
+ (_forumGroupCallBar ? _forumGroupCallBar->height() : 0);
|
||||||
|
if (_forumRequestsBar) {
|
||||||
|
_forumRequestsBar->move(0, forumRequestsTop);
|
||||||
|
_forumRequestsBar->resizeToWidth(barw);
|
||||||
|
}
|
||||||
|
const auto forumReportTop = forumRequestsTop
|
||||||
|
+ (_forumRequestsBar ? _forumRequestsBar->height() : 0);
|
||||||
|
if (_forumReportBar) {
|
||||||
|
_forumReportBar->bar().move(0, forumReportTop);
|
||||||
|
}
|
||||||
|
auto scrollTop = forumReportTop
|
||||||
|
+ (_forumReportBar ? _forumReportBar->bar().height() : 0);
|
||||||
|
auto scrollHeight = height() - scrollTop;
|
||||||
|
|
||||||
|
const auto wasScrollHeight = _scroll->height();
|
||||||
|
_scroll->setGeometry(0, scrollTop, scrollw, scrollHeight);
|
||||||
|
if (scrollHeight != wasScrollHeight) {
|
||||||
|
controller()->floatPlayerAreaUpdated();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
_updateScrollGeometryCached();
|
||||||
|
|
||||||
_inner->resize(scrollw, _inner->height());
|
_inner->resize(scrollw, _inner->height());
|
||||||
_inner->setNarrowRatio(narrowRatio);
|
_inner->setNarrowRatio(narrowRatio);
|
||||||
if (scrollHeight != wasScrollHeight) {
|
if (newScrollTop != wasScrollTop) {
|
||||||
controller()->floatPlayerAreaUpdated();
|
|
||||||
}
|
|
||||||
const auto startWithTop = 0;
|
|
||||||
if (wasScrollHeight < startWithTop && scrollHeight >= startWithTop) {
|
|
||||||
_scroll->scrollToY(startWithTop);
|
|
||||||
} else if (newScrollTop != wasScrollTop) {
|
|
||||||
_scroll->scrollToY(newScrollTop);
|
_scroll->scrollToY(newScrollTop);
|
||||||
} else {
|
} else {
|
||||||
listScrollUpdated();
|
listScrollUpdated();
|
||||||
|
@ -2646,7 +2699,7 @@ void Widget::updateControlsGeometry() {
|
||||||
|
|
||||||
if (_childList) {
|
if (_childList) {
|
||||||
const auto childw = std::max(_narrowWidth, width() - scrollw);
|
const auto childw = std::max(_narrowWidth, width() - scrollw);
|
||||||
const auto childh = scrollTop + scrollHeight;
|
const auto childh = _scroll->y() + _scroll->height();
|
||||||
const auto childx = width() - childw;
|
const auto childx = width() - childw;
|
||||||
_childList->setGeometryWithTopMoved(
|
_childList->setGeometryWithTopMoved(
|
||||||
{ childx, 0, childw, childh },
|
{ childx, 0, childw, childh },
|
||||||
|
|
|
@ -167,6 +167,7 @@ private:
|
||||||
void setupDownloadBar();
|
void setupDownloadBar();
|
||||||
void setupShortcuts();
|
void setupShortcuts();
|
||||||
void setupStories();
|
void setupStories();
|
||||||
|
void storiesToggleExplicitExpand(bool expand);
|
||||||
[[nodiscard]] bool searchForPeersRequired(const QString &query) const;
|
[[nodiscard]] bool searchForPeersRequired(const QString &query) const;
|
||||||
[[nodiscard]] bool searchForTopicsRequired(const QString &query) const;
|
[[nodiscard]] bool searchForTopicsRequired(const QString &query) const;
|
||||||
bool setSearchInChat(Key chat, PeerData *from = nullptr);
|
bool setSearchInChat(Key chat, PeerData *from = nullptr);
|
||||||
|
@ -267,8 +268,13 @@ private:
|
||||||
bool _scrollToTopIsShown = false;
|
bool _scrollToTopIsShown = false;
|
||||||
bool _forumSearchRequested = false;
|
bool _forumSearchRequested = false;
|
||||||
|
|
||||||
int _overscrollTop = 0;
|
Fn<void()> _updateScrollGeometryCached;
|
||||||
std::unique_ptr<Stories::List> _stories;
|
std::unique_ptr<Stories::List> _stories;
|
||||||
|
Ui::Animations::Simple _storiesExplicitExpandAnimation;
|
||||||
|
rpl::variable<int> _storiesExplicitExpandValue = 0;
|
||||||
|
int _storiesExplicitExpandScrollTop = 0;
|
||||||
|
int _aboveScrollAdded = 0;
|
||||||
|
bool _storiesExplicitExpand = false;
|
||||||
|
|
||||||
Data::Folder *_openedFolder = nullptr;
|
Data::Folder *_openedFolder = nullptr;
|
||||||
Data::Forum *_openedForum = nullptr;
|
Data::Forum *_openedForum = nullptr;
|
||||||
|
|
|
@ -813,7 +813,7 @@ void List::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
}
|
}
|
||||||
updateSelected();
|
updateSelected();
|
||||||
if (_selected == pressed) {
|
if (_selected == pressed) {
|
||||||
if (_selected < 0) {
|
if (!_expanded) {
|
||||||
requestExpanded(true);
|
requestExpanded(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);
|
||||||
|
@ -906,7 +906,7 @@ void List::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
_lastMousePosition = e->globalPos();
|
_lastMousePosition = e->globalPos();
|
||||||
updateSelected();
|
updateSelected();
|
||||||
}
|
}
|
||||||
if (_selected < 0 || _data.empty()) {
|
if (_selected < 0 || _data.empty() || !_expanded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_menu = base::make_unique_q<Ui::PopupMenu>(
|
_menu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 80308cea4f57fd13e73abec121325f174ba21883
|
Subproject commit 763b3a37c34fd7819f9d553b94387c4fe16554ff
|
Loading…
Reference in New Issue
Block a user