diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index b9147a8de9..4317d45a32 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -61,6 +61,13 @@ namespace AC_KEYS */ static const wxChar EnableSvgImport[] = wxT( "EnableSvgImport" ); +/** + * Allow legacy canvas to be shown in GTK3. Legacy canvas is generally pretty + * broken, but this avoids code in an ifdef where it could become broken + * on other platforms + */ +static const wxChar AllowLegacyCanvasInGtk3[] = wxT( "AllowLegacyCanvasInGtk3" ); + } // namespace KEYS @@ -139,6 +146,7 @@ ADVANCED_CFG::ADVANCED_CFG() // Init defaults - this is done in case the config doesn't exist, // then the values will remain as set here. m_enableSvgImport = false; + m_allowLegacyCanvasInGtk3 = false; loadFromConfigFile(); } @@ -175,7 +183,24 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableSvgImport, &m_enableSvgImport, false ) ); + configParams.push_back( new PARAM_CFG_BOOL( + true, AC_KEYS::AllowLegacyCanvasInGtk3, &m_allowLegacyCanvasInGtk3, false ) ); + wxConfigLoadSetups( &aCfg, configParams ); dumpCfg( configParams ); +} + + +bool ADVANCED_CFG::AllowLegacyCanvas() const +{ + // default is to allow + bool allow = true; + + // on GTK3, check the config +#ifdef __WXGTK3__ + allow = m_allowLegacyCanvasInGtk3; +#endif + + return allow; } \ No newline at end of file diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp index 5536068538..5adcc5aacc 100644 --- a/common/legacy_gal/eda_draw_frame.cpp +++ b/common/legacy_gal/eda_draw_frame.cpp @@ -67,6 +67,7 @@ #include #include #include +#include /** * Definition for enabling and disabling scroll bar setting trace output. See the @@ -1083,6 +1084,13 @@ EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::LoadCanvasTypeSetting() canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; } + // Coerce the value into a GAL type when Legacy is not available + if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE + && !ADVANCED_CFG::GetCfg().AllowLegacyCanvas() ) + { + canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; + } + return canvasType; } diff --git a/common/legacy_wx/eda_draw_frame.cpp b/common/legacy_wx/eda_draw_frame.cpp index 0c4787f8d0..9cc319d958 100644 --- a/common/legacy_wx/eda_draw_frame.cpp +++ b/common/legacy_wx/eda_draw_frame.cpp @@ -66,10 +66,11 @@ #include #include +#include #include -#include #include #include +#include /** * Definition for enabling and disabling scroll bar setting trace output. See the @@ -1329,6 +1330,13 @@ EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::LoadCanvasTypeSetting() canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; } + // Coerce the value into a GAL type when Legacy is not available + if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE + && !ADVANCED_CFG::GetCfg().AllowLegacyCanvas() ) + { + canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; + } + return canvasType; } diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 792eaaf3a4..1a1fdaddd4 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -28,11 +28,12 @@ * @brief (Re)Create the main menubar for GerbView */ +#include "gerbview_frame.h" +#include #include #include -#include "gerbview_frame.h" #include "gerbview_id.h" #include "hotkeys.h" #include @@ -300,10 +301,13 @@ void GERBVIEW_FRAME::ReCreateMenuBar() // Canvas selection configMenu->AppendSeparator(); - text = AddHotkeyName( _( "Legacy Tool&set" ), GerbviewHokeysDescr, HK_CANVAS_LEGACY ); - AddMenuItem( configMenu, ID_MENU_CANVAS_LEGACY, - text, _( "Use Legacy Toolset (not all features will be available)" ), - KiBitmap( tools_xpm ), wxITEM_RADIO ); + if( ADVANCED_CFG::GetCfg().AllowLegacyCanvas() ) + { + text = AddHotkeyName( _( "Legacy Tool&set" ), GerbviewHokeysDescr, HK_CANVAS_LEGACY ); + AddMenuItem( configMenu, ID_MENU_CANVAS_LEGACY, text, + _( "Use Legacy Toolset (not all features will be available)" ), + KiBitmap( tools_xpm ), wxITEM_RADIO ); + } text = AddHotkeyName( _( "Modern Toolset (&Accelerated)" ), GerbviewHokeysDescr, HK_CANVAS_OPENGL ); AddMenuItem( configMenu, ID_MENU_CANVAS_OPENGL, text, diff --git a/include/advanced_config.h b/include/advanced_config.h index 20b10f4f9c..a69669ebd6 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -73,6 +73,21 @@ public: */ bool m_enableSvgImport; + /** + * Helper to determine if legacy canvas is allowed (according to platform + * and config) + * @return true if legacy canvas should be shown + */ + bool AllowLegacyCanvas() const; + +private: + /* + * These settings are private, as there is extra logic provide by helper + * functions above. + */ + + bool m_allowLegacyCanvasInGtk3; + private: ADVANCED_CFG(); diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index 7677950c87..ced90d1474 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -29,13 +29,14 @@ * @brief (Re)Create the main menubar for the footprint editor */ +#include "footprint_edit_frame.h" +#include #include #include #include "help_common_strings.h" #include "hotkeys.h" -#include "footprint_edit_frame.h" #include "pcbnew.h" #include "pcbnew_id.h" @@ -431,10 +432,13 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() prefs_menu->AppendSeparator(); - text = AddHotkeyName( _( "Legacy Tool&set" ), m_hotkeysDescrList, HK_CANVAS_LEGACY ); - AddMenuItem( prefs_menu, ID_MENU_CANVAS_LEGACY, text, - _( "Use Legacy Toolset (not all features will be available)" ), - KiBitmap( tools_xpm ), wxITEM_RADIO ); + if( ADVANCED_CFG::GetCfg().AllowLegacyCanvas() ) + { + text = AddHotkeyName( _( "Legacy Tool&set" ), m_hotkeysDescrList, HK_CANVAS_LEGACY ); + AddMenuItem( prefs_menu, ID_MENU_CANVAS_LEGACY, text, + _( "Use Legacy Toolset (not all features will be available)" ), + KiBitmap( tools_xpm ), wxITEM_RADIO ); + } text = AddHotkeyName( _( "Modern Toolset (&Accelerated)" ), m_hotkeysDescrList, HK_CANVAS_OPENGL ); AddMenuItem( prefs_menu, ID_MENU_CANVAS_OPENGL, text, diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index b104f2517b..9683cfe803 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -28,20 +28,19 @@ * @file menubar_pcb_editor.cpp * board editor menubars */ - - -#include -#include -#include #include +#include +#include +#include +#include + #include "help_common_strings.h" #include "hotkeys.h" #include "pcbnew.h" #include "pcbnew_id.h" - // Build the files menu. Because some commands are available only if // Pcbnew is run outside a project (run alone), aIsOutsideProject is false // when Pcbnew is run from Kicad manager, and true is run as stand alone app. @@ -158,11 +157,14 @@ void preparePreferencesMenu( PCB_EDIT_FRAME* aFrame, wxMenu* aParentMenu ) _( "&Preferences..." ), _( "Show preferences for all open tools" ), KiBitmap( preference_xpm ) ); - text = AddHotkeyName( _( "Legacy Tool&set" ), g_Board_Editor_Hotkeys_Descr, - HK_CANVAS_LEGACY ); - AddMenuItem( aParentMenu, ID_MENU_CANVAS_LEGACY, text, - _( "Use Legacy Toolset (not all features will be available)" ), - KiBitmap( tools_xpm ), wxITEM_RADIO ); + if( ADVANCED_CFG::GetCfg().AllowLegacyCanvas() ) + { + text = AddHotkeyName( + _( "Legacy Tool&set" ), g_Board_Editor_Hotkeys_Descr, HK_CANVAS_LEGACY ); + AddMenuItem( aParentMenu, ID_MENU_CANVAS_LEGACY, text, + _( "Use Legacy Toolset (not all features will be available)" ), + KiBitmap( tools_xpm ), wxITEM_RADIO ); + } text = AddHotkeyName( _( "Modern Toolset (&Accelerated)" ), g_Board_Editor_Hotkeys_Descr, HK_CANVAS_OPENGL );