From 24e8bbc62353f892d34adccc240113e869b03212 Mon Sep 17 00:00:00 2001 From: James Crook Date: Sat, 10 Feb 2018 19:50:30 +0000 Subject: [PATCH] Scripts in Piped-Work - New docimages script for the tracks. - Added new option in screenshots to capture ruler as well as track. - Typo fix (focussed) --- scripts/piped-work/docimages_tracks.py | 119 ++++++++++++++++++ ...-gui-structure.py => get_gui_structure.py} | 0 .../piped-work/{pipe-test.pl => pipe_test.pl} | 0 .../piped-work/{pipe-test.py => pipe_test.py} | 0 .../{recording-test.py => recording_test.py} | 0 src/commands/ScreenshotCommand.cpp | 27 +++- src/commands/SetTrackInfoCommand.cpp | 13 +- 7 files changed, 146 insertions(+), 13 deletions(-) create mode 100644 scripts/piped-work/docimages_tracks.py rename scripts/piped-work/{get-gui-structure.py => get_gui_structure.py} (100%) rename scripts/piped-work/{pipe-test.pl => pipe_test.pl} (100%) rename scripts/piped-work/{pipe-test.py => pipe_test.py} (100%) rename scripts/piped-work/{recording-test.py => recording_test.py} (100%) diff --git a/scripts/piped-work/docimages_tracks.py b/scripts/piped-work/docimages_tracks.py new file mode 100644 index 000000000..7cbe3ecc2 --- /dev/null +++ b/scripts/piped-work/docimages_tracks.py @@ -0,0 +1,119 @@ +# docimages_tracks.py +# Sends commands to get images for the manual. +# Images for https://alphamanual.audacityteam.org/man/Audio_Tracks + +# Make sure Audacity is running first and that mod-script-pipe is enabled +# before running this script. + +import os +import sys + + +if( sys.platform == 'win32' ): + print( "pipe-test.py, running on windows" ) + toname = '\\\\.\\pipe\\ToSrvPipe' + fromname = '\\\\.\\pipe\\FromSrvPipe' + EOL = '\r\n\0' +else: + print( "pipe-test.py, running on linux or mac" ) + toname = '/tmp/audacity_script_pipe.to.' + str(os.getuid()) + fromname = '/tmp/audacity_script_pipe.from.' + str(os.getuid()) + EOL = '\n' + +print( "Write to \"" + toname +"\"" ) +if not os.path.exists( toname ) : + print( " ..does not exist. Ensure Audacity is running with mod-script-pipe." ) + sys.exit(); + +print( "Read from \"" + fromname +"\"") +if not os.path.exists( fromname ) : + print( " ..does not exist. Ensure Audacity is running with mod-script-pipe." ) + sys.exit(); + +print( "-- Both pipes exist. Good." ) + +tofile = open( toname, 'wt+' ) +print( "-- File to write to has been opened" ) +fromfile = open( fromname, 'rt') +print( "-- File to read from has now been opened too\r\n" ) + + +def sendCommand( command ) : + print( "Send: >>> "+command ) + tofile.write( command + EOL ) + tofile.flush() + +def getResponse() : + result = '' + line = '' + while line != '\n' : + result += line + line = fromfile.readline() + #print(" I read line:["+line+"]") + return result + +def doCommand( command ) : + sendCommand( command ) + response = getResponse() + print( "Rcvd: <<< " + response ) + return response + +def do( command ) : + doCommand( command ) + +def quickTest() : + do( 'Help: Command=Help' ) + do( 'Help: Command="SetTrackInfo"' ) + do( 'SetPreference: Name=GUI/Theme Value=light Reload=false' ) + + +def setup() : + global path + path = '\"C:/Users/James Crook/\"' + do( 'SetProject: X=10 Y=10 Width=1000 Height=800' ) + +def makeMonoTrack() : + do( 'SelectTime: StartTime=0 EndTime=30' ) + do( 'Chirp: StartAmp=0.5' ) + do( 'SelectTracks' ) + do( 'Wahwah' ) + do( 'FitInWindow' ) + do( 'SetTrack: TrackIndex=0 Name="Foxy Lady"') + +def makeStereoTrack() : + do( 'SetProject: X=10 Y=10 Width=1000 Height=800' ) + do( 'SelectTime: StartTime=0 EndTime=30' ) + do( 'NewStereoTrack' ) + do( 'Chirp: StartAmp=0.5' ) +# do( 'SelectTracks: FirstTrack=0 LastTrack=1' ) + do( 'Wahwah' ) + do( 'FitInWindow' ) + do( 'SetTrack: TrackIndex=0 Name="Voodoo Children IN STEREO"') + +def closeTrack( ): + do( 'SetTrack: TrackIndex=0 Focused=True' ) + do( 'TrackClose' ) + +def image1() : + global path + makeMonoTrack() + do( 'SelectTime: StartTime=11 EndTime=14') + do( 'Screenshot: Path='+path+' CaptureWhat=First_Track_Plus' ) + +def image2() : + global path + makeStereoTrack() + do( 'SelectTime: StartTime=11 EndTime=14') + do( 'Screenshot: Path='+path+' CaptureWhat=First_Track_Plus' ) + + +#quickTest() +setup() +image1() +closeTrack() +image2() +closeTrack() + + + + diff --git a/scripts/piped-work/get-gui-structure.py b/scripts/piped-work/get_gui_structure.py similarity index 100% rename from scripts/piped-work/get-gui-structure.py rename to scripts/piped-work/get_gui_structure.py diff --git a/scripts/piped-work/pipe-test.pl b/scripts/piped-work/pipe_test.pl similarity index 100% rename from scripts/piped-work/pipe-test.pl rename to scripts/piped-work/pipe_test.pl diff --git a/scripts/piped-work/pipe-test.py b/scripts/piped-work/pipe_test.py similarity index 100% rename from scripts/piped-work/pipe-test.py rename to scripts/piped-work/pipe_test.py diff --git a/scripts/piped-work/recording-test.py b/scripts/piped-work/recording_test.py similarity index 100% rename from scripts/piped-work/recording-test.py rename to scripts/piped-work/recording_test.py diff --git a/src/commands/ScreenshotCommand.cpp b/src/commands/ScreenshotCommand.cpp index 3601940e2..31f132ba5 100644 --- a/src/commands/ScreenshotCommand.cpp +++ b/src/commands/ScreenshotCommand.cpp @@ -73,6 +73,8 @@ enum kCaptureTypes ktracks, kfirsttrack, ksecondtrack, + ktracksplus, + kfirsttrackplus, nCaptureWhats }; @@ -103,6 +105,8 @@ static const wxString kCaptureWhatStrings[nCaptureWhats] = XO("Tracks"), XO("First_Track"), XO("Second_Track") + XO("Tracks_Plus"), + XO("First_Track_Plus"), }; @@ -267,14 +271,15 @@ bool ScreenshotCommand::Capture( //wxRect r(x, y, width, height); - // Ensure within bounds (x/y are negative on Windows when maximized) - r.Intersect(wxRect(0, 0, screenW, screenH)); // Convert to screen coordinates if needed if (window && window->GetParent() && !window->IsTopLevel()) { r.SetPosition(window->GetParent()->ClientToScreen(r.GetPosition())); } + // Ensure within bounds (x/y are negative on Windows when maximized) + r.Intersect(wxRect(0, 0, screenW, screenH)); + // Extract the actual image wxBitmap part = full.GetSubBitmap(r); @@ -799,6 +804,12 @@ bool ScreenshotCommand::Apply(const CommandContext & context) TrackPanel *panel = context.GetProject()->GetTrackPanel(); AdornedRulerPanel *ruler = panel->mRuler; + int x1,y1,x2,y2; + w->ClientToScreen(&x1, &y1); + panel->ClientToScreen(&x2, &y2); + + wxPoint p( x2-x1, y2-y1); + if (mCaptureMode.IsSameAs(wxT("Window"))) return Capture(context, WindowFileName( context.GetProject(), w ) , w, GetWindowRect(w)); else if (mCaptureMode.IsSameAs(wxT("Fullwindow")) @@ -848,6 +859,18 @@ bool ScreenshotCommand::Apply(const CommandContext & context) return Capture(context, mFileName, panel, GetTrackRect( context.GetProject(), panel, 0 ) ); else if (mCaptureMode.IsSameAs(wxT("Second_Track"))) return Capture(context, mFileName, panel, GetTrackRect( context.GetProject(), panel, 1 ) ); + else if (mCaptureMode.IsSameAs(wxT("Tracks_Plus"))) + { wxRect r = GetTracksRect(panel); + r.SetTop( r.GetTop() - ruler->GetRulerHeight() ); + r.SetHeight( r.GetHeight() + ruler->GetRulerHeight() ); + return Capture(context, mFileName, panel, r); + } + else if (mCaptureMode.IsSameAs(wxT("First_Track_Plus"))) + { wxRect r = GetTrackRect(context.GetProject(), panel, 0 ); + r.SetTop( r.GetTop() - ruler->GetRulerHeight() ); + r.SetHeight( r.GetHeight() + ruler->GetRulerHeight() ); + return Capture(context, mFileName, panel, r ); + } else return false; diff --git a/src/commands/SetTrackInfoCommand.cpp b/src/commands/SetTrackInfoCommand.cpp index f7c87aaae..47c0cf516 100644 --- a/src/commands/SetTrackInfoCommand.cpp +++ b/src/commands/SetTrackInfoCommand.cpp @@ -27,16 +27,7 @@ #include "CommandContext.h" SetTrackCommand::SetTrackCommand() -{/* - mTrackIndex = 0; - mTrackName = "unnamed"; - mPan = 0.0f; - mGain = 1.0f; - bSelected = false; - bFocused = false; - bSolo = false; - bMute = false; -*/ +{ } enum kColours @@ -65,7 +56,7 @@ bool SetTrackCommand::DefineParams( ShuttleParams & S ){ S.Optional( bHasHeight ).Define( mHeight, wxT("Height"), 120, 44, 700 ); S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours ); S.Optional( bHasSelected ).Define( bSelected, wxT("Selected"), false ); - S.Optional( bHasFocused ).Define( bFocused, wxT("Focuseed"), false ); + S.Optional( bHasFocused ).Define( bFocused, wxT("Focused"), false ); S.Optional( bHasSolo ).Define( bSolo, wxT("Solo"), false ); S.Optional( bHasMute ).Define( bMute, wxT("Mute"), false ); return true;