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 "ui/abstract_button.h" 11 #include "ui/effects/animations.h" 12 #include "ui/rp_widget.h" 13 14 namespace Ui { 15 namespace Paint { 16 class Blobs; 17 } // namespace Paint 18 } // namespace Ui 19 20 namespace HistoryView::Controls { 21 22 class VoiceRecordButton final : public Ui::AbstractButton { 23 public: 24 VoiceRecordButton( 25 not_null<Ui::RpWidget*> parent, 26 rpl::producer<> leaveWindowEventProducer); 27 ~VoiceRecordButton(); 28 29 enum class Type { 30 Send, 31 Record, 32 }; 33 34 void setType(Type state); 35 36 void requestPaintColor(float64 progress); 37 void requestPaintProgress(float64 progress); 38 void requestPaintLevel(quint16 level); 39 40 [[nodiscard]] rpl::producer<bool> actives() const; 41 [[nodiscard]] rpl::producer<> clicks() const; 42 43 [[nodiscard]] bool inCircle(const QPoint &localPos) const; 44 45 private: 46 void init(); 47 48 std::unique_ptr<Ui::Paint::Blobs> _blobs; 49 50 crl::time _lastUpdateTime = 0; 51 crl::time _blobsHideLastTime = 0; 52 const int _center; 53 54 rpl::variable<float64> _showProgress = 0.; 55 float64 _colorProgress = 0.; 56 rpl::variable<bool> _inCircle = false; 57 rpl::variable<Type> _state = Type::Record; 58 59 // This can animate for a very long time (like in music playing), 60 // so it should be a Basic, not a Simple animation. 61 Ui::Animations::Basic _animation; 62 Ui::Animations::Simple _stateChangedAnimation; 63 }; 64 65 } // namespace HistoryView::Controls 66