Collapse forum row height in narrow layout.
This commit is contained in:
parent
c200263f2e
commit
f0b8ccbd71
|
@ -380,13 +380,6 @@ void Entry::updateChatListEntryPostponed() {
|
|||
}
|
||||
|
||||
void Entry::updateChatListEntryHeight() {
|
||||
auto &filters = _owner->chatsFilters();
|
||||
for (auto &[filterId, rows] : _chatListLinks) {
|
||||
const auto list = filterId
|
||||
? filters.chatsList(filterId)
|
||||
: _owner->chatsList(folder());
|
||||
list->updateEntryHeight(rows);
|
||||
}
|
||||
session().changes().entryUpdated(this, Data::EntryUpdate::Flag::Height);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,13 +61,12 @@ void IndexedList::adjustByDate(const RowsByLetter &links) {
|
|||
}
|
||||
}
|
||||
|
||||
void IndexedList::updateHeight(const RowsByLetter &links) {
|
||||
_list.updateHeight(links.main);
|
||||
for (const auto &[ch, row] : links.letters) {
|
||||
if (auto it = _index.find(ch); it != _index.cend()) {
|
||||
it->second.updateHeight(row);
|
||||
}
|
||||
}
|
||||
bool IndexedList::updateHeights(float64 narrowRatio) {
|
||||
return _list.updateHeights(narrowRatio);
|
||||
}
|
||||
|
||||
bool IndexedList::updateHeight(Key key, float64 narrowRatio) {
|
||||
return _list.updateHeight(key, narrowRatio);
|
||||
}
|
||||
|
||||
void IndexedList::moveToTop(Key key) {
|
||||
|
|
|
@ -22,7 +22,8 @@ public:
|
|||
Row *addByName(Key key);
|
||||
void adjustByDate(const RowsByLetter &links);
|
||||
void moveToTop(Key key);
|
||||
void updateHeight(const RowsByLetter &links);
|
||||
bool updateHeight(Key key, float64 narrowRatio);
|
||||
bool updateHeights(float64 narrowRatio);
|
||||
|
||||
// row must belong to this indexed list all().
|
||||
void movePinned(Row *row, int deltaSign);
|
||||
|
|
|
@ -294,8 +294,9 @@ InnerWidget::InnerWidget(
|
|||
) | rpl::start_with_next([=](const Data::EntryUpdate &update) {
|
||||
const auto entry = update.entry;
|
||||
if (update.flags & Data::EntryUpdate::Flag::Height) {
|
||||
updateFilteredEntryHeight(entry);
|
||||
refresh();
|
||||
if (updateEntryHeight(entry)) {
|
||||
refresh();
|
||||
}
|
||||
return;
|
||||
}
|
||||
const auto repaintId = (_state == WidgetState::Default)
|
||||
|
@ -331,7 +332,10 @@ InnerWidget::InnerWidget(
|
|||
setupShortcuts();
|
||||
}
|
||||
|
||||
void InnerWidget::updateFilteredEntryHeight(not_null<Entry*> entry) {
|
||||
bool InnerWidget::updateEntryHeight(not_null<Entry*> entry) {
|
||||
if (!_geometryInited) {
|
||||
return false;
|
||||
}
|
||||
auto changing = false;
|
||||
auto top = 0;
|
||||
for (auto &result : _filterResults) {
|
||||
|
@ -339,7 +343,7 @@ void InnerWidget::updateFilteredEntryHeight(not_null<Entry*> entry) {
|
|||
result.top = top;
|
||||
}
|
||||
if (result.row->key().entry() == entry) {
|
||||
result.row->recountHeight();
|
||||
result.row->recountHeight(_narrowRatio);
|
||||
changing = true;
|
||||
top = result.top;
|
||||
}
|
||||
|
@ -347,6 +351,18 @@ void InnerWidget::updateFilteredEntryHeight(not_null<Entry*> entry) {
|
|||
top += result.row->height();
|
||||
}
|
||||
}
|
||||
return _shownList->updateHeight(entry, _narrowRatio) || changing;
|
||||
}
|
||||
|
||||
void InnerWidget::setNarrowRatio(float64 narrowRatio) {
|
||||
if (_geometryInited && _narrowRatio == narrowRatio) {
|
||||
return;
|
||||
}
|
||||
_geometryInited = true;
|
||||
_narrowRatio = narrowRatio;
|
||||
if (_shownList->updateHeights(_narrowRatio) || !height()) {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
Main::Session &InnerWidget::session() const {
|
||||
|
@ -2070,11 +2086,14 @@ void InnerWidget::updateSelectedRow(Key key) {
|
|||
}
|
||||
|
||||
void InnerWidget::refreshShownList() {
|
||||
_shownList = _openedForum
|
||||
const auto list = _openedForum
|
||||
? _openedForum->topicsList()->indexed()
|
||||
: _filterId
|
||||
? session().data().chatsFilters().chatsList(_filterId)->indexed()
|
||||
: session().data().chatsList(_openedFolder)->indexed();
|
||||
if (_shownList != list) {
|
||||
_shownList = list;
|
||||
}
|
||||
}
|
||||
|
||||
void InnerWidget::leaveEventHook(QEvent *e) {
|
||||
|
@ -2240,6 +2259,7 @@ void InnerWidget::applyFilterUpdate(QString newFilter, bool force) {
|
|||
end(results));
|
||||
for (const auto e = end(_filterResults); i != e; ++i) {
|
||||
i->top = top;
|
||||
i->row->recountHeight(_narrowRatio);
|
||||
top += i->row->height();
|
||||
}
|
||||
};
|
||||
|
@ -2672,7 +2692,9 @@ void InnerWidget::editOpenedFilter() {
|
|||
}
|
||||
|
||||
void InnerWidget::refresh(bool toTop) {
|
||||
if (needCollapsedRowsRefresh()) {
|
||||
if (!_geometryInited) {
|
||||
return;
|
||||
} else if (needCollapsedRowsRefresh()) {
|
||||
return refreshWithCollapsedRows(toTop);
|
||||
}
|
||||
refreshEmptyLabel();
|
||||
|
|
|
@ -112,6 +112,7 @@ public:
|
|||
void selectSkipPage(int32 pixels, int32 direction);
|
||||
|
||||
void dragLeft();
|
||||
void setNarrowRatio(float64 narrowRatio);
|
||||
|
||||
void clearFilter();
|
||||
void refresh(bool toTop = false);
|
||||
|
@ -235,7 +236,7 @@ private:
|
|||
void repaintDialogRow(FilterId filterId, not_null<Row*> row);
|
||||
void repaintDialogRow(RowDescriptor row);
|
||||
void refreshDialogRow(RowDescriptor row);
|
||||
void updateFilteredEntryHeight(not_null<Entry*> entry);
|
||||
bool updateEntryHeight(not_null<Entry*> entry);
|
||||
|
||||
void clearMouseSelection(bool clearSelection = false);
|
||||
void mousePressReleased(
|
||||
|
@ -496,6 +497,8 @@ private:
|
|||
rpl::event_stream<> _refreshHashtagsRequests;
|
||||
|
||||
rpl::variable<ChildListShown> _childListShown;
|
||||
float64 _narrowRatio = 0.;
|
||||
bool _geometryInited = false;
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> _menu;
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ not_null<Row*> List::addToEnd(Key key) {
|
|||
key,
|
||||
std::make_unique<Row>(key, _rows.size(), height())
|
||||
).first->second.get();
|
||||
result->recountHeight(_narrowRatio);
|
||||
_rows.emplace_back(result);
|
||||
if (_sortMode == SortMode::Date) {
|
||||
adjustByDate(result);
|
||||
|
@ -103,15 +104,36 @@ void List::adjustByDate(not_null<Row*> row) {
|
|||
}
|
||||
}
|
||||
|
||||
void List::updateHeight(not_null<Row*> row) {
|
||||
row->recountHeight();
|
||||
|
||||
bool List::updateHeight(Key key, float64 narrowRatio) {
|
||||
const auto i = _rowByKey.find(key);
|
||||
if (i == _rowByKey.cend()) {
|
||||
return false;
|
||||
}
|
||||
const auto row = i->second.get();
|
||||
const auto index = row->index();
|
||||
auto top = row->top();
|
||||
const auto was = row->height();
|
||||
row->recountHeight(narrowRatio);
|
||||
if (row->height() == was) {
|
||||
return false;
|
||||
}
|
||||
for (auto i = _rows.begin() + index, e = _rows.end(); i != e; ++i) {
|
||||
(*i)->_top = top;
|
||||
top += (*i)->height();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool List::updateHeights(float64 narrowRatio) {
|
||||
_narrowRatio = narrowRatio;
|
||||
auto was = height();
|
||||
auto top = 0;
|
||||
for (const auto &row : _rows) {
|
||||
row->_top = top;
|
||||
row->recountHeight(narrowRatio);
|
||||
top += row->height();
|
||||
}
|
||||
return (height() != was);
|
||||
}
|
||||
|
||||
bool List::moveToTop(Key key) {
|
||||
|
|
|
@ -48,7 +48,8 @@ public:
|
|||
not_null<Row*> addByName(Key key);
|
||||
bool moveToTop(Key key);
|
||||
void adjustByDate(not_null<Row*> row);
|
||||
void updateHeight(not_null<Row*> row);
|
||||
bool updateHeight(Key key, float64 narrowRatio);
|
||||
bool updateHeights(float64 narrowRatio);
|
||||
bool remove(Key key, Row *replacedBy = nullptr);
|
||||
|
||||
using const_iterator = std::vector<not_null<Row*>>::const_iterator;
|
||||
|
@ -76,6 +77,7 @@ private:
|
|||
|
||||
SortMode _sortMode = SortMode();
|
||||
FilterId _filterId = 0;
|
||||
float64 _narrowRatio = 0.;
|
||||
std::vector<not_null<Row*>> _rows;
|
||||
std::map<Key, std::unique_ptr<Row>> _rowByKey;
|
||||
|
||||
|
|
|
@ -107,10 +107,6 @@ void MainList::removeEntry(Key key) {
|
|||
recomputeFullListSize();
|
||||
}
|
||||
|
||||
void MainList::updateEntryHeight(const RowsByLetter &links) {
|
||||
_all.updateHeight(links);
|
||||
}
|
||||
|
||||
void MainList::recomputeFullListSize() {
|
||||
_fullListSize = std::max(_all.size(), loaded() ? 0 : _cloudListSize);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ public:
|
|||
|
||||
RowsByLetter addEntry(Key key);
|
||||
void removeEntry(Key key);
|
||||
void updateEntryHeight(const RowsByLetter &links);
|
||||
|
||||
void unreadStateChanged(
|
||||
const UnreadState &wasState,
|
||||
|
|
|
@ -101,13 +101,15 @@ Row::Row(Key key, int index, int top) : _id(key), _top(top), _index(index) {
|
|||
if (const auto history = key.history()) {
|
||||
updateCornerBadgeShown(history->peer);
|
||||
}
|
||||
recountHeight();
|
||||
}
|
||||
|
||||
void Row::recountHeight() {
|
||||
void Row::recountHeight(float64 narrowRatio) {
|
||||
if (const auto history = _id.history()) {
|
||||
_height = history->peer->isForum()
|
||||
? st::forumDialogRow.height
|
||||
? anim::interpolate(
|
||||
st::forumDialogRow.height,
|
||||
st::defaultDialogRow.height,
|
||||
narrowRatio)
|
||||
: st::defaultDialogRow.height;
|
||||
} else if (_id.folder()) {
|
||||
_height = st::defaultDialogRow.height;
|
||||
|
|
|
@ -89,9 +89,11 @@ public:
|
|||
return _top;
|
||||
}
|
||||
[[nodiscard]] int height() const {
|
||||
Expects(_height != 0);
|
||||
|
||||
return _height;
|
||||
}
|
||||
void recountHeight();
|
||||
void recountHeight(float64 narrowRatio);
|
||||
|
||||
void updateCornerBadgeShown(
|
||||
not_null<PeerData*> peer,
|
||||
|
|
|
@ -436,15 +436,19 @@ void Widget::chosenRow(const ChosenRow &row) {
|
|||
? history->peer->forumTopicFor(row.message.fullId.msg)
|
||||
: nullptr;
|
||||
if (topicJump) {
|
||||
if (!controller()->adaptive().isOneColumn()) {
|
||||
controller()->showForum(
|
||||
topicJump->forum(),
|
||||
Window::SectionShow().withChildColumn());
|
||||
if (controller()->shownForum().current() == topicJump->forum()) {
|
||||
controller()->closeForum();
|
||||
} else {
|
||||
if (!controller()->adaptive().isOneColumn()) {
|
||||
controller()->showForum(
|
||||
topicJump->forum(),
|
||||
Window::SectionShow().withChildColumn());
|
||||
}
|
||||
controller()->showThread(
|
||||
topicJump,
|
||||
ShowAtUnreadMsgId,
|
||||
Window::SectionShow::Way::ClearStack);
|
||||
}
|
||||
controller()->showThread(
|
||||
topicJump,
|
||||
ShowAtUnreadMsgId,
|
||||
Window::SectionShow::Way::ClearStack);
|
||||
return;
|
||||
} else if (const auto topic = row.key.topic()) {
|
||||
controller()->showThread(
|
||||
|
@ -2334,6 +2338,9 @@ void Widget::updateSearchFromVisibility(bool fast) {
|
|||
}
|
||||
|
||||
void Widget::updateControlsGeometry() {
|
||||
if (width() < _narrowWidth) {
|
||||
return;
|
||||
}
|
||||
auto filterAreaTop = 0;
|
||||
|
||||
const auto ratiow = anim::interpolate(
|
||||
|
@ -2434,6 +2441,7 @@ void Widget::updateControlsGeometry() {
|
|||
const auto wasScrollHeight = _scroll->height();
|
||||
_scroll->setGeometry(0, scrollTop, scrollw, scrollHeight);
|
||||
_inner->resize(scrollw, _inner->height());
|
||||
_inner->setNarrowRatio(narrowRatio);
|
||||
if (scrollHeight != wasScrollHeight) {
|
||||
controller()->floatPlayerAreaUpdated();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue