3#include "../CommonCommandFlags.h"
7#include "../ProjectWindow.h"
8#include "../ProjectWindows.h"
9#include "../RealtimeEffectPanel.h"
12#include "../TrackPanel.h"
15#include "../toolbars/ToolManager.h"
16#include "../widgets/AButton.h"
17#include "../widgets/ASlider.h"
18#include "../widgets/MeterPanel.h"
33 std::vector<wxWindow*> seq;
42 auto FindAncestor = [&]() {
46 auto it = std::find(seq.cbegin(), seq.cend(), pWindow);
48 return static_cast<size_t>(std::distance(seq.cbegin(), it));
49 pWindow = pWindow->GetParent();
54 const auto idx = FindAncestor();
55 if (idx == seq.size())
59 const auto increment = (
forward ? 1 :
static_cast<int>(seq.size()) - 1);
61 while( idx != (idx2 = (idx2 + increment) % seq.size()) ) {
62 wxWindow *toFocus = seq[idx2];
63 if(!toFocus->IsShown())
67 if ( FindAncestor() == idx2 )
83 const auto t = trackFocus.Get();
86 const auto last = *
tracks.rbegin();
89 viewport.ShowTrack(*last);
90 projectHistory.ModifyState(
false);
94 assert(t->IsLeader());
97 auto p = * --
tracks.Find(t);
103 if (circularTrackNavigation)
106 viewport.ShowTrack(*t);
112 assert(p && p->IsLeader());
113 auto tSelected = t->GetSelected();
114 auto pSelected = p->GetSelected();
115 if (tSelected && pSelected) {
116 selectionState.SelectTrack(*t,
false,
false);
119 viewport.ShowTrack(*p);
120 projectHistory.ModifyState(
false);
124 if (tSelected && !pSelected) {
125 selectionState.SelectTrack(*p,
true,
false);
128 viewport.ShowTrack(*p);
129 projectHistory.ModifyState(
false);
133 if (!tSelected && pSelected) {
134 selectionState.SelectTrack(*p,
false,
false);
137 viewport.ShowTrack(*p);
138 projectHistory.ModifyState(
false);
142 if (!tSelected && !pSelected) {
143 selectionState.SelectTrack(*t,
true,
false);
146 viewport.ShowTrack(*p);
147 projectHistory.ModifyState(
false);
153 auto p = * --
tracks.Find(t);
157 if (circularTrackNavigation) {
158 auto range =
tracks.Any();
159 p = * range.rbegin();
162 viewport.ShowTrack(*p);
163 projectHistory.ModifyState(
false);
168 viewport.ShowTrack(*t);
174 viewport.ShowTrack(*p);
175 projectHistory.ModifyState(
false);
193 const auto t = trackFocus.Get();
196 const auto first = *
tracks.begin();
197 trackFocus.Set(first);
199 viewport.ShowTrack(*first);
200 projectHistory.ModifyState(
false);
204 assert(t->IsLeader());
207 auto n = * ++
tracks.Find(t);
211 if (circularTrackNavigation)
214 viewport.ShowTrack(*t);
220 assert(n && n->IsLeader());
221 auto tSelected = t->GetSelected();
222 auto nSelected = n->GetSelected();
223 if (tSelected && nSelected) {
224 selectionState.SelectTrack(*t,
false,
false);
227 viewport.ShowTrack(*n);
228 projectHistory.ModifyState(
false);
232 if (tSelected && !nSelected) {
233 selectionState.SelectTrack(*n,
true,
false);
236 viewport.ShowTrack(*n);
237 projectHistory.ModifyState(
false);
241 if (!tSelected && nSelected) {
242 selectionState.SelectTrack(*n,
false,
false);
245 viewport.ShowTrack(*n);
246 projectHistory.ModifyState(
false);
250 if (!tSelected && !nSelected) {
251 selectionState.SelectTrack(*t,
true,
false);
254 viewport.ShowTrack(*n);
255 projectHistory.ModifyState(
false);
261 auto n = * ++
tracks.Find(t);
265 if (circularTrackNavigation) {
269 viewport.ShowTrack(*n);
270 projectHistory.ModifyState(
false);
275 viewport.ShowTrack(*t);
281 viewport.ShowTrack(*n);
282 projectHistory.ModifyState(
false);
308 auto isEnabled = window.IsEnabled();
311 const auto & list = window.GetChildren();
312 auto iter = list.rbegin(),
end = list.rend();
322 while (iter !=
end && *iter != w)
329 for (; iter !=
end; ++iter)
334 if (w->IsTopLevel() && w->IsShown() && isEnabled)
341 if ((iter ==
end) && isEnabled)
352#if defined(__WXMAC__) || defined(__WXGTK__)
357 if (
dynamic_cast<wxDialog*
>(w)) {
367 auto isEnabled = window.IsEnabled();
370 const auto & list = window.GetChildren();
371 auto iter = list.begin(),
end = list.end();
384 while (iter !=
end && *iter != w)
391 for (; iter !=
end; ++iter)
397 if (w->IsTopLevel() && w->IsShown() && w->IsEnabled())
404 if ((iter ==
end) && isEnabled)
415#if defined(__WXMAC__) || defined(__WXGTK__)
420 if (
dynamic_cast<wxDialog*
>(w)) {
461 auto t = trackFocus.Get();
469 viewport.ShowTrack(*f);
471 projectHistory.ModifyState(
false);
488 auto l = *
tracks.rbegin();
492 viewport.ShowTrack(*l);
494 projectHistory.ModifyState(
false);
520 t = trackFocus.
Get();
524 selectionState.SelectTrack(*t, !t->
GetSelected(),
true);
525 viewport.ShowTrack(*t);
526 projectHistory.ModifyState(
false);
528 trackFocus.UpdateAccessibility();
553 return std::make_unique< NavigationActions::Handler >(); } };
561#define FN(X) (& NavigationActions::Handler :: X)
568 static auto items = std::shared_ptr{
571 Command(
wxT(
"PrevWindow"),
XXO(
"Move Backward Through Active Windows"),
574 Command(
wxT(
"NextWindow"),
XXO(
"Move Forward Through Active Windows"),
582 wxT(
"Optional/Extra/Part2")
587 static const auto FocusedTracksFlags =
589 static auto menu = std::shared_ptr{
593 XXO(
"Move &Backward from Toolbars to Tracks"),
FN(OnPrevFrame),
596 XXO(
"Move F&orward from Toolbars to Tracks"),
FN(OnNextFrame),
598 Command(
wxT(
"PrevTrack"),
XXO(
"Move Focus to &Previous Track"),
599 FN(OnCursorUp), FocusedTracksFlags,
wxT(
"Up") ),
601 FN(OnCursorDown), FocusedTracksFlags,
wxT(
"Down") ),
602 Command(
wxT(
"FirstTrack"),
XXO(
"Move Focus to &First Track"),
603 FN(OnFirstTrack), FocusedTracksFlags,
wxT(
"Ctrl+Home") ),
605 FN(OnLastTrack), FocusedTracksFlags,
wxT(
"Ctrl+End") ),
606 Command(
wxT(
"ShiftUp"),
XXO(
"Move Focus to P&revious and Select"),
607 FN(OnShiftUp), FocusedTracksFlags,
wxT(
"Shift+Up") ),
608 Command(
wxT(
"ShiftDown"),
XXO(
"Move Focus to N&ext and Select"),
609 FN(OnShiftDown), FocusedTracksFlags,
wxT(
"Shift+Down") ),
611 FocusedTracksFlags,
wxT(
"Return") ),
613 FocusedTracksFlags,
wxT(
"NUMPAD_ENTER") )
619 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::BasicSettings * gPrefs
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)
Generates classes whose instances register items at construction.
static SelectionState & Get(AudacityProject &project)
Abstract base class for an object holding data associated with points on a time axis.
bool GetSelected() const
Selectedness is always the same for all channels of a group.
bool IsLeader() const override
static TrackList & Get(AudacityProject &project)
static TrackPanel & Get(AudacityProject &project)
static Viewport & Get(AudacityProject &project)
bool ReadBool(const wxString &key, bool defaultValue) const
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::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
A convenient default parameter for class template Site.
void OnNextWindow(const CommandContext &context)
void OnNextFrame(const CommandContext &context)
Handler(const Handler &)=delete
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 & operator=(const Handler &)=delete
void OnLastTrack(const CommandContext &context)
void OnCursorDown(const CommandContext &context)
bool mCircularTrackNavigation
void OnFirstTrack(const CommandContext &context)
void OnShiftUp(const CommandContext &context)