Fix large video being removed animation.

This commit is contained in:
John Preston 2021-06-07 19:38:48 +04:00
parent 945411274f
commit 4f8989fad7
2 changed files with 24 additions and 9 deletions

View file

@ -525,16 +525,30 @@ Viewport::Layout Viewport::countWide(int outerWidth, int outerHeight) const {
}
void Viewport::showLarge(const VideoEndpoint &endpoint) {
const auto i = ranges::find(_tiles, endpoint, &VideoTile::endpoint);
const auto large = (i != end(_tiles)) ? i->get() : nullptr;
if (_large != large) {
prepareLargeChangeAnimation();
_large = large;
updateTopControlsVisibility();
startLargeChangeAnimation();
}
// If a video get's switched off, GroupCall first unpins it,
// then removes it from Large endpoint, then removes from active tracks.
//
// If we want to animate large video removal properly, we need to
// delay this update and start animation directly from removing of the
// track from the active list. Otherwise final state won't be correct.
_updateLargeScheduled = [=] {
const auto i = ranges::find(_tiles, endpoint, &VideoTile::endpoint);
const auto large = (i != end(_tiles)) ? i->get() : nullptr;
if (_large != large) {
prepareLargeChangeAnimation();
_large = large;
updateTopControlsVisibility();
startLargeChangeAnimation();
}
Ensures(!_large || !_large->trackOrUserpicSize().isEmpty());
Ensures(!_large || !_large->trackOrUserpicSize().isEmpty());
};
crl::on_main(widget(), [=] {
if (!_updateLargeScheduled) {
return;
}
base::take(_updateLargeScheduled)();
});
}
void Viewport::updateTilesGeometry() {

View file

@ -176,6 +176,7 @@ private:
rpl::event_stream<VideoQualityRequest> _qualityRequests;
float64 _controlsShownRatio = 1.;
VideoTile *_large = nullptr;
Fn<void()> _updateLargeScheduled;
Ui::Animations::Simple _largeChangeAnimation;
Layout _startTilesLayout;
Layout _finishTilesLayout;