2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-10-05 13:36:18 +00:00

Collapse forum row height in narrow layout.

This commit is contained in:
John Preston
2022-12-01 21:36:26 +04:00
parent c200263f2e
commit f0b8ccbd71
12 changed files with 92 additions and 43 deletions

View File

@@ -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) {