2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
Screenshot.cpp
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
Dominic Mazzoni
|
|
|
|
|
|
|
|
*******************************************************************/
|
|
|
|
|
|
|
|
#include "Screenshot.h"
|
2016-03-31 05:13:29 +00:00
|
|
|
#include "MemoryX.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "commands/ScreenshotCommand.h"
|
|
|
|
#include "commands/CommandTargets.h"
|
|
|
|
#include "commands/CommandDirectory.h"
|
|
|
|
#include <wx/defs.h>
|
|
|
|
#include <wx/event.h>
|
|
|
|
#include <wx/frame.h>
|
|
|
|
|
|
|
|
#include "ShuttleGui.h"
|
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/dirdlg.h>
|
|
|
|
#include <wx/image.h>
|
|
|
|
#include <wx/intl.h>
|
|
|
|
#include <wx/panel.h>
|
|
|
|
#include <wx/statusbr.h>
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
#include <wx/timer.h>
|
|
|
|
#include <wx/tglbtn.h>
|
|
|
|
#include <wx/window.h>
|
|
|
|
|
|
|
|
#include "AudacityApp.h"
|
|
|
|
#include "Project.h"
|
|
|
|
#include "Prefs.h"
|
|
|
|
#include "toolbars/ToolManager.h"
|
|
|
|
|
2015-07-03 04:20:21 +00:00
|
|
|
#include "Track.h"
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
class CommandType;
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class ScreenFrame final : public wxFrame
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// constructors and destructors
|
|
|
|
ScreenFrame(wxWindow *parent, wxWindowID id);
|
|
|
|
virtual ~ScreenFrame();
|
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
bool ProcessEvent(wxEvent & event) override;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void Populate();
|
|
|
|
void PopulateOrExchange(ShuttleGui &S);
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void OnCloseWindow(wxCloseEvent & event);
|
|
|
|
void OnUIUpdate(wxUpdateUIEvent & event);
|
|
|
|
void OnDirChoose(wxCommandEvent & event);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
void SizeMainWindow(int w, int h);
|
2013-08-25 21:51:26 +00:00
|
|
|
void OnMainWindowSmall(wxCommandEvent & event);
|
|
|
|
void OnMainWindowLarge(wxCommandEvent & event);
|
|
|
|
void OnToggleBackgroundBlue(wxCommandEvent & event);
|
|
|
|
void OnToggleBackgroundWhite(wxCommandEvent & event);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
void DoCapture(wxString captureMode);
|
2017-06-10 20:32:04 +00:00
|
|
|
void OnCaptureSomething(wxCommandEvent & event);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
void TimeZoom(double seconds);
|
2013-08-25 21:51:26 +00:00
|
|
|
void OnOneSec(wxCommandEvent & event);
|
|
|
|
void OnTenSec(wxCommandEvent & event);
|
|
|
|
void OnOneMin(wxCommandEvent & event);
|
|
|
|
void OnFiveMin(wxCommandEvent & event);
|
|
|
|
void OnOneHour(wxCommandEvent & event);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
void SizeTracks(int h);
|
2013-08-25 21:51:26 +00:00
|
|
|
void OnShortTracks(wxCommandEvent & event);
|
|
|
|
void OnMedTracks(wxCommandEvent & event);
|
|
|
|
void OnTallTracks(wxCommandEvent & event);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-03-31 11:40:05 +00:00
|
|
|
std::unique_ptr<ScreenshotCommand> CreateCommand();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
wxCheckBox *mDelayCheckBox;
|
|
|
|
wxTextCtrl *mDirectoryTextBox;
|
|
|
|
wxToggleButton *mBlue;
|
|
|
|
wxToggleButton *mWhite;
|
|
|
|
wxStatusBar *mStatus;
|
|
|
|
|
2016-03-31 11:40:05 +00:00
|
|
|
std::unique_ptr<ScreenshotCommand> mCommand;
|
2010-01-23 19:44:49 +00:00
|
|
|
CommandExecutionContext mContext;
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
2017-08-07 20:11:20 +00:00
|
|
|
// Static pointer to the unique ScreenFrame window.
|
|
|
|
// Formerly it was parentless, therefore this was a Destroy_ptr<ScreenFrame>
|
|
|
|
// But now the window is owned, so just use a bare pointer, and null it when
|
|
|
|
// the unique window is destroyed.
|
|
|
|
using ScreenFramePtr = ScreenFrame*;
|
2016-08-10 02:46:59 +00:00
|
|
|
ScreenFramePtr mFrame;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void OpenScreenshotTools()
|
|
|
|
{
|
|
|
|
if (!mFrame) {
|
2017-08-07 20:11:20 +00:00
|
|
|
auto parent = wxGetApp().GetTopWindow();
|
|
|
|
if (!parent) {
|
|
|
|
wxASSERT(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mFrame = ScreenFramePtr{ safenew ScreenFrame(parent, -1) };
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
mFrame->Show();
|
|
|
|
mFrame->Raise();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CloseScreenshotTools()
|
|
|
|
{
|
2017-08-07 20:11:20 +00:00
|
|
|
mFrame = nullptr;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class ScreenFrameTimer final : public wxTimer
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
ScreenFrameTimer(ScreenFrame *frame,
|
2013-08-25 21:51:26 +00:00
|
|
|
wxEvent & event)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
screenFrame = frame;
|
2016-03-31 05:13:29 +00:00
|
|
|
evt.reset(event.Clone());
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2016-02-24 06:06:47 +00:00
|
|
|
void Notify() override
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2016-03-31 05:13:29 +00:00
|
|
|
// Process timer notification just once, then destroy self
|
2010-01-23 19:44:49 +00:00
|
|
|
evt->SetEventObject(NULL);
|
|
|
|
screenFrame->ProcessEvent(*evt);
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ScreenFrame *screenFrame;
|
2016-03-31 05:13:29 +00:00
|
|
|
std::unique_ptr<wxEvent> evt;
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
IdMainWindowSmall = 19200,
|
|
|
|
IdMainWindowLarge,
|
|
|
|
|
|
|
|
IdDirectory,
|
|
|
|
IdDirChoose,
|
|
|
|
|
|
|
|
IdOneSec,
|
|
|
|
IdTenSec,
|
|
|
|
IdOneMin,
|
|
|
|
IdFiveMin,
|
|
|
|
IdOneHour,
|
|
|
|
|
|
|
|
IdShortTracks,
|
|
|
|
IdMedTracks,
|
|
|
|
IdTallTracks,
|
|
|
|
|
|
|
|
IdDelayCheckBox,
|
|
|
|
|
2017-06-10 20:32:04 +00:00
|
|
|
IdCaptureFirst,
|
2017-08-14 17:53:44 +00:00
|
|
|
// No point delaying the capture of sets of things.
|
|
|
|
IdCaptureMenus= IdCaptureFirst,
|
|
|
|
IdCaptureEffects,
|
|
|
|
IdCapturePreferences,
|
|
|
|
|
|
|
|
// Put all events that need delay between AllDelayed and LastDelayed.
|
|
|
|
IdAllDelayedEvents,
|
|
|
|
IdCaptureToolbars =IdAllDelayedEvents,
|
|
|
|
IdCaptureWindowContents,
|
2017-06-10 20:32:04 +00:00
|
|
|
IdCaptureFullWindow,
|
|
|
|
IdCaptureWindowPlus,
|
|
|
|
IdCaptureFullScreen,
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
IdCaptureSelectionBar,
|
2017-06-10 20:32:04 +00:00
|
|
|
IdCaptureSpectralSelection,
|
2010-01-23 19:44:49 +00:00
|
|
|
IdCaptureTools,
|
2010-11-16 01:18:39 +00:00
|
|
|
IdCaptureTransport,
|
2010-01-23 19:44:49 +00:00
|
|
|
IdCaptureMixer,
|
|
|
|
IdCaptureMeter,
|
2017-06-10 20:32:04 +00:00
|
|
|
IdCapturePlayMeter,
|
|
|
|
IdCaptureRecordMeter,
|
2010-01-23 19:44:49 +00:00
|
|
|
IdCaptureEdit,
|
|
|
|
IdCaptureDevice,
|
|
|
|
IdCaptureTranscription,
|
2017-06-10 20:32:04 +00:00
|
|
|
IdCaptureScrub,
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
IdCaptureTrackPanel,
|
|
|
|
IdCaptureRuler,
|
|
|
|
IdCaptureTracks,
|
|
|
|
IdCaptureFirstTrack,
|
|
|
|
IdCaptureSecondTrack,
|
2017-06-10 20:32:04 +00:00
|
|
|
IdCaptureLast = IdCaptureSecondTrack,
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2017-08-14 17:53:44 +00:00
|
|
|
IdLastDelayedEvent,
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
IdToggleBackgroundBlue,
|
|
|
|
IdToggleBackgroundWhite,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(ScreenFrame, wxFrame)
|
|
|
|
EVT_CLOSE(ScreenFrame::OnCloseWindow)
|
|
|
|
|
|
|
|
EVT_UPDATE_UI(IdCaptureFullScreen, ScreenFrame::OnUIUpdate)
|
|
|
|
|
|
|
|
EVT_BUTTON(IdMainWindowSmall, ScreenFrame::OnMainWindowSmall)
|
|
|
|
EVT_BUTTON(IdMainWindowLarge, ScreenFrame::OnMainWindowLarge)
|
|
|
|
EVT_TOGGLEBUTTON(IdToggleBackgroundBlue, ScreenFrame::OnToggleBackgroundBlue)
|
|
|
|
EVT_TOGGLEBUTTON(IdToggleBackgroundWhite, ScreenFrame::OnToggleBackgroundWhite)
|
2017-06-10 20:32:04 +00:00
|
|
|
EVT_COMMAND_RANGE(IdCaptureFirst, IdCaptureLast, wxEVT_COMMAND_BUTTON_CLICKED, ScreenFrame::OnCaptureSomething)
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
EVT_BUTTON(IdOneSec, ScreenFrame::OnOneSec)
|
|
|
|
EVT_BUTTON(IdTenSec, ScreenFrame::OnTenSec)
|
|
|
|
EVT_BUTTON(IdOneMin, ScreenFrame::OnOneMin)
|
|
|
|
EVT_BUTTON(IdFiveMin, ScreenFrame::OnFiveMin)
|
|
|
|
EVT_BUTTON(IdOneHour, ScreenFrame::OnOneHour)
|
|
|
|
|
|
|
|
EVT_BUTTON(IdShortTracks, ScreenFrame::OnShortTracks)
|
|
|
|
EVT_BUTTON(IdMedTracks, ScreenFrame::OnMedTracks)
|
|
|
|
EVT_BUTTON(IdTallTracks, ScreenFrame::OnTallTracks)
|
|
|
|
|
|
|
|
EVT_BUTTON(IdDirChoose, ScreenFrame::OnDirChoose)
|
|
|
|
END_EVENT_TABLE();
|
|
|
|
|
|
|
|
// Must not be called before CreateStatusBar!
|
2016-03-31 11:40:05 +00:00
|
|
|
std::unique_ptr<ScreenshotCommand> ScreenFrame::CreateCommand()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
wxASSERT(mStatus != NULL);
|
2016-03-31 11:40:05 +00:00
|
|
|
auto output =
|
2016-03-31 17:12:04 +00:00
|
|
|
std::make_unique<CommandOutputTarget>(std::make_unique<NullProgressTarget>(),
|
|
|
|
std::make_shared<StatusBarTarget>(*mStatus),
|
|
|
|
std::make_shared<MessageBoxTarget>());
|
2010-01-23 19:44:49 +00:00
|
|
|
CommandType *type = CommandDirectory::Get()->LookUp(wxT("Screenshot"));
|
|
|
|
wxASSERT_MSG(type != NULL, wxT("Screenshot command doesn't exist!"));
|
2016-03-31 11:40:05 +00:00
|
|
|
return std::make_unique<ScreenshotCommand>(*type, std::move(output), this);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ScreenFrame::ScreenFrame(wxWindow * parent, wxWindowID id)
|
|
|
|
: wxFrame(parent, id, _("Screen Capture Frame"),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2016-04-11 10:40:13 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#if !defined(__WXMSW__)
|
2016-04-11 10:40:13 +00:00
|
|
|
|
|
|
|
#if !defined(__WXMAC__) // bug1358
|
|
|
|
wxFRAME_TOOL_WINDOW |
|
|
|
|
#endif
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#else
|
2016-04-11 10:40:13 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
wxSTAY_ON_TOP|
|
2016-04-11 10:40:13 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#endif
|
2016-04-11 10:40:13 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX),
|
|
|
|
mContext(&wxGetApp(), GetActiveProject())
|
|
|
|
{
|
|
|
|
mDelayCheckBox = NULL;
|
|
|
|
mDirectoryTextBox = NULL;
|
|
|
|
|
|
|
|
mStatus = CreateStatusBar();
|
|
|
|
mCommand = CreateCommand();
|
|
|
|
|
|
|
|
Populate();
|
|
|
|
|
2011-05-03 12:00:45 +00:00
|
|
|
// Reset the toolbars to a known state.
|
|
|
|
// Note that the audio could be playing.
|
|
|
|
// The monitoring will switch off temporarily
|
|
|
|
// because we've switched monitor mid play.
|
2017-06-22 15:38:50 +00:00
|
|
|
// Bug 383 - Resetting the toolbars is not wanted.
|
|
|
|
// Any that are invisible will be amde visible as/when needed.
|
|
|
|
//mContext.GetProject()->GetToolManager()->Reset();
|
2017-05-14 16:36:18 +00:00
|
|
|
Center();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ScreenFrame::~ScreenFrame()
|
|
|
|
{
|
2017-08-07 20:11:20 +00:00
|
|
|
if (this == mFrame)
|
|
|
|
mFrame = nullptr;
|
|
|
|
else
|
|
|
|
// There should only be one!
|
|
|
|
wxASSERT(false);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScreenFrame::Populate()
|
|
|
|
{
|
|
|
|
ShuttleGui S(this, eIsCreating);
|
|
|
|
PopulateOrExchange(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScreenFrame::PopulateOrExchange(ShuttleGui & S)
|
|
|
|
{
|
|
|
|
wxPanel *p = S.StartPanel();
|
|
|
|
{
|
|
|
|
S.SetBorder(3);
|
|
|
|
|
|
|
|
S.StartStatic(_("Choose location to save files"));
|
|
|
|
{
|
|
|
|
S.StartMultiColumn(3, wxEXPAND);
|
|
|
|
{
|
|
|
|
S.SetStretchyCol(1);
|
|
|
|
|
|
|
|
wxString dir =
|
|
|
|
gPrefs->Read(wxT("/ScreenshotPath"),
|
|
|
|
wxFileName::GetHomeDir());
|
|
|
|
mDirectoryTextBox =
|
|
|
|
S.Id(IdDirectory).AddTextBox(_("Save images to:"),
|
|
|
|
dir, 30);
|
|
|
|
S.Id(IdDirChoose).AddButton(_("Choose..."));
|
|
|
|
}
|
|
|
|
S.EndMultiColumn();
|
|
|
|
}
|
|
|
|
S.EndStatic();
|
|
|
|
|
|
|
|
S.StartStatic(_("Capture entire window or screen"));
|
|
|
|
{
|
|
|
|
S.StartHorizontalLay();
|
|
|
|
{
|
|
|
|
S.Id(IdMainWindowSmall).AddButton(_("Resize Small"));
|
|
|
|
S.Id(IdMainWindowLarge).AddButton(_("Resize Large"));
|
2012-03-20 15:36:02 +00:00
|
|
|
/* i18n-hint: Bkgnd is short for background and appears on a small button
|
|
|
|
* It is OK to just translate this item as if it said 'Blue' */
|
2016-02-13 23:06:49 +00:00
|
|
|
wxASSERT(p); // To justify safenew
|
|
|
|
mBlue = safenew wxToggleButton(p,
|
2010-01-23 19:44:49 +00:00
|
|
|
IdToggleBackgroundBlue,
|
|
|
|
_("Blue Bkgnd"));
|
|
|
|
S.AddWindow(mBlue);
|
2012-03-20 15:36:02 +00:00
|
|
|
/* i18n-hint: Bkgnd is short for background and appears on a small button
|
|
|
|
* It is OK to just translate this item as if it said 'White' */
|
2016-02-13 23:06:49 +00:00
|
|
|
mWhite = safenew wxToggleButton(p,
|
2010-01-23 19:44:49 +00:00
|
|
|
IdToggleBackgroundWhite,
|
|
|
|
_("White Bkgnd"));
|
|
|
|
S.AddWindow(mWhite);
|
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
|
|
|
|
S.StartHorizontalLay();
|
|
|
|
{
|
|
|
|
S.Id(IdCaptureWindowContents).AddButton(_("Capture Window Only"));
|
|
|
|
S.Id(IdCaptureFullWindow).AddButton(_("Capture Full Window"));
|
|
|
|
S.Id(IdCaptureWindowPlus).AddButton(_("Capture Window Plus"));
|
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
|
|
|
|
S.StartHorizontalLay();
|
|
|
|
{
|
|
|
|
S.Id(IdCaptureFullScreen).AddButton(_("Capture Full Screen"));
|
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
|
|
|
|
S.StartHorizontalLay();
|
|
|
|
{
|
|
|
|
mDelayCheckBox = S.Id(IdDelayCheckBox).AddCheckBox
|
|
|
|
(_("Wait 5 seconds and capture frontmost window/dialog"),
|
|
|
|
_("false"));
|
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
}
|
|
|
|
S.EndStatic();
|
|
|
|
|
|
|
|
S.StartStatic(_("Capture part of a project window"));
|
|
|
|
{
|
|
|
|
S.StartHorizontalLay();
|
|
|
|
{
|
|
|
|
S.Id(IdCaptureToolbars).AddButton(_("All Toolbars"));
|
2017-06-02 22:52:53 +00:00
|
|
|
#ifdef EXPERIMENTAL_DOCS_AUTOMATION
|
2017-03-20 17:06:29 +00:00
|
|
|
S.Id(IdCaptureMenus).AddButton(_("All Menus"));
|
2017-06-02 22:52:53 +00:00
|
|
|
S.Id(IdCaptureEffects).AddButton(_("All Effects"));
|
2017-06-07 14:58:06 +00:00
|
|
|
S.Id(IdCapturePreferences).AddButton(_("All Preferences"));
|
2017-06-02 22:52:53 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
|
|
|
|
S.StartHorizontalLay();
|
|
|
|
{
|
2010-01-23 19:44:49 +00:00
|
|
|
S.Id(IdCaptureSelectionBar).AddButton(_("SelectionBar"));
|
2017-06-10 20:32:04 +00:00
|
|
|
S.Id(IdCaptureSpectralSelection).AddButton(_("Spectral Selection"));
|
2010-01-23 19:44:49 +00:00
|
|
|
S.Id(IdCaptureTools).AddButton(_("Tools"));
|
2010-11-16 01:18:39 +00:00
|
|
|
S.Id(IdCaptureTransport).AddButton(_("Transport"));
|
2017-06-10 20:32:04 +00:00
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
|
|
|
|
S.StartHorizontalLay();
|
|
|
|
{
|
2017-06-02 22:52:53 +00:00
|
|
|
S.Id(IdCaptureMixer).AddButton(_("Mixer"));
|
|
|
|
S.Id(IdCaptureMeter).AddButton(_("Meter"));
|
2017-06-10 20:32:04 +00:00
|
|
|
S.Id(IdCapturePlayMeter).AddButton(_("Play Meter"));
|
|
|
|
S.Id(IdCaptureRecordMeter).AddButton(_("Record Meter"));
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
|
|
|
|
S.StartHorizontalLay();
|
|
|
|
{
|
|
|
|
S.Id(IdCaptureEdit).AddButton(_("Edit"));
|
|
|
|
S.Id(IdCaptureDevice).AddButton(_("Device"));
|
|
|
|
S.Id(IdCaptureTranscription).AddButton(_("Transcription"));
|
2017-06-10 20:32:04 +00:00
|
|
|
S.Id(IdCaptureScrub).AddButton(_("Scrub"));
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
|
|
|
|
S.StartHorizontalLay();
|
|
|
|
{
|
|
|
|
S.Id(IdCaptureTrackPanel).AddButton(_("Track Panel"));
|
|
|
|
S.Id(IdCaptureRuler).AddButton(_("Ruler"));
|
|
|
|
S.Id(IdCaptureTracks).AddButton(_("Tracks"));
|
|
|
|
S.Id(IdCaptureFirstTrack).AddButton(_("First Track"));
|
|
|
|
S.Id(IdCaptureSecondTrack).AddButton(_("Second Track"));
|
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
}
|
|
|
|
S.EndStatic();
|
|
|
|
|
|
|
|
S.StartStatic(_("Scale"));
|
|
|
|
{
|
|
|
|
S.StartHorizontalLay();
|
|
|
|
{
|
|
|
|
S.Id(IdOneSec).AddButton(_("One Sec"));
|
|
|
|
S.Id(IdTenSec).AddButton(_("Ten Sec"));
|
|
|
|
S.Id(IdOneMin).AddButton(_("One Min"));
|
|
|
|
S.Id(IdFiveMin).AddButton(_("Five Min"));
|
|
|
|
S.Id(IdOneHour).AddButton(_("One Hour"));
|
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
|
|
|
|
S.StartHorizontalLay();
|
|
|
|
{
|
|
|
|
S.Id(IdShortTracks).AddButton(_("Short Tracks"));
|
|
|
|
S.Id(IdMedTracks).AddButton(_("Medium Tracks"));
|
|
|
|
S.Id(IdTallTracks).AddButton(_("Tall Tracks"));
|
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
}
|
|
|
|
S.EndStatic();
|
|
|
|
}
|
|
|
|
S.EndPanel();
|
|
|
|
|
|
|
|
Layout();
|
2015-07-31 11:45:57 +00:00
|
|
|
GetSizer()->Fit(this);
|
2010-01-23 19:44:49 +00:00
|
|
|
SetMinSize(GetSize());
|
|
|
|
|
|
|
|
int top = 0;
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
// Allow for Mac menu bar
|
|
|
|
top += 20;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int width, height;
|
|
|
|
GetSize(&width, &height);
|
|
|
|
int displayWidth, displayHeight;
|
|
|
|
wxDisplaySize(&displayWidth, &displayHeight);
|
|
|
|
|
|
|
|
if (width > 100) {
|
|
|
|
Move(displayWidth - width - 16, top + 16);
|
|
|
|
}
|
|
|
|
else {
|
2014-06-03 20:30:19 +00:00
|
|
|
CentreOnParent();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2015-05-16 22:57:01 +00:00
|
|
|
SetIcon(mContext.GetProject()->GetIcon());
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ScreenFrame::ProcessEvent(wxEvent & e)
|
|
|
|
{
|
|
|
|
int id = e.GetId();
|
|
|
|
|
2017-08-14 17:53:44 +00:00
|
|
|
// If split into two parts to make for easier breakpoint
|
|
|
|
// when testing timer.
|
2010-01-23 19:44:49 +00:00
|
|
|
if (mDelayCheckBox &&
|
|
|
|
mDelayCheckBox->GetValue() &&
|
|
|
|
e.IsCommandEvent() &&
|
2017-08-14 17:53:44 +00:00
|
|
|
e.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED)
|
|
|
|
{
|
|
|
|
if( id >= IdAllDelayedEvents && id <= IdLastDelayedEvent &&
|
2010-01-23 19:44:49 +00:00
|
|
|
e.GetEventObject() != NULL) {
|
2017-08-14 17:53:44 +00:00
|
|
|
// safenew because it's a one-shot that deletes itself
|
|
|
|
ScreenFrameTimer *timer = safenew ScreenFrameTimer(this, e);
|
|
|
|
timer->Start(5000, true);
|
|
|
|
return true;
|
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (e.IsCommandEvent() && e.GetEventObject() == NULL) {
|
|
|
|
e.SetEventObject(this);
|
|
|
|
}
|
|
|
|
return wxFrame::ProcessEvent(e);
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnCloseWindow(wxCloseEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnUIUpdate(wxUpdateUIEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
#ifdef __WXMAC__
|
2015-04-19 07:05:17 +00:00
|
|
|
wxTopLevelWindow *top = mCommand->GetFrontWindow(GetActiveProject());
|
2010-01-23 19:44:49 +00:00
|
|
|
bool needupdate = false;
|
|
|
|
bool enable = false;
|
|
|
|
|
|
|
|
if ((!top || top->IsIconized()) && mDirectoryTextBox->IsEnabled()) {
|
|
|
|
needupdate = true;
|
|
|
|
enable = false;
|
|
|
|
}
|
|
|
|
else if ((top && !top->IsIconized()) && !mDirectoryTextBox->IsEnabled()) {
|
|
|
|
needupdate = true;
|
|
|
|
enable = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needupdate) {
|
|
|
|
for (int i = IdMainWindowSmall; i < IdLastDelayedEvent; i++) {
|
|
|
|
wxWindow *w = wxWindow::FindWindowById(i, this);
|
|
|
|
if (w) {
|
|
|
|
w->Enable(enable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnDirChoose(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
wxString current = mDirectoryTextBox->GetValue();
|
|
|
|
|
2017-10-12 19:23:52 +00:00
|
|
|
wxDirDialogWrapper dlog(this,
|
2010-01-23 19:44:49 +00:00
|
|
|
_("Choose a location to save screenshot images"),
|
|
|
|
current);
|
|
|
|
|
|
|
|
dlog.ShowModal();
|
|
|
|
if (dlog.GetPath() != wxT("")) {
|
|
|
|
wxFileName tmpDirPath;
|
|
|
|
tmpDirPath.AssignDir(dlog.GetPath());
|
|
|
|
wxString path = tmpDirPath.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR);
|
|
|
|
mDirectoryTextBox->SetValue(path);
|
|
|
|
gPrefs->Write(wxT("/ScreenshotPath"), path);
|
2012-08-02 06:03:19 +00:00
|
|
|
gPrefs->Flush();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnToggleBackgroundBlue(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
mWhite->SetValue(false);
|
|
|
|
mCommand->SetParameter(wxT("Background"),
|
|
|
|
mBlue->GetValue() ? wxT("Blue") : wxT("None"));
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnToggleBackgroundWhite(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
mBlue->SetValue(false);
|
|
|
|
mCommand->SetParameter(wxT("Background"),
|
|
|
|
mWhite->GetValue() ? wxT("White") : wxT("None"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScreenFrame::SizeMainWindow(int w, int h)
|
|
|
|
{
|
|
|
|
int top = 20;
|
|
|
|
|
2015-05-16 22:57:01 +00:00
|
|
|
mContext.GetProject()->Maximize(false);
|
|
|
|
mContext.GetProject()->SetSize(16, 16 + top, w, h);
|
2017-06-25 10:21:24 +00:00
|
|
|
//Bug383 - Toolbar Resets not wanted.
|
|
|
|
//mContext.GetProject()->GetToolManager()->Reset();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnMainWindowSmall(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
SizeMainWindow(680, 450);
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnMainWindowLarge(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
SizeMainWindow(900, 600);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScreenFrame::DoCapture(wxString captureMode)
|
|
|
|
{
|
|
|
|
Hide();
|
|
|
|
mCommand->SetParameter(wxT("FilePath"), mDirectoryTextBox->GetValue());
|
|
|
|
|
|
|
|
mCommand->SetParameter(wxT("CaptureMode"), captureMode);
|
|
|
|
if (!mCommand->Apply(mContext))
|
2015-06-02 14:18:12 +00:00
|
|
|
mStatus->SetStatusText(wxT("Capture failed!"), mainStatusBarField);
|
2010-01-23 19:44:49 +00:00
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
2017-06-10 20:32:04 +00:00
|
|
|
void ScreenFrame::OnCaptureSomething(wxCommandEvent & event)
|
|
|
|
{
|
|
|
|
int i = event.GetId() - IdCaptureFirst;
|
|
|
|
|
|
|
|
wxArrayString Names;
|
|
|
|
|
2017-08-14 17:53:44 +00:00
|
|
|
Names.Add(wxT("menus"));
|
|
|
|
Names.Add(wxT("effects"));
|
|
|
|
Names.Add(wxT("preferences"));
|
|
|
|
|
|
|
|
Names.Add(wxT("toolbars"));
|
2017-06-10 20:32:04 +00:00
|
|
|
Names.Add(wxT("window"));
|
|
|
|
Names.Add(wxT("fullwindow"));
|
|
|
|
Names.Add(wxT("windowplus"));
|
|
|
|
Names.Add(wxT("fullscreen"));
|
|
|
|
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"));
|
|
|
|
|
|
|
|
DoCapture(Names[i]);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScreenFrame::TimeZoom(double seconds)
|
|
|
|
{
|
|
|
|
int width, height;
|
2015-05-16 22:57:01 +00:00
|
|
|
mContext.GetProject()->GetClientSize(&width, &height);
|
2015-04-19 23:26:36 +00:00
|
|
|
mContext.GetProject()->mViewInfo.SetZoom((0.75 * width) / seconds);
|
2015-05-16 22:57:01 +00:00
|
|
|
mContext.GetProject()->RedrawProject();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnOneSec(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
TimeZoom(1.0);
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnTenSec(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
TimeZoom(10.0);
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnOneMin(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
TimeZoom(60.0);
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnFiveMin(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
TimeZoom(300.0);
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnOneHour(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
TimeZoom(3600.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScreenFrame::SizeTracks(int h)
|
|
|
|
{
|
2015-05-16 22:57:01 +00:00
|
|
|
TrackListIterator iter(mContext.GetProject()->GetTracks());
|
2010-01-23 19:44:49 +00:00
|
|
|
for (Track * t = iter.First(); t; t = iter.Next()) {
|
|
|
|
if (t->GetKind() == Track::Wave) {
|
|
|
|
if (t->GetLink()) {
|
|
|
|
t->SetHeight(h);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
t->SetHeight(h*2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-16 22:57:01 +00:00
|
|
|
mContext.GetProject()->RedrawProject();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnShortTracks(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-05-16 22:57:01 +00:00
|
|
|
TrackListIterator iter(mContext.GetProject()->GetTracks());
|
2010-01-23 19:44:49 +00:00
|
|
|
for (Track * t = iter.First(); t; t = iter.Next()) {
|
|
|
|
if (t->GetKind() == Track::Wave) {
|
|
|
|
t->SetHeight(t->GetMinimizedHeight());
|
|
|
|
}
|
|
|
|
}
|
2015-05-16 22:57:01 +00:00
|
|
|
mContext.GetProject()->RedrawProject();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnMedTracks(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
SizeTracks(60);
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ScreenFrame::OnTallTracks(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
SizeTracks(85);
|
|
|
|
}
|