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"
47#include <unordered_set>
53 using Type =
unsigned long long;
94 space.push_back(CalculateUsage(*pTracks, seen));
102 clipboardSpaceUsage = CalculateUsage(
131#define HistoryTitle XO("History")
135 wxDefaultPosition, wxDefaultSize,
136 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
162 auto imageList = std::make_unique<wxImageList>(9, 16);
163 imageList->Add(wxIcon(empty9x16_xpm));
164 imageList->Add(wxIcon(arrow_xpm));
167 S.StartVerticalLay(
true);
169 S.StartStatic(
XO(
"&Manage History"), 1);
174 .AddListControlReportMode(
175 { {
XO(
"Action"), wxLIST_FORMAT_LEFT, 260 },
176 {
XO(
"Used Space"), wxLIST_FORMAT_LEFT, 125 } },
182 mList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL);
184 S.StartMultiColumn(3, wxCENTRE);
186 S.AddPrompt(
XXO(
"&Total space used"));
188 S.AddVariableText( {} )->Hide();
190#if defined(ALLOW_DISCARD)
191 S.AddPrompt(
XXO(
"&Undo levels available"));
193 S.AddVariableText( {} )->Hide();
195 S.AddPrompt(
XXO(
"&Levels to discard"));
209 S.AddPrompt(
XXO(
"Clip&board space used"));
212#if defined(ALLOW_DISCARD)
219#if defined(ALLOW_DISCARD)
231 SetMinSize(GetSize());
232 mList->SetColumnWidth(0,
mList->GetClientSize().x -
mList->GetColumnWidth(1));
233 mList->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
242#if defined(ALLOW_DISCARD)
255 switch (message.
type) {
276 if ( show && !IsShown())
285 SpaceUsageCalculator calculator;
289 auto iter = calculator.space.rbegin();
291 mList->DeleteAllItems();
293 wxLongLong_t total = 0;
297 const auto space = *iter++;
302 mList->SetItem(i, 1,
size.Translation());
310 auto clipboardUsage = calculator.clipboardSpaceUsage;
312#if defined(ALLOW_DISCARD)
319 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
320 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
327#if defined(ALLOW_DISCARD)
329 int value =
mLevels->GetValue();
363 mList->DeleteItem(i);
377 projectFileIO.ReopenProject();
379 auto baseFile = wxFileName(projectFileIO.GetFileName());
380 auto walFile = wxFileName(projectFileIO.GetFileName() +
wxT(
"-wal"));
381 auto before = baseFile.GetSize() + walFile.GetSize();
383 projectFileIO.Compact({},
true);
385 auto after = baseFile.GetSize() + walFile.GetSize();
388 XO(
"Compacting actually freed %s of disk space.")
402 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
403 wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
407 int selected =
event.GetIndex();
410 for (i = 0; i <
mList->GetItemCount(); i++) {
411 mList->SetItemImage(i, 0);
413 mList->SetItemTextColour(i, *wxLIGHT_GREY);
415 mList->SetItemTextColour(i,
mList->GetTextColour());
417 mList->SetItemImage(selected, 1);
432 switch (event.GetKeyCode())
437 EmulateButtonClickIfPresent(GetAffirmativeId());
462 mList->SetColumnWidth(0,
mList->GetClientSize().x -
mList->GetColumnWidth(1));
463 if (
mList->GetItemCount() > 0)
470 bool shown = IsShown();
507 historyWindow->Show();
508 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(const SampleBlock &) > BlockSpaceUsageAccumulator(unsigned long long &total)
void InspectBlocks(const TrackList &tracks, BlockInspector inspector, SampleBlockIDSet *pIDs)
std::unordered_set< SampleBlockID > SampleBlockIDSet
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...
static TrackList * FindUndoTracks(const UndoStackElem &state)
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.
ExportResult Show(ExportTask exportTask)
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