From a79526cad821b1323a471b1762461a4971fb17d4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 4 Sep 2019 16:00:54 +0200 Subject: [PATCH] Footprint viewers: force cairo canvas instead of legacy canvas when the legacy canvas is selected in the board editor. Legacy canvas does not work in footprint preview panel and does not work fine in footprint viewer frame. Fixes: lp:1842483 https://bugs.launchpad.net/kicad/+bug/1842483 --- pcbnew/footprint_preview_panel.cpp | 6 +++++- pcbnew/footprint_viewer_frame.cpp | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index 5052e81bc4..07a063d832 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -247,7 +247,11 @@ public: FOOTPRINT_PREVIEW_PANEL::FOOTPRINT_PREVIEW_PANEL( KIWAY* aKiway, wxWindow* aParent, std::unique_ptr aOpts, GAL_TYPE aGalType ) - : PCB_DRAW_PANEL_GAL ( aParent, -1, wxPoint( 0, 0 ), wxSize(200, 200), *aOpts, aGalType ), + : PCB_DRAW_PANEL_GAL ( aParent, -1, wxPoint( 0, 0 ), wxSize(200, 200), *aOpts, + // Note: legacy canvas does not work in FOOTPRINT_PREVIEW_PANEL: + // force opengl or cairo canvas + aGalType == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ? aGalType + : EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ), KIWAY_HOLDER( aKiway ), m_DisplayOptions( std::move( aOpts ) ), m_footprintDisplayed( true ) diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index eef6dcefba..e000794689 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -192,9 +192,15 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent UpdateTitle(); // Create GAL canvas + m_canvasType = LoadCanvasTypeSetting(); + + // Legacy canvas is deprecated and does not work fine in footprint viewer. + // So force cairo canvas in this case + if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) + m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; + PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, - GetGalDisplayOptions(), - LoadCanvasTypeSetting() ); + GetGalDisplayOptions(), m_canvasType ); SetGalCanvas( drawPanel ); // Create the manager and dispatcher & route draw panel events to the dispatcher @@ -244,13 +250,14 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent m_auimgr.Update(); GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); - UseGalCanvas( true ); // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.) GetGalCanvas()->GetView()->SetScale( m_lastZoom ); updateView(); + UseGalCanvas( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ); + if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame { Raise(); // On some window managers, this is needed