2016-10-12 19:34:25 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-10-12 19:34:25 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-10-12 19:34:25 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-12-09 15:13:06 +00:00
|
|
|
#include "base/timer.h"
|
|
|
|
#include "ui/rp_widget.h"
|
|
|
|
#include "info/info_controller.h"
|
|
|
|
|
|
|
|
namespace Window {
|
|
|
|
class Controller;
|
|
|
|
} // namespace Window
|
|
|
|
|
2016-10-13 15:04:40 +00:00
|
|
|
namespace Ui {
|
2016-11-16 10:44:06 +00:00
|
|
|
class ScrollArea;
|
2016-12-13 17:07:56 +00:00
|
|
|
class Shadow;
|
2016-10-13 15:04:40 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2016-10-12 19:34:25 +00:00
|
|
|
namespace Media {
|
|
|
|
namespace Player {
|
|
|
|
|
|
|
|
class CoverWidget;
|
|
|
|
|
2017-12-09 15:13:06 +00:00
|
|
|
class Panel : public Ui::RpWidget, private Info::AbstractController {
|
2016-10-12 19:34:25 +00:00
|
|
|
public:
|
|
|
|
enum class Layout {
|
|
|
|
Full,
|
|
|
|
OnlyPlaylist,
|
|
|
|
};
|
2017-12-09 15:13:06 +00:00
|
|
|
Panel(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Window::Controller*> controller,
|
|
|
|
Layout layout);
|
2016-10-12 19:34:25 +00:00
|
|
|
|
|
|
|
bool overlaps(const QRect &globalRect);
|
|
|
|
|
2016-10-14 17:10:15 +00:00
|
|
|
void hideIgnoringEnterEvents();
|
2016-10-12 19:34:25 +00:00
|
|
|
|
2016-10-14 17:10:15 +00:00
|
|
|
void showFromOther();
|
|
|
|
void hideFromOther();
|
|
|
|
|
2017-02-26 11:32:13 +00:00
|
|
|
using ButtonCallback = base::lambda<void()>;
|
2016-10-18 15:19:13 +00:00
|
|
|
void setPinCallback(ButtonCallback &&callback);
|
|
|
|
void setCloseCallback(ButtonCallback &&callback);
|
2016-10-12 19:34:25 +00:00
|
|
|
|
2016-10-14 17:10:15 +00:00
|
|
|
int bestPositionFor(int left) const;
|
2016-10-12 19:34:25 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2017-02-11 11:24:37 +00:00
|
|
|
void enterEventHook(QEvent *e) override;
|
|
|
|
void leaveEventHook(QEvent *e) override;
|
2016-10-12 19:34:25 +00:00
|
|
|
|
|
|
|
private:
|
2017-12-09 15:13:06 +00:00
|
|
|
// Info::AbstractController implementation.
|
2018-01-22 19:51:38 +00:00
|
|
|
Info::Key key() const override;
|
2017-12-09 15:13:06 +00:00
|
|
|
PeerData *migrated() const override;
|
|
|
|
Info::Section section() const override;
|
|
|
|
|
|
|
|
void startShow();
|
|
|
|
void startHide();
|
|
|
|
void startHideChecked();
|
|
|
|
bool preventAutoHide() const;
|
|
|
|
void listHeightUpdated(int newHeight);
|
|
|
|
int emptyInnerHeight() const;
|
|
|
|
bool contentTooSmall() const;
|
|
|
|
void windowActiveChanged();
|
|
|
|
|
2016-10-14 17:10:15 +00:00
|
|
|
void ensureCreated();
|
|
|
|
void performDestroy();
|
|
|
|
|
|
|
|
void updateControlsGeometry();
|
2017-12-09 15:13:06 +00:00
|
|
|
void refreshList();
|
2016-10-13 15:04:40 +00:00
|
|
|
void updateSize();
|
2016-10-12 19:34:25 +00:00
|
|
|
void appearanceCallback();
|
2016-10-26 16:43:13 +00:00
|
|
|
void hideFinished();
|
2016-10-12 19:34:25 +00:00
|
|
|
int contentLeft() const;
|
2016-10-14 17:10:15 +00:00
|
|
|
int contentTop() const;
|
|
|
|
int contentRight() const;
|
|
|
|
int contentBottom() const;
|
|
|
|
int scrollMarginBottom() const;
|
2016-10-12 19:34:25 +00:00
|
|
|
int contentWidth() const {
|
2016-10-14 17:10:15 +00:00
|
|
|
return width() - contentLeft() - contentRight();
|
|
|
|
}
|
|
|
|
int contentHeight() const {
|
|
|
|
return height() - contentTop() - contentBottom();;
|
2016-10-12 19:34:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void startAnimation();
|
2016-10-14 17:10:15 +00:00
|
|
|
void scrollPlaylistToCurrentTrack();
|
2017-12-09 15:13:06 +00:00
|
|
|
not_null<Info::AbstractController*> infoController() {
|
|
|
|
return static_cast<Info::AbstractController*>(this);
|
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
|
2016-10-14 17:10:15 +00:00
|
|
|
Layout _layout;
|
2016-10-12 19:34:25 +00:00
|
|
|
bool _hiding = false;
|
|
|
|
|
|
|
|
QPixmap _cache;
|
2016-12-07 13:32:25 +00:00
|
|
|
Animation _a_appearance;
|
2016-10-12 19:34:25 +00:00
|
|
|
|
2016-10-14 17:10:15 +00:00
|
|
|
bool _ignoringEnterEvents = false;
|
|
|
|
|
2017-12-09 15:13:06 +00:00
|
|
|
base::Timer _showTimer;
|
|
|
|
base::Timer _hideTimer;
|
2016-10-12 19:34:25 +00:00
|
|
|
|
2016-10-18 15:19:13 +00:00
|
|
|
ButtonCallback _pinCallback, _closeCallback;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<CoverWidget> _cover = { nullptr };
|
|
|
|
object_ptr<Ui::ScrollArea> _scroll;
|
|
|
|
object_ptr<Ui::Shadow> _scrollShadow = { nullptr };
|
2016-10-12 19:34:25 +00:00
|
|
|
|
2017-12-09 15:13:06 +00:00
|
|
|
rpl::lifetime _refreshListLifetime;
|
|
|
|
PeerData *_listPeer = nullptr;
|
|
|
|
PeerData *_listMigratedPeer = nullptr;
|
|
|
|
|
2016-10-12 19:34:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Clip
|
|
|
|
} // namespace Media
|