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
This commit is contained in:
Jeff Young 2022-07-10 21:00:46 -06:00
parent b8e2278b86
commit 0a623bff9f
6 changed files with 142 additions and 8 deletions

View File

@ -219,9 +219,9 @@ SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAM
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) .Bottom().Layer(6) ); m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) .Bottom().Layer(6) );
m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2) m_auimgr.AddPane( libPanel, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
.CaptionVisible( false ).MinSize( 100, -1 ).BestSize( m_libListWidth, -1 ) ); .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
m_auimgr.AddPane( symbolPanel, EDA_PANE().Palette().Name( "Symbols" ).Left().Layer(1) m_auimgr.AddPane( symbolPanel, EDA_PANE().Palette().Name( "Symbols" ).Left().Layer(1)
.CaptionVisible( false ).MinSize( 100, -1 ).BestSize( m_symbolListWidth, -1 ) ); .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
@ -229,6 +229,44 @@ SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAM
m_auimgr.Update(); 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 if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
{ {
Raise(); Raise();
@ -791,11 +829,13 @@ void SYMBOL_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_LibViewPanel.show_pin_electrical_type; GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_LibViewPanel.show_pin_electrical_type;
// Set parameters to a reasonable value. // Set parameters to a reasonable value.
if( m_libListWidth > m_frameSize.x / 2 ) int maxWidth = cfg->m_LibViewPanel.window.state.size_x - 80;
m_libListWidth = m_frameSize.x / 2;
if( m_symbolListWidth > m_frameSize.x / 2 ) if( m_libListWidth + m_symbolListWidth > maxWidth )
m_symbolListWidth = m_frameSize.x / 2; {
m_libListWidth = maxWidth * ( m_libListWidth / ( m_libListWidth + m_symbolListWidth ) );
m_symbolListWidth = maxWidth - m_libListWidth;
}
} }

View File

@ -217,7 +217,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" ) m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" )
.Left().Layer(2) .Left().Layer(2)
.Caption( _( "Libraries" ) ) .Caption( _( "Libraries" ) )
.MinSize( 250, 400 ).Resizable() ); .MinSize( 250, -1 ).BestSize( 250, -1 ) );
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ) m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
.Right().Layer(2) ); .Right().Layer(2) );
@ -245,6 +245,25 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
FinishAUIInitialization(); FinishAUIInitialization();
if( GetSettings()->m_LibWidth > 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( GetSettings()->m_LibWidth, -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( 250, -1 );
}
wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" ); wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" );
if( m_editorSettings->m_LibWidth > 0 ) if( m_editorSettings->m_LibWidth > 0 )

View File

@ -137,6 +137,9 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_footprint_browser ) ); icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_footprint_browser ) );
SetIcon( icon ); SetIcon( icon );
m_libListWidth = 200;
m_fpListWidth = 300;
wxPanel* libPanel = new wxPanel( this ); wxPanel* libPanel = new wxPanel( this );
wxSizer* libSizer = new wxBoxSizer( wxVERTICAL ); wxSizer* libSizer = new wxBoxSizer( wxVERTICAL );
@ -276,6 +279,44 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
// after changing something to the aui manager call Update() to reflect the changes // after changing something to the aui manager call Update() to reflect the changes
m_auimgr.Update(); 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 // The canvas should not steal the focus from the list boxes
GetCanvas()->SetCanFocus( false ); GetCanvas()->SetCanFocus( false );
GetCanvas()->GetGAL()->SetAxesEnabled( true ); GetCanvas()->GetGAL()->SetAxesEnabled( true );
@ -816,6 +857,18 @@ void FOOTPRINT_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>(); auto fpedit = Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
m_displayOptions = fpedit->m_Display; m_displayOptions = fpedit->m_Display;
GetGalDisplayOptions().ReadWindowSettings( fpedit->m_Window ); 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;
}
} }
@ -834,6 +887,15 @@ void FOOTPRINT_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL ); wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL );
cfg->m_FootprintViewerAutoZoomOnSelect = ( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED ); cfg->m_FootprintViewerAutoZoomOnSelect = ( toolOpt->GetState() & wxAUI_BUTTON_STATE_CHECKED );
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

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

View File

@ -77,7 +77,9 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_AllowFreePads( false ), m_AllowFreePads( false ),
m_PnsSettings( nullptr ), m_PnsSettings( nullptr ),
m_FootprintViewerZoom( 1.0 ), m_FootprintViewerZoom( 1.0 ),
m_FootprintViewerAutoZoomOnSelect( true ) m_FootprintViewerAutoZoomOnSelect( true ),
m_FootprintViewerLibListWidth( 200 ),
m_FootprintViewerFPListWidth( 300 )
{ {
m_MagneticItems.pads = MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL; m_MagneticItems.pads = MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL;
m_MagneticItems.tracks = MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL; m_MagneticItems.tracks = MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL;
@ -529,6 +531,12 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom", m_params.emplace_back( new PARAM<bool>( "footprint_viewer.autozoom",
&m_FootprintViewerAutoZoomOnSelect, true ) ); &m_FootprintViewerAutoZoomOnSelect, true ) );
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" ); addParamsForWindow( &m_FootprintWizard, "footprint_wizard" );
m_params.emplace_back( new PARAM<wxString>( "system.last_footprint_lib_dir", m_params.emplace_back( new PARAM<wxString>( "system.last_footprint_lib_dir",

View File

@ -351,6 +351,8 @@ public:
double m_FootprintViewerZoom; ///< The last zoom level used (0 for auto) double m_FootprintViewerZoom; ///< The last zoom level used (0 for auto)
bool m_FootprintViewerAutoZoomOnSelect; ///< true to use automatic zoom on fp selection bool m_FootprintViewerAutoZoomOnSelect; ///< true to use automatic zoom on fp selection
int m_FootprintViewerLibListWidth;
int m_FootprintViewerFPListWidth;
wxString m_lastFootprintLibDir; wxString m_lastFootprintLibDir;