From 8f9b7ca757932fdb4c98bcacdecea0fc7f65f7cd Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 9 Jan 2025 13:39:41 -0800 Subject: [PATCH] Hide the AUI notebook tabs if we only have 1 --- kicad/kicad_manager_frame.cpp | 34 ++++++++++++++++++++++++++-------- kicad/kicad_manager_frame.h | 7 +++++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index 07c3a75101..c442088f4e 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -228,15 +228,16 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl wxAUI_NB_TOP | wxAUI_NB_CLOSE_ON_ALL_TABS | wxAUI_NB_TAB_MOVE | wxAUI_NB_SCROLL_BUTTONS | wxNO_BORDER ); - m_notebook->Connect( - wxEVT_AUINOTEBOOK_PAGE_CLOSE, - wxAuiNotebookEventHandler( KICAD_MANAGER_FRAME::onNotebookPageCloseRequest ), nullptr, - this ); + m_notebook->Bind( wxEVT_AUINOTEBOOK_PAGE_CLOSE, + &KICAD_MANAGER_FRAME::onNotebookPageCloseRequest, this ); + m_notebook->Bind( wxEVT_AUINOTEBOOK_PAGE_CLOSED, + &KICAD_MANAGER_FRAME::onNotebookPageCountChanged, this ); m_launcher = new PANEL_KICAD_LAUNCHER( m_notebook ); m_notebook->Freeze(); m_launcher->SetClosable( false ); m_notebook->AddPage( m_launcher, EDITORS_CAPTION, false ); + m_notebook->SetTabCtrlHeight( 0 ); m_notebook->Thaw(); m_auimgr.AddPane( m_notebook, EDA_PANE() @@ -252,6 +253,7 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl // Now the actual m_leftWin size is set, give it a reasonable min width m_auimgr.GetPane( m_leftWin ).MinSize( defaultLeftWinWidth, -1 ); + wxSizer* mainSizer = GetSizer(); // Only fit the initial window size the first time KiCad is run. @@ -292,10 +294,10 @@ KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME() Unbind( wxEVT_CHAR, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher ); Unbind( wxEVT_CHAR_HOOK, &TOOL_DISPATCHER::DispatchWxEvent, m_toolDispatcher ); - m_notebook->Disconnect( - wxEVT_AUINOTEBOOK_PAGE_CLOSE, - wxAuiNotebookEventHandler( KICAD_MANAGER_FRAME::onNotebookPageCloseRequest ), nullptr, - this ); + m_notebook->Unbind( wxEVT_AUINOTEBOOK_PAGE_CLOSE, + &KICAD_MANAGER_FRAME::onNotebookPageCloseRequest, this ); + m_notebook->Unbind( wxEVT_AUINOTEBOOK_PAGE_CLOSED, + &KICAD_MANAGER_FRAME::onNotebookPageCountChanged, this ); Pgm().GetBackgroundJobMonitor().UnregisterStatusBar( (KISTATUSBAR*) GetStatusBar() ); Pgm().GetNotificationsManager().UnregisterStatusBar( (KISTATUSBAR*) GetStatusBar() ); @@ -314,6 +316,20 @@ KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME() m_auimgr.UnInit(); } +void KICAD_MANAGER_FRAME::HideTabsIfNeeded() +{ + if( m_notebook->GetPageCount() == 1 ) + m_notebook->SetTabCtrlHeight( 0 ); + else + m_notebook->SetTabCtrlHeight( -1 ); +} + + +void KICAD_MANAGER_FRAME::onNotebookPageCountChanged( wxAuiNotebookEvent& evt ) +{ + HideTabsIfNeeded(); +} + void KICAD_MANAGER_FRAME::onNotebookPageCloseRequest( wxAuiNotebookEvent& evt ) { @@ -740,6 +756,7 @@ bool KICAD_MANAGER_FRAME::CloseProject( bool aSave ) } m_leftWin->EmptyTreePrj(); + HideTabsIfNeeded(); return true; } @@ -771,6 +788,7 @@ void KICAD_MANAGER_FRAME::OpenJobsFile( const wxFileName& aFileName, bool aCreat jobPanel->SetProjectTied( true ); jobPanel->SetClosable( true ); m_notebook->AddPage( jobPanel, aFileName.GetFullName(), true ); + HideTabsIfNeeded(); if( aResaveProjectPreferences ) SaveOpenJobSetsToLocalSettings(); diff --git a/kicad/kicad_manager_frame.h b/kicad/kicad_manager_frame.h index f146718324..22fa601211 100644 --- a/kicad/kicad_manager_frame.h +++ b/kicad/kicad_manager_frame.h @@ -71,6 +71,11 @@ public: wxStatusBar* OnCreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) override; + /** + * Hides the tabs for Editor notebook if there is only 1 page + */ + void HideTabsIfNeeded(); + /** * (Re)Create the left vertical toolbar */ @@ -202,6 +207,8 @@ protected: void onNotebookPageCloseRequest( wxAuiNotebookEvent& evt ); + void onNotebookPageCountChanged( wxAuiNotebookEvent& evt ); + private: void setupTools(); void setupActions();