message_sending_animation_controller.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #include "base/unique_qptr.h"
  9. #include "ui/effects/message_sending_animation_common.h"
  10. namespace HistoryView {
  11. class Element;
  12. } // namespace HistoryView
  13. namespace Window {
  14. class SessionController;
  15. } // namespace Window
  16. namespace Ui {
  17. class RpWidget;
  18. struct ChatPaintContext;
  19. class MessageSendingAnimationController final {
  20. public:
  21. explicit MessageSendingAnimationController(
  22. not_null<Window::SessionController*> controller);
  23. struct SendingInfoTo {
  24. rpl::producer<std::optional<QPoint>> globalEndTopLeft;
  25. Fn<HistoryView::Element*()> view;
  26. Fn<Ui::ChatPaintContext()> paintContext;
  27. };
  28. void appendSending(MessageSendingAnimationFrom from);
  29. void startAnimation(SendingInfoTo &&to);
  30. [[nodiscard]] bool hasAnimatedMessage(not_null<HistoryItem*> item) const;
  31. [[nodiscard]] bool checkExpectedType(not_null<HistoryItem*> item);
  32. void clear();
  33. private:
  34. void subscribeToDestructions();
  35. const not_null<Window::SessionController*> _controller;
  36. base::flat_map<MsgId, MessageSendingAnimationFrom> _itemSendPending;
  37. base::flat_map<
  38. not_null<HistoryItem*>,
  39. base::unique_qptr<RpWidget>> _processing;
  40. rpl::lifetime _lifetime;
  41. };
  42. } // namespace Ui