mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-18 00:50:52 +02:00
New commands for selecting clips using the keyboard
Added two commands: Select > Previous clip. Select the previous clip for which clip start < selection start/cursor position. Select > Next clip. If the position of selection start/cursor is at the start of a clip, and selection end is not at the end of the clip, select that clip. Otherwise, select the next clip for which clip start > selection start/cursor position.
This commit is contained in:
parent
a519e6fc7d
commit
c382139c05
@ -593,6 +593,10 @@ void AudacityProject::CreateMenusAndCommands()
|
|||||||
c->AddItem(wxT("SelCursorToNextClipBoundary"), _("Cursor to Ne&xt Clip Boundary"),
|
c->AddItem(wxT("SelCursorToNextClipBoundary"), _("Cursor to Ne&xt Clip Boundary"),
|
||||||
FN(OnSelectCursorToNextClipBoundary), wxT(""),
|
FN(OnSelectCursorToNextClipBoundary), wxT(""),
|
||||||
TrackPanelHasFocus |WaveTracksExistFlag, TrackPanelHasFocus | WaveTracksExistFlag);
|
TrackPanelHasFocus |WaveTracksExistFlag, TrackPanelHasFocus | WaveTracksExistFlag);
|
||||||
|
c->AddItem(wxT("SelPrevClip"), _("Previo&us Clip"), FN(OnSelectPrevClip), wxT(""),
|
||||||
|
WaveTracksExistFlag | TrackPanelHasFocus, WaveTracksExistFlag | TrackPanelHasFocus);
|
||||||
|
c->AddItem(wxT("SelNextClip"), _("N&ext Clip"), FN(OnSelectNextClip), wxT(""),
|
||||||
|
WaveTracksExistFlag | TrackPanelHasFocus, WaveTracksExistFlag | TrackPanelHasFocus);
|
||||||
c->AddItem(wxT("SelCursorStoredCursor"), _("Cursor to Saved &Cursor Position"), FN(OnSelectCursorStoredCursor),
|
c->AddItem(wxT("SelCursorStoredCursor"), _("Cursor to Saved &Cursor Position"), FN(OnSelectCursorStoredCursor),
|
||||||
wxT(""), TracksExistFlag, TracksExistFlag);
|
wxT(""), TracksExistFlag, TracksExistFlag);
|
||||||
|
|
||||||
@ -5366,6 +5370,65 @@ void AudacityProject::OnSelectClipBoundary(bool next)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudacityProject::OnSelectPrevClip()
|
||||||
|
{
|
||||||
|
OnSelectClip(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudacityProject::OnSelectNextClip()
|
||||||
|
{
|
||||||
|
OnSelectClip(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudacityProject::OnSelectClip(bool next)
|
||||||
|
{
|
||||||
|
auto track = mTrackPanel->GetFocusedTrack();
|
||||||
|
|
||||||
|
if (track && track->GetKind() == Track::Wave) {
|
||||||
|
auto wt = static_cast<WaveTrack*>(track);
|
||||||
|
const auto clips = wt->SortedClipArray();
|
||||||
|
double t0 = mViewInfo.selectedRegion.t0();
|
||||||
|
double t1 = mViewInfo.selectedRegion.t1();
|
||||||
|
WaveClip* clip = nullptr;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (next) {
|
||||||
|
auto result = find_if(clips.begin(), clips.end(), [&] (WaveClip* const& clip) {
|
||||||
|
return clip->GetStartTime() == t0; });
|
||||||
|
if (result != clips.end() && (*result)->GetEndTime() != t1 ) {
|
||||||
|
clip = *result;
|
||||||
|
i = result - clips.begin();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto result = find_if(clips.begin(), clips.end(), [&] (WaveClip* const& clip) {
|
||||||
|
return clip->GetStartTime() > t0; });
|
||||||
|
if (result != clips.end()) {
|
||||||
|
clip = *result;
|
||||||
|
i = result - clips.begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto result = find_if(clips.rbegin(), clips.rend(), [&] (WaveClip* const& clip) {
|
||||||
|
return clip->GetStartTime() < t0; });
|
||||||
|
if (result != clips.rend()) {
|
||||||
|
clip = *result;
|
||||||
|
i = static_cast<int>(clips.size()) - 1 - (result - clips.rbegin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clip) {
|
||||||
|
mViewInfo.selectedRegion.setTimes(clip->GetStartTime(), clip->GetEndTime());
|
||||||
|
mTrackPanel->ScrollIntoView(mViewInfo.selectedRegion.t0());
|
||||||
|
ModifyState(false);
|
||||||
|
mTrackPanel->Refresh(false);
|
||||||
|
wxString message;
|
||||||
|
message.Printf(wxT("%d %s %d %s"), i + 1, _("of"), clips.size(), _("selected"));
|
||||||
|
mTrackPanel->MessageForScreenReader(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AudacityProject::OnSelectCursorStoredCursor()
|
void AudacityProject::OnSelectCursorStoredCursor()
|
||||||
{
|
{
|
||||||
if (mCursorPositionHasBeenStored) {
|
if (mCursorPositionHasBeenStored) {
|
||||||
|
@ -285,6 +285,9 @@ void OnSelectStartCursor();
|
|||||||
void OnSelectPrevClipBoundaryToCursor();
|
void OnSelectPrevClipBoundaryToCursor();
|
||||||
void OnSelectCursorToNextClipBoundary();
|
void OnSelectCursorToNextClipBoundary();
|
||||||
void OnSelectClipBoundary(bool next);
|
void OnSelectClipBoundary(bool next);
|
||||||
|
void OnSelectPrevClip();
|
||||||
|
void OnSelectNextClip();
|
||||||
|
void OnSelectClip(bool next);
|
||||||
void OnSelectCursorStoredCursor();
|
void OnSelectCursorStoredCursor();
|
||||||
void OnSelectSyncLockSel();
|
void OnSelectSyncLockSel();
|
||||||
void OnSelectAllTracks();
|
void OnSelectAllTracks();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user