1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-17 02:59:03 +01:00

Check that rating position is to the right or left of the rectangle.

Adapted from Clementine.

Author: Jim Broadus
This commit is contained in:
Jonas Kvinge 2021-04-02 00:47:53 +02:00
parent bddb371e31
commit 39dda0f16b

View File

@ -86,6 +86,10 @@ double RatingPainter::RatingForPos(const QPoint &pos, const QRect &rect) {
const QRect contents = Contents(rect);
const double raw = double(pos.x() - contents.left()) / contents.width();
// Check if the position was to the right or left of the rectangle.
if (raw < 0) return 0;
if (raw > 1) return 1;
// Round to the nearest 0.1
return double(int(raw * kStarCount * 2 + 0.5)) / (kStarCount * 2);