1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 23:59:37 +02:00

Various preliminaries for use of ShuttleGui in more places

This commit is contained in:
Paul Licameli 2019-12-10 09:59:34 -05:00
commit 9d05fc0c7d
11 changed files with 86 additions and 49 deletions

View File

@ -292,7 +292,7 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
S.StartVerticalLay(2);
{
vRuler = safenew RulerPanel(
this, wxID_ANY, wxVERTICAL,
S.GetParent(), wxID_ANY, wxVERTICAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ 0.0, -dBRange },
Ruler::LinearDBFormat,
@ -310,7 +310,7 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
}
S.EndVerticalLay();
mFreqPlot = safenew FreqPlot(this, wxID_ANY);
mFreqPlot = safenew FreqPlot(S.GetParent(), wxID_ANY);
S.Prop(1)
.Position(wxEXPAND)
.MinSize( { wxDefaultCoord, FREQ_WINDOW_HEIGHT } )
@ -320,7 +320,7 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
{
S.StartVerticalLay();
{
mPanScroller = safenew wxScrollBar(this, FreqPanScrollerID,
mPanScroller = safenew wxScrollBar(S.GetParent(), FreqPanScrollerID,
wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
@ -336,13 +336,13 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
S.StartVerticalLay();
{
wxStaticBitmap *zi = safenew wxStaticBitmap(this, wxID_ANY, wxBitmap(ZoomIn));
wxStaticBitmap *zi = safenew wxStaticBitmap(S.GetParent(), wxID_ANY, wxBitmap(ZoomIn));
S.Position(wxALIGN_CENTER)
.AddWindow(zi);
S.AddSpace(5);
mZoomSlider = safenew wxSliderWrapper(this, FreqZoomSliderID, 100, 1, 100,
mZoomSlider = safenew wxSliderWrapper(S.GetParent(), FreqZoomSliderID, 100, 1, 100,
wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL);
S.Prop(1);
S
@ -356,7 +356,7 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
S.AddSpace(5);
wxStaticBitmap *zo = safenew wxStaticBitmap(this, wxID_ANY, wxBitmap(ZoomOut));
wxStaticBitmap *zo = safenew wxStaticBitmap(S.GetParent(), wxID_ANY, wxBitmap(ZoomOut));
S.Position(wxALIGN_CENTER)
.AddWindow(zo);
}
@ -375,7 +375,7 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
S.StartHorizontalLay(wxEXPAND, 0);
{
hRuler = safenew RulerPanel(
this, wxID_ANY, wxHORIZONTAL,
S.GetParent(), wxID_ANY, wxHORIZONTAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ 10, 20000 },
Ruler::RealFormat,
@ -508,7 +508,7 @@ FrequencyPlotDialog::FrequencyPlotDialog(wxWindow * parent, wxWindowID id,
S.AddSpace(5);
mProgress = safenew FreqGauge(this, wxID_ANY); //, wxST_SIZEGRIP);
mProgress = safenew FreqGauge(S.GetParent(), wxID_ANY); //, wxST_SIZEGRIP);
S.Position(wxEXPAND)
.AddWindow(mProgress);

View File

@ -255,7 +255,7 @@ void LabelDialog::PopulateOrExchange( ShuttleGui & S )
{
S.StartVerticalLay(wxEXPAND,1);
{
mGrid = safenew Grid(this, wxID_ANY);
mGrid = safenew Grid(S.GetParent(), wxID_ANY);
S.Prop(1).AddWindow( mGrid );
}
S.EndVerticalLay();

View File

@ -107,6 +107,7 @@ for registering for changes.
#include <wx/grid.h>
#include <wx/listctrl.h>
#include <wx/notebook.h>
#include <wx/simplebook.h>
#include <wx/treectrl.h>
#include <wx/spinctrl.h>
#include <wx/stattext.h>
@ -119,21 +120,22 @@ for registering for changes.
#include "widgets/WindowAccessible.h"
#endif
ShuttleGuiBase::ShuttleGuiBase(wxWindow * pParent, teShuttleMode ShuttleMode )
ShuttleGuiBase::ShuttleGuiBase(
wxWindow * pParent, teShuttleMode ShuttleMode, bool vertical, wxSize minSize )
: mpDlg{ pParent }
{
wxASSERT( (pParent != NULL ) || ( ShuttleMode != eIsCreating));
mpbOptionalFlag = nullptr;
mpParent = pParent;
mShuttleMode = ShuttleMode;
Init();
Init( vertical, minSize );
}
ShuttleGuiBase::~ShuttleGuiBase()
{
}
void ShuttleGuiBase::Init()
void ShuttleGuiBase::Init(bool vertical, wxSize minSize)
{
mpShuttle = NULL;
mpSizer = NULL;
@ -171,10 +173,11 @@ void ShuttleGuiBase::Init()
if( !mpSizer )
{
mpParent->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL));
mpParent->SetSizer(
mpSizer = safenew wxBoxSizer(vertical ? wxVERTICAL : wxHORIZONTAL));
}
PushSizer();
mpSizer->SetMinSize(250,100);
mpSizer->SetMinSize(minSize);
}
void ShuttleGuiBase::ResetId()
@ -977,12 +980,33 @@ void ShuttleGuiBase::EndNotebook()
}
wxSimplebook * ShuttleGuiBase::StartSimplebook()
{
UseUpId();
if( mShuttleMode != eIsCreating )
return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxSimplebook);
wxSimplebook * pNotebook;
mpWind = pNotebook = safenew wxSimplebook(GetParent(),
miId, wxDefaultPosition, wxDefaultSize, GetStyle( 0 ));
SetProportions( 1 );
UpdateSizers();
mpParent = pNotebook;
return pNotebook;
}
void ShuttleGuiBase::EndSimplebook()
{
//PopSizer();
mpParent = mpParent->GetParent();
}
wxNotebookPage * ShuttleGuiBase::StartNotebookPage( const wxString & Name )
{
if( mShuttleMode != eIsCreating )
return NULL;
// return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wx);
wxNotebook * pNotebook = (wxNotebook*)mpParent;
auto pNotebook = static_cast< wxBookCtrlBase* >( mpParent );
wxNotebookPage * pPage = safenew wxPanelWrapper(GetParent());
pPage->SetName(Name);
@ -994,7 +1018,6 @@ wxNotebookPage * ShuttleGuiBase::StartNotebookPage( const wxString & Name )
mpParent = pPage;
pPage->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL));
PushSizer();
mpSizer->SetMinSize(250, 500);
// UpdateSizers();
return pPage;
}
@ -1004,7 +1027,7 @@ void ShuttleGuiBase::StartNotebookPage( const wxString & Name, wxNotebookPage *
if( mShuttleMode != eIsCreating )
return;
// return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wx);
wxNotebook * pNotebook = (wxNotebook*)mpParent;
auto pNotebook = static_cast< wxBookCtrlBase* >( mpParent );
// wxNotebookPage * pPage = safenew wxPanelWrapper(GetParent());
pPage->Create( mpParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxT("panel"));
pPage->SetName(Name);
@ -1017,7 +1040,6 @@ void ShuttleGuiBase::StartNotebookPage( const wxString & Name, wxNotebookPage *
mpParent = pPage;
pPage->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL));
PushSizer();
mpSizer->SetMinSize(250, 500);
// UpdateSizers();
}
@ -2178,13 +2200,14 @@ void SetIfCreated( wxStaticText *&Var, wxStaticText * Val )
#include "../extnpanel-src/GuiWaveTrack.h"
#endif
ShuttleGui::ShuttleGui(wxWindow * pParent, teShuttleMode ShuttleMode) :
ShuttleGuiBase( pParent, ShuttleMode )
ShuttleGui::ShuttleGui(
wxWindow * pParent, teShuttleMode ShuttleMode, bool vertical, wxSize minSize)
: ShuttleGuiBase( pParent, ShuttleMode, vertical, minSize )
{
if( ShuttleMode == eIsCreatingFromPrefs )
{
mShuttleMode = eIsCreating;
Init(); // Wasn't fully done in base constructor because it is only done when eIsCreating is set.
Init( vertical, minSize ); // Wasn't fully done in base constructor because it is only done when eIsCreating is set.
}
else if( ShuttleMode == eIsSavingToPrefs )
{
@ -2381,7 +2404,7 @@ std::unique_ptr<wxSizer> CreateStdButtonSizer(wxWindow *parent, long buttons, wx
return std::unique_ptr<wxSizer>{ s.release() };
}
void ShuttleGui::AddStandardButtons(long buttons, wxButton *extra)
void ShuttleGui::AddStandardButtons(long buttons, wxWindow *extra)
{
if( mShuttleMode != eIsCreating )
return;
@ -2396,12 +2419,15 @@ void ShuttleGui::AddStandardButtons(long buttons, wxButton *extra)
EndVerticalLay();
}
wxSizerItem * ShuttleGui::AddSpace( int width, int height )
wxSizerItem * ShuttleGui::AddSpace( int width, int height, int prop )
{
if( mShuttleMode != eIsCreating )
return NULL;
SetProportions(0);
return mpSizer->Add( width, height, miProp);
// SetProportions(0);
// return mpSizer->Add( width, height, miProp);
return mpSizer->Add( width, height, prop );
}
void ShuttleGui::SetMinSize( wxWindow *window, const wxArrayStringEx & items )

View File

@ -58,6 +58,7 @@ class wxTreeCtrl;
class wxTextCtrl;
class wxSlider;
class wxNotebook;
class wxSimplebook;
typedef wxWindow wxNotebookPage; // so far, any window can be a page
class wxButton;
class wxBitmapButton;
@ -255,9 +256,14 @@ struct Item {
class AUDACITY_DLL_API ShuttleGuiBase /* not final */
{
public:
ShuttleGuiBase(wxWindow * pParent,teShuttleMode ShuttleMode);
ShuttleGuiBase(
wxWindow * pParent,
teShuttleMode ShuttleMode,
bool vertical, // Choose layout direction of topmost level sizer
wxSize minSize
);
virtual ~ShuttleGuiBase();
void Init();
void Init( bool vertical, wxSize minSize );
void ResetId();
//-- Add functions. These only add a widget or 2.
@ -360,11 +366,16 @@ public:
wxNotebook * StartNotebook();
void EndNotebook();
wxSimplebook * StartSimplebook();
void EndSimplebook();
// Use within any kind of book control:
// IDs of notebook pages cannot be chosen by the caller
wxNotebookPage * StartNotebookPage( const wxString & Name );
void StartNotebookPage( const wxString & Name, wxNotebookPage * pPage );
void EndNotebookPage();
wxPanel * StartInvisiblePanel();
void EndInvisiblePanel();
@ -590,7 +601,11 @@ AUDACITY_DLL_API std::unique_ptr<wxSizer> CreateStdButtonSizer( wxWindow *parent
class AUDACITY_DLL_API ShuttleGui /* not final */ : public ShuttleGuiBase
{
public:
ShuttleGui(wxWindow * pParent,teShuttleMode ShuttleMode);
ShuttleGui(
wxWindow * pParent, teShuttleMode ShuttleMode,
bool vertical = true, // Choose layout direction of topmost level sizer
wxSize minSize = { 250, 100 }
);
~ShuttleGui(void);
public:
ShuttleGui & Optional( bool & bVar );
@ -697,9 +712,9 @@ public:
// The first of these buttons, if any, that is included will be default:
// Apply, Yes, OK
void AddStandardButtons(
long buttons = eOkButton | eCancelButton, wxButton *extra = NULL );
long buttons = eOkButton | eCancelButton, wxWindow *extra = NULL );
wxSizerItem * AddSpace( int width, int height );
wxSizerItem * AddSpace( int width, int height, int prop = 0 );
wxSizerItem * AddSpace( int size ) { return AddSpace( size, size ); };
// Calculate width of a choice control adequate for the items, maybe after

View File

@ -725,8 +725,6 @@ bool EffectEqualization::CloseUI()
void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
{
wxWindow *const parent = S.GetParent();
//LoadCurves();
auto trackList = inputTracks();
@ -770,7 +768,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
S.StartVerticalLay(wxEXPAND, 1);
{
mdBRuler = safenew RulerPanel(
parent, wxID_ANY, wxVERTICAL,
S.GetParent(), wxID_ANY, wxVERTICAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ 60.0, -120.0 },
Ruler::LinearDBFormat,
@ -789,7 +787,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
}
S.EndVerticalLay();
mPanel = safenew EqualizationPanel(parent, wxID_ANY, this);
mPanel = safenew EqualizationPanel(S.GetParent(), wxID_ANY, this);
S.Prop(1)
.Position(wxEXPAND)
.MinSize( { wxDefaultCoord, wxDefaultCoord } )
@ -827,7 +825,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
S.AddSpace(1, 1);
mFreqRuler = safenew RulerPanel(
parent, wxID_ANY, wxHORIZONTAL,
S.GetParent(), wxID_ANY, wxHORIZONTAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ mLoFreq, mHiFreq },
Ruler::IntFormat,

View File

@ -263,7 +263,7 @@ private:
wxSizerItem *mLeftSpacer;
EqualizationPanel *mPanel;
wxPanel *mGraphicPanel;
//wxPanel *mGraphicPanel;
wxRadioButton *mDraw;
wxRadioButton *mGraphic;
wxCheckBox *mLinFreq;

View File

@ -359,8 +359,6 @@ bool EffectScienFilter::Init()
void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
{
wxWindow *const parent = S.GetParent();
S.AddSpace(5);
S.SetSizerProportion(1);
S.StartMultiColumn(3, wxEXPAND);
@ -375,7 +373,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
S.StartVerticalLay();
{
mdBRuler = safenew RulerPanel(
parent, wxID_ANY, wxVERTICAL,
S.GetParent(), wxID_ANY, wxVERTICAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ 30.0, -120.0 },
Ruler::LinearDBFormat,
@ -394,7 +392,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
S.EndVerticalLay();
mPanel = safenew EffectScienFilterPanel(
parent, wxID_ANY,
S.GetParent(), wxID_ANY,
this, mLoFreq, mNyquist
);
@ -432,8 +430,8 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
S.AddSpace(1, 1);
mfreqRuler = safenew RulerPanel(
parent, wxID_ANY, wxHORIZONTAL,
mfreqRuler = safenew RulerPanel(
S.GetParent(), wxID_ANY, wxHORIZONTAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ mLoFreq, mNyquist },
Ruler::IntFormat,

View File

@ -551,7 +551,7 @@ PrefsDialog::PrefsDialog
{
wxASSERT(factories.size() > 0);
if (!uniquePage) {
mCategories = safenew wxTreebookExt(this, wxID_ANY, mTitlePrefix);
mCategories = safenew wxTreebookExt(S.GetParent(), wxID_ANY, mTitlePrefix);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mCategories->GetTreeCtrl()->SetAccessible(
@ -602,7 +602,7 @@ PrefsDialog::PrefsDialog
// Unique page, don't show the factory
const PrefsNode &node = factories[0];
const PrefsPanel::Factory &factory = node.factory;
mUniquePage = factory(this, wxID_ANY);
mUniquePage = factory(S.GetParent(), wxID_ANY);
wxWindow * uniquePageWindow = S.Prop(1)
.Position(wxEXPAND)
.AddWindow(mUniquePage);

View File

@ -125,7 +125,7 @@ void LabelTrackMenuTable::OnSetFont(wxCommandEvent &)
/* i18n-hint: (noun) The name of the typeface*/
S.AddPrompt(_("Face name"));
lb = safenew wxListBox(&dlg, wxID_ANY,
lb = safenew wxListBox(S.GetParent(), wxID_ANY,
wxDefaultPosition,
wxDefaultSize,
facenames,
@ -139,7 +139,7 @@ void LabelTrackMenuTable::OnSetFont(wxCommandEvent &)
/* i18n-hint: (noun) The size of the typeface*/
S.AddPrompt(_("Face size"));
sc = safenew wxSpinCtrl(&dlg, wxID_ANY,
sc = safenew wxSpinCtrl(S.GetParent(), wxID_ANY,
wxString::Format(wxT("%ld"), fontsize),
wxDefaultPosition,
wxDefaultSize,

View File

@ -283,7 +283,7 @@ SliderDialog::SliderDialog(wxWindow * parent, wxWindowID id,
mTextCtrl = S.Validator<wxTextValidator>(wxFILTER_NUMERIC)
.AddTextBox( {}, wxEmptyString, 15);
mSlider = safenew ASlider(this,
mSlider = safenew ASlider(S.GetParent(),
wxID_ANY,
title,
wxDefaultPosition,

View File

@ -160,7 +160,7 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
pFrame->SetTransparent(0);
ShuttleGui S( pWnd, eIsCreating );
wxPanel *pPan = S.Style( wxNO_BORDER | wxTAB_TRAVERSAL )
S.Style( wxNO_BORDER | wxTAB_TRAVERSAL )
.Prop(true)
.StartPanel();
{
@ -181,7 +181,7 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
}
S.EndHorizontalLay();
html = safenew LinkingHtmlWindow(pPan, wxID_ANY,
html = safenew LinkingHtmlWindow(S.GetParent(), wxID_ANY,
wxDefaultPosition,
bIsFile ? wxSize(500, 400) : wxSize(480, 240),
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);