diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.cpp b/3d-viewer/3d_viewer/eda_3d_viewer.cpp index 6ce2843f11..3d68cc1a0b 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer.cpp @@ -144,13 +144,12 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxSt m_auimgr.SetManagedWindow( this ); + CreateInfoBar(); m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) ); m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); - // Call Update() to fix all pane default sizes. - m_auimgr.Update(); + FinishAUIInitialization(); - m_infoBar = new WX_INFOBAR( m_canvas ); m_canvas->SetInfoBar( m_infoBar ); m_canvas->SetStatusBar( status_bar ); diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index c3253a5988..af2b1e69ba 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -683,6 +683,34 @@ void EDA_BASE_FRAME::PrintMsg( const wxString& text ) } +void EDA_BASE_FRAME::CreateInfoBar() +{ +#if defined( __WXOSX_MAC__ ) + m_infoBar = new WX_INFOBAR( GetToolCanvas() ); +#else + m_infoBar = new WX_INFOBAR( this, m_auimgr ); + + m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) ); +#endif +} + + +void EDA_BASE_FRAME::FinishAUIInitialization() +{ +#if defined( __WXOSX_MAC__ ) + m_auimgr.Update(); +#else + // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before + // hidding it. + m_auimgr.Update(); + + // We don't want the infobar displayed right away + m_auimgr.GetPane( "InfoBar" ).Hide(); + m_auimgr.Update(); +#endif +} + + void EDA_BASE_FRAME::ShowInfoBarError( const wxString& aErrorMsg, bool aShowCloseButton ) { m_infoBar->RemoveAllButtons(); diff --git a/common/widgets/infobar.cpp b/common/widgets/infobar.cpp index 3723ec7e97..e74ae93ea4 100644 --- a/common/widgets/infobar.cpp +++ b/common/widgets/infobar.cpp @@ -21,6 +21,7 @@ #include #include #include "wx/artprov.h" +#include #include #include #include @@ -40,11 +41,12 @@ BEGIN_EVENT_TABLE( WX_INFOBAR, wxInfoBarGeneric ) END_EVENT_TABLE() -WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxWindowID aWinid ) +WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr, wxWindowID aWinid ) : wxInfoBarGeneric( aParent, aWinid ), m_showTime( 0 ), m_updateLock( false ), - m_showTimer( nullptr ) + m_showTimer( nullptr ), + m_auiManager( aMgr ) { m_showTimer = new wxTimer( this, ID_CLOSE_INFOBAR ); @@ -133,6 +135,9 @@ void WX_INFOBAR::ShowMessage( const wxString& aMessage, int aFlags ) wxInfoBarGeneric::ShowMessage( aMessage, aFlags ); + if( m_auiManager ) + updateAuiLayout( true ); + if( m_showTime > 0 ) m_showTimer->StartOnce( m_showTime ); @@ -150,6 +155,9 @@ void WX_INFOBAR::Dismiss() wxInfoBarGeneric::Dismiss(); + if( m_auiManager ) + updateAuiLayout( false ); + m_updateLock = false; } @@ -166,6 +174,26 @@ void WX_INFOBAR::onSize( wxSizeEvent& aEvent ) } +void WX_INFOBAR::updateAuiLayout( bool aShow ) +{ + wxASSERT( m_auiManager ); + + wxAuiPaneInfo& pane = m_auiManager->GetPane( this ); + + // If the infobar is in a pane, then show/hide the pane + if( pane.IsOk() ) + { + if( aShow ) + pane.Show(); + else + pane.Hide(); + } + + // Update the AUI manager regardless + m_auiManager->Update(); +} + + void WX_INFOBAR::AddButton( wxWindowID aId, const wxString& aLabel ) { wxButton* button = new wxButton( this, aId, aLabel ); diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index d0f1d7486b..de5c061e05 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -129,6 +129,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa m_auimgr.SetManagedWindow( this ); + CreateInfoBar(); m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ) .Top().Layer( 6 ) ); m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ) @@ -138,10 +139,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) .Bottom().Layer( 6 ) ); - // Call Update() to fix all pane default sizes. - m_auimgr.Update(); - - m_infoBar = new WX_INFOBAR( GetCanvas() ); + FinishAUIInitialization(); auto& galOpts = GetGalDisplayOptions(); galOpts.m_axesEnabled = true; diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index d37403e469..f14e7bd251 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -249,6 +249,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.SetManagedWindow( this ); + CreateInfoBar(); m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ) .Top().Layer( 6 ) ); m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ) @@ -260,10 +261,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) .Bottom().Layer( 6 ) ); - // Call Update() to fix all pane default sizes. - m_auimgr.Update(); - - m_infoBar = new WX_INFOBAR( GetCanvas() ); + FinishAUIInitialization(); resolveCanvasType(); SwitchCanvas( m_canvasType ); diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 14e701a155..fb82a6c6f2 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -148,6 +148,7 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.SetManagedWindow( this ); + CreateInfoBar(); m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ) .Top().Layer( 6 ) ); m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ) @@ -165,10 +166,7 @@ SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" ) .CentrePane() ); - // Call Update() to fix all pane default sizes. - m_auimgr.Update(); - - m_infoBar = new WX_INFOBAR( GetCanvas() ); + FinishAUIInitialization(); if( m_settings->m_LibWidth > 0 ) { diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index 9440247236..782bf70e44 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -205,6 +205,10 @@ public: void PrintMsg( const wxString& text ); + void CreateInfoBar(); + + void FinishAUIInitialization(); + /** * @return the #WX_INFOBAR that can be displayed on the top of the canvas. */ diff --git a/include/widgets/infobar.h b/include/widgets/infobar.h index 69d6e9958f..11b3c48fa6 100644 --- a/include/widgets/infobar.h +++ b/include/widgets/infobar.h @@ -26,6 +26,7 @@ #include +class wxAuiManager; class wxHyperlinkCtrl; @@ -76,7 +77,7 @@ public: * @param aMgr is the AUI manager that this infobar is added to * @param aWinId is the ID for this infobar object */ - WX_INFOBAR( wxWindow* aParent, wxWindowID aWinid = wxID_ANY ); + WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr = nullptr, wxWindowID aWinid = wxID_ANY ); ~WX_INFOBAR(); @@ -200,10 +201,18 @@ protected: void onSize( wxSizeEvent& aEvent ); + /** + * Update the AUI pane to show or hide this infobar. + * + * @param aShow is true to show the pane + */ + void updateAuiLayout( bool aShow ); + protected: int m_showTime; ///< The time to show the infobar. 0 = don't auto hide bool m_updateLock; ///< True if this infobar requested the UI update wxTimer* m_showTimer; ///< The timer counting the autoclose period + wxAuiManager* m_auiManager; ///< The AUI manager that contains this infobar DECLARE_EVENT_TABLE() }; diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index fe4b51a1a9..ab7e5c10f0 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -150,6 +150,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.SetManagedWindow( this ); + CreateInfoBar(); m_propertiesPagelayout = new PROPERTIES_FRAME( this ); // Rows; layers 4 - 6 @@ -174,11 +175,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ) .Center() ); - - // Call Update() to fix all pane default sizes. - m_auimgr.Update(); - - m_infoBar = new WX_INFOBAR( GetCanvas() ); + FinishAUIInitialization(); resolveCanvasType(); SwitchCanvas( m_canvasType ); diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index a81197d707..488e315473 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -199,6 +199,8 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, m_auimgr.SetManagedWindow( this ); + CreateInfoBar(); + unsigned int auiFlags = wxAUI_MGR_DEFAULT; #if !defined( _WIN32 ) // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds @@ -247,10 +249,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR, wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) ); - // Call Update() to fix all pane default sizes. - m_auimgr.Update(); - - m_infoBar = new WX_INFOBAR( GetCanvas() ); + FinishAUIInitialization(); if( m_settings->m_LibWidth > 0 ) { diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index eb56a8fcde..d4c86a6687 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -225,6 +225,8 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.SetManagedWindow( this ); + CreateInfoBar(); + unsigned int auiFlags = wxAUI_MGR_DEFAULT; #if !defined( _WIN32 ) // Windows cannot redraw the UI fast enough during a live resize and may lead to all kinds of graphical glitches @@ -272,10 +274,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR, wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) ); - // Call Update() to fix all pane default sizes. - m_auimgr.Update(); - - m_infoBar = new WX_INFOBAR( GetCanvas() ); + FinishAUIInitialization(); if( PCBNEW_SETTINGS* settings = dynamic_cast( config() ) ) {