tdesktop/Telegram/SourceFiles/history/history_drag_area.h

69 lines
1.5 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
2019-09-13 12:22:54 +00:00
#include "ui/rp_widget.h"
2019-04-02 09:13:30 +00:00
#include "ui/effects/animations.h"
2015-12-08 12:33:37 +00:00
class DragArea : public TWidget {
Q_OBJECT
public:
DragArea(QWidget *parent);
void setText(const QString &text, const QString &subtext);
void otherEnter();
void otherLeave();
bool overlaps(const QRect &globalRect);
2015-10-01 14:05:05 +00:00
void hideFast();
void setDroppedCallback(Fn<void(const QMimeData *data)> callback) {
_droppedCallback = std::move(callback);
}
protected:
void paintEvent(QPaintEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void dragEnterEvent(QDragEnterEvent *e) override;
void dragLeaveEvent(QDragLeaveEvent *e) override;
void dropEvent(QDropEvent *e) override;
void dragMoveEvent(QDragMoveEvent *e) override;
public slots:
void hideStart();
void hideFinish();
void showStart();
private:
void setIn(bool in);
void opacityAnimationCallback();
QRect innerRect() const {
return QRect(
st::dragPadding.left(),
st::dragPadding.top(),
width() - st::dragPadding.left() - st::dragPadding.right(),
height() - st::dragPadding.top() - st::dragPadding.bottom()
);
}
bool _hiding = false;
bool _in = false;
QPixmap _cache;
Fn<void(const QMimeData *data)> _droppedCallback;
2019-04-02 09:13:30 +00:00
Ui::Animations::Simple _a_opacity;
Ui::Animations::Simple _a_in;
QString _text, _subtext;
};