From 6e9ddd9c936ff27095de95172bdd9567843818f5 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sat, 31 Oct 2020 17:16:48 -0400 Subject: [PATCH] Enable canvas switching in pl_editor --- common/eda_draw_frame.cpp | 3 ++- pagelayout_editor/menubar.cpp | 6 ++++++ pagelayout_editor/pl_draw_panel_gal.cpp | 5 ----- pagelayout_editor/pl_editor_frame.cpp | 11 +++++++---- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index ad5f285ece..3d821f7ae1 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -698,7 +698,8 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas { FRAME_SCH, FRAME_PCB_EDITOR, FRAME_FOOTPRINT_EDITOR, - FRAME_GERBER + FRAME_GERBER, + FRAME_PL_EDITOR }; bool allow_save = false; diff --git a/pagelayout_editor/menubar.cpp b/pagelayout_editor/menubar.cpp index 3742803931..c148b85c75 100644 --- a/pagelayout_editor/menubar.cpp +++ b/pagelayout_editor/menubar.cpp @@ -161,6 +161,12 @@ void PL_EDITOR_FRAME::ReCreateMenuBar() // Language submenu AddMenuLanguageList( preferencesMenu, selTool ); +#ifndef __WXMAC__ + preferencesMenu->AppendSeparator(); + preferencesMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); + preferencesMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); +#endif + //-- Menubar ----------------------------------------------------------- // menuBar->Append( fileMenu, _( "&File" ) ); diff --git a/pagelayout_editor/pl_draw_panel_gal.cpp b/pagelayout_editor/pl_draw_panel_gal.cpp index 4b8ae85217..53fc7ed21d 100644 --- a/pagelayout_editor/pl_draw_panel_gal.cpp +++ b/pagelayout_editor/pl_draw_panel_gal.cpp @@ -139,11 +139,6 @@ bool PL_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType ) { bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType ); - // The next onPaint event will call m_view->UpdateItems() that is very time consumming - // after switching to opengl. Clearing m_view and rebuild it is much faster - if( aGalType == GAL_TYPE_OPENGL ) - m_view->Clear(); - setDefaultLayerDeps(); GetGAL()->SetWorldUnitLength( 1.0/IU_PER_MM /* 10 nm */ / 25.4 /* 1 inch in mm */ ); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index f89300824d..d90573d3bf 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -101,10 +101,8 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SetIcon( icon ); // Create GAL canvas - m_canvasType = EDA_DRAW_PANEL_GAL::GAL_FALLBACK; - auto* drawPanel = new PL_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, - GetGalDisplayOptions(), m_canvasType ); + GetGalDisplayOptions(), EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ); SetCanvas( drawPanel ); LoadSettings( config() ); @@ -173,7 +171,6 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); - ActivateGalCanvas(); // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before // hidding it. @@ -183,6 +180,9 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.GetPane( "InfoBar" ).Hide(); m_auimgr.Update(); + ResolveCanvasType(); + SwitchCanvas( m_canvasType ); + // Add the exit key handler InitExitKey(); setupUnits( config() ); @@ -263,6 +263,9 @@ void PL_EDITOR_FRAME::setupUIConditions() mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) ); mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) ); + mgr->SetConditions( ACTIONS::acceleratedGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ) ); + mgr->SetConditions( ACTIONS::standardGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) ); + mgr->SetConditions( ACTIONS::cut, ENABLE( SELECTION_CONDITIONS::NotEmpty ) ); mgr->SetConditions( ACTIONS::copy, ENABLE( SELECTION_CONDITIONS::NotEmpty ) ); mgr->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::Idle ) );