forked from mia/Aegisub
Update the audio scroll position at most once every 50ms when dragging markers
Originally committed to SVN as r6736.
This commit is contained in:
parent
1558aa2dad
commit
2ef7ed98c0
2 changed files with 36 additions and 11 deletions
|
@ -591,6 +591,7 @@ AudioDisplay::AudioDisplay(wxWindow *parent, AudioController *controller, agi::C
|
||||||
Bind(wxEVT_MOTION, &AudioDisplay::OnMouseEvent, this);
|
Bind(wxEVT_MOTION, &AudioDisplay::OnMouseEvent, this);
|
||||||
Bind(wxEVT_ENTER_WINDOW, &AudioDisplay::OnMouseEvent, this);
|
Bind(wxEVT_ENTER_WINDOW, &AudioDisplay::OnMouseEvent, this);
|
||||||
Bind(wxEVT_LEAVE_WINDOW, &AudioDisplay::OnMouseEvent, this);
|
Bind(wxEVT_LEAVE_WINDOW, &AudioDisplay::OnMouseEvent, this);
|
||||||
|
scroll_timer.Bind(wxEVT_TIMER, &AudioDisplay::OnScrollTimer, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1026,6 +1027,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
if (!dragged_object->OnMouseEvent(event))
|
if (!dragged_object->OnMouseEvent(event))
|
||||||
{
|
{
|
||||||
|
scroll_timer.Stop();
|
||||||
SetDraggedObject(0);
|
SetDraggedObject(0);
|
||||||
SetCursor(wxNullCursor);
|
SetCursor(wxNullCursor);
|
||||||
}
|
}
|
||||||
|
@ -1234,6 +1236,31 @@ void AudioDisplay::OnSelectionChanged()
|
||||||
|
|
||||||
if (audio_marker)
|
if (audio_marker)
|
||||||
{
|
{
|
||||||
|
if (!scroll_timer.IsRunning())
|
||||||
|
{
|
||||||
|
// If the dragged object is outside the visible area, start the
|
||||||
|
// scroll timer to shift it back into view
|
||||||
|
int rel_x = RelativeXFromTime(audio_marker->GetPosition());
|
||||||
|
if (rel_x < 0 || rel_x >= GetClientSize().GetWidth())
|
||||||
|
{
|
||||||
|
// 50ms is the default for this on Windows (hardcoded since
|
||||||
|
// wxSystemSettings doesn't expose DragScrollDelay etc.)
|
||||||
|
scroll_timer.Start(50, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (OPT_GET("Audio/Auto/Scroll")->GetBool() && sel.end() != 0)
|
||||||
|
{
|
||||||
|
ScrollTimeRangeInView(sel);
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshRect(scrollbar->GetBounds(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioDisplay::OnScrollTimer(wxTimerEvent &event)
|
||||||
|
{
|
||||||
|
if (!audio_marker) return;
|
||||||
|
|
||||||
int rel_x = RelativeXFromTime(audio_marker->GetPosition());
|
int rel_x = RelativeXFromTime(audio_marker->GetPosition());
|
||||||
int width = GetClientSize().GetWidth();
|
int width = GetClientSize().GetWidth();
|
||||||
|
|
||||||
|
@ -1247,13 +1274,6 @@ void AudioDisplay::OnSelectionChanged()
|
||||||
{
|
{
|
||||||
ScrollBy(rel_x - width + width / 20);
|
ScrollBy(rel_x - width + width / 20);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (OPT_GET("Audio/Auto/Scroll")->GetBool() && sel.end() != 0)
|
|
||||||
{
|
|
||||||
ScrollTimeRangeInView(sel);
|
|
||||||
}
|
|
||||||
|
|
||||||
RefreshRect(scrollbar->GetBounds(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDisplay::OnStyleRangesChanged()
|
void AudioDisplay::OnStyleRangesChanged()
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
|
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
#include <wx/timer.h>
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -131,6 +132,9 @@ class AudioDisplay: public wxWindow {
|
||||||
void SetDraggedObject(AudioDisplayInteractionObject *new_obj);
|
void SetDraggedObject(AudioDisplayInteractionObject *new_obj);
|
||||||
|
|
||||||
|
|
||||||
|
/// Timer for scrolling when markers are dragged out of the displayed area
|
||||||
|
wxTimer scroll_timer;
|
||||||
|
|
||||||
/// Leftmost pixel in the virtual audio image being displayed
|
/// Leftmost pixel in the virtual audio image being displayed
|
||||||
int scroll_left;
|
int scroll_left;
|
||||||
|
|
||||||
|
@ -213,6 +217,7 @@ class AudioDisplay: public wxWindow {
|
||||||
void OnFocus(wxFocusEvent &event);
|
void OnFocus(wxFocusEvent &event);
|
||||||
/// wxWidgets keypress event
|
/// wxWidgets keypress event
|
||||||
void OnKeyDown(wxKeyEvent& event);
|
void OnKeyDown(wxKeyEvent& event);
|
||||||
|
void OnScrollTimer(wxTimerEvent &event);
|
||||||
|
|
||||||
// AudioControllerAudioEventListener implementation
|
// AudioControllerAudioEventListener implementation
|
||||||
void OnAudioOpen(AudioProvider *provider);
|
void OnAudioOpen(AudioProvider *provider);
|
||||||
|
|
Loading…
Reference in a new issue