diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp
index 3b38a0344c..52ea1fedf7 100644
--- a/eeschema/eeschema_config.cpp
+++ b/eeschema/eeschema_config.cpp
@@ -1,24 +1,20 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
- * Copyright (C) 2014-2021 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you may find one here:
- * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
- * or you may search the http://www.gnu.org website for the version 2 license,
- * or you may write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
*/
#include
@@ -155,27 +151,18 @@ void SCH_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
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 );
- wxAuiPaneInfo& hierarchy = m_auimgr.GetPane( SchematicHierarchyPaneName() );
- m_showHierarchy = hierarchy.IsShown();
eeconfig()->m_AuiPanels.show_schematic_hierarchy = m_showHierarchy;
-
- if( hierarchy.IsFloating() )
- {
- eeconfig()->m_AuiPanels.schematic_hierarchy_float = true;
- eeconfig()->m_AuiPanels.hierarchy_panel_float_width = hierarchy.floating_size.x;
- eeconfig()->m_AuiPanels.hierarchy_panel_float_height = hierarchy.floating_size.y;
- }
- else
- {
- eeconfig()->m_AuiPanels.hierarchy_panel_docked_width = m_hierarchy->GetSize().x;
- eeconfig()->m_AuiPanels.schematic_hierarchy_float = false;
- }
-
+ 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
+ // hierarchy panel
}
}
diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp
index b0cbe08036..a9b2f48e9f 100644
--- a/eeschema/sch_edit_frame.cpp
+++ b/eeschema/sch_edit_frame.cpp
@@ -172,8 +172,9 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
.BottomDockable( false )
.CloseButton( true )
.MinSize(120, -1)
- .BestSize(150, -1)
+ .BestSize(200, -1)
.FloatingSize( 200, 80 )
+ .Show( false )
);
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
.Right().Layer( 2 ) );
@@ -186,11 +187,12 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
if( eeconfig() )
{
- hierarchy_pane.FloatingSize( eeconfig()->m_AuiPanels.hierarchy_panel_float_width,
- eeconfig()->m_AuiPanels.hierarchy_panel_float_height );
-
- if( eeconfig()->m_AuiPanels.schematic_hierarchy_float )
- hierarchy_pane.Float();
+ 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 );
+ }
if( eeconfig()->m_AuiPanels.hierarchy_panel_docked_width > 0 )
{
@@ -200,8 +202,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
}
}
- hierarchy_pane.Show( m_showHierarchy );
-
FinishAUIInitialization();
resolveCanvasType();
@@ -211,6 +211,11 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
initScreenZoom();
+ m_hierarchy->Connect( wxEVT_SIZE,
+ wxSizeEventHandler( SCH_EDIT_FRAME::OnResizeHierarchyNavigator ),
+ NULL, this );
+
+
// This is used temporarily to fix a client size issue on GTK that causes zoom to fit
// to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
@@ -241,11 +246,20 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// to the left top 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 );
// Ensure m_canvasType is up to date, to save it in config
m_canvasType = GetCanvas()->GetBackend();
@@ -289,6 +303,38 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
}
+void SCH_EDIT_FRAME::OnResizeHierarchyNavigator( wxSizeEvent& aEvent )
+{
+ aEvent.Skip();
+
+ // Called when resizing the Hierarchy Navigator panel
+ // 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
+
+ EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() );
+ wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() );
+
+ if( cfg && m_hierarchy->IsShown() )
+ {
+ cfg->m_AuiPanels.hierarchy_panel_float_width = hierarchy_pane.floating_size.x;
+ cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
+
+ // initialize hierarchy_panel_docked_width and best size only if the hierarchy_pane
+ // width is > 0 (i.e. if its size is already set and has meaning)
+ // if it is floating, its size is not initialized (only floating_size is initialized)
+ // initializing hierarchy_pane.best_size is useful when switching to float pane and
+ // after switching to the docked pane, to retrieve the last docked pane width
+ if( hierarchy_pane.rect.width > 50 ) // 50 is a good margin
+ {
+ cfg->m_AuiPanels.hierarchy_panel_docked_width = hierarchy_pane.rect.width;
+ hierarchy_pane.best_size.x = hierarchy_pane.rect.width;
+ }
+ }
+}
+
+
void SCH_EDIT_FRAME::setupTools()
{
// Create the manager and dispatcher & route draw panel events to the dispatcher
diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h
index d01455fae8..8948c64fe9 100644
--- a/eeschema/sch_edit_frame.h
+++ b/eeschema/sch_edit_frame.h
@@ -3,7 +3,7 @@
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh
- * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -864,6 +864,9 @@ protected:
void onSize( wxSizeEvent& aEvent );
private:
+ // Called when resizing the Hierarchy Navigator panel
+ void OnResizeHierarchyNavigator( wxSizeEvent& aEvent );
+
// Sets up the tool framework
void setupTools();