calls_volume_item.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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/rp_widget.h"
  9. #include "ui/widgets/menu/menu_item_base.h"
  10. namespace Ui {
  11. class CrossLineAnimation;
  12. class MediaSlider;
  13. namespace Paint {
  14. class ArcsAnimation;
  15. } // namespace Paint
  16. } // namespace Ui
  17. namespace Calls {
  18. namespace Group {
  19. struct MuteRequest;
  20. struct VolumeRequest;
  21. struct ParticipantState;
  22. } // namespace Group
  23. class MenuVolumeItem final : public Ui::Menu::ItemBase {
  24. public:
  25. MenuVolumeItem(
  26. not_null<RpWidget*> parent,
  27. const style::Menu &st,
  28. const style::MediaSlider &stSlider,
  29. rpl::producer<Group::ParticipantState> participantState,
  30. int startVolume,
  31. int maxVolume,
  32. bool muted,
  33. const QMargins &padding);
  34. not_null<QAction*> action() const override;
  35. bool isEnabled() const override;
  36. [[nodiscard]] rpl::producer<bool> toggleMuteRequests() const;
  37. [[nodiscard]] rpl::producer<bool> toggleMuteLocallyRequests() const;
  38. [[nodiscard]] rpl::producer<int> changeVolumeRequests() const;
  39. [[nodiscard]] rpl::producer<int> changeVolumeLocallyRequests() const;
  40. protected:
  41. int contentHeight() const override;
  42. private:
  43. void initArcsAnimation();
  44. void setCloudVolume(int volume);
  45. void setSliderVolume(int volume);
  46. void updateSliderColor(float64 value);
  47. QColor unmuteColor() const;
  48. QColor muteColor() const;
  49. const int _maxVolume;
  50. int _cloudVolume = 0;
  51. bool _waitingForUpdateVolume = false;
  52. bool _cloudMuted = false;
  53. bool _localMuted = false;
  54. QRect _itemRect;
  55. QRect _speakerRect;
  56. QPoint _arcPosition;
  57. const base::unique_qptr<Ui::MediaSlider> _slider;
  58. const not_null<QAction*> _dummyAction;
  59. const style::Menu &_st;
  60. const style::CrossLineAnimation &_stCross;
  61. const QMargins &_padding;
  62. const std::unique_ptr<Ui::CrossLineAnimation> _crossLineMute;
  63. Ui::Animations::Simple _crossLineAnimation;
  64. const std::unique_ptr<Ui::Paint::ArcsAnimation> _arcs;
  65. Ui::Animations::Basic _arcsAnimation;
  66. rpl::event_stream<bool> _toggleMuteRequests;
  67. rpl::event_stream<bool> _toggleMuteLocallyRequests;
  68. rpl::event_stream<int> _changeVolumeRequests;
  69. rpl::event_stream<int> _changeVolumeLocallyRequests;
  70. };
  71. } // namespace Calls