Save fp browser list widths and apply known hack to work around wxWidgets bug.

Fixes https://gitlab.com/kicad/code/kicad/issues/11744

Fixes https://gitlab.com/kicad/code/kicad/issues/11745

(cherry picked from commit 0a623bff9f)
This commit is contained in:
Jeff Young 2022-07-11 04:00:46 +01:00
parent ccb416eead
commit 61bb793324
6 changed files with 126 additions and 12 deletions

View File

@ -181,11 +181,10 @@ SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAM
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( wxT( "MsgPanel" ) )
.Bottom().Layer( 6 ) );
m_auimgr.AddPane( m_libList, EDA_PANE().Palette().Name( wxT( "Libraries" ) ).Left().Layer(3)
.CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_libListWidth, -1 ) );
m_auimgr.AddPane( m_symbolList, EDA_PANE().Palette().Name( wxT( "Symbols" ) ).Left().Layer(1)
.CaptionVisible( false ).MinSize( 80, -1 )
.BestSize( m_symbolListWidth, -1 ) );
m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( wxT( "Libraries" ) ).Left().Layer(2)
.CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
m_auimgr.AddPane( symbolPanel, EDA_PANE().Palette().Name( wxT( "Symbols" ) ).Left().Layer(1)
.CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( wxT( "DrawFrame" ) ).Center() );
@ -193,6 +192,44 @@ SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAM
m_auimgr.Update();
if( m_libListWidth > 0 )
{
wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Libraries" );
// wxAUI hack: force width by setting MinSize() and then Fixed()
// thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
treePane.MinSize( m_libListWidth, -1 );
treePane.Fixed();
m_auimgr.Update();
// now make it resizable again
treePane.Resizable();
m_auimgr.Update();
// Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
// back to minimum.
treePane.MinSize( 100, -1 );
}
if( m_symbolListWidth > 0 )
{
wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Symbols" );
// wxAUI hack: force width by setting MinSize() and then Fixed()
// thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
treePane.MinSize( m_symbolListWidth, -1 );
treePane.Fixed();
m_auimgr.Update();
// now make it resizable again
treePane.Resizable();
m_auimgr.Update();
// Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
// back to minimum.
treePane.MinSize( 100, -1 );
}
if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
{
Raise();
@ -705,11 +742,13 @@ void SYMBOL_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_LibViewPanel.show_pin_electrical_type;
// Set parameters to a reasonable value.
if( m_libListWidth > m_frameSize.x / 2 )
m_libListWidth = m_frameSize.x / 2;
int maxWidth = cfg->m_LibViewPanel.window.state.size_x - 80;
if( m_symbolListWidth > m_frameSize.x / 2 )
m_symbolListWidth = m_frameSize.x / 2;
if( m_libListWidth + m_symbolListWidth > maxWidth )
{
m_libListWidth = maxWidth * ( m_libListWidth / ( m_libListWidth + m_symbolListWidth ) );
m_symbolListWidth = maxWidth - m_libListWidth;
}
}

View File

@ -225,7 +225,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" )
.Left().Layer(2)
.Caption( _( "Libraries" ) )
.MinSize( 250, 400 ).Resizable() );
.MinSize( 250, -1 ).BestSize( 250, -1 ) );
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
.Right().Layer(2) );

View File

@ -135,6 +135,9 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_footprint_browser ) );
SetIcon( icon );
m_libListWidth = 200;
m_fpListWidth = 300;
wxPanel* libPanel = new wxPanel( this );
wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
@ -274,6 +277,44 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
// after changing something to the aui manager call Update() to reflect the changes
m_auimgr.Update();
if( m_libListWidth > 0 )
{
wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Libraries" );
// wxAUI hack: force width by setting MinSize() and then Fixed()
// thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
treePane.MinSize( m_libListWidth, -1 );
treePane.Fixed();
m_auimgr.Update();
// now make it resizable again
treePane.Resizable();
m_auimgr.Update();
// Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
// back to minimum.
treePane.MinSize( 100, -1 );
}
if( m_fpListWidth > 0 )
{
wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
// wxAUI hack: force width by setting MinSize() and then Fixed()
// thanks to ZenJu http://trac.wxwidgets.org/ticket/13180
treePane.MinSize( m_fpListWidth, -1 );
treePane.Fixed();
m_auimgr.Update();
// now make it resizable again
treePane.Resizable();
m_auimgr.Update();
// Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size
// back to minimum.
treePane.MinSize( 100, -1 );
}
// The canvas should not steal the focus from the list boxes
GetCanvas()->SetCanFocus( false );
GetCanvas()->GetGAL()->SetAxesEnabled( true );
@ -794,6 +835,18 @@ void FOOTPRINT_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
m_displayOptions = fpedit->m_Display;
GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window );
m_libListWidth = cfg->m_FootprintViewerLibListWidth;
m_fpListWidth = cfg->m_FootprintViewerFPListWidth;
// Set parameters to a reasonable value.
int maxWidth = cfg->m_FootprintViewer.state.size_x - 80;
if( m_libListWidth + m_fpListWidth > maxWidth )
{
m_libListWidth = maxWidth * ( m_libListWidth / ( m_libListWidth + m_fpListWidth ) );
m_fpListWidth = maxWidth - m_libListWidth;
}
}
@ -809,6 +862,15 @@ void FOOTPRINT_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
if( GetCanvas() && GetCanvas()->GetView() )
cfg->m_FootprintViewerZoom = GetCanvas()->GetView()->GetScale();
if( m_libListWidth && m_libList )
m_libListWidth = m_libList->GetSize().x;
m_fpListWidth = m_fpList->GetSize().x;
cfg->m_FootprintViewerLibListWidth = m_libListWidth;
cfg->m_FootprintViewerFPListWidth = m_fpListWidth;
}

View File

@ -166,8 +166,11 @@ private:
wxSearchCtrl* m_libFilter;
wxListBox* m_libList; // The list of library names.
int m_libListWidth; // Last width of the window.
wxSearchCtrl* m_fpFilter;
wxListBox* m_fpList; // The list of footprint names.
int m_fpListWidth; // Last width of the window.
bool m_autoZoom;
double m_lastZoom;

View File

@ -76,7 +76,9 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_AutoRefillZones( true ),
m_AllowFreePads( false ),
m_PnsSettings( nullptr ),
m_FootprintViewerZoom( 1.0 )
m_FootprintViewerZoom( 1.0 ),
m_FootprintViewerLibListWidth( 200 ),
m_FootprintViewerFPListWidth( 300 )
{
m_MagneticItems.pads = MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL;
m_MagneticItems.tracks = MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL;
@ -511,6 +513,12 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_params.emplace_back( new PARAM<double>( "footprint_viewer.zoom",
&m_FootprintViewerZoom, 1.0 ) );
m_params.emplace_back( new PARAM<int>( "footprint_viewer.lib_list_width",
&m_FootprintViewerLibListWidth, 200 ) );
m_params.emplace_back( new PARAM<int>( "footprint_viewer.fp_list_width",
&m_FootprintViewerFPListWidth, 300 ) );
addParamsForWindow( &m_FootprintWizard, "footprint_wizard" );
m_params.emplace_back( new PARAM<wxString>( "system.last_footprint_lib_dir",

View File

@ -299,7 +299,9 @@ public:
std::unique_ptr<PNS::ROUTING_SETTINGS> m_PnsSettings;
double m_FootprintViewerZoom; ///< The last zoom level used (0 for auto)
double m_FootprintViewerZoom; ///< The last zoom level used (0 for auto)
int m_FootprintViewerLibListWidth;
int m_FootprintViewerFPListWidth;
wxString m_lastFootprintLibDir;