2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
HistoryWindow.cpp
|
|
|
|
|
|
|
|
Joshua Haberman
|
|
|
|
Leland Lucius
|
|
|
|
|
|
|
|
*******************************************************************//*!
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
\class HistoryDialog
|
2014-06-03 20:30:19 +00:00
|
|
|
\brief Works with UndoManager to allow user to see descriptions of
|
|
|
|
and undo previous commands. Also allows you to selectively clear the
|
2010-01-23 19:44:49 +00:00
|
|
|
undo memory so as to free up space.
|
|
|
|
|
|
|
|
*//*******************************************************************/
|
|
|
|
|
|
|
|
#include "Audacity.h"
|
2018-11-10 19:47:12 +00:00
|
|
|
#include "HistoryWindow.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-11-22 18:16:03 +00:00
|
|
|
#include <wx/app.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/defs.h>
|
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/dialog.h>
|
|
|
|
#include <wx/event.h>
|
2019-06-08 14:14:02 +00:00
|
|
|
#include <wx/frame.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/imaglist.h>
|
|
|
|
#include <wx/intl.h>
|
|
|
|
#include <wx/listctrl.h>
|
|
|
|
#include <wx/settings.h>
|
2018-11-14 20:23:25 +00:00
|
|
|
#include <wx/spinctrl.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
|
2015-08-23 23:36:40 +00:00
|
|
|
#include "AudioIO.h"
|
2019-04-25 20:49:31 +00:00
|
|
|
#include "Clipboard.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "../images/Arrow.xpm"
|
The fabled realtime effects...
I've made it where you can enable and disable via experimentals:
EXPERIMENTAL_REALTIME_EFFECTS
EXPERIMENTAL_EFFECTS_RACK
You will notice that, as of now, the only effects currently set up for
realtime are VSTs. Now that this is in, I will start converting the
rest.
As I start to convert the effects, the astute of you may notice that
they no longer directly access tracks or any "internal" Audacity
objects. This isolates the effects from changes in Audacity and makes
it much easier to add new ones.
Anyway, all 3 platforms can now display VST effects in graphical mode.
Yes, that means Linux too. There are quite a few VSTs for Linux if
you search for them.
The so-called "rack" definitely needs some discussion, work, and attention
from someone much better at graphics than me. I'm not really sure it should
stay in as-is. I'd originally planned for it to be simply a utility window
where you can store your (preconfigured) favorite effects. It should probably
revert back to that idea.
You may notice that this DOES include the API work I did. The realtime effects
were too tied to it and I didn't want to redo the whole thing. As I mentioned
elsewhere, the API stuff may or may not be very future proof.
So, let the critter complaints commence. I absolute KNOW there will be some.
(I know I'll be hearing from the Linux peeps pretty darn quickly. ;-))
2014-10-26 03:24:10 +00:00
|
|
|
#include "../images/Empty9x16.xpm"
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "UndoManager.h"
|
2019-06-08 14:14:02 +00:00
|
|
|
#include "Project.h"
|
2019-06-06 13:55:34 +00:00
|
|
|
#include "ProjectHistory.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "ShuttleGui.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ID_AVAIL = 1000,
|
2015-05-30 20:56:46 +00:00
|
|
|
ID_TOTAL,
|
2010-01-23 19:44:49 +00:00
|
|
|
ID_LEVELS,
|
2016-11-07 16:25:27 +00:00
|
|
|
ID_DISCARD,
|
|
|
|
ID_DISCARD_CLIPBOARD
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
BEGIN_EVENT_TABLE(HistoryDialog, wxDialogWrapper)
|
|
|
|
EVT_SIZE(HistoryDialog::OnSize)
|
|
|
|
EVT_CLOSE(HistoryDialog::OnCloseWindow)
|
|
|
|
EVT_LIST_ITEM_SELECTED(wxID_ANY, HistoryDialog::OnItemSelected)
|
|
|
|
EVT_BUTTON(ID_DISCARD, HistoryDialog::OnDiscard)
|
|
|
|
EVT_BUTTON(ID_DISCARD_CLIPBOARD, HistoryDialog::OnDiscardClipboard)
|
2010-01-23 19:44:49 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
HistoryDialog::HistoryDialog(AudacityProject *parent, UndoManager *manager):
|
2019-12-08 05:25:47 +00:00
|
|
|
wxDialogWrapper(FindProjectFrame( parent ), wxID_ANY, XO("History"),
|
2010-01-23 19:44:49 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
|
|
|
|
{
|
2019-12-08 05:25:47 +00:00
|
|
|
SetName();
|
2015-05-12 13:29:27 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
mManager = manager;
|
|
|
|
mProject = parent;
|
|
|
|
mSelected = 0;
|
2015-08-23 23:36:40 +00:00
|
|
|
mAudioIOBusy = false;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-08-10 05:34:44 +00:00
|
|
|
auto imageList = std::make_unique<wxImageList>(9, 16);
|
The fabled realtime effects...
I've made it where you can enable and disable via experimentals:
EXPERIMENTAL_REALTIME_EFFECTS
EXPERIMENTAL_EFFECTS_RACK
You will notice that, as of now, the only effects currently set up for
realtime are VSTs. Now that this is in, I will start converting the
rest.
As I start to convert the effects, the astute of you may notice that
they no longer directly access tracks or any "internal" Audacity
objects. This isolates the effects from changes in Audacity and makes
it much easier to add new ones.
Anyway, all 3 platforms can now display VST effects in graphical mode.
Yes, that means Linux too. There are quite a few VSTs for Linux if
you search for them.
The so-called "rack" definitely needs some discussion, work, and attention
from someone much better at graphics than me. I'm not really sure it should
stay in as-is. I'd originally planned for it to be simply a utility window
where you can store your (preconfigured) favorite effects. It should probably
revert back to that idea.
You may notice that this DOES include the API work I did. The realtime effects
were too tied to it and I didn't want to redo the whole thing. As I mentioned
elsewhere, the API stuff may or may not be very future proof.
So, let the critter complaints commence. I absolute KNOW there will be some.
(I know I'll be hearing from the Linux peeps pretty darn quickly. ;-))
2014-10-26 03:24:10 +00:00
|
|
|
imageList->Add(wxIcon(empty9x16_xpm));
|
2010-01-23 19:44:49 +00:00
|
|
|
imageList->Add(wxIcon(arrow_xpm));
|
|
|
|
|
|
|
|
//------------------------- Main section --------------------
|
|
|
|
// Construct the GUI.
|
|
|
|
ShuttleGui S(this, eIsCreating);
|
|
|
|
|
|
|
|
S.SetBorder(5);
|
|
|
|
S.StartVerticalLay(true);
|
|
|
|
{
|
2015-05-30 20:56:46 +00:00
|
|
|
S.StartStatic(_("&Manage History"), 1);
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2018-02-03 00:22:07 +00:00
|
|
|
mList = S
|
2018-01-31 20:31:22 +00:00
|
|
|
.MinSize()
|
2018-02-03 00:22:07 +00:00
|
|
|
.AddListControlReportMode(
|
|
|
|
{ { _("Action"), wxLIST_FORMAT_LEFT, 260 },
|
|
|
|
{ _("Reclaimable Space"), wxLIST_FORMAT_LEFT, 125 } },
|
|
|
|
wxLC_SINGLE_SEL
|
|
|
|
);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
//Assign rather than set the image list, so that it is deleted later.
|
2016-08-10 05:34:44 +00:00
|
|
|
// AssignImageList takes ownership
|
|
|
|
mList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
S.StartMultiColumn(3, wxCENTRE);
|
|
|
|
{
|
2018-01-31 16:31:55 +00:00
|
|
|
mTotal = S.Id(ID_TOTAL)
|
2019-12-06 10:39:07 +00:00
|
|
|
.ConnectRoot(wxEVT_KEY_DOWN, &HistoryDialog::OnChar)
|
2018-01-31 16:31:55 +00:00
|
|
|
.AddTextBox(_("&Total space used"), wxT("0"), 10);
|
2017-09-28 01:20:14 +00:00
|
|
|
S.AddVariableText( {} )->Hide();
|
2015-05-30 20:56:46 +00:00
|
|
|
|
2018-01-31 16:31:55 +00:00
|
|
|
mAvail = S.Id(ID_AVAIL)
|
2019-12-06 10:39:07 +00:00
|
|
|
.ConnectRoot(wxEVT_KEY_DOWN, &HistoryDialog::OnChar)
|
2018-01-31 16:31:55 +00:00
|
|
|
.AddTextBox(_("&Undo levels available"), wxT("0"), 10);
|
2017-09-28 01:20:14 +00:00
|
|
|
S.AddVariableText( {} )->Hide();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-07-19 11:27:14 +00:00
|
|
|
S.AddPrompt(_("&Levels to discard"));
|
2017-10-20 16:43:20 +00:00
|
|
|
mLevels = safenew wxSpinCtrl(S.GetParent(),
|
2010-01-23 19:44:49 +00:00
|
|
|
ID_LEVELS,
|
|
|
|
wxT("1"),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
|
|
|
wxSP_ARROW_KEYS,
|
2011-08-26 23:44:43 +00:00
|
|
|
0,
|
2010-01-23 19:44:49 +00:00
|
|
|
mManager->GetCurrentState() - 1,
|
2011-08-26 23:44:43 +00:00
|
|
|
0);
|
2010-01-23 19:44:49 +00:00
|
|
|
S.AddWindow(mLevels);
|
2012-03-20 15:36:02 +00:00
|
|
|
/* i18n-hint: (verb)*/
|
2010-01-23 19:44:49 +00:00
|
|
|
mDiscard = S.Id(ID_DISCARD).AddButton(_("&Discard"));
|
2016-11-07 16:25:27 +00:00
|
|
|
|
2018-01-31 16:31:55 +00:00
|
|
|
mClipboard = S
|
2019-12-06 10:39:07 +00:00
|
|
|
.ConnectRoot(wxEVT_KEY_DOWN, &HistoryDialog::OnChar)
|
2018-01-31 16:31:55 +00:00
|
|
|
.AddTextBox(_("Clipboard space used"), wxT("0"), 10);
|
2016-11-07 16:25:27 +00:00
|
|
|
S.Id(ID_DISCARD_CLIPBOARD).AddButton(_("Discard"));
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
S.EndMultiColumn();
|
|
|
|
}
|
|
|
|
S.EndStatic();
|
|
|
|
|
2015-07-30 07:02:59 +00:00
|
|
|
S.StartHorizontalLay(wxALIGN_RIGHT, false);
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
S.SetBorder(10);
|
2019-11-19 16:33:37 +00:00
|
|
|
S.Id(wxID_OK).AddButton(_("&OK"), wxALIGN_CENTER, true);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
}
|
|
|
|
S.EndVerticalLay();
|
|
|
|
// ----------------------- End of main section --------------
|
|
|
|
|
|
|
|
Fit();
|
|
|
|
SetMinSize(GetSize());
|
|
|
|
mList->SetColumnWidth(0, mList->GetClientSize().x - mList->GetColumnWidth(1));
|
|
|
|
mList->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
2015-08-23 23:36:40 +00:00
|
|
|
|
2018-02-12 23:09:20 +00:00
|
|
|
wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK,
|
2019-12-06 10:39:07 +00:00
|
|
|
&HistoryDialog::OnAudioIO,
|
2015-08-23 23:36:40 +00:00
|
|
|
this);
|
|
|
|
|
2018-02-12 23:09:20 +00:00
|
|
|
wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
|
2019-12-06 10:39:07 +00:00
|
|
|
&HistoryDialog::OnAudioIO,
|
2015-08-23 23:36:40 +00:00
|
|
|
this);
|
2018-02-17 20:31:18 +00:00
|
|
|
|
2019-04-25 20:49:31 +00:00
|
|
|
Clipboard::Get().Bind(
|
2019-12-06 10:39:07 +00:00
|
|
|
EVT_CLIPBOARD_CHANGE, &HistoryDialog::UpdateDisplay, this);
|
|
|
|
parent->Bind(EVT_UNDO_PUSHED, &HistoryDialog::UpdateDisplay, this);
|
|
|
|
parent->Bind(EVT_UNDO_MODIFIED, &HistoryDialog::UpdateDisplay, this);
|
|
|
|
parent->Bind(EVT_UNDO_OR_REDO, &HistoryDialog::UpdateDisplay, this);
|
|
|
|
parent->Bind(EVT_UNDO_RESET, &HistoryDialog::UpdateDisplay, this);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
void HistoryDialog::OnChar( wxEvent& )
|
2018-01-31 16:31:55 +00:00
|
|
|
{
|
|
|
|
// ignore it
|
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
void HistoryDialog::OnAudioIO(wxCommandEvent& evt)
|
2015-08-23 23:36:40 +00:00
|
|
|
{
|
|
|
|
evt.Skip();
|
|
|
|
|
|
|
|
if (evt.GetInt() != 0)
|
|
|
|
mAudioIOBusy = true;
|
|
|
|
else
|
|
|
|
mAudioIOBusy = false;
|
|
|
|
|
|
|
|
mDiscard->Enable(!mAudioIOBusy);
|
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
void HistoryDialog::UpdateDisplay(wxEvent& e)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2018-02-17 20:31:18 +00:00
|
|
|
e.Skip();
|
2010-01-23 19:44:49 +00:00
|
|
|
if(IsShown())
|
|
|
|
DoUpdate();
|
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
bool HistoryDialog::Show( bool show )
|
2019-04-25 21:52:22 +00:00
|
|
|
{
|
|
|
|
if ( show && !IsShown())
|
|
|
|
DoUpdate();
|
2019-05-27 13:11:52 +00:00
|
|
|
return wxDialogWrapper::Show( show );
|
2019-04-25 21:52:22 +00:00
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
void HistoryDialog::DoUpdate()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2015-04-07 11:20:50 +00:00
|
|
|
mManager->CalculateSpaceUsage();
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
mList->DeleteAllItems();
|
|
|
|
|
2015-05-30 20:56:46 +00:00
|
|
|
wxLongLong_t total = 0;
|
2010-01-23 19:44:49 +00:00
|
|
|
mSelected = mManager->GetCurrentState() - 1;
|
|
|
|
for (i = 0; i < (int)mManager->GetNumStates(); i++) {
|
|
|
|
wxString desc, size;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2015-05-30 20:56:46 +00:00
|
|
|
total += mManager->GetLongDescription(i + 1, &desc, &size);
|
2010-01-23 19:44:49 +00:00
|
|
|
mList->InsertItem(i, desc, i == mSelected ? 1 : 0);
|
|
|
|
mList->SetItem(i, 1, size);
|
|
|
|
}
|
|
|
|
|
2015-05-30 20:56:46 +00:00
|
|
|
mTotal->SetValue(Internat::FormatSize(total));
|
|
|
|
|
2016-11-07 16:25:27 +00:00
|
|
|
auto clipboardUsage = mManager->GetClipboardSpaceUsage();
|
|
|
|
mClipboard->SetValue(Internat::FormatSize(clipboardUsage));
|
|
|
|
FindWindowById(ID_DISCARD_CLIPBOARD)->Enable(clipboardUsage > 0);
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
mList->EnsureVisible(mSelected);
|
|
|
|
|
|
|
|
mList->SetItemState(mSelected,
|
|
|
|
wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
|
|
|
|
wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
|
|
|
|
|
|
|
|
UpdateLevels();
|
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
void HistoryDialog::UpdateLevels()
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
wxWindow *focus;
|
|
|
|
int value = mLevels->GetValue();
|
|
|
|
|
|
|
|
if (value > mSelected) {
|
|
|
|
value = mSelected;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value == 0) {
|
|
|
|
value = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mLevels->SetValue(value);
|
|
|
|
mLevels->SetRange(1, mSelected);
|
|
|
|
|
|
|
|
mAvail->SetValue(wxString::Format(wxT("%d"), mSelected));
|
|
|
|
|
|
|
|
focus = FindFocus();
|
|
|
|
if ((focus == mDiscard || focus == mLevels) && mSelected == 0) {
|
|
|
|
mList->SetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
mLevels->Enable(mSelected > 0);
|
2018-01-14 23:55:16 +00:00
|
|
|
mDiscard->Enable(!mAudioIOBusy && mSelected > 0);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
void HistoryDialog::OnDiscard(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
int i = mLevels->GetValue();
|
|
|
|
|
|
|
|
mSelected -= i;
|
|
|
|
mManager->RemoveStates(i);
|
2019-06-06 13:55:34 +00:00
|
|
|
ProjectHistory::Get( *mProject ).SetStateTo(mSelected + 1);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
while(--i >= 0)
|
|
|
|
mList->DeleteItem(i);
|
|
|
|
|
2015-06-16 00:42:42 +00:00
|
|
|
DoUpdate();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
void HistoryDialog::OnDiscardClipboard(wxCommandEvent & WXUNUSED(event))
|
2016-11-07 16:25:27 +00:00
|
|
|
{
|
2019-04-25 20:49:31 +00:00
|
|
|
Clipboard::Get().Clear();
|
2016-11-07 16:25:27 +00:00
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
void HistoryDialog::OnItemSelected(wxListEvent &event)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-08-23 23:36:40 +00:00
|
|
|
if (mAudioIOBusy) {
|
|
|
|
mList->SetItemState(mSelected,
|
|
|
|
wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
|
|
|
|
wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
int selected = event.GetIndex();
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < mList->GetItemCount(); i++) {
|
|
|
|
mList->SetItemImage(i, 0);
|
|
|
|
if (i > selected)
|
|
|
|
mList->SetItemTextColour(i, *wxLIGHT_GREY);
|
|
|
|
else
|
|
|
|
mList->SetItemTextColour(i, mList->GetTextColour());
|
|
|
|
}
|
|
|
|
mList->SetItemImage(selected, 1);
|
|
|
|
|
|
|
|
// Do not do a SetStateTo() if we're not actually changing the selected
|
|
|
|
// entry. Doing so can cause unnecessary delays upon initial load or while
|
|
|
|
// clicking the same entry over and over.
|
|
|
|
if (selected != mSelected) {
|
2019-06-06 13:55:34 +00:00
|
|
|
ProjectHistory::Get( *mProject ).SetStateTo(selected + 1);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
mSelected = selected;
|
|
|
|
|
|
|
|
UpdateLevels();
|
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
void HistoryDialog::OnCloseWindow(wxCloseEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
this->Show(false);
|
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
void HistoryDialog::OnSize(wxSizeEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
Layout();
|
|
|
|
mList->SetColumnWidth(0, mList->GetClientSize().x - mList->GetColumnWidth(1));
|
2011-12-22 22:36:20 +00:00
|
|
|
if (mList->GetItemCount() > 0)
|
|
|
|
mList->EnsureVisible(mSelected);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|