From 0f6dfb782e6381c075f641e5fdee04afb920c56e Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 6 Dec 2013 19:33:16 -0500 Subject: [PATCH] Pcbnew: footprint viewer wxAUI improvements. * Make the tool bar dockable. * Enable the overflow control in the tool bar in case the it does not fit in it's parent window. * Fix some wxAuiPaneInfo usage issues. * Remove unused wxAuiPaneInfo objects. * Move perspective saving and loading into EDA_BASE_FRAME object in preparation for extending this to all frame windows. --- common/basicframe.cpp | 14 ++++++++++++++ include/wxstruct.h | 2 ++ pcbnew/modview_frame.cpp | 41 +++++++++++++++++----------------------- pcbnew/modview_frame.h | 1 - pcbnew/tool_modview.cpp | 4 ++-- 5 files changed, 35 insertions(+), 27 deletions(-) diff --git a/common/basicframe.cpp b/common/basicframe.cpp index d513ac5839..5ab90f9353 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -56,6 +56,10 @@ const wxChar* traceAutoSave = wxT( "KicadAutoSave" ); /// Configuration file entry name for auto save interval. static const wxChar* entryAutoSaveInterval = wxT( "AutoSaveInterval" ); +/// Configuration file entry for wxAuiManger perspective. +static const wxChar* entryPerspective = wxT( "ModViewPerspective" ); + + EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType, @@ -213,6 +217,11 @@ void EDA_BASE_FRAME::LoadSettings() if( maximized ) Maximize(); + + // Once this is fully implemented, wxAuiManager will be used to maintain the persistance of + // the main frame and all it's managed windows and all of the legacy frame persistence + // position code can be removed. + config->Read( m_FrameName + entryPerspective, &m_perspective ); } @@ -247,6 +256,11 @@ void EDA_BASE_FRAME::SaveSettings() text = m_FrameName + entryAutoSaveInterval; config->Write( text, m_autoSaveInterval ); } + + // Once this is fully implemented, wxAuiManager will be used to maintain the persistance of + // the main frame and all it's managed windows and all of the legacy frame persistence + // position code can be removed. + config->Write( m_FrameName + entryPerspective, m_auimgr.SavePerspective() ); } diff --git a/include/wxstruct.h b/include/wxstruct.h index 5b91ee655d..b26dfeeca2 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -136,6 +136,8 @@ protected: /// The timer used to implement the auto save feature; wxTimer* m_autoSaveTimer; + wxString m_perspective; ///< wxAuiManager perspective. + /** * Function onAutoSaveTimer * handles the auto save timer event. diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index 9976912a69..dbe5ec59a5 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -59,9 +59,6 @@ #define PREVIOUS_PART -1 -static wxString entryPerspective( wxT( "ModViewPerspective" ) ); - - /** * Save previous component library viewer state. */ @@ -217,11 +214,13 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent, m_auimgr.SetManagedWindow( this ); - EDA_PANEINFO horiz; - horiz.HorizontalToolbarPane(); - - EDA_PANEINFO vert; - vert.VerticalToolbarPane(); + // Main toolbar is initially docked at the top of the main window and dockable on any side. + // The close button is disable because the footprint viewer has no main menu to re-enable it. + // The tool bar will only be dockable on the top or bottom of the main frame window. This is + // most likely due to the fact that the other windows are not dockable and are preventing the + // tool bar from docking on the right and left. + wxAuiPaneInfo toolbarPaneInfo; + toolbarPaneInfo.Name( wxT( "m_mainToolBar" ) ).ToolbarPane().Top().CloseButton( false ); EDA_PANEINFO info; info.InfoToolbarPane(); @@ -229,27 +228,25 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent, EDA_PANEINFO mesg; mesg.MessageToolbarPane(); - // Manage main toolbar - m_auimgr.AddPane( m_mainToolBar, - wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) ); + // Manage main toolbar, top pane + m_auimgr.AddPane( m_mainToolBar, toolbarPaneInfo ); - // Manage the left window (list of libraries) + // Manage the list of libraries, left pane. if( m_LibListWindow ) m_auimgr.AddPane( m_LibListWindow, wxAuiPaneInfo( info ).Name( wxT( "m_LibList" ) ). - Left().Row( 0 ) ); + Left().Row( 1 ) ); - // Manage the list of components) + // Manage the list of footprints, center pane. m_auimgr.AddPane( m_FootprintListWindow, - wxAuiPaneInfo( info ).Name( wxT( "m_FootprintList" ) ). - Left().Row( 1 ) ); + wxAuiPaneInfo( info ).Name( wxT( "m_FootprintList" ) ).Centre().Row( 1 ) ); - // Manage the draw panel + // Manage the draw panel, right pane. m_auimgr.AddPane( m_canvas, - wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).Centre().CloseButton( false ) ); + wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).Right().Row( 1 ).CloseButton( false ) ); - // Manage the message panel + // Manage the message panel, bottom pane. m_auimgr.AddPane( m_messagePanel, - wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer( 10 ) ); + wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom() ); /* Now the minimum windows are fixed, set library list * and component list of the previous values from last viewlib use @@ -547,8 +544,6 @@ void FOOTPRINT_VIEWER_FRAME::LoadSettings( ) wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath ); cfg = wxGetApp().GetSettings(); - - cfg->Read( entryPerspective, &m_perspective ); } @@ -560,8 +555,6 @@ void FOOTPRINT_VIEWER_FRAME::SaveSettings() wxConfigPathChanger cpc( wxGetApp().GetSettings(), m_configPath ); cfg = wxGetApp().GetSettings(); - - cfg->Write( entryPerspective, m_auimgr.SavePerspective() ); } diff --git a/pcbnew/modview_frame.h b/pcbnew/modview_frame.h index c833e5c10c..19d09d6268 100644 --- a/pcbnew/modview_frame.h +++ b/pcbnew/modview_frame.h @@ -55,7 +55,6 @@ private: // Flags wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog wxString m_configPath; // subpath for configuration - wxString m_perspective; // wxAuiManager perspective. protected: static wxString m_libraryName; // Current selected library diff --git a/pcbnew/tool_modview.cpp b/pcbnew/tool_modview.cpp index 85237ce72c..8d40fa2601 100644 --- a/pcbnew/tool_modview.cpp +++ b/pcbnew/tool_modview.cpp @@ -44,10 +44,10 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar() { wxString msg; - if( m_mainToolBar == NULL ) + if( m_mainToolBar == NULL ) { m_mainToolBar = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT ); + wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW ); // Set up toolbar m_mainToolBar->AddTool( ID_MODVIEW_SELECT_LIB, wxEmptyString,