From 96f4e8f6f877a4a13ac701c9695934bd1ada2fe0 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 17 Aug 2020 22:06:31 -0400 Subject: [PATCH] Remember the last active tab on the appearance panel Fixes https://gitlab.com/kicad/code/kicad/-/issues/5216 --- pcbnew/pcb_edit_frame.cpp | 4 ++++ pcbnew/pcbnew_settings.cpp | 3 +++ pcbnew/pcbnew_settings.h | 1 + pcbnew/widgets/appearance_controls.cpp | 15 +++++++++++++++ pcbnew/widgets/appearance_controls.h | 6 ++++++ 5 files changed, 29 insertions(+) diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index e81e9ec7a6..acf2bffa68 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -280,7 +280,10 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : wxSize size = m_appearancePanel->GetBestSize(); size.x = settings->m_AuiPanels.right_panel_width; m_auimgr.GetPane( "LayersManager" ).BestSize( size ); + m_appearancePanel->SetSize( size ); } + + m_appearancePanel->SetTabIndex( settings->m_AuiPanels.appearance_panel_tab ); } // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before @@ -944,6 +947,7 @@ void PCB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) cfg->m_AuiPanels.show_microwave_tools = m_show_microwave_tools; 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_ShowPageLimits = m_showPageLimits; } } diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index c116854c54..fc6ce6a0ea 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -88,6 +88,9 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_params.emplace_back( new PARAM( "aui.right_panel_width", &m_AuiPanels.right_panel_width, -1 ) ); + m_params.emplace_back( new PARAM( + "aui.appearance_panel_tab", &m_AuiPanels.appearance_panel_tab, 0, 0, 2 ) ); + m_params.emplace_back( new PARAM( "footprint_chooser.width", &m_FootprintChooser.width, -1 ) ); diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h index 2ee56440bd..dbf3f390ce 100644 --- a/pcbnew/pcbnew_settings.h +++ b/pcbnew/pcbnew_settings.h @@ -67,6 +67,7 @@ class PCBNEW_SETTINGS : public APP_SETTINGS_BASE public: struct AUI_PANELS { + int appearance_panel_tab; int right_panel_width; bool show_microwave_tools; bool show_layer_manager; diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index dfd4e45ece..7fc0b6a989 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -836,6 +836,21 @@ void APPEARANCE_CONTROLS::OnLayerContextMenu( wxCommandEvent& aEvent ) } +int APPEARANCE_CONTROLS::GetTabIndex() const +{ + return m_notebook->GetSelection(); +} + + +void APPEARANCE_CONTROLS::SetTabIndex( int aTab ) +{ + size_t max = m_notebook->GetPageCount(); + + if( aTab >= 0 && static_cast( aTab ) < max ) + m_notebook->SetSelection( aTab ); +} + + void APPEARANCE_CONTROLS::syncColorsAndVisibility() { BOARD* board = m_frame->GetBoard(); diff --git a/pcbnew/widgets/appearance_controls.h b/pcbnew/widgets/appearance_controls.h index f6554be62d..7e677a0ab8 100644 --- a/pcbnew/widgets/appearance_controls.h +++ b/pcbnew/widgets/appearance_controls.h @@ -143,6 +143,12 @@ public: void OnLayerContextMenu( wxCommandEvent& aEvent ); + ///> Returns the index of the current tab (0-2) + int GetTabIndex() const; + + ///> Sets the current notebook tab + void SetTabIndex( int aTab ); + protected: void OnLayerDisplayPaneChanged( wxCollapsiblePaneEvent& event ) override;