From d8b9899516fef82e8c0bed8d2a8e72e2ed771059 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Tue, 14 Aug 2018 20:52:27 +0200 Subject: [PATCH] eeschema-gal: configurable worksheet & grid colors --- eeschema/eeschema.cpp | 10 ++++++---- eeschema/sch_painter.cpp | 5 +++++ .../widgets/widget_eeschema_color_config.cpp | 18 +++++++++--------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 6765a3176f..481b22464a 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -169,11 +169,11 @@ PGM_BASE& Pgm() } -static COLOR4D s_layerColor[SCH_LAYER_ID_COUNT]; +static COLOR4D s_layerColor[LAYER_ID_COUNT]; COLOR4D GetLayerColor( SCH_LAYER_ID aLayer ) { - unsigned layer = SCH_LAYER_INDEX( aLayer ); + unsigned layer = ( aLayer ); wxASSERT( layer < DIM( s_layerColor ) ); return s_layerColor[layer]; } @@ -186,7 +186,7 @@ void SetLayerColor( COLOR4D aColor, SCH_LAYER_ID aLayer ) if( aColor == COLOR4D::WHITE && aLayer != LAYER_SCHEMATIC_BACKGROUND ) aColor.Darken( 0.01 ); - unsigned layer = SCH_LAYER_INDEX( aLayer ); + unsigned layer = aLayer; wxASSERT( layer < DIM( s_layerColor ) ); s_layerColor[layer] = aColor; } @@ -203,7 +203,7 @@ static PARAM_CFG_ARRAY& cfg_params() #define CLR(x, y, z)\ ca.push_back( new PARAM_CFG_SETCOLOR( true, wxT( x ),\ - &s_layerColor[SCH_LAYER_INDEX( y )], z ) ); + &s_layerColor[( y )], z ) ); CLR( "Color4DWireEx", LAYER_WIRE, COLOR4D( GREEN ) ) CLR( "Color4DBusEx", LAYER_BUS, COLOR4D( BLUE ) ) @@ -231,6 +231,8 @@ static PARAM_CFG_ARRAY& cfg_params() CLR( "Color4DGridEx", LAYER_SCHEMATIC_GRID, COLOR4D( DARKGRAY ) ) CLR( "Color4DBgCanvasEx", LAYER_SCHEMATIC_BACKGROUND, COLOR4D( WHITE ) ) CLR( "Color4DBrightenedEx", LAYER_BRIGHTENED, COLOR4D( PUREMAGENTA ) ) + CLR( "Color4DWorksheetEx", LAYER_WORKSHEET, COLOR4D( RED ) ) + CLR( "Color4DGridEx", LAYER_GRID, COLOR4D( DARKGRAY ) ) } return ca; diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 51ef00ee87..3a77a510b7 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -86,6 +86,11 @@ void SCH_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSet m_layerColors[ layer ] = ::GetLayerColor( static_cast( layer ) ); } + for( int layer = GAL_LAYER_ID_START; layer < GAL_LAYER_ID_END; layer ++) + { + m_layerColors[ layer ] = ::GetLayerColor( static_cast( layer ) ); + } + m_backgroundColor = ::GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ); } diff --git a/eeschema/widgets/widget_eeschema_color_config.cpp b/eeschema/widgets/widget_eeschema_color_config.cpp index 96f318fd6b..cb471f58fc 100644 --- a/eeschema/widgets/widget_eeschema_color_config.cpp +++ b/eeschema/widgets/widget_eeschema_color_config.cpp @@ -106,7 +106,7 @@ static BUTTONINDEX buttonGroups[] = { static COLORBUTTON bgColorButton = { "", LAYER_SCHEMATIC_BACKGROUND }; -static COLOR4D currentColors[ SCH_LAYER_ID_COUNT ]; +static COLOR4D currentColors[ LAYER_ID_COUNT ]; WIDGET_EESCHEMA_COLOR_CONFIG::WIDGET_EESCHEMA_COLOR_CONFIG( wxWindow* aParent, EDA_DRAW_FRAME* aDrawFrame ) : @@ -155,7 +155,7 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls() columnBoxSizer->Add( rowBoxSizer, 0, wxGROW | wxALL, 0 ); COLOR4D color = GetLayerColor( SCH_LAYER_ID( buttons->m_Layer ) ); - currentColors[ SCH_LAYER_INDEX( buttons->m_Layer ) ] = color; + currentColors[ buttons->m_Layer ] = color; wxMemoryDC iconDC; wxBitmap bitmap( m_butt_size_pix ); @@ -220,7 +220,7 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::CreateControls() columnBoxSizer->Add( selBgColorBtn, 1, wxRIGHT | wxBOTTOM, 5 ); } - currentColors[ SCH_LAYER_INDEX( LAYER_SCHEMATIC_BACKGROUND ) ] = bgColor; + currentColors[ LAYER_SCHEMATIC_BACKGROUND ] = bgColor; // Dialog now needs to be resized, but the associated command is found elsewhere. } @@ -235,7 +235,7 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::SetColor( wxCommandEvent& event ) COLORBUTTON* colorButton = (COLORBUTTON*) button->GetClientData(); wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) ); - COLOR4D oldColor = currentColors[ SCH_LAYER_INDEX( colorButton->m_Layer ) ]; + COLOR4D oldColor = currentColors[ colorButton->m_Layer ]; COLOR4D newColor = COLOR4D::UNSPECIFIED; DIALOG_COLOR_PICKER dialog( this, oldColor, false ); @@ -247,7 +247,7 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::SetColor( wxCommandEvent& event ) if( newColor == COLOR4D::UNSPECIFIED || oldColor == newColor ) return; - currentColors[ SCH_LAYER_INDEX( colorButton->m_Layer ) ] = newColor; + currentColors[ colorButton->m_Layer ] = newColor; wxMemoryDC iconDC; @@ -275,11 +275,11 @@ bool WIDGET_EESCHEMA_COLOR_CONFIG::TransferDataFromControl() // Check for color conflicts with background color to give user a chance to bail // out before making changes. - COLOR4D bgcolor = currentColors[ SCH_LAYER_INDEX( LAYER_SCHEMATIC_BACKGROUND ) ]; + COLOR4D bgcolor = currentColors[ LAYER_SCHEMATIC_BACKGROUND ]; for( SCH_LAYER_ID clyr = LAYER_WIRE; clyr < SCH_LAYER_ID_END; ++clyr ) { - if( bgcolor == currentColors[ SCH_LAYER_INDEX( clyr ) ] && clyr != LAYER_SCHEMATIC_BACKGROUND ) + if( bgcolor == currentColors[ clyr ] && clyr != LAYER_SCHEMATIC_BACKGROUND ) { warning = true; break; @@ -300,12 +300,12 @@ bool WIDGET_EESCHEMA_COLOR_CONFIG::TransferDataFromControl() // Update color of background GetDrawFrame()->SetDrawBgColor( bgcolor ); - currentColors[ SCH_LAYER_INDEX( LAYER_SCHEMATIC_BACKGROUND ) ] = bgcolor; + currentColors[ LAYER_SCHEMATIC_BACKGROUND ] = bgcolor; for( SCH_LAYER_ID clyr = LAYER_WIRE; clyr < SCH_LAYER_ID_END; ++clyr ) { - SetLayerColor( currentColors[ SCH_LAYER_INDEX( clyr ) ], clyr ); + SetLayerColor( currentColors[ clyr ], clyr ); } GetDrawFrame()->SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) );