calls_group_members_row.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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 "boxes/peer_list_box.h"
  9. #include "calls/group/calls_group_common.h"
  10. class PeerData;
  11. class Painter;
  12. namespace Data {
  13. struct GroupCallParticipant;
  14. } // namespace Data
  15. namespace Ui {
  16. class RippleAnimation;
  17. struct PeerUserpicView;
  18. } // namespace Ui
  19. namespace Calls::Group {
  20. enum class MembersRowStyle {
  21. Default,
  22. Narrow,
  23. Video,
  24. };
  25. class MembersRow;
  26. class MembersRowDelegate {
  27. public:
  28. struct IconState {
  29. float64 speaking = 0.;
  30. float64 active = 0.;
  31. float64 muted = 0.;
  32. bool mutedByMe = false;
  33. bool raisedHand = false;
  34. bool invited = false;
  35. MembersRowStyle style = MembersRowStyle::Default;
  36. };
  37. virtual bool rowIsMe(not_null<PeerData*> participantPeer) = 0;
  38. virtual bool rowCanMuteMembers() = 0;
  39. virtual void rowUpdateRow(not_null<MembersRow*> row) = 0;
  40. virtual void rowScheduleRaisedHandStatusRemove(
  41. not_null<MembersRow*> row) = 0;
  42. virtual void rowPaintIcon(
  43. QPainter &p,
  44. QRect rect,
  45. const IconState &state) = 0;
  46. virtual int rowPaintStatusIcon(
  47. QPainter &p,
  48. int x,
  49. int y,
  50. int outerWidth,
  51. not_null<MembersRow*> row,
  52. const IconState &state) = 0;
  53. virtual bool rowIsNarrow() = 0;
  54. virtual void rowShowContextMenu(not_null<PeerListRow*> row) = 0;
  55. };
  56. class MembersRow final : public PeerListRow {
  57. public:
  58. MembersRow(
  59. not_null<MembersRowDelegate*> delegate,
  60. not_null<PeerData*> participantPeer);
  61. ~MembersRow();
  62. enum class State {
  63. Active,
  64. Inactive,
  65. Muted,
  66. RaisedHand,
  67. Invited,
  68. };
  69. void setAbout(const QString &about);
  70. void setSkipLevelUpdate(bool value);
  71. void updateState(const Data::GroupCallParticipant *participant);
  72. void updateLevel(float level);
  73. void updateBlobAnimation(crl::time now);
  74. void clearRaisedHandStatus();
  75. [[nodiscard]] State state() const {
  76. return _state;
  77. }
  78. [[nodiscard]] bool sounding() const {
  79. return _sounding;
  80. }
  81. [[nodiscard]] bool speaking() const {
  82. return _speaking;
  83. }
  84. [[nodiscard]] bool mutedByMe() const {
  85. return _mutedByMe;
  86. }
  87. [[nodiscard]] crl::time speakingLastTime() const {
  88. return _speakingLastTime;
  89. }
  90. [[nodiscard]] int volume() const {
  91. return _volume;
  92. }
  93. [[nodiscard]] uint64 raisedHandRating() const {
  94. return _raisedHandRating;
  95. }
  96. void refreshName(const style::PeerListItem &st) override;
  97. void rightActionAddRipple(
  98. QPoint point,
  99. Fn<void()> updateCallback) override;
  100. void rightActionStopLastRipple() override;
  101. QSize rightActionSize() const override;
  102. bool rightActionDisabled() const override;
  103. QMargins rightActionMargins() const override;
  104. void rightActionPaint(
  105. Painter &p,
  106. int x,
  107. int y,
  108. int outerWidth,
  109. bool selected,
  110. bool actionSelected) override;
  111. PaintRoundImageCallback generatePaintUserpicCallback(
  112. bool forceRound) override;
  113. void paintComplexUserpic(
  114. Painter &p,
  115. int x,
  116. int y,
  117. int outerWidth,
  118. int sizew,
  119. int sizeh,
  120. PanelMode mode,
  121. bool selected = false);
  122. void paintStatusText(
  123. Painter &p,
  124. const style::PeerListItem &st,
  125. int x,
  126. int y,
  127. int availableWidth,
  128. int outerWidth,
  129. bool selected) override;
  130. void paintComplexStatusText(
  131. Painter &p,
  132. const style::PeerListItem &st,
  133. int x,
  134. int y,
  135. int availableWidth,
  136. int outerWidth,
  137. bool selected,
  138. MembersRowStyle style);
  139. void paintMuteIcon(
  140. QPainter &p,
  141. QRect iconRect,
  142. MembersRowStyle style = MembersRowStyle::Default);
  143. [[nodiscard]] MembersRowDelegate::IconState computeIconState(
  144. MembersRowStyle style = MembersRowStyle::Default) const;
  145. void showContextMenu();
  146. private:
  147. struct BlobsAnimation;
  148. struct StatusIcon;
  149. int statusIconWidth(bool skipIcon) const;
  150. int statusIconHeight() const;
  151. void paintStatusIcon(
  152. Painter &p,
  153. int x,
  154. int y,
  155. const style::PeerListItem &st,
  156. const style::font &font,
  157. bool selected,
  158. bool skipIcon);
  159. void refreshStatus() override;
  160. void setSounding(bool sounding);
  161. void setSpeaking(bool speaking);
  162. void setState(State state);
  163. void setVolume(int volume);
  164. void ensureUserpicCache(
  165. Ui::PeerUserpicView &view,
  166. int size);
  167. void paintBlobs(
  168. Painter &p,
  169. int x,
  170. int y,
  171. int sizew,
  172. int sizeh, PanelMode mode);
  173. void paintScaledUserpic(
  174. Painter &p,
  175. Ui::PeerUserpicView &userpic,
  176. int x,
  177. int y,
  178. int outerWidth,
  179. int sizew,
  180. int sizeh,
  181. PanelMode mode);
  182. const not_null<MembersRowDelegate*> _delegate;
  183. State _state = State::Inactive;
  184. std::unique_ptr<Ui::RippleAnimation> _actionRipple;
  185. std::unique_ptr<BlobsAnimation> _blobsAnimation;
  186. std::unique_ptr<StatusIcon> _statusIcon;
  187. Ui::Animations::Simple _speakingAnimation; // For gray-red/green icon.
  188. Ui::Animations::Simple _mutedAnimation; // For gray/red icon.
  189. Ui::Animations::Simple _activeAnimation; // For icon cross animation.
  190. Ui::Text::String _about;
  191. crl::time _speakingLastTime = 0;
  192. uint64 _raisedHandRating = 0;
  193. int _volume = Group::kDefaultVolume;
  194. bool _sounding : 1 = false;
  195. bool _speaking : 1 = false;
  196. bool _raisedHandStatus : 1 = false;
  197. bool _skipLevelUpdate : 1 = false;
  198. bool _mutedByMe : 1 = false;
  199. };
  200. } // namespace Calls::Group