← Back to team overview

kicad-developers team mailing list archive

[PATCH] Change from EDA_COLOR_T to COLOR4D and arbitrary color support

 

Hi all,

Attached is a (rather large!) patch that changes the internal color
representation to COLOR4D across the codebase (except for places that
directly deal with wx, where wxColour is used).

This patch also enables arbitrary color selection for schematic and symbol
library editor, as well as pcbnew in the GAL canvas.  GerbView and pcbnew
legacy canvas still use the old color picker.  Colors will be coerced into
the legacy palette when switching from GAL to legacy, in a way that tries
to preserve the hue and value.

Colors are serialized to the settings in CSS format, because it supports
alpha and represents color components the same way COLOR4D does (as
floating-point values from 0 to 1)

Tested on Linux.  Can't test on Windows or Mac yet, sorry.
I realize this is a large changeset and might take a while to review, so
just ping me if it stops applying on master and I'll update it.

Best,
Jon
From 43e80713d1ab40f4b207405e27aace4b4ffe5254 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Fri, 10 Feb 2017 20:31:29 -0500
Subject: [PATCH] Change from EDA_COLOR_T to COLOR4D globally; arbitrary color
 support

eeschema now supports arbitrary colors for all object types, and
pcbnew does in GAL canvas.  When switching from GAL to legacy canvas,
pcbnew will convert colors to the nearest legacy color.
---
 3d-viewer/3d_canvas/cinfo3d_visu.cpp               |  23 +-
 3d-viewer/3d_canvas/cinfo3d_visu.h                 |   2 +-
 3d-viewer/3d_canvas/create_layer_items.cpp         |   2 +-
 3d-viewer/CMakeLists.txt                           |   7 +-
 bitmap2component/CMakeLists.txt                    |   1 +
 common/block_commande.cpp                          |   2 +-
 common/class_bitmap_base.cpp                       |   2 +-
 common/class_colors_design_settings.cpp            |  19 +-
 common/class_layer_box_selector.cpp                |   3 +-
 common/common.cpp                                  |   4 +-
 common/common_plotDXF_functions.cpp                |  23 +-
 common/common_plotGERBER_functions.cpp             |   2 +-
 common/common_plotPDF_functions.cpp                |   2 +-
 common/common_plotPS_functions.cpp                 |  17 +-
 common/common_plotSVG_functions.cpp                |   4 +-
 common/common_plot_functions.cpp                   |   2 +-
 common/config_params.cpp                           |  25 ++-
 common/draw_frame.cpp                              |  13 +-
 common/draw_panel.cpp                              |  24 +-
 common/drawtxt.cpp                                 |  22 +-
 common/eda_text.cpp                                |  10 +-
 common/gal/color4d.cpp                             | 246 ++++++++++++++++++++-
 common/gr_basic.cpp                                | 117 +++++-----
 common/msgpanel.cpp                                |  14 +-
 common/page_layout/class_worksheet_dataitem.cpp    |   8 +-
 common/page_layout/page_layout_graphic_items.cpp   |  22 +-
 common/page_layout/title_block_shapes.cpp          |   4 +-
 common/painter.cpp                                 |   9 -
 common/selcolor.cpp                                |  24 +-
 common/swig/kicad.i                                |   1 +
 common/worksheet.cpp                               |   4 +-
 common/worksheet_viewitem.cpp                      |   3 +-
 cvpcb/class_DisplayFootprintsFrame.cpp             |   4 +-
 cvpcb/class_DisplayFootprintsFrame.h               |   2 +-
 eeschema/CMakeLists.txt                            |   1 +
 eeschema/block_libedit.cpp                         |   4 +-
 eeschema/bus-wire-junction.cpp                     |   3 +-
 eeschema/class_libentry.cpp                        |   8 +-
 eeschema/class_libentry.h                          |   2 +-
 eeschema/class_sch_screen.h                        |   2 +-
 eeschema/dialogs/dialog_choose_component.cpp       |   6 +-
 eeschema/dialogs/dialog_lib_edit_pin.cpp           |   4 +-
 eeschema/dialogs/dialog_print_using_printer.cpp    |   4 +-
 eeschema/dialogs/dialog_rescue_each.cpp            |   6 +-
 eeschema/eeredraw.cpp                              |   2 +-
 eeschema/eeschema.cpp                              |  62 +++---
 eeschema/eeschema_config.cpp                       |   8 +-
 eeschema/general.h                                 |  12 +-
 eeschema/lib_arc.cpp                               |  10 +-
 eeschema/lib_arc.h                                 |   4 +-
 eeschema/lib_bezier.cpp                            |   8 +-
 eeschema/lib_bezier.h                              |   2 +-
 eeschema/lib_circle.cpp                            |   8 +-
 eeschema/lib_circle.h                              |   2 +-
 eeschema/lib_draw_item.cpp                         |   6 +-
 eeschema/lib_draw_item.h                           |  16 +-
 eeschema/lib_field.cpp                             |  17 +-
 eeschema/lib_field.h                               |   4 +-
 eeschema/lib_pin.cpp                               |  30 +--
 eeschema/lib_pin.h                                 |  10 +-
 eeschema/lib_polyline.cpp                          |   8 +-
 eeschema/lib_polyline.h                            |   2 +-
 eeschema/lib_rectangle.cpp                         |   8 +-
 eeschema/lib_rectangle.h                           |   2 +-
 eeschema/lib_text.cpp                              |  10 +-
 eeschema/lib_text.h                                |   2 +-
 eeschema/libedit.cpp                               |   2 +-
 eeschema/libeditframe.cpp                          |   8 +-
 eeschema/pinedit.cpp                               |   6 +-
 eeschema/protos.h                                  |   4 +-
 eeschema/sch_base_frame.cpp                        |   4 +-
 eeschema/sch_base_frame.h                          |   4 +-
 eeschema/sch_bitmap.cpp                            |   4 +-
 eeschema/sch_bitmap.h                              |   2 +-
 eeschema/sch_bus_entry.cpp                         |   6 +-
 eeschema/sch_bus_entry.h                           |   2 +-
 eeschema/sch_component.cpp                         |   2 +-
 eeschema/sch_component.h                           |   6 +-
 eeschema/sch_field.cpp                             |   8 +-
 eeschema/sch_field.h                               |   2 +-
 eeschema/sch_item_struct.h                         |   4 +-
 eeschema/sch_junction.cpp                          |   6 +-
 eeschema/sch_junction.h                            |   2 +-
 eeschema/sch_line.cpp                              |   6 +-
 eeschema/sch_line.h                                |   2 +-
 eeschema/sch_marker.cpp                            |   8 +-
 eeschema/sch_marker.h                              |   2 +-
 eeschema/sch_no_connect.cpp                        |   6 +-
 eeschema/sch_no_connect.h                          |   2 +-
 eeschema/sch_screen.cpp                            |   4 +-
 eeschema/sch_sheet.cpp                             |  14 +-
 eeschema/sch_sheet.h                               |   4 +-
 eeschema/sch_sheet_pin.cpp                         |   2 +-
 eeschema/sch_text.cpp                              |  30 +--
 eeschema/sch_text.h                                |   8 +-
 eeschema/schedit.cpp                               |   4 +-
 eeschema/sim/sim_plot_frame.cpp                    |   2 +-
 eeschema/symbdraw.cpp                              |   8 +-
 eeschema/viewlibs.cpp                              |   2 +-
 eeschema/widgets/widget_eeschema_color_config.cpp  |  83 +++----
 eeschema/widgets/widget_eeschema_color_config.h    |   4 +-
 gerbview/CMakeLists.txt                            |   1 +
 gerbview/block.cpp                                 |   2 +-
 gerbview/class_aperture_macro.cpp                  |   2 +-
 gerbview/class_aperture_macro.h                    |   2 +-
 gerbview/class_gbr_display_options.h               |  10 +-
 gerbview/class_gbr_layer_box_selector.cpp          |   2 +-
 gerbview/class_gbr_layer_box_selector.h            |   2 +-
 gerbview/class_gbr_layout.cpp                      |  12 +-
 gerbview/class_gbr_layout.h                        |   2 +-
 gerbview/class_gerber_draw_item.cpp                |  10 +-
 gerbview/class_gerber_draw_item.h                  |   2 +-
 gerbview/class_gerber_file_image.h                 |   4 +-
 gerbview/class_gerbview_layer_widget.cpp           |   6 +-
 gerbview/class_gerbview_layer_widget.h             |   4 +-
 gerbview/dcode.cpp                                 |   4 +-
 gerbview/dcode.h                                   |   5 +-
 gerbview/draw_gerber_screen.cpp                    |   2 +-
 gerbview/gerbview_config.cpp                       |  20 +-
 gerbview/gerbview_frame.cpp                        |  12 +-
 gerbview/gerbview_frame.h                          |  10 +-
 gerbview/printout_control.cpp                      |   2 +-
 include/base_struct.h                              |   2 +-
 include/basic_gal.h                                |   2 +-
 include/block_commande.h                           |   8 +-
 include/class_bitmap_base.h                        |   2 +-
 include/class_colors_design_settings.h             |  17 +-
 include/class_drawpanel.h                          |   3 +-
 include/class_layer_box_selector.h                 |   5 +-
 include/class_marker_base.h                        |   4 +-
 include/class_worksheet_dataitem.h                 |  42 ++--
 include/colors.h                                   |   9 +
 include/common.h                                   |   4 +-
 include/config_params.h                            |  16 +-
 include/draw_frame.h                               |  21 +-
 include/drawtxt.h                                  |  10 +-
 include/eda_text.h                                 |   8 +-
 include/gal/color4d.h                              |  80 ++++++-
 include/gr_basic.h                                 | 102 ++++-----
 include/msgpanel.h                                 |  19 +-
 include/painter.h                                  |  14 --
 include/plot_common.h                              |  28 +--
 include/worksheet.h                                |   6 +-
 include/worksheet_shape_builder.h                  |  34 +--
 include/wxPcbStruct.h                              |  10 +-
 include/wxstruct.h                                 |   1 -
 kicad/CMakeLists.txt                               |   1 +
 pagelayout_editor/CMakeLists.txt                   |   1 +
 pagelayout_editor/dialogs/dialogs_for_printing.cpp |   4 +-
 pagelayout_editor/pl_editor_frame.cpp              |   2 +-
 pcb_calculator/CMakeLists.txt                      |   1 +
 pcbnew/CMakeLists.txt                              |   1 +
 pcbnew/autorouter/auto_place_footprints.cpp        |  16 +-
 pcbnew/autorouter/autorout.cpp                     |  16 +-
 pcbnew/board_items_to_polygon_shape_transform.cpp  |   2 +-
 pcbnew/class_board.cpp                             |  10 +-
 pcbnew/class_board.h                               |   8 +-
 pcbnew/class_dimension.cpp                         |   2 +-
 pcbnew/class_drawsegment.cpp                       |   4 +-
 pcbnew/class_edge_mod.cpp                          |   4 +-
 pcbnew/class_mire.cpp                              |   2 +-
 pcbnew/class_netinfo_item.cpp                      |   2 +-
 pcbnew/class_pad.h                                 |   6 +-
 pcbnew/class_pad_draw_functions.cpp                |  23 +-
 pcbnew/class_pcb_layer_box_selector.cpp            |   2 +-
 pcbnew/class_pcb_layer_box_selector.h              |   2 +-
 pcbnew/class_pcb_layer_widget.cpp                  |  26 ++-
 pcbnew/class_pcb_layer_widget.h                    |   5 +-
 pcbnew/class_pcb_text.cpp                          |   6 +-
 pcbnew/class_text_mod.cpp                          |   6 +-
 pcbnew/class_track.cpp                             |  42 ++--
 pcbnew/class_track.h                               |   2 +-
 pcbnew/class_zone.cpp                              |  32 ++-
 pcbnew/dialogs/dialog_SVG_print.cpp                |   2 +-
 pcbnew/dialogs/dialog_copper_zones.cpp             |   8 +-
 pcbnew/dialogs/dialog_keepout_area_properties.cpp  |   8 +-
 .../dialogs/dialog_non_copper_zones_properties.cpp |   8 +-
 pcbnew/dialogs/dialog_pad_properties.cpp           |   4 +-
 pcbnew/editrack.cpp                                |   6 +-
 pcbnew/exporters/export_vrml.cpp                   |   2 +-
 pcbnew/exporters/gen_drill_report_files.cpp        |   4 +-
 pcbnew/layer_widget.cpp                            |  85 ++++---
 pcbnew/layer_widget.h                              |  25 ++-
 pcbnew/modedit.cpp                                 |   2 +-
 pcbnew/module_editor_frame.h                       |   2 +-
 pcbnew/modview_frame.cpp                           |   2 +-
 pcbnew/modview_frame.h                             |   2 +-
 pcbnew/pcb_painter.cpp                             |   4 +-
 pcbnew/pcb_plot_params.h                           |  18 +-
 pcbnew/pcbframe.cpp                                |  43 +++-
 pcbnew/pcbplot.h                                   |   6 +-
 pcbnew/plot_board_layers.cpp                       |  10 +-
 pcbnew/plot_brditems_plotter.cpp                   |  26 +--
 pcbnew/print_board_functions.cpp                   |   4 +-
 pcbnew/printout_controler.cpp                      |   2 +-
 pcbnew/ratsnest.cpp                                |   2 +-
 pcbnew/router/router_preview_item.cpp              |   1 -
 pcbnew/sel_layer.cpp                               |  22 +-
 pcbnew/swig/pcbnew.i                               |   4 +-
 pcbnew/swig/python_scripting.cpp                   |   2 +-
 pcbnew/tool_pcb.cpp                                |  14 +-
 201 files changed, 1326 insertions(+), 986 deletions(-)

diff --git a/3d-viewer/3d_canvas/cinfo3d_visu.cpp b/3d-viewer/3d_canvas/cinfo3d_visu.cpp
index 353546d..088f580 100644
--- a/3d-viewer/3d_canvas/cinfo3d_visu.cpp
+++ b/3d-viewer/3d_canvas/cinfo3d_visu.cpp
@@ -532,16 +532,9 @@ SFVEC3F CINFO3D_VISU::GetLayerColor( LAYER_ID aLayerId ) const
 {
     wxASSERT( aLayerId < LAYER_ID_COUNT );
 
-    const EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( aLayerId );
-    const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];
+    const COLOR4D color = g_ColorsSettings.GetLayerColor( aLayerId );
 
-    static const float inv_255 = 1.0f / 255.0f;
-
-    const float red     = colordata.m_Red   * inv_255;
-    const float green   = colordata.m_Green * inv_255;
-    const float blue    = colordata.m_Blue  * inv_255;
-
-    return SFVEC3F( red, green, blue );
+    return SFVEC3F( color.r, color.g, color.b );
 }
 
 
@@ -551,15 +544,7 @@ SFVEC3F CINFO3D_VISU::GetItemColor( int aItemId ) const
 }
 
 
-SFVEC3F CINFO3D_VISU::GetColor( EDA_COLOR_T aColor ) const
+SFVEC3F CINFO3D_VISU::GetColor( COLOR4D aColor ) const
 {
-    const StructColors &colordata = g_ColorRefs[ColorGetBase( aColor )];
-
-    static const float inv_255 = 1.0f / 255.0f;
-
-    const float red     = colordata.m_Red   * inv_255;
-    const float green   = colordata.m_Green * inv_255;
-    const float blue    = colordata.m_Blue  * inv_255;
-
-    return SFVEC3F( red, green, blue );
+    return SFVEC3F( aColor.r, aColor.g, aColor.b );
 }
diff --git a/3d-viewer/3d_canvas/cinfo3d_visu.h b/3d-viewer/3d_canvas/cinfo3d_visu.h
index b50cf3e..90db438 100644
--- a/3d-viewer/3d_canvas/cinfo3d_visu.h
+++ b/3d-viewer/3d_canvas/cinfo3d_visu.h
@@ -270,7 +270,7 @@ class CINFO3D_VISU
      * @param aColor: the color mapped
      * @return the color in SFVEC3F format
      */
-    SFVEC3F GetColor( EDA_COLOR_T aColor ) const;
+    SFVEC3F GetColor( COLOR4D aColor ) const;
 
     /**
      * @brief GetLayerTopZpos3DU - Get the top z position
diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp
index 34ab284..361e8f3 100644
--- a/3d-viewer/3d_canvas/create_layer_items.cpp
+++ b/3d-viewer/3d_canvas/create_layer_items.cpp
@@ -106,7 +106,7 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const TEXTE_PCB* aTextPCB,
     s_boardBBox3DU = &m_board2dBBox3DU;
 
     // not actually used, but needed by DrawGraphicText
-    const EDA_COLOR_T dummy_color = BLACK;
+    const COLOR4D dummy_color = COLOR4D_BLACK;
 
     if( aTextPCB->IsMultilineAllowed() )
     {
diff --git a/3d-viewer/CMakeLists.txt b/3d-viewer/CMakeLists.txt
index cf664c0..096c437 100644
--- a/3d-viewer/CMakeLists.txt
+++ b/3d-viewer/CMakeLists.txt
@@ -111,6 +111,11 @@ set(3D-VIEWER_SRCS
 add_library(3d-viewer STATIC ${3D-VIEWER_SRCS})
 add_dependencies( 3d-viewer pcbcommon )
 
-target_link_libraries( 3d-viewer ${Boost_} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} kicad_3dsg )
+target_link_libraries( 3d-viewer
+                       gal
+                       ${Boost_}
+                       ${wxWidgets_LIBRARIES}
+                       ${OPENGL_LIBRARIES}
+                       kicad_3dsg )
 
 add_subdirectory( 3d_cache )
diff --git a/bitmap2component/CMakeLists.txt b/bitmap2component/CMakeLists.txt
index b1d2720..76d3990 100644
--- a/bitmap2component/CMakeLists.txt
+++ b/bitmap2component/CMakeLists.txt
@@ -47,6 +47,7 @@ target_link_libraries( bitmap2component
     common
     polygon
     bitmaps
+    gal
     ${wxWidgets_LIBRARIES}
     potrace
     )
diff --git a/common/block_commande.cpp b/common/block_commande.cpp
index e313eb4..00a77af 100644
--- a/common/block_commande.cpp
+++ b/common/block_commande.cpp
@@ -122,7 +122,7 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
 
 
 void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                           GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+                           GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
     if( !aDC )
         return;
diff --git a/common/class_bitmap_base.cpp b/common/class_bitmap_base.cpp
index 5cf46b4..892a560 100644
--- a/common/class_bitmap_base.cpp
+++ b/common/class_bitmap_base.cpp
@@ -287,7 +287,7 @@ void BITMAP_BASE::Rotate( bool aRotateCCW )
 
 void BITMAP_BASE::PlotImage( PLOTTER*       aPlotter,
                              const wxPoint& aPos,
-                             EDA_COLOR_T    aDefaultColor,
+                             COLOR4D        aDefaultColor,
                              int            aDefaultPensize )
 {
     if( m_image == NULL )
diff --git a/common/class_colors_design_settings.cpp b/common/class_colors_design_settings.cpp
index dbdd6ac..8b72a32 100644
--- a/common/class_colors_design_settings.cpp
+++ b/common/class_colors_design_settings.cpp
@@ -27,7 +27,6 @@
  * @brief Handle colors used to draw all items or layers.
  */
 #include <fctsys.h>
-#include <colors.h>
 #include <macros.h>
 
 #include <class_colors_design_settings.h>
@@ -91,7 +90,7 @@ COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
 {
     for( unsigned src = 0, dst = 0; dst < DIM(m_LayersColors); ++dst )
     {
-        m_LayersColors[dst] = default_layer_color[src++];
+        m_LayersColors[dst] = COLOR4D( default_layer_color[src++] );
 
         if( src >= DIM( default_layer_color ) )
             src = 0;        // wrap the source.
@@ -99,7 +98,7 @@ COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
 
     for( unsigned src = 0, dst = 0; dst < DIM(m_ItemsColors);  ++dst )
     {
-        m_ItemsColors[dst] = default_items_color[src++];
+        m_ItemsColors[dst] = COLOR4D( default_items_color[src++] );
 
         if( src >= DIM( default_items_color ) )
             src = 0;
@@ -107,17 +106,17 @@ COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
 }
 
 
-EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const
+COLOR4D COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const
 {
     if( (unsigned) aLayer < DIM(m_LayersColors) )
     {
         return m_LayersColors[aLayer];
     }
-    return UNSPECIFIED_COLOR;
+    return UNSPECIFIED_COLOR4D;
 }
 
 
-void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
+void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor )
 {
     if( (unsigned) aLayer < DIM(m_LayersColors) )
     {
@@ -126,18 +125,18 @@ void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor
 }
 
 
-EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const
+COLOR4D COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const
 {
     if( (unsigned) aItemIdx < DIM( m_ItemsColors ) )
     {
         return m_ItemsColors[aItemIdx];
     }
 
-    return UNSPECIFIED_COLOR;
+    return UNSPECIFIED_COLOR4D;
 }
 
 
-void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, EDA_COLOR_T aColor )
+void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, COLOR4D aColor )
 {
     if( (unsigned) aItemIdx < DIM(m_ItemsColors) )
     {
@@ -146,7 +145,7 @@ void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, EDA_COLOR_T aColor )
 }
 
 
-void COLORS_DESIGN_SETTINGS::SetAllColorsAs( EDA_COLOR_T aColor )
+void COLORS_DESIGN_SETTINGS::SetAllColorsAs( COLOR4D aColor )
 {
     for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
         m_LayersColors[ii] = aColor;
diff --git a/common/class_layer_box_selector.cpp b/common/class_layer_box_selector.cpp
index ad2df99..3a8d4b7 100644
--- a/common/class_layer_box_selector.cpp
+++ b/common/class_layer_box_selector.cpp
@@ -26,7 +26,6 @@
 #include <colors_selection.h>
 #include <layers_id_colors_and_visibility.h>
 #include <bitmaps.h>
-#include <colors.h>
 
 #include <wx/wx.h>
 #include <wx/ownerdrw.h>
@@ -56,7 +55,7 @@ void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
 
     // Prepare Bitmap
     bmpDC.SelectObject( aLayerbmp );
-    brush.SetColour( MakeColour( GetLayerColor( aLayer ) ) );
+    brush.SetColour( GetLayerColor( aLayer ).ToColour() );
     brush.SetStyle( wxBRUSHSTYLE_SOLID );
 
     bmpDC.SetBrush( brush );
diff --git a/common/common.cpp b/common/common.cpp
index 976e419..7e5f90f 100644
--- a/common/common.cpp
+++ b/common/common.cpp
@@ -42,6 +42,8 @@
 
 #include <pgm_base.h>
 
+using KIGFX::COLOR4D;
+
 
 /**
  * Global variables definitions.
@@ -53,7 +55,7 @@
 
 bool           g_ShowPageLimits = true;
 EDA_UNITS_T    g_UserUnit;
-EDA_COLOR_T    g_GhostColor;
+COLOR4D        g_GhostColor;
 
 
 /* Class LOCALE_IO
diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp
index 84917a8..62b6e20 100644
--- a/common/common_plotDXF_functions.cpp
+++ b/common/common_plotDXF_functions.cpp
@@ -25,6 +25,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
 
+
 #include <fctsys.h>
 #include <gr_basic.h>
 #include <trigo.h>
@@ -68,7 +69,7 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
 
     SetDefaultLineWidth( 0 );               // No line width on DXF
     m_plotMirror = false;                     // No mirroring on DXF
-    m_currentColor = BLACK;
+    m_currentColor = COLOR4D_BLACK;
 }
 
 /**
@@ -275,17 +276,17 @@ bool DXF_PLOTTER::EndPlot()
 /**
  * The DXF exporter handles 'colors' as layers...
  */
-void DXF_PLOTTER::SetColor( EDA_COLOR_T color )
+void DXF_PLOTTER::SetColor( COLOR4D color )
 {
     wxASSERT( outputFile );
-    if( ( color >= 0 && colorMode )
-       || ( color == BLACK )
-       || ( color == WHITE ) )
+    if( ( colorMode )
+       || ( color == COLOR4D_BLACK )
+       || ( color == COLOR4D_WHITE ) )
     {
         m_currentColor = color;
     }
     else
-        m_currentColor = BLACK;
+        m_currentColor = COLOR4D_BLACK;
 }
 
 /**
@@ -315,7 +316,7 @@ void DXF_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_T fill, int
     DPOINT centre_dev = userToDeviceCoordinates( centre );
     if( radius > 0 )
     {
-        wxString cname( ColorGetName( m_currentColor ) );
+        wxString cname( m_currentColor.ToColour().GetAsString(wxC2S_CSS_SYNTAX) );
         if (!fill)
         {
             fprintf( outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n",
@@ -462,7 +463,7 @@ void DXF_PLOTTER::PenTo( const wxPoint& pos, char plume )
     if( penLastpos != pos && plume == 'D' )
     {
         // DXF LINE
-        wxString cname( ColorGetName( m_currentColor ) );
+        wxString cname( m_currentColor.ToColour().GetAsString(wxC2S_CSS_SYNTAX) );
         fprintf( outputFile, "0\nLINE\n8\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n",
                  TO_UTF8( cname ),
                  pen_lastpos_dev.x, pen_lastpos_dev.y, pos_dev.x, pos_dev.y );
@@ -509,7 +510,7 @@ void DXF_PLOTTER::Arc( const wxPoint& centre, double StAngle, double EndAngle, i
     double radius_dev = userToDeviceSize( radius );
 
     // Emit a DXF ARC entity
-    wxString cname( ColorGetName( m_currentColor ) );
+    wxString cname( m_currentColor.ToColour().GetAsString(wxC2S_CSS_SYNTAX) );
     fprintf( outputFile,
              "0\nARC\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n50\n%g\n51\n%g\n",
              TO_UTF8( cname ),
@@ -699,7 +700,7 @@ bool containsNonAsciiChars( const wxString& string )
 }
 
 void DXF_PLOTTER::Text( const wxPoint&              aPos,
-                        enum EDA_COLOR_T            aColor,
+                        COLOR4D                     aColor,
                         const wxString&             aText,
                         double                      aOrient,
                         const wxSize&               aSize,
@@ -729,7 +730,7 @@ void DXF_PLOTTER::Text( const wxPoint&              aPos,
            more useful as a CAD object */
         DPOINT origin_dev = userToDeviceCoordinates( aPos );
         SetColor( aColor );
-        wxString cname( ColorGetName( m_currentColor ) );
+        wxString cname( m_currentColor.ToColour().GetAsString(wxC2S_CSS_SYNTAX) );
         DPOINT size_dev = userToDeviceSize( aSize );
         int h_code = 0, v_code = 0;
         switch( aH_justify )
diff --git a/common/common_plotGERBER_functions.cpp b/common/common_plotGERBER_functions.cpp
index ecdb57e..22ab552 100644
--- a/common/common_plotGERBER_functions.cpp
+++ b/common/common_plotGERBER_functions.cpp
@@ -938,7 +938,7 @@ void GERBER_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos,  const wxPoint* aCo
 }
 
 
-void GERBER_PLOTTER::Text( const wxPoint& aPos, enum EDA_COLOR_T aColor,
+void GERBER_PLOTTER::Text( const wxPoint& aPos, const COLOR4D aColor,
                            const wxString& aText, double aOrient, const wxSize& aSize,
                            enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify,
                            int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed,
diff --git a/common/common_plotPDF_functions.cpp b/common/common_plotPDF_functions.cpp
index 2a7d7e6..4dd20bb 100644
--- a/common/common_plotPDF_functions.cpp
+++ b/common/common_plotPDF_functions.cpp
@@ -755,7 +755,7 @@ bool PDF_PLOTTER::EndPlot()
 }
 
 void PDF_PLOTTER::Text( const wxPoint&              aPos,
-                        enum EDA_COLOR_T            aColor,
+                        const COLOR4D               aColor,
                         const wxString&             aText,
                         double                      aOrient,
                         const wxSize&               aSize,
diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp
index 4a24551..316b195 100644
--- a/common/common_plotPS_functions.cpp
+++ b/common/common_plotPS_functions.cpp
@@ -56,21 +56,14 @@ void PSLIKE_PLOTTER::SetDefaultLineWidth( int width )
 }
 
 
-void PSLIKE_PLOTTER::SetColor( EDA_COLOR_T color )
+void PSLIKE_PLOTTER::SetColor( COLOR4D color )
 {
-    // Return at invalid color index
-    if( color < 0 )
-        return;
-
     if( colorMode )
     {
-        double r = g_ColorRefs[color].m_Red / 255.0;
-        double g = g_ColorRefs[color].m_Green / 255.0;
-        double b = g_ColorRefs[color].m_Blue / 255.0;
         if( negativeMode )
-            emitSetRGBColor( 1 - r, 1 - g, 1 - b );
+            emitSetRGBColor( 1 - color.r, 1 - color.g, 1 - color.b );
         else
-            emitSetRGBColor( r, g, b );
+            emitSetRGBColor( color.r, color.g, color.b );
     }
     else
     {
@@ -79,7 +72,7 @@ void PSLIKE_PLOTTER::SetColor( EDA_COLOR_T color )
          * holes in white on pads in black
          */
         double k = 1; // White
-        if( color != WHITE )
+        if( color != COLOR4D_WHITE )
             k = 0;
         if( negativeMode )
             emitSetRGBColor( 1 - k, 1 - k, 1 - k );
@@ -927,7 +920,7 @@ bool PS_PLOTTER::EndPlot()
 
 
 void PS_PLOTTER::Text( const wxPoint&       aPos,
-                enum EDA_COLOR_T            aColor,
+                const COLOR4D               aColor,
                 const wxString&             aText,
                 double                      aOrient,
                 const wxSize&               aSize,
diff --git a/common/common_plotSVG_functions.cpp b/common/common_plotSVG_functions.cpp
index 5c0973b..4a0820a 100644
--- a/common/common_plotSVG_functions.cpp
+++ b/common/common_plotSVG_functions.cpp
@@ -187,7 +187,7 @@ void SVG_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
 }
 
 
-void SVG_PLOTTER::SetColor( EDA_COLOR_T color )
+void SVG_PLOTTER::SetColor( COLOR4D color )
 {
     PSLIKE_PLOTTER::SetColor( color );
 
@@ -602,7 +602,7 @@ bool SVG_PLOTTER::EndPlot()
 
 
 void SVG_PLOTTER::Text( const wxPoint&              aPos,
-                        enum EDA_COLOR_T            aColor,
+                        const COLOR4D               aColor,
                         const wxString&             aText,
                         double                      aOrient,
                         const wxSize&               aSize,
diff --git a/common/common_plot_functions.cpp b/common/common_plot_functions.cpp
index 8154796..2a171bd 100644
--- a/common/common_plot_functions.cpp
+++ b/common/common_plot_functions.cpp
@@ -79,7 +79,7 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
      */
     double   iusPerMil = plotter->GetIUsPerDecimil() * 10.0;
 
-    EDA_COLOR_T plotColor = plotter->GetColorMode() ? RED : BLACK;
+    COLOR4D plotColor = plotter->GetColorMode() ? COLOR4D( RED ) : COLOR4D_BLACK;
     plotter->SetColor( plotColor );
     WS_DRAW_ITEM_LIST drawList;
 
diff --git a/common/config_params.cpp b/common/config_params.cpp
index 9737e8e..52cf3aa 100644
--- a/common/config_params.cpp
+++ b/common/config_params.cpp
@@ -243,8 +243,8 @@ void PARAM_CFG_INT_WITH_SCALE::SaveParam( wxConfigBase* aConfig ) const
 }
 
 
-PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, EDA_COLOR_T* ptparam,
-                                        EDA_COLOR_T default_val,
+PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, COLOR4D* ptparam,
+                                        COLOR4D default_val,
                                         const wxChar* group ) :
     PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
 {
@@ -255,8 +255,8 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxString& ident, EDA_COLOR_T* ptpa
 
 PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool          Insetup,
                                         const wxString& ident,
-                                        EDA_COLOR_T*  ptparam,
-                                        EDA_COLOR_T   default_val,
+                                        COLOR4D*      ptparam,
+                                        COLOR4D       default_val,
                                         const wxChar* group ) :
     PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
 {
@@ -271,11 +271,22 @@ void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const
     if( !m_Pt_param || !aConfig )
         return;
 
+    // First try reading old format
     EDA_COLOR_T itmp = ColorByName( aConfig->Read( m_Ident, wxT("NONE") ) );
+    COLOR4D wtmp = UNSPECIFIED_COLOR4D;
 
     if( itmp == UNSPECIFIED_COLOR )
-        itmp = m_Default;
-    *m_Pt_param = itmp;
+    {
+        // Next try reading new format
+        if( !wtmp.SetFromWxString( aConfig->Read( m_Ident, wxT("NONE") ) ) )
+            wtmp = m_Default;
+    }
+    else
+    {
+        wtmp = COLOR4D( itmp );
+    }
+
+    *m_Pt_param = wtmp;
 }
 
 
@@ -284,7 +295,7 @@ void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) const
     if( !m_Pt_param || !aConfig )
         return;
 
-    aConfig->Write( m_Ident, ColorGetName( *m_Pt_param ) );
+    aConfig->Write( m_Ident, m_Pt_param->ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
 }
 
 
diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp
index b55f47b..45a32c3 100644
--- a/common/draw_frame.cpp
+++ b/common/draw_frame.cpp
@@ -153,10 +153,10 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
     m_cursorShape         = 0;
     m_LastGridSizeId      = 0;
     m_drawGrid            = true;       // hide/Show grid. default = show
-    m_gridColor           = DARKGRAY;   // Default grid color
+    m_gridColor           = COLOR4D( DARKGRAY );   // Default grid color
     m_showPageLimits      = false;
-    m_drawBgColor         = BLACK;      // the background color of the draw canvas:
-                                        // BLACK for Pcbnew, BLACK or WHITE for eeschema
+    m_drawBgColor         = COLOR4D( BLACK );   // the background color of the draw canvas:
+                                                // BLACK for Pcbnew, BLACK or WHITE for eeschema
     m_snapToGrid          = true;
     m_MsgFrameHeight      = EDA_MSG_PANEL::GetRequiredHeight();
     m_movingCursorWithKeyboard = false;
@@ -206,7 +206,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
     m_messagePanel  = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ),
                                          wxSize( m_FrameSize.x, m_MsgFrameHeight ) );
 
-    m_messagePanel->SetBackgroundColour( MakeColour( LIGHTGRAY ) );
+    m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
 }
 
 
@@ -723,7 +723,8 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
 
     aCfg->Write( baseCfgName + CursorShapeEntryKeyword, m_cursorShape );
     aCfg->Write( baseCfgName + ShowGridEntryKeyword, IsGridVisible() );
-    aCfg->Write( baseCfgName + GridColorEntryKeyword, ( long ) GetGridColor() );
+    aCfg->Write( baseCfgName + GridColorEntryKeyword,
+                 GetGridColor().ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
     aCfg->Write( baseCfgName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
 
     if( GetScreen() )
@@ -735,7 +736,7 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
 
 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
                                      const wxString& textLower,
-                                     EDA_COLOR_T color, int pad )
+                                     COLOR4D color, int pad )
 {
     if( m_messagePanel == NULL )
         return;
diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp
index d324464..4d91fa4 100644
--- a/common/draw_panel.cpp
+++ b/common/draw_panel.cpp
@@ -109,7 +109,7 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id,
 
     SetLayoutDirection( wxLayout_LeftToRight );
 
-    SetBackgroundColour( MakeColour( parent->GetDrawBgColor() ) );
+    SetBackgroundColour( parent->GetDrawBgColor().ToColour() );
 
 #if KICAD_USE_BUFFERED_DC || KICAD_USE_BUFFERED_PAINTDC
     SetBackgroundStyle( wxBG_STYLE_CUSTOM );
@@ -212,7 +212,7 @@ wxPoint EDA_DRAW_PANEL::ToLogicalXY( const wxPoint& pos )
 }
 
 
-void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor )
+void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, COLOR4D aColor )
 {
     if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair )
         return;
@@ -554,7 +554,7 @@ void EDA_DRAW_PANEL::EraseScreen( wxDC* DC )
 {
     GRSetDrawMode( DC, GR_COPY );
 
-    EDA_COLOR_T bgColor = GetParent()->GetDrawBgColor();
+    COLOR4D bgColor = GetParent()->GetDrawBgColor();
 
     GRSFilledRect( NULL, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
                    m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
@@ -611,12 +611,10 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
     if( Screen == NULL )
         return;
 
-    EDA_COLOR_T bgColor = GetParent()->GetDrawBgColor();
+    COLOR4D bgColor = GetParent()->GetDrawBgColor();
 
-    if( ( bgColor != WHITE ) && ( bgColor != BLACK ) )
-        bgColor = BLACK;
-
-    if( bgColor == WHITE )
+    // TODO(JE): Is this correct?
+    if( bgColor.GetBrightness() > 0.5 )
     {
         g_XorMode    = GR_NXOR;
         g_GhostColor = BLACK;
@@ -629,7 +627,7 @@ void EDA_DRAW_PANEL::ReDraw( wxDC* DC, bool erasebg )
 
     GRResetPenAndBrush( DC );
 
-    DC->SetBackground( bgColor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
+    DC->SetBackground( wxBrush( bgColor.ToColour() ) );
     DC->SetBackgroundMode( wxSOLID );
 
     if( erasebg )
@@ -666,7 +664,7 @@ void EDA_DRAW_PANEL::SetEnableZoomNoCenter( bool aEnable )
 
 void EDA_DRAW_PANEL::DrawBackGround( wxDC* DC )
 {
-    EDA_COLOR_T axis_color = BLUE;
+    COLOR4D axis_color = COLOR4D( BLUE );
 
     GRSetDrawMode( DC, GR_COPY );
 
@@ -756,7 +754,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC )
         const double h = aDC->DeviceToLogicalYRel( gsz );
 
         // Use our own pen
-        wxPen pen( MakeColour( GetParent()->GetGridColor() ), h );
+        wxPen pen( GetParent()->GetGridColor(), h );
         pen.SetCap( wxCAP_BUTT );
         gc->SetPen( pen );
 
@@ -801,7 +799,7 @@ void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode )
     if( origin == wxPoint( 0, 0 ) )
         return;
 
-    EDA_COLOR_T color = RED;
+    COLOR4D color = COLOR4D( RED );
 
     GRSetDrawMode( aDC, aDrawMode );
 
@@ -837,7 +835,7 @@ void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoi
     if( !GetParent()->m_showGridAxis || ( !aGridOrigin.x && !aGridOrigin.y ) )
         return;
 
-    EDA_COLOR_T color    = GetParent()->GetGridColor();
+    COLOR4D color = GetParent()->GetGridColor();
 
     GRSetDrawMode( aDC, aDrawMode );
 
diff --git a/common/drawtxt.cpp b/common/drawtxt.cpp
index 85ca776..ff5e012 100644
--- a/common/drawtxt.cpp
+++ b/common/drawtxt.cpp
@@ -103,7 +103,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
  *  @param aClipBox = the clipping rect, or NULL if no clipping
  *  @param aDC = the current Device Context. NULL if draw within a 3D GL Canvas
  *  @param aPos = text position (according to h_justify, v_justify)
- *  @param aColor (enum EDA_COLOR_T) = text color
+ *  @param aColor (COLOR4D) = text color
  *  @param aText = text to draw
  *  @param aOrient = angle in 0.1 degree
  *  @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
@@ -122,7 +122,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool aItalic,
 void DrawGraphicText( EDA_RECT* aClipBox,
                       wxDC* aDC,
                       const wxPoint& aPos,
-                      EDA_COLOR_T aColor,
+                      COLOR4D aColor,
                       const wxString& aText,
                       double aOrient,
                       const wxSize& aSize,
@@ -175,9 +175,9 @@ void DrawGraphicText( EDA_RECT* aClipBox,
 
 void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
                           const wxPoint &aPos,
-                          enum EDA_COLOR_T aBgColor,
-                          enum EDA_COLOR_T aColor1,
-                          enum EDA_COLOR_T aColor2,
+                          const COLOR4D aBgColor,
+                          COLOR4D aColor1,
+                          COLOR4D aColor2,
                           const wxString &aText,
                           double aOrient,
                           const wxSize &aSize,
@@ -188,9 +188,10 @@ void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
                           PLOTTER * aPlotter )
 {
     // Swap color if contrast would be better
-    if( ColorIsLight( aBgColor ) )
+    // TODO: Maybe calculate contrast some way other than brightness
+    if( aBgColor.GetBrightness() > 0.5 )
     {
-        EDA_COLOR_T c = aColor1;
+        COLOR4D c = aColor1;
         aColor1 = aColor2;
         aColor2 = c;
     }
@@ -210,7 +211,7 @@ void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
  * Function PLOTTER::Text
  *  same as DrawGraphicText, but plot graphic text insteed of draw it
  *  @param aPos = text position (according to aH_justify, aV_justify)
- *  @param aColor (enum EDA_COLOR_T) = text color
+ *  @param aColor (COLOR4D) = text color
  *  @param aText = text to draw
  *  @param aOrient = angle in 0.1 degree
  *  @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
@@ -224,7 +225,7 @@ void DrawGraphicHaloText( EDA_RECT* aClipBox, wxDC * aDC,
  *  @param aMultilineAllowed = true to plot text as multiline, otherwise single line
  */
 void PLOTTER::Text( const wxPoint&              aPos,
-                    enum EDA_COLOR_T            aColor,
+                    const COLOR4D               aColor,
                     const wxString&             aText,
                     double                      aOrient,
                     const wxSize&               aSize,
@@ -248,8 +249,7 @@ void PLOTTER::Text( const wxPoint&              aPos,
 
     SetCurrentLineWidth( textPensize, aData );
 
-    if( aColor >= 0 )
-        SetColor( aColor );
+    SetColor( aColor );
 
     DrawGraphicText( NULL, NULL, aPos, aColor, aText,
                      aOrient, aSize,
diff --git a/common/eda_text.cpp b/common/eda_text.cpp
index 02fc24b..874fc74 100644
--- a/common/eda_text.cpp
+++ b/common/eda_text.cpp
@@ -289,8 +289,8 @@ bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy
 
 
 void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-                     EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode,
-                     EDA_DRAW_MODE_T aFillMode, EDA_COLOR_T aAnchor_color )
+                     COLOR4D aColor, GR_DRAWMODE aDrawMode,
+                     EDA_DRAW_MODE_T aFillMode, COLOR4D aAnchor_color )
 {
     if( IsMultilineAllowed() )
     {
@@ -314,7 +314,7 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
                            aDrawMode, aFillMode, GetShownText(), GetTextPos() );
 
     // Draw text anchor, if requested
-    if( aAnchor_color != UNSPECIFIED_COLOR )
+    if( aAnchor_color != UNSPECIFIED_COLOR4D )
     {
         GRDrawAnchor( aClipBox, aDC,
                       GetTextPos().x + aOffset.x, GetTextPos().y + aOffset.y,
@@ -366,7 +366,7 @@ void EDA_TEXT::GetPositionsOfLinesOfMultilineText(
 }
 
 void EDA_TEXT::drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
-                                  const wxPoint& aOffset, EDA_COLOR_T aColor,
+                                  const wxPoint& aOffset, COLOR4D aColor,
                                   GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode,
                                   const wxString& aText, const wxPoint &aPos )
 {
@@ -511,7 +511,7 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
         size.x = -size.x;
 
     s_cornerBuffer = &aCornerBuffer;
-    EDA_COLOR_T color = BLACK;  // not actually used, but needed by DrawGraphicText
+    COLOR4D color = COLOR4D_BLACK;  // not actually used, but needed by DrawGraphicText
 
     if( IsMultilineAllowed() )
     {
diff --git a/common/gal/color4d.cpp b/common/gal/color4d.cpp
index 3b509d3..b708e9e 100644
--- a/common/gal/color4d.cpp
+++ b/common/gal/color4d.cpp
@@ -24,6 +24,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
 
+#include <map>
+
 #include <gal/color4d.h>
 
 using namespace KIGFX;
@@ -40,23 +42,251 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor )
 #ifdef WX_COMPATIBILITY
     COLOR4D::COLOR4D( const wxColour& aColor )
     {
-        r = aColor.Red();
-        g = aColor.Green();
-        b = aColor.Blue();
-        a = aColor.Alpha();
+        r = aColor.Red() / 255.0;
+        g = aColor.Green() / 255.0;
+        b = aColor.Blue() / 255.0;
+        a = aColor.Alpha() / 255.0;
+    }
+
+
+    bool COLOR4D::SetFromWxString( const wxString& aColorString )
+    {
+        wxColour c;
+
+        if ( c.Set( aColorString ) )
+        {
+            r = c.Red() / 255.0;
+            g = c.Green() / 255.0;
+            b = c.Blue() / 255.0;
+            a = c.Alpha() / 255.0;
+
+            return true;
+        }
+
+        return false;
+    }
+
+
+    wxString COLOR4D::ToWxString( long flags )
+    {
+        wxColour c = ToColour();
+        return c.GetAsString( flags );
+    }
+
+
+    COLOR4D COLOR4D::LegacyMix( COLOR4D aColor ) const
+    {
+        /* Memoization storage. This could be potentially called for each
+         * color merge so a cache is useful (there are few colours anyway) */
+        static std::map< std::pair< uint32_t, uint32_t >, uint32_t > mix_cache;
+
+        // First easy thing: a black gives always the other colour
+        if( *this == COLOR4D_BLACK )
+            return aColor;
+
+        if( aColor == COLOR4D_BLACK )
+            return *this;
+
+        uint32_t myPackedColor = ToU32();
+        uint32_t aPackedColor = aColor.ToU32();
+
+        /* Now we are sure that black can't occur, so the rule is:
+         * BLACK means not computed yet. If we're lucky we already have
+         * an answer */
+        auto search = mix_cache.find( std::pair< uint32_t, uint32_t >( myPackedColor,
+                                                                       aPackedColor ) );
+        COLOR4D candidate = COLOR4D_BLACK;
+        if( search != mix_cache.end() )
+            candidate.FromU32( search->second );
+
+        if( candidate != COLOR4D_BLACK )
+            return candidate;
+
+        // Blend the two colors (i.e. OR the RGB values)
+        COLOR4D mixed( ( (uint8_t)( 255.0 * this->r ) | (uint8_t)( 255.0 * aColor.r ) ) / 255.0,
+                       ( (uint8_t)( 255.0 * this->g ) | (uint8_t)( 255.0 * aColor.g ) ) / 255.0,
+                       ( (uint8_t)( 255.0 * this->b ) | (uint8_t)( 255.0 * aColor.b ) ) / 255.0,
+                       1.0 );
+        candidate = mixed;
+
+        /* Here, BLACK is *not* a good answer, since it would recompute the next time.
+         * Even theorically its not possible (with the current rules), but
+         * maybe the metric will change in the future */
+        if( candidate == COLOR4D_BLACK )
+            candidate = COLOR4D( DARKDARKGRAY );
+
+        // Store the result in the cache. The operation is commutative, too
+        mix_cache.insert( std::pair< std::pair< uint32_t, uint32_t >, uint32_t >
+                          ( std::pair< uint32_t, uint32_t >( myPackedColor, aPackedColor ),
+                            candidate.ToU32() ) );
+        mix_cache.insert( std::pair< std::pair< uint32_t, uint32_t >, uint32_t >
+                          ( std::pair< uint32_t, uint32_t >( aPackedColor, myPackedColor ),
+                            candidate.ToU32() ) );
+
+        return candidate;
+    }
+
+
+    COLOR4D& COLOR4D::SetToLegacyHighlightColor()
+    {
+        EDA_COLOR_T legacyColor = GetNearestLegacyColor( *this );
+        EDA_COLOR_T highlightColor = g_ColorRefs[legacyColor].m_LightColor;
+
+        r = g_ColorRefs[highlightColor].m_Red / 255.0;
+        g = g_ColorRefs[highlightColor].m_Green / 255.0;
+        b = g_ColorRefs[highlightColor].m_Blue / 255.0;
+        a = 1.0;
+
+        return *this;
+    }
+
+
+    COLOR4D& COLOR4D::SetToNearestLegacyColor()
+    {
+        EDA_COLOR_T legacyColor = GetNearestLegacyColor( *this );
+
+        r = g_ColorRefs[legacyColor].m_Red / 255.0;
+        g = g_ColorRefs[legacyColor].m_Green / 255.0;
+        b = g_ColorRefs[legacyColor].m_Blue / 255.0;
+        a = 1.0;
+
+        return *this;
+    }
+
+
+    unsigned int COLOR4D::ToU32() const
+    {
+        return ToColour().GetRGB();
+    }
+
+
+    void COLOR4D::FromU32( unsigned int aPackedColor )
+    {
+        wxColour c;
+        c.SetRGB( aPackedColor );
+        r = c.Red();
+        g = c.Green();
+        b = c.Blue();
+        a = c.Alpha();
+    }
+
+
+    EDA_COLOR_T COLOR4D::GetNearestLegacyColor( COLOR4D &aColor )
+    {
+        // Cache layer implemented here, because all callers are using wxColour
+        static std::map< unsigned int, unsigned int > nearestCache;
+        static double hues[NBCOLORS];
+        static double values[NBCOLORS];
+
+        unsigned int colorInt = aColor.ToU32();
+
+        auto search = nearestCache.find( colorInt );
+
+        if( search != nearestCache.end() )
+            return static_cast<EDA_COLOR_T>( search->second );
+
+        // First use ColorFindNearest to check for exact matches
+        EDA_COLOR_T nearest = ColorFindNearest( aColor.r * 255.0, aColor.g * 255.0, aColor.b * 255.0 );
+
+        if( COLOR4D( nearest ) == aColor )
+        {
+            nearestCache.insert( std::pair< unsigned int, unsigned int >(
+                                 colorInt, static_cast<unsigned int>( nearest ) ) );
+            return nearest;
+        }
+
+        // If not, use hue and value to match.
+        // Hue will be NAN for grayscale colors.
+        // The legacy color palette is a grid across hue and value.
+        // We can exploit that to find a good match -- hue is most apparent to the user.
+        // So, first we determine the closest hue match, and then the closest value from that
+        // "grid row" in the legacy palette.
+
+        double h, s, v;
+        aColor.ToHSV( h, s, v );
+
+        double minDist = 360.0;
+        double legacyHue = 0.0;
+
+        if( std::isnan( h ) )
+        {
+            legacyHue = NAN;
+        }
+        else
+        {
+            for( EDA_COLOR_T candidate = BLACK; candidate < NBCOLORS; candidate = NextColor(candidate) )
+            {
+                double ch, cs, cv;
+
+                if( hues[candidate] == 0.0 && values[candidate] == 0.0 )
+                {
+                    COLOR4D candidate4d( candidate );
+
+                    candidate4d.ToHSV( ch, cs, cv );
+
+                    values[candidate] = cv;
+                    // Set the hue to non-zero for black so that we won't do this more than once
+                    hues[candidate] = ( cv == 0.0 ) ? 1.0 : ch;
+                }
+                else
+                {
+                    ch = hues[candidate];
+                    cv = values[candidate];
+                    cv = 0.0;
+                }
+
+                if( fabs( ch - h ) < minDist )
+                {
+                    minDist = fabs( ch - h );
+                    legacyHue = ch;
+                }
+            }
+        }
+
+        // Now we have the desired hue; let's find the nearest value
+        minDist = 1.0;
+        for( EDA_COLOR_T candidate = BLACK; candidate < NBCOLORS; candidate = NextColor(candidate) )
+        {
+            // If the target hue is NAN, we didn't extract the value for any colors above
+            if( std::isnan( legacyHue ) )
+            {
+                double ch, cs, cv;
+                COLOR4D candidate4d( candidate );
+                candidate4d.ToHSV( ch, cs, cv );
+                values[candidate] = cv;
+                hues[candidate] = ( cv == 0.0 ) ? 1.0 : ch;
+            }
+
+            if( ( std::isnan( legacyHue ) != std::isnan( hues[candidate] ) ) || hues[candidate] != legacyHue )
+                continue;
+
+            if( fabs( values[candidate] - v ) < minDist )
+            {
+                minDist = fabs( values[candidate] - v );
+                nearest = candidate;
+            }
+        }
+
+        nearestCache.insert( std::pair< unsigned int, unsigned int >(
+                             colorInt, static_cast<unsigned int>( nearest ) ) );
+
+        return nearest;
     }
 #endif
 
+namespace KIGFX {
 
-const bool COLOR4D::operator==( const COLOR4D& aColor )
+const bool operator==( const COLOR4D& lhs, const COLOR4D& rhs )
 {
-    return a == aColor.a && r == aColor.r && g == aColor.g && b == aColor.b;
+    return lhs.a == rhs.a && lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b;
 }
 
 
-const bool COLOR4D::operator!=( const COLOR4D& aColor )
+const bool operator!=( const COLOR4D& lhs, const COLOR4D& rhs )
 {
-    return a != aColor.a || r != aColor.r || g != aColor.g || b != aColor.b;
+    return !(lhs == rhs);
+}
+
 }
 
 
diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp
index ebb5898..4f69c42 100644
--- a/common/gr_basic.cpp
+++ b/common/gr_basic.cpp
@@ -59,7 +59,7 @@ static void ClipAndDrawPoly( EDA_RECT * ClipBox, wxDC * DC, wxPoint Points[],
  * from user units to screen units(pixels coordinates)
  */
 static void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1,
-                     int x2, int y2, int aWidth, EDA_COLOR_T aColor,
+                     int x2, int y2, int aWidth, COLOR4D aColor,
                      wxPenStyle aStyle = wxPENSTYLE_SOLID );
 
 /**/
@@ -72,8 +72,8 @@ static int          xcliplo = 0,
                     xcliphi = 2000,
                     ycliphi = 2000;
 
-static EDA_COLOR_T   s_DC_lastcolor = UNSPECIFIED_COLOR;
-static EDA_COLOR_T   s_DC_lastbrushcolor = UNSPECIFIED_COLOR;
+static COLOR4D   s_DC_lastcolor( 0, 0, 0, 0 );
+static COLOR4D   s_DC_lastbrushcolor( 0, 0, 0, 0 );
 static bool  s_DC_lastbrushfill  = false;
 static wxDC* s_DC_lastDC = NULL;
 
@@ -196,8 +196,8 @@ static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int
 void GRResetPenAndBrush( wxDC* DC )
 {
     GRSetBrush( DC, BLACK );  // Force no fill
-    s_DC_lastbrushcolor = UNSPECIFIED_COLOR;
-    s_DC_lastcolor =  UNSPECIFIED_COLOR;
+    s_DC_lastbrushcolor = UNSPECIFIED_COLOR4D;
+    s_DC_lastcolor =  UNSPECIFIED_COLOR4D;
     s_DC_lastDC    = NULL;
 }
 
@@ -206,7 +206,7 @@ void GRResetPenAndBrush( wxDC* DC )
  * Function GRSetColorPen
  * sets a pen style, width, color, and alpha into the given device context.
  */
-void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width, wxPenStyle style )
+void GRSetColorPen( wxDC* DC, COLOR4D Color, int width, wxPenStyle style )
 {
     // Under OSX and while printing when wxPen is set to 0, renderer follows the request drawing
     // nothing & in the bitmap world the minimum is enough to light a pixel, in vectorial one not
@@ -214,17 +214,16 @@ void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width, wxPenStyle style )
         width = DC->DeviceToLogicalXRel( 1 );
 
     if( s_ForceBlackPen )
-        Color = BLACK;
+        Color = COLOR4D_BLACK;
 
-    wxColour wx_color = MakeColour( Color );
     const wxPen& curr_pen = DC->GetPen();
 
-    if( !curr_pen.IsOk() || curr_pen.GetColour() != wx_color
+    if( !curr_pen.IsOk() || curr_pen.GetColour() != Color.ToColour()
        || curr_pen.GetWidth() != width
        || curr_pen.GetStyle() != style )
     {
         wxPen pen;
-        pen.SetColour( wx_color );
+        pen.SetColour( Color.ToColour() );
         pen.SetWidth( width );
         pen.SetStyle( style );
         DC->SetPen( pen );
@@ -238,10 +237,10 @@ void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width, wxPenStyle style )
 }
 
 
-void GRSetBrush( wxDC* DC, EDA_COLOR_T Color, bool fill )
+void GRSetBrush( wxDC* DC, COLOR4D Color, bool fill )
 {
     if( s_ForceBlackPen )
-        Color = BLACK;
+        Color = COLOR4D_BLACK;
 
     if(   s_DC_lastbrushcolor != Color
        || s_DC_lastbrushfill  != fill
@@ -249,7 +248,7 @@ void GRSetBrush( wxDC* DC, EDA_COLOR_T Color, bool fill )
     {
         wxBrush brush;
 
-        brush.SetColour( MakeColour( Color ) );
+        brush.SetColour( Color.ToColour() );
 
         if( fill )
             brush.SetStyle( wxBRUSHSTYLE_SOLID );
@@ -337,7 +336,7 @@ void GRSetDrawMode( wxDC* DC, GR_DRAWMODE draw_mode )
 }
 
 
-void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, EDA_COLOR_T Color )
+void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, COLOR4D Color )
 {
     if( ClipBox && !ClipBox->Contains( x, y ) )
         return;
@@ -357,7 +356,7 @@ void GRLine( EDA_RECT* ClipBox,
              int       x2,
              int       y2,
              int       width,
-             EDA_COLOR_T       Color )
+             COLOR4D   Color )
 {
     GRSetColorPen( DC, Color, width );
     WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
@@ -366,7 +365,7 @@ void GRLine( EDA_RECT* ClipBox,
 }
 
 
-void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, EDA_COLOR_T aColor )
+void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor )
 {
     GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor );
 }
@@ -374,14 +373,14 @@ void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aW
 
 void GRDashedLine( EDA_RECT* ClipBox, wxDC*     DC,
                    int x1, int y1, int x2, int  y2,
-                   int       width, EDA_COLOR_T Color )
+                   int       width, COLOR4D Color )
 {
     GRLastMoveToX  = x2;
     GRLastMoveToY  = y2;
-    s_DC_lastcolor = UNSPECIFIED_COLOR;
+    s_DC_lastcolor = UNSPECIFIED_COLOR4D;
     GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH );
     WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
-    s_DC_lastcolor = UNSPECIFIED_COLOR;
+    s_DC_lastcolor = UNSPECIFIED_COLOR4D;
     GRSetColorPen( DC, Color, width );
 }
 
@@ -399,14 +398,14 @@ void GRMoveTo( int x, int y )
 /*
  * Draw line to a new position, in object space.
  */
-void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, EDA_COLOR_T Color )
+void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, COLOR4D Color )
 {
     GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
 }
 
 
 void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-                  int width, EDA_COLOR_T Color )
+                  int width, COLOR4D Color )
 {
     GRSetColorPen( DC, Color, width, wxPENSTYLE_DOT_DASH );
     GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color );
@@ -422,11 +421,11 @@ void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  * @param aDC = the device context into which drawing should occur.
  * @param aLines = a list of pair of coordinate in user space: a pair for each line.
  * @param aWidth = the width of each line.
- * @param aColor = an index into our color table of RGB colors.
- * @see EDA_COLOR_T and colors.h
+ * @param aColor = color to draw the lines
+ * @see COLOR4D
  */
 void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
-                  int aWidth, EDA_COLOR_T aColor )
+                  int aWidth, COLOR4D aColor )
 {
     if( aLines.empty() )
         return;
@@ -480,7 +479,7 @@ void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aLines,
 
 // Draw  the outline of a thick segment wih rounded ends
 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-              int width, int aPenSize, EDA_COLOR_T Color )
+              int width, int aPenSize, COLOR4D Color )
 {
     GRLastMoveToX = x2;
     GRLastMoveToY = y2;
@@ -566,14 +565,14 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
 
 
 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-              int width, EDA_COLOR_T Color )
+              int width, COLOR4D Color )
 {
     GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color );
 }
 
 
 void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
-              int aWidth, EDA_COLOR_T aColor )
+              int aWidth, COLOR4D aColor )
 {
     GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor );
 }
@@ -583,7 +582,7 @@ void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
  * Draw segment (full) with rounded ends in object space (real coords.).
  */
 void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-                  int width, EDA_COLOR_T Color )
+                  int width, COLOR4D Color )
 {
     GRSetColorPen( DC, Color, width );
     WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
@@ -591,7 +590,7 @@ void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
 
 
 void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
-                      int aWidth, EDA_COLOR_T aColor )
+                      int aWidth, COLOR4D aColor )
 {
     GRSetColorPen( aDC, aColor, aWidth );
     WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
@@ -642,7 +641,7 @@ static bool IsGRSPolyDrawable( EDA_RECT* ClipBox, int n, wxPoint Points[] )
  */
 static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
                      bool      Fill, int width,
-                     EDA_COLOR_T Color, EDA_COLOR_T BgColor )
+                     COLOR4D Color, COLOR4D BgColor )
 {
     if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
         return;
@@ -701,8 +700,8 @@ static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
 static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC,
                            int       aPointCount, wxPoint aPoints[],
                            bool      aFill, int aWidth,
-                           EDA_COLOR_T       aColor,
-                           EDA_COLOR_T       aBgColor )
+                           COLOR4D   aColor,
+                           COLOR4D   aBgColor )
 {
     if( !IsGRSPolyDrawable( aClipBox, aPointCount, aPoints ) )
         return;
@@ -766,7 +765,7 @@ static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC,
  * Draw a new polyline and fill it if Fill, in drawing space.
  */
 void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
-             bool Fill, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
+             bool Fill, int width, COLOR4D Color, COLOR4D BgColor )
 {
     GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
 }
@@ -776,20 +775,20 @@ void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
  * Draw a closed polyline and fill it if Fill, in object space.
  */
 void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
-                   bool Fill, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
+                   bool Fill, COLOR4D Color, COLOR4D BgColor )
 {
     GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
 }
 
 
 void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
-                   bool Fill, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
+                   bool Fill, int width, COLOR4D Color, COLOR4D BgColor )
 {
     GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
 }
 
 
-void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, EDA_COLOR_T Color )
+void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, COLOR4D Color )
 {
     /* Clip circles off screen. */
     if( ClipBox )
@@ -819,20 +818,20 @@ void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, ED
 }
 
 
-void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, EDA_COLOR_T Color )
+void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, COLOR4D Color )
 {
     GRCircle( ClipBox, DC, x, y, r, 0, Color );
 }
 
 
-void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, EDA_COLOR_T aColor )
+void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor )
 {
     GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor );
 }
 
 
 void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r,
-                     int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
+                     int width, COLOR4D Color, COLOR4D BgColor )
 {
     /* Clip circles off screen. */
     if( ClipBox )
@@ -862,7 +861,7 @@ void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r,
 }
 
 
-void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, EDA_COLOR_T aColor )
+void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, COLOR4D aColor )
 {
     GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, 0, aColor, aColor );
 }
@@ -872,7 +871,7 @@ void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, E
  * Draw an arc in user space.
  */
 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-             int xc, int yc, EDA_COLOR_T Color )
+             int xc, int yc, COLOR4D Color )
 {
     GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color );
 }
@@ -882,7 +881,7 @@ void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  * Draw an arc, width = width in user space.
  */
 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-             int xc, int yc, int width, EDA_COLOR_T Color )
+             int xc, int yc, int width, COLOR4D Color )
 {
     /* Clip arcs off screen. */
     if( ClipBox )
@@ -910,7 +909,7 @@ void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
 
 
 void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
-             wxPoint aCenter, int aWidth, EDA_COLOR_T aColor )
+             wxPoint aCenter, int aWidth, COLOR4D aColor )
 {
     GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
             aWidth, aColor );
@@ -928,8 +927,8 @@ void GRFilledArc( EDA_RECT* ClipBox,
                   double    EndAngle,
                   int       r,
                   int       width,
-                  EDA_COLOR_T       Color,
-                  EDA_COLOR_T       BgColor )
+                  COLOR4D   Color,
+                  COLOR4D   BgColor )
 {
     int x1, y1, x2, y2;
 
@@ -971,7 +970,7 @@ void GRFilledArc( EDA_RECT* ClipBox,
 
 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
                   double StAngle, double EndAngle, int r,
-                  EDA_COLOR_T Color, EDA_COLOR_T BgColor )
+                  COLOR4D Color, COLOR4D BgColor )
 {
     GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
 }
@@ -981,7 +980,7 @@ void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
  * Draw an arc in drawing space.
  */
 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, double StAngle,
-            double EndAngle, int r, EDA_COLOR_T Color )
+            double EndAngle, int r, COLOR4D Color )
 {
     int x1, y1, x2, y2;
 
@@ -1032,7 +1031,7 @@ void GRArc( EDA_RECT* ClipBox,
             double    EndAngle,
             int       r,
             int       width,
-            EDA_COLOR_T       Color )
+            COLOR4D   Color )
 {
     int x1, y1, x2, y2;
 
@@ -1075,13 +1074,13 @@ void GRArc( EDA_RECT* ClipBox,
 /*
  * Draw a rectangle in drawing space.
  */
-void GRRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, EDA_COLOR_T aColor )
+void GRRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, COLOR4D aColor )
 {
     GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor );
 }
 
 
-void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, EDA_COLOR_T aColor, wxPenStyle aStyle )
+void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, COLOR4D aColor, wxPenStyle aStyle )
 {
     int x1 = aRect.GetX();
     int y1 = aRect.GetY();
@@ -1095,13 +1094,13 @@ void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, EDA_COLOR_T
 /*
  * Draw a rectangle (thick lines) in drawing space.
  */
-void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color )
+void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color )
 {
     GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
 }
 
 
-void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, EDA_COLOR_T aColor )
+void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, COLOR4D aColor )
 {
     int x1 = aRect.GetX();
     int y1 = aRect.GetY();
@@ -1116,7 +1115,7 @@ void GRRect( EDA_RECT* aClipBox, wxDC* aDC, const EDA_RECT& aRect, int aWidth, E
  * Draw a rectangle (filled with AreaColor) in drawing space.
  */
 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-                   EDA_COLOR_T Color, EDA_COLOR_T BgColor )
+                   COLOR4D Color, COLOR4D BgColor )
 {
     GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
 }
@@ -1126,7 +1125,7 @@ void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  * Draw a rectangle (filled with AreaColor) in drawing space.
  */
 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-                   int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor )
+                   int width, COLOR4D Color, COLOR4D BgColor )
 {
     GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
 }
@@ -1137,7 +1136,7 @@ void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  */
 
 void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
-              int aWidth, EDA_COLOR_T aColor, wxPenStyle aStyle )
+              int aWidth, COLOR4D aColor, wxPenStyle aStyle )
 {
     wxPoint points[5];
     points[0] = wxPoint(x1, y1);
@@ -1151,7 +1150,7 @@ void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
 
 
 void GRSFilledRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
-                    int aWidth, EDA_COLOR_T aColor, EDA_COLOR_T aBgColor )
+                    int aWidth, COLOR4D aColor, COLOR4D aBgColor )
 {
     wxPoint points[5];
     points[0] = wxPoint(x1, y1);
@@ -1232,7 +1231,7 @@ void GRBezier( EDA_RECT* ClipBox,
                int       x3,
                int       y3,
                int       width,
-               EDA_COLOR_T       Color )
+               COLOR4D   Color )
 {
     std::vector<wxPoint> Points = Bezier2Poly( x1, y1, x2, y2, x3, y3 );
     GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color );
@@ -1250,7 +1249,7 @@ void GRBezier( EDA_RECT* ClipBox,
                int       x4,
                int       y4,
                int       width,
-               EDA_COLOR_T       Color )
+               COLOR4D   Color )
 {
     std::vector<wxPoint> Points = Bezier2Poly( x1, y1, x2, y2, x3, y3, x4, y4 );
     GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color );
@@ -1258,7 +1257,7 @@ void GRBezier( EDA_RECT* ClipBox,
 
 
 void GRDrawAnchor( EDA_RECT *aClipBox, wxDC *aDC, int x, int y,
-                   int aSize, EDA_COLOR_T aColor )
+                   int aSize, COLOR4D aColor )
 {
         int anchor_size = aDC->DeviceToLogicalXRel( aSize );
 
diff --git a/common/msgpanel.cpp b/common/msgpanel.cpp
index 97e8abe..32ba735 100644
--- a/common/msgpanel.cpp
+++ b/common/msgpanel.cpp
@@ -109,7 +109,7 @@ void EDA_MSG_PANEL::OnPaint( wxPaintEvent& aEvent )
 
 void EDA_MSG_PANEL::AppendMessage( const wxString& aUpperText,
                                    const wxString& aLowerText,
-                                   EDA_COLOR_T aColor, int aPad )
+                                   COLOR4D aColor, int aPad )
 {
     wxString    text;
     wxSize      drawSize = GetClientSize();
@@ -143,7 +143,7 @@ void EDA_MSG_PANEL::AppendMessage( const wxString& aUpperText,
 
 
 void EDA_MSG_PANEL::SetMessage( int aXPosition, const wxString& aUpperText,
-                                const wxString& aLowerText, EDA_COLOR_T aColor )
+                                const wxString& aLowerText, COLOR4D aColor )
 {
     wxPoint pos;
     wxSize drawSize = GetClientSize();
@@ -196,13 +196,9 @@ void EDA_MSG_PANEL::SetMessage( int aXPosition, const wxString& aUpperText,
 
 void EDA_MSG_PANEL::showItem( wxDC& aDC, const MSG_PANEL_ITEM& aItem )
 {
-    EDA_COLOR_T color = aItem.m_Color;
+    COLOR4D color = aItem.m_Color;
 
-    if( color >= 0 )
-    {
-        color = ColorGetBase( color );
-        aDC.SetTextForeground( MakeColour( color ) );
-    }
+    aDC.SetTextForeground( color.ToColour() );
 
     if( !aItem.m_UpperText.IsEmpty() )
     {
@@ -230,7 +226,7 @@ void EDA_MSG_PANEL::erase( wxDC* aDC )
     wxBrush brush;
 
     wxSize  size  = GetClientSize();
-    wxColor color = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
+    wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
 
     pen.SetColour( color );
 
diff --git a/common/page_layout/class_worksheet_dataitem.cpp b/common/page_layout/class_worksheet_dataitem.cpp
index 3faf86b..4240fcc 100644
--- a/common/page_layout/class_worksheet_dataitem.cpp
+++ b/common/page_layout/class_worksheet_dataitem.cpp
@@ -61,6 +61,8 @@
 #include <worksheet_shape_builder.h>
 #include <class_worksheet_dataitem.h>
 
+using KIGFX::COLOR4D;
+
 
 // Static members of class WORKSHEET_DATAITEM:
 double WORKSHEET_DATAITEM::m_WSunits2Iu = 1.0;
@@ -70,9 +72,9 @@ double WORKSHEET_DATAITEM::m_DefaultLineWidth = 0.0;
 DSIZE  WORKSHEET_DATAITEM::m_DefaultTextSize( TB_DEFAULT_TEXTSIZE, TB_DEFAULT_TEXTSIZE );
 double WORKSHEET_DATAITEM::m_DefaultTextThickness = 0.0;
 bool WORKSHEET_DATAITEM::m_SpecialMode = false;
-EDA_COLOR_T WORKSHEET_DATAITEM::m_Color = RED;              // the default color to draw items
-EDA_COLOR_T WORKSHEET_DATAITEM::m_AltColor = RED;           // an alternate color to draw items
-EDA_COLOR_T WORKSHEET_DATAITEM::m_SelectedColor = BROWN;   // the color to draw selected items
+COLOR4D WORKSHEET_DATAITEM::m_Color = COLOR4D( RED );            // the default color to draw items
+COLOR4D WORKSHEET_DATAITEM::m_AltColor = COLOR4D( RED );         // an alternate color to draw items
+COLOR4D WORKSHEET_DATAITEM::m_SelectedColor = COLOR4D( BROWN );  // the color to draw selected items
 
 
 // The constructor:
diff --git a/common/page_layout/page_layout_graphic_items.cpp b/common/page_layout/page_layout_graphic_items.cpp
index 21dd1dd..eaa5734 100644
--- a/common/page_layout/page_layout_graphic_items.cpp
+++ b/common/page_layout/page_layout_graphic_items.cpp
@@ -175,7 +175,7 @@ void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC )
 
 WS_DRAW_ITEM_TEXT::WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aParent,
                    wxString& aText, wxPoint aPos, wxSize aSize,
-                   int aPenWidth, EDA_COLOR_T aColor,
+                   int aPenWidth, COLOR4D aColor,
                    bool aItalic, bool aBold ) :
     WS_DRAW_ITEM_BASE( aParent, wsg_text, aColor ), EDA_TEXT( aText )
 {
@@ -188,12 +188,12 @@ WS_DRAW_ITEM_TEXT::WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aParent,
 
 
 void WS_DRAW_ITEM_TEXT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-       GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+       GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
     Draw( aClipBox, aDC, aOffset,
-            aColor == UNSPECIFIED_COLOR ? GetColor() : aColor,
+            aColor == UNSPECIFIED_COLOR4D ? GetColor() : aColor,
             aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode,
-            FILLED, UNSPECIFIED_COLOR );
+            FILLED, UNSPECIFIED_COLOR4D );
 }
 
 
@@ -222,7 +222,7 @@ bool WS_DRAW_ITEM_TEXT::HitTestStartPoint( const wxPoint& aPosition)
 
 
 void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-        GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+        GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
     std::vector<wxPoint> points_moved;
     wxPoint *points;
@@ -238,7 +238,7 @@ void WS_DRAW_ITEM_POLYGON::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPo
         points = &m_Corners[0];
     }
 
-    auto color = ( aColor == UNSPECIFIED_COLOR ) ? GetColor() : aColor;
+    auto color = ( aColor == UNSPECIFIED_COLOR4D ) ? GetColor() : aColor;
 
     GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode ) );
     GRPoly( aClipBox, aDC,
@@ -288,14 +288,14 @@ bool WS_DRAW_ITEM_POLYGON::HitTestStartPoint( const wxPoint& aPosition)
 
 
 void WS_DRAW_ITEM_RECT::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-       GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+       GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
     GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ? GR_COPY : aDrawMode ) );
     GRRect( aClipBox, aDC,
             GetStart().x + aOffset.x, GetStart().y + aOffset.y,
             GetEnd().x + aOffset.x, GetEnd().y + aOffset.y,
             GetPenWidth(),
-            ( aColor == UNSPECIFIED_COLOR ) ? GetColor() : aColor );
+            ( aColor == UNSPECIFIED_COLOR4D ) ? GetColor() : aColor );
     GRSetDrawMode( aDC, GR_COPY );
 }
 
@@ -393,12 +393,12 @@ bool WS_DRAW_ITEM_RECT::HitTestEndPoint( const wxPoint& aPosition)
 
 
 void WS_DRAW_ITEM_LINE::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-        GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+        GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
     GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
     GRLine( aClipBox, aDC, GetStart() + aOffset, GetEnd() + aOffset,
             GetPenWidth(),
-            ( aColor == UNSPECIFIED_COLOR ) ? GetColor() : aColor );
+            ( aColor == UNSPECIFIED_COLOR4D ) ? GetColor() : aColor );
     GRSetDrawMode( aDC, GR_COPY );
 }
 
@@ -468,7 +468,7 @@ void WS_DRAW_ITEM_LIST::Locate( std::vector <WS_DRAW_ITEM_BASE*>& aList,
 
 
 void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-        GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+        GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
     WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)GetParent();
 
diff --git a/common/page_layout/title_block_shapes.cpp b/common/page_layout/title_block_shapes.cpp
index 086d518..1b8d44a 100644
--- a/common/page_layout/title_block_shapes.cpp
+++ b/common/page_layout/title_block_shapes.cpp
@@ -66,7 +66,7 @@
 void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
                        const PAGE_INFO& aPageInfo,
                        const TITLE_BLOCK& aTitleBlock,
-                       EDA_COLOR_T aColor, EDA_COLOR_T aAltColor )
+                       COLOR4D aColor, COLOR4D aAltColor )
 {
     WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
 
@@ -122,7 +122,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
             && m_sheetNumber > 1 )
             continue;
 
-        EDA_COLOR_T color = wsItem->GetItemColor();
+        COLOR4D color = wsItem->GetItemColor();
 
         pensize = wsItem->GetPenSizeUi();
 
diff --git a/common/painter.cpp b/common/painter.cpp
index 0d6b1f0..fcc0dcd 100644
--- a/common/painter.cpp
+++ b/common/painter.cpp
@@ -41,15 +41,6 @@ RENDER_SETTINGS::RENDER_SETTINGS()
     m_highlightNetcode      = -1;
     m_outlineWidth          = 1;
     m_worksheetLineWidth    = 100000;
-
-    // Store the predefined colors used in KiCad in format used by GAL
-    for( int i = 0; i < NBCOLORS; i++ )
-    {
-        m_legacyColorMap[g_ColorRefs[i].m_Numcolor] = COLOR4D( (double) g_ColorRefs[i].m_Red / 255.0,
-                                                               (double) g_ColorRefs[i].m_Green / 255.0,
-                                                               (double) g_ColorRefs[i].m_Blue / 255.0,
-                                                               m_layerOpacity );
-    }
 }
 
 
diff --git a/common/selcolor.cpp b/common/selcolor.cpp
index fb96bcc..7bc6334 100644
--- a/common/selcolor.cpp
+++ b/common/selcolor.cpp
@@ -26,14 +26,17 @@
 /* Dialog for selecting color from the palette of available colors.
  */
 
+
 #include <fctsys.h>
 #include <common.h>
-#include <colors.h>
+#include <gal/color4d.h>
 
 #include <wx/statline.h>
 
 #include <algorithm>
 
+using KIGFX::COLOR4D;
+
 
 enum colors_id {
     ID_COLOR_BLACK = 2000 // colors_id = ID_COLOR_BLACK a ID_COLOR_BLACK + NBCOLORS-1
@@ -43,16 +46,16 @@ enum colors_id {
 class CHOOSE_COLOR_DLG : public wxDialog
 {
 public:
-    CHOOSE_COLOR_DLG( wxWindow* aParent, EDA_COLOR_T aOldColor );
+    CHOOSE_COLOR_DLG( wxWindow* aParent, COLOR4D aOldColor );
     ~CHOOSE_COLOR_DLG() {};
 
-    EDA_COLOR_T GetSelectedColor() { return m_color; }
+    COLOR4D GetSelectedColor() { return m_color; }
 
 private:
     void init_Dialog();
     void selColor( wxCommandEvent& event );
 
-    EDA_COLOR_T m_color;
+    COLOR4D m_color;
 
     DECLARE_EVENT_TABLE()
 };
@@ -65,7 +68,7 @@ BEGIN_EVENT_TABLE( CHOOSE_COLOR_DLG, wxDialog )
 END_EVENT_TABLE()
 
 
-EDA_COLOR_T DisplayColorFrame( wxWindow* aParent, EDA_COLOR_T aOldColor )
+COLOR4D DisplayColorFrame( wxWindow* aParent, COLOR4D aOldColor )
 {
     CHOOSE_COLOR_DLG dlg( aParent, aOldColor );
 
@@ -74,11 +77,11 @@ EDA_COLOR_T DisplayColorFrame( wxWindow* aParent, EDA_COLOR_T aOldColor )
         return dlg.GetSelectedColor();
     }
 
-    return UNSPECIFIED_COLOR;
+    return UNSPECIFIED_COLOR4D;
 }
 
 
-CHOOSE_COLOR_DLG::CHOOSE_COLOR_DLG( wxWindow* aParent, EDA_COLOR_T aOldColor ) :
+CHOOSE_COLOR_DLG::CHOOSE_COLOR_DLG( wxWindow* aParent, COLOR4D aOldColor ) :
     wxDialog( aParent, wxID_ANY, _( "Colors" ), wxDefaultPosition, wxDefaultSize,
               wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
 {
@@ -131,10 +134,10 @@ void CHOOSE_COLOR_DLG::init_Dialog()
 
         iconDC.SelectObject( ButtBitmap );
 
-        EDA_COLOR_T buttcolor = g_ColorRefs[ii].m_Numcolor;
+        COLOR4D buttcolor = COLOR4D( g_ColorRefs[ii].m_Numcolor );
 
         iconDC.SetPen( *wxBLACK_PEN );
-        ColorSetBrush( &brush, buttcolor );
+        brush.SetColour( buttcolor.ToColour() );
         brush.SetStyle( wxBRUSHSTYLE_SOLID );
 
         iconDC.SetBrush( brush );
@@ -154,7 +157,8 @@ void CHOOSE_COLOR_DLG::init_Dialog()
         if( m_color == buttcolor )
             focusedButton = bitmapButton;
 
-        wxStaticText* label = new wxStaticText( this, -1, wxGetTranslation( ColorGetName( buttcolor ) ),
+        EDA_COLOR_T edaColor = ColorFindNearest( buttcolor.ToColour() );
+        wxStaticText* label = new wxStaticText( this, -1, wxGetTranslation( ColorGetName( edaColor ) ),
                                         wxDefaultPosition, wxDefaultSize, 0 );
         FlexColumnBoxSizer->Add( label, 1,
                                  wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
diff --git a/common/swig/kicad.i b/common/swig/kicad.i
index 6382369..768b9b6 100644
--- a/common/swig/kicad.i
+++ b/common/swig/kicad.i
@@ -106,6 +106,7 @@ principle should be easily implemented by adapting the current STL containers.
 %include class_eda_rect.h
 %include common.h
 %include class_title_block.h
+%include gal/color4d.h
 %include class_colors_design_settings.h
 %include class_marker_base.h
 %include eda_text.h
diff --git a/common/worksheet.cpp b/common/worksheet.cpp
index 367fa98..4cff42e 100644
--- a/common/worksheet.cpp
+++ b/common/worksheet.cpp
@@ -53,7 +53,7 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
                      TITLE_BLOCK& aTitleBlock,
                      int aSheetCount, int aSheetNumber,
                      int aPenWidth, double aScalar,
-                     EDA_COLOR_T aColor, EDA_COLOR_T aAltColor,
+                     COLOR4D aColor, COLOR4D aAltColor,
                      const wxString& aSheetLayer )
 {
     WS_DRAW_ITEM_LIST drawList;
@@ -94,7 +94,7 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
     }
 
     TITLE_BLOCK t_block = GetTitleBlock();
-    EDA_COLOR_T color = RED;
+    COLOR4D color = COLOR4D( RED );
 
     wxPoint origin = aDC->GetDeviceOrigin();
 
diff --git a/common/worksheet_viewitem.cpp b/common/worksheet_viewitem.cpp
index c546379..18f8fb9 100644
--- a/common/worksheet_viewitem.cpp
+++ b/common/worksheet_viewitem.cpp
@@ -92,8 +92,7 @@ void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, VIEW* aView ) const
     drawList.SetSheetName( sheetName );
 
     COLOR4D color = settings->GetColor( this, aLayer );
-    EDA_COLOR_T edaColor = ColorFindNearest( color.r * 255, color.g * 255, color.b * 255 );
-    drawList.BuildWorkSheetGraphicList( *m_pageInfo, *m_titleBlock, edaColor, edaColor );
+    drawList.BuildWorkSheetGraphicList( *m_pageInfo, *m_titleBlock, color, color );
 
     // Draw all the components that make the page layout
     WS_DRAW_ITEM_BASE* item = drawList.GetFirst();
diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp
index 3888361..892f5e9 100644
--- a/cvpcb/class_DisplayFootprintsFrame.cpp
+++ b/cvpcb/class_DisplayFootprintsFrame.cpp
@@ -432,9 +432,9 @@ void DISPLAY_FOOTPRINTS_FRAME::SetGridVisibility(bool aVisible)
 }
 
 
-EDA_COLOR_T DISPLAY_FOOTPRINTS_FRAME::GetGridColor() const
+COLOR4D DISPLAY_FOOTPRINTS_FRAME::GetGridColor() const
 {
-    return DARKGRAY;
+    return COLOR4D( DARKGRAY );
 }
 
 
diff --git a/cvpcb/class_DisplayFootprintsFrame.h b/cvpcb/class_DisplayFootprintsFrame.h
index 94d495c..e82f61a 100644
--- a/cvpcb/class_DisplayFootprintsFrame.h
+++ b/cvpcb/class_DisplayFootprintsFrame.h
@@ -87,7 +87,7 @@ public:
      * Function GetGridColor() , virtual
      * @return the color of the grid
      */
-    virtual EDA_COLOR_T GetGridColor() const override;
+    virtual COLOR4D GetGridColor() const override;
 
     void    OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
     void    OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) override;
diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt
index 1a3dd71..83526a2 100644
--- a/eeschema/CMakeLists.txt
+++ b/eeschema/CMakeLists.txt
@@ -275,6 +275,7 @@ target_link_libraries( eeschema
     # There's way too much crap coming in from common yet.
     common
     bitmaps
+    gal
     ${wxWidgets_LIBRARIES}
     )
 
diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp
index 865d4e6..83528a9 100644
--- a/eeschema/block_libedit.cpp
+++ b/eeschema/block_libedit.cpp
@@ -348,7 +348,7 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
         block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
 
         component->Draw( aPanel, aDC, block->GetMoveVector(), unit, convert,
-                         g_XorMode, UNSPECIFIED_COLOR, DefaultTransform, true, true, true );
+                         g_XorMode, UNSPECIFIED_COLOR4D, DefaultTransform, true, true, true );
     }
 
     // Repaint new view
@@ -358,5 +358,5 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
     block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
 
     component->Draw( aPanel, aDC, block->GetMoveVector(), unit, convert,
-                     g_XorMode, UNSPECIFIED_COLOR, DefaultTransform, true, true, true );
+                     g_XorMode, UNSPECIFIED_COLOR4D, DefaultTransform, true, true, true );
 }
diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp
index 1c929de..528d09d 100644
--- a/eeschema/bus-wire-junction.cpp
+++ b/eeschema/bus-wire-junction.cpp
@@ -121,8 +121,7 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
         return;
 
     segment = (SCH_LINE*) s_wires.begin();
-    EDA_COLOR_T color = GetLayerColor( segment->GetLayer() );
-    ColorChangeHighlightFlag( &color, !(color & HIGHLIGHT_FLAG) );
+    COLOR4D color = GetLayerColor( segment->GetLayer() );
 
     if( aErase )
     {
diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp
index 42cd535..f8b891a 100644
--- a/eeschema/class_libentry.cpp
+++ b/eeschema/class_libentry.cpp
@@ -314,7 +314,7 @@ void LIB_PART::SetName( const wxString& aName )
 
 
 void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset, int aMulti,
-                     int aConvert, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor,
+                     int aConvert, GR_DRAWMODE aDrawMode, COLOR4D aColor,
                      const TRANSFORM& aTransform, bool aShowPinText, bool aDrawFields,
                      bool aOnlySelected, const std::vector<bool>* aPinsDangling,
                      bool aShowElectricalType )
@@ -329,8 +329,8 @@ void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
      *   printing in black and white
      *   If the color is not the default color (aColor != -1 )
      */
-    if( ! (screen && screen->m_IsPrinting && GetGRForceBlackPenState())
-            && (aColor == UNSPECIFIED_COLOR) )
+    if( ! ( screen && screen->m_IsPrinting && GetGRForceBlackPenState() )
+            && ( aColor == UNSPECIFIED_COLOR4D ) )
     {
         for( LIB_ITEM& drawItem : drawings )
         {
@@ -550,7 +550,7 @@ void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aD
         if( *i == aItem )
         {
             if( aDc != NULL )
-                aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR,
+                aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D,
                              g_XorMode, NULL, DefaultTransform );
 
             drawings.erase( i );
diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h
index 5237df5..c97d24a 100644
--- a/eeschema/class_libentry.h
+++ b/eeschema/class_libentry.h
@@ -427,7 +427,7 @@ public:
      */
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
                int aMulti, int aConvert, GR_DRAWMODE aDrawMode,
-               EDA_COLOR_T aColor = UNSPECIFIED_COLOR,
+               COLOR4D aColor = UNSPECIFIED_COLOR4D,
                const TRANSFORM& aTransform = DefaultTransform,
                bool aShowPinText = true, bool aDrawFields = true,
                bool aOnlySelected = false,
diff --git a/eeschema/class_sch_screen.h b/eeschema/class_sch_screen.h
index 43f07c0..74271cd 100644
--- a/eeschema/class_sch_screen.h
+++ b/eeschema/class_sch_screen.h
@@ -218,7 +218,7 @@ public:
      * @param aColor The drawing color.
      */
     void Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode,
-               EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
+               COLOR4D aColor = UNSPECIFIED_COLOR4D );
 
     /**
      * Function Plot
diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp
index 6401827..75ece13 100644
--- a/eeschema/dialogs/dialog_choose_component.cpp
+++ b/eeschema/dialogs/dialog_choose_component.cpp
@@ -347,9 +347,9 @@ void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUnit )
 
     GRResetPenAndBrush( &dc );
 
-    EDA_COLOR_T bgcolor = m_parent->GetDrawBgColor();
+    COLOR4D bgColor = m_parent->GetDrawBgColor();
 
-    dc.SetBackground( bgcolor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
+    dc.SetBackground( wxBrush( bgColor.ToColour() ) );
     dc.Clear();
 
     if( aComponent == NULL )
@@ -372,7 +372,7 @@ void DIALOG_CHOOSE_COMPONENT::renderPreview( LIB_PART* aComponent, int aUnit )
 
 
     aComponent->Draw( NULL, &dc, offset, aUnit, m_deMorganConvert, GR_COPY,
-                      UNSPECIFIED_COLOR, DefaultTransform, true, true, false );
+                      UNSPECIFIED_COLOR4D, DefaultTransform, true, true, false );
 }
 
 
diff --git a/eeschema/dialogs/dialog_lib_edit_pin.cpp b/eeschema/dialogs/dialog_lib_edit_pin.cpp
index 3da3c90..6cc2a9d 100644
--- a/eeschema/dialogs/dialog_lib_edit_pin.cpp
+++ b/eeschema/dialogs/dialog_lib_edit_pin.cpp
@@ -44,7 +44,7 @@ DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( EDA_DRAW_FRAME* parent, LIB_PIN* aPin
     m_dummyPin->SetParent( NULL );
     m_dummyPin->ClearFlags();
 
-    m_panelShowPin->SetBackgroundColour( MakeColour( parent->GetDrawBgColor() ) );
+    m_panelShowPin->SetBackgroundColour( parent->GetDrawBgColor().ToColour() );
 
     // Set tab order
     m_textPadName->MoveAfterInTabOrder(m_textPinName);
@@ -103,7 +103,7 @@ void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event )
     // This is a flag for m_dummyPin->Draw
     uintptr_t flags = uintptr_t( PIN_DRAW_TEXTS | PIN_DRAW_DANGLING );
 
-    m_dummyPin->Draw( NULL, &dc, offset, UNSPECIFIED_COLOR, GR_COPY,
+    m_dummyPin->Draw( NULL, &dc, offset, UNSPECIFIED_COLOR4D, GR_COPY,
                       (void*)flags, DefaultTransform );
 
     m_dummyPin->SetParent(NULL);
diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp
index f89b039..177e96f 100644
--- a/eeschema/dialogs/dialog_print_using_printer.cpp
+++ b/eeschema/dialogs/dialog_print_using_printer.cpp
@@ -455,7 +455,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
 
     aScreen->m_IsPrinting = true;
 
-    EDA_COLOR_T bg_color = m_parent->GetDrawBgColor();
+    COLOR4D bgColor = m_parent->GetDrawBgColor();
 
     aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 );
 
@@ -463,7 +463,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
         m_parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(),
                 IU_PER_MILS, aScreen->GetFileName() );
 
-    m_parent->SetDrawBgColor( bg_color );
+    m_parent->SetDrawBgColor( bgColor );
     aScreen->m_IsPrinting = false;
     panel->SetClipBox( oldClipBox );
 
diff --git a/eeschema/dialogs/dialog_rescue_each.cpp b/eeschema/dialogs/dialog_rescue_each.cpp
index 1aa9550..b340b4b 100644
--- a/eeschema/dialogs/dialog_rescue_each.cpp
+++ b/eeschema/dialogs/dialog_rescue_each.cpp
@@ -207,9 +207,9 @@ void DIALOG_RESCUE_EACH::OnDialogResize( wxSizeEvent& aSizeEvent )
 void DIALOG_RESCUE_EACH::renderPreview( LIB_PART* aComponent, int aUnit, wxPanel* aPanel )
 {
     wxPaintDC dc( aPanel );
-    EDA_COLOR_T bgcolor = m_Parent->GetDrawBgColor();
+    wxColour bgColor = m_Parent->GetDrawBgColor().ToColour();
 
-    dc.SetBackground( bgcolor == BLACK ? *wxBLACK_BRUSH : *wxWHITE_BRUSH );
+    dc.SetBackground( wxBrush( bgColor ) );
     dc.Clear();
 
     if( aComponent == NULL )
@@ -239,7 +239,7 @@ void DIALOG_RESCUE_EACH::renderPreview( LIB_PART* aComponent, int aUnit, wxPanel
         return;
 
     aComponent->Draw( NULL, &dc, offset, aUnit, /* deMorganConvert */ 1, GR_COPY,
-                      UNSPECIFIED_COLOR, DefaultTransform, true, true, false );
+                      UNSPECIFIED_COLOR4D, DefaultTransform, true, true, false );
 }
 
 
diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp
index 7f0899d..c2c25b9 100644
--- a/eeschema/eeredraw.cpp
+++ b/eeschema/eeredraw.cpp
@@ -34,7 +34,7 @@
 #include <general.h>
 
 
-void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, EDA_COLOR_T Color )
+void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, COLOR4D Color )
 {
     BASE_SCREEN* screen = panel->GetScreen();
 
diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp
index 2f05925..9280368 100644
--- a/eeschema/eeschema.cpp
+++ b/eeschema/eeschema.cpp
@@ -161,15 +161,15 @@ PGM_BASE& Pgm()
 }
 
 
-static EDA_COLOR_T s_layerColor[LAYERSCH_ID_COUNT];
+static COLOR4D s_layerColor[LAYERSCH_ID_COUNT];
 
-EDA_COLOR_T GetLayerColor( LAYERSCH_ID aLayer )
+COLOR4D GetLayerColor( LAYERSCH_ID aLayer )
 {
     wxASSERT( unsigned( aLayer ) < DIM( s_layerColor ) );
     return s_layerColor[aLayer];
 }
 
-void SetLayerColor( EDA_COLOR_T aColor, LAYERSCH_ID aLayer )
+void SetLayerColor( COLOR4D aColor, LAYERSCH_ID aLayer )
 {
     wxASSERT( unsigned( aLayer ) < DIM( s_layerColor ) );
     s_layerColor[aLayer] = aColor;
@@ -188,32 +188,32 @@ static PARAM_CFG_ARRAY& cfg_params()
 #define CLR(x, y, z)\
     ca.push_back( new PARAM_CFG_SETCOLOR( true, wxT( x ), &s_layerColor[y], z ) );
 
-        CLR( "ColorWireEx",             LAYER_WIRE,             GREEN )
-        CLR( "ColorBusEx",              LAYER_BUS,              BLUE )
-        CLR( "ColorConnEx",             LAYER_JUNCTION,         GREEN )
-        CLR( "ColorLLabelEx",           LAYER_LOCLABEL,         BLACK )
-        CLR( "ColorHLabelEx",           LAYER_HIERLABEL,        BROWN )
-        CLR( "ColorGLabelEx",           LAYER_GLOBLABEL,        RED )
-        CLR( "ColorPinNumEx",           LAYER_PINNUM,           RED )
-        CLR( "ColorPinNameEx",          LAYER_PINNAM,           CYAN )
-        CLR( "ColorFieldEx",            LAYER_FIELDS,           MAGENTA )
-        CLR( "ColorReferenceEx",        LAYER_REFERENCEPART,    CYAN )
-        CLR( "ColorValueEx",            LAYER_VALUEPART,        CYAN )
-        CLR( "ColorNoteEx",             LAYER_NOTES,            LIGHTBLUE )
-        CLR( "ColorBodyEx",             LAYER_DEVICE,           RED )
-        CLR( "ColorBodyBgEx",           LAYER_DEVICE_BACKGROUND,LIGHTYELLOW )
-        CLR( "ColorNetNameEx",          LAYER_NETNAM,           DARKGRAY )
-        CLR( "ColorPinEx",              LAYER_PIN,              RED )
-        CLR( "ColorSheetEx",            LAYER_SHEET,            MAGENTA )
-        CLR( "ColorSheetFileNameEx",    LAYER_SHEETFILENAME,    BROWN )
-        CLR( "ColorSheetNameEx",        LAYER_SHEETNAME,        CYAN )
-        CLR( "ColorSheetLabelEx",       LAYER_SHEETLABEL,       BROWN )
-        CLR( "ColorNoConnectEx",        LAYER_NOCONNECT,        BLUE )
-        CLR( "ColorErcWEx",             LAYER_ERC_WARN,         GREEN )
-        CLR( "ColorErcEEx",             LAYER_ERC_ERR,          RED )
-        CLR( "ColorGridEx",             LAYER_GRID,             DARKGRAY )
-        CLR( "ColorBgCanvasEx",         LAYER_BACKGROUND,       WHITE )
-        CLR( "ColorBrighenedEx",        LAYER_BRIGHTENED,       PUREMAGENTA )
+        CLR( "ColorWireEx",             LAYER_WIRE,              COLOR4D( GREEN ) )
+        CLR( "ColorBusEx",              LAYER_BUS,               COLOR4D( BLUE ) )
+        CLR( "ColorConnEx",             LAYER_JUNCTION,          COLOR4D( GREEN ) )
+        CLR( "ColorLLabelEx",           LAYER_LOCLABEL,          COLOR4D( BLACK ) )
+        CLR( "ColorHLabelEx",           LAYER_HIERLABEL,         COLOR4D( BROWN ) )
+        CLR( "ColorGLabelEx",           LAYER_GLOBLABEL,         COLOR4D( RED ) )
+        CLR( "ColorPinNumEx",           LAYER_PINNUM,            COLOR4D( RED ) )
+        CLR( "ColorPinNameEx",          LAYER_PINNAM,            COLOR4D( CYAN ) )
+        CLR( "ColorFieldEx",            LAYER_FIELDS,            COLOR4D( MAGENTA ) )
+        CLR( "ColorReferenceEx",        LAYER_REFERENCEPART,     COLOR4D( CYAN ) )
+        CLR( "ColorValueEx",            LAYER_VALUEPART,         COLOR4D( CYAN ) )
+        CLR( "ColorNoteEx",             LAYER_NOTES,             COLOR4D( LIGHTBLUE ) )
+        CLR( "ColorBodyEx",             LAYER_DEVICE,            COLOR4D( RED ) )
+        CLR( "ColorBodyBgEx",           LAYER_DEVICE_BACKGROUND, COLOR4D( LIGHTYELLOW ) )
+        CLR( "ColorNetNameEx",          LAYER_NETNAM,            COLOR4D( DARKGRAY ) )
+        CLR( "ColorPinEx",              LAYER_PIN,               COLOR4D( RED ) )
+        CLR( "ColorSheetEx",            LAYER_SHEET,             COLOR4D( MAGENTA ) )
+        CLR( "ColorSheetFileNameEx",    LAYER_SHEETFILENAME,     COLOR4D( BROWN ) )
+        CLR( "ColorSheetNameEx",        LAYER_SHEETNAME,         COLOR4D( CYAN ) )
+        CLR( "ColorSheetLabelEx",       LAYER_SHEETLABEL,        COLOR4D( BROWN ) )
+        CLR( "ColorNoConnectEx",        LAYER_NOCONNECT,         COLOR4D( BLUE ) )
+        CLR( "ColorErcWEx",             LAYER_ERC_WARN,          COLOR4D( GREEN ) )
+        CLR( "ColorErcEEx",             LAYER_ERC_ERR,           COLOR4D( RED ) )
+        CLR( "ColorGridEx",             LAYER_GRID,              COLOR4D( DARKGRAY ) )
+        CLR( "ColorBgCanvasEx",         LAYER_BACKGROUND,        COLOR4D( WHITE ) )
+        CLR( "ColorBrighenedEx",        LAYER_BRIGHTENED,        COLOR4D( PUREMAGENTA ) )
     }
 
     return ca;
@@ -231,9 +231,9 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
     // Give a default colour for all layers
     // (actual color will be initialized by config)
     for( LAYERSCH_ID ii = LAYER_FIRST; ii < LAYERSCH_ID_COUNT; ++ii )
-        SetLayerColor( DARKGRAY, ii );
+        SetLayerColor( COLOR4D( DARKGRAY ), ii );
 
-    SetLayerColor( WHITE, LAYER_BACKGROUND );
+    SetLayerColor( COLOR4D_WHITE, LAYER_BACKGROUND );
 
     // Must be called before creating the main frame in order to
     // display the real hotkeys in menus or tool tips
diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp
index 6282438..12d72f5 100644
--- a/eeschema/eeschema_config.cpp
+++ b/eeschema/eeschema_config.cpp
@@ -112,17 +112,17 @@ void SetDefaultLineThickness( int aThickness )
 
 
 // Color to draw selected items
-EDA_COLOR_T GetItemSelectedColor()
+COLOR4D GetItemSelectedColor()
 {
-    return BROWN;
+    return COLOR4D( BROWN );
 }
 
 
 // Color to draw items flagged invisible, in libedit (they are invisible
 // in Eeschema
-EDA_COLOR_T GetInvisibleItemColor()
+COLOR4D GetInvisibleItemColor()
 {
-    return DARKGRAY;
+    return COLOR4D( DARKGRAY );
 }
 
 
diff --git a/eeschema/general.h b/eeschema/general.h
index c2214ec..6a094dc 100644
--- a/eeschema/general.h
+++ b/eeschema/general.h
@@ -29,7 +29,9 @@
 #ifndef _GENERAL_H_
 #define _GENERAL_H_
 
-#include <colors.h>     // for EDA_COLOR_T
+#include <gal/color4d.h>
+
+using KIGFX::COLOR4D;
 
 class TRANSFORM;
 class SCH_SHEET;
@@ -138,13 +140,13 @@ void SetDefaultTextSize( int aSize );
 int GetDefaultBusThickness();
 void SetDefaultBusThickness( int aThickness );
 
-EDA_COLOR_T GetLayerColor( LAYERSCH_ID aLayer );
-void        SetLayerColor( EDA_COLOR_T aColor, LAYERSCH_ID aLayer );
+COLOR4D  GetLayerColor( LAYERSCH_ID aLayer );
+void     SetLayerColor( COLOR4D aColor, LAYERSCH_ID aLayer );
 
 // Color to draw selected items
-EDA_COLOR_T GetItemSelectedColor();
+COLOR4D GetItemSelectedColor();
 
 // Color to draw items flagged invisible, in libedit (they are invisible in Eeschema
-EDA_COLOR_T GetInvisibleItemColor();
+COLOR4D GetInvisibleItemColor();
 
 #endif    // _GENERAL_H_
diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp
index 68f52ef..0f6ec34 100644
--- a/eeschema/lib_arc.cpp
+++ b/eeschema/lib_arc.cpp
@@ -388,7 +388,7 @@ int LIB_ARC::GetPenSize() const
 }
 
 
-void LIB_ARC::drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor )
+void LIB_ARC::drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor )
 {
     // The edit indicators only get drawn when a new arc is being drawn.
     if( !IsNew() )
@@ -409,7 +409,7 @@ void LIB_ARC::drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColo
 
 
 void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                           EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                           COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                            const TRANSFORM& aTransform )
 {
     // Don't draw the arc until the end point is selected.  Only the edit indicators
@@ -418,9 +418,9 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
         return;
 
     wxPoint pos1, pos2, posc;
-    EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
+    COLOR4D color = GetLayerColor( LAYER_DEVICE );
 
-    if( aColor < 0 )       // Used normal color or selected color
+    if( aColor == UNSPECIFIED_COLOR4D )       // Used normal color or selected color
     {
         if( IsSelected() )
             color = GetItemSelectedColor();
@@ -447,7 +447,7 @@ void LIB_ARC::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
 
     FILL_T fill = aData ? NO_FILL : m_Fill;
 
-    if( aColor >= 0 )
+    if( aColor != UNSPECIFIED_COLOR4D )
         fill = NO_FILL;
 
     EDA_RECT* const clipbox  = aPanel? aPanel->GetClipBox() : NULL;
diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h
index a59fb03..a5ecbd2 100644
--- a/eeschema/lib_arc.h
+++ b/eeschema/lib_arc.h
@@ -61,13 +61,13 @@ class LIB_ARC : public LIB_ITEM
      * Draws the arc.
      */
     void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                      EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                      COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                       const TRANSFORM& aTransform ) override;
 
     /**
      * Draw the graphics when the arc is being edited.
      */
-    void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor ) override;
+    void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) override;
 
     /**
      * Calculates the center, radius, and angles at \a aPosition when the arc is being edited.
diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp
index 35c3187..5a0130f 100644
--- a/eeschema/lib_bezier.cpp
+++ b/eeschema/lib_bezier.cpp
@@ -285,12 +285,12 @@ int LIB_BEZIER::GetPenSize() const
 
 
 void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                              EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                              COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                               const TRANSFORM& aTransform )
 {
     std::vector<wxPoint> PolyPointsTraslated;
 
-    EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
+    COLOR4D color = GetLayerColor( LAYER_DEVICE );
 
     m_PolyPoints = Bezier2Poly( m_BezierPoints[0],
                                 m_BezierPoints[1],
@@ -303,7 +303,7 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
         PolyPointsTraslated.push_back( aTransform.TransformCoordinate( m_PolyPoints[i] ) +
                                        aOffset );
 
-    if( aColor < 0 )                // Used normal color or selected color
+    if( aColor == UNSPECIFIED_COLOR4D )                // Used normal color or selected color
     {
         if( IsSelected() )
             color = GetItemSelectedColor();
@@ -315,7 +315,7 @@ void LIB_BEZIER::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
 
     FILL_T fill = aData ? NO_FILL : m_Fill;
 
-    if( aColor >= 0 )
+    if( aColor != UNSPECIFIED_COLOR4D )
         fill = NO_FILL;
 
     GRSetDrawMode( aDC, aDrawMode );
diff --git a/eeschema/lib_bezier.h b/eeschema/lib_bezier.h
index 0d923af..850706b 100644
--- a/eeschema/lib_bezier.h
+++ b/eeschema/lib_bezier.h
@@ -43,7 +43,7 @@ class LIB_BEZIER : public LIB_ITEM
     std::vector<wxPoint> m_PolyPoints;     // list of points (>= 2)
 
     void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                      EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                      COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                       const TRANSFORM& aTransform ) override;
 
 public:
diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp
index bcf6a40..f45416d 100644
--- a/eeschema/lib_circle.cpp
+++ b/eeschema/lib_circle.cpp
@@ -207,14 +207,14 @@ int LIB_CIRCLE::GetPenSize() const
 
 
 void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                              EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                              COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                               const TRANSFORM& aTransform )
 {
     wxPoint pos1;
 
-    EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
+    COLOR4D color = GetLayerColor( LAYER_DEVICE );
 
-    if( aColor < 0 )       // Used normal color or selected color
+    if( aColor == UNSPECIFIED_COLOR4D )       // Used normal color or selected color
     {
         if( IsSelected() )
             color = GetItemSelectedColor();
@@ -228,7 +228,7 @@ void LIB_CIRCLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
     GRSetDrawMode( aDC, aDrawMode );
 
     FILL_T fill = aData ? NO_FILL : m_Fill;
-    if( aColor >= 0 )
+    if( aColor != UNSPECIFIED_COLOR4D )
         fill = NO_FILL;
 
     EDA_RECT* const clipbox  = aPanel? aPanel->GetClipBox() : NULL;
diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h
index 0dab47e..c54b71e 100644
--- a/eeschema/lib_circle.h
+++ b/eeschema/lib_circle.h
@@ -39,7 +39,7 @@ class LIB_CIRCLE : public LIB_ITEM
     int     m_Width;          // Line width.
 
     void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                      EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                      COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                       const TRANSFORM& aTransform ) override;
 
     void calcEdit( const wxPoint& aPosition ) override;
diff --git a/eeschema/lib_draw_item.cpp b/eeschema/lib_draw_item.cpp
index 00a0a77..c9e16b0 100644
--- a/eeschema/lib_draw_item.cpp
+++ b/eeschema/lib_draw_item.cpp
@@ -115,7 +115,7 @@ bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const
 
 
 void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
-                     const wxPoint& aOffset, EDA_COLOR_T aColor,
+                     const wxPoint& aOffset, COLOR4D aColor,
                      GR_DRAWMODE aDrawMode, void* aData,
                      const TRANSFORM& aTransform )
 {
@@ -123,7 +123,7 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
     {
         // Temporarily disable filling while the item is being edited.
         FILL_T fillMode = m_Fill;
-        EDA_COLOR_T color = GetDefaultColor();
+        COLOR4D color = GetDefaultColor();
 
         m_Fill = NO_FILL;
 
@@ -154,7 +154,7 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
 }
 
 
-EDA_COLOR_T LIB_ITEM::GetDefaultColor()
+COLOR4D LIB_ITEM::GetDefaultColor()
 {
     return GetLayerColor( LAYER_DEVICE );
 }
diff --git a/eeschema/lib_draw_item.h b/eeschema/lib_draw_item.h
index bb4f6c0..da6721a 100644
--- a/eeschema/lib_draw_item.h
+++ b/eeschema/lib_draw_item.h
@@ -84,14 +84,14 @@ class LIB_ITEM : public EDA_ITEM
      * @param aDC A pointer to the device context used to draw the object.
      * @param aOffset A reference to a wxPoint object containing the offset where to draw
      *                from the object's current position.
-     * @param aColor An #EDA_COLOR_T to draw the object or -1 to draw the object in it's
-     *               default color.
+     * @param aColor A COLOR4D to draw the object or UNSPECIFIED_COLOR4D to draw
+     *               the object in it's default color.
      * @param aDrawMode The mode used to perform the draw (#GR_OR, #GR_COPY, etc.).
      * @param aData A pointer to any object specific data required to perform the draw.
      * @param aTransform A reference to a #TRANSFORM object containing drawing transform.
      */
     virtual void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
-                              const wxPoint& aOffset, EDA_COLOR_T aColor,
+                              const wxPoint& aOffset, COLOR4D aColor,
                               GR_DRAWMODE aDrawMode, void* aData,
                               const TRANSFORM& aTransform ) = 0;
 
@@ -100,9 +100,9 @@ class LIB_ITEM : public EDA_ITEM
      *
      * @param aClipBox Clip box of the current device context.
      * @param aDC The device context to draw on.
-     * @param aColor The index of the color to draw.
+     * @param aColor Draw color
      */
-    virtual void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor ) {}
+    virtual void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) {}
 
     /**
      * Calculates the attributes of an item at \a aPosition when it is being edited.
@@ -207,7 +207,7 @@ public:
      * @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes.
      * @param aDC Device Context (can be null)
      * @param aOffset Offset to draw
-     * @param aColor -1 to use the normal body item color, or use this color if >= 0
+     * @param aColor Draw color, or UNSPECIFIED_COLOR4D to use the normal body item color
      * @param aDrawMode GR_OR, GR_XOR, ...
      * @param aData Value or pointer used to pass others parameters, depending on body items.
      *              Used for some items to force to force no fill mode ( has meaning only for
@@ -216,7 +216,7 @@ public:
      * @param aTransform Transform Matrix (rotation, mirror ..)
      */
     virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint &aOffset,
-                       EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                       COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                        const TRANSFORM& aTransform );
 
     /**
@@ -405,7 +405,7 @@ public:
 
     void SetEraseLastDrawItem( bool aErase = true ) { m_eraseLastDrawItem = aErase; }
 
-    virtual EDA_COLOR_T GetDefaultColor();
+    virtual COLOR4D GetDefaultColor();
 
     void SetUnit( int aUnit ) { m_Unit = aUnit; }
 
diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp
index a443203..65ac252 100644
--- a/eeschema/lib_field.cpp
+++ b/eeschema/lib_field.cpp
@@ -286,11 +286,11 @@ int LIB_FIELD::GetPenSize() const
 
 
 void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                             EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                             COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                              const TRANSFORM& aTransform )
 {
     wxPoint  text_pos;
-    int      color;
+    COLOR4D color = UNSPECIFIED_COLOR4D;
     int      linewidth = GetPenSize();
 
     if( IsBold() )
@@ -298,11 +298,11 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
     else
         linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
 
-    if( !IsVisible() &&  aColor < 0 )
+    if( !IsVisible() && ( aColor == UNSPECIFIED_COLOR4D ) )
     {
         color = GetInvisibleItemColor();
     }
-    else if( IsSelected() &&  aColor < 0 )
+    else if( IsSelected() && ( aColor == UNSPECIFIED_COLOR4D) )
     {
         color = GetItemSelectedColor();
     }
@@ -311,7 +311,7 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
         color = aColor;
     }
 
-    if( color < 0 )
+    if( color == UNSPECIFIED_COLOR4D )
         color = GetDefaultColor();
 
     text_pos = aTransform.TransformCoordinate( GetTextPos() ) + aOffset;
@@ -325,7 +325,8 @@ void LIB_FIELD::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a
 
     GRSetDrawMode( aDC, aDrawMode );
     EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
-    DrawGraphicText( clipbox, aDC, text_pos, (EDA_COLOR_T) color, text,
+
+    DrawGraphicText( clipbox, aDC, text_pos, color, text,
                      GetTextAngle(), GetTextSize(),
                      GetHorizJustify(), GetVertJustify(),
                      linewidth, IsItalic(), IsBold() );
@@ -568,9 +569,9 @@ const EDA_RECT LIB_FIELD::GetBoundingBox() const
 }
 
 
-EDA_COLOR_T LIB_FIELD::GetDefaultColor()
+COLOR4D LIB_FIELD::GetDefaultColor()
 {
-    EDA_COLOR_T color;
+    COLOR4D color;
 
     switch( m_id )
     {
diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h
index 0715e98..6723e61 100644
--- a/eeschema/lib_field.h
+++ b/eeschema/lib_field.h
@@ -74,7 +74,7 @@ class LIB_FIELD : public LIB_ITEM, public EDA_TEXT
      * </p>
      */
     void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                      EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                      COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                       const TRANSFORM& aTransform ) override;
 
     /**
@@ -191,7 +191,7 @@ public:
      */
     wxString GetFullText( int unit = 1 ) const;
 
-    EDA_COLOR_T GetDefaultColor() override;
+    COLOR4D GetDefaultColor() override;
 
     void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
 
diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp
index ff13462..03171b1 100644
--- a/eeschema/lib_pin.cpp
+++ b/eeschema/lib_pin.cpp
@@ -905,7 +905,7 @@ int LIB_PIN::GetPenSize() const
 void LIB_PIN::drawGraphic( EDA_DRAW_PANEL*  aPanel,
                            wxDC*            aDC,
                            const wxPoint&   aOffset,
-                           EDA_COLOR_T      aColor,
+                           COLOR4D          aColor,
                            GR_DRAWMODE      aDrawMode,
                            void*            aData,
                            const TRANSFORM& aTransform )
@@ -982,7 +982,7 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
                              const wxPoint&  aPinPos,
                              int             aOrient,
                              GR_DRAWMODE     aDrawMode,
-                             EDA_COLOR_T     aColor,
+                             COLOR4D         aColor,
                              bool            aDrawDangling,
                              bool            aOnlyTarget )
 {
@@ -991,9 +991,9 @@ void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel,
     int       posX    = aPinPos.x, posY = aPinPos.y, len = m_length;
     EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
 
-    EDA_COLOR_T color = GetLayerColor( LAYER_PIN );
+    COLOR4D color = GetLayerColor( LAYER_PIN );
 
-    if( aColor < 0 )       // Used normal color or selected color
+    if( aColor == UNSPECIFIED_COLOR4D )       // Used normal color or selected color
     {
         if( IsSelected() )
             color = GetItemSelectedColor();
@@ -1183,7 +1183,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
                             int             TextInside,
                             bool            DrawPinNum,
                             bool            DrawPinName,
-                            EDA_COLOR_T     Color,
+                            COLOR4D         Color,
                             GR_DRAWMODE     DrawMode )
 {
     if( !DrawPinName && !DrawPinNum )
@@ -1210,13 +1210,13 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
     EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
 
     /* Get the num and name colors */
-    if( (Color < 0) && IsSelected() )
+    if( ( Color == UNSPECIFIED_COLOR4D ) && IsSelected() )
         Color = GetItemSelectedColor();
 
-    EDA_COLOR_T NameColor = Color == UNSPECIFIED_COLOR ?
-                                GetLayerColor( LAYER_PINNAM ) : Color;
-    EDA_COLOR_T NumColor  = Color == UNSPECIFIED_COLOR ?
-                                GetLayerColor( LAYER_PINNUM ) : Color;
+    COLOR4D NameColor = Color == UNSPECIFIED_COLOR4D ?
+                            GetLayerColor( LAYER_PINNAM ) : Color;
+    COLOR4D NumColor  = Color == UNSPECIFIED_COLOR4D ?
+                            GetLayerColor( LAYER_PINNUM ) : Color;
 
     /* Create the pin num string */
     PinStringNum( StringPinNum );
@@ -1396,7 +1396,7 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel,
 
 void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
                                          wxPoint& aPosition, int aOrientation,
-                                         EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode )
+                                         COLOR4D aColor, GR_DRAWMODE aDrawMode )
 {
     wxString    etypeName = GetElectricalTypeName();
 
@@ -1411,7 +1411,7 @@ void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
     int pensize = etextSize/6;
 
     // Get a suitable color
-    if( (aColor < 0) && IsSelected() )
+    if( ( aColor == UNSPECIFIED_COLOR4D ) && IsSelected() )
         aColor = GetItemSelectedColor();
     else if( !IsVisible() )
         aColor = GetInvisibleItemColor();
@@ -1459,7 +1459,7 @@ void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
 void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
 {
     int         MapX1, MapY1, x1, y1;
-    EDA_COLOR_T color = GetLayerColor( LAYER_PIN );
+    COLOR4D     color = GetLayerColor( LAYER_PIN );
 
     aPlotter->SetColor( color );
     aPlotter->SetCurrentLineWidth( GetPenSize() );
@@ -1639,8 +1639,8 @@ void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int  orient,
                          ( numLineWidth + GetDefaultLineThickness() ) / 2;
 
     /* Get the num and name colors */
-    EDA_COLOR_T NameColor = GetLayerColor( LAYER_PINNAM );
-    EDA_COLOR_T NumColor  = GetLayerColor( LAYER_PINNUM );
+    COLOR4D NameColor = GetLayerColor( LAYER_PINNAM );
+    COLOR4D NumColor  = GetLayerColor( LAYER_PINNUM );
 
     int x1 = pin_pos.x;
     int y1 = pin_pos.y;
diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h
index f7fba3a..4f871e0 100644
--- a/eeschema/lib_pin.h
+++ b/eeschema/lib_pin.h
@@ -85,7 +85,7 @@ class LIB_PIN : public LIB_ITEM
      * @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes.
      * @param aDC Device Context (can be null)
      * @param aOffset Offset to draw
-     * @param aColor -1 to use the normal body item color, or use this color if >= 0
+     * @param aColor UNSPECIFIED_COLOR4D to use the normal body item color, or else use this color
      * @param aDrawMode GR_OR, GR_XOR, ...
      * @param aData = used here as uintptr_t containing bitwise OR'd flags:
      *      PIN_DRAW_TEXTS,     -- false to draw only pin shape, useful for fast mode
@@ -95,7 +95,7 @@ class LIB_PIN : public LIB_ITEM
      * @param aTransform Transform Matrix (rotation, mirror ..)
      */
     void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                      EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                      COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                       const TRANSFORM& aTransform ) override;
 
 public:
@@ -385,7 +385,7 @@ public:
      */
     void DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
                         int aOrientation, GR_DRAWMODE aDrawMode,
-                        EDA_COLOR_T aColor = UNSPECIFIED_COLOR,
+                        COLOR4D aColor = UNSPECIFIED_COLOR4D,
                         bool aDrawDangling = true,
                         bool aOnlyTarget = false );
 
@@ -401,7 +401,7 @@ public:
      */
     void DrawPinTexts( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition,
                        int aOrientation, int TextInside, bool DrawPinNum, bool DrawPinName,
-                       EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode );
+                       COLOR4D aColor, GR_DRAWMODE aDrawMode );
 
     /**
      * Function DrawPinElectricalTypeName
@@ -409,7 +409,7 @@ public:
      * aDrawMode = GR_OR, XOR ...
      */
     void DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition,
-                       int aOrientation, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode );
+                       int aOrientation, COLOR4D aColor, GR_DRAWMODE aDrawMode );
 
     /**
      * Function PlotPinTexts
diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp
index b568956..713d22e 100644
--- a/eeschema/lib_polyline.cpp
+++ b/eeschema/lib_polyline.cpp
@@ -262,14 +262,14 @@ int LIB_POLYLINE::GetPenSize() const
 
 
 void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                                EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                                COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                                 const TRANSFORM& aTransform )
 {
     wxPoint  pos1;
-    EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
+    COLOR4D color = GetLayerColor( LAYER_DEVICE );
     wxPoint* buffer = NULL;
 
-    if( aColor < 0 )                // Used normal color or selected color
+    if( aColor == UNSPECIFIED_COLOR4D )                // Used normal color or selected color
     {
         if( IsSelected() )
             color = GetItemSelectedColor();
@@ -288,7 +288,7 @@ void LIB_POLYLINE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint
 
     FILL_T fill = aData ? NO_FILL : m_Fill;
 
-    if( aColor >= 0 )
+    if( aColor != UNSPECIFIED_COLOR4D )
         fill = NO_FILL;
 
     GRSetDrawMode( aDC, aDrawMode );
diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h
index 5b137a0..c3cc42c 100644
--- a/eeschema/lib_polyline.h
+++ b/eeschema/lib_polyline.h
@@ -40,7 +40,7 @@ class LIB_POLYLINE : public LIB_ITEM
     int m_ModifyIndex;                        // Index of the polyline point to modify
 
     void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                      EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                      COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                       const TRANSFORM& aTransform ) override;
 
     void calcEdit( const wxPoint& aPosition ) override;
diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp
index 74a1987..ac44384 100644
--- a/eeschema/lib_rectangle.cpp
+++ b/eeschema/lib_rectangle.cpp
@@ -195,14 +195,14 @@ int LIB_RECTANGLE::GetPenSize() const
 
 
 void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
-                                 const wxPoint& aOffset, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode,
+                                 const wxPoint& aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode,
                                  void* aData, const TRANSFORM& aTransform )
 {
     wxPoint pos1, pos2;
 
-    EDA_COLOR_T color = GetLayerColor( LAYER_DEVICE );
+    COLOR4D color = GetLayerColor( LAYER_DEVICE );
 
-    if( aColor < 0 )       // Used normal color or selected color
+    if( aColor == UNSPECIFIED_COLOR4D )       // Used normal color or selected color
     {
         if( IsSelected() )
             color = GetItemSelectedColor();
@@ -217,7 +217,7 @@ void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
 
     FILL_T fill = aData ? NO_FILL : m_Fill;
 
-    if( aColor >= 0 )
+    if( aColor != UNSPECIFIED_COLOR4D )
         fill = NO_FILL;
 
     GRSetDrawMode( aDC, aDrawMode );
diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h
index 8e549d2..38dd32e 100644
--- a/eeschema/lib_rectangle.h
+++ b/eeschema/lib_rectangle.h
@@ -42,7 +42,7 @@ class LIB_RECTANGLE  : public LIB_ITEM
     bool    m_isStartPointSelected; // Flag: is the upper left edge selected?
 
     void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                      EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                      COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                       const TRANSFORM& aTransform ) override;
 
     void calcEdit( const wxPoint& aPosition ) override;
diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp
index a60c2bb..36cb385 100644
--- a/eeschema/lib_text.cpp
+++ b/eeschema/lib_text.cpp
@@ -333,12 +333,12 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
     wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset;
 
     // Get color
-    EDA_COLOR_T     color;
+    COLOR4D color;
 
     if( plotter->GetColorMode() )       // Used normal color or selected color
         color = IsSelected() ? GetItemSelectedColor() : GetDefaultColor();
     else
-        color = BLACK;
+        color = COLOR4D_BLACK;
 
     plotter->Text( pos, color, GetShownText(),
                    t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT,
@@ -366,12 +366,12 @@ int LIB_TEXT::GetPenSize() const
 
 
 void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                            EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                            COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                             const TRANSFORM& aTransform )
 {
-    EDA_COLOR_T color = GetDefaultColor();
+    COLOR4D color = GetDefaultColor();
 
-    if( aColor < 0 )       // Used normal color or selected color
+    if( aColor == UNSPECIFIED_COLOR4D )       // Used normal color or selected color
     {
         if( IsSelected() )
             color = GetItemSelectedColor();
diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h
index dd389ea..0de5c58 100644
--- a/eeschema/lib_text.h
+++ b/eeschema/lib_text.h
@@ -49,7 +49,7 @@ class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
     bool m_updateText;            ///< Flag to indicate text change occurred while editing.
 
     void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                      EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
+                      COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
                       const TRANSFORM& aTransform ) override;
 
     void calcEdit( const wxPoint& aPosition ) override;
diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp
index a11283d..78f496a 100644
--- a/eeschema/libedit.cpp
+++ b/eeschema/libedit.cpp
@@ -254,7 +254,7 @@ void LIB_EDIT_FRAME::RedrawComponent( wxDC* aDC, wxPoint aOffset  )
 
         field->EDA_TEXT::SetText( fieldfullText );  // change the field text string only
         part->Draw( m_canvas, aDC, aOffset, m_unit, m_convert, GR_DEFAULT_DRAWMODE,
-                    UNSPECIFIED_COLOR, DefaultTransform,
+                    UNSPECIFIED_COLOR4D, DefaultTransform,
                     true, true,false, NULL, GetShowElectricalType() );
         field->EDA_TEXT::SetText( fieldText );      // restore the field text string
     }
diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp
index 7f0fcc8..0111852 100644
--- a/eeschema/libeditframe.cpp
+++ b/eeschema/libeditframe.cpp
@@ -801,10 +801,10 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
             m_canvas->MoveCursorToCrossHair();
             STATUS_FLAGS oldFlags = m_drawItem->GetFlags();
             m_drawItem->ClearFlags();
-            m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL,
+            m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, g_XorMode, NULL,
                               DefaultTransform );
             ( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetCrossHairPosition( true ) );
-            m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL,
+            m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, g_XorMode, NULL,
                               DefaultTransform );
             m_drawItem->SetFlags( oldFlags );
             m_lastDrawItem = NULL;
@@ -1048,7 +1048,7 @@ void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem )
 
     // Deleting old text
     if( DC && !DrawItem->InEditMode() )
-        DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL,
+        DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, g_XorMode, NULL,
                         DefaultTransform );
 
     DIALOG_LIB_EDIT_TEXT* frame = new DIALOG_LIB_EDIT_TEXT( this, (LIB_TEXT*) DrawItem );
@@ -1058,7 +1058,7 @@ void LIB_EDIT_FRAME::EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem )
 
     // Display new text
     if( DC && !DrawItem->InEditMode() )
-        DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_DEFAULT_DRAWMODE, NULL,
+        DrawItem->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, GR_DEFAULT_DRAWMODE, NULL,
                         DefaultTransform );
 }
 
diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp
index ef97672..3eb01d3 100644
--- a/eeschema/pinedit.cpp
+++ b/eeschema/pinedit.cpp
@@ -400,13 +400,13 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi
     if( aErase )
     {
         cur_pin->Move( PinPreviousPos );
-        cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
+        cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, g_XorMode,
                           showOptions, DefaultTransform );
     }
 
     // Redraw pin in new position
     cur_pin->Move( aPanel->GetParent()->GetCrossHairPosition( true ) );
-    cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode,
+    cur_pin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, g_XorMode,
                    showOptions, DefaultTransform );
 
     PinPreviousPos = cur_pin->GetPosition();
@@ -480,7 +480,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
             // Build it:
             void* showOptions = reinterpret_cast<void*>( show_opts );
 
-            pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_COPY,
+            pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR4D, GR_COPY,
                        showOptions, DefaultTransform );
         }
 
diff --git a/eeschema/protos.h b/eeschema/protos.h
index ae3cf1d..441c36d 100644
--- a/eeschema/protos.h
+++ b/eeschema/protos.h
@@ -26,8 +26,6 @@
 #ifndef __PROTOS_H__
 #define __PROTOS_H__
 
-#include <colors.h>
-
 class EDA_DRAW_PANEL;
 class PICKED_ITEMS_LIST;
 class SCH_ITEM;
@@ -52,7 +50,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct, bool aClone = false );
 /* EEREDRAW.CPP */
 /****************/
 void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC,
-                         const wxPoint& pos, EDA_COLOR_T Color );
+                         const wxPoint& pos, COLOR4D Color );
 
 
 #endif  /* __PROTOS_H__ */
diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp
index 52898e8..bd434c1 100644
--- a/eeschema/sch_base_frame.cpp
+++ b/eeschema/sch_base_frame.cpp
@@ -63,12 +63,12 @@ void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
 }
 
 // Virtual from EDA_DRAW_FRAME
-EDA_COLOR_T SCH_BASE_FRAME::GetDrawBgColor() const
+COLOR4D SCH_BASE_FRAME::GetDrawBgColor() const
 {
     return GetLayerColor( LAYER_BACKGROUND );
 }
 
-void SCH_BASE_FRAME::SetDrawBgColor( EDA_COLOR_T aColor)
+void SCH_BASE_FRAME::SetDrawBgColor( COLOR4D aColor)
 {
     m_drawBgColor= aColor;
     SetLayerColor( aColor, LAYER_BACKGROUND );
diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h
index 2f96696..b5a5acc 100644
--- a/eeschema/sch_base_frame.h
+++ b/eeschema/sch_base_frame.h
@@ -114,8 +114,8 @@ public:
 
     // Virtual from EDA_DRAW_FRAME
     // the background color of the draw canvas:
-    EDA_COLOR_T GetDrawBgColor() const override;
-    void SetDrawBgColor( EDA_COLOR_T aColor) override;
+    COLOR4D GetDrawBgColor() const override;
+    void SetDrawBgColor( COLOR4D aColor) override;
 
     const TITLE_BLOCK& GetTitleBlock() const override;
     void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp
index 44e0a52..1398378 100644
--- a/eeschema/sch_bitmap.cpp
+++ b/eeschema/sch_bitmap.cpp
@@ -189,11 +189,11 @@ const EDA_RECT SCH_BITMAP::GetBoundingBox() const
 
 
 void SCH_BITMAP::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                       GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+                       GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
     wxPoint pos = m_pos + aOffset;
 
-    if( aColor < 0 )    // Use normal drawing function
+    if( aColor == UNSPECIFIED_COLOR4D )    // Use normal drawing function
     {
         // https://bugs.launchpad.net/kicad/+bug/1529163
         // "Moving images in eeschema on OS X uses
diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h
index e92b9dc..8f810e7 100644
--- a/eeschema/sch_bitmap.h
+++ b/eeschema/sch_bitmap.h
@@ -99,7 +99,7 @@ public:
     void SwapData( SCH_ITEM* aItem ) override;
 
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-               GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     /**
      * Function ReadImageFile
diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp
index 07749cc..7cc39c9 100644
--- a/eeschema/sch_bus_entry.cpp
+++ b/eeschema/sch_bus_entry.cpp
@@ -181,12 +181,12 @@ int SCH_BUS_BUS_ENTRY::GetPenSize() const
 
 
 void SCH_BUS_ENTRY_BASE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                          GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+                          GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
-    EDA_COLOR_T color;
+    COLOR4D color;
     EDA_RECT* clipbox = aPanel->GetClipBox();
 
-    if( aColor >= 0 )
+    if( aColor != UNSPECIFIED_COLOR4D )
         color = aColor;
     else
         color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h
index 678762c..4553243 100644
--- a/eeschema/sch_bus_entry.h
+++ b/eeschema/sch_bus_entry.h
@@ -83,7 +83,7 @@ public:
     void SwapData( SCH_ITEM* aItem ) override;
 
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-               GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     static bool Load( LINE_READER& aLine, wxString& aErrorMsg, SCH_ITEM **out );
 
diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp
index 1ea194b..1fb6de1 100644
--- a/eeschema/sch_component.cpp
+++ b/eeschema/sch_component.cpp
@@ -346,7 +346,7 @@ int SCH_COMPONENT::GetUnitCount() const
 
 
 void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                          GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor,
+                          GR_DRAWMODE aDrawMode, COLOR4D aColor,
                           bool aDrawPinText )
 {
     if( PART_SPTR part = m_part.lock() )
diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h
index 9d94bba..9a89bee 100644
--- a/eeschema/sch_component.h
+++ b/eeschema/sch_component.h
@@ -379,7 +379,7 @@ public:
      * Virtual function, from the base class SCH_ITEM::Draw
      */
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-               GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override
+               GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override
     {
         Draw( aPanel, aDC, aOffset, aDrawMode, aColor, true );
     }
@@ -392,12 +392,12 @@ public:
      * @param aOffset drawing Offset (usually wxPoint(0,0),
      *  but can be different when moving an object)
      * @param aDrawMode GR_OR, GR_XOR, ...
-     * @param aColor UNSPECIFIED_COLOR to use the normal body item color, or use this color if >= 0
+     * @param aColor UNSPECIFIED_COLOR4D to use the normal body item color, or use this color if >= 0
      * @param aDrawPinText = true to draw pin texts, false to draw only the pin shape
      *  usually false to draw a component when moving it, and true otherwise.
      */
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-               GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor,
+               GR_DRAWMODE aDrawMode, COLOR4D aColor,
                bool aDrawPinText );
 
     void SwapData( SCH_ITEM* aItem ) override;
diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp
index 32d2fc4..58fa333 100644
--- a/eeschema/sch_field.cpp
+++ b/eeschema/sch_field.cpp
@@ -115,10 +115,10 @@ int SCH_FIELD::GetPenSize() const
 
 
 void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                      GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+                      GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
     int            orient;
-    EDA_COLOR_T    color;
+    COLOR4D        color;
     wxPoint        textpos;
     SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent;
     int            lineWidth = GetThickness();
@@ -166,7 +166,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
 
     if( m_forceVisible )
     {
-        color = DARKGRAY;
+        color = COLOR4D( DARKGRAY );
     }
     else
     {
@@ -533,7 +533,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter )
     wxCHECK_RET( parent != NULL && parent->Type() == SCH_COMPONENT_T,
                  wxT( "Cannot plot field with invalid parent." ) );
 
-    EDA_COLOR_T color = GetLayerColor( GetLayer() );
+    COLOR4D color = GetLayerColor( GetLayer() );
 
     if( !IsVisible() )
         return;
diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h
index d467390..0a94046 100644
--- a/eeschema/sch_field.h
+++ b/eeschema/sch_field.h
@@ -141,7 +141,7 @@ public:
     int GetPenSize() const override;
 
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-               GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     bool Save( FILE* aFile ) const override;
 
diff --git a/eeschema/sch_item_struct.h b/eeschema/sch_item_struct.h
index 10e083d..64484ea 100644
--- a/eeschema/sch_item_struct.h
+++ b/eeschema/sch_item_struct.h
@@ -184,11 +184,11 @@ public:
      * @param aOffset drawing Offset (usually wxPoint(0,0),
      *  but can be different when moving an object)
      * @param aDrawMode GR_OR, GR_XOR, ...
-     * @param aColor UNSPECIFIED_COLOR to use the normal body item color,
+     * @param aColor UNSPECIFIED_COLOR4D to use the normal body item color,
      * or force this color if it is a valid color
      */
     virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&  aOffset,
-                       GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) = 0;
+                       GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) = 0;
 
     /**
      * Function Move
diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp
index a0b7efc..c799fa1 100644
--- a/eeschema/sch_junction.cpp
+++ b/eeschema/sch_junction.cpp
@@ -110,11 +110,11 @@ const EDA_RECT SCH_JUNCTION::GetBoundingBox() const
 
 
 void SCH_JUNCTION::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                         GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+                         GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
-    EDA_COLOR_T color;
+    COLOR4D color;
 
-    if( aColor >= 0 )
+    if( aColor != UNSPECIFIED_COLOR4D )
         color = aColor;
     else
         color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h
index 6fbb1f8..51ae550 100644
--- a/eeschema/sch_junction.h
+++ b/eeschema/sch_junction.h
@@ -58,7 +58,7 @@ public:
     const EDA_RECT GetBoundingBox() const override;
 
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-               GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     bool Save( FILE* aFile ) const override;
 
diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp
index e3f21bf..05eb395 100644
--- a/eeschema/sch_line.cpp
+++ b/eeschema/sch_line.cpp
@@ -212,12 +212,12 @@ int SCH_LINE::GetPenSize() const
 
 
 void SCH_LINE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
-                     GR_DRAWMODE DrawMode, EDA_COLOR_T Color )
+                     GR_DRAWMODE DrawMode, COLOR4D Color )
 {
-    EDA_COLOR_T color;
+    COLOR4D color;
     int width = GetPenSize();
 
-    if( Color >= 0 )
+    if( Color != UNSPECIFIED_COLOR4D )
         color = Color;
     else
         color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h
index 9c4937b..f1cb8c7 100644
--- a/eeschema/sch_line.h
+++ b/eeschema/sch_line.h
@@ -85,7 +85,7 @@ public:
     double GetLength() const;
 
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-               GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     bool Save( FILE* aFile ) const override;
 
diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp
index 334d277..615c671 100644
--- a/eeschema/sch_marker.cpp
+++ b/eeschema/sch_marker.cpp
@@ -84,10 +84,10 @@ bool SCH_MARKER::Save( FILE* aFile ) const
 
 
 void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
-                       const wxPoint& aOffset, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+                       const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
-    EDA_COLOR_T color = m_Color;
-    EDA_COLOR_T tmp   = color;
+    COLOR4D color = m_Color;
+    COLOR4D tmp   = color;
 
     if( GetMarkerType() == MARKER_BASE::MARKER_ERC )
     {
@@ -95,7 +95,7 @@ void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
                   GetLayerColor( LAYER_ERC_ERR ) : GetLayerColor( LAYER_ERC_WARN );
     }
 
-    if( aColor < 0 )
+    if( aColor == UNSPECIFIED_COLOR4D )
         m_Color = color;
     else
         m_Color = aColor;
diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h
index 08da741..4e81bdc 100644
--- a/eeschema/sch_marker.h
+++ b/eeschema/sch_marker.h
@@ -53,7 +53,7 @@ public:
     }
 
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-               GR_DRAWMODE aDraw_mode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE aDraw_mode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     void Plot( PLOTTER* aPlotter ) override
     {
diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp
index dd1e978..ee0e9ab 100644
--- a/eeschema/sch_no_connect.cpp
+++ b/eeschema/sch_no_connect.cpp
@@ -127,7 +127,7 @@ int SCH_NO_CONNECT::GetPenSize() const
 
 
 void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-                           GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+                           GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
     int pX, pY;
     int delta = m_size.x / 2;
@@ -136,8 +136,8 @@ void SCH_NO_CONNECT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOf
     pX = m_pos.x + aOffset.x;
     pY = m_pos.y + aOffset.y;
 
-    EDA_COLOR_T color;
-    if( aColor >= 0 )
+    COLOR4D color;
+    if( aColor != UNSPECIFIED_COLOR4D )
         color = aColor;
     else
         color = GetLayerColor( LAYER_NOCONNECT );
diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h
index ca83720..775f425 100644
--- a/eeschema/sch_no_connect.h
+++ b/eeschema/sch_no_connect.h
@@ -56,7 +56,7 @@ public:
     void SwapData( SCH_ITEM* aItem ) override;
 
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-               GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     bool Save( FILE* aFile ) const override;
 
diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp
index 113da38..9b68862 100644
--- a/eeschema/sch_screen.cpp
+++ b/eeschema/sch_screen.cpp
@@ -558,7 +558,7 @@ void SCH_SCREEN::CheckComponentsToPartsLinks()
 }
 
 
-void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
     /* note: SCH_SCREEN::Draw is useful only for schematic.
      * library editor and library viewer do not use m_drawList, and therefore
@@ -927,7 +927,9 @@ bool SCH_SCREEN::TestDanglingEnds()
     for( item = m_drawList.begin(); item; item = item->Next() )
     {
         if( item->IsDanglingStateChanged( endPoints ) )
+        {
             hasStateChanged = true;
+        }
     }
 
     return hasStateChanged;
diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp
index dc3ece8..1e6ed1c 100644
--- a/eeschema/sch_sheet.cpp
+++ b/eeschema/sch_sheet.cpp
@@ -581,18 +581,18 @@ wxPoint SCH_SHEET::GetFileNamePosition()
 
 
 void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
-                      const wxPoint& aOffset, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
+                      const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor )
 {
-    EDA_COLOR_T txtcolor;
+    COLOR4D txtcolor;
     wxString Text;
-    EDA_COLOR_T color;
+    COLOR4D color;
     int      name_orientation;
     wxPoint  pos_sheetname,pos_filename;
     wxPoint  pos = m_pos + aOffset;
     int      lineWidth = GetPenSize();
     EDA_RECT* clipbox  = aPanel? aPanel->GetClipBox() : NULL;
 
-    if( aColor >= 0 )
+    if( aColor != UNSPECIFIED_COLOR4D )
         color = aColor;
     else
         color = GetLayerColor( m_Layer );
@@ -611,7 +611,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
         name_orientation = TEXT_ANGLE_HORIZ;
 
     /* Draw text : SheetName */
-    if( aColor > 0 )
+    if( aColor != UNSPECIFIED_COLOR4D )
         txtcolor = aColor;
     else
         txtcolor = GetLayerColor( LAYER_SHEETNAME );
@@ -624,7 +624,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
                      false, false );
 
     /* Draw text : FileName */
-    if( aColor >= 0 )
+    if( aColor != UNSPECIFIED_COLOR4D )
         txtcolor = aColor;
     else
         txtcolor = GetLayerColor( LAYER_SHEETFILENAME );
@@ -1132,7 +1132,7 @@ void SCH_SHEET::GetNetListItem( NETLIST_OBJECT_LIST& aNetListItems,
 
 void SCH_SHEET::Plot( PLOTTER* aPlotter )
 {
-    EDA_COLOR_T txtcolor = UNSPECIFIED_COLOR;
+    COLOR4D    txtcolor = UNSPECIFIED_COLOR4D;
     wxSize      size;
     wxString    Text;
     int         name_orientation;
diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h
index ab7159c..98d6a45 100644
--- a/eeschema/sch_sheet.h
+++ b/eeschema/sch_sheet.h
@@ -113,7 +113,7 @@ public:
     bool IsMovableFromAnchorPoint() override { return true; }
 
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-               GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     /**
      * Function CreateGraphicShape (virtual)
@@ -429,7 +429,7 @@ public:
     int GetPenSize() const override;
 
     void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
-               GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     EDA_RECT const GetBoundingBox() const override;
 
diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp
index f29c390..4b84516 100644
--- a/eeschema/sch_sheet_pin.cpp
+++ b/eeschema/sch_sheet_pin.cpp
@@ -71,7 +71,7 @@ void SCH_SHEET_PIN::Draw( EDA_DRAW_PANEL* aPanel,
                           wxDC*           aDC,
                           const wxPoint&  aOffset,
                           GR_DRAWMODE     aDraw_mode,
-                          EDA_COLOR_T     aColor )
+                          COLOR4D         aColor )
 {
     // The icon selection is handle by the virtual method CreateGraphicShape
     // called by ::Draw
diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp
index 8e572f5..366e8a7 100644
--- a/eeschema/sch_text.cpp
+++ b/eeschema/sch_text.cpp
@@ -341,15 +341,15 @@ int SCH_TEXT::GetPenSize() const
 
 
 void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset,
-                     GR_DRAWMODE DrawMode, EDA_COLOR_T Color )
+                     GR_DRAWMODE DrawMode, COLOR4D Color )
 {
-    EDA_COLOR_T color;
+    COLOR4D     color;
     int         linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
     EDA_RECT*   clipbox = panel? panel->GetClipBox() : NULL;
 
     linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
 
-    if( Color >= 0 )
+    if( Color != UNSPECIFIED_COLOR4D )
         color = Color;
     else
         color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
@@ -361,7 +361,7 @@ void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset,
     int savedWidth = GetThickness();
     SetThickness( linewidth );              // Set the minimum width
 
-    EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
+    EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR4D );
 
     SetThickness( savedWidth );
 
@@ -669,8 +669,8 @@ bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy )
 void SCH_TEXT::Plot( PLOTTER* aPlotter )
 {
     static std::vector <wxPoint> Poly;
-    EDA_COLOR_T color = GetLayerColor( GetLayer() );
-    int         thickness = GetPenSize();
+    COLOR4D  color = GetLayerColor( GetLayer() );
+    int      thickness = GetPenSize();
 
     aPlotter->SetCurrentLineWidth( thickness );
 
@@ -972,7 +972,7 @@ bool SCH_LABEL::Load( LINE_READER& aLine, wxString& aErrorMsg )
 
 
 void SCH_LABEL::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
-                      GR_DRAWMODE DrawMode, EDA_COLOR_T Color )
+                      GR_DRAWMODE DrawMode, COLOR4D Color )
 {
     SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color );
 }
@@ -1256,13 +1256,13 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel,
                             wxDC*           DC,
                             const wxPoint&  aOffset,
                             GR_DRAWMODE     DrawMode,
-                            EDA_COLOR_T     Color )
+                            COLOR4D        Color )
 {
     static std::vector <wxPoint> Poly;
-    EDA_COLOR_T color;
+    COLOR4D color;
     wxPoint     text_offset = aOffset + GetSchematicTextOffset();
 
-    if( Color >= 0 )
+    if( Color != UNSPECIFIED_COLOR4D )
         color = Color;
     else
         color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
@@ -1277,7 +1277,7 @@ void SCH_GLOBALLABEL::Draw( EDA_DRAW_PANEL* panel,
     SetThickness( linewidth );
 
     EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
-    EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
+    EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR4D );
 
     SetThickness( save_width );   // restore initial value
 
@@ -1617,16 +1617,16 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel,
                           wxDC*           DC,
                           const wxPoint&  offset,
                           GR_DRAWMODE     DrawMode,
-                          EDA_COLOR_T     Color )
+                          COLOR4D         Color )
 {
     static std::vector <wxPoint> Poly;
-    EDA_COLOR_T color;
+    COLOR4D color;
     int         linewidth = GetThickness() == 0 ? GetDefaultLineThickness() : GetThickness();
     EDA_RECT*   clipbox = panel? panel->GetClipBox() : NULL;
 
     linewidth = Clamp_Text_PenSize( linewidth, GetTextSize(), IsBold() );
 
-    if( Color >= 0 )
+    if( Color != UNSPECIFIED_COLOR4D )
         color = Color;
     else
         color = GetLayerColor( GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : m_Layer );
@@ -1637,7 +1637,7 @@ void SCH_HIERLABEL::Draw( EDA_DRAW_PANEL* panel,
     SetThickness( linewidth );
 
     wxPoint text_offset = offset + GetSchematicTextOffset();
-    EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
+    EDA_TEXT::Draw( clipbox, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR4D );
 
     SetThickness( save_width );         // restore initial value
 
diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h
index 24b1aaa..9699157 100644
--- a/eeschema/sch_text.h
+++ b/eeschema/sch_text.h
@@ -132,7 +132,7 @@ public:
     virtual wxPoint GetSchematicTextOffset() const;
 
     virtual void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
-                       GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR ) override;
+                       GR_DRAWMODE draw_mode, COLOR4D Color = UNSPECIFIED_COLOR4D ) override;
 
     /**
      * Function CreateGraphicShape
@@ -228,7 +228,7 @@ public:
     ~SCH_LABEL() { }
 
     void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
-               GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE draw_mode, COLOR4D Color = UNSPECIFIED_COLOR4D ) override;
 
     wxString GetClass() const override
     {
@@ -274,7 +274,7 @@ public:
     ~SCH_GLOBALLABEL() { }
 
     void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
-               GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE draw_mode, COLOR4D Color = UNSPECIFIED_COLOR4D ) override;
 
     wxString GetClass() const override
     {
@@ -324,7 +324,7 @@ public:
     ~SCH_HIERLABEL() { }
 
     void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
-               GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR ) override;
+               GR_DRAWMODE draw_mode, COLOR4D Color = UNSPECIFIED_COLOR4D ) override;
 
     wxString GetClass() const override
     {
diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp
index 46bfa3d..b43d233 100644
--- a/eeschema/schedit.cpp
+++ b/eeschema/schedit.cpp
@@ -708,7 +708,7 @@ static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
     if( aErase )
     {
         if( cmp )   // Use fast mode (do not draw pin texts)
-            cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR, false );
+            cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR4D, false );
         else
             item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
     }
@@ -723,7 +723,7 @@ static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
     item->SetWireImage();  // While moving, the item may choose to render differently
 
     if( cmp )   // Use fast mode (do not draw pin texts)
-        cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR, false );
+        cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR4D, false );
     else
         item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
 }
diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp
index bf04f24..c327d33 100644
--- a/eeschema/sim/sim_plot_frame.cpp
+++ b/eeschema/sim/sim_plot_frame.cpp
@@ -561,7 +561,7 @@ void SIM_PLOT_FRAME::updateSignalList()
     {
         wxBitmap bitmap( isize, isize );
         bmDC.SelectObject( bitmap );
-        wxColor tcolor = trace.second->GetTraceColour();
+        wxColour tcolor = trace.second->GetTraceColour();
 
         wxColour bgColor = m_signals->wxWindow::GetBackgroundColour();
         bmDC.SetPen( wxPen( bgColor ) );
diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp
index 136c914..0e6d23d 100644
--- a/eeschema/symbdraw.cpp
+++ b/eeschema/symbdraw.cpp
@@ -240,7 +240,7 @@ void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC )
 
     if( m_drawItem->ContinueEdit( pos ) )
     {
-        m_drawItem->Draw( m_canvas, DC, pos, UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform );
+        m_drawItem->Draw( m_canvas, DC, pos, UNSPECIFIED_COLOR4D, g_XorMode, NULL, DefaultTransform );
         return;
     }
 
@@ -270,12 +270,12 @@ static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
         wxString    text = ((LIB_FIELD*)item)->GetFullText( unit );
 
         item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
-                    UNSPECIFIED_COLOR, g_XorMode, &text,
+                    UNSPECIFIED_COLOR4D, g_XorMode, &text,
                     DefaultTransform );
     }
     else
         item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ),
-                    UNSPECIFIED_COLOR, g_XorMode, NULL,
+                    UNSPECIFIED_COLOR4D, g_XorMode, NULL,
                     DefaultTransform );
 }
 
@@ -323,7 +323,7 @@ static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
         return;
 
     item->SetEraseLastDrawItem( aErase );
-    item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, g_XorMode, NULL,
+    item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ), UNSPECIFIED_COLOR4D, g_XorMode, NULL,
                 DefaultTransform );
 }
 
diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp
index 88a578b..d7c85b3 100644
--- a/eeschema/viewlibs.cpp
+++ b/eeschema/viewlibs.cpp
@@ -218,7 +218,7 @@ void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
         msg = _( "None" );
 
     part->Draw( m_canvas, DC, wxPoint( 0, 0 ), m_unit, m_convert, GR_DEFAULT_DRAWMODE,
-                UNSPECIFIED_COLOR, DefaultTransform,
+                UNSPECIFIED_COLOR4D, DefaultTransform,
                 true, true,false, NULL, GetShowElectricalType() );
 
     // Redraw the cursor
diff --git a/eeschema/widgets/widget_eeschema_color_config.cpp b/eeschema/widgets/widget_eeschema_color_config.cpp
index d8dd97f..11e148e 100644
--- a/eeschema/widgets/widget_eeschema_color_config.cpp
+++ b/eeschema/widgets/widget_eeschema_color_config.cpp
@@ -33,9 +33,6 @@
 
 #include "widget_eeschema_color_config.h"
 
-// See selcolor.cpp:
-extern EDA_COLOR_T DisplayColorFrame( wxWindow* aParent, EDA_COLOR_T aOldColor );
-
 // Specify the width and height of every (color-displaying / bitmap) button
 const int BUTT_SIZE_X = 16;
 const int BUTT_SIZE_Y = 16;
@@ -108,7 +105,7 @@ static BUTTONINDEX buttonGroups[] = {
 };
 
 
-static EDA_COLOR_T currentColors[ LAYERSCH_ID_COUNT ];
+static COLOR4D currentColors[ LAYERSCH_ID_COUNT ];
 
 
 WIDGET_EESCHEMA_COLOR_CONFIG::WIDGET_EESCHEMA_COLOR_CONFIG( wxWindow* aParent, EDA_DRAW_FRAME* aDrawFrame ) :
@@ -153,28 +150,16 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls()
             rowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
             columnBoxSizer->Add( rowBoxSizer, 0, wxGROW | wxALL, 0 );
 
-            wxMemoryDC iconDC;
-            wxBitmap   bitmap( BUTT_SIZE_X, BUTT_SIZE_Y );
-
-            iconDC.SelectObject( bitmap );
-
-            EDA_COLOR_T color = GetLayerColor( LAYERSCH_ID( buttons->m_Layer ) );
+            COLOR4D color = GetLayerColor( LAYERSCH_ID( buttons->m_Layer ) );
             currentColors[ buttons->m_Layer ] = color;
 
-            iconDC.SetPen( *wxBLACK_PEN );
-
-            wxBrush brush;
-            ColorSetBrush( &brush, color );
-            brush.SetStyle( wxBRUSHSTYLE_SOLID );
-            iconDC.SetBrush( brush );
-            iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
+            wxColourPickerCtrl* colourPicker = new wxColourPickerCtrl(
+                                    this, buttonId, color.ToColour(), wxDefaultPosition,
+                                    wxSize( BUTT_SIZE_X+20, BUTT_SIZE_Y+20 ) );
 
-            wxBitmapButton* bitmapButton = new wxBitmapButton(
-                                    this, buttonId, bitmap, wxDefaultPosition,
-                                    wxSize( BUTT_SIZE_X+8, BUTT_SIZE_Y+6 ) );
-            bitmapButton->SetClientData( (void*) buttons );
+            colourPicker->SetClientData( (void*) buttons );
 
-            rowBoxSizer->Add( bitmapButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );
+            rowBoxSizer->Add( colourPicker, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );
 
             label = new wxStaticText( this, wxID_ANY, wxGetTranslation( buttons->m_Name ) );
             rowBoxSizer->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );
@@ -185,25 +170,38 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls()
         groups++;
     }
 
-    Connect( 1800, buttonId - 1, wxEVT_COMMAND_BUTTON_CLICKED,
+    Connect( 1800, buttonId - 1, wxEVT_COLOURPICKER_CHANGED,
              wxCommandEventHandler( WIDGET_EESCHEMA_COLOR_CONFIG::SetColor ) );
 
-    wxArrayString selBgColorStrings;
+    /*wxArrayString selBgColorStrings;
     selBgColorStrings.Add( _( "White" ) );
     selBgColorStrings.Add( _( "Black" ) );
     m_SelBgColor = new wxRadioBox( this, wxID_ANY, _( "Background Color" ),
                                    wxDefaultPosition, wxDefaultSize,
                                    selBgColorStrings, 1, wxRA_SPECIFY_COLS );
     m_SelBgColor->SetSelection( ( GetDrawFrame()->GetDrawBgColor() == BLACK ) ? 1 : 0 );
+    */
+
+    COLOR4D bgColor = GetDrawFrame()->GetDrawBgColor();
+    m_SelBgColor = new wxColourPickerCtrl(
+                        this, buttonId, bgColor.ToColour(), wxDefaultPosition,
+                        wxSize( BUTT_SIZE_X+20, BUTT_SIZE_Y+20 ) );
+
+    wxStaticText* bgColorLabel = new wxStaticText( this, wxID_ANY, _( "Background Color" ) );
+    wxFont font( bgColorLabel->GetFont() );
+    font.SetWeight( wxFONTWEIGHT_BOLD );
+    bgColorLabel->SetFont( font );
 
     if( columnBoxSizer )
     {
         // Add a spacer to improve appearance.
         columnBoxSizer->AddSpacer( 5 );
-        columnBoxSizer->Add( m_SelBgColor, 1, wxGROW | wxRIGHT | wxTOP | wxBOTTOM, 5 );
+        columnBoxSizer->Add( bgColorLabel, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
+        columnBoxSizer->Add( m_SelBgColor, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM, 5 );
     }
 
-    currentColors[ LAYER_BACKGROUND ] =  GetDrawFrame()->GetDrawBgColor();
+    // TODO(jon) fix currentColors
+    //currentColors[ LAYER_BACKGROUND ] =  GetDrawFrame()->GetDrawBgColor();
 
     // Dialog now needs to be resized, but the associated command is found elsewhere.
 }
@@ -211,38 +209,22 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls()
 
 void WIDGET_EESCHEMA_COLOR_CONFIG::SetColor( wxCommandEvent& event )
 {
-    wxBitmapButton* button = (wxBitmapButton*) event.GetEventObject();
+    wxColourPickerCtrl* picker = (wxColourPickerCtrl*) event.GetEventObject();
 
-    wxCHECK_RET( button != NULL, wxT( "Color button event object is NULL." ) );
+    wxCHECK_RET( picker != NULL, wxT( "Color picker event object is NULL." ) );
 
-    COLORBUTTON* colorButton = (COLORBUTTON*) button->GetClientData();
+    COLORBUTTON* colorButton = (COLORBUTTON*) picker->GetClientData();
 
     wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) );
 
-    EDA_COLOR_T color = DisplayColorFrame( this, currentColors[colorButton->m_Layer] );
+    // DisplayColorFrame( this, currentColors[colorButton->m_Layer] );
+    COLOR4D color = COLOR4D( picker->GetColour() );
 
-    if( color < 0 || currentColors[ colorButton->m_Layer ] == color )
+    if( color == UNSPECIFIED_COLOR4D || currentColors[ colorButton->m_Layer ] == color )
         return;
 
     currentColors[ colorButton->m_Layer ] = color;
 
-    wxMemoryDC iconDC;
-
-    wxBitmap bitmap = button->GetBitmapLabel();
-    iconDC.SelectObject( bitmap );
-    iconDC.SetPen( *wxBLACK_PEN );
-
-    wxBrush  brush;
-
-    ColorSetBrush( &brush, color);
-
-    brush.SetStyle( wxBRUSHSTYLE_SOLID );
-
-    iconDC.SetBrush( brush );
-    iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
-    button->SetBitmapLabel( bitmap );
-    button->Refresh();
-
     Refresh( false );
 }
 
@@ -254,10 +236,7 @@ bool WIDGET_EESCHEMA_COLOR_CONFIG::TransferDataFromControl()
     // Check for color conflicts with background color to give user a chance to bail
     // out before making changes.
 
-    EDA_COLOR_T bgcolor = WHITE;
-
-    if( m_SelBgColor->GetSelection() > 0 )
-        bgcolor =  BLACK;
+    COLOR4D bgcolor = m_SelBgColor->GetColour();
 
     for( LAYERSCH_ID clyr = LAYER_WIRE; clyr < LAYERSCH_ID_COUNT; ++clyr )
     {
diff --git a/eeschema/widgets/widget_eeschema_color_config.h b/eeschema/widgets/widget_eeschema_color_config.h
index 1f99a31..6f9fb8a 100644
--- a/eeschema/widgets/widget_eeschema_color_config.h
+++ b/eeschema/widgets/widget_eeschema_color_config.h
@@ -27,6 +27,8 @@
 
 #include <wx/panel.h>
 #include <wx/sizer.h>
+#include <wx/colordlg.h>
+#include <wx/clrpicker.h>
 
 class wxBoxSizer;
 class wxStaticLine;
@@ -41,7 +43,7 @@ class WIDGET_EESCHEMA_COLOR_CONFIG : public wxPanel
 {
 private:
     EDA_DRAW_FRAME*         m_drawFrame;
-    wxRadioBox*             m_SelBgColor;
+    wxColourPickerCtrl*     m_SelBgColor;
     wxBoxSizer*             m_mainBoxSizer;
 
     // Creates the controls and sizers
diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt
index e919ac5..fec3088 100644
--- a/gerbview/CMakeLists.txt
+++ b/gerbview/CMakeLists.txt
@@ -102,6 +102,7 @@ target_link_libraries( gerbview
     # There's way too much crap coming in from common yet.
     common
     bitmaps
+    gal
     ${wxWidgets_LIBRARIES}
     )
 
diff --git a/gerbview/block.cpp b/gerbview/block.cpp
index c2345ab..d284d7d 100644
--- a/gerbview/block.cpp
+++ b/gerbview/block.cpp
@@ -148,7 +148,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
 {
     BASE_SCREEN* screen = aPanel->GetScreen();
 
-    EDA_COLOR_T Color = YELLOW;
+    COLOR4D Color = COLOR4D( YELLOW );
 
     if( aErase )
     {
diff --git a/gerbview/class_aperture_macro.cpp b/gerbview/class_aperture_macro.cpp
index 8a04c2f..41fb469 100644
--- a/gerbview/class_aperture_macro.cpp
+++ b/gerbview/class_aperture_macro.cpp
@@ -712,7 +712,7 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
  */
 void APERTURE_MACRO::DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent,
                                              EDA_RECT* aClipBox, wxDC* aDC,
-                                             EDA_COLOR_T aColor,
+                                             COLOR4D aColor,
                                              wxPoint aShapePos, bool aFilledShape )
 {
     SHAPE_POLY_SET shapeBuffer;
diff --git a/gerbview/class_aperture_macro.h b/gerbview/class_aperture_macro.h
index 816e461..0b88de2 100644
--- a/gerbview/class_aperture_macro.h
+++ b/gerbview/class_aperture_macro.h
@@ -195,7 +195,7 @@ struct APERTURE_MACRO
      * @param aFilledShape = true to draw in filled mode, false to draw in skecth mode
      */
     void DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC,
-                                 EDA_COLOR_T aColor, wxPoint aShapePos, bool aFilledShape );
+                                 COLOR4D aColor, wxPoint aShapePos, bool aFilledShape );
 
     /**
      * Function GetShapeDim
diff --git a/gerbview/class_gbr_display_options.h b/gerbview/class_gbr_display_options.h
index 7541d58..3ff5179 100644
--- a/gerbview/class_gbr_display_options.h
+++ b/gerbview/class_gbr_display_options.h
@@ -31,8 +31,6 @@
 #ifndef CLASS_GBR_DISPLAY_OPTIONS_H
 #define CLASS_GBR_DISPLAY_OPTIONS_H
 
-#include <colors.h>
-
 /**
  * @note Some of these parameters are used only for printing, some others only
  * for drawing on screen.
@@ -49,10 +47,10 @@ public:
     bool    m_DisplayNegativeObjects;   ///< Option to draw negative objects in a specific color
     bool    m_IsPrinting;               ///< true when printing a page, false when drawing on screen
     bool    m_ForceBlackAndWhite;       ///< Option print in blackand white (ont used id draw mode
-    EDA_COLOR_T m_NegativeDrawColor;    ///< The color used to draw negative objects, usually the
+    COLOR4D m_NegativeDrawColor;        ///< The color used to draw negative objects, usually the
                                         ///< background color, but not always, when negative objects
                                         ///< must be visible
-    EDA_COLOR_T m_BgDrawColor;          ///< The background color
+    COLOR4D m_BgDrawColor;              ///< The background color
 
 public:
     GBR_DISPLAY_OPTIONS()
@@ -65,8 +63,8 @@ public:
         m_IsPrinting = false;
         m_DisplayNegativeObjects = false;
         m_ForceBlackAndWhite    = false;
-        m_NegativeDrawColor     = DARKGRAY;
-        m_BgDrawColor = BLACK;
+        m_NegativeDrawColor     = COLOR4D( DARKGRAY );
+        m_BgDrawColor = COLOR4D_BLACK;
     }
 };
 
diff --git a/gerbview/class_gbr_layer_box_selector.cpp b/gerbview/class_gbr_layer_box_selector.cpp
index c28569a..7ebb47d 100644
--- a/gerbview/class_gbr_layer_box_selector.cpp
+++ b/gerbview/class_gbr_layer_box_selector.cpp
@@ -70,7 +70,7 @@ void GBR_LAYER_BOX_SELECTOR::Resync()
 
 
 // Returns a color index from the layer id
-EDA_COLOR_T GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayer ) const
+COLOR4D GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayer ) const
 {
     GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
 
diff --git a/gerbview/class_gbr_layer_box_selector.h b/gerbview/class_gbr_layer_box_selector.h
index 382379e..bf96318 100644
--- a/gerbview/class_gbr_layer_box_selector.h
+++ b/gerbview/class_gbr_layer_box_selector.h
@@ -46,7 +46,7 @@ public:
 
     // Returns a color index from the layer id
     // Virtual function
-    EDA_COLOR_T GetLayerColor( int aLayer ) const override;
+    COLOR4D GetLayerColor( int aLayer ) const override;
 
     // Returns true if the layer id is enabled (i.e. is it should be displayed)
     // Virtual function
diff --git a/gerbview/class_gbr_layout.cpp b/gerbview/class_gbr_layout.cpp
index b9588d0..ebba33f 100644
--- a/gerbview/class_gbr_layout.cpp
+++ b/gerbview/class_gbr_layout.cpp
@@ -155,8 +155,8 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
     wxPoint dev_org = aDC->GetDeviceOrigin();
     wxPoint logical_org = aDC->GetLogicalOrigin( );
 
-    wxColour bgColor = MakeColour( aDisplayOptions->m_BgDrawColor );
-    wxBrush  bgBrush( bgColor, wxBRUSHSTYLE_SOLID );
+    COLOR4D bgColor = aDisplayOptions->m_BgDrawColor;
+    wxBrush  bgBrush( bgColor.ToColour(), wxBRUSHSTYLE_SOLID );
 
     if( useBufferBitmap )
     {
@@ -233,7 +233,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                     // Use the layer bitmap itself as a mask when blitting.  The bitmap
                     // cannot be referenced by a device context when setting the mask.
                     layerDC.SelectObject( wxNullBitmap );
-                    layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
+                    layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor.ToColour() ) );
                     layerDC.SelectObject( *layerBitmap );
                     screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
                 }
@@ -264,7 +264,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
         if( gerber->m_ImageNegative )
         {
             // Draw background negative (i.e. in graphic layer color) for negative images.
-            EDA_COLOR_T neg_color = gerber->GetPositiveDrawColor();
+            COLOR4D neg_color = gerber->GetPositiveDrawColor();
 
             GRSetDrawMode( &layerDC, GR_COPY );
             GRFilledRect( &drawBox, plotDC, drawBox.GetX(), drawBox.GetY(),
@@ -328,7 +328,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
         if( aDrawMode == GR_COPY )
         {
             layerDC.SelectObject( wxNullBitmap );
-            layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor ) );
+            layerBitmap->SetMask( new wxMask( *layerBitmap, bgColor.ToColour() ) );
             layerDC.SelectObject( *layerBitmap );
             screenDC.Blit( 0, 0, bitmapWidth, bitmapHeight, &layerDC, 0, 0, wxCOPY, true );
 
@@ -364,7 +364,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
 
 
 void GBR_LAYOUT::DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
-                                   GR_DRAWMODE aDrawMode, EDA_COLOR_T aDrawColor )
+                                   GR_DRAWMODE aDrawMode, COLOR4D aDrawColor )
 {
     wxPoint     pos;
     int         width;
diff --git a/gerbview/class_gbr_layout.h b/gerbview/class_gbr_layout.h
index 563b2b8..477136e 100644
--- a/gerbview/class_gbr_layout.h
+++ b/gerbview/class_gbr_layout.h
@@ -125,7 +125,7 @@ public:
      * @param aDrawColor = the color of dcode texts
      */
     void DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
-                           GR_DRAWMODE aDrawMode, EDA_COLOR_T aDrawColor );
+                           GR_DRAWMODE aDrawMode, COLOR4D aDrawColor );
 
 
     /**
diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp
index 4ddb771..653c5c0 100644
--- a/gerbview/class_gerber_draw_item.cpp
+++ b/gerbview/class_gerber_draw_item.cpp
@@ -282,12 +282,10 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra
     if( d_codeDescr == NULL )
         d_codeDescr = &dummyD_CODE;
 
-    EDA_COLOR_T color = m_GerberImageFile->GetPositiveDrawColor();
+    COLOR4D color = m_GerberImageFile->GetPositiveDrawColor();
 
-    if( aDrawMode & GR_HIGHLIGHT )
-        ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
-
-    ColorApplyHighlightFlag( &color );
+    if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
+        color.SetToLegacyHighlightColor();
 
     /* isDark is true if flash is positive and should use a drawing
      *   color other than the background color, else use the background color
@@ -479,7 +477,7 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon( )
 
 void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_RECT*      aClipBox,
                                     wxDC*          aDC,
-                                    EDA_COLOR_T    aColor,
+                                    COLOR4D        aColor,
                                     const wxPoint& aOffset,
                                     bool           aFilledShape )
 {
diff --git a/gerbview/class_gerber_draw_item.h b/gerbview/class_gerber_draw_item.h
index a64e0be..832528f 100644
--- a/gerbview/class_gerber_draw_item.h
+++ b/gerbview/class_gerber_draw_item.h
@@ -221,7 +221,7 @@ public:
      * Function DrawGbrPoly
      * a helper function used to draw the polygon stored in m_PolyCorners
      */
-    void DrawGbrPoly( EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor,
+    void DrawGbrPoly( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor,
                       const wxPoint& aOffset, bool aFilledShape );
 
     /* divers */
diff --git a/gerbview/class_gerber_file_image.h b/gerbview/class_gerber_file_image.h
index fddb4d7..00a89b7 100644
--- a/gerbview/class_gerber_file_image.h
+++ b/gerbview/class_gerber_file_image.h
@@ -109,7 +109,7 @@ public:
                                                                 // (a file is loaded in it)
     bool               m_IsVisible;                             // true if the draw layer is visible and must be drawn
                                                                 // false if it must be not drawn
-    EDA_COLOR_T        m_PositiveDrawColor;                     // The color used to draw positive items
+    COLOR4D            m_PositiveDrawColor;                     // The color used to draw positive items
     wxString           m_FileName;                              // Full File Name for this layer
     wxString           m_ImageName;                             // Image name, from IN <name>* command
     bool               m_IsX2_file;                             // true if a X2 gerber attribute was found in file
@@ -203,7 +203,7 @@ public:
 
     virtual void ResetDefaultValues();
 
-    EDA_COLOR_T GetPositiveDrawColor() const { return m_PositiveDrawColor; }
+    COLOR4D GetPositiveDrawColor() const { return m_PositiveDrawColor; }
 
     /**
      * Function GetItemsList
diff --git a/gerbview/class_gerbview_layer_widget.cpp b/gerbview/class_gerbview_layer_widget.cpp
index aeb53cd..cc33e89 100644
--- a/gerbview/class_gerbview_layer_widget.cpp
+++ b/gerbview/class_gerbview_layer_widget.cpp
@@ -114,7 +114,7 @@ void GERBER_LAYER_WIDGET::ReFillRender()
 
     for( unsigned row=0;  row<DIM(renderRows);  ++row )
     {
-        if( renderRows[row].color != -1 )       // does this row show a color?
+        if( renderRows[row].color != UNSPECIFIED_COLOR4D )       // does this row show a color?
         {
             renderRows[row].color = myframe->GetVisibleElementColor(
                                     (GERBER_VISIBLE_ID)renderRows[row].id );
@@ -252,7 +252,7 @@ void GERBER_LAYER_WIDGET::ReFill()
 
 //-----<LAYER_WIDGET callbacks>-------------------------------------------
 
-void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor )
+void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )
 {
     myframe->SetLayerColor( aLayer, aColor );
     myframe->m_SelLayerBox->ResyncBitmapOnly();
@@ -291,7 +291,7 @@ void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFin
         myframe->GetCanvas()->Refresh();
 }
 
-void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor )
+void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
 {
     myframe->SetVisibleElementColor( (GERBER_VISIBLE_ID)aId, aColor );
     myframe->GetCanvas()->Refresh();
diff --git a/gerbview/class_gerbview_layer_widget.h b/gerbview/class_gerbview_layer_widget.h
index f59de18..8e5c6ef 100644
--- a/gerbview/class_gerbview_layer_widget.h
+++ b/gerbview/class_gerbview_layer_widget.h
@@ -100,10 +100,10 @@ public:
     void ReFillRender();
 
     //-----<implement LAYER_WIDGET abstract callback functions>-----------
-    void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ) override;
+    void OnLayerColorChange( int aLayer, COLOR4D aColor ) override;
     bool OnLayerSelect( int aLayer ) override;
     void OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) override;
-    void OnRenderColorChange( int aId, EDA_COLOR_T aColor ) override;
+    void OnRenderColorChange( int aId, COLOR4D aColor ) override;
     void OnRenderEnable( int aId, bool isEnabled ) override;
 
     /**
diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp
index 992cf9c..b7cd055 100644
--- a/gerbview/dcode.cpp
+++ b/gerbview/dcode.cpp
@@ -151,7 +151,7 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
 
 
 void D_CODE::DrawFlashedShape(  GERBER_DRAW_ITEM* aParent,
-                                EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor,
+                                EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor,
                                 wxPoint aShapePos, bool aFilledShape )
 {
     int radius;
@@ -268,7 +268,7 @@ void D_CODE::DrawFlashedShape(  GERBER_DRAW_ITEM* aParent,
 
 void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent,
                                  EDA_RECT* aClipBox, wxDC* aDC,
-                                 EDA_COLOR_T aColor, bool aFilled,
+                                 COLOR4D aColor, bool aFilled,
                                  const wxPoint& aPosition )
 {
     if( m_PolyCorners.size() == 0 )
diff --git a/gerbview/dcode.h b/gerbview/dcode.h
index d809848..a569343 100644
--- a/gerbview/dcode.h
+++ b/gerbview/dcode.h
@@ -34,6 +34,7 @@
 
 #include <base_struct.h>
 
+using KIGFX::COLOR4D;
 
 class GERBER_DRAW_ITEM;
 
@@ -173,7 +174,7 @@ public:
      * @param aFilledShape = true to draw in filled mode, false to draw in sketch mode
      */
     void DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox,
-                           wxDC* aDC, EDA_COLOR_T aColor,
+                           wxDC* aDC, COLOR4D aColor,
                            wxPoint aShapePos, bool aFilledShape );
 
     /**
@@ -190,7 +191,7 @@ public:
      * @param aPosition = the actual shape position
      */
     void DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent,
-                             EDA_RECT* aClipBox, wxDC* aDC, EDA_COLOR_T aColor,
+                             EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor,
                              bool aFilled, const wxPoint& aPosition );
 
     /**
diff --git a/gerbview/draw_gerber_screen.cpp b/gerbview/draw_gerber_screen.cpp
index 93f14d4..022db48 100644
--- a/gerbview/draw_gerber_screen.cpp
+++ b/gerbview/draw_gerber_screen.cpp
@@ -120,7 +120,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
 
     if( m_DisplayOptions.m_DisplayDCodes )
     {
-        EDA_COLOR_T dcode_color = GetVisibleElementColor( DCODES_VISIBLE );
+        COLOR4D dcode_color = GetVisibleElementColor( DCODES_VISIBLE );
         GetGerberLayout()->DrawItemsDCodeID( m_canvas, DC, GR_COPY, dcode_color );
     }
 
diff --git a/gerbview/gerbview_config.cpp b/gerbview/gerbview_config.cpp
index 7d35e06..d53b028 100644
--- a/gerbview/gerbview_config.cpp
+++ b/gerbview/gerbview_config.cpp
@@ -103,15 +103,15 @@ PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings()
                                                     false ) );
 
     // Default colors for layers 0 to 31
-    static const EDA_COLOR_T color_default[] = {
-        GREEN,     BLUE,         LIGHTGRAY, MAGENTA,
-        RED,       DARKGREEN,    BROWN,     MAGENTA,
-        LIGHTGRAY, BLUE,         GREEN,     CYAN,
-        LIGHTRED,  LIGHTMAGENTA, YELLOW,    RED,
-        BLUE,      BROWN,        LIGHTCYAN, RED,
-        MAGENTA,   CYAN,         BROWN,     MAGENTA,
-        LIGHTGRAY, BLUE,         GREEN,     DARKCYAN,
-        YELLOW,    LIGHTMAGENTA, YELLOW,    LIGHTGRAY,
+    static const COLOR4D color_default[] = {
+        COLOR4D( GREEN ),     COLOR4D( BLUE ),         COLOR4D( LIGHTGRAY ), COLOR4D( MAGENTA ),
+        COLOR4D( RED ),       COLOR4D( DARKGREEN ),    COLOR4D( BROWN ),     COLOR4D( MAGENTA ),
+        COLOR4D( LIGHTGRAY ), COLOR4D( BLUE ),         COLOR4D( GREEN ),     COLOR4D( CYAN ),
+        COLOR4D( LIGHTRED ),  COLOR4D( LIGHTMAGENTA ), COLOR4D( YELLOW ),    COLOR4D( RED ),
+        COLOR4D( BLUE ),      COLOR4D( BROWN ),        COLOR4D( LIGHTCYAN ), COLOR4D( RED ),
+        COLOR4D( MAGENTA ),   COLOR4D( CYAN ),         COLOR4D( BROWN ),     COLOR4D( MAGENTA ),
+        COLOR4D( LIGHTGRAY ), COLOR4D( BLUE ),         COLOR4D( GREEN ),     COLOR4D( DARKCYAN ),
+        COLOR4D( YELLOW ),    COLOR4D( LIGHTMAGENTA ), COLOR4D( YELLOW ),    COLOR4D( LIGHTGRAY ),
     };
 
     // List of keywords used as identifiers in config.
@@ -134,7 +134,7 @@ PARAM_CFG_ARRAY& GERBVIEW_FRAME::GetConfigurationSettings()
 
     for( unsigned i = 0; i < DIM(keys);  ++i )
     {
-        EDA_COLOR_T* prm = &g_ColorsSettings.m_LayersColors[i];
+        COLOR4D* prm = &g_ColorsSettings.m_LayersColors[i];
 
         PARAM_CFG_SETCOLOR* prm_entry =
             new PARAM_CFG_SETCOLOR( true, keys[i], prm, color_default[i] );
diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp
index c94dd1f..f2e7770 100644
--- a/gerbview/gerbview_frame.cpp
+++ b/gerbview/gerbview_frame.cpp
@@ -606,9 +606,9 @@ bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
 }
 
 
-EDA_COLOR_T GERBVIEW_FRAME::GetVisibleElementColor( GERBER_VISIBLE_ID aItemIdVisible ) const
+COLOR4D GERBVIEW_FRAME::GetVisibleElementColor( GERBER_VISIBLE_ID aItemIdVisible ) const
 {
-    EDA_COLOR_T color = UNSPECIFIED_COLOR;
+    COLOR4D color = UNSPECIFIED_COLOR4D;
 
     switch( aItemIdVisible )
     {
@@ -638,7 +638,7 @@ void GERBVIEW_FRAME::SetGridVisibility( bool aVisible )
 
 
 void GERBVIEW_FRAME::SetVisibleElementColor( GERBER_VISIBLE_ID aItemIdVisible,
-                                             EDA_COLOR_T aColor )
+                                             COLOR4D aColor )
 {
     switch( aItemIdVisible )
     {
@@ -658,7 +658,7 @@ void GERBVIEW_FRAME::SetVisibleElementColor( GERBER_VISIBLE_ID aItemIdVisible,
     }
 }
 
-EDA_COLOR_T GERBVIEW_FRAME::GetNegativeItemsColor() const
+COLOR4D GERBVIEW_FRAME::GetNegativeItemsColor() const
 {
     if( IsElementVisible( NEGATIVE_OBJECTS_VISIBLE ) )
         return GetVisibleElementColor( NEGATIVE_OBJECTS_VISIBLE );
@@ -667,13 +667,13 @@ EDA_COLOR_T GERBVIEW_FRAME::GetNegativeItemsColor() const
 }
 
 
-EDA_COLOR_T GERBVIEW_FRAME::GetLayerColor( int aLayer ) const
+COLOR4D GERBVIEW_FRAME::GetLayerColor( int aLayer ) const
 {
     return m_colorsSettings->GetLayerColor( aLayer );
 }
 
 
-void GERBVIEW_FRAME::SetLayerColor( int aLayer, EDA_COLOR_T aColor )
+void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
 {
     m_colorsSettings->SetLayerColor( aLayer, aColor );
 }
diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h
index 4635b62..8646ff8 100644
--- a/gerbview/gerbview_frame.h
+++ b/gerbview/gerbview_frame.h
@@ -334,21 +334,21 @@ public:
      * Function GetVisibleElementColor
      * returns the color of a gerber visible element.
      */
-    EDA_COLOR_T GetVisibleElementColor( GERBER_VISIBLE_ID aItemIdVisible ) const;
+    COLOR4D GetVisibleElementColor( GERBER_VISIBLE_ID aItemIdVisible ) const;
 
-    void    SetVisibleElementColor( GERBER_VISIBLE_ID aItemIdVisible, EDA_COLOR_T aColor );
+    void    SetVisibleElementColor( GERBER_VISIBLE_ID aItemIdVisible, COLOR4D aColor );
 
     /**
      * Function GetLayerColor
      * gets a layer color for any valid layer.
      */
-    EDA_COLOR_T GetLayerColor( int aLayer ) const;
+    COLOR4D GetLayerColor( int aLayer ) const;
 
     /**
      * Function SetLayerColor
      * changes a layer color for any valid layer.
      */
-    void    SetLayerColor( int aLayer, EDA_COLOR_T aColor );
+    void    SetLayerColor( int aLayer, COLOR4D aColor );
 
     /**
      * Function GetNegativeItemsColor
@@ -356,7 +356,7 @@ public:
      * This is usually the background color, but can be an other color
      * in order to see negative objects
      */
-    EDA_COLOR_T GetNegativeItemsColor() const;
+    COLOR4D GetNegativeItemsColor() const;
 
     /**
      * Function DisplayLinesSolidMode
diff --git a/gerbview/printout_control.cpp b/gerbview/printout_control.cpp
index 60befca..21a758c 100644
--- a/gerbview/printout_control.cpp
+++ b/gerbview/printout_control.cpp
@@ -237,7 +237,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage( const wxString& aLayerName,
     panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) );
 
     screen->m_IsPrinting = true;
-    EDA_COLOR_T bg_color = m_Parent->GetDrawBgColor();
+    COLOR4D bg_color = m_Parent->GetDrawBgColor();
 
     // Print frame reference, if requested, before printing draw layers
     if( m_PrintParams.m_Print_Black_and_White )
diff --git a/include/base_struct.h b/include/base_struct.h
index 61205b0..f8ad0de 100644
--- a/include/base_struct.h
+++ b/include/base_struct.h
@@ -34,7 +34,7 @@
 
 #include <core/typeinfo.h>
 
-#include <colors.h>
+#include <gal/color4d.h>
 #include <bitmaps.h>
 #include <richio.h>
 #include <view/view_item.h>
diff --git a/include/basic_gal.h b/include/basic_gal.h
index e10d0ca..5d3198f 100644
--- a/include/basic_gal.h
+++ b/include/basic_gal.h
@@ -57,7 +57,7 @@ class BASIC_GAL: public KIGFX::GAL
 {
 public:
     wxDC* m_DC;
-    EDA_COLOR_T m_Color;
+    COLOR4D m_Color;
 
 private:
     TRANSFORM_PRM m_transform;
diff --git a/include/block_commande.h b/include/block_commande.h
index 8c7d5e8..8c85aad 100644
--- a/include/block_commande.h
+++ b/include/block_commande.h
@@ -75,7 +75,7 @@ class BLOCK_SELECTOR : public EDA_RECT
     BLOCK_STATE_T     m_state;                    //< State (enum BLOCK_STATE_T) of the block.
     BLOCK_COMMAND_T   m_command;                  //< Command (enum BLOCK_COMMAND_T) operation.
     PICKED_ITEMS_LIST m_items;                    //< List of items selected in this block.
-    EDA_COLOR_T       m_color;                    //< Block Color (for drawings).
+    COLOR4D           m_color;                    //< Block Color (for drawings).
     wxPoint           m_moveVector;               //< Move distance to move the block.
     wxPoint           m_lastCursorPosition;       //< Last Mouse position in block command
                                                   //< last cursor position in move commands
@@ -93,9 +93,9 @@ public:
 
     BLOCK_COMMAND_T GetCommand() const { return m_command; }
 
-    void SetColor( EDA_COLOR_T aColor ) { m_color = aColor; }
+    void SetColor( COLOR4D aColor ) { m_color = aColor; }
 
-    EDA_COLOR_T GetColor() const { return m_color; }
+    COLOR4D GetColor() const { return m_color; }
 
     /**
      * Function SetLastCursorPosition
@@ -128,7 +128,7 @@ public:
                wxDC*           aDC,
                const wxPoint&  aOffset,
                GR_DRAWMODE     aDrawMode,
-               EDA_COLOR_T     aColor );
+               COLOR4D         aColor );
 
     /**
      * Function PushItem
diff --git a/include/class_bitmap_base.h b/include/class_bitmap_base.h
index a9c1332..5863160 100644
--- a/include/class_bitmap_base.h
+++ b/include/class_bitmap_base.h
@@ -222,7 +222,7 @@ public:
      * @param aDefaultPensize = the pen size used to plot the rectangle when bitmap is not supported
      */
     void PlotImage( PLOTTER* aPlotter, const wxPoint& aPos,
-                    EDA_COLOR_T aDefaultColor, int aDefaultPensize );
+                    COLOR4D aDefaultColor, int aDefaultPensize );
 };
 
 
diff --git a/include/class_colors_design_settings.h b/include/class_colors_design_settings.h
index 601526d..a2ae982 100644
--- a/include/class_colors_design_settings.h
+++ b/include/class_colors_design_settings.h
@@ -29,9 +29,10 @@
 
 #ifndef COLORS_DESIGN_SETTING_H
 #define COLORS_DESIGN_SETTING_H
-#include <colors.h>     // definition of EDA_COLOR_T
+#include <gal/color4d.h>
 #include <layers_id_colors_and_visibility.h>
 
+using KIGFX::COLOR4D;
 
 /**
  * Class COLORS_DESIGN_SETTINGS
@@ -43,10 +44,10 @@ public:
     // Color options for screen display of the Printed Board and schematic:
 
     // Common to Eeschema, Pcbnew, GerbView
-    EDA_COLOR_T m_LayersColors[LAYER_ID_COUNT];     ///< Layer colors (tracks and graphic items)
+    COLOR4D m_LayersColors[LAYER_ID_COUNT];     ///< Layer colors (tracks and graphic items)
 
     // Common to Eeschema, Pcbnew
-    EDA_COLOR_T m_ItemsColors[32];                  ///< All others items but layers
+    COLOR4D m_ItemsColors[32];                  ///< All others items but layers
 
 public:
     COLORS_DESIGN_SETTINGS();
@@ -56,35 +57,35 @@ public:
      * @return the color for aLayer which is one of the layer indices given
      * in pcbstruct.h or in schematic
      */
-    EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const;
+    COLOR4D GetLayerColor( LAYER_NUM aLayer ) const;
 
     /**
      * Function SetLayerColor
      * sets the color for aLayer which is one of the layer indices given
      * in pcbstruct.h or in schematic
      */
-    void SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor );
+    void SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor );
 
     /**
      * Function GetItemColor
      * @return the color for an item which is one of the item indices given
      * in pcbstruct.h, enum PCB_VISIBLE or in schematic
      */
-    EDA_COLOR_T GetItemColor( int aItemIdx ) const;
+    COLOR4D GetItemColor( int aItemIdx ) const;
 
     /**
      * Function SetItemColor
      * sets the color for an item which is one of the item indices given
      * in pcbstruct.h, enum PCB_VISIBLE or in schematic
      */
-    void SetItemColor( int aItemIdx, EDA_COLOR_T aColor );
+    void SetItemColor( int aItemIdx, COLOR4D aColor );
 
     /**
      * Function SetAllColorsAs
      * sets alls colors to aColor
      * Usefull to create a monochrome color selection for printing purpose
      */
-    void SetAllColorsAs( EDA_COLOR_T aColor);
+    void SetAllColorsAs( COLOR4D aColor);
 };
 
 #endif  //  COLORS_DESIGN_SETTING_H
diff --git a/include/class_drawpanel.h b/include/class_drawpanel.h
index 4aa5aff..2c35f8d 100644
--- a/include/class_drawpanel.h
+++ b/include/class_drawpanel.h
@@ -31,7 +31,6 @@
 #ifndef  PANEL_WXSTRUCT_H
 #define  PANEL_WXSTRUCT_H
 
-#include <colors.h>
 #include <base_struct.h>
 #include <gr_basic.h>
 
@@ -368,7 +367,7 @@ public:
      * @param aDC - the device context to draw the cursor
      * @param aColor - the color to draw the cursor
      */
-    void DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor = WHITE );
+    void DrawCrossHair( wxDC* aDC, COLOR4D aColor = COLOR4D_WHITE );
 
     // Hide the cross hair.
     void CrossHairOff( wxDC* DC );
diff --git a/include/class_layer_box_selector.h b/include/class_layer_box_selector.h
index 1f07df7..d2edc1d 100644
--- a/include/class_layer_box_selector.h
+++ b/include/class_layer_box_selector.h
@@ -26,10 +26,11 @@
 #define CLASS_LAYER_BOX_SELECTOR_H 1
 
 #include <wx/bmpcbox.h>
-#include <colors.h>     // EDA_COLOR_T definition
+#include <gal/color4d.h>
 #include <layers_id_colors_and_visibility.h>
 
 struct EDA_HOTKEY_CONFIG;
+using KIGFX::COLOR4D;
 
 /* Basic class to build a layer list.
  * this is an basic abstract class to build a layer list selector.
@@ -49,7 +50,7 @@ public:
 
     // Returns a color index from the layer id
     // Virtual function because GerbView uses its own functions in a derived class
-    virtual EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const = 0;
+    virtual COLOR4D GetLayerColor( LAYER_NUM aLayer ) const = 0;
 
     // Returns the name of the layer id
     // Virtual pure function because GerbView uses its own functions in a derived class
diff --git a/include/class_marker_base.h b/include/class_marker_base.h
index b91de15..5903eae 100644
--- a/include/class_marker_base.h
+++ b/include/class_marker_base.h
@@ -55,7 +55,7 @@ public:
 protected:
     TYPEMARKER            m_MarkerType;          ///< The type of marker (useful to filter markers)
     MARKER_SEVERITY       m_ErrorLevel;          ///< Specify the severity of the error
-    EDA_COLOR_T           m_Color;               ///< color
+    COLOR4D               m_Color;               ///< color
     EDA_RECT              m_ShapeBoundingBox;    ///< Bounding box of the graphic symbol, relative
                                                  ///< to the position of the shape, used for Hit
                                                  ///< Tests
@@ -122,7 +122,7 @@ public:
      * Function SetColor
      * Set the color of this marker
      */
-    void SetColor( EDA_COLOR_T aColor )
+    void SetColor( COLOR4D aColor )
     {
         m_Color = aColor;
     }
diff --git a/include/class_worksheet_dataitem.h b/include/class_worksheet_dataitem.h
index bbd289c..87fb6eb 100644
--- a/include/class_worksheet_dataitem.h
+++ b/include/class_worksheet_dataitem.h
@@ -105,44 +105,44 @@ public:
     };
 
 protected:
-    WS_ItemType       m_type;
-    int               m_flags;
+    WS_ItemType    m_type;
+    int            m_flags;
 
 public:
-    wxString          m_Name;               // a item name used in page layout
+    wxString       m_Name;                  // a item name used in page layout
                                             // editor to identify items
-    wxString          m_Info;               // a comment, only useful in page
+    wxString       m_Info;                  // a comment, only useful in page
                                             // layout editor
-    POINT_COORD       m_Pos;
-    POINT_COORD       m_End;
-    double            m_LineWidth;
-    int               m_RepeatCount;        // repeat count for duplicate items
-    DPOINT            m_IncrementVector;    // For duplicate items: move vector
+    POINT_COORD    m_Pos;
+    POINT_COORD    m_End;
+    double         m_LineWidth;
+    int            m_RepeatCount;           // repeat count for duplicate items
+    DPOINT         m_IncrementVector;       // For duplicate items: move vector
                                             // for position increment
-    int               m_IncrementLabel;
+    int            m_IncrementLabel;
 
     // These variables are static, because these values are common to all
     // instances of WORKSHEET_DATAITEM.
     // They are default or common values.
-    static double     m_WSunits2Iu;         // conversion factor between
+    static double  m_WSunits2Iu;            // conversion factor between
                                             // ws units (mils) and draw/plot units
-    static DPOINT     m_RB_Corner;          // cordinates of the right bottom corner
+    static DPOINT  m_RB_Corner;             // cordinates of the right bottom corner
                                             // (ws units)
-    static DPOINT     m_LT_Corner;          // cordinates of the left top corner
+    static DPOINT  m_LT_Corner;             // cordinates of the left top corner
                                             // (ws units)
-    static double     m_DefaultLineWidth;   // Default line width,
+    static double  m_DefaultLineWidth;      // Default line width,
                                             // when not defined inside a line
                                             // or a rect
-    static DSIZE      m_DefaultTextSize;    // Default text size,
+    static DSIZE   m_DefaultTextSize;       // Default text size,
                                             // when not defined inside a tbtext
-    static double     m_DefaultTextThickness;// Default text thickness,
+    static double  m_DefaultTextThickness;  // Default text thickness,
                                             // when not defined inside a tbtext
-    static bool       m_SpecialMode;        // Used in page layout editor
+    static bool    m_SpecialMode;           // Used in page layout editor
                                             // When set to true, base texts
                                             // instead of full texts are displayed
-    static EDA_COLOR_T m_Color;             // the default color to draw items
-    static EDA_COLOR_T m_AltColor;          // an alternate color to draw items
-    static EDA_COLOR_T m_SelectedColor;     // the color to draw selected items
+    static COLOR4D m_Color;                 // the default color to draw items
+    static COLOR4D m_AltColor;              // an alternate color to draw items
+    static COLOR4D m_SelectedColor;         // the color to draw selected items
                                             // (used in page layout editor
 
 
@@ -279,7 +279,7 @@ public:
 
     bool UseAltColor() {return m_flags & USE_ALT_COLOR; }
 
-    EDA_COLOR_T GetItemColor()
+    COLOR4D GetItemColor()
     {
         if( IsSelected() )
             return m_SelectedColor;
diff --git a/include/colors.h b/include/colors.h
index 6b58bb7..67a9e73 100644
--- a/include/colors.h
+++ b/include/colors.h
@@ -22,6 +22,15 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
 
+/**
+ * NOTE: EDA_COLOR_T is deprecated and is kept around for compatibility with
+ *       legacy canvas.  Once there is no need for legacy support, the color
+ *       table g_ColorRefs in colors.cpp can be re-written in COLOR4D and this
+ *       file can go away.
+ *
+ *       Please use COLOR4D instead of including this file.
+ */
+
 #ifndef COLORS_H_
 #define COLORS_H_
 
diff --git a/include/common.h b/include/common.h
index dbd4dd6..a083de8 100644
--- a/include/common.h
+++ b/include/common.h
@@ -40,7 +40,7 @@
 #include <wx/fileconf.h>
 
 #include <richio.h>
-#include <colors.h>
+#include <gal/color4d.h>
 
 #include <atomic>
 
@@ -181,7 +181,7 @@ enum EDA_UNITS_T {
 extern EDA_UNITS_T  g_UserUnit;     ///< display units
 
 /// Draw color for moving objects.
-extern EDA_COLOR_T  g_GhostColor;
+extern KIGFX::COLOR4D  g_GhostColor;
 
 
 /**
diff --git a/include/config_params.h b/include/config_params.h
index 9d4dad1..c01f867 100644
--- a/include/config_params.h
+++ b/include/config_params.h
@@ -34,9 +34,11 @@
 #include <wx/confbase.h>
 #include <wx/fileconf.h>
 #include <boost/ptr_container/ptr_vector.hpp>
-#include <colors.h>
+#include <gal/color4d.h>
 #include <limits>
 
+using KIGFX::COLOR4D;
+
 /// Names of sub sections where to store project info in *.pro project config files
 #define GROUP_PCB           wxT( "/pcbnew" )            /// parameters for Pcbnew/Modedit
 #define GROUP_SCH           wxT( "/eeschema" )          /// library list and lib paths list
@@ -183,14 +185,14 @@ public:
 class PARAM_CFG_SETCOLOR : public PARAM_CFG_BASE
 {
 public:
-    EDA_COLOR_T* m_Pt_param;    ///<  Pointer to the parameter value
-    EDA_COLOR_T  m_Default;     ///<  The default value of the parameter
+    COLOR4D* m_Pt_param;    ///<  Pointer to the parameter value
+    COLOR4D  m_Default;     ///<  The default value of the parameter
 
 public:
-    PARAM_CFG_SETCOLOR( const wxString& ident, EDA_COLOR_T* ptparam,
-                        EDA_COLOR_T default_val, const wxChar* group = NULL );
-    PARAM_CFG_SETCOLOR( bool Insetup, const wxString& ident, EDA_COLOR_T* ptparam,
-                        EDA_COLOR_T default_val, const wxChar* group = NULL );
+    PARAM_CFG_SETCOLOR( const wxString& ident, COLOR4D* ptparam,
+                        COLOR4D default_val, const wxChar* group = NULL );
+    PARAM_CFG_SETCOLOR( bool Insetup, const wxString& ident, COLOR4D* ptparam,
+                        COLOR4D default_val, const wxChar* group = NULL );
 
     virtual void ReadParam( wxConfigBase* aConfig ) const override;
     virtual void SaveParam( wxConfigBase* aConfig ) const override;
diff --git a/include/draw_frame.h b/include/draw_frame.h
index 537e781..979c69c 100644
--- a/include/draw_frame.h
+++ b/include/draw_frame.h
@@ -30,10 +30,13 @@
 #include <kiway_player.h>
 #include <climits>
 #include <gal/gal_display_options.h>
+#include <gal/color4d.h>
 
 class wxSingleInstanceChecker;
 class EDA_HOTKEY;
 
+using KIGFX::COLOR4D;
+
 #define DEFAULT_MAX_UNDO_ITEMS 0
 #define ABS_MAX_UNDO_ITEMS (INT_MAX / 2)
 
@@ -69,8 +72,8 @@ protected:
                                             // a wxCommand ID = ID_POPUP_GRID_LEVEL_1000.
     bool        m_drawGrid;                 // hide/Show grid
     bool        m_showPageLimits;           ///< true to display the page limits
-    EDA_COLOR_T m_gridColor;                // Grid color
-    EDA_COLOR_T m_drawBgColor;              ///< the background color of the draw canvas
+    COLOR4D     m_gridColor;                ///< Grid color
+    COLOR4D     m_drawBgColor;              ///< the background color of the draw canvas
                                             ///< BLACK for Pcbnew, BLACK or WHITE for eeschema
     double      m_zoomLevelCoeff;           ///< a suitable value to convert the internal zoom scaling factor
                                             // to a zoom level value which rougly gives 1.0 when the board/schematic
@@ -275,14 +278,14 @@ public:
     // the background color of the draw canvas:
     // Virtual because some frames can have a specific way to get/set the bg color
     /**
-     * @return the EDA_COLOR_T for the canvas background
+     * @return the COLOR4D for the canvas background
      */
-    virtual EDA_COLOR_T GetDrawBgColor() const { return m_drawBgColor; }
+    virtual COLOR4D GetDrawBgColor() const { return m_drawBgColor; }
 
     /**
-     * @param aColor: the EDA_COLOR_T for the canvas background
+     * @param aColor: the COLOR4D for the canvas background
      */
-    virtual void SetDrawBgColor( EDA_COLOR_T aColor) { m_drawBgColor= aColor ; }
+    virtual void SetDrawBgColor( COLOR4D aColor) { m_drawBgColor= aColor ; }
 
     int GetCursorShape() const { return m_cursorShape; }
 
@@ -430,7 +433,7 @@ public:
      * Function GetGridColor() , virtual
      * @return the color of the grid
      */
-    virtual EDA_COLOR_T GetGridColor() const
+    virtual COLOR4D GetGridColor() const
     {
         return m_gridColor;
     }
@@ -439,7 +442,7 @@ public:
      * Function SetGridColor() , virtual
      * @param aColor = the new color of the grid
      */
-    virtual void SetGridColor( EDA_COLOR_T aColor )
+    virtual void SetGridColor( COLOR4D aColor )
     {
         m_gridColor = aColor;
     }
@@ -711,7 +714,7 @@ public:
      * @param pad - Number of spaces to pad between messages (default = 4).
      */
     void AppendMsgPanel( const wxString& textUpper, const wxString& textLower,
-                         EDA_COLOR_T color, int pad = 6 );
+                         COLOR4D color, int pad = 6 );
 
     /**
      * Clear all messages from the message panel.
diff --git a/include/drawtxt.h b/include/drawtxt.h
index faf61cf..c87873c 100644
--- a/include/drawtxt.h
+++ b/include/drawtxt.h
@@ -86,7 +86,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool italic, b
  *  @param aClipBox = the clipping rect, or NULL if no clipping
  *  @param aDC = the current Device Context. NULL if draw within a 3D GL Canvas
  *  @param aPos = text position (according to h_justify, v_justify)
- *  @param aColor (enum EDA_COLOR_T) = text color
+ *  @param aColor (COLOR4D) = text color
  *  @param aText = text to draw
  *  @param aOrient = angle in 0.1 degree
  *  @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
@@ -105,7 +105,7 @@ int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool italic, b
 void DrawGraphicText( EDA_RECT* aClipBox,
                       wxDC * aDC,
                       const wxPoint &aPos,
-                      enum EDA_COLOR_T aColor,
+                      const COLOR4D aColor,
                       const wxString &aText,
                       double aOrient,
                       const wxSize &aSize,
@@ -127,9 +127,9 @@ void DrawGraphicText( EDA_RECT* aClipBox,
 void DrawGraphicHaloText( EDA_RECT* aClipBox,
                           wxDC * aDC,
                           const wxPoint &aPos,
-                          enum EDA_COLOR_T aBgColor,
-                          enum EDA_COLOR_T aColor1,
-                          enum EDA_COLOR_T aColor2,
+                          const COLOR4D aBgColor,
+                          COLOR4D aColor1,
+                          COLOR4D aColor2,
                           const wxString &aText,
                           double aOrient,
                           const wxSize &aSize,
diff --git a/include/eda_text.h b/include/eda_text.h
index 4580484..fafda2e 100644
--- a/include/eda_text.h
+++ b/include/eda_text.h
@@ -238,12 +238,12 @@ public:
      * @param aColor = text color
      * @param aDrawMode = GR_OR, GR_XOR.., -1 to use the current mode.
      * @param aDisplay_mode = FILLED or SKETCH
-     * @param aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ).
+     * @param aAnchor_color = anchor color ( UNSPECIFIED_COLOR4D = do not draw anchor ).
      */
     void Draw( EDA_RECT* aClipBox, wxDC* aDC,
-               const wxPoint& aOffset, EDA_COLOR_T aColor,
+               const wxPoint& aOffset, COLOR4D aColor,
                GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aDisplay_mode = FILLED,
-               EDA_COLOR_T aAnchor_color = EDA_COLOR_T(UNSPECIFIED_COLOR) );
+               COLOR4D aAnchor_color = UNSPECIFIED_COLOR4D );
 
     /**
      * Convert the text shape to a list of segment
@@ -362,7 +362,7 @@ private:
      * @param aPos = the position of this line ).
      */
     void drawOneLineOfText( EDA_RECT* aClipBox, wxDC* aDC,
-                            const wxPoint& aOffset, EDA_COLOR_T aColor,
+                            const wxPoint& aOffset, COLOR4D aColor,
                             GR_DRAWMODE aDrawMode, EDA_DRAW_MODE_T aFillMode,
                             const wxString& aText, const wxPoint& aPos );
 
diff --git a/include/gal/color4d.h b/include/gal/color4d.h
index 46ae899..ba5ed34 100644
--- a/include/gal/color4d.h
+++ b/include/gal/color4d.h
@@ -77,6 +77,65 @@ public:
      * @param aColor is the color type used by wxWidgets.
      */
     COLOR4D( const wxColour& aColor );
+
+    /**
+     * Function SetFromWxString
+     * Sets color values by parsing a string using wxColour::Set()
+     *
+     * @param aColorString is a color string that wxColour can understand
+     * @return true if color was set successfully
+     */
+    bool SetFromWxString( const wxString& aColorString );
+
+    wxString ToWxString( long flags );
+
+    wxColour ToColour() const
+    {
+        wxColour colour( r * 255, g * 255, b * 255, a * 255 );
+        return colour;
+    }
+
+    /**
+     * Function LegacyMix()
+     * Mixes this COLOR4D with an input COLOR4D using the OR-mixing of legacy canvas.
+     *
+     * Can be removed once legacy canvas is removed.
+     * Depends on wxColour for simplicity, but could be re-written to avoid
+     * this dependency if desired.
+     *
+     * @param aColor The color to mix with this one
+     */
+    COLOR4D LegacyMix( COLOR4D aColor ) const;
+
+    /**
+     * Function SetToLegacyHighlightColor()
+     * Sets the color to the "light" version of the nearest matching
+     * legacy color (see g_ColorRefs in colors.cpp).
+     */
+    COLOR4D& SetToLegacyHighlightColor();
+
+    /**
+     * Function SetToNearestLegacyColor()
+     * Sets the color to the nearest matching
+     * legacy color (see g_ColorRefs in colors.cpp).
+     */
+    COLOR4D& SetToNearestLegacyColor();
+
+    /**
+     * Packs the color into an unsigned int for compatibility with legacy canvas.
+     * Note that this is a lossy downsampling and also that the alpha channel is lost.
+     */
+    unsigned int ToU32() const;
+
+    /**
+     * Unpacks from a unsigned int in the legacy EDA_COLOR_T format.
+     */
+    void FromU32( unsigned int aPackedColor );
+
+    /**
+     * Determines the "nearest" EDA_COLOR_T according to ColorFindNearest
+     */
+    static EDA_COLOR_T GetNearestLegacyColor( COLOR4D &aColor );
 #endif /* WX_COMPATIBLITY */
 
     /**
@@ -205,18 +264,27 @@ public:
      */
     void FromHSV( double aInH, double aInS, double aInV );
 
-    /// @brief Equality operator, are two colors equal
-    const bool operator==( const COLOR4D& aColor );
-
-    /// @brief Not equality operator, are two colors not equal
-    const bool operator!=( const COLOR4D& aColor );
-
     // Color components: red, green, blue, alpha
     double r; ///< Red component
     double g; ///< Green component
     double b; ///< Blue component
     double a; ///< Alpha component
 };
+
+/// @brief Equality operator, are two colors equal
+const bool operator==( const COLOR4D& lhs, const COLOR4D& rhs );
+
+/// @brief Not equality operator, are two colors not equal
+const bool operator!=( const COLOR4D& lhs, const COLOR4D& rhs );
+
 } // namespace KIGFX
 
+/// For legacy support; used as a value to indicate color hasn't been set yet
+#define UNSPECIFIED_COLOR4D ( KIGFX::COLOR4D( 0, 0, 0, 0 ) )
+
+/// Declare a few color shortcuts that are used for comparisons frequently
+#define COLOR4D_WHITE ( KIGFX::COLOR4D( 1, 1, 1, 1 ) )
+#define COLOR4D_BLACK ( KIGFX::COLOR4D( 0, 0, 0, 1 ) )
+
+
 #endif /* COLOR4D_H_ */
diff --git a/include/gr_basic.h b/include/gr_basic.h
index c68ea5a..1e4d513 100644
--- a/include/gr_basic.h
+++ b/include/gr_basic.h
@@ -30,10 +30,12 @@
 #ifndef GR_BASIC
 #define GR_BASIC
 
-#include <colors.h>
+#include <gal/color4d.h>
 #include <vector>
 class EDA_RECT;
 
+using KIGFX::COLOR4D;
+
 
 /// Drawmode. Compositing mode plus a flag or two
 enum GR_DRAWMODE {
@@ -94,8 +96,8 @@ class EDA_DRAW_PANEL;
 void GRSetDrawMode( wxDC* DC, GR_DRAWMODE mode );
 GR_DRAWMODE  GRGetDrawMode( wxDC* DC );
 void GRResetPenAndBrush( wxDC* DC );
-void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width = 1, wxPenStyle stype = wxPENSTYLE_SOLID );
-void GRSetBrush( wxDC* DC, EDA_COLOR_T Color, bool fill = false );
+void GRSetColorPen( wxDC* DC, COLOR4D Color, int width = 1, wxPenStyle stype = wxPENSTYLE_SOLID );
+void GRSetBrush( wxDC* DC, COLOR4D Color, bool fill = false );
 
 /**
  * Function GRForceBlackPen
@@ -110,24 +112,24 @@ void GRForceBlackPen( bool flagforce );
 bool GetGRForceBlackPenState( void );
 
 void GRLine( EDA_RECT* aClipBox, wxDC* aDC,
-             wxPoint aStart, wxPoint aEnd, int aWidth, EDA_COLOR_T aColor );
+             wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor );
 void GRLine( EDA_RECT* ClipBox, wxDC* DC,
-             int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color );
+             int x1, int y1, int x2, int y2, int width, COLOR4D Color );
 void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-                  int width, EDA_COLOR_T Color );
+                  int width, COLOR4D Color );
 void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int  y2,
-                   int width, EDA_COLOR_T Color );
+                   int width, COLOR4D Color );
 void GRMoveTo( int x, int y );
 void GRLineTo( EDA_RECT* ClipBox, wxDC* DC,
-               int x, int y, int width, EDA_COLOR_T Color );
+               int x, int y, int width, COLOR4D Color );
 
 void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill,
-             int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor );
+             int width, COLOR4D Color, COLOR4D BgColor );
 
 void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-               int x3, int y3, int width, EDA_COLOR_T Color );
+               int x3, int y3, int width, COLOR4D Color );
 void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-               int x3, int y3, int x4, int y4, int width, EDA_COLOR_T Color );
+               int x3, int y3, int x4, int y4, int width, COLOR4D Color );
 
 /**
  * Function GRClosedPoly
@@ -138,7 +140,7 @@ void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
  * @param aPointCount the number of points in the array \a aPoints.
  * @param aPoints The points to draw.
  * @param doFill true if polygon is to be filled, else false and only the boundary is drawn.
- * @param aPenColor the color index of the border.
+ * @param aPenColor the color of the border.
  * @param aFillColor the fill color of the polygon's interior.
  */
 void GRClosedPoly( EDA_RECT* ClipBox,
@@ -146,8 +148,8 @@ void GRClosedPoly( EDA_RECT* ClipBox,
                    int       aPointCount,
                    wxPoint   aPoints[],
                    bool      doFill,
-                   EDA_COLOR_T aPenColor,
-                   EDA_COLOR_T aFillColor );
+                   COLOR4D   aPenColor,
+                   COLOR4D   aFillColor );
 
 // @todo could make these 2 closed polygons calls a single function and default
 // the aPenWidth argument
@@ -162,7 +164,7 @@ void GRClosedPoly( EDA_RECT* ClipBox,
  * @param aPoints the points to draw.
  * @param doFill true if polygon is to be filled, else false and only the boundary is drawn.
  * @param aPenWidth is the width of the pen to use on the perimeter, can be zero.
- * @param aPenColor the color index of the border.
+ * @param aPenColor the color of the border.
  * @param aFillColor the fill color of the polygon's interior.
  */
 void GRClosedPoly( EDA_RECT* ClipBox,
@@ -171,8 +173,8 @@ void GRClosedPoly( EDA_RECT* ClipBox,
                    wxPoint   aPoints[],
                    bool      doFill,
                    int       aPenWidth,
-                   EDA_COLOR_T aPenColor,
-                   EDA_COLOR_T aFillColor );
+                   COLOR4D   aPenColor,
+                   COLOR4D   aFillColor );
 
 
 /**
@@ -185,59 +187,59 @@ void GRClosedPoly( EDA_RECT* ClipBox,
  * @param x The x coordinate in user space of the center of the circle.
  * @param y The y coordinate in user space of the center of the circle.
  * @param aRadius is the radius of the circle.
- * @param aColor is an index into our color table of RGB colors.
- * @see EDA_COLOR_T and colors.h
+ * @param aColor is the color to draw
+ * @see COLOR4D
  */
-void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, EDA_COLOR_T aColor );
-void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int  width, EDA_COLOR_T Color );
+void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, COLOR4D aColor );
+void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int  width, COLOR4D Color );
 void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
-                     EDA_COLOR_T Color, EDA_COLOR_T BgColor );
-void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, EDA_COLOR_T aColor );
-void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, EDA_COLOR_T aColor );
+                     COLOR4D Color, COLOR4D BgColor );
+void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, COLOR4D aColor );
+void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor );
 
 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
-            double EndAngle, int r, EDA_COLOR_T Color );
+            double EndAngle, int r, COLOR4D Color );
 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
-            double EndAngle, int r, int width, EDA_COLOR_T Color );
+            double EndAngle, int r, int width, COLOR4D Color );
 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-             int xc, int yc, EDA_COLOR_T Color );
+             int xc, int yc, COLOR4D Color );
 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-             int xc, int yc, int width, EDA_COLOR_T Color );
+             int xc, int yc, int width, COLOR4D Color );
 void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
-             wxPoint aCenter, int aWidth, EDA_COLOR_T aColor );
+             wxPoint aCenter, int aWidth, COLOR4D aColor );
 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
-                  double StAngle, double EndAngle, int r, EDA_COLOR_T Color, EDA_COLOR_T BgColor );
+                  double StAngle, double EndAngle, int r, COLOR4D Color, COLOR4D BgColor );
 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
-                  double EndAngle, int r, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor );
-void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color );
+                  double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor );
+void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color );
 
 void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-                  int width, EDA_COLOR_T Color );
+                  int width, COLOR4D Color );
 void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
-                      int aWidth, EDA_COLOR_T aColor );
+                      int aWidth, COLOR4D aColor );
 
 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
-              int width, int aPenSize, EDA_COLOR_T Color );
+              int width, int aPenSize, COLOR4D Color );
 void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
-              int aWidth, EDA_COLOR_T aColor );
+              int aWidth, COLOR4D aColor );
 
-void GRSetColor( EDA_COLOR_T Color );
+void GRSetColor( COLOR4D Color );
 void GRSetDefaultPalette();
-EDA_COLOR_T  GRGetColor();
-void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, EDA_COLOR_T color );
+COLOR4D  GRGetColor();
+void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, COLOR4D color );
 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
-                   int x2, int y2, EDA_COLOR_T Color, EDA_COLOR_T BgColor );
+                   int x2, int y2, COLOR4D Color, COLOR4D BgColor );
 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
-                   int x2, int y2, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor );
-void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, EDA_COLOR_T Color );
-void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, EDA_COLOR_T Color );
+                   int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
+void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, COLOR4D Color );
+void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, COLOR4D Color );
 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
-             int x2, int y2, int width, EDA_COLOR_T Color );
+             int x2, int y2, int width, COLOR4D Color );
 void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect,
-               int aWidth, EDA_COLOR_T aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
+               int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
 
 void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
-                    int x2, int y2, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor );
+                    int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
 
 /**
  * Function GRLineArray
@@ -246,13 +248,13 @@ void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
  * @param aDC = the device context into which drawing should occur.
  * @param aLines = a list of pair of coordinate in user space: a pair for each line.
  * @param aWidth = the width of each line.
- * @param aColor = an index into our color table of RGB colors.
- * @see EDA_COLOR_T and colors.h
+ * @param aColor = the color of the lines
+ * @see COLOR4D
  */
 void GRLineArray(  EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
-                   int aWidth, EDA_COLOR_T aColor );
+                   int aWidth, COLOR4D aColor );
 
 void GRDrawAnchor( EDA_RECT* aClipBox, wxDC *aDC, int x, int y, int aSize,
-                   EDA_COLOR_T aColor );
+                   COLOR4D aColor );
 
 #endif      /* define GR_BASIC */
diff --git a/include/msgpanel.h b/include/msgpanel.h
index 31478f2..f4dbe13 100644
--- a/include/msgpanel.h
+++ b/include/msgpanel.h
@@ -32,12 +32,13 @@
 #define  _MSGPANEL_H_
 
 
-#include <colors.h>
+#include <gal/color4d.h>
 
 #include <wx/window.h>
 
 #include <vector>
 
+using KIGFX::COLOR4D;
 
 #define MSG_PANEL_DEFAULT_PAD      6  ///< The default number of spaces between each text string.
 
@@ -56,13 +57,13 @@ class MSG_PANEL_ITEM
     int         m_LowerY;
     wxString    m_UpperText;
     wxString    m_LowerText;
-    EDA_COLOR_T m_Color;
+    COLOR4D     m_Color;
     int         m_Pad;
 
     friend class EDA_MSG_PANEL;
 
 public:
-    MSG_PANEL_ITEM( const wxString& aUpperText, const wxString& aLowerText, EDA_COLOR_T aColor,
+    MSG_PANEL_ITEM( const wxString& aUpperText, const wxString& aLowerText, COLOR4D aColor,
                     int aPad = MSG_PANEL_DEFAULT_PAD ) :
         m_UpperText( aUpperText ),
         m_LowerText( aLowerText ),
@@ -81,7 +82,7 @@ public:
         m_X = 0;
         m_UpperY = 0;
         m_LowerY = 0;
-        m_Color = UNSPECIFIED_COLOR;
+        m_Color = UNSPECIFIED_COLOR4D;
     }
 
     void SetUpperText( const wxString& aUpperText ) { m_UpperText = aUpperText; }
@@ -90,8 +91,8 @@ public:
     void SetLowerText( const wxString& aLowerText )  { m_LowerText = aLowerText; }
     const wxString& GetLowerText() const { return m_LowerText; }
 
-    void SetColor( EDA_COLOR_T aColor ) { m_Color = aColor; }
-    EDA_COLOR_T GetColor() const { return m_Color; }
+    void SetColor( COLOR4D aColor ) { m_Color = aColor; }
+    COLOR4D GetColor() const { return m_Color; }
 
     void SetPadding( int aPad )  { m_Pad = aPad; }
     int GetPadding() const { return m_Pad; }
@@ -156,7 +157,7 @@ public:
      * @param aColor Color of the text to display.
      */
     void SetMessage( int aXPosition, const wxString& aUpperText,
-                     const wxString& aLowerText, EDA_COLOR_T aColor );
+                     const wxString& aLowerText, COLOR4D aColor );
 
    /**
     * Function AppendMessage
@@ -169,11 +170,11 @@ public:
     *
     * @param aUpperText The message upper text.
     * @param aLowerText The message lower text.
-    * @param aColor A color ID from the KiCad color list (see colors.h).
+    * @param aColor A color to use for the message text
     * @param aPad Number of spaces to pad between messages (default = 4).
     */
     void AppendMessage( const wxString& aUpperText, const wxString& aLowerText,
-                        EDA_COLOR_T aColor, int aPad = 6 );
+                        COLOR4D aColor, int aPad = 6 );
 
    /**
     * Function AppendMessage
diff --git a/include/painter.h b/include/painter.h
index cf586fa..f069475 100644
--- a/include/painter.h
+++ b/include/painter.h
@@ -31,7 +31,6 @@
 #include <set>
 
 #include <gal/color4d.h>
-#include <colors.h>
 #include <worksheet_shape_builder.h>
 #include <memory>
 
@@ -178,16 +177,6 @@ public:
     }
 
     /**
-     * Function TranslateColor
-     * Returns the color responding to the one of EDA_COLOR_T enum values.
-     * @param aColor equivalent.
-     */
-    inline const COLOR4D& TranslateColor( EDA_COLOR_T aColor )
-    {
-        return m_legacyColorMap[aColor];
-    }
-
-    /**
      * Function GetBackgroundColor
      * Returns current background color settings.
      * @return Background color.
@@ -234,9 +223,6 @@ protected:
     float   m_worksheetLineWidth;   ///< Line width used when drawing worksheet
 
     COLOR4D m_backgroundColor;      ///< The background color
-
-    /// Map of colors that were usually used for display
-    std::map<EDA_COLOR_T, COLOR4D> m_legacyColorMap;
 };
 
 
diff --git a/include/plot_common.h b/include/plot_common.h
index e2df2c6..c75fda7 100644
--- a/include/plot_common.h
+++ b/include/plot_common.h
@@ -144,7 +144,7 @@ public:
         return currentPenWidth;
     }
 
-    virtual void SetColor( EDA_COLOR_T color ) = 0;
+    virtual void SetColor( COLOR4D color ) = 0;
 
     virtual void SetDash( bool dashed ) = 0;
 
@@ -364,7 +364,7 @@ public:
      * for specific plotters (GERBER) aData is used to pass extra parameters
      */
     virtual void Text( const wxPoint&              aPos,
-                       enum EDA_COLOR_T            aColor,
+                       const COLOR4D               aColor,
                        const wxString&             aText,
                        double                      aOrient,
                        const wxSize&               aSize,
@@ -581,7 +581,7 @@ public:
     virtual void SetDefaultLineWidth( int width ) override {}
     virtual void SetDash( bool dashed ) override;
 
-    virtual void SetColor( EDA_COLOR_T color ) override {}
+    virtual void SetColor( COLOR4D color ) override {}
 
     virtual void SetPenSpeed( int speed )
     {
@@ -686,7 +686,7 @@ public:
      * The PSLIKE computes the rgb values, the subclass emits the
      * operator to actually do it
      */
-    virtual void SetColor( EDA_COLOR_T color ) override;
+    virtual void SetColor( COLOR4D color ) override;
 
 protected:
     void computeTextParameters( const wxPoint&           aPos,
@@ -771,7 +771,7 @@ public:
 
     virtual void PenTo( const wxPoint& pos, char plume ) override;
     virtual void Text( const wxPoint&              aPos,
-                       enum EDA_COLOR_T            aColor,
+                       const COLOR4D               aColor,
                        const wxString&             aText,
                        double                      aOrient,
                        const wxSize&               aSize,
@@ -842,7 +842,7 @@ public:
     virtual void PenTo( const wxPoint& pos, char plume ) override;
 
     virtual void Text( const wxPoint&              aPos,
-                       enum EDA_COLOR_T            aColor,
+                       const COLOR4D               aColor,
                        const wxString&             aText,
                        double                      aOrient,
                        const wxSize&               aSize,
@@ -890,7 +890,7 @@ public:
         return PLOT_FORMAT_SVG;
     }
 
-    virtual void SetColor( EDA_COLOR_T color ) override;
+    virtual void SetColor( COLOR4D color ) override;
     virtual bool StartPlot() override;
     virtual bool EndPlot() override;
     virtual void SetCurrentLineWidth( int width, void* aData = NULL ) override;
@@ -914,7 +914,7 @@ public:
 
     virtual void PenTo( const wxPoint& pos, char plume ) override;
     virtual void Text( const wxPoint&              aPos,
-                       enum EDA_COLOR_T            aColor,
+                       const COLOR4D               aColor,
                        const wxString&             aText,
                        double                      aOrient,
                        const wxSize&               aSize,
@@ -1009,7 +1009,7 @@ public:
 
     // RS274X has no dashing, nor colours
     virtual void SetDash( bool dashed ) override {}
-    virtual void SetColor( EDA_COLOR_T color ) override {}
+    virtual void SetColor( COLOR4D color ) override {}
     // Currently, aScale and aMirror are not used in gerber plotter
     virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
                           double aScale, bool aMirror ) override;
@@ -1040,7 +1040,7 @@ public:
     virtual void PenTo( const wxPoint& pos, char plume ) override;
 
     virtual void Text( const wxPoint&              aPos,
-                       enum EDA_COLOR_T            aColor,
+                       const COLOR4D               aColor,
                        const wxString&             aText,
                        double                      aOrient,
                        const wxSize&               aSize,
@@ -1209,7 +1209,7 @@ public:
     DXF_PLOTTER() : textAsLines( false )
     {
         textAsLines = true;
-        m_currentColor = BLACK;
+        m_currentColor = COLOR4D_BLACK;
     }
 
     virtual PlotFormat GetPlotterType() const override
@@ -1248,7 +1248,7 @@ public:
 
     virtual void SetDash( bool dashed ) override;
 
-    virtual void SetColor( EDA_COLOR_T color ) override;
+    virtual void SetColor( COLOR4D color ) override;
 
     virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
                   double aScale, bool aMirror ) override;
@@ -1280,7 +1280,7 @@ public:
                                  double aPadOrient, EDA_DRAW_MODE_T aTrace_Mode, void* aData ) override;
 
     virtual void Text( const wxPoint&              aPos,
-                       enum EDA_COLOR_T            aColor,
+                       const COLOR4D               aColor,
                        const wxString&             aText,
                        double                      aOrient,
                        const wxSize&               aSize,
@@ -1294,7 +1294,7 @@ public:
 
 protected:
     bool textAsLines;
-    EDA_COLOR_T m_currentColor;
+    COLOR4D m_currentColor;
 };
 
 class TITLE_BLOCK;
diff --git a/include/worksheet.h b/include/worksheet.h
index cb2a667..b77fd31 100644
--- a/include/worksheet.h
+++ b/include/worksheet.h
@@ -26,7 +26,7 @@
 #ifndef WORKSHEET_H_
 #define WORKSHEET_H_
 
-#include <colors.h>     // EDA_COLOR_T definition
+#include <gal/color4d.h>
 #include <class_page_info.h>
 
 // Forward declarations:
@@ -34,6 +34,8 @@ class EDA_DRAW_PANEL;
 class EDA_RECT;
 class TITLE_BLOCK;
 
+using KIGFX::COLOR4D;
+
 /**
  * Function DrawPageLayout is a core function to draw the page layout with
  * the frame and the basic inscriptions.
@@ -63,7 +65,7 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
                      TITLE_BLOCK& aTitleBlock,
                      int aSheetCount, int aSheetNumber,
                      int aPenWidth, double aScalar,
-                     EDA_COLOR_T aColor, EDA_COLOR_T aAltColor,
+                     COLOR4D aColor, COLOR4D aAltColor,
                      const wxString& aSheetLayer = wxEmptyString );
 
 
diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h
index 8cd5f22..b88a5bd 100644
--- a/include/worksheet_shape_builder.h
+++ b/include/worksheet_shape_builder.h
@@ -63,13 +63,13 @@ public:
 
 protected:
     WS_DRAW_TYPE    m_type; // wsg_line, wsg_rect, wsg_poly, wsg_text
-    EDA_COLOR_T     m_color;
+    COLOR4D         m_color;
     WORKSHEET_DATAITEM*  m_parent;  // an unique identifier, used as link
                                     // to the parent WORKSHEET_DATAITEM item,
                                     // in page layout editor
 
     WS_DRAW_ITEM_BASE( WORKSHEET_DATAITEM*  aParent,
-                       WS_DRAW_TYPE aType, EDA_COLOR_T aColor )
+                       WS_DRAW_TYPE aType, COLOR4D aColor )
     {
         m_type  = aType;
         m_color = aColor;
@@ -81,7 +81,7 @@ public:
     virtual ~WS_DRAW_ITEM_BASE() {}
 
     // Accessors:
-    EDA_COLOR_T GetColor() const { return m_color; }
+    COLOR4D GetColor() const { return m_color; }
     WS_DRAW_TYPE GetType() const { return m_type; };
 
     WORKSHEET_DATAITEM* GetParent() const { return m_parent; }
@@ -91,13 +91,13 @@ public:
     virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC)
     {
         wxPoint offset( 0, 0 );
-        DrawWsItem( aClipBox, aDC, offset, UNSPECIFIED_DRAWMODE, UNSPECIFIED_COLOR );
+        DrawWsItem( aClipBox, aDC, offset, UNSPECIFIED_DRAWMODE, UNSPECIFIED_COLOR4D );
     }
 
     /// More advanced version of DrawWsItem. This is what must be
     /// defined in the derived type.
     virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-            GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) = 0;
+            GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) = 0;
 
     /**
      * Abstract function: should exist for derived items
@@ -143,7 +143,7 @@ class WS_DRAW_ITEM_LINE : public WS_DRAW_ITEM_BASE
 public:
     WS_DRAW_ITEM_LINE( WORKSHEET_DATAITEM* aParent,
                        wxPoint aStart, wxPoint aEnd,
-                       int aPenWidth, EDA_COLOR_T aColor ) :
+                       int aPenWidth, COLOR4D aColor ) :
         WS_DRAW_ITEM_BASE( aParent, wsg_line, aColor )
     {
         m_start     = aStart;
@@ -159,7 +159,7 @@ public:
     /** The function to draw a WS_DRAW_ITEM_LINE
      */
     virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-            GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+            GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     /**
      * Virtual function
@@ -200,7 +200,7 @@ public:
 
 public:
     WS_DRAW_ITEM_POLYGON( WORKSHEET_DATAITEM* aParent, wxPoint aPos,
-                          bool aFill, int aPenWidth, EDA_COLOR_T aColor ) :
+                          bool aFill, int aPenWidth, COLOR4D aColor ) :
         WS_DRAW_ITEM_BASE( aParent, wsg_poly, aColor )
     {
         m_penWidth = aPenWidth;
@@ -216,7 +216,7 @@ public:
     /** The function to draw a WS_DRAW_ITEM_POLYGON
      */
     virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-            GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+            GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     /**
      * Virtual function
@@ -242,7 +242,7 @@ class WS_DRAW_ITEM_RECT : public WS_DRAW_ITEM_LINE
 public:
     WS_DRAW_ITEM_RECT( WORKSHEET_DATAITEM* aParent,
                        wxPoint aStart, wxPoint aEnd,
-                       int aPenWidth, EDA_COLOR_T aColor ) :
+                       int aPenWidth, COLOR4D aColor ) :
         WS_DRAW_ITEM_LINE( aParent, aStart, aEnd, aPenWidth, aColor )
     {
         m_type = wsg_rect;
@@ -251,7 +251,7 @@ public:
     /** The function to draw a WS_DRAW_ITEM_RECT
      */
     virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-            GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+            GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     /**
      * Virtual function
@@ -286,13 +286,13 @@ class WS_DRAW_ITEM_TEXT : public WS_DRAW_ITEM_BASE, public EDA_TEXT
 public:
     WS_DRAW_ITEM_TEXT( WORKSHEET_DATAITEM* aParent,
                        wxString& aText, wxPoint aPos, wxSize aSize,
-                       int aPenWidth, EDA_COLOR_T aColor,
+                       int aPenWidth, COLOR4D aColor,
                        bool aItalic = false, bool aBold = false );
 
     /** The function to draw a WS_DRAW_ITEM_TEXT
      */
     virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-            GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+            GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     // Accessors:
     int GetPenWidth() { return GetThickness(); }
@@ -327,13 +327,13 @@ class WS_DRAW_ITEM_BITMAP : public WS_DRAW_ITEM_BASE
 
 public:
     WS_DRAW_ITEM_BITMAP( WORKSHEET_DATAITEM* aParent, wxPoint aPos )
-        :WS_DRAW_ITEM_BASE( aParent, wsg_bitmap, UNSPECIFIED_COLOR )
+        :WS_DRAW_ITEM_BASE( aParent, wsg_bitmap, UNSPECIFIED_COLOR4D )
     {
         m_pos = aPos;
     }
 
     WS_DRAW_ITEM_BITMAP()
-        :WS_DRAW_ITEM_BASE( NULL, wsg_bitmap, UNSPECIFIED_COLOR )
+        :WS_DRAW_ITEM_BASE( NULL, wsg_bitmap, UNSPECIFIED_COLOR4D )
     {
     }
 
@@ -342,7 +342,7 @@ public:
     /** The function to draw a WS_DRAW_ITEM_BITMAP
      */
     virtual void DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
-            GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) override;
+            GR_DRAWMODE aDrawMode, COLOR4D aColor = UNSPECIFIED_COLOR4D ) override;
 
     /**
      * Virtual function
@@ -557,7 +557,7 @@ public:
      */
     void BuildWorkSheetGraphicList( const PAGE_INFO& aPageInfo,
                                     const TITLE_BLOCK& aTitleBlock,
-                                    EDA_COLOR_T aColor, EDA_COLOR_T aAltColor );
+                                    COLOR4D aColor, COLOR4D aAltColor );
     /**
      * Function BuildFullText
      * returns the full text corresponding to the aTextbase,
diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h
index 7ee768d..7a2a2bf 100644
--- a/include/wxPcbStruct.h
+++ b/include/wxPcbStruct.h
@@ -117,6 +117,12 @@ protected:
      */
     void enableGALSpecificMenus();
 
+    /**
+     * Helper function to coerce all colors to legacy-compatible when
+     * switching from GAL to legacy canvas
+     */
+    void forceColorsToLegacy();
+
 #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
     /**
      * Function RebuildActionPluginMenus
@@ -356,13 +362,13 @@ public:
      * Function GetGridColor() , virtual
      * @return the color of the grid
      */
-    virtual EDA_COLOR_T GetGridColor() const override;
+    virtual COLOR4D GetGridColor() const override;
 
     /**
      * Function SetGridColor() , virtual
      * @param aColor = the new color of the grid
      */
-    virtual void SetGridColor( EDA_COLOR_T aColor ) override;
+    virtual void SetGridColor( COLOR4D aColor ) override;
 
     ///> @copydoc EDA_DRAW_FRAME::SetCursorShape()
     virtual void SetCursorShape( int aCursorShape ) override;
diff --git a/include/wxstruct.h b/include/wxstruct.h
index 35d4af9..02867fa 100644
--- a/include/wxstruct.h
+++ b/include/wxstruct.h
@@ -42,7 +42,6 @@
 #include <wx/aui/aui.h>
 #include <wx/docview.h>
 
-#include <colors.h>
 #include <fctsys.h>
 #include <common.h>
 #include <layers_id_colors_and_visibility.h>
diff --git a/kicad/CMakeLists.txt b/kicad/CMakeLists.txt
index 97d485a..b6b8823 100644
--- a/kicad/CMakeLists.txt
+++ b/kicad/CMakeLists.txt
@@ -73,6 +73,7 @@ else()
         common
         bitmaps
         polygon
+        gal
         ${wxWidgets_LIBRARIES}
         ${GDI_PLUS_LIBRARIES}
         )
diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt
index 70ebc9a..9116fcb 100644
--- a/pagelayout_editor/CMakeLists.txt
+++ b/pagelayout_editor/CMakeLists.txt
@@ -76,6 +76,7 @@ target_link_libraries( pl_editor
     # There's way too much crap coming in from common yet.
     common
     bitmaps
+    gal
     ${wxWidgets_LIBRARIES}
     )
 
diff --git a/pagelayout_editor/dialogs/dialogs_for_printing.cpp b/pagelayout_editor/dialogs/dialogs_for_printing.cpp
index 7a4f5f2..952bfe7 100644
--- a/pagelayout_editor/dialogs/dialogs_for_printing.cpp
+++ b/pagelayout_editor/dialogs/dialogs_for_printing.cpp
@@ -186,8 +186,8 @@ void PLEDITOR_PRINTOUT::DrawPage( int aPageNum )
     GRForceBlackPen( true );
     screen->m_IsPrinting = true;
 
-    EDA_COLOR_T bg_color = m_parent->GetDrawBgColor();
-    m_parent->SetDrawBgColor( WHITE );
+    COLOR4D bg_color = m_parent->GetDrawBgColor();
+    m_parent->SetDrawBgColor( MakeColour ( WHITE ) );
 
     screen->m_ScreenNumber = aPageNum;
     m_parent->DrawWorkSheet( dc, screen, 0, IU_PER_MILS, wxEmptyString );
diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp
index 58d83b5..0b2c68a 100644
--- a/pagelayout_editor/pl_editor_frame.cpp
+++ b/pagelayout_editor/pl_editor_frame.cpp
@@ -688,7 +688,7 @@ WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition )
 {
     const PAGE_INFO&    pageInfo = GetPageSettings();
     TITLE_BLOCK         t_block = GetTitleBlock();
-    EDA_COLOR_T         color = RED;    // Needed, not used
+    COLOR4D             color = COLOR4D( RED );    // Needed, not used
     PL_EDITOR_SCREEN*   screen = (PL_EDITOR_SCREEN*) GetScreen();
 
     screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt
index 292308c..94d6ce4 100644
--- a/pcb_calculator/CMakeLists.txt
+++ b/pcb_calculator/CMakeLists.txt
@@ -68,6 +68,7 @@ target_link_libraries( pcb_calculator
     # There's way too much crap coming in from common yet.
     common
     bitmaps
+    gal
     ${wxWidgets_LIBRARIES}
     )
 
diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt
index 7c36570..e409fcd 100644
--- a/pcbnew/CMakeLists.txt
+++ b/pcbnew/CMakeLists.txt
@@ -612,6 +612,7 @@ target_link_libraries( pcbnew
     # There's way too much crap coming in from common yet.
     common
     bitmaps
+    gal
     ${wxWidgets_LIBRARIES}
     )
 
diff --git a/pcbnew/autorouter/auto_place_footprints.cpp b/pcbnew/autorouter/auto_place_footprints.cpp
index 4493d75..3552579 100644
--- a/pcbnew/autorouter/auto_place_footprints.cpp
+++ b/pcbnew/autorouter/auto_place_footprints.cpp
@@ -412,7 +412,7 @@ end_of_tst:
 void drawPlacementRoutingMatrix( BOARD* aBrd, wxDC* DC )
 {
     int         ii, jj;
-    EDA_COLOR_T color;
+    COLOR4D     color;
     int         ox, oy;
     MATRIX_CELL top_state, bottom_state;
 
@@ -425,21 +425,21 @@ void drawPlacementRoutingMatrix( BOARD* aBrd, wxDC* DC )
         for( jj = 0; jj < RoutingMatrix.m_Ncols; jj++ )
         {
             ox      = RoutingMatrix.m_BrdBox.GetX() + (jj * RoutingMatrix.m_GridRouting);
-            color   = BLACK;
+            color   = COLOR4D_BLACK;
 
             top_state       = RoutingMatrix.GetCell( ii, jj, TOP );
             bottom_state    = RoutingMatrix.GetCell( ii, jj, BOTTOM );
 
             if( top_state & CELL_is_ZONE )
-                color = BLUE;
+                color = COLOR4D( BLUE );
 
             // obstacles
             if( ( top_state & CELL_is_EDGE ) || ( bottom_state & CELL_is_EDGE ) )
-                color = WHITE;
+                color = COLOR4D_WHITE;
             else if( top_state & ( HOLE | CELL_is_MODULE ) )
-                color = LIGHTRED;
+                color = COLOR4D( LIGHTRED );
             else if( bottom_state & (HOLE | CELL_is_MODULE) )
-                color = LIGHTGREEN;
+                color = COLOR4D( LIGHTGREEN );
             else    // Display the filling and keep out regions.
             {
                 if( RoutingMatrix.GetDist( ii, jj, TOP )
@@ -606,7 +606,7 @@ void genModuleOnRoutingMatrix( MODULE* Module )
 }
 
 // A minor helper function to draw a bounding box:
-inline void draw_FootprintRect(EDA_RECT * aClipBox, wxDC* aDC, EDA_RECT& fpBBox, EDA_COLOR_T aColor)
+inline void draw_FootprintRect(EDA_RECT * aClipBox, wxDC* aDC, EDA_RECT& fpBBox, COLOR4D aColor)
 {
 #ifndef USE_WX_OVERLAY
     GRRect( aClipBox, aDC, fpBBox, 0, aColor );
@@ -676,7 +676,7 @@ int getOptimalModulePlacement( PCB_EDIT_FRAME* aFrame, MODULE* aModule, wxDC* aD
     }
 
     // Draw the initial bounding box position
-    EDA_COLOR_T color = BROWN;
+    COLOR4D color = COLOR4D( BROWN );
     fpBBox.SetOrigin( fpBBoxOrg + CurrPosition );
     draw_FootprintRect(aFrame->GetCanvas()->GetClipBox(), aDC, fpBBox, color);
 
diff --git a/pcbnew/autorouter/autorout.cpp b/pcbnew/autorouter/autorout.cpp
index 7c53f0e..5044172 100644
--- a/pcbnew/autorouter/autorout.cpp
+++ b/pcbnew/autorouter/autorout.cpp
@@ -222,7 +222,7 @@ void PCB_EDIT_FRAME::Reset_Noroutable( wxDC* DC )
 void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC )
 {
     int dcell0;
-    EDA_COLOR_T color;
+    COLOR4D color;
 
     int maxi = 600 / RoutingMatrix.m_Ncols;
     maxi = ( maxi * 3 ) / 4;
@@ -236,11 +236,11 @@ void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC )
     {
         for( int row = 0; row < RoutingMatrix.m_Nrows; row++ )
         {
-            color  = BLACK;
+            color  = COLOR4D_BLACK;
             dcell0 = RoutingMatrix.GetCell( row, col, BOTTOM );
 
             if( dcell0 & HOLE )
-                color = GREEN;
+                color = COLOR4D( GREEN );
 
 #if 0
             int dcell1 = 0;
@@ -249,17 +249,17 @@ void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC )
                 dcell1 = GetCell( row, col, TOP );
 
             if( dcell1 & HOLE )
-                color = RED;
+                color = COLOR4D( RED );
 
             dcell0 |= dcell1;
 #endif
-            if( !color && ( dcell0 & VIA_IMPOSSIBLE ) )
-                color = BLUE;
+            if( ( color == COLOR4D_BLACK ) && ( dcell0 & VIA_IMPOSSIBLE ) )
+                color = COLOR4D( BLUE );
 
             if( dcell0 & CELL_is_EDGE )
-                color = YELLOW;
+                color = COLOR4D( YELLOW );
             else if( dcell0 & CELL_is_ZONE )
-                color = YELLOW;
+                color = COLOR4D( YELLOW );
 
             #define DRAW_OFFSET_X -20
             #define DRAW_OFFSET_Y 20
diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp
index cdeae72..92ee3e8 100644
--- a/pcbnew/board_items_to_polygon_shape_transform.cpp
+++ b/pcbnew/board_items_to_polygon_shape_transform.cpp
@@ -445,7 +445,7 @@ void TEXTE_PCB::TransformShapeWithClearanceToPolygonSet(
     s_cornerBuffer = &aCornerBuffer;
     s_textWidth  = GetThickness() + ( 2 * aClearanceValue );
     s_textCircle2SegmentCount = aCircleToSegmentsCount;
-    EDA_COLOR_T color = BLACK;  // not actually used, but needed by DrawGraphicText
+    COLOR4D color = COLOR4D_BLACK;  // not actually used, but needed by DrawGraphicText
 
     if( IsMultilineAllowed() )
     {
diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp
index d715f44..a6c82ab 100644
--- a/pcbnew/class_board.cpp
+++ b/pcbnew/class_board.cpp
@@ -777,9 +777,9 @@ void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled )
 }
 
 
-EDA_COLOR_T BOARD::GetVisibleElementColor( int aPCB_VISIBLE )
+COLOR4D BOARD::GetVisibleElementColor( int aPCB_VISIBLE )
 {
-    EDA_COLOR_T color = UNSPECIFIED_COLOR;
+    COLOR4D color = UNSPECIFIED_COLOR4D;
 
     switch( aPCB_VISIBLE )
     {
@@ -806,7 +806,7 @@ EDA_COLOR_T BOARD::GetVisibleElementColor( int aPCB_VISIBLE )
 }
 
 
-void BOARD::SetVisibleElementColor( int aPCB_VISIBLE, EDA_COLOR_T aColor )
+void BOARD::SetVisibleElementColor( int aPCB_VISIBLE, COLOR4D aColor )
 {
     switch( aPCB_VISIBLE )
     {
@@ -831,13 +831,13 @@ void BOARD::SetVisibleElementColor( int aPCB_VISIBLE, EDA_COLOR_T aColor )
 }
 
 
-void BOARD::SetLayerColor( LAYER_ID aLayer, EDA_COLOR_T aColor )
+void BOARD::SetLayerColor( LAYER_ID aLayer, COLOR4D aColor )
 {
     GetColorsSettings()->SetLayerColor( aLayer, aColor );
 }
 
 
-EDA_COLOR_T BOARD::GetLayerColor( LAYER_ID aLayer ) const
+COLOR4D BOARD::GetLayerColor( LAYER_ID aLayer ) const
 {
     return GetColorsSettings()->GetLayerColor( aLayer );
 }
diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h
index e43fa5a..1045e6d 100644
--- a/pcbnew/class_board.h
+++ b/pcbnew/class_board.h
@@ -520,9 +520,9 @@ public:
      * returns the color of a pcb visible element.
      * @see enum PCB_VISIBLE
      */
-    EDA_COLOR_T GetVisibleElementColor( int aPCB_VISIBLE );
+    COLOR4D GetVisibleElementColor( int aPCB_VISIBLE );
 
-    void SetVisibleElementColor( int aPCB_VISIBLE, EDA_COLOR_T aColor );
+    void SetVisibleElementColor( int aPCB_VISIBLE, COLOR4D aColor );
 
     /**
      * Function GetDesignSettings
@@ -685,13 +685,13 @@ public:
      * Function SetLayerColor
      * changes a layer color for any valid layer, including non-copper ones.
      */
-    void SetLayerColor( LAYER_ID aLayer, EDA_COLOR_T aColor );
+    void SetLayerColor( LAYER_ID aLayer, COLOR4D aColor );
 
     /**
      * Function GetLayerColor
      * gets a layer color for any valid layer, including non-copper ones.
      */
-    EDA_COLOR_T GetLayerColor( LAYER_ID aLayer ) const;
+    COLOR4D GetLayerColor( LAYER_ID aLayer ) const;
 
     /** Functions to get some items count */
     int GetNumSegmTrack() const;
diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp
index 0efa9fa..fd9b658 100644
--- a/pcbnew/class_dimension.cpp
+++ b/pcbnew/class_dimension.cpp
@@ -315,7 +315,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
 void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
                       const wxPoint& offset )
 {
-    EDA_COLOR_T gcolor;
+    COLOR4D     gcolor;
     BOARD*      brd = GetBoard();
 
     if( brd->IsLayerVisible( m_Layer ) == false )
diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp
index 50ddf98..03cb930 100644
--- a/pcbnew/class_drawsegment.cpp
+++ b/pcbnew/class_drawsegment.cpp
@@ -205,7 +205,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
     int radius;
 
     LAYER_ID    curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
-    EDA_COLOR_T color;
+    COLOR4D    color;
 
     BOARD * brd =  GetBoard( );
 
@@ -219,7 +219,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
     if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) &&  displ_opts && displ_opts->m_ContrastModeDisplay )
     {
         if( !IsOnLayer( curr_layer ) && !IsOnLayer( Edge_Cuts ) )
-            ColorTurnToDarkDarkGray( &color );
+            color = COLOR4D( DARKDARKGRAY );
     }
 
     GRSetDrawMode( DC, draw_mode );
diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp
index e49f7d7..868c9d4 100644
--- a/pcbnew/class_edge_mod.cpp
+++ b/pcbnew/class_edge_mod.cpp
@@ -118,13 +118,13 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
     if( brd->IsLayerVisible( m_Layer ) == false )
         return;
 
-    EDA_COLOR_T color = brd->GetLayerColor( m_Layer );
+    COLOR4D color = brd->GetLayerColor( m_Layer );
     DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
 
     if(( draw_mode & GR_ALLOW_HIGHCONTRAST ) && displ_opts && displ_opts->m_ContrastModeDisplay )
     {
         if( !IsOnLayer( curr_layer ) )
-            ColorTurnToDarkDarkGray( &color );
+            color = COLOR4D( DARKDARKGRAY );
     }
 
     ux0 = m_Start.x - offset.x;
diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp
index e447134..5fc552b 100644
--- a/pcbnew/class_mire.cpp
+++ b/pcbnew/class_mire.cpp
@@ -88,7 +88,7 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
     if( brd->IsLayerVisible( m_Layer ) == false )
         return;
 
-    EDA_COLOR_T gcolor = brd->GetLayerColor( m_Layer );
+    COLOR4D gcolor = brd->GetLayerColor( m_Layer );
 
     GRSetDrawMode( DC, mode_color );
     DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
diff --git a/pcbnew/class_netinfo_item.cpp b/pcbnew/class_netinfo_item.cpp
index c52e973..53cfe66 100644
--- a/pcbnew/class_netinfo_item.cpp
+++ b/pcbnew/class_netinfo_item.cpp
@@ -174,7 +174,7 @@ void RATSNEST_ITEM::Draw( EDA_DRAW_PANEL* panel,
 {
     GRSetDrawMode( DC, aDrawMode );
 
-    EDA_COLOR_T color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE);
+    COLOR4D color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE);
 
     GRLine( panel->GetClipBox(), DC,
             m_PadStart->GetPosition() - aOffset,
diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h
index d8c26a8..715285c 100644
--- a/pcbnew/class_pad.h
+++ b/pcbnew/class_pad.h
@@ -57,10 +57,10 @@ class PAD_DRAWINFO
 public:
     EDA_DRAW_PANEL* m_DrawPanel;  // the EDA_DRAW_PANEL used to draw a PAD ; can be null
     GR_DRAWMODE m_DrawMode;       // the draw mode
-    EDA_COLOR_T m_Color;          // color used to draw the pad shape , from pad layers and
+    COLOR4D m_Color;              // color used to draw the pad shape , from pad layers and
                                   // visible layers
-    EDA_COLOR_T m_HoleColor;      // color used to draw the pad hole
-    EDA_COLOR_T m_NPHoleColor;    // color used to draw a pad Not Plated hole
+    COLOR4D m_HoleColor;          // color used to draw the pad hole
+    COLOR4D m_NPHoleColor;        // color used to draw a pad Not Plated hole
     int m_PadClearance;           // clearance value, used to draw the pad area outlines
     wxSize m_Mask_margin;         // margin, used to draw solder paste when only one layer is shown
     bool m_Display_padnum;        // true to show pad number
diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp
index 817a5ee..0a49887 100644
--- a/pcbnew/class_pad_draw_functions.cpp
+++ b/pcbnew/class_pad_draw_functions.cpp
@@ -130,7 +130,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
     else
         drawInfo.m_ShowPadFilled = true;
 
-    EDA_COLOR_T color = BLACK;
+    COLOR4D color = COLOR4D_BLACK;
 
     if( m_layerMask[F_Cu] )
     {
@@ -139,7 +139,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
 
     if( m_layerMask[B_Cu] )
     {
-        color = ColorMix( color, brd->GetVisibleElementColor( PAD_BK_VISIBLE ) );
+        color = color.LegacyMix( brd->GetVisibleElementColor( PAD_BK_VISIBLE ) );
     }
 
     if( color == BLACK ) // Not on a visible copper layer (i.e. still nothing to show)
@@ -189,7 +189,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
                 )
             {
                 if( !IsOnLayer( screen->m_Active_Layer ) )
-                    ColorTurnToDarkDarkGray( &color );
+                    color = COLOR4D( DARKDARKGRAY );
             }
             // else routing between an internal signal layer and some other
             // layer.  Grey out all PAD_ATTRIB_SMD pads not on current or the single
@@ -198,7 +198,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
                     && !IsOnLayer( routeTop )
                     && !IsOnLayer( routeBot ) )
             {
-                ColorTurnToDarkDarkGray( &color );
+                color = COLOR4D( DARKDARKGRAY );
             }
         }
         // when not edting tracks, show PAD_ATTRIB_SMD components not on active layer
@@ -206,7 +206,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
         else
         {
             if( !IsOnLayer( screen->m_Active_Layer ) )
-                ColorTurnToDarkDarkGray( &color );
+                color = COLOR4D( DARKDARKGRAY );
         }
     }
 
@@ -264,11 +264,8 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
             color = DARKDARKGRAY;
     }
 
-
-    if( aDraw_mode & GR_HIGHLIGHT )
-        ColorChangeHighlightFlag( &color, !(aDraw_mode & GR_AND) );
-
-    ColorApplyHighlightFlag( &color );
+    if( ( aDraw_mode & GR_HIGHLIGHT ) && !( aDraw_mode & GR_AND ) )
+        color.SetToLegacyHighlightColor();
 
     bool DisplayIsol = displ_opts && displ_opts->m_DisplayPadIsol;
 
@@ -288,7 +285,7 @@ void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
     drawInfo.m_Mask_margin = mask_margin;
     drawInfo.m_ShowNCMark  = brd->IsElementVisible( PCB_VISIBLE( NO_CONNECTS_VISIBLE ) );
     drawInfo.m_IsPrinting  = screen->m_IsPrinting;
-    SetAlpha( &color, 170 );
+    color.a = 0.666;
 
     /* Get the pad clearance. This has a meaning only for Pcbnew.
      *  for CvPcb GetClearance() creates debug errors because
@@ -488,7 +485,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
             GRSetDrawMode( aDC, ( aDrawInfo.m_DrawMode != GR_XOR ) ? GR_COPY : GR_XOR );
         }
 
-        EDA_COLOR_T hole_color = aDrawInfo.m_HoleColor;
+        COLOR4D hole_color = aDrawInfo.m_HoleColor;
 
         if( aDrawInfo. m_ShowNotPlatedHole )    // Draw a specific hole color
             hole_color = aDrawInfo.m_NPHoleColor;
@@ -524,7 +521,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
     if( GetNetCode() == 0 && aDrawInfo.m_ShowNCMark )
     {
         int dx0 = std::min( halfsize.x, halfsize.y );
-        EDA_COLOR_T nc_color = BLUE;
+        COLOR4D nc_color = COLOR4D( BLUE );
 
         if( m_layerMask[F_Cu] )    /* Draw \ */
             GRLine( aClipBox, aDC, holepos.x - dx0, holepos.y - dx0,
diff --git a/pcbnew/class_pcb_layer_box_selector.cpp b/pcbnew/class_pcb_layer_box_selector.cpp
index ee02ba6..152be82 100644
--- a/pcbnew/class_pcb_layer_box_selector.cpp
+++ b/pcbnew/class_pcb_layer_box_selector.cpp
@@ -146,7 +146,7 @@ LSET PCB_LAYER_BOX_SELECTOR::getEnabledLayers() const
 
 
 // Returns a color index from the layer id
-EDA_COLOR_T PCB_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayer ) const
+COLOR4D PCB_LAYER_BOX_SELECTOR::GetLayerColor( LAYER_NUM aLayer ) const
 {
     wxASSERT( m_boardFrame );
     BOARD* board = m_boardFrame->GetBoard();
diff --git a/pcbnew/class_pcb_layer_box_selector.h b/pcbnew/class_pcb_layer_box_selector.h
index fbcd30a..59ee6fb 100644
--- a/pcbnew/class_pcb_layer_box_selector.h
+++ b/pcbnew/class_pcb_layer_box_selector.h
@@ -89,7 +89,7 @@ public:
 private:
     // Returns a color index from the layer id
     // Virtual function
-    EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const override;
+    COLOR4D GetLayerColor( LAYER_NUM aLayer ) const override;
 
     // Returns true if the layer id is enabled (i.e. is it should be displayed)
     // Virtual function
diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp
index 6faef76..0fe14ed 100644
--- a/pcbnew/class_pcb_layer_widget.cpp
+++ b/pcbnew/class_pcb_layer_widget.cpp
@@ -67,17 +67,17 @@ const LAYER_WIDGET::ROW PCB_LAYER_WIDGET::s_render_rows[] = {
     RR( _( "Pads Front" ),      PAD_FR_VISIBLE,         WHITE,      _( "Show footprint pads on board's front" ) ),
     RR( _( "Pads Back" ),       PAD_BK_VISIBLE,         WHITE,      _( "Show footprint pads on board's back" ) ),
 
-    RR( _( "Text Front" ),      MOD_TEXT_FR_VISIBLE,    UNSPECIFIED_COLOR,  _( "Show footprint text on board's front" ) ),
-    RR( _( "Text Back" ),       MOD_TEXT_BK_VISIBLE,    UNSPECIFIED_COLOR,  _( "Show footprint text on board's back" ) ),
+    RR( _( "Text Front" ),      MOD_TEXT_FR_VISIBLE,    UNSPECIFIED_COLOR4D,  _( "Show footprint text on board's front" ) ),
+    RR( _( "Text Back" ),       MOD_TEXT_BK_VISIBLE,    UNSPECIFIED_COLOR4D,  _( "Show footprint text on board's back" ) ),
     RR( _( "Hidden Text" ),     MOD_TEXT_INVISIBLE,     WHITE,      _( "Show footprint text marked as invisible" ) ),
 
     RR( _( "Anchors" ),         ANCHOR_VISIBLE,         WHITE,      _( "Show footprint and text origins as a cross" ) ),
     RR( _( "Grid" ),            GRID_VISIBLE,           WHITE,      _( "Show the (x,y) grid dots" ) ),
-    RR( _( "No-Connects" ),     NO_CONNECTS_VISIBLE,    UNSPECIFIED_COLOR,  _( "Show a marker on pads which have no net connected" ) ),
-    RR( _( "Footprints Front" ),   MOD_FR_VISIBLE,         UNSPECIFIED_COLOR,  _( "Show footprints that are on board's front") ),
-    RR( _( "Footprints Back" ),    MOD_BK_VISIBLE,         UNSPECIFIED_COLOR,  _( "Show footprints that are on board's back") ),
-    RR( _( "Values" ),          MOD_VALUES_VISIBLE,     UNSPECIFIED_COLOR,  _( "Show footprint's values") ),
-    RR( _( "References" ),      MOD_REFERENCES_VISIBLE, UNSPECIFIED_COLOR,  _( "Show footprint's references") ),
+    RR( _( "No-Connects" ),     NO_CONNECTS_VISIBLE,    UNSPECIFIED_COLOR4D,  _( "Show a marker on pads which have no net connected" ) ),
+    RR( _( "Footprints Front" ),   MOD_FR_VISIBLE,         UNSPECIFIED_COLOR4D,  _( "Show footprints that are on board's front") ),
+    RR( _( "Footprints Back" ),    MOD_BK_VISIBLE,         UNSPECIFIED_COLOR4D,  _( "Show footprints that are on board's back") ),
+    RR( _( "Values" ),          MOD_VALUES_VISIBLE,     UNSPECIFIED_COLOR4D,  _( "Show footprint's values") ),
+    RR( _( "References" ),      MOD_REFERENCES_VISIBLE, UNSPECIFIED_COLOR4D,  _( "Show footprint's references") ),
 };
 
 static int s_allowed_in_FpEditor[] =
@@ -115,6 +115,12 @@ PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwn
 }
 
 
+bool PCB_LAYER_WIDGET::AreArbitraryColorsAllowed()
+{
+    return myframe->IsGalCanvasActive();
+}
+
+
 bool PCB_LAYER_WIDGET::isAllowedInFpMode( int aId )
 {
     for( unsigned ii = 0; ii < DIM( s_allowed_in_FpEditor ); ii++ )
@@ -293,7 +299,7 @@ void PCB_LAYER_WIDGET::ReFillRender()
         renderRow.tooltip = wxGetTranslation( s_render_rows[row].tooltip );
         renderRow.rowName = wxGetTranslation( s_render_rows[row].rowName );
 
-        if( renderRow.color != -1 )       // does this row show a color?
+        if( renderRow.color != UNSPECIFIED_COLOR4D )       // does this row show a color?
         {
             // this window frame must have an established BOARD, i.e. after SetBoard()
             renderRow.color = board->GetVisibleElementColor( renderRow.id );
@@ -437,7 +443,7 @@ void PCB_LAYER_WIDGET::ReFill()
 
 //-----<LAYER_WIDGET callbacks>-------------------------------------------
 
-void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor )
+void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )
 {
     myframe->GetBoard()->SetLayerColor( ToLAYER_ID( aLayer ), aColor );
 
@@ -509,7 +515,7 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal
 }
 
 
-void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor )
+void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
 {
     myframe->GetBoard()->SetVisibleElementColor( aId, aColor );
 
diff --git a/pcbnew/class_pcb_layer_widget.h b/pcbnew/class_pcb_layer_widget.h
index 69e99b3..be1fe4e 100644
--- a/pcbnew/class_pcb_layer_widget.h
+++ b/pcbnew/class_pcb_layer_widget.h
@@ -88,10 +88,10 @@ public:
     void SetLayersManagerTabsText();
 
     //-----<implement LAYER_WIDGET abstract callback functions>-----------
-    void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ) override;
+    void OnLayerColorChange( int aLayer, COLOR4D aColor ) override;
     bool OnLayerSelect( int aLayer ) override;
     void OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) override;
-    void OnRenderColorChange( int aId, EDA_COLOR_T aColor ) override;
+    void OnRenderColorChange( int aId, COLOR4D aColor ) override;
     void OnRenderEnable( int aId, bool isEnabled ) override;
     //-----</implement LAYER_WIDGET abstract callback functions>----------
 
@@ -125,6 +125,7 @@ protected:
 #define ID_SHOW_NO_LAYERS                           (wxID_HIGHEST+4)
 #define ID_SHOW_ALL_LAYERS                          (wxID_HIGHEST+5)
 
+    virtual bool AreArbitraryColorsAllowed() override;
 
     /**
      * Function isAllowedInFpMode
diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp
index 82e6ea9..a9ca700 100644
--- a/pcbnew/class_pcb_text.cpp
+++ b/pcbnew/class_pcb_text.cpp
@@ -74,7 +74,7 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
     if( brd->IsLayerVisible( m_Layer ) == false )
         return;
 
-    EDA_COLOR_T color = brd->GetLayerColor( m_Layer );
+    COLOR4D color = brd->GetLayerColor( m_Layer );
 
     EDA_DRAW_MODE_T fillmode = FILLED;
     DISPLAY_OPTIONS* displ_opts =
@@ -89,10 +89,10 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
         LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
 
         if( !IsOnLayer( curr_layer ) )
-            ColorTurnToDarkDarkGray( &color );
+            color = COLOR4D( DARKDARKGRAY );
     }
 
-    EDA_COLOR_T anchor_color = UNSPECIFIED_COLOR;
+    COLOR4D anchor_color = UNSPECIFIED_COLOR4D;
 
     if( brd->IsElementVisible( ANCHOR_VISIBLE ) )
         anchor_color = brd->GetVisibleElementColor( ANCHOR_VISIBLE );
diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp
index 3703d7c..7c9f1ff 100644
--- a/pcbnew/class_text_mod.cpp
+++ b/pcbnew/class_text_mod.cpp
@@ -222,7 +222,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod
     wxASSERT( m_Parent );
 
     BOARD* brd = GetBoard( );
-    EDA_COLOR_T color = brd->GetLayerColor( GetLayer() );
+    COLOR4D color = brd->GetLayerColor( GetLayer() );
     LAYER_ID text_layer = GetLayer();
 
     if( !brd->IsLayerVisible( m_Layer )
@@ -248,7 +248,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod
         LAYER_ID curr_layer = ( (PCB_SCREEN*) aPanel->GetScreen() )->m_Active_Layer;
 
         if( !IsOnLayer( curr_layer ) )
-            ColorTurnToDarkDarkGray( &color );
+            color = COLOR4D( DARKDARKGRAY );
     }
 
     // Draw mode compensation for the width
@@ -263,7 +263,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMod
     // Draw the text anchor point
     if( brd->IsElementVisible( ANCHOR_VISIBLE ) )
     {
-        EDA_COLOR_T anchor_color = brd->GetVisibleElementColor(ANCHOR_VISIBLE);
+        COLOR4D anchor_color = brd->GetVisibleElementColor(ANCHOR_VISIBLE);
         GRDrawAnchor( aPanel->GetClipBox(), aDC, pos.x, pos.y, DIM_ANCRE_TEXTE, anchor_color );
     }
 
diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp
index 27a622f..aa456c9 100644
--- a/pcbnew/class_track.cpp
+++ b/pcbnew/class_track.cpp
@@ -534,7 +534,7 @@ TRACK* TRACK::GetEndNetCode( int NetCode )
 }
 
 void TRACK::DrawShortNetname( EDA_DRAW_PANEL* panel,
-        wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aBgColor )
+        wxDC* aDC, GR_DRAWMODE aDrawMode, COLOR4D aBgColor )
 {
     if( ! panel )
         return;
@@ -625,7 +625,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
                   const wxPoint& aOffset )
 {
     BOARD * brd = GetBoard( );
-    EDA_COLOR_T color = brd->GetLayerColor(m_Layer);
+    COLOR4D color = brd->GetLayerColor( m_Layer );
 
     if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
         return;
@@ -643,15 +643,13 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
         LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
 
         if( !IsOnLayer( curr_layer ) )
-            ColorTurnToDarkDarkGray( &color );
+            color = COLOR4D( DARKDARKGRAY );
     }
 
-    if( aDrawMode & GR_HIGHLIGHT )
-        ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
+    if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
+        color.SetToLegacyHighlightColor();
 
-    ColorApplyHighlightFlag( &color );
-
-    SetAlpha( &color, 150 );
+    color.a = 0.588;
 
     GRSetDrawMode( aDC, aDrawMode );
 
@@ -697,7 +695,7 @@ void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
         return;
 
     BOARD * brd = GetBoard( );
-    EDA_COLOR_T color = brd->GetLayerColor(m_Layer);
+    COLOR4D color = brd->GetLayerColor(m_Layer);
 
     if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
         return;
@@ -713,15 +711,13 @@ void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
         LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
 
         if( !IsOnLayer( curr_layer ) )
-            ColorTurnToDarkDarkGray( &color );
+            color = COLOR4D( DARKDARKGRAY );
     }
 
-    if( aDrawMode & GR_HIGHLIGHT )
-        ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
-
-    ColorApplyHighlightFlag( &color );
+    if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
+        color.SetToLegacyHighlightColor();
 
-    SetAlpha( &color, 150 );
+    color.a = 0.588;
 
     GRSetDrawMode( aDC, aDrawMode );
 
@@ -788,11 +784,11 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const w
     GRSetDrawMode( aDC, aDrawMode );
 
     BOARD * brd =  GetBoard();
-    EDA_COLOR_T color = brd->GetVisibleElementColor( VIAS_VISIBLE + GetViaType() );
+    COLOR4D color = brd->GetVisibleElementColor( VIAS_VISIBLE + GetViaType() );
 
     if( brd->IsElementVisible( PCB_VISIBLE(VIAS_VISIBLE + GetViaType()) ) == false
-        && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG )
-        return;
+        && !( aDrawMode & GR_HIGHLIGHT ) )
+       return;
 
     // Only draw the via if at least one of the layers it crosses is being displayed
     if( !( brd->GetVisibleLayers() & GetLayerSet() ).any() )
@@ -801,15 +797,13 @@ void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const w
     if( displ_opts->m_ContrastModeDisplay )
     {
         if( !IsOnLayer( curr_layer ) )
-            ColorTurnToDarkDarkGray( &color );
+            color = COLOR4D( DARKDARKGRAY );
     }
 
-    if( aDrawMode & GR_HIGHLIGHT )
-        ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
-
-    ColorApplyHighlightFlag( &color );
+    if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
+        color.SetToLegacyHighlightColor();
 
-    SetAlpha( &color, 150 );
+    color.a = 0.588;
 
 
     radius = m_Width >> 1;
diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h
index e185179..1d5875b 100644
--- a/pcbnew/class_track.h
+++ b/pcbnew/class_track.h
@@ -332,7 +332,7 @@ protected:
     /**
      * Helper for drawing the short netname in tracks */
     void DrawShortNetname( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
-            EDA_COLOR_T aBgColor );
+            COLOR4D aBgColor );
 
     int         m_Width;            ///< Thickness of track, or via diameter
     wxPoint     m_Start;            ///< Line start point
diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp
index 0ac7966..8cc655e 100644
--- a/pcbnew/class_zone.cpp
+++ b/pcbnew/class_zone.cpp
@@ -174,9 +174,9 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod
     LAYER_ID    curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
     BOARD*      brd   = GetBoard();
 
-    EDA_COLOR_T color = brd->GetLayerColor( m_Layer );
+    COLOR4D     color = brd->GetLayerColor( m_Layer );
 
-    if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG )
+    if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
         return;
 
     GRSetDrawMode( DC, aDrawMode );
@@ -185,15 +185,13 @@ void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMod
     if( displ_opts->m_ContrastModeDisplay )
     {
         if( !IsOnLayer( curr_layer ) )
-            ColorTurnToDarkDarkGray( &color );
+            color = COLOR4D( DARKDARKGRAY );
     }
 
-    if( aDrawMode & GR_HIGHLIGHT )
-        ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
+    if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
+        color.SetToLegacyHighlightColor();
 
-    ColorApplyHighlightFlag( &color );
-
-    SetAlpha( &color, 150 );
+    color.a = 0.588;
 
     // draw the lines
     int i_start_contour = 0;
@@ -257,9 +255,9 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
 
     BOARD*      brd = GetBoard();
     LAYER_ID    curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
-    EDA_COLOR_T color = brd->GetLayerColor( m_Layer );
+    COLOR4D     color = brd->GetLayerColor( m_Layer );
 
-    if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG )
+    if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
         return;
 
     GRSetDrawMode( DC, aDrawMode );
@@ -267,15 +265,13 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
     if( displ_opts->m_ContrastModeDisplay )
     {
         if( !IsOnLayer( curr_layer ) )
-            ColorTurnToDarkDarkGray( &color );
+            color = COLOR4D( DARKDARKGRAY );
     }
 
-    if( aDrawMode & GR_HIGHLIGHT )
-        ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
-
-    ColorApplyHighlightFlag( &color );
+    if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
+        color.SetToLegacyHighlightColor();
 
-    SetAlpha( &color, 150 );
+    color.a = 0.588;
 
 
     for ( int ic = 0; ic < m_FilledPolysList.OutlineCount(); ic++ )
@@ -385,13 +381,13 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC,
 
     LAYER_ID    curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
     BOARD*      brd   = GetBoard();
-    EDA_COLOR_T color = brd->GetLayerColor( m_Layer );
+    COLOR4D     color = brd->GetLayerColor( m_Layer );
     DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
 
     if( displ_opts->m_ContrastModeDisplay )
     {
         if( !IsOnLayer( curr_layer ) )
-            ColorTurnToDarkDarkGray( &color );
+            color = COLOR4D( DARKDARKGRAY );
     }
 
     // draw the lines
diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp
index f33c2f6..68ec60c 100644
--- a/pcbnew/dialogs/dialog_SVG_print.cpp
+++ b/pcbnew/dialogs/dialog_SVG_print.cpp
@@ -336,7 +336,7 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName, bool aOnlyO
     plot_opts.SetMirror( m_printMirror );
     plot_opts.SetFormat( PLOT_FORMAT_SVG );
 
-    EDA_COLOR_T color = UNSPECIFIED_COLOR;      // Used layer color to plot ref and value
+    COLOR4D color = UNSPECIFIED_COLOR4D;      // Used layer color to plot ref and value
 
     plot_opts.SetReferenceColor( color );
     plot_opts.SetValueColor( color );
diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp
index 2f34a51..b20b241 100644
--- a/pcbnew/dialogs/dialog_copper_zones.cpp
+++ b/pcbnew/dialogs/dialog_copper_zones.cpp
@@ -115,7 +115,7 @@ private:
      * creates the colored rectangle bitmaps used in the layer selection widget.
      * @param aColor is the color to fill the rectangle with.
      */
-    wxBitmap makeLayerBitmap( EDA_COLOR_T aColor );
+    wxBitmap makeLayerBitmap( COLOR4D aColor );
 };
 
 
@@ -253,7 +253,7 @@ void DIALOG_COPPER_ZONE::initDialog()
 
         msg.Trim();
 
-        EDA_COLOR_T layerColor = board->GetLayerColor( layer );
+        COLOR4D layerColor = board->GetLayerColor( layer );
 
         imageList->Add( makeLayerBitmap( layerColor ) );
 
@@ -681,14 +681,14 @@ void DIALOG_COPPER_ZONE::buildAvailableListOfNets()
 }
 
 
-wxBitmap DIALOG_COPPER_ZONE::makeLayerBitmap( EDA_COLOR_T aColor )
+wxBitmap DIALOG_COPPER_ZONE::makeLayerBitmap( COLOR4D aColor )
 {
     wxBitmap    bitmap( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y );
     wxBrush     brush;
     wxMemoryDC  iconDC;
 
     iconDC.SelectObject( bitmap );
-    brush.SetColour( MakeColour( aColor ) );
+    brush.SetColour( aColor.ToColour() );
     brush.SetStyle( wxBRUSHSTYLE_SOLID );
     iconDC.SetBrush( brush );
     iconDC.DrawRectangle( 0, 0, LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y );
diff --git a/pcbnew/dialogs/dialog_keepout_area_properties.cpp b/pcbnew/dialogs/dialog_keepout_area_properties.cpp
index e9f4887..9da362d 100644
--- a/pcbnew/dialogs/dialog_keepout_area_properties.cpp
+++ b/pcbnew/dialogs/dialog_keepout_area_properties.cpp
@@ -83,7 +83,7 @@ private:
      * creates the colored rectangle bitmaps used in the layer selection widget.
      * @param aColor is the color to fill the rectangle with.
      */
-    wxBitmap makeLayerBitmap( EDA_COLOR_T aColor );
+    wxBitmap makeLayerBitmap( COLOR4D aColor );
 };
 
 
@@ -164,7 +164,7 @@ void DIALOG_KEEPOUT_AREA_PROPERTIES::initDialog()
 
         msg = board->GetLayerName( layer );
 
-        EDA_COLOR_T layerColor = board->GetLayerColor( layer );
+        COLOR4D layerColor = board->GetLayerColor( layer );
 
         imageList->Add( makeLayerBitmap( layerColor ) );
 
@@ -255,14 +255,14 @@ bool DIALOG_KEEPOUT_AREA_PROPERTIES::AcceptOptionsForKeepOut()
 }
 
 
-wxBitmap DIALOG_KEEPOUT_AREA_PROPERTIES::makeLayerBitmap( EDA_COLOR_T aColor )
+wxBitmap DIALOG_KEEPOUT_AREA_PROPERTIES::makeLayerBitmap( COLOR4D aColor )
 {
     wxBitmap    bitmap( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y );
     wxBrush     brush;
     wxMemoryDC  iconDC;
 
     iconDC.SelectObject( bitmap );
-    brush.SetColour( MakeColour( aColor ) );
+    brush.SetColour( aColor.ToColour() );
     brush.SetStyle( wxBRUSHSTYLE_SOLID );
 
     iconDC.SetBrush( brush );
diff --git a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp
index 552dd73..d55eea7 100644
--- a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp
+++ b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp
@@ -73,7 +73,7 @@ private:
      * creates the colored rectangle bitmaps used in the layer selection widget.
      * @param aColor is the color to fill the rectangle with.
      */
-    wxBitmap makeLayerBitmap( EDA_COLOR_T aColor );
+    wxBitmap makeLayerBitmap( COLOR4D aColor );
 };
 
 
@@ -155,7 +155,7 @@ void DIALOG_NON_COPPER_ZONES_EDITOR::Init()
     {
         LAYER_ID layer = *seq;
 
-        EDA_COLOR_T layerColor = board->GetLayerColor( layer );
+        COLOR4D layerColor = board->GetLayerColor( layer );
         imageList->Add( makeLayerBitmap( layerColor ) );
 
         msg = board->GetLayerName( layer );
@@ -251,14 +251,14 @@ void DIALOG_NON_COPPER_ZONES_EDITOR::OnCancelClick( wxCommandEvent& event )
 }
 
 
-wxBitmap DIALOG_NON_COPPER_ZONES_EDITOR::makeLayerBitmap( EDA_COLOR_T aColor )
+wxBitmap DIALOG_NON_COPPER_ZONES_EDITOR::makeLayerBitmap( COLOR4D aColor )
 {
     wxBitmap    bitmap( LAYER_BITMAP_SIZE_X, LAYER_BITMAP_SIZE_Y );
     wxBrush     brush;
     wxMemoryDC  iconDC;
 
     iconDC.SelectObject( bitmap );
-    brush.SetColour( MakeColour( aColor ) );
+    brush.SetColour( aColor.ToColour() );
     brush.SetStyle( wxBRUSHSTYLE_SOLID );
 
     iconDC.SetBrush( brush );
diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp
index de1fe5b..45c95b6 100644
--- a/pcbnew/dialogs/dialog_pad_properties.cpp
+++ b/pcbnew/dialogs/dialog_pad_properties.cpp
@@ -167,7 +167,7 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
     wxPaintDC    dc( m_panelShowPad );
     PAD_DRAWINFO drawInfo;
 
-    EDA_COLOR_T color = BLACK;
+    COLOR4D color = COLOR4D_BLACK;
 
     if( m_dummyPad->GetLayerSet()[F_Cu] )
     {
@@ -176,7 +176,7 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
 
     if( m_dummyPad->GetLayerSet()[B_Cu] )
     {
-        color = ColorMix( color, m_board->GetVisibleElementColor( PAD_BK_VISIBLE ) );
+        color = color.LegacyMix( m_board->GetVisibleElementColor( PAD_BK_VISIBLE ) );
     }
 
     // What could happen: the pad color is *actually* black, or no
diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp
index d556096..c5081ed 100644
--- a/pcbnew/editrack.cpp
+++ b/pcbnew/editrack.cpp
@@ -660,7 +660,7 @@ inline void DrawViaCirclesWhenEditingNewTrack( EDA_RECT* aPanelClipBox,
                                                wxDC* aDC, const wxPoint& aPos,
                                                int aViaRadius,
                                                int aViaRadiusWithClearence,
-                                               EDA_COLOR_T aColor)
+                                               COLOR4D aColor)
 {
     //Current viasize clearence circle
     GRCircle( aPanelClipBox, aDC, aPos.x, aPos.y, aViaRadiusWithClearence, aColor );
@@ -706,7 +706,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
 
         if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
         {
-            EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( g_CurrentTrackSegment->GetLayer() );
+            COLOR4D color = g_ColorsSettings.GetLayerColor( g_CurrentTrackSegment->GetLayer() );
             DrawViaCirclesWhenEditingNewTrack( panelClipBox, aDC, g_CurrentTrackSegment->GetEnd(),
                                                boardViaRadius, viaRadiusWithClearence, color);
         }
@@ -773,7 +773,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
 
     if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
     {
-        EDA_COLOR_T color = g_ColorsSettings.GetLayerColor(g_CurrentTrackSegment->GetLayer());
+        COLOR4D color = g_ColorsSettings.GetLayerColor(g_CurrentTrackSegment->GetLayer());
 
         //Via diameter must have taken what we are using, rather than netclass value.
         DrawViaCirclesWhenEditingNewTrack( panelClipBox, aDC, g_CurrentTrackSegment->GetEnd(),
diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp
index 5793b34..8b502de 100644
--- a/pcbnew/exporters/export_vrml.cpp
+++ b/pcbnew/exporters/export_vrml.cpp
@@ -734,7 +734,7 @@ static void export_vrml_pcbtext( MODEL_VRML& aModel, TEXTE_PCB* text )
     if( text->IsMirrored() )
         size.x = -size.x;
 
-    EDA_COLOR_T color = BLACK;  // not actually used, but needed by DrawGraphicText
+    COLOR4D color = COLOR4D_BLACK;  // not actually used, but needed by DrawGraphicText
 
     if( text->IsMultilineAllowed() )
     {
diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp
index eabcf40..36e7ad3 100644
--- a/pcbnew/exporters/gen_drill_report_files.cpp
+++ b/pcbnew/exporters/gen_drill_report_files.cpp
@@ -219,7 +219,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
 
     // Plot title  "Info"
     wxString Text = wxT( "Drill Map:" );
-    plotter->Text( wxPoint( plotX, plotY ), UNSPECIFIED_COLOR, Text, 0,
+    plotter->Text( wxPoint( plotX, plotY ), UNSPECIFIED_COLOR4D, Text, 0,
                    wxSize( KiROUND( charSize * charScale ),
                            KiROUND( charSize * charScale ) ),
                    GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
@@ -266,7 +266,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
         if( tool.m_Hole_NotPlated )
             msg += wxT( " (not plated)" );
 
-        plotter->Text( wxPoint( plotX, y ), UNSPECIFIED_COLOR, msg, 0,
+        plotter->Text( wxPoint( plotX, y ), UNSPECIFIED_COLOR4D, msg, 0,
                        wxSize( KiROUND( charSize * charScale ),
                                KiROUND( charSize * charScale ) ),
                        GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp
index da861fc..5a89b49 100644
--- a/pcbnew/layer_widget.cpp
+++ b/pcbnew/layer_widget.cpp
@@ -37,18 +37,18 @@
 
 #include <macros.h>
 #include <common.h>
-#include <colors.h>
 #include <wx/colour.h>
+#include <wx/colordlg.h>
 
 #include <algorithm>
 
 
 #define BUTT_SIZE_X             20
 #define BUTT_SIZE_Y             18
-#define BUTT_VOID               4
+#define BUTT_VOID               2
 
 // See selcolor.cpp:
-extern EDA_COLOR_T DisplayColorFrame( wxWindow* aParent, EDA_COLOR_T aOldColor );
+extern COLOR4D DisplayColorFrame( wxWindow* aParent, COLOR4D aOldColor );
 
 const wxEventType LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE = wxNewEventType();
 
@@ -152,14 +152,12 @@ static const char * rightarrow_alternate_xpm[] = {
 
 /**
  * Function makeColorTxt
- * returns a string containing the numeric value of the color.
- * in a form like 0x00000000.  (Color is currently an index, not RGB).
+ * returns a string representing the color in CSS format
+ * For example: "rgba(255, 0, 0, 255)"
  */
-static wxString makeColorTxt( EDA_COLOR_T aColor )
+static wxString makeColorTxt( COLOR4D aColor )
 {
-    wxString txt;
-    txt.Printf( wxT("0x%08x"), aColor );
-    return txt;
+    return aColor.ToWxString( wxC2S_CSS_SYNTAX );
 }
 
 
@@ -189,7 +187,7 @@ LAYER_NUM LAYER_WIDGET::getDecodedId( int aControlId )
 }
 
 
-wxBitmap LAYER_WIDGET::makeBitmap( EDA_COLOR_T aColor )
+wxBitmap LAYER_WIDGET::makeBitmap( COLOR4D aColor )
 {
     // the bitmap will be BUTT_VOID*2 pixels smaller than the button, leaving a
     // border of BUTT_VOID pixels on each side.
@@ -199,7 +197,7 @@ wxBitmap LAYER_WIDGET::makeBitmap( EDA_COLOR_T aColor )
 
     iconDC.SelectObject( bitmap );
 
-    brush.SetColour( MakeColour( aColor ) );
+    brush.SetColour( aColor.ToColour() );
     brush.SetStyle( wxBRUSHSTYLE_SOLID );
 
     iconDC.SetBrush( brush );
@@ -210,7 +208,7 @@ wxBitmap LAYER_WIDGET::makeBitmap( EDA_COLOR_T aColor )
 }
 
 
-wxBitmapButton* LAYER_WIDGET::makeColorButton( wxWindow* aParent, EDA_COLOR_T aColor, int aID )
+wxBitmapButton* LAYER_WIDGET::makeColorButton( wxWindow* aParent, COLOR4D aColor, int aID )
 {
     // dynamically make a wxBitMap and brush it with the appropriate color,
     // then create a wxBitmapButton from it.
@@ -283,14 +281,31 @@ void LAYER_WIDGET::OnMiddleDownLayerColor( wxMouseEvent& aEvent )
 
     wxString colorTxt = eventSource->GetName();
 
-    EDA_COLOR_T oldColor = ColorFromInt( strtoul( TO_UTF8(colorTxt), NULL, 0 ) );
-    EDA_COLOR_T newColor = DisplayColorFrame( this, oldColor );
+    COLOR4D oldColor;
+    wxASSERT( oldColor.SetFromWxString( colorTxt ) );
+    COLOR4D newColor = UNSPECIFIED_COLOR4D;
 
-    if( newColor >= 0 )
+    if( AreArbitraryColorsAllowed() )
+    {
+        wxColourData colourData;
+        colourData.SetColour( oldColor.ToColour() );
+        wxColourDialog *dialog = new wxColourDialog( m_LayerScrolledWindow, &colourData );
+
+        if( dialog->ShowModal() == wxID_OK )
+        {
+            newColor = COLOR4D( dialog->GetColourData().GetColour() );
+        }
+    }
+    else
+    {
+        newColor = DisplayColorFrame( this, oldColor );
+    }
+
+    if( newColor != UNSPECIFIED_COLOR4D )
     {
         eventSource->SetName( makeColorTxt( newColor ) );
 
-        wxBitmap bm = makeBitmap( newColor );
+        wxBitmap bm = makeBitmap( newColor.ToColour() );
         eventSource->SetBitmapLabel( bm );
 
         LAYER_NUM layer = getDecodedId( eventSource->GetId() );
@@ -322,10 +337,27 @@ void LAYER_WIDGET::OnMiddleDownRenderColor( wxMouseEvent& event )
 
     wxString colorTxt = eventSource->GetName();
 
-    EDA_COLOR_T oldColor = ColorFromInt( strtoul( TO_UTF8(colorTxt), NULL, 0 ) );
-    EDA_COLOR_T newColor = DisplayColorFrame( this, oldColor );
+    COLOR4D oldColor;
+    wxASSERT( oldColor.SetFromWxString( colorTxt ) );
+    COLOR4D newColor = UNSPECIFIED_COLOR4D;
 
-    if( newColor >= 0 )
+    if( AreArbitraryColorsAllowed() )
+    {
+        wxColourData colourData;
+        colourData.SetColour( oldColor.ToColour() );
+        wxColourDialog *dialog = new wxColourDialog( m_LayerScrolledWindow, &colourData );
+
+        if( dialog->ShowModal() == wxID_OK )
+        {
+            newColor = COLOR4D( dialog->GetColourData().GetColour() );
+        }
+    }
+    else
+    {
+        newColor = DisplayColorFrame( this, oldColor );
+    }
+
+    if( newColor != UNSPECIFIED_COLOR4D )
     {
         eventSource->SetName( makeColorTxt( newColor ) );
 
@@ -427,6 +459,7 @@ void LAYER_WIDGET::insertLayerRow( int aRow, const ROW& aSpec )
 
     // column 1 (COLUMN_COLORBM)
     col = COLUMN_COLORBM;
+
     wxBitmapButton* bmb = makeColorButton( m_LayerScrolledWindow, aSpec.color, encodeId( col, aSpec.id ) );
     bmb->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( LAYER_WIDGET::OnLeftDownLayers ), NULL, this );
     bmb->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( LAYER_WIDGET::OnMiddleDownLayerColor ), NULL, this );
@@ -462,7 +495,7 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
 
     // column 0
     col = 0;
-    if( aSpec.color != -1 )
+    if( aSpec.color != UNSPECIFIED_COLOR4D )
     {
         wxBitmapButton* bmb = makeColorButton( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ) );
         bmb->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( LAYER_WIDGET::OnMiddleDownRenderColor ), NULL, this );
@@ -764,7 +797,7 @@ bool LAYER_WIDGET::IsLayerVisible( LAYER_NUM aLayer )
 }
 
 
-void LAYER_WIDGET::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
+void LAYER_WIDGET::SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor )
 {
     int row = findLayerRow( aLayer );
     if( row >= 0 )
@@ -781,7 +814,7 @@ void LAYER_WIDGET::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor )
 }
 
 
-EDA_COLOR_T LAYER_WIDGET::GetLayerColor( LAYER_NUM aLayer ) const
+COLOR4D LAYER_WIDGET::GetLayerColor( LAYER_NUM aLayer ) const
 {
     int row = findLayerRow( aLayer );
     if( row >= 0 )
@@ -794,7 +827,7 @@ EDA_COLOR_T LAYER_WIDGET::GetLayerColor( LAYER_NUM aLayer ) const
         return ColorFromInt( strtoul( TO_UTF8(colorTxt), NULL, 0 ) );
     }
 
-    return UNSPECIFIED_COLOR;   // it's caller fault, gave me a bad layer
+    return UNSPECIFIED_COLOR4D;   // it's caller fault, gave me a bad layer
 }
 
 
@@ -860,7 +893,7 @@ class MYFRAME : public wxFrame
         {
         }
 
-        void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor )
+        void OnLayerColorChange( int aLayer, COLOR4D aColor )
         {
             printf( "OnLayerColorChange( aLayer:%d, aColor:%d )\n", aLayer, aColor );
 
@@ -884,7 +917,7 @@ class MYFRAME : public wxFrame
             printf( "OnLayerVisible( aLayer:%d, isVisible:%d isFinal:%d)\n", aLayer, isVisible, isFinal );
         }
 
-        void OnRenderColorChange( int aId, EDA_COLOR_T aColor )
+        void OnRenderColorChange( int aId, COLOR4D aColor )
         {
             printf( "OnRenderColorChange( aId:%d, aColor:%d )\n", aId, aColor );
         }
@@ -918,7 +951,7 @@ public:
 
         // add some render rows
         static const LAYER_WIDGET::ROW renderRows[] = {
-            LAYER_WIDGET::ROW( wxT("With Very Large Ears"), 0, UNSPECIFIED_COLOR, wxT("Spock here") ),
+            LAYER_WIDGET::ROW( wxT("With Very Large Ears"), 0, UNSPECIFIED_COLOR4D, wxT("Spock here") ),
             LAYER_WIDGET::ROW( wxT("With Legs"), 1, YELLOW ),
             LAYER_WIDGET::ROW( wxT("With Oval Eyes"), 1, BROWN, wxT("My eyes are upon you") ),
         };
diff --git a/pcbnew/layer_widget.h b/pcbnew/layer_widget.h
index e35be8e..de4a33c 100644
--- a/pcbnew/layer_widget.h
+++ b/pcbnew/layer_widget.h
@@ -42,7 +42,7 @@
 #include <wx/image.h>
 #include <wx/icon.h>
 #include <layers_id_colors_and_visibility.h>
-#include <colors.h>
+#include <gal/color4d.h>
 
 #define LYR_COLUMN_COUNT        4           ///< Layer tab column count
 #define RND_COLUMN_COUNT        2           ///< Rendering tab column count
@@ -52,6 +52,7 @@
 #define COLUMN_COLOR_LYR_CB 2
 #define COLUMN_COLOR_LYRNAME 3
 
+using KIGFX::COLOR4D;
 
 /**
  * Class LAYER_WIDGET
@@ -84,11 +85,11 @@ public:
     {
         wxString    rowName;    ///< the prompt or layername
         int         id;         ///< either a layer or "visible element" id
-        EDA_COLOR_T color;      ///< -1 if none.
+        COLOR4D     color;      ///< UNSPECIFIED_COLOR4D if none.
         bool        state;      ///< initial wxCheckBox state
         wxString    tooltip;    ///< if not empty, use this tooltip on row
 
-        ROW( const wxString& aRowName, int aId, EDA_COLOR_T aColor = UNSPECIFIED_COLOR,
+        ROW( const wxString& aRowName, int aId, COLOR4D aColor = UNSPECIFIED_COLOR4D,
             const wxString& aTooltip = wxEmptyString, bool aState = true )
         {
             rowName = aRowName;
@@ -120,7 +121,7 @@ protected:
     int                 m_CurrentRow;           ///< selected row of layer list
     int                 m_PointSize;
 
-    static wxBitmap makeBitmap( EDA_COLOR_T aColor );
+    static wxBitmap makeBitmap( COLOR4D aColor );
 
     /**
      * Virtual Function useAlternateBitmap
@@ -133,6 +134,12 @@ protected:
     virtual bool useAlternateBitmap(int aRow) { return false; }
 
     /**
+     * Subclasses can override this to provide logic for allowing
+     * arbitrary color selection via wxColourPicker instead of DisplayColorFrame.
+     */
+    virtual bool AreArbitraryColorsAllowed() { return false; }
+
+    /**
      * Function encodeId
      * is here to allow saving a layer index within a control as its wxControl id,
      * but to do so in a way that all child wxControl ids within a wxWindow are unique,
@@ -153,7 +160,7 @@ protected:
      * Function makeColorButton
      * creates a wxBitmapButton and assigns it a solid color and a control ID
      */
-    wxBitmapButton* makeColorButton( wxWindow* aParent, EDA_COLOR_T aColor, int aID );
+    wxBitmapButton* makeColorButton( wxWindow* aParent, COLOR4D aColor, int aID );
 
     void OnLeftDownLayers( wxMouseEvent& event );
 
@@ -332,13 +339,13 @@ public:
      * Function SetLayerColor
      * changes the color of \a aLayer
      */
-    void SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor );
+    void SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor );
 
     /**
      * Function GetLayerColor
      * returns the color of the layer ROW associated with \a aLayer id.
      */
-    EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const;
+    COLOR4D GetLayerColor( LAYER_NUM aLayer ) const;
 
     /**
      * Function SetRenderState
@@ -385,7 +392,7 @@ public:
      * @param aLayer is the board layer to change
      * @param aColor is the new color
      */
-    virtual void OnLayerColorChange( int aLayer, EDA_COLOR_T aColor ) = 0;
+    virtual void OnLayerColorChange( int aLayer, COLOR4D aColor ) = 0;
 
     /**
      * Function OnLayerSelect
@@ -416,7 +423,7 @@ public:
      * via the AddRenderRow() function.
      * @param aColor is the new color
      */
-    virtual void OnRenderColorChange( int aId, EDA_COLOR_T aColor ) = 0;
+    virtual void OnRenderColorChange( int aId, COLOR4D aColor ) = 0;
 
     /**
      * Function OnRenderEnable
diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp
index bbce20c..b7659fe 100644
--- a/pcbnew/modedit.cpp
+++ b/pcbnew/modedit.cpp
@@ -969,7 +969,7 @@ void FOOTPRINT_EDIT_FRAME::OnVerticalToolbar( wxCommandEvent& aEvent )
 }
 
 
-EDA_COLOR_T FOOTPRINT_EDIT_FRAME::GetGridColor() const
+COLOR4D FOOTPRINT_EDIT_FRAME::GetGridColor() const
 {
     return g_ColorsSettings.GetItemColor( GRID_VISIBLE );
 }
diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h
index eee7155..d89a701 100644
--- a/pcbnew/module_editor_frame.h
+++ b/pcbnew/module_editor_frame.h
@@ -448,7 +448,7 @@ public:
      * Function GetGridColor() , virtual
      * @return the color of the grid
      */
-    virtual EDA_COLOR_T GetGridColor() const override;
+    virtual COLOR4D GetGridColor() const override;
 
     ///> @copydoc PCB_BASE_FRAME::SetActiveLayer()
     void SetActiveLayer( LAYER_ID aLayer ) override;
diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp
index 93e43e1..ab68b79 100644
--- a/pcbnew/modview_frame.cpp
+++ b/pcbnew/modview_frame.cpp
@@ -678,7 +678,7 @@ void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint )
 }
 
 
-EDA_COLOR_T FOOTPRINT_VIEWER_FRAME::GetGridColor() const
+COLOR4D FOOTPRINT_VIEWER_FRAME::GetGridColor() const
 {
     return g_ColorsSettings.GetItemColor( GRID_VISIBLE );
 }
diff --git a/pcbnew/modview_frame.h b/pcbnew/modview_frame.h
index ca347af..9c6ce27 100644
--- a/pcbnew/modview_frame.h
+++ b/pcbnew/modview_frame.h
@@ -52,7 +52,7 @@ protected:
 public:
     ~FOOTPRINT_VIEWER_FRAME();
 
-    virtual EDA_COLOR_T GetGridColor() const override;
+    virtual COLOR4D GetGridColor() const override;
 
     /**
      * Function ReCreateLibraryList
diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp
index 2aec042..0a92284 100644
--- a/pcbnew/pcb_painter.cpp
+++ b/pcbnew/pcb_painter.cpp
@@ -64,10 +64,10 @@ PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
 void PCB_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings )
 {
     for( int i = 0; i < LAYER_ID_COUNT; i++ )
-        m_layerColors[i] = m_legacyColorMap[aSettings->GetLayerColor( i )];
+        m_layerColors[i] = aSettings->GetLayerColor( i );
 
     for( int i = 0; i < END_PCB_VISIBLE_LIST; i++ )
-        m_layerColors[ITEM_GAL_LAYER( i )] = m_legacyColorMap[aSettings->GetItemColor( i )];
+        m_layerColors[ITEM_GAL_LAYER( i )] = aSettings->GetItemColor( i );
 
     m_layerColors[ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE )]            = m_layerColors[F_SilkS];
     m_layerColors[ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE )]            = m_layerColors[B_SilkS];
diff --git a/pcbnew/pcb_plot_params.h b/pcbnew/pcb_plot_params.h
index 8559ef7..1e17071 100644
--- a/pcbnew/pcb_plot_params.h
+++ b/pcbnew/pcb_plot_params.h
@@ -152,9 +152,9 @@ private:
     int         m_HPGLPenNum;           ///< HPGL only: pen number selection(1 to 9)
     int         m_HPGLPenSpeed;         ///< HPGL only: pen speed, always in cm/s (1 to 99 cm/s)
     int         m_HPGLPenDiam;          ///< HPGL only: pen diameter in MILS, useful to fill areas
-    EDA_COLOR_T m_color;                ///< Color for plotting the current layer
-    EDA_COLOR_T m_referenceColor;       ///< Color for plotting references
-    EDA_COLOR_T m_valueColor;           ///< Color for plotting values
+    COLOR4D     m_color;                ///< Color for plotting the current layer
+    COLOR4D     m_referenceColor;       ///< Color for plotting references
+    COLOR4D     m_valueColor;           ///< Color for plotting values
 
 public:
     PCB_PLOT_PARAMS();
@@ -169,14 +169,14 @@ public:
     bool        operator==( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
     bool        operator!=( const PCB_PLOT_PARAMS &aPcbPlotParams ) const;
 
-    void        SetColor( EDA_COLOR_T aVal ) { m_color = aVal; }
-    EDA_COLOR_T GetColor() const { return m_color; }
+    void        SetColor( COLOR4D aVal ) { m_color = aVal; }
+    COLOR4D     GetColor() const { return m_color; }
 
-    void        SetReferenceColor( EDA_COLOR_T aVal ) { m_referenceColor = aVal; }
-    EDA_COLOR_T GetReferenceColor() const { return m_referenceColor; }
+    void        SetReferenceColor( COLOR4D aVal ) { m_referenceColor = aVal; }
+    COLOR4D     GetReferenceColor() const { return m_referenceColor; }
 
-    void        SetValueColor( EDA_COLOR_T aVal ) { m_valueColor = aVal; }
-    EDA_COLOR_T GetValueColor() const { return m_valueColor; }
+    void        SetValueColor( COLOR4D aVal ) { m_valueColor = aVal; }
+    COLOR4D     GetValueColor() const { return m_valueColor; }
 
     void        SetTextMode( PlotTextMode aVal ) { m_textMode = aVal; }
     PlotTextMode GetTextMode() const { return m_textMode; }
diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp
index 11cef6d..b15a4f7 100644
--- a/pcbnew/pcbframe.cpp
+++ b/pcbnew/pcbframe.cpp
@@ -716,6 +716,37 @@ void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
     PCB_BASE_EDIT_FRAME::UseGalCanvas( aEnable );
 
     enableGALSpecificMenus();
+
+    // Force colors to be legacy-compatible in case they were changed in GAL
+    if( !aEnable )
+    {
+        forceColorsToLegacy();
+        Refresh();
+    }
+
+    // Re-create the layer manager to allow arbitrary colors when GAL is enabled
+    ReFillLayerWidget();
+    m_Layers->ReFillRender();
+}
+
+
+void PCB_EDIT_FRAME::forceColorsToLegacy()
+{
+    COLORS_DESIGN_SETTINGS *cds = GetBoard()->GetColorsSettings();
+
+    for( int i = 0; i < LAYER_ID_COUNT; i++ )
+    {
+        COLOR4D c = cds->GetLayerColor( i );
+        c.SetToNearestLegacyColor();
+        cds->SetLayerColor( i, c );
+    }
+
+    for( unsigned int i = 0; i < DIM( cds->m_ItemsColors ); i++ )
+    {
+        COLOR4D c = cds->GetItemColor( i );
+        c.SetToNearestLegacyColor();
+        cds->SetItemColor( i, c );
+    }
 }
 
 
@@ -816,26 +847,20 @@ void PCB_EDIT_FRAME::SetGridVisibility(bool aVisible)
 }
 
 
-EDA_COLOR_T PCB_EDIT_FRAME::GetGridColor() const
+COLOR4D PCB_EDIT_FRAME::GetGridColor() const
 {
     return GetBoard()->GetVisibleElementColor( GRID_VISIBLE );
 }
 
 
-void PCB_EDIT_FRAME::SetGridColor( EDA_COLOR_T aColor )
+void PCB_EDIT_FRAME::SetGridColor( COLOR4D aColor )
 {
 
     GetBoard()->SetVisibleElementColor( GRID_VISIBLE, aColor );
 
     if( IsGalCanvasActive() )
     {
-        StructColors c = g_ColorRefs[ aColor ];
-        KIGFX::COLOR4D color(  (double) c.m_Red / 255.0,
-                        (double) c.m_Green / 255.0,
-                        (double) c.m_Blue / 255.0,
-                        0.7 );
-
-         GetGalCanvas()->GetGAL()->SetGridColor( color );
+        GetGalCanvas()->GetGAL()->SetGridColor( aColor );
     }
 }
 
diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h
index 602f3ba..d204833 100644
--- a/pcbnew/pcbplot.h
+++ b/pcbnew/pcbplot.h
@@ -104,7 +104,7 @@ public:
     void SetLayerSet( LSET aLayerMask )     { m_layerMask = aLayerMask; }
     void Plot_Edges_Modules();
     void Plot_1_EdgeModule( EDGE_MODULE* aEdge );
-    void PlotTextModule( TEXTE_MODULE* aTextMod, EDA_COLOR_T aColor );
+    void PlotTextModule( TEXTE_MODULE* aTextMod, COLOR4D aColor );
 
     /*
      * Plot field of a module (footprint)
@@ -127,7 +127,7 @@ public:
      * and be drawn as a non filled item although the plot mode is filled
      * color and plot mode are needed by this function
      */
-    void PlotPad( D_PAD* aPad, EDA_COLOR_T aColor, EDA_DRAW_MODE_T aPlotMode );
+    void PlotPad( D_PAD* aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode );
 
     /**
      * plot items like text and graphics,
@@ -151,7 +151,7 @@ public:
      * and in B&W mode, is plotted as white but other colors are plotted in BLACK
      * so the returned color is LIGHTGRAY when the layer color is WHITE
      */
-    EDA_COLOR_T getColor( LAYER_NUM aLayer );
+    COLOR4D getColor( LAYER_NUM aLayer );
 
 private:
     /** Helper function to plot a single drill mark. It compensate and clamp
diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp
index e01bba7..8711378 100644
--- a/pcbnew/plot_board_layers.cpp
+++ b/pcbnew/plot_board_layers.cpp
@@ -98,13 +98,13 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
                 if( !( masklayer & layersmask_plotpads ).any() )
                     continue;
 
-                EDA_COLOR_T color = ColorFromInt( 0 );
+                COLOR4D color = COLOR4D_BLACK;
 
                 if( layersmask_plotpads[B_SilkS] )
                    color = aBoard->GetLayerColor( B_SilkS );
 
                 if( layersmask_plotpads[F_SilkS] )
-                    color = ColorFromInt( color | aBoard->GetLayerColor( F_SilkS ) );
+                    color = ( color == COLOR4D_BLACK) ? aBoard->GetLayerColor( F_SilkS ) : color;
 
                 itemplotter.PlotPad( pad, color, SKETCH );
             }
@@ -408,13 +408,13 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
             if( padPlotsSize.x <= 0 || padPlotsSize.y <= 0 )
                 continue;
 
-            EDA_COLOR_T color = BLACK;
+            COLOR4D color = COLOR4D_BLACK;
 
             if( pad->GetLayerSet()[B_Cu] )
                color = aBoard->GetVisibleElementColor( PAD_BK_VISIBLE );
 
             if( pad->GetLayerSet()[F_Cu] )
-                color = ColorFromInt( color | aBoard->GetVisibleElementColor( PAD_FR_VISIBLE ) );
+                color = color.LegacyMix( aBoard->GetVisibleElementColor( PAD_FR_VISIBLE ) );
 
             // Temporary set the pad size to the required plot size:
             wxSize tmppadsize = pad->GetSize();
@@ -507,7 +507,7 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter,
 
         gbr_metadata.SetNetName( Via->GetNetname() );
 
-        EDA_COLOR_T color = aBoard->GetVisibleElementColor(VIAS_VISIBLE + Via->GetViaType());
+        COLOR4D color = aBoard->GetVisibleElementColor( VIAS_VISIBLE + Via->GetViaType() );
         // Set plot color (change WHITE to LIGHTGRAY because
         // the white items are not seen on a white paper or screen
         aPlotter->SetColor( color != WHITE ? color : LIGHTGRAY);
diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp
index 12fce73..91c4bd0 100644
--- a/pcbnew/plot_brditems_plotter.cpp
+++ b/pcbnew/plot_brditems_plotter.cpp
@@ -54,16 +54,16 @@
  * and a group of board items
  */
 
-EDA_COLOR_T BRDITEMS_PLOTTER::getColor( LAYER_NUM aLayer )
+COLOR4D BRDITEMS_PLOTTER::getColor( LAYER_NUM aLayer )
 {
-    EDA_COLOR_T color = m_board->GetLayerColor( ToLAYER_ID( aLayer ) );
-    if (color == WHITE)
-        color = LIGHTGRAY;
+    COLOR4D color = m_board->GetLayerColor( ToLAYER_ID( aLayer ) );
+    if( color == COLOR4D_WHITE )
+        color = COLOR4D( LIGHTGRAY );
     return color;
 }
 
 
-void BRDITEMS_PLOTTER::PlotPad( D_PAD* aPad, EDA_COLOR_T aColor, EDA_DRAW_MODE_T aPlotMode )
+void BRDITEMS_PLOTTER::PlotPad( D_PAD* aPad, COLOR4D aColor, EDA_DRAW_MODE_T aPlotMode )
 {
     wxPoint shape_pos = aPad->ShapePos();
     GBR_METADATA gbr_metadata;
@@ -223,7 +223,7 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule )
     // Plot text fields, if allowed
     if( trace_ref )
     {
-        if( GetReferenceColor() == UNSPECIFIED_COLOR )
+        if( GetReferenceColor() == UNSPECIFIED_COLOR4D )
             PlotTextModule( &aModule->Reference(), getColor( textLayer ) );
         else
             PlotTextModule( &aModule->Reference(), GetReferenceColor() );
@@ -231,7 +231,7 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule )
 
     if( trace_val )
     {
-        if( GetValueColor() == UNSPECIFIED_COLOR )
+        if( GetValueColor() == UNSPECIFIED_COLOR4D )
             PlotTextModule( &aModule->Value(), getColor( textLayer ) );
         else
             PlotTextModule( &aModule->Value(), GetValueColor() );
@@ -292,15 +292,15 @@ void BRDITEMS_PLOTTER::PlotBoardGraphicItems()
     }
 }
 
-void BRDITEMS_PLOTTER::PlotTextModule( TEXTE_MODULE* pt_texte, EDA_COLOR_T aColor )
+void BRDITEMS_PLOTTER::PlotTextModule( TEXTE_MODULE* pt_texte, COLOR4D aColor )
 {
     wxSize  size;
     wxPoint pos;
     double  orient;
     int     thickness;
 
-    if( aColor == WHITE )
-        aColor = LIGHTGRAY;
+    if( aColor == COLOR4D_WHITE )
+        aColor = COLOR4D( LIGHTGRAY );
 
     m_plotter->SetColor( aColor );
 
@@ -344,7 +344,7 @@ void BRDITEMS_PLOTTER::PlotDimension( DIMENSION* aDim )
     draw.SetWidth( aDim->GetWidth() );
     draw.SetLayer( aDim->GetLayer() );
 
-    EDA_COLOR_T color = aDim->GetBoard()->GetLayerColor( aDim->GetLayer() );
+    COLOR4D color = aDim->GetBoard()->GetLayerColor( aDim->GetLayer() );
 
     // Set plot color (change WHITE to LIGHTGRAY because
     // the white items are not seen on a white paper or screen
@@ -591,14 +591,14 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
         for( unsigned ii = 0; ii <  strings_list.Count(); ii++ )
         {
             wxString& txt =  strings_list.Item( ii );
-            m_plotter->Text( positions[ii], UNSPECIFIED_COLOR, txt, orient, size,
+            m_plotter->Text( positions[ii], UNSPECIFIED_COLOR4D, txt, orient, size,
                              pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
                              thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
         }
     }
     else
     {
-        m_plotter->Text( pos, UNSPECIFIED_COLOR, shownText, orient, size,
+        m_plotter->Text( pos, UNSPECIFIED_COLOR4D, shownText, orient, size,
                          pt_texte->GetHorizJustify(), pt_texte->GetVertJustify(),
                          thickness, pt_texte->IsItalic(), allow_bold, false, &gbr_metadata );
     }
diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp
index 47291ed..00aef8b 100644
--- a/pcbnew/print_board_functions.cpp
+++ b/pcbnew/print_board_functions.cpp
@@ -223,7 +223,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
             int         radius = track->GetWidth() / 2;
             const VIA*  via = static_cast<const VIA*>( track );
 
-            EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + via->GetViaType() );
+            COLOR4D color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + via->GetViaType() );
 
             GRFilledCircle( m_canvas->GetClipBox(), aDC,
                             via->GetStart().x,
@@ -272,7 +272,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
     if( drillShapeOpt != PRINT_PARAMETERS::NO_DRILL_SHAPE )
     {
         TRACK*      track = Pcb->m_Track;
-        EDA_COLOR_T color = WHITE;
+        COLOR4D     color = COLOR4D_WHITE;
 
         bool blackpenstate = GetGRForceBlackPenState();
 
diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp
index f49c0e6..1e55633 100644
--- a/pcbnew/printout_controler.cpp
+++ b/pcbnew/printout_controler.cpp
@@ -282,7 +282,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage( const wxString& aLayerName, int aPageN
     panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) );
 
     screen->m_IsPrinting = true;
-    EDA_COLOR_T bg_color = m_Parent->GetDrawBgColor();
+    COLOR4D bg_color = m_Parent->GetDrawBgColor();
 
     // Print frame reference, if requested, before
     if( m_PrintParams.m_Print_Black_and_White )
diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp
index fcd3be2..aa80370 100644
--- a/pcbnew/ratsnest.cpp
+++ b/pcbnew/ratsnest.cpp
@@ -752,7 +752,7 @@ void PCB_BASE_FRAME::TraceModuleRatsNest( wxDC* DC )
     if( ( m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK ) == 0 )
         return;
 
-    EDA_COLOR_T tmpcolor = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE);
+    COLOR4D tmpcolor = g_ColorsSettings.GetItemColor( RATSNEST_VISIBLE );
 
     for( unsigned ii = 0; ii < m_Pcb->m_LocalRatsnest.size(); ii++ )
     {
diff --git a/pcbnew/router/router_preview_item.cpp b/pcbnew/router/router_preview_item.cpp
index 7eaf0bc..abd4609 100644
--- a/pcbnew/router/router_preview_item.cpp
+++ b/pcbnew/router/router_preview_item.cpp
@@ -27,7 +27,6 @@
 
 #include "class_track.h"
 #include <pcb_painter.h>
-#include <colors.h>
 
 #include "router_preview_item.h"
 
diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp
index 44fad09..63b9654 100644
--- a/pcbnew/sel_layer.cpp
+++ b/pcbnew/sel_layer.cpp
@@ -59,7 +59,7 @@ protected:
 
     // Returns a color index from the layer id
     // Virtual function
-    EDA_COLOR_T GetLayerColor( LAYER_NUM aLayer ) const override
+    COLOR4D GetLayerColor( LAYER_NUM aLayer ) const override
     {
         return m_brd->GetLayerColor( ToLAYER_ID( aLayer ) );
     }
@@ -138,7 +138,7 @@ void PCB_ONE_LAYER_SELECTOR::buildList()
         if( m_notAllowedLayersMask[layerid] )
             continue;
 
-        wxColour color = MakeColour( GetLayerColor( layerid ) );
+        COLOR4D color = GetLayerColor( layerid );
         layername = GetLayerName( layerid );
 
         if( IsCopperLayer( layerid ) )
@@ -147,7 +147,7 @@ void PCB_ONE_LAYER_SELECTOR::buildList()
                 m_leftGridLayers->AppendRows( 1 );
 
             m_leftGridLayers->SetCellBackgroundColour ( left_row, COLOR_COLNUM,
-                                                        color );
+                                                        color.ToColour() );
             m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM,
                                             layername );
 
@@ -156,7 +156,7 @@ void PCB_ONE_LAYER_SELECTOR::buildList()
                 m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM,
                                                 wxT("X") );
                 m_leftGridLayers->SetCellBackgroundColour ( left_row, SELECT_COLNUM,
-                                                        color );
+                                                        color.ToColour() );
                 m_leftGridLayers->SetGridCursor( left_row, LAYERNAME_COLNUM );
             }
 
@@ -169,7 +169,7 @@ void PCB_ONE_LAYER_SELECTOR::buildList()
                 m_rightGridLayers->AppendRows( 1 );
 
             m_rightGridLayers->SetCellBackgroundColour ( right_row, COLOR_COLNUM,
-                                                         color );
+                                                         color.ToColour() );
             m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM,
                                              layername );
 
@@ -178,7 +178,7 @@ void PCB_ONE_LAYER_SELECTOR::buildList()
                 m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM,
                                                  wxT("X") );
                 m_rightGridLayers->SetCellBackgroundColour ( right_row, SELECT_COLNUM,
-                                                         color );
+                                                         color.ToColour() );
                 m_rightGridLayers->SetGridCursor( right_row, LAYERNAME_COLNUM );
             }
 
@@ -338,14 +338,14 @@ void SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList()
         if( !IsCopperLayer( layerid ) )
             break;
 
-        wxColour color = MakeColour( GetLayerColor( layerid ) );
+        COLOR4D color = GetLayerColor( layerid );
 
         layername = GetLayerName( layerid );
 
         if( row )
             m_leftGridLayers->AppendRows( 1 );
 
-        m_leftGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color );
+        m_leftGridLayers->SetCellBackgroundColour( row, COLOR_COLNUM, color.ToColour() );
         m_leftGridLayers->SetCellValue( row, LAYERNAME_COLNUM, layername );
         m_layersId.push_back( layerid );
 
@@ -358,7 +358,7 @@ void SELECT_COPPER_LAYERS_PAIR_DIALOG::buildList()
         if( row )
             m_rightGridLayers->AppendRows( 1 );
         m_rightGridLayers->SetCellBackgroundColour ( row, COLOR_COLNUM,
-                                                     color );
+                                                     color.ToColour() );
         m_rightGridLayers->SetCellValue( row, LAYERNAME_COLNUM,
                                          layername );
 
@@ -384,9 +384,9 @@ void SELECT_COPPER_LAYERS_PAIR_DIALOG::SetGridCursor( wxGrid* aGrid, int aRow,
     if( aEnable )
     {
         LAYER_ID  layerid = m_layersId[aRow];
-        wxColour color = MakeColour( GetLayerColor( layerid ) );
+        COLOR4D color = GetLayerColor( layerid );
         aGrid->SetCellValue( aRow, SELECT_COLNUM, wxT("X") );
-        aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM, color );
+        aGrid->SetCellBackgroundColour( aRow, SELECT_COLNUM, color.ToColour() );
         aGrid->SetGridCursor( aRow, LAYERNAME_COLNUM );
     }
     else
diff --git a/pcbnew/swig/pcbnew.i b/pcbnew/swig/pcbnew.i
index 3a6ada4..6e9997c 100644
--- a/pcbnew/swig/pcbnew.i
+++ b/pcbnew/swig/pcbnew.i
@@ -59,7 +59,7 @@ class BASE_SET {};
 
 %{
 #include <wx_python_helpers.h>
-#include <colors.h>
+#include <gal/color4d.h>
 
 #include <pcbnew_scripting_helpers.h>
 
@@ -103,7 +103,7 @@ HANDLE_EXCEPTIONS(PLUGIN::FootprintDelete)
 %include <pcb_plot_params.h>
 %include <plot_common.h>
 %include <exporters/gendrill_Excellon_writer.h>
-%include <colors.h>
+%include <gal/color4d.h>
 
 %include <pcbnew_scripting_helpers.h>
 
diff --git a/pcbnew/swig/python_scripting.cpp b/pcbnew/swig/python_scripting.cpp
index ece4fcf..af57668 100644
--- a/pcbnew/swig/python_scripting.cpp
+++ b/pcbnew/swig/python_scripting.cpp
@@ -34,7 +34,7 @@
 #include <fctsys.h>
 #include <wxstruct.h>
 #include <common.h>
-#include <colors.h>
+#include <gal/color4d.h>
 #include <macros.h>
 
 #include <pgm_base.h>
diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp
index 5131298..cc8fb37 100644
--- a/pcbnew/tool_pcb.cpp
+++ b/pcbnew/tool_pcb.cpp
@@ -92,13 +92,13 @@ static const char s_BitmapLayerIcon[BM_LAYERICON_SIZE][BM_LAYERICON_SIZE] =
 void PCB_EDIT_FRAME::PrepareLayerIndicator()
 {
     int        ii, jj;
-    EDA_COLOR_T active_layer_color, Route_Layer_TOP_color,
+    COLOR4D    active_layer_color, Route_Layer_TOP_color,
                Route_Layer_BOTTOM_color, via_color;
     bool       change = false;
     bool first_call = LayerPairBitmap == NULL;
 
-    static int previous_active_layer_color, previous_Route_Layer_TOP_color,
-               previous_Route_Layer_BOTTOM_color, previous_via_color;
+    static COLOR4D previous_active_layer_color, previous_Route_Layer_TOP_color,
+                   previous_Route_Layer_BOTTOM_color, previous_via_color;
 
     /* get colors, and redraw bitmap button only on changes */
     active_layer_color = GetBoard()->GetLayerColor(GetActiveLayer());
@@ -163,19 +163,19 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator()
                 {
                 default:
                 case 0:
-                    pen.SetColour( MakeColour( active_layer_color ) );
+                    pen.SetColour( active_layer_color.ToColour() );
                     break;
 
                 case 1:
-                    pen.SetColour( MakeColour( Route_Layer_TOP_color) );
+                    pen.SetColour( Route_Layer_TOP_color.ToColour() );
                     break;
 
                 case 2:
-                    pen.SetColour( MakeColour( Route_Layer_BOTTOM_color ) );
+                    pen.SetColour( Route_Layer_BOTTOM_color.ToColour() );
                     break;
 
                 case 3:
-                    pen.SetColour( MakeColour( via_color ) );
+                    pen.SetColour( via_color.ToColour() );
                     break;
                 }
 
-- 
2.7.4


Follow ups