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 >
|
||||
bool between_inclusive(LOW l, MID m, HIGH h)
|
||||
bool between_incexc(LOW l, MID m, HIGH 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);
|
||||
return (m >= l && m < h);
|
||||
}
|
||||
|
||||
template < class CLIPPEE, class CLIPVAL >
|
||||
@ -1289,7 +1283,7 @@ void TrackPanel::TimerUpdateIndicator()
|
||||
#endif
|
||||
AudacityProject *p = GetProject();
|
||||
const bool
|
||||
onScreen = between_inclusive(mViewInfo->h,
|
||||
onScreen = between_incexc(mViewInfo->h,
|
||||
pos,
|
||||
GetScreenEndTime());
|
||||
|
||||
@ -1337,7 +1331,7 @@ void TrackPanel::UndrawIndicator(wxDC & dc)
|
||||
int width;
|
||||
GetTracksUsableArea(&width, NULL);
|
||||
const bool
|
||||
onScreen = between_inclusive(GetLeftOffset(),
|
||||
onScreen = between_incexc(GetLeftOffset(),
|
||||
mLastIndicatorX,
|
||||
GetLeftOffset() + width);
|
||||
if (onScreen)
|
||||
@ -1373,9 +1367,9 @@ void TrackPanel::DoDrawIndicator(wxDC & dc)
|
||||
|
||||
// Ensure that we don't draw through the TrackInfo or vertical ruler.
|
||||
wxRect clip = GetRect();
|
||||
int leftCutoff = clip.x + GetLabelWidth();
|
||||
int leftCutoff = clip.x + GetLeftOffset();
|
||||
int rightCutoff = clip.x + clip.width - kRightMargin;
|
||||
if (!between_inclusive(leftCutoff, mLastIndicatorX, rightCutoff))
|
||||
if (!between_incexc(leftCutoff, mLastIndicatorX, rightCutoff))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1441,7 +1435,7 @@ void TrackPanel::UndrawCursor(wxDC & dc)
|
||||
{
|
||||
int width;
|
||||
GetTracksUsableArea(&width, NULL);
|
||||
onScreen = between_inclusive(GetLeftOffset(),
|
||||
onScreen = between_incexc(GetLeftOffset(),
|
||||
mLastCursorX,
|
||||
GetLeftOffset() + width);
|
||||
if( onScreen )
|
||||
@ -1456,7 +1450,7 @@ void TrackPanel::DoDrawCursor(wxDC & dc)
|
||||
return;
|
||||
|
||||
const bool
|
||||
onScreen = between_inclusive( mViewInfo->h,
|
||||
onScreen = between_incexc(mViewInfo->h,
|
||||
mCursorTime,
|
||||
GetScreenEndTime() );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user