mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Add elastic overscroll to swipe-to-reply.
This commit is contained in:
@@ -671,6 +671,8 @@ PeerShortInfoBox::PeerShortInfoBox(
|
||||
) | rpl::start_with_next([=] {
|
||||
_cover.setScrollTop(_scroll->scrollTop());
|
||||
}, _cover.lifetime());
|
||||
|
||||
setCustomCornersFilling(RectPart::FullTop);
|
||||
}
|
||||
|
||||
PeerShortInfoBox::~PeerShortInfoBox() = default;
|
||||
@@ -795,10 +797,6 @@ void PeerShortInfoBox::prepareRows() {
|
||||
tr::lng_mediaview_copy(tr::now));
|
||||
}
|
||||
|
||||
RectParts PeerShortInfoBox::customCornersFilling() {
|
||||
return RectPart::FullTop;
|
||||
}
|
||||
|
||||
void PeerShortInfoBox::resizeEvent(QResizeEvent *e) {
|
||||
BoxContent::resizeEvent(e);
|
||||
|
||||
|
||||
@@ -162,7 +162,6 @@ public:
|
||||
private:
|
||||
void prepare() override;
|
||||
void prepareRows();
|
||||
RectParts customCornersFilling() override;
|
||||
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
|
||||
@@ -20,6 +20,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
namespace HistoryView {
|
||||
namespace {
|
||||
|
||||
constexpr auto kSwipeSlow = 0.2;
|
||||
|
||||
} // namespace
|
||||
|
||||
void SetupSwipeHandler(
|
||||
not_null<Ui::RpWidget*> widget,
|
||||
@@ -63,10 +68,16 @@ void SetupSwipeHandler(
|
||||
}, state->lifetime);
|
||||
|
||||
const auto updateRatio = [=](float64 ratio) {
|
||||
state->data.ratio = std::clamp(ratio, 0., kMaxRatio),
|
||||
ratio = std::max(ratio, 0.);
|
||||
state->data.ratio = ratio;
|
||||
const auto overscrollRatio = std::max(ratio - 1., 0.);
|
||||
const auto translation = int(
|
||||
base::SafeRound(-std::min(ratio, 1.) * threshold)
|
||||
) + Ui::OverscrollFromAccumulated(int(
|
||||
base::SafeRound(-overscrollRatio * threshold)
|
||||
));
|
||||
state->data.msgBareId = state->finishByTopData.msgBareId;
|
||||
state->data.translation = int(
|
||||
base::SafeRound(-std::clamp(ratio, 0., kMaxRatio) * threshold));
|
||||
state->data.translation = translation;
|
||||
state->data.cursorTop = state->cursorTop;
|
||||
update(state->data);
|
||||
};
|
||||
@@ -248,10 +259,11 @@ void SetupSwipeHandler(
|
||||
processEnd();
|
||||
} else {
|
||||
const auto invert = (w->inverted() ? -1 : 1);
|
||||
const auto delta = Ui::ScrollDeltaF(w) * invert;
|
||||
updateWith({
|
||||
.globalCursor = w->globalPosition().toPoint(),
|
||||
.position = QPointF(),
|
||||
.delta = state->delta + Ui::ScrollDelta(w) * invert,
|
||||
.delta = state->delta + delta * kSwipeSlow,
|
||||
.touch = false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1512,10 +1512,12 @@ void Message::draw(Painter &p, const PaintContext &context) const {
|
||||
+ ((g.height() < size * kMaxHeightRatio)
|
||||
? rightActionSize().value_or(QSize()).width()
|
||||
: 0);
|
||||
const auto shift = std::min(
|
||||
(size * kShiftRatio * context.gestureHorizontal.ratio),
|
||||
-1. * context.gestureHorizontal.translation
|
||||
) + (st::historySwipeIconSkip * ratio * (isLeftSize ? .7 : 1.));
|
||||
const auto rect = QRectF(
|
||||
outerWidth
|
||||
- (size * kShiftRatio * context.gestureHorizontal.ratio)
|
||||
- (st::historySwipeIconSkip * ratio * (isLeftSize ? .7 : 1.)),
|
||||
outerWidth - shift,
|
||||
g.y() + (g.height() - size) / 2,
|
||||
size,
|
||||
size);
|
||||
|
||||
+1
-1
Submodule Telegram/lib_ui updated: 9965046aac...9ca74272a0
Reference in New Issue
Block a user