Audacity 3.2.0
Functions | Variables
anonymous_namespace{NavigationMenus.cpp} Namespace Reference

Functions

void NextOrPrevFrame (AudacityProject &project, bool forward)
 
void DoPrevTrack (AudacityProject &project, bool shift, bool circularTrackNavigation)
 
void DoNextTrack (AudacityProject &project, bool shift, bool circularTrackNavigation)
 
BaseItemSharedPtr ExtraGlobalCommands ()
 
BaseItemSharedPtr ExtraFocusMenu ()
 

Variables

AttachedItem sAttachment2
 
AttachedItem sAttachment3
 

Function Documentation

◆ DoNextTrack()

void anonymous_namespace{NavigationMenus.cpp}::DoNextTrack ( AudacityProject project,
bool  shift,
bool  circularTrackNavigation 
)

The following method moves to the next track, selecting and unselecting depending if you are on the start of a block or not.

Definition at line 185 of file NavigationMenus.cpp.

187{
188 auto &projectHistory = ProjectHistory::Get( project );
189 auto &trackFocus = TrackFocus::Get( project );
190 auto &tracks = TrackList::Get( project );
191 auto &selectionState = SelectionState::Get( project );
192
193 auto t = trackFocus.Get(); // Get currently focused track
194 if( t == NULL ) // if there isn't one, focus on first
195 {
196 t = *tracks.Any().begin();
197 trackFocus.Set( t );
198 if (t)
199 t->EnsureVisible( true );
200 return;
201 }
202
203 if( shift )
204 {
205 auto n = * ++ tracks.FindLeader( t ); // Get next track
206 if( n == NULL ) // On last track so stay there
207 {
208 wxBell();
209 if( circularTrackNavigation )
210 n = *tracks.Any().begin();
211 else
212 {
213 t->EnsureVisible();
214 return;
215 }
216 }
217 auto tSelected = t->GetSelected();
218 auto nSelected = n->GetSelected();
219 if( tSelected && nSelected )
220 {
221 selectionState.SelectTrack
222 ( *t, false, false );
223 trackFocus.Set( n ); // move focus to next track down
224 if (n)
225 n->EnsureVisible( true );
226 return;
227 }
228 if( tSelected && !nSelected )
229 {
230 selectionState.SelectTrack
231 ( *n, true, false );
232 trackFocus.Set( n ); // move focus to next track down
233 if (n)
234 n->EnsureVisible( true );
235 return;
236 }
237 if( !tSelected && nSelected )
238 {
239 selectionState.SelectTrack
240 ( *n, false, false );
241 trackFocus.Set( n ); // move focus to next track down
242 if (n)
243 n->EnsureVisible( true );
244 return;
245 }
246 if( !tSelected && !nSelected )
247 {
248 selectionState.SelectTrack
249 ( *t, true, false );
250 trackFocus.Set( n ); // move focus to next track down
251 if (n)
252 n->EnsureVisible( true );
253 return;
254 }
255 }
256 else
257 {
258 auto n = * ++ tracks.FindLeader( t ); // Get next track
259 if( n == NULL ) // On last track so stay there
260 {
261 wxBell();
262 if( circularTrackNavigation )
263 {
264 n = *tracks.Any().begin();
265 trackFocus.Set( n ); // Wrap to the first track
266 if (n)
267 n->EnsureVisible( true );
268 return;
269 }
270 else
271 {
272 t->EnsureVisible();
273 return;
274 }
275 }
276 else
277 {
278 trackFocus.Set( n ); // move focus to next track down
279 n->EnsureVisible( true );
280 return;
281 }
282 }
283}
static ProjectHistory & Get(AudacityProject &project)
static SelectionState & Get(AudacityProject &project)
Track * Get()
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:385

References TrackFocus::Get(), ProjectHistory::Get(), SelectionState::Get(), and TrackList::Get().

Referenced by NavigationActions::Handler::OnCursorDown(), and NavigationActions::Handler::OnShiftDown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoPrevTrack()

void anonymous_namespace{NavigationMenus.cpp}::DoPrevTrack ( AudacityProject project,
bool  shift,
bool  circularTrackNavigation 
)
Todo:
Merge related methods, OnPrevTrack and OnNextTrack.

Definition at line 75 of file NavigationMenus.cpp.

77{
78 auto &projectHistory = ProjectHistory::Get( project );
79 auto &trackFocus = TrackFocus::Get( project );
80 auto &tracks = TrackList::Get( project );
81 auto &selectionState = SelectionState::Get( project );
82
83 auto t = trackFocus.Get();
84 if( t == NULL ) // if there isn't one, focus on last
85 {
86 t = *tracks.Any().rbegin();
87 trackFocus.Set( t );
88 if (t)
89 t->EnsureVisible( true );
90 return;
91 }
92
93 Track* p = NULL;
94 bool tSelected = false;
95 bool pSelected = false;
96 if( shift )
97 {
98 p = * -- tracks.FindLeader( t ); // Get previous track
99 if( p == NULL ) // On first track
100 {
101 // JKC: wxBell() is probably for accessibility, so a blind
102 // user knows they were at the top track.
103 wxBell();
104 if( circularTrackNavigation )
105 p = *tracks.Any().rbegin();
106 else
107 {
108 t->EnsureVisible();
109 return;
110 }
111 }
112 tSelected = t->GetSelected();
113 if (p)
114 pSelected = p->GetSelected();
115 if( tSelected && pSelected )
116 {
117 selectionState.SelectTrack
118 ( *t, false, false );
119 trackFocus.Set( p ); // move focus to next track up
120 if (p)
121 p->EnsureVisible( true );
122 return;
123 }
124 if( tSelected && !pSelected )
125 {
126 selectionState.SelectTrack
127 ( *p, true, false );
128 trackFocus.Set( p ); // move focus to next track up
129 if (p)
130 p->EnsureVisible( true );
131 return;
132 }
133 if( !tSelected && pSelected )
134 {
135 selectionState.SelectTrack
136 ( *p, false, false );
137 trackFocus.Set( p ); // move focus to next track up
138 if (p)
139 p->EnsureVisible( true );
140 return;
141 }
142 if( !tSelected && !pSelected )
143 {
144 selectionState.SelectTrack
145 ( *t, true, false );
146 trackFocus.Set( p ); // move focus to next track up
147 if (p)
148 p->EnsureVisible( true );
149 return;
150 }
151 }
152 else
153 {
154 p = * -- tracks.FindLeader( t ); // Get previous track
155 if( p == NULL ) // On first track so stay there?
156 {
157 wxBell();
158 if( circularTrackNavigation )
159 {
160 auto range = tracks.Leaders();
161 p = * range.rbegin(); // null if range is empty
162 trackFocus.Set( p ); // Wrap to the last track
163 if (p)
164 p->EnsureVisible( true );
165 return;
166 }
167 else
168 {
169 t->EnsureVisible();
170 return;
171 }
172 }
173 else
174 {
175 trackFocus.Set( p ); // move focus to next track up
176 p->EnsureVisible( true );
177 return;
178 }
179 }
180}
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:162
bool GetSelected() const
Selectedness is always the same for all channels of a group.
Definition: Track.cpp:82
void EnsureVisible(bool modifyState=false)
Definition: Track.cpp:98
bool Any() const
Definition: Track.cpp:299

References Track::Any(), Track::EnsureVisible(), TrackFocus::Get(), ProjectHistory::Get(), SelectionState::Get(), TrackList::Get(), and Track::GetSelected().

Referenced by NavigationActions::Handler::OnCursorUp(), and NavigationActions::Handler::OnShiftUp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtraFocusMenu()

BaseItemSharedPtr anonymous_namespace{NavigationMenus.cpp}::ExtraFocusMenu ( )

Definition at line 572 of file NavigationMenus.cpp.

573{
574 static const auto FocusedTracksFlags = TracksExistFlag() | TrackPanelHasFocus();
575
576 static BaseItemSharedPtr menu{
578 Menu( wxT("Focus"), XXO("Foc&us"),
579 Command( wxT("PrevFrame"),
580 XXO("Move &Backward from Toolbars to Tracks"), FN(OnPrevFrame),
581 AlwaysEnabledFlag, wxT("Ctrl+Shift+F6") ),
582 Command( wxT("NextFrame"),
583 XXO("Move F&orward from Toolbars to Tracks"), FN(OnNextFrame),
584 AlwaysEnabledFlag, wxT("Ctrl+F6") ),
585 Command( wxT("PrevTrack"), XXO("Move Focus to &Previous Track"),
586 FN(OnCursorUp), FocusedTracksFlags, wxT("Up") ),
587 Command( wxT("NextTrack"), XXO("Move Focus to &Next Track"),
588 FN(OnCursorDown), FocusedTracksFlags, wxT("Down") ),
589 Command( wxT("FirstTrack"), XXO("Move Focus to &First Track"),
590 FN(OnFirstTrack), FocusedTracksFlags, wxT("Ctrl+Home") ),
591 Command( wxT("LastTrack"), XXO("Move Focus to &Last Track"),
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") ),
597 Command( wxT("Toggle"), XXO("&Toggle Focused Track"), FN(OnToggle),
598 FocusedTracksFlags, wxT("Return") ),
599 Command( wxT("ToggleAlt"), XXO("Toggle Focuse&d Track"), FN(OnToggle),
600 FocusedTracksFlags, wxT("NUMPAD_ENTER") )
601 ) ) };
602 return menu;
603}
wxT("CloseDown"))
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:34
const ReservedCommandFlag & TracksExistFlag()
const ReservedCommandFlag & TrackPanelHasFocus()
XXO("&Cut/Copy/Paste Toolbar")
#define FN(X)
static CommandHandlerObject & findCommandHandler(AudacityProject &project)
constexpr auto Menu
constexpr auto Command
std::shared_ptr< BaseItem > BaseItemSharedPtr
Definition: Registry.h:74

References AlwaysEnabledFlag, MenuTable::Command, findCommandHandler(), FN, MenuTable::Menu, TrackPanelHasFocus(), TracksExistFlag(), wxT(), and XXO().

Here is the call graph for this function:

◆ ExtraGlobalCommands()

BaseItemSharedPtr anonymous_namespace{NavigationMenus.cpp}::ExtraGlobalCommands ( )

Definition at line 549 of file NavigationMenus.cpp.

550{
551 // Ceci n'est pas un menu
553
554 static BaseItemSharedPtr items{
556 Items( wxT("Navigation"),
557 Command( wxT("PrevWindow"), XXO("Move Backward Through Active Windows"),
558 FN(OnPrevWindow), AlwaysEnabledFlag,
559 Options{ wxT("Alt+Shift+F6") }.IsGlobal() ),
560 Command( wxT("NextWindow"), XXO("Move Forward Through Active Windows"),
561 FN(OnNextWindow), AlwaysEnabledFlag,
562 Options{ wxT("Alt+F6") }.IsGlobal() )
563 ) ) };
564 return items;
565}
constexpr auto Items

References AlwaysEnabledFlag, MenuTable::Command, findCommandHandler(), FN, MenuTable::Items, wxT(), and XXO().

Here is the call graph for this function:

◆ NextOrPrevFrame()

void anonymous_namespace{NavigationMenus.cpp}::NextOrPrevFrame ( AudacityProject project,
bool  forward 
)

Definition at line 24 of file NavigationMenus.cpp.

25{
26 // Focus won't take in a dock unless at least one descendant window
27 // accepts focus. Tell controls to take focus for the duration of this
28 // function, only. Outside of this, they won't steal the focus when
29 // clicked.
30 auto temp1 = AButton::TemporarilyAllowFocus();
31 auto temp2 = ASlider::TemporarilyAllowFocus();
33
34 std::vector<wxWindow*> seq;
35 // Skip docks that are empty (Bug 1564).
36 if(!ToolManager::Get(project).GetTopDock()->GetChildren().IsEmpty())
37 seq.push_back(ProjectWindow::Get( project ).GetTopPanel());
38 seq.push_back(&TrackPanel::Get( project ));
39 seq.push_back(&RealtimeEffectPanel::Get(project));
40 if(!ToolManager::Get( project ).GetBotDock()->GetChildren().IsEmpty())
41 seq.push_back(ToolManager::Get( project ).GetBotDock());
42
43 auto FindAncestor = [&]() {
44 wxWindow *pWindow = wxWindow::FindFocus();
45 while (pWindow)
46 {
47 auto it = std::find(seq.cbegin(), seq.cend(), pWindow);
48 if(it != seq.cend())
49 return static_cast<size_t>(std::distance(seq.cbegin(), it));
50 pWindow = pWindow->GetParent();
51 }
52 return seq.size();
53 };
54
55 const auto idx = FindAncestor();
56 if (idx == seq.size())
57 return;
58
59 auto idx2 = idx;
60 const auto increment = (forward ? 1 : static_cast<int>(seq.size()) - 1);
61
62 while( idx != (idx2 = (idx2 + increment) % seq.size()) ) {
63 wxWindow *toFocus = seq[idx2];
64 if(!toFocus->IsShown())
65 continue;
66
67 toFocus->SetFocus();
68 if ( FindAncestor() == idx2 )
69 // The focus took!
70 break;
71 }
72}
static TempAllowFocus TemporarilyAllowFocus()
Definition: AButton.cpp:658
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1894
static TempAllowFocus TemporarilyAllowFocus()
static ProjectWindow & Get(AudacityProject &project)
static RealtimeEffectPanel & Get(AudacityProject &project)
static ToolManager & Get(AudacityProject &project)
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:231
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:343

References BasicUI::FindFocus(), ProjectWindow::Get(), RealtimeEffectPanel::Get(), ToolManager::Get(), TrackPanel::Get(), AButton::TemporarilyAllowFocus(), ASlider::TemporarilyAllowFocus(), and MeterPanelBase::TemporarilyAllowFocus().

Referenced by NavigationActions::Handler::OnNextFrame(), and NavigationActions::Handler::OnPrevFrame().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ sAttachment2

AttachedItem anonymous_namespace{NavigationMenus.cpp}::sAttachment2
Initial value:
{
wxT("Optional/Extra/Part2"),
}
std::unique_ptr< IndirectItem > Indirect(const BaseItemSharedPtr &ptr)
A convenience function.
Definition: Registry.h:97

Definition at line 567 of file NavigationMenus.cpp.

◆ sAttachment3

AttachedItem anonymous_namespace{NavigationMenus.cpp}::sAttachment3
Initial value:
{
wxT("Optional/Extra/Part2"),
}

Definition at line 605 of file NavigationMenus.cpp.