Eeschema, hierarchy navigator: fixes and enhancements.

Work in progress.
This commit is contained in:
jean-pierre charras 2022-06-08 18:09:25 +02:00
parent 46fd32b738
commit b401e98c80
5 changed files with 92 additions and 19 deletions

View File

@ -161,9 +161,21 @@ void SCH_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{
eeconfig()->m_System.units = static_cast<int>( 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;
}
}
}

View File

@ -125,8 +125,17 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
m_params.emplace_back( new PARAM<bool>( "aui.show_schematic_hierarchy",
&m_AuiPanels.show_schematic_hierarchy, true ) );
m_params.emplace_back( new PARAM<int>( "aui.left_panel_width",
&m_AuiPanels.left_panel_width, -1 ) );
m_params.emplace_back( new PARAM<int>( "aui.hierarchy_panel_docked_width",
&m_AuiPanels.hierarchy_panel_docked_width, -1 ) );
m_params.emplace_back( new PARAM<int>( "aui.hierarchy_panel_float_width",
&m_AuiPanels.hierarchy_panel_float_width, -1 ) );
m_params.emplace_back( new PARAM<int>( "aui.hierarchy_panel_float_height",
&m_AuiPanels.hierarchy_panel_float_height, -1 ) );
m_params.emplace_back( new PARAM<bool>( "aui.schematic_hierarchy_float",
&m_AuiPanels.schematic_hierarchy_float, false ) );
m_params.emplace_back( new PARAM<bool>( "autoplace_fields.enable",
&m_AutoplaceFields.enable, true ) );

View File

@ -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

View File

@ -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 );
}

View File

@ -227,19 +227,45 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar()
void SCH_EDIT_FRAME::ToggleSchematicHierarchy()
{
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( 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();
}