From 73a1ce3e84e0f4f2c270aff4f8212b2e840915c6 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Wed, 20 May 2020 02:31:47 +0100 Subject: [PATCH] Move eeschema find notification to the infobar and improve the infobar widget * Move it to a panel along with the canvas to have a better UI * Allow the infobar to automatically close after a set time CHANGED: The eeschema find notifications now use the infobar instead of a popup window --- common/CMakeLists.txt | 2 +- common/eda_draw_frame.cpp | 1 + .../widgets/{wx_infobar.cpp => infobar.cpp} | 102 ++++++++++++++++-- eeschema/files-io.cpp | 3 +- eeschema/libedit/lib_edit_frame.cpp | 9 +- eeschema/sch_edit_frame.cpp | 46 +++----- eeschema/sch_edit_frame.h | 3 +- include/eda_draw_frame.h | 2 + include/widgets/{wx_infobar.h => infobar.h} | 78 +++++++++++++- pagelayout_editor/files.cpp | 3 +- pagelayout_editor/pl_editor_frame.cpp | 14 ++- pcbnew/footprint_edit_frame.cpp | 9 +- pcbnew/pcb_edit_frame.cpp | 16 +-- 13 files changed, 226 insertions(+), 62 deletions(-) rename common/widgets/{wx_infobar.cpp => infobar.cpp} (59%) rename include/widgets/{wx_infobar.h => infobar.h} (56%) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 892c5a4333..12b360faab 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -196,6 +196,7 @@ set( COMMON_WIDGET_SRCS widgets/grid_icon_text_helpers.cpp widgets/grid_text_button_helpers.cpp widgets/indicator_icon.cpp + widgets/infobar.cpp widgets/layer_box_selector.cpp widgets/lib_tree.cpp widgets/mathplot.cpp @@ -211,7 +212,6 @@ set( COMMON_WIDGET_SRCS widgets/wx_busy_indicator.cpp widgets/wx_grid.cpp widgets/wx_angle_text.cpp - widgets/wx_infobar.cpp ) set( COMMON_PAGE_LAYOUT_SRCS diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index ba2f1a7fb1..4460f28739 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -81,6 +81,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame m_toolDispatcher = NULL; m_messagePanel = NULL; m_infoBar = nullptr; + m_canvasPanel = nullptr; m_currentScreen = NULL; m_showBorderAndTitleBlock = false; // true to display reference sheet. m_LastGridSizeId = 0; diff --git a/common/widgets/wx_infobar.cpp b/common/widgets/infobar.cpp similarity index 59% rename from common/widgets/wx_infobar.cpp rename to common/widgets/infobar.cpp index e5629e0c7c..efc1daf715 100644 --- a/common/widgets/wx_infobar.cpp +++ b/common/widgets/infobar.cpp @@ -19,20 +19,28 @@ */ #include -#include +#include #include +#include #include +#include +#include BEGIN_EVENT_TABLE( WX_INFOBAR, wxInfoBarGeneric ) EVT_BUTTON( ID_CLOSE_INFOBAR, WX_INFOBAR::OnCloseButton ) + EVT_TIMER( ID_CLOSE_INFOBAR, WX_INFOBAR::OnTimer ) END_EVENT_TABLE() WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager *aMgr, wxWindowID aWinid ) : wxInfoBarGeneric( aParent, aWinid ), + m_showTime( 0 ), + m_showTimer( nullptr ), m_auiManager( aMgr ) { + m_showTimer = new wxTimer( this, ID_CLOSE_INFOBAR ); + // On GTK, the infobar seems to start too small, so increase its height #ifdef __WXGTK__ int sx, sy; @@ -42,33 +50,60 @@ WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager *aMgr, wxWindowID aWinid } +void WX_INFOBAR::SetShowTime( int aTime ) +{ + m_showTime = aTime; +} + + +void WX_INFOBAR::ShowMessageFor( const wxString& aMessage, int aTime, int aFlags ) +{ + m_showTime = aTime; + ShowMessage( aMessage, aFlags ); +} + + void WX_INFOBAR::ShowMessage( const wxString& aMessage, int aFlags ) { wxInfoBarGeneric::ShowMessage( aMessage, aFlags ); - UpdateAuiLayout( true ); + if( m_auiManager ) + UpdateAuiLayout( true ); + + if( m_showTime > 0 ) + m_showTimer->StartOnce( m_showTime ); + + Refresh(); + Update(); } void WX_INFOBAR::Dismiss() { wxInfoBarGeneric::Dismiss(); - UpdateAuiLayout( false ); + + if( m_auiManager ) + UpdateAuiLayout( false ); } void WX_INFOBAR::UpdateAuiLayout( bool aShow ) { - // Update the AUI pane that contains the infobar - if( m_auiManager ) + 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 ) - m_auiManager->GetPane( this ).Show(); + pane.Show(); else - m_auiManager->GetPane( this ).Hide(); - - m_auiManager->Update(); + pane.Hide(); } + + // Update the AUI manager regardless + m_auiManager->Update(); } @@ -84,6 +119,8 @@ void WX_INFOBAR::AddButton( wxButton* aButton ) { wxSizer* sizer = GetSizer(); + wxASSERT( aButton ); + #ifdef __WXMAC__ // Based on the code in the original class: // smaller buttons look better in the (narrow) info bar under OS X @@ -130,7 +167,52 @@ void WX_INFOBAR::RemoveAllButtons() } -void WX_INFOBAR::OnCloseButton( wxCommandEvent& aEvt ) +void WX_INFOBAR::OnCloseButton( wxCommandEvent& aEvent ) { Dismiss(); } + + +void WX_INFOBAR::OnTimer( wxTimerEvent& aEvent ) +{ + // Reset and clear the timer + m_showTimer->Stop(); + m_showTime = 0; + + Dismiss(); +} + + +EDA_INFOBAR_PANEL::EDA_INFOBAR_PANEL( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos, + const wxSize& aSize, long aStyle, const wxString& aName ) + : wxPanel( aParent, aId, aPos, aSize, aStyle, aName ) +{ + m_mainSizer = new wxFlexGridSizer( 1, 0, 0 ); + + m_mainSizer->SetFlexibleDirection( wxBOTH ); + m_mainSizer->AddGrowableCol( 0, 1 ); + + SetSizer( m_mainSizer ); +} + + +void EDA_INFOBAR_PANEL::AddInfoBar( WX_INFOBAR* aInfoBar ) +{ + wxASSERT( aInfoBar ); + + aInfoBar->Reparent( this ); + m_mainSizer->Add( aInfoBar, 1, wxALIGN_TOP | wxEXPAND, 0 ); + m_mainSizer->Layout(); +} + + +void EDA_INFOBAR_PANEL::AddOtherItem( wxWindow* aOtherItem ) +{ + wxASSERT( aOtherItem ); + + aOtherItem->Reparent( this ); + m_mainSizer->Add( aOtherItem, 1, wxALIGN_BOTTOM | wxEXPAND, 0 ); + + m_mainSizer->AddGrowableRow( 1, 1 ); + m_mainSizer->Layout(); +} diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 8ae896b76b..9a17c98f3e 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -55,7 +55,7 @@ #include #include #include -#include +#include bool SCH_EDIT_FRAME::SaveEEFile( SCH_SHEET* aSheet, bool aSaveUnderNewName, @@ -499,6 +499,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in UpdateTitle(); wxFileName fn = Prj().AbsolutePath( GetScreen()->GetFileName() ); + m_infoBar->Dismiss(); if( fn.FileExists() && !fn.IsFileWritable() ) { diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 5595417988..bcca630404 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -148,6 +149,12 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : DisplayCmpDoc(); RebuildSymbolUnitsList(); + // Create the infobar and the panel to hold it and the canvas + m_infoBar = new WX_INFOBAR( this ); + m_canvasPanel = new EDA_INFOBAR_PANEL( this ); + m_canvasPanel->AddInfoBar( m_infoBar ); + m_canvasPanel->AddOtherItem( GetCanvas() ); + m_auimgr.SetManagedWindow( this ); m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) ); @@ -159,7 +166,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : .BestSize( m_settings->m_LibWidth, -1 ).Resizable() ); m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) ); - m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() ); + m_auimgr.AddPane( m_canvasPanel, wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() ); m_auimgr.Update(); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index f67d75b2de..4072f4f6ce 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -69,7 +69,7 @@ #include #include #include -#include +#include #include #include @@ -215,7 +215,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): m_AboutTitle = "Eeschema"; m_findReplaceDialog = nullptr; - m_findReplaceStatusPopup = nullptr; m_generateNetlistAndExit = false; m_netlistFilename = wxEmptyString; @@ -240,7 +239,11 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): ReCreateVToolbar(); ReCreateOptToolbar(); - m_infoBar = new WX_INFOBAR( this, &m_auimgr ); + // Create the infobar and the panel to hold it and the canvas + m_infoBar = new WX_INFOBAR( this ); + m_canvasPanel = new EDA_INFOBAR_PANEL( this ); + m_canvasPanel->AddInfoBar( m_infoBar ); + m_canvasPanel->AddOtherItem( GetCanvas() ); // Initialize common print setup dialog settings. m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER ); @@ -256,16 +259,11 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) ); m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(2) ); - m_auimgr.AddPane( m_infoBar, - EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) ); - m_auimgr.AddPane( GetCanvas(), + m_auimgr.AddPane( m_canvasPanel, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) ); - // We don't want the infobar displayed right away - m_auimgr.GetPane( "InfoBar" ).Hide(); - m_auimgr.Update(); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true ); @@ -527,11 +525,6 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) m_findStringHistoryList = m_findReplaceDialog->GetFindEntries(); m_replaceStringHistoryList = m_findReplaceDialog->GetReplaceEntries(); - m_findReplaceStatusPopup->Destroy(); - m_findReplaceStatusPopup = nullptr; - - // Must destroy statusPopup first as it holds a pointer to the dialog - m_findReplaceDialog->Destroy(); m_findReplaceDialog = nullptr; } @@ -678,11 +671,6 @@ void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aForceUpdate ) void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace ) { - if( m_findReplaceStatusPopup ) - m_findReplaceStatusPopup->Destroy(); - - // Must destroy statusPopup first as it holds a pointer to the dialog - if( m_findReplaceDialog ) m_findReplaceDialog->Destroy(); @@ -692,25 +680,22 @@ void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace ) m_findReplaceDialog->SetFindEntries( m_findStringHistoryList ); m_findReplaceDialog->SetReplaceEntries( m_replaceStringHistoryList ); m_findReplaceDialog->Show( true ); - - m_findReplaceStatusPopup = new STATUS_TEXT_POPUP( m_findReplaceDialog ); - m_findReplaceStatusPopup->SetTextColor( wxColour( 255, 0, 0 ) ); } -void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg ) +void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime ) { - wxPoint pos = wxGetMousePosition() - m_findReplaceStatusPopup->GetSize() - wxPoint( 10, 10 ); + // Prepare the infobar, since we don't know its state + m_infoBar->RemoveAllButtons(); + m_infoBar->AddCloseButton(); - m_findReplaceStatusPopup->SetText( aMsg ); - m_findReplaceStatusPopup->Move( pos ); - m_findReplaceStatusPopup->PopupFor( 3000 ); + m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION ); } void SCH_EDIT_FRAME::ClearFindReplaceStatus() { - m_findReplaceStatusPopup->Hide(); + m_infoBar->Dismiss(); } @@ -719,11 +704,6 @@ void SCH_EDIT_FRAME::OnFindDialogClose() m_findStringHistoryList = m_findReplaceDialog->GetFindEntries(); m_replaceStringHistoryList = m_findReplaceDialog->GetReplaceEntries(); - m_findReplaceStatusPopup->Destroy(); - m_findReplaceStatusPopup = nullptr; - - // Must destroy statusPopup first as it holds a pointer to the dialog - m_findReplaceDialog->Destroy(); m_findReplaceDialog = nullptr; } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 87d37a576c..22bda30e03 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -135,7 +135,6 @@ private: ///< to call a custom net list generator. DIALOG_SCH_FIND* m_findReplaceDialog; - STATUS_TEXT_POPUP* m_findReplaceStatusPopup; wxString m_plotDirectoryName; wxString m_netListFormat; @@ -314,7 +313,7 @@ public: */ HIERARCHY_NAVIG_DLG* FindHierarchyNavigator(); - void ShowFindReplaceStatus( const wxString& aMsg ); + void ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime ); void ClearFindReplaceStatus(); /** diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 1df10b119f..f6460ec658 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -40,6 +40,7 @@ class ACTION_TOOLBAR; class COLOR_SETTINGS; class TOOL_MENU; class APP_SETTINGS_BASE; +class EDA_INFOBAR_PANEL; class WX_INFOBAR; namespace KIGFX @@ -115,6 +116,7 @@ protected: int m_MsgFrameHeight; WX_INFOBAR* m_infoBar; + EDA_INFOBAR_PANEL* m_canvasPanel; // The panel that holds the canvas and infobar COLOR_SETTINGS* m_colorSettings; diff --git a/include/widgets/wx_infobar.h b/include/widgets/infobar.h similarity index 56% rename from include/widgets/wx_infobar.h rename to include/widgets/infobar.h index 642f9f2d38..e4eff01ee1 100644 --- a/include/widgets/wx_infobar.h +++ b/include/widgets/infobar.h @@ -18,6 +18,9 @@ * with this program. If not, see . */ +#ifndef INFOBAR_H_ +#define INFOBAR_H_ + #include #include @@ -28,6 +31,7 @@ class wxAuiManager; * A modified version of the wxInfoBar class that allows us to: * * Show the close button along with the other buttons * * Remove all user-provided buttons at once + * * Allow automaticly hiding the infobar after a time period * * This inherits from the generic infobar because the native infobar * on GTK doesn't include the icon on the left and it looks worse. @@ -44,6 +48,17 @@ public: */ WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr = nullptr, wxWindowID aWinid = wxID_ANY ); + /** + * Set the time period to show the infobar. + * + * This only applies for the next showing of the infobar, + * so it must be reset every time. A value of 0 disables + * the automatic hiding (this is the default). + * + * @param aTime is the time in milliseconds to show the infobar + */ + void SetShowTime( int aTime ); + /** * Add the default close button to the infobar on the right side. * @@ -73,6 +88,16 @@ public: */ void RemoveAllButtons(); + /** + * Show the infobar with the provided message and icon for a specific period + * of time. + * + * @param aMessage is the message to display + * @param aTime is the amount of time to show the infobar + * @param aFlags is the flag containing the icon to display on the left side of the infobar + */ + void ShowMessageFor( const wxString& aMessage, int aTime, int aFlags = wxICON_INFORMATION ); + /** * Show the info bar with the provided message and icon. * @@ -92,7 +117,12 @@ protected: * Event handler for the close button. * This is bound to ID_CLOSE_INFOBAR on the infobar. */ - void OnCloseButton( wxCommandEvent& aEvt ); + void OnCloseButton( wxCommandEvent& aEvent ); + + /** + * Event handler for the automatic closing timer. + */ + void OnTimer( wxTimerEvent& aEvent ); /** * Update the AUI pane to show or hide this infobar. @@ -101,7 +131,51 @@ protected: */ void UpdateAuiLayout( bool aShow ); - wxAuiManager* m_auiManager; + int m_showTime; ///< The time to show the infobar. 0 = don't auto hide + wxTimer* m_showTimer; ///< The timer counting the autoclose period + wxAuiManager* m_auiManager; ///< The AUI manager that contains this infobar DECLARE_EVENT_TABLE() }; + + +/** + * A wxPanel derived class that hold an infobar and another control. + * The infobar is located at the top of the panel, and the other control + * is located below it. + * + * This allows the infobar to be controlled nicely by an AUI manager, + * since adding the infobar on its own to the AUI manager produces + * artifacts when showing/hiding it due to the AUI pane layout. + * + */ +class EDA_INFOBAR_PANEL : public wxPanel +{ +public: + EDA_INFOBAR_PANEL( wxWindow* aParent, wxWindowID aId = wxID_ANY, + const wxPoint& aPos = wxDefaultPosition, + const wxSize& aSize = wxSize( -1,-1 ), + long aStyle = wxTAB_TRAVERSAL, + const wxString& aName = wxEmptyString ); + + /** + * Add the given infobar object to the panel + * + * @param aInfoBar is the infobar to add + */ + void AddInfoBar( WX_INFOBAR* aInfoBar ); + + /** + * Add the other item to the panel. + * This item will expand to fill up the vertical space left. + * + * @param aOtherItem is the item to add + */ + void AddOtherItem( wxWindow* aOtherItem ); + +protected: + // The sizer containing the infobar and the other object + wxFlexGridSizer* m_mainSizer; +}; + +#endif // INFOBAR_H_ diff --git a/pagelayout_editor/files.cpp b/pagelayout_editor/files.cpp index b43688fc90..f8b402559c 100644 --- a/pagelayout_editor/files.cpp +++ b/pagelayout_editor/files.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include @@ -231,6 +231,7 @@ bool PL_EDITOR_FRAME::LoadPageLayoutDescrFile( const wxString& aFullFileName ) GetScreen()->ClrModify(); wxFileName fn = aFullFileName; + m_infoBar->Dismiss(); if( fn.FileExists() && !fn.IsFileWritable() ) { diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index f777176951..9793f6d007 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -56,7 +56,7 @@ #include #include #include -#include +#include BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME ) EVT_CLOSE( PL_EDITOR_FRAME::OnCloseWindow ) @@ -125,7 +125,17 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : ReCreateHToolbar(); ReCreateVToolbar(); - m_infoBar = new WX_INFOBAR( this, &m_auimgr ); + // TODO (ISM): Figure out why using the infobar panel doesn't work here (it works + // in the other frames) but using the AUI pane version does. + // When the panel is used, the infobar isn't shown until the window is resized + // (but the sizer has a space for it), and the sizer space doesn't disappear + // when it is dismissed until the window is resized. + + // Create the infobar and the panel to hold it and the canvas + m_infoBar = new WX_INFOBAR( this, &m_auimgr ); + //m_canvasPanel = new EDA_INFOBAR_PANEL( this ); + //m_canvasPanel->AddInfoBar( m_infoBar ); + //m_canvasPanel->AddOtherItem( GetCanvas() ); wxWindow* stsbar = GetStatusBar(); int dims[] = { diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index ddeef39e63..4704de19d9 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -65,6 +65,7 @@ #include #include #include +#include #include #include #include @@ -196,6 +197,12 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, m_Layers->SelectLayer( F_SilkS ); m_Layers->OnLayerSelected(); + // Create the infobar and the panel to hold it and the canvas + m_infoBar = new WX_INFOBAR( this ); + m_canvasPanel = new EDA_INFOBAR_PANEL( this ); + m_canvasPanel->AddInfoBar( m_infoBar ); + m_canvasPanel->AddOtherItem( GetCanvas() ); + m_auimgr.SetManagedWindow( this ); // Horizontal items; layers 4 - 6 @@ -213,7 +220,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, .Caption( _( "Layers Manager" ) ).PaneBorder( false ) .MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ) ); - m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); + m_auimgr.AddPane( m_canvasPanel, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); GetCanvas()->GetView()->SetScale( GetZoomLevelCoeff() / GetScreen()->GetZoom() ); ActivateGalCanvas(); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 47c45d6039..465c058b46 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -87,7 +87,7 @@ #include #include #include // for DIALOG_DRC_WINDOW_NAME definition -#include +#include #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON) #include @@ -223,7 +223,11 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : ReCreateOptToolbar(); ReCreateMicrowaveVToolbar(); - m_infoBar = new WX_INFOBAR( this, &m_auimgr ); + // Create the infobar and the panel to hold it and the canvas + m_infoBar = new WX_INFOBAR( this ); + m_canvasPanel = new EDA_INFOBAR_PANEL( this ); + m_canvasPanel->AddInfoBar( m_infoBar ); + m_canvasPanel->AddOtherItem( GetCanvas() ); m_auimgr.SetManagedWindow( this ); @@ -234,8 +238,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(5) ); m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) ); - m_auimgr.AddPane( m_infoBar, - EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) ); // Vertical items; layers 1 - 3 m_auimgr.AddPane( m_optionsToolBar, @@ -250,7 +252,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : .Caption( _( "Layers Manager" ) ).PaneBorder( false ) .MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ) ); - m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); + m_auimgr.AddPane( m_canvasPanel, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools ); m_auimgr.GetPane( "MicrowaveToolbar" ).Show( m_show_microwave_tools ); @@ -260,9 +262,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // because contents establish size syncLayerWidgetLayer(); - // We don't want the infobar displayed right away - m_auimgr.GetPane( "InfoBar" ).Hide(); - m_auimgr.Update(); GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId ); GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false ); @@ -714,6 +713,7 @@ void PCB_EDIT_FRAME::onBoardLoaded() UpdateTitle(); wxFileName fn = GetBoard()->GetFileName(); + m_infoBar->Dismiss(); // Display a warning that the file is read only if( fn.FileExists() && !fn.IsFileWritable() )