calls_top_bar.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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/weak_ptr.h"
  9. #include "base/timer.h"
  10. #include "base/object_ptr.h"
  11. #include "base/unique_qptr.h"
  12. #include "ui/effects/animations.h"
  13. #include "ui/effects/gradient.h"
  14. #include "ui/rp_widget.h"
  15. namespace Ui {
  16. class IconButton;
  17. class AbstractButton;
  18. class LabelSimple;
  19. class FlatLabel;
  20. struct GroupCallUser;
  21. class GroupCallUserpics;
  22. class Show;
  23. } // namespace Ui
  24. namespace Main {
  25. class Session;
  26. } // namespace Main
  27. namespace Calls {
  28. class Call;
  29. class GroupCall;
  30. class SignalBars;
  31. class Mute;
  32. enum class MuteState;
  33. enum class BarState;
  34. class TopBar : public Ui::RpWidget {
  35. public:
  36. TopBar(
  37. QWidget *parent,
  38. const base::weak_ptr<Call> &call,
  39. std::shared_ptr<Ui::Show> show);
  40. TopBar(
  41. QWidget *parent,
  42. const base::weak_ptr<GroupCall> &call,
  43. std::shared_ptr<Ui::Show> show);
  44. ~TopBar();
  45. void initBlobsUnder(
  46. QWidget *blobsParent,
  47. rpl::producer<QRect> barGeometry);
  48. protected:
  49. void resizeEvent(QResizeEvent *e) override;
  50. void paintEvent(QPaintEvent *e) override;
  51. private:
  52. struct User;
  53. TopBar(
  54. QWidget *parent,
  55. std::shared_ptr<Ui::Show> show,
  56. const base::weak_ptr<Call> &call,
  57. const base::weak_ptr<GroupCall> &groupCall);
  58. void initControls();
  59. void setupInitialBrush();
  60. void updateInfoLabels();
  61. void setInfoLabels();
  62. void updateDurationText();
  63. void updateControlsGeometry();
  64. void startDurationUpdateTimer(crl::time currentDuration);
  65. void setMuted(bool mute);
  66. void subscribeToMembersChanges(not_null<GroupCall*> call);
  67. void updateUserpics();
  68. const base::weak_ptr<Call> _call;
  69. const base::weak_ptr<GroupCall> _groupCall;
  70. const std::shared_ptr<Ui::Show> _show;
  71. bool _muted = false;
  72. std::vector<Ui::GroupCallUser> _users;
  73. std::unique_ptr<Ui::GroupCallUserpics> _userpics;
  74. int _userpicsWidth = 0;
  75. object_ptr<Ui::LabelSimple> _durationLabel;
  76. object_ptr<SignalBars> _signalBars;
  77. object_ptr<Ui::FlatLabel> _fullInfoLabel;
  78. object_ptr<Ui::FlatLabel> _shortInfoLabel;
  79. object_ptr<Ui::LabelSimple> _hangupLabel;
  80. object_ptr<Mute> _mute;
  81. object_ptr<Ui::AbstractButton> _info;
  82. object_ptr<Ui::IconButton> _hangup;
  83. base::unique_qptr<Ui::RpWidget> _blobs;
  84. rpl::variable<bool> _isGroupConnecting = false;
  85. QBrush _groupBrush;
  86. anim::linear_gradients<BarState> _gradients;
  87. Ui::Animations::Simple _switchStateAnimation;
  88. Fn<void(float64)> _switchStateCallback;
  89. base::Timer _updateDurationTimer;
  90. };
  91. } // namespace Calls