KiCad PCB EDA Suite
panel_fp_editor_color_settings.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020 Jon Evans <[email protected]>
5 * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <pgm_base.h>
24#include <layer_ids.h>
26
27
29 PANEL_COLOR_SETTINGS( aParent )
30{
31 // Currently this only applies to eeschema
32 m_optOverrideColors->Hide();
33
34 m_colorNamespace = "board";
35
36 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
38 COLOR_SETTINGS* current = mgr.GetColorSettings( settings->m_ColorTheme );
39
40 // Store the current settings before reloading below
41 current->Store();
42 mgr.SaveColorSettings( current, "board" );
43
44 m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() );
45
46 m_currentSettings = new COLOR_SETTINGS( *current );
47
49 createThemeList( settings->m_ColorTheme );
50
51 m_validLayers.push_back( F_Cu );
52 m_validLayers.push_back( In1_Cu ); // "Internal Layers"
53 m_validLayers.push_back( B_Cu );
54
55 for( int id = GAL_LAYER_ID_START; id < GAL_LAYER_ID_END; id++ )
56 {
57 if( id == LAYER_VIAS
58 || id == LAYER_VIA_HOLES
59 || id == LAYER_VIA_HOLEWALLS
61 || id == LAYER_PAD_HOLEWALLS )
62 {
63 continue;
64 }
65
66 m_validLayers.push_back( id );
67 }
68
70
71 m_colorsMainSizer->Insert( 0, 10, 0, 0, wxEXPAND, 5 );
72}
73
74
76{
77 delete m_currentSettings;
78}
79
80
82{
83 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
86
87 return true;
88}
89
90
92{
93 return true;
94}
95
96
98{
99 std::vector<GAL_LAYER_ID> galLayers;
100
101 // Sort the gal layers by name
102 for( int i : m_validLayers )
103 {
104 if( i >= GAL_LAYER_ID_START && m_currentSettings->GetColor( i ) != COLOR4D::UNSPECIFIED )
105 galLayers.push_back( (GAL_LAYER_ID) i );
106 }
107
108 std::sort( galLayers.begin(), galLayers.end(),
109 []( int a, int b )
110 {
111 return LayerName( a ) < LayerName( b );
112 } );
113
115 createSwatch( In1_Cu, _( "Internal Layers" ) );
117
118 for( GAL_LAYER_ID layer : galLayers )
119 createSwatch( layer, LayerName( layer ) );
120
121 Layout();
122}
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:187
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
virtual bool Store()
Stores the current parameters into the JSON document represented by this object Note: this doesn't do...
wxString GetFilename() const
Definition: json_settings.h:73
void createThemeList(const wxString &aCurrent)
Builds the theme listbox and sets the selection to the current theme.
void createSwatch(int aLayer, const wxString &aName)
std::vector< int > m_validLayers
A list of layer IDs that are valid for the current color settings dialog.
std::string m_colorNamespace
A namespace that will be passed to SETTINGS_MANAGER::SaveColorSettings.
COLOR_SETTINGS * m_currentSettings
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
void ReloadColorSettings()
Re-scans the color themes directory, reloading any changes it finds.
#define _(s)
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition: layer_id.cpp:30
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:190
@ GAL_LAYER_ID_START
Definition: layer_ids.h:191
@ LAYER_VIA_HOLEWALLS
Definition: layer_ids.h:234
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:220
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition: layer_ids.h:214
@ GAL_LAYER_ID_END
Definition: layer_ids.h:260
@ LAYER_VIA_HOLES
to draw via holes (pad holes do not use this layer)
Definition: layer_ids.h:215
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:193
@ LAYER_PAD_HOLEWALLS
Definition: layer_ids.h:233
@ B_Cu
Definition: layer_ids.h:95
@ In1_Cu
Definition: layer_ids.h:65
@ F_Cu
Definition: layer_ids.h:64
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111