Fix some issue with hierarchy panel on OSX.

Also moves the option toolbars tight to the canvas for all windows.

Fixes https://gitlab.com/kicad/code/kicad/issues/12087
This commit is contained in:
Jeff Young 2022-07-26 12:13:16 +01:00
parent 008b4f583b
commit ee0f93ed17
6 changed files with 141 additions and 116 deletions

View File

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

View File

@ -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,10 +160,15 @@ 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" ) )
.Left().Layer( 3 )
@ -174,39 +178,67 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
.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() );
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 );
}
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 );
}
}
FinishAUIInitialization();
resolveCanvasType();
SwitchCanvas( m_canvasType );
GetCanvas()->GetGAL()->SetAxesEnabled( false );
KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
static_cast<KIGFX::SCH_PAINTER*>( 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 );
}
if( cfg->m_AuiPanels.schematic_hierarchy_float )
hierarchy_pane.Float();
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();
initScreenZoom();
@ -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<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() ) )
p->SetSchematic( m_schematic );
}
setupUnits( eeconfig() );
// Net list generator
@ -242,21 +266,15 @@ 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 );
@ -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<EESCHEMA_SETTINGS*>( 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();

View File

@ -923,7 +923,6 @@ private:
DIALOG_SCH_FIND* m_findReplaceDialog;
HIERARCHY_NAVIG_PANEL* m_hierarchy;
bool m_showHierarchy;
};

View File

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

View File

@ -226,17 +226,12 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar()
void SCH_EDIT_FRAME::ToggleSchematicHierarchy()
{
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( 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( cfg )
if( hierarchy_pane.IsShown() )
{
if( hierarchy_pane.IsFloating() )
{
@ -244,19 +239,14 @@ void SCH_EDIT_FRAME::ToggleSchematicHierarchy()
cfg->m_AuiPanels.hierarchy_panel_float_height );
m_auimgr.Update();
}
else
else if( cfg->m_AuiPanels.hierarchy_panel_docked_width > 0 )
{
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 );
// SetAuiPaneSize also updates m_auimgr
SetAuiPaneSize( m_auimgr, hierarchy_pane,
cfg->m_AuiPanels.hierarchy_panel_docked_width, -1 );
}
}
else
m_auimgr.Update();
}
else
{
if( cfg )
{
if( hierarchy_pane.IsFloating() )
{
@ -264,6 +254,7 @@ void SCH_EDIT_FRAME::ToggleSchematicHierarchy()
cfg->m_AuiPanels.hierarchy_panel_float_height = hierarchy_pane.floating_size.y;
}
else
{
cfg->m_AuiPanels.hierarchy_panel_docked_width = m_hierarchy->GetSize().x;
}

View File

@ -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 )
{
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 )
SetAuiPaneSize( m_auimgr, treePane, m_editorSettings->m_LibWidth, -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 );
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 )
{
SetAuiPaneSize( m_auimgr, treePane, cfg->m_LibWidth, -1 );
treePane.MinSize( cfg->m_LibWidth, -1 );
treePane.Fixed();
}
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 );
layersManager.MinSize( cfg->m_LibWidth, -1 );
layersManager.Fixed();
}
// Apply fixed sizes
m_auimgr.Update();
// 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 );
m_appearancePanel->SetUserLayerPresets( cfg->m_LayerPresets );
m_appearancePanel->ApplyLayerPreset( cfg->m_ActiveLayerPreset );
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;