1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-22 23:30:07 +02:00

(most of) Bug 1077: Resizing cursor correctly appears, except...

... we still see an incorrect arrow cursor where the cutline meets the bottom
of the track.
This commit is contained in:
Paul Licameli 2015-07-13 07:59:46 -04:00
parent e553837832
commit 912cdb6c53
2 changed files with 24 additions and 28 deletions

View File

@ -1762,8 +1762,7 @@ void TrackPanel::SetCursorAndTipWhenInLabel( Track * t,
} }
/// When in the resize area we can adjust size or relative size. /// When in the resize area we can adjust size or relative size.
void TrackPanel::SetCursorAndTipWhenInVResizeArea( Track * label, void TrackPanel::SetCursorAndTipWhenInVResizeArea( bool bLinked, wxString &tip )
bool bLinked, wxString &tip )
{ {
// Check to see whether it is the first channel of a stereo track // Check to see whether it is the first channel of a stereo track
if (bLinked) { if (bLinked) {
@ -1771,11 +1770,6 @@ void TrackPanel::SetCursorAndTipWhenInVResizeArea( Track * label,
// not actually in the resize area at all. (The resize area // not actually in the resize area at all. (The resize area
// is shorter when it is between stereo tracks). // is shorter when it is between stereo tracks).
// IF we are in the label THEN return.
// Subsequently called methods can detect that a tip and
// cursor are still needed.
if (label)
return;
tip = _("Click and drag to adjust relative size of stereo tracks."); tip = _("Click and drag to adjust relative size of stereo tracks.");
SetCursor(*mResizeCursor); SetCursor(*mResizeCursor);
} else { } else {
@ -2075,12 +2069,12 @@ void TrackPanel::HandleCursor(wxMouseEvent & event)
// (2) If we are not over a track at all, set the cursor to Arrow and // (2) If we are not over a track at all, set the cursor to Arrow and
// clear the StatusBar, // clear the StatusBar,
wxRect r; wxRect labelRect, trackRect;
Track *label = FindTrack(event.m_x, event.m_y, true, true, &r); Track *const label = FindTrack(event.m_x, event.m_y, true, true, &labelRect);
Track *nonlabel = FindTrack(event.m_x, event.m_y, false, false, &r); Track *const nonlabel = FindTrack(event.m_x, event.m_y, false, false, &trackRect);
Track *t = label ? label : nonlabel; Track *const track = label ? label : nonlabel;
if (!t) { if (!track) {
SetCursor(*mArrowCursor); SetCursor(*mArrowCursor);
mListener->TP_DisplayStatusMessage(wxT("")); mListener->TP_DisplayStatusMessage(wxT(""));
return; return;
@ -2096,23 +2090,25 @@ void TrackPanel::HandleCursor(wxMouseEvent & event)
wxString tip; wxString tip;
if (label) { // Are we within the vertical resize area?
SetCursorAndTipWhenInLabel( label, event, tip ); if (nonlabel
? within(event.m_y, trackRect.y + trackRect.height, TRACK_RESIZE_REGION)
: within(event.m_y, labelRect.y + labelRect.height, TRACK_RESIZE_REGION))
{
SetCursorAndTipWhenInVResizeArea(nonlabel && track->GetLinked(), tip);
// tip may still be NULL at this point, in which case we go on looking.
} }
// Are we within the vertical resize area? if ((tip == wxString()) && label) {
if ((tip == wxString() ) && within(event.m_y, r.y + r.height, TRACK_RESIZE_REGION)) SetCursorAndTipWhenInLabel( label, event, tip );
{
SetCursorAndTipWhenInVResizeArea( label, t->GetLinked(), tip );
// tip may still be NULL at this point, in which case we go on looking.
} }
// Otherwise, we must be over a track of some kind // Otherwise, we must be over a track of some kind
// Is it a label track? // Is it a label track?
if ((tip == wxString()) && (t->GetKind() == Track::Label)) if ((tip == wxString()) && (track->GetKind() == Track::Label))
{ {
// We are over a label track // We are over a label track
SetCursorAndTipWhenInLabelTrack( (LabelTrack*)t, event, tip ); SetCursorAndTipWhenInLabelTrack( static_cast<LabelTrack*>(track), event, tip );
// ..and if we haven't yet determined the cursor, // ..and if we haven't yet determined the cursor,
// we go on to do all the standard track hit tests. // we go on to do all the standard track hit tests.
} }
@ -2143,7 +2139,7 @@ void TrackPanel::HandleCursor(wxMouseEvent & event)
bool bMultiToolMode = ttb->IsDown(multiTool); bool bMultiToolMode = ttb->IsDown(multiTool);
const wxCursor *pSelection = 0; const wxCursor *pSelection = 0;
SetCursorAndTipWhenSelectTool SetCursorAndTipWhenSelectTool
( t, event, r, bMultiToolMode, tip, &pSelection ); ( track, event, trackRect, bMultiToolMode, tip, &pSelection );
if (pSelection) if (pSelection)
// Set cursor once only here, to avoid flashing during drags // Set cursor once only here, to avoid flashing during drags
SetCursor(*pSelection); SetCursor(*pSelection);
@ -6698,17 +6694,17 @@ bool TrackPanel::HandleLabelTrackMouseEvent(LabelTrack * lTrack, wxRect &r, wxMo
void TrackPanel::HandleTrackSpecificMouseEvent(wxMouseEvent & event) void TrackPanel::HandleTrackSpecificMouseEvent(wxMouseEvent & event)
{ {
Track * pTrack; Track * pTrack;
wxRect r; wxRect rTrack;
wxRect rLabel; wxRect rLabel;
bool unsafe = IsUnsafe(); bool unsafe = IsUnsafe();
FindTrack(event.m_x, event.m_y, true, true, &rLabel); FindTrack(event.m_x, event.m_y, true, true, &rLabel);
pTrack = FindTrack(event.m_x, event.m_y, false, false, &r); pTrack = FindTrack(event.m_x, event.m_y, false, false, &rTrack);
//call HandleResize if I'm over the border area //call HandleResize if I'm over the border area
if (event.LeftDown() && if (event.LeftDown() &&
(within(event.m_y, r.y + r.height, TRACK_RESIZE_REGION) (within(event.m_y, rTrack.y + rTrack.height, TRACK_RESIZE_REGION)
|| within(event.m_y, rLabel.y + rLabel.height, || within(event.m_y, rLabel.y + rLabel.height,
TRACK_RESIZE_REGION))) { TRACK_RESIZE_REGION))) {
HandleResize(event); HandleResize(event);
@ -6734,7 +6730,7 @@ void TrackPanel::HandleTrackSpecificMouseEvent(wxMouseEvent & event)
//If so, use MouseDown handler for the label track. //If so, use MouseDown handler for the label track.
if (pTrack && (pTrack->GetKind() == Track::Label)) if (pTrack && (pTrack->GetKind() == Track::Label))
{ {
if(HandleLabelTrackMouseEvent( (LabelTrack *) pTrack, r, event )) if (HandleLabelTrackMouseEvent((LabelTrack *)pTrack, rTrack, event))
return; return;
} }
@ -6755,7 +6751,7 @@ void TrackPanel::HandleTrackSpecificMouseEvent(wxMouseEvent & event)
(mMouseCapture == IsUncaptured || mMouseCapture == IsOverCutLine || (mMouseCapture == IsUncaptured || mMouseCapture == IsOverCutLine ||
mMouseCapture == WasOverCutLine)) mMouseCapture == WasOverCutLine))
{ {
if (HandleTrackLocationMouseEvent( (WaveTrack *) pTrack, r, event )) if (HandleTrackLocationMouseEvent((WaveTrack *)pTrack, rTrack, event))
return; return;
} }

View File

@ -356,7 +356,7 @@ protected:
// AS: Cursor handling // AS: Cursor handling
virtual bool SetCursorByActivity( ); virtual bool SetCursorByActivity( );
virtual void SetCursorAndTipWhenInLabel( Track * t, wxMouseEvent &event, wxString &tip ); virtual void SetCursorAndTipWhenInLabel( Track * t, wxMouseEvent &event, wxString &tip );
virtual void SetCursorAndTipWhenInVResizeArea( Track * label, bool blinked, wxString &tip ); virtual void SetCursorAndTipWhenInVResizeArea( bool blinked, wxString &tip );
virtual void SetCursorAndTipWhenInLabelTrack( LabelTrack * pLT, wxMouseEvent & event, wxString &tip ); virtual void SetCursorAndTipWhenInLabelTrack( LabelTrack * pLT, wxMouseEvent & event, wxString &tip );
virtual void SetCursorAndTipWhenSelectTool virtual void SetCursorAndTipWhenSelectTool
( Track * t, wxMouseEvent & event, wxRect &r, bool bMultiToolMode, wxString &tip, const wxCursor ** ppCursor ); ( Track * t, wxMouseEvent & event, wxRect &r, bool bMultiToolMode, wxString &tip, const wxCursor ** ppCursor );