group_call_userpics.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/timer.h"
  9. namespace style {
  10. struct GroupCallUserpics;
  11. } // namespace style
  12. namespace Ui {
  13. struct GroupCallUser {
  14. QImage userpic;
  15. std::pair<uint64, uint64> userpicKey = {};
  16. uint64 id = 0;
  17. bool speaking = false;
  18. };
  19. class GroupCallUserpics final {
  20. public:
  21. GroupCallUserpics(
  22. const style::GroupCallUserpics &st,
  23. rpl::producer<bool> &&hideBlobs,
  24. Fn<void()> repaint);
  25. ~GroupCallUserpics();
  26. void update(
  27. const std::vector<GroupCallUser> &users,
  28. bool visible);
  29. void paint(QPainter &p, int x, int y, int size);
  30. void finishAnimating();
  31. [[nodiscard]] int maxWidth() const;
  32. [[nodiscard]] rpl::producer<int> widthValue() const;
  33. [[nodiscard]] rpl::lifetime &lifetime() {
  34. return _lifetime;
  35. }
  36. private:
  37. using User = GroupCallUser;
  38. struct BlobsAnimation;
  39. struct Userpic;
  40. void toggle(Userpic &userpic, bool shown);
  41. void updatePositions();
  42. void validateCache(Userpic &userpic);
  43. [[nodiscard]] bool needCacheRefresh(Userpic &userpic);
  44. void ensureBlobsAnimation(Userpic &userpic);
  45. void sendRandomLevels();
  46. void recountAndRepaint();
  47. const style::GroupCallUserpics &_st;
  48. std::vector<Userpic> _list;
  49. base::Timer _randomSpeakingTimer;
  50. Fn<void()> _repaint;
  51. Ui::Animations::Basic _speakingAnimation;
  52. int _maxWidth = 0;
  53. bool _skipLevelUpdate = false;
  54. crl::time _speakingAnimationHideLastTime = 0;
  55. rpl::variable<int> _width;
  56. rpl::lifetime _lifetime;
  57. };
  58. } // namespace Ui