ShuttleGui can specify orientation and minimum size...

... This will be needed for rewrite of EffectUIHost dialog
This commit is contained in:
Paul Licameli 2019-12-10 09:04:05 -05:00
parent bb3159c758
commit f825c32a50
2 changed files with 23 additions and 11 deletions

View File

@ -120,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;
@ -172,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()
@ -2198,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 )
{

View File

@ -256,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.
@ -596,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 );