mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-02 08:39:46 +02:00
Fix off-by-one errors in allowable ranges for drawing indicator and cursor
This commit is contained in:
parent
1b8f44d053
commit
99f490c75f
@ -292,15 +292,9 @@ template < class A, class B, class DIST > bool within(A a, B b, DIST d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template < class LOW, class MID, class HIGH >
|
template < class LOW, class MID, class HIGH >
|
||||||
bool between_inclusive(LOW l, MID m, HIGH h)
|
bool between_incexc(LOW l, MID m, HIGH h)
|
||||||
{
|
{
|
||||||
return (m >= l && m <= h);
|
return (m >= l && m < h);
|
||||||
}
|
|
||||||
|
|
||||||
template < class LOW, class MID, class HIGH >
|
|
||||||
bool between_exclusive(LOW l, MID m, HIGH h)
|
|
||||||
{
|
|
||||||
return (m > l && m < h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class CLIPPEE, class CLIPVAL >
|
template < class CLIPPEE, class CLIPVAL >
|
||||||
@ -1289,9 +1283,9 @@ void TrackPanel::TimerUpdateIndicator()
|
|||||||
#endif
|
#endif
|
||||||
AudacityProject *p = GetProject();
|
AudacityProject *p = GetProject();
|
||||||
const bool
|
const bool
|
||||||
onScreen = between_inclusive(mViewInfo->h,
|
onScreen = between_incexc(mViewInfo->h,
|
||||||
pos,
|
pos,
|
||||||
GetScreenEndTime());
|
GetScreenEndTime());
|
||||||
|
|
||||||
// This displays the audio time, too...
|
// This displays the audio time, too...
|
||||||
DisplaySelection();
|
DisplaySelection();
|
||||||
@ -1337,9 +1331,9 @@ void TrackPanel::UndrawIndicator(wxDC & dc)
|
|||||||
int width;
|
int width;
|
||||||
GetTracksUsableArea(&width, NULL);
|
GetTracksUsableArea(&width, NULL);
|
||||||
const bool
|
const bool
|
||||||
onScreen = between_inclusive(GetLeftOffset(),
|
onScreen = between_incexc(GetLeftOffset(),
|
||||||
mLastIndicatorX,
|
mLastIndicatorX,
|
||||||
GetLeftOffset() + width);
|
GetLeftOffset() + width);
|
||||||
if (onScreen)
|
if (onScreen)
|
||||||
{
|
{
|
||||||
// LL: Keep from trying to blit outsize of the source DC. This results in a crash on
|
// LL: Keep from trying to blit outsize of the source DC. This results in a crash on
|
||||||
@ -1373,9 +1367,9 @@ void TrackPanel::DoDrawIndicator(wxDC & dc)
|
|||||||
|
|
||||||
// Ensure that we don't draw through the TrackInfo or vertical ruler.
|
// Ensure that we don't draw through the TrackInfo or vertical ruler.
|
||||||
wxRect clip = GetRect();
|
wxRect clip = GetRect();
|
||||||
int leftCutoff = clip.x + GetLabelWidth();
|
int leftCutoff = clip.x + GetLeftOffset();
|
||||||
int rightCutoff = clip.x + clip.width - kRightMargin;
|
int rightCutoff = clip.x + clip.width - kRightMargin;
|
||||||
if (!between_inclusive(leftCutoff, mLastIndicatorX, rightCutoff))
|
if (!between_incexc(leftCutoff, mLastIndicatorX, rightCutoff))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1441,9 +1435,9 @@ void TrackPanel::UndrawCursor(wxDC & dc)
|
|||||||
{
|
{
|
||||||
int width;
|
int width;
|
||||||
GetTracksUsableArea(&width, NULL);
|
GetTracksUsableArea(&width, NULL);
|
||||||
onScreen = between_inclusive(GetLeftOffset(),
|
onScreen = between_incexc(GetLeftOffset(),
|
||||||
mLastCursorX,
|
mLastCursorX,
|
||||||
GetLeftOffset() + width);
|
GetLeftOffset() + width);
|
||||||
if( onScreen )
|
if( onScreen )
|
||||||
dc.Blit(mLastCursorX, 0, 1, mBacking->GetHeight(), &mBackingDC, mLastCursorX, 0);
|
dc.Blit(mLastCursorX, 0, 1, mBacking->GetHeight(), &mBackingDC, mLastCursorX, 0);
|
||||||
}
|
}
|
||||||
@ -1456,9 +1450,9 @@ void TrackPanel::DoDrawCursor(wxDC & dc)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const bool
|
const bool
|
||||||
onScreen = between_inclusive( mViewInfo->h,
|
onScreen = between_incexc(mViewInfo->h,
|
||||||
mCursorTime,
|
mCursorTime,
|
||||||
GetScreenEndTime() );
|
GetScreenEndTime() );
|
||||||
|
|
||||||
if( !onScreen )
|
if( !onScreen )
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user