From 009044bd6ba1289ad339e481a3c143ef842ad1fd Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 11 Aug 2018 13:16:41 +0200 Subject: [PATCH] FOOTPRINT_EDIT_FRAME: fix incorrect layer manager initialization depending on canvas type. Especially, the color selector is not the same when selecting GAL or Legacy canvas. Due to this incorrect init, the color selector type was incorrect. --- pcbnew/footprint_edit_frame.cpp | 59 ++++++++++++++++++++++++--------- pcbnew/footprint_edit_frame.h | 12 +++++++ pcbnew/pcb_edit_frame.cpp | 2 +- pcbnew/pcb_edit_frame.h | 1 + 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 2fd464ea6e..ea08afaea8 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -169,9 +169,9 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, FOOTPRINT_EDIT_FRAME::Show3D_Frame ) // Switching canvases - EVT_MENU( ID_MENU_CANVAS_LEGACY, PCB_BASE_FRAME::OnSwitchCanvas ) - EVT_MENU( ID_MENU_CANVAS_CAIRO, PCB_BASE_FRAME::OnSwitchCanvas ) - EVT_MENU( ID_MENU_CANVAS_OPENGL, PCB_BASE_FRAME::OnSwitchCanvas ) + EVT_MENU( ID_MENU_CANVAS_LEGACY, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas ) + EVT_MENU( ID_MENU_CANVAS_CAIRO, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas ) + EVT_MENU( ID_MENU_CANVAS_OPENGL, FOOTPRINT_EDIT_FRAME::OnSwitchCanvas ) // UI update events. EVT_UPDATE_UI( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleTargeted ) @@ -360,6 +360,18 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME() } + +void FOOTPRINT_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent ) +{ + // switches currently used canvas (default / Cairo / OpenGL). + PCB_BASE_FRAME::OnSwitchCanvas( aEvent ); + + // The base class method *does not reinit* the layers manager. + // We must upate the layer widget to match board visibility states, + // both layers and render columns, and and some settings dependent on the canvas. + UpdateUserInterface(); +} + BOARD_ITEM_CONTAINER* FOOTPRINT_EDIT_FRAME::GetModel() const { return GetBoard()->m_Modules; @@ -673,7 +685,10 @@ void FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent void FOOTPRINT_EDIT_FRAME::ReFillLayerWidget() { + + m_Layers->Freeze(); m_Layers->ReFill(); + m_Layers->Thaw(); wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_Layers ); @@ -702,24 +717,13 @@ void FOOTPRINT_EDIT_FRAME::ShowChangedLanguage() bool tree_shown = tree_pane_info.IsShown(); tree_pane_info.Caption( _( "Footprint Libraries" ) ); - // update the layer manager - m_Layers->Freeze(); - wxAuiPaneInfo& lm_pane_info = m_auimgr.GetPane( m_Layers ); bool lm_shown = lm_pane_info.IsShown(); lm_pane_info.Caption( _( "Visibles" ) ); + // update the layer manager m_Layers->SetLayersManagerTabsText(); - ReFillLayerWidget(); - m_Layers->ReFillRender(); - - // upate the layer widget to match board visibility states. - m_Layers->SyncLayerVisibilities(); - static_cast( GetGalCanvas() )->SyncLayersVisibility( m_Pcb ); - m_Layers->SelectLayer( GetActiveLayer() ); - m_Layers->OnLayerSelected(); - - m_Layers->Thaw(); + UpdateUserInterface(); // Now restore the visibility: lm_pane_info.Show( lm_shown ); @@ -810,6 +814,26 @@ void FOOTPRINT_EDIT_FRAME::updateTitle() } +void FOOTPRINT_EDIT_FRAME::UpdateUserInterface() +{ + // Update the layer manager and other widgets from the board setup + // (layer and items visibility, colors ...) + + // Update the layer manager + m_Layers->Freeze(); + ReFillLayerWidget(); + m_Layers->ReFillRender(); + + // update the layer widget to match board visibility states. + m_Layers->SyncLayerVisibilities(); + static_cast( GetGalCanvas() )->SyncLayersVisibility( m_Pcb ); + m_Layers->SelectLayer( GetActiveLayer() ); + m_Layers->OnLayerSelected(); + + m_Layers->Thaw(); +} + + void FOOTPRINT_EDIT_FRAME::updateView() { auto dp = static_cast( GetGalCanvas() ); @@ -1007,6 +1031,9 @@ void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable ) } ReCreateMenuBar(); + + // Ensure the m_Layers settings are using the canvas type: + UpdateUserInterface(); } diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 10a4b73082..a719882200 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -89,6 +89,18 @@ public: void OnCloseWindow( wxCloseEvent& Event ) override; void CloseModuleEditor( wxCommandEvent& Event ); + /** + * switches currently used canvas (default / Cairo / OpenGL). + * It also reinit the layers manager that slightly changes with canvases + */ + virtual void OnSwitchCanvas( wxCommandEvent& aEvent ) override; + + /** + * Update the layer manager and other widgets from the board setup + * (layer and items visibility, colors ...) + */ + void UpdateUserInterface(); + void Process_Special_Functions( wxCommandEvent& event ); void ProcessPreferences( wxCommandEvent& event ); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index b45924a97a..5eef5ebc99 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1135,7 +1135,7 @@ void PCB_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent ) // switches currently used canvas (default / Cairo / OpenGL). PCB_BASE_FRAME::OnSwitchCanvas( aEvent ); - // The base class method reinit the layers manager. + // The base class method *does not reinit* the layers manager. // We must upate the layer widget to match board visibility states, // both layers and render columns. syncLayerVisibilities(); diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index a5341ccc7d..c8fdb18a29 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -110,6 +110,7 @@ protected: /** * switches currently used canvas (default / Cairo / OpenGL). + * It also reinit the layers manager that slightly changes with canvases */ virtual void OnSwitchCanvas( wxCommandEvent& aEvent ) override;