diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 911ded445b..3b38a0344c 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -161,9 +161,21 @@ void SCH_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { eeconfig()->m_System.units = static_cast( m_userUnits ); wxAuiPaneInfo& hierarchy = m_auimgr.GetPane( SchematicHierarchyPaneName() ); - m_showHierarchy = hierarchy.IsShown(); + m_showHierarchy = hierarchy.IsShown(); eeconfig()->m_AuiPanels.show_schematic_hierarchy = m_showHierarchy; - eeconfig()->m_AuiPanels.left_panel_width = m_hierarchy->GetSize().x; + + 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; + } + } } diff --git a/eeschema/eeschema_settings.cpp b/eeschema/eeschema_settings.cpp index 18b0d015c7..2de09eb4c0 100644 --- a/eeschema/eeschema_settings.cpp +++ b/eeschema/eeschema_settings.cpp @@ -125,8 +125,17 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : m_params.emplace_back( new PARAM( "aui.show_schematic_hierarchy", &m_AuiPanels.show_schematic_hierarchy, true ) ); - m_params.emplace_back( new PARAM( "aui.left_panel_width", - &m_AuiPanels.left_panel_width, -1 ) ); + m_params.emplace_back( new PARAM( "aui.hierarchy_panel_docked_width", + &m_AuiPanels.hierarchy_panel_docked_width, -1 ) ); + + m_params.emplace_back( new PARAM( "aui.hierarchy_panel_float_width", + &m_AuiPanels.hierarchy_panel_float_width, -1 ) ); + + m_params.emplace_back( new PARAM( "aui.hierarchy_panel_float_height", + &m_AuiPanels.hierarchy_panel_float_height, -1 ) ); + + m_params.emplace_back( new PARAM( "aui.schematic_hierarchy_float", + &m_AuiPanels.schematic_hierarchy_float, false ) ); m_params.emplace_back( new PARAM( "autoplace_fields.enable", &m_AutoplaceFields.enable, true ) ); diff --git a/eeschema/eeschema_settings.h b/eeschema/eeschema_settings.h index 7335a55098..b91e03a764 100644 --- a/eeschema/eeschema_settings.h +++ b/eeschema/eeschema_settings.h @@ -65,8 +65,11 @@ public: struct AUI_PANELS { - int left_panel_width; - bool show_schematic_hierarchy; + int hierarchy_panel_docked_width; // width of hierarchy tree panel and pane when docked + int hierarchy_panel_float_width; // width of hierarchy tree panel when floating + int hierarchy_panel_float_height; // height of hierarchy tree panel when floating + bool schematic_hierarchy_float; // show hierarchy tree panel as floating + bool show_schematic_hierarchy; // show hierarchy tree pane }; struct AUTOPLACE_FIELDS diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 7e73989954..cebef0e2ee 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -270,9 +270,13 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.AddPane( m_hierarchy, EDA_PANE().Palette().Name( SchematicHierarchyPaneName() ) .Caption( _("Schematic Hierarchy") ) .Left().Layer( 3 ) + .TopDockable( false ) + .BottomDockable( false ) .CloseButton( true ) .MinSize(120, -1) - .BestSize(200, -1)); + .BestSize(150, -1) + .FloatingSize( 200, 80 ) + ); m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ) .Right().Layer( 2 ) ); m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ) @@ -280,6 +284,26 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) .Bottom().Layer( 6 ) ); + wxAuiPaneInfo& hierarchy_pane = m_auimgr.GetPane( SchematicHierarchyPaneName() ); + + 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_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 ); + } + } + + hierarchy_pane.Show( m_showHierarchy ); + FinishAUIInitialization(); resolveCanvasType(); @@ -289,12 +313,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : initScreenZoom(); - wxAuiPaneInfo& hierarchy = m_auimgr.GetPane( SchematicHierarchyPaneName() ); - hierarchy.Show( m_showHierarchy ); - - if( eeconfig() && ( eeconfig()->m_AuiPanels.left_panel_width > 0 ) ) - SetAuiPaneSize( m_auimgr, hierarchy, eeconfig()->m_AuiPanels.left_panel_width, -1 ); - // 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 ); @@ -320,6 +338,11 @@ 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 + wxPoint canvas_pos = GetCanvas()->GetScreenPosition(); + hierarchy_pane.FloatingPosition( canvas_pos.x + 10, canvas_pos.y + 10 ); } diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index 1e9f5b69a9..66b8e43bb5 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -227,19 +227,45 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar() void SCH_EDIT_FRAME::ToggleSchematicHierarchy() { EESCHEMA_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); - wxAuiPaneInfo& hierarchy = m_auimgr.GetPane( SchematicHierarchyPaneName() ); - m_showHierarchy = hierarchy.IsShown(); + 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.Show( m_showHierarchy ); + hierarchy_pane.Show( m_showHierarchy ); - if( m_showHierarchy && cfg ) - SetAuiPaneSize( m_auimgr, hierarchy, cfg->m_AuiPanels.left_panel_width, -1 ); + if( m_showHierarchy ) + { + if( cfg ) + { + 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 + m_auimgr.Update(); + } else { if( cfg ) - cfg->m_AuiPanels.left_panel_width = m_hierarchy->GetSize().x; + { + 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; + } m_auimgr.Update(); }