For your consideration, a patch is attached that implements the above.
On Sun, Dec 31, 2017 at 2:24 PM, Jon Evans <j...@craftyjon.com> wrote: > I think that getting automatic OpenGL detection and recovery working for > 5.0 might be ambitious. > Maybe Chris can detail what the next steps are for his approach there, but > in case we want to push that to a later release, here's what I propose: > > 1) Rename the View menu options based on my proposal "Legacy", "Modern > (Accelerated)", "Modern (Fallback)" > 2) Change PCB_BASE_FRAME::SwitchCanvas to save the canvas config value > after calling UseGalCanvas() rather than before. > 3) Show a first-run dialog like the mockup in my earlier email, IF canvas > is not OpenGL and the dialog has not been shown before > 44) If user clicks "yes" in the first run dialog, then: > (a) set the config value to prevent the dialog from showing again, > (b) Set the canvas config setting to Cairo (but don't switch the GAL > to Cairo), then > (c) switch to OpenGL canvas using SwitchCanvas() > > That way, if the app crashes in step 4c, it should come back up as Cairo > on the next launch (assuming we crash right away when trying to set up the > canvas) > > Any concerns with the above? > > -Jon > > > > On Sun, Dec 31, 2017 at 1:55 PM, Jeff Young <j...@rokeby.ie> wrote: > >> +1 >> >> No menu items. Just a checkbox for Enable Hardware Acceleration in >> Preferences. >> >> On 31 Dec 2017, at 18:36, Andy Peters <de...@latke.net> wrote: >> >> - In the case of graphics glitches, inform the users in the FAQ/Manual >> that they can fall back to software renderer in the View menu. >> - Don't use the term 'canvas' or 'view'. Just 'Enable HW acceleration’. >> >> >> I like that. The fewer technical/programmer terms, the better. >> >> >> >> _______________________________________________ >> Mailing list: https://launchpad.net/~kicad-developers >> Post to : kicad-developers@lists.launchpad.net >> Unsubscribe : https://launchpad.net/~kicad-developers >> More help : https://help.launchpad.net/ListHelp >> >> >
From d4383c70db5ff5c9c92d91df5783005fd72e05a0 Mon Sep 17 00:00:00 2001 From: Jon Evans <j...@craftyjon.com> Date: Sun, 31 Dec 2017 16:27:52 -0500 Subject: [PATCH] Add a first-run dialog to encourage user to switch to OpenGL graphics --- common/CMakeLists.txt | 1 + common/dialogs/dialog_first_run.cpp | 101 ++++++++++++++++++++++++++++++++++++ common/dialogs/dialog_first_run.h | 56 ++++++++++++++++++++ common/draw_frame.cpp | 4 ++ gerbview/gerbview_frame.cpp | 12 +++++ gerbview/gerbview_id.h | 3 -- gerbview/menubar.cpp | 12 ++--- include/draw_frame.h | 13 +++++ include/id.h | 4 ++ pcbnew/basepcbframe.cpp | 2 +- pcbnew/menubar_modedit.cpp | 12 ++--- pcbnew/menubar_pcbframe.cpp | 12 ++--- pcbnew/pcbframe.cpp | 12 +++++ pcbnew/pcbnew_id.h | 3 -- 14 files changed, 222 insertions(+), 25 deletions(-) create mode 100644 common/dialogs/dialog_first_run.cpp create mode 100644 common/dialogs/dialog_first_run.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index f053ee5b6..b8de67078 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -155,6 +155,7 @@ set( COMMON_DLG_SRCS dialogs/dialog_env_var_config.cpp dialogs/dialog_env_var_config_base.cpp dialogs/dialog_exit_base.cpp + dialogs/dialog_first_run.cpp dialogs/dialog_get_component.cpp dialogs/dialog_get_component_base.cpp dialogs/dialog_hotkeys_editor.cpp diff --git a/common/dialogs/dialog_first_run.cpp b/common/dialogs/dialog_first_run.cpp new file mode 100644 index 000000000..086ac7137 --- /dev/null +++ b/common/dialogs/dialog_first_run.cpp @@ -0,0 +1,101 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2017 Jon Evans <j...@craftyjon.com> + * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <wxstruct.h> +#include "id.h" + +#include "dialog_first_run.h" + + +DIALOG_FIRST_RUN::DIALOG_FIRST_RUN( EDA_DRAW_FRAME* aParent ) + : DIALOG_SHIM( aParent, wxID_ANY, _( "Enable Graphics Acceleration" ), + wxDefaultPosition, wxSize( 420, 220 ), + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ), + m_parent( aParent ) +{ + auto sizer = new wxBoxSizer( wxVERTICAL ); + auto buttons = new wxStdDialogButtonSizer(); + + auto ok = new wxButton( this, wxID_OK, _( "Enable Acceleration" ) ); + auto cancel = new wxButton( this, wxID_CANCEL, _( "No Thanks" ) ); + + buttons->AddButton( ok ); + buttons->AddButton( cancel ); + buttons->Realize(); + + 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." ); + + auto text = new wxStaticText( this, -1, msg ); + text->Wrap( 400 ); + + sizer->Add( text, 1, wxEXPAND | wxALL, 5 ); + sizer->Add( buttons, 0, wxEXPAND | wxBOTTOM, 10 ); + SetSizer( sizer ); + + cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, + wxCommandEventHandler( DIALOG_FIRST_RUN::OnCancelClick ), + NULL, this ); + + ok->Connect( wxEVT_COMMAND_BUTTON_CLICKED, + wxCommandEventHandler( DIALOG_FIRST_RUN::OnOkClick ), + NULL, this ); + + ok->SetFocus(); + + FinishDialogSettings(); +} + + +void DIALOG_FIRST_RUN::accept() +{ + // Save Cairo as default in case OpenGL crashes + m_parent->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 = m_parent->GetEventHandler(); + handler->ProcessEvent( evt ); +} + + +void DIALOG_FIRST_RUN::decline() +{ + // If they were on legacy, switch them to Cairo + auto current = m_parent->loadCanvasTypeSetting(); + + if( current == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) + { + wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO ); + auto handler = m_parent->GetEventHandler(); + handler->ProcessEvent( evt ); + } +} + + +void EDA_DRAW_FRAME::ShowFirstRunDialog( EDA_DRAW_FRAME* aCaller ) +{ + DIALOG_FIRST_RUN dlg( aCaller ); + dlg.ShowModal(); +} diff --git a/common/dialogs/dialog_first_run.h b/common/dialogs/dialog_first_run.h new file mode 100644 index 000000000..d36b1485c --- /dev/null +++ b/common/dialogs/dialog_first_run.h @@ -0,0 +1,56 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2017 Jon Evans <j...@craftyjon.com> + * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef _DIALOG_FIRST_RUN_H_ +#define _DIALOG_FIRST_RUN_H_ + +#include "draw_frame.h" +#include "dialog_shim.h" + + +class DIALOG_FIRST_RUN : public DIALOG_SHIM +{ +public: + DIALOG_FIRST_RUN( EDA_DRAW_FRAME* aParent ); + +private: + EDA_DRAW_FRAME* m_parent; + + void OnOkClick( wxCommandEvent& event ) + { + accept(); + EndModal( wxID_OK ); + } + + void OnCancelClick( wxCommandEvent& event ) + { + decline(); + EndModal( wxID_CANCEL ); + } + + void accept(); + + void decline(); +}; + + +#endif + +// _DIALOG_FIRST_RUN_H_ diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index e1f79db7b..bd9342155 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 45ea60476..eb1538e34 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -211,6 +211,18 @@ 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( ( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) && + ( m_firstRunDialogSetting < 1 ) ) + { + ShowFirstRunDialog( this ); + 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 2e4494b81..035aa716a 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 fa3f372b7..ca75755d3 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 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 graphics mode" ), wxITEM_RADIO ) ); // Menu miscellaneous diff --git a/include/draw_frame.h b/include/draw_frame.h index e3e2cae89..e5b7ddd63 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -57,6 +57,9 @@ class EDA_DRAW_FRAME : public KIWAY_PLAYER /// it is closely tied to the #EDA_DRAW_FRAME. friend class EDA_DRAW_PANEL; + // For access to saveCanvasTypeSetting() + friend class DIALOG_FIRST_RUN; + ///< Id of active button on the vertical toolbar. int m_toolId; @@ -112,6 +115,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; @@ -884,6 +890,13 @@ public: */ KIGFX::GAL_DISPLAY_OPTIONS& GetGalDisplayOptions() { return *m_galDisplayOptions; } + /** + * Launches the first-run dialog + * + * Currently, this dialog prompts the user to switch to the OpenGL canvas + */ + void ShowFirstRunDialog( EDA_DRAW_FRAME* aCaller ); + DECLARE_EVENT_TABLE() }; diff --git a/include/id.h b/include/id.h index e95ff3f08..1ca5b4dac 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 c959f8055..54ba21cb7 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 88cfed0df..94bcbdc7e 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 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 graphics mode" ), wxITEM_RADIO ) ); //-------- Place menu -------------------- diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index 3085d5a4d..419eaa26b 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 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 graphics mode" ), wxITEM_RADIO ) ); } diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index c8accb7f9..036d1503e 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -470,6 +470,18 @@ 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( ( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) && + ( m_firstRunDialogSetting < 1 ) ) + { + ShowFirstRunDialog( this ); + 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 8c1bf27c8..41184794e 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, -- 2.14.1
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : kicad-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp