diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index 803bc9c65c..b4185c5897 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -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( 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) - .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() ); @@ -229,6 +229,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(); @@ -791,11 +829,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; + } } diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 9afdd2ccb8..f9e30d58ec 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -217,7 +217,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) ); @@ -245,6 +245,25 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : 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" ); if( m_editorSettings->m_LibWidth > 0 ) diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index c9a95cf4a6..e9eec1ae3a 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -137,6 +137,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 ); @@ -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 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 ); @@ -816,6 +857,18 @@ void FOOTPRINT_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) auto fpedit = Pgm().GetSettingsManager().GetAppSettings(); 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; + } } @@ -834,6 +887,15 @@ void FOOTPRINT_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) wxAuiToolBarItem* toolOpt = m_mainToolBar->FindTool( ID_FPVIEWER_AUTOZOOM_TOOL ); 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; + } diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index 9687aca449..80d3a4e348 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -167,8 +167,11 @@ private: wxSearchCtrl* m_libFilter; WX_LISTBOX* m_libList; // The list of library names. + int m_libListWidth; // Last width of the window. + wxSearchCtrl* m_fpFilter; WX_LISTBOX* m_fpList; // The list of footprint names. + int m_fpListWidth; // Last width of the window. bool m_autoZoom; double m_lastZoom; diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index a6e15ddb74..3bf88adf09 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -77,7 +77,9 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_AllowFreePads( false ), m_PnsSettings( nullptr ), 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.tracks = MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL; @@ -529,6 +531,12 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_params.emplace_back( new PARAM( "footprint_viewer.autozoom", &m_FootprintViewerAutoZoomOnSelect, true ) ); + m_params.emplace_back( new PARAM( "footprint_viewer.lib_list_width", + &m_FootprintViewerLibListWidth, 200 ) ); + + m_params.emplace_back( new PARAM( "footprint_viewer.fp_list_width", + &m_FootprintViewerFPListWidth, 300 ) ); + addParamsForWindow( &m_FootprintWizard, "footprint_wizard" ); m_params.emplace_back( new PARAM( "system.last_footprint_lib_dir", diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h index 717f075da6..6c88c194e4 100644 --- a/pcbnew/pcbnew_settings.h +++ b/pcbnew/pcbnew_settings.h @@ -351,6 +351,8 @@ public: double m_FootprintViewerZoom; ///< The last zoom level used (0 for auto) bool m_FootprintViewerAutoZoomOnSelect; ///< true to use automatic zoom on fp selection + int m_FootprintViewerLibListWidth; + int m_FootprintViewerFPListWidth; wxString m_lastFootprintLibDir;