diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index e14181d2fc..69002a6b35 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -39,8 +39,6 @@ #include #include -#include // display options definition - #ifdef PROFILE #include #endif /* PROFILE */ @@ -164,7 +162,7 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) wxASSERT( m_painter ); m_drawing = true; - KIGFX::PCB_RENDER_SETTINGS* settings = static_cast( m_painter->GetSettings() ); + KIGFX::RENDER_SETTINGS* settings = static_cast( m_painter->GetSettings() ); // Scrollbars broken in GAL on OSX #ifndef __WXMAC__ diff --git a/common/painter.cpp b/common/painter.cpp index 0d6b1f0399..60d6614e1b 100644 --- a/common/painter.cpp +++ b/common/painter.cpp @@ -62,6 +62,14 @@ void RENDER_SETTINGS::update() { m_hiContrastColor = COLOR4D( m_hiContrastFactor, m_hiContrastFactor, m_hiContrastFactor, m_layerOpacity ); + + // Calculate darkened/highlighted variants of layer colors + for( int i = 0; i < TOTAL_LAYER_COUNT; i++ ) + { + m_layerColorsHi[i] = m_layerColors[i].Brightened( m_highlightFactor ); + m_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor ); + m_layerColorsSel[i] = m_layerColors[i].Brightened( m_selectFactor ); + } } diff --git a/include/painter.h b/include/painter.h index cf586fa085..cf6cefc7a0 100644 --- a/include/painter.h +++ b/include/painter.h @@ -33,6 +33,7 @@ #include #include #include +#include #include class EDA_ITEM; @@ -207,6 +208,29 @@ public: m_backgroundColor = aColor; } + /** + * Function GetLayerColor + * Returns the color used to draw a layer. + * @param aLayer is the layer number. + */ + inline const COLOR4D& GetLayerColor( int aLayer ) const + { + return m_layerColors[aLayer]; + } + + /** + * Function SetLayerColor + * Changes the color used to draw a layer. + * @param aLayer is the layer number. + * @param aColor is the new color. + */ + inline void SetLayerColor( int aLayer, const COLOR4D& aColor ) + { + m_layerColors[aLayer] = aColor; + + update(); // recompute other shades of the color + } + protected: /** * Function update @@ -217,6 +241,18 @@ protected: std::set m_activeLayers; ///< Stores active layers number + ///> Colors for all layers (normal) + COLOR4D m_layerColors[TOTAL_LAYER_COUNT]; + + ///> Colors for all layers (highlighted) + COLOR4D m_layerColorsHi[TOTAL_LAYER_COUNT]; + + ///> Colors for all layers (selected) + COLOR4D m_layerColorsSel[TOTAL_LAYER_COUNT]; + + ///> Colors for all layers (darkened) + COLOR4D m_layerColorsDark[TOTAL_LAYER_COUNT]; + /// Parameters for display modes bool m_hiContrastEnabled; ///< High contrast display mode on/off COLOR4D m_hiContrastColor; ///< Color used for high contrast display mode diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 94bae89004..22060521e9 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -225,20 +225,6 @@ const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer } -void PCB_RENDER_SETTINGS::update() -{ - RENDER_SETTINGS::update(); - - // Calculate darkened/highlighted variants of layer colors - for( int i = 0; i < TOTAL_LAYER_COUNT; i++ ) - { - m_layerColorsHi[i] = m_layerColors[i].Brightened( m_highlightFactor ); - m_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor ); - m_layerColorsSel[i] = m_layerColors[i].Brightened( m_selectFactor ); - } -} - - PCB_PAINTER::PCB_PAINTER( GAL* aGal ) : PAINTER( aGal ) { diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index 718f619a12..25235fb6d6 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -27,7 +27,6 @@ #ifndef __CLASS_PCB_PAINTER_H #define __CLASS_PCB_PAINTER_H -#include #include #include @@ -105,29 +104,6 @@ public: /// @copydoc RENDER_SETTINGS::GetColor() virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override; - /** - * Function GetLayerColor - * Returns the color used to draw a layer. - * @param aLayer is the layer number. - */ - inline const COLOR4D& GetLayerColor( int aLayer ) const - { - return m_layerColors[aLayer]; - } - - /** - * Function SetLayerColor - * Changes the color used to draw a layer. - * @param aLayer is the layer number. - * @param aColor is the new color. - */ - inline void SetLayerColor( int aLayer, const COLOR4D& aColor ) - { - m_layerColors[aLayer] = aColor; - - update(); // recompute other shades of the color - } - /** * Function SetSketchMode * Turns on/off sketch mode for given item layer. @@ -151,21 +127,6 @@ public: } protected: - ///> @copydoc RENDER_SETTINGS::Update() - void update() override; - - ///> Colors for all layers (normal) - COLOR4D m_layerColors[TOTAL_LAYER_COUNT]; - - ///> Colors for all layers (highlighted) - COLOR4D m_layerColorsHi[TOTAL_LAYER_COUNT]; - - ///> Colors for all layers (selected) - COLOR4D m_layerColorsSel[TOTAL_LAYER_COUNT]; - - ///> Colors for all layers (darkened) - COLOR4D m_layerColorsDark[TOTAL_LAYER_COUNT]; - ///> Flag determining if items on a given layer should be drawn as an outline or a filled item bool m_sketchMode[TOTAL_LAYER_COUNT];