mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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() {
|
void HistoryInner::setupSwipeReply() {
|
||||||
HistoryView::SetupSwipeHandler(this, _scroll, [=, history = _history](
|
HistoryView::SetupSwipeHandler(this, _scroll, [=, history = _history](
|
||||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||||
|
const auto changed = (_gestureHorizontal.msgBareId != data.msgBareId)
|
||||||
|
|| (_gestureHorizontal.translation != data.translation);
|
||||||
_gestureHorizontal = data;
|
_gestureHorizontal = data;
|
||||||
const auto item = history->peer->owner().message(
|
if (changed) {
|
||||||
history->peer->id,
|
const auto item = history->peer->owner().message(
|
||||||
MsgId{ data.msgBareId });
|
history->peer->id,
|
||||||
if (item) {
|
MsgId{ data.msgBareId });
|
||||||
repaintItem(item);
|
if (item) {
|
||||||
|
repaintItem(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [=, show = _controller->uiShow()](int cursorTop) {
|
}, [=, show = _controller->uiShow()](int cursorTop) {
|
||||||
auto result = HistoryView::SwipeHandlerFinishData();
|
auto result = HistoryView::SwipeHandlerFinishData();
|
||||||
|
@ -1230,7 +1234,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
|
||||||
// paint the userpic if it intersects the painted rect
|
// paint the userpic if it intersects the painted rect
|
||||||
if (userpicTop + st::msgPhotoSize > clip.top()) {
|
if (userpicTop + st::msgPhotoSize > clip.top()) {
|
||||||
const auto item = view->data();
|
const auto item = view->data();
|
||||||
const auto hasTranslation = _gestureHorizontal.ratio
|
const auto hasTranslation = _gestureHorizontal.translation
|
||||||
&& (_gestureHorizontal.msgBareId == item->fullId().msg.bare);
|
&& (_gestureHorizontal.msgBareId == item->fullId().msg.bare);
|
||||||
if (hasTranslation) {
|
if (hasTranslation) {
|
||||||
p.translate(_gestureHorizontal.translation, 0);
|
p.translate(_gestureHorizontal.translation, 0);
|
||||||
|
|
|
@ -48,7 +48,7 @@ void SetupSwipeHandler(
|
||||||
update({
|
update({
|
||||||
.ratio = std::clamp(ratio, 0., 1.5),
|
.ratio = std::clamp(ratio, 0., 1.5),
|
||||||
.reachRatio = state->animationReach.value(0.),
|
.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,
|
.msgBareId = state->finishByTopData.msgBareId,
|
||||||
.cursorTop = state->cursorTop,
|
.cursorTop = state->cursorTop,
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,8 +12,8 @@ namespace HistoryView {
|
||||||
struct ChatPaintGestureHorizontalData {
|
struct ChatPaintGestureHorizontalData {
|
||||||
float64 ratio = 0.;
|
float64 ratio = 0.;
|
||||||
float64 reachRatio = 0.;
|
float64 reachRatio = 0.;
|
||||||
float64 translation = 0.;
|
|
||||||
int64 msgBareId = 0;
|
int64 msgBareId = 0;
|
||||||
|
int translation = 0;
|
||||||
int cursorTop = 0;
|
int cursorTop = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2305,7 +2305,7 @@ void ListWidget::paintUserpics(
|
||||||
// paint the userpic if it intersects the painted rect
|
// paint the userpic if it intersects the painted rect
|
||||||
if (userpicTop + st::msgPhotoSize > clip.top()) {
|
if (userpicTop + st::msgPhotoSize > clip.top()) {
|
||||||
const auto item = view->data();
|
const auto item = view->data();
|
||||||
const auto hasTranslation = context.gestureHorizontal.ratio
|
const auto hasTranslation = context.gestureHorizontal.translation
|
||||||
&& (context.gestureHorizontal.msgBareId == item->fullId().msg.bare);
|
&& (context.gestureHorizontal.msgBareId == item->fullId().msg.bare);
|
||||||
if (hasTranslation) {
|
if (hasTranslation) {
|
||||||
p.translate(context.gestureHorizontal.translation, 0);
|
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 item = data();
|
||||||
const auto media = this->media();
|
const auto media = this->media();
|
||||||
|
|
||||||
const auto hasGesture = context.gestureHorizontal.ratio
|
const auto hasGesture = context.gestureHorizontal.translation
|
||||||
&& (context.gestureHorizontal.msgBareId == item->fullId().msg.bare);
|
&& (context.gestureHorizontal.msgBareId == item->fullId().msg.bare);
|
||||||
if (hasGesture) {
|
if (hasGesture) {
|
||||||
p.translate(context.gestureHorizontal.translation, 0);
|
p.translate(context.gestureHorizontal.translation, 0);
|
||||||
|
|
|
@ -882,13 +882,16 @@ void RepliesWidget::setupSwipeReply() {
|
||||||
};
|
};
|
||||||
HistoryView::SetupSwipeHandler(_inner, _scroll.get(), [=](
|
HistoryView::SetupSwipeHandler(_inner, _scroll.get(), [=](
|
||||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||||
|
const auto changed = (_gestureHorizontal.msgBareId != data.msgBareId)
|
||||||
|
|| (_gestureHorizontal.translation != data.translation);
|
||||||
_gestureHorizontal = data;
|
_gestureHorizontal = data;
|
||||||
const auto item = _history->peer->owner().message(
|
if (changed) {
|
||||||
_history->peer->id,
|
const auto item = _history->peer->owner().message(
|
||||||
MsgId{ data.msgBareId });
|
_history->peer->id,
|
||||||
if (item) {
|
MsgId{ data.msgBareId });
|
||||||
_inner->update();
|
if (item) {
|
||||||
// repaintItem(item);
|
_history->owner().requestItemRepaint(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [=, show = controller()->uiShow()](int cursorTop) {
|
}, [=, show = controller()->uiShow()](int cursorTop) {
|
||||||
auto result = HistoryView::SwipeHandlerFinishData();
|
auto result = HistoryView::SwipeHandlerFinishData();
|
||||||
|
|
Loading…
Add table
Reference in a new issue