pinned_bar.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 "base/object_ptr.h"
  10. namespace Ui {
  11. struct MessageBarContent;
  12. template <typename Widget>
  13. class FadeWrapScaled;
  14. class MessageBar;
  15. class IconButton;
  16. class PlainShadow;
  17. class RpWidget;
  18. class PinnedBar final {
  19. public:
  20. PinnedBar(
  21. not_null<QWidget*> parent,
  22. Fn<bool()> customEmojiPaused,
  23. rpl::producer<> customEmojiPausedChanges);
  24. ~PinnedBar();
  25. void show();
  26. void hide();
  27. void raise();
  28. void customEmojiRepaint();
  29. void finishAnimating();
  30. void setShadowGeometryPostprocess(Fn<QRect(QRect)> postprocess);
  31. void setContent(rpl::producer<Ui::MessageBarContent> content);
  32. void setRightButton(object_ptr<Ui::RpWidget> button);
  33. void move(int x, int y);
  34. void resizeToWidth(int width);
  35. [[nodiscard]] int height() const;
  36. [[nodiscard]] rpl::producer<int> heightValue() const;
  37. [[nodiscard]] rpl::producer<> barClicks() const;
  38. [[nodiscard]] rpl::producer<> contextMenuRequested() const;
  39. [[nodiscard]] rpl::lifetime &lifetime() {
  40. return _wrap.lifetime();
  41. }
  42. private:
  43. using RightButton = object_ptr<Ui::FadeWrapScaled<Ui::RpWidget>>;
  44. void createControls();
  45. void updateShadowGeometry(QRect wrapGeometry);
  46. void updateControlsGeometry(QRect wrapGeometry);
  47. Ui::SlideWrap<> _wrap;
  48. std::unique_ptr<Ui::MessageBar> _bar;
  49. struct {
  50. RightButton button = { nullptr };
  51. rpl::lifetime previousButtonLifetime;
  52. } _right;
  53. std::unique_ptr<Ui::PlainShadow> _shadow;
  54. Fn<bool()> _customEmojiPaused;
  55. rpl::event_stream<> _barClicks;
  56. rpl::event_stream<> _contextMenuRequested;
  57. Fn<QRect(QRect)> _shadowGeometryPostprocess;
  58. bool _shouldBeShown = false;
  59. bool _forceHidden = false;
  60. rpl::lifetime _contentLifetime;
  61. };
  62. } // namespace Ui