mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-08 08:27:43 +02:00
Merge branch 'Bug30'
This commit is contained in:
commit
554f215948
@ -99,7 +99,7 @@ LabelTrack::LabelTrack(DirManager * projDirManager):
|
|||||||
mSelIndex(-1),
|
mSelIndex(-1),
|
||||||
mMouseOverLabelLeft(-1),
|
mMouseOverLabelLeft(-1),
|
||||||
mMouseOverLabelRight(-1),
|
mMouseOverLabelRight(-1),
|
||||||
mpRestoreFocus(0),
|
mRestoreFocus(-1),
|
||||||
mClipLen(0.0),
|
mClipLen(0.0),
|
||||||
mIsAdjustingLabel(false)
|
mIsAdjustingLabel(false)
|
||||||
{
|
{
|
||||||
@ -1841,9 +1841,14 @@ bool LabelTrack::OnKeyDown(SelectedRegion &newSel, wxKeyEvent & event)
|
|||||||
case WXK_NUMPAD_ENTER:
|
case WXK_NUMPAD_ENTER:
|
||||||
|
|
||||||
case WXK_ESCAPE:
|
case WXK_ESCAPE:
|
||||||
if (mpRestoreFocus) {
|
if (mRestoreFocus >= 0) {
|
||||||
GetActiveProject()->GetTrackPanel()->SetFocusedTrack(mpRestoreFocus);
|
TrackListIterator iter(GetActiveProject()->GetTracks());
|
||||||
mpRestoreFocus = 0;
|
Track *track = iter.First();
|
||||||
|
while (track && mRestoreFocus--)
|
||||||
|
track = iter.Next();
|
||||||
|
if (track)
|
||||||
|
GetActiveProject()->GetTrackPanel()->SetFocusedTrack(track);
|
||||||
|
mRestoreFocus = -1;
|
||||||
}
|
}
|
||||||
mSelIndex = -1;
|
mSelIndex = -1;
|
||||||
break;
|
break;
|
||||||
@ -2647,7 +2652,7 @@ int LabelTrack::GetLabelIndex(double t, double t1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int LabelTrack::AddLabel(const SelectedRegion &selectedRegion,
|
int LabelTrack::AddLabel(const SelectedRegion &selectedRegion,
|
||||||
const wxString &title, Track *pRestoreFocus)
|
const wxString &title, int restoreFocus)
|
||||||
{
|
{
|
||||||
LabelStruct *l = new LabelStruct(selectedRegion, title);
|
LabelStruct *l = new LabelStruct(selectedRegion, title);
|
||||||
mCurrentCursorPos = title.length();
|
mCurrentCursorPos = title.length();
|
||||||
@ -2674,7 +2679,7 @@ int LabelTrack::AddLabel(const SelectedRegion &selectedRegion,
|
|||||||
// mDrawCursor flag will be reset once the action is complete.
|
// mDrawCursor flag will be reset once the action is complete.
|
||||||
mDrawCursor = true;
|
mDrawCursor = true;
|
||||||
|
|
||||||
mpRestoreFocus = pRestoreFocus;
|
mRestoreFocus = restoreFocus;
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ class AUDACITY_DLL_API LabelTrack : public Track
|
|||||||
|
|
||||||
//This returns the index of the label we just added.
|
//This returns the index of the label we just added.
|
||||||
int AddLabel(const SelectedRegion ®ion, const wxString &title = wxT(""),
|
int AddLabel(const SelectedRegion ®ion, const wxString &title = wxT(""),
|
||||||
Track *pRestoreFocus = 0);
|
int restoreFocus = -1);
|
||||||
//And this tells us the index, if there is a label already there.
|
//And this tells us the index, if there is a label already there.
|
||||||
int GetLabelIndex(double t, double t1);
|
int GetLabelIndex(double t, double t1);
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ class AUDACITY_DLL_API LabelTrack : public Track
|
|||||||
bool mResetCursorPos; /// flag to reset cursor position(used in the dragging the glygh)
|
bool mResetCursorPos; /// flag to reset cursor position(used in the dragging the glygh)
|
||||||
bool mRightDragging; /// flag to tell if it's a valid dragging
|
bool mRightDragging; /// flag to tell if it's a valid dragging
|
||||||
bool mDrawCursor; /// flag to tell if drawing the cursor or not
|
bool mDrawCursor; /// flag to tell if drawing the cursor or not
|
||||||
Track *mpRestoreFocus; /// Restore focus to this track when done editing
|
int mRestoreFocus; /// Restore focus to this track when done editing
|
||||||
|
|
||||||
// Set in copied label tracks
|
// Set in copied label tracks
|
||||||
double mClipLen;
|
double mClipLen;
|
||||||
|
@ -6347,7 +6347,23 @@ int AudacityProject::DoAddLabel(const SelectedRegion ®ion, bool preserveFocus
|
|||||||
// SelectNone();
|
// SelectNone();
|
||||||
lt->SetSelected(true);
|
lt->SetSelected(true);
|
||||||
|
|
||||||
int index = lt->AddLabel(region, wxString(), (preserveFocus ? pFocusedTrack : 0));
|
int focusTrackNumber = -1;
|
||||||
|
if (pFocusedTrack && preserveFocus) {
|
||||||
|
// Must remember the track to re-focus after finishing a label edit.
|
||||||
|
// do NOT identify it by a pointer, which might dangle! Identify
|
||||||
|
// by position.
|
||||||
|
TrackListIterator iter(GetTracks());
|
||||||
|
Track *track = iter.First();
|
||||||
|
do
|
||||||
|
++focusTrackNumber;
|
||||||
|
while (track != pFocusedTrack &&
|
||||||
|
NULL != (track = iter.Next()));
|
||||||
|
if (!track)
|
||||||
|
// How could we not find it?
|
||||||
|
focusTrackNumber = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = lt->AddLabel(region, wxString(), focusTrackNumber);
|
||||||
|
|
||||||
PushState(_("Added label"), _("Label"));
|
PushState(_("Added label"), _("Label"));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user