2024-09-02 20:14:33 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Ui {
|
2025-02-17 20:00:30 +03:00
|
|
|
class ElasticScroll;
|
2024-09-02 20:14:33 +03:00
|
|
|
class RpWidget;
|
|
|
|
class ScrollArea;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2025-02-19 00:12:58 +03:00
|
|
|
namespace Ui::Controls {
|
2025-02-17 15:13:56 +03:00
|
|
|
|
2025-02-19 00:21:05 +03:00
|
|
|
struct SwipeContextData;
|
|
|
|
struct SwipeBackResult;
|
|
|
|
|
2024-09-02 20:14:33 +03:00
|
|
|
struct SwipeHandlerFinishData {
|
|
|
|
Fn<void(void)> callback;
|
|
|
|
int64 msgBareId = 0;
|
2025-02-18 00:04:51 +03:00
|
|
|
float64 speedRatio = 1.0;
|
2025-03-16 19:00:59 +03:00
|
|
|
crl::time reachRatioDuration = 0;
|
2025-02-19 22:29:09 +03:00
|
|
|
bool keepRatioWithinRange = false;
|
2025-03-16 18:57:46 +03:00
|
|
|
bool provideReachOutRatio = false;
|
2024-09-02 20:14:33 +03:00
|
|
|
};
|
|
|
|
|
2025-02-17 20:00:30 +03:00
|
|
|
using Scroll = std::variant<
|
|
|
|
v::null_t,
|
|
|
|
not_null<Ui::ScrollArea*>,
|
|
|
|
not_null<Ui::ElasticScroll*>>;
|
|
|
|
|
2025-03-24 14:50:11 +03:00
|
|
|
struct SwipeHandlerArgs {
|
|
|
|
not_null<Ui::RpWidget*> widget;
|
|
|
|
Scroll scroll;
|
|
|
|
Fn<void(SwipeContextData)> update;
|
|
|
|
Fn<SwipeHandlerFinishData(int, Qt::LayoutDirection)> init;
|
|
|
|
rpl::producer<bool> dontStart = nullptr;
|
|
|
|
rpl::lifetime *onLifetime = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetupSwipeHandler(SwipeHandlerArgs &&args);
|
2024-09-02 20:14:33 +03:00
|
|
|
|
2025-02-19 00:21:05 +03:00
|
|
|
[[nodiscard]] SwipeBackResult SetupSwipeBack(
|
2025-02-17 15:13:56 +03:00
|
|
|
not_null<Ui::RpWidget*> widget,
|
2025-02-18 21:17:57 +03:00
|
|
|
Fn<std::pair<QColor, QColor>()> colors,
|
2025-03-08 04:05:25 +03:00
|
|
|
bool mirrored = false,
|
|
|
|
bool iconMirrored = false);
|
2025-02-17 15:13:56 +03:00
|
|
|
|
2025-02-18 00:04:51 +03:00
|
|
|
[[nodiscard]] SwipeHandlerFinishData DefaultSwipeBackHandlerFinishData(
|
|
|
|
Fn<void(void)> callback);
|
|
|
|
|
2025-02-19 00:12:58 +03:00
|
|
|
} // namespace Ui::Controls
|