1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-17 14:11:13 +01:00

Add scriptables to screenshot, remove menus.

- Also made automation and the extra screenshot buttons non-experimental.
This commit is contained in:
James Crook
2018-02-27 21:50:53 +00:00
parent e1c30db38c
commit 104c3b6a5a
4 changed files with 68 additions and 65 deletions

View File

@@ -48,12 +48,6 @@
// feature to link audio tracks to a label track // feature to link audio tracks to a label track
#define EXPERIMENTAL_SYNC_LOCK #define EXPERIMENTAL_SYNC_LOCK
// JKC: Enable to get extra buttons in the screenshot tools.
//#define EXPERIMENTAL_DOCS_AUTOMATION
// JKC: Enable to get experiemental code to move
// mod-script-pipe towards being mainstream.
//#define EXPERIMENTAL_AUTOMATION
// DA: Enables dark audacity theme and customisations. // DA: Enables dark audacity theme and customisations.
//#define EXPERIMENTAL_DA //#define EXPERIMENTAL_DA

View File

@@ -179,14 +179,14 @@ enum
IdCaptureFirst, IdCaptureFirst,
// No point delaying the capture of sets of things. // No point delaying the capture of sets of things.
IdCaptureMenus= IdCaptureFirst, IdCaptureEffects= IdCaptureFirst,
IdCaptureEffects, IdCaptureScriptables,
IdCapturePreferences, IdCapturePreferences,
IdCaptureToolbars,
// Put all events that need delay between AllDelayed and LastDelayed. // Put all events that need delay between AllDelayed and LastDelayed.
IdAllDelayedEvents, IdAllDelayedEvents,
IdCaptureToolbars =IdAllDelayedEvents, IdCaptureWindowContents=IdAllDelayedEvents,
IdCaptureWindowContents,
IdCaptureFullWindow, IdCaptureFullWindow,
IdCaptureWindowPlus, IdCaptureWindowPlus,
IdCaptureFullScreen, IdCaptureFullScreen,
@@ -380,11 +380,9 @@ void ScreenFrame::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay(); S.StartHorizontalLay();
{ {
S.Id(IdCaptureToolbars).AddButton(_("All Toolbars")); S.Id(IdCaptureToolbars).AddButton(_("All Toolbars"));
#ifdef EXPERIMENTAL_DOCS_AUTOMATION
S.Id(IdCaptureMenus).AddButton(_("All Menus"));
S.Id(IdCaptureEffects).AddButton(_("All Effects")); S.Id(IdCaptureEffects).AddButton(_("All Effects"));
S.Id(IdCaptureScriptables).AddButton(_("All Scriptables"));
S.Id(IdCapturePreferences).AddButton(_("All Preferences")); S.Id(IdCapturePreferences).AddButton(_("All Preferences"));
#endif
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
@@ -603,11 +601,11 @@ void ScreenFrame::OnCaptureSomething(wxCommandEvent & event)
wxArrayString Names; wxArrayString Names;
Names.Add(wxT("Menus"));
Names.Add(wxT("Effects")); Names.Add(wxT("Effects"));
Names.Add(wxT("Scriptables"));
Names.Add(wxT("Preferences")); Names.Add(wxT("Preferences"));
Names.Add(wxT("Toolbars")); Names.Add(wxT("Toolbars"));
Names.Add(wxT("Window")); Names.Add(wxT("Window"));
Names.Add(wxT("Full_Window")); Names.Add(wxT("Full_Window"));
Names.Add(wxT("Window_Plus")); Names.Add(wxT("Window_Plus"));

View File

@@ -53,8 +53,8 @@ enum kCaptureTypes
kwindowplus, kwindowplus,
kfullscreen, kfullscreen,
ktoolbars, ktoolbars,
kmenus,
keffects, keffects,
kscriptables,
kpreferences, kpreferences,
kselectionbar, kselectionbar,
kspectralselection, kspectralselection,
@@ -90,8 +90,8 @@ static const wxString kCaptureWhatStrings[nCaptureWhats] =
XO("Window_Plus"), XO("Window_Plus"),
XO("Fullscreen"), XO("Fullscreen"),
XO("Toolbars"), XO("Toolbars"),
XO("Menus"),
XO("Effects"), XO("Effects"),
XO("Scriptables"),
XO("Preferences"), XO("Preferences"),
XO("Selectionbar"), XO("Selectionbar"),
XO("Spectral_Selection"), XO("Spectral_Selection"),
@@ -408,38 +408,6 @@ void ExploreMenu(
} }
} }
void ScreenshotCommand::CaptureMenus(
const CommandContext & context,
wxMenuBar*pBar, const wxString &mFileName)
{
mFileName;//compiler food.
if(!pBar ){
wxLogDebug("No menus");
return;
}
size_t cnt = pBar->GetMenuCount();
size_t i;
wxString Label;
for(i=0;i<cnt;i++)
{
Label = pBar->GetMenuLabelText( i );
wxLogDebug( "\nT.Add( 0, 0, 0, \"%s<>\" );", Label);
ExploreMenu( context, pBar->GetMenu( i ), pBar->GetId(), 1 );
}
#if 0
int x = 0, y = 0;
int width, height;
win->ClientToScreen(&x, &y);
win->GetParent()->ScreenToClient(&x, &y);
win->GetClientSize(&width, &height);
Capture(mFileName, win, wxRect(x, y, width, height));
#endif
}
// Handed a dialog, which it is given the option to capture. // Handed a dialog, which it is given the option to capture.
bool ScreenshotCommand::MayCapture( wxDialog * pDlg ) bool ScreenshotCommand::MayCapture( wxDialog * pDlg )
{ {
@@ -474,7 +442,7 @@ void ScreenshotCommand::CaptureWindowOnIdle(
wxLogDebug("Taking screenshot of window %s (%i,%i,%i,%i)", Name, wxLogDebug("Taking screenshot of window %s (%i,%i,%i,%i)", Name,
Pos.x, Pos.y, Siz.x, Siz.y ); Pos.x, Pos.y, Siz.x, Siz.y );
// This delay is needed, as dialogs take a moment or two to fade in. // This delay is needed, as dialogs take a moment or two to fade in.
wxMilliSleep( 200 ); wxMilliSleep( 400 );
// JKC: The border of 7 pixels was determined from a trial capture and then measuring // JKC: The border of 7 pixels was determined from a trial capture and then measuring
// in the GIMP. I'm unsure where the border comes from. // in the GIMP. I'm unsure where the border comes from.
Capture( context, Name, pDlg, wxRect((int)Pos.x+7, (int)Pos.y, (int)Siz.x-14, (int)Siz.y-7) ); Capture( context, Name, pDlg, wxRect((int)Pos.x+7, (int)Pos.y, (int)Siz.x-14, (int)Siz.y-7) );
@@ -516,22 +484,16 @@ void ScreenshotCommand::CapturePreferences(
void ScreenshotCommand::CaptureEffects( void ScreenshotCommand::CaptureEffects(
const CommandContext & context, const CommandContext & context,
AudacityProject * pProject, const wxString &mFileName ){ AudacityProject * pProject, const wxString &mFileName )
{
(void)pProject;
(void)&mFileName;//compiler food. (void)&mFileName;//compiler food.
(void)&context; (void)&context;
CommandManager * pMan = pProject->GetCommandManager();
wxString Str;
// Yucky static variables. Is there a better way? The problem is that we need the
// idle callback to know more about what to do.
mDirToWriteTo = mFileName.BeforeLast('\\') + "\\";
mpShooter = this;
#define TRICKY_CAPTURE #define TRICKY_CAPTURE
#define CAPTURE_NYQUIST_TOO #define CAPTURE_NYQUIST_TOO
// Commented out the effects that don't have dialogs. // Commented out the effects that don't have dialogs.
// Also any problematic ones, // Also any problematic ones,
const wxString EffectNames[] = { const wxString EffectNames[] = {
#ifdef TRICKY_CAPTURE #ifdef TRICKY_CAPTURE
//"Contrast...", // renamed //"Contrast...", // renamed
"ContrastAnalyser", "ContrastAnalyser",
@@ -609,17 +571,65 @@ void ScreenshotCommand::CaptureEffects(
"Sound Finder...", "Sound Finder...",
#endif #endif
}; };
wxArrayString Commands( sizeof(EffectNames)/sizeof(EffectNames[0]), EffectNames );
CaptureCommands( context, Commands );
}
for( int i=0;i<sizeof(EffectNames)/sizeof(EffectNames[0]);i++){ void ScreenshotCommand::CaptureScriptables(
const CommandContext & context,
AudacityProject * pProject, const wxString &mFileName )
{
(void)pProject;
(void)&mFileName;//compiler food.
(void)&context;
const wxString ScriptablesNames[] = {
"Select",
"GetInfo",
"Help", // Help on individual commands
"Import2",
"Export2",
"OpenProject2",
"SaveProject2",
"Message",
"Screenshot",
"Drag",
"CompareAudio",
"GetPreference",
"SetPreference",
"SetClip",
"SetEnvelope",
"SetLabel",
"SetProject",
"SetTrack",
};
wxArrayString Commands( sizeof(ScriptablesNames)/sizeof(ScriptablesNames[0]), ScriptablesNames );
CaptureCommands( context, Commands );
}
void ScreenshotCommand::CaptureCommands(
const CommandContext & context, wxArrayString & Commands ){
AudacityProject * pProject = context.GetProject();
CommandManager * pMan = pProject->GetCommandManager();
wxString Str;
// Yucky static variables. Is there a better way? The problem is that we need the
// idle callback to know more about what to do.
mDirToWriteTo = mFileName.BeforeLast('\\') + "\\";
mpShooter = this;
for( size_t i=0;i<Commands.GetCount();i++){
// The handler is cleared each time it is used. // The handler is cleared each time it is used.
SetIdleHandler( IdleHandler ); SetIdleHandler( IdleHandler );
Str = EffectNames[i]; Str = Commands[i];
const CommandContext context( *pProject ); const CommandContext context( *pProject );
if( !pMan->HandleTextualCommand( Str, context, AlwaysEnabledFlag, AlwaysEnabledFlag ) ) if( !pMan->HandleTextualCommand( Str, context, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
{ {
wxLogDebug("Command %s not found", Str); wxLogDebug("Command %s not found", Str);
} }
// This sleep is not needed, but gives user a chance to see the // This particular sleep is not needed, but gives user a chance to see the
// dialogs as they whizz by. // dialogs as they whizz by.
wxMilliSleep( 200 ); wxMilliSleep( 200 );
} }
@@ -842,8 +852,8 @@ bool ScreenshotCommand::Apply(const CommandContext & context)
return Capture(context, mFileName, w,GetScreenRect()); return Capture(context, mFileName, w,GetScreenRect());
else if (mCaptureMode.IsSameAs(wxT("Toolbars"))) else if (mCaptureMode.IsSameAs(wxT("Toolbars")))
return CaptureDock(context, context.GetProject()->GetToolManager()->GetTopDock(), mFileName); return CaptureDock(context, context.GetProject()->GetToolManager()->GetTopDock(), mFileName);
else if (mCaptureMode.IsSameAs(wxT("Menus"))) else if (mCaptureMode.IsSameAs(wxT("Scriptables")))
CaptureMenus(context, context.GetProject()->GetMenuBar(), mFileName); CaptureScriptables(context, context.GetProject(), mFileName);
else if (mCaptureMode.IsSameAs(wxT("Effects"))) else if (mCaptureMode.IsSameAs(wxT("Effects")))
CaptureEffects(context, context.GetProject(), mFileName); CaptureEffects(context, context.GetProject(), mFileName);
else if (mCaptureMode.IsSameAs(wxT("Preferences"))) else if (mCaptureMode.IsSameAs(wxT("Preferences")))

View File

@@ -75,8 +75,9 @@ private:
bool CaptureToolbar(const CommandContext & Context, ToolManager *man, int type, const wxString &name); bool CaptureToolbar(const CommandContext & Context, ToolManager *man, int type, const wxString &name);
bool CaptureDock(const CommandContext & Context, wxWindow *win, const wxString &fileName); bool CaptureDock(const CommandContext & Context, wxWindow *win, const wxString &fileName);
void CaptureMenus(const CommandContext & Context, wxMenuBar*pBar, const wxString &fileName); void CaptureCommands(const CommandContext & Context, wxArrayString &Commands );
void CaptureEffects(const CommandContext & Context, AudacityProject * pProject, const wxString &fileName ); void CaptureEffects(const CommandContext & Context, AudacityProject * pProject, const wxString &fileName );
void CaptureScriptables(const CommandContext & Context, AudacityProject * pProject, const wxString &fileName );
void CapturePreferences(const CommandContext & Context, AudacityProject * pProject, const wxString &fileName ); void CapturePreferences(const CommandContext & Context, AudacityProject * pProject, const wxString &fileName );
bool Capture( bool Capture(
const CommandContext & Context, const CommandContext & Context,