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);
96 auto p = * --
tracks.Find(t);
102 if (circularTrackNavigation)
105 viewport.ShowTrack(*t);
112 auto tSelected = t->GetSelected();
113 auto pSelected = p->GetSelected();
114 if (tSelected && pSelected) {
115 selectionState.SelectTrack(*t,
false,
false);
118 viewport.ShowTrack(*p);
119 projectHistory.ModifyState(
false);
123 if (tSelected && !pSelected) {
124 selectionState.SelectTrack(*p,
true,
false);
127 viewport.ShowTrack(*p);
128 projectHistory.ModifyState(
false);
132 if (!tSelected && pSelected) {
133 selectionState.SelectTrack(*p,
false,
false);
136 viewport.ShowTrack(*p);
137 projectHistory.ModifyState(
false);
141 if (!tSelected && !pSelected) {
142 selectionState.SelectTrack(*t,
true,
false);
145 viewport.ShowTrack(*p);
146 projectHistory.ModifyState(
false);
152 auto p = * --
tracks.Find(t);
156 if (circularTrackNavigation) {
157 auto range =
tracks.Any();
158 p = * range.rbegin();
161 viewport.ShowTrack(*p);
162 projectHistory.ModifyState(
false);
167 viewport.ShowTrack(*t);
173 viewport.ShowTrack(*p);
174 projectHistory.ModifyState(
false);
192 const auto t = trackFocus.Get();
195 const auto first = *
tracks.begin();
196 trackFocus.Set(first);
198 viewport.ShowTrack(*first);
199 projectHistory.ModifyState(
false);
205 auto n = * ++
tracks.Find(t);
209 if (circularTrackNavigation)
212 viewport.ShowTrack(*t);
219 auto tSelected = t->GetSelected();
220 auto nSelected = n->GetSelected();
221 if (tSelected && nSelected) {
222 selectionState.SelectTrack(*t,
false,
false);
225 viewport.ShowTrack(*n);
226 projectHistory.ModifyState(
false);
230 if (tSelected && !nSelected) {
231 selectionState.SelectTrack(*n,
true,
false);
234 viewport.ShowTrack(*n);
235 projectHistory.ModifyState(
false);
239 if (!tSelected && nSelected) {
240 selectionState.SelectTrack(*n,
false,
false);
243 viewport.ShowTrack(*n);
244 projectHistory.ModifyState(
false);
248 if (!tSelected && !nSelected) {
249 selectionState.SelectTrack(*t,
true,
false);
252 viewport.ShowTrack(*n);
253 projectHistory.ModifyState(
false);
259 auto n = * ++
tracks.Find(t);
263 if (circularTrackNavigation) {
267 viewport.ShowTrack(*n);
268 projectHistory.ModifyState(
false);
273 viewport.ShowTrack(*t);
279 viewport.ShowTrack(*n);
280 projectHistory.ModifyState(
false);
306 auto isEnabled = window.IsEnabled();
309 const auto & list = window.GetChildren();
310 auto iter = list.rbegin(),
end = list.rend();
320 while (iter !=
end && *iter != w)
327 for (; iter !=
end; ++iter)
332 if (w->IsTopLevel() && w->IsShown() && isEnabled)
339 if ((iter ==
end) && isEnabled)
350#if defined(__WXMAC__) || defined(__WXGTK__)
355 if (
dynamic_cast<wxDialog*
>(w)) {
365 auto isEnabled = window.IsEnabled();
368 const auto & list = window.GetChildren();
369 auto iter = list.begin(),
end = list.end();
382 while (iter !=
end && *iter != w)
389 for (; iter !=
end; ++iter)
395 if (w->IsTopLevel() && w->IsShown() && w->IsEnabled())
402 if ((iter ==
end) && isEnabled)
413#if defined(__WXMAC__) || defined(__WXGTK__)
418 if (
dynamic_cast<wxDialog*
>(w)) {
459 auto t = trackFocus.Get();
467 viewport.ShowTrack(*f);
469 projectHistory.ModifyState(
false);
485 auto l = *
tracks.rbegin();
489 viewport.ShowTrack(*l);
491 projectHistory.ModifyState(
false);
517 t = trackFocus.
Get();
520 selectionState.SelectTrack(*t, !t->
GetSelected(),
true);
521 viewport.ShowTrack(*t);
522 projectHistory.ModifyState(
false);
524 trackFocus.UpdateAccessibility();
549 return std::make_unique< NavigationActions::Handler >(); } };
557#define FN(X) (& NavigationActions::Handler :: X)
564 static auto items = std::shared_ptr{
567 Command(
wxT(
"PrevWindow"),
XXO(
"Move Backward Through Active Windows"),
570 Command(
wxT(
"NextWindow"),
XXO(
"Move Forward Through Active Windows"),
578 wxT(
"Optional/Extra/Part2")
583 static const auto FocusedTracksFlags =
585 static auto menu = std::shared_ptr{
589 XXO(
"Move &Backward from Toolbars to Tracks"),
FN(OnPrevFrame),
592 XXO(
"Move F&orward from Toolbars to Tracks"),
FN(OnNextFrame),
594 Command(
wxT(
"PrevTrack"),
XXO(
"Move Focus to &Previous Track"),
595 FN(OnCursorUp), FocusedTracksFlags,
wxT(
"Up") ),
597 FN(OnCursorDown), FocusedTracksFlags,
wxT(
"Down") ),
598 Command(
wxT(
"FirstTrack"),
XXO(
"Move Focus to &First Track"),
599 FN(OnFirstTrack), FocusedTracksFlags,
wxT(
"Ctrl+Home") ),
601 FN(OnLastTrack), FocusedTracksFlags,
wxT(
"Ctrl+End") ),
602 Command(
wxT(
"ShiftUp"),
XXO(
"Move Focus to P&revious and Select"),
603 FN(OnShiftUp), FocusedTracksFlags,
wxT(
"Shift+Up") ),
604 Command(
wxT(
"ShiftDown"),
XXO(
"Move Focus to N&ext and Select"),
605 FN(OnShiftDown), FocusedTracksFlags,
wxT(
"Shift+Down") ),
607 FocusedTracksFlags,
wxT(
"Return") ),
609 FocusedTracksFlags,
wxT(
"NUMPAD_ENTER") )
615 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.
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)
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
const char * end(const char *str) noexcept
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)