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.
|
|
|
|
|
|
|
|
*//*******************************************************************/
|
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
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"
|
2020-02-01 04:44:00 +00:00
|
|
|
#include "CommonCommandFlags.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"
|
2020-07-15 14:26:23 +00:00
|
|
|
#include "ProjectFileIO.h"
|
2019-06-06 13:55:34 +00:00
|
|
|
#include "ProjectHistory.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "ShuttleGui.h"
|
2020-08-02 02:41:49 +00:00
|
|
|
#include "widgets/AudacityMessageBox.h"
|
|
|
|
#include "widgets/HelpSystem.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
ID_AVAIL = 1000,
|
2020-07-15 14:26:23 +00:00
|
|
|
ID_FILESIZE,
|
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,
|
2020-08-02 02:41:49 +00:00
|
|
|
ID_DISCARD_CLIPBOARD,
|
|
|
|
ID_COMPACT
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
BEGIN_EVENT_TABLE(HistoryDialog, wxDialogWrapper)
|
2020-08-05 13:56:44 +00:00
|
|
|
EVT_SHOW(HistoryDialog::OnShow)
|
2019-12-06 10:39:07 +00:00
|
|
|
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)
|
2020-08-02 02:41:49 +00:00
|
|
|
EVT_BUTTON(ID_COMPACT, HistoryDialog::OnCompact)
|
|
|
|
EVT_BUTTON(wxID_HELP, HistoryDialog::OnGetURL)
|
2010-01-23 19:44:49 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2021-02-14 07:25:52 +00:00
|
|
|
#define HistoryTitle XO("History")
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
HistoryDialog::HistoryDialog(AudacityProject *parent, UndoManager *manager):
|
2021-02-14 07:25:52 +00:00
|
|
|
wxDialogWrapper(FindProjectFrame( parent ), wxID_ANY, HistoryTitle,
|
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
|
|
|
|
|
|
|
//------------------------- Main section --------------------
|
|
|
|
// Construct the GUI.
|
|
|
|
ShuttleGui S(this, eIsCreating);
|
2021-02-14 07:25:52 +00:00
|
|
|
Populate(S);
|
|
|
|
|
|
|
|
wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK,
|
|
|
|
&HistoryDialog::OnAudioIO,
|
|
|
|
this);
|
|
|
|
|
|
|
|
wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
|
|
|
|
&HistoryDialog::OnAudioIO,
|
|
|
|
this);
|
|
|
|
|
|
|
|
Clipboard::Get().Bind(
|
|
|
|
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);
|
|
|
|
parent->Bind(EVT_UNDO_PURGE, &HistoryDialog::UpdateDisplay, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HistoryDialog::Populate(ShuttleGui & S)
|
|
|
|
{
|
|
|
|
auto imageList = std::make_unique<wxImageList>(9, 16);
|
|
|
|
imageList->Add(wxIcon(empty9x16_xpm));
|
|
|
|
imageList->Add(wxIcon(arrow_xpm));
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
S.SetBorder(5);
|
|
|
|
S.StartVerticalLay(true);
|
|
|
|
{
|
2019-12-22 19:58:36 +00:00
|
|
|
S.StartStatic(XO("&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()
|
2020-08-05 13:56:44 +00:00
|
|
|
.ConnectRoot(wxEVT_KEY_DOWN, &HistoryDialog::OnListKeyDown)
|
2018-02-03 00:22:07 +00:00
|
|
|
.AddListControlReportMode(
|
2019-12-23 22:57:45 +00:00
|
|
|
{ { XO("Action"), wxLIST_FORMAT_LEFT, 260 },
|
2020-08-04 15:04:44 +00:00
|
|
|
{ XO("Used Space"), wxLIST_FORMAT_LEFT, 125 } },
|
2018-02-03 00:22:07 +00:00
|
|
|
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);
|
|
|
|
{
|
2020-08-05 13:56:44 +00:00
|
|
|
S.AddPrompt(XXO("&Total space used"));
|
|
|
|
mTotal = S.Id(ID_TOTAL).Style(wxTE_READONLY).AddTextBox({}, wxT(""), 10);
|
2017-09-28 01:20:14 +00:00
|
|
|
S.AddVariableText( {} )->Hide();
|
2015-05-30 20:56:46 +00:00
|
|
|
|
2020-08-03 21:40:51 +00:00
|
|
|
#if defined(ALLOW_DISCARD)
|
2020-08-05 13:56:44 +00:00
|
|
|
S.AddPrompt(XXO("&Undo levels available"));
|
|
|
|
mAvail = S.Id(ID_AVAIL).Style(wxTE_READONLY).AddTextBox({}, wxT(""), 10);
|
2017-09-28 01:20:14 +00:00
|
|
|
S.AddVariableText( {} )->Hide();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2020-05-11 15:28:14 +00:00
|
|
|
S.AddPrompt(XXO("&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,
|
2020-07-23 16:17:29 +00:00
|
|
|
mManager->GetCurrentState(),
|
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)*/
|
2020-05-11 15:28:14 +00:00
|
|
|
mDiscard = S.Id(ID_DISCARD).AddButton(XXO("&Discard"));
|
2020-08-03 21:40:51 +00:00
|
|
|
#endif
|
2020-08-05 13:56:44 +00:00
|
|
|
S.AddPrompt(XXO("Clip&board space used"));
|
|
|
|
mClipboard = S.Style(wxTE_READONLY).AddTextBox({}, wxT(""), 10);
|
2020-08-03 21:40:51 +00:00
|
|
|
|
|
|
|
#if defined(ALLOW_DISCARD)
|
2020-08-02 02:41:49 +00:00
|
|
|
S.Id(ID_DISCARD_CLIPBOARD).AddButton(XXO("D&iscard"));
|
2020-08-03 21:40:51 +00:00
|
|
|
#endif
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
S.EndMultiColumn();
|
|
|
|
}
|
|
|
|
S.EndStatic();
|
2020-08-03 21:40:51 +00:00
|
|
|
#if defined(ALLOW_DISCARD)
|
2020-08-02 02:41:49 +00:00
|
|
|
mCompact = safenew wxButton(this, ID_COMPACT, _("&Compact"));
|
|
|
|
S.AddStandardButtons(eOkButton | eHelpButton, mCompact);
|
2020-08-03 21:40:51 +00:00
|
|
|
#else
|
|
|
|
S.AddStandardButtons(eOkButton | eHelpButton);
|
|
|
|
#endif
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
S.EndVerticalLay();
|
|
|
|
// ----------------------- End of main section --------------
|
|
|
|
|
2021-02-14 07:25:52 +00:00
|
|
|
Layout();
|
2010-01-23 19:44:49 +00:00
|
|
|
Fit();
|
|
|
|
SetMinSize(GetSize());
|
|
|
|
mList->SetColumnWidth(0, mList->GetClientSize().x - mList->GetColumnWidth(1));
|
|
|
|
mList->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2020-08-03 21:40:51 +00:00
|
|
|
#if defined(ALLOW_DISCARD)
|
2015-08-23 23:36:40 +00:00
|
|
|
mDiscard->Enable(!mAudioIOBusy);
|
2020-08-02 02:41:49 +00:00
|
|
|
mCompact->Enable(!mAudioIOBusy);
|
2020-08-03 21:40:51 +00:00
|
|
|
#endif
|
2015-08-23 23:36:40 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2020-07-23 16:17:29 +00:00
|
|
|
mSelected = mManager->GetCurrentState();
|
2010-01-23 19:44:49 +00:00
|
|
|
for (i = 0; i < (int)mManager->GetNumStates(); i++) {
|
2020-05-23 10:41:26 +00:00
|
|
|
TranslatableString desc, size;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2020-07-23 16:17:29 +00:00
|
|
|
total += mManager->GetLongDescription(i, &desc, &size);
|
2019-12-08 17:11:31 +00:00
|
|
|
mList->InsertItem(i, desc.Translation(), i == mSelected ? 1 : 0);
|
2020-05-23 10:41:26 +00:00
|
|
|
mList->SetItem(i, 1, size.Translation());
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2020-05-23 10:41:26 +00:00
|
|
|
mTotal->SetValue(Internat::FormatSize(total).Translation());
|
2015-05-30 20:56:46 +00:00
|
|
|
|
2016-11-07 16:25:27 +00:00
|
|
|
auto clipboardUsage = mManager->GetClipboardSpaceUsage();
|
2020-05-23 10:41:26 +00:00
|
|
|
mClipboard->SetValue(Internat::FormatSize(clipboardUsage).Translation());
|
2020-08-03 21:40:51 +00:00
|
|
|
#if defined(ALLOW_DISCARD)
|
2016-11-07 16:25:27 +00:00
|
|
|
FindWindowById(ID_DISCARD_CLIPBOARD)->Enable(clipboardUsage > 0);
|
2020-08-03 21:40:51 +00:00
|
|
|
#endif
|
2016-11-07 16:25:27 +00:00
|
|
|
|
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
|
|
|
{
|
2020-08-03 21:40:51 +00:00
|
|
|
#if defined(ALLOW_DISCARD)
|
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);
|
2020-08-03 21:40:51 +00:00
|
|
|
#endif
|
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;
|
2020-09-06 20:27:19 +00:00
|
|
|
mManager->RemoveStates(0, i);
|
2020-07-23 16:17:29 +00:00
|
|
|
ProjectHistory::Get( *mProject ).SetStateTo(mSelected);
|
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
|
|
|
}
|
|
|
|
|
2020-08-02 02:41:49 +00:00
|
|
|
void HistoryDialog::OnCompact(wxCommandEvent & WXUNUSED(event))
|
|
|
|
{
|
|
|
|
auto &projectFileIO = ProjectFileIO::Get(*mProject);
|
|
|
|
|
|
|
|
projectFileIO.ReopenProject();
|
|
|
|
|
|
|
|
auto baseFile = wxFileName(projectFileIO.GetFileName());
|
|
|
|
auto walFile = wxFileName(projectFileIO.GetFileName() + wxT("-wal"));
|
|
|
|
auto before = baseFile.GetSize() + walFile.GetSize();
|
|
|
|
|
2020-11-18 21:34:21 +00:00
|
|
|
projectFileIO.Compact({}, true);
|
2020-08-02 02:41:49 +00:00
|
|
|
|
|
|
|
auto after = baseFile.GetSize() + walFile.GetSize();
|
|
|
|
|
|
|
|
AudacityMessageBox(
|
|
|
|
XO("Compacting actually freed %s of disk space.")
|
|
|
|
.Format(Internat::FormatSize((before - after).GetValue())),
|
|
|
|
XO("History"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void HistoryDialog::OnGetURL(wxCommandEvent & WXUNUSED(event))
|
|
|
|
{
|
2021-06-06 19:40:11 +00:00
|
|
|
HelpSystem::ShowHelp(this, L"Undo,_Redo_and_History");
|
2020-08-02 02:41:49 +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) {
|
2020-07-23 16:17:29 +00:00
|
|
|
ProjectHistory::Get( *mProject ).SetStateTo(selected);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
mSelected = selected;
|
|
|
|
|
|
|
|
UpdateLevels();
|
|
|
|
}
|
|
|
|
|
2020-08-05 13:56:44 +00:00
|
|
|
void HistoryDialog::OnListKeyDown(wxKeyEvent & event)
|
|
|
|
{
|
|
|
|
switch (event.GetKeyCode())
|
|
|
|
{
|
|
|
|
case WXK_RETURN:
|
|
|
|
// Don't know why wxListCtrls prevent default dialog action,
|
|
|
|
// but they do, so handle it.
|
|
|
|
EmulateButtonClickIfPresent(GetAffirmativeId());
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
event.Skip();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-06 10:39:07 +00:00
|
|
|
void HistoryDialog::OnCloseWindow(wxCloseEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2020-08-05 13:56:44 +00:00
|
|
|
this->Show(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HistoryDialog::OnShow(wxShowEvent & event)
|
|
|
|
{
|
|
|
|
if (event.IsShown())
|
|
|
|
{
|
|
|
|
mList->SetFocus();
|
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2020-02-01 04:44:00 +00:00
|
|
|
|
2021-02-14 07:25:52 +00:00
|
|
|
// PrefsListener implementation
|
|
|
|
void HistoryDialog::UpdatePrefs()
|
|
|
|
{
|
|
|
|
bool shown = IsShown();
|
|
|
|
if (shown) {
|
|
|
|
Show(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetSizer(nullptr);
|
|
|
|
DestroyChildren();
|
|
|
|
|
|
|
|
SetTitle(HistoryTitle);
|
|
|
|
ShuttleGui S(this, eIsCreating);
|
|
|
|
Populate(S);
|
|
|
|
|
|
|
|
if (shown) {
|
|
|
|
Show(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-01 04:44:00 +00:00
|
|
|
// Remaining code hooks this add-on into the application
|
|
|
|
#include "commands/CommandContext.h"
|
|
|
|
#include "commands/CommandManager.h"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// History window attached to each project is built on demand by:
|
|
|
|
AudacityProject::AttachedWindows::RegisteredFactory sHistoryWindowKey{
|
|
|
|
[]( AudacityProject &parent ) -> wxWeakRef< wxWindow > {
|
|
|
|
auto &undoManager = UndoManager::Get( parent );
|
|
|
|
return safenew HistoryDialog( &parent, &undoManager );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Define our extra menu item that invokes that factory
|
|
|
|
struct Handler : CommandHandlerObject {
|
|
|
|
void OnHistory(const CommandContext &context)
|
|
|
|
{
|
|
|
|
auto &project = context.project;
|
|
|
|
|
|
|
|
auto historyWindow = &project.AttachedWindows::Get( sHistoryWindowKey );
|
|
|
|
historyWindow->Show();
|
|
|
|
historyWindow->Raise();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
CommandHandlerObject &findCommandHandler(AudacityProject &) {
|
|
|
|
// Handler is not stateful. Doesn't need a factory registered with
|
|
|
|
// AudacityProject.
|
|
|
|
static Handler instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Register that menu item
|
|
|
|
|
|
|
|
using namespace MenuTable;
|
|
|
|
AttachedItem sAttachment{ wxT("View/Windows"),
|
|
|
|
// History window should be available either for UndoAvailableFlag
|
|
|
|
// or RedoAvailableFlag,
|
|
|
|
// but we can't make the AddItem flags and mask have both,
|
|
|
|
// because they'd both have to be true for the
|
|
|
|
// command to be enabled.
|
|
|
|
// If user has Undone the entire stack, RedoAvailableFlag is on
|
|
|
|
// but UndoAvailableFlag is off.
|
|
|
|
// If user has done things but not Undone anything,
|
|
|
|
// RedoAvailableFlag is off but UndoAvailableFlag is on.
|
|
|
|
// So in either of those cases,
|
|
|
|
// (AudioIONotBusyFlag | UndoAvailableFlag | RedoAvailableFlag) mask
|
|
|
|
// would fail.
|
|
|
|
// The only way to fix this in the current architecture
|
|
|
|
// is to hack in special cases for RedoAvailableFlag
|
|
|
|
// in AudacityProject::UpdateMenus() (ugly)
|
|
|
|
// and CommandManager::HandleCommandEntry() (*really* ugly --
|
|
|
|
// shouldn't know about particular command names and flags).
|
|
|
|
// Here's the hack that would be necessary in
|
|
|
|
// AudacityProject::UpdateMenus(), if somebody decides to do it:
|
|
|
|
// // Because EnableUsingFlags requires all the flag bits match the
|
|
|
|
// // corresponding mask bits,
|
|
|
|
// // "UndoHistory" specifies only
|
|
|
|
// // AudioIONotBusyFlag | UndoAvailableFlag, because that
|
|
|
|
// // covers the majority of cases where it should be enabled.
|
|
|
|
// // If history is not empty but we've Undone the whole stack,
|
|
|
|
// // we also want to enable,
|
|
|
|
// // to show the Redo's on stack.
|
|
|
|
// // "UndoHistory" might already be enabled,
|
|
|
|
// // but add this check for RedoAvailableFlag.
|
|
|
|
// if (flags & RedoAvailableFlag)
|
|
|
|
// GetCommandManager()->Enable(wxT("UndoHistory"), true);
|
|
|
|
// So for now, enable the command regardless of stack.
|
|
|
|
// It will just show empty sometimes.
|
|
|
|
// FOR REDESIGN,
|
|
|
|
// clearly there are some limitations with the flags/mask bitmaps.
|
|
|
|
|
2020-04-05 12:40:15 +00:00
|
|
|
( FinderScope{ findCommandHandler },
|
2020-02-01 04:44:00 +00:00
|
|
|
/* i18n-hint: Clicking this menu item shows the various editing steps
|
|
|
|
that have been taken.*/
|
|
|
|
Command( wxT("UndoHistory"), XXO("&History..."), &Handler::OnHistory,
|
|
|
|
AudioIONotBusyFlag() ) )
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|