1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-22 23:30:07 +02:00

Screen capture preference panels too.

This commit is contained in:
James Crook 2017-06-07 15:58:06 +01:00
parent 7bf7815c75
commit 8f66c3603d
4 changed files with 48 additions and 6 deletions

View File

@ -4231,6 +4231,9 @@ void AudacityProject::OnPreferences()
{ {
GlobalPrefsDialog dialog(this /* parent */ ); GlobalPrefsDialog dialog(this /* parent */ );
if( ScreenshotCommand::MayCapture( &dialog ) )
return;
if (!dialog.ShowModal()) { if (!dialog.ShowModal()) {
// Canceled // Canceled
return; return;

View File

@ -72,6 +72,7 @@ class ScreenFrame final : public wxFrame
void OnCaptureToolbars(wxCommandEvent & event); void OnCaptureToolbars(wxCommandEvent & event);
void OnCaptureMenus(wxCommandEvent & event); void OnCaptureMenus(wxCommandEvent & event);
void OnCaptureEffects(wxCommandEvent & event); void OnCaptureEffects(wxCommandEvent & event);
void OnCapturePreferences(wxCommandEvent & event);
void OnCaptureSelectionBar(wxCommandEvent & event); void OnCaptureSelectionBar(wxCommandEvent & event);
void OnCaptureTools(wxCommandEvent & event); void OnCaptureTools(wxCommandEvent & event);
void OnCaptureTransport(wxCommandEvent & event); void OnCaptureTransport(wxCommandEvent & event);
@ -182,6 +183,7 @@ enum
IdCaptureToolbars, IdCaptureToolbars,
IdCaptureMenus, IdCaptureMenus,
IdCaptureEffects, IdCaptureEffects,
IdCapturePreferences,
IdCaptureSelectionBar, IdCaptureSelectionBar,
IdCaptureTools, IdCaptureTools,
IdCaptureTransport, IdCaptureTransport,
@ -228,6 +230,7 @@ BEGIN_EVENT_TABLE(ScreenFrame, wxFrame)
EVT_BUTTON(IdCaptureToolbars, ScreenFrame::OnCaptureToolbars) EVT_BUTTON(IdCaptureToolbars, ScreenFrame::OnCaptureToolbars)
EVT_BUTTON(IdCaptureMenus, ScreenFrame::OnCaptureMenus) EVT_BUTTON(IdCaptureMenus, ScreenFrame::OnCaptureMenus)
EVT_BUTTON(IdCaptureEffects, ScreenFrame::OnCaptureEffects) EVT_BUTTON(IdCaptureEffects, ScreenFrame::OnCaptureEffects)
EVT_BUTTON(IdCapturePreferences, ScreenFrame::OnCapturePreferences)
EVT_BUTTON(IdCaptureSelectionBar, ScreenFrame::OnCaptureSelectionBar) EVT_BUTTON(IdCaptureSelectionBar, ScreenFrame::OnCaptureSelectionBar)
EVT_BUTTON(IdCaptureTools, ScreenFrame::OnCaptureTools) EVT_BUTTON(IdCaptureTools, ScreenFrame::OnCaptureTools)
EVT_BUTTON(IdCaptureTransport, ScreenFrame::OnCaptureTransport) EVT_BUTTON(IdCaptureTransport, ScreenFrame::OnCaptureTransport)
@ -392,6 +395,7 @@ void ScreenFrame::PopulateOrExchange(ShuttleGui & S)
#ifdef EXPERIMENTAL_DOCS_AUTOMATION #ifdef EXPERIMENTAL_DOCS_AUTOMATION
S.Id(IdCaptureMenus).AddButton(_("All Menus")); S.Id(IdCaptureMenus).AddButton(_("All Menus"));
S.Id(IdCaptureEffects).AddButton(_("All Effects")); S.Id(IdCaptureEffects).AddButton(_("All Effects"));
S.Id(IdCapturePreferences).AddButton(_("All Preferences"));
#endif #endif
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
@ -629,6 +633,11 @@ void ScreenFrame::OnCaptureEffects(wxCommandEvent & WXUNUSED(event))
DoCapture(wxT("effects")); DoCapture(wxT("effects"));
} }
void ScreenFrame::OnCapturePreferences(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("preferences"));
}
void ScreenFrame::OnCaptureSelectionBar(wxCommandEvent & WXUNUSED(event)) void ScreenFrame::OnCaptureSelectionBar(wxCommandEvent & WXUNUSED(event))
{ {
DoCapture(wxT("selectionbar")); DoCapture(wxT("selectionbar"));

View File

@ -42,6 +42,7 @@ project window.
#include "../toolbars/ToolsToolBar.h" #include "../toolbars/ToolsToolBar.h"
#include "../toolbars/TranscriptionToolBar.h" #include "../toolbars/TranscriptionToolBar.h"
#include "../widgets/Ruler.h" #include "../widgets/Ruler.h"
#include "../Prefs.h"
#if defined(__WXMAC__) && !wxCHECK_VERSION(3, 0, 0) #if defined(__WXMAC__) && !wxCHECK_VERSION(3, 0, 0)
// //
@ -376,16 +377,13 @@ void ScreenshotCommand::CaptureWindowOnIdle( wxWindow * pWin )
wxPoint Pos = pDlg->GetScreenPosition(); wxPoint Pos = pDlg->GetScreenPosition();
wxSize Siz = pDlg->GetSize(); wxSize Siz = pDlg->GetSize();
wxString Name = mDirToWriteTo;
wxString Title = pDlg->GetTitle(); wxString Title = pDlg->GetTitle();
// Remove '/' from "Sliding Time Scale/Pitch Shift..." // Remove '/' from "Sliding Time Scale/Pitch Shift..."
// and any other effects that have illegal filename chanracters. // and any other effects that have illegal filename chanracters.
Title.Replace( "/", "" ); Title.Replace( "/", "" );
Name.Replace( "effects000", Title ); Title.Replace( ":", "" );
wxString Name = mDirToWriteTo + Title + ".png";
int x = 0, y = 0;
int width, height;
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 );
@ -400,13 +398,39 @@ void ScreenshotCommand::CaptureWindowOnIdle( wxWindow * pWin )
pDlg->GetEventHandler()->AddPendingEvent( Evt ); pDlg->GetEventHandler()->AddPendingEvent( Evt );
} }
void ScreenshotCommand::CapturePreferences( AudacityProject * pProject, const wxString &fileName ){
fileName;//compiler food.
CommandManager * pMan = pProject->GetCommandManager();
// 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 = fileName.BeforeLast('\\') + "\\";
mpShooter = this;
const int nPrefsPages = 19;
for( int i=0;i<nPrefsPages;i++){
// The handler is cleared each time it is used.
SetIdleHandler( IdleHandler );
gPrefs->Write(wxT("/Prefs/PrefsCategory"), (long)i);
gPrefs->Flush();
wxString Command = "Preferences";
if( !pMan->HandleTextualCommand( Command, AlwaysEnabledFlag, AlwaysEnabledFlag ) )
{
wxLogDebug("Command %s not found", Command );
}
// This sleep is not needed, but gives user a chance to see the
// dialogs as they whizz by.
wxMilliSleep( 200 );
}
}
void ScreenshotCommand::CaptureEffects( AudacityProject * pProject, const wxString &fileName ){ void ScreenshotCommand::CaptureEffects( AudacityProject * pProject, const wxString &fileName ){
fileName;//compiler food. fileName;//compiler food.
CommandManager * pMan = pProject->GetCommandManager(); CommandManager * pMan = pProject->GetCommandManager();
wxString Str; wxString Str;
// Yucky static variables. Is there a better way? The problem is that we need the // Yucky static variables. Is there a better way? The problem is that we need the
// idle callback to know more about what to do. // idle callback to know more about what to do.
mDirToWriteTo = fileName; mDirToWriteTo = fileName.BeforeLast('/') + "/";
mpShooter = this; mpShooter = this;
#define TRICKY_CAPTURE #define TRICKY_CAPTURE
@ -523,6 +547,7 @@ void ScreenshotCommandType::BuildSignature(CommandSignature &signature)
captureModeValidator->AddOption(wxT("toolbars")); captureModeValidator->AddOption(wxT("toolbars"));
captureModeValidator->AddOption(wxT("menus")); captureModeValidator->AddOption(wxT("menus"));
captureModeValidator->AddOption(wxT("effects")); captureModeValidator->AddOption(wxT("effects"));
captureModeValidator->AddOption(wxT("preferences"));
captureModeValidator->AddOption(wxT("selectionbar")); captureModeValidator->AddOption(wxT("selectionbar"));
captureModeValidator->AddOption(wxT("tools")); captureModeValidator->AddOption(wxT("tools"));
captureModeValidator->AddOption(wxT("transport")); captureModeValidator->AddOption(wxT("transport"));
@ -708,6 +733,10 @@ bool ScreenshotCommand::Apply(CommandExecutionContext context)
{ {
CaptureEffects(context.GetProject(), fileName); CaptureEffects(context.GetProject(), fileName);
} }
else if (captureMode.IsSameAs(wxT("preferences")))
{
CapturePreferences(context.GetProject(), fileName);
}
else if (captureMode.IsSameAs(wxT("selectionbar"))) else if (captureMode.IsSameAs(wxT("selectionbar")))
{ {
CaptureDock(context.GetProject()->GetToolManager()->GetBotDock(), fileName); CaptureDock(context.GetProject()->GetToolManager()->GetBotDock(), fileName);

View File

@ -49,6 +49,7 @@ private:
void CaptureDock(wxWindow *win, const wxString &fileName); void CaptureDock(wxWindow *win, const wxString &fileName);
void CaptureMenus(wxMenuBar*pBar, const wxString &fileName); void CaptureMenus(wxMenuBar*pBar, const wxString &fileName);
void CaptureEffects( AudacityProject * pProject, const wxString &fileName ); void CaptureEffects( AudacityProject * pProject, const wxString &fileName );
void CapturePreferences( AudacityProject * pProject, const wxString &fileName );
void Capture(const wxString &basename, void Capture(const wxString &basename,
wxWindow *window, wxWindow *window,
int x, int y, int width, int height, int x, int y, int width, int height,