KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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
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
72
74{
75 delete m_currentSettings;
76}
77
78
80{
81 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
84
85 return true;
86}
87
88
90{
91 return true;
92}
93
94
96{
97 std::vector<GAL_LAYER_ID> galLayers;
98
99 // Sort the gal layers by name
100 for( int i : m_validLayers )
101 {
102 if( i >= GAL_LAYER_ID_START && m_currentSettings->GetColor( i ) != COLOR4D::UNSPECIFIED )
103 galLayers.push_back( (GAL_LAYER_ID) i );
104 }
105
106 std::sort( galLayers.begin(), galLayers.end(),
107 []( int a, int b )
108 {
109 return LayerName( a ) < LayerName( b );
110 } );
111
113 createSwatch( In1_Cu, _( "Internal Layers" ) );
115
116 for( GAL_LAYER_ID layer : galLayers )
117 createSwatch( layer, LayerName( layer ) );
118
119 Layout();
120}
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:189
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:80
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
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
T * GetAppSettings()
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:31
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition: layer_ids.h:191
@ GAL_LAYER_ID_START
Definition: layer_ids.h:192
@ LAYER_VIA_HOLEWALLS
Definition: layer_ids.h:235
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:221
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition: layer_ids.h:215
@ GAL_LAYER_ID_END
Definition: layer_ids.h:268
@ LAYER_VIA_HOLES
to draw via holes (pad holes do not use this layer)
Definition: layer_ids.h:216
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:194
@ LAYER_PAD_HOLEWALLS
Definition: layer_ids.h:234
@ B_Cu
Definition: layer_ids.h:65
@ In1_Cu
Definition: layer_ids.h:66
@ F_Cu
Definition: layer_ids.h:64
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE