mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 21:27:07 +02:00
Use only integer translations in reply swipe.
This commit is contained in:
parent
71e3cd227c
commit
e8dd2b9e7b
6 changed files with 23 additions and 16 deletions
|
@ -581,12 +581,16 @@ void HistoryInner::setupSharingDisallowed() {
|
|||
void HistoryInner::setupSwipeReply() {
|
||||
HistoryView::SetupSwipeHandler(this, _scroll, [=, history = _history](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
const auto changed = (_gestureHorizontal.msgBareId != data.msgBareId)
|
||||
|| (_gestureHorizontal.translation != data.translation);
|
||||
_gestureHorizontal = data;
|
||||
const auto item = history->peer->owner().message(
|
||||
history->peer->id,
|
||||
MsgId{ data.msgBareId });
|
||||
if (item) {
|
||||
repaintItem(item);
|
||||
if (changed) {
|
||||
const auto item = history->peer->owner().message(
|
||||
history->peer->id,
|
||||
MsgId{ data.msgBareId });
|
||||
if (item) {
|
||||
repaintItem(item);
|
||||
}
|
||||
}
|
||||
}, [=, show = _controller->uiShow()](int cursorTop) {
|
||||
auto result = HistoryView::SwipeHandlerFinishData();
|
||||
|
@ -1230,7 +1234,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
|
|||
// paint the userpic if it intersects the painted rect
|
||||
if (userpicTop + st::msgPhotoSize > clip.top()) {
|
||||
const auto item = view->data();
|
||||
const auto hasTranslation = _gestureHorizontal.ratio
|
||||
const auto hasTranslation = _gestureHorizontal.translation
|
||||
&& (_gestureHorizontal.msgBareId == item->fullId().msg.bare);
|
||||
if (hasTranslation) {
|
||||
p.translate(_gestureHorizontal.translation, 0);
|
||||
|
|
|
@ -48,7 +48,7 @@ void SetupSwipeHandler(
|
|||
update({
|
||||
.ratio = std::clamp(ratio, 0., 1.5),
|
||||
.reachRatio = state->animationReach.value(0.),
|
||||
.translation = (-std::clamp(ratio, 0., 1.5) * threshold),
|
||||
.translation = int(base::SafeRound(-std::clamp(ratio, 0., 1.5) * threshold)),
|
||||
.msgBareId = state->finishByTopData.msgBareId,
|
||||
.cursorTop = state->cursorTop,
|
||||
});
|
||||
|
|
|
@ -12,8 +12,8 @@ namespace HistoryView {
|
|||
struct ChatPaintGestureHorizontalData {
|
||||
float64 ratio = 0.;
|
||||
float64 reachRatio = 0.;
|
||||
float64 translation = 0.;
|
||||
int64 msgBareId = 0;
|
||||
int translation = 0;
|
||||
int cursorTop = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -2305,7 +2305,7 @@ void ListWidget::paintUserpics(
|
|||
// paint the userpic if it intersects the painted rect
|
||||
if (userpicTop + st::msgPhotoSize > clip.top()) {
|
||||
const auto item = view->data();
|
||||
const auto hasTranslation = context.gestureHorizontal.ratio
|
||||
const auto hasTranslation = context.gestureHorizontal.translation
|
||||
&& (context.gestureHorizontal.msgBareId == item->fullId().msg.bare);
|
||||
if (hasTranslation) {
|
||||
p.translate(context.gestureHorizontal.translation, 0);
|
||||
|
|
|
@ -1092,7 +1092,7 @@ void Message::draw(Painter &p, const PaintContext &context) const {
|
|||
const auto item = data();
|
||||
const auto media = this->media();
|
||||
|
||||
const auto hasGesture = context.gestureHorizontal.ratio
|
||||
const auto hasGesture = context.gestureHorizontal.translation
|
||||
&& (context.gestureHorizontal.msgBareId == item->fullId().msg.bare);
|
||||
if (hasGesture) {
|
||||
p.translate(context.gestureHorizontal.translation, 0);
|
||||
|
|
|
@ -882,13 +882,16 @@ void RepliesWidget::setupSwipeReply() {
|
|||
};
|
||||
HistoryView::SetupSwipeHandler(_inner, _scroll.get(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
const auto changed = (_gestureHorizontal.msgBareId != data.msgBareId)
|
||||
|| (_gestureHorizontal.translation != data.translation);
|
||||
_gestureHorizontal = data;
|
||||
const auto item = _history->peer->owner().message(
|
||||
_history->peer->id,
|
||||
MsgId{ data.msgBareId });
|
||||
if (item) {
|
||||
_inner->update();
|
||||
// repaintItem(item);
|
||||
if (changed) {
|
||||
const auto item = _history->peer->owner().message(
|
||||
_history->peer->id,
|
||||
MsgId{ data.msgBareId });
|
||||
if (item) {
|
||||
_history->owner().requestItemRepaint(item);
|
||||
}
|
||||
}
|
||||
}, [=, show = controller()->uiShow()](int cursorTop) {
|
||||
auto result = HistoryView::SwipeHandlerFinishData();
|
||||
|
|
Loading…
Add table
Reference in a new issue