1
0
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:
David Sansome 2010-12-19 14:06:51 +00:00
parent 7fd29f160d
commit a348a4529d
2 changed files with 11 additions and 0 deletions

View File

@ -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();

View File

@ -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;