From 2dec95b4e63c160539e1fa3f88996c78a733d2c3 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 4 Jan 2018 09:28:02 -0500 Subject: [PATCH] Add a first-run dialog to encourage user to switch to OpenGL --- common/draw_frame.cpp | 4 ++++ gerbview/gerbview_frame.cpp | 47 +++++++++++++++++++++++++++++++++++++ gerbview/gerbview_id.h | 3 --- gerbview/menubar.cpp | 12 +++++----- include/draw_frame.h | 3 +++ include/id.h | 4 ++++ pcbnew/basepcbframe.cpp | 2 +- pcbnew/menubar_modedit.cpp | 12 +++++----- pcbnew/menubar_pcbframe.cpp | 12 +++++----- pcbnew/pcbframe.cpp | 47 +++++++++++++++++++++++++++++++++++++ pcbnew/pcbnew_id.h | 3 --- 11 files changed, 124 insertions(+), 25 deletions(-) diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index e1f79db7b4..bd9342155a 100644 --- a/common/draw_frame.cpp +++ b/common/draw_frame.cpp @@ -76,6 +76,7 @@ static const wxString GalDisplayOptionsKeyword( wxT( "GalDisplayOptions" ) ); const wxChar EDA_DRAW_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" ); +static const wxString FirstRunShownKeyword( wxT( "FirstRunShown" ) ); ///@} @@ -739,6 +740,8 @@ void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg ) m_UndoRedoCountMax = aCfg->Read( baseCfgName + MaxUndoItemsEntry, long( DEFAULT_MAX_UNDO_ITEMS ) ); + aCfg->Read( baseCfgName + FirstRunShownKeyword, &m_firstRunDialogSetting, 0L ); + m_galDisplayOptions->ReadConfig( aCfg, baseCfgName + GalDisplayOptionsKeyword ); } @@ -753,6 +756,7 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg ) aCfg->Write( baseCfgName + GridColorEntryKeyword, GetGridColor().ToColour().GetAsString( wxC2S_CSS_SYNTAX ) ); aCfg->Write( baseCfgName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId ); + aCfg->Write( baseCfgName + FirstRunShownKeyword, m_firstRunDialogSetting ); if( GetScreen() ) aCfg->Write( baseCfgName + MaxUndoItemsEntry, long( GetScreen()->GetMaxUndoItems() ) ); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 45ea604763..fe89877a40 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -211,6 +211,53 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = loadCanvasTypeSetting(); + // Nudge user to switch to OpenGL if they are on legacy or Cairo + if( m_firstRunDialogSetting < 1 ) + { + if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) + { + wxString msg = _( "KiCad can use your graphics card to give you a smoother " + "and faster experience. This option is turned off by " + "default since it is not compatible with all computers.\n\n" + "Would you like to try enabling graphics acceleration?\n\n" + "If you'd like to choose later, select the Modern " + "(Accelerated) graphics mode in the View menu." ); + + wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), + wxYES_NO ); + + dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) ); + + if( dlg.ShowModal() == wxID_YES ) + { + // Save Cairo as default in case OpenGL crashes + saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); + + // Switch to OpenGL, which will save the new setting if successful + wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_OPENGL ); + auto handler = GetEventHandler(); + handler->ProcessEvent( evt ); + } + else + { + // If they were on legacy, switch them to Cairo + + if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) + { + wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO ); + auto handler = GetEventHandler(); + handler->ProcessEvent( evt ); + } + } + } + + m_firstRunDialogSetting = 1; + SaveSettings( config() ); + } + + // Canvas may have been updated by the dialog + canvasType = loadCanvasTypeSetting(); + if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) { if( GetGalCanvas()->SwitchBackend( canvasType ) ) diff --git a/gerbview/gerbview_id.h b/gerbview/gerbview_id.h index 2e4494b814..035aa716a2 100644 --- a/gerbview/gerbview_id.h +++ b/gerbview/gerbview_id.h @@ -50,9 +50,6 @@ enum gerbview_ids ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG, ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR, - ID_MENU_CANVAS_LEGACY, - ID_MENU_CANVAS_OPENGL, - ID_MENU_CANVAS_CAIRO, ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE, ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE, diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index fa3f372b70..dc9b745e40 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -211,28 +211,28 @@ void GERBVIEW_FRAME::ReCreateMenuBar() // Canvas selection configMenu->AppendSeparator(); - text = AddHotkeyName( _( "Legacy Canva&s" ), GerbviewHokeysDescr, + text = AddHotkeyName( _( "Legacy graphic&s" ), GerbviewHokeysDescr, HK_CANVAS_LEGACY ); configMenu->Append( new wxMenuItem( configMenu, ID_MENU_CANVAS_LEGACY, - text, _( "Switch the canvas implementation to Legacy" ), + text, _( "Use legacy graphics mode (not all features will be available" ), wxITEM_RADIO ) ); - text = AddHotkeyName( _( "Open&GL Canvas" ), GerbviewHokeysDescr, + text = AddHotkeyName( _( "Modern (&Accelerated)" ), GerbviewHokeysDescr, HK_CANVAS_OPENGL ); configMenu->Append( new wxMenuItem( configMenu, ID_MENU_CANVAS_OPENGL, - text, _( "Switch the canvas implementation to OpenGL" ), + text, _( "Use modern hardware-accelerated (OpenGL) graphics mode (recommended)" ), wxITEM_RADIO ) ); - text = AddHotkeyName( _( "&Cairo Canvas" ), GerbviewHokeysDescr, + text = AddHotkeyName( _( "Modern (Fallba&ck)" ), GerbviewHokeysDescr, HK_CANVAS_CAIRO ); configMenu->Append( new wxMenuItem( configMenu, ID_MENU_CANVAS_CAIRO, - text, _( "Switch the canvas implementation to Cairo" ), + text, _( "Use modern fallback (Cairo) graphics mode" ), wxITEM_RADIO ) ); // Menu miscellaneous diff --git a/include/draw_frame.h b/include/draw_frame.h index e3e2cae891..899c9784b3 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -112,6 +112,9 @@ protected: /// True shows the drawing border and title block. bool m_showBorderAndTitleBlock; + /// Key to control whether first run dialog is shown on startup + long m_firstRunDialogSetting; + /// Choice box to choose the grid size. wxChoice* m_gridSelectBox; diff --git a/include/id.h b/include/id.h index e95ff3f085..1ca5b4dacc 100644 --- a/include/id.h +++ b/include/id.h @@ -85,6 +85,10 @@ enum main_id ID_CONFIG_SAVE, ID_CONFIG_READ, + ID_MENU_CANVAS_LEGACY, + ID_MENU_CANVAS_OPENGL, + ID_MENU_CANVAS_CAIRO, + ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_EXPORT_CONFIG, ID_PREFERENCES_HOTKEY_IMPORT_CONFIG, diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index c959f80555..54ba21cb73 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -957,8 +957,8 @@ void PCB_BASE_FRAME::SwitchCanvas( wxCommandEvent& aEvent ) break; } - saveCanvasTypeSetting( canvasType ); UseGalCanvas( use_gal ); + saveCanvasTypeSetting( canvasType ); } diff --git a/pcbnew/menubar_modedit.cpp b/pcbnew/menubar_modedit.cpp index 88cfed0df0..637f23dce3 100644 --- a/pcbnew/menubar_modedit.cpp +++ b/pcbnew/menubar_modedit.cpp @@ -254,28 +254,28 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() // Add canvas selection viewMenu->AppendSeparator(); - text = AddHotkeyName( _( "Legacy Canva&s" ), m_hotkeysDescrList, + text = AddHotkeyName( _( "Legacy graphic&s" ), m_hotkeysDescrList, HK_CANVAS_LEGACY ); viewMenu->Append( new wxMenuItem( viewMenu, ID_MENU_CANVAS_LEGACY, - text, _( "Switch the canvas implementation to Legacy" ), + text, _( "Use legacy graphics mode (not all features will be available" ), wxITEM_RADIO ) ); - text = AddHotkeyName( _( "Open&GL Canvas" ), m_hotkeysDescrList, + text = AddHotkeyName( _( "Modern (&Accelerated)" ), m_hotkeysDescrList, HK_CANVAS_OPENGL ); viewMenu->Append( new wxMenuItem( viewMenu, ID_MENU_CANVAS_OPENGL, - text, _( "Switch the canvas implementation to OpenGL" ), + text, _( "Use modern hardware-accelerated (OpenGL) graphics mode (recommended)" ), wxITEM_RADIO ) ); - text = AddHotkeyName( _( "&Cairo Canvas" ), m_hotkeysDescrList, + text = AddHotkeyName( _( "Modern (Fallba&ck)" ), m_hotkeysDescrList, HK_CANVAS_CAIRO ); viewMenu->Append( new wxMenuItem( viewMenu, ID_MENU_CANVAS_CAIRO, - text, _( "Switch the canvas implementation to Cairo" ), + text, _( "Use modern fallback (Cairo) graphics mode" ), wxITEM_RADIO ) ); //-------- Place menu -------------------- diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index 3085d5a4d3..358c510e69 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -559,28 +559,28 @@ void prepareViewMenu( wxMenu* aParentMenu ) aParentMenu->AppendSeparator(); - text = AddHotkeyName( _( "Legacy Canva&s" ), g_Pcbnew_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "Legacy graphic&s" ), g_Pcbnew_Editor_Hokeys_Descr, HK_CANVAS_LEGACY ); aParentMenu->Append( new wxMenuItem( aParentMenu, ID_MENU_CANVAS_LEGACY, - text, _( "Switch canvas implementation to Legacy" ), + text, _( "Use legacy graphics mode (not all features will be available" ), wxITEM_RADIO ) ); - text = AddHotkeyName( _( "Open&GL Canvas" ), g_Pcbnew_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "Modern (&Accelerated)" ), g_Pcbnew_Editor_Hokeys_Descr, HK_CANVAS_OPENGL ); aParentMenu->Append( new wxMenuItem( aParentMenu, ID_MENU_CANVAS_OPENGL, - text, _( "Switch canvas implementation to OpenGL" ), + text, _( "Use modern hardware-accelerated (OpenGL) graphics mode (recommended)" ), wxITEM_RADIO ) ); - text = AddHotkeyName( _( "&Cairo Canvas" ), g_Pcbnew_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "Modern (Fallba&ck)" ), g_Pcbnew_Editor_Hokeys_Descr, HK_CANVAS_CAIRO ); aParentMenu->Append( new wxMenuItem( aParentMenu, ID_MENU_CANVAS_CAIRO, - text, _( "Switch canvas implementation to Cairo" ), + text, _( "Use modern fallback (Cairo) graphics mode" ), wxITEM_RADIO ) ); } diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index c8accb7f92..38029d150a 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -470,6 +470,53 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = loadCanvasTypeSetting(); + // Nudge user to switch to OpenGL if they are on legacy or Cairo + if( m_firstRunDialogSetting < 1 ) + { + if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) + { + wxString msg = _( "KiCad can use your graphics card to give you a smoother " + "and faster experience. This option is turned off by " + "default since it is not compatible with all computers.\n\n" + "Would you like to try enabling graphics acceleration?\n\n" + "If you'd like to choose later, select the Modern " + "(Accelerated) graphics mode in the View menu." ); + + wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), + wxYES_NO ); + + dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) ); + + if( dlg.ShowModal() == wxID_YES ) + { + // Save Cairo as default in case OpenGL crashes + saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); + + // Switch to OpenGL, which will save the new setting if successful + wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_OPENGL ); + auto handler = GetEventHandler(); + handler->ProcessEvent( evt ); + } + else + { + // If they were on legacy, switch them to Cairo + + if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) + { + wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO ); + auto handler = GetEventHandler(); + handler->ProcessEvent( evt ); + } + } + } + + m_firstRunDialogSetting = 1; + SaveSettings( config() ); + } + + // Canvas may have been updated by the dialog + canvasType = loadCanvasTypeSetting(); + if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) { if( GetGalCanvas()->SwitchBackend( canvasType ) ) diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 8c1bf27c8f..41184794ee 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -299,9 +299,6 @@ enum pcbnew_ids ID_PCB_GEN_CMP_FILE, ID_MENU_PCB_SHOW_3D_FRAME, - ID_MENU_CANVAS_LEGACY, - ID_MENU_CANVAS_OPENGL, - ID_MENU_CANVAS_CAIRO, ID_PCB_USER_GRID_SETUP, ID_PCB_GEN_BOM_FILE_FROM_BOARD, ID_PCB_LIB_WIZARD,