From f372c8025b712569f750dd30bbcc51791fb2e97e Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 7 Jan 2021 00:45:32 +0000 Subject: [PATCH] Better sizing for some conditional dialogs. These dialogs don't have growable features but do have conditional features, so the size is better adjusted automatically by the code then by the user. --- common/dialog_shim.cpp | 18 ++++++++++---- include/dialog_shim.h | 5 +++- .../dialogs/dialog_track_via_properties.cpp | 2 ++ .../dialog_track_via_properties_base.cpp | 10 ++++---- .../dialog_track_via_properties_base.fbp | 24 +++++++++---------- pcbnew/sel_layer.cpp | 2 ++ 6 files changed, 38 insertions(+), 23 deletions(-) diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 2781eb8a1d..27fb7ca80f 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -77,6 +77,7 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl const wxString& name ) : wxDialog( aParent, id, title, pos, size, style, name ), KIWAY_HOLDER( nullptr, KIWAY_HOLDER::DIALOG ), + m_useCalculatedSize( false ), m_units( EDA_UNITS::MILLIMETRES ), m_firstPaintEvent( true ), m_initialFocusTarget( nullptr ), @@ -211,11 +212,18 @@ bool DIALOG_SHIM::Show( bool show ) if( savedDialogRect.GetSize().x != 0 && savedDialogRect.GetSize().y != 0 ) { - SetSize( savedDialogRect.GetPosition().x, - savedDialogRect.GetPosition().y, - std::max( wxDialog::GetSize().x, savedDialogRect.GetSize().x ), - std::max( wxDialog::GetSize().y, savedDialogRect.GetSize().y ), - 0 ); + if( m_useCalculatedSize ) + { + SetSize( savedDialogRect.GetPosition().x, savedDialogRect.GetPosition().y, + wxDialog::GetSize().x, wxDialog::GetSize().y, 0 ); + } + else + { + SetSize( savedDialogRect.GetPosition().x, savedDialogRect.GetPosition().y, + std::max( wxDialog::GetSize().x, savedDialogRect.GetSize().x ), + std::max( wxDialog::GetSize().y, savedDialogRect.GetSize().y ), + 0 ); + } } // Be sure that the dialog appears in a visible area diff --git a/include/dialog_shim.h b/include/dialog_shim.h index 725ad33990..420474892f 100644 --- a/include/dialog_shim.h +++ b/include/dialog_shim.h @@ -194,6 +194,10 @@ protected: EDA_UNITS m_units; // userUnits for display and parsing std::string m_hash_key; // alternate for class_map when classname re-used + // The following disables the storing of a user size. It is used primarily for dialogs + // with conditional content which don't need user sizing. + bool m_useCalculatedSize; + // On MacOS (at least) SetFocus() calls made in the constructor will fail because a // window that isn't yet visible will return false to AcceptsFocus(). So we must delay // the initial-focus SetFocus() call to the first paint event. @@ -208,7 +212,6 @@ protected: EDA_BASE_FRAME* m_parentFrame; std::vector m_tabOrder; - }; #endif // DIALOG_SHIM_ diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index 880310cab3..3579b67649 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -53,6 +53,8 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen m_tracks( false ), m_vias( false ) { + m_useCalculatedSize = true; + wxASSERT( !m_items.Empty() ); // Configure display origin transforms diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.cpp b/pcbnew/dialogs/dialog_track_via_properties_base.cpp index 51431cdeea..609ae994e4 100644 --- a/pcbnew/dialogs/dialog_track_via_properties_base.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties_base.cpp @@ -41,7 +41,7 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa m_sbCommonSizer->Add( bSizerNetWidgets, 5, wxEXPAND|wxRIGHT, 10 ); m_staticline1 = new wxStaticLine( m_sbCommonSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - m_sbCommonSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + m_sbCommonSizer->Add( m_staticline1, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 ); m_lockedCbox = new wxCheckBox( m_sbCommonSizer->GetStaticBox(), wxID_ANY, _("Locked"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); m_sbCommonSizer->Add( m_lockedCbox, 0, wxALL, 5 ); @@ -154,10 +154,7 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa fgTrackRightSizer->Add( m_TrackLayerCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - fgTrackRightSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - - - m_sbTrackSizer->Add( fgTrackRightSizer, 4, wxLEFT, 10 ); + m_sbTrackSizer->Add( fgTrackRightSizer, 4, wxLEFT|wxEXPAND, 10 ); m_MainSizer->Add( m_sbTrackSizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); @@ -281,6 +278,9 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa m_MainSizer->Add( m_sbViaSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); + + m_MainSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + m_StdButtons = new wxStdDialogButtonSizer(); m_StdButtonsOK = new wxButton( this, wxID_OK ); m_StdButtons->AddButton( m_StdButtonsOK ); diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.fbp b/pcbnew/dialogs/dialog_track_via_properties_base.fbp index bc51e0dbfd..209ef2a42f 100644 --- a/pcbnew/dialogs/dialog_track_via_properties_base.fbp +++ b/pcbnew/dialogs/dialog_track_via_properties_base.fbp @@ -281,7 +281,7 @@ 5 - wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT + wxEXPAND|wxBOTTOM|wxRIGHT 0 1 @@ -1648,7 +1648,7 @@ 10 - wxLEFT + wxLEFT|wxEXPAND 4 3 @@ -1788,16 +1788,6 @@ - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - @@ -3275,6 +3265,16 @@ + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + 5 wxEXPAND|wxALL diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index ceee259eee..0fc2730f88 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -107,6 +107,8 @@ PCB_ONE_LAYER_SELECTOR::PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD* PCB_LAYER_SELECTOR( aParent ), DIALOG_LAYER_SELECTION_BASE( aParent ) { + m_useCalculatedSize = true; + m_layerSelected = aDefaultLayer; m_notAllowedLayersMask = aNotAllowedLayersMask; m_brd = aBrd;