Save and restore properties and search panel sizes

This commit is contained in:
Jon Evans 2022-11-25 09:11:20 -05:00
parent 6d1ab81261
commit bbea5b3fbc
6 changed files with 63 additions and 11 deletions

View File

@ -335,6 +335,19 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SetAuiPaneSize( m_auimgr, layersManager, settings->m_AuiPanels.right_panel_width, -1 );
}
if( settings->m_AuiPanels.properties_panel_width > 0 && m_propertiesPanel )
{
wxAuiPaneInfo& propertiesPanel = m_auimgr.GetPane( "PropertiesManager" );
SetAuiPaneSize( m_auimgr, propertiesPanel,
settings->m_AuiPanels.properties_panel_width, -1 );
}
if( settings->m_AuiPanels.search_panel_height > 0 )
{
wxAuiPaneInfo& searchPane = m_auimgr.GetPane( SearchPaneName() );
SetAuiPaneSize( m_auimgr, searchPane, -1, settings->m_AuiPanels.search_panel_height );
}
m_appearancePanel->SetTabIndex( settings->m_AuiPanels.appearance_panel_tab );
}
@ -1198,11 +1211,17 @@ void PCB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
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_properties = m_show_properties;
if( m_propertiesPanel )
{
cfg->m_AuiPanels.show_properties = m_show_properties;
cfg->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x;
}
// ensure m_show_search is up to date (the pane can be closed)
m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
cfg->m_AuiPanels.show_search = m_show_search;
cfg->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
}
}

View File

@ -1240,11 +1240,11 @@ static struct TRACK_VIA_DESC
propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "Width" ),
&PCB_TRACK::SetWidth, &PCB_TRACK::GetWidth, PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
new PROPERTY<PCB_TRACK, int, BOARD_ITEM>( _HKI( "Origin X" ),
new PROPERTY<PCB_TRACK, int, BOARD_ITEM>( _HKI( "Start X" ),
&PCB_TRACK::SetX, &PCB_TRACK::GetX, PROPERTY_DISPLAY::PT_COORD,
ORIGIN_TRANSFORMS::ABS_X_COORD) );
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
new PROPERTY<PCB_TRACK, int, BOARD_ITEM>( _HKI( "Origin Y" ),
new PROPERTY<PCB_TRACK, int, BOARD_ITEM>( _HKI( "Start Y" ),
&PCB_TRACK::SetY, &PCB_TRACK::GetY, PROPERTY_DISPLAY::PT_COORD,
ORIGIN_TRANSFORMS::ABS_Y_COORD ) );
propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End X" ),
@ -1261,11 +1261,11 @@ static struct TRACK_VIA_DESC
propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "Width" ),
&PCB_ARC::SetWidth, &PCB_ARC::GetWidth, PROPERTY_DISPLAY::PT_SIZE ) );
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
new PROPERTY<PCB_ARC, int, BOARD_ITEM>( _HKI( "Origin X" ),
new PROPERTY<PCB_ARC, int, BOARD_ITEM>( _HKI( "Start X" ),
&PCB_TRACK::SetX, &PCB_ARC::GetX, PROPERTY_DISPLAY::PT_COORD,
ORIGIN_TRANSFORMS::ABS_X_COORD) );
propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
new PROPERTY<PCB_ARC, int, BOARD_ITEM>( _HKI( "Origin Y" ),
new PROPERTY<PCB_ARC, int, BOARD_ITEM>( _HKI( "Start Y" ),
&PCB_TRACK::SetY, &PCB_ARC::GetY, PROPERTY_DISPLAY::PT_COORD,
ORIGIN_TRANSFORMS::ABS_Y_COORD) );
propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End X" ),

View File

@ -93,6 +93,12 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
m_params.emplace_back( new PARAM<int>( "aui.right_panel_width",
&m_AuiPanels.right_panel_width, -1 ) );
m_params.emplace_back( new PARAM<int>( "aui.properties_panel_width",
&m_AuiPanels.properties_panel_width, -1 ) );
m_params.emplace_back( new PARAM<int>( "aui.search_panel_height",
&m_AuiPanels.search_panel_height, -1 ) );
m_params.emplace_back( new PARAM<int>( "aui.appearance_panel_tab",
&m_AuiPanels.appearance_panel_tab, 0, 0, 2 ) );

View File

@ -127,6 +127,8 @@ public:
bool appearance_expand_layer_display;
bool appearance_expand_net_display;
int right_panel_width;
int properties_panel_width;
int search_panel_height;
bool show_layer_manager;
bool show_properties;
bool show_search;

View File

@ -47,6 +47,7 @@
#include <tools/pcb_actions.h>
#include <tools/pcb_selection_tool.h>
#include <widgets/appearance_controls.h>
#include <dialogs/pcb_properties_panel.h>
#include <widgets/pcb_search_pane.h>
#include <widgets/wx_aui_utils.h>
#include <wx/wupdlock.h>
@ -789,27 +790,51 @@ void PCB_EDIT_FRAME::ToggleLayersManager()
void PCB_EDIT_FRAME::ToggleProperties()
{
if( !m_propertiesPanel )
return;
PCBNEW_SETTINGS* settings = GetPcbNewSettings();
m_show_properties = !m_show_properties;
m_auimgr.GetPane( "PropertiesManager" ).Show( m_show_properties );
m_auimgr.Update();
wxAuiPaneInfo& propertiesPaneInfo = m_auimgr.GetPane( "PropertiesManager" );
propertiesPaneInfo.Show( m_show_properties );
if( m_show_properties )
{
SetAuiPaneSize( m_auimgr, propertiesPaneInfo,
settings->m_AuiPanels.properties_panel_width, -1 );
}
else
{
settings->m_AuiPanels.properties_panel_width = m_propertiesPanel->GetSize().x;
m_auimgr.Update();
}
}
void PCB_EDIT_FRAME::ToggleSearch()
{
PCBNEW_SETTINGS* settings = GetPcbNewSettings();
// Ensure m_show_search is up to date (the pane can be closed outside the menu)
m_show_search = m_auimgr.GetPane( SearchPaneName() ).IsShown();
m_show_search = !m_show_search;
m_auimgr.GetPane( SearchPaneName() ).Show( m_show_search );
m_auimgr.Update();
wxAuiPaneInfo& searchPaneInfo = m_auimgr.GetPane( SearchPaneName() );
searchPaneInfo.Show( m_show_search );
if( m_show_search )
{
SetAuiPaneSize( m_auimgr, searchPaneInfo, -1, settings->m_AuiPanels.search_panel_height );
m_searchPane->FocusSearch();
}
else
{
settings->m_AuiPanels.search_panel_height = m_searchPane->GetSize().y;
m_auimgr.Update();
}
}

View File

@ -1667,8 +1667,8 @@ void BOARD_EDITOR_CONTROL::setTransitions()
ACTIONS::updateSchematicFromPcb.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ShowEeschema, PCB_ACTIONS::showEeschema.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ToggleLayersManager, PCB_ACTIONS::showLayersManager.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ToggleProperties, PCB_ACTIONS::showProperties.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ToggleSearch, PCB_ACTIONS::showSearch.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ToggleProperties, PCB_ACTIONS::showProperties.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::ToggleSearch, PCB_ACTIONS::showSearch.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::TogglePythonConsole, PCB_ACTIONS::showPythonConsole.MakeEvent() );
Go( &BOARD_EDITOR_CONTROL::RepairBoard, PCB_ACTIONS::repairBoard.MakeEvent() );
}