requests_bar.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 "ui/text/text.h"
  11. #include "base/object_ptr.h"
  12. #include "base/timer.h"
  13. class Painter;
  14. namespace Ui {
  15. class PlainShadow;
  16. struct GroupCallUser;
  17. class GroupCallUserpics;
  18. struct RequestsBarContent {
  19. std::vector<GroupCallUser> users;
  20. QString nameFull;
  21. QString nameShort;
  22. int count = 0;
  23. bool isGroup = false;
  24. };
  25. class RequestsBar final {
  26. public:
  27. RequestsBar(
  28. not_null<QWidget*> parent,
  29. rpl::producer<RequestsBarContent> content);
  30. ~RequestsBar();
  31. void show();
  32. void hide();
  33. void raise();
  34. void finishAnimating();
  35. void setShadowGeometryPostprocess(Fn<QRect(QRect)> postprocess);
  36. void move(int x, int y);
  37. void resizeToWidth(int width);
  38. [[nodiscard]] int height() const;
  39. [[nodiscard]] rpl::producer<int> heightValue() const;
  40. [[nodiscard]] rpl::producer<> barClicks() const;
  41. [[nodiscard]] rpl::lifetime &lifetime() {
  42. return _wrap.lifetime();
  43. }
  44. private:
  45. using User = GroupCallUser;
  46. void updateShadowGeometry(QRect wrapGeometry);
  47. void updateControlsGeometry(QRect wrapGeometry);
  48. void updateUserpics();
  49. void setupInner();
  50. void paint(Painter &p);
  51. SlideWrap<> _wrap;
  52. not_null<RpWidget*> _inner;
  53. std::unique_ptr<PlainShadow> _shadow;
  54. rpl::event_stream<> _barClicks;
  55. Fn<QRect(QRect)> _shadowGeometryPostprocess;
  56. bool _shouldBeShown = false;
  57. bool _forceHidden = false;
  58. RequestsBarContent _content;
  59. std::unique_ptr<GroupCallUserpics> _userpics;
  60. int _userpicsWidth = 0;
  61. Ui::Text::String _textShort;
  62. Ui::Text::String _textFull;
  63. };
  64. } // namespace Ui