1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Ruler is in the ctrl+f6 cycle instead of reachable by arrows; experimental...

... flag for turning off navigability of the ruler.
This commit is contained in:
Paul Licameli 2016-05-10 13:52:05 -04:00
parent 7d7865c1a6
commit 80e19f2130
6 changed files with 134 additions and 99 deletions

View File

@ -96,8 +96,6 @@ enum CommandFlag : unsigned long long
= 0x80000000ULL, // prl
RulerHasFocus
= 0x100000000ULL, // prl
TrackPanelOrRulerHasFocus
= 0x200000000ULL, // prl
NoFlagsSpecifed = ~0ULL
};

View File

@ -200,5 +200,9 @@
// interpolating in frequency domain.
#define EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
// Paul Licameli (PRL) 10 May 2016
// Time ruler accepts focus, buttons can be reached with TAB
#define EXPERIMENTAL_TIME_RULER_NAVIGATION
#endif

View File

@ -1139,8 +1139,8 @@ void AudacityProject::CreateMenusAndCommands()
c->AddCommand(wxT("SeekLeftLong"), _("Long seek left during playback"), FN(OnSeekLeftLong), wxT("Shift+Left\tallowDup"));
c->AddCommand(wxT("SeekRightLong"), _("Long Seek right during playback"), FN(OnSeekRightLong), wxT("Shift+Right\tallowDup"));
c->SetDefaultFlags(TrackPanelOrRulerHasFocus,
TrackPanelOrRulerHasFocus);
c->SetDefaultFlags(TracksExistFlag | TrackPanelHasFocus,
TracksExistFlag | TrackPanelHasFocus);
c->AddCommand(wxT("PrevTrack"), _("Move Focus to Previous Track"), FN(OnCursorUp), wxT("Up"));
c->AddCommand(wxT("NextTrack"), _("Move Focus to Next Track"), FN(OnCursorDown), wxT("Down"));
@ -1152,9 +1152,6 @@ void AudacityProject::CreateMenusAndCommands()
c->AddCommand(wxT("ShiftDown"), _("Move Focus to Next and Select"), FN(OnShiftDown), wxT("Shift+Down"));
c->SetDefaultFlags(TracksExistFlag | TrackPanelHasFocus,
TracksExistFlag | TrackPanelHasFocus);
c->AddCommand(wxT("Toggle"), _("Toggle Focused Track"), FN(OnToggle), wxT("Return"));
c->AddCommand(wxT("ToggleAlt"), _("Toggle Focused Track"), FN(OnToggle), wxT("NUMPAD_ENTER"));
@ -1745,8 +1742,6 @@ CommandFlag AudacityProject::GetUpdateFlags()
flags |= TextClipFlag;
flags |= GetFocusedFrame();
if (flags & (TrackPanelHasFocus | RulerHasFocus))
flags |= TrackPanelOrRulerHasFocus;
double start, end;
GetPlayRegion(&start, &end);
@ -2745,13 +2740,17 @@ void AudacityProject::NextFrame()
switch( GetFocusedFrame() )
{
case TopDockHasFocus:
if(mTrackPanel->GetFocusedTrack())
mTrackPanel->SetFocus();
else
mRuler->SetFocus();
#ifdef EXPERIMENTAL_TIME_RULER_NAVIGATION
mRuler->SetFocus();
break;
case RulerHasFocus:
#endif
mTrackPanel->SetFocus();
break;
case TrackPanelHasFocus:
mToolManager->GetBotDock()->SetFocus();
break;
@ -2769,20 +2768,24 @@ void AudacityProject::PrevFrame()
{
switch( GetFocusedFrame() )
{
case TopDockHasFocus:
mToolManager->GetBotDock()->SetFocus();
case BotDockHasFocus:
mTrackPanel->SetFocus();
break;
case TrackPanelHasFocus:
#ifdef EXPERIMENTAL_TIME_RULER_NAVIGATION
mRuler->SetFocus();
break;
case TrackPanelHasFocus:
case RulerHasFocus:
#endif
mToolManager->GetTopDock()->SetFocus();
break;
case BotDockHasFocus:
if(mTrackPanel->GetFocusedTrack())
mTrackPanel->SetFocus();
else
mRuler->SetFocus();
case TopDockHasFocus:
mToolManager->GetBotDock()->SetFocus();
break;
default:

View File

@ -7113,49 +7113,46 @@ void TrackPanel::UpdateVRulerSize()
/// TrackPanel::OnNextTrack.
void TrackPanel::OnPrevTrack( bool shift )
{
bool rulerFocus = mRuler->HasFocus();
bool stealFocus = (mCircularTrackNavigation && rulerFocus);
if(stealFocus) // if there isn't one, focus on last
TrackListIterator iter( mTracks );
Track* t = GetFocusedTrack();
if( t == NULL ) // if there isn't one, focus on last
{
if(rulerFocus) {
this->SetFocus();
mRuler->Refresh();
}
TrackListIterator iter( mTracks );
auto t = iter.Last();
t = iter.Last();
SetFocusedTrack( t );
EnsureVisible( t );
MakeParentModifyState(false);
return;
}
else if (rulerFocus) {
// JKC: wxBell() is probably for accessibility, so a blind
// user knows they were at the top track.
wxBell();
return;
}
Track* t = GetFocusedTrack();
Track* p = mTracks->GetPrev( t, true ); // Get previous track
if (!p) {
SetFocusedTrack(nullptr);
mRuler->SetFocus();
Refresh(false);
mRuler->Refresh();
return;
}
Track* p = NULL;
bool tSelected = false;
bool pSelected = false;
if( shift )
{
p = mTracks->GetPrev( t, true ); // Get previous track
if( p == NULL ) // On first track
{
// JKC: wxBell() is probably for accessibility, so a blind
// user knows they were at the top track.
wxBell();
if( mCircularTrackNavigation )
{
TrackListIterator iter( mTracks );
p = iter.Last();
}
else
{
EnsureVisible( t );
return;
}
}
tSelected = t->GetSelected();
if (p)
pSelected = p->GetSelected();
if( tSelected && pSelected )
{
mTracks->Select( t, false );
SetFocusedTrack( p ); // move focus to next track up
SetFocusedTrack( p ); // move focus to next track down
EnsureVisible( p );
MakeParentModifyState(false);
return;
@ -7163,7 +7160,7 @@ void TrackPanel::OnPrevTrack( bool shift )
if( tSelected && !pSelected )
{
mTracks->Select( p, true );
SetFocusedTrack( p ); // move focus to next track up
SetFocusedTrack( p ); // move focus to next track down
EnsureVisible( p );
MakeParentModifyState(false);
return;
@ -7171,7 +7168,7 @@ void TrackPanel::OnPrevTrack( bool shift )
if( !tSelected && pSelected )
{
mTracks->Select( p, false );
SetFocusedTrack( p ); // move focus to next track up
SetFocusedTrack( p ); // move focus to next track down
EnsureVisible( p );
MakeParentModifyState(false);
return;
@ -7179,7 +7176,7 @@ void TrackPanel::OnPrevTrack( bool shift )
if( !tSelected && !pSelected )
{
mTracks->Select( t, true );
SetFocusedTrack( p ); // move focus to next track up
SetFocusedTrack( p ); // move focus to next track down
EnsureVisible( p );
MakeParentModifyState(false);
return;
@ -7187,10 +7184,35 @@ void TrackPanel::OnPrevTrack( bool shift )
}
else
{
SetFocusedTrack( p ); // move focus to next track up
EnsureVisible( p );
MakeParentModifyState(false);
return;
p = mTracks->GetPrev( t, true ); // Get next track
if( p == NULL ) // On last track so stay there?
{
wxBell();
if( mCircularTrackNavigation )
{
TrackListIterator iter( mTracks );
for( Track *d = iter.First(); d; d = iter.Next( true ) )
{
p = d;
}
SetFocusedTrack( p ); // Wrap to the first track
EnsureVisible( p );
MakeParentModifyState(false);
return;
}
else
{
EnsureVisible( t );
return;
}
}
else
{
SetFocusedTrack( p ); // move focus to next track down
EnsureVisible( p );
MakeParentModifyState(false);
return;
}
}
}
@ -7199,46 +7221,37 @@ void TrackPanel::OnPrevTrack( bool shift )
/// block or not.
void TrackPanel::OnNextTrack( bool shift )
{
if(mRuler->HasFocus()) {
TrackListIterator iter(mTracks);
auto first = iter.First();
if(first != nullptr) {
// Steal focus
this->SetFocus();
SetFocusedTrack(first);
EnsureVisible(first);
MakeParentModifyState(false);
mRuler->Refresh();
}
return;
}
Track *t;
Track *n = nullptr;
bool tSelected, nSelected;
Track *n;
TrackListIterator iter( mTracks );
bool tSelected,nSelected;
t = GetFocusedTrack(); // Get currently focused track
bool surrenderFocus =
t == nullptr ||
((n = mTracks->GetNext( t, true )) == nullptr &&
mCircularTrackNavigation);
if( surrenderFocus ) // if there is no next, give focus to the ruler
if( t == NULL ) // if there isn't one, focus on first
{
SetFocusedTrack(nullptr);
mRuler->SetFocus();
mRuler->Refresh();
Refresh(false);
t = iter.First();
SetFocusedTrack( t );
EnsureVisible( t );
MakeParentModifyState(false);
return;
}
if( shift )
{
n = mTracks->GetNext( t, true ); // Get next track
if( n == NULL ) // On last track so stay there
{
wxBell();
EnsureVisible( t );
return;
if( mCircularTrackNavigation )
{
TrackListIterator iter( mTracks );
n = iter.First();
}
else
{
EnsureVisible( t );
return;
}
}
tSelected = t->GetSelected();
nSelected = n->GetSelected();
@ -7277,11 +7290,24 @@ void TrackPanel::OnNextTrack( bool shift )
}
else
{
n = mTracks->GetNext( t, true ); // Get next track
if( n == NULL ) // On last track so stay there
{
wxBell();
EnsureVisible( t );
return;
if( mCircularTrackNavigation )
{
TrackListIterator iter( mTracks );
n = iter.First();
SetFocusedTrack( n ); // Wrap to the first track
EnsureVisible( n );
MakeParentModifyState(false);
return;
}
else
{
EnsureVisible( t );
return;
}
}
else
{
@ -7295,25 +7321,26 @@ void TrackPanel::OnNextTrack( bool shift )
void TrackPanel::OnFirstTrack()
{
SetFocusedTrack(nullptr);
if (!mRuler->HasFocus()) {
mRuler->SetFocus();
mRuler->Refresh();
Track *t = GetFocusedTrack();
if (!t)
return;
TrackListIterator iter(mTracks);
Track *f = iter.First();
if (t != f)
{
SetFocusedTrack(f);
MakeParentModifyState(false);
}
EnsureVisible(f);
}
void TrackPanel::OnLastTrack()
{
if (mTracks->empty()) {
OnFirstTrack();
return;
}
else if(mRuler->HasFocus()) {
this->SetFocus();
mRuler->Refresh();
}
Track *t = GetFocusedTrack();
if (!t)
return;
TrackListIterator iter(mTracks);
Track *l = iter.Last();
if (t != l)

View File

@ -2923,7 +2923,6 @@ void AdornedRulerPanel::OnKeyDown(wxKeyEvent &event)
void AdornedRulerPanel::OnSetFocus(wxFocusEvent & WXUNUSED(event))
{
AudacityProject::CaptureKeyboard(this);
mProject->GetTrackPanel()->SetFocusedTrack(nullptr);
mTabState = TabState{};
Refresh( false );
}

View File

@ -293,6 +293,10 @@ public:
~AdornedRulerPanel();
#ifndef EXPERIMENTAL_TIME_RULER_NAVIGATION
bool AcceptsFocus() const override { return false; }
#endif
public:
static int GetRulerHeight();
static int GetRulerHeight(bool showScrubBar);