2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
ProgressDialog.h
|
|
|
|
|
|
|
|
Copyright
|
|
|
|
Leland Lucius
|
|
|
|
Vaughan Johnson
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_WIDGETS_PROGRESSDIALOG__
|
|
|
|
#define __AUDACITY_WIDGETS_PROGRESSDIALOG__
|
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-01-05 20:41:36 +00:00
|
|
|
#include <vector>
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/defs.h>
|
2018-11-14 16:48:46 +00:00
|
|
|
#include <wx/evtloop.h> // member variable
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-03-30 19:06:57 +00:00
|
|
|
#include "wxPanelWrapper.h" // to inherit
|
2016-07-10 21:10:50 +00:00
|
|
|
|
2018-11-16 15:12:10 +00:00
|
|
|
class wxGauge;
|
2018-11-11 21:41:45 +00:00
|
|
|
class wxStaticText;
|
|
|
|
|
2016-12-24 15:43:25 +00:00
|
|
|
enum class ProgressResult : unsigned
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2016-12-24 15:43:25 +00:00
|
|
|
Cancelled = 0, //<! User says that whatever is happening is undesirable and shouldn't have happened at all
|
|
|
|
Success, //<! User says nothing, everything works fine, continue doing whatever we're doing
|
|
|
|
Failed, //<! Something has gone wrong, we should stop and cancel everything we did
|
|
|
|
Stopped //<! Nothing is wrong, but user says we should stop now and leave things as they are now
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ProgressDialogFlags
|
|
|
|
{
|
|
|
|
pdlgEmptyFlags = 0x00000000,
|
|
|
|
pdlgHideStopButton = 0x00000001,
|
2015-07-19 20:47:50 +00:00
|
|
|
pdlgHideCancelButton = 0x00000002,
|
2016-03-30 22:46:15 +00:00
|
|
|
pdlgHideElapsedTime = 0x00000004,
|
|
|
|
pdlgConfirmStopCancel = 0x00000008,
|
2015-07-19 20:47:50 +00:00
|
|
|
|
2015-08-18 02:48:10 +00:00
|
|
|
pdlgDefaultFlags = pdlgEmptyFlags
|
2015-07-19 20:47:50 +00:00
|
|
|
};
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// ProgressDialog Class
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
2016-07-10 21:10:50 +00:00
|
|
|
class AUDACITY_DLL_API ProgressDialog /* not final */ : public wxDialogWrapper
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-07-19 20:47:50 +00:00
|
|
|
public:
|
|
|
|
ProgressDialog();
|
2018-01-05 20:41:36 +00:00
|
|
|
|
|
|
|
// Display a simple message.
|
2019-12-08 03:37:02 +00:00
|
|
|
ProgressDialog(const TranslatableString & title,
|
|
|
|
const TranslatableString & message = {},
|
2016-03-30 22:46:15 +00:00
|
|
|
int flags = pdlgDefaultFlags,
|
2019-12-08 03:37:02 +00:00
|
|
|
const TranslatableString & sRemainingLabelText = {});
|
2018-01-05 20:41:36 +00:00
|
|
|
|
2019-12-08 03:37:02 +00:00
|
|
|
using MessageColumn = std::vector< TranslatableString >;
|
2018-01-05 20:41:36 +00:00
|
|
|
using MessageTable = std::vector< MessageColumn >;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Display a table of messages.
|
|
|
|
// Each member of the table is a column of messages.
|
|
|
|
// Each member of a column is a string that should have no newlines,
|
|
|
|
// and each column should have the same number of elements, to make
|
|
|
|
// proper correspondences, but this is not checked.
|
2019-12-08 03:37:02 +00:00
|
|
|
ProgressDialog(const TranslatableString & title,
|
2018-01-05 20:41:36 +00:00
|
|
|
const MessageTable & columns,
|
|
|
|
int flags = pdlgDefaultFlags,
|
2019-12-08 03:37:02 +00:00
|
|
|
const TranslatableString & sRemainingLabelText = {});
|
2018-01-05 20:41:36 +00:00
|
|
|
|
|
|
|
public:
|
2015-08-14 21:15:28 +00:00
|
|
|
virtual ~ProgressDialog();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-12-08 03:37:02 +00:00
|
|
|
bool Create(const TranslatableString & title,
|
|
|
|
const TranslatableString & message = {},
|
2018-01-05 20:41:36 +00:00
|
|
|
int flags = pdlgDefaultFlags,
|
2019-12-08 03:37:02 +00:00
|
|
|
const TranslatableString & sRemainingLabelText = {});
|
2018-01-05 20:41:36 +00:00
|
|
|
|
2018-01-25 20:58:37 +00:00
|
|
|
void Reinit();
|
|
|
|
|
2018-01-05 20:41:36 +00:00
|
|
|
protected:
|
2019-12-08 03:37:02 +00:00
|
|
|
bool Create(const TranslatableString & title,
|
2018-01-05 20:41:36 +00:00
|
|
|
const MessageTable & columns,
|
|
|
|
int flags = pdlgDefaultFlags,
|
2019-12-08 03:37:02 +00:00
|
|
|
const TranslatableString & sRemainingLabelText = {});
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-01-05 20:41:36 +00:00
|
|
|
public:
|
2019-12-08 03:37:02 +00:00
|
|
|
ProgressResult Update(int value, const TranslatableString & message = {});
|
|
|
|
ProgressResult Update(double current, const TranslatableString & message = {});
|
|
|
|
ProgressResult Update(double current, double total, const TranslatableString & message = {});
|
|
|
|
ProgressResult Update(wxULongLong_t current, wxULongLong_t total, const TranslatableString & message = {});
|
|
|
|
ProgressResult Update(wxLongLong current, wxLongLong total, const TranslatableString & message = {});
|
|
|
|
ProgressResult Update(wxLongLong_t current, wxLongLong_t total, const TranslatableString & message = {});
|
|
|
|
ProgressResult Update(int current, int total, const TranslatableString & message = {});
|
|
|
|
|
|
|
|
void SetMessage(const TranslatableString & message);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-07-19 20:47:50 +00:00
|
|
|
protected:
|
2018-08-02 02:41:13 +00:00
|
|
|
wxWindowRef mHadFocus;
|
2015-09-03 07:33:41 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
wxStaticText *mElapsed;
|
|
|
|
wxStaticText *mRemaining;
|
|
|
|
wxGauge *mGauge;
|
|
|
|
|
|
|
|
wxLongLong_t mStartTime;
|
|
|
|
wxLongLong_t mLastUpdate;
|
2017-01-16 12:35:07 +00:00
|
|
|
wxLongLong_t mYieldTimer;
|
2010-01-23 19:44:49 +00:00
|
|
|
int mLastValue; // gauge value, range = [0,1000]
|
|
|
|
|
|
|
|
bool mCancel;
|
|
|
|
bool mStop;
|
|
|
|
|
2015-08-14 21:15:28 +00:00
|
|
|
bool mIsTransparent;
|
|
|
|
|
2016-03-30 22:46:15 +00:00
|
|
|
// MY: Booleans to hold the flag values
|
|
|
|
bool m_bShowElapsedTime = true;
|
|
|
|
bool m_bConfirmAction = false;
|
|
|
|
|
2015-07-19 20:47:50 +00:00
|
|
|
private:
|
|
|
|
void Init();
|
2015-09-03 07:33:41 +00:00
|
|
|
bool SearchForWindow(const wxWindowList & list, const wxWindow *searchfor) const;
|
2015-07-19 20:47:50 +00:00
|
|
|
void OnCancel(wxCommandEvent & e);
|
|
|
|
void OnStop(wxCommandEvent & e);
|
|
|
|
void OnCloseWindow(wxCloseEvent & e);
|
2015-08-14 21:15:28 +00:00
|
|
|
void Beep() const;
|
2016-04-05 22:24:24 +00:00
|
|
|
|
2019-12-18 00:40:32 +00:00
|
|
|
bool ConfirmAction(const TranslatableString & sPrompt,
|
|
|
|
const TranslatableString & sTitle,
|
2016-04-05 22:24:24 +00:00
|
|
|
int iButtonID = -1);
|
2015-07-19 20:47:50 +00:00
|
|
|
|
2018-01-05 20:41:36 +00:00
|
|
|
void AddMessageAsColumn(wxBoxSizer * pSizer,
|
|
|
|
const MessageColumn &column, bool bFirstColumn);
|
2016-08-30 19:29:10 +00:00
|
|
|
|
2015-07-19 20:47:50 +00:00
|
|
|
private:
|
|
|
|
// This guarantees we have an active event loop...possible during OnInit()
|
|
|
|
wxEventLoopGuarantor mLoop;
|
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
|
|
|
|
2016-04-06 22:32:14 +00:00
|
|
|
std::unique_ptr<wxWindowDisabler> mDisable;
|
2015-08-14 21:15:28 +00:00
|
|
|
|
2018-01-05 20:41:36 +00:00
|
|
|
wxStaticText *mMessage{} ;
|
|
|
|
int mLastW{ 0 };
|
|
|
|
int mLastH{ 0 };
|
2015-05-22 05:47:52 +00:00
|
|
|
|
2016-09-18 14:26:29 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class AUDACITY_DLL_API TimerProgressDialog final : public ProgressDialog
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-08-14 21:15:28 +00:00
|
|
|
public:
|
2014-06-03 20:30:19 +00:00
|
|
|
TimerProgressDialog(const wxLongLong_t duration,
|
2019-12-08 03:37:02 +00:00
|
|
|
const TranslatableString &title,
|
2018-01-05 20:41:36 +00:00
|
|
|
const MessageTable & columns,
|
2016-03-30 22:46:15 +00:00
|
|
|
int flags = pdlgDefaultFlags,
|
2019-12-08 03:37:02 +00:00
|
|
|
const TranslatableString & sRemainingLabelText = {});
|
2018-01-05 20:41:36 +00:00
|
|
|
|
|
|
|
// Oh no, there is an inherited nullary "Update" in wxDialog!
|
|
|
|
// Choose another name then...
|
|
|
|
ProgressResult UpdateProgress();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-08-14 21:15:28 +00:00
|
|
|
protected:
|
2010-01-23 19:44:49 +00:00
|
|
|
wxLongLong_t mDuration;
|
2018-01-05 20:41:36 +00:00
|
|
|
|
|
|
|
// Disallow direct use of the inherited overloads of Update because it
|
|
|
|
// doesn't support changes of message
|
|
|
|
using ProgressDialog::Update;
|
2010-01-23 19:44:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|