From 9bb41d696339c370c641529c8cd42147b1900f2d Mon Sep 17 00:00:00 2001 From: James Crook Date: Sun, 18 Feb 2018 11:05:29 +0000 Subject: [PATCH] Arrange and Align done. - Registration names of align commands sorted. They had &, : and / in them. - Fixed bug in SetTrackInfo where bFocused was being ignored - Fixed bug where command manager ignored multi-commands. --- scripts/piped-work/docimages_arrange.py | 82 ++++++++++++++++++------- scripts/piped-work/docimages_core.py | 1 + src/commands/CommandManager.cpp | 31 +++++++--- src/commands/SetTrackInfoCommand.cpp | 2 +- 4 files changed, 86 insertions(+), 30 deletions(-) diff --git a/scripts/piped-work/docimages_arrange.py b/scripts/piped-work/docimages_arrange.py index 31524df92..dc1f8f539 100644 --- a/scripts/piped-work/docimages_arrange.py +++ b/scripts/piped-work/docimages_arrange.py @@ -11,8 +11,7 @@ exec( open("docimages_core.py" ).read() ) import time - -def arrange_imagesA() : +def loadFourColours() : loadMonoTracks( 4 ) do( 'SetTrack: Track=0 Name="Claire" Height=60 Color=Color0') do( 'SetTrack: Track=1 Name="Ann" Height=60 Color=Color1') @@ -23,38 +22,79 @@ def arrange_imagesA() : do( 'SetClip: Track=2 At=1 Start=20') do( 'SetClip: Track=3 At=1 Start=10') do( 'Select: First=0 Last=100 Mode=Remove' ) - capture( 'TrackOrder001.png', 'All_Tracks' ) - do( 'SetTrack: Track=2 Focused=1') + +def loadFourColoursSelected() : + loadFourColours() + do( 'ZoomOut' ) + do( 'Select: Start=90 End=135 First=0 Last=100' ) + +def blockMoves( name ): + # These are the align commands that move tracks 'en block'. + loadFourColoursSelected() + capture( name + '001.png', 'All_Tracks_Plus' ) + do( 'Align_StarttoZero' ) + capture( name + '002.png', 'All_Tracks_Plus' ) + loadFourColoursSelected() + do( 'Align_StarttoCursorSelectionStart' ) + capture( name + '003.png', 'All_Tracks_Plus' ) + loadFourColoursSelected() + do( 'Align_StarttoSelectionEnd' ) + capture( name + '004.png', 'All_Tracks_Plus' ) + loadFourColoursSelected() + do( 'Align_EndtoCursorSelectionStart' ) + capture( name + '005.png', 'All_Tracks_Plus' ) + loadFourColoursSelected() + do( 'Align_EndtoSelectionEnd' ) + capture( name + '006.png', 'All_Tracks_Plus' ) + +def track_moves( type ) : + loadFourColours() + # Sorting tracks into order + do( 'SetTrack: Track=1 Focused=1') capture( 'TrackOrder002.png', 'All_Tracks' ) + +def arrange_imagesA() : + loadFourColours() + # Moving tracks up and down. + capture( 'TrackOrder001.png', 'All_Tracks' ) + do( 'SetTrack: Track=1 Focused=1') + # ToTop=0 to show the focus... + capture( 'TrackOrder002.png', 'All_Tracks ToTop=0' ) + do( 'TrackMoveUp' ) + capture( 'TrackUp.png', 'All_Tracks ToTop=0' ) + do( 'TrackMoveDown' ) # undo + do( 'TrackMoveDown' ) + capture( 'TrackDown.png', 'All_Tracks ToTop=0' ) + do( 'TrackMoveTop' ) + capture( 'TrackTop.png', 'All_Tracks ToTop=0' ) + do( 'TrackMoveBottom' ) + capture( 'TrackBottom.png', 'All_Tracks ToTop=0' ) + # Sorting tracks into order do( 'SortByName') capture( 'TrackOrder003.png', 'All_Tracks' ) do( 'SortByTime') capture( 'TrackOrder004.png', 'All_Tracks' ) + # Aligning tracks + do( 'Select: First=0 Last=100 From=0 To=0') + do( 'Align_AlignTogether' ) + capture( 'TrackAlign001.png', 'All_Tracks' ) + do( 'Align_AlignEndtoEnd' ) + do( 'FitInWindow' ) + capture( 'TrackAlign002.png', 'All_Tracks' ) + def arrange_imagesB() : - loadMonoTracks( 3 ) - do( 'SetClip: Track=0 At=1 Start=5') - time.sleep( 1 ) - do( 'SetClip: Track=1 At=1 Start=3') - time.sleep( 1 ) - do( 'SetClip: Track=2 At=1 Start=4') - time.sleep( 1 ) - do( 'SetClip: Track=3 At=1 Start=2') - capture( 'TrackOrder001.png', 'All_Tracks' ) + blockMoves( 'BlockMoves' ) + do( 'MoveSelectionWithTracks') + blockMoves( 'BlockAndCursorMoves' ) + do( 'MoveSelectionWithTracks') -def arrange_imagesC() : - do( 'SetTrack: Track=2 Focused=1') - capture( 'TrackOrder002.png', 'All_Tracks' ) - do( 'SortByName') - capture( 'TrackOrder003.png', 'All_Tracks' ) - do( 'SortByTime') - capture( 'TrackOrder004.png', 'All_Tracks' ) #quickTest() arrange_imagesA() #arrange_imagesB() -#arrange_imagesC() + diff --git a/scripts/piped-work/docimages_core.py b/scripts/piped-work/docimages_core.py index 2d387a4a8..c2f44723a 100644 --- a/scripts/piped-work/docimages_core.py +++ b/scripts/piped-work/docimages_core.py @@ -122,6 +122,7 @@ def loadStereoTracks( num ) : loadStereoTrack() do( 'SetTrack: Track=0 Name="Foxy Lady"') for i in range( 0, num-1 ): + do( 'Select: First=0 Last=0') do( 'Duplicate' ) do( 'FitInWindow' ) do( 'Select: Start=55 End=70 First=0 Last=' + str(num*2-1) ) diff --git a/src/commands/CommandManager.cpp b/src/commands/CommandManager.cpp index 9d1bb8797..6e833f97a 100644 --- a/src/commands/CommandManager.cpp +++ b/src/commands/CommandManager.cpp @@ -947,7 +947,7 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name, count, {}); } -CommandListEntry *CommandManager::NewIdentifier(const wxString & name, +CommandListEntry *CommandManager::NewIdentifier(const wxString & nameIn, const wxString & label, const wxString & accel, wxMenu *menu, @@ -958,6 +958,8 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name, int count, const CommandParameter ¶meter) { + wxString name = nameIn; + // If we have the identifier already, reuse it. CommandListEntry *prev = mCommandNameHash[name]; if (!prev); @@ -975,6 +977,18 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name, labelPrefix = mSubMenuList.back()->name; } + // For key bindings for commands with a list, such as align, + // the name in prefs is the category name plus the effect name. + // This feature is not used for built-in effects. + if (multi) { + // The name needs to be clean for use by automation. + wxString cleanedName = wxString::Format(wxT("%s_%s"), name, label); + cleanedName.Replace( "/", "" ); + cleanedName.Replace( "&", "" ); + cleanedName.Replace( " ", "" ); + name = cleanedName; + } + // wxMac 2.5 and higher will do special things with the // Preferences, Exit (Quit), and About menu items, // if we give them the right IDs. @@ -1024,13 +1038,6 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name, if( mMaxListOnly.Index( entry->key ) !=-1) entry->key = wxT(""); - - // For key bindings for commands with a list, such as effects, - // the name in prefs is the category name plus the effect name. - if (multi) { - entry->name = wxString::Format(wxT("%s:%s"), name, label); - } - // Key from preferences overridse the default key given gPrefs->SetPath(wxT("/NewKeys")); if (gPrefs->HasEntry(entry->name)) { @@ -1551,6 +1558,14 @@ bool CommandManager::HandleTextualCommand(const wxString & Str, const CommandCon return HandleCommandEntry( entry.get(), flags, mask); } } + else + { + // Handle multis too... + if( Str.IsSameAs( entry->name, false ) ) + { + return HandleCommandEntry( entry.get(), flags, mask); + } + } } // Not one of the singleton commands. // We could/should try all the list-style commands. diff --git a/src/commands/SetTrackInfoCommand.cpp b/src/commands/SetTrackInfoCommand.cpp index 63f2f1ea0..aad714a06 100644 --- a/src/commands/SetTrackInfoCommand.cpp +++ b/src/commands/SetTrackInfoCommand.cpp @@ -214,7 +214,7 @@ bool SetTrackCommand::Apply(const CommandContext & context) if( !bIsSecondChannel ){ if( bHasSelected ) t->SetSelected(bSelected); - if( bHasFocused ) + if( bHasFocused && bFocused) { TrackPanel *panel = context.GetProject()->GetTrackPanel(); panel->SetFocusedTrack( t );