swipe_handler.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. namespace Ui {
  9. class ElasticScroll;
  10. class RpWidget;
  11. class ScrollArea;
  12. } // namespace Ui
  13. namespace Ui::Controls {
  14. struct SwipeContextData;
  15. struct SwipeBackResult;
  16. struct SwipeHandlerFinishData {
  17. Fn<void(void)> callback;
  18. int64 msgBareId = 0;
  19. float64 speedRatio = 1.0;
  20. crl::time reachRatioDuration = 0;
  21. bool keepRatioWithinRange = false;
  22. bool provideReachOutRatio = false;
  23. };
  24. using Scroll = std::variant<
  25. v::null_t,
  26. not_null<Ui::ScrollArea*>,
  27. not_null<Ui::ElasticScroll*>>;
  28. void SetupSwipeHandler(
  29. not_null<Ui::RpWidget*> widget,
  30. Scroll scroll,
  31. Fn<void(SwipeContextData)> update,
  32. Fn<SwipeHandlerFinishData(int, Qt::LayoutDirection)> generateFinishByTop,
  33. rpl::producer<bool> dontStart = nullptr,
  34. rpl::lifetime *onLifetime = nullptr);
  35. [[nodiscard]] SwipeBackResult SetupSwipeBack(
  36. not_null<Ui::RpWidget*> widget,
  37. Fn<std::pair<QColor, QColor>()> colors,
  38. bool mirrored = false,
  39. bool iconMirrored = false);
  40. [[nodiscard]] SwipeHandlerFinishData DefaultSwipeBackHandlerFinishData(
  41. Fn<void(void)> callback);
  42. } // namespace Ui::Controls