Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Only expand thumb at Paint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wangqr committed Oct 26, 2019
1 parent c5a5839 commit 41a1690
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/audio_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class AudioDisplay::AudioDisplayScrollbar final : public AudioDisplayInteraction
// Recalculate thumb bounds from position and length data
void RecalculateThumb()
{
thumb.width = std::max<int>(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;
Expand Down Expand Up @@ -264,7 +264,12 @@ class AudioDisplay::AudioDisplayScrollbar final : public AudioDisplayInteraction

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);
}
};

Expand Down

0 comments on commit 41a1690

Please sign in to comment.