From aedc65f20feded15a91eda52e6d87c56494f53fb Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@craftyjon.com>
Date: Tue, 23 Feb 2021 20:02:48 -0500
Subject: [PATCH] Fix footprint editor default grid

Fixes https://gitlab.com/kicad/code/kicad/-/issues/7659
---
 common/settings/app_settings.cpp | 27 +++++++++++++++++++++++++++
 include/settings/app_settings.h  |  9 +++++++--
 pcbnew/pcbnew_settings.cpp       | 27 ---------------------------
 pcbnew/pcbnew_settings.h         |  2 --
 4 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/common/settings/app_settings.cpp b/common/settings/app_settings.cpp
index 69fc87c8d8..384a39effd 100644
--- a/common/settings/app_settings.cpp
+++ b/common/settings/app_settings.cpp
@@ -327,3 +327,30 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std:
     m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.fullscreen_cursor",
             &aWindow->cursor.fullscreen_cursor, false ) );
 }
+
+
+const std::vector<wxString> APP_SETTINGS_BASE::DefaultGridSizeList() const
+{
+    return { "1000 mil",
+             "500 mil",
+             "250 mil",
+             "200 mil",
+             "100 mil",
+             "50 mil",
+             "25 mil",
+             "20 mil",
+             "10 mil",
+             "5 mil",
+             "2 mil",
+             "1 mil",
+             "5.0 mm",
+             "2.5 mm",
+             "1.0 mm",
+             "0.5 mm",
+             "0.25 mm",
+             "0.2 mm",
+             "0.1 mm",
+             "0.05 mm",
+             "0.025 mm",
+             "0.01 mm" };
+}
diff --git a/include/settings/app_settings.h b/include/settings/app_settings.h
index f7fd2f4563..be3b734569 100644
--- a/include/settings/app_settings.h
+++ b/include/settings/app_settings.h
@@ -155,8 +155,13 @@ public:
 
     virtual bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
 
-    /// Override in child classes to define the default for the window.grid.sizes parameter
-    virtual const std::vector<wxString> DefaultGridSizeList() const { return {}; }
+    /**
+     * By default, this returns the list of grids available in PcbNew-based applications.
+     * Eeschema does not allow customization of the grid.  If it ever does, override this in
+     * Eeschema settings to provide a different set of defaults.
+     * @return a default value for the the window.grid.sizes parameter
+     */
+    virtual const std::vector<wxString> DefaultGridSizeList() const;
 
 public:
     CROSS_PROBING_SETTINGS m_CrossProbing;
diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp
index 8f2732ad09..5a67eded5e 100644
--- a/pcbnew/pcbnew_settings.cpp
+++ b/pcbnew/pcbnew_settings.cpp
@@ -790,30 +790,3 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
 
     return ret;
 }
-
-
-const std::vector<wxString> PCBNEW_SETTINGS::DefaultGridSizeList() const
-{
-    return { "1000 mil",
-             "500 mil",
-             "250 mil",
-             "200 mil",
-             "100 mil",
-             "50 mil",
-             "25 mil",
-             "20 mil",
-             "10 mil",
-             "5 mil",
-             "2 mil",
-             "1 mil",
-             "5.0 mm",
-             "2.5 mm",
-             "1.0 mm",
-             "0.5 mm",
-             "0.25 mm",
-             "0.2 mm",
-             "0.1 mm",
-             "0.05 mm",
-             "0.025 mm",
-             "0.01 mm" };
-}
diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h
index bbf0c6002a..81600b53f6 100644
--- a/pcbnew/pcbnew_settings.h
+++ b/pcbnew/pcbnew_settings.h
@@ -234,8 +234,6 @@ public:
 
     virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
 
-    const std::vector<wxString> DefaultGridSizeList() const override;
-
     AUI_PANELS m_AuiPanels;
 
     DIALOG_CLEANUP m_Cleanup;