From 41c0e498139a7610af0cd2061d5279cc22be538d Mon Sep 17 00:00:00 2001 From: wangqr Date: Sat, 26 Oct 2019 02:44:40 -0400 Subject: [PATCH] Only expand thumb at Paint This will give a more natural indication of where the position is. When dragging with mouse, now the thumb block will always center under the mouse position. Fix wangqr/Aegisub#26 --- src/audio_display.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/audio_display.cpp b/src/audio_display.cpp index 6548d4814..cdc942692 100644 --- a/src/audio_display.cpp +++ b/src/audio_display.cpp @@ -154,7 +154,7 @@ class AudioDisplay::AudioDisplayScrollbar final : public AudioDisplayInteraction // Recalculate thumb bounds from position and length data void RecalculateThumb() { - thumb.width = std::max(min_width, (int64_t)bounds.width * page_length / data_length); + thumb.width = int((int64_t)bounds.width * page_length / data_length); thumb.height = height; thumb.x = int((int64_t)bounds.width * position / data_length); thumb.y = bounds.y; @@ -264,7 +264,12 @@ public: dc.SetPen(wxPen(colours.Light())); dc.SetBrush(wxBrush(colours.Light())); - dc.DrawRectangle(thumb); + + // Paint the thumb at least min_width, expand to both left and right + if (thumb.width < min_width) + dc.DrawRectangle(wxRect(thumb.x - (min_width - thumb.width) / 2, thumb.y, min_width, thumb.height)); + else + dc.DrawRectangle(thumb); } };