1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-01 16:19:43 +02:00

Change to the initial row selected in label editor. The initial row is the nearest previous label. If there is not one, then its the first label.

This commit is contained in:
David Bailes 2015-05-21 14:16:06 +01:00
parent 0dbaa76a7b
commit 7b88005899
2 changed files with 42 additions and 3 deletions

View File

@ -39,6 +39,7 @@
#include "widgets/NumericTextCtrl.h"
#include "FileDialog.h"
#include <limits>
enum Column
{
@ -380,7 +381,6 @@ void LabelDialog::FindAllLabels()
TrackListIterator iter(mTracks);
Track *t;
mInitialRow = -1;
// Add labels from all label tracks
for (t = iter.First(); t; t = iter.Next()) {
@ -389,6 +389,8 @@ void LabelDialog::FindAllLabels()
}
}
FindInitialRow();
if (mData.GetCount() == 0) {
wxCommandEvent e;
OnInsert(e);
@ -414,9 +416,45 @@ void LabelDialog::AddLabels(LabelTrack *t)
rd->title = ls->title;
mData.Add(rd);
}
}
if (i == t->getSelectedIndex()) {
mInitialRow = mData.GetCount() - 1;
void LabelDialog::FindInitialRow()
{
int cnt = mData.GetCount();
mInitialRow = -1;
if (cnt == 0)
return;
// find closest previous label
double distMin = std::numeric_limits<double>::max();
double dist;
double t0 = mViewInfo->selectedRegion.t0();
int i;
for (i = 0; i < cnt; i++)
{
dist = t0 - mData[i]->selectedRegion.t0();
if (dist >= 0.0 && dist < distMin)
{
mInitialRow = i;
distMin = dist;
}
}
// if no previous label was found, find first label
if (mInitialRow == -1)
{
double t0Min = std::numeric_limits<double>::max();
for (i = 0; i < cnt; i++)
{
if (mData[i]->selectedRegion.t0() < t0Min)
{
mInitialRow = i;
t0Min = mData[i]->selectedRegion.t0();
}
}
}
}

View File

@ -50,6 +50,7 @@ class LabelDialog:public wxDialog
bool Validate();
void FindAllLabels();
void AddLabels(LabelTrack *t);
void FindInitialRow();
wxString TrackName(int & index, wxString dflt = _("Label Track"));
void OnUpdate(wxCommandEvent &event);