group_call_bar.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 "ui/wrap/slide_wrap.h"
  9. #include "ui/effects/animations.h"
  10. #include "base/object_ptr.h"
  11. #include "base/timer.h"
  12. class Painter;
  13. namespace Ui {
  14. class PlainShadow;
  15. class RoundButton;
  16. struct GroupCallUser;
  17. class GroupCallUserpics;
  18. struct GroupCallBarContent {
  19. QString title;
  20. TimeId scheduleDate = 0;
  21. int count = 0;
  22. bool shown = false;
  23. bool livestream = false;
  24. std::vector<GroupCallUser> users;
  25. };
  26. class GroupCallScheduledLeft final {
  27. public:
  28. enum class Negative {
  29. Show,
  30. Ignore,
  31. };
  32. explicit GroupCallScheduledLeft(TimeId date);
  33. void setDate(TimeId date);
  34. [[nodiscard]] rpl::producer<QString> text(Negative negative) const;
  35. [[nodiscard]] rpl::producer<bool> late() const;
  36. private:
  37. [[nodiscard]] crl::time computePreciseDate() const;
  38. void restart();
  39. void update();
  40. rpl::variable<QString> _text;
  41. rpl::variable<QString> _textNonNegative;
  42. rpl::variable<bool> _late;
  43. TimeId _date = 0;
  44. crl::time _datePrecise = 0;
  45. base::Timer _timer;
  46. rpl::lifetime _lifetime;
  47. };
  48. class GroupCallBar final {
  49. public:
  50. GroupCallBar(
  51. not_null<QWidget*> parent,
  52. rpl::producer<GroupCallBarContent> content,
  53. rpl::producer<bool> &&hideBlobs);
  54. ~GroupCallBar();
  55. void show();
  56. void hide();
  57. void raise();
  58. void finishAnimating();
  59. void setShadowGeometryPostprocess(Fn<QRect(QRect)> postprocess);
  60. void move(int x, int y);
  61. void resizeToWidth(int width);
  62. [[nodiscard]] int height() const;
  63. [[nodiscard]] rpl::producer<int> heightValue() const;
  64. [[nodiscard]] rpl::producer<> barClicks() const;
  65. [[nodiscard]] rpl::producer<> joinClicks() const;
  66. [[nodiscard]] rpl::lifetime &lifetime() {
  67. return _wrap.lifetime();
  68. }
  69. private:
  70. using User = GroupCallUser;
  71. void refreshOpenBrush();
  72. void refreshScheduledProcess();
  73. void updateShadowGeometry(QRect wrapGeometry);
  74. void updateControlsGeometry(QRect wrapGeometry);
  75. void updateUserpics();
  76. void setupInner();
  77. void setupRightButton(not_null<RoundButton*> button);
  78. void paint(Painter &p);
  79. void paintTitleAndStatus(Painter &p);
  80. void paintUserpics(Painter &p);
  81. SlideWrap<> _wrap;
  82. not_null<RpWidget*> _inner;
  83. std::unique_ptr<RoundButton> _join;
  84. std::unique_ptr<RoundButton> _open;
  85. rpl::event_stream<Qt::MouseButton> _joinClicks;
  86. QBrush _openBrushOverride;
  87. int _openBrushForWidth = 0;
  88. std::unique_ptr<PlainShadow> _shadow;
  89. rpl::event_stream<> _barClicks;
  90. Fn<QRect(QRect)> _shadowGeometryPostprocess;
  91. bool _shouldBeShown = false;
  92. bool _forceHidden = false;
  93. GroupCallBarContent _content;
  94. std::unique_ptr<GroupCallScheduledLeft> _scheduledProcess;
  95. std::unique_ptr<GroupCallUserpics> _userpics;
  96. };
  97. } // namespace Ui