Bug1252 more: Omit empty tool docks from ctrl+f6 rotation
This commit is contained in:
parent
48414d6e61
commit
5a121bbbd8
|
@ -2749,66 +2749,72 @@ void AudacityProject::OnSetRightSelection()
|
|||
}
|
||||
}
|
||||
|
||||
void AudacityProject::NextFrame()
|
||||
void AudacityProject::NextOrPrevFrame(bool forward)
|
||||
{
|
||||
// Focus won't take in a dock unless at least one descendant window
|
||||
// accepts focus. Tell all AButtons to take focus for the duration of this
|
||||
// function, only. Outside of this, they won't steal the focus when
|
||||
// clicked.
|
||||
auto temp = AButton::TemporarilyAllowFocus();
|
||||
|
||||
switch( GetFocusedFrame() )
|
||||
{
|
||||
case TopDockHasFocus:
|
||||
|
||||
// Define the set of windows we rotate among.
|
||||
static const unsigned rotationSize = 3u
|
||||
#ifdef EXPERIMENTAL_TIME_RULER_NAVIGATION
|
||||
mRuler->SetFocus();
|
||||
break;
|
||||
|
||||
case RulerHasFocus:
|
||||
+ 1
|
||||
#endif
|
||||
;
|
||||
|
||||
mTrackPanel->SetFocus();
|
||||
break;
|
||||
wxWindow *const begin [rotationSize] = {
|
||||
mToolManager->GetTopDock(),
|
||||
#ifdef EXPERIMENTAL_TIME_RULER_NAVIGATION
|
||||
GetRulerPanel(),
|
||||
#endif
|
||||
GetTrackPanel(),
|
||||
mToolManager->GetBotDock(),
|
||||
};
|
||||
const auto end = begin + rotationSize;
|
||||
|
||||
case TrackPanelHasFocus:
|
||||
mToolManager->GetBotDock()->SetFocus();
|
||||
break;
|
||||
// helper functions
|
||||
auto IndexOf = [&](wxWindow *pWindow) {
|
||||
return std::find(begin, end, pWindow) - begin;
|
||||
};
|
||||
|
||||
case BotDockHasFocus:
|
||||
mToolManager->GetTopDock()->SetFocus();
|
||||
break;
|
||||
auto FindAncestor = [&]() {
|
||||
wxWindow *pWindow = wxWindow::FindFocus();
|
||||
unsigned index = rotationSize;
|
||||
while ( pWindow &&
|
||||
(rotationSize == (index = IndexOf(pWindow) ) ) )
|
||||
pWindow = pWindow->GetParent();
|
||||
return index;
|
||||
};
|
||||
|
||||
default:
|
||||
break;
|
||||
const auto idx = FindAncestor();
|
||||
if (idx == rotationSize)
|
||||
return;
|
||||
|
||||
auto idx2 = idx;
|
||||
auto increment = (forward ? 1 : rotationSize - 1);
|
||||
|
||||
while( idx != (idx2 = (idx2 + increment) % rotationSize) ) {
|
||||
wxWindow *toFocus = begin[idx2];
|
||||
toFocus->SetFocus();
|
||||
if ( FindAncestor() == idx2 )
|
||||
// The focus took!
|
||||
break;
|
||||
// else, one of the tool docks might be empty because all bars were
|
||||
// dragged off it. Skip it and try another.
|
||||
}
|
||||
}
|
||||
|
||||
void AudacityProject::NextFrame()
|
||||
{
|
||||
NextOrPrevFrame(true);
|
||||
}
|
||||
|
||||
void AudacityProject::PrevFrame()
|
||||
{
|
||||
auto temp = AButton::TemporarilyAllowFocus();
|
||||
|
||||
switch( GetFocusedFrame() )
|
||||
{
|
||||
case BotDockHasFocus:
|
||||
mTrackPanel->SetFocus();
|
||||
break;
|
||||
|
||||
case TrackPanelHasFocus:
|
||||
|
||||
#ifdef EXPERIMENTAL_TIME_RULER_NAVIGATION
|
||||
mRuler->SetFocus();
|
||||
break;
|
||||
|
||||
case RulerHasFocus:
|
||||
#endif
|
||||
|
||||
mToolManager->GetTopDock()->SetFocus();
|
||||
break;
|
||||
|
||||
case TopDockHasFocus:
|
||||
mToolManager->GetBotDock()->SetFocus();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
NextOrPrevFrame(false);
|
||||
}
|
||||
|
||||
void AudacityProject::NextWindow()
|
||||
|
|
|
@ -413,6 +413,7 @@ void OnSeparator();
|
|||
|
||||
// Keyboard navigation
|
||||
|
||||
void NextOrPrevFrame(bool next);
|
||||
void PrevFrame();
|
||||
void NextFrame();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user