3#include "../CommonCommandFlags.h"
7#include "../ProjectWindow.h"
8#include "../ProjectWindows.h"
10#include "../SelectionState.h"
11#include "../TrackPanel.h"
12#include "../TrackPanelAx.h"
13#include "../commands/CommandContext.h"
14#include "../commands/CommandManager.h"
15#include "../toolbars/ToolManager.h"
16#include "../widgets/AButton.h"
17#include "../widgets/ASlider.h"
18#include "../widgets/MeterPanel.h"
34 auto botDock = toolManager.GetBotDock();
38 static const unsigned rotationSize = 3u;
40 wxWindow *
const begin [rotationSize] = {
46 const auto end =
begin + rotationSize;
49 auto IndexOf = [&](wxWindow *pWindow) {
53 auto FindAncestor = [&]() {
54 wxWindow *pWindow = wxWindow::FindFocus();
55 unsigned index = rotationSize;
57 (rotationSize == (index = IndexOf(pWindow) ) ) )
58 pWindow = pWindow->GetParent();
62 const auto idx = FindAncestor();
63 if (idx == rotationSize)
67 auto increment = (forward ? 1 : rotationSize - 1);
69 while( idx != (idx2 = (idx2 + increment) % rotationSize) ) {
70 wxWindow *toFocus =
begin[idx2];
71 bool bIsAnEmptyDock=
false;
73 bIsAnEmptyDock = ((idx2==0) ? toolManager.GetTopDock() : botDock)->
74 GetChildren().GetCount() < 1;
77 if( !bIsAnEmptyDock ){
79 if ( FindAncestor() == idx2 )
95 auto t = trackFocus.Get();
98 t = *tracks.Any().rbegin();
101 t->EnsureVisible(
true );
106 bool tSelected =
false;
107 bool pSelected =
false;
110 p = * -- tracks.FindLeader( t );
116 if( circularTrackNavigation )
117 p = *tracks.
Any().rbegin();
124 tSelected = t->GetSelected();
127 if( tSelected && pSelected )
129 selectionState.SelectTrack
130 ( *t,
false,
false );
136 if( tSelected && !pSelected )
138 selectionState.SelectTrack
145 if( !tSelected && pSelected )
147 selectionState.SelectTrack
148 ( *p,
false,
false );
154 if( !tSelected && !pSelected )
156 selectionState.SelectTrack
166 p = * -- tracks.FindLeader( t );
170 if( circularTrackNavigation )
172 auto range = tracks.Leaders();
173 p = * range.rbegin();
205 auto t = trackFocus.Get();
208 t = *tracks.Any().begin();
211 t->EnsureVisible(
true );
217 auto n = * ++ tracks.FindLeader( t );
221 if( circularTrackNavigation )
222 n = *tracks.Any().begin();
229 auto tSelected = t->GetSelected();
230 auto nSelected = n->GetSelected();
231 if( tSelected && nSelected )
233 selectionState.SelectTrack
234 ( *t,
false,
false );
237 n->EnsureVisible(
true );
240 if( tSelected && !nSelected )
242 selectionState.SelectTrack
246 n->EnsureVisible(
true );
249 if( !tSelected && nSelected )
251 selectionState.SelectTrack
252 ( *n,
false,
false );
255 n->EnsureVisible(
true );
258 if( !tSelected && !nSelected )
260 selectionState.SelectTrack
264 n->EnsureVisible(
true );
270 auto n = * ++ tracks.FindLeader( t );
274 if( circularTrackNavigation )
276 n = *tracks.Any().begin();
279 n->EnsureVisible(
true );
291 n->EnsureVisible(
true );
315 auto &project = context.
project;
317 auto isEnabled = window.IsEnabled();
319 wxWindow *w = wxGetTopLevelParent(wxWindow::FindFocus());
320 const auto & list = window.GetChildren();
321 auto iter = list.rbegin(),
end = list.rend();
331 while (iter !=
end && *iter != w)
338 for (; iter !=
end; ++iter)
343 if (w->IsTopLevel() && w->IsShown() && isEnabled)
350 if ((iter ==
end) && isEnabled)
361#if defined(__WXMAC__) || defined(__WXGTK__)
366 if (
dynamic_cast<wxDialog*
>(w)) {
374 auto &project = context.
project;
376 auto isEnabled = window.IsEnabled();
378 wxWindow *w = wxGetTopLevelParent(wxWindow::FindFocus());
379 const auto & list = window.GetChildren();
380 auto iter = list.begin(),
end = list.end();
393 while (iter !=
end && *iter != w)
400 for (; iter !=
end; ++iter)
406 if (w->IsTopLevel() && w->IsShown() && w->IsEnabled())
413 if ((iter ==
end) && isEnabled)
424#if defined(__WXMAC__) || defined(__WXGTK__)
429 if (
dynamic_cast<wxDialog*
>(w)) {
437 auto &project = context.
project;
443 auto &project = context.
project;
452 auto &project = context.
project;
458 auto &project = context.
project;
464 auto &project = context.
project;
468 auto t = trackFocus.Get();
472 auto f = *tracks.Any().begin();
476 f->EnsureVisible( t != f );
481 auto &project = context.
project;
489 auto l = *tracks.Any().rbegin();
493 l->EnsureVisible( t != l );
498 auto &project = context.
project;
504 auto &project = context.
project;
510 auto &project = context.
project;
516 t = trackFocus.
Get();
520 selectionState.SelectTrack
524 trackFocus.UpdateAccessibility();
532 gPrefs->ReadBool(wxT(
"/GUI/CircularTrackNavigation"),
false);
549 return std::make_unique< NavigationActions::Handler >(); } };
557#define FN(X) (& NavigationActions::Handler :: X)
568 Items( wxT(
"Navigation"),
569 Command( wxT(
"PrevWindow"),
XXO(
"Move Backward Through Active Windows"),
571 Options{ wxT(
"Alt+Shift+F6") }.IsGlobal() ),
572 Command( wxT(
"NextWindow"),
XXO(
"Move Forward Through Active Windows"),
574 Options{ wxT(
"Alt+F6") }.IsGlobal() )
580 wxT(
"Optional/Extra/Part2"),
590 Menu( wxT(
"Focus"),
XXO(
"Foc&us"),
592 XXO(
"Move &Backward from Toolbars to Tracks"),
FN(OnPrevFrame),
595 XXO(
"Move F&orward from Toolbars to Tracks"),
FN(OnNextFrame),
597 Command( wxT(
"PrevTrack"),
XXO(
"Move Focus to &Previous Track"),
598 FN(OnCursorUp), FocusedTracksFlags, wxT(
"Up") ),
599 Command( wxT(
"NextTrack"),
XXO(
"Move Focus to &Next Track"),
600 FN(OnCursorDown), FocusedTracksFlags, wxT(
"Down") ),
601 Command( wxT(
"FirstTrack"),
XXO(
"Move Focus to &First Track"),
602 FN(OnFirstTrack), FocusedTracksFlags, wxT(
"Ctrl+Home") ),
603 Command( wxT(
"LastTrack"),
XXO(
"Move Focus to &Last Track"),
604 FN(OnLastTrack), FocusedTracksFlags, wxT(
"Ctrl+End") ),
605 Command( wxT(
"ShiftUp"),
XXO(
"Move Focus to P&revious and Select"),
606 FN(OnShiftUp), FocusedTracksFlags, wxT(
"Shift+Up") ),
607 Command( wxT(
"ShiftDown"),
XXO(
"Move Focus to N&ext and Select"),
608 FN(OnShiftDown), FocusedTracksFlags, wxT(
"Shift+Down") ),
609 Command( wxT(
"Toggle"),
XXO(
"&Toggle Focused Track"),
FN(OnToggle),
610 FocusedTracksFlags, wxT(
"Return") ),
611 Command( wxT(
"ToggleAlt"),
XXO(
"Toggle Focuse&d Track"),
FN(OnToggle),
612 FocusedTracksFlags, wxT(
"NUMPAD_ENTER") )
618 wxT(
"Optional/Extra/Part2"),
constexpr CommandFlag AlwaysEnabledFlag
wxEvtHandler CommandHandlerObject
const ReservedCommandFlag & TracksExistFlag()
const ReservedCommandFlag & TrackPanelHasFocus()
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)
wxPanel * GetTopPanel() noexcept
Top panel contains project-related controls and tools.
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)
Namespace for functions for project navigation menu (part of Extra menu)
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for, if Traits<Type>::iterated_type is defined.
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for, if Traits<Type>::iterated_type is defined.
std::shared_ptr< BaseItem > BaseItemSharedPtr
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)