media_player_panel.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 "base/timer.h"
  9. #include "ui/rp_widget.h"
  10. #include "ui/effects/animations.h"
  11. #include "info/info_controller.h"
  12. namespace Window {
  13. class SessionController;
  14. } // namespace Window
  15. namespace Ui {
  16. class ScrollArea;
  17. class Shadow;
  18. } // namespace Ui
  19. namespace Media {
  20. namespace Player {
  21. class CoverWidget;
  22. class Panel : public Ui::RpWidget, private Info::AbstractController {
  23. public:
  24. Panel(
  25. QWidget *parent,
  26. not_null<Window::SessionController*> controller);
  27. bool overlaps(const QRect &globalRect);
  28. void hideIgnoringEnterEvents();
  29. void showFromOther();
  30. void hideFromOther();
  31. int bestPositionFor(int left) const;
  32. protected:
  33. void resizeEvent(QResizeEvent *e) override;
  34. void paintEvent(QPaintEvent *e) override;
  35. void enterEventHook(QEnterEvent *e) override;
  36. void leaveEventHook(QEvent *e) override;
  37. private:
  38. // Info::AbstractController implementation.
  39. Info::Key key() const override;
  40. PeerData *migrated() const override;
  41. Info::Section section() const override;
  42. void startShow();
  43. void startHide();
  44. void startHideChecked();
  45. bool preventAutoHide() const;
  46. void listHeightUpdated(int newHeight);
  47. int emptyInnerHeight() const;
  48. bool contentTooSmall() const;
  49. void ensureCreated();
  50. void performDestroy();
  51. void updateControlsGeometry();
  52. void refreshList();
  53. void updateSize();
  54. void appearanceCallback();
  55. void hideFinished();
  56. int contentLeft() const;
  57. int contentTop() const;
  58. int contentRight() const;
  59. int contentBottom() const;
  60. int scrollMarginBottom() const;
  61. int contentWidth() const {
  62. return width() - contentLeft() - contentRight();
  63. }
  64. int contentHeight() const {
  65. return height() - contentTop() - contentBottom();
  66. }
  67. void startAnimation();
  68. void scrollPlaylistToCurrentTrack();
  69. not_null<Info::AbstractController*> infoController() {
  70. return static_cast<Info::AbstractController*>(this);
  71. }
  72. bool _hiding = false;
  73. QPixmap _cache;
  74. Ui::Animations::Simple _a_appearance;
  75. bool _ignoringEnterEvents = false;
  76. base::Timer _showTimer;
  77. base::Timer _hideTimer;
  78. object_ptr<Ui::ScrollArea> _scroll;
  79. rpl::lifetime _refreshListLifetime;
  80. PeerData *_listPeer = nullptr;
  81. PeerData *_listMigratedPeer = nullptr;
  82. };
  83. } // namespace Player
  84. } // namespace Media