Nullptr safety for various panels.

Also moves preference saving out to parent as different parents
save different settings.
This commit is contained in:
Jeff Young 2023-09-25 12:35:31 +01:00
parent 7835b8ddc7
commit bf493f32f5
15 changed files with 57 additions and 45 deletions

View File

@ -238,7 +238,7 @@ void SCH_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
wxAuiPaneInfo& propertiesPane = m_auimgr.GetPane( PropertiesPaneName() );
cfg->m_AuiPanels.show_properties = propertiesPane.IsShown();
cfg->m_AuiPanels.properties_splitter_proportion = m_propertiesPanel->SplitterProportion();
cfg->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion();
}
}

View File

@ -256,7 +256,7 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
&m_AuiPanels.properties_panel_width, -1 ) );
m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
&m_AuiPanels.properties_splitter_proportion, 0.5f ) );
&m_AuiPanels.properties_splitter, 0.5f ) );
m_params.emplace_back( new PARAM<bool>( "autoplace_fields.enable",
&m_AutoplaceFields.enable, true ) );

View File

@ -97,7 +97,7 @@ public:
bool float_net_nav_panel;
bool show_net_nav_panel;
int properties_panel_width;
float properties_splitter_proportion;
float properties_splitter;
bool show_properties;
};

View File

@ -179,7 +179,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_searchPane = new SCH_SEARCH_PANE( this );
m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter_proportion );
m_propertiesPanel->SetSplitterProportion( eeconfig()->m_AuiPanels.properties_splitter );
m_auimgr.SetManagedWindow( this );

View File

@ -177,7 +177,7 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
RebuildSymbolUnitsList();
m_propertiesPanel = new SCH_PROPERTIES_PANEL( this, this );
m_propertiesPanel->SetSplitterProportion( m_settings->m_AuiPanels.properties_splitter_proportion );
m_propertiesPanel->SetSplitterProportion( m_settings->m_AuiPanels.properties_splitter );
m_auimgr.SetManagedWindow( this );
@ -307,7 +307,7 @@ void SYMBOL_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
m_settings->m_LibrarySortMode = m_treePane->GetLibTree()->GetSortMode();
m_settings->m_AuiPanels.properties_splitter_proportion = m_propertiesPanel->SplitterProportion();
m_settings->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion();
bool prop_shown = m_auimgr.GetPane( PropertiesPaneName() ).IsShown();
m_settings->m_AuiPanels.show_properties = prop_shown;
}

View File

@ -53,7 +53,7 @@ SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS() :
&m_AuiPanels.properties_panel_width, -1 ) );
m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
&m_AuiPanels.properties_splitter_proportion, 0.5f ) );
&m_AuiPanels.properties_splitter, 0.5f ) );
m_params.emplace_back( new PARAM<int>( "defaults.line_width",
&m_Defaults.line_width, 0 ) );

View File

@ -34,7 +34,7 @@ public:
struct AUI_PANELS
{
int properties_panel_width;
float properties_splitter_proportion;
float properties_splitter;
bool show_properties;
};

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2023 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
@ -37,7 +37,7 @@ public:
bool show_layer_manager;
bool show_properties;
int properties_panel_width;
float properties_splitter_proportion;
float properties_splitter;
};
struct USER_GRID

View File

@ -186,7 +186,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew
LoadSettings( GetSettings() );
float proportion = GetFootprintEditorSettings()->m_AuiPanels.properties_splitter_proportion;
float proportion = GetFootprintEditorSettings()->m_AuiPanels.properties_splitter;
m_propertiesPanel->SetSplitterProportion( proportion );
// Must be set after calling LoadSettings() to be sure these parameters are not dependent
@ -643,24 +643,29 @@ void FOOTPRINT_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{
PCB_BASE_FRAME::SaveSettings( cfg );
cfg->m_DesignSettings = GetDesignSettings();
cfg->m_Display = m_displayOptions;
cfg->m_LibWidth = m_treePane->GetSize().x;
cfg->m_SelectionFilter = GetToolManager()->GetTool<PCB_SELECTION_TOOL>()->GetFilter();
cfg->m_LayerPresets = m_appearancePanel->GetUserLayerPresets();
cfg->m_ActiveLayerPreset = m_appearancePanel->GetActiveLayerPreset();
cfg->m_DesignSettings = GetDesignSettings();
cfg->m_Display = m_displayOptions;
cfg->m_LibWidth = m_treePane->GetSize().x;
cfg->m_SelectionFilter = GetToolManager()->GetTool<PCB_SELECTION_TOOL>()->GetFilter();
cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
cfg->m_AuiPanels.show_properties = m_propertiesPanel->IsShownOnScreen();
cfg->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x;
cfg->m_AuiPanels.properties_splitter_proportion =
m_propertiesPanel->SplitterProportion();
if( m_propertiesPanel )
{
cfg->m_AuiPanels.show_properties = m_propertiesPanel->IsShownOnScreen();
cfg->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x;
cfg->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion();
}
cfg->m_LibrarySortMode = m_treePane->GetLibTree()->GetSortMode();
if( m_appearancePanel )
{
cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
cfg->m_LayerPresets = m_appearancePanel->GetUserLayerPresets();
cfg->m_ActiveLayerPreset = m_appearancePanel->GetActiveLayerPreset();
}
}
}

View File

@ -75,7 +75,7 @@ FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() :
&m_AuiPanels.properties_panel_width, -1 ) );
m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
&m_AuiPanels.properties_splitter_proportion, 0.5f ) );
&m_AuiPanels.properties_splitter, 0.5f ) );
m_params.emplace_back( new PARAM<bool>( "aui.show_properties",
&m_AuiPanels.show_properties, false ) );

View File

@ -257,7 +257,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_propertiesPanel = new PCB_PROPERTIES_PANEL( this, this );
float proportion = GetPcbNewSettings()->m_AuiPanels.properties_splitter_proportion;
float proportion = GetPcbNewSettings()->m_AuiPanels.properties_splitter;
m_propertiesPanel->SetSplitterProportion( proportion );
m_selectionFilterPanel = new PANEL_SELECTION_FILTER( this );
@ -1315,17 +1315,13 @@ void PCB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
if( cfg )
{
cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
cfg->m_AuiPanels.show_layer_manager = m_show_layer_manager_tools;
if( m_propertiesPanel )
{
cfg->m_AuiPanels.show_properties = m_propertiesPanel->IsShownOnScreen();
cfg->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x;
cfg->m_AuiPanels.properties_splitter_proportion =
m_propertiesPanel->SplitterProportion();
cfg->m_AuiPanels.properties_splitter = m_propertiesPanel->SplitterProportion();
}
// ensure m_show_search is up to date (the pane can be closed)
@ -1337,7 +1333,12 @@ void PCB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
cfg->m_AuiPanels.search_panel_dock_direction = searchPaneInfo.dock_direction;
if( m_appearancePanel )
m_appearancePanel->SaveSettings( cfg );
{
cfg->m_AuiPanels.right_panel_width = m_appearancePanel->GetSize().x;
cfg->m_AuiPanels.appearance_panel_tab = m_appearancePanel->GetTabIndex();
cfg->m_AuiPanels.appearance_expand_layer_display = m_appearancePanel->IsLayerOptionsExpanded();
cfg->m_AuiPanels.appearance_expand_net_display = m_appearancePanel->IsNetOptionsExpanded();
}
}
}

View File

@ -101,7 +101,7 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
&m_AuiPanels.properties_panel_width, -1 ) );
m_params.emplace_back( new PARAM<float>( "aui.properties_splitter_proportion",
&m_AuiPanels.properties_splitter_proportion, 0.5f ) );
&m_AuiPanels.properties_splitter, 0.5f ) );
m_params.emplace_back( new PARAM<int>( "aui.search_panel_height",
&m_AuiPanels.search_panel_height, -1 ) );

View File

@ -140,7 +140,7 @@ public:
bool appearance_expand_net_display;
int right_panel_width;
int properties_panel_width;
float properties_splitter_proportion;
float properties_splitter;
int search_panel_height;
int search_panel_width;
int search_panel_dock_direction;

View File

@ -595,13 +595,6 @@ APPEARANCE_CONTROLS::~APPEARANCE_CONTROLS()
}
void APPEARANCE_CONTROLS::SaveSettings( PCBNEW_SETTINGS* aCfg )
{
aCfg->m_AuiPanels.appearance_expand_layer_display = m_paneLayerDisplayOptions->IsExpanded();
aCfg->m_AuiPanels.appearance_expand_net_display = m_paneNetDisplayOptions->IsExpanded();
}
void APPEARANCE_CONTROLS::createControls()
{
int hotkey;
@ -812,6 +805,18 @@ wxSize APPEARANCE_CONTROLS::GetBestSize() const
}
bool APPEARANCE_CONTROLS::IsLayerOptionsExpanded()
{
return m_paneLayerDisplayOptions->IsExpanded();
}
bool APPEARANCE_CONTROLS::IsNetOptionsExpanded()
{
return m_paneNetDisplayOptions->IsExpanded();
}
void APPEARANCE_CONTROLS::OnNotebookPageChanged( wxNotebookEvent& aEvent )
{
// Work around wxMac issue where the notebook pages are blank

View File

@ -200,8 +200,6 @@ public:
wxSize GetBestSize() const;
void SaveSettings( PCBNEW_SETTINGS* aCfg );
void OnLanguageChanged();
///< Update the panel contents from the application and board models.
@ -281,6 +279,9 @@ public:
*/
void RefreshCollapsiblePanes();
bool IsLayerOptionsExpanded();
bool IsNetOptionsExpanded();
protected:
void OnNotebookPageChanged( wxNotebookEvent& event ) override;
void OnSetFocus( wxFocusEvent& aEvent ) override;