← Back to team overview

kicad-developers team mailing list archive

Re: [Patch] Add ability to reset Pcbnew layer colors to default

 

Whoops, that wasn't supposed to be committed. This patch has it removed it.

-Ian

On Thu, Aug 22, 2019 at 7:00 PM Jon Evans <jon@xxxxxxxxxxxxx> wrote:

> Yup, I'm fine with this patch, just trying to answer Ian's question about
> whether or not there is V6 work planned here.
>
> On Thu, Aug 22, 2019 at 11:55 AM Wayne Stambaugh <stambaughw@xxxxxxxxx>
> wrote:
>
>> Jon,
>>
>> Ian's patch resets the layer colors back to the hard coded default layer
>> colors.  I know this isn't a complete solution but it might be handy
>> until you finish the full layer color changes.  Unless this interferes
>> with something you are working on, I'm fine with merging this patch as a
>> short term solution.
>>
>> Ian,
>>
>> You accidentally committed your Doxygen error log file.  I don't think
>> we would want to merge that into the KiCad source.  If Jon is OK with
>> merging this, you please resubmit the patch without your Doxygen error
>> log file.
>>
>> Cheers,
>>
>> Wayne
>>
>> On 8/21/19 5:21 PM, Jon Evans wrote:
>> > Yes, there is V6 work planned for this, I was planning on doing it, but
>> > there are several steps in between (first changing how settings in
>> > general are stored, and then a general refresh of the layers/color
>> > settings GUI)
>> >
>> > On Wed, Aug 21, 2019 at 5:06 PM Ian McInerney <Ian.S.McInerney@xxxxxxxx
>> > <mailto:Ian.S.McInerney@xxxxxxxx>> wrote:
>> >
>> >     I noticed today that the layer color selector dialog didn't have a
>> >     way of resetting the color to the KiCad default (I needed to do this
>> >     today). This patch adds the ability for that to be done in Pcbnew
>> >     (for both layers and items).
>> >
>> >     This same thing could be done in Gerbview, but the default colors
>> >     there are not exposed as nicely as in Pcbnew, so it would be more
>> >     convoluted. I wasn't sure if there was already v6 work planned on
>> >     that part, so I have left it alone. If there isn't, then I could go
>> >     back and tidy it up to implement this same defaults system.
>> >
>> >     -Ian
>> >     _______________________________________________
>> >     Mailing list: https://launchpad.net/~kicad-developers
>> >     Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> >     <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
>> >     Unsubscribe : https://launchpad.net/~kicad-developers
>> >     More help   : https://help.launchpad.net/ListHelp
>> >
>> >
>> > _______________________________________________
>> > Mailing list: https://launchpad.net/~kicad-developers
>> > Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> > Unsubscribe : https://launchpad.net/~kicad-developers
>> > More help   : https://help.launchpad.net/ListHelp
>> >
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help   : https://help.launchpad.net/ListHelp
>>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
>
From 721d99e4f105f78e289fd1df83fc88978e475a10 Mon Sep 17 00:00:00 2001
From: Ian McInerney <Ian.S.McInerney@xxxxxxxx>
Date: Wed, 21 Aug 2019 22:57:53 +0200
Subject: [PATCH] pcbnew: Add ability to reset layer/item colors to defaults

---
 common/colors_design_settings.cpp           | 76 +++++++++++++--------
 common/dialogs/dialog_color_picker.cpp      | 21 +++++-
 common/dialogs/dialog_color_picker.h        |  8 ++-
 common/dialogs/dialog_color_picker_base.cpp |  7 +-
 common/dialogs/dialog_color_picker_base.fbp | 73 ++++++++++++++++++++
 common/dialogs/dialog_color_picker_base.h   |  4 +-
 common/widgets/color_swatch.cpp             |  8 ++-
 include/colors_design_settings.h            | 25 +++++--
 include/widgets/color_swatch.h              |  6 +-
 pcbnew/layer_widget.cpp                     |  4 +-
 pcbnew/layer_widget.h                       |  6 +-
 pcbnew/pcb_layer_widget.cpp                 | 15 ++--
 12 files changed, 204 insertions(+), 49 deletions(-)

diff --git a/common/colors_design_settings.cpp b/common/colors_design_settings.cpp
index 67c764890..dae50497c 100644
--- a/common/colors_design_settings.cpp
+++ b/common/colors_design_settings.cpp
@@ -70,28 +70,35 @@ static const EDA_COLOR_T default_layer_color[] = {
 
 // for color order, see enum GAL_LAYER_ID
 static const EDA_COLOR_T default_items_color[] = {
-    LIGHTGRAY, // unused
-    CYAN,      // LAYER_VIA_MICROVIA
-    BROWN,     // LAYER_VIA_BBLIND
-    LIGHTGRAY, // LAYER_VIA_THROUGH
-    YELLOW,    // LAYER_NON_PLATED
-    LIGHTGRAY, // LAYER_MOD_TEXT_FR
-    BLUE,      // LAYER_MOD_TEXT_BK
-    DARKGRAY,  // LAYER_MOD_TEXT_INVISIBLE
-    BLUE,      // LAYER_ANCHOR
-    RED,       // LAYER_PAD_FR
-    GREEN,     // LAYER_PAD_BK
-    LIGHTGRAY, // LAYER_RATSNEST
-    DARKGRAY,  // LAYER_GRID
-    LIGHTRED,  // LAYER_GRID_AXES
-    BLUE,      // LAYER_NO_CONNECTS
-    LIGHTGRAY, LIGHTGRAY,   // LAYER_MOD_FR, LAYER_MOD_BK
-    LIGHTGRAY, LIGHTGRAY,   // LAYER_MOD_VALUES, LAYER_MOD_REFERENCES
-    LIGHTGRAY, // LAYER_TRACKS
-    YELLOW,    // LAYER_PADS
-    LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY,
-    LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY,
-    LIGHTGRAY, LIGHTGRAY, LIGHTGRAY
+    LIGHTGRAY,            // unused (LAYER_VIAS = GAL_LAYER_ID_START)
+    CYAN,                 // LAYER_VIA_MICROVIA
+    BROWN,                // LAYER_VIA_BBLIND
+    LIGHTGRAY,            // LAYER_VIA_THROUGH
+    YELLOW,               // LAYER_NON_PLATED
+    LIGHTGRAY,            // LAYER_MOD_TEXT_FR
+    BLUE,                 // LAYER_MOD_TEXT_BK
+    DARKGRAY,             // LAYER_MOD_TEXT_INVISIBLE
+    BLUE,                 // LAYER_ANCHOR
+    RED,                  // LAYER_PAD_FR
+    GREEN,                // LAYER_PAD_BK
+    LIGHTGRAY,            // LAYER_RATSNEST
+    DARKGRAY,             // LAYER_GRID
+    LIGHTRED,             // LAYER_GRID_AXES
+    BLUE,                 // LAYER_NO_CONNECTS
+    LIGHTGRAY, LIGHTGRAY, // LAYER_MOD_FR, LAYER_MOD_BK
+    LIGHTGRAY, LIGHTGRAY, // LAYER_MOD_VALUES, LAYER_MOD_REFERENCES
+    LIGHTGRAY,            // LAYER_TRACKS
+    YELLOW, LIGHTGRAY,    // LAYER_PADS, LAYER_PADS_PLATEDHOLES
+    LIGHTGRAY,            // LAYER_VIAS_HOLES
+    LIGHTGRAY,            // LAYER_DRC
+    DARKRED,              // LAYER_WORKSHEET
+    LIGHTGRAY,            // LAYER_GP_OVERLAY
+    LIGHTGRAY,            // LAYER_SELECT_OVERLAY
+    BLACK,                // LAYER_PCB_BACKGROUND
+    WHITE,                // LAYER_CURSOR
+    WHITE,                // LAYER_AUX_ITEMS
+    LIGHTGRAY,            // LAYER_DRAW_BITMAPS
+    LIGHTGRAY             // unused (GAL_LAYER_ID_BITMASK_END)
 };
 
 
@@ -112,16 +119,19 @@ COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS( FRAME_T aFrameType )
         m_LayersColors[dst] = COLOR4D( default_items_color[src] );
     }
 
-    m_LayersColors[ LAYER_PCB_BACKGROUND ] = BLACK;
-    m_LayersColors[ LAYER_CURSOR ] = WHITE;
-    m_LayersColors[ LAYER_AUX_ITEMS ] = WHITE;
-    m_LayersColors[ LAYER_WORKSHEET ] = DARKRED;
-    m_LayersColors[ LAYER_GRID ] = DARKGRAY;
-
     setupConfigParams();
 }
 
 
+COLOR4D COLORS_DESIGN_SETTINGS::GetDefaultLayerColor( LAYER_NUM aLayer )
+{
+    if( (unsigned) aLayer < arrayDim( default_layer_color ) )
+        return COLOR4D( default_layer_color[aLayer] );
+
+    return COLOR4D::UNSPECIFIED;
+}
+
+
 COLOR4D COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const
 {
     if( (unsigned) aLayer < arrayDim( m_LayersColors ) )
@@ -138,6 +148,16 @@ void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor )
 }
 
 
+COLOR4D COLORS_DESIGN_SETTINGS::GetDefaultItemColor( int aItemIdx )
+{
+    unsigned int idx = (unsigned) aItemIdx - LAYER_VIAS;
+    if( idx < arrayDim( default_items_color ) )
+        return COLOR4D( default_items_color[idx] );
+
+    return COLOR4D::UNSPECIFIED;
+}
+
+
 COLOR4D COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const
 {
     if( (unsigned) aItemIdx < arrayDim( m_LayersColors ) )
diff --git a/common/dialogs/dialog_color_picker.cpp b/common/dialogs/dialog_color_picker.cpp
index dfabbfac0..b331e6ea0 100644
--- a/common/dialogs/dialog_color_picker.cpp
+++ b/common/dialogs/dialog_color_picker.cpp
@@ -24,7 +24,8 @@
 #define ALPHA_MAX 100   // the max value returned by the alpha (opacity) slider
 
 DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, KIGFX::COLOR4D& aCurrentColor,
-                                          bool aAllowOpacityControl, CUSTOM_COLORS_LIST* aUserColors )
+                                          bool aAllowOpacityControl, CUSTOM_COLORS_LIST* aUserColors,
+                                          const KIGFX::COLOR4D& aDefaultColor )
 	: DIALOG_COLOR_PICKER_BASE( aParent )
 {
     m_allowMouseEvents = false;
@@ -36,6 +37,7 @@ DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, KIGFX::COLOR4D& aCu
     m_bitmapRGB = nullptr;
     m_bitmapHSV = nullptr;
     m_selectedCursor = nullptr;
+    m_defaultColor = aDefaultColor;
 
     if( !m_allowOpacityCtrl )
     {
@@ -50,6 +52,10 @@ DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, KIGFX::COLOR4D& aCu
     // Build the defined colors panel:
     initDefinedColors( aUserColors );
 
+    // If there is no default color, don't give the option to reset to default
+    if( aDefaultColor == KIGFX::COLOR4D::UNSPECIFIED )
+        m_resetToDefault->Hide();
+
     m_sdbSizerOK->SetDefault();
 }
 
@@ -794,3 +800,16 @@ void DIALOG_COLOR_PICKER::OnChangeBrightness( wxScrollEvent& event )
 
     drawAll();
 }
+
+
+void DIALOG_COLOR_PICKER::OnResetButton( wxCommandEvent& aEvent )
+{
+    m_newColor4D.r = m_defaultColor.r;
+    m_newColor4D.g = m_defaultColor.g;
+    m_newColor4D.b = m_defaultColor.b;
+
+    m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
+    SetEditVals( ALL_CHANGED );
+
+    drawAll();
+}
diff --git a/common/dialogs/dialog_color_picker.h b/common/dialogs/dialog_color_picker.h
index 776e4a75f..a647adb0e 100644
--- a/common/dialogs/dialog_color_picker.h
+++ b/common/dialogs/dialog_color_picker.h
@@ -76,7 +76,8 @@ public:
      * @param aUserColors: if not null is a list of defined colors replacing the dialog predefined colors
      */
 	DIALOG_COLOR_PICKER( wxWindow* aParent, KIGFX::COLOR4D& aCurrentColor,
-                         bool aAllowOpacityControl, CUSTOM_COLORS_LIST* aUserColors = nullptr );
+                         bool aAllowOpacityControl, CUSTOM_COLORS_LIST* aUserColors = nullptr,
+                         const KIGFX::COLOR4D& aDefaultColor = KIGFX::COLOR4D::UNSPECIFIED );
 	~DIALOG_COLOR_PICKER();
 
 	KIGFX::COLOR4D GetColor() { return m_newColor4D; };
@@ -95,6 +96,8 @@ private:
                                         ///< false to keep alpha channel = 1.0
     KIGFX::COLOR4D m_previousColor4D;   ///< the inital color4d
     KIGFX::COLOR4D m_newColor4D;        ///< the current color4d
+    KIGFX::COLOR4D m_defaultColor;      ///< The default color4d
+
     /// the list of color4d ordered by button ID, for predefined colors
     std::vector<KIGFX::COLOR4D> m_Color4DList;
     int m_cursorsSize;
@@ -145,6 +148,9 @@ private:
 	void onHSVMouseClick( wxMouseEvent& event ) override;
 	void onHSVMouseDrag( wxMouseEvent& event ) override;
 
+    ///< Event handler for the reset button press
+    void OnResetButton( wxCommandEvent& aEvent ) override;
+
     /** manage the Hue and Saturation settings when the mouse cursor
      * is at aMouseCursor.
      * @param aMouseCursor is the mouse cursor position on the HSV bitmap
diff --git a/common/dialogs/dialog_color_picker_base.cpp b/common/dialogs/dialog_color_picker_base.cpp
index 38cb085c0..7f9a31dd9 100644
--- a/common/dialogs/dialog_color_picker_base.cpp
+++ b/common/dialogs/dialog_color_picker_base.cpp
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Mar 28 2019)
+// C++ code generated with wxFormBuilder (version Aug 21 2019)
 // http://www.wxformbuilder.org/
 //
 // PLEASE DO *NOT* EDIT THIS FILE!
@@ -206,6 +206,9 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
 
 	bButtonsSizer->Add( m_NewColorRect, 0, wxALIGN_CENTER_VERTICAL, 5 );
 
+	m_resetToDefault = new wxButton( this, wxID_ANY, _("Reset to Default"), wxDefaultPosition, wxDefaultSize, 0 );
+	bButtonsSizer->Add( m_resetToDefault, 0, wxALL, 5 );
+
 	m_sdbSizer = new wxStdDialogButtonSizer();
 	m_sdbSizerOK = new wxButton( this, wxID_OK );
 	m_sdbSizer->AddButton( m_sdbSizerOK );
@@ -253,6 +256,7 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
 	m_sliderTransparency->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeAlpha ), NULL, this );
 	m_sliderTransparency->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeAlpha ), NULL, this );
 	m_sliderTransparency->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeAlpha ), NULL, this );
+	m_resetToDefault->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COLOR_PICKER_BASE::OnResetButton ), NULL, this );
 }
 
 DIALOG_COLOR_PICKER_BASE::~DIALOG_COLOR_PICKER_BASE()
@@ -285,5 +289,6 @@ DIALOG_COLOR_PICKER_BASE::~DIALOG_COLOR_PICKER_BASE()
 	m_sliderTransparency->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeAlpha ), NULL, this );
 	m_sliderTransparency->Disconnect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeAlpha ), NULL, this );
 	m_sliderTransparency->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeAlpha ), NULL, this );
+	m_resetToDefault->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COLOR_PICKER_BASE::OnResetButton ), NULL, this );
 
 }
diff --git a/common/dialogs/dialog_color_picker_base.fbp b/common/dialogs/dialog_color_picker_base.fbp
index d52726bff..7082a4e56 100644
--- a/common/dialogs/dialog_color_picker_base.fbp
+++ b/common/dialogs/dialog_color_picker_base.fbp
@@ -1640,6 +1640,79 @@
                                 <property name="window_style"></property>
                             </object>
                         </object>
+                        <object class="sizeritem" expanded="1">
+                            <property name="border">5</property>
+                            <property name="flag">wxALL</property>
+                            <property name="proportion">0</property>
+                            <object class="wxButton" expanded="1">
+                                <property name="BottomDockable">1</property>
+                                <property name="LeftDockable">1</property>
+                                <property name="RightDockable">1</property>
+                                <property name="TopDockable">1</property>
+                                <property name="aui_layer"></property>
+                                <property name="aui_name"></property>
+                                <property name="aui_position"></property>
+                                <property name="aui_row"></property>
+                                <property name="best_size"></property>
+                                <property name="bg"></property>
+                                <property name="bitmap"></property>
+                                <property name="caption"></property>
+                                <property name="caption_visible">1</property>
+                                <property name="center_pane">0</property>
+                                <property name="close_button">1</property>
+                                <property name="context_help"></property>
+                                <property name="context_menu">1</property>
+                                <property name="current"></property>
+                                <property name="default">0</property>
+                                <property name="default_pane">0</property>
+                                <property name="disabled"></property>
+                                <property name="dock">Dock</property>
+                                <property name="dock_fixed">0</property>
+                                <property name="docking">Left</property>
+                                <property name="enabled">1</property>
+                                <property name="fg"></property>
+                                <property name="floatable">1</property>
+                                <property name="focus"></property>
+                                <property name="font"></property>
+                                <property name="gripper">0</property>
+                                <property name="hidden">0</property>
+                                <property name="id">wxID_ANY</property>
+                                <property name="label">Reset to Default</property>
+                                <property name="margins"></property>
+                                <property name="markup">0</property>
+                                <property name="max_size"></property>
+                                <property name="maximize_button">0</property>
+                                <property name="maximum_size"></property>
+                                <property name="min_size"></property>
+                                <property name="minimize_button">0</property>
+                                <property name="minimum_size"></property>
+                                <property name="moveable">1</property>
+                                <property name="name">m_resetToDefault</property>
+                                <property name="pane_border">1</property>
+                                <property name="pane_position"></property>
+                                <property name="pane_size"></property>
+                                <property name="permission">protected</property>
+                                <property name="pin_button">1</property>
+                                <property name="pos"></property>
+                                <property name="position"></property>
+                                <property name="pressed"></property>
+                                <property name="resize">Resizable</property>
+                                <property name="show">1</property>
+                                <property name="size"></property>
+                                <property name="style"></property>
+                                <property name="subclass">; ; forward_declare</property>
+                                <property name="toolbar_pane">0</property>
+                                <property name="tooltip"></property>
+                                <property name="validator_data_type"></property>
+                                <property name="validator_style">wxFILTER_NONE</property>
+                                <property name="validator_type">wxDefaultValidator</property>
+                                <property name="validator_variable"></property>
+                                <property name="window_extra_style"></property>
+                                <property name="window_name"></property>
+                                <property name="window_style"></property>
+                                <event name="OnButtonClick">OnResetButton</event>
+                            </object>
+                        </object>
                         <object class="sizeritem" expanded="1">
                             <property name="border">5</property>
                             <property name="flag">wxALL</property>
diff --git a/common/dialogs/dialog_color_picker_base.h b/common/dialogs/dialog_color_picker_base.h
index 2ed44d9fc..eb5faad19 100644
--- a/common/dialogs/dialog_color_picker_base.h
+++ b/common/dialogs/dialog_color_picker_base.h
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Mar 28 2019)
+// C++ code generated with wxFormBuilder (version Aug 21 2019)
 // http://www.wxformbuilder.org/
 //
 // PLEASE DO *NOT* EDIT THIS FILE!
@@ -68,6 +68,7 @@ class DIALOG_COLOR_PICKER_BASE : public DIALOG_SHIM
 		wxStaticText* m_staticTextOldColor;
 		wxStaticBitmap* m_OldColorRect;
 		wxStaticBitmap* m_NewColorRect;
+		wxButton* m_resetToDefault;
 		wxStdDialogButtonSizer* m_sdbSizer;
 		wxButton* m_sdbSizerOK;
 		wxButton* m_sdbSizerCancel;
@@ -84,6 +85,7 @@ class DIALOG_COLOR_PICKER_BASE : public DIALOG_SHIM
 		virtual void OnChangeEditSat( wxSpinEvent& event ) { event.Skip(); }
 		virtual void OnChangeBrightness( wxScrollEvent& event ) { event.Skip(); }
 		virtual void OnChangeAlpha( wxScrollEvent& event ) { event.Skip(); }
+		virtual void OnResetButton( wxCommandEvent& event ) { event.Skip(); }
 
 
 	public:
diff --git a/common/widgets/color_swatch.cpp b/common/widgets/color_swatch.cpp
index 4d719a697..72a2829e9 100644
--- a/common/widgets/color_swatch.cpp
+++ b/common/widgets/color_swatch.cpp
@@ -79,10 +79,12 @@ static std::unique_ptr<wxStaticBitmap> makeColorSwatch( wxWindow* aParent, COLOR
 }
 
 
-COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, COLOR4D aColor, int aID, COLOR4D aBackground ):
+COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, COLOR4D aColor, int aID, COLOR4D aBackground,
+        const COLOR4D aDefault ) :
         wxPanel( aParent, aID ),
         m_color( aColor ),
-        m_background( aBackground )
+        m_background( aBackground ),
+        m_default( aDefault )
 {
     auto sizer = new wxBoxSizer( wxHORIZONTAL );
     SetSizer( sizer );
@@ -157,7 +159,7 @@ void COLOR_SWATCH::GetNewSwatchColor()
 {
     COLOR4D newColor = COLOR4D::UNSPECIFIED;
 
-    DIALOG_COLOR_PICKER dialog( ::wxGetTopLevelParent( this ), m_color, true );
+    DIALOG_COLOR_PICKER dialog( ::wxGetTopLevelParent( this ), m_color, true, nullptr, m_default );
 
     if( dialog.ShowModal() == wxID_OK )
         newColor = dialog.GetColor();
diff --git a/include/colors_design_settings.h b/include/colors_design_settings.h
index 079eacea0..6396bfba3 100644
--- a/include/colors_design_settings.h
+++ b/include/colors_design_settings.h
@@ -59,29 +59,46 @@ public:
 
     virtual void Load( wxConfigBase *aConfig ) override;
     virtual void Save( wxConfigBase *aConfig ) override;
+
+    /**
+     * Function GetDefaultLayerColor
+     * @return the default color for aLayer which is one of the item indices given in
+     * enum PCB_LAYER_ID
+     */
+    static COLOR4D GetDefaultLayerColor( LAYER_NUM aLayer );
+
     /**
      * Function GetLayerColor
-     * @return the color for aLayer which
+     * @return the color for aLayer which is one of the item indices given in
+     * enum PCB_LAYER_ID
      */
     COLOR4D GetLayerColor( LAYER_NUM aLayer ) const;
 
     /**
      * Function SetLayerColor
-     * sets the color for aLayer
+     * sets the color for aLayer which is one of the item indices given in
+     * enum PCB_LAYER_ID
      */
     void SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor );
 
+    /**
+     * Function GetDefaultItemColor
+     * @return the default color for the an item which is one of the item
+     * indices given in enum GAL_LAYER_ID
+     */
+    static COLOR4D GetDefaultItemColor( int aItemIdx );
+
     /**
      * Function GetItemColor
      * @return the color for an item which is one of the item indices given
-     * in enum PCB_LAYER_ID
+     * in enum GAL_LAYER_ID
      */
     COLOR4D GetItemColor( int aItemIdx ) const;
 
     /**
      * Function SetItemColor
      * sets the color for an item which is one of the item indices given
-     * in enum PCB_LAYER_ID
+     * in enum GAL_LAYER_ID
      */
     void SetItemColor( int aItemIdx, COLOR4D aColor );
 
diff --git a/include/widgets/color_swatch.h b/include/widgets/color_swatch.h
index b356d642b..f95d2f75c 100644
--- a/include/widgets/color_swatch.h
+++ b/include/widgets/color_swatch.h
@@ -46,7 +46,8 @@ public:
      * @param aColor initial swatch color
      * @param aID id to use when sending swatch events
      */
-    COLOR_SWATCH( wxWindow* aParent, KIGFX::COLOR4D aColor, int aID, KIGFX::COLOR4D aBackground );
+    COLOR_SWATCH( wxWindow* aParent, KIGFX::COLOR4D aColor, int aID, KIGFX::COLOR4D aBackground,
+            const KIGFX::COLOR4D aDefault = KIGFX::COLOR4D::UNSPECIFIED );
 
     /**
      * Set the current swatch color directly.
@@ -85,6 +86,9 @@ private:
     ///> The background colour to show the swatch over
     KIGFX::COLOR4D m_background;
 
+    ///> The default color for the swatch
+    KIGFX::COLOR4D m_default;
+
     ///> Handle of the actual swatch shown
     wxStaticBitmap* m_swatch;
 };
diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp
index d9eae839c..9cc50e66d 100644
--- a/pcbnew/layer_widget.cpp
+++ b/pcbnew/layer_widget.cpp
@@ -328,7 +328,7 @@ void LAYER_WIDGET::insertLayerRow( int aRow, const ROW& aSpec )
     col = COLUMN_COLORBM;
 
     auto bmb = new COLOR_SWATCH( m_LayerScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
-                                 getBackgroundLayerColor() );
+                                 getBackgroundLayerColor(), aSpec.defaultColor );
     bmb->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
     bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnLayerSwatchChanged, this );
     bmb->SetToolTip( _("Left double click or middle click for color change, right click for menu" ) );
@@ -403,7 +403,7 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
     if( aSpec.color != COLOR4D::UNSPECIFIED )
     {
         auto bmb = new COLOR_SWATCH( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
-                                     getBackgroundLayerColor() );
+                                     getBackgroundLayerColor(), aSpec.defaultColor );
         bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnRenderSwatchChanged, this );
         bmb->SetToolTip( _( "Left double click or middle click for color change" ) );
         m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
diff --git a/pcbnew/layer_widget.h b/pcbnew/layer_widget.h
index 9d50797b7..8b650e191 100644
--- a/pcbnew/layer_widget.h
+++ b/pcbnew/layer_widget.h
@@ -93,9 +93,11 @@ public:
         wxString    tooltip;    ///< if not empty, use this tooltip on row
         bool        changeable; ///< if true, the state can be changed
         bool        spacer;     ///< if true, this row is a spacer
+        COLOR4D     defaultColor; ///< The default color for the row
 
         ROW( const wxString& aRowName, int aId, COLOR4D aColor = COLOR4D::UNSPECIFIED,
-            const wxString& aTooltip = wxEmptyString, bool aState = true, bool aChangeable = true )
+             const wxString& aTooltip = wxEmptyString, bool aState = true,
+             bool aChangeable = true, COLOR4D aDefaultColor = COLOR4D::UNSPECIFIED )
         {
             rowName = aRowName;
             id      = aId;
@@ -104,6 +106,7 @@ public:
             tooltip = aTooltip;
             changeable = aChangeable;
             spacer = false;
+            defaultColor = aDefaultColor;
         }
 
         ROW()
@@ -113,6 +116,7 @@ public:
             state = true;
             changeable = true;
             spacer = true;
+            defaultColor = COLOR4D::UNSPECIFIED;
         }
     };
 
diff --git a/pcbnew/pcb_layer_widget.cpp b/pcbnew/pcb_layer_widget.cpp
index 4dd17c90b..d33d1d267 100644
--- a/pcbnew/pcb_layer_widget.cpp
+++ b/pcbnew/pcb_layer_widget.cpp
@@ -404,6 +404,8 @@ void PCB_LAYER_WIDGET::ReFillRender()
                 // this window frame must have an established BOARD, i.e. after SetBoard()
                 renderRow.color = myframe->Settings().Colors().GetItemColor(
                         static_cast<GAL_LAYER_ID>( renderRow.id ) );
+                renderRow.defaultColor = myframe->Settings().Colors().GetDefaultItemColor(
+                        static_cast<GAL_LAYER_ID>( renderRow.id ) );
             }
 
             if( renderRow.id == LAYER_RATSNEST )
@@ -506,9 +508,9 @@ void PCB_LAYER_WIDGET::ReFill()
             break;
         }
 
-        AppendLayerRow( LAYER_WIDGET::ROW(
-            brd->GetLayerName( layer ), layer, myframe->Settings().Colors().GetLayerColor( layer ),
-            dsc, true ) );
+        AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer,
+                myframe->Settings().Colors().GetLayerColor( layer ), dsc, true, true,
+                myframe->Settings().Colors().GetDefaultLayerColor( layer ) ) );
 
         if( m_fp_editor_mode && LSET::ForbiddenFootprintLayers().test( layer ) )
         {
@@ -554,9 +556,10 @@ void PCB_LAYER_WIDGET::ReFill()
         if( !enabled[layer] )
             continue;
 
-        AppendLayerRow( LAYER_WIDGET::ROW(
-            brd->GetLayerName( layer ), layer,  myframe->Settings().Colors().GetLayerColor( layer ),
-            wxGetTranslation( non_cu_seq[i].tooltip ), true ) );
+        AppendLayerRow( LAYER_WIDGET::ROW( brd->GetLayerName( layer ), layer,
+                myframe->Settings().Colors().GetLayerColor( layer ),
+                wxGetTranslation( non_cu_seq[i].tooltip ), true, true,
+                myframe->Settings().Colors().GetDefaultLayerColor( layer ) ) );
 
         if( m_fp_editor_mode && LSET::ForbiddenFootprintLayers().test( layer ) )
         {
-- 
2.21.0


Follow ups

References