mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-16 08:34:10 +02:00
Support mice with high-precision scroll wheels
fixes P2: Ctrl+Mouse Wheel causes Crash (hang)
This commit is contained in:
parent
5e3b227f5b
commit
b51db1586b
@ -443,7 +443,8 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
|
|||||||
mBacking(NULL),
|
mBacking(NULL),
|
||||||
mRefreshBacking(false),
|
mRefreshBacking(false),
|
||||||
mAutoScrolling(false),
|
mAutoScrolling(false),
|
||||||
vrulerSize(36,0)
|
vrulerSize(36,0),
|
||||||
|
mVertScrollRemainder(0)
|
||||||
#ifndef __WXGTK__ //Get rid if this pragma for gtk
|
#ifndef __WXGTK__ //Get rid if this pragma for gtk
|
||||||
#pragma warning( default: 4355 )
|
#pragma warning( default: 4355 )
|
||||||
#endif
|
#endif
|
||||||
@ -4144,8 +4145,8 @@ void TrackPanel::HandleResize(wxMouseEvent & event)
|
|||||||
/// Handle mouse wheel rotation (for zoom in/out and vertical scrolling)
|
/// Handle mouse wheel rotation (for zoom in/out and vertical scrolling)
|
||||||
void TrackPanel::HandleWheelRotation(wxMouseEvent & event)
|
void TrackPanel::HandleWheelRotation(wxMouseEvent & event)
|
||||||
{
|
{
|
||||||
int steps = event.m_wheelRotation /
|
double steps = event.m_wheelRotation /
|
||||||
(event.m_wheelDelta > 0 ? event.m_wheelDelta : 120);
|
(event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0);
|
||||||
|
|
||||||
if (event.ShiftDown())
|
if (event.ShiftDown())
|
||||||
{
|
{
|
||||||
@ -4160,10 +4161,7 @@ void TrackPanel::HandleWheelRotation(wxMouseEvent & event)
|
|||||||
int trackLeftEdge = GetLeftOffset();
|
int trackLeftEdge = GetLeftOffset();
|
||||||
|
|
||||||
double center_h = PositionToTime(event.m_x, trackLeftEdge);
|
double center_h = PositionToTime(event.m_x, trackLeftEdge);
|
||||||
if (steps < 0)
|
mViewInfo->zoom = wxMin(mViewInfo->zoom * pow(2.0, steps), gMaxZoom);
|
||||||
mViewInfo->zoom = wxMax(mViewInfo->zoom / (2.0 * -steps), gMinZoom);
|
|
||||||
else
|
|
||||||
mViewInfo->zoom = wxMin(mViewInfo->zoom * (2.0 * steps), gMaxZoom);
|
|
||||||
|
|
||||||
double new_center_h = PositionToTime(event.m_x, trackLeftEdge);
|
double new_center_h = PositionToTime(event.m_x, trackLeftEdge);
|
||||||
mViewInfo->h += (center_h - new_center_h);
|
mViewInfo->h += (center_h - new_center_h);
|
||||||
@ -4173,7 +4171,10 @@ void TrackPanel::HandleWheelRotation(wxMouseEvent & event)
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// MM: Zoom up/down when used without modifier keys
|
// MM: Zoom up/down when used without modifier keys
|
||||||
mListener->TP_ScrollUpDown(-steps * 4);
|
double lines = steps * 4 + mVertScrollRemainder;
|
||||||
|
mVertScrollRemainder = lines - floor(lines);
|
||||||
|
lines = floor(lines);
|
||||||
|
mListener->TP_ScrollUpDown((int)-lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,6 +578,9 @@ private:
|
|||||||
|
|
||||||
wxString mSoloPref;
|
wxString mSoloPref;
|
||||||
|
|
||||||
|
// Keeps track of extra fractional vertical scroll steps
|
||||||
|
double mVertScrollRemainder;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// The screenshot class needs to access internals
|
// The screenshot class needs to access internals
|
||||||
|
@ -1036,19 +1036,18 @@ void LWSlider::OnMouseEvent(wxMouseEvent & event)
|
|||||||
}
|
}
|
||||||
else if( event.m_wheelRotation != 0 )
|
else if( event.m_wheelRotation != 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
//Calculate the number of steps in a given direction this event
|
//Calculate the number of steps in a given direction this event
|
||||||
//represents (allows for two or more clicks on a single event.)
|
//represents (allows for two or more clicks on a single event.)
|
||||||
int steps = event.m_wheelRotation /
|
double steps = event.m_wheelRotation /
|
||||||
(event.m_wheelDelta > 0 ? event.m_wheelDelta : 120);
|
(event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0);
|
||||||
|
|
||||||
if( steps < 0 )
|
if( steps < 0.0 )
|
||||||
{
|
{
|
||||||
Decrease( -steps );
|
Decrease( (float)-steps );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Increase( steps );
|
Increase( (float)steps );
|
||||||
}
|
}
|
||||||
SendUpdate( mCurrentValue );
|
SendUpdate( mCurrentValue );
|
||||||
}
|
}
|
||||||
|
@ -982,15 +982,18 @@ void TimeTextCtrl::OnMouse(wxMouseEvent &event)
|
|||||||
OnContext(e);
|
OnContext(e);
|
||||||
}
|
}
|
||||||
else if( event.m_wheelRotation != 0 ) {
|
else if( event.m_wheelRotation != 0 ) {
|
||||||
int steps = event.m_wheelRotation /
|
double steps = event.m_wheelRotation /
|
||||||
(event.m_wheelDelta > 0 ? event.m_wheelDelta : 120);
|
(event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0) +
|
||||||
|
mScrollRemainder;
|
||||||
|
mScrollRemainder = steps - floor(steps);
|
||||||
|
steps = floor(steps);
|
||||||
|
|
||||||
if (steps < 0) {
|
if (steps < 0.0) {
|
||||||
Decrease(-steps);
|
Decrease((int)-steps);
|
||||||
Updated();
|
Updated();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Increase(steps);
|
Increase((int)steps);
|
||||||
Updated();
|
Updated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,9 @@ private:
|
|||||||
double mScalingFactor;
|
double mScalingFactor;
|
||||||
bool mNtscDrop;
|
bool mNtscDrop;
|
||||||
|
|
||||||
|
// Keeps track of extra fractional scrollwheel steps
|
||||||
|
double mScrollRemainder;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user