Add ability to override individual item colors.

Fixes https://gitlab.com/kicad/code/kicad/issues/4167
This commit is contained in:
Jeff Young 2020-04-09 17:15:57 +01:00
parent 2c8ada42a0
commit f4e22a9264
19 changed files with 204 additions and 51 deletions

View File

@ -145,7 +145,7 @@ bool DIALOG_COLOR_PICKER::TransferDataToWindow()
{ {
// Draw all bitmaps, with colors according to the color 4D // Draw all bitmaps, with colors according to the color 4D
setIconColor( m_OldColorRect, m_previousColor4D ); setIconColor( m_OldColorRect, m_previousColor4D );
SetEditVals( ALL_CHANGED ); SetEditVals( ALL_CHANGED, false );
drawAll(); drawAll();
// Configure the spin control sizes // Configure the spin control sizes
@ -525,8 +525,16 @@ void DIALOG_COLOR_PICKER::drawHSVPalette()
} }
void DIALOG_COLOR_PICKER::SetEditVals( CHANGED_COLOR aChanged ) void DIALOG_COLOR_PICKER::SetEditVals( CHANGED_COLOR aChanged, bool aCheckTransparency )
{ {
if( aCheckTransparency )
{
// If they've changed the color, they probably don't want it to remain 100% transparent,
// and it looks like a bug when it changing the color has no effect.
if( m_newColor4D.a == 0.0 )
m_newColor4D.a = 1.0;
}
m_sliderTransparency->SetValue( normalizeToInt( m_newColor4D.a, ALPHA_MAX ) ); m_sliderTransparency->SetValue( normalizeToInt( m_newColor4D.a, ALPHA_MAX ) );
if( aChanged == RED_CHANGED || aChanged == GREEN_CHANGED || aChanged == BLUE_CHANGED ) if( aChanged == RED_CHANGED || aChanged == GREEN_CHANGED || aChanged == BLUE_CHANGED )
@ -578,9 +586,10 @@ void DIALOG_COLOR_PICKER::buttColorClick( wxCommandEvent& event )
m_newColor4D.r = color.r; m_newColor4D.r = color.r;
m_newColor4D.g = color.g; m_newColor4D.g = color.g;
m_newColor4D.b = color.b; m_newColor4D.b = color.b;
m_newColor4D.a = color.a;
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true ); m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
SetEditVals( ALL_CHANGED ); SetEditVals( ALL_CHANGED, false );
drawAll(); drawAll();
@ -680,7 +689,7 @@ void DIALOG_COLOR_PICKER::onRGBMouseDrag( wxMouseEvent& event )
} }
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true ); m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
SetEditVals( ALL_CHANGED ); SetEditVals( ALL_CHANGED, true );
drawAll(); drawAll();
} }
@ -737,7 +746,7 @@ bool DIALOG_COLOR_PICKER::setHSvaluesFromCursor( wxPoint aMouseCursor )
m_hue += 360.0; m_hue += 360.0;
m_newColor4D.FromHSV( m_hue, m_sat, m_val ); m_newColor4D.FromHSV( m_hue, m_sat, m_val );
SetEditVals( ALL_CHANGED ); SetEditVals( ALL_CHANGED, true );
return true; return true;
} }
@ -758,7 +767,7 @@ void DIALOG_COLOR_PICKER::OnChangeEditRed( wxSpinEvent& event )
{ {
double val = (double)event.GetPosition() / 255.0; double val = (double)event.GetPosition() / 255.0;
m_newColor4D.r = val; m_newColor4D.r = val;
SetEditVals( RED_CHANGED ); SetEditVals( RED_CHANGED, true );
drawAll(); drawAll();
} }
@ -768,7 +777,7 @@ void DIALOG_COLOR_PICKER::OnChangeEditGreen( wxSpinEvent& event )
{ {
double val = (double)event.GetPosition() / 255.0; double val = (double)event.GetPosition() / 255.0;
m_newColor4D.g = val; m_newColor4D.g = val;
SetEditVals( GREEN_CHANGED ); SetEditVals( GREEN_CHANGED, true );
drawAll(); drawAll();
} }
@ -778,7 +787,7 @@ void DIALOG_COLOR_PICKER::OnChangeEditBlue( wxSpinEvent& event )
{ {
double val = (double)event.GetPosition() / 255.0; double val = (double)event.GetPosition() / 255.0;
m_newColor4D.b = val; m_newColor4D.b = val;
SetEditVals( BLUE_CHANGED ); SetEditVals( BLUE_CHANGED, true );
drawAll(); drawAll();
} }
@ -790,7 +799,7 @@ void DIALOG_COLOR_PICKER::OnChangeEditHue( wxSpinEvent& event )
m_newColor4D.FromHSV( m_hue, m_sat, m_val ); m_newColor4D.FromHSV( m_hue, m_sat, m_val );
SetEditVals( HUE_CHANGED ); SetEditVals( HUE_CHANGED, true );
drawAll(); drawAll();
} }
@ -802,7 +811,7 @@ void DIALOG_COLOR_PICKER::OnChangeEditSat( wxSpinEvent& event )
m_newColor4D.FromHSV( m_hue, m_sat, m_val ); m_newColor4D.FromHSV( m_hue, m_sat, m_val );
SetEditVals( SAT_CHANGED ); SetEditVals( SAT_CHANGED, true );
drawAll(); drawAll();
} }
@ -814,7 +823,7 @@ void DIALOG_COLOR_PICKER::OnChangeBrightness( wxScrollEvent& event )
m_newColor4D.FromHSV( m_hue, m_sat, m_val ); m_newColor4D.FromHSV( m_hue, m_sat, m_val );
SetEditVals( VAL_CHANGED ); SetEditVals( VAL_CHANGED, true );
drawAll(); drawAll();
} }
@ -825,9 +834,10 @@ void DIALOG_COLOR_PICKER::OnResetButton( wxCommandEvent& aEvent )
m_newColor4D.r = m_defaultColor.r; m_newColor4D.r = m_defaultColor.r;
m_newColor4D.g = m_defaultColor.g; m_newColor4D.g = m_defaultColor.g;
m_newColor4D.b = m_defaultColor.b; m_newColor4D.b = m_defaultColor.b;
m_newColor4D.a = m_defaultColor.a;
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true ); m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
SetEditVals( ALL_CHANGED ); SetEditVals( ALL_CHANGED, false );
drawAll(); drawAll();
} }

View File

@ -117,7 +117,7 @@ private:
std::vector<wxBitmapButton*> m_buttonsColor; ///< list of defined colors buttons std::vector<wxBitmapButton*> m_buttonsColor; ///< list of defined colors buttons
void SetEditVals( CHANGED_COLOR aChanged ); void SetEditVals( CHANGED_COLOR aChanged, bool aCheckTransparency );
void drawAll(); void drawAll();
void createHSVBitmap(); ///< generate the bitmap that shows the HSV color circle void createHSVBitmap(); ///< generate the bitmap that shows the HSV color circle

View File

@ -164,7 +164,7 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
m_opacityLabel->Wrap( -1 ); m_opacityLabel->Wrap( -1 );
m_SizerTransparency->Add( m_opacityLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxLEFT, 5 ); m_SizerTransparency->Add( m_opacityLabel, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxLEFT, 5 );
m_sliderTransparency = new wxSlider( this, wxID_ANY, 80, 20, 100, wxDefaultPosition, wxDefaultSize, wxSL_INVERSE|wxSL_LABELS|wxSL_LEFT|wxSL_VERTICAL ); m_sliderTransparency = new wxSlider( this, wxID_ANY, 80, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_INVERSE|wxSL_LABELS|wxSL_LEFT|wxSL_VERTICAL );
m_SizerTransparency->Add( m_sliderTransparency, 1, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_HORIZONTAL, 10 ); m_SizerTransparency->Add( m_sliderTransparency, 1, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_HORIZONTAL, 10 );

View File

@ -1350,7 +1350,7 @@
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="minValue">20</property> <property name="minValue">0</property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>

View File

@ -29,6 +29,14 @@ PANEL_COLOR_SETTINGS_BASE::PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindow
bControlSizer->Add( m_cbTheme, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); bControlSizer->Add( m_cbTheme, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 );
bControlSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_optOverrideColors = new wxCheckBox( this, wxID_ANY, _("Override individual item colors"), wxDefaultPosition, wxDefaultSize, 0 );
m_optOverrideColors->SetToolTip( _("Show all items in their default color even if they have specific colors set in their properties.") );
bControlSizer->Add( m_optOverrideColors, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
bControlSizer->Add( 0, 0, 1, wxEXPAND, 5 ); bControlSizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_btnReset = new wxButton( this, wxID_ANY, _("&Reset to Defaults"), wxDefaultPosition, wxDefaultSize, 0 ); m_btnReset = new wxButton( this, wxID_ANY, _("&Reset to Defaults"), wxDefaultPosition, wxDefaultSize, 0 );
@ -74,6 +82,7 @@ PANEL_COLOR_SETTINGS_BASE::PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindow
// Connect Events // Connect Events
this->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_COLOR_SETTINGS_BASE::OnSize ) ); this->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_COLOR_SETTINGS_BASE::OnSize ) );
m_cbTheme->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeChanged ), NULL, this ); m_cbTheme->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeChanged ), NULL, this );
m_optOverrideColors->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnOverrideItemColorsClicked ), NULL, this );
m_btnReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnResetClicked ), NULL, this ); m_btnReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnResetClicked ), NULL, this );
m_btnOpenFolder->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnOpenThemeFolderClicked ), NULL, this ); m_btnOpenFolder->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnOpenThemeFolderClicked ), NULL, this );
} }
@ -83,6 +92,7 @@ PANEL_COLOR_SETTINGS_BASE::~PANEL_COLOR_SETTINGS_BASE()
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_COLOR_SETTINGS_BASE::OnSize ) ); this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_COLOR_SETTINGS_BASE::OnSize ) );
m_cbTheme->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeChanged ), NULL, this ); m_cbTheme->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeChanged ), NULL, this );
m_optOverrideColors->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnOverrideItemColorsClicked ), NULL, this );
m_btnReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnResetClicked ), NULL, this ); m_btnReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnResetClicked ), NULL, this );
m_btnOpenFolder->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnOpenThemeFolderClicked ), NULL, this ); m_btnOpenFolder->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnOpenThemeFolderClicked ), NULL, this );

View File

@ -200,6 +200,81 @@
<property name="width">0</property> <property name="width">0</property>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Override individual item colors</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_optOverrideColors</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">public</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Show all items in their default color even if they have specific colors set in their properties.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCheckBox">OnOverrideItemColorsClicked</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property> <property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>

View File

@ -17,6 +17,7 @@
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/choice.h> #include <wx/choice.h>
#include <wx/checkbox.h>
#include <wx/bitmap.h> #include <wx/bitmap.h>
#include <wx/image.h> #include <wx/image.h>
#include <wx/icon.h> #include <wx/icon.h>
@ -49,11 +50,13 @@ class PANEL_COLOR_SETTINGS_BASE : public wxPanel
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnSize( wxSizeEvent& event ) { event.Skip(); } virtual void OnSize( wxSizeEvent& event ) { event.Skip(); }
virtual void OnThemeChanged( wxCommandEvent& event ) { event.Skip(); } virtual void OnThemeChanged( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOverrideItemColorsClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnResetClicked( wxCommandEvent& event ) { event.Skip(); } virtual void OnBtnResetClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnOpenThemeFolderClicked( wxCommandEvent& event ) { event.Skip(); } virtual void OnBtnOpenThemeFolderClicked( wxCommandEvent& event ) { event.Skip(); }
public: public:
wxCheckBox* m_optOverrideColors;
PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 826,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 826,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_COLOR_SETTINGS_BASE(); ~PANEL_COLOR_SETTINGS_BASE();

View File

@ -29,7 +29,8 @@ const int colorsSchemaVersion = 0;
COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) : COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) :
JSON_SETTINGS( std::move( aFilename ), SETTINGS_LOC::COLORS, colorsSchemaVersion ), JSON_SETTINGS( std::move( aFilename ), SETTINGS_LOC::COLORS, colorsSchemaVersion ),
m_Palette(), m_colors(), m_color_context( COLOR_CONTEXT::PCB ) m_overrideSchItemColors( false ),
m_color_context( COLOR_CONTEXT::PCB )
{ {
m_params.emplace_back( new PARAM<wxString>( "meta.name", &m_displayName, "KiCad Default" ) ); m_params.emplace_back( new PARAM<wxString>( "meta.name", &m_displayName, "KiCad Default" ) );
@ -56,6 +57,9 @@ COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) :
// TODO(JE) in actual usage, how long does the default palette need to be? // TODO(JE) in actual usage, how long does the default palette need to be?
m_params.emplace_back( new PARAM_LIST<COLOR4D>( "palette", &m_Palette, default_palette ) ); m_params.emplace_back( new PARAM_LIST<COLOR4D>( "palette", &m_Palette, default_palette ) );
m_params.emplace_back( new PARAM<bool>( "schematic.override_item_colors",
&m_overrideSchItemColors, false ) );
#define CLR( x, y, z ) m_params.emplace_back( new COLOR_MAP_PARAM( x, y, z, &m_colors ) ) #define CLR( x, y, z ) m_params.emplace_back( new COLOR_MAP_PARAM( x, y, z, &m_colors ) )
CLR( "schematic.background", LAYER_SCHEMATIC_BACKGROUND, COLOR4D( WHITE ) ); CLR( "schematic.background", LAYER_SCHEMATIC_BACKGROUND, COLOR4D( WHITE ) );

View File

@ -35,7 +35,7 @@
#include <bitmaps.h> #include <bitmaps.h>
#include <eeschema_settings.h> #include <eeschema_settings.h>
#include <settings/color_settings.h> #include <settings/color_settings.h>
#include "panel_eeschema_color_settings.h"
DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( SCH_EDIT_FRAME* aParent, SCH_SHEET* aSheet, DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( SCH_EDIT_FRAME* aParent, SCH_SHEET* aSheet,
bool* aClearAnnotationNewItems ) : bool* aClearAnnotationNewItems ) :
@ -159,12 +159,12 @@ bool DIALOG_SCH_SHEET_PROPS::TransferDataToWindow()
if( backgroundColor == COLOR4D::UNSPECIFIED ) if( backgroundColor == COLOR4D::UNSPECIFIED )
backgroundColor = colorSettings->GetColor( LAYER_SHEET_BACKGROUND ); backgroundColor = colorSettings->GetColor( LAYER_SHEET_BACKGROUND );
m_borderColorSwatch->SetSwatchColor( borderColor, false ); m_borderSwatch->SetSwatchColor( borderColor, false );
m_backgroundColorSwatch->SetSwatchColor( backgroundColor, false ); m_backgroundSwatch->SetSwatchColor( backgroundColor, false );
KIGFX::COLOR4D canvas = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ); KIGFX::COLOR4D canvas = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
m_borderColorSwatch->SetSwatchBackground( canvas ); m_borderSwatch->SetSwatchBackground( canvas );
m_backgroundColorSwatch->SetSwatchBackground( canvas ); m_backgroundSwatch->SetSwatchBackground( canvas );
// set up the read-only fields // set up the read-only fields
m_heirarchyPath->SetValue( g_CurrentSheet->PathHumanReadable() ); m_heirarchyPath->SetValue( g_CurrentSheet->PathHumanReadable() );
@ -286,8 +286,29 @@ bool DIALOG_SCH_SHEET_PROPS::TransferDataFromWindow()
m_sheet->SetFields( *m_fields ); m_sheet->SetFields( *m_fields );
m_sheet->SetBorderWidth( m_borderWidth.GetValue() ); m_sheet->SetBorderWidth( m_borderWidth.GetValue() );
m_sheet->SetBorderColor( m_borderColorSwatch->GetSwatchColor() );
m_sheet->SetBackgroundColor( m_backgroundColorSwatch->GetSwatchColor() ); COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings();
if( colorSettings->GetOverrideSchItemColors()
&& ( m_sheet->GetBorderColor() != m_borderSwatch->GetSwatchColor() ||
m_sheet->GetBackgroundColor() != m_backgroundSwatch->GetSwatchColor() ) )
{
wxPanel temp( this );
temp.Hide();
PANEL_EESCHEMA_COLOR_SETTINGS prefs( m_frame, &temp );
wxString checkboxLabel = prefs.m_optOverrideColors->GetLabel();
KIDIALOG dlg( this, _( "Note: item colors are overridden in the current color theme." ),
KIDIALOG::KD_WARNING );
dlg.ShowDetailedText( wxString::Format( _( "To see individual item colors uncheck '%s'\n"
"in Preferences > Eeschema > Colors." ),
checkboxLabel ) );
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
dlg.ShowModal();
}
m_sheet->SetBorderColor( m_borderSwatch->GetSwatchColor() );
m_sheet->SetBackgroundColor( m_backgroundSwatch->GetSwatchColor() );
m_frame->TestDanglingEnds(); m_frame->TestDanglingEnds();
m_frame->RefreshItem( m_sheet ); m_frame->RefreshItem( m_sheet );

View File

@ -136,11 +136,11 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi
m_borderColorLabel->Wrap( -1 ); m_borderColorLabel->Wrap( -1 );
sbSizer2->Add( m_borderColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); sbSizer2->Add( m_borderColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_borderColorSwatch = new COLOR_SWATCH( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_borderSwatch = new COLOR_SWATCH( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_borderColorSwatch->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); m_borderSwatch->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
m_borderColorSwatch->SetMinSize( wxSize( 48,24 ) ); m_borderSwatch->SetMinSize( wxSize( 48, 24 ) );
sbSizer2->Add( m_borderColorSwatch, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); sbSizer2->Add( m_borderSwatch, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
sbSizer2->Add( 40, 0, 1, wxEXPAND, 5 ); sbSizer2->Add( 40, 0, 1, wxEXPAND, 5 );
@ -149,10 +149,10 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi
m_backgroundColorLabel->Wrap( -1 ); m_backgroundColorLabel->Wrap( -1 );
sbSizer2->Add( m_backgroundColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); sbSizer2->Add( m_backgroundColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_backgroundColorSwatch = new COLOR_SWATCH( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_backgroundSwatch = new COLOR_SWATCH( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_backgroundColorSwatch->SetMinSize( wxSize( 48,24 ) ); m_backgroundSwatch->SetMinSize( wxSize( 48, 24 ) );
sbSizer2->Add( m_backgroundColorSwatch, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); sbSizer2->Add( m_backgroundSwatch, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 );
bSizer5->Add( sbSizer2, 1, wxEXPAND|wxBOTTOM, 5 ); bSizer5->Add( sbSizer2, 1, wxEXPAND|wxBOTTOM, 5 );

View File

@ -816,7 +816,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size">48,24</property> <property name="minimum_size">48,24</property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_borderColorSwatch</property> <property name="name">m_borderSwatch</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -949,7 +949,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size">48,24</property> <property name="minimum_size">48,24</property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_backgroundColorSwatch</property> <property name="name">m_backgroundSwatch</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>

View File

@ -53,9 +53,9 @@ class DIALOG_SCH_SHEET_PROPS_BASE : public DIALOG_SHIM
wxTextCtrl* m_borderWidthCtrl; wxTextCtrl* m_borderWidthCtrl;
wxStaticText* m_borderWidthUnits; wxStaticText* m_borderWidthUnits;
wxStaticText* m_borderColorLabel; wxStaticText* m_borderColorLabel;
COLOR_SWATCH* m_borderColorSwatch; COLOR_SWATCH* m_borderSwatch;
wxStaticText* m_backgroundColorLabel; wxStaticText* m_backgroundColorLabel;
COLOR_SWATCH* m_backgroundColorSwatch; COLOR_SWATCH* m_backgroundSwatch;
wxStaticLine* m_staticline1; wxStaticLine* m_staticline1;
wxStaticText* m_hiearchicalPathLabel; wxStaticText* m_hiearchicalPathLabel;
wxTextCtrl* m_heirarchyPath; wxTextCtrl* m_heirarchyPath;

View File

@ -91,6 +91,8 @@ PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS( SCH_BASE_FRAME* aF
m_cbTheme->Append( wxT( "---" ) ); m_cbTheme->Append( wxT( "---" ) );
m_cbTheme->Append( _( "New Theme..." ) ); m_cbTheme->Append( _( "New Theme..." ) );
m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() );
m_currentSettings = new COLOR_SETTINGS( *current ); m_currentSettings = new COLOR_SETTINGS( *current );
KIGFX::GAL_DISPLAY_OPTIONS options; KIGFX::GAL_DISPLAY_OPTIONS options;
@ -132,6 +134,8 @@ PANEL_EESCHEMA_COLOR_SETTINGS::~PANEL_EESCHEMA_COLOR_SETTINGS()
bool PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataFromWindow() bool PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataFromWindow()
{ {
m_currentSettings->SetOverrideSchItemColors( m_optOverrideColors->GetValue() );
if( !saveCurrentTheme( true ) ) if( !saveCurrentTheme( true ) )
return false; return false;
@ -178,6 +182,8 @@ bool PANEL_EESCHEMA_COLOR_SETTINGS::saveCurrentTheme( bool aValidate )
SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager(); SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
COLOR_SETTINGS* selected = settingsMgr.GetColorSettings( m_currentSettings->GetFilename() ); COLOR_SETTINGS* selected = settingsMgr.GetColorSettings( m_currentSettings->GetFilename() );
selected->SetOverrideSchItemColors( m_optOverrideColors->GetValue() );
for( SCH_LAYER_ID layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; ++layer ) for( SCH_LAYER_ID layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; ++layer )
{ {
COLOR4D color; COLOR4D color;
@ -535,6 +541,9 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
idx = m_cbTheme->Insert( themeName, idx - 1, static_cast<void*>( newSettings ) ); idx = m_cbTheme->Insert( themeName, idx - 1, static_cast<void*>( newSettings ) );
m_cbTheme->SetSelection( idx ); m_cbTheme->SetSelection( idx );
m_optOverrideColors->SetValue( newSettings->GetOverrideSchItemColors() );
*m_currentSettings = *newSettings; *m_currentSettings = *newSettings;
} }
else else
@ -546,6 +555,8 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
if( !saveCurrentTheme( false ) ) if( !saveCurrentTheme( false ) )
return; return;
m_optOverrideColors->SetValue( selected->GetOverrideSchItemColors() );
*m_currentSettings = *selected; *m_currentSettings = *selected;
updatePreview(); updatePreview();
@ -556,6 +567,12 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
} }
void PANEL_EESCHEMA_COLOR_SETTINGS::OnOverrideItemColorsClicked( wxCommandEvent& aEvent )
{
// JEY TODO: hide/show extra color buttons
}
void PANEL_EESCHEMA_COLOR_SETTINGS::ShowColorContextMenu( wxMouseEvent& aEvent, void PANEL_EESCHEMA_COLOR_SETTINGS::ShowColorContextMenu( wxMouseEvent& aEvent,
SCH_LAYER_ID aLayer ) SCH_LAYER_ID aLayer )
{ {

View File

@ -51,10 +51,9 @@ protected:
void SetColor( wxCommandEvent& aEvent ); void SetColor( wxCommandEvent& aEvent );
void OnBtnResetClicked( wxCommandEvent& aEvent ) override;
void OnThemeChanged( wxCommandEvent& aEvent ) override; void OnThemeChanged( wxCommandEvent& aEvent ) override;
void OnOverrideItemColorsClicked( wxCommandEvent& aEvent ) override;
void OnBtnResetClicked( wxCommandEvent& aEvent ) override;
void OnSize( wxSizeEvent& aEvent ) override; void OnSize( wxSizeEvent& aEvent ) override;
void ShowColorContextMenu( wxMouseEvent& aEvent, SCH_LAYER_ID aLayer ); void ShowColorContextMenu( wxMouseEvent& aEvent, SCH_LAYER_ID aLayer );

View File

@ -522,11 +522,20 @@ COLOR4D SCH_BASE_FRAME::GetLayerColor( SCH_LAYER_ID aLayer )
} }
void SCH_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
{
EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged );
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
m_colorSettings = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme );
}
COLOR_SETTINGS* SCH_BASE_FRAME::GetColorSettings() COLOR_SETTINGS* SCH_BASE_FRAME::GetColorSettings()
{ {
if( !m_colorSettings ) if( !m_colorSettings )
{ {
auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>(); EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
m_colorSettings = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme ); m_colorSettings = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme );
} }

View File

@ -374,6 +374,8 @@ public:
*/ */
virtual void OnModify() {} virtual void OnModify() {}
void CommonSettingsChanged( bool aEnvVarsChanged ) override;
/** /**
* Helper to retrieve a layer color from the global color settings * Helper to retrieve a layer color from the global color settings
*/ */

View File

@ -73,6 +73,7 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
m_ShowPinsElectricalType( true ), m_ShowPinsElectricalType( true ),
m_ShowDisabled( false ), m_ShowDisabled( false ),
m_ShowUmbilicals( true ), m_ShowUmbilicals( true ),
m_OverrideItemColors( false ),
m_DefaultLineWidth( 0 ), m_DefaultLineWidth( 0 ),
m_DefaultWireThickness( 0 ), m_DefaultWireThickness( 0 ),
m_DefaultBusThickness( 0 ) m_DefaultBusThickness( 0 )
@ -88,6 +89,8 @@ void SCH_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
m_layerColors[ layer ] = aSettings->GetColor( layer ); m_layerColors[ layer ] = aSettings->GetColor( layer );
m_backgroundColor = aSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); m_backgroundColor = aSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
m_OverrideItemColors = aSettings->GetOverrideSchItemColors();
} }
@ -256,7 +259,9 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr
if( sheet->GetBackgroundColor() == COLOR4D::UNSPECIFIED ) if( sheet->GetBackgroundColor() == COLOR4D::UNSPECIFIED )
sheet->SetBackgroundColor( m_schSettings.GetLayerColor( LAYER_SHEET_BACKGROUND ) ); sheet->SetBackgroundColor( m_schSettings.GetLayerColor( LAYER_SHEET_BACKGROUND ) );
if( aLayer == LAYER_SHEET ) if( m_schSettings.m_OverrideItemColors )
color = m_schSettings.GetLayerColor( aLayer );
else if( aLayer == LAYER_SHEET )
color = sheet->GetBorderColor(); color = sheet->GetBorderColor();
else if( aLayer == LAYER_SHEET_BACKGROUND ) else if( aLayer == LAYER_SHEET_BACKGROUND )
color = sheet->GetBackgroundColor(); color = sheet->GetBackgroundColor();

View File

@ -108,6 +108,8 @@ public:
bool m_ShowDisabled; bool m_ShowDisabled;
bool m_ShowUmbilicals; bool m_ShowUmbilicals;
bool m_OverrideItemColors;
int m_DefaultLineWidth; int m_DefaultLineWidth;
int m_DefaultWireThickness; int m_DefaultWireThickness;
int m_DefaultBusThickness; int m_DefaultBusThickness;

View File

@ -63,9 +63,9 @@ class COLOR_SETTINGS : public JSON_SETTINGS
{ {
public: public:
/** /**
* m_Pallete stores a list of colors that are used, in order, when a list of colors needs to be * m_Pallete stores a list of colors that are used, in order, when a list of colors needs to
* generated for an application. For example, layer colors in GerbView, or default layer colors * be generated for an application. For example, layer colors in GerbView, or default layer
* in PcbNew. * colors in PcbNew.
*/ */
std::vector<COLOR4D> m_Palette; std::vector<COLOR4D> m_Palette;
@ -87,19 +87,15 @@ public:
m_color_context = aContext; m_color_context = aContext;
} }
const wxString& GetName() const wxString& GetName() const { return m_displayName; }
{ void SetName( const wxString& aName ) { m_displayName = aName; }
return m_displayName;
}
void SetName( const wxString& aName ) bool GetOverrideSchItemColors() const { return m_overrideSchItemColors; }
{ void SetOverrideSchItemColors( bool aFlag ) { m_overrideSchItemColors = aFlag; }
m_displayName = aName;
}
private: private:
wxString m_displayName; wxString m_displayName;
bool m_overrideSchItemColors;
/** /**
* Map of all layer colors. * Map of all layer colors.