diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 52ea1fedf7..43ac0a0235 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -140,8 +140,6 @@ void SCH_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) // For now, axes are forced off in Eeschema even if turned on in config eeconfig()->m_Window.grid.axes_enabled = false; - m_showHierarchy = eeconfig()->m_AuiPanels.show_schematic_hierarchy; - SCH_BASE_FRAME::LoadSettings( eeconfig() ); GetRenderSettings()->m_ShowPinsElectricalType = false; @@ -152,13 +150,12 @@ void SCH_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { SCH_BASE_FRAME::SaveSettings( eeconfig() ); wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() ); - m_showHierarchy = hierarchy_pane.IsShown(); // TODO(JE) do we need to keep m_userUnits around? if( eeconfig() ) { eeconfig()->m_System.units = static_cast( m_userUnits ); - eeconfig()->m_AuiPanels.show_schematic_hierarchy = m_showHierarchy; + eeconfig()->m_AuiPanels.show_schematic_hierarchy = hierarchy_pane.IsShown(); eeconfig()->m_AuiPanels.schematic_hierarchy_float = hierarchy_pane.IsFloating(); // Other parameters (hierarchy_panel_float_width, hierarchy_panel_float_height, // and hierarchy_panel_docked_width should have been updated when resizing the diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index eac8bc978b..8791dbf0bb 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -119,7 +119,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_schematic = new SCHEMATIC( nullptr ); m_showBorderAndTitleBlock = true; // true to show sheet references - m_showHierarchy = true; m_supportsAutoSave = true; m_aboutTitle = _( "KiCad Schematic Editor" ); @@ -161,51 +160,84 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.SetManagedWindow( this ); CreateInfoBar(); + + // Rows; layers 4 - 6 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ) .Top().Layer( 6 ) ); - m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ) - .Left().Layer( 4 ) ); + + m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) + .Bottom().Layer( 6 ) ); + + // Columns; layers 1 - 3 m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() ) - .Caption( _("Schematic Hierarchy") ) + .Caption( _( "Schematic Hierarchy" ) ) .Left().Layer( 3 ) .TopDockable( false ) .BottomDockable( false ) .CloseButton( true ) - .MinSize(120, -1) - .BestSize(200, -1) + .MinSize( 120, -1 ) + .BestSize( 200, -1 ) .FloatingSize( 200, 80 ) - .Show( false ) - ); + .Show( false ) ); + m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ) + .Left().Layer( 2 ) ); + m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ) .Right().Layer( 2 ) ); + + // Center m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ) .Center() ); - m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) - .Bottom().Layer( 6 ) ); - wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() ); + FinishAUIInitialization(); - if( eeconfig() ) - { - if( eeconfig()->m_AuiPanels.hierarchy_panel_float_width > 0 - && eeconfig()->m_AuiPanels.hierarchy_panel_float_height > 0 ) - { - hierarchy_pane.FloatingSize( eeconfig()->m_AuiPanels.hierarchy_panel_float_width, - eeconfig()->m_AuiPanels.hierarchy_panel_float_height ); - } + resolveCanvasType(); + SwitchCanvas( m_canvasType ); - if( eeconfig()->m_AuiPanels.hierarchy_panel_docked_width > 0 ) - { - hierarchy_pane.BestSize( eeconfig()->m_AuiPanels.hierarchy_panel_docked_width, -1); - SetAuiPaneSize( m_auimgr, hierarchy_pane, - eeconfig()->m_AuiPanels.hierarchy_panel_docked_width, -1 ); - } + GetCanvas()->GetGAL()->SetAxesEnabled( false ); + + KIGFX::SCH_VIEW* view = GetCanvas()->GetView(); + static_cast( view->GetPainter() )->SetSchematic( m_schematic ); + + wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() ); + EESCHEMA_SETTINGS* cfg = eeconfig(); + + hierarchy_pane.Show( cfg->m_AuiPanels.show_schematic_hierarchy ); + + if( cfg->m_AuiPanels.hierarchy_panel_float_width > 0 + && cfg->m_AuiPanels.hierarchy_panel_float_height > 0 ) + { + // Show at end, after positioning + hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width, + cfg->m_AuiPanels.hierarchy_panel_float_height ); } - FinishAUIInitialization(); + if( cfg->m_AuiPanels.schematic_hierarchy_float ) + hierarchy_pane.Float(); - resolveCanvasType(); - SwitchCanvas( m_canvasType ); + if( cfg->m_AuiPanels.hierarchy_panel_docked_width > 0 ) + { + SetAuiPaneSize( m_auimgr, hierarchy_pane, + cfg->m_AuiPanels.hierarchy_panel_docked_width, -1 ); + + // wxAUI hack: force width by setting MinSize() and then Fixed() + // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180 + hierarchy_pane.MinSize( cfg->m_AuiPanels.hierarchy_panel_docked_width, -1 ); + hierarchy_pane.Fixed(); + m_auimgr.Update(); + + // now make it resizable again + hierarchy_pane.Resizable(); + m_auimgr.Update(); + + // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size + // back to minimum. + hierarchy_pane.MinSize( 120, -1 ); + } + else + { + m_auimgr.Update(); + } LoadProjectSettings(); @@ -220,14 +252,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize(). Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this ); - if( GetCanvas() ) - { - GetCanvas()->GetGAL()->SetAxesEnabled( false ); - - if( auto p = dynamic_cast( GetCanvas()->GetView()->GetPainter() ) ) - p->SetSchematic( m_schematic ); - } - setupUnits( eeconfig() ); // Net list generator @@ -242,24 +266,18 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // Ensure the window is on top Raise(); - // Now every sizes are fixed, set the initial hierarchy_pane floating position - // to the left top corner of the canvas + // Now that all sizes are fixed, set the initial hierarchy_pane floating position to the + // top-left corner of the canvas wxPoint canvas_pos = GetCanvas()->GetScreenPosition(); hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 ); - - if( eeconfig() && eeconfig()->m_AuiPanels.schematic_hierarchy_float ) - hierarchy_pane.Float(); - - hierarchy_pane.Show( m_showHierarchy ); } SCH_EDIT_FRAME::~SCH_EDIT_FRAME() { - m_hierarchy->Disconnect( wxEVT_SIZE, - wxSizeEventHandler( SCH_EDIT_FRAME::OnResizeHierarchyNavigator ), - NULL, this ); + wxSizeEventHandler( SCH_EDIT_FRAME::OnResizeHierarchyNavigator ), + NULL, this ); // Ensure m_canvasType is up to date, to save it in config m_canvasType = GetCanvas()->GetBackend(); @@ -311,7 +329,7 @@ void SCH_EDIT_FRAME::OnResizeHierarchyNavigator( wxSizeEvent& aEvent ) // Store the current pane size // It allows to retrieve the last defined pane size when switching between // docked and floating pane state - // Note: *DO NOT* call m_auimgr.Update() here: it crashes Kicad at leat on Windows + // Note: *DO NOT* call m_auimgr.Update() here: it crashes Kicad at least on Windows EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() ); @@ -799,6 +817,14 @@ void SCH_EDIT_FRAME::doCloseWindow() m_findReplaceDialog = nullptr; } + wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() ); + + if( hierarchy_pane.IsShown() && hierarchy_pane.IsFloating() ) + { + hierarchy_pane.Show( false ); + m_auimgr.Update(); + } + if( Kiway().Player( FRAME_SIMULATOR, false ) ) Prj().GetProjectFile().m_SchematicSettings->m_NgspiceSimulatorSettings->SaveToFile(); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 9bfc9e56cf..6d1be195bc 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -923,7 +923,6 @@ private: DIALOG_SCH_FIND* m_findReplaceDialog; HIERARCHY_NAVIG_PANEL* m_hierarchy; - bool m_showHierarchy; }; diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index dca51059cb..ff08454c5e 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -175,20 +175,26 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.SetManagedWindow( this ); CreateInfoBar(); + + // Rows; layers 4 - 6 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ) .Top().Layer( 6 ) ); + m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) .Bottom().Layer( 6 ) ); - m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ) - .Left().Layer( 3 ) ); + // Columns; layers 1 - 3 m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "SymbolTree" ) - .Left().Layer( 2 ) + .Left().Layer( 3 ) .Caption( _( "Libraries" ) ) .MinSize( 250, -1 ).BestSize( 250, -1 ) ); + m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ) + .Left().Layer( 2 ) ); + m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ) .Right().Layer( 2 ) ); + // Center m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" ) .CentrePane() ); diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index 66b8e43bb5..8384b17839 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -226,45 +226,36 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar() void SCH_EDIT_FRAME::ToggleSchematicHierarchy() { - EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); + EESCHEMA_SETTINGS* cfg = eeconfig(); wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() ); - m_showHierarchy = hierarchy_pane.IsShown(); - // show auxiliary Vertical layers and visibility manager toolbar - m_showHierarchy = !m_showHierarchy; - hierarchy_pane.Show( m_showHierarchy ); + hierarchy_pane.Show( !hierarchy_pane.IsShown() ); - if( m_showHierarchy ) + if( hierarchy_pane.IsShown() ) { - if( cfg ) + if( hierarchy_pane.IsFloating() ) { - if( hierarchy_pane.IsFloating() ) - { - hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width, - cfg->m_AuiPanels.hierarchy_panel_float_height ); - m_auimgr.Update(); - } - else - { - hierarchy_pane.BestSize( cfg->m_AuiPanels.hierarchy_panel_docked_width, -1); - // SetAuiPaneSize also update m_auimgr - SetAuiPaneSize( m_auimgr, hierarchy_pane, cfg->m_AuiPanels.hierarchy_panel_docked_width, -1 ); - } - } - else + hierarchy_pane.FloatingSize( cfg->m_AuiPanels.hierarchy_panel_float_width, + cfg->m_AuiPanels.hierarchy_panel_float_height ); m_auimgr.Update(); + } + else if( cfg->m_AuiPanels.hierarchy_panel_docked_width > 0 ) + { + // SetAuiPaneSize also updates m_auimgr + SetAuiPaneSize( m_auimgr, hierarchy_pane, + cfg->m_AuiPanels.hierarchy_panel_docked_width, -1 ); + } } else { - if( cfg ) + if( hierarchy_pane.IsFloating() ) + { + cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x; + cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y; + } + else { - if( hierarchy_pane.IsFloating() ) - { - cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x; - cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y; - } - else - cfg->m_AuiPanels.hierarchy_panel_docked_width = m_hierarchy->GetSize().x; + cfg->m_AuiPanels.hierarchy_panel_docked_width = m_hierarchy->GetSize().x; } m_auimgr.Update(); diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 30fecdc306..eb47043239 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -208,20 +208,20 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // Rows; layers 4 - 6 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ) .Top().Layer( 6 ) ); + m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) .Bottom().Layer( 6 ) ); // Columns; layers 1 - 3 - m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ) - .Left().Layer( 3 ) ); m_auimgr.AddPane( m_treePane, EDA_PANE().Palette().Name( "Footprints" ) - .Left().Layer(2) + .Left().Layer( 3 ) .Caption( _( "Libraries" ) ) .MinSize( 250, -1 ).BestSize( 250, -1 ) ); + m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ) + .Left().Layer( 2 ) ); m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ) .Right().Layer(2) ); - m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" ) .Right().Layer( 3 ) .Caption( _( "Appearance" ) ).PaneBorder( false ) @@ -245,41 +245,44 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : FinishAUIInitialization(); - if( GetSettings()->m_LibWidth > 0 ) + // Apply saved visibility stuff at the end + FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings(); + wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" ); + wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" ); + + // wxAUI hack: force widths by setting MinSize() and then Fixed() + // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180 + + if( cfg->m_LibWidth > 0 ) { - wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" ); + SetAuiPaneSize( m_auimgr, treePane, cfg->m_LibWidth, -1 ); - // 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.MinSize( cfg->m_LibWidth, -1 ); treePane.Fixed(); - m_auimgr.Update(); + } - // now make it resizable again - treePane.Resizable(); - m_auimgr.Update(); + if( cfg->m_AuiPanels.right_panel_width > 0 ) + { + SetAuiPaneSize( m_auimgr, layersManager, cfg->m_AuiPanels.right_panel_width, -1 ); - // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the size - // back to minimum. - treePane.MinSize( 250, -1 ); + layersManager.MinSize( cfg->m_LibWidth, -1 ); + layersManager.Fixed(); } - wxAuiPaneInfo& treePane = m_auimgr.GetPane( "Footprints" ); + // Apply fixed sizes + m_auimgr.Update(); - if( m_editorSettings->m_LibWidth > 0 ) - SetAuiPaneSize( m_auimgr, treePane, m_editorSettings->m_LibWidth, -1 ); + // Now make them resizable again + treePane.Resizable(); + m_auimgr.Update(); + + // Note: DO NOT call m_auimgr.Update() anywhere after this; it will nuke the sizes + // back to minimum. + treePane.MinSize( 250, -1 ); + layersManager.MinSize( 250, -1 ); - // Apply saved visibility stuff at the end - FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings(); m_appearancePanel->SetUserLayerPresets( cfg->m_LayerPresets ); m_appearancePanel->ApplyLayerPreset( cfg->m_ActiveLayerPreset ); - - if( cfg->m_AuiPanels.right_panel_width > 0 ) - { - wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" ); - SetAuiPaneSize( m_auimgr, layersManager, cfg->m_AuiPanels.right_panel_width, -1 ); - } - m_appearancePanel->SetTabIndex( cfg->m_AuiPanels.appearance_panel_tab ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false ); @@ -364,7 +367,10 @@ void FOOTPRINT_EDIT_FRAME::ToggleSearchTree() treePane.Show( !IsSearchTreeShown() ); if( IsSearchTreeShown() ) + { + // SetAuiPaneSize also updates m_auimgr SetAuiPaneSize( m_auimgr, treePane, m_editorSettings->m_LibWidth, -1 ); + } else { m_editorSettings->m_LibWidth = m_treePane->GetSize().x;