mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-08 16:22:10 +01:00
Make the pretty OSD snap to the center of the screen while dragging. Thanks brunciter.
This commit is contained in:
parent
7fd29f160d
commit
a348a4529d
@ -46,6 +46,8 @@ const int OSDPretty::kDropShadowSize = 13;
|
||||
const int OSDPretty::kBorderRadius = 10;
|
||||
const int OSDPretty::kMaxIconSize = 100;
|
||||
|
||||
const int OSDPretty::kSnapProximity = 20;
|
||||
|
||||
const QRgb OSDPretty::kPresetBlue = qRgb(102, 150, 227);
|
||||
const QRgb OSDPretty::kPresetOrange = qRgb(254, 156, 67);
|
||||
|
||||
@ -337,6 +339,13 @@ void OSDPretty::mouseMoveEvent(QMouseEvent* e) {
|
||||
new_pos.setX(qBound(geometry.left(), new_pos.x(), geometry.right() - width()));
|
||||
new_pos.setY(qBound(geometry.top(), new_pos.y(), geometry.bottom() - height()));
|
||||
|
||||
// Snap to center
|
||||
int snap_x = geometry.center().x() - width() / 2;
|
||||
qDebug() << snap_x << new_pos.x();
|
||||
if (new_pos.x() > snap_x - kSnapProximity && new_pos.x() < snap_x + kSnapProximity) {
|
||||
new_pos.setX(snap_x);
|
||||
}
|
||||
|
||||
move(new_pos);
|
||||
|
||||
popup_display_ = current_display();
|
||||
|
@ -42,6 +42,8 @@ class OSDPretty : public QWidget {
|
||||
static const int kBorderRadius;
|
||||
static const int kMaxIconSize;
|
||||
|
||||
static const int kSnapProximity;
|
||||
|
||||
static const QRgb kPresetBlue;
|
||||
static const QRgb kPresetOrange;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user