1 /* 2 This file is part of Telegram Desktop, 3 the official desktop application for the Telegram messaging service. 4 5 For license and copyright information please follow this link: 6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL 7 */ 8 #pragma once 9 10 #include "base/weak_ptr.h" 11 #include "base/timer.h" 12 #include "base/object_ptr.h" 13 #include "base/unique_qptr.h" 14 #include "ui/effects/animations.h" 15 #include "ui/effects/gradient.h" 16 #include "ui/rp_widget.h" 17 18 namespace Ui { 19 class IconButton; 20 class AbstractButton; 21 class LabelSimple; 22 class FlatLabel; 23 struct GroupCallUser; 24 class GroupCallUserpics; 25 } // namespace Ui 26 27 namespace Main { 28 class Session; 29 } // namespace Main 30 31 namespace Calls { 32 33 class Call; 34 class GroupCall; 35 class SignalBars; 36 class Mute; 37 enum class MuteState; 38 enum class BarState; 39 40 class TopBar : public Ui::RpWidget { 41 public: 42 TopBar(QWidget *parent, const base::weak_ptr<Call> &call); 43 TopBar(QWidget *parent, const base::weak_ptr<GroupCall> &call); 44 ~TopBar(); 45 46 void initBlobsUnder( 47 QWidget *blobsParent, 48 rpl::producer<QRect> barGeometry); 49 50 protected: 51 void resizeEvent(QResizeEvent *e) override; 52 void paintEvent(QPaintEvent *e) override; 53 54 private: 55 struct User; 56 57 TopBar( 58 QWidget *parent, 59 const base::weak_ptr<Call> &call, 60 const base::weak_ptr<GroupCall> &groupCall); 61 62 void initControls(); 63 void updateInfoLabels(); 64 void setInfoLabels(); 65 void updateDurationText(); 66 void updateControlsGeometry(); 67 void startDurationUpdateTimer(crl::time currentDuration); 68 void setMuted(bool mute); 69 70 void subscribeToMembersChanges(not_null<GroupCall*> call); 71 void updateUserpics(); 72 73 const base::weak_ptr<Call> _call; 74 const base::weak_ptr<GroupCall> _groupCall; 75 76 bool _muted = false; 77 std::vector<Ui::GroupCallUser> _users; 78 std::unique_ptr<Ui::GroupCallUserpics> _userpics; 79 int _userpicsWidth = 0; 80 object_ptr<Ui::LabelSimple> _durationLabel; 81 object_ptr<SignalBars> _signalBars; 82 object_ptr<Ui::FlatLabel> _fullInfoLabel; 83 object_ptr<Ui::FlatLabel> _shortInfoLabel; 84 object_ptr<Ui::LabelSimple> _hangupLabel; 85 object_ptr<Mute> _mute; 86 object_ptr<Ui::AbstractButton> _info; 87 object_ptr<Ui::IconButton> _hangup; 88 base::unique_qptr<Ui::RpWidget> _blobs; 89 90 rpl::variable<bool> _isGroupConnecting = false; 91 92 QBrush _groupBrush; 93 anim::linear_gradients<BarState> _gradients; 94 Ui::Animations::Simple _switchStateAnimation; 95 96 base::Timer _updateDurationTimer; 97 98 }; 99 100 } // namespace Calls 101