25#include <wx/imaglist.h>
26#include <wx/listctrl.h>
27#include <wx/settings.h>
28#include <wx/spinctrl.h>
29#include <wx/stattext.h>
30#include <wx/textctrl.h>
36#include "../images/Arrow.xpm"
37#include "../images/Empty9x16.xpm"
48#include <unordered_set>
56 using Type =
unsigned long long;
97 space.push_back(CalculateUsage(*pTracks, seen));
105 clipboardSpaceUsage = CalculateUsage(
134#define HistoryTitle XO("History")
138 wxDefaultPosition, wxDefaultSize,
139 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
165 auto imageList = std::make_unique<wxImageList>(9, 16);
166 imageList->Add(wxIcon(empty9x16_xpm));
167 imageList->Add(wxIcon(arrow_xpm));
170 S.StartVerticalLay(
true);
172 S.StartStatic(
XO(
"&Manage History"), 1);
177 .AddListControlReportMode(
178 { {
XO(
"Action"), wxLIST_FORMAT_LEFT, 260 },
179 {
XO(
"Used Space"), wxLIST_FORMAT_LEFT, 125 } },
185 mList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL);
187 S.StartMultiColumn(3, wxCENTRE);
189 S.AddPrompt(
XXO(
"&Total space used"));
191 S.AddVariableText( {} )->Hide();
193#if defined(ALLOW_DISCARD)
194 S.AddPrompt(
XXO(
"&Undo levels available"));
196 S.AddVariableText( {} )->Hide();
198 S.AddPrompt(
XXO(
"&Levels to discard"));
212 S.AddPrompt(
XXO(
"Clip&board space used"));
215#if defined(ALLOW_DISCARD)
222#if defined(ALLOW_DISCARD)
234 SetMinSize(GetSize());
235 mList->SetColumnWidth(0,
mList->GetClientSize().x -
mList->GetColumnWidth(1));
236 mList->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
245#if defined(ALLOW_DISCARD)
258 switch (message.
type) {
279 if ( show && !IsShown())
288 SpaceUsageCalculator calculator;
292 auto iter = calculator.space.rbegin();
294 mList->DeleteAllItems();
296 wxLongLong_t total = 0;
300 const auto space = *iter++;
305 mList->SetItem(i, 1,
size.Translation());
313 auto clipboardUsage = calculator.clipboardSpaceUsage;
315#if defined(ALLOW_DISCARD)
322 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
323 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
330#if defined(ALLOW_DISCARD)
332 int value =
mLevels->GetValue();
366 mList->DeleteItem(i);
380 projectFileIO.ReopenProject();
382 auto baseFile = wxFileName(projectFileIO.GetFileName());
383 auto walFile = wxFileName(projectFileIO.GetFileName() +
wxT(
"-wal"));
384 auto before = baseFile.GetSize() + walFile.GetSize();
386 projectFileIO.Compact({},
true);
388 auto after = baseFile.GetSize() + walFile.GetSize();
391 XO(
"Compacting actually freed %s of disk space.")
405 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
406 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
410 int selected =
event.GetIndex();
413 for (i = 0; i <
mList->GetItemCount(); i++) {
414 mList->SetItemImage(i, 0);
416 mList->SetItemTextColour(i, *wxLIGHT_GREY);
418 mList->SetItemTextColour(i,
mList->GetTextColour());
420 mList->SetItemImage(selected, 1);
435 switch (event.GetKeyCode())
440 EmulateButtonClickIfPresent(GetAffirmativeId());
465 mList->SetColumnWidth(0,
mList->GetClientSize().x -
mList->GetColumnWidth(1));
466 if (
mList->GetItemCount() > 0)
473 bool shown = IsShown();
510 historyWindow->Show();
511 historyWindow->Raise();
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
const ReservedCommandFlag & AudioIONotBusyFlag()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
EVT_LIST_ITEM_SELECTED(CurvesListID, EqualizationCurvesDialog::OnListSelectionChange) EVT_LIST_ITEM_DESELECTED(CurvesListID
XXO("&Cut/Copy/Paste Toolbar")
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
AUDACITY_DLL_API AttachedWindows & GetAttachedWindows(AudacityProject &project)
accessors for certain important windows associated with each project
static const AttachedProjectObjects::RegisteredFactory manager
std::function< void(SampleBlockConstPtr) > BlockSpaceUsageAccumulator(unsigned long long &total)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
AudacityProject & project
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Works with UndoManager to allow user to see descriptions of and undo previous commands....
void OnListKeyDown(wxKeyEvent &event)
bool Show(bool show=true) override
void UpdateDisplayForClipboard(struct ClipboardChangeMessage)
void OnSize(wxSizeEvent &event)
AudacityProject * mProject
Observer::Subscription mClipboardSubscription
void OnAudioIO(AudioIOEvent)
void OnDiscard(wxCommandEvent &event)
Observer::Subscription mUndoSubscription
void OnDiscardClipboard(wxCommandEvent &event)
void UpdateDisplay(struct UndoRedoMessage)
HistoryDialog(AudacityProject *parent, UndoManager *manager)
void UpdatePrefs() override
void OnCompact(wxCommandEvent &event)
void OnShow(wxShowEvent &event)
void OnGetURL(wxCommandEvent &event)
void OnCloseWindow(wxCloseEvent &event)
void OnItemSelected(wxListEvent &event)
void Populate(ShuttleGui &S)
Observer::Subscription mAudioIOSubscription
static TranslatableString FormatSize(wxLongLong size)
Convert a number to a string while formatting it in bytes, KB, MB, GB.
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
static ProjectFileIO & Get(AudacityProject &project)
void SetStateTo(unsigned int n, bool doAutosave=true)
static ProjectHistory & Get(AudacityProject &project)
Generates classes whose instances register items at construction.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
wxString Translation() const
Maintain a non-persistent list of states of the project, to support undo and redo commands.
void VisitStates(const Consumer &consumer, bool newestFirst)
Give read-only access to all states.
void RemoveStates(size_t begin, size_t end)
static UndoManager & Get(AudacityProject &project)
unsigned int GetCurrentState()
void SetTitle(const TranslatableString &title)
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
IMPORT_EXPORT_API ExportResult Show(ExportTask exportTask)
TRACK_API TrackList * Find(const UndoStackElem &state)
WAVE_TRACK_API void InspectBlocks(const TrackList &tracks, BlockInspector inspector, SampleBlockIDSet *pIDs=nullptr)
std::unordered_set< SampleBlockID > SampleBlockIDSet
const TranslatableString desc
void OnHistory(const CommandContext &context)
AttachedWindows::RegisteredFactory sHistoryWindowKey
enum AudioIOEvent::Type type
Message is sent during idle time by the global clipboard.
Type of message published by UndoManager.
@ Purge
Undo or redo states eliminated.
enum UndoRedoMessage::Type type
Holds one item with description and time range for the UndoManager.
TranslatableString description
Type CalculateUsage(const TrackList &tracks, SampleBlockIDSet &seen)
void Calculate(UndoManager &manager)
std::vector< Type > SpaceArray