GAL: Make high-contrast meld into background

This mixes the de-emphasized layers into the background color rather
than merely a black color.  This also keeps some of the original layer
color.

Fixes: lp:1831316
* https://bugs.launchpad.net/kicad/+bug/1831316
This commit is contained in:
Seth Hillbrand 2019-06-09 08:13:50 -07:00
parent 63eb552e0a
commit 4a52062a54
5 changed files with 24 additions and 7 deletions

View File

@ -37,7 +37,7 @@ RENDER_SETTINGS::RENDER_SETTINGS()
m_layerOpacity = 0.8;
m_highlightEnabled = false;
m_hiContrastEnabled = false;
m_hiContrastFactor = 0.2;
m_hiContrastFactor = 0.2; //TODO: Make this user-configurable
m_highlightNetcode = -1;
m_outlineWidth = 1;
m_worksheetLineWidth = 100000;
@ -52,12 +52,11 @@ RENDER_SETTINGS::~RENDER_SETTINGS()
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 < LAYER_ID_COUNT; i++ )
{
m_hiContrastColor[i] = m_layerColors[i].Mix( m_layerColors[LAYER_PCB_BACKGROUND],
m_hiContrastFactor );
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 );

View File

@ -133,7 +133,7 @@ const COLOR4D& GERBVIEW_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int a
// Return grayish color for non-highlighted layers in the high contrast mode
if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0)
return m_hiContrastColor;
return m_hiContrastColor[aLayer];
// Catch the case when highlight and high-contraste modes are enabled
// and we are drawing a not highlighted track

View File

@ -222,6 +222,22 @@ public:
a );
}
/**
* Function Mix
* Returns a color that is mixed with the input by a factor
* @param aFactor Specifies how much of the original color to keep (valid values: 0.0 .. 1.0).
* @return COLOR4D Mixed color.
*/
COLOR4D Mix( const COLOR4D& aColor, double aFactor ) const
{
assert( aFactor >= 0.0 && aFactor <= 1.0 );
return COLOR4D( aColor.r * ( 1.0 - aFactor ) + r * aFactor,
aColor.g * ( 1.0 - aFactor ) + g * aFactor,
aColor.b * ( 1.0 - aFactor ) + b * aFactor,
a );
}
/**
* Function WithAlpha
* Returns a colour with the same colour, but the given alpha

View File

@ -271,9 +271,11 @@ protected:
///> Colors for all layers (darkened)
COLOR4D m_layerColorsDark[LAYER_ID_COUNT];
///< Colora used for high contrast display mode
COLOR4D m_hiContrastColor[LAYER_ID_COUNT];
/// Parameters for display modes
bool m_hiContrastEnabled; ///< High contrast display mode on/off
COLOR4D m_hiContrastColor; ///< Color used for high contrast display mode
float m_hiContrastFactor; ///< Factor used for computing high contrast color
bool m_highlightEnabled; ///< Highlight display mode on/off

View File

@ -254,7 +254,7 @@ const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer
// Return grayish color for non-highlighted layers in the high contrast mode
if( m_hiContrastEnabled && m_activeLayers.count( aLayer ) == 0 )
return m_hiContrastColor;
return m_hiContrastColor[aLayer];
// Catch the case when highlight and high-contraste modes are enabled
// and we are drawing a not highlighted track