Fix issues with audio auto scrolling and lines longer than the display
Clicking on the audio display (to change line timing) now never scrolls the display, rather than jumping around if the line is too long to fit on the display. Dragged markers are now always kept visible in the display, even if auto scroll is off. Originally committed to SVN as r6541.
This commit is contained in:
parent
9f6bb17379
commit
c84c9fe6b8
1 changed files with 24 additions and 1 deletions
|
@ -502,6 +502,9 @@ public:
|
|||
// We lose the marker drag if the button used to initiate it goes up
|
||||
return !event.ButtonUp(button_used);
|
||||
}
|
||||
|
||||
/// Get the position in milliseconds of this group of markers
|
||||
int GetPosition() const { return markers.front()->GetPosition(); }
|
||||
};
|
||||
|
||||
class AudioStyleRangeMerger : public AudioRenderingStyleRanges {
|
||||
|
@ -1090,6 +1093,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
|
|||
SetCursor(wxNullCursor);
|
||||
}
|
||||
|
||||
int old_scroll_pos = scroll_left;
|
||||
if (event.LeftDown() || event.RightDown())
|
||||
{
|
||||
int timepos = TimeFromRelativeX(mousepos.x);
|
||||
|
@ -1097,6 +1101,9 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
|
|||
timing->OnLeftClick(timepos, event.CmdDown(), drag_sensitivity, snap_sensitivity) :
|
||||
timing->OnRightClick(timepos, event.CmdDown(), drag_sensitivity, snap_sensitivity);
|
||||
|
||||
// Clicking should never result in the audio display scrolling
|
||||
ScrollPixelToLeft(old_scroll_pos);
|
||||
|
||||
if (markers.size())
|
||||
{
|
||||
RemoveTrackCursor();
|
||||
|
@ -1222,7 +1229,23 @@ void AudioDisplay::OnSelectionChanged()
|
|||
TimeRange sel(controller->GetPrimaryPlaybackRange());
|
||||
scrollbar->SetSelection(AbsoluteXFromTime(sel.begin()), AbsoluteXFromTime(sel.length()));
|
||||
|
||||
if (OPT_GET("Audio/Auto/Scroll")->GetBool())
|
||||
if (audio_marker)
|
||||
{
|
||||
int rel_x = RelativeXFromTime(audio_marker->GetPosition());
|
||||
int width = GetClientSize().GetWidth();
|
||||
|
||||
// If the dragged object is outside the visible area, scroll it into
|
||||
// view with a 5% margin
|
||||
if (rel_x < 0)
|
||||
{
|
||||
ScrollBy(rel_x - width / 20);
|
||||
}
|
||||
else if (rel_x >= width)
|
||||
{
|
||||
ScrollBy(rel_x - width + width / 20);
|
||||
}
|
||||
}
|
||||
else if (OPT_GET("Audio/Auto/Scroll")->GetBool())
|
||||
{
|
||||
ScrollTimeRangeInView(sel);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue