MCPcopy Create free account
hub / github.com/audacity/audacity / NextOrPrevFrame

Function NextOrPrevFrame

src/menus/NavigationMenus.cpp:23–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21namespace {
22
23void NextOrPrevFrame(AudacityProject &project, bool forward)
24{
25 // Focus won't take in a dock unless at least one descendant window
26 // accepts focus. Tell controls to take focus for the duration of this
27 // function, only. Outside of this, they won't steal the focus when
28 // clicked.
29 auto temp1 = AButton::TemporarilyAllowFocus();
30 auto temp2 = ASlider::TemporarilyAllowFocus();
31 auto temp3 = MeterPanel::TemporarilyAllowFocus();
32
33 std::vector<wxWindow*> seq;
34 // Skip docks that are empty (Bug 1564).
35 if(!ToolManager::Get(project).GetTopDock()->GetChildren().IsEmpty())
36 seq.push_back(ProjectWindow::Get( project ).GetTopPanel());
37 seq.push_back(&TrackPanel::Get( project ));
38 seq.push_back(&RealtimeEffectPanel::Get(project));
39 if(!ToolManager::Get( project ).GetBotDock()->GetChildren().IsEmpty())
40 seq.push_back(ToolManager::Get( project ).GetBotDock());
41
42 auto FindAncestor = [&]() {
43 wxWindow *pWindow = wxWindow::FindFocus();
44 while (pWindow)
45 {
46 auto it = std::find(seq.cbegin(), seq.cend(), pWindow);
47 if(it != seq.cend())
48 return static_cast<size_t>(std::distance(seq.cbegin(), it));
49 pWindow = pWindow->GetParent();
50 }
51 return seq.size();
52 };
53
54 const auto idx = FindAncestor();
55 if (idx == seq.size())
56 return;
57
58 auto idx2 = idx;
59 const auto increment = (forward ? 1 : static_cast<int>(seq.size()) - 1);
60
61 while( idx != (idx2 = (idx2 + increment) % seq.size()) ) {
62 wxWindow *toFocus = seq[idx2];
63 if(!toFocus->IsShown())
64 continue;
65
66 toFocus->SetFocus();
67 if ( FindAncestor() == idx2 )
68 // The focus took!
69 break;
70 }
71}
72
73/// \todo Merge related methods, OnPrevTrack and OnNextTrack.
74void DoPrevTrack(

Callers 2

OnPrevFrameMethod · 0.85
OnNextFrameMethod · 0.85

Calls 14

GetFunction · 0.85
FindFocusFunction · 0.85
GetChildrenMethod · 0.80
GetTopDockMethod · 0.80
GetTopPanelMethod · 0.80
GetBotDockMethod · 0.80
cbeginMethod · 0.80
cendMethod · 0.80
IsShownMethod · 0.80
IsEmptyMethod · 0.45
push_backMethod · 0.45
GetParentMethod · 0.45

Tested by

no test coverage detected