mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Bring second large peer video to the top.
This commit is contained in:
parent
6a001f2e6c
commit
ec9fa00f46
2 changed files with 50 additions and 14 deletions
|
@ -415,24 +415,12 @@ void Viewport::updateTilesGeometryWide(int outerWidth, int outerHeight) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewport::updateTilesGeometryNarrow(int outerWidth) {
|
void Viewport::updateTilesGeometryNarrow(int outerWidth) {
|
||||||
const auto y = -_scrollTop;
|
|
||||||
|
|
||||||
if (outerWidth <= st::groupCallNarrowMembersWidth) {
|
if (outerWidth <= st::groupCallNarrowMembersWidth) {
|
||||||
auto top = 0;
|
updateTilesGeometryColumn(outerWidth);
|
||||||
for (const auto &tile : _tiles) {
|
|
||||||
const auto video = tile.get();
|
|
||||||
const auto size = video->trackSize();
|
|
||||||
const auto shown = !size.isEmpty() && _large && video != _large;
|
|
||||||
const auto height = shown
|
|
||||||
? st::groupCallNarrowVideoHeight
|
|
||||||
: 0;
|
|
||||||
video->setGeometry({ 0, y + top, outerWidth, height });
|
|
||||||
top += height ? (height + st::groupCallVideoSmallSkip) : 0;
|
|
||||||
}
|
|
||||||
_fullHeight = top;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto y = -_scrollTop;
|
||||||
auto sizes = base::flat_map<not_null<VideoTile*>, QSize>();
|
auto sizes = base::flat_map<not_null<VideoTile*>, QSize>();
|
||||||
sizes.reserve(_tiles.size());
|
sizes.reserve(_tiles.size());
|
||||||
for (const auto &tile : _tiles) {
|
for (const auto &tile : _tiles) {
|
||||||
|
@ -493,7 +481,53 @@ void Viewport::updateTilesGeometryNarrow(int outerWidth) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_fullHeight = rows * (min + skip);
|
_fullHeight = rows * (min + skip);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Viewport::updateTilesGeometryColumn(int outerWidth) {
|
||||||
|
const auto y = -_scrollTop;
|
||||||
|
auto top = 0;
|
||||||
|
const auto layoutNext = [&](not_null<VideoTile*> tile) {
|
||||||
|
const auto size = tile->trackSize();
|
||||||
|
const auto shown = !size.isEmpty() && _large && tile != _large;
|
||||||
|
const auto height = shown
|
||||||
|
? st::groupCallNarrowVideoHeight
|
||||||
|
: 0;
|
||||||
|
tile->setGeometry({ 0, y + top, outerWidth, height });
|
||||||
|
top += height ? (height + st::groupCallVideoSmallSkip) : 0;
|
||||||
|
};
|
||||||
|
const auto topPeer = _large ? _large->row()->peer().get() : nullptr;
|
||||||
|
const auto reorderNeeded = [&] {
|
||||||
|
if (!_large) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (const auto &tile : _tiles) {
|
||||||
|
if (tile.get() != _large && tile->row()->peer() == topPeer) {
|
||||||
|
return (tile.get() != _tiles.front().get())
|
||||||
|
&& !tile->trackSize().isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}();
|
||||||
|
if (reorderNeeded) {
|
||||||
|
_tilesForOrder.clear();
|
||||||
|
_tilesForOrder.reserve(_tiles.size());
|
||||||
|
for (const auto &tile : _tiles) {
|
||||||
|
_tilesForOrder.push_back(tile.get());
|
||||||
|
}
|
||||||
|
ranges::stable_partition(
|
||||||
|
_tilesForOrder,
|
||||||
|
[&](not_null<VideoTile*> tile) {
|
||||||
|
return (tile->row()->peer() == topPeer);
|
||||||
|
});
|
||||||
|
for (const auto &tile : _tilesForOrder) {
|
||||||
|
layoutNext(tile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (const auto &tile : _tiles) {
|
||||||
|
layoutNext(tile.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_fullHeight = top;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewport::setTileGeometry(not_null<VideoTile*> tile, QRect geometry) {
|
void Viewport::setTileGeometry(not_null<VideoTile*> tile, QRect geometry) {
|
||||||
|
|
|
@ -117,6 +117,7 @@ private:
|
||||||
void updateTilesGeometry(int outerWidth);
|
void updateTilesGeometry(int outerWidth);
|
||||||
void updateTilesGeometryWide(int outerWidth, int outerHeight);
|
void updateTilesGeometryWide(int outerWidth, int outerHeight);
|
||||||
void updateTilesGeometryNarrow(int outerWidth);
|
void updateTilesGeometryNarrow(int outerWidth);
|
||||||
|
void updateTilesGeometryColumn(int outerWidth);
|
||||||
void setTileGeometry(not_null<VideoTile*> tile, QRect geometry);
|
void setTileGeometry(not_null<VideoTile*> tile, QRect geometry);
|
||||||
void refreshHasTwoOrMore();
|
void refreshHasTwoOrMore();
|
||||||
void updateTopControlsVisibility();
|
void updateTopControlsVisibility();
|
||||||
|
@ -138,6 +139,7 @@ private:
|
||||||
bool _geometryStaleAfterModeChange = false;
|
bool _geometryStaleAfterModeChange = false;
|
||||||
const std::unique_ptr<Ui::RpWidgetWrap> _content;
|
const std::unique_ptr<Ui::RpWidgetWrap> _content;
|
||||||
std::vector<std::unique_ptr<VideoTile>> _tiles;
|
std::vector<std::unique_ptr<VideoTile>> _tiles;
|
||||||
|
std::vector<not_null<VideoTile*>> _tilesForOrder;
|
||||||
rpl::variable<int> _fullHeight = 0;
|
rpl::variable<int> _fullHeight = 0;
|
||||||
bool _hasTwoOrMore = false;
|
bool _hasTwoOrMore = false;
|
||||||
int _scrollTop = 0;
|
int _scrollTop = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue