send_action_animations.h 981 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 Api {
  9. enum class SendProgressType;
  10. } // namespace Api
  11. namespace Ui {
  12. class SendActionAnimation {
  13. public:
  14. using Type = Api::SendProgressType;
  15. class Impl;
  16. SendActionAnimation();
  17. ~SendActionAnimation();
  18. void start(Type type);
  19. void tryToFinish();
  20. int width() const;
  21. int widthNoMargins() const;
  22. void paint(
  23. QPainter &p,
  24. style::color color,
  25. int x,
  26. int y,
  27. int outerWidth,
  28. crl::time ms) const;
  29. explicit operator bool() const {
  30. return _impl != nullptr;
  31. }
  32. static void PaintSpeakingIdle(
  33. QPainter &p,
  34. style::color color,
  35. int x,
  36. int y,
  37. int outerWidth);
  38. private:
  39. [[nodiscard]] static std::unique_ptr<Impl> CreateByType(Type type);
  40. std::unique_ptr<Impl> _impl;
  41. };
  42. } // namespace Ui