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

Support screenshots of toolbar variants.

Slightly tidied up the code too.
This commit is contained in:
James Crook 2017-06-10 21:32:04 +01:00
parent 06e51ba075
commit 198dbc4c2a
2 changed files with 72 additions and 152 deletions

View File

@ -65,22 +65,7 @@ class ScreenFrame final : public wxFrame
void OnToggleBackgroundWhite(wxCommandEvent & event);
void DoCapture(wxString captureMode);
void OnCaptureWindowContents(wxCommandEvent & event);
void OnCaptureFullWindow(wxCommandEvent & event);
void OnCaptureWindowPlus(wxCommandEvent & event);
void OnCaptureFullScreen(wxCommandEvent & event);
void OnCaptureToolbars(wxCommandEvent & event);
void OnCaptureMenus(wxCommandEvent & event);
void OnCaptureEffects(wxCommandEvent & event);
void OnCapturePreferences(wxCommandEvent & event);
void OnCaptureSelectionBar(wxCommandEvent & event);
void OnCaptureTools(wxCommandEvent & event);
void OnCaptureTransport(wxCommandEvent & event);
void OnCaptureMixer(wxCommandEvent & event);
void OnCaptureMeter(wxCommandEvent & event);
void OnCaptureEdit(wxCommandEvent & event);
void OnCaptureDevice(wxCommandEvent & event);
void OnCaptureTranscription(wxCommandEvent & event);
void OnCaptureSomething(wxCommandEvent & event);
void TimeZoom(double seconds);
void OnOneSec(wxCommandEvent & event);
@ -94,12 +79,6 @@ class ScreenFrame final : public wxFrame
void OnMedTracks(wxCommandEvent & event);
void OnTallTracks(wxCommandEvent & event);
void OnCaptureTrackPanel(wxCommandEvent & event);
void OnCaptureRuler(wxCommandEvent & event);
void OnCaptureTracks(wxCommandEvent & event);
void OnCaptureFirstTrack(wxCommandEvent & event);
void OnCaptureSecondTrack(wxCommandEvent & event);
std::unique_ptr<ScreenshotCommand> CreateCommand();
wxCheckBox *mDelayCheckBox;
@ -180,24 +159,35 @@ enum
IdDelayCheckBox,
IdCaptureFirst,
IdCaptureWindowContents = IdCaptureFirst,
IdCaptureFullWindow,
IdCaptureWindowPlus,
IdCaptureFullScreen,
IdCaptureToolbars,
IdCaptureMenus,
IdCaptureEffects,
IdCapturePreferences,
IdCaptureSelectionBar,
IdCaptureSpectralSelection,
IdCaptureTools,
IdCaptureTransport,
IdCaptureMixer,
IdCaptureMeter,
IdCapturePlayMeter,
IdCaptureRecordMeter,
IdCaptureEdit,
IdCaptureDevice,
IdCaptureTranscription,
IdCaptureScrub,
IdCaptureTrackPanel,
IdCaptureRuler,
IdCaptureTracks,
IdCaptureFirstTrack,
IdCaptureSecondTrack,
IdCaptureLast = IdCaptureSecondTrack,
IdToggleBackgroundBlue,
IdToggleBackgroundWhite,
@ -205,10 +195,6 @@ enum
// Put all events that might need delay below:
IdAllDelayedEvents,
IdCaptureWindowContents,
IdCaptureFullWindow,
IdCaptureWindowPlus,
IdCaptureFullScreen,
IdLastDelayedEvent,
};
@ -222,23 +208,7 @@ BEGIN_EVENT_TABLE(ScreenFrame, wxFrame)
EVT_BUTTON(IdMainWindowLarge, ScreenFrame::OnMainWindowLarge)
EVT_TOGGLEBUTTON(IdToggleBackgroundBlue, ScreenFrame::OnToggleBackgroundBlue)
EVT_TOGGLEBUTTON(IdToggleBackgroundWhite, ScreenFrame::OnToggleBackgroundWhite)
EVT_BUTTON(IdCaptureWindowContents, ScreenFrame::OnCaptureWindowContents)
EVT_BUTTON(IdCaptureFullWindow, ScreenFrame::OnCaptureFullWindow)
EVT_BUTTON(IdCaptureWindowPlus, ScreenFrame::OnCaptureWindowPlus)
EVT_BUTTON(IdCaptureFullScreen, ScreenFrame::OnCaptureFullScreen)
EVT_BUTTON(IdCaptureToolbars, ScreenFrame::OnCaptureToolbars)
EVT_BUTTON(IdCaptureMenus, ScreenFrame::OnCaptureMenus)
EVT_BUTTON(IdCaptureEffects, ScreenFrame::OnCaptureEffects)
EVT_BUTTON(IdCapturePreferences, ScreenFrame::OnCapturePreferences)
EVT_BUTTON(IdCaptureSelectionBar, ScreenFrame::OnCaptureSelectionBar)
EVT_BUTTON(IdCaptureTools, ScreenFrame::OnCaptureTools)
EVT_BUTTON(IdCaptureTransport, ScreenFrame::OnCaptureTransport)
EVT_BUTTON(IdCaptureMixer, ScreenFrame::OnCaptureMixer)
EVT_BUTTON(IdCaptureMeter, ScreenFrame::OnCaptureMeter)
EVT_BUTTON(IdCaptureEdit, ScreenFrame::OnCaptureEdit)
EVT_BUTTON(IdCaptureDevice, ScreenFrame::OnCaptureDevice)
EVT_BUTTON(IdCaptureTranscription, ScreenFrame::OnCaptureTranscription)
EVT_COMMAND_RANGE(IdCaptureFirst, IdCaptureLast, wxEVT_COMMAND_BUTTON_CLICKED, ScreenFrame::OnCaptureSomething)
EVT_BUTTON(IdOneSec, ScreenFrame::OnOneSec)
EVT_BUTTON(IdTenSec, ScreenFrame::OnTenSec)
@ -250,12 +220,6 @@ BEGIN_EVENT_TABLE(ScreenFrame, wxFrame)
EVT_BUTTON(IdMedTracks, ScreenFrame::OnMedTracks)
EVT_BUTTON(IdTallTracks, ScreenFrame::OnTallTracks)
EVT_BUTTON(IdCaptureTrackPanel, ScreenFrame::OnCaptureTrackPanel)
EVT_BUTTON(IdCaptureRuler, ScreenFrame::OnCaptureRuler)
EVT_BUTTON(IdCaptureTracks, ScreenFrame::OnCaptureTracks)
EVT_BUTTON(IdCaptureFirstTrack, ScreenFrame::OnCaptureFirstTrack)
EVT_BUTTON(IdCaptureSecondTrack, ScreenFrame::OnCaptureSecondTrack)
EVT_BUTTON(IdDirChoose, ScreenFrame::OnDirChoose)
END_EVENT_TABLE();
@ -403,10 +367,18 @@ void ScreenFrame::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay();
{
S.Id(IdCaptureSelectionBar).AddButton(_("SelectionBar"));
S.Id(IdCaptureSpectralSelection).AddButton(_("Spectral Selection"));
S.Id(IdCaptureTools).AddButton(_("Tools"));
S.Id(IdCaptureTransport).AddButton(_("Transport"));
}
S.EndHorizontalLay();
S.StartHorizontalLay();
{
S.Id(IdCaptureMixer).AddButton(_("Mixer"));
S.Id(IdCaptureMeter).AddButton(_("Meter"));
S.Id(IdCapturePlayMeter).AddButton(_("Play Meter"));
S.Id(IdCaptureRecordMeter).AddButton(_("Record Meter"));
}
S.EndHorizontalLay();
@ -415,6 +387,7 @@ void ScreenFrame::PopulateOrExchange(ShuttleGui & S)
S.Id(IdCaptureEdit).AddButton(_("Edit"));
S.Id(IdCaptureDevice).AddButton(_("Device"));
S.Id(IdCaptureTranscription).AddButton(_("Transcription"));
S.Id(IdCaptureScrub).AddButton(_("Scrub"));
}
S.EndHorizontalLay();
@ -598,109 +571,39 @@ void ScreenFrame::DoCapture(wxString captureMode)
Show();
}
void ScreenFrame::OnCaptureWindowContents(wxCommandEvent & WXUNUSED(event))
void ScreenFrame::OnCaptureSomething(wxCommandEvent & event)
{
DoCapture(wxT("window"));
}
int i = event.GetId() - IdCaptureFirst;
void ScreenFrame::OnCaptureFullWindow(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("fullwindow"));
}
wxArrayString Names;
void ScreenFrame::OnCaptureWindowPlus(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("windowplus"));
}
Names.Add(wxT("window"));
Names.Add(wxT("fullwindow"));
Names.Add(wxT("windowplus"));
Names.Add(wxT("fullscreen"));
Names.Add(wxT("toolbars"));
Names.Add(wxT("menus"));
Names.Add(wxT("effects"));
Names.Add(wxT("preferences"));
Names.Add(wxT("selectionbar"));
Names.Add(wxT("spectralselection"));
Names.Add(wxT("tools"));
Names.Add(wxT("transport"));
Names.Add(wxT("mixer"));
Names.Add(wxT("meter"));
Names.Add(wxT("playmeter"));
Names.Add(wxT("recordmeter"));
Names.Add(wxT("edit"));
Names.Add(wxT("device"));
Names.Add(wxT("transcription"));
Names.Add(wxT("scrub"));
Names.Add(wxT("trackpanel"));
Names.Add(wxT("ruler"));
Names.Add(wxT("tracks"));
Names.Add(wxT("firsttrack"));
Names.Add(wxT("secondtrack"));
void ScreenFrame::OnCaptureFullScreen(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("fullscreen"));
}
void ScreenFrame::OnCaptureToolbars(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("toolbars"));
}
void ScreenFrame::OnCaptureMenus(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("menus"));
}
void ScreenFrame::OnCaptureEffects(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("effects"));
}
void ScreenFrame::OnCapturePreferences(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("preferences"));
}
void ScreenFrame::OnCaptureSelectionBar(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("selectionbar"));
}
void ScreenFrame::OnCaptureTools(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("tools"));
}
void ScreenFrame::OnCaptureTransport(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("transport"));
}
void ScreenFrame::OnCaptureMixer(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("mixer"));
}
void ScreenFrame::OnCaptureMeter(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("meter"));
}
void ScreenFrame::OnCaptureEdit(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("edit"));
}
void ScreenFrame::OnCaptureDevice(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("device"));
}
void ScreenFrame::OnCaptureTranscription(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("transcription"));
}
void ScreenFrame::OnCaptureTrackPanel(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("trackpanel"));
}
void ScreenFrame::OnCaptureRuler(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("ruler"));
}
void ScreenFrame::OnCaptureTracks(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("tracks"));
}
void ScreenFrame::OnCaptureFirstTrack(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("firsttrack"));
}
void ScreenFrame::OnCaptureSecondTrack(wxCommandEvent & WXUNUSED(event))
{
DoCapture(wxT("secondtrack"));
DoCapture(Names[i]);
}
void ScreenFrame::TimeZoom(double seconds)

View File

@ -549,12 +549,16 @@ void ScreenshotCommandType::BuildSignature(CommandSignature &signature)
captureModeValidator->AddOption(wxT("effects"));
captureModeValidator->AddOption(wxT("preferences"));
captureModeValidator->AddOption(wxT("selectionbar"));
captureModeValidator->AddOption(wxT("spectralselection"));
captureModeValidator->AddOption(wxT("tools"));
captureModeValidator->AddOption(wxT("transport"));
captureModeValidator->AddOption(wxT("mixer"));
captureModeValidator->AddOption(wxT("meter"));
captureModeValidator->AddOption(wxT("playmeter"));
captureModeValidator->AddOption(wxT("recordmeter"));
captureModeValidator->AddOption(wxT("edit"));
captureModeValidator->AddOption(wxT("device"));
captureModeValidator->AddOption(wxT("scrub"));
captureModeValidator->AddOption(wxT("transcription"));
captureModeValidator->AddOption(wxT("trackpanel"));
captureModeValidator->AddOption(wxT("ruler"));
@ -659,8 +663,9 @@ bool ScreenshotCommand::Apply(CommandExecutionContext context)
mBackground = false;
}
// Reset the toolbars to a known state
context.GetProject()->GetToolManager()->Reset();
//Don't reset the toolbars to a known state.
//We wil lbe capturing variations of them.
//context.GetProject()->GetToolManager()->Reset();
wxTopLevelWindow *w = GetFrontWindow(context.GetProject());
if (!w)
@ -739,7 +744,11 @@ bool ScreenshotCommand::Apply(CommandExecutionContext context)
}
else if (captureMode.IsSameAs(wxT("selectionbar")))
{
CaptureDock(context.GetProject()->GetToolManager()->GetBotDock(), fileName);
CaptureToolbar(context.GetProject()->GetToolManager(), SelectionBarID, fileName);
}
else if (captureMode.IsSameAs(wxT("spectralselection")))
{
CaptureToolbar(context.GetProject()->GetToolManager(), SpectralSelectionBarID, fileName);
}
else if (captureMode.IsSameAs(wxT("tools")))
{
@ -757,6 +766,14 @@ bool ScreenshotCommand::Apply(CommandExecutionContext context)
{
CaptureToolbar(context.GetProject()->GetToolManager(), MeterBarID, fileName);
}
else if (captureMode.IsSameAs(wxT("recordmeter")))
{
CaptureToolbar(context.GetProject()->GetToolManager(), RecordMeterBarID, fileName);
}
else if (captureMode.IsSameAs(wxT("playmeter")))
{
CaptureToolbar(context.GetProject()->GetToolManager(), PlayMeterBarID, fileName);
}
else if (captureMode.IsSameAs(wxT("edit")))
{
CaptureToolbar(context.GetProject()->GetToolManager(), EditBarID, fileName);
@ -769,7 +786,7 @@ bool ScreenshotCommand::Apply(CommandExecutionContext context)
{
CaptureToolbar(context.GetProject()->GetToolManager(), TranscriptionBarID, fileName);
}
else if (captureMode.IsSameAs(wxT("scrubbing")))
else if (captureMode.IsSameAs(wxT("scrub")))
{
CaptureToolbar(context.GetProject()->GetToolManager(), ScrubbingBarID, fileName);
}