mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-03 17:19:43 +02:00
Label context menu can bring up the edit dialog
This commit is contained in:
parent
28c31903e9
commit
53e30e5533
@ -88,6 +88,8 @@ END_EVENT_TABLE()
|
||||
LabelDialog::LabelDialog(wxWindow *parent,
|
||||
TrackFactory &factory,
|
||||
TrackList *tracks,
|
||||
LabelTrack *selectedTrack,
|
||||
int index,
|
||||
ViewInfo &viewinfo,
|
||||
double rate,
|
||||
const wxString & format)
|
||||
@ -98,8 +100,10 @@ LabelDialog::LabelDialog(wxWindow *parent,
|
||||
wxSize(800, 600),
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
|
||||
mFactory(factory),
|
||||
mTracks(tracks),
|
||||
mViewInfo(&viewinfo),
|
||||
mTracks(tracks)
|
||||
, mSelectedTrack(selectedTrack)
|
||||
, mIndex(index)
|
||||
, mViewInfo(&viewinfo),
|
||||
mRate(rate),
|
||||
mFormat(format)
|
||||
{
|
||||
@ -302,9 +306,10 @@ bool LabelDialog::TransferDataFromWindow()
|
||||
Track *t;
|
||||
int tndx = 0;
|
||||
|
||||
// Clear all label tracks of labels
|
||||
// Clear label tracks of labels
|
||||
for (t = iter.First(); t; t = iter.Next()) {
|
||||
if (t->GetKind() == Track::Label) {
|
||||
if (t->GetKind() == Track::Label &&
|
||||
(!mSelectedTrack || mSelectedTrack == t)) {
|
||||
LabelTrack *lt = (LabelTrack *)t;
|
||||
tndx++;
|
||||
|
||||
@ -343,8 +348,8 @@ bool LabelDialog::TransferDataFromWindow()
|
||||
return false;
|
||||
|
||||
// Add the label to it
|
||||
((LabelTrack *) t)->AddLabel(rd.selectedRegion, rd.title);
|
||||
((LabelTrack *) t)->Unselect();
|
||||
static_cast<LabelTrack *>(t)->AddLabel(rd.selectedRegion, rd.title);
|
||||
static_cast<LabelTrack *>(t)->Unselect();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -380,9 +385,8 @@ void LabelDialog::FindAllLabels()
|
||||
|
||||
// Add labels from all label tracks
|
||||
for (t = iter.First(); t; t = iter.Next()) {
|
||||
if (t->GetKind() == Track::Label) {
|
||||
AddLabels((LabelTrack *) t);
|
||||
}
|
||||
if (t->GetKind() == Track::Label)
|
||||
AddLabels(static_cast<LabelTrack *>(t));
|
||||
}
|
||||
|
||||
FindInitialRow();
|
||||
@ -402,11 +406,14 @@ void LabelDialog::AddLabels(LabelTrack *t)
|
||||
// Add a NEW track name
|
||||
TrackName(tndx, t->GetName());
|
||||
|
||||
// Add each label in the track
|
||||
for (i = 0; i < t->GetNumLabels(); i++) {
|
||||
const LabelStruct *ls = t->GetLabel(i);
|
||||
// If editor was invoked for one label, add that one only, else add all.
|
||||
if (!mSelectedTrack || mSelectedTrack == t) {
|
||||
for (i = 0; i < t->GetNumLabels(); i++) {
|
||||
const LabelStruct *ls = t->GetLabel(i);
|
||||
|
||||
mData.push_back(RowData(tndx, ls->title, ls->selectedRegion));
|
||||
if (mIndex < 0 || mIndex == i)
|
||||
mData.push_back(RowData(tndx, ls->title, ls->selectedRegion));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -569,7 +576,7 @@ void LabelDialog::OnImport(wxCommandEvent & WXUNUSED(event))
|
||||
auto lt = mFactory.NewLabelTrack();
|
||||
lt->Import(f);
|
||||
|
||||
// Add the labesls to our collection
|
||||
// Add the labels to our collection
|
||||
AddLabels(lt.get());
|
||||
|
||||
// Done with the temporary track
|
||||
|
@ -37,6 +37,14 @@ class LabelDialog final : public wxDialog
|
||||
LabelDialog(wxWindow *parent,
|
||||
TrackFactory &factory,
|
||||
TrackList *tracks,
|
||||
|
||||
// if NULL edit all tracks, else this one only:
|
||||
LabelTrack *selectedTrack,
|
||||
|
||||
// This is nonnegative only if selectedTrack is not NULL
|
||||
// and is the unique label to edit
|
||||
int index,
|
||||
|
||||
ViewInfo &viewinfo,
|
||||
double rate,
|
||||
const wxString & format);
|
||||
@ -78,6 +86,8 @@ class LabelDialog final : public wxDialog
|
||||
|
||||
TrackFactory &mFactory;
|
||||
TrackList *mTracks;
|
||||
LabelTrack *mSelectedTrack {};
|
||||
int mIndex { -1 };
|
||||
ViewInfo *mViewInfo;
|
||||
wxArrayString mTrackNames;
|
||||
double mRate;
|
||||
|
@ -69,6 +69,7 @@ enum
|
||||
OnCopySelectedTextID,
|
||||
OnPasteSelectedTextID,
|
||||
OnDeleteSelectedLabelID,
|
||||
OnEditSelectedLabelID,
|
||||
};
|
||||
|
||||
wxFont LabelTrack::msFont;
|
||||
@ -2029,11 +2030,13 @@ void LabelTrack::ShowContextMenu()
|
||||
menu.Append(OnCopySelectedTextID, _("&Copy"));
|
||||
menu.Append(OnPasteSelectedTextID, _("&Paste"));
|
||||
menu.Append(OnDeleteSelectedLabelID, _("&Delete Label"));
|
||||
menu.Append(OnEditSelectedLabelID, _("&Edit..."));
|
||||
|
||||
menu.Enable(OnCutSelectedTextID, IsTextSelected());
|
||||
menu.Enable(OnCopySelectedTextID, IsTextSelected());
|
||||
menu.Enable(OnPasteSelectedTextID, IsTextClipSupported());
|
||||
menu.Enable(OnDeleteSelectedLabelID, true);
|
||||
menu.Enable(OnEditSelectedLabelID, true);
|
||||
|
||||
const LabelStruct *ls = GetLabel(mSelIndex);
|
||||
|
||||
@ -2094,7 +2097,7 @@ void LabelTrack::OnContextMenu(wxCommandEvent & evt)
|
||||
break;
|
||||
|
||||
/// DELETE selected label
|
||||
case OnDeleteSelectedLabelID:
|
||||
case OnDeleteSelectedLabelID: {
|
||||
int ndx = GetLabelIndex(p->GetSel0(), p->GetSel1());
|
||||
if (ndx != -1)
|
||||
{
|
||||
@ -2103,6 +2106,14 @@ void LabelTrack::OnContextMenu(wxCommandEvent & evt)
|
||||
_("Label Edit"),
|
||||
UndoPush::CONSOLIDATE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case OnEditSelectedLabelID: {
|
||||
int ndx = GetLabelIndex(p->GetSel0(), p->GetSel1());
|
||||
if (ndx != -1)
|
||||
p->DoEditLabels(this, ndx);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -6551,11 +6551,14 @@ void AudacityProject::OnAddLabelPlaying()
|
||||
}
|
||||
}
|
||||
|
||||
void AudacityProject::OnEditLabels()
|
||||
void AudacityProject::DoEditLabels(LabelTrack *lt, int index)
|
||||
{
|
||||
wxString format = GetSelectionFormat();
|
||||
|
||||
LabelDialog dlg(this, *GetTrackFactory(), mTracks, mViewInfo, mRate, format);
|
||||
LabelDialog dlg(this, *GetTrackFactory(), mTracks,
|
||||
lt, index,
|
||||
mViewInfo, mRate,
|
||||
format);
|
||||
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
PushState(_("Edited labels"), _("Label"));
|
||||
@ -6563,6 +6566,11 @@ void AudacityProject::OnEditLabels()
|
||||
}
|
||||
}
|
||||
|
||||
void AudacityProject::OnEditLabels()
|
||||
{
|
||||
DoEditLabels();
|
||||
}
|
||||
|
||||
void AudacityProject::OnApplyChain()
|
||||
{
|
||||
BatchProcessDialog dlg(this);
|
||||
|
@ -365,6 +365,7 @@ void OnRemoveTracks();
|
||||
void OnSyncLock();
|
||||
void OnAddLabel();
|
||||
void OnAddLabelPlaying();
|
||||
void DoEditLabels(LabelTrack *lt = nullptr, int index = -1);
|
||||
void OnEditLabels();
|
||||
|
||||
// Effect Menu
|
||||
|
Loading…
x
Reference in New Issue
Block a user