1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-29 08:43:56 +01:00

TrackPanel no longer implements label keystrokes, drags, text selection...

... also implemented ESC key for those drags

... temporarily loses the special CTRL click handling
This commit is contained in:
Paul Licameli
2015-08-17 17:49:00 -04:00
committed by Paul Licameli
parent bbfa574790
commit efdb9889b1
15 changed files with 923 additions and 326 deletions

View File

@@ -166,7 +166,6 @@ is time to refresh some aspect of the screen.
#include "AllThemeResources.h"
#include "AudioIO.h"
#include "float_cast.h"
#include "LabelTrack.h"
#include "MixerBoard.h"
#include "NoteTrack.h"
@@ -356,8 +355,6 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
}
mMouseCapture = IsUncaptured;
mLabelTrackStartXPos=-1;
mRedrawAfterStop = false;
@@ -553,28 +550,6 @@ void TrackPanel::SetCapturedTrack( Track * t, enum MouseCaptureEnum MouseCapture
mMouseCapture = MouseCapture;
}
/// Select all tracks marked by the label track lt
void TrackPanel::SelectTracksByLabel( LabelTrack *lt )
{
TrackListIterator iter(GetTracks());
Track *t = iter.First();
//do nothing if at least one other track is selected
while (t) {
if( t->GetSelected() && t != lt )
return;
t = iter.Next();
}
//otherwise, select all tracks
t = iter.First();
while( t )
{
GetSelectionState().SelectTrack( *mTracks, *t, true, true, GetMixerBoard() );
t = iter.Next();
}
}
void TrackPanel::GetTracksUsableArea(int *width, int *height) const
{
GetSize(width, height);
@@ -859,7 +834,6 @@ void TrackPanel::HandleInterruptedDrag()
{
case IsUncaptured:
case IsSelecting:
case IsSelectingLabelText:
sendEvent = false;
default:
@@ -867,9 +841,8 @@ void TrackPanel::HandleInterruptedDrag()
}
/*
So this includes the cases:
So this includes the case:
IsAdjustingLabel,
IsStretching
*/
@@ -1087,9 +1060,6 @@ bool TrackPanel::SetCursorByActivity( )
case IsSelecting:
SetCursor(*mSelectCursor);
return true;
case IsAdjustingLabel:
case IsSelectingLabelText:
return true;
#if 0
case IsStretching:
SetCursor( unsafe
@@ -1103,37 +1073,6 @@ bool TrackPanel::SetCursorByActivity( )
return false;
}
/// When in a label track, find out if we've hit anything that
/// would cause a cursor change.
void TrackPanel::SetCursorAndTipWhenInLabelTrack( LabelTrack * pLT,
const wxMouseEvent & event, wxString &tip )
{
int edge=pLT->OverGlyph(event.m_x, event.m_y);
if(edge !=0)
{
SetCursor(*mArrowCursor);
}
//KLUDGE: We refresh the whole Label track when the icon hovered over
//changes colouration. As well as being inefficient we are also
//doing stuff that should be delegated to the label track itself.
edge += pLT->mbHitCenter ? 4:0;
if( edge != pLT->mOldEdge )
{
pLT->mOldEdge = edge;
RefreshTrack( pLT );
}
// IF edge!=0 THEN we've set the cursor and we're done.
// signal this by setting the tip.
if( edge != 0 )
{
tip =
(pLT->mbHitCenter ) ?
_("Drag one or more label boundaries.") :
_("Drag label boundary.");
}
}
namespace {
// This returns true if we're a spectral editing track.
@@ -1415,16 +1354,6 @@ void TrackPanel::HandleCursor(wxMouseEvent & event)
SetCursor(*pCursor);
}
// Is it a label track?
if (track &&
pCursor == NULL && tip == wxString() && track->GetKind() == Track::Label)
{
// We are over a label track
SetCursorAndTipWhenInLabelTrack( static_cast<LabelTrack*>(track), event, tip );
// ..and if we haven't yet determined the cursor,
// we go on to do all the standard track hit tests.
}
if( pCursor == NULL && tip == wxString() )
{
ToolsToolBar * ttb = mListener->TP_GetToolsToolBar();
@@ -3038,9 +2967,6 @@ void TrackPanel::OnCaptureKey(wxCommandEvent & event)
HandleInterruptedDrag();
Track * const t = GetFocusedTrack();
if (t && t->GetKind() == Track::Label)
event.Skip(!((LabelTrack *)t)->CaptureKey(*kevent));
else
if (t) {
const unsigned refreshResult =
((TrackPanelCell*)t)->CaptureKey(*kevent, *mViewInfo, this);
@@ -3087,33 +3013,6 @@ void TrackPanel::OnKeyDown(wxKeyEvent & event)
Track *const t = GetFocusedTrack();
if (t && t->GetKind() == Track::Label) {
LabelTrack *lt = (LabelTrack *)t;
double bkpSel0 = mViewInfo->selectedRegion.t0(),
bkpSel1 = mViewInfo->selectedRegion.t1();
// Pass keystroke to labeltrack's handler and add to history if any
// updates were done
if (lt->OnKeyDown(mViewInfo->selectedRegion, event))
MakeParentPushState(_("Modified Label"),
_("Label Edit"),
UndoPush::CONSOLIDATE);
// Make sure caret is in view
int x;
if (lt->CalcCursorX(&x)) {
ScrollIntoView(x);
}
// If selection modified, refresh
// Otherwise, refresh track display if the keystroke was handled
if (bkpSel0 != mViewInfo->selectedRegion.t0() ||
bkpSel1 != mViewInfo->selectedRegion.t1())
Refresh(false);
else if (!event.GetSkipped())
RefreshTrack(t);
}
else
if (t) {
const unsigned refreshResult =
((TrackPanelCell*)t)->KeyDown(event, *mViewInfo, this);
@@ -3137,25 +3036,6 @@ void TrackPanel::OnChar(wxKeyEvent & event)
}
Track *const t = GetFocusedTrack();
if (t && t->GetKind() == Track::Label) {
double bkpSel0 = mViewInfo->selectedRegion.t0(),
bkpSel1 = mViewInfo->selectedRegion.t1();
// Pass keystroke to labeltrack's handler and add to history if any
// updates were done
if (((LabelTrack *)t)->OnChar(mViewInfo->selectedRegion, event))
MakeParentPushState(_("Modified Label"),
_("Label Edit"),
UndoPush::CONSOLIDATE);
// If selection modified, refresh
// Otherwise, refresh track display if the keystroke was handled
if (bkpSel0 != mViewInfo->selectedRegion.t0() ||
bkpSel1 != mViewInfo->selectedRegion.t1())
Refresh(false);
else if (!event.GetSkipped())
RefreshTrack(t);
}
else
if (t) {
const unsigned refreshResult =
((TrackPanelCell*)t)->Char(event, *mViewInfo, this);
@@ -3341,19 +3221,10 @@ try
// HandleCursor(event);
}
}
else switch( mMouseCapture ) {
case IsAdjustingLabel:
// Reach this case only when the captured track was label
HandleGlyphDragRelease(static_cast<LabelTrack *>(mCapturedTrack), event);
break;
case IsSelectingLabelText:
// Reach this case only when the captured track was label
HandleTextDragRelease(static_cast<LabelTrack *>(mCapturedTrack), event);
break;
default: //includes case of IsUncaptured
else {
// includes case of IsUncaptured
// This is where most button-downs are detected
HandleTrackSpecificMouseEvent(event);
break;
}
if (event.ButtonDown() && IsMouseCaptured()) {
@@ -3390,171 +3261,6 @@ catch( ... )
throw;
}
/// Event has happened on a track and it has been determined to be a label track.
bool TrackPanel::HandleLabelTrackClick(LabelTrack * lTrack, const wxRect &rect, wxMouseEvent & event)
{
if (!event.ButtonDown())
return false;
if(event.LeftDown())
{
/// \todo This method is one of a large number of methods in
/// TrackPanel which suitably modified belong in other classes.
TrackListIterator iter(GetTracks());
Track *n = iter.First();
while (n) {
if (n->GetKind() == Track::Label && lTrack != n) {
((LabelTrack *)n)->ResetFlags();
((LabelTrack *)n)->Unselect();
}
n = iter.Next();
}
}
mCapturedRect = rect;
lTrack->HandleClick(event, mCapturedRect, *mViewInfo, &mViewInfo->selectedRegion);
if (lTrack->IsAdjustingLabel())
{
SetCapturedTrack(lTrack, IsAdjustingLabel);
//If we are adjusting a label on a labeltrack, do not do anything
//that follows. Instead, redraw the track.
RefreshTrack(lTrack);
return true;
}
if( event.LeftDown() ){
bool bShift = event.ShiftDown();
bool bCtrlDown = event.ControlDown();
bool unsafe = IsUnsafe();
if( /*bShift ||*/ bCtrlDown ){
GetProject()->HandleListSelection(lTrack, bShift, bCtrlDown, !unsafe);
return true;
}
}
// IF the user clicked a label, THEN select all other tracks by Label
if (lTrack->IsSelected()) {
SelectTracksByLabel(lTrack);
// Do this after, for the effect on mLastPickedTrack:
GetSelectionState().SelectTrack
( *mTracks, *lTrack, true, true, GetMixerBoard() );
DisplaySelection();
// Not starting a drag
SetCapturedTrack(NULL, IsUncaptured);
if(mCapturedTrack == NULL)
SetCapturedTrack(lTrack, IsSelectingLabelText);
RefreshTrack(lTrack);
// PRL: bug1659 -- make selection change undo correctly
if (!IsUnsafe())
MakeParentModifyState(false);
return true;
}
// handle shift+ctrl down
/*if (event.ShiftDown()) { // && event.ControlDown()) {
lTrack->SetHighlightedByKey(true);
Refresh(false);
return;
}*/
// return false, there is more to do...
return false;
}
/// Event has happened on a track and it has been determined to be a label track.
void TrackPanel::HandleGlyphDragRelease(LabelTrack * lTrack, wxMouseEvent & event)
{
if (!lTrack)
return;
/// \todo This method is one of a large number of methods in
/// TrackPanel which suitably modified belong in other classes.
if (event.Dragging()) {
;
}
else if (event.LeftUp())
SetCapturedTrack(NULL);
if (lTrack->HandleGlyphDragRelease(event, mCapturedRect,
*mViewInfo, &mViewInfo->selectedRegion)) {
MakeParentPushState(_("Modified Label"),
_("Label Edit"),
UndoPush::CONSOLIDATE);
}
// Update cursor on the screen if it is a point.
DrawOverlays(false);
mRuler->DrawOverlays(false);
//If we are adjusting a label on a labeltrack, do not do anything
//that follows. Instead, redraw the track.
RefreshTrack(lTrack);
return;
}
/// Event has happened on a track and it has been determined to be a label track.
void TrackPanel::HandleTextDragRelease(LabelTrack * lTrack, wxMouseEvent & event)
{
if (!lTrack)
return;
lTrack->HandleTextDragRelease(event);
/// \todo This method is one of a large number of methods in
/// TrackPanel which suitably modified belong in other classes.
if (event.Dragging()) {
;
}
else if (event.ButtonUp())
SetCapturedTrack(NULL);
// handle dragging
if (event.Dragging()) {
// locate the initial mouse position
if (event.LeftIsDown()) {
if (mLabelTrackStartXPos == -1) {
mLabelTrackStartXPos = event.m_x;
mLabelTrackStartYPos = event.m_y;
if ((lTrack->getSelectedIndex() != -1) &&
lTrack->OverTextBox(
lTrack->GetLabel(lTrack->getSelectedIndex()),
mLabelTrackStartXPos,
mLabelTrackStartYPos))
{
mLabelTrackStartYPos = -1;
}
}
// if initial mouse position in the text box
// then only drag text
if (mLabelTrackStartYPos == -1) {
RefreshTrack(lTrack);
return;
}
}
}
// handle mouse left button up
if (event.LeftUp()) {
mLabelTrackStartXPos = -1;
}
}
// AS: I don't really understand why this code is sectioned off
// from the other OnMouseEvent code.
void TrackPanel::HandleTrackSpecificMouseEvent(wxMouseEvent & event)
@@ -3605,16 +3311,6 @@ void TrackPanel::HandleTrackSpecificMouseEvent(wxMouseEvent & event)
// To do: remove the following special things
// so that we can coalesce the code for track and non-track clicks
//Determine if user clicked on a label track.
//If so, use MouseDown handler for the label track.
if (!mUIHandle &&
pTrack && foundCell.type == CellType::Track &&
(pTrack->GetKind() == Track::Label))
{
if (HandleLabelTrackClick((LabelTrack *)pTrack, rect, event))
return;
}
bool handled = false;
ToolsToolBar * pTtb = mListener->TP_GetToolsToolBar();