mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Migrated SendingInfoTo from using of end geometry to end point.
This commit is contained in:
parent
6939da2fd2
commit
0dc2e1a5ae
4 changed files with 18 additions and 15 deletions
|
@ -5394,7 +5394,7 @@ void HistoryWidget::startMessageSendingAnimation(
|
||||||
Assert(item->mainView() != nullptr);
|
Assert(item->mainView() != nullptr);
|
||||||
Assert(item->mainView()->media() != nullptr);
|
Assert(item->mainView()->media() != nullptr);
|
||||||
|
|
||||||
auto globalEndGeometry = rpl::merge(
|
auto globalEndTopLeft = rpl::merge(
|
||||||
_scroll->innerResizes() | rpl::to_empty,
|
_scroll->innerResizes() | rpl::to_empty,
|
||||||
session().data().newItemAdded() | rpl::to_empty,
|
session().data().newItemAdded() | rpl::to_empty,
|
||||||
geometryValue() | rpl::to_empty,
|
geometryValue() | rpl::to_empty,
|
||||||
|
@ -5405,13 +5405,13 @@ void HistoryWidget::startMessageSendingAnimation(
|
||||||
const auto additional = (_list->height() == _scroll->height())
|
const auto additional = (_list->height() == _scroll->height())
|
||||||
? view->height()
|
? view->height()
|
||||||
: 0;
|
: 0;
|
||||||
return _list->mapToGlobal(view->innerGeometry().translated(
|
return _list->mapToGlobal(QPoint(
|
||||||
0,
|
0,
|
||||||
_list->itemTop(view) - additional));
|
_list->itemTop(view) - additional));
|
||||||
});
|
});
|
||||||
|
|
||||||
sendingAnimation.startAnimation({
|
sendingAnimation.startAnimation({
|
||||||
.globalEndGeometry = std::move(globalEndGeometry),
|
.globalEndTopLeft = std::move(globalEndTopLeft),
|
||||||
.view = [=] { return item->mainView(); },
|
.view = [=] { return item->mainView(); },
|
||||||
.paintContext = [=] { return _list->preparePaintContext({}); },
|
.paintContext = [=] { return _list->preparePaintContext({}); },
|
||||||
});
|
});
|
||||||
|
|
|
@ -1582,18 +1582,17 @@ void ListWidget::startMessageSendingAnimation(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto globalEndGeometry = rpl::merge(
|
auto globalEndTopLeft = rpl::merge(
|
||||||
session().data().newItemAdded() | rpl::to_empty,
|
session().data().newItemAdded() | rpl::to_empty,
|
||||||
geometryValue() | rpl::to_empty
|
geometryValue() | rpl::to_empty
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
const auto view = viewForItem(item);
|
const auto view = viewForItem(item);
|
||||||
const auto additional = !_visibleTop ? view->height() : 0;
|
const auto additional = !_visibleTop ? view->height() : 0;
|
||||||
return mapToGlobal(
|
return mapToGlobal(QPoint(0, itemTop(view) - additional));
|
||||||
view->innerGeometry().translated(0, itemTop(view) - additional));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
sendingAnimation.startAnimation({
|
sendingAnimation.startAnimation({
|
||||||
.globalEndGeometry = std::move(globalEndGeometry),
|
.globalEndTopLeft = std::move(globalEndTopLeft),
|
||||||
.view = [=] { return viewForItem(item); },
|
.view = [=] { return viewForItem(item); },
|
||||||
.paintContext = [=] { return preparePaintContext({}); },
|
.paintContext = [=] { return preparePaintContext({}); },
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,7 +53,7 @@ private:
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
MessageSendingAnimationController::SendingInfoTo _toInfo;
|
MessageSendingAnimationController::SendingInfoTo _toInfo;
|
||||||
QRect _from;
|
QRect _from;
|
||||||
QRect _to;
|
QPoint _to;
|
||||||
QRect _innerContentRect;
|
QRect _innerContentRect;
|
||||||
|
|
||||||
Animations::Simple _animation;
|
Animations::Simple _animation;
|
||||||
|
@ -74,7 +74,8 @@ Content::Content(
|
||||||
, _controller(controller)
|
, _controller(controller)
|
||||||
, _toInfo(std::move(to))
|
, _toInfo(std::move(to))
|
||||||
, _from(parent->mapFromGlobal(globalGeometryFrom))
|
, _from(parent->mapFromGlobal(globalGeometryFrom))
|
||||||
, _innerContentRect(view()->media()->contentRectForReactions()) {
|
, _innerContentRect(view()->media()->contentRectForReactions())
|
||||||
|
, _minScale(float64(_from.height()) / _innerContentRect.height()) {
|
||||||
Expects(_toInfo.view != nullptr);
|
Expects(_toInfo.view != nullptr);
|
||||||
Expects(_toInfo.paintContext != nullptr);
|
Expects(_toInfo.paintContext != nullptr);
|
||||||
|
|
||||||
|
@ -83,11 +84,10 @@ Content::Content(
|
||||||
raise();
|
raise();
|
||||||
|
|
||||||
base::take(
|
base::take(
|
||||||
_toInfo.globalEndGeometry
|
_toInfo.globalEndTopLeft
|
||||||
) | rpl::distinct_until_changed(
|
) | rpl::distinct_until_changed(
|
||||||
) | rpl::start_with_next([=](const QRect &r) {
|
) | rpl::start_with_next([=](const QPoint &p) {
|
||||||
_to = parent->mapFromGlobal(r);
|
_to = parent->mapFromGlobal(p);
|
||||||
_minScale = float64(_from.height()) / _to.height();
|
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_controller->session().downloaderTaskFinished(
|
_controller->session().downloaderTaskFinished(
|
||||||
|
@ -97,11 +97,15 @@ Content::Content(
|
||||||
|
|
||||||
resize(_innerContentRect.size());
|
resize(_innerContentRect.size());
|
||||||
|
|
||||||
|
const auto innerGeometry = view()->innerGeometry();
|
||||||
|
|
||||||
auto animationCallback = [=](float64 value) {
|
auto animationCallback = [=](float64 value) {
|
||||||
auto resultFrom = rect();
|
auto resultFrom = rect();
|
||||||
resultFrom.moveCenter(_from.center());
|
resultFrom.moveCenter(_from.center());
|
||||||
|
|
||||||
const auto resultTo = _to.topLeft() + _innerContentRect.topLeft();
|
const auto resultTo = _to
|
||||||
|
+ innerGeometry.topLeft()
|
||||||
|
+ _innerContentRect.topLeft();
|
||||||
const auto x = anim::interpolate(resultFrom.x(), resultTo.x(), value);
|
const auto x = anim::interpolate(resultFrom.x(), resultTo.x(), value);
|
||||||
const auto y = anim::interpolate(resultFrom.y(), resultTo.y(), value);
|
const auto y = anim::interpolate(resultFrom.y(), resultTo.y(), value);
|
||||||
moveToLeft(x, y);
|
moveToLeft(x, y);
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
not_null<Window::SessionController*> controller);
|
not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
struct SendingInfoTo {
|
struct SendingInfoTo {
|
||||||
rpl::producer<QRect> globalEndGeometry;
|
rpl::producer<QPoint> globalEndTopLeft;
|
||||||
Fn<not_null<HistoryView::Element*>()> view;
|
Fn<not_null<HistoryView::Element*>()> view;
|
||||||
Fn<Ui::ChatPaintContext()> paintContext;
|
Fn<Ui::ChatPaintContext()> paintContext;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue