2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
HistoryWindow.cpp
|
|
|
|
|
|
|
|
Joshua Haberman
|
|
|
|
Leland Lucius
|
|
|
|
|
|
|
|
*******************************************************************//*!
|
|
|
|
|
|
|
|
\class HistoryWindow
|
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"
|
|
|
|
|
|
|
|
#include <wx/defs.h>
|
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/dialog.h>
|
|
|
|
#include <wx/event.h>
|
|
|
|
#include <wx/imaglist.h>
|
|
|
|
#include <wx/intl.h>
|
|
|
|
#include <wx/listctrl.h>
|
|
|
|
#include <wx/settings.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
|
|
|
|
#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 "HistoryWindow.h"
|
|
|
|
#include "UndoManager.h"
|
|
|
|
#include "Project.h"
|
|
|
|
#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,
|
|
|
|
ID_DISCARD
|
|
|
|
};
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(HistoryWindow, wxDialog)
|
|
|
|
EVT_SIZE(HistoryWindow::OnSize)
|
|
|
|
EVT_CLOSE(HistoryWindow::OnCloseWindow)
|
|
|
|
EVT_LIST_ITEM_SELECTED(wxID_ANY, HistoryWindow::OnItemSelected)
|
|
|
|
EVT_BUTTON(ID_DISCARD, HistoryWindow::OnDiscard)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
|
|
|
|
wxDialog((wxWindow*)parent, wxID_ANY, wxString(_("Undo History")),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
|
|
|
|
{
|
2015-05-12 13:29:27 +00:00
|
|
|
SetName(GetTitle());
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
mManager = manager;
|
|
|
|
mProject = parent;
|
|
|
|
mSelected = 0;
|
|
|
|
|
|
|
|
wxImageList *imageList = new 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
|
|
|
{
|
|
|
|
mList = S.AddListControlReportMode();
|
|
|
|
// Do this BEFORE inserting the columns. On the Mac at least, the
|
|
|
|
// columns are deleted and later InsertItem()s will cause Audacity to crash.
|
|
|
|
mList->SetSingleStyle(wxLC_SINGLE_SEL);
|
|
|
|
mList->InsertColumn(0, _("Action"), wxLIST_FORMAT_LEFT, 300);
|
2015-06-16 00:42:42 +00:00
|
|
|
mList->InsertColumn(1, _("Size"), wxLIST_FORMAT_LEFT, 85);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
//Assign rather than set the image list, so that it is deleted later.
|
|
|
|
mList->AssignImageList(imageList, wxIMAGE_LIST_SMALL);
|
|
|
|
|
|
|
|
S.StartMultiColumn(3, wxCENTRE);
|
|
|
|
{
|
2015-06-16 00:42:42 +00:00
|
|
|
// FIXME: Textbox labels have inconsistent capitalization
|
2015-05-30 20:56:46 +00:00
|
|
|
mTotal = S.Id(ID_TOTAL).AddTextBox(_("&Total space used"), wxT("0"), 10);
|
|
|
|
mTotal->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
|
|
|
|
S.AddVariableText(wxT(""))->Hide();
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
mAvail = S.Id(ID_AVAIL).AddTextBox(_("&Undo Levels Available"), wxT("0"), 10);
|
|
|
|
mAvail->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
|
|
|
|
S.AddVariableText(wxT(""))->Hide();
|
|
|
|
|
2015-05-30 20:56:46 +00:00
|
|
|
S.AddPrompt(_("&Levels To Discard"));
|
2010-01-23 19:44:49 +00:00
|
|
|
mLevels = new wxSpinCtrl(this,
|
|
|
|
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"));
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
S.Id(wxID_OK).AddButton(_("&OK"))->SetDefault();
|
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
}
|
|
|
|
S.EndVerticalLay();
|
|
|
|
// ----------------------- End of main section --------------
|
|
|
|
|
2015-04-07 11:20:50 +00:00
|
|
|
DoUpdate();
|
2010-01-23 19:44:49 +00:00
|
|
|
mList->SetMinSize(mList->GetSize());
|
|
|
|
Fit();
|
|
|
|
SetMinSize(GetSize());
|
|
|
|
mList->SetColumnWidth(0, mList->GetClientSize().x - mList->GetColumnWidth(1));
|
|
|
|
mList->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
|
|
|
}
|
|
|
|
|
|
|
|
HistoryWindow::~HistoryWindow()
|
|
|
|
{
|
|
|
|
mAvail->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(HistoryWindow::OnChar));
|
|
|
|
}
|
|
|
|
|
|
|
|
void HistoryWindow::UpdateDisplay()
|
|
|
|
{
|
|
|
|
if(IsShown())
|
|
|
|
DoUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HistoryWindow::DoUpdate()
|
|
|
|
{
|
|
|
|
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));
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HistoryWindow::UpdateLevels()
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
mDiscard->Enable(mSelected > 0);
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void HistoryWindow::OnDiscard(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
int i = mLevels->GetValue();
|
|
|
|
|
|
|
|
mSelected -= i;
|
|
|
|
mManager->RemoveStates(i);
|
|
|
|
mProject->SetStateTo(mSelected + 1);
|
|
|
|
|
|
|
|
while(--i >= 0)
|
|
|
|
mList->DeleteItem(i);
|
|
|
|
|
2015-06-16 00:42:42 +00:00
|
|
|
DoUpdate();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HistoryWindow::OnItemSelected(wxListEvent &event)
|
|
|
|
{
|
|
|
|
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) {
|
|
|
|
mProject->SetStateTo(selected + 1);
|
|
|
|
}
|
|
|
|
mSelected = selected;
|
|
|
|
|
|
|
|
UpdateLevels();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HistoryWindow::OnCloseWindow(wxCloseEvent & WXUNUSED(event))
|
|
|
|
{
|
|
|
|
this->Show(false);
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void HistoryWindow::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
|
|
|
}
|
|
|
|
|
|
|
|
void HistoryWindow::OnChar(wxKeyEvent &event)
|
|
|
|
{
|
|
|
|
event.Skip(false);
|
|
|
|
return;
|
|
|
|
}
|