1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 11:35:24 +01:00

Make the track slider popup more accurate, make the text bold, make the shadow bigger but fade out towards the bottom, and make it close when the mouse leaves the area of the slider.

This commit is contained in:
David Sansome 2010-12-27 19:23:12 +00:00
parent 72da76a71a
commit 62e21d64f3
2 changed files with 20 additions and 5 deletions

View File

@ -10,7 +10,7 @@ const int TrackSliderPopup::kTextMargin = 4;
const int TrackSliderPopup::kPointLength = 16;
const int TrackSliderPopup::kPointWidth = 4;
const int TrackSliderPopup::kBorderRadius = 4;
const qreal TrackSliderPopup::kBlurRadius = 10.0;
const qreal TrackSliderPopup::kBlurRadius = 20.0;
void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
@ -39,6 +39,7 @@ TrackSliderPopup::TrackSliderPopup(QWidget* parent)
connect(visibility_timer_, SIGNAL(timeout()), SLOT(UpdateVisibility()));
font_.setPointSizeF(7.5);
font_.setBold(true);
font_metrics_ = QFontMetrics(font_);
UpdatePixmap();
@ -97,9 +98,16 @@ void TrackSliderPopup::UpdatePixmap() {
blur_painter.setRenderHint(QPainter::Antialiasing);
blur_painter.setRenderHint(QPainter::HighQualityAntialiasing);
blur_painter.setBrush(bg_color_2);
blur_painter.setOpacity(0.5);
blur_painter.drawRoundedRect(bubble_rect.adjusted(1, 1, -1, -1), kBorderRadius, kBorderRadius);
blur_painter.drawPolygon(inner_pointy);
blur_painter.drawRoundedRect(bubble_rect, kBorderRadius, kBorderRadius);
blur_painter.drawPolygon(pointy);
// Fade the shadow out towards the bottom
QLinearGradient fade_gradient(QPoint(0, bubble_bottom),
QPoint(0, bubble_bottom + kPointLength));
fade_gradient.setColorAt(0.0, QColor(255, 0, 0, 0));
fade_gradient.setColorAt(1.0, QColor(255, 0, 0, 255));
blur_painter.setCompositionMode(QPainter::CompositionMode_DestinationOut);
blur_painter.fillRect(total_rect, fade_gradient);
blur_painter.end();
p.save();
@ -173,5 +181,11 @@ void TrackSliderPopup::mouseReleaseEvent(QMouseEvent* e) {
}
void TrackSliderPopup::mouseMoveEvent(QMouseEvent* e) {
if (!parentWidget()->rect().contains(
parentWidget()->mapFromGlobal(e->globalPos()))) {
// The mouse left the parent widget - close this popup
mouse_over_popup_ = false;
visibility_timer_->start();
}
SendMouseEventToParent(e);
}

View File

@ -72,7 +72,8 @@ void TrackSliderSlider::mouseMoveEvent(QMouseEvent* e) {
int slider_max = gr.right() - slider_length + 1;
int seconds = QStyle::sliderValueFromPosition(
minimum(), maximum(), e->x() - slider_length/2, slider_max - slider_min);
minimum(), maximum(), e->x() - slider_length/2 - slider_min + 1,
slider_max - slider_min);
popup_->SetText(Utilities::PrettyTime(seconds));
popup_->SetPopupPosition(mapToGlobal(QPoint(