more_chats_bar.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. class IconButton;
  17. struct MoreChatsBarContent {
  18. int count = 0;
  19. };
  20. class MoreChatsBar final {
  21. public:
  22. MoreChatsBar(
  23. not_null<QWidget*> parent,
  24. rpl::producer<MoreChatsBarContent> content);
  25. ~MoreChatsBar();
  26. [[nodiscard]] not_null<RpWidget*> wrap() {
  27. return &_wrap;
  28. }
  29. void show();
  30. void hide();
  31. void raise();
  32. void finishAnimating();
  33. void setShadowGeometryPostprocess(Fn<QRect(QRect)> postprocess);
  34. void move(int x, int y);
  35. void resizeToWidth(int width);
  36. [[nodiscard]] int height() const;
  37. [[nodiscard]] rpl::producer<int> heightValue() const;
  38. [[nodiscard]] rpl::producer<> barClicks() const;
  39. [[nodiscard]] rpl::producer<> closeClicks() const;
  40. [[nodiscard]] rpl::lifetime &lifetime() {
  41. return _wrap.lifetime();
  42. }
  43. private:
  44. void updateShadowGeometry(QRect wrapGeometry);
  45. void updateControlsGeometry(QRect wrapGeometry);
  46. void setupInner();
  47. void paint(Painter &p);
  48. SlideWrap<> _wrap;
  49. not_null<RpWidget*> _inner;
  50. std::unique_ptr<PlainShadow> _shadow;
  51. object_ptr<IconButton> _close;
  52. rpl::event_stream<> _barClicks;
  53. Fn<QRect(QRect)> _shadowGeometryPostprocess;
  54. bool _shouldBeShown = false;
  55. bool _forceHidden = false;
  56. MoreChatsBarContent _content;
  57. Ui::Text::String _text;
  58. Ui::Text::String _status;
  59. };
  60. } // namespace Ui