Update default color theme
Blue is the new green :) ADDED: built-in read-only color themes support Classic theme is still available for those who love it Fixes https://gitlab.com/kicad/code/kicad/-/issues/1991 Fixes https://gitlab.com/kicad/code/kicad/-/issues/4259
This commit is contained in:
parent
ae6900e7d7
commit
c388bf0f92
|
@ -107,6 +107,7 @@ void PANEL_COLOR_SETTINGS::OnLeftDownTheme( wxMouseEvent& event )
|
|||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
|
||||
{
|
||||
int idx = m_cbTheme->GetSelection();
|
||||
|
@ -145,6 +146,7 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
|
|||
SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
|
||||
COLOR_SETTINGS* newSettings = settingsMgr.AddNewColorSettings( themeName );
|
||||
newSettings->SetName( themeName );
|
||||
newSettings->SetReadOnly( false );
|
||||
|
||||
for( auto layer : m_validLayers )
|
||||
newSettings->SetColor( layer, m_currentSettings->GetColor( layer ) );
|
||||
|
@ -157,6 +159,7 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
|
|||
m_optOverrideColors->SetValue( newSettings->GetOverrideSchItemColors() );
|
||||
|
||||
*m_currentSettings = *newSettings;
|
||||
updateSwatches();
|
||||
onNewThemeSelected();
|
||||
}
|
||||
else
|
||||
|
@ -180,12 +183,14 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
|
|||
|
||||
void PANEL_COLOR_SETTINGS::updateSwatches()
|
||||
{
|
||||
bool isReadOnly = m_currentSettings->IsReadOnly();
|
||||
COLOR4D background = m_currentSettings->GetColor( m_backgroundLayer );
|
||||
|
||||
for( std::pair<int, COLOR_SWATCH*> pair : m_swatches )
|
||||
{
|
||||
pair.second->SetSwatchBackground( background );
|
||||
pair.second->SetSwatchColor( m_currentSettings->GetColor( pair.first ), false );
|
||||
pair.second->SetReadOnly( isReadOnly );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,12 +207,17 @@ void PANEL_COLOR_SETTINGS::createThemeList( const wxString& aCurrent )
|
|||
|
||||
for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
|
||||
{
|
||||
int pos = m_cbTheme->Append( settings->GetName(), static_cast<void*>( settings ) );
|
||||
wxString name = settings->GetName();
|
||||
|
||||
if( settings->IsReadOnly() )
|
||||
name += _( " (read-only)" );
|
||||
|
||||
int pos = m_cbTheme->Append( name, static_cast<void*>( settings ) );
|
||||
|
||||
if( settings->GetFilename() == aCurrent )
|
||||
m_cbTheme->SetSelection( pos );
|
||||
|
||||
m_cbTheme->GetTextExtent( settings->GetName(), &width, &height );
|
||||
m_cbTheme->GetTextExtent( name, &width, &height );
|
||||
minwidth = std::max( minwidth, width );
|
||||
}
|
||||
|
||||
|
@ -251,8 +261,9 @@ void PANEL_COLOR_SETTINGS::createSwatch( int aLayer, const wxString& aName )
|
|||
swatch->Bind( wxEVT_RIGHT_DOWN,
|
||||
[&, aLayer]( wxMouseEvent& aEvent )
|
||||
{
|
||||
ShowColorContextMenu( aEvent, aLayer );
|
||||
ShowColorContextMenu( aEvent, aLayer );
|
||||
} );
|
||||
|
||||
swatch->Bind( COLOR_SWATCH_CHANGED, &PANEL_COLOR_SETTINGS::OnColorChanged, this );
|
||||
}
|
||||
|
||||
|
@ -262,17 +273,18 @@ void PANEL_COLOR_SETTINGS::ShowColorContextMenu( wxMouseEvent& aEvent, int aLaye
|
|||
auto selected =
|
||||
static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( m_cbTheme->GetSelection() ) );
|
||||
|
||||
COLOR4D current = m_currentSettings->GetColor( aLayer );
|
||||
COLOR4D saved = selected->GetColor( aLayer );
|
||||
COLOR4D current = m_currentSettings->GetColor( aLayer );
|
||||
COLOR4D saved = selected->GetColor( aLayer );
|
||||
bool readOnly = m_currentSettings->IsReadOnly();
|
||||
|
||||
wxMenu menu;
|
||||
|
||||
AddMenuItem( &menu, ID_COPY, _( "Copy color" ), KiBitmap( copy_xpm ) );
|
||||
|
||||
if( m_copied != COLOR4D::UNSPECIFIED )
|
||||
if( !readOnly && m_copied != COLOR4D::UNSPECIFIED )
|
||||
AddMenuItem( &menu, ID_PASTE, _( "Paste color" ), KiBitmap( paste_xpm ) );
|
||||
|
||||
if( current != saved )
|
||||
if( !readOnly && current != saved )
|
||||
AddMenuItem( &menu, ID_REVERT, _( "Revert to saved color" ), KiBitmap( undo_xpm ) );
|
||||
|
||||
menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
|
||||
|
@ -336,6 +348,9 @@ void PANEL_COLOR_SETTINGS::updateColor( int aLayer, const KIGFX::COLOR4D& aColor
|
|||
|
||||
bool PANEL_COLOR_SETTINGS::saveCurrentTheme( bool aValidate )
|
||||
{
|
||||
if( m_currentSettings->IsReadOnly() )
|
||||
return true;
|
||||
|
||||
if( aValidate && !validateSave() )
|
||||
return false;
|
||||
|
||||
|
|
|
@ -472,3 +472,13 @@ EDA_COLOR_T COLOR4D::FindNearestLegacyColor( int aR, int aG, int aB )
|
|||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
COLOR4D& COLOR4D::FromCSSRGBA( int aRed, int aGreen, int aBlue, double aAlpha )
|
||||
{
|
||||
r = std::max( 0, std::min( 255, aRed ) ) / 255.0;
|
||||
g = std::max( 0, std::min( 255, aGreen ) ) / 255.0;
|
||||
b = std::max( 0, std::min( 255, aBlue ) ) / 255.0;
|
||||
a = std::max( 0.0, std::min( 1.0, aAlpha ) );
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV
|
|||
&m_System.last_imperial_units, static_cast<int>( EDA_UNITS::INCHES ) ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<wxString>( "appearance.color_theme",
|
||||
&m_ColorTheme, "user" ) );
|
||||
&m_ColorTheme, "_builtin_default" ) );
|
||||
|
||||
addParamsForWindow( &m_Window, "window" );
|
||||
|
||||
|
|
|
@ -0,0 +1,320 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// NOTE: This file should only be included in color_settings.cpp
|
||||
|
||||
#ifndef _BUILTIN_COLOR_THEMES_H
|
||||
#define _BUILTIN_COLOR_THEMES_H
|
||||
|
||||
#define CSS_COLOR( r, g, b, a ) COLOR4D().FromCSSRGBA( r, g, b, a )
|
||||
|
||||
static const std::map<int, COLOR4D> s_defaultTheme =
|
||||
{
|
||||
{ LAYER_SCHEMATIC_AUX_ITEMS, CSS_COLOR( 0, 0, 0, 1 ) },
|
||||
{ LAYER_SCHEMATIC_BACKGROUND, CSS_COLOR( 245, 241, 237, 1 ) },
|
||||
{ LAYER_BRIGHTENED, CSS_COLOR( 255, 0, 255, 1 ) },
|
||||
{ LAYER_BUS, CSS_COLOR( 0, 0, 132, 1 ) },
|
||||
{ LAYER_BUS_JUNCTION, CSS_COLOR( 0, 0, 132, 1 ) },
|
||||
{ LAYER_DEVICE_BACKGROUND, CSS_COLOR( 255, 255, 194, 1 ) },
|
||||
{ LAYER_DEVICE, CSS_COLOR( 132, 0, 0, 1 ) },
|
||||
{ LAYER_SCHEMATIC_CURSOR, CSS_COLOR( 15, 15, 15, 1 ) },
|
||||
{ LAYER_ERC_ERR, CSS_COLOR( 230, 9, 13, 0.8 ) },
|
||||
{ LAYER_ERC_WARN, CSS_COLOR( 209, 146, 0, 0.8 ) },
|
||||
{ LAYER_FIELDS, CSS_COLOR( 132, 0, 132, 1 ) },
|
||||
{ LAYER_SCHEMATIC_GRID, CSS_COLOR( 181, 181, 181, 1 ) },
|
||||
{ LAYER_SCHEMATIC_GRID_AXES, CSS_COLOR( 0, 0, 132, 1 ) },
|
||||
{ LAYER_HIDDEN, CSS_COLOR( 94, 194, 194, 1 ) },
|
||||
{ LAYER_JUNCTION, CSS_COLOR( 0, 150, 0, 1 ) },
|
||||
{ LAYER_GLOBLABEL, CSS_COLOR( 132, 0, 0, 1 ) },
|
||||
{ LAYER_HIERLABEL, CSS_COLOR( 114, 86, 0, 1 ) },
|
||||
{ LAYER_LOCLABEL, CSS_COLOR( 15, 15, 15, 1 ) },
|
||||
{ LAYER_NETNAM, CSS_COLOR( 132, 132, 132, 1 ) },
|
||||
{ LAYER_NOCONNECT, CSS_COLOR( 0, 0, 132, 1 ) },
|
||||
{ LAYER_NOTES, CSS_COLOR( 0, 0, 194, 1 ) },
|
||||
{ LAYER_PIN, CSS_COLOR( 132, 0, 0, 1 ) },
|
||||
{ LAYER_PINNAM, CSS_COLOR( 0, 100, 100, 1 ) },
|
||||
{ LAYER_PINNUM, CSS_COLOR( 169, 0, 0, 1 ) },
|
||||
{ LAYER_REFERENCEPART, CSS_COLOR( 0, 100, 100, 1 ) },
|
||||
#ifdef __WXMAC__
|
||||
// Macs look better with a lighter shadow
|
||||
{ LAYER_SELECTION_SHADOWS, COLOR4D( .78, .92, 1.0, 0.8 ) },
|
||||
#else
|
||||
{ LAYER_SELECTION_SHADOWS, COLOR4D( .4, .7, 1.0, 0.8 ) },
|
||||
#endif
|
||||
{ LAYER_SHEET, CSS_COLOR( 132, 0, 0, 1 ) },
|
||||
{ LAYER_SHEET_BACKGROUND, CSS_COLOR( 255, 255, 255, 0 ) },
|
||||
{ LAYER_SHEETFILENAME, CSS_COLOR( 114, 86, 0, 1 ) },
|
||||
{ LAYER_SHEETFIELDS, CSS_COLOR( 132, 0, 132, 1 ) },
|
||||
{ LAYER_SHEETLABEL, CSS_COLOR( 0, 100, 100, 1 ) },
|
||||
{ LAYER_SHEETNAME, CSS_COLOR( 0, 100, 100, 1 ) },
|
||||
{ LAYER_VALUEPART, CSS_COLOR( 0, 100, 100, 1 ) },
|
||||
{ LAYER_WIRE, CSS_COLOR( 0, 150, 0, 1 ) },
|
||||
{ LAYER_SCHEMATIC_WORKSHEET, CSS_COLOR( 132, 0, 0, 1 ) },
|
||||
|
||||
{ LAYER_GERBVIEW_AXES, CSS_COLOR( 0, 0, 132, 1 ) },
|
||||
{ LAYER_GERBVIEW_BACKGROUND, CSS_COLOR( 0, 0, 0, 1 ) },
|
||||
{ LAYER_DCODES, CSS_COLOR( 255, 255, 255, 1 ) },
|
||||
{ LAYER_GERBVIEW_GRID, CSS_COLOR( 132, 132, 132, 1 ) },
|
||||
{ LAYER_NEGATIVE_OBJECTS, CSS_COLOR( 132, 132, 132, 1 ) },
|
||||
{ LAYER_GERBVIEW_WORKSHEET, CSS_COLOR( 0, 0, 132, 1 ) },
|
||||
|
||||
{ LAYER_ANCHOR, CSS_COLOR( 255, 38, 226, 1 ) },
|
||||
{ LAYER_AUX_ITEMS, CSS_COLOR( 255, 255, 255, 1 ) },
|
||||
{ LAYER_PCB_BACKGROUND, CSS_COLOR( 0, 16, 35, 1 ) },
|
||||
{ LAYER_CURSOR, CSS_COLOR( 255, 255, 255, 1 ) },
|
||||
{ LAYER_DRC_ERROR, CSS_COLOR( 215, 91, 107, 0.8 ) },
|
||||
{ LAYER_DRC_WARNING, CSS_COLOR( 255, 208, 66, 0.8 ) },
|
||||
{ LAYER_DRC_EXCLUSION, CSS_COLOR( 255, 255, 255, 0.8 ) },
|
||||
{ LAYER_MOD_TEXT_INVISIBLE, CSS_COLOR( 132, 132, 132, 1 ) },
|
||||
{ LAYER_GRID, CSS_COLOR( 132, 132, 132, 1 ) },
|
||||
{ LAYER_GRID_AXES, CSS_COLOR( 194, 194, 194, 1 ) },
|
||||
{ LAYER_NO_CONNECTS, CSS_COLOR( 0, 0, 132, 1 ) },
|
||||
{ LAYER_PAD_BK, CSS_COLOR( 77, 127, 196, 1 ) },
|
||||
{ LAYER_PAD_FR, CSS_COLOR( 200, 52, 52, 1 ) },
|
||||
{ LAYER_PADS_PLATEDHOLES, CSS_COLOR( 194, 194, 0, 1 ) },
|
||||
{ LAYER_PADS_TH, CSS_COLOR( 227, 183, 46, 1 ) },
|
||||
{ LAYER_NON_PLATEDHOLES, CSS_COLOR( 26, 196, 210, 1 ) },
|
||||
{ LAYER_RATSNEST, CSS_COLOR( 245, 255, 213, 0.702 ) },
|
||||
{ LAYER_SELECT_OVERLAY, CSS_COLOR( 4, 255, 67, 1 ) },
|
||||
{ LAYER_VIA_THROUGH, CSS_COLOR( 236, 236, 236, 1 ) },
|
||||
{ LAYER_VIA_BBLIND, CSS_COLOR( 187, 151, 38, 1 ) },
|
||||
{ LAYER_VIAS_HOLES, CSS_COLOR( 227, 183, 46, 1 ) },
|
||||
{ LAYER_VIA_MICROVIA, CSS_COLOR( 0, 132, 132, 1 ) },
|
||||
{ LAYER_WORKSHEET, CSS_COLOR( 200, 114, 171, 1 ) },
|
||||
|
||||
{ F_Cu, CSS_COLOR( 200, 52, 52, 1 ) },
|
||||
{ In1_Cu, CSS_COLOR( 127, 200, 127, 1 ) },
|
||||
{ In2_Cu, CSS_COLOR( 206, 125, 44, 1 ) },
|
||||
{ In3_Cu, CSS_COLOR( 79, 203, 203, 1 ) },
|
||||
{ In4_Cu, CSS_COLOR( 219, 98, 139, 1 ) },
|
||||
{ In5_Cu, CSS_COLOR( 167, 165, 198, 1 ) },
|
||||
{ In6_Cu, CSS_COLOR( 40, 204, 217, 1 ) },
|
||||
{ In7_Cu, CSS_COLOR( 232, 178, 167, 1 ) },
|
||||
{ In8_Cu, CSS_COLOR( 242, 237, 161, 1 ) },
|
||||
{ In9_Cu, CSS_COLOR( 141, 203, 129, 1 ) },
|
||||
{ In10_Cu, CSS_COLOR( 237, 124, 51, 1 ) },
|
||||
{ In11_Cu, CSS_COLOR( 91, 195, 235, 1 ) },
|
||||
{ In12_Cu, CSS_COLOR( 247, 111, 142, 1 ) },
|
||||
{ In13_Cu, CSS_COLOR( 167, 165, 198, 1 ) },
|
||||
{ In14_Cu, CSS_COLOR( 40, 204, 217, 1 ) },
|
||||
{ In15_Cu, CSS_COLOR( 232, 178, 167, 1 ) },
|
||||
{ In16_Cu, CSS_COLOR( 242, 237, 161, 1 ) },
|
||||
{ In17_Cu, CSS_COLOR( 237, 124, 51, 1 ) },
|
||||
{ In18_Cu, CSS_COLOR( 91, 195, 235, 1 ) },
|
||||
{ In19_Cu, CSS_COLOR( 247, 111, 142, 1 ) },
|
||||
{ In20_Cu, CSS_COLOR( 167, 165, 198, 1 ) },
|
||||
{ In21_Cu, CSS_COLOR( 40, 204, 217, 1 ) },
|
||||
{ In22_Cu, CSS_COLOR( 232, 178, 167, 1 ) },
|
||||
{ In23_Cu, CSS_COLOR( 242, 237, 161, 1 ) },
|
||||
{ In24_Cu, CSS_COLOR( 237, 124, 51, 1 ) },
|
||||
{ In25_Cu, CSS_COLOR( 91, 195, 235, 1 ) },
|
||||
{ In26_Cu, CSS_COLOR( 247, 111, 142, 1 ) },
|
||||
{ In27_Cu, CSS_COLOR( 167, 165, 198, 1 ) },
|
||||
{ In28_Cu, CSS_COLOR( 40, 204, 217, 1 ) },
|
||||
{ In29_Cu, CSS_COLOR( 232, 178, 167, 1 ) },
|
||||
{ In30_Cu, CSS_COLOR( 242, 237, 161, 1 ) },
|
||||
{ B_Cu, CSS_COLOR( 77, 127, 196, 1 ) },
|
||||
|
||||
{ B_Adhes, CSS_COLOR( 0, 0, 132, 1 ) },
|
||||
{ F_Adhes, CSS_COLOR( 132, 0, 132, 1 ) },
|
||||
{ B_Paste, CSS_COLOR( 0, 194, 194, 0.9 ) },
|
||||
{ F_Paste, CSS_COLOR( 180, 160, 154, 0.9 ) },
|
||||
{ B_SilkS, CSS_COLOR( 232, 178, 167, 1 ) },
|
||||
{ F_SilkS, CSS_COLOR( 242, 237, 161, 1 ) },
|
||||
{ B_Mask, CSS_COLOR( 2, 255, 238, 0.4 ) },
|
||||
{ F_Mask, CSS_COLOR( 216, 100, 255, 0.4 ) },
|
||||
{ Dwgs_User, CSS_COLOR( 194, 194, 194, 1 ) },
|
||||
{ Cmts_User, CSS_COLOR( 89, 148, 220, 1 ) },
|
||||
{ Eco1_User, CSS_COLOR( 180, 219, 210, 1 ) },
|
||||
{ Eco2_User, CSS_COLOR( 216, 200, 82, 1 ) },
|
||||
{ Edge_Cuts, CSS_COLOR( 208, 210, 205, 1 ) },
|
||||
{ Margin, CSS_COLOR( 255, 38, 226, 1 ) },
|
||||
{ B_CrtYd, CSS_COLOR( 255, 38, 226, 1 ) },
|
||||
{ F_CrtYd, CSS_COLOR( 255, 0, 245, 1 ) },
|
||||
{ B_Fab, CSS_COLOR( 88, 93, 132, 1 ) },
|
||||
{ F_Fab, CSS_COLOR( 175, 175, 175, 1 ) },
|
||||
{ User_1, CSS_COLOR( 194, 194, 194, 1 ) },
|
||||
{ User_2, CSS_COLOR( 89, 148, 220, 1 ) },
|
||||
{ User_3, CSS_COLOR( 180, 219, 210, 1 ) },
|
||||
{ User_4, CSS_COLOR( 216, 200, 82, 1 ) },
|
||||
{ User_5, CSS_COLOR( 194, 194, 194, 1 ) },
|
||||
{ User_6, CSS_COLOR( 89, 148, 220, 1 ) },
|
||||
{ User_7, CSS_COLOR( 180, 219, 210, 1 ) },
|
||||
{ User_8, CSS_COLOR( 216, 200, 82, 1 ) },
|
||||
{ User_9, CSS_COLOR( 232, 178, 167, 1 ) },
|
||||
|
||||
{ LAYER_3D_BACKGROUND_BOTTOM, COLOR4D( 0.4, 0.4, 0.5, 1.0 ) },
|
||||
{ LAYER_3D_BACKGROUND_TOP, COLOR4D( 0.8, 0.8, 0.9, 1.0 ) },
|
||||
{ LAYER_3D_BOARD, COLOR4D( 0.2, 0.17, 0.09, 0.9 ) },
|
||||
{ LAYER_3D_COPPER, COLOR4D( 0.7, 0.61, 0.0, 1.0 ) },
|
||||
{ LAYER_3D_SILKSCREEN_BOTTOM, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) },
|
||||
{ LAYER_3D_SILKSCREEN_TOP, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) },
|
||||
{ LAYER_3D_SOLDERMASK, COLOR4D( 0.08, 0.2, 0.14, 0.83 ) },
|
||||
{ LAYER_3D_SOLDERPASTE, COLOR4D( 0.5, 0.5, 0.5, 1.0 ) }
|
||||
};
|
||||
|
||||
|
||||
static const std::map<int, COLOR4D> s_classicTheme =
|
||||
{
|
||||
{ LAYER_SCHEMATIC_AUX_ITEMS, COLOR4D( BLACK ) },
|
||||
{ LAYER_SCHEMATIC_BACKGROUND, COLOR4D( WHITE ) },
|
||||
{ LAYER_BRIGHTENED, COLOR4D( PUREMAGENTA ) },
|
||||
{ LAYER_BUS, COLOR4D( BLUE ) },
|
||||
{ LAYER_BUS_JUNCTION, COLOR4D( BLUE ) },
|
||||
{ LAYER_DEVICE_BACKGROUND, COLOR4D( LIGHTYELLOW ) },
|
||||
{ LAYER_DEVICE, COLOR4D( RED ) },
|
||||
{ LAYER_SCHEMATIC_CURSOR, COLOR4D( BLACK ) },
|
||||
{ LAYER_ERC_ERR, COLOR4D( PURERED ).WithAlpha( 0.8 ) },
|
||||
{ LAYER_ERC_WARN, COLOR4D( PUREGREEN ).WithAlpha( 0.8 ) },
|
||||
{ LAYER_FIELDS, COLOR4D( MAGENTA ) },
|
||||
{ LAYER_SCHEMATIC_GRID, COLOR4D( DARKGRAY ) },
|
||||
{ LAYER_SCHEMATIC_GRID_AXES, COLOR4D( BLUE ) },
|
||||
{ LAYER_HIDDEN, COLOR4D( LIGHTGRAY ) },
|
||||
{ LAYER_JUNCTION, COLOR4D( GREEN ) },
|
||||
{ LAYER_GLOBLABEL, COLOR4D( RED ) },
|
||||
{ LAYER_HIERLABEL, COLOR4D( BROWN ) },
|
||||
{ LAYER_LOCLABEL, COLOR4D( BLACK ) },
|
||||
{ LAYER_NETNAM, COLOR4D( DARKGRAY ) },
|
||||
{ LAYER_NOCONNECT, COLOR4D( BLUE ) },
|
||||
{ LAYER_NOTES, COLOR4D( LIGHTBLUE ) },
|
||||
{ LAYER_PIN, COLOR4D( RED ) },
|
||||
{ LAYER_PINNAM, COLOR4D( CYAN ) },
|
||||
{ LAYER_PINNUM, COLOR4D( RED ) },
|
||||
{ LAYER_REFERENCEPART, COLOR4D( CYAN ) },
|
||||
#ifdef __WXMAC__
|
||||
// Macs look better with a lighter shadow
|
||||
{ LAYER_SELECTION_SHADOWS, COLOR4D( .78, .92, 1.0, 0.8 ) },
|
||||
#else
|
||||
{ LAYER_SELECTION_SHADOWS, COLOR4D( .4, .7, 1.0, 0.8 ) },
|
||||
#endif
|
||||
{ LAYER_SHEET, COLOR4D( MAGENTA ) },
|
||||
{ LAYER_SHEET_BACKGROUND, COLOR4D( WHITE ).WithAlpha( 0.0 ) },
|
||||
{ LAYER_SHEETFILENAME, COLOR4D( BROWN ) },
|
||||
{ LAYER_SHEETFIELDS, COLOR4D( MAGENTA ) },
|
||||
{ LAYER_SHEETLABEL, COLOR4D( CYAN ) },
|
||||
{ LAYER_SHEETNAME, COLOR4D( CYAN ) },
|
||||
{ LAYER_VALUEPART, COLOR4D( CYAN ) },
|
||||
{ LAYER_WIRE, COLOR4D( GREEN ) },
|
||||
{ LAYER_SCHEMATIC_WORKSHEET, COLOR4D( RED ) },
|
||||
|
||||
{ LAYER_GERBVIEW_AXES, COLOR4D( BLUE ) },
|
||||
{ LAYER_GERBVIEW_BACKGROUND, COLOR4D( BLACK ) },
|
||||
{ LAYER_DCODES, COLOR4D( WHITE ) },
|
||||
{ LAYER_GERBVIEW_GRID, COLOR4D( MAGENTA ) },
|
||||
{ LAYER_NEGATIVE_OBJECTS, COLOR4D( DARKGRAY ) },
|
||||
{ LAYER_GERBVIEW_WORKSHEET, COLOR4D( RED ) },
|
||||
|
||||
{ LAYER_ANCHOR, COLOR4D( BLUE ) },
|
||||
{ LAYER_AUX_ITEMS, COLOR4D( WHITE ) },
|
||||
{ LAYER_PCB_BACKGROUND, COLOR4D( BLACK ) },
|
||||
{ LAYER_CURSOR, COLOR4D( WHITE ) },
|
||||
{ LAYER_DRC_ERROR, COLOR4D( PURERED ).WithAlpha( 0.8 ) },
|
||||
{ LAYER_DRC_WARNING, COLOR4D( PUREGREEN ).WithAlpha( 0.8 ) },
|
||||
{ LAYER_DRC_EXCLUSION, COLOR4D( WHITE ) },
|
||||
{ LAYER_MOD_TEXT_INVISIBLE, COLOR4D( LIGHTGRAY ) },
|
||||
{ LAYER_GRID, COLOR4D( DARKGRAY ) },
|
||||
{ LAYER_GRID_AXES, COLOR4D( BLUE ) },
|
||||
{ LAYER_NO_CONNECTS, COLOR4D( BLUE ) },
|
||||
{ LAYER_PAD_BK, COLOR4D( GREEN ) },
|
||||
{ LAYER_PAD_FR, COLOR4D( RED ) },
|
||||
{ LAYER_PADS_PLATEDHOLES, COLOR4D( YELLOW ) },
|
||||
{ LAYER_PADS_TH, COLOR4D( YELLOW ) },
|
||||
{ LAYER_NON_PLATEDHOLES, COLOR4D( YELLOW ) },
|
||||
{ LAYER_RATSNEST, COLOR4D( WHITE ) },
|
||||
{ LAYER_SELECT_OVERLAY, COLOR4D( PUREGREEN ) },
|
||||
{ LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) },
|
||||
{ LAYER_VIA_BBLIND, COLOR4D( BROWN ) },
|
||||
{ LAYER_VIAS_HOLES, COLOR4D( 0.5, 0.4, 0, 0.8 ) },
|
||||
{ LAYER_VIA_MICROVIA, COLOR4D( CYAN ) },
|
||||
{ LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) },
|
||||
{ LAYER_WORKSHEET, COLOR4D( DARKRED ) },
|
||||
|
||||
{ F_Cu, COLOR4D( RED ) },
|
||||
{ In1_Cu, COLOR4D( YELLOW ) },
|
||||
{ In2_Cu, COLOR4D( LIGHTMAGENTA ) },
|
||||
{ In3_Cu, COLOR4D( LIGHTRED ) },
|
||||
{ In4_Cu, COLOR4D( CYAN ) },
|
||||
{ In5_Cu, COLOR4D( GREEN ) },
|
||||
{ In6_Cu, COLOR4D( BLUE ) },
|
||||
{ In7_Cu, COLOR4D( DARKGRAY ) },
|
||||
{ In8_Cu, COLOR4D( MAGENTA ) },
|
||||
{ In9_Cu, COLOR4D( LIGHTGRAY ) },
|
||||
{ In10_Cu, COLOR4D( MAGENTA ) },
|
||||
{ In11_Cu, COLOR4D( RED ) },
|
||||
{ In12_Cu, COLOR4D( BROWN ) },
|
||||
{ In13_Cu, COLOR4D( LIGHTGRAY ) },
|
||||
{ In14_Cu, COLOR4D( BLUE ) },
|
||||
{ In15_Cu, COLOR4D( GREEN ) },
|
||||
{ In16_Cu, COLOR4D( RED ) },
|
||||
{ In17_Cu, COLOR4D( YELLOW ) },
|
||||
{ In18_Cu, COLOR4D( LIGHTMAGENTA ) },
|
||||
{ In19_Cu, COLOR4D( LIGHTRED ) },
|
||||
{ In20_Cu, COLOR4D( CYAN ) },
|
||||
{ In21_Cu, COLOR4D( GREEN ) },
|
||||
{ In22_Cu, COLOR4D( BLUE ) },
|
||||
{ In23_Cu, COLOR4D( DARKGRAY ) },
|
||||
{ In24_Cu, COLOR4D( MAGENTA ) },
|
||||
{ In25_Cu, COLOR4D( LIGHTGRAY ) },
|
||||
{ In26_Cu, COLOR4D( MAGENTA ) },
|
||||
{ In27_Cu, COLOR4D( RED ) },
|
||||
{ In28_Cu, COLOR4D( BROWN ) },
|
||||
{ In29_Cu, COLOR4D( LIGHTGRAY ) },
|
||||
{ In30_Cu, COLOR4D( BLUE ) },
|
||||
{ B_Cu, COLOR4D( GREEN ) },
|
||||
|
||||
{ B_Adhes, COLOR4D( BLUE ) },
|
||||
{ F_Adhes, COLOR4D( MAGENTA ) },
|
||||
{ B_Paste, COLOR4D( LIGHTCYAN ) },
|
||||
{ F_Paste, COLOR4D( RED ) },
|
||||
{ B_SilkS, COLOR4D( MAGENTA ) },
|
||||
{ F_SilkS, COLOR4D( CYAN ) },
|
||||
{ B_Mask, COLOR4D( BROWN ) },
|
||||
{ F_Mask, COLOR4D( MAGENTA ) },
|
||||
{ Dwgs_User, COLOR4D( LIGHTGRAY ) },
|
||||
{ Cmts_User, COLOR4D( BLUE ) },
|
||||
{ Eco1_User, COLOR4D( GREEN ) },
|
||||
{ Eco2_User, COLOR4D( YELLOW ) },
|
||||
{ Edge_Cuts, COLOR4D( YELLOW ) },
|
||||
{ Margin, COLOR4D( LIGHTMAGENTA ) },
|
||||
{ B_CrtYd, COLOR4D( DARKGRAY ) },
|
||||
{ F_CrtYd, COLOR4D( LIGHTGRAY ) },
|
||||
{ B_Fab, COLOR4D( BLUE ) },
|
||||
{ F_Fab, COLOR4D( DARKGRAY ) },
|
||||
{ User_1, COLOR4D( BLUE ) },
|
||||
{ User_2, COLOR4D( BLUE ) },
|
||||
{ User_3, COLOR4D( BLUE ) },
|
||||
{ User_4, COLOR4D( BLUE ) },
|
||||
{ User_5, COLOR4D( BLUE ) },
|
||||
{ User_6, COLOR4D( BLUE ) },
|
||||
{ User_7, COLOR4D( BLUE ) },
|
||||
{ User_8, COLOR4D( BLUE ) },
|
||||
{ User_9, COLOR4D( BLUE ) },
|
||||
|
||||
{ LAYER_3D_BACKGROUND_BOTTOM, COLOR4D( 0.4, 0.4, 0.5, 1.0 ) },
|
||||
{ LAYER_3D_BACKGROUND_TOP, COLOR4D( 0.8, 0.8, 0.9, 1.0 ) },
|
||||
{ LAYER_3D_BOARD, COLOR4D( 0.2, 0.17, 0.09, 0.9 ) },
|
||||
{ LAYER_3D_COPPER, COLOR4D( 0.7, 0.61, 0.0, 1.0 ) },
|
||||
{ LAYER_3D_SILKSCREEN_BOTTOM, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) },
|
||||
{ LAYER_3D_SILKSCREEN_TOP, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) },
|
||||
{ LAYER_3D_SOLDERMASK, COLOR4D( 0.08, 0.2, 0.14, 0.83 ) },
|
||||
{ LAYER_3D_SOLDERPASTE, COLOR4D( 0.5, 0.5, 0.5, 1.0 ) }
|
||||
};
|
||||
|
||||
#endif
|
|
@ -24,6 +24,8 @@
|
|||
#include <settings/parameters.h>
|
||||
#include <settings/settings_manager.h>
|
||||
|
||||
#include "builtin_color_themes.h"
|
||||
|
||||
|
||||
///! Update the schema version whenever a migration is required
|
||||
const int colorsSchemaVersion = 2;
|
||||
|
@ -37,22 +39,20 @@ COLOR_SETTINGS::COLOR_SETTINGS( wxString aFilename ) :
|
|||
m_params.emplace_back( new PARAM<wxString>( "meta.name", &m_displayName, "KiCad Default" ) );
|
||||
|
||||
std::vector<COLOR4D> default_palette = {
|
||||
COLOR4D( RED ),
|
||||
COLOR4D( YELLOW ),
|
||||
COLOR4D( LIGHTMAGENTA ),
|
||||
COLOR4D( LIGHTRED ),
|
||||
COLOR4D( CYAN ),
|
||||
COLOR4D( GREEN ),
|
||||
COLOR4D( BLUE ),
|
||||
COLOR4D( DARKGRAY ),
|
||||
COLOR4D( MAGENTA ),
|
||||
COLOR4D( LIGHTGRAY ),
|
||||
COLOR4D( MAGENTA ),
|
||||
COLOR4D( RED ),
|
||||
COLOR4D( BROWN ),
|
||||
COLOR4D( LIGHTGRAY ),
|
||||
COLOR4D( BLUE ),
|
||||
COLOR4D( GREEN )
|
||||
CSS_COLOR( 200, 52, 52, 1 ),
|
||||
CSS_COLOR( 127, 200, 127, 1 ),
|
||||
CSS_COLOR( 206, 125, 44, 1 ),
|
||||
CSS_COLOR( 79, 203, 203, 1 ),
|
||||
CSS_COLOR( 219, 98, 139, 1 ),
|
||||
CSS_COLOR( 167, 165, 198, 1 ),
|
||||
CSS_COLOR( 40, 204, 217, 1 ),
|
||||
CSS_COLOR( 232, 178, 167, 1 ),
|
||||
CSS_COLOR( 242, 237, 161, 1 ),
|
||||
CSS_COLOR( 141, 203, 129, 1 ),
|
||||
CSS_COLOR( 237, 124, 51, 1 ),
|
||||
CSS_COLOR( 91, 195, 235, 1 ),
|
||||
CSS_COLOR( 247, 111, 142, 1 ),
|
||||
CSS_COLOR( 77, 127, 196, 1 )
|
||||
};
|
||||
|
||||
// TODO(JE) in actual usage, how long does the default palette need to be?
|
||||
|
@ -61,159 +61,160 @@ COLOR_SETTINGS::COLOR_SETTINGS( wxString aFilename ) :
|
|||
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 ) \
|
||||
wxASSERT( s_defaultTheme.count( y ) ); \
|
||||
m_params.emplace_back( new COLOR_MAP_PARAM( x, y, s_defaultTheme.at( y ), &m_colors ) );
|
||||
|
||||
CLR( "schematic.aux_items", LAYER_SCHEMATIC_AUX_ITEMS, COLOR4D( BLACK ) );
|
||||
CLR( "schematic.background", LAYER_SCHEMATIC_BACKGROUND, COLOR4D( WHITE ) );
|
||||
CLR( "schematic.brightened", LAYER_BRIGHTENED, COLOR4D( PUREMAGENTA ) );
|
||||
CLR( "schematic.bus", LAYER_BUS, COLOR4D( BLUE ) );
|
||||
CLR( "schematic.bus_junction", LAYER_BUS_JUNCTION, COLOR4D( BLUE ) );
|
||||
CLR( "schematic.component_body", LAYER_DEVICE_BACKGROUND, COLOR4D( LIGHTYELLOW ) );
|
||||
CLR( "schematic.component_outline", LAYER_DEVICE, COLOR4D( RED ) );
|
||||
CLR( "schematic.cursor", LAYER_SCHEMATIC_CURSOR, COLOR4D( BLACK ) );
|
||||
CLR( "schematic.erc_error", LAYER_ERC_ERR, COLOR4D( PURERED ).WithAlpha( 0.8 ) );
|
||||
CLR( "schematic.erc_warning", LAYER_ERC_WARN, COLOR4D( PUREGREEN ).WithAlpha( 0.8 ) );
|
||||
CLR( "schematic.fields", LAYER_FIELDS, COLOR4D( MAGENTA ) );
|
||||
CLR( "schematic.grid", LAYER_SCHEMATIC_GRID, COLOR4D( DARKGRAY ) );
|
||||
CLR( "schematic.grid_axes", LAYER_SCHEMATIC_GRID_AXES, COLOR4D( BLUE ) );
|
||||
CLR( "schematic.hidden", LAYER_HIDDEN, COLOR4D( LIGHTGRAY ) );
|
||||
CLR( "schematic.junction", LAYER_JUNCTION, COLOR4D( GREEN ) );
|
||||
CLR( "schematic.label_global", LAYER_GLOBLABEL, COLOR4D( RED ) );
|
||||
CLR( "schematic.label_hier", LAYER_HIERLABEL, COLOR4D( BROWN ) );
|
||||
CLR( "schematic.label_local", LAYER_LOCLABEL, COLOR4D( BLACK ) );
|
||||
CLR( "schematic.net_name", LAYER_NETNAM, COLOR4D( DARKGRAY ) );
|
||||
CLR( "schematic.no_connect", LAYER_NOCONNECT, COLOR4D( BLUE ) );
|
||||
CLR( "schematic.note", LAYER_NOTES, COLOR4D( LIGHTBLUE ) );
|
||||
CLR( "schematic.pin", LAYER_PIN, COLOR4D( RED ) );
|
||||
CLR( "schematic.pin_name", LAYER_PINNAM, COLOR4D( CYAN ) );
|
||||
CLR( "schematic.pin_number", LAYER_PINNUM, COLOR4D( RED ) );
|
||||
CLR( "schematic.reference", LAYER_REFERENCEPART, COLOR4D( CYAN ) );
|
||||
CLR( "schematic.aux_items", LAYER_SCHEMATIC_AUX_ITEMS );
|
||||
CLR( "schematic.background", LAYER_SCHEMATIC_BACKGROUND );
|
||||
CLR( "schematic.brightened", LAYER_BRIGHTENED );
|
||||
CLR( "schematic.bus", LAYER_BUS );
|
||||
CLR( "schematic.bus_junction", LAYER_BUS_JUNCTION );
|
||||
CLR( "schematic.component_body", LAYER_DEVICE_BACKGROUND );
|
||||
CLR( "schematic.component_outline", LAYER_DEVICE );
|
||||
CLR( "schematic.cursor", LAYER_SCHEMATIC_CURSOR );
|
||||
CLR( "schematic.erc_error", LAYER_ERC_ERR );
|
||||
CLR( "schematic.erc_warning", LAYER_ERC_WARN );
|
||||
CLR( "schematic.fields", LAYER_FIELDS );
|
||||
CLR( "schematic.grid", LAYER_SCHEMATIC_GRID );
|
||||
CLR( "schematic.grid_axes", LAYER_SCHEMATIC_GRID_AXES );
|
||||
CLR( "schematic.hidden", LAYER_HIDDEN );
|
||||
CLR( "schematic.junction", LAYER_JUNCTION );
|
||||
CLR( "schematic.label_global", LAYER_GLOBLABEL );
|
||||
CLR( "schematic.label_hier", LAYER_HIERLABEL );
|
||||
CLR( "schematic.label_local", LAYER_LOCLABEL );
|
||||
CLR( "schematic.net_name", LAYER_NETNAM );
|
||||
CLR( "schematic.no_connect", LAYER_NOCONNECT );
|
||||
CLR( "schematic.note", LAYER_NOTES );
|
||||
CLR( "schematic.pin", LAYER_PIN );
|
||||
CLR( "schematic.pin_name", LAYER_PINNAM );
|
||||
CLR( "schematic.pin_number", LAYER_PINNUM );
|
||||
CLR( "schematic.reference", LAYER_REFERENCEPART );
|
||||
// Macs look better with a lighter shadow
|
||||
#ifdef __WXMAC__
|
||||
CLR( "schematic.shadow", LAYER_SELECTION_SHADOWS, COLOR4D( .78, .92, 1.0, 0.8 ) );
|
||||
CLR( "schematic.shadow", LAYER_SELECTION_SHADOWS );
|
||||
#else
|
||||
CLR( "schematic.shadow", LAYER_SELECTION_SHADOWS, COLOR4D( .4, .7, 1.0, 0.8 ) );
|
||||
CLR( "schematic.shadow", LAYER_SELECTION_SHADOWS );
|
||||
#endif
|
||||
CLR( "schematic.sheet", LAYER_SHEET, COLOR4D( MAGENTA ) );
|
||||
CLR( "schematic.sheet_background", LAYER_SHEET_BACKGROUND, COLOR4D( WHITE ).WithAlpha( 0.0 ) );
|
||||
CLR( "schematic.sheet_filename", LAYER_SHEETFILENAME, COLOR4D( BROWN ) );
|
||||
CLR( "schematic.sheet_fields", LAYER_SHEETFIELDS, COLOR4D( MAGENTA ) );
|
||||
CLR( "schematic.sheet_label", LAYER_SHEETLABEL, COLOR4D( CYAN ) );
|
||||
CLR( "schematic.sheet_name", LAYER_SHEETNAME, COLOR4D( CYAN ) );
|
||||
CLR( "schematic.value", LAYER_VALUEPART, COLOR4D( CYAN ) );
|
||||
CLR( "schematic.wire", LAYER_WIRE, COLOR4D( GREEN ) );
|
||||
CLR( "schematic.worksheet", LAYER_SCHEMATIC_WORKSHEET, COLOR4D( RED ) );
|
||||
CLR( "schematic.sheet", LAYER_SHEET );
|
||||
CLR( "schematic.sheet_background", LAYER_SHEET_BACKGROUND );
|
||||
CLR( "schematic.sheet_filename", LAYER_SHEETFILENAME );
|
||||
CLR( "schematic.sheet_fields", LAYER_SHEETFIELDS );
|
||||
CLR( "schematic.sheet_label", LAYER_SHEETLABEL );
|
||||
CLR( "schematic.sheet_name", LAYER_SHEETNAME );
|
||||
CLR( "schematic.value", LAYER_VALUEPART );
|
||||
CLR( "schematic.wire", LAYER_WIRE );
|
||||
CLR( "schematic.worksheet", LAYER_SCHEMATIC_WORKSHEET );
|
||||
|
||||
CLR( "gerbview.axes", LAYER_GERBVIEW_AXES, COLOR4D( BLUE ) );
|
||||
CLR( "gerbview.background", LAYER_GERBVIEW_BACKGROUND, COLOR4D( BLACK ) );
|
||||
CLR( "gerbview.dcodes", LAYER_DCODES, COLOR4D( WHITE ) );
|
||||
CLR( "gerbview.grid", LAYER_GERBVIEW_GRID, COLOR4D( MAGENTA ) );
|
||||
CLR( "gerbview.negative_objects", LAYER_NEGATIVE_OBJECTS, COLOR4D( DARKGRAY ) );
|
||||
CLR( "gerbview.worksheet", LAYER_GERBVIEW_WORKSHEET, COLOR4D( RED ) );
|
||||
CLR( "gerbview.axes", LAYER_GERBVIEW_AXES );
|
||||
CLR( "gerbview.background", LAYER_GERBVIEW_BACKGROUND );
|
||||
CLR( "gerbview.dcodes", LAYER_DCODES );
|
||||
CLR( "gerbview.grid", LAYER_GERBVIEW_GRID );
|
||||
CLR( "gerbview.negative_objects", LAYER_NEGATIVE_OBJECTS );
|
||||
CLR( "gerbview.worksheet", LAYER_GERBVIEW_WORKSHEET );
|
||||
|
||||
// TODO(JE) New default scheme for GerbView
|
||||
for( int i = 0, id = GERBVIEW_LAYER_ID_START;
|
||||
id < GERBER_DRAWLAYERS_COUNT + GERBVIEW_LAYER_ID_START; ++i, ++id )
|
||||
{
|
||||
CLR( "gerbview.layers." + std::to_string( i ), id,
|
||||
default_palette[ i % default_palette.size() ] );
|
||||
m_params.emplace_back( new COLOR_MAP_PARAM( "gerbview.layers." + std::to_string( i ), id,
|
||||
default_palette[ i % default_palette.size() ],
|
||||
&m_colors ) );
|
||||
}
|
||||
|
||||
CLR( "board.anchor", LAYER_ANCHOR, COLOR4D( BLUE ) );
|
||||
CLR( "board.aux_items", LAYER_AUX_ITEMS, COLOR4D( WHITE ) );
|
||||
CLR( "board.background", LAYER_PCB_BACKGROUND, COLOR4D( BLACK ) );
|
||||
CLR( "board.cursor", LAYER_CURSOR, COLOR4D( WHITE ) );
|
||||
CLR( "board.drc_error", LAYER_DRC_ERROR, COLOR4D( PURERED ) );
|
||||
CLR( "board.drc_warning", LAYER_DRC_WARNING, COLOR4D( PUREYELLOW ) );
|
||||
CLR( "board.drc_exclusion", LAYER_DRC_EXCLUSION, COLOR4D( WHITE ) );
|
||||
CLR( "board.footprint_text_invisible", LAYER_MOD_TEXT_INVISIBLE, COLOR4D( LIGHTGRAY ) );
|
||||
CLR( "board.grid", LAYER_GRID, COLOR4D( DARKGRAY ) );
|
||||
CLR( "board.grid_axes", LAYER_GRID_AXES, COLOR4D( LIGHTGRAY ) );
|
||||
CLR( "board.no_connect", LAYER_NO_CONNECTS, COLOR4D( BLUE ) );
|
||||
CLR( "board.pad_back", LAYER_PAD_BK, COLOR4D( GREEN ) );
|
||||
CLR( "board.pad_front", LAYER_PAD_FR, COLOR4D( RED ) );
|
||||
CLR( "board.pad_plated_hole", LAYER_PADS_PLATEDHOLES, COLOR4D( YELLOW ) );
|
||||
CLR( "board.pad_through_hole", LAYER_PADS_TH, COLOR4D( YELLOW ) );
|
||||
CLR( "board.plated_hole", LAYER_NON_PLATEDHOLES, COLOR4D( YELLOW ) );
|
||||
CLR( "board.ratsnest", LAYER_RATSNEST, COLOR4D( WHITE ) );
|
||||
CLR( "board.select_overlay", LAYER_SELECT_OVERLAY, COLOR4D( PUREGREEN ) );
|
||||
CLR( "board.through_via", LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) );
|
||||
CLR( "board.via_blind_buried", LAYER_VIA_BBLIND, COLOR4D( BROWN ) );
|
||||
CLR( "board.via_hole", LAYER_VIAS_HOLES, COLOR4D( 0.5, 0.4, 0, 0.8 ) );
|
||||
CLR( "board.via_micro", LAYER_VIA_MICROVIA, COLOR4D( CYAN ) );
|
||||
CLR( "board.via_through", LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) );
|
||||
CLR( "board.worksheet", LAYER_WORKSHEET, COLOR4D( DARKRED ) );
|
||||
CLR( "board.anchor", LAYER_ANCHOR );
|
||||
CLR( "board.aux_items", LAYER_AUX_ITEMS );
|
||||
CLR( "board.background", LAYER_PCB_BACKGROUND );
|
||||
CLR( "board.cursor", LAYER_CURSOR );
|
||||
CLR( "board.drc_error", LAYER_DRC_ERROR );
|
||||
CLR( "board.drc_warning", LAYER_DRC_WARNING );
|
||||
CLR( "board.drc_exclusion", LAYER_DRC_EXCLUSION );
|
||||
CLR( "board.footprint_text_invisible", LAYER_MOD_TEXT_INVISIBLE );
|
||||
CLR( "board.grid", LAYER_GRID );
|
||||
CLR( "board.grid_axes", LAYER_GRID_AXES );
|
||||
CLR( "board.no_connect", LAYER_NO_CONNECTS );
|
||||
CLR( "board.pad_back", LAYER_PAD_BK );
|
||||
CLR( "board.pad_front", LAYER_PAD_FR );
|
||||
CLR( "board.pad_plated_hole", LAYER_PADS_PLATEDHOLES );
|
||||
CLR( "board.pad_through_hole", LAYER_PADS_TH );
|
||||
CLR( "board.plated_hole", LAYER_NON_PLATEDHOLES );
|
||||
CLR( "board.ratsnest", LAYER_RATSNEST );
|
||||
CLR( "board.select_overlay", LAYER_SELECT_OVERLAY );
|
||||
CLR( "board.via_blind_buried", LAYER_VIA_BBLIND );
|
||||
CLR( "board.via_hole", LAYER_VIAS_HOLES );
|
||||
CLR( "board.via_micro", LAYER_VIA_MICROVIA );
|
||||
CLR( "board.via_through", LAYER_VIA_THROUGH );
|
||||
CLR( "board.worksheet", LAYER_WORKSHEET );
|
||||
|
||||
CLR( "board.copper.f", F_Cu, COLOR4D( RED ) );
|
||||
CLR( "board.copper.in1", In1_Cu, COLOR4D( YELLOW ) );
|
||||
CLR( "board.copper.in2", In2_Cu, COLOR4D( LIGHTMAGENTA ) );
|
||||
CLR( "board.copper.in3", In3_Cu, COLOR4D( LIGHTRED ) );
|
||||
CLR( "board.copper.in4", In4_Cu, COLOR4D( CYAN ) );
|
||||
CLR( "board.copper.in5", In5_Cu, COLOR4D( GREEN ) );
|
||||
CLR( "board.copper.in6", In6_Cu, COLOR4D( BLUE ) );
|
||||
CLR( "board.copper.in7", In7_Cu, COLOR4D( DARKGRAY ) );
|
||||
CLR( "board.copper.in8", In8_Cu, COLOR4D( MAGENTA ) );
|
||||
CLR( "board.copper.in9", In9_Cu, COLOR4D( LIGHTGRAY ) );
|
||||
CLR( "board.copper.in10", In10_Cu, COLOR4D( MAGENTA ) );
|
||||
CLR( "board.copper.in11", In11_Cu, COLOR4D( RED ) );
|
||||
CLR( "board.copper.in12", In12_Cu, COLOR4D( BROWN ) );
|
||||
CLR( "board.copper.in13", In13_Cu, COLOR4D( LIGHTGRAY ) );
|
||||
CLR( "board.copper.in14", In14_Cu, COLOR4D( BLUE ) );
|
||||
CLR( "board.copper.in15", In15_Cu, COLOR4D( GREEN ) );
|
||||
CLR( "board.copper.in16", In16_Cu, COLOR4D( RED ) );
|
||||
CLR( "board.copper.in17", In17_Cu, COLOR4D( YELLOW ) );
|
||||
CLR( "board.copper.in18", In18_Cu, COLOR4D( LIGHTMAGENTA ) );
|
||||
CLR( "board.copper.in19", In19_Cu, COLOR4D( LIGHTRED ) );
|
||||
CLR( "board.copper.in20", In20_Cu, COLOR4D( CYAN ) );
|
||||
CLR( "board.copper.in21", In21_Cu, COLOR4D( GREEN ) );
|
||||
CLR( "board.copper.in22", In22_Cu, COLOR4D( BLUE ) );
|
||||
CLR( "board.copper.in23", In23_Cu, COLOR4D( DARKGRAY ) );
|
||||
CLR( "board.copper.in24", In24_Cu, COLOR4D( MAGENTA ) );
|
||||
CLR( "board.copper.in25", In25_Cu, COLOR4D( LIGHTGRAY ) );
|
||||
CLR( "board.copper.in26", In26_Cu, COLOR4D( MAGENTA ) );
|
||||
CLR( "board.copper.in27", In27_Cu, COLOR4D( RED ) );
|
||||
CLR( "board.copper.in28", In28_Cu, COLOR4D( BROWN ) );
|
||||
CLR( "board.copper.in29", In29_Cu, COLOR4D( LIGHTGRAY ) );
|
||||
CLR( "board.copper.in30", In30_Cu, COLOR4D( BLUE ) );
|
||||
CLR( "board.copper.b", B_Cu, COLOR4D( GREEN ) );
|
||||
CLR( "board.copper.f", F_Cu );
|
||||
CLR( "board.copper.in1", In1_Cu );
|
||||
CLR( "board.copper.in2", In2_Cu );
|
||||
CLR( "board.copper.in3", In3_Cu );
|
||||
CLR( "board.copper.in4", In4_Cu );
|
||||
CLR( "board.copper.in5", In5_Cu );
|
||||
CLR( "board.copper.in6", In6_Cu );
|
||||
CLR( "board.copper.in7", In7_Cu );
|
||||
CLR( "board.copper.in8", In8_Cu );
|
||||
CLR( "board.copper.in9", In9_Cu );
|
||||
CLR( "board.copper.in10", In10_Cu );
|
||||
CLR( "board.copper.in11", In11_Cu );
|
||||
CLR( "board.copper.in12", In12_Cu );
|
||||
CLR( "board.copper.in13", In13_Cu );
|
||||
CLR( "board.copper.in14", In14_Cu );
|
||||
CLR( "board.copper.in15", In15_Cu );
|
||||
CLR( "board.copper.in16", In16_Cu );
|
||||
CLR( "board.copper.in17", In17_Cu );
|
||||
CLR( "board.copper.in18", In18_Cu );
|
||||
CLR( "board.copper.in19", In19_Cu );
|
||||
CLR( "board.copper.in20", In20_Cu );
|
||||
CLR( "board.copper.in21", In21_Cu );
|
||||
CLR( "board.copper.in22", In22_Cu );
|
||||
CLR( "board.copper.in23", In23_Cu );
|
||||
CLR( "board.copper.in24", In24_Cu );
|
||||
CLR( "board.copper.in25", In25_Cu );
|
||||
CLR( "board.copper.in26", In26_Cu );
|
||||
CLR( "board.copper.in27", In27_Cu );
|
||||
CLR( "board.copper.in28", In28_Cu );
|
||||
CLR( "board.copper.in29", In29_Cu );
|
||||
CLR( "board.copper.in30", In30_Cu );
|
||||
CLR( "board.copper.b", B_Cu );
|
||||
|
||||
CLR( "board.b_adhes", B_Adhes, COLOR4D( BLUE ) );
|
||||
CLR( "board.f_adhes", F_Adhes, COLOR4D( MAGENTA ) );
|
||||
CLR( "board.b_paste", B_Paste, COLOR4D( LIGHTCYAN ) );
|
||||
CLR( "board.f_paste", F_Paste, COLOR4D( RED ) );
|
||||
CLR( "board.b_silks", B_SilkS, COLOR4D( MAGENTA ) );
|
||||
CLR( "board.f_silks", F_SilkS, COLOR4D( CYAN ) );
|
||||
CLR( "board.b_mask", B_Mask, COLOR4D( BROWN ) );
|
||||
CLR( "board.f_mask", F_Mask, COLOR4D( MAGENTA ) );
|
||||
CLR( "board.dwgs_user", Dwgs_User, COLOR4D( LIGHTGRAY ) );
|
||||
CLR( "board.cmts_user", Cmts_User, COLOR4D( BLUE ) );
|
||||
CLR( "board.eco1_user", Eco1_User, COLOR4D( GREEN ) );
|
||||
CLR( "board.eco2_user", Eco2_User, COLOR4D( YELLOW ) );
|
||||
CLR( "board.edge_cuts", Edge_Cuts, COLOR4D( YELLOW ) );
|
||||
CLR( "board.margin", Margin, COLOR4D( LIGHTMAGENTA ) );
|
||||
CLR( "board.b_crtyd", B_CrtYd, COLOR4D( DARKGRAY ) );
|
||||
CLR( "board.f_crtyd", F_CrtYd, COLOR4D( LIGHTGRAY ) );
|
||||
CLR( "board.b_fab", B_Fab, COLOR4D( BLUE ) );
|
||||
CLR( "board.f_fab", F_Fab, COLOR4D( DARKGRAY ) );
|
||||
CLR( "board.user_1", User_1, COLOR4D( BLUE ) );
|
||||
CLR( "board.user_2", User_2, COLOR4D( BLUE ) );
|
||||
CLR( "board.user_3", User_3, COLOR4D( BLUE ) );
|
||||
CLR( "board.user_4", User_4, COLOR4D( BLUE ) );
|
||||
CLR( "board.user_5", User_5, COLOR4D( BLUE ) );
|
||||
CLR( "board.user_6", User_6, COLOR4D( BLUE ) );
|
||||
CLR( "board.user_7", User_7, COLOR4D( BLUE ) );
|
||||
CLR( "board.user_8", User_8, COLOR4D( BLUE ) );
|
||||
CLR( "board.user_9", User_9, COLOR4D( BLUE ) );
|
||||
CLR( "board.b_adhes", B_Adhes );
|
||||
CLR( "board.f_adhes", F_Adhes );
|
||||
CLR( "board.b_paste", B_Paste );
|
||||
CLR( "board.f_paste", F_Paste );
|
||||
CLR( "board.b_silks", B_SilkS );
|
||||
CLR( "board.f_silks", F_SilkS );
|
||||
CLR( "board.b_mask", B_Mask );
|
||||
CLR( "board.f_mask", F_Mask );
|
||||
CLR( "board.dwgs_user", Dwgs_User );
|
||||
CLR( "board.cmts_user", Cmts_User );
|
||||
CLR( "board.eco1_user", Eco1_User );
|
||||
CLR( "board.eco2_user", Eco2_User );
|
||||
CLR( "board.edge_cuts", Edge_Cuts );
|
||||
CLR( "board.margin", Margin );
|
||||
CLR( "board.b_crtyd", B_CrtYd );
|
||||
CLR( "board.f_crtyd", F_CrtYd );
|
||||
CLR( "board.b_fab", B_Fab );
|
||||
CLR( "board.f_fab", F_Fab );
|
||||
CLR( "board.user_1", User_1 );
|
||||
CLR( "board.user_2", User_2 );
|
||||
CLR( "board.user_3", User_3 );
|
||||
CLR( "board.user_4", User_4 );
|
||||
CLR( "board.user_5", User_5 );
|
||||
CLR( "board.user_6", User_6 );
|
||||
CLR( "board.user_7", User_7 );
|
||||
CLR( "board.user_8", User_8 );
|
||||
CLR( "board.user_9", User_9 );
|
||||
|
||||
// Colors for 3D viewer, which are used as defaults unless overridden by the board
|
||||
CLR( "3d_viewer.background_bottom", LAYER_3D_BACKGROUND_BOTTOM, COLOR4D( 0.4, 0.4, 0.5, 1.0 ) );
|
||||
CLR( "3d_viewer.background_top", LAYER_3D_BACKGROUND_TOP, COLOR4D( 0.8, 0.8, 0.9, 1.0 ) );
|
||||
CLR( "3d_viewer.board", LAYER_3D_BOARD, COLOR4D( 0.2, 0.17, 0.09, 0.9 ) );
|
||||
CLR( "3d_viewer.copper", LAYER_3D_COPPER, COLOR4D( 0.7, 0.61, 0.0, 1.0 ) );
|
||||
CLR( "3d_viewer.silkscreen_bottom", LAYER_3D_SILKSCREEN_BOTTOM, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) );
|
||||
CLR( "3d_viewer.silkscreen_top", LAYER_3D_SILKSCREEN_TOP, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) );
|
||||
CLR( "3d_viewer.soldermask", LAYER_3D_SOLDERMASK, COLOR4D( 0.08, 0.2, 0.14, 0.83 ) );
|
||||
CLR( "3d_viewer.solderpaste", LAYER_3D_SOLDERPASTE, COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
|
||||
CLR( "3d_viewer.background_bottom", LAYER_3D_BACKGROUND_BOTTOM );
|
||||
CLR( "3d_viewer.background_top", LAYER_3D_BACKGROUND_TOP );
|
||||
CLR( "3d_viewer.board", LAYER_3D_BOARD );
|
||||
CLR( "3d_viewer.copper", LAYER_3D_COPPER );
|
||||
CLR( "3d_viewer.silkscreen_bottom", LAYER_3D_SILKSCREEN_BOTTOM );
|
||||
CLR( "3d_viewer.silkscreen_top", LAYER_3D_SILKSCREEN_TOP );
|
||||
CLR( "3d_viewer.soldermask", LAYER_3D_SOLDERMASK );
|
||||
CLR( "3d_viewer.solderpaste", LAYER_3D_SOLDERPASTE );
|
||||
|
||||
registerMigration( 0, 1, std::bind( &COLOR_SETTINGS::migrateSchema0to1, this ) );
|
||||
|
||||
|
@ -253,6 +254,7 @@ void COLOR_SETTINGS::initFromOther( const COLOR_SETTINGS& aOther )
|
|||
m_overrideSchItemColors = aOther.m_overrideSchItemColors;
|
||||
m_colors = aOther.m_colors;
|
||||
m_defaultColors = aOther.m_defaultColors;
|
||||
m_writeFile = aOther.m_writeFile;
|
||||
|
||||
// Ensure default colors are present
|
||||
for( PARAM_BASE* param : aOther.m_params )
|
||||
|
@ -354,3 +356,26 @@ void COLOR_SETTINGS::SetColor( int aLayer, COLOR4D aColor )
|
|||
{
|
||||
m_colors[ aLayer ] = aColor;
|
||||
}
|
||||
|
||||
|
||||
std::vector<COLOR_SETTINGS*> COLOR_SETTINGS::CreateBuiltinColorSettings()
|
||||
{
|
||||
COLOR_SETTINGS* defaultTheme = new COLOR_SETTINGS( wxT( "_builtin_default" ) );
|
||||
defaultTheme->SetName( _( "KiCad Default" ) );
|
||||
defaultTheme->m_writeFile = false;
|
||||
defaultTheme->Load(); // We can just get the colors out of the param defaults for this one
|
||||
|
||||
COLOR_SETTINGS* classicTheme = new COLOR_SETTINGS( wxT( "_builtin_classic" ) );
|
||||
classicTheme->SetName( _( "KiCad Classic" ) );
|
||||
classicTheme->m_writeFile = false;
|
||||
|
||||
for( const std::pair<int, COLOR4D> entry : s_classicTheme )
|
||||
classicTheme->m_colors[entry.first] = entry.second;
|
||||
|
||||
std::vector<COLOR_SETTINGS*> ret;
|
||||
|
||||
ret.push_back( defaultTheme );
|
||||
ret.push_back( classicTheme );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -227,9 +227,6 @@ public:
|
|||
if( file.GetExt() != "json" )
|
||||
return wxDIR_CONTINUE;
|
||||
|
||||
if( file.GetName() == "user" )
|
||||
return wxDIR_CONTINUE;
|
||||
|
||||
m_action( file.GetName() );
|
||||
|
||||
return wxDIR_CONTINUE;
|
||||
|
@ -264,10 +261,27 @@ COLOR_SETTINGS* SETTINGS_MANAGER::AddNewColorSettings( const wxString& aFilename
|
|||
}
|
||||
|
||||
|
||||
COLOR_SETTINGS* SETTINGS_MANAGER::GetMigratedColorSettings()
|
||||
{
|
||||
if( !m_color_settings.count( "user" ) )
|
||||
{
|
||||
registerColorSettings( wxT( "user" ) );
|
||||
m_color_settings.at( "user" )->SetName( wxT( "User" ) );
|
||||
Save( m_color_settings.at( "user" ) );
|
||||
}
|
||||
|
||||
return m_color_settings.at( "user" );
|
||||
}
|
||||
|
||||
|
||||
void SETTINGS_MANAGER::loadAllColorSettings()
|
||||
{
|
||||
// Create the default color settings
|
||||
registerColorSettings( "user" );
|
||||
// Create the built-in color settings
|
||||
for( COLOR_SETTINGS* settings : COLOR_SETTINGS::CreateBuiltinColorSettings() )
|
||||
{
|
||||
m_color_settings[settings->GetFilename()] =
|
||||
static_cast<COLOR_SETTINGS*>( RegisterSettings( settings, false ) );
|
||||
}
|
||||
|
||||
// Search for and load any other settings
|
||||
COLOR_SETTINGS_LOADER loader( [&]( const wxString& aFilename )
|
||||
|
|
|
@ -118,7 +118,8 @@ COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, COLOR4D aColor, int aID, COLOR4D
|
|||
wxPanel( aParent, aID ),
|
||||
m_color( aColor ),
|
||||
m_background( aBackground ),
|
||||
m_default( aDefault )
|
||||
m_default( aDefault ),
|
||||
m_readOnly( false )
|
||||
{
|
||||
wxASSERT_MSG( aSwatchSize != SWATCH_EXPAND, "SWATCH_EXPAND not supported in COLOR_SWATCH" );
|
||||
|
||||
|
@ -148,7 +149,8 @@ COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, COLOR4D aColor, int aID, COLOR4D
|
|||
|
||||
COLOR_SWATCH::COLOR_SWATCH( wxWindow *aParent, wxWindowID aID, const wxPoint &aPos,
|
||||
const wxSize &aSize, long aStyle ) :
|
||||
wxPanel( aParent, aID, aPos, aSize, aStyle )
|
||||
wxPanel( aParent, aID, aPos, aSize, aStyle ),
|
||||
m_readOnly( false )
|
||||
{
|
||||
if( aSize == wxDefaultSize )
|
||||
m_size = ConvertDialogToPixels( SWATCH_SIZE_MEDIUM_DU );
|
||||
|
@ -263,6 +265,14 @@ COLOR4D COLOR_SWATCH::GetSwatchColor() const
|
|||
|
||||
void COLOR_SWATCH::GetNewSwatchColor()
|
||||
{
|
||||
if( m_readOnly )
|
||||
{
|
||||
if( m_readOnlyCallback )
|
||||
m_readOnlyCallback();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
DIALOG_COLOR_PICKER dialog( ::wxGetTopLevelParent( this ), m_color, true, nullptr, m_default );
|
||||
|
||||
if( dialog.ShowModal() == wxID_OK )
|
||||
|
|
|
@ -517,7 +517,7 @@ bool EESCHEMA_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|||
// Legacy version stored this setting in eeschema, so move it to common if it exists
|
||||
aCfg->Read( "MoveWarpsCursor", &Pgm().GetCommonSettings()->m_Input.warp_mouse_on_move );
|
||||
|
||||
COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
|
||||
COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetMigratedColorSettings();
|
||||
|
||||
auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) {
|
||||
wxString str;
|
||||
|
@ -559,6 +559,8 @@ bool EESCHEMA_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|||
|
||||
Pgm().GetSettingsManager().SaveColorSettings( cs, "schematic" );
|
||||
|
||||
( *this )[PointerFromString( "appearance.color_theme" )] = cs->GetFilename();
|
||||
|
||||
// LibEdit settings were stored with eeschema. If eeschema is the first app to run,
|
||||
// we need to migrate the LibEdit settings here
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ bool GERBVIEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|||
}
|
||||
}
|
||||
|
||||
COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
|
||||
COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetMigratedColorSettings();
|
||||
|
||||
auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) {
|
||||
wxString str;
|
||||
|
@ -129,7 +129,7 @@ bool GERBVIEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|||
if( aCfg->Read( aKey, &str ) )
|
||||
cs->SetColor( aLayerId, COLOR4D( str ) );
|
||||
};
|
||||
|
||||
*
|
||||
migrateLegacyColor( "BackgroundColorEx", LAYER_GERBVIEW_BACKGROUND );
|
||||
migrateLegacyColor( "DCodeColorEx", LAYER_DCODES );
|
||||
migrateLegacyColor( "GridColorEx", LAYER_GERBVIEW_GRID );
|
||||
|
@ -147,5 +147,7 @@ bool GERBVIEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|||
|
||||
Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
|
||||
|
||||
( *this )[PointerFromString( "appearance.color_theme" )] = cs->GetFilename();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -131,6 +131,13 @@ public:
|
|||
*/
|
||||
COLOR4D( EDA_COLOR_T aColor );
|
||||
|
||||
/**
|
||||
* Initializes the color from a RGBA value with 0-255 red/green/blue and 0-1 alpha.
|
||||
* Suitable for taking the values directly from the "CSS syntax" from ToWxString
|
||||
* @return this color
|
||||
*/
|
||||
COLOR4D& FromCSSRGBA( int aRed, int aGreen, int aBlue, double aAlpha = 1.0 );
|
||||
|
||||
#ifdef WX_COMPATIBILITY
|
||||
/**
|
||||
* @brief Constructor
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <gal/color4d.h>
|
||||
#include <settings/json_settings.h>
|
||||
#include <settings/parameters.h>
|
||||
|
||||
using KIGFX::COLOR4D;
|
||||
|
||||
|
@ -45,11 +46,6 @@ using KIGFX::COLOR4D;
|
|||
* Each application (eeschema, gerbview, pcbnew) can have a different active color scheme selected.
|
||||
* The "child applications" (library editors) inherit from either eeschema or pcbnew.
|
||||
*/
|
||||
|
||||
#include <settings/json_settings.h>
|
||||
#include <settings/parameters.h>
|
||||
|
||||
|
||||
class COLOR_SETTINGS : public JSON_SETTINGS
|
||||
{
|
||||
public:
|
||||
|
@ -86,6 +82,15 @@ public:
|
|||
bool GetOverrideSchItemColors() const { return m_overrideSchItemColors; }
|
||||
void SetOverrideSchItemColors( bool aFlag ) { m_overrideSchItemColors = aFlag; }
|
||||
|
||||
/**
|
||||
* Constructs and returns a list of color settings objects based on the built-in color themes.
|
||||
* These color settings are not backed by a file and cannot be modified by the user.
|
||||
* This is expected to be called by SETTINGS_MANAGER which will take ownership of the objects
|
||||
* and handle freeing them at the end of its lifetime.
|
||||
* @return a list of pointers COLOR_SETTINGS objects containing the default color theme(s)
|
||||
*/
|
||||
static std::vector<COLOR_SETTINGS*> CreateBuiltinColorSettings();
|
||||
|
||||
private:
|
||||
bool migrateSchema0to1();
|
||||
|
||||
|
@ -124,7 +129,7 @@ public:
|
|||
( *m_map )[ m_key ] = m_default;
|
||||
}
|
||||
|
||||
void Store( JSON_SETTINGS* aSettings) const override
|
||||
void Store( JSON_SETTINGS* aSettings ) const override
|
||||
{
|
||||
aSettings->Set<COLOR4D>( m_path, ( *m_map )[ m_key ] );
|
||||
}
|
||||
|
|
|
@ -71,6 +71,9 @@ public:
|
|||
|
||||
void SetLegacyFilename( const wxString& aFilename ) { m_legacy_filename = aFilename; }
|
||||
|
||||
bool IsReadOnly() const { return !m_writeFile; }
|
||||
void SetReadOnly( bool aReadOnly ) { m_writeFile = !aReadOnly; }
|
||||
|
||||
/**
|
||||
* Updates the parameters of this object based on the current JSON document contents
|
||||
*/
|
||||
|
|
|
@ -155,6 +155,13 @@ public:
|
|||
*/
|
||||
COLOR_SETTINGS* AddNewColorSettings( const wxString& aFilename );
|
||||
|
||||
/**
|
||||
* Returns a color theme for storing colors migrated from legacy (5.x and earlier) settings,
|
||||
* creating the theme if necessary. This theme will be called "user.json" / "User".
|
||||
* @return the color settings to be used for migrating legacy settings
|
||||
*/
|
||||
COLOR_SETTINGS* GetMigratedColorSettings();
|
||||
|
||||
/**
|
||||
* Retrieves the common settings shared by all applications
|
||||
* @return a pointer to a loaded COMMON_SETTINGS
|
||||
|
|
|
@ -97,6 +97,12 @@ public:
|
|||
*/
|
||||
void GetNewSwatchColor();
|
||||
|
||||
void SetReadOnly( bool aReadOnly = true ) { m_readOnly = aReadOnly; }
|
||||
bool IsReadOnly() const { return m_readOnly; }
|
||||
|
||||
/// Registers a handler for when the user tries to interact with a read-only swatch
|
||||
void SetReadOnlyCallback( std::function<void()> aCallback ) { m_readOnlyCallback = aCallback; }
|
||||
|
||||
static wxBitmap MakeBitmap( KIGFX::COLOR4D aColor, KIGFX::COLOR4D aBackground, wxSize aSize,
|
||||
wxSize aCheckerboardSize, KIGFX::COLOR4D aCheckerboardBackground );
|
||||
|
||||
|
@ -117,6 +123,10 @@ private:
|
|||
wxSize m_size;
|
||||
wxSize m_checkerboardSize;
|
||||
KIGFX::COLOR4D m_checkerboardBg;
|
||||
|
||||
/// A read-only swatch won't show the color chooser dialog but otherwise works normally
|
||||
bool m_readOnly;
|
||||
std::function<void()> m_readOnlyCallback;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ bool FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|||
SETTINGS_MANAGER& manager = Pgm().GetSettingsManager();
|
||||
COLOR_SETTINGS* cs = manager.AddNewColorSettings( "user_footprints" );
|
||||
|
||||
cs->SetName( wxT( "KiCad Default (Footprints)" ) );
|
||||
cs->SetName( wxT( "User (Footprints)" ) );
|
||||
manager.Save( cs );
|
||||
|
||||
auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId )
|
||||
|
|
|
@ -706,7 +706,7 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|||
|
||||
// Migrate color settings that were stored in the pcbnew config file
|
||||
|
||||
COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
|
||||
COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetMigratedColorSettings();
|
||||
|
||||
auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) {
|
||||
wxString str;
|
||||
|
@ -740,6 +740,8 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
|
|||
|
||||
Pgm().GetSettingsManager().SaveColorSettings( cs, "board" );
|
||||
|
||||
( *this )[PointerFromString( "appearance.color_theme" )] = cs->GetFilename();
|
||||
|
||||
double x, y;
|
||||
|
||||
if( aCfg->Read( f + "PcbUserGrid_X", &x ) && aCfg->Read( f + "PcbUserGrid_Y", &y ) )
|
||||
|
|
|
@ -40,7 +40,9 @@
|
|||
#include <widgets/grid_color_swatch_helpers.h>
|
||||
#include <widgets/grid_text_helpers.h>
|
||||
#include <widgets/indicator_icon.h>
|
||||
#include <widgets/infobar.h>
|
||||
#include <widgets/wx_grid.h>
|
||||
#include <wx/hyperlink.h>
|
||||
#include <wx/statline.h>
|
||||
|
||||
|
||||
|
@ -1277,6 +1279,7 @@ void APPEARANCE_CONTROLS::rebuildLayers()
|
|||
COLOR_SETTINGS* theme = m_frame->GetColorSettings();
|
||||
COLOR4D bgColor = theme->GetColor( LAYER_PCB_BACKGROUND );
|
||||
bool firstLayer = true;
|
||||
bool readOnly = theme->IsReadOnly();
|
||||
|
||||
#ifdef __WXMAC__
|
||||
wxSizerItem* m_windowLayersSizerItem = m_panelLayersSizer->GetItem( m_windowLayers );
|
||||
|
@ -1366,6 +1369,9 @@ void APPEARANCE_CONTROLS::rebuildLayers()
|
|||
|
||||
swatch->Bind( COLOR_SWATCH_CHANGED, &APPEARANCE_CONTROLS::OnColorSwatchChanged,
|
||||
this );
|
||||
swatch->SetReadOnlyCallback(std::bind( &APPEARANCE_CONTROLS::onReadOnlySwatch,
|
||||
this ) );
|
||||
swatch->SetReadOnly( readOnly );
|
||||
|
||||
auto rightClickHandler =
|
||||
[&]( wxMouseEvent& aEvent )
|
||||
|
@ -1641,8 +1647,10 @@ void APPEARANCE_CONTROLS::SetTabIndex( int aTab )
|
|||
|
||||
void APPEARANCE_CONTROLS::syncColorsAndVisibility()
|
||||
{
|
||||
LSET visible = getVisibleLayers();
|
||||
GAL_SET objects = getVisibleObjects();
|
||||
COLOR_SETTINGS* theme = m_frame->GetColorSettings();
|
||||
bool readOnly = theme->IsReadOnly();
|
||||
LSET visible = getVisibleLayers();
|
||||
GAL_SET objects = getVisibleObjects();
|
||||
|
||||
Freeze();
|
||||
|
||||
|
@ -1655,8 +1663,9 @@ void APPEARANCE_CONTROLS::syncColorsAndVisibility()
|
|||
|
||||
if( setting->ctl_color )
|
||||
{
|
||||
const COLOR4D& color = m_frame->GetColorSettings()->GetColor( layer );
|
||||
const COLOR4D& color = theme->GetColor( layer );
|
||||
setting->ctl_color->SetSwatchColor( color, false );
|
||||
setting->ctl_color->SetReadOnly( readOnly );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1669,8 +1678,9 @@ void APPEARANCE_CONTROLS::syncColorsAndVisibility()
|
|||
|
||||
if( setting->ctl_color )
|
||||
{
|
||||
const COLOR4D& color = m_frame->GetColorSettings()->GetColor( layer );
|
||||
const COLOR4D& color = theme->GetColor( layer );
|
||||
setting->ctl_color->SetSwatchColor( color, false );
|
||||
setting->ctl_color->SetReadOnly( readOnly );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2702,3 +2712,27 @@ void APPEARANCE_CONTROLS::passOnFocus()
|
|||
{
|
||||
m_focusOwner->SetFocus();
|
||||
}
|
||||
|
||||
|
||||
void APPEARANCE_CONTROLS::onReadOnlySwatch()
|
||||
{
|
||||
WX_INFOBAR* infobar = m_frame->GetInfoBar();
|
||||
|
||||
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Open Preferences" ),
|
||||
wxEmptyString );
|
||||
|
||||
button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
|
||||
[&]( wxHyperlinkEvent& aEvent )
|
||||
{
|
||||
wxCommandEvent dummy;
|
||||
m_frame->OnPreferences( dummy );
|
||||
} ) );
|
||||
|
||||
infobar->RemoveAllButtons();
|
||||
infobar->AddButton( button );
|
||||
infobar->AddCloseButton();
|
||||
|
||||
infobar->ShowMessageFor( _( "The current color theme is read-only. Create a new theme in "
|
||||
"Preferences to enable color editing." ),
|
||||
10000, wxICON_INFORMATION );
|
||||
}
|
||||
|
|
|
@ -455,6 +455,8 @@ private:
|
|||
void passOnFocus();
|
||||
|
||||
void idleFocusHandler( wxIdleEvent& aEvent );
|
||||
|
||||
void onReadOnlySwatch();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue