3#include "../CommonCommandFlags.h"
7#include "../ProjectWindow.h"
8#include "../ProjectWindows.h"
9#include "../RealtimeEffectPanel.h"
12#include "../TrackPanel.h"
13#include "../TrackPanelAx.h"
14#include "../commands/CommandContext.h"
15#include "../commands/CommandManager.h"
16#include "../toolbars/ToolManager.h"
17#include "../widgets/AButton.h"
18#include "../widgets/ASlider.h"
19#include "../widgets/MeterPanel.h"
34 std::vector<wxWindow*> seq;
43 auto FindAncestor = [&]() {
47 auto it = std::find(seq.cbegin(), seq.cend(), pWindow);
49 return static_cast<size_t>(std::distance(seq.cbegin(), it));
50 pWindow = pWindow->GetParent();
55 const auto idx = FindAncestor();
56 if (idx == seq.size())
60 const auto increment = (forward ? 1 :
static_cast<int>(seq.size()) - 1);
62 while( idx != (idx2 = (idx2 + increment) % seq.size()) ) {
63 wxWindow *toFocus = seq[idx2];
64 if(!toFocus->IsShown())
68 if ( FindAncestor() == idx2 )
83 auto t = trackFocus.Get();
86 t = *tracks.Any().rbegin();
89 t->EnsureVisible(
true );
94 bool tSelected =
false;
95 bool pSelected =
false;
98 p = * -- tracks.FindLeader( t );
104 if( circularTrackNavigation )
105 p = *tracks.
Any().rbegin();
112 tSelected = t->GetSelected();
115 if( tSelected && pSelected )
117 selectionState.SelectTrack
118 ( *t,
false,
false );
124 if( tSelected && !pSelected )
126 selectionState.SelectTrack
133 if( !tSelected && pSelected )
135 selectionState.SelectTrack
136 ( *p,
false,
false );
142 if( !tSelected && !pSelected )
144 selectionState.SelectTrack
154 p = * -- tracks.FindLeader( t );
158 if( circularTrackNavigation )
160 auto range = tracks.Leaders();
161 p = * range.rbegin();
193 auto t = trackFocus.Get();
196 t = *tracks.Any().begin();
199 t->EnsureVisible(
true );
205 auto n = * ++ tracks.FindLeader( t );
209 if( circularTrackNavigation )
210 n = *tracks.Any().begin();
217 auto tSelected = t->GetSelected();
218 auto nSelected = n->GetSelected();
219 if( tSelected && nSelected )
221 selectionState.SelectTrack
222 ( *t,
false,
false );
225 n->EnsureVisible(
true );
228 if( tSelected && !nSelected )
230 selectionState.SelectTrack
234 n->EnsureVisible(
true );
237 if( !tSelected && nSelected )
239 selectionState.SelectTrack
240 ( *n,
false,
false );
243 n->EnsureVisible(
true );
246 if( !tSelected && !nSelected )
248 selectionState.SelectTrack
252 n->EnsureVisible(
true );
258 auto n = * ++ tracks.FindLeader( t );
262 if( circularTrackNavigation )
264 n = *tracks.Any().begin();
267 n->EnsureVisible(
true );
279 n->EnsureVisible(
true );
303 auto &project = context.
project;
305 auto isEnabled = window.IsEnabled();
308 const auto & list = window.GetChildren();
309 auto iter = list.rbegin(),
end = list.rend();
319 while (iter !=
end && *iter != w)
326 for (; iter !=
end; ++iter)
331 if (w->IsTopLevel() && w->IsShown() && isEnabled)
338 if ((iter ==
end) && isEnabled)
349#if defined(__WXMAC__) || defined(__WXGTK__)
354 if (
dynamic_cast<wxDialog*
>(w)) {
362 auto &project = context.
project;
364 auto isEnabled = window.IsEnabled();
367 const auto & list = window.GetChildren();
368 auto iter = list.begin(),
end = list.end();
381 while (iter !=
end && *iter != w)
388 for (; iter !=
end; ++iter)
394 if (w->IsTopLevel() && w->IsShown() && w->IsEnabled())
401 if ((iter ==
end) && isEnabled)
412#if defined(__WXMAC__) || defined(__WXGTK__)
417 if (
dynamic_cast<wxDialog*
>(w)) {
425 auto &project = context.
project;
431 auto &project = context.
project;
440 auto &project = context.
project;
446 auto &project = context.
project;
452 auto &project = context.
project;
456 auto t = trackFocus.Get();
460 auto f = *tracks.Any().begin();
464 f->EnsureVisible( t != f );
469 auto &project = context.
project;
477 auto l = *tracks.Any().rbegin();
481 l->EnsureVisible( t != l );
486 auto &project = context.
project;
492 auto &project = context.
project;
498 auto &project = context.
project;
504 t = trackFocus.
Get();
508 selectionState.SelectTrack
512 trackFocus.UpdateAccessibility();
520 gPrefs->ReadBool(
wxT(
"/GUI/CircularTrackNavigation"),
false);
537 return std::make_unique< NavigationActions::Handler >(); } };
545#define FN(X) (& NavigationActions::Handler :: X)
557 Command(
wxT(
"PrevWindow"),
XXO(
"Move Backward Through Active Windows"),
560 Command(
wxT(
"NextWindow"),
XXO(
"Move Forward Through Active Windows"),
568 wxT(
"Optional/Extra/Part2"),
580 XXO(
"Move &Backward from Toolbars to Tracks"),
FN(OnPrevFrame),
583 XXO(
"Move F&orward from Toolbars to Tracks"),
FN(OnNextFrame),
585 Command(
wxT(
"PrevTrack"),
XXO(
"Move Focus to &Previous Track"),
586 FN(OnCursorUp), FocusedTracksFlags,
wxT(
"Up") ),
588 FN(OnCursorDown), FocusedTracksFlags,
wxT(
"Down") ),
589 Command(
wxT(
"FirstTrack"),
XXO(
"Move Focus to &First Track"),
590 FN(OnFirstTrack), FocusedTracksFlags,
wxT(
"Ctrl+Home") ),
592 FN(OnLastTrack), FocusedTracksFlags,
wxT(
"Ctrl+End") ),
593 Command(
wxT(
"ShiftUp"),
XXO(
"Move Focus to P&revious and Select"),
594 FN(OnShiftUp), FocusedTracksFlags,
wxT(
"Shift+Up") ),
595 Command(
wxT(
"ShiftDown"),
XXO(
"Move Focus to N&ext and Select"),
596 FN(OnShiftDown), FocusedTracksFlags,
wxT(
"Shift+Down") ),
598 FocusedTracksFlags,
wxT(
"Return") ),
600 FocusedTracksFlags,
wxT(
"NUMPAD_ENTER") )
606 wxT(
"Optional/Extra/Part2"),
AttachedItem sAttachment3
AttachedItem sAttachment2
constexpr CommandFlag AlwaysEnabledFlag
wxEvtHandler CommandHandlerObject
const ReservedCommandFlag & TracksExistFlag()
const ReservedCommandFlag & TrackPanelHasFocus()
XXO("&Cut/Copy/Paste Toolbar")
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
declares abstract base class Track, TrackList, and iterators over TrackList
static TempAllowFocus TemporarilyAllowFocus()
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
AudacityProject & project
static TempAllowFocus TemporarilyAllowFocus()
A listener notified of changes in preferences.
static ProjectHistory & Get(AudacityProject &project)
static ProjectWindow & Get(AudacityProject &project)
static RealtimeEffectPanel & Get(AudacityProject &project)
static SelectionState & Get(AudacityProject &project)
Abstract base class for an object holding data associated with points on a time axis.
void EnsureVisible(bool modifyState=false)
static TrackList & Get(AudacityProject &project)
static TrackPanel & Get(AudacityProject &project)
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Namespace for functions for project navigation menu (part of Extra menu)
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
std::shared_ptr< BaseItem > BaseItemSharedPtr
CommandManager::Options Options
A convenient default parameter for class template Site.
void OnNextWindow(const CommandContext &context)
void OnNextFrame(const CommandContext &context)
void OnToggle(const CommandContext &context)
void OnPrevFrame(const CommandContext &context)
void OnCursorUp(const CommandContext &context)
void OnShiftDown(const CommandContext &context)
void OnPrevWindow(const CommandContext &context)
void UpdatePrefs() override
Handler(const Handler &) PROHIBITED
Handler & operator=(const Handler &) PROHIBITED
void OnLastTrack(const CommandContext &context)
void OnCursorDown(const CommandContext &context)
bool mCircularTrackNavigation
void OnFirstTrack(const CommandContext &context)
void OnShiftUp(const CommandContext &context)